UNPKG

@novu/framework

Version:

The Code-First Notifications Workflow SDK.

3 lines (2 loc) 25.8 kB
"use strict";var it=Object.create;var P=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var st=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty;var at=(e,n)=>{for(var i in n)P(e,i,{get:n[i],enumerable:!0})},fe=(e,n,i,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of ot(n))!rt.call(e,r)&&r!==i&&P(e,r,{get:()=>n[r],enumerable:!(s=nt(n,r))||s.enumerable});return e};var be=(e,n,i)=>(i=e!=null?it(st(e)):{},fe(n||!e||!e.__esModule?P(i,"default",{value:e,enumerable:!0}):i,e)),pt=e=>fe(P({},"__esModule",{value:!0}),e);var kt={};at(kt,{ActionStepEnum:()=>Re,BadRequestError:()=>u,BridgeError:()=>M,ChannelStepEnum:()=>_e,ConflictError:()=>I,CronExpression:()=>Oe,ErrorCodeEnum:()=>h,ExecutionEventControlsInvalidError:()=>j,ExecutionEventPayloadInvalidError:()=>F,ExecutionProviderOutputInvalidError:()=>J,ExecutionStateControlsInvalidError:()=>Y,ExecutionStateCorruptError:()=>L,ExecutionStateOutputInvalidError:()=>V,ExecutionStateResultInvalidError:()=>q,FILTER_VALIDATORS:()=>ct,ForbiddenError:()=>U,FrameworkError:()=>g,GetActionEnum:()=>we,HttpHeaderKeysEnum:()=>D,HttpMethodEnum:()=>E,HttpQueryKeysEnum:()=>Ae,HttpStatusEnum:()=>R,InvalidActionError:()=>z,JobStatusEnum:()=>Ke,MethodNotAllowedError:()=>B,MissingSecretKeyError:()=>X,NotFoundError:()=>v,NovuApiEndpointsEnum:()=>Se,PlatformError:()=>K,PostActionEnum:()=>Te,ProviderExecutionFailedError:()=>Q,ProviderNotFoundError:()=>H,ResourceConflictError:()=>A,ResourceEnum:()=>x,ResourceExecutionFailed:()=>_,ResourceNotFoundError:()=>b,SIGNATURE_TIMESTAMP_TOLERANCE:()=>lt,SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES:()=>C,ServerError:()=>O,SeverityLevelEnum:()=>He,SignatureExpiredError:()=>ie,SignatureInvalidError:()=>te,SignatureMismatchError:()=>Z,SignatureNotFoundError:()=>ee,SignatureVersionInvalidError:()=>oe,SigningKeyNotFoundError:()=>ne,StepAlreadyExistsError:()=>re,StepControlCompilationFailedError:()=>W,StepExecutionFailedError:()=>ae,StepNotFoundError:()=>se,UnauthorizedError:()=>f,WorkflowAlreadyExistsError:()=>le,WorkflowChannelEnum:()=>xe,WorkflowNotFoundError:()=>pe,WorkflowPayloadInvalidError:()=>G,actionStepSchemas:()=>Ve,channelStepSchemas:()=>Xe,createLiquidEngine:()=>et,digest:()=>ce,isFrameworkError:()=>Ie,isNativeError:()=>ve,pluralize:()=>de,toSentence:()=>he,toSentenceArgsValidator:()=>me});module.exports=pt(kt);var Te=(s=>(s.TRIGGER="trigger",s.EXECUTE="execute",s.PREVIEW="preview",s))(Te||{}),we=(s=>(s.DISCOVER="discover",s.HEALTH_CHECK="health-check",s.CODE="code",s))(we||{});var Se=(i=>(i.SYNC="/v1/bridge/sync",i.DIFF="/v1/bridge/diff",i))(Se||{}),C=5,lt=1500;var Oe=(o=>(o.EVERY_SECOND="* * * * * *",o.EVERY_5_SECONDS="*/5 * * * * *",o.EVERY_10_SECONDS="*/10 * * * * *",o.EVERY_30_SECONDS="*/30 * * * * *",o.EVERY_MINUTE="*/1 * * * *",o.EVERY_5_MINUTES="0 */5 * * * *",o.EVERY_10_MINUTES="0 */10 * * * *",o.EVERY_30_MINUTES="0 */30 * * * *",o.EVERY_HOUR="0 0-23/1 * * *",o.EVERY_2_HOURS="0 0-23/2 * * *",o.EVERY_3_HOURS="0 0-23/3 * * *",o.EVERY_4_HOURS="0 0-23/4 * * *",o.EVERY_5_HOURS="0 0-23/5 * * *",o.EVERY_6_HOURS="0 0-23/6 * * *",o.EVERY_7_HOURS="0 0-23/7 * * *",o.EVERY_8_HOURS="0 0-23/8 * * *",o.EVERY_9_HOURS="0 0-23/9 * * *",o.EVERY_10_HOURS="0 0-23/10 * * *",o.EVERY_11_HOURS="0 0-23/11 * * *",o.EVERY_12_HOURS="0 0-23/12 * * *",o.EVERY_DAY_AT_1AM="0 01 * * *",o.EVERY_DAY_AT_2AM="0 02 * * *",o.EVERY_DAY_AT_3AM="0 03 * * *",o.EVERY_DAY_AT_4AM="0 04 * * *",o.EVERY_DAY_AT_5AM="0 05 * * *",o.EVERY_DAY_AT_6AM="0 06 * * *",o.EVERY_DAY_AT_7AM="0 07 * * *",o.EVERY_DAY_AT_8AM="0 08 * * *",o.EVERY_DAY_AT_9AM="0 09 * * *",o.EVERY_DAY_AT_10AM="0 10 * * *",o.EVERY_DAY_AT_11AM="0 11 * * *",o.EVERY_DAY_AT_NOON="0 12 * * *",o.EVERY_DAY_AT_1PM="0 13 * * *",o.EVERY_DAY_AT_2PM="0 14 * * *",o.EVERY_DAY_AT_3PM="0 15 * * *",o.EVERY_DAY_AT_4PM="0 16 * * *",o.EVERY_DAY_AT_5PM="0 17 * * *",o.EVERY_DAY_AT_6PM="0 18 * * *",o.EVERY_DAY_AT_7PM="0 19 * * *",o.EVERY_DAY_AT_8PM="0 20 * * *",o.EVERY_DAY_AT_9PM="0 21 * * *",o.EVERY_DAY_AT_10PM="0 22 * * *",o.EVERY_DAY_AT_11PM="0 23 * * *",o.EVERY_DAY_AT_MIDNIGHT="0 0 * * *",o.EVERY_WEEK="0 0 * * 0",o.EVERY_WEEKDAY="0 0 * * 1-5",o.EVERY_WEEKEND="0 0 * * 6,0",o.EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT="0 0 1 * *",o.EVERY_1ST_DAY_OF_MONTH_AT_NOON="0 12 1 * *",o.EVERY_2ND_HOUR="0 */2 * * *",o.EVERY_2ND_HOUR_FROM_1AM_THROUGH_11PM="0 1-23/2 * * *",o.EVERY_2ND_MONTH="0 0 1 */2 *",o.EVERY_QUARTER="0 0 1 */3 *",o.EVERY_6_MONTHS="0 0 1 */6 *",o.EVERY_YEAR="0 0 1 0 *",o.EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM="0 */30 9-17 * * *",o.EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM="0 */30 9-18 * * *",o.EVERY_30_MINUTES_BETWEEN_10AM_AND_7PM="0 */30 10-19 * * *",o.MONDAY_TO_FRIDAY_AT_1AM="0 0 01 * * 1-5",o.MONDAY_TO_FRIDAY_AT_2AM="0 0 02 * * 1-5",o.MONDAY_TO_FRIDAY_AT_3AM="0 0 03 * * 1-5",o.MONDAY_TO_FRIDAY_AT_4AM="0 0 04 * * 1-5",o.MONDAY_TO_FRIDAY_AT_5AM="0 0 05 * * 1-5",o.MONDAY_TO_FRIDAY_AT_6AM="0 0 06 * * 1-5",o.MONDAY_TO_FRIDAY_AT_7AM="0 0 07 * * 1-5",o.MONDAY_TO_FRIDAY_AT_8AM="0 0 08 * * 1-5",o.MONDAY_TO_FRIDAY_AT_9AM="0 0 09 * * 1-5",o.MONDAY_TO_FRIDAY_AT_09_30AM="0 30 09 * * 1-5",o.MONDAY_TO_FRIDAY_AT_10AM="0 0 10 * * 1-5",o.MONDAY_TO_FRIDAY_AT_11AM="0 0 11 * * 1-5",o.MONDAY_TO_FRIDAY_AT_11_30AM="0 30 11 * * 1-5",o.MONDAY_TO_FRIDAY_AT_12PM="0 0 12 * * 1-5",o.MONDAY_TO_FRIDAY_AT_1PM="0 0 13 * * 1-5",o.MONDAY_TO_FRIDAY_AT_2PM="0 0 14 * * 1-5",o.MONDAY_TO_FRIDAY_AT_3PM="0 0 15 * * 1-5",o.MONDAY_TO_FRIDAY_AT_4PM="0 0 16 * * 1-5",o.MONDAY_TO_FRIDAY_AT_5PM="0 0 17 * * 1-5",o.MONDAY_TO_FRIDAY_AT_6PM="0 0 18 * * 1-5",o.MONDAY_TO_FRIDAY_AT_7PM="0 0 19 * * 1-5",o.MONDAY_TO_FRIDAY_AT_8PM="0 0 20 * * 1-5",o.MONDAY_TO_FRIDAY_AT_9PM="0 0 21 * * 1-5",o.MONDAY_TO_FRIDAY_AT_10PM="0 0 22 * * 1-5",o.MONDAY_TO_FRIDAY_AT_11PM="0 0 23 * * 1-5",o))(Oe||{});var h=(p=>(p.BRIDGE_ERROR="BridgeError",p.EXECUTION_EVENT_CONTROL_INVALID_ERROR="ExecutionEventControlInvalidError",p.EXECUTION_EVENT_PAYLOAD_INVALID_ERROR="ExecutionEventPayloadInvalidError",p.EXECUTION_PROVIDER_OUTPUT_INVALID_ERROR="ExecutionProviderOutputInvalidError",p.EXECUTION_STATE_CONTROL_INVALID_ERROR="ExecutionStateControlInvalidError",p.EXECUTION_STATE_CORRUPT_ERROR="ExecutionStateCorruptError",p.EXECUTION_STATE_OUTPUT_INVALID_ERROR="ExecutionStateOutputInvalidError",p.EXECUTION_STATE_RESULT_INVALID_ERROR="ExecutionStateResultInvalidError",p.INVALID_ACTION_ERROR="InvalidActionError",p.METHOD_NOT_ALLOWED_ERROR="MethodNotAllowedError",p.MISSING_DEPENDENCY_ERROR="MissingDependencyError",p.MISSING_SECRET_KEY_ERROR="MissingSecretKeyError",p.PROVIDER_EXECUTION_FAILED_ERROR="ProviderExecutionFailedError",p.PROVIDER_NOT_FOUND_ERROR="ProviderNotFoundError",p.SIGNATURE_EXPIRED_ERROR="SignatureExpiredError",p.SIGNATURE_INVALID_ERROR="SignatureInvalidError",p.SIGNATURE_MISMATCH_ERROR="SignatureMismatchError",p.SIGNATURE_NOT_FOUND_ERROR="SignatureNotFoundError",p.SIGNATURE_VERSION_INVALID_ERROR="SignatureVersionInvalidError",p.SIGNING_KEY_NOT_FOUND_ERROR="SigningKeyNotFoundError",p.STEP_ALREADY_EXISTS_ERROR="StepAlreadyExistsError",p.STEP_CONTROL_COMPILATION_FAILED_ERROR="StepControlCompilationFailedError",p.STEP_EXECUTION_FAILED_ERROR="StepExecutionFailedError",p.STEP_NOT_FOUND_ERROR="StepNotFoundError",p.WORKFLOW_ALREADY_EXISTS_ERROR="WorkflowAlreadyExistsError",p.WORKFLOW_NOT_FOUND_ERROR="WorkflowNotFoundError",p.WORKFLOW_PAYLOAD_INVALID_ERROR="WorkflowPayloadInvalidError",p))(h||{});var D=(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))(D||{});var E=(s=>(s.POST="POST",s.GET="GET",s.OPTIONS="OPTIONS",s))(E||{});var Ae=(r=>(r.WORKFLOW_ID="workflowId",r.STEP_ID="stepId",r.ACTION="action",r.SOURCE="source",r))(Ae||{});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 x=(s=>(s.WORKFLOW="workflow",s.PROVIDER="provider",s.STEP="step",s))(x||{});var _e=(a=>(a.EMAIL="email",a.SMS="sms",a.PUSH="push",a.CHAT="chat",a.IN_APP="in_app",a))(_e||{}),Re=(r=>(r.DIGEST="digest",r.DELAY="delay",r.THROTTLE="throttle",r.CUSTOM="custom",r))(Re||{});var xe=(a=>(a.EMAIL="email",a.SMS="sms",a.PUSH="push",a.CHAT="chat",a.IN_APP="inApp",a))(xe||{});var ve=e=>{var i,s;if(typeof e!="object"||e===null)return!1;let n=Object.getPrototypeOf(e);return(s=(i=n==null?void 0:n.constructor)==null?void 0:i.name.endsWith("Error"))!=null?s:!1},g=class extends Error{},v=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(n,{cause:i}={}){var s;ve(i)?(super(`${n}: ${i.message}`),this.data={stack:(s=i.stack)!=null?s:n}):(super(`${n}${i?`: ${JSON.stringify(i,null,2)}`:""}`),this.data={stack:n})}},I=class extends g{constructor(){super(...arguments);this.statusCode=409}},U=class extends g{constructor(){super(...arguments);this.statusCode=403}};var M=class extends O{constructor(i){super("Unknown BridgeError",{cause:i});this.statusCode=500;this.code="BridgeError"}};var L=class extends u{constructor(i,s){super(`Workflow with id: \`${i}\` has a corrupt state. Step with id: \`${s}\` does not exist. Please provide the missing state.`);this.code="ExecutionStateCorruptError";this.data={workflowId:i,stepId:s}}},F=class extends u{constructor(i,s){super(`Workflow with id: \`${i}\` has invalid \`payload\`. Please provide the correct event payload.`);this.code="ExecutionEventPayloadInvalidError";this.data=s}},j=class extends u{constructor(i,s){super(`Workflow with id: \`${i}\` has invalid \`controls\`. Please provide the correct event controls.`);this.code="ExecutionEventControlInvalidError";this.data=s}},Y=class extends u{constructor(i,s,r){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${s}\` has invalid \`controls\`. Please provide the correct step controls.`);this.code="ExecutionStateControlInvalidError";this.data=r}},V=class extends u{constructor(i,s,r){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${s}\` has invalid output. Please provide the correct step output.`);this.code="ExecutionStateOutputInvalidError";this.data=r}},q=class extends u{constructor(i,s,r){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${s}\` has invalid result. Please provide the correct step result.`);this.code="ExecutionStateResultInvalidError";this.data=r}},W=class extends u{constructor(i,s,r){super(`Workflow with id: \`${i}\` has invalid controls syntax in step with id: \`${s}\`. Please correct step control syntax.`);this.code="StepControlCompilationFailedError";this.data=r}},J=class extends u{constructor(i,s,r,a){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${s}\` and provider with id: \`${r}\` has invalid output. Please provide the correct provider output.`);this.code="ExecutionProviderOutputInvalidError";this.data=a}},G=class extends u{constructor(i,s){super(`Workflow with id: \`${i}\` has invalid \`payload\`. Please provide the correct payload.`);this.code="WorkflowPayloadInvalidError";this.data=s}};var Ie=e=>Object.values(h).includes(e==null?void 0:e.code);var $=e=>Object.values(e).map(n=>`\`${n}\``).join(", "),N=e=>e.replaceAll(/(\w)(\w*)/g,(n,i,s)=>i.toUpperCase()+s.toLowerCase()).replaceAll(/[\s-]+/g,"");var B=class extends g{constructor(){super(...arguments);this.code="MethodNotAllowedError";this.statusCode=405;this.message=`Method not allowed. Please use one of ${$(E)}`}},z=class extends u{constructor(i,s){super(`Invalid query string: \`action\`=\`${i}\`. Please use one of ${$(s)}`);this.code="InvalidActionError"}},X=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 K=class extends Error{constructor(n,i,s){super(),this.data={message:s},this.statusCode=n,this.code=i}};var A=class extends I{constructor(n,i){super(`${N(n)} with id: \`${i}\` already exists. Please use a different id.`)}},b=class extends v{constructor(n,i){super(`${N(n)} with id: \`${i}\` does not exist. Please provide a valid id.`)}},_=class extends O{constructor(i,s,r,a){super(`Failed to ${r} ${N(i)} with id: \`${s}\``,{cause:a});this.statusCode=502}};var H=class extends b{constructor(i){super("provider",i);this.code="ProviderNotFoundError"}},Q=class extends _{constructor(i,s,r){super("provider",i,s,r);this.code="ProviderExecutionFailedError"}};var Z=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"}},ee=class extends f{constructor(){super("Signature not found. Please provide a signature in the `novu-signature` header");this.code="SignatureNotFoundError"}},te=class extends f{constructor(){super("Signature is invalid. Please provide a valid signature in the `novu-signature` header");this.code="SignatureInvalidError"}},ie=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"}},ne=class extends f{constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.secretKey`");this.code="SigningKeyNotFoundError"}},oe=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 se=class extends b{constructor(i){super("step",i);this.code="StepNotFoundError"}},re=class extends A{constructor(i){super("step",i);this.code="StepAlreadyExistsError"}},ae=class extends _{constructor(i,s,r){super("step",i,s,r);this.code="StepExecutionFailedError"}};var pe=class extends b{constructor(i){super("workflow",i);this.code="WorkflowNotFoundError"}},le=class extends A{constructor(i){super("workflow",i);this.code="WorkflowAlreadyExistsError"}};function k(e,n){let i=n.split(".").reduce((s,r)=>{if(s&&typeof s=="object")return s[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 s=JSON.stringify(i);return s==="{}"?"":s}return""}function ce(e,n=2,i,s=", "){if(!Array.isArray(e)||e.length===0)return"";let r=i?e.map(l=>typeof l!="object"||!l?"":k(l,i)):e;if(r.length===1)return r[0];if(r.length===2)return`${r[0]} and ${r[1]}`;if(r.length===3&&n>=3)return`${r[0]}, ${s}${r[1]} and ${r[2]}`;let a=r.slice(0,n),w=r.length-n;return`${a.join(s)} and ${w} ${w===1?"other":"others"}`}var Pe=be(require("pluralize"),1);function de(e,n="",i="",s="true"){if(e==null)return"";let r=0;if(Array.isArray(e)?r=e.length:typeof e=="object"?r=Object.keys(e).length:typeof e=="string"?r=+e:typeof e=="number"?r=e:r=Number(e),Number.isNaN(r)&&(r=0),r<=0)return"";let a;return i?a=r===1?n:i:a=(0,Pe.default)(n,r),s==="true"?`${r} ${a}`:a}var ue=require("liquidjs"),Ne=be(require("pluralize"),1),T=require("zod");var ke="",Ce=2,De="other",Ue=", ",Me=" and ",Le=", and ",Ee={0:"keyPath",1:"limit",2:"overflowSuffix",3:"wordsConnector",4:"twoWordsConnector",5:"lastWordConnector"};function he(e,n=ke,i=Ce,s=De,r=Ue,a=Me,w=Le){if(!Array.isArray(e)||e.length===0)return"";let l=n?e.map(y=>typeof y!="object"||!y?"":k(y,n)):e,m=l.length;if(m===1)return l[0];if(m===2)return`${l[0]}${a}${l[1]}`;if(i>=m){let y=l.slice(0,m-1),ge=l[m-1];return`${y.join(r)}${w}${ge}`}let c=l.slice(0,i),S=m-i,d=i===1?a:w;return`${c.join(r)}${d}${S} ${(0,Ne.default)(s,S)}`}function me(e={},...n){let{requireKeyPath:i=!1}=e,s=[];if(n.length<1)return s.push({message:"Expected at least 1 argument",begin:0,end:0,value:""}),s;let r=T.z.object({keyPath:i?T.z.string().min(1,"must be non-empty"):T.z.string().optional().default(ke),limit:T.z.number().optional().default(Ce).refine(l=>l>=0,"must be greater than or equal to 0"),overflowSuffix:T.z.string().optional().default(De),wordsConnector:T.z.string().optional().default(Ue),twoWordsConnector:T.z.string().optional().default(Me),lastWordConnector:T.z.string().optional().default(Le)}),a={};n.forEach((l,m)=>{if(!Array.isArray(l)){let c=l.getText();(l.kind===ue.TokenKind.Quoted||l.kind===ue.TokenKind.Number)&&(c=l.content);let S=Ee[m];a[S]=c}});let w=r.safeParse(a);if(!w.success)for(let l of w.error.issues){let m="string";"type"in l&&(m=l.type);let c=l.path[0],S=Object.entries(Ee).find(([ge,tt])=>tt===c),d=S?parseInt(S[0],10):null,y=typeof d=="number"?n[d]:null;y&&!Array.isArray(y)&&s.push({message:`"toSentence" expects a ${m}${l.message?` that ${l.message}`:""} for argument "${c}"`,begin:y.begin,end:y.end,value:y.getText()})}return s}var ct={toSentence:me};var dt={type:"object",properties:{type:{enum:["regular"]},amount:{type:"number"},unit:{type:"string",enum:["seconds","minutes","hours","days","weeks","months"]},extendToSchedule:{type:"boolean"}},required:["amount","unit"],additionalProperties:!1},ut={type:"object",properties:{type:{enum:["timed"]},cron:{type:"string"},extendToSchedule:{type:"boolean"}},required:["cron"],additionalProperties:!1},ht={type:"object",properties:{type:{enum:["dynamic"]},dynamicKey:{type:"string"},extendToSchedule:{type:"boolean"}},required:["dynamicKey"],additionalProperties:!1},mt={oneOf:[dt,ut,ht]},yt={type:"object",properties:{duration:{type:"number"}},required:["duration"],additionalProperties:!1},Fe={output:mt,result:yt};var gt={type:"object",properties:{type:{enum:["regular"]},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},extendToSchedule:{type:"boolean"}},required:["amount","unit"],additionalProperties:!1},ft={type:"object",properties:{type:{enum:["timed"]},cron:{type:"string"},digestKey:{type:"string"},extendToSchedule:{type:"boolean"}},required:["cron"],additionalProperties:!1},bt={oneOf:[gt,ft]},Tt={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},je={output:bt,result:Tt};var Ye={output:{type:"object",properties:{type:{type:"string",enum:["fixed","dynamic"]},amount:{type:"number"},unit:{type:"string",enum:["minutes","hours","days"]},dynamicKey:{type:"string"},threshold:{type:"number"},throttleKey:{type:"string"}},required:["type"],additionalProperties:!1},result:{type:"object",properties:{throttled:{type:"boolean",description:"Whether the workflow execution was throttled"},executionCount:{type:"number",description:"Number of executions within the throttle window"},threshold:{type:"number",description:"The throttle threshold that was applied"},windowStart:{type:"string",format:"date-time",description:"Start time of the throttle window"}},required:["throttled"],additionalProperties:!1}};var Ve={delay:Fe,digest:je,throttle:Ye};var wt={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},St={type:"object",properties:{},required:[],additionalProperties:!1},qe={output:wt,result:St};var Ot={type:"object",properties:{subject:{type:"string",minLength:1},body:{type:"string"}},required:["subject","body"],additionalProperties:!1},At={type:"object",properties:{},required:[],additionalProperties:!1},We={output:Ot,result:At};var _t="^(?!mailto:)(?:(https?):\\/\\/[^\\s/$.?#].[^\\s]*)|^(\\/[^\\s]*)$",Ge={type:"object",properties:{url:{type:"string",pattern:_t},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},Je={type:"object",properties:{label:{type:"string"},redirect:Ge},required:["label"],additionalProperties:!1},Rt={type:"object",properties:{subject:{type:"string",minLength:1},body:{type:"string",minLength:1},avatar:{type:"string",format:"uri"},primaryAction:Je,secondaryAction:Je,data:{type:"object",additionalProperties:!0},redirect:Ge},anyOf:[{required:["subject"]},{required:["body"]}],additionalProperties:!1},xt={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},$e={output:Rt,result:xt};var vt={type:"object",properties:{subject:{type:"string"},body:{type:"string"}},required:["subject","body"],additionalProperties:!1},It={type:"object",properties:{},required:[],additionalProperties:!1},Be={output:vt,result:It};var Pt={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},Et={type:"object",properties:{},required:[],additionalProperties:!1},ze={output:Pt,result:Et};var Xe={chat:qe,sms:ze,push:Be,email:We,in_app:$e};var Ke=(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))(Ke||{});var He=(r=>(r.NONE="none",r.LOW="low",r.MEDIUM="medium",r.HIGH="high",r))(He||{});var Qe=require("liquidjs");function Nt(e){return Array.isArray(e)||typeof e=="object"&&e!==null?Ze(e):typeof e=="string"&&e.includes(` `)?e.replace(/\n/g,"\\n"):e==null?"":String(e)}var Ze=(e,n=0)=>Array.isArray(e)||typeof e=="object"&&e!==null?JSON.stringify(e,null,n).replace(/"/g,"'").replace(/\n/g,"\\n"):e==null?"":String(e);function et(e){let n=new Qe.Liquid({outputEscape:Nt,...e});return n.registerFilter("json",(i,s)=>Ze(i,s)),n.registerFilter("digest",ce),n.registerFilter("toSentence",he),n.registerFilter("pluralize",de),n}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,SeverityLevelEnum,SignatureExpiredError,SignatureInvalidError,SignatureMismatchError,SignatureNotFoundError,SignatureVersionInvalidError,SigningKeyNotFoundError,StepAlreadyExistsError,StepControlCompilationFailedError,StepExecutionFailedError,StepNotFoundError,UnauthorizedError,WorkflowAlreadyExistsError,WorkflowChannelEnum,WorkflowNotFoundError,WorkflowPayloadInvalidError,actionStepSchemas,channelStepSchemas,createLiquidEngine,digest,isFrameworkError,isNativeError,pluralize,toSentence,toSentenceArgsValidator});