@novu/framework
Version:
The Code-First Notifications Workflow SDK.
3 lines (2 loc) • 24.4 kB
JavaScript
;var et=Object.create;var P=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var nt=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var st=(e,o)=>{for(var i in o)P(e,i,{get:o[i],enumerable:!0})},fe=(e,o,i,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of it(o))!ot.call(e,r)&&r!==i&&P(e,r,{get:()=>o[r],enumerable:!(n=tt(o,r))||n.enumerable});return e};var be=(e,o,i)=>(i=e!=null?et(nt(e)):{},fe(o||!e||!e.__esModule?P(i,"default",{value:e,enumerable:!0}):i,e)),rt=e=>fe(P({},"__esModule",{value:!0}),e);var xt={};st(xt,{ActionStepEnum:()=>Ue,BadRequestError:()=>u,BridgeError:()=>q,ChannelStepEnum:()=>Me,ConflictError:()=>I,CronExpression:()=>Ce,ErrorCodeEnum:()=>h,ExecutionEventControlsInvalidError:()=>J,ExecutionEventPayloadInvalidError:()=>G,ExecutionProviderOutputInvalidError:()=>K,ExecutionStateControlsInvalidError:()=>$,ExecutionStateCorruptError:()=>W,ExecutionStateOutputInvalidError:()=>B,ExecutionStateResultInvalidError:()=>z,FILTER_VALIDATORS:()=>Rt,ForbiddenError:()=>V,FrameworkError:()=>g,GetActionEnum:()=>Ne,HttpHeaderKeysEnum:()=>M,HttpMethodEnum:()=>E,HttpQueryKeysEnum:()=>De,HttpStatusEnum:()=>R,InvalidActionError:()=>ee,JobStatusEnum:()=>Xe,MethodNotAllowedError:()=>Z,MissingSecretKeyError:()=>te,NotFoundError:()=>x,NovuApiEndpointsEnum:()=>ke,PlatformError:()=>ie,PostActionEnum:()=>Ee,ProviderExecutionFailedError:()=>oe,ProviderNotFoundError:()=>ne,ResourceConflictError:()=>A,ResourceEnum:()=>v,ResourceExecutionFailed:()=>_,ResourceNotFoundError:()=>T,SIGNATURE_TIMESTAMP_TOLERANCE:()=>_t,SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES:()=>D,ServerError:()=>O,SignatureExpiredError:()=>pe,SignatureInvalidError:()=>ae,SignatureMismatchError:()=>se,SignatureNotFoundError:()=>re,SignatureVersionInvalidError:()=>ce,SigningKeyNotFoundError:()=>le,StepAlreadyExistsError:()=>ue,StepControlCompilationFailedError:()=>X,StepExecutionFailedError:()=>he,StepNotFoundError:()=>de,UnauthorizedError:()=>f,WorkflowAlreadyExistsError:()=>ye,WorkflowChannelEnum:()=>Le,WorkflowNotFoundError:()=>me,WorkflowPayloadInvalidError:()=>Q,actionStepSchemas:()=>Se,channelStepSchemas:()=>Pe,createLiquidEngine:()=>He,digest:()=>Y,isFrameworkError:()=>ze,isNativeError:()=>Be,pluralize:()=>U,toSentence:()=>F,toSentenceArgsValidator:()=>j});module.exports=rt(xt);var at={type:"object",properties:{type:{enum:["regular"],default:"regular"},amount:{type:"number"},unit:{type:"string",enum:["seconds","minutes","hours","days","weeks","months"]}},required:["amount","unit"],additionalProperties:!1},pt={type:"object",properties:{duration:{type:"number"}},required:["duration"],additionalProperties:!1},Te={output:at,result:pt};var lt={type:"object",properties:{amount:{type:"number"},unit:{type:"string",enum:["seconds","minutes","hours","days","weeks","months"]},digestKey:{type:"string"},lookBackWindow:{type:"object",properties:{amount:{type:"number"},unit:{type:"string",enum:["seconds","minutes","hours","days","weeks","months"]}},required:["amount","unit"],additionalProperties:!1}},required:["amount","unit"],additionalProperties:!1},ct={type:"object",properties:{cron:{type:"string"},digestKey:{type:"string"}},required:["cron"],additionalProperties:!1},dt={oneOf:[lt,ct]},ut={type:"object",properties:{eventCount:{type:"number"},events:{type:"array",items:{type:"object",properties:{id:{type:"string"},time:{type:"string"},payload:{type:"object"}},required:["id","time","payload"],additionalProperties:!1}}},required:["events"],additionalProperties:!1},we={output:dt,result:ut};var Se={delay:Te,digest:we};var ht={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},mt={type:"object",properties:{},required:[],additionalProperties:!1},Oe={output:ht,result:mt};var yt={type:"object",properties:{subject:{type:"string",minLength:1},body:{type:"string"}},required:["subject","body"],additionalProperties:!1},gt={type:"object",properties:{},required:[],additionalProperties:!1},Ae={output:yt,result:gt};var ft="^(?!mailto:)(?:(https?):\\/\\/[^\\s/$.?#].[^\\s]*)|^(\\/[^\\s]*)$",Re={type:"object",properties:{url:{type:"string",pattern:ft},target:{type:"string",enum:["_self","_blank","_parent","_top","_unfencedTop"],default:"_blank"}},if:{properties:{url:{type:"string",pattern:"^/"}}},then:{properties:{target:{default:"_self"}}},else:{properties:{target:{default:"_blank"}}},required:["url"],additionalProperties:!1},_e={type:"object",properties:{label:{type:"string"},redirect:Re},required:["label"],additionalProperties:!1},bt={type:"object",properties:{subject:{type:"string",minLength:1},body:{type:"string",minLength:1},avatar:{type:"string",format:"uri"},primaryAction:_e,secondaryAction:_e,data:{type:"object",additionalProperties:!0},redirect:Re},anyOf:[{required:["subject"]},{required:["body"]}],additionalProperties:!1},Tt={type:"object",properties:{seen:{type:"boolean"},read:{type:"boolean"},lastSeenDate:{type:"string",format:"date-time",nullable:!0},lastReadDate:{type:"string",format:"date-time",nullable:!0}},required:["seen","read","lastSeenDate","lastReadDate"],additionalProperties:!1},ve={output:bt,result:Tt};var wt={type:"object",properties:{subject:{type:"string"},body:{type:"string"}},required:["subject","body"],additionalProperties:!1},St={type:"object",properties:{},required:[],additionalProperties:!1},xe={output:wt,result:St};var Ot={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},At={type:"object",properties:{},required:[],additionalProperties:!1},Ie={output:Ot,result:At};var Pe={chat:Oe,sms:Ie,push:xe,email:Ae,in_app:ve};var Ee=(n=>(n.TRIGGER="trigger",n.EXECUTE="execute",n.PREVIEW="preview",n))(Ee||{}),Ne=(n=>(n.DISCOVER="discover",n.HEALTH_CHECK="health-check",n.CODE="code",n))(Ne||{});var ke=(i=>(i.SYNC="/v1/bridge/sync",i.DIFF="/v1/bridge/diff",i))(ke||{}),D=5,_t=1500;var Ce=(s=>(s.EVERY_SECOND="* * * * * *",s.EVERY_5_SECONDS="*/5 * * * * *",s.EVERY_10_SECONDS="*/10 * * * * *",s.EVERY_30_SECONDS="*/30 * * * * *",s.EVERY_MINUTE="*/1 * * * *",s.EVERY_5_MINUTES="0 */5 * * * *",s.EVERY_10_MINUTES="0 */10 * * * *",s.EVERY_30_MINUTES="0 */30 * * * *",s.EVERY_HOUR="0 0-23/1 * * *",s.EVERY_2_HOURS="0 0-23/2 * * *",s.EVERY_3_HOURS="0 0-23/3 * * *",s.EVERY_4_HOURS="0 0-23/4 * * *",s.EVERY_5_HOURS="0 0-23/5 * * *",s.EVERY_6_HOURS="0 0-23/6 * * *",s.EVERY_7_HOURS="0 0-23/7 * * *",s.EVERY_8_HOURS="0 0-23/8 * * *",s.EVERY_9_HOURS="0 0-23/9 * * *",s.EVERY_10_HOURS="0 0-23/10 * * *",s.EVERY_11_HOURS="0 0-23/11 * * *",s.EVERY_12_HOURS="0 0-23/12 * * *",s.EVERY_DAY_AT_1AM="0 01 * * *",s.EVERY_DAY_AT_2AM="0 02 * * *",s.EVERY_DAY_AT_3AM="0 03 * * *",s.EVERY_DAY_AT_4AM="0 04 * * *",s.EVERY_DAY_AT_5AM="0 05 * * *",s.EVERY_DAY_AT_6AM="0 06 * * *",s.EVERY_DAY_AT_7AM="0 07 * * *",s.EVERY_DAY_AT_8AM="0 08 * * *",s.EVERY_DAY_AT_9AM="0 09 * * *",s.EVERY_DAY_AT_10AM="0 10 * * *",s.EVERY_DAY_AT_11AM="0 11 * * *",s.EVERY_DAY_AT_NOON="0 12 * * *",s.EVERY_DAY_AT_1PM="0 13 * * *",s.EVERY_DAY_AT_2PM="0 14 * * *",s.EVERY_DAY_AT_3PM="0 15 * * *",s.EVERY_DAY_AT_4PM="0 16 * * *",s.EVERY_DAY_AT_5PM="0 17 * * *",s.EVERY_DAY_AT_6PM="0 18 * * *",s.EVERY_DAY_AT_7PM="0 19 * * *",s.EVERY_DAY_AT_8PM="0 20 * * *",s.EVERY_DAY_AT_9PM="0 21 * * *",s.EVERY_DAY_AT_10PM="0 22 * * *",s.EVERY_DAY_AT_11PM="0 23 * * *",s.EVERY_DAY_AT_MIDNIGHT="0 0 * * *",s.EVERY_WEEK="0 0 * * 0",s.EVERY_WEEKDAY="0 0 * * 1-5",s.EVERY_WEEKEND="0 0 * * 6,0",s.EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT="0 0 1 * *",s.EVERY_1ST_DAY_OF_MONTH_AT_NOON="0 12 1 * *",s.EVERY_2ND_HOUR="0 */2 * * *",s.EVERY_2ND_HOUR_FROM_1AM_THROUGH_11PM="0 1-23/2 * * *",s.EVERY_2ND_MONTH="0 0 1 */2 *",s.EVERY_QUARTER="0 0 1 */3 *",s.EVERY_6_MONTHS="0 0 1 */6 *",s.EVERY_YEAR="0 0 1 0 *",s.EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM="0 */30 9-17 * * *",s.EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM="0 */30 9-18 * * *",s.EVERY_30_MINUTES_BETWEEN_10AM_AND_7PM="0 */30 10-19 * * *",s.MONDAY_TO_FRIDAY_AT_1AM="0 0 01 * * 1-5",s.MONDAY_TO_FRIDAY_AT_2AM="0 0 02 * * 1-5",s.MONDAY_TO_FRIDAY_AT_3AM="0 0 03 * * 1-5",s.MONDAY_TO_FRIDAY_AT_4AM="0 0 04 * * 1-5",s.MONDAY_TO_FRIDAY_AT_5AM="0 0 05 * * 1-5",s.MONDAY_TO_FRIDAY_AT_6AM="0 0 06 * * 1-5",s.MONDAY_TO_FRIDAY_AT_7AM="0 0 07 * * 1-5",s.MONDAY_TO_FRIDAY_AT_8AM="0 0 08 * * 1-5",s.MONDAY_TO_FRIDAY_AT_9AM="0 0 09 * * 1-5",s.MONDAY_TO_FRIDAY_AT_09_30AM="0 30 09 * * 1-5",s.MONDAY_TO_FRIDAY_AT_10AM="0 0 10 * * 1-5",s.MONDAY_TO_FRIDAY_AT_11AM="0 0 11 * * 1-5",s.MONDAY_TO_FRIDAY_AT_11_30AM="0 30 11 * * 1-5",s.MONDAY_TO_FRIDAY_AT_12PM="0 0 12 * * 1-5",s.MONDAY_TO_FRIDAY_AT_1PM="0 0 13 * * 1-5",s.MONDAY_TO_FRIDAY_AT_2PM="0 0 14 * * 1-5",s.MONDAY_TO_FRIDAY_AT_3PM="0 0 15 * * 1-5",s.MONDAY_TO_FRIDAY_AT_4PM="0 0 16 * * 1-5",s.MONDAY_TO_FRIDAY_AT_5PM="0 0 17 * * 1-5",s.MONDAY_TO_FRIDAY_AT_6PM="0 0 18 * * 1-5",s.MONDAY_TO_FRIDAY_AT_7PM="0 0 19 * * 1-5",s.MONDAY_TO_FRIDAY_AT_8PM="0 0 20 * * 1-5",s.MONDAY_TO_FRIDAY_AT_9PM="0 0 21 * * 1-5",s.MONDAY_TO_FRIDAY_AT_10PM="0 0 22 * * 1-5",s.MONDAY_TO_FRIDAY_AT_11PM="0 0 23 * * 1-5",s))(Ce||{});var h=(a=>(a.BRIDGE_ERROR="BridgeError",a.EXECUTION_EVENT_CONTROL_INVALID_ERROR="ExecutionEventControlInvalidError",a.EXECUTION_EVENT_PAYLOAD_INVALID_ERROR="ExecutionEventPayloadInvalidError",a.EXECUTION_PROVIDER_OUTPUT_INVALID_ERROR="ExecutionProviderOutputInvalidError",a.EXECUTION_STATE_CONTROL_INVALID_ERROR="ExecutionStateControlInvalidError",a.EXECUTION_STATE_CORRUPT_ERROR="ExecutionStateCorruptError",a.EXECUTION_STATE_OUTPUT_INVALID_ERROR="ExecutionStateOutputInvalidError",a.EXECUTION_STATE_RESULT_INVALID_ERROR="ExecutionStateResultInvalidError",a.INVALID_ACTION_ERROR="InvalidActionError",a.METHOD_NOT_ALLOWED_ERROR="MethodNotAllowedError",a.MISSING_DEPENDENCY_ERROR="MissingDependencyError",a.MISSING_SECRET_KEY_ERROR="MissingSecretKeyError",a.PROVIDER_EXECUTION_FAILED_ERROR="ProviderExecutionFailedError",a.PROVIDER_NOT_FOUND_ERROR="ProviderNotFoundError",a.SIGNATURE_EXPIRED_ERROR="SignatureExpiredError",a.SIGNATURE_INVALID_ERROR="SignatureInvalidError",a.SIGNATURE_MISMATCH_ERROR="SignatureMismatchError",a.SIGNATURE_NOT_FOUND_ERROR="SignatureNotFoundError",a.SIGNATURE_VERSION_INVALID_ERROR="SignatureVersionInvalidError",a.SIGNING_KEY_NOT_FOUND_ERROR="SigningKeyNotFoundError",a.STEP_ALREADY_EXISTS_ERROR="StepAlreadyExistsError",a.STEP_CONTROL_COMPILATION_FAILED_ERROR="StepControlCompilationFailedError",a.STEP_EXECUTION_FAILED_ERROR="StepExecutionFailedError",a.STEP_NOT_FOUND_ERROR="StepNotFoundError",a.WORKFLOW_ALREADY_EXISTS_ERROR="WorkflowAlreadyExistsError",a.WORKFLOW_NOT_FOUND_ERROR="WorkflowNotFoundError",a.WORKFLOW_PAYLOAD_INVALID_ERROR="WorkflowPayloadInvalidError",a))(h||{});var M=(d=>(d.NOVU_SIGNATURE="novu-signature",d.NOVU_ANONYMOUS="novu-anonymous",d.NOVU_FRAMEWORK_SDK="novu-framework-sdk",d.NOVU_FRAMEWORK_SERVER="novu-framework-server",d.NOVU_FRAMEWORK_VERSION="novu-framework-version",d.USER_AGENT="user-agent",d.CONTENT_TYPE="content-type",d.ACCESS_CONTROL_ALLOW_ORIGIN="access-control-allow-origin",d.ACCESS_CONTROL_ALLOW_METHODS="access-control-allow-methods",d.ACCESS_CONTROL_ALLOW_HEADERS="access-control-allow-headers",d.ACCESS_CONTROL_MAX_AGE="access-control-max-age",d))(M||{});var E=(n=>(n.POST="POST",n.GET="GET",n.OPTIONS="OPTIONS",n))(E||{});var De=(r=>(r.WORKFLOW_ID="workflowId",r.STEP_ID="stepId",r.ACTION="action",r.SOURCE="source",r))(De||{});var R=(t=>(t[t.CONTINUE=100]="CONTINUE",t[t.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",t[t.PROCESSING=102]="PROCESSING",t[t.EARLYHINTS=103]="EARLYHINTS",t[t.OK=200]="OK",t[t.CREATED=201]="CREATED",t[t.ACCEPTED=202]="ACCEPTED",t[t.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",t[t.NO_CONTENT=204]="NO_CONTENT",t[t.RESET_CONTENT=205]="RESET_CONTENT",t[t.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",t[t.AMBIGUOUS=300]="AMBIGUOUS",t[t.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",t[t.FOUND=302]="FOUND",t[t.SEE_OTHER=303]="SEE_OTHER",t[t.NOT_MODIFIED=304]="NOT_MODIFIED",t[t.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",t[t.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",t[t.BAD_REQUEST=400]="BAD_REQUEST",t[t.UNAUTHORIZED=401]="UNAUTHORIZED",t[t.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",t[t.FORBIDDEN=403]="FORBIDDEN",t[t.NOT_FOUND=404]="NOT_FOUND",t[t.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",t[t.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",t[t.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",t[t.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",t[t.CONFLICT=409]="CONFLICT",t[t.GONE=410]="GONE",t[t.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",t[t.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",t[t.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",t[t.URI_TOO_LONG=414]="URI_TOO_LONG",t[t.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",t[t.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",t[t.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",t[t.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",t[t.MISDIRECTED=421]="MISDIRECTED",t[t.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",t[t.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",t[t.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",t[t.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",t[t.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",t[t.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",t[t.BAD_GATEWAY=502]="BAD_GATEWAY",t[t.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",t[t.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",t[t.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",t))(R||{});var v=(n=>(n.WORKFLOW="workflow",n.PROVIDER="provider",n.STEP="step",n))(v||{});var Me=(l=>(l.EMAIL="email",l.SMS="sms",l.PUSH="push",l.CHAT="chat",l.IN_APP="in_app",l))(Me||{}),Ue=(n=>(n.DIGEST="digest",n.DELAY="delay",n.CUSTOM="custom",n))(Ue||{});var Le=(l=>(l.EMAIL="email",l.SMS="sms",l.PUSH="push",l.CHAT="chat",l.IN_APP="inApp",l))(Le||{});var Fe=be(require("pluralize"),1);function U(e,o="",i=""){if(e==null)return"";let n=0;return Array.isArray(e)?n=e.length:typeof e=="object"?n=Object.keys(e).length:typeof e=="string"?n=+e:typeof e=="number"?n=e:n=Number(e),Number.isNaN(n)&&(n=0),n<=0?"":i?`${n} ${n===1?o:i}`:`${n} ${(0,Fe.default)(o,n)}`}var L=require("liquidjs"),b=require("zod"),Ye=be(require("pluralize"),1);function N(e,o){let i=o.split(".").reduce((n,r)=>{if(n&&typeof n=="object")return n[r]},e);if(i==null)return"";if(typeof i=="string")return i;if(typeof i=="number"||typeof i=="boolean")return String(i);if(typeof i=="object"){let n=JSON.stringify(i);return n==="{}"?"":n}return""}var Ve="",qe=2,We="other",Ge=", ",Je=" and ",$e=", and ",je={0:"keyPath",1:"limit",2:"overflowSuffix",3:"wordsConnector",4:"twoWordsConnector",5:"lastWordConnector"};function F(e,o=Ve,i=qe,n=We,r=Ge,l=Je,w=$e){if(!Array.isArray(e)||e.length===0)return"";let p=o?e.map(y=>typeof y!="object"||!y?"":N(y,o)):e,m=p.length;if(m===1)return p[0];if(m===2)return`${p[0]}${l}${p[1]}`;if(i>=m){let y=p.slice(0,m-1),ge=p[m-1];return`${y.join(r)}${w}${ge}`}let c=p.slice(0,i),S=m-i,d=i===1?l:w;return`${c.join(r)}${d}${S} ${(0,Ye.default)(n,S)}`}function j(e={},...o){let{requireKeyPath:i=!1}=e,n=[];if(o.length<1)return n.push({message:"Expected at least 1 argument",begin:0,end:0,value:""}),n;let r=b.z.object({keyPath:i?b.z.string().min(1,"must be non-empty"):b.z.string().optional().default(Ve),limit:b.z.number().optional().default(qe).refine(p=>p>=0,"must be greater than or equal to 0"),overflowSuffix:b.z.string().optional().default(We),wordsConnector:b.z.string().optional().default(Ge),twoWordsConnector:b.z.string().optional().default(Je),lastWordConnector:b.z.string().optional().default($e)}),l={};o.forEach((p,m)=>{if(!Array.isArray(p)){let c=p.getText();(p.kind===L.TokenKind.Quoted||p.kind===L.TokenKind.Number)&&(c=p.content);let S=je[m];l[S]=c}});let w=r.safeParse(l);if(!w.success)for(let p of w.error.issues){let m="string";"type"in p&&(m=p.type);let c=p.path[0],S=Object.entries(je).find(([ge,Ze])=>Ze===c),d=S?parseInt(S[0],10):null,y=typeof d=="number"?o[d]:null;y&&!Array.isArray(y)&&n.push({message:`"toSentence" expects a ${m}${p.message?` that ${p.message}`:""} for argument "${c}"`,begin:y.begin,end:y.end,value:y.getText()})}return n}function Y(e,o=2,i,n=", "){if(!Array.isArray(e)||e.length===0)return"";let r=i?e.map(p=>typeof p!="object"||!p?"":N(p,i)):e;if(r.length===1)return r[0];if(r.length===2)return`${r[0]} and ${r[1]}`;if(r.length===3&&o>=3)return`${r[0]}, ${n}${r[1]} and ${r[2]}`;let l=r.slice(0,o),w=r.length-o;return`${l.join(n)} and ${w} ${w===1?"other":"others"}`}var Rt={toSentence:j};var Be=e=>{var i,n;if(typeof e!="object"||e===null)return!1;let o=Object.getPrototypeOf(e);return(n=(i=o==null?void 0:o.constructor)==null?void 0:i.name.endsWith("Error"))!=null?n:!1},g=class extends Error{},x=class extends g{constructor(){super(...arguments);this.statusCode=404}},u=class extends g{constructor(){super(...arguments);this.statusCode=400}},f=class extends g{constructor(){super(...arguments);this.statusCode=401}},O=class extends g{constructor(o,{cause:i}={}){var n;Be(i)?(super(`${o}: ${i.message}`),this.data={stack:(n=i.stack)!=null?n:o}):(super(`${o}${i?`: ${JSON.stringify(i,null,2)}`:""}`),this.data={stack:o})}},I=class extends g{constructor(){super(...arguments);this.statusCode=409}},V=class extends g{constructor(){super(...arguments);this.statusCode=403}};var q=class extends O{constructor(i){super("Unknown BridgeError",{cause:i});this.statusCode=500;this.code="BridgeError"}};var W=class extends u{constructor(i,n){super(`Workflow with id: \`${i}\` has a corrupt state. Step with id: \`${n}\` does not exist. Please provide the missing state.`);this.code="ExecutionStateCorruptError";this.data={workflowId:i,stepId:n}}},G=class extends u{constructor(i,n){super(`Workflow with id: \`${i}\` has invalid \`payload\`. Please provide the correct event payload.`);this.code="ExecutionEventPayloadInvalidError";this.data=n}},J=class extends u{constructor(i,n){super(`Workflow with id: \`${i}\` has invalid \`controls\`. Please provide the correct event controls.`);this.code="ExecutionEventControlInvalidError";this.data=n}},$=class extends u{constructor(i,n,r){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${n}\` has invalid \`controls\`. Please provide the correct step controls.`);this.code="ExecutionStateControlInvalidError";this.data=r}},B=class extends u{constructor(i,n,r){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${n}\` has invalid output. Please provide the correct step output.`);this.code="ExecutionStateOutputInvalidError";this.data=r}},z=class extends u{constructor(i,n,r){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${n}\` has invalid result. Please provide the correct step result.`);this.code="ExecutionStateResultInvalidError";this.data=r}},X=class extends u{constructor(i,n,r){super(`Workflow with id: \`${i}\` has invalid controls syntax in step with id: \`${n}\`. Please correct step control syntax.`);this.code="StepControlCompilationFailedError";this.data=r}},K=class extends u{constructor(i,n,r,l){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${n}\` and provider with id: \`${r}\` has invalid output. Please provide the correct provider output.`);this.code="ExecutionProviderOutputInvalidError";this.data=l}},Q=class extends u{constructor(i,n){super(`Workflow with id: \`${i}\` has invalid \`payload\`. Please provide the correct payload.`);this.code="WorkflowPayloadInvalidError";this.data=n}};var H=e=>Object.values(e).map(o=>`\`${o}\``).join(", "),k=e=>e.replaceAll(/(\w)(\w*)/g,(o,i,n)=>i.toUpperCase()+n.toLowerCase()).replaceAll(/[\s-]+/g,"");var Z=class extends g{constructor(){super(...arguments);this.code="MethodNotAllowedError";this.statusCode=405;this.message=`Method not allowed. Please use one of ${H(E)}`}},ee=class extends u{constructor(i,n){super(`Invalid query string: \`action\`=\`${i}\`. Please use one of ${H(n)}`);this.code="InvalidActionError"}},te=class extends u{constructor(){super("Missing secret key. Set the `NOVU_SECRET_KEY` environment variable or pass `secretKey` to the client options.");this.code="MissingSecretKeyError"}};var ie=class extends Error{constructor(o,i,n){super(),this.data={message:n},this.statusCode=o,this.code=i}};var A=class extends I{constructor(o,i){super(`${k(o)} with id: \`${i}\` already exists. Please use a different id.`)}},T=class extends x{constructor(o,i){super(`${k(o)} with id: \`${i}\` does not exist. Please provide a valid id.`)}},_=class extends O{constructor(i,n,r,l){super(`Failed to ${r} ${k(i)} with id: \`${n}\``,{cause:l});this.statusCode=502}};var ne=class extends T{constructor(i){super("provider",i);this.code="ProviderNotFoundError"}},oe=class extends _{constructor(i,n,r){super("provider",i,n,r);this.code="ProviderExecutionFailedError"}};var se=class extends f{constructor(){super("Signature does not match the expected signature. Please ensure the signature provided in the `novu-signature` header is correct and try again.");this.code="SignatureMismatchError"}},re=class extends f{constructor(){super("Signature not found. Please provide a signature in the `novu-signature` header");this.code="SignatureNotFoundError"}},ae=class extends f{constructor(){super("Signature is invalid. Please provide a valid signature in the `novu-signature` header");this.code="SignatureInvalidError"}},pe=class extends f{constructor(){super(`Signature expired. Please provide a signature with a timestamp no older than ${5} minutes in the \`novu-signature\` header`);this.code="SignatureExpiredError"}},le=class extends f{constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.secretKey`");this.code="SigningKeyNotFoundError"}},ce=class extends f{constructor(){super("Signature version is invalid. Please provide a signature version with version `v1` in the `novu-signature` header");this.code="SignatureVersionInvalidError"}};var de=class extends T{constructor(i){super("step",i);this.code="StepNotFoundError"}},ue=class extends A{constructor(i){super("step",i);this.code="StepAlreadyExistsError"}},he=class extends _{constructor(i,n,r){super("step",i,n,r);this.code="StepExecutionFailedError"}};var me=class extends T{constructor(i){super("workflow",i);this.code="WorkflowNotFoundError"}},ye=class extends A{constructor(i){super("workflow",i);this.code="WorkflowAlreadyExistsError"}};var ze=e=>Object.values(h).includes(e==null?void 0:e.code);var Xe=(c=>(c.PENDING="pending",c.QUEUED="queued",c.RUNNING="running",c.COMPLETED="completed",c.FAILED="failed",c.DELAYED="delayed",c.CANCELED="canceled",c.MERGED="merged",c.SKIPPED="skipped",c))(Xe||{});var Ke=require("liquidjs");function vt(e){return Array.isArray(e)||typeof e=="object"&&e!==null?Qe(e):typeof e=="string"&&e.includes(`
`)?e.replace(/\n/g,"\\n"):e==null?"":String(e)}var Qe=(e,o=0)=>Array.isArray(e)||typeof e=="object"&&e!==null?JSON.stringify(e,null,o).replace(/"/g,"'").replace(/\n/g,"\\n"):e==null?"":String(e);function He(e){let o=new Ke.Liquid({outputEscape:vt,...e});return o.registerFilter("json",(i,n)=>Qe(i,n)),o.registerFilter("digest",Y),o.registerFilter("toSentence",F),o.registerFilter("pluralize",U),o}0&&(module.exports={ActionStepEnum,BadRequestError,BridgeError,ChannelStepEnum,ConflictError,CronExpression,ErrorCodeEnum,ExecutionEventControlsInvalidError,ExecutionEventPayloadInvalidError,ExecutionProviderOutputInvalidError,ExecutionStateControlsInvalidError,ExecutionStateCorruptError,ExecutionStateOutputInvalidError,ExecutionStateResultInvalidError,FILTER_VALIDATORS,ForbiddenError,FrameworkError,GetActionEnum,HttpHeaderKeysEnum,HttpMethodEnum,HttpQueryKeysEnum,HttpStatusEnum,InvalidActionError,JobStatusEnum,MethodNotAllowedError,MissingSecretKeyError,NotFoundError,NovuApiEndpointsEnum,PlatformError,PostActionEnum,ProviderExecutionFailedError,ProviderNotFoundError,ResourceConflictError,ResourceEnum,ResourceExecutionFailed,ResourceNotFoundError,SIGNATURE_TIMESTAMP_TOLERANCE,SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES,ServerError,SignatureExpiredError,SignatureInvalidError,SignatureMismatchError,SignatureNotFoundError,SignatureVersionInvalidError,SigningKeyNotFoundError,StepAlreadyExistsError,StepControlCompilationFailedError,StepExecutionFailedError,StepNotFoundError,UnauthorizedError,WorkflowAlreadyExistsError,WorkflowChannelEnum,WorkflowNotFoundError,WorkflowPayloadInvalidError,actionStepSchemas,channelStepSchemas,createLiquidEngine,digest,isFrameworkError,isNativeError,pluralize,toSentence,toSentenceArgsValidator});