@decaf-ts/for-nest 0.10.1 → 0.10.2

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/for-nest.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var e,t;e=this,t=function(e,t,r,o,a,s,i,n,c,p,d,l,u,h,m,f,y,g){"use strict";function _(e){var t=Object.create(null);return e&&Object.keys(e).forEach(r=>{if("default"!==r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}),t.default=e,Object.freeze(t)}var A=_(m);const b="swagger",E={API_OPERATION:b+"/apiOperation",API_RESPONSE:b+"/apiResponse",API_PRODUCES:b+"/apiProduces",API_CONSUMES:b+"/apiConsumes",API_TAGS:b+"/apiUseTags",API_CALLBACKS:b+"/apiCallbacks",API_PARAMETERS:b+"/apiParameters",API_HEADERS:b+"/apiHeaders",API_MODEL_PROPERTIES:b+"/apiModelProperties",API_MODEL_PROPERTIES_ARRAY:b+"/apiModelPropertiesArray",API_SECURITY:b+"/apiSecurity",API_EXCLUDE_ENDPOINT:b+"/apiExcludeEndpoint",API_EXCLUDE_CONTROLLER:b+"/apiExcludeController",API_EXTRA_MODELS:b+"/apiExtraModels",API_EXTENSION:b+"/apiExtension",API_SCHEMA:b+"/apiSchema",API_DEFAULT_GETTER:b+"/apiDefaultGetter",API_LINK:b+"/apiLink"},P=e=>void 0===e;function O(e){if("function"==typeof e)return O(e());if(Array.isArray(e))return e;if("object"!=typeof e)return[];const t=Object.values(e).filter(e=>"number"==typeof e).map(e=>e.toString());return Object.keys(e).filter(e=>!t.includes(e)).map(t=>e[t])}function R(e){return e.filter(i.isString).length>0?"string":"number"}function v(e,t,r=!0){return(o,a)=>{const s=Reflect.getMetadata(E.API_MODEL_PROPERTIES_ARRAY,o)||[],n=":"+a;s.includes(n)||Reflect.defineMetadata(E.API_MODEL_PROPERTIES_ARRAY,[...s,":"+a],o);const c=Reflect.getMetadata(e,o,a);if(c){const s=i.pickBy(t,i.negate(P)),n=r?{...c,...s}:{...s,...c};Reflect.defineMetadata(e,n,o,a)}else{const r=o?.constructor?._OPENAPI_METADATA_FACTORY?.()[a]?.type??Reflect.getMetadata("design:type",o,a);Reflect.defineMetadata(e,{type:r,required:!1,...i.pickBy(t,i.negate(P))},o,a)}}}function w(e={}){return D(e)}function D(e={},t=!0){const[r,o]=((e,t)=>{if(!e)return[e,t];if(t)return[e,t];const r=i.isArray(e);return[r?e[0]:e,r]})(e.type,e.isArray);if((a=e={...e,type:r,isArray:o}).isArray&&"enum"in a&&void 0!==a.enum){e.type="array";const t=O(e.enum);e.items={type:R(t),enum:t},delete e.enum}else if("enum"in e&&void 0!==e.enum){const t=O(e.enum);e.enum=t,e.type=R(t)}var a;return Array.isArray(e.type)&&(e.type="array",e.items={type:"array",items:{type:e.type[0]}}),v(E.API_MODEL_PROPERTIES,e,t)}function S(e,r){const{handler:o,args:a}=t.Metadata.get(e,c.OperationKeys.REFLECT+c.OperationKeys.BLOCK)||{};return!!o&&(o(...a,r)??!1)}function T(e,r,a){const s={GET:[c.OperationKeys.READ,o.Get],POST:[c.OperationKeys.CREATE,o.Post],PUT:[c.OperationKeys.UPDATE,o.Put],PATCH:[c.OperationKeys.UPDATE,o.Patch],DELETE:[c.OperationKeys.DELETE,o.Delete]},[i,p]=s[r];return S(e,i)?t.apply(n.ApiExcludeEndpoint()):t.apply(p(a))}function C(e=[]){const t=e.map(e=>n.ApiParam({name:e.name,description:e.description??"Path parameter: "+e.name,required:e.required??!0,type:e.type??String}));return o.applyDecorators(...t)}const x=o.createParamDecorator((e,t)=>{const r=t.switchToHttp().getRequest().body,a=t.getClass(),s=a.class;if(!s)throw new o.InternalServerErrorException(`ModelConstructor not found on controller ${a.name}. Ensure the controller was created via FromModelController.`);return r?Array.isArray(r)?r.map(e=>new s(e)):new s(r):r}),M=o.createParamDecorator((e,t)=>{const r=t.switchToHttp().getRequest(),o=r?.params??{},a=e??Object.keys(o),s=a.map(e=>o[e]);return{raw:o,valuesInOrder:s,keysInOrder:a}});function I(e=[]){const t=e.map(e=>e.name);return M(t)}const $=o.createParamDecorator((e,t)=>{const r={...t.switchToHttp().getRequest().query??{}};if(void 0!==r.limit){const e=Number(r.limit);Number.isNaN(e)||(r.limit=e)}if(void 0!==r.offset){const e=Number(r.offset);Number.isNaN(e)||(r.offset=e)}if(void 0!==r.bookmark){const e=Number(r.bookmark);r.bookmark=Number.isNaN(e)?r.bookmark:e}return r});function q(e){const t={GET:o.Get,POST:o.Post,PUT:o.Put,PATCH:o.Patch,DELETE:o.Delete}[e];if(!t)throw Error(`Unsupported HTTP verb "${e}". No NestJS decorator mapping was found.`);return t}const F="DecafModuleOptions",k="DecafAdapter",N="DecafRoute",j=Symbol("DecafHandlers"),L=Symbol("DecafAdapterForOptions"),K=Symbol("AUTH_HANDLER"),B="auth:meta",U=Symbol("decaf:context");function H(t){const r=t?"string"==typeof t?t:t.name:void 0,a=[n.ApiBearerAuth(),o.UseInterceptors(e.AuthInterceptor)];return r&&a.push(o.SetMetadata(B,r)),o.applyDecorators(...a)}e.AuthInterceptor=class{constructor(e,t){this.reflector=e,this.authHandler=t}async intercept(e,t){const r=l.Logging.for(this).for(this.intercept),o=this.reflector.get(B,e.getHandler())??this.reflector.get(B,e.getClass());return r.verbose("Intercepted request"+(o?" for "+o:"")),this.authHandler?await this.authHandler.authorize(e,o):r.debug("No auth handler/model"),t.handle()}},e.AuthInterceptor=p.__decorate([o.Injectable(),p.__param(1,o.Optional()),p.__param(1,o.Inject(K)),p.__metadata("design:paramtypes",[d.Reflector,Object])],e.AuthInterceptor);class G{parseRequest(e){const t=e.headers.authorization?.split(" ")[1];return t}async authorize(e,r){const o=e.switchToHttp().getRequest(),i=this.parseRequest(o);if(!i)throw new s.AuthorizationError("Unauthenticated");if(!t.Metadata.get(a.Model.get(r),s.PersistenceKeys.AUTH_ROLE).includes(i))throw new s.AuthorizationError("Missing role: "+i)}}var z;e.DecafRequestContext=class{constructor(e){this.req=e,this.uuid=s.UUID.instance.generate()}get request(){return this.req}put(e){let t;try{t=this.ctx.get("overrides")}catch(e){t={}}this._ctx=this.ctx.accumulate({overrides:Object.assign(t,e)})}applyCtx(e){if(this._ctx)throw new c.InternalError("Trying to overwrite context");this._ctx=e}get ctx(){if(!this._ctx)throw new c.InternalError("Context not initialized for request");return this._ctx}},e.DecafRequestContext=p.__decorate([o.Injectable({scope:o.Scope.REQUEST}),p.__param(0,o.Inject(d.REQUEST)),p.__metadata("design:paramtypes",[Request])],e.DecafRequestContext),e.DecafHandlerExecutor=z=class{constructor(e,t){this.handlers=e,this.context=t}async exec(e,t){l.Logging.for(z.name).for(this.exec).debug(`CONTEXT ${this.context.uuid} running ${this.handlers.length} handlers for request ${e.method} ${e.url}`);for(const r of this.handlers)await r.handle(this.context,e,t)}},e.DecafHandlerExecutor=z=p.__decorate([o.Injectable({scope:o.Scope.REQUEST}),p.__param(0,o.Inject(j)),p.__metadata("design:paramtypes",[Array,e.DecafRequestContext])],e.DecafHandlerExecutor),e.DecafResponseInterceptor=class{constructor(e){this.ctx=e}intercept(e,t){let r=e.switchToHttp().getResponse();return t.handle().pipe(u.tap(e=>{r=this.ctx.ctx.toResponse(r)}))}},e.DecafResponseInterceptor=p.__decorate([o.Injectable(),p.__metadata("design:paramtypes",[e.DecafRequestContext])],e.DecafResponseInterceptor);const Q=e=>({name:e,description:e+" parameter for the query",required:!0,type:String});function V(e,t,r,a=!1){const i=q(r),c=(e=>e.split("/").filter(e=>e.startsWith(":")).map(e=>e.slice(1)))(t).map(Q),p=[];return"GET"===r&&a&&p.push(n.ApiQuery({name:"direction",required:!1,enum:s.OrderDirection,description:"the sort order when applicable"}),n.ApiQuery({name:"limit",required:!1,description:"limit or page size when applicable"}),n.ApiQuery({name:"offset",required:!1,description:"offset or bookmark when applicable"})),{method:[i(t),...c.map(n.ApiParam),...p,n.ApiOperation({summary:`Retrieve records using according to "${e}".`}),n.ApiOkResponse({description:"Result successfully retrieved."}),n.ApiNoContentResponse({description:"No content returned by the method."})],params:[I(c),o.Query()]}}function Y(e,t,r,o){const a=e?.prototype??e;o.method.forEach(e=>e(a,t,r)),o.params?.forEach((e,r)=>e(a,t,r))}function J(e,t,...r){if(e instanceof s.ModelService)return"function"==typeof e[t]?e[t](...r):e.statement(t,...r);if("function"==typeof e[t])return e[t](...r);throw Error(`Persistence method "${t}" not found on ${e?.constructor?.name}`)}function X(e){return async function(t,r){const o=this.log.for(e);try{o.debug(`Invoking persistence method "${e}" given parameters: ${JSON.stringify(t.valuesInOrder)}`);const{direction:a,limit:s,offset:i}=r;return await J(this.persistence(),e,...t.valuesInOrder,a,s,i)}catch(t){throw o.error(`Custom query "${e}" failed`,t),t}}}function W(e,t,r){return Object.defineProperty(e.prototype||e,t,{value:r,writable:!1}),Object.getOwnPropertyDescriptor(e.prototype||e,t)}class Z extends s.Service{constructor(e,t){super(),this.clientContext=e}logCtx(e,t,r=!1,o){const a=this.clientContext.ctx;let i;e=e.filter(e=>void 0!==e),o&&(o.headers||o.ip)&&(i=o,o={});const n=s.ContextualLoggedClass.logCtx.call(this,t,o||{},r,...e,a);return this.bindLoggerToRequest(n,i)}bindLoggerToRequest(e,t){const r=this;function o(e,t){return e.log=((e,t)=>{const o=(e=>{if(!e)return;const t=e.headers,r=te(t?.["x-forwarded-for"])??te(t?.["x-real-ip"])??te(t?.["X-Forwarded-For"])??te(t?.["X-Real-IP"]);if(r)return r;if("string"==typeof e.ip&&e.ip.length)return e.ip;const o=e.socket||e.connection;return o&&"string"==typeof o.remoteAddress&&o.remoteAddress.length?o.remoteAddress:void 0})(t??r.clientContext.request);if(!o)return e;const a={ip:o};return e.for(a)})(e.log,t),e}return(e=>"object"==typeof e&&null!==e&&"function"==typeof e.then)(e)?e.then(e=>o(e,t)):o(e,t)}}class ee extends Z{persistence(e){if(!this._persistence)try{this._persistence=s.Service.get(this.class)}catch(e){try{this._persistence=s.ModelService.getService(this.class)}catch(e){this._persistence=s.Repository.forModel(this.class)}}const t=this.clientContext.request[L]||{};return e&&this.clientContext.put(t),e?this._persistence instanceof s.Repository?this._persistence.override(t):this._persistence.for(t):this._persistence}constructor(e,t){super(e,t)}logCtx(e,t,r=!1,o){const a=this.clientContext.ctx;let i;o&&(o.headers||o.ip)&&(i=o,o={});try{o=a.get("overrides")}catch(e){}const n=this.persistence(a);let c,p;return n instanceof s.ModelService?c=n.repo._adapter:n instanceof s.Repository?c=n._adapter:n.context&&(c=n),r?c.logCtx(e,t,!0,o).then(e=>this.bindLoggerToRequest(e,i)):(p=c.logCtx(e,t,!1,o),this.bindLoggerToRequest(p,i))}}function te(e){if(e)return(Array.isArray(e)?e[0]:e).split(",").map(e=>e.trim()).filter(Boolean)[0]}const re=new Map;function oe(e,r){if(!s.TransactionOperationKeys.includes(e))return r;const o=(e=>(re.has(e)||re.set(e,new WeakMap),re.get(e)))(e),i=o.get(r);if(i)return i;const n=[c.OperationKeys.UPDATE,c.BulkCrudOperationKeys.UPDATE_ALL].includes(e);class p{}o.set(r,p),Object.defineProperty(p,"name",{value:`${l.toPascalCase(r.name)}${l.toPascalCase(e)}DTO`});const d=(()=>{try{return a.Model.pk(r)}catch{return}})(),u=d?a.Model.pkProps(r):void 0,h=d?Reflect.getMetadata("design:type",r.prototype,d):void 0,m=h===Number||h===BigInt,f=!!u?.generated||!!d&&(a.Model.generatedBySequence(r,d)||ie(r,d)||m),y=Array.from(new Set(t.Metadata.properties(r)||[])),g=new Set(a.Model.relations(r)||[]),_=[];for(const e of y)e&&(g.has(e)||e===d&&!n&&f||e!==d&&ie(r,e)||_.push(e));for(const e of _){const t=ne(r,e),o=!!t?.[a.ValidationKeys.REQUIRED],s=ce(r,e)??Reflect.getMetadata("design:type",r.prototype,e),i={required:o};s&&(i.type=s),w(i)(p.prototype,e);const n=Reflect.getMetadata("design:type",r.prototype,e)??s;void 0!==n&&Reflect.defineMetadata("design:type",n,p.prototype,e),Object.defineProperty(p.prototype,e,{value:void 0,writable:!0,enumerable:!0,configurable:!0})}for(const o of g){const s=t.Metadata.relations(r,o);if(!s)throw new c.InternalError(`Metadata for relation ${o} not found`);let i=s.class;if("function"!=typeof i||i.name||(i=i()),!i||"function"!=typeof i)throw new c.InternalError(`Type for relation ${o} not found`);if(!a.Model.get(i.name))continue;const d=t.Metadata.validationFor(r,o),l=!!d?.[a.ValidationKeys.LIST],u=!!d?.[a.ValidationKeys.REQUIRED],h=oe(e,i);n?se(p,o,i,h,l,u):ae(p,o,h,l,u)}return p}function ae(e,t,r,o,a){w({type:r,required:a,isArray:o})(e.prototype,t),Reflect.defineMetadata("design:type",o?Array:r,e.prototype,t),Object.defineProperty(e.prototype,t,{value:void 0,writable:!0,enumerable:!0,configurable:!0})}function se(e,t,r,o,s,i){const n=Reflect.getMetadata(E.API_EXTRA_MODELS,e)||[];n.includes(o)||Reflect.defineMetadata(E.API_EXTRA_MODELS,[...n,o],e);const c="#/components/schemas/"+o.name,p=(e=>{try{const t=a.Model.pkProps(e),r=t?.type;return r===Number||r===BigInt?"integer":"string"}catch{return"string"}})(r),d=[{$ref:c},{type:p}];w(s?{type:"array",required:i,oneOf:d}:{type:Object,required:i,oneOf:d})(e.prototype,t),Reflect.defineMetadata("design:type",s?Array:Object,e.prototype,t),Object.defineProperty(e.prototype,t,{value:void 0,writable:!0,enumerable:!0,configurable:!0})}function ie(e,t){let r=e;for(;r&&r!==Object&&r!==Function;){if(a.Model.generated(r,t))return!0;r=Object.getPrototypeOf(r)}return!1}function ne(e,r){let o=e;for(;o&&o!==Object&&o!==Function;){const e=t.Metadata.validationFor(o,r);if(e)return e;o=Object.getPrototypeOf(o)}}function ce(e,r){let o=e;for(;o&&o!==Object&&o!==Function;){const e=t.Metadata.type(o,r);if(e)return e;o=Object.getPrototypeOf(o)}}s.Adapter.transformerFor=(e=>{const r="string"==typeof e?e:e.alias;return t.Metadata.innerGet(Symbol.for("transformers"),r)}).bind(s.Adapter),s.Adapter.flavoursToTransform=(()=>{const e=t.Metadata.innerGet(Symbol.for("transformers"));if(e)return Object.keys(e)}).bind(s.Adapter),s.Context.prototype.toResponse=function(e){const t=this.pending();return t&&e.header("x-pending-task",JSON.stringify(t)),e};const pe=a.ModelBuilder.prototype;if(pe.decorateClass||(pe.decorateClass=function(e){return this._classDecorators||(this._classDecorators=[]),this._classDecorators.push(e),this}),pe.Auth=function(e){return this.decorateClass(H(e))},!pe.__hasClassDecoratorSupport){const e=pe.build;pe.build=function(){let t=e.call(this);const r=this._classDecorators;if(r?.length)for(const e of r){const r=e(t);r&&(t=r)}return t},pe.__hasClassDecoratorSupport=!0}class de{static{this.log=l.Logging.for(de.name)}static getPersistence(e){try{return s.Service.get(e)}catch(t){try{return s.ModelService.getService(e)}catch(t){return s.Repository.forModel(e)}}}static createQueryRoutesFromRepository(e,r=s.PersistenceKeys.QUERY){const o=de.log.for(de.createQueryRoutesFromRepository),a=e instanceof s.ModelService?e.repo:e,i=a.class,n=t.Metadata.get(a.constructor,t.Metadata.key(s.PersistenceKeys.QUERY))??{},c=t.Metadata.get(e.constructor,t.Metadata.key(N))??{};class p extends ee{get class(){throw Error("Method not implemented.")}constructor(e,t){super(e,t)}}for(const[e,t]of Object.entries(c)){const r=[t.path.replace(/^\/+|\/+$/g,"")].filter(e=>e&&e.trim()).join("/"),a=X(e);if(!a){const t=`Invalid or missing handler for model ${i.name} on decorated method ${e}`;throw o.error(t),Error(t)}const s=W(p,e,a);s&&Y(p,e,s,V(e,r,t.httpMethod))}for(const[e,t]of Object.entries(n)){const o=[r,e,...(t.fields??[]).map(e=>":"+e)].filter(e=>e&&e.trim()).join("/"),a=W(p,e,X(e));a&&Y(p,e,a,V(e,o,"GET",!0))}return p}static create(t){const r=de.log.for(de.create),i=a.Model.tableName(t),d=l.toKebabCase(i),u=t.name,h=de.getPersistence(t),{description:m,getPK:f,apiProperties:y,path:g}=de.getRouteParametersFromModel(t);r.debug("Creating controller for model: "+u);const _=de.createQueryRoutesFromRepository(h);let A=class extends _{static get class(){return t}get class(){return t}constructor(e){super(e),this.pk=a.Model.pk(t),r.info(`Registering dynamic controller for model: ${this.class.name} route: /${d}`)}async listBy(e,t){const{ctx:r}=(await this.logCtx([],s.PreparedStatementKeys.LIST_BY,!0)).for(this.listBy);return this.persistence(r).listBy(e,t.direction,r)}async paginateBy(e,t){const{ctx:r}=(await this.logCtx([],s.PreparedStatementKeys.PAGE_BY,!0)).for(this.paginateBy);return this.persistence(r).paginateBy(e,t.direction,t,r)}async find(e,t){const{ctx:r}=(await this.logCtx([],s.PreparedStatementKeys.FIND,!0)).for(this.find),o=t.direction??s.OrderDirection.ASC;return J(this.persistence(r),this.find.name,e,o,r)}async page(e,t){const{ctx:r}=(await this.logCtx([],s.PreparedStatementKeys.PAGE,!0)).for(this.page),{direction:o=s.OrderDirection.ASC,limit:a,offset:i,bookmark:n}=t,c={offset:i??1,limit:a??10,bookmark:n};return J(this.persistence(r),this.page.name,e,o,c,r)}async findOneBy(e,t){const{ctx:r}=(await this.logCtx([],s.PreparedStatementKeys.FIND_ONE_BY,!0)).for(this.findOneBy);return this.persistence(r).findOneBy(e,t,r)}async findBy(e,t,r){const{ctx:o}=(await this.logCtx([],s.PreparedStatementKeys.FIND_BY,!0)).for(this.findBy);return this.persistence(o).for(o.toOverrides()).findBy(e,t,o)}async statement(e,t,r){const{ctx:o}=(await this.logCtx([],s.PersistenceKeys.STATEMENT,!0)).for(this.statement),{direction:a,offset:i,limit:n,bookmark:c}=r,p=(t=t.map(e=>("string"==typeof e?parseInt(e):e)||e)).length>1?t[1]:void 0,d=a??p;switch(d&&t.length>1&&(t[1]=d),e){case s.PreparedStatementKeys.FIND:case s.PreparedStatementKeys.FIND_BY:break;case s.PreparedStatementKeys.LIST_BY:t.push(a);break;case s.PreparedStatementKeys.PAGE:case s.PreparedStatementKeys.PAGE_BY:t=[t[0],d,{limit:n,offset:i,bookmark:c}];case s.PreparedStatementKeys.FIND_ONE_BY:case s.PreparedStatementKeys.COUNT_OF:case s.PreparedStatementKeys.MAX_OF:case s.PreparedStatementKeys.MIN_OF:case s.PreparedStatementKeys.AVG_OF:case s.PreparedStatementKeys.SUM_OF:case s.PreparedStatementKeys.DISTINCT_OF:case s.PreparedStatementKeys.GROUP_OF:}return this.persistence(o).statement(e,...t,o)}async createAll(e,r){const{ctx:o,log:a}=(await this.logCtx([],c.BulkCrudOperationKeys.CREATE_ALL,!0)).for(this.createAll);let s;a.verbose("creating new "+u);try{s=await this.persistence(o).createAll(e.map(e=>new t(e)),o)}catch(e){throw a.error("Failed to create new "+u,e),e}return a.info(`created new ${u} with id ${s[this.pk]}`),o.toResponse(r),s}async create(e,t){const{ctx:r,log:o}=(await this.logCtx([],c.OperationKeys.CREATE,!0)).for(this.create);let a;o.verbose("creating new "+u);try{const t=this.persistence(r);a=await t.create(e,r)}catch(e){throw o.error("Failed to create new "+u,e),e}return o.info(`created new ${u} with id ${a[this.pk]}`),r.toResponse(t),a}async readAll(e){const{ctx:t,log:r}=(await this.logCtx([],c.BulkCrudOperationKeys.READ_ALL,!0)).for(this.readAll);let o;try{r.debug(`reading ${e.length} ${u}: ${e}`);const a=this.persistence(t);o=await a.readAll(e,t)}catch(t){throw r.error(`Failed to ${u} with id ${e}`,t),t}return r.info(`read ${o.length} ${u}`),o}async read(e){const{ctx:t,log:r}=(await this.logCtx([],c.OperationKeys.READ,!0)).for(this.read),o=f(...e.valuesInOrder);if(void 0===o)throw new c.ValidationError(`No ${this.pk} provided`);let a;try{r.debug(`reading ${u} with ${this.pk} ${o}`);const e=this.persistence(t);a=await e.read(o,t)}catch(e){throw r.error(`Failed to read ${u} with id ${o}`,e),e}return r.info(`read ${u} with id ${a[this.pk]}`),a}async updateAll(e,t){const{ctx:r,log:o}=(await this.logCtx([],c.BulkCrudOperationKeys.UPDATE_ALL,!0)).for(this.updateAll);let a;try{o.info(`updating ${e.length} ${u}`),a=await this.persistence(r).updateAll(e,r)}catch(e){throw o.error(e),e}return r.toResponse(t),a}async update(e,r,o){const{ctx:a,log:s}=(await this.logCtx([],c.OperationKeys.UPDATE,!0)).for(this.update),i=f(...e.valuesInOrder);if(void 0===i)throw new c.ValidationError(`No ${this.pk} provided`);let n;try{s.info(`updating ${u} with ${this.pk} ${i}`);const e=JSON.parse(JSON.stringify(r)),o=this.persistence(a);n=await o.update(new t({...e,[this.pk]:i}),a)}catch(e){throw s.error(e),e}return a.toResponse(o),n}async deleteAll(e,t){const{ctx:r,log:o}=(await this.logCtx([],c.BulkCrudOperationKeys.DELETE_ALL,!0)).for(this.deleteAll);let a;try{o.debug(`deleting ${e.length} ${u}: ${e}`),a=await this.persistence(r).deleteAll(e,r)}catch(t){throw o.error(`Failed to delete ${u} with id ${e}`,t),t}return o.info(`deleted ${a.length} ${u}`),r.toResponse(t),a}async delete(e,t){const{ctx:r,log:o}=(await this.logCtx([],c.OperationKeys.DELETE,!0)).for(this.delete),a=f(...e.valuesInOrder);if(void 0===a)throw new c.ValidationError(`No ${this.pk} provided`);let s;try{o.debug(`deleting ${u} with ${this.pk} ${a}`),s=await this.persistence(r).delete(a,r)}catch(e){throw o.error(`Failed to delete ${u} with id ${a}`,e),e}return o.info(`deleted ${u} with id ${a}`),r.toResponse(t),s}};return p.__decorate([T(t,"GET","listBy/:key"),n.ApiOperation({summary:`Retrieve ${u} records by query.`}),n.ApiParam({name:"key",description:"the model key to sort by"}),n.ApiQuery({name:"direction",required:!0,enum:s.OrderDirection}),n.ApiOkResponse({description:u+" listed successfully."}),p.__param(0,o.Param("key")),p.__param(1,$()),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"listBy",null),p.__decorate([T(t,"GET","paginateBy/:key/:page"),n.ApiOperation({summary:`Retrieve ${u} records by query.`}),n.ApiParam({name:"key",description:"the model key to sort by"}),n.ApiParam({name:"page",description:"the page to retrieve or the bookmark"}),n.ApiQuery({name:"direction",required:!0,enum:s.OrderDirection,description:"the sort order"}),n.ApiQuery({name:"limit",required:!0,description:"the page size"}),n.ApiQuery({name:"offset",description:"the bookmark when necessary"}),n.ApiOkResponse({description:u+" listed paginated."}),p.__param(0,o.Param("key")),p.__param(1,$()),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"paginateBy",null),p.__decorate([T(t,"GET","find/:value"),n.ApiOperation({summary:`Find ${u} records using the default query attributes.`}),n.ApiParam({name:"value",description:"The string to match against the default query attributes"}),n.ApiQuery({name:"direction",required:!1,enum:s.OrderDirection,description:"the sort order for the matching results"}),n.ApiOkResponse({description:u+" records matching the provided prefix."}),p.__param(0,o.Param("value")),p.__param(1,$()),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"find",null),p.__decorate([T(t,"GET","page/:value"),n.ApiOperation({summary:`Page ${u} records using the default query attributes.`}),n.ApiParam({name:"value",description:"The string to match against the default query attributes"}),n.ApiQuery({name:"direction",required:!1,enum:s.OrderDirection,description:"the sort order for the paged results"}),n.ApiQuery({name:"limit",required:!1,description:"page size"}),n.ApiQuery({name:"offset",required:!1,description:"page number"}),n.ApiQuery({name:"bookmark",required:!1,description:"bookmark for cursor pagination"}),n.ApiOkResponse({description:u+" records paged by the provided prefix."}),p.__param(0,o.Param("value")),p.__param(1,$()),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"page",null),p.__decorate([T(t,"GET","findOneBy/:key"),n.ApiOperation({summary:`Retrieve ${u} records by query.`}),n.ApiParam({name:"key",description:"the model key to sort by"}),n.ApiOkResponse({description:u+" listed found."}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),p.__param(0,o.Param("key")),p.__param(1,o.Param("value")),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"findOneBy",null),p.__decorate([T(t,"GET","findBy/:key/:value"),n.ApiOperation({summary:`Retrieve ${u} records by query.`}),n.ApiParam({name:"key",description:"the model key to compare"}),n.ApiParam({name:"value",description:"the value to match"}),n.ApiQuery({name:"direction",required:!0,enum:s.OrderDirection,description:"the sort order when applicable"}),n.ApiOkResponse({description:u+" listed found."}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),p.__param(0,o.Param("key")),p.__param(1,o.Param("value")),p.__param(2,$()),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String,Object,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"findBy",null),p.__decorate([T(t,"GET","statement/:method/*args"),n.ApiOperation({summary:`Executes a prepared statement on ${u}.`}),n.ApiParam({name:"method",description:"the prepared statement to execute"}),n.ApiParam({name:"args",description:"concatenated list of arguments the prepared statement can accept"}),n.ApiQuery({name:"direction",required:!0,enum:s.OrderDirection,description:"the sort order when applicable"}),n.ApiQuery({name:"limit",required:!0,description:"limit or page size when applicable"}),n.ApiQuery({name:"offset",required:!0,description:"offset or bookmark when applicable"}),n.ApiOkResponse({description:u+" listed found."}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),p.__param(0,o.Param("method")),p.__param(1,o.Param("args")),p.__param(2,$()),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String,Array,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"statement",null),p.__decorate([T(t,"POST","bulk"),n.ApiOperation({summary:`Create a new ${u}.`}),n.ApiBody({description:"Payload for "+u,schema:{type:"array",items:{$ref:n.getSchemaPath(t)}}}),n.ApiCreatedResponse({description:u+" created successfully.",schema:{type:"array",items:{$ref:n.getSchemaPath(t)}}}),n.ApiBadRequestResponse({description:"Payload validation failed."}),n.ApiUnprocessableEntityResponse({description:"Repository rejected the provided payload."}),p.__param(0,x()),p.__param(1,o.Response({passthrough:!0})),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Array,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"createAll",null),p.__decorate([T(t,"POST"),n.ApiOperation({summary:`Create a new ${u}.`}),n.ApiBody({description:"Payload for "+u,type:oe(c.OperationKeys.CREATE,t)}),n.ApiCreatedResponse({description:u+" created successfully.",schema:{$ref:n.getSchemaPath(t)}}),n.ApiBadRequestResponse({description:"Payload validation failed."}),n.ApiUnprocessableEntityResponse({description:"Repository rejected the provided payload."}),p.__param(0,x()),p.__param(1,o.Response({passthrough:!0})),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Object,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"create",null),p.__decorate([T(t,"GET","bulk"),n.ApiOperation({summary:`Retrieve a ${u} record by id.`}),n.ApiQuery({name:"ids",required:!0,type:"array"}),n.ApiOkResponse({description:u+" retrieved successfully.",schema:{type:"array",items:{$ref:n.getSchemaPath(t)}}}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),p.__param(0,o.Query("ids")),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Array]),p.__metadata("design:returntype",Promise)],A.prototype,"readAll",null),p.__decorate([T(t,"GET",g),C(y),n.ApiOperation({summary:`Retrieve a ${u} record by id.`}),n.ApiOkResponse({description:u+" retrieved successfully.",schema:{$ref:n.getSchemaPath(t)}}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),p.__param(0,I(y)),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Object]),p.__metadata("design:returntype",Promise)],A.prototype,"read",null),p.__decorate([T(t,"PUT","bulk"),C(y),n.ApiOperation({summary:`Replace an existing ${u} record with a new payload.`}),n.ApiBody({description:"Payload for replace a existing record of "+u,schema:{type:"array",$ref:n.getSchemaPath(oe(c.OperationKeys.UPDATE,t))}}),n.ApiOkResponse({description:u+" updated successfully.",schema:{type:"array",items:{$ref:n.getSchemaPath(t)}}}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),n.ApiBadRequestResponse({description:"Payload validation failed."}),p.__param(0,x()),p.__param(1,o.Response({passthrough:!0})),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Array,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"updateAll",null),p.__decorate([T(t,"PUT",g),C(y),n.ApiOperation({summary:`Replace an existing ${u} record with a new payload.`}),n.ApiBody({description:"Payload for replace a existing record of "+u,type:oe(c.OperationKeys.UPDATE,t)}),n.ApiOkResponse({description:u+" updated successfully.",schema:{$ref:n.getSchemaPath(t)}}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),n.ApiBadRequestResponse({description:"Payload validation failed."}),p.__param(0,I(y)),p.__param(1,x()),p.__param(2,o.Response({passthrough:!0})),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Object,Object,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"update",null),p.__decorate([T(t,"DELETE","bulk"),C(y),n.ApiOperation({summary:`Retrieve a ${u} record by id.`}),n.ApiQuery({name:"ids",required:!0,type:"array"}),n.ApiOkResponse({description:u+" deleted successfully.",schema:{type:"array",items:{$ref:n.getSchemaPath(t)}}}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),p.__param(0,o.Query("ids")),p.__param(1,o.Response({passthrough:!0})),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Array,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"deleteAll",null),p.__decorate([T(t,"DELETE",g),C(y),n.ApiOperation({summary:`Delete a ${u} record by id.`}),n.ApiOkResponse({description:u+" deleted successfully.",schema:{$ref:n.getSchemaPath(t)}}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),p.__param(0,I(y)),p.__param(1,o.Response({passthrough:!0})),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Object,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"delete",null),A=p.__decorate([o.Controller(d),n.ApiTags(u),n.ApiExtraModels(t),H(t),p.__metadata("design:paramtypes",[e.DecafRequestContext])],A),A}static getRouteParametersFromModel(e){const r=a.Model.pk(e),o=t.Metadata.get(e,t.Metadata.key(c.DBKeys.COMPOSED,r)),s=o?.args??[],i=Array.isArray(s)&&s.length>0?Array.from(new Set([...s])):Array.from(new Set([r])),n=t.Metadata.description(e);return{path:":"+i.join("/:"),description:n,apiProperties:i.map(r=>({name:r,description:t.Metadata.description(e,r),required:!0,type:String})),getPK:(...e)=>o?.separator?e.join(o.separator):e.join("")}}}function le(e){var t;let r=class{static{t=this}static{this.log=l.Logging.for(t.name).for(e)}static createModelServices(e){return e.map(e=>({provide:e.name+"Service",useFactory:()=>s.ModelService.forModel(e)}))}static forRoot(e,r={}){const o=this.log.for(this.forRoot);o.info("Generating controllers for flavour...");const a=s.Adapter.models(e);let i=[];r.autoServices&&(o.info("Auto-services enabled. Initializing service generation."),i=this.createModelServices(a),o.info(`Auto-services completed. ${i.length} services initialized.`));const n=a.map(de.create);return o.info(`Generated ${n.length} controllers`),{module:t,controllers:n,providers:[...i]}}};return r=t=p.__decorate([o.Module({})],r),Object.assign(r,"name",{value:"DecafModule"+e}),r}t.Decoration.for(r.InjectablesKeys.INJECTABLE).extend({decorator:(e,t)=>(t=t||("object"==typeof e?Object.assign(e,r.DefaultInjectablesConfig):r.DefaultInjectablesConfig),o.Injectable({scope:t.singleton?o.Scope.DEFAULT:o.Scope.REQUEST,durable:!t.singleton||void 0}))}).apply(),t.Decoration.for(r.InjectablesKeys.INJECT).extend({decorator:(e,t)=>(t,r,a)=>o.Inject(e||t)(t,r,a)}).apply(),t.Decoration.for(a.ValidationKeys.REQUIRED).extend(w({required:!0})).apply(),t.Decoration.for(a.ValidationKeys.MAX).extend({decorator:e=>w({maximum:e,required:!1})}).apply(),t.Decoration.for(a.ValidationKeys.MIN).extend({decorator:e=>w({minimum:e,required:!1})}).apply(),t.Decoration.for(a.ValidationKeys.MAX_LENGTH).extend({decorator:e=>w({maxLength:e,required:!1})}).apply(),t.Decoration.for(a.ValidationKeys.MIN_LENGTH).extend({decorator:e=>w({minLength:e,required:!1})}).apply(),t.Decoration.for(a.ValidationKeys.TYPE).extend({decorator:e=>(t,r)=>("function"!=typeof(e=Array.isArray(e)?e[0]:e)||e.name||(e=e()),w({type:e,required:!1})(t,r))}).apply(),t.Decoration.for(a.ValidationKeys.DATE).extend({decorator:e=>w({type:String,format:"date-time",required:!1})}).apply(),t.Decoration.for(a.ValidationKeys.ENUM).extend({decorator:e=>w({enum:Array.isArray(e)?e:Object.values(e),required:!1})}).apply(),t.Decoration.for(a.ValidationKeys.PATTERN).extend({decorator:e=>w({pattern:"string"==typeof e?e:e.source,required:!1})}).apply(),t.Decoration.for(s.PersistenceKeys.COLUMN).extend({decorator:e=>w({name:e,required:!1})}).apply(),t.Decoration.for(t.DecorationKeys.DESCRIPTION).extend({decorator:e=>w({description:e,required:!1})}).apply(),t.Decoration.for(s.PersistenceKeys.AUTH).extend({decorator:H}).apply();class ue extends s.ForbiddenError{constructor(e){super(e,ue.name)}}class he extends c.BaseError{constructor(e){super(he.name,e,429)}}e.DecafExceptionFilter=class{catch(e,t){const r=t.switchToHttp(),a=r.getResponse(),i=r.getRequest(),n="production"===l.LoggedEnvironment.env;let p;e instanceof o.NotFoundException||e instanceof s.UnsupportedError?p=(e=new o.NotAcceptableException(e.message)).getStatus():e instanceof c.BaseError||(e=429===e.status?new he(e.message):new c.InternalError(e.message)),a.status(e.code||p).json({status:e.code||p,error:n?e.name:e.message,timestamp:(new Date).toISOString(),path:i.url,method:i.method})}},e.DecafExceptionFilter=p.__decorate([o.Catch()],e.DecafExceptionFilter);const me={path:"docs",auth:{type:"http",scheme:"bearer",bearerFormat:"JWT",name:"Authorization",description:"Enter JWT token",in:"header"},topbarBgColor:"#000000"};class fe{constructor(e){this.options={...e}}customCSS(){let e="";return this.options.topbarIconPath&&(e+=`.topbar-wrapper { content: url('data:image/png;base64,${this.b64(this.options.topbarIconPath)}'); width: 200px; height: auto; }\n`),e+`\n .topbar-wrapper svg { visibility: hidden; }\n .swagger-ui .topbar { background-color: ${this.options.topbarBgColor||me.topbarBgColor}; }\n `}getCustomOptions(){const e={};return this.options.faviconPath&&(e.customfavIcon=this.b64(this.options.faviconPath,!0)),{customSiteTitle:this.options.title,...e,customCss:this.customCSS(),swaggerOptions:{persistAuthorization:this.options.persistAuthorization}}}b64(e,t=!1){const r=A.join(this.options.assetsPath||"",e),o=h.readFileSync(r,{encoding:"base64"});return t?"data:image/png;base64,"+o:o}}class ye{constructor(e,t){this.app=e,this.options=t}createDocument(){const e=this.options.path?this.options.description+""+`<br><br><a href="${this.options.openApiJsonPath}">OpenAPI JSON Spec</a> | `+`<a href="${this.options.openApiYamlPath}">OpenAPI YAML Spec</a>`:this.options.description,t=(new n.DocumentBuilder).setTitle(this.options.title).setDescription(e).setVersion(this.options.version||"0.0.1").addBearerAuth(this.options.auth||me.auth).build();return n.SwaggerModule.createDocument(this.app,t,{extraModels:this.options.extraModels||[]})}registerOpenApiRoute(e,t,r){if(!e)return;const o=this.app.getHttpAdapter();e=e.startsWith("/")?e:"/"+e,o.get(e,(e,a)=>{o.reply(a,r(),200,{"Content-Type":t})})}setupSwagger(){const e=this.createDocument(),t=new fe({title:this.options.title,path:this.options.path||me.path,persistAuthorization:this.options.persistAuthorization??!0,assetsPath:this.options.assetsPath,faviconPath:this.options.faviconFilePath,topbarIconPath:this.options.topbarIconFilePath,topbarBgColor:this.options.topbarBgColor});n.SwaggerModule.setup(this.options.path||me.path,this.app,e,{...t.getCustomOptions(),jsonDocumentUrl:this.options.openApiJsonPath?""+this.options.openApiJsonPath:void 0,yamlDocumentUrl:this.options.openApiYamlPath?""+this.options.openApiYamlPath:void 0}),this.registerOpenApiRoute(this.options.openApiJsonPath,"application/json",()=>e),this.registerOpenApiRoute(this.options.openApiYamlPath,"application/x-yaml",()=>f.stringify(e))}}var ge,_e;function Ae(e){return r=>(t.Metadata.set("transformers",e,r),"function"==typeof r?t.metadata("transformers",e)(r):r)}e.DecafRequestHandlerInterceptor=ge=class{constructor(e,t){this.requestContext=e,this.executor=t}async contextualize(e){const t={headers:e.headers,overrides:{}},r=s.Adapter.flavoursToTransform();if(r)for(const o of r)try{const r=s.Adapter.transformerFor(o),a=await r.from(e);Object.assign(t.overrides,a)}catch(e){throw new c.InternalError("Failed to contextualize request: "+e)}return(new s.Context).accumulate(Object.assign({},s.DefaultAdapterFlags,{logger:l.Logging.get(),timestamp:new Date},t))}async intercept(e,t){const r=e.switchToHttp().getRequest(),o=e.switchToHttp().getResponse(),a=l.Logging.for(ge).for(this.intercept);a.debug(`CONTEXT ${this.requestContext.uuid} - request: ${r.method} ${r.url}`);const s=await this.contextualize(r);return a.debug(`CONTEXT ${this.requestContext.uuid} contextualized - request: ${r.method} ${r.url}`),this.requestContext.applyCtx(s),a.debug(`CONTEXT ${this.requestContext.uuid} applied - request: ${r.method} ${r.url}`),await this.executor.exec(r,o),a.debug(`CONTEXT ${this.requestContext.uuid} executors finished - request: ${r.method} ${r.url}`),t.handle()}},e.DecafRequestHandlerInterceptor=ge=p.__decorate([o.Injectable({scope:o.Scope.REQUEST}),p.__metadata("design:paramtypes",[e.DecafRequestContext,e.DecafHandlerExecutor])],e.DecafRequestHandlerInterceptor),e.DecafCoreModule=class{static{_e=this}static get persistence(){if(!this._persistence)throw new c.InternalError("Persistence service not initialized");return this._persistence}static get log(){return this._logger||(this._logger=l.Logging.for(_e)),this._logger}constructor(e,t){this.options=e,this.moduleRef=t}static forRoot(t){const r=this.log.for(this.forRoot);return{module:_e,providers:[{provide:F,useValue:t},{provide:k,useValue:this.persistence?.client},{provide:j,useFactory:()=>t.handlers?.map(e=>(r.info("Registered request handler: "+e.name),new e))??[]},e.AuthInterceptor,{provide:d.APP_INTERCEPTOR,useExisting:e.AuthInterceptor},e.DecafRequestContext,e.DecafHandlerExecutor,{provide:d.APP_INTERCEPTOR,useClass:e.DecafRequestHandlerInterceptor}],exports:[F,k,j,e.DecafRequestContext,e.DecafHandlerExecutor]}}static async bootPersistence(e){const t=this.log.for(this.bootPersistence);if(!this._persistence){const r=e.conf.map(([e,t,...r])=>r.pop()?[e,t,...r]:[e,t]);this._persistence=new s.PersistenceService,await this._persistence.boot(r);const o=this._persistence.client;for(let t=0;t<o.length;t++){const r=e.conf[t];let a=r.slice(2,r.length).pop();if(!a||!a.from){const e=s.Adapter.transformerFor(o[t].flavour);if(!e)throw new c.InternalError(`No transformer found for flavour ${o[t].flavour}. you should either @requestToContextTransformer or provide a transformer in the config`);try{a=e.from?e:new e}catch(e){throw new c.InternalError(`Failed to boot transformer for ${o[t].flavour}: ${e}`)}}Ae(o[t].flavour)(a)}if(t.info("persistence layer created successfully!"),e.initialization)try{await e.initialization()}catch(e){throw new c.InternalError("Failed to initialize application: "+e)}}return this.persistence.client}async onApplicationShutdown(){const e=_e.log.for(this.onApplicationShutdown),t=this.moduleRef.get(k);for(const r of t)try{r&&(e.info("Shutting down "+r.toString()),await r.shutdown())}catch(t){e.error("Failed to shutdown application",t)}try{await s.Service.shutdown()}catch(t){e.error("Failed to shutdown services",t)}}},e.DecafCoreModule=_e=p.__decorate([o.Global(),o.Module({}),p.__param(0,o.Inject(F)),p.__metadata("design:paramtypes",[Object,d.ModuleRef])],e.DecafCoreModule);const be=Symbol("LISTENING_ADAPTERS_FLAVOURS");var Ee,Pe,Oe,Re;e.EventsController=Ee=class extends Z{constructor(e,t){super(e,Ee.name),this.adapters=t.map(e=>s.Adapter.get(e))}listen(){const e=l.Logging.for(Ee.name),t=new u.Observable(t=>{const r=("B-"+Math.random().toString(36).slice(2,8)).toUpperCase();e.info(`Creating SSE observer: ${r} for client ${this.clientContext.uuid}`);const o=new class{constructor(){this.observerId=r}refresh(...r){return e.debug(`SSE observer ${this.observerId} received refresh event`),Promise.resolve().then(()=>{const o=(e=>{const[t,r,o,a]=e;return[t?.name??t,r,o,Array.isArray(a)?a.map(e=>{try{return"function"==typeof e.serialize?e.serialize():"string"==typeof e?e:JSON.stringify(e)}catch(e){return}}):a&&"function"==typeof a.serialize?a.serialize():"string"==typeof a?a:JSON.stringify(a)]})(r);t.next({type:"message",data:o}),e.debug(`SSE observer ${this.observerId} event pushed to client`)})}};e.verbose(`Registering observer ${r} across ${this.adapters.length} adapter(s)`);for(const t of this.adapters){const a=t?.constructor?.name??"UnknownAdapter";try{e.debug(`Registering observer ${r} in adapter ${a}`),t.observe(o)}catch(t){e.debug(`Failed to register observer ${r} in adapter ${a}: ${t?.message||t}`),e.error(t)}}return()=>{e.debug("Cleaning up SSE observer "+r);for(const t of this.adapters){const a=t?.constructor?.name??"UnknownAdapter";try{e.debug(`Unregistering observer ${r} from adapter ${a}`),t.unObserve(o)}catch(t){e.debug(`Failed during cleanup of observer ${r} in adapter ${a}: ${t?.message||t}`),e.error(t)}}}}),r=u.interval(15e3).pipe(y.tap(()=>{e.debug("Sending heartbeat")}),y.map(()=>({type:"heartbeat",data:{ts:(new Date).toISOString()}})));return u.merge(t,r)}listenForModel(e){const t=l.Logging.for(Ee.name);return new u.Observable(e=>{const r=new class{refresh(...t){return Promise.resolve().then(()=>{e.next({data:t})})}};try{for(const e of this.adapters)e.observe(r)}catch(t){e.error("Failed to observe event: "+(t.message||t))}return()=>{try{for(const e of this.adapters)e.unObserve(r)}catch(e){t.error(e)}}})}},p.__decorate([o.Sse(),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[]),p.__metadata("design:returntype",u.Observable)],e.EventsController.prototype,"listen",null),p.__decorate([o.Sse("/:model"),p.__param(0,o.Query("model")),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String]),p.__metadata("design:returntype",u.Observable)],e.EventsController.prototype,"listenForModel",null),e.EventsController=Ee=p.__decorate([o.Controller(),p.__param(1,o.Inject(be)),p.__metadata("design:paramtypes",[e.DecafRequestContext,Array])],e.EventsController),e.DecafStreamModule=Pe=class{static forFlavours(t,r="events"){return{module:Pe,controllers:[e.EventsController],imports:[d.RouterModule.register([{path:r.replace(/^\//,""),module:Pe}])],providers:[e.DecafRequestContext,{provide:be,useValue:t??[]}]}}},e.DecafStreamModule=Pe=p.__decorate([o.Module({})],e.DecafStreamModule),e.DecafModule=Oe=class{static async forRootAsync(t){const{autoControllers:r,autoServices:o}=t,a=(await e.DecafCoreModule.bootPersistence(t)).map(e=>e.flavour),s=[e.DecafCoreModule.forRoot(t)];return r&&a.forEach(e=>{s.push(le(e).forRoot(e,{autoServices:o}))}),t.observerOptions?.enableObserverEvents&&s.push(e.DecafStreamModule.forFlavours(t.observerOptions.observerFlavours||a)),{module:Oe,imports:s}}},e.DecafModule=Oe=p.__decorate([o.Module({})],e.DecafModule);const ve=l.Logging.for("DecafMigrationModule");e.DecafMigrationModule=Re=class{static forRoot(){return{module:Re}}static async migrate(e,t){const r=ve.for(this.migrate);if(!t||0===t.length)throw new c.InternalError("No adapters provided. Make sure DecafCoreModule is configured and adapters are available.");return r.info("Running migrations with config: "+JSON.stringify(e)),g.MigrationService.migrateAdapters(t,e||{})}},e.DecafMigrationModule=Re=p.__decorate([o.Global(),o.Module({providers:[{provide:"MIGRATION_ADAPTERS",useFactory:e=>e,inject:[k]}],exports:["MIGRATION_ADAPTERS"]})],e.DecafMigrationModule);const we="##VERSION##",De="##PACKAGE##";t.Metadata.allowReregistration(!0),t.Metadata.registerLibrary(De,we),t.Metadata.allowReregistration(!1),e.AUTH_HANDLER=K,e.AUTH_META_KEY=B,e.ApiOperationFromModel=T,e.ApiParamsFromModel=C,e.ApiProperty=w,e.Auth=H,e.BulkApiOperationFromModel=(e,r,a)=>{const s={GET:[c.BulkCrudOperationKeys.READ_ALL,o.Get],POST:[c.BulkCrudOperationKeys.CREATE_ALL,o.Post],PUT:[c.BulkCrudOperationKeys.UPDATE_ALL,o.Put],PATCH:[c.BulkCrudOperationKeys.UPDATE_ALL,o.Patch],DELETE:[c.BulkCrudOperationKeys.DELETE_ALL,o.Delete]},[i,p]=s[r];return S(e,i)?t.apply(n.ApiExcludeEndpoint()):t.apply(p(a))},e.COMMIT="4ea8766",e.CorsError=ue,e.DECAF_ADAPTER_ID=k,e.DECAF_ADAPTER_OPTIONS=L,e.DECAF_CONTEXT_KEY=U,e.DECAF_HANDLERS=j,e.DECAF_MODULE_OPTIONS=F,e.DECAF_ROUTE=N,e.DECAF_TASK_SERVICE_ID="DecafTaskService",e.DECORATORS=E,e.DECORATORS_PREFIX=b,e.DecafAuthHandler=G,e.DecafBody=x,e.DecafController=Z,e.DecafModelController=ee,e.DecafParams=I,e.DecafQuery=$,e.DecafRoleAuthHandler=class extends G{constructor(){super()}async authorize(e,r){const o=e.switchToHttp().getRequest(),i=this.parseRequest(o);if(!i)throw new s.AuthorizationError("Unauthenticated");const n=t.Metadata.get(a.Model.get(r),s.PersistenceKeys.AUTH_ROLE);if(!n.includes(i))throw new s.AuthorizationError("Missing role: "+i);return n}},e.DtoFor=oe,e.FULL_VERSION="0.10.0-4ea8766",e.FromModelController=de,e.HttpVerbToDecorator=q,e.NestBootstraper=class{static get logger(){return this._logger||(this._logger=new o.Logger("NestBootstrap")),this._logger}static initialize(e){return this.app=e,this}static enableLogger(e){return this._logger=e||new o.Logger("NestBootstrap"),this.app.useLogger(this._logger),this}static enableCors(e=[],t=["GET","POST","PUT","DELETE"]){const r="*"===e?"*":e.map(e=>e.trim().toLowerCase()),o={origin:(e,t)=>e?"*"===r||Array.isArray(r)&&r.includes(e.toLowerCase())?t(null,!0):void t(new ue(`Origin ${e} not allowed`)):t(null,!0),credentials:!0,methods:t.join(",")};return this.app.enableCors(o),this}static useHelmet(e){try{const t=require("helmet");this.app.use(t(e)),this.logger.log("Helmet middleware enabled successfully.")}catch(e){this.logger.warn("Helmet not installed. Skipping middleware.")}return this}static setupSwagger(e){return new ye(this.app,{title:e.title,description:e.description,version:e.version,path:e.path||"api",persistAuthorization:e.persistAuthorization??!0,assetsPath:e.assetsPath,faviconFilePath:e.faviconPath,topbarIconFilePath:e.topbarIconPath,topbarBgColor:e.topbarBgColor,openApiJsonPath:e.openApiJsonPath,openApiYamlPath:e.openApiYamlPath}).setupSwagger(),this}static useGlobalPipes(...e){return e.length>0&&this.app.useGlobalPipes(...e),this}static useGlobalFilters(...t){return this.app.useGlobalFilters(...t.length>0?t:[new e.DecafExceptionFilter]),this}static useGlobalInterceptors(...e){return e.length>0&&this.app.useGlobalInterceptors(...e),this}static async start(e=Number(process.env.PORT)||3e3,t=void 0,r=!0){this.app.listen(e,t).then(async()=>{if(r){const e=await this.app.getUrl();this.logger.log("\ud83d\ude80 Application is running at: "+e)}})}},e.PACKAGE_NAME=De,e.RequestToContextTransformer=class{},e.SwaggerBuilder=ye,e.UseDecafFilter=()=>o.UseFilters(new e.DecafExceptionFilter),e.UseDecafHeaders=()=>o.UseInterceptors(e.DecafResponseInterceptor),e.VERSION=we,e.createApiPropertyDecorator=D,e.createPropertyDecorator=v,e.getEnumType=R,e.getEnumValues=O,e.getModuleFor=le,e.isOperationBlocked=S,e.isUndefined=P,e.repoForModel=e=>{const t=a.Model.get(e);if(!t)throw new c.InternalError("Failed to find repository for "+e);return s.Repository.forModel(t)},e.requestToContextTransformer=Ae,e.runMigrations=async()=>{}},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@decaf-ts/decoration"),require("@decaf-ts/injectable-decorators"),require("@nestjs/common"),require("@decaf-ts/decorator-validation"),require("@decaf-ts/core"),require("lodash"),require("@nestjs/swagger"),require("@decaf-ts/db-decorators"),require("tslib"),require("@nestjs/core"),require("@decaf-ts/logging"),require("rxjs"),require("fs"),require("path"),require("yaml"),require("rxjs/operators"),require("@decaf-ts/core/migrations")):"function"==typeof define&&define.amd?define(["exports","@decaf-ts/decoration","@decaf-ts/injectable-decorators","@nestjs/common","@decaf-ts/decorator-validation","@decaf-ts/core","lodash","@nestjs/swagger","@decaf-ts/db-decorators","tslib","@nestjs/core","@decaf-ts/logging","rxjs","fs","path","yaml","rxjs/operators","@decaf-ts/core/migrations"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["for-nest"]={},e.decafTsDecoration,e.decafTsInjectableDecorators,e.nestjsCommon,e.decafTsDecoratorValidation,e.decafTsCore,e.lodash,e.nestjsSwagger,e.decafTsDbDecorators,e.tslib,e.nestjsCore,e.decafTsLogging,e.rxjs,e.fs,e.path,e.yaml,e.operators,e.migrations);
1
+ var e,t;e=this,t=function(e,t,r,o,a,s,i,n,c,p,d,l,u,h,m,f,y,g){"use strict";function _(e){var t=Object.create(null);return e&&Object.keys(e).forEach(r=>{if("default"!==r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}),t.default=e,Object.freeze(t)}var A=_(m);const b="swagger",E={API_OPERATION:b+"/apiOperation",API_RESPONSE:b+"/apiResponse",API_PRODUCES:b+"/apiProduces",API_CONSUMES:b+"/apiConsumes",API_TAGS:b+"/apiUseTags",API_CALLBACKS:b+"/apiCallbacks",API_PARAMETERS:b+"/apiParameters",API_HEADERS:b+"/apiHeaders",API_MODEL_PROPERTIES:b+"/apiModelProperties",API_MODEL_PROPERTIES_ARRAY:b+"/apiModelPropertiesArray",API_SECURITY:b+"/apiSecurity",API_EXCLUDE_ENDPOINT:b+"/apiExcludeEndpoint",API_EXCLUDE_CONTROLLER:b+"/apiExcludeController",API_EXTRA_MODELS:b+"/apiExtraModels",API_EXTENSION:b+"/apiExtension",API_SCHEMA:b+"/apiSchema",API_DEFAULT_GETTER:b+"/apiDefaultGetter",API_LINK:b+"/apiLink"},P=e=>void 0===e;function O(e){if("function"==typeof e)return O(e());if(Array.isArray(e))return e;if("object"!=typeof e)return[];const t=Object.values(e).filter(e=>"number"==typeof e).map(e=>e.toString());return Object.keys(e).filter(e=>!t.includes(e)).map(t=>e[t])}function R(e){return e.filter(i.isString).length>0?"string":"number"}function v(e,t,r=!0){return(o,a)=>{const s=Reflect.getMetadata(E.API_MODEL_PROPERTIES_ARRAY,o)||[],n=":"+a;s.includes(n)||Reflect.defineMetadata(E.API_MODEL_PROPERTIES_ARRAY,[...s,":"+a],o);const c=Reflect.getMetadata(e,o,a);if(c){const s=i.pickBy(t,i.negate(P)),n=r?{...c,...s}:{...s,...c};Reflect.defineMetadata(e,n,o,a)}else{const r=o?.constructor?._OPENAPI_METADATA_FACTORY?.()[a]?.type??Reflect.getMetadata("design:type",o,a);Reflect.defineMetadata(e,{type:r,required:!1,...i.pickBy(t,i.negate(P))},o,a)}}}function w(e={}){return D(e)}function D(e={},t=!0){const[r,o]=((e,t)=>{if(!e)return[e,t];if(t)return[e,t];const r=i.isArray(e);return[r?e[0]:e,r]})(e.type,e.isArray);if((a=e={...e,type:r,isArray:o}).isArray&&"enum"in a&&void 0!==a.enum){e.type="array";const t=O(e.enum);e.items={type:R(t),enum:t},delete e.enum}else if("enum"in e&&void 0!==e.enum){const t=O(e.enum);e.enum=t,e.type=R(t)}var a;return Array.isArray(e.type)&&(e.type="array",e.items={type:"array",items:{type:e.type[0]}}),v(E.API_MODEL_PROPERTIES,e,t)}function S(e,r){const{handler:o,args:a}=t.Metadata.get(e,c.OperationKeys.REFLECT+c.OperationKeys.BLOCK)||{};return!!o&&(o(...a,r)??!1)}function T(e,r,a){const s={GET:[c.OperationKeys.READ,o.Get],POST:[c.OperationKeys.CREATE,o.Post],PUT:[c.OperationKeys.UPDATE,o.Put],PATCH:[c.OperationKeys.UPDATE,o.Patch],DELETE:[c.OperationKeys.DELETE,o.Delete]},[i,p]=s[r];return S(e,i)?t.apply(n.ApiExcludeEndpoint()):t.apply(p(a))}function C(e=[]){const t=e.map(e=>n.ApiParam({name:e.name,description:e.description??"Path parameter: "+e.name,required:e.required??!0,type:e.type??String}));return o.applyDecorators(...t)}const x=o.createParamDecorator((e,t)=>{const r=t.switchToHttp().getRequest().body,a=t.getClass(),s=a.class;if(!s)throw new o.InternalServerErrorException(`ModelConstructor not found on controller ${a.name}. Ensure the controller was created via FromModelController.`);return r?Array.isArray(r)?r.map(e=>new s(e)):new s(r):r}),M=o.createParamDecorator((e,t)=>{const r=t.switchToHttp().getRequest(),o=r?.params??{},a=e??Object.keys(o),s=a.map(e=>o[e]);return{raw:o,valuesInOrder:s,keysInOrder:a}});function I(e=[]){const t=e.map(e=>e.name);return M(t)}const $=o.createParamDecorator((e,t)=>{const r={...t.switchToHttp().getRequest().query??{}};if(void 0!==r.limit){const e=Number(r.limit);Number.isNaN(e)||(r.limit=e)}if(void 0!==r.offset){const e=Number(r.offset);Number.isNaN(e)||(r.offset=e)}if(void 0!==r.bookmark){const e=Number(r.bookmark);r.bookmark=Number.isNaN(e)?r.bookmark:e}return r});function q(e){const t={GET:o.Get,POST:o.Post,PUT:o.Put,PATCH:o.Patch,DELETE:o.Delete}[e];if(!t)throw Error(`Unsupported HTTP verb "${e}". No NestJS decorator mapping was found.`);return t}const F="DecafModuleOptions",k="DecafAdapter",N="DecafRoute",j=Symbol("DecafHandlers"),L=Symbol("DecafAdapterForOptions"),K=Symbol("AUTH_HANDLER"),B="auth:meta",U=Symbol("decaf:context");function H(t){const r=t?"string"==typeof t?t:t.name:void 0,a=[n.ApiBearerAuth(),o.UseInterceptors(e.AuthInterceptor)];return r&&a.push(o.SetMetadata(B,r)),o.applyDecorators(...a)}e.AuthInterceptor=class{constructor(e,t){this.reflector=e,this.authHandler=t}async intercept(e,t){const r=l.Logging.for(this).for(this.intercept),o=this.reflector.get(B,e.getHandler())??this.reflector.get(B,e.getClass());return r.verbose("Intercepted request"+(o?" for "+o:"")),this.authHandler?await this.authHandler.authorize(e,o):r.debug("No auth handler/model"),t.handle()}},e.AuthInterceptor=p.__decorate([o.Injectable(),p.__param(1,o.Optional()),p.__param(1,o.Inject(K)),p.__metadata("design:paramtypes",[d.Reflector,Object])],e.AuthInterceptor);class G{parseRequest(e){const t=e.headers.authorization?.split(" ")[1];return t}async authorize(e,r){const o=e.switchToHttp().getRequest(),i=this.parseRequest(o);if(!i)throw new s.AuthorizationError("Unauthenticated");if(!t.Metadata.get(a.Model.get(r),s.PersistenceKeys.AUTH_ROLE).includes(i))throw new s.AuthorizationError("Missing role: "+i)}}var z;e.DecafRequestContext=class{constructor(e){this.req=e,this.uuid=s.UUID.instance.generate()}get request(){return this.req}put(e){let t;try{t=this.ctx.get("overrides")}catch(e){t={}}this._ctx=this.ctx.accumulate({overrides:Object.assign(t,e)})}applyCtx(e){if(this._ctx)throw new c.InternalError("Trying to overwrite context");this._ctx=e}get ctx(){if(!this._ctx)throw new c.InternalError("Context not initialized for request");return this._ctx}},e.DecafRequestContext=p.__decorate([o.Injectable({scope:o.Scope.REQUEST}),p.__param(0,o.Inject(d.REQUEST)),p.__metadata("design:paramtypes",[Request])],e.DecafRequestContext),e.DecafHandlerExecutor=z=class{constructor(e,t){this.handlers=e,this.context=t}async exec(e,t){l.Logging.for(z.name).for(this.exec).debug(`CONTEXT ${this.context.uuid} running ${this.handlers.length} handlers for request ${e.method} ${e.url}`);for(const r of this.handlers)await r.handle(this.context,e,t)}},e.DecafHandlerExecutor=z=p.__decorate([o.Injectable({scope:o.Scope.REQUEST}),p.__param(0,o.Inject(j)),p.__metadata("design:paramtypes",[Array,e.DecafRequestContext])],e.DecafHandlerExecutor),e.DecafResponseInterceptor=class{constructor(e){this.ctx=e}intercept(e,t){let r=e.switchToHttp().getResponse();return t.handle().pipe(u.tap(e=>{r=this.ctx.ctx.toResponse(r)}))}},e.DecafResponseInterceptor=p.__decorate([o.Injectable(),p.__metadata("design:paramtypes",[e.DecafRequestContext])],e.DecafResponseInterceptor);const Q=e=>({name:e,description:e+" parameter for the query",required:!0,type:String});function V(e,t,r,a=!1){const i=q(r),c=(e=>e.split("/").filter(e=>e.startsWith(":")).map(e=>e.slice(1)))(t).map(Q),p=[];return"GET"===r&&a&&p.push(n.ApiQuery({name:"direction",required:!1,enum:s.OrderDirection,description:"the sort order when applicable"}),n.ApiQuery({name:"limit",required:!1,description:"limit or page size when applicable"}),n.ApiQuery({name:"offset",required:!1,description:"offset or bookmark when applicable"})),{method:[i(t),...c.map(n.ApiParam),...p,n.ApiOperation({summary:`Retrieve records using according to "${e}".`}),n.ApiOkResponse({description:"Result successfully retrieved."}),n.ApiNoContentResponse({description:"No content returned by the method."})],params:[I(c),o.Query()]}}function Y(e,t,r,o){const a=e?.prototype??e;o.method.forEach(e=>e(a,t,r)),o.params?.forEach((e,r)=>e(a,t,r))}function J(e,t,...r){if(e instanceof s.ModelService)return"function"==typeof e[t]?e[t](...r):e.statement(t,...r);if("function"==typeof e[t])return e[t](...r);throw Error(`Persistence method "${t}" not found on ${e?.constructor?.name}`)}function X(e){return async function(t,r){const o=this.log.for(e);try{o.debug(`Invoking persistence method "${e}" given parameters: ${JSON.stringify(t.valuesInOrder)}`);const{direction:a,limit:s,offset:i}=r;return await J(this.persistence(),e,...t.valuesInOrder,a,s,i)}catch(t){throw o.error(`Custom query "${e}" failed`,t),t}}}function W(e,t,r){return Object.defineProperty(e.prototype||e,t,{value:r,writable:!1}),Object.getOwnPropertyDescriptor(e.prototype||e,t)}class Z extends s.Service{constructor(e,t){super(),this.clientContext=e}logCtx(e,t,r=!1,o){const a=this.clientContext.ctx;let i;e=e.filter(e=>void 0!==e),o&&(o.headers||o.ip)&&(i=o,o={});const n=s.ContextualLoggedClass.logCtx.call(this,t,o||{},r,...e,a);return this.bindLoggerToRequest(n,i)}bindLoggerToRequest(e,t){const r=this;function o(e,t){return e.log=((e,t)=>{const o=(e=>{if(!e)return;const t=e.headers,r=te(t?.["x-forwarded-for"])??te(t?.["x-real-ip"])??te(t?.["X-Forwarded-For"])??te(t?.["X-Real-IP"]);if(r)return r;if("string"==typeof e.ip&&e.ip.length)return e.ip;const o=e.socket||e.connection;return o&&"string"==typeof o.remoteAddress&&o.remoteAddress.length?o.remoteAddress:void 0})(t??r.clientContext.request);if(!o)return e;const a={ip:o};return e.for(a)})(e.log,t),e}return(e=>"object"==typeof e&&null!==e&&"function"==typeof e.then)(e)?e.then(e=>o(e,t)):o(e,t)}}class ee extends Z{persistence(e){if(!this._persistence)try{this._persistence=s.Service.get(this.class)}catch(e){try{this._persistence=s.ModelService.getService(this.class)}catch(e){this._persistence=s.Repository.forModel(this.class)}}const t=this.clientContext.request[L]||{};return e&&this.clientContext.put(t),e?this._persistence instanceof s.Repository?this._persistence.override(t):this._persistence.for(t):this._persistence}constructor(e,t){super(e,t)}logCtx(e,t,r=!1,o){const a=this.clientContext.ctx;let i;o&&(o.headers||o.ip)&&(i=o,o={});try{o=a.get("overrides")}catch(e){}const n=this.persistence(a);let c,p;return n instanceof s.ModelService?c=n.repo._adapter:n instanceof s.Repository?c=n._adapter:n.context&&(c=n),r?c.logCtx(e,t,!0,o).then(e=>this.bindLoggerToRequest(e,i)):(p=c.logCtx(e,t,!1,o),this.bindLoggerToRequest(p,i))}}function te(e){if(e)return(Array.isArray(e)?e[0]:e).split(",").map(e=>e.trim()).filter(Boolean)[0]}const re=new Map;function oe(e,r){if(!s.TransactionOperationKeys.includes(e))return r;const o=(e=>(re.has(e)||re.set(e,new WeakMap),re.get(e)))(e),i=o.get(r);if(i)return i;const n=[c.OperationKeys.UPDATE,c.BulkCrudOperationKeys.UPDATE_ALL].includes(e);class p{}o.set(r,p),Object.defineProperty(p,"name",{value:`${l.toPascalCase(r.name)}${l.toPascalCase(e)}DTO`});const d=(()=>{try{return a.Model.pk(r)}catch{return}})(),u=d?a.Model.pkProps(r):void 0,h=d?Reflect.getMetadata("design:type",r.prototype,d):void 0,m=h===Number||h===BigInt,f=!!u?.generated||!!d&&(a.Model.generatedBySequence(r,d)||ie(r,d)||m),y=Array.from(new Set(t.Metadata.properties(r)||[])),g=new Set(a.Model.relations(r)||[]),_=[];for(const e of y)e&&(g.has(e)||e===d&&!n&&f||e!==d&&ie(r,e)||_.push(e));for(const e of _){const t=ne(r,e),o=!!t?.[a.ValidationKeys.REQUIRED],s=ce(r,e)??Reflect.getMetadata("design:type",r.prototype,e),i={required:o};s&&(i.type=s),w(i)(p.prototype,e);const n=Reflect.getMetadata("design:type",r.prototype,e)??s;void 0!==n&&Reflect.defineMetadata("design:type",n,p.prototype,e),Object.defineProperty(p.prototype,e,{value:void 0,writable:!0,enumerable:!0,configurable:!0})}for(const o of g){const s=t.Metadata.relations(r,o);if(!s)throw new c.InternalError(`Metadata for relation ${o} not found`);let i=s.class;if("function"!=typeof i||i.name||(i=i()),!i||"function"!=typeof i)throw new c.InternalError(`Type for relation ${o} not found`);if(!a.Model.get(i.name))continue;const d=t.Metadata.validationFor(r,o),l=!!d?.[a.ValidationKeys.LIST],u=!!d?.[a.ValidationKeys.REQUIRED],h=oe(e,i);n?se(p,o,i,h,l,u):ae(p,o,h,l,u)}return p}function ae(e,t,r,o,a){w({type:r,required:a,isArray:o})(e.prototype,t),Reflect.defineMetadata("design:type",o?Array:r,e.prototype,t),Object.defineProperty(e.prototype,t,{value:void 0,writable:!0,enumerable:!0,configurable:!0})}function se(e,t,r,o,s,i){const n=Reflect.getMetadata(E.API_EXTRA_MODELS,e)||[];n.includes(o)||Reflect.defineMetadata(E.API_EXTRA_MODELS,[...n,o],e);const c="#/components/schemas/"+o.name,p=(e=>{try{const t=a.Model.pkProps(e),r=t?.type;return r===Number||r===BigInt?"integer":"string"}catch{return"string"}})(r),d=[{$ref:c},{type:p}];w(s?{type:"array",required:i,oneOf:d}:{type:Object,required:i,oneOf:d})(e.prototype,t),Reflect.defineMetadata("design:type",s?Array:Object,e.prototype,t),Object.defineProperty(e.prototype,t,{value:void 0,writable:!0,enumerable:!0,configurable:!0})}function ie(e,t){let r=e;for(;r&&r!==Object&&r!==Function;){if(a.Model.generated(r,t))return!0;r=Object.getPrototypeOf(r)}return!1}function ne(e,r){let o=e;for(;o&&o!==Object&&o!==Function;){const e=t.Metadata.validationFor(o,r);if(e)return e;o=Object.getPrototypeOf(o)}}function ce(e,r){let o=e;for(;o&&o!==Object&&o!==Function;){const e=t.Metadata.type(o,r);if(e)return e;o=Object.getPrototypeOf(o)}}s.Adapter.transformerFor=(e=>{const r="string"==typeof e?e:e.alias;return t.Metadata.innerGet(Symbol.for("transformers"),r)}).bind(s.Adapter),s.Adapter.flavoursToTransform=(()=>{const e=t.Metadata.innerGet(Symbol.for("transformers"));if(e)return Object.keys(e)}).bind(s.Adapter),s.Context.prototype.toResponse=function(e){const t=this.pending();return t&&e.header("x-pending-task",JSON.stringify(t)),e};const pe=a.ModelBuilder.prototype;if(pe.decorateClass||(pe.decorateClass=function(e){return this._classDecorators||(this._classDecorators=[]),this._classDecorators.push(e),this}),pe.Auth=function(e){return this.decorateClass(H(e))},!pe.__hasClassDecoratorSupport){const e=pe.build;pe.build=function(){let t=e.call(this);const r=this._classDecorators;if(r?.length)for(const e of r){const r=e(t);r&&(t=r)}return t},pe.__hasClassDecoratorSupport=!0}class de{static{this.log=l.Logging.for(de.name)}static getPersistence(e){try{return s.Service.get(e)}catch(t){try{return s.ModelService.getService(e)}catch(t){return s.Repository.forModel(e)}}}static createQueryRoutesFromRepository(e,r=s.PersistenceKeys.QUERY){const o=de.log.for(de.createQueryRoutesFromRepository),a=e instanceof s.ModelService?e.repo:e,i=a.class,n=t.Metadata.get(a.constructor,t.Metadata.key(s.PersistenceKeys.QUERY))??{},c=t.Metadata.get(e.constructor,t.Metadata.key(N))??{};class p extends ee{get class(){throw Error("Method not implemented.")}constructor(e,t){super(e,t)}}for(const[e,t]of Object.entries(c)){const r=[t.path.replace(/^\/+|\/+$/g,"")].filter(e=>e&&e.trim()).join("/"),a=X(e);if(!a){const t=`Invalid or missing handler for model ${i.name} on decorated method ${e}`;throw o.error(t),Error(t)}const s=W(p,e,a);s&&Y(p,e,s,V(e,r,t.httpMethod))}for(const[e,t]of Object.entries(n)){const o=[r,e,...(t.fields??[]).map(e=>":"+e)].filter(e=>e&&e.trim()).join("/"),a=W(p,e,X(e));a&&Y(p,e,a,V(e,o,"GET",!0))}return p}static create(t){const r=de.log.for(de.create),i=a.Model.tableName(t),d=l.toKebabCase(i),u=t.name,h=de.getPersistence(t),{description:m,getPK:f,apiProperties:y,path:g}=de.getRouteParametersFromModel(t);r.debug("Creating controller for model: "+u);const _=de.createQueryRoutesFromRepository(h);let A=class extends _{static get class(){return t}get class(){return t}constructor(e){super(e),this.pk=a.Model.pk(t),r.info(`Registering dynamic controller for model: ${this.class.name} route: /${d}`)}async listBy(e,t){const{ctx:r}=(await this.logCtx([],s.PreparedStatementKeys.LIST_BY,!0)).for(this.listBy);return this.persistence(r).listBy(e,t.direction,r)}async paginateBy(e,t){const{ctx:r}=(await this.logCtx([],s.PreparedStatementKeys.PAGE_BY,!0)).for(this.paginateBy);return this.persistence(r).paginateBy(e,t.direction,t,r)}async find(e,t){const{ctx:r}=(await this.logCtx([],s.PreparedStatementKeys.FIND,!0)).for(this.find),o=t.direction??s.OrderDirection.ASC;return J(this.persistence(r),this.find.name,e,o,r)}async page(e,t){const{ctx:r}=(await this.logCtx([],s.PreparedStatementKeys.PAGE,!0)).for(this.page),{direction:o=s.OrderDirection.ASC,limit:a,offset:i,bookmark:n}=t,c={offset:i??1,limit:a??10,bookmark:n};return J(this.persistence(r),this.page.name,e,o,c,r)}async findOneBy(e,t){const{ctx:r}=(await this.logCtx([],s.PreparedStatementKeys.FIND_ONE_BY,!0)).for(this.findOneBy);return this.persistence(r).findOneBy(e,t,r)}async findBy(e,t,r){const{ctx:o}=(await this.logCtx([],s.PreparedStatementKeys.FIND_BY,!0)).for(this.findBy);return this.persistence(o).for(o.toOverrides()).findBy(e,t,o)}async statement(e,t,r){const{ctx:o}=(await this.logCtx([],s.PersistenceKeys.STATEMENT,!0)).for(this.statement),{direction:a,offset:i,limit:n,bookmark:c}=r,p=(t=t.map(e=>("string"==typeof e?parseInt(e):e)||e)).length>1?t[1]:void 0,d=a??p;switch(d&&t.length>1&&(t[1]=d),e){case s.PreparedStatementKeys.FIND:case s.PreparedStatementKeys.FIND_BY:break;case s.PreparedStatementKeys.LIST_BY:t.push(a);break;case s.PreparedStatementKeys.PAGE:case s.PreparedStatementKeys.PAGE_BY:t=[t[0],d,{limit:n,offset:i,bookmark:c}];case s.PreparedStatementKeys.FIND_ONE_BY:case s.PreparedStatementKeys.COUNT_OF:case s.PreparedStatementKeys.MAX_OF:case s.PreparedStatementKeys.MIN_OF:case s.PreparedStatementKeys.AVG_OF:case s.PreparedStatementKeys.SUM_OF:case s.PreparedStatementKeys.DISTINCT_OF:case s.PreparedStatementKeys.GROUP_OF:}return this.persistence(o).statement(e,...t,o)}async createAll(e,r){const{ctx:o,log:a}=(await this.logCtx([],c.BulkCrudOperationKeys.CREATE_ALL,!0)).for(this.createAll);let s;a.verbose("creating new "+u);try{s=await this.persistence(o).createAll(e.map(e=>new t(e)),o)}catch(e){throw a.error("Failed to create new "+u,e),e}return a.info(`created new ${u} with id ${s[this.pk]}`),o.toResponse(r),s}async create(e,t){const{ctx:r,log:o}=(await this.logCtx([],c.OperationKeys.CREATE,!0)).for(this.create);let a;o.verbose("creating new "+u);try{const t=this.persistence(r);a=await t.create(e,r)}catch(e){throw o.error("Failed to create new "+u,e),e}return o.info(`created new ${u} with id ${a[this.pk]}`),r.toResponse(t),a}async readAll(e){const{ctx:t,log:r}=(await this.logCtx([],c.BulkCrudOperationKeys.READ_ALL,!0)).for(this.readAll);let o;try{r.debug(`reading ${e.length} ${u}: ${e}`);const a=this.persistence(t);o=await a.readAll(e,t)}catch(t){throw r.error(`Failed to ${u} with id ${e}`,t),t}return r.info(`read ${o.length} ${u}`),o}async read(e){const{ctx:t,log:r}=(await this.logCtx([],c.OperationKeys.READ,!0)).for(this.read),o=f(...e.valuesInOrder);if(void 0===o)throw new c.ValidationError(`No ${this.pk} provided`);let a;try{r.debug(`reading ${u} with ${this.pk} ${o}`);const e=this.persistence(t);a=await e.read(o,t)}catch(e){throw r.error(`Failed to read ${u} with id ${o}`,e),e}return r.info(`read ${u} with id ${a[this.pk]}`),a}async updateAll(e,t){const{ctx:r,log:o}=(await this.logCtx([],c.BulkCrudOperationKeys.UPDATE_ALL,!0)).for(this.updateAll);let a;try{o.info(`updating ${e.length} ${u}`),a=await this.persistence(r).updateAll(e,r)}catch(e){throw o.error(e),e}return r.toResponse(t),a}async update(e,r,o){const{ctx:a,log:s}=(await this.logCtx([],c.OperationKeys.UPDATE,!0)).for(this.update),i=f(...e.valuesInOrder);if(void 0===i)throw new c.ValidationError(`No ${this.pk} provided`);let n;try{s.info(`updating ${u} with ${this.pk} ${i}`);const e=JSON.parse(JSON.stringify(r)),o=this.persistence(a);n=await o.update(new t({...e,[this.pk]:i}),a)}catch(e){throw s.error(e),e}return a.toResponse(o),n}async deleteAll(e,t){const{ctx:r,log:o}=(await this.logCtx([],c.BulkCrudOperationKeys.DELETE_ALL,!0)).for(this.deleteAll);let a;try{o.debug(`deleting ${e.length} ${u}: ${e}`),a=await this.persistence(r).deleteAll(e,r)}catch(t){throw o.error(`Failed to delete ${u} with id ${e}`,t),t}return o.info(`deleted ${a.length} ${u}`),r.toResponse(t),a}async delete(e,t){const{ctx:r,log:o}=(await this.logCtx([],c.OperationKeys.DELETE,!0)).for(this.delete),a=f(...e.valuesInOrder);if(void 0===a)throw new c.ValidationError(`No ${this.pk} provided`);let s;try{o.debug(`deleting ${u} with ${this.pk} ${a}`),s=await this.persistence(r).delete(a,r)}catch(e){throw o.error(`Failed to delete ${u} with id ${a}`,e),e}return o.info(`deleted ${u} with id ${a}`),r.toResponse(t),s}};return p.__decorate([T(t,"GET","listBy/:key"),n.ApiOperation({summary:`Retrieve ${u} records by query.`}),n.ApiParam({name:"key",description:"the model key to sort by"}),n.ApiQuery({name:"direction",required:!0,enum:s.OrderDirection}),n.ApiOkResponse({description:u+" listed successfully."}),p.__param(0,o.Param("key")),p.__param(1,$()),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"listBy",null),p.__decorate([T(t,"GET","paginateBy/:key/:page"),n.ApiOperation({summary:`Retrieve ${u} records by query.`}),n.ApiParam({name:"key",description:"the model key to sort by"}),n.ApiParam({name:"page",description:"the page to retrieve or the bookmark"}),n.ApiQuery({name:"direction",required:!0,enum:s.OrderDirection,description:"the sort order"}),n.ApiQuery({name:"limit",required:!0,description:"the page size"}),n.ApiQuery({name:"offset",description:"the bookmark when necessary"}),n.ApiOkResponse({description:u+" listed paginated."}),p.__param(0,o.Param("key")),p.__param(1,$()),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"paginateBy",null),p.__decorate([T(t,"GET","find/:value"),n.ApiOperation({summary:`Find ${u} records using the default query attributes.`}),n.ApiParam({name:"value",description:"The string to match against the default query attributes"}),n.ApiQuery({name:"direction",required:!1,enum:s.OrderDirection,description:"the sort order for the matching results"}),n.ApiOkResponse({description:u+" records matching the provided prefix."}),p.__param(0,o.Param("value")),p.__param(1,$()),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"find",null),p.__decorate([T(t,"GET","page/:value"),n.ApiOperation({summary:`Page ${u} records using the default query attributes.`}),n.ApiParam({name:"value",description:"The string to match against the default query attributes"}),n.ApiQuery({name:"direction",required:!1,enum:s.OrderDirection,description:"the sort order for the paged results"}),n.ApiQuery({name:"limit",required:!1,description:"page size"}),n.ApiQuery({name:"offset",required:!1,description:"page number"}),n.ApiQuery({name:"bookmark",required:!1,description:"bookmark for cursor pagination"}),n.ApiOkResponse({description:u+" records paged by the provided prefix."}),p.__param(0,o.Param("value")),p.__param(1,$()),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"page",null),p.__decorate([T(t,"GET","findOneBy/:key"),n.ApiOperation({summary:`Retrieve ${u} records by query.`}),n.ApiParam({name:"key",description:"the model key to sort by"}),n.ApiOkResponse({description:u+" listed found."}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),p.__param(0,o.Param("key")),p.__param(1,o.Param("value")),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"findOneBy",null),p.__decorate([T(t,"GET","findBy/:key/:value"),n.ApiOperation({summary:`Retrieve ${u} records by query.`}),n.ApiParam({name:"key",description:"the model key to compare"}),n.ApiParam({name:"value",description:"the value to match"}),n.ApiQuery({name:"direction",required:!0,enum:s.OrderDirection,description:"the sort order when applicable"}),n.ApiOkResponse({description:u+" listed found."}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),p.__param(0,o.Param("key")),p.__param(1,o.Param("value")),p.__param(2,$()),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String,Object,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"findBy",null),p.__decorate([T(t,"GET","statement/:method/*args"),n.ApiOperation({summary:`Executes a prepared statement on ${u}.`}),n.ApiParam({name:"method",description:"the prepared statement to execute"}),n.ApiParam({name:"args",description:"concatenated list of arguments the prepared statement can accept"}),n.ApiQuery({name:"direction",required:!0,enum:s.OrderDirection,description:"the sort order when applicable"}),n.ApiQuery({name:"limit",required:!0,description:"limit or page size when applicable"}),n.ApiQuery({name:"offset",required:!0,description:"offset or bookmark when applicable"}),n.ApiOkResponse({description:u+" listed found."}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),p.__param(0,o.Param("method")),p.__param(1,o.Param("args")),p.__param(2,$()),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String,Array,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"statement",null),p.__decorate([T(t,"POST","bulk"),n.ApiOperation({summary:`Create a new ${u}.`}),n.ApiBody({description:"Payload for "+u,schema:{type:"array",items:{$ref:n.getSchemaPath(t)}}}),n.ApiCreatedResponse({description:u+" created successfully.",schema:{type:"array",items:{$ref:n.getSchemaPath(t)}}}),n.ApiBadRequestResponse({description:"Payload validation failed."}),n.ApiUnprocessableEntityResponse({description:"Repository rejected the provided payload."}),p.__param(0,x()),p.__param(1,o.Response({passthrough:!0})),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Array,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"createAll",null),p.__decorate([T(t,"POST"),n.ApiOperation({summary:`Create a new ${u}.`}),n.ApiBody({description:"Payload for "+u,type:oe(c.OperationKeys.CREATE,t)}),n.ApiCreatedResponse({description:u+" created successfully.",schema:{$ref:n.getSchemaPath(t)}}),n.ApiBadRequestResponse({description:"Payload validation failed."}),n.ApiUnprocessableEntityResponse({description:"Repository rejected the provided payload."}),p.__param(0,x()),p.__param(1,o.Response({passthrough:!0})),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Object,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"create",null),p.__decorate([T(t,"GET","bulk"),n.ApiOperation({summary:`Retrieve a ${u} record by id.`}),n.ApiQuery({name:"ids",required:!0,type:"array"}),n.ApiOkResponse({description:u+" retrieved successfully.",schema:{type:"array",items:{$ref:n.getSchemaPath(t)}}}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),p.__param(0,o.Query("ids")),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Array]),p.__metadata("design:returntype",Promise)],A.prototype,"readAll",null),p.__decorate([T(t,"GET",g),C(y),n.ApiOperation({summary:`Retrieve a ${u} record by id.`}),n.ApiOkResponse({description:u+" retrieved successfully.",schema:{$ref:n.getSchemaPath(t)}}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),p.__param(0,I(y)),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Object]),p.__metadata("design:returntype",Promise)],A.prototype,"read",null),p.__decorate([T(t,"PUT","bulk"),C(y),n.ApiOperation({summary:`Replace an existing ${u} record with a new payload.`}),n.ApiBody({description:"Payload for replace a existing record of "+u,schema:{type:"array",$ref:n.getSchemaPath(oe(c.OperationKeys.UPDATE,t))}}),n.ApiOkResponse({description:u+" updated successfully.",schema:{type:"array",items:{$ref:n.getSchemaPath(t)}}}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),n.ApiBadRequestResponse({description:"Payload validation failed."}),p.__param(0,x()),p.__param(1,o.Response({passthrough:!0})),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Array,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"updateAll",null),p.__decorate([T(t,"PUT",g),C(y),n.ApiOperation({summary:`Replace an existing ${u} record with a new payload.`}),n.ApiBody({description:"Payload for replace a existing record of "+u,type:oe(c.OperationKeys.UPDATE,t)}),n.ApiOkResponse({description:u+" updated successfully.",schema:{$ref:n.getSchemaPath(t)}}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),n.ApiBadRequestResponse({description:"Payload validation failed."}),p.__param(0,I(y)),p.__param(1,x()),p.__param(2,o.Response({passthrough:!0})),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Object,Object,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"update",null),p.__decorate([T(t,"DELETE","bulk"),C(y),n.ApiOperation({summary:`Retrieve a ${u} record by id.`}),n.ApiQuery({name:"ids",required:!0,type:"array"}),n.ApiOkResponse({description:u+" deleted successfully.",schema:{type:"array",items:{$ref:n.getSchemaPath(t)}}}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),p.__param(0,o.Query("ids")),p.__param(1,o.Response({passthrough:!0})),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Array,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"deleteAll",null),p.__decorate([T(t,"DELETE",g),C(y),n.ApiOperation({summary:`Delete a ${u} record by id.`}),n.ApiOkResponse({description:u+" deleted successfully.",schema:{$ref:n.getSchemaPath(t)}}),n.ApiNotFoundResponse({description:`No ${u} record matches the provided identifier.`}),p.__param(0,I(y)),p.__param(1,o.Response({passthrough:!0})),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[Object,Object]),p.__metadata("design:returntype",Promise)],A.prototype,"delete",null),A=p.__decorate([o.Controller(d),n.ApiTags(u),n.ApiExtraModels(t),H(t),p.__metadata("design:paramtypes",[e.DecafRequestContext])],A),A}static getRouteParametersFromModel(e){const r=a.Model.pk(e),o=t.Metadata.get(e,t.Metadata.key(c.DBKeys.COMPOSED,r)),s=o?.args??[],i=Array.isArray(s)&&s.length>0?Array.from(new Set([...s])):Array.from(new Set([r])),n=t.Metadata.description(e);return{path:":"+i.join("/:"),description:n,apiProperties:i.map(r=>({name:r,description:t.Metadata.description(e,r),required:!0,type:String})),getPK:(...e)=>o?.separator?e.join(o.separator):e.join("")}}}function le(e){var t;let r=class{static{t=this}static{this.log=l.Logging.for(t.name).for(e)}static createModelServices(e){return e.map(e=>({provide:e.name+"Service",useFactory:()=>s.ModelService.forModel(e)}))}static forRoot(e,r={}){const o=this.log.for(this.forRoot);o.info("Generating controllers for flavour...");const a=s.Adapter.models(e);let i=[];r.autoServices&&(o.info("Auto-services enabled. Initializing service generation."),i=this.createModelServices(a),o.info(`Auto-services completed. ${i.length} services initialized.`));const n=a.map(de.create);return o.info(`Generated ${n.length} controllers`),{module:t,controllers:n,providers:[...i]}}};return r=t=p.__decorate([o.Module({})],r),Object.assign(r,"name",{value:"DecafModule"+e}),r}t.Decoration.for(r.InjectablesKeys.INJECTABLE).extend({decorator:(e,t)=>(t=t||("object"==typeof e?Object.assign(e,r.DefaultInjectablesConfig):r.DefaultInjectablesConfig),o.Injectable({scope:t.singleton?o.Scope.DEFAULT:o.Scope.REQUEST,durable:!t.singleton||void 0}))}).apply(),t.Decoration.for(r.InjectablesKeys.INJECT).extend({decorator:(e,t)=>(t,r,a)=>o.Inject(e||t)(t,r,a)}).apply(),t.Decoration.for(a.ValidationKeys.REQUIRED).extend(w({required:!0})).apply(),t.Decoration.for(a.ValidationKeys.MAX).extend({decorator:e=>w({maximum:e,required:!1})}).apply(),t.Decoration.for(a.ValidationKeys.MIN).extend({decorator:e=>w({minimum:e,required:!1})}).apply(),t.Decoration.for(a.ValidationKeys.MAX_LENGTH).extend({decorator:e=>w({maxLength:e,required:!1})}).apply(),t.Decoration.for(a.ValidationKeys.MIN_LENGTH).extend({decorator:e=>w({minLength:e,required:!1})}).apply(),t.Decoration.for(a.ValidationKeys.TYPE).extend({decorator:e=>(t,r)=>("function"!=typeof(e=Array.isArray(e)?e[0]:e)||e.name||(e=e()),w({type:e,required:!1})(t,r))}).apply(),t.Decoration.for(a.ValidationKeys.DATE).extend({decorator:e=>w({type:String,format:"date-time",required:!1})}).apply(),t.Decoration.for(a.ValidationKeys.ENUM).extend({decorator:e=>w({enum:Array.isArray(e)?e:Object.values(e),required:!1})}).apply(),t.Decoration.for(a.ValidationKeys.PATTERN).extend({decorator:e=>w({pattern:"string"==typeof e?e:e.source,required:!1})}).apply(),t.Decoration.for(s.PersistenceKeys.COLUMN).extend({decorator:e=>w({name:e,required:!1})}).apply(),t.Decoration.for(t.DecorationKeys.DESCRIPTION).extend({decorator:e=>w({description:e,required:!1})}).apply(),t.Decoration.for(s.PersistenceKeys.AUTH).extend({decorator:H}).apply();class ue extends s.ForbiddenError{constructor(e){super(e,ue.name)}}class he extends c.BaseError{constructor(e){super(he.name,e,429)}}e.DecafExceptionFilter=class{catch(e,t){const r=t.switchToHttp(),a=r.getResponse(),i=r.getRequest(),n="production"===l.LoggedEnvironment.env;let p;e instanceof o.NotFoundException||e instanceof s.UnsupportedError?p=(e=new o.NotAcceptableException(e.message)).getStatus():e instanceof c.BaseError||(e=429===e.status?new he(e.message):new c.InternalError(e.message)),a.status(e.code||p).json({status:e.code||p,error:n?e.name:e.message,timestamp:(new Date).toISOString(),path:i.url,method:i.method})}},e.DecafExceptionFilter=p.__decorate([o.Catch()],e.DecafExceptionFilter);const me={path:"docs",auth:{type:"http",scheme:"bearer",bearerFormat:"JWT",name:"Authorization",description:"Enter JWT token",in:"header"},topbarBgColor:"#000000"};class fe{constructor(e){this.options={...e}}customCSS(){let e="";return this.options.topbarIconPath&&(e+=`.topbar-wrapper { content: url('data:image/png;base64,${this.b64(this.options.topbarIconPath)}'); width: 200px; height: auto; }\n`),e+`\n .topbar-wrapper svg { visibility: hidden; }\n .swagger-ui .topbar { background-color: ${this.options.topbarBgColor||me.topbarBgColor}; }\n `}getCustomOptions(){const e={};return this.options.faviconPath&&(e.customfavIcon=this.b64(this.options.faviconPath,!0)),{customSiteTitle:this.options.title,...e,customCss:this.customCSS(),swaggerOptions:{persistAuthorization:this.options.persistAuthorization}}}b64(e,t=!1){const r=A.join(this.options.assetsPath||"",e),o=h.readFileSync(r,{encoding:"base64"});return t?"data:image/png;base64,"+o:o}}class ye{constructor(e,t){this.app=e,this.options=t}createDocument(){const e=this.options.path?this.options.description+""+`<br><br><a href="${this.options.openApiJsonPath}">OpenAPI JSON Spec</a> | `+`<a href="${this.options.openApiYamlPath}">OpenAPI YAML Spec</a>`:this.options.description,t=(new n.DocumentBuilder).setTitle(this.options.title).setDescription(e).setVersion(this.options.version||"0.0.1").addBearerAuth(this.options.auth||me.auth).build();return n.SwaggerModule.createDocument(this.app,t,{extraModels:this.options.extraModels||[]})}registerOpenApiRoute(e,t,r){if(!e)return;const o=this.app.getHttpAdapter();e=e.startsWith("/")?e:"/"+e,o.get(e,(e,a)=>{o.reply(a,r(),200,{"Content-Type":t})})}setupSwagger(){const e=this.createDocument(),t=new fe({title:this.options.title,path:this.options.path||me.path,persistAuthorization:this.options.persistAuthorization??!0,assetsPath:this.options.assetsPath,faviconPath:this.options.faviconFilePath,topbarIconPath:this.options.topbarIconFilePath,topbarBgColor:this.options.topbarBgColor});n.SwaggerModule.setup(this.options.path||me.path,this.app,e,{...t.getCustomOptions(),jsonDocumentUrl:this.options.openApiJsonPath?""+this.options.openApiJsonPath:void 0,yamlDocumentUrl:this.options.openApiYamlPath?""+this.options.openApiYamlPath:void 0}),this.registerOpenApiRoute(this.options.openApiJsonPath,"application/json",()=>e),this.registerOpenApiRoute(this.options.openApiYamlPath,"application/x-yaml",()=>f.stringify(e))}}var ge,_e;function Ae(e){return r=>(t.Metadata.set("transformers",e,r),"function"==typeof r?t.metadata("transformers",e)(r):r)}e.DecafRequestHandlerInterceptor=ge=class{constructor(e,t){this.requestContext=e,this.executor=t}async contextualize(e){const t={headers:e.headers,overrides:{}},r=s.Adapter.flavoursToTransform();if(r)for(const o of r)try{const r=s.Adapter.transformerFor(o),a=await r.from(e);Object.assign(t.overrides,a)}catch(e){throw new c.InternalError("Failed to contextualize request: "+e)}return(new s.Context).accumulate(Object.assign({},s.DefaultAdapterFlags,{logger:l.Logging.get(),timestamp:new Date},t))}async intercept(e,t){const r=e.switchToHttp().getRequest(),o=e.switchToHttp().getResponse(),a=l.Logging.for(ge).for(this.intercept);a.debug(`CONTEXT ${this.requestContext.uuid} - request: ${r.method} ${r.url}`);const s=await this.contextualize(r);return a.debug(`CONTEXT ${this.requestContext.uuid} contextualized - request: ${r.method} ${r.url}`),this.requestContext.applyCtx(s),a.debug(`CONTEXT ${this.requestContext.uuid} applied - request: ${r.method} ${r.url}`),await this.executor.exec(r,o),a.debug(`CONTEXT ${this.requestContext.uuid} executors finished - request: ${r.method} ${r.url}`),t.handle()}},e.DecafRequestHandlerInterceptor=ge=p.__decorate([o.Injectable({scope:o.Scope.REQUEST}),p.__metadata("design:paramtypes",[e.DecafRequestContext,e.DecafHandlerExecutor])],e.DecafRequestHandlerInterceptor),e.DecafCoreModule=class{static{_e=this}static get persistence(){if(!this._persistence)throw new c.InternalError("Persistence service not initialized");return this._persistence}static get log(){return this._logger||(this._logger=l.Logging.for(_e)),this._logger}constructor(e,t){this.options=e,this.moduleRef=t}static forRoot(t){const r=this.log.for(this.forRoot);return{module:_e,providers:[{provide:F,useValue:t},{provide:k,useValue:this.persistence?.client},{provide:j,useFactory:()=>t.handlers?.map(e=>(r.info("Registered request handler: "+e.name),new e))??[]},e.AuthInterceptor,{provide:d.APP_INTERCEPTOR,useExisting:e.AuthInterceptor},e.DecafRequestContext,e.DecafHandlerExecutor,{provide:d.APP_INTERCEPTOR,useClass:e.DecafRequestHandlerInterceptor}],exports:[F,k,j,e.DecafRequestContext,e.DecafHandlerExecutor]}}static async bootPersistence(e){const t=this.log.for(this.bootPersistence);if(!this._persistence){const r=e.conf.map(([e,t,...r])=>r.pop()?[e,t,...r]:[e,t]);this._persistence=new s.PersistenceService,await this._persistence.boot(r);const o=this._persistence.client;for(let t=0;t<o.length;t++){const r=e.conf[t];let a=r.slice(2,r.length).pop();if(!a||!a.from){const e=s.Adapter.transformerFor(o[t].flavour);if(!e)throw new c.InternalError(`No transformer found for flavour ${o[t].flavour}. you should either @requestToContextTransformer or provide a transformer in the config`);try{a=e.from?e:new e}catch(e){throw new c.InternalError(`Failed to boot transformer for ${o[t].flavour}: ${e}`)}}Ae(o[t].flavour)(a)}if(t.info("persistence layer created successfully!"),e.initialization)try{await e.initialization()}catch(e){throw new c.InternalError("Failed to initialize application: "+e)}}return this.persistence.client}async onApplicationShutdown(){const e=_e.log.for(this.onApplicationShutdown),t=this.moduleRef.get(k);for(const r of t)try{r&&(e.info("Shutting down "+r.toString()),await r.shutdown())}catch(t){e.error("Failed to shutdown application",t)}try{await s.Service.shutdown()}catch(t){e.error("Failed to shutdown services",t)}}},e.DecafCoreModule=_e=p.__decorate([o.Global(),o.Module({}),p.__param(0,o.Inject(F)),p.__metadata("design:paramtypes",[Object,d.ModuleRef])],e.DecafCoreModule);const be=Symbol("LISTENING_ADAPTERS_FLAVOURS");var Ee,Pe,Oe,Re;e.EventsController=Ee=class extends Z{constructor(e,t){super(e,Ee.name),this.adapters=t.map(e=>s.Adapter.get(e))}listen(){const e=l.Logging.for(Ee.name),t=new u.Observable(t=>{const r=("B-"+Math.random().toString(36).slice(2,8)).toUpperCase();e.info(`Creating SSE observer: ${r} for client ${this.clientContext.uuid}`);const o=new class{constructor(){this.observerId=r}refresh(...r){return e.debug(`SSE observer ${this.observerId} received refresh event`),Promise.resolve().then(()=>{const o=(e=>{const[t,r,o,a]=e;return[t?.name??t,r,o,Array.isArray(a)?a.map(e=>{try{return"function"==typeof e.serialize?e.serialize():"string"==typeof e?e:JSON.stringify(e)}catch(e){return}}):a&&"function"==typeof a.serialize?a.serialize():"string"==typeof a?a:JSON.stringify(a)]})(r);t.next({type:"message",data:o}),e.debug(`SSE observer ${this.observerId} event pushed to client`)})}};e.verbose(`Registering observer ${r} across ${this.adapters.length} adapter(s)`);for(const t of this.adapters){const a=t?.constructor?.name??"UnknownAdapter";try{e.debug(`Registering observer ${r} in adapter ${a}`),t.observe(o)}catch(t){e.debug(`Failed to register observer ${r} in adapter ${a}: ${t?.message||t}`),e.error(t)}}return()=>{e.debug("Cleaning up SSE observer "+r);for(const t of this.adapters){const a=t?.constructor?.name??"UnknownAdapter";try{e.debug(`Unregistering observer ${r} from adapter ${a}`),t.unObserve(o)}catch(t){e.debug(`Failed during cleanup of observer ${r} in adapter ${a}: ${t?.message||t}`),e.error(t)}}}}),r=u.interval(15e3).pipe(y.tap(()=>{e.debug("Sending heartbeat")}),y.map(()=>({type:"heartbeat",data:{ts:(new Date).toISOString()}})));return u.merge(t,r)}listenForModel(e){const t=l.Logging.for(Ee.name);return new u.Observable(e=>{const r=new class{refresh(...t){return Promise.resolve().then(()=>{e.next({data:t})})}};try{for(const e of this.adapters)e.observe(r)}catch(t){e.error("Failed to observe event: "+(t.message||t))}return()=>{try{for(const e of this.adapters)e.unObserve(r)}catch(e){t.error(e)}}})}},p.__decorate([o.Sse(),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[]),p.__metadata("design:returntype",u.Observable)],e.EventsController.prototype,"listen",null),p.__decorate([o.Sse("/:model"),p.__param(0,o.Query("model")),p.__metadata("design:type",Function),p.__metadata("design:paramtypes",[String]),p.__metadata("design:returntype",u.Observable)],e.EventsController.prototype,"listenForModel",null),e.EventsController=Ee=p.__decorate([o.Controller(),p.__param(1,o.Inject(be)),p.__metadata("design:paramtypes",[e.DecafRequestContext,Array])],e.EventsController),e.DecafStreamModule=Pe=class{static forFlavours(t,r="events"){return{module:Pe,controllers:[e.EventsController],imports:[d.RouterModule.register([{path:r.replace(/^\//,""),module:Pe}])],providers:[e.DecafRequestContext,{provide:be,useValue:t??[]}]}}},e.DecafStreamModule=Pe=p.__decorate([o.Module({})],e.DecafStreamModule),e.DecafModule=Oe=class{static async forRootAsync(t){const{autoControllers:r,autoServices:o}=t,a=(await e.DecafCoreModule.bootPersistence(t)).map(e=>e.flavour),s=[e.DecafCoreModule.forRoot(t)];return r&&a.forEach(e=>{s.push(le(e).forRoot(e,{autoServices:o}))}),t.observerOptions?.enableObserverEvents&&s.push(e.DecafStreamModule.forFlavours(t.observerOptions.observerFlavours||a)),{module:Oe,imports:s}}},e.DecafModule=Oe=p.__decorate([o.Module({})],e.DecafModule);const ve=l.Logging.for("DecafMigrationModule");e.DecafMigrationModule=Re=class{static forRoot(){return{module:Re}}static async migrate(e,t){const r=ve.for(this.migrate);if(!t||0===t.length)throw new c.InternalError("No adapters provided. Make sure DecafCoreModule is configured and adapters are available.");return r.info("Running migrations with config: "+JSON.stringify(e)),g.MigrationService.migrateAdapters(t,e||{})}},e.DecafMigrationModule=Re=p.__decorate([o.Global(),o.Module({providers:[{provide:"MIGRATION_ADAPTERS",useFactory:e=>e,inject:[k]}],exports:["MIGRATION_ADAPTERS"]})],e.DecafMigrationModule);const we="##VERSION##",De="##PACKAGE##";t.Metadata.allowReregistration(!0),t.Metadata.registerLibrary(De,we),t.Metadata.allowReregistration(!1),e.AUTH_HANDLER=K,e.AUTH_META_KEY=B,e.ApiOperationFromModel=T,e.ApiParamsFromModel=C,e.ApiProperty=w,e.Auth=H,e.BulkApiOperationFromModel=(e,r,a)=>{const s={GET:[c.BulkCrudOperationKeys.READ_ALL,o.Get],POST:[c.BulkCrudOperationKeys.CREATE_ALL,o.Post],PUT:[c.BulkCrudOperationKeys.UPDATE_ALL,o.Put],PATCH:[c.BulkCrudOperationKeys.UPDATE_ALL,o.Patch],DELETE:[c.BulkCrudOperationKeys.DELETE_ALL,o.Delete]},[i,p]=s[r];return S(e,i)?t.apply(n.ApiExcludeEndpoint()):t.apply(p(a))},e.COMMIT="2609028",e.CorsError=ue,e.DECAF_ADAPTER_ID=k,e.DECAF_ADAPTER_OPTIONS=L,e.DECAF_CONTEXT_KEY=U,e.DECAF_HANDLERS=j,e.DECAF_MODULE_OPTIONS=F,e.DECAF_ROUTE=N,e.DECAF_TASK_SERVICE_ID="DecafTaskService",e.DECORATORS=E,e.DECORATORS_PREFIX=b,e.DecafAuthHandler=G,e.DecafBody=x,e.DecafController=Z,e.DecafModelController=ee,e.DecafParams=I,e.DecafQuery=$,e.DecafRoleAuthHandler=class extends G{constructor(){super()}async authorize(e,r){const o=e.switchToHttp().getRequest(),i=this.parseRequest(o);if(!i)throw new s.AuthorizationError("Unauthenticated");const n=t.Metadata.get(a.Model.get(r),s.PersistenceKeys.AUTH_ROLE);if(!n.includes(i))throw new s.AuthorizationError("Missing role: "+i);return n}},e.DtoFor=oe,e.FULL_VERSION="0.10.1-2609028",e.FromModelController=de,e.HttpVerbToDecorator=q,e.NestBootstraper=class{static get logger(){return this._logger||(this._logger=new o.Logger("NestBootstrap")),this._logger}static initialize(e){return this.app=e,this}static enableLogger(e){return this._logger=e||new o.Logger("NestBootstrap"),this.app.useLogger(this._logger),this}static enableCors(e=[],t=["GET","POST","PUT","DELETE"]){const r="*"===e?"*":e.map(e=>e.trim().toLowerCase()),o={origin:(e,t)=>e?"*"===r||Array.isArray(r)&&r.includes(e.toLowerCase())?t(null,!0):void t(new ue(`Origin ${e} not allowed`)):t(null,!0),credentials:!0,methods:t.join(",")};return this.app.enableCors(o),this}static useHelmet(e){try{const t=require("helmet");this.app.use(t(e)),this.logger.log("Helmet middleware enabled successfully.")}catch(e){this.logger.warn("Helmet not installed. Skipping middleware.")}return this}static setupSwagger(e){return new ye(this.app,{title:e.title,description:e.description,version:e.version,path:e.path||"api",persistAuthorization:e.persistAuthorization??!0,assetsPath:e.assetsPath,faviconFilePath:e.faviconPath,topbarIconFilePath:e.topbarIconPath,topbarBgColor:e.topbarBgColor,openApiJsonPath:e.openApiJsonPath,openApiYamlPath:e.openApiYamlPath}).setupSwagger(),this}static useGlobalPipes(...e){return e.length>0&&this.app.useGlobalPipes(...e),this}static useGlobalFilters(...t){return this.app.useGlobalFilters(...t.length>0?t:[new e.DecafExceptionFilter]),this}static useGlobalInterceptors(...e){return e.length>0&&this.app.useGlobalInterceptors(...e),this}static async start(e=Number(process.env.PORT)||3e3,t=void 0,r=!0){this.app.listen(e,t).then(async()=>{if(r){const e=await this.app.getUrl();this.logger.log("\ud83d\ude80 Application is running at: "+e)}})}},e.PACKAGE_NAME=De,e.RequestToContextTransformer=class{},e.SwaggerBuilder=ye,e.UseDecafFilter=()=>o.UseFilters(new e.DecafExceptionFilter),e.UseDecafHeaders=()=>o.UseInterceptors(e.DecafResponseInterceptor),e.VERSION=we,e.createApiPropertyDecorator=D,e.createPropertyDecorator=v,e.getEnumType=R,e.getEnumValues=O,e.getModuleFor=le,e.isOperationBlocked=S,e.isUndefined=P,e.repoForModel=e=>{const t=a.Model.get(e);if(!t)throw new c.InternalError("Failed to find repository for "+e);return s.Repository.forModel(t)},e.requestToContextTransformer=Ae,e.runMigrations=async()=>{}},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@decaf-ts/decoration"),require("@decaf-ts/injectable-decorators"),require("@nestjs/common"),require("@decaf-ts/decorator-validation"),require("@decaf-ts/core"),require("lodash"),require("@nestjs/swagger"),require("@decaf-ts/db-decorators"),require("tslib"),require("@nestjs/core"),require("@decaf-ts/logging"),require("rxjs"),require("fs"),require("path"),require("yaml"),require("rxjs/operators"),require("@decaf-ts/core/migrations")):"function"==typeof define&&define.amd?define(["exports","@decaf-ts/decoration","@decaf-ts/injectable-decorators","@nestjs/common","@decaf-ts/decorator-validation","@decaf-ts/core","lodash","@nestjs/swagger","@decaf-ts/db-decorators","tslib","@nestjs/core","@decaf-ts/logging","rxjs","fs","path","yaml","rxjs/operators","@decaf-ts/core/migrations"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["for-nest"]={},e.decafTsDecoration,e.decafTsInjectableDecorators,e.nestjsCommon,e.decafTsDecoratorValidation,e.decafTsCore,e.lodash,e.nestjsSwagger,e.decafTsDbDecorators,e.tslib,e.nestjsCore,e.decafTsLogging,e.rxjs,e.fs,e.path,e.yaml,e.operators,e.migrations);
2
2
  //# sourceMappingURL=for-nest.cjs.map
@@ -36,9 +36,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.migrateCommand = void 0;
39
40
  exports.resolveInputPath = resolveInputPath;
40
41
  exports.buildOutputFilePath = buildOutputFilePath;
41
42
  exports.resolveMigrateCommandConfig = resolveMigrateCommandConfig;
43
+ exports.buildFileVersionHandlers = buildFileVersionHandlers;
42
44
  exports.default = nest;
43
45
  const logging_1 = require("@decaf-ts/logging");
44
46
  const logger = logging_1.Logging.for("for-nest");
@@ -46,6 +48,7 @@ const commander_1 = require("commander");
46
48
  const fs_1 = __importDefault(require("fs"));
47
49
  const path_1 = __importDefault(require("path"));
48
50
  const core_1 = require("@decaf-ts/core");
51
+ const SemverMigrationVersioning_1 = require("@decaf-ts/core/migrations/SemverMigrationVersioning");
49
52
  const db_decorators_1 = require("@decaf-ts/db-decorators");
50
53
  const core_2 = require("@nestjs/core");
51
54
  const index_js_1 = require("./migrations/index.cjs");
@@ -112,6 +115,8 @@ function resolveMigrateCommandConfig(options = {}, pkg = {}) {
112
115
  const cliFlavours = parseList(options.flavour ?? options.adapter);
113
116
  const packageFlavours = parseList(packageMigration.flavour ?? packageMigration.flavours);
114
117
  const flavours = cliFlavours.length > 0 ? unique(cliFlavours) : unique(packageFlavours);
118
+ const versionDir = options.versionDir || packageMigration.versionDir;
119
+ const references = parseList(options.reference ?? packageMigration.references);
115
120
  return {
116
121
  input,
117
122
  config: {
@@ -119,9 +124,38 @@ function resolveMigrateCommandConfig(options = {}, pkg = {}) {
119
124
  taskMode: parseBooleanFlag(options.taskMode ?? packageMigration.taskMode),
120
125
  dryRun: parseBooleanFlag(options.dryRun ?? packageMigration.dryRun),
121
126
  flavours,
127
+ versionDir,
128
+ references,
122
129
  },
123
130
  };
124
131
  }
132
+ function buildFileVersionHandlers(versionDir, adapters) {
133
+ const handlers = {};
134
+ for (const adapter of adapters) {
135
+ const alias = adapter.alias;
136
+ const file = path_1.default.join(versionDir, `${alias}.migration.version`);
137
+ handlers[alias] = {
138
+ // adapter and ctxArgs are available but not needed — version lives in the file
139
+ retrieveLastVersion: async (_adapter, ..._args) => {
140
+ try {
141
+ if (fs_1.default.existsSync(file)) {
142
+ const v = fs_1.default.readFileSync(file, "utf-8").trim();
143
+ return v || undefined;
144
+ }
145
+ }
146
+ catch {
147
+ // no file yet → first run
148
+ }
149
+ return undefined;
150
+ },
151
+ setCurrentVersion: async (version, _adapter, ..._args) => {
152
+ fs_1.default.mkdirSync(versionDir, { recursive: true });
153
+ fs_1.default.writeFileSync(file, version, "utf-8");
154
+ },
155
+ };
156
+ }
157
+ return handlers;
158
+ }
125
159
  const migrateCommand = new commander_1.Command()
126
160
  .name("migrate")
127
161
  .description("boots the app context headlessly, executes decaf migrations, and exits")
@@ -131,6 +165,12 @@ const migrateCommand = new commander_1.Command()
131
165
  .option("--adapter <String>", "adapter flavour alias(es), comma-separated (same behavior as --flavour)")
132
166
  .option("--task-mode [Boolean]", "runs migration via task mode (true/false). accepts bare flag as true")
133
167
  .option("--dry-run [Boolean]", "runs migrations with dry-run context (true/false). accepts bare flag as true")
168
+ .option("--version-dir <String>", "directory where per-adapter version files are persisted (e.g. a Docker volume path). " +
169
+ "Each adapter writes its last-migrated version to <versionDir>/<alias>.migration.version. " +
170
+ "Can also be set via package.json decaf.migration.versionDir.")
171
+ .option("--reference <String>", "run only the named migration reference(s), comma-separated (e.g. 'product-migration'). " +
172
+ "Bypasses version range filtering — use for zero-day or one-off migrations. " +
173
+ "Can also be set via package.json decaf.migration.references.")
134
174
  .action(async (options) => {
135
175
  const pkg = JSON.parse(fs_1.default.readFileSync(path_1.default.join(process.cwd(), "package.json"), "utf-8"));
136
176
  const log = logger.for("migrate");
@@ -166,12 +206,24 @@ const migrateCommand = new commander_1.Command()
166
206
  const migrateAdapters = taskAdapterAlias
167
207
  ? adapters.filter((a) => a.alias !== taskAdapterAlias && a.flavour !== taskAdapterAlias)
168
208
  : adapters;
209
+ const handlers = config.versionDir
210
+ ? buildFileVersionHandlers(config.versionDir, migrateAdapters)
211
+ : undefined;
212
+ if (config.versionDir)
213
+ log.info(`Version tracking: ${path_1.default.resolve(config.versionDir)}`);
214
+ else
215
+ log.warn(`No --version-dir set — every run will re-apply all migrations up to ${config.toVersion}`);
216
+ if (config.references.length)
217
+ log.info(`Running only references: ${config.references.join(", ")}`);
169
218
  const migrations = await index_js_1.DecafMigrationModule.migrate({
170
219
  toVersion: config.toVersion,
171
220
  taskMode: config.taskMode,
172
221
  dryRun: config.dryRun,
173
222
  flavours: config.flavours.length > 0 ? config.flavours : undefined,
174
223
  taskService,
224
+ handlers,
225
+ versioning: new SemverMigrationVersioning_1.SemverMigrationVersioning(),
226
+ references: config.references.length > 0 ? config.references : undefined,
175
227
  }, migrateAdapters);
176
228
  for (const migrationService of migrations || []) {
177
229
  await migrationService.track();
@@ -186,6 +238,7 @@ const migrateCommand = new commander_1.Command()
186
238
  await app.close();
187
239
  }
188
240
  });
241
+ exports.migrateCommand = migrateCommand;
189
242
  const nestCmd = new commander_1.Command()
190
243
  .name("nest")
191
244
  .description("exposes several commands to help manage the nest integration");
@@ -1 +1 @@
1
- {"version":3,"file":"cli-module.js","sourceRoot":"","sources":["cli-module.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,4CAKC;AACD,kDAWC;AA0BD,kEAqBC;AAqED,uBAEC;AAxJD,+CAA4C;AAC5C,MAAM,MAAM,GAAG,iBAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AACvC,yCAAoC;AACpC,4CAAoB;AACpB,gDAAwB;AACxB,yCAA8E;AAC9E,2DAAwD;AACxD,uCAA2C;AAC3C,oDAA6D;AAC7D,MAAM,sBAAsB,GAAG;IAC3B,sBAAsB;IACtB,qBAAqB;IACrB,qBAAqB;CACxB,CAAC;AACF,SAAS,sBAAsB,CAAC,SAAS;IACrC,OAAO,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;AAC9D,CAAC;AACD,SAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,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nC,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,sBAAsB,OAAO,CAAC,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,OAAO,CAAC,EAAE,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7G,CAAC;IACD,OAAO,CAAC,EAAE,CAAC;QACP,MAAM,IAAI,6BAAa,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;YACO,CAAC;QACL,IAAI,GAAG;YACH,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;AACL,CAAC,CAAC,CAAC;AACM,wCAAc;AACvB,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE;KACxB,IAAI,CAAC,MAAM,CAAC;KACZ,WAAW,CAAC,8DAA8D,CAAC,CAAC;AACjF,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AACnC,SAAwB,IAAI;IACxB,OAAO,OAAO,CAAC;AACnB,CAAC;AACD,sCAAsC"}
package/lib/cjs/index.cjs CHANGED
@@ -58,21 +58,21 @@ __exportStar(require("./events-module/index.cjs"), exports);
58
58
  * @constant
59
59
  * @type {string}
60
60
  */
61
- exports.VERSION = "0.10.0";
61
+ exports.VERSION = "0.10.1";
62
62
  /**
63
63
  * @description Represents the current commit hash of the module build.
64
64
  * @summary Stores the current git commit hash for the package. The build replaces
65
65
  * the placeholder with the actual commit hash at publish time.
66
66
  * @const COMMIT
67
67
  */
68
- exports.COMMIT = "4ea8766";
68
+ exports.COMMIT = "2609028";
69
69
  /**
70
70
  * @description Represents the full version string of the module.
71
71
  * @summary Stores the semver version and commit hash for the package.
72
72
  * The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
73
73
  * @const FULL_VERSION
74
74
  */
75
- exports.FULL_VERSION = "0.10.0-4ea8766";
75
+ exports.FULL_VERSION = "0.10.1-2609028";
76
76
  exports.PACKAGE_NAME = "@decaf-ts/for-nest";
77
77
  decoration_1.Metadata.allowReregistration(true);
78
78
  decoration_1.Metadata.registerLibrary(exports.PACKAGE_NAME, exports.VERSION);
@@ -4,6 +4,7 @@ import { Command } from "commander";
4
4
  import fs from "fs";
5
5
  import path from "path";
6
6
  import { Adapter, normalizeImport, Service, TaskModel } from "@decaf-ts/core";
7
+ import { SemverMigrationVersioning } from "@decaf-ts/core/migrations/SemverMigrationVersioning";
7
8
  import { InternalError } from "@decaf-ts/db-decorators";
8
9
  import { NestFactory } from "@nestjs/core";
9
10
  import { DecafMigrationModule } from "./migrations/index.js";
@@ -70,6 +71,8 @@ export function resolveMigrateCommandConfig(options = {}, pkg = {}) {
70
71
  const cliFlavours = parseList(options.flavour ?? options.adapter);
71
72
  const packageFlavours = parseList(packageMigration.flavour ?? packageMigration.flavours);
72
73
  const flavours = cliFlavours.length > 0 ? unique(cliFlavours) : unique(packageFlavours);
74
+ const versionDir = options.versionDir || packageMigration.versionDir;
75
+ const references = parseList(options.reference ?? packageMigration.references);
73
76
  return {
74
77
  input,
75
78
  config: {
@@ -77,9 +80,38 @@ export function resolveMigrateCommandConfig(options = {}, pkg = {}) {
77
80
  taskMode: parseBooleanFlag(options.taskMode ?? packageMigration.taskMode),
78
81
  dryRun: parseBooleanFlag(options.dryRun ?? packageMigration.dryRun),
79
82
  flavours,
83
+ versionDir,
84
+ references,
80
85
  },
81
86
  };
82
87
  }
88
+ export function buildFileVersionHandlers(versionDir, adapters) {
89
+ const handlers = {};
90
+ for (const adapter of adapters) {
91
+ const alias = adapter.alias;
92
+ const file = path.join(versionDir, `${alias}.migration.version`);
93
+ handlers[alias] = {
94
+ // adapter and ctxArgs are available but not needed — version lives in the file
95
+ retrieveLastVersion: async (_adapter, ..._args) => {
96
+ try {
97
+ if (fs.existsSync(file)) {
98
+ const v = fs.readFileSync(file, "utf-8").trim();
99
+ return v || undefined;
100
+ }
101
+ }
102
+ catch {
103
+ // no file yet → first run
104
+ }
105
+ return undefined;
106
+ },
107
+ setCurrentVersion: async (version, _adapter, ..._args) => {
108
+ fs.mkdirSync(versionDir, { recursive: true });
109
+ fs.writeFileSync(file, version, "utf-8");
110
+ },
111
+ };
112
+ }
113
+ return handlers;
114
+ }
83
115
  const migrateCommand = new Command()
84
116
  .name("migrate")
85
117
  .description("boots the app context headlessly, executes decaf migrations, and exits")
@@ -89,6 +121,12 @@ const migrateCommand = new Command()
89
121
  .option("--adapter <String>", "adapter flavour alias(es), comma-separated (same behavior as --flavour)")
90
122
  .option("--task-mode [Boolean]", "runs migration via task mode (true/false). accepts bare flag as true")
91
123
  .option("--dry-run [Boolean]", "runs migrations with dry-run context (true/false). accepts bare flag as true")
124
+ .option("--version-dir <String>", "directory where per-adapter version files are persisted (e.g. a Docker volume path). " +
125
+ "Each adapter writes its last-migrated version to <versionDir>/<alias>.migration.version. " +
126
+ "Can also be set via package.json decaf.migration.versionDir.")
127
+ .option("--reference <String>", "run only the named migration reference(s), comma-separated (e.g. 'product-migration'). " +
128
+ "Bypasses version range filtering — use for zero-day or one-off migrations. " +
129
+ "Can also be set via package.json decaf.migration.references.")
92
130
  .action(async (options) => {
93
131
  const pkg = JSON.parse(fs.readFileSync(path.join(process.cwd(), "package.json"), "utf-8"));
94
132
  const log = logger.for("migrate");
@@ -124,12 +162,24 @@ const migrateCommand = new Command()
124
162
  const migrateAdapters = taskAdapterAlias
125
163
  ? adapters.filter((a) => a.alias !== taskAdapterAlias && a.flavour !== taskAdapterAlias)
126
164
  : adapters;
165
+ const handlers = config.versionDir
166
+ ? buildFileVersionHandlers(config.versionDir, migrateAdapters)
167
+ : undefined;
168
+ if (config.versionDir)
169
+ log.info(`Version tracking: ${path.resolve(config.versionDir)}`);
170
+ else
171
+ log.warn(`No --version-dir set — every run will re-apply all migrations up to ${config.toVersion}`);
172
+ if (config.references.length)
173
+ log.info(`Running only references: ${config.references.join(", ")}`);
127
174
  const migrations = await DecafMigrationModule.migrate({
128
175
  toVersion: config.toVersion,
129
176
  taskMode: config.taskMode,
130
177
  dryRun: config.dryRun,
131
178
  flavours: config.flavours.length > 0 ? config.flavours : undefined,
132
179
  taskService,
180
+ handlers,
181
+ versioning: new SemverMigrationVersioning(),
182
+ references: config.references.length > 0 ? config.references : undefined,
133
183
  }, migrateAdapters);
134
184
  for (const migrationService of migrations || []) {
135
185
  await migrationService.track();
@@ -144,6 +194,7 @@ const migrateCommand = new Command()
144
194
  await app.close();
145
195
  }
146
196
  });
197
+ export { migrateCommand };
147
198
  const nestCmd = new Command()
148
199
  .name("nest")
149
200
  .description("exposes several commands to help manage the nest integration");
@@ -1 +1 @@
1
- {"version":3,"file":"cli-module.js","sourceRoot":"","sources":["../../src/cli-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AAEvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAE,oBAAoB,EAAE,8BAAqB;AAEpD,MAAM,sBAAsB,GAAG;IAC7B,sBAAsB;IACtB,qBAAqB;IACrB,qBAAqB;CACtB,CAAC;AAEF,SAAS,sBAAsB,CAAC,SAAiB;IAC/C,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,KAAc,EACd,SAAyC,sBAAsB,EAC/D,UAAU,GAAG,sBAAsB;IAEnC,I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,UAAU,CAAC,CAAC,CAAC,SAAS;SAC/D,EACD,eAAe,CAChB,CAAC;QAEF,KAAK,MAAM,gBAAgB,IAAI,UAAU,IAAI,EAAE,EAAE,CAAC;YAChD,MAAM,gBAAgB,CAAC,KAAK,EAAE,CAAC;QACjC,CAAC;QAED,GAAG,CAAC,IAAI,CACN,sBAAsB,OAAO,CAAC,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,OAAO,CAAC,EAAE,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC/F,CAAC;IACJ,CAAC;IAAC,OAAO,CAAU,EAAE,CAAC;QACpB,MAAM,IAAI,aAAa,CAAC,CAAU,CAAC,CAAC;IACtC,CAAC;YAAS,CAAC;QACT,IAAI,GAAG;YAAE,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE;KAC1B,IAAI,CAAC,MAAM,CAAC;KACZ,WAAW,CAAC,8DAA8D,CAAC,CAAC;AAE/E,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AAEnC,MAAM,CAAC,OAAO,UAAU,IAAI;IAC1B,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/lib/esm/index.js CHANGED
@@ -41,21 +41,21 @@ export * from "./events-module/index.js";
41
41
  * @constant
42
42
  * @type {string}
43
43
  */
44
- export const VERSION = "0.10.0";
44
+ export const VERSION = "0.10.1";
45
45
  /**
46
46
  * @description Represents the current commit hash of the module build.
47
47
  * @summary Stores the current git commit hash for the package. The build replaces
48
48
  * the placeholder with the actual commit hash at publish time.
49
49
  * @const COMMIT
50
50
  */
51
- export const COMMIT = "4ea8766";
51
+ export const COMMIT = "2609028";
52
52
  /**
53
53
  * @description Represents the full version string of the module.
54
54
  * @summary Stores the semver version and commit hash for the package.
55
55
  * The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
56
56
  * @const FULL_VERSION
57
57
  */
58
- export const FULL_VERSION = "0.10.0-4ea8766";
58
+ export const FULL_VERSION = "0.10.1-2609028";
59
59
  export const PACKAGE_NAME = "@decaf-ts/for-nest";
60
60
  Metadata.allowReregistration(true);
61
61
  Metadata.registerLibrary(PACKAGE_NAME, VERSION);
@@ -1,4 +1,5 @@
1
1
  import { Command } from "commander";
2
+ import { Adapter } from "@decaf-ts/core";
2
3
  export declare function resolveInputPath(input?: string, exists?: (candidate: string) => boolean, candidates?: string[]): string;
3
4
  export declare function buildOutputFilePath(params: {
4
5
  outputDir: string;
@@ -15,6 +16,14 @@ export declare function resolveMigrateCommandConfig(options?: Record<string, unk
15
16
  taskMode: boolean | undefined;
16
17
  dryRun: boolean | undefined;
17
18
  flavours: string[];
19
+ versionDir: string | undefined;
20
+ references: string[];
18
21
  };
19
22
  };
23
+ export declare function buildFileVersionHandlers(versionDir: string, adapters: Adapter<any, any, any, any>[]): Record<string, {
24
+ retrieveLastVersion: () => Promise<string | undefined>;
25
+ setCurrentVersion: (v: string) => Promise<void>;
26
+ }>;
27
+ declare const migrateCommand: Command;
28
+ export { migrateCommand };
20
29
  export default function nest(): Command;
@@ -1,4 +1,5 @@
1
1
  import { Command } from "commander";
2
+ import { Adapter } from "@decaf-ts/core";
2
3
  export declare function resolveInputPath(input?: string, exists?: (candidate: string) => boolean, candidates?: string[]): string;
3
4
  export declare function buildOutputFilePath(params: {
4
5
  outputDir: string;
@@ -15,6 +16,14 @@ export declare function resolveMigrateCommandConfig(options?: Record<string, unk
15
16
  taskMode: boolean | undefined;
16
17
  dryRun: boolean | undefined;
17
18
  flavours: string[];
19
+ versionDir: string | undefined;
20
+ references: string[];
18
21
  };
19
22
  };
23
+ export declare function buildFileVersionHandlers(versionDir: string, adapters: Adapter<any, any, any, any>[]): Record<string, {
24
+ retrieveLastVersion: () => Promise<string | undefined>;
25
+ setCurrentVersion: (v: string) => Promise<void>;
26
+ }>;
27
+ declare const migrateCommand: Command;
28
+ export { migrateCommand };
20
29
  export default function nest(): Command;
@@ -40,19 +40,19 @@ export * from "./events-module/index.d.cts";
40
40
  * @constant
41
41
  * @type {string}
42
42
  */
43
- export declare const VERSION = "0.10.0";
43
+ export declare const VERSION = "0.10.1";
44
44
  /**
45
45
  * @description Represents the current commit hash of the module build.
46
46
  * @summary Stores the current git commit hash for the package. The build replaces
47
47
  * the placeholder with the actual commit hash at publish time.
48
48
  * @const COMMIT
49
49
  */
50
- export declare const COMMIT = "4ea8766";
50
+ export declare const COMMIT = "2609028";
51
51
  /**
52
52
  * @description Represents the full version string of the module.
53
53
  * @summary Stores the semver version and commit hash for the package.
54
54
  * The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
55
55
  * @const FULL_VERSION
56
56
  */
57
- export declare const FULL_VERSION = "0.10.0-4ea8766";
57
+ export declare const FULL_VERSION = "0.10.1-2609028";
58
58
  export declare const PACKAGE_NAME = "@decaf-ts/for-nest";
@@ -40,19 +40,19 @@ export * from "./events-module/index.d.mts";
40
40
  * @constant
41
41
  * @type {string}
42
42
  */
43
- export declare const VERSION = "0.10.0";
43
+ export declare const VERSION = "0.10.1";
44
44
  /**
45
45
  * @description Represents the current commit hash of the module build.
46
46
  * @summary Stores the current git commit hash for the package. The build replaces
47
47
  * the placeholder with the actual commit hash at publish time.
48
48
  * @const COMMIT
49
49
  */
50
- export declare const COMMIT = "4ea8766";
50
+ export declare const COMMIT = "2609028";
51
51
  /**
52
52
  * @description Represents the full version string of the module.
53
53
  * @summary Stores the semver version and commit hash for the package.
54
54
  * The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
55
55
  * @const FULL_VERSION
56
56
  */
57
- export declare const FULL_VERSION = "0.10.0-4ea8766";
57
+ export declare const FULL_VERSION = "0.10.1-2609028";
58
58
  export declare const PACKAGE_NAME = "@decaf-ts/for-nest";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decaf-ts/for-nest",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "description": "NestJS decaf integration",
5
5
  "type": "module",
6
6
  "exports": {