Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: ExpressJS Quickstart = Directory Import error on Nodejs v20 and Deno v2 #7071

Open
2 tasks done
soccer99 opened this issue Nov 19, 2024 · 3 comments
Open
2 tasks done
Labels

Comments

@soccer99
Copy link

soccer99 commented Nov 19, 2024

📜 Description

I have an expressjs NodeJS (v20) project with type: module and got import errors following the quickstart guide for express.

https://docs.novu.co/quickstart/express

We are hoping to move to Deno v2 (TypeScript) soon, so I ran the project in Deno + TypeScript and got error:

error: [ERR_UNSUPPORTED_DIR_IMPORT] Directory import 'file:///<user>/backend/node_modules/.deno/@[email protected]/node_modules/@novu/shared/dist/esm/config' is not supported resolving ES modules imported from 'file:///<user>/backend/node_modules/.deno/@[email protected]/node_modules/@novu/shared/dist/esm/index.js'

👟 Reproduction steps

Run expressjs in Node.js v20 and set "type": "module",.

OR

Setup expressjs in Deno V2 using TypeScript

Quickstart guide for express and has export error in both.

👍 Expected behavior

No export error.

👎 Actual Behavior with Screenshots

Terminal error is pasted above:

Novu version

Novu SaaS

@novu/[email protected]

EDIT:

This error does not occur on @novu/[email protected]

npm version

NA

node version

v20.18.0

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

None

@soccer99
Copy link
Author

This is a lot of text but this is the error I get on Node.js v20

file:///Users/<me>/code/greco/backend/node_modules/@novu/framework/dist/esm/chunk-SZGUSA3L.js:1
import{$ as gr,A as Cn,B as dr,C as $n,D as xn,E as Dn,F as Fn,G as Wn,H as Un,I as jn,J as hr,K as Bn,L as mr,M as Vn,N as Yn,R as Hn,S as qn,T as Kn,U as Jn,V as Gn,W as Qn,X as Zn,Z as zn,_ as Xn,aa as yr,c as _t,ca as pt,d as fr,da as ei,ea as ti,fa as wr,g as Nn,ga as Sr,ia as We,ja as Fe,o as pr,w as Ln,z as It}from"./chunk-J2MPR7MB.js";import{Liquid as Ls}from"liquidjs";var ri=async($,s)=>{let d=new TextEncoder,y=d.encode($),P=d.encode(s),j=await crypto.subtle.importKey("raw",y,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),x=await crypto.subtle.sign("HMAC",j,P);return Array.from(new Uint8Array(x)).map(te=>te.toString(16).padStart(2,"0")).join("")};import{Response as Rs}from"cross-fetch";var Us=()=>typeof Response!="undefined"?Response:Rs,ni=async()=>{if(process.env.NOVU_BRIDGE_ORIGIN)return`${process.env.NOVU_BRIDGE_ORIGIN}/api/novu`;if(process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"&&process.env.NEXT_PUBLIC_VERCEL_URL)return`https://${process.env.NEXT_PUBLIC_VERCEL_URL}/api/novu`;try{if(process.env.NODE_ENV==="development"){let s=await(await fetch("http://localhost:2022/.well-known/novu")).json();return`${s.tunnelOrigin}${s.route}`}}catch($){console.error($)}return""};import{checkIsResponseError as _s}from"@novu/shared";var Mt=($,s)=>{if(!$)throw new Vn;return{post:async(d,y)=>{let P=await fetch(`${s}/v1${d}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${$}`},body:JSON.stringify(y)}),j=await P.json();if(P.ok)return j;throw _s(j)?new Yn(j.statusCode,j.error,j.message):new It(j)},delete:async d=>(await fetch(`${s}/v1${d}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${$}`}})).json()}};import tt from"chalk";var me={info:$=>tt.blue($),warning:$=>tt.yellow($),error:$=>tt.red($),success:$=>tt.green($),underline:$=>tt.underline($),bold:$=>tt.bold($)},Ae={SUCCESS:me.success("\u2714"),ERROR:me.error("\u2717"),WARNING:me.warning("\u26A0"),INFO:me.info("\u2139"),ARROW:me.bold("\u2192"),MOCK:me.info("\u25CB"),HYDRATED:me.bold(me.info("\u2192")),STEP:me.info("\u03C3"),ACTION:me.info("\u03B1"),DURATION:me.info("\u0394"),PROVIDER:me.info("\u2699"),OUTPUT:me.info("\u21E2"),INPUT:me.info("\u21E0"),WORKFLOW:me.info("\u03C9"),STATE:me.info("\u03C3"),EXECUTE:me.info("\u03B5"),PREVIEW:me.info("\u03C1")};function kt($){return $||process.env.NOVU_API_URL||"https://api.novu.co"}function Nt($){return $||process.env.NOVU_SECRET_KEY||process.env.NOVU_API_KEY||""}import si from"sanitize-html";var Is={allowedTags:si.defaults.allowedTags.concat(["style","img","html","head","body","link","meta","title"]),allowedAttributes:!1,allowVulnerableTags:!0,parseStyleAttributes:!1,parser:{lowerCaseAttributeNames:!0}},ii=$=>{if(!$)return $;let s=/^<!DOCTYPE .*?>/,d=$.match(s),y=si($,Is);return d?d[0]+y:y},Lt=$=>Object.keys($).reduce((s,d)=>{let y=$[d];return typeof y=="string"?s[d]=ii(y):Array.isArray(y)?s[d]=y.map(P=>typeof P=="string"?ii(P):typeof P=="object"?Lt(P):P):typeof y=="object"&&y!==null?s[d]=Lt(y):s[d]=y,s},{});import ks from"ajv";import Ns from"ajv-formats";var oi=$=>typeof structuredClone=="function"?structuredClone($):JSON.parse(JSON.stringify($));var Ct=class extends Ln{constructor(d,y){let P=y.length===1?"it":"them";super(`Tried to use a ${d} in @novu/framework without ${y.join(", ")} installed. Please install ${P} by running \`npm install ${y.join(" ")}\`.`);this.statusCode=500;this.code="MissingDependencyError"}};var $t=async($,s)=>{let d=new Set;if((await Promise.allSettled($.map(P=>P.import))).forEach((P,j)=>{let x=$[j];P.status==="fulfilled"&&x.exports.every(ae=>P.value[ae]!==void 0)||d.add(x.name)}),d.size>0)throw new Ct(s,Array.from(d))};var xt=class{constructor(){this.requiredImports=[];this.ajv=new ks({useDefaults:!0,removeAdditional:"failing"}),Ns(this.ajv),this.compiledSchemas=new Map}async canHandle(s){let d=s.type==="object"||!!s.anyOf||!!s.allOf||!!s.oneOf;return d&&await $t(this.requiredImports,"JSON schema"),d}async validate(s,d){let y=this.compiledSchemas.get(d);y||(y=this.ajv.compile(d),this.compiledSchemas.set(d,y));let P=oi(s);return y(P)?{success:!0,data:P}:{success:!1,errors:y.errors.map(x=>({path:x.instancePath,message:x.message}))}}async transformToJsonSchema(s){return s}};var Dt=class{constructor(){this.requiredImports=[{name:"zod",import:import("zod"),exports:["ZodType"]},{name:"zod-to-json-schema",import:import("zod-to-json-schema"),exports:["zodToJsonSchema"]}]}async canHandle(s){let d=s.safeParseAsync!==void 0;return d&&await $t(this.requiredImports,"Zod schema"),d}async validate(s,d){let y=await d.safeParseAsync(s);return y.success?{success:!0,data:y.data}:{success:!1,errors:y.error.errors.map(P=>({path:`/${P.path.join("/")}`,message:P.message}))}}async transformToJsonSchema(s){let{zodToJsonSchema:d}=await import("zod-to-json-schema");return d(s)}};var Ft=new Dt,Wt=new xt,Ut=async($,s)=>{if(await Ft.canHandle($))return Ft.validate(s,$);if(await Wt.canHandle($))return Wt.validate(s,$);throw new Error("Invalid schema")},Re=async $=>{if(await Ft.canHandle($))return Ft.transformToJsonSchema($);if(await Wt.canHandle($))return Wt.transformToJsonSchema($);throw new Error("Invalid schema")};var jt=(()=>{var $=Object.defineProperty,s=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,y=Object.prototype.hasOwnProperty,P=(e,t)=>function(){return e&&(t=(0,e[d(e)[0]])(e=0)),t},j=(e,t)=>function(){return t||(0,e[d(e)[0]])((t={exports:{}}).exports,t),t.exports},x=(e,t)=>{for(var r in t)$(e,r,{get:t[r],enumerable:!0})},te=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of d(t))!y.call(e,l)&&l!==r&&$(e,l,{get:()=>t[l],enumerable:!(a=s(t,l))||a.enumerable});return e},ae=e=>te($({},"__esModule",{value:!0}),e),ve={};x(ve,{JSONSchemaFaker:()=>Mn,default:()=>kn,setDependencies:()=>Yr});function ke(e,t){return typeof e=="string"?typeof t!="undefined"?at.register(e,t):at.get(e):at.registerMany(e)}function Le(e,t){return e=typeof e=="undefined"?Ve.MIN_INTEGER:e,t=typeof t=="undefined"?Ve.MAX_INTEGER:t,Math.floor(z("random")()*(t-e+1))+e}function be(e){return vt.default.prototype.max=z("defaultRandExpMax"),vt.default.prototype.randInt=(r,a)=>r+Math.floor(z("random")()*(1+(a-r))),new vt.default(e).gen()}function Ne(e){return e[Math.floor(z("random")()*e.length)]}function $e(e){let t,r,a=e.length,l=e.slice();for(;a>0;)r=Math.floor(z("random")()*a),a-=1,t=l[a],l[a]=l[r],l[r]=t;return l}function Qe(e,t){return z("random")()*(t-e)+e}function Ue(e,t,r,a,l=!1){return r=typeof r=="undefined"?Ve.MIN_NUMBER:r,a=typeof a=="undefined"?Ve.MAX_NUMBER:a,e=typeof e=="undefined"?r:e,t=typeof t=="undefined"?a:t,t<e&&(t+=e),l?Qe(e,t):Le(e,t)}function yt(e){switch(e){case"seconds":return Ue(0,60)*60;case"minutes":return Ue(15,50)*612;case"hours":return Ue(12,72)*36123;case"days":return Ue(7,30)*86412345;case"weeks":return Ue(4,52)*604812345;case"months":return Ue(2,13)*2592012345;case"years":return Ue(1,20)*31104012345;default:break}}function Bt(e){if(e)return yt(e);let t=z("minDateTime"),r=z("maxDateTime");typeof t=="string"&&(t=new Date(t)),typeof r=="string"&&(r=new Date(r));let a=new Date().getTime();return typeof t=="number"&&(t=new Date(a+t)),typeof r=="number"&&(r=new Date(a+r)),new Date(Qe(t.getTime(),r.getTime()))}function br(e,t,r){if(t=decodeURIComponent(t),r&&r[t])return St(r[t]);let a=t.replace("#/","/").split("/"),l=e.$ref&&r&&r[e.$ref]||e;for(!l&&!a[0]&&(a[0]=e.$ref.split("#/")[0]),r&&t.includes("#/")&&r[a[0]]&&(l=r[a.shift()]),a[0]||a.shift();l&&a.length>0;){let f=a.shift();if(!l[f])throw new Error(`Prop not found: ${f} (${t})`);l=l[f]}return l}function wt(e){return typeof e=="string"&&en.test(e)}function je(e){return["number","boolean"].includes(typeof e)}function Be(e,...t){return t.filter(r=>typeof e[r]!="undefined").length>0}function Tr(e){if(e.includes(" "))return new Date(e).toISOString().substr(0,10);let[t,r,a]=e.split("T")[0].split("-");return r=`0${Math.max(1,Math.min(12,r))}`.slice(-2),a=`0${Math.max(1,Math.min(31,a))}`.slice(-2),`${t}-${r}-${a}`}function wi(e){if(e.includes(" "))return new Date(e).toISOString().substr(0,10);let[t,r]=e.split("T"),[a,l,f]=t.split("-"),[c,E,C]=r.substr(0,8).split(":");return l=`0${Math.max(1,Math.min(12,l))}`.slice(-2),f=`0${Math.max(1,Math.min(31,f))}`.slice(-2),c=`0${Math.max(1,Math.min(23,c))}`.slice(-2),E=`0${Math.max(1,Math.min(59,E))}`.slice(-2),C=`0${Math.max(1,Math.min(59,C))}`.slice(-2),`${a}-${l}-${f}T${c}:${E}:${C}.000Z`}function Si(e,t,r){let a={};switch(e||t.type){case"integer":case"number":if(typeof t.minimum!="undefined"&&(a.minimum=t.minimum),typeof t.maximum!="undefined"&&(a.maximum=t.maximum),t.enum){let f=Math.max(a.minimum||0,0),c=Math.min(a.maximum||1/0,1/0);t.exclusiveMinimum&&f===t.minimum&&(f+=t.multipleOf||1),t.exclusiveMaximum&&c===t.maximum&&(c-=t.multipleOf||1),(f||c!==1/0)&&(t.enum=t.enum.filter(E=>E>=f&&E<=c))}break;case"string":{a.minLength=z("minLength")||0,a.maxLength=z("maxLength")||Number.MAX_SAFE_INTEGER,typeof t.minLength!="undefined"&&(a.minLength=Math.max(a.minLength,t.minLength)),typeof t.maxLength!="undefined"&&(a.maxLength=Math.min(a.maxLength,t.maxLength));break}default:break}let l=r(a);if(l==null)return null;switch(e||t.type){case"number":l=wt(l)?parseFloat(l):l;break;case"integer":l=wt(l)?parseInt(l,10):l;break;case"boolean":l=!!l;break;case"string":{if(je(l))return l;l=String(l);let f=Math.max(a.minLength||0,0),c=Math.min(a.maxLength||1/0,1/0),E,C=0;for(;l.length<f;)if(E=l,t.pattern?l+=Q.randexp(t.pattern):l+=`${Q.pick([" ","/","_","-","+","=","@","^"])}${l}`,l===E){if(C+=1,C===3)break}else C=0;switch(l.length>c&&(l=l.substr(0,c)),t.format){case"date-time":case"datetime":l=new Date(wi(l)).toISOString().replace(/([0-9])0+Z$/,"$1Z");break;case"full-date":case"date":l=new Date(Tr(l)).toISOString().substr(0,10);break;case"time":l=new Date(`1969-01-01 ${l}`).toISOString().substr(11);break;default:break}break}default:break}return l}function ze(e,t){return Object.keys(t).forEach(r=>{typeof t[r]!="object"||t[r]===null?e[r]=t[r]:Array.isArray(t[r])?(e[r]=e[r]||[],t[r].forEach((a,l)=>{e.type==="array"&&t.type==="array"?e[r][l]=ze(e[r][l]||{},a,!0):Array.isArray(e[r])&&e[r].indexOf(a)===-1&&e[r].push(a)})):typeof e[r]!="object"||e[r]===null||Array.isArray(e[r])?e[r]=ze({},t[r]):e[r]=ze(e[r],t[r])}),e}function St(e,t=new Map){if(!e||typeof e!="object")return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){let a=[];return t.set(e,a),a.push(...e.map(l=>St(l,t))),a}let r={};return t.set(e,r),Object.keys(e).reduce((a,l)=>(a[l]=St(e[l],t),a),r)}function Ei(e){let t=JSON.stringify(e),r=JSON.stringify(e,null,2);return t.length>400?`${r.substr(0,400)}...`:r}function Pr(){return Q.pick([!1,!0,null,-1,NaN,Math.PI,1/0,void 0,[],{},Math.random(),Math.random().toString(36).substr(2)])}function vi(e,t){if(e.enum)return e.enum.includes(t);if(e.const)return e.const===t}function Oi(e,t){let r=ze({},t);if(typeof e.minimum!="undefined"&&(r.maximum=e.minimum,r.exclusiveMaximum=!0),typeof e.maximum!="undefined"&&(r.minimum=e.maximum>r.maximum?0:e.maximum,r.exclusiveMinimum=!0),typeof e.minLength!="undefined"&&(r.maxLength=e.minLength),typeof e.maxLength!="undefined"&&(r.minLength=e.maxLength>r.maxLength?0:e.maxLength),e.type)r.type=Q.pick(Ve.SCALAR_TYPES.filter(a=>(Array.isArray(e.type)?e.type:[e.type]).every(f=>a==="number"||a==="integer"?f!=="number"&&f!=="integer":a!==f)));else if(e.enum){let a;do a=Pr();while(e.enum.indexOf(a)!==-1);r.enum=[a]}return e.required&&r.properties&&e.required.forEach(a=>{delete r.properties[a]}),r}function Vt(e,t){let r=t.minimum!==void 0,a=t.maximum!==void 0;return(r||a)&&(!r||e>=t.minimum)&&(!a||e<=t.maximum)}function Ai(e,t){return!t.every(r=>Vt(e,r))}function bi(e,t){return t.reduce((a,l)=>a+(Vt(e,l)?1:0),0)===1}function Ti(e){return["enum","const","default","examples","required","definitions","items","properties"].includes(e)}function Pi(e,t){return Object.keys(e).filter(r=>!t.includes(r)).reduce((r,a)=>(Array.isArray(e[a])?r[a]=e[a].slice():r[a]=e[a]instanceof Object?ze({},e[a]):e[a],r),{})}function Rr(e,t){return Array.isArray(e)?e.map(r=>Rr(r,t)):(typeof e=="string"&&(e=e.replace(/#\{([\w.-]+)\}/g,(r,a)=>t[a])),e)}function Yt(e){return Object.prototype.toString.call(e)==="[object Object]"&&!Object.keys(e).length}function _r(e,t){t=t.items||t;let r=z("alwaysFakeOptionals"),a=Array.isArray(t.required)&&t.required.includes(e)||r,l=typeof t.thunk=="function"||t.additionalProperties&&typeof t.additionalProperties.thunk=="function";return!a&&!l}function Ht(e,t,r=!1){if(!e||typeof e!="object")return e;if(Array.isArray(e))return e.map(a=>Ht(a,t,!0)).filter(a=>typeof a!="undefined");if(Object.keys(e).forEach(a=>{if(Yt(e[a]))_r(a,t)&&delete e[a];else{let l=t;t&&t.properties&&t.properties[a]&&(l=t.properties[a]);let f=Ht(e[a],l);Yt(f)||(e[a]=f)}typeof e[a]=="undefined"&&delete e[a]}),!(!Object.keys(e).length&&r))return e}function Ri(e){return(t,r,a,l)=>{let f=t,c=[];typeof t=="object"&&(f=Object.keys(t)[0],Array.isArray(t[f])?c=t[f]:c.push(t[f]));let E=f.split("."),C=e();for(;E.length>1;)C=C[E.shift()];return t=typeof C=="object"?C[E[0]]:C,typeof t=="function"&&(t=t.apply(C,c.map(S=>ue.template(S,l)))),Object.prototype.toString.call(t)==="[object Object]"&&Object.keys(t).forEach(S=>{if(typeof t[S]=="function")throw new Error(`Cannot resolve value for '${a}: ${f}', given: ${t}`)}),t}}function _i(e,t){if(typeof e=="undefined")return et.list();if(typeof e=="string")if(typeof t=="function")et.register(e,t);else if(t===null||t===!1)et.unregister(e);else return et.get(e);else et.registerMany(e)}function Ii(e,t,r){return Object.keys(e).filter(a=>{let l=sn.indexOf(t)>-1;return r.indexOf(a)>-1&&!l}).length>0}function Mi(e,t){let r=Object.keys(lt);for(let a=0;a<r.length;a+=1){let l=r[a],f=t[t.length-1];if(Ii(e,f,lt[l]))return l}}function ki(){return z("random")()>.5}function Ni(){return null}function Li(e,t,r,a,l,f){let c=[],E=[];function C(D){let A=JSON.stringify(D.value);return E.indexOf(A)===-1?(E.push(A),c.push(D),!0):!1}t.forEach(C);let S=100;for(;c.length!==t.length&&(C(f(r.items||a,e,l))||(S-=1),!!S););return c}function Ci(e,t,r,a){let l=[];if(!(e.items||e.additionalItems)){if(ue.hasProperties(e,"minItems","maxItems","uniqueItems")&&(e.minItems!==0||e.maxItems!==0))throw new Ot(`missing items for ${ue.short(e)}`,t);return l}if(Array.isArray(e.items))return e.items.map((U,ie)=>{let G=t.concat(["items",ie]);return a(U,G,r)});let f=e.minItems,c=e.maxItems,E=z("minItems"),C=z("maxItems");E&&(f=typeof f=="undefined"?E:Math.min(E,f)),C&&(c=typeof c=="undefined"?C:Math.min(C,c),c&&c>C&&(c=C),f&&f>C&&(f=c));let S=z("alwaysFakeOptionals")===!0?1:z("optionalsProbability"),D=z("alwaysFakeOptionals")||z("fixedProbabilities")||!1,A=Q.number(f,c,1,5);S!==null&&(A=Math.max(D?Math.round((c||A)*S):Math.abs(Q.number(f,c)*S),f||0));let Y=typeof e.additionalItems=="object"?e.additionalItems:{};for(let U=l.length;U<A;U+=1){let ie=t.concat(["items",U]),G=a(e.items||Y,ie,r);l.push(G)}if(e.contains&&A>0){let U=Q.number(0,A-1);l[U]=a(e.contains,t.concat(["items",U]),r)}return e.uniqueItems?Li(t.concat(["items"]),l,e,Y,r,a):l}function $i(e){let t=typeof e.minimum=="undefined"||e.minimum===-Number.MAX_VALUE?Ve.MIN_INTEGER:e.minimum,r=typeof e.maximum=="undefined"||e.maximum===Number.MAX_VALUE?Ve.MAX_INTEGER:e.maximum,a=e.multipleOf,l=a&&String(a).match(/e-(\d)|\.(\d+)$/);if(l){let f=(Math.random()*Q.number(0,10)+1)*a,c=l[1]||l[2].length,E=parseFloat(f.toFixed(c)),C=Q.number(t,r-1);return String(E).includes(".")?C+E:(C+E).toExponential()}if(a&&(r=Math.floor(r/a)*a,t=Math.ceil(t/a)*a),e.exclusiveMinimum&&t===e.minimum&&(t+=a||1),e.exclusiveMaximum&&r===e.maximum&&(r-=a||1),t>r)return NaN;if(a){let f=Q.number(Math.floor(t/a),Math.floor(r/a))*a;for(;f<t;)f+=a;return f}return Q.number(t,r,void 0,void 0,e.type!=="integer")}function xi(e){return Math.floor(or({...e}))}function Di(e){return Q.shuffle(mn).slice(0,e)}function Fi(e,t,r,a){let l={},f=e.properties||{},c=e.patternProperties||{},E=typeof e.required=="boolean"?[]:(e.required||[]).slice(),C=e.additionalProperties!==!1,S=Object.keys(f),D=Object.keys(c),A=S.concat(D).reduce((W,p)=>(E.indexOf(p)===-1&&W.push(p),W),[]),Y=E.concat(A),U=C&&e.additionalProperties===!0?bt:e.additionalProperties;if(!C&&S.length===0&&D.length===0&&ue.hasProperties(e,"minProperties","maxProperties","dependencies","required"))return null;if(z("requiredOnly")===!0)return E.forEach(W=>{f[W]&&(l[W]=f[W])}),a(l,t.concat(["properties"]),r,e);let ie=z("alwaysFakeOptionals")===!0?1:z("optionalsProbability"),G=z("alwaysFakeOptionals")||z("fixedProbabilities")||!1,X=z("ignoreProperties")||[],fe=z("reuseProperties"),de=z("fillProperties"),F=e.maxProperties||Y.length+(C?Q.number(1,5):0),g=Math.max(e.minProperties||0,E.length),w=Math.max(0,Y.length-g);Y.length===1&&!E.length&&(g=Math.max(Q.number(de?1:0,F),g)),ie!==null&&(G===!0?w=Math.round(g-E.length+ie*(Y.length-g)):w=Q.number(g-E.length,ie*(Y.length-g)));let T=Q.shuffle(A).slice(0,w),_=A.filter(W=>T.indexOf(W)!==-1),N=ie!==null||E.length===F?F:Q.number(0,F),b=E.concat(Q.shuffle(_).slice(0,N)).slice(0,F),I=[],k=[];if(e.dependencies&&(Object.keys(e.dependencies).forEach(W=>{let p=e.dependencies[W];if(b.indexOf(W)!==-1)if(Array.isArray(p))p.forEach(M=>{b.indexOf(M)===-1&&b.push(M)});else if(Array.isArray(p.oneOf||p.anyOf)){let M=p.oneOf||p.anyOf;k.push({prop:W,values:M})}else I.push(p)}),I.length))return delete e.dependencies,a({allOf:I.concat(e)},t.concat(["properties"]),r,e);let B=[],H=[];b.forEach(W=>{if(f[W]&&["{}","true"].includes(JSON.stringify(f[W].not)))return;for(let M=0;M<X.length;M+=1)if(X[M]instanceof RegExp&&X[M].test(W)||typeof X[M]=="string"&&X[M]===W||typeof X[M]=="function"&&X[M](f[W],W)){B.push(W);return}U===!1&&E.indexOf(W)!==-1&&(l[W]=f[W]),f[W]&&(l[W]=f[W]);let p;if(D.forEach(M=>{W.match(new RegExp(M))&&(p=!0,l[W]?ue.merge(l[W],c[M]):l[Q.randexp(W)]=c[M])}),!p){let M=c[W]||U;M&&U!==!1?l[c[W]?Q.randexp(W):W]=f[W]||M:H.push(W)}});let Z=Object.keys(l).length+(de?0:B.length),we=W=>Q.randexp(`_?[_a-f\\d]{1,3}${W?"\\$?":""}`);function Se(W){let p;do{if(!W.length)break;p=W.shift()}while(l[p]);return p}let Oe=g;if(C&&!E.length&&(Oe=Math.max(ie===null||U?Q.number(de?1:0,F):0,g)),!_.length&&!w&&C&&G===!0&&de){let W=Q.number(0,F);for(let p=0;p<W;p+=1)l[At(1)+we(W[p])]=U||bt}for(;de&&!(!(D.length||C)||Z>=Oe);){if(C)if(fe&&S.length-Z>Oe){let W=0,p;do{if(W+=1,W>1e3)break;p=Se(E)||Q.pick(S)}while(typeof l[p]!="undefined");typeof l[p]=="undefined"&&(l[p]=f[p],Z+=1)}else if(D.length&&!U){let W=Q.pick(D),p=Q.randexp(W);l[p]||(l[p]=c[W],Z+=1)}else{let W=Se(E)||At(1)+we();l[W]||(l[W]=U||bt,Z+=1)}for(let W=0;Z<g&&W<D.length;W+=1){let p=D[W],M=Q.randexp(p);l[M]||(l[M]=c[p],Z+=1)}}if(E.length===0&&(!C||ie===!1)){let W=Q.number(g,F);for(;Z<W;){let p=Se(S);p&&(l[p]=f[p]),Z+=1}}let Te=l;if(z("sortProperties")!==null){let W=Object.keys(f);Te=Object.keys(l).sort((M,q)=>z("sortProperties")?M.localeCompare(q):W.indexOf(M)-W.indexOf(q)).reduce((M,q)=>(M[q]=l[q],M),{})}let _e=a(Te,t.concat(["properties"]),r,e);return k.forEach(W=>{for(let p of W.values)if(ue.hasValue(p.properties[W.prop],_e.value[W.prop])){Object.keys(p.properties).forEach(M=>{M!==W.prop&&ue.merge(_e.value,a(p.properties,t.concat(["properties"]),r,e).value)});break}}),_e}function Ir(){let e=Q.number(1,5);return At(e).join(" ")}function Wi(e=0,t=140){let r=Math.max(0,e),a=Q.number(r,t),l=Ir();for(;l.length<r;)l+=Ir();return l.length>a&&(l=l.substr(0,a)),l}function Ui(){return[0,0,0,0].map(()=>Q.number(0,255)).join(".")}function ji(){return Q.date().toISOString()}function Bi(){return Tt().slice(0,10)}function Vi(){return Tt().slice(11)}function Yi(e){return Q.randexp(xe[e]).replace(vn,(t,r)=>Q.randexp(xe[r]))}function Hi(e,t){let r=sr(e.format);if(typeof r=="function")return r(e);switch(e.format){case"date-time":case"datetime":return Tt();case"date":return wn();case"time":return Sn();case"ipv4":return yn();case"regex":return".+?";case"email":case"hostname":case"ipv6":case"uri":case"uri-reference":case"iri":case"iri-reference":case"idn-email":case"idn-hostname":case"json-pointer":case"slug":case"uri-template":case"uuid":case"duration":return On(e.format);default:if(typeof r=="undefined"){if(z("failOnInvalidFormat"))throw new Error(`unknown registry key ${ue.short(e.format)}`);return t()}throw new Error(`unsupported format '${e.format}'`)}}function qi(e){return ue.typecast("string",e,r=>e.format?Hi(e,()=>ar(r.minLength,r.maxLength)):e.pattern?Q.randexp(e.pattern):ar(r.minLength,r.maxLength))}function Ki({$comment:e,title:t,description:r}){return Object.entries({comment:e,title:t,description:r}).filter(([,a])=>a).reduce((a,[l,f])=>(a[l]=f,a),{})}function Xe(e,t,r,a){if(e=r(e,null,t),e&&(e.oneOf||e.anyOf||e.allOf)&&(e=r(e,null,t)),!e)throw new Error(`Cannot traverse at '${t.join(".")}', given '${JSON.stringify(a)}'`);let l={...Ki(e),schemaPath:t};if(t[t.length-1]!=="properties"){if(z("useExamplesValue")&&Array.isArray(e.examples)){let S=e.examples.concat("default"in e?[e.default]:[]);return{value:ue.typecast(null,e,()=>Q.pick(S)),context:l}}if(z("useExamplesValue")&&typeof e.example!="undefined")return{value:ue.typecast(null,e,()=>e.example),context:l};if(z("useDefaultValue")&&"default"in e&&(e.default!==""||!z("replaceEmptyByRandomValue")))return{value:e.default,context:l};if("template"in e)return{value:ue.template(e.template,a),context:l};if("const"in e)return{value:e.const,context:l}}if(e.not&&typeof e.not=="object"&&(e=ue.notValue(e.not,ue.omitProps(e,["not"])),e.type&&e.type==="object")){let{value:S,context:D}=Xe(e,t.concat(["not"]),r,a);return{value:ue.clean(S,e,!1),context:{...l,items:D}}}if(typeof e.thunk=="function"){let{value:S,context:D}=Xe(e.thunk(a),t,r);return{value:S,context:{...l,items:D}}}if(e.jsonPath)return{value:e,context:l};let f=e.type;if(Array.isArray(f)?f=Q.pick(f):typeof f=="undefined"&&(f=on(e,t)||f,f&&(e.type=f)),typeof e.generate=="function"){let S=ue.typecast(null,e,()=>e.generate(a,t)),D=S===null?"null":typeof S;if(D===f||D==="number"&&f==="integer"||Array.isArray(S)&&f==="array")return{value:S,context:l}}if(typeof e.pattern=="string")return{value:ue.typecast("string",e,()=>Q.randexp(e.pattern)),context:l};if(Array.isArray(e.enum))return{value:ue.typecast(null,e,()=>Q.pick(e.enum)),context:l};if(typeof f=="string")if(ut[f])try{let S=ut[f](e,t,r,Xe);return f==="array"?{value:S.map(({value:D})=>D),context:{...l,items:S.map(Array.isArray(e.items)?({context:D})=>D:({context:D})=>({...D,schemaPath:D.schemaPath.slice(0,-1)}))}}:f==="object"?S!==null?{value:S.value,context:{...l,items:S.context}}:{value:{},context:l}:{value:S,context:l}}catch(S){throw typeof S.path=="undefined"?new Ot(S.stack,t):S}else{if(z("failOnInvalidTypes"))throw new Ot(`unknown primitive ${ue.short(f)}`,t.concat(["type"]));{let S=z("defaultInvalidTypeProduct");return typeof S=="string"&&ut[S]?{value:ut[S](e,t,r,Xe),context:l}:{value:S,context:l}}}let c={},E={...l};Array.isArray(e)&&(c=[]);let C=z("pruneProperties")||[];return Object.keys(e).forEach(S=>{if(!C.includes(S)&&e[S]!==null)if(typeof e[S]=="object"&&S!=="definitions"){let{value:D,context:A}=Xe(e[S],t.concat([S]),r,c);c[S]=ue.clean(D,e[S],!1),E[S]=A,c[S]===null&&z("omitNulls")&&(delete c[S],delete E[S])}else c[S]=e[S]}),{value:c,context:E}}function Ji(e){return Array.isArray(e)?Q.pick(e):e}function Gi(e,t){if(!Array.isArray(e))return e;let r=t?e.pop():e.shift();return t?e.unshift(r):e.push(r),r}function qt(e,t,r,a){if(!e||typeof e!="object")return e;if(r||(r={}),t||(t=e),Array.isArray(e))return e.map(l=>qt(l,t,r,a));if(e.jsonPath){let{JSONPath:l}=er(),f=typeof e.jsonPath!="object"?{path:e.jsonPath}:e.jsonPath;f.group=e.group||f.group||a,f.cycle=e.cycle||f.cycle||!1,f.reverse=e.reverse||f.reverse||!1,f.count=e.count||f.count||1;let c=`${f.group}__${f.path}`;return r[c]||(f.count>1?r[c]=l(f.path,t).slice(0,f.count):r[c]=l(f.path,t)),f.cycle||f.reverse?Gi(r[c],f.reverse):Ji(r[c])}return Object.keys(e).forEach(l=>{e[l]=qt(e[l],t,r,l)}),e}function Qi(e,t,r,a){if(Object.prototype.toString.call(t)!=="[object Object]")throw new Error(`Invalid input, expecting object but given ${typeof t}`);let l=z("refDepthMin")||0,f=z("refDepthMax")||3;try{let{resolveSchema:c}=Rn({refs:e,schema:t,container:r,synchronous:a,refDepthMin:l,refDepthMax:f}),E=Tn(ue.clone(t),[],c);return z("resolveJsonPath")?{value:qt(E.value),context:E.context}:E}catch(c){throw c.path?new Error(`${c.message} in /${c.path.join("/")}`):c}}function Zi(e){return e.value}function zi(e,t){return t.reduce((r,a)=>a in r?r[a]:{},e)}function Kt(e,t,r,a=r){let{title:l,description:f,comment:c}=zi(e,t),E=[];z("renderTitle")&&l&&E.push(` ${l}`,""),z("renderDescription")&&f&&E.push(` ${f}`),z("renderComment")&&c&&E.push(` ${c}`),r.commentBefore=E.join(`

SyntaxError: Named export 'checkIsResponseError' not found. The requested module '@novu/shared' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@novu/shared';
const {$: gr,A: Cn,B: dr,C: $n,D: xn,E: Dn,F: Fn,G: Wn,H: Un,I: jn,J: hr,K: Bn,L: mr,M: Vn,N: Yn,R: Hn,S: qn,T: Kn,U: Jn,V: Gn,W: Qn,X: Zn,Z: zn,_: Xn,aa: yr,c: _t,ca: pt,d: fr,da: ei,ea: ti,fa: wr,g: Nn,ga: Sr,ia: We,ja: Fe,o: pr,w: Ln,z: It}from"./chunk-J2MPR7MB.js";import{Liquid: Ls}from"liquidjs";var ri=async($,s)=>{let d=new TextEncoder,y=d.encode($),P=d.encode(s),j=await crypto.subtle.importKey("raw",y,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),x=await crypto.subtle.sign("HMAC",j,P);return Array.from(new Uint8Array(x)).map(te=>te.toString(16).padStart(2,"0")).join("")};import{Response: Rs}from"cross-fetch";var Us=()=>typeof Response!="undefined"?Response:Rs,ni=async()=>{if(process.env.NOVU_BRIDGE_ORIGIN)return`${process.env.NOVU_BRIDGE_ORIGIN}/api/novu`;if(process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"&&process.env.NEXT_PUBLIC_VERCEL_URL)return`https://${process.env.NEXT_PUBLIC_VERCEL_URL}/api/novu`;try{if(process.env.NODE_ENV==="development"){let s=await(await fetch("http://localhost:2022/.well-known/novu")).json();return`${s.tunnelOrigin}${s.route}`}}catch($){console.error($)}return""};import{checkIsResponseError: _s}from"@novu/shared";var Mt=($,s)=>{if(!$)throw new Vn;return{post:async(d,y)=>{let P=await fetch(`${s}/v1${d}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${$}`},body:JSON.stringify(y)}),j=await P.json();if(P.ok)return j;throw _s(j)?new Yn(j.statusCode,j.error,j.message):new It(j)},delete:async d=>(await fetch(`${s}/v1${d}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${$}`}})).json()}};import tt from"chalk";var me={info:$=>tt.blue($),warning:$=>tt.yellow($),error:$=>tt.red($),success:$=>tt.green($),underline:$=>tt.underline($),bold:$=>tt.bold($)},Ae={SUCCESS:me.success("\u2714"),ERROR:me.error("\u2717"),WARNING:me.warning("\u26A0"),INFO:me.info("\u2139"),ARROW:me.bold("\u2192"),MOCK:me.info("\u25CB"),HYDRATED:me.bold(me.info("\u2192")),STEP:me.info("\u03C3"),ACTION:me.info("\u03B1"),DURATION:me.info("\u0394"),PROVIDER:me.info("\u2699"),OUTPUT:me.info("\u21E2"),INPUT:me.info("\u21E0"),WORKFLOW:me.info("\u03C9"),STATE:me.info("\u03C3"),EXECUTE:me.info("\u03B5"),PREVIEW:me.info("\u03C1")};function kt($){return $||process.env.NOVU_API_URL||"https://api.novu.co"}function Nt($){return $||process.env.NOVU_SECRET_KEY||process.env.NOVU_API_KEY||""}import si from"sanitize-html";var Is={allowedTags:si.defaults.allowedTags.concat(["style","img","html","head","body","link","meta","title"]),allowedAttributes:!1,allowVulnerableTags:!0,parseStyleAttributes:!1,parser:{lowerCaseAttributeNames:!0}},ii=$=>{if(!$)return $;let s=/^<!DOCTYPE .*?>/,d=$.match(s),y=si($,Is);return d?d[0]+y:y},Lt=$=>Object.keys($).reduce((s,d)=>{let y=$[d];return typeof y=="string"?s[d]=ii(y):Array.isArray(y)?s[d]=y.map(P=>typeof P=="string"?ii(P):typeof P=="object"?Lt(P):P):typeof y=="object"&&y!==null?s[d]=Lt(y):s[d]=y,s},{});import ks from"ajv";import Ns from"ajv-formats";var oi=$=>typeof structuredClone=="function"?structuredClone($):JSON.parse(JSON.stringify($));var Ct=class extends Ln{constructor(d,y){let P=y.length===1?"it":"them";super(`Tried to use a ${d} in @novu/framework without ${y.join(", ")} installed. Please install ${P} by running \`npm install ${y.join(" ")}\`.`);this.statusCode=500;this.code="MissingDependencyError"}};var $t=async($,s)=>{let d=new Set;if((await Promise.allSettled($.map(P=>P.import))).forEach((P,j)=>{let x=$[j];P.status==="fulfilled"&&x.exports.every(ae=>P.value[ae]!==void 0)||d.add(x.name)}),d.size>0)throw new Ct(s,Array.from(d))};var xt=class{constructor(){this.requiredImports=[];this.ajv=new ks({useDefaults:!0,removeAdditional:"failing"}),Ns(this.ajv),this.compiledSchemas=new Map}async canHandle(s){let d=s.type==="object"||!!s.anyOf||!!s.allOf||!!s.oneOf;return d&&await $t(this.requiredImports,"JSON schema"),d}async validate(s,d){let y=this.compiledSchemas.get(d);y||(y=this.ajv.compile(d),this.compiledSchemas.set(d,y));let P=oi(s);return y(P)?{success:!0,data:P}:{success:!1,errors:y.errors.map(x=>({path:x.instancePath,message:x.message}))}}async transformToJsonSchema(s){return s}};var Dt=class{constructor(){this.requiredImports=[{name:"zod",import:import("zod"),exports:["ZodType"]},{name:"zod-to-json-schema",import:import("zod-to-json-schema"),exports:["zodToJsonSchema"]}]}async canHandle(s){let d=s.safeParseAsync!==void 0;return d&&await $t(this.requiredImports,"Zod schema"),d}async validate(s,d){let y=await d.safeParseAsync(s);return y.success?{success:!0,data:y.data}:{success:!1,errors:y.error.errors.map(P=>({path:`/${P.path.join("/")}`,message:P.message}))}}async transformToJsonSchema(s){let{zodToJsonSchema:d}=await import("zod-to-json-schema");return d(s)}};var Ft=new Dt,Wt=new xt,Ut=async($,s)=>{if(await Ft.canHandle($))return Ft.validate(s,$);if(await Wt.canHandle($))return Wt.validate(s,$);throw new Error("Invalid schema")},Re=async $=>{if(await Ft.canHandle($))return Ft.transformToJsonSchema($);if(await Wt.canHandle($))return Wt.transformToJsonSchema($);throw new Error("Invalid schema")};var jt=(()=>{var $=Object.defineProperty,s=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,y=Object.prototype.hasOwnProperty,P=(e,t)=>function(){return e&&(t=(0,e[d(e)[0]])(e=0)),t},j=(e,t)=>function(){return t||(0,e[d(e)[0]])((t={exports:{}}).exports,t),t.exports},x=(e,t)=>{for(var r in t)$(e,r,{get:t[r],enumerable:!0})},te=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of d(t))!y.call(e,l)&&l!==r&&$(e,l,{get:()=>t[l],enumerable:!(a=s(t,l))||a.enumerable});return e},ae=e=>te($({},"__esModule",{value:!0}),e),ve={};x(ve,{JSONSchemaFaker:()=>Mn,default:()=>kn,setDependencies:()=>Yr});function ke(e,t){return typeof e=="string"?typeof t!="undefined"?at.register(e,t):at.get(e):at.registerMany(e)}function Le(e,t){return e=typeof e=="undefined"?Ve.MIN_INTEGER:e,t=typeof t=="undefined"?Ve.MAX_INTEGER:t,Math.floor(z("random")()*(t-e+1))+e}function be(e){return vt.default.prototype.max=z("defaultRandExpMax"),vt.default.prototype.randInt=(r,a)=>r+Math.floor(z("random")()*(1+(a-r))),new vt.default(e).gen()}function Ne(e){return e[Math.floor(z("random")()*e.length)]}function $e(e){let t,r,a=e.length,l=e.slice();for(;a>0;)r=Math.floor(z("random")()*a),a-=1,t=l[a],l[a]=l[r],l[r]=t;return l}function Qe(e,t){return z("random")()*(t-e)+e}function Ue(e,t,r,a,l=!1){return r=typeof r=="undefined"?Ve.MIN_NUMBER:r,a=typeof a=="undefined"?Ve.MAX_NUMBER:a,e=typeof e=="undefined"?r:e,t=typeof t=="undefined"?a:t,t<e&&(t+=e),l?Qe(e,t):Le(e,t)}function yt(e){switch(e){case"seconds":return Ue(0,60)*60;case"minutes":return Ue(15,50)*612;case"hours":return Ue(12,72)*36123;case"days":return Ue(7,30)*86412345;case"weeks":return Ue(4,52)*604812345;case"months":return Ue(2,13)*2592012345;case"years":return Ue(1,20)*31104012345;default:break}}function Bt(e){if(e)return yt(e);let t=z("minDateTime"),r=z("maxDateTime");typeof t=="string"&&(t=new Date(t)),typeof r=="string"&&(r=new Date(r));let a=new Date().getTime();return typeof t=="number"&&(t=new Date(a+t)),typeof r=="number"&&(r=new Date(a+r)),new Date(Qe(t.getTime(),r.getTime()))}function br(e,t,r){if(t=decodeURIComponent(t),r&&r[t])return St(r[t]);let a=t.replace("#/","/").split("/"),l=e.$ref&&r&&r[e.$ref]||e;for(!l&&!a[0]&&(a[0]=e.$ref.split("#/")[0]),r&&t.includes("#/")&&r[a[0]]&&(l=r[a.shift()]),a[0]||a.shift();l&&a.length>0;){let f=a.shift();if(!l[f])throw new Error(`Prop not found: ${f} (${t})`);l=l[f]}return l}function wt(e){return typeof e=="string"&&en.test(e)}function je(e){return["number","boolean"].includes(typeof e)}function Be(e,...t){return t.filter(r=>typeof e[r]!="undefined").length>0}function Tr(e){if(e.includes(" "))return new Date(e).toISOString().substr(0,10);let[t,r,a]=e.split("T")[0].split("-");return r=`0${Math.max(1,Math.min(12,r))}`.slice(-2),a=`0${Math.max(1,Math.min(31,a))}`.slice(-2),`${t}-${r}-${a}`}function wi(e){if(e.includes(" "))return new Date(e).toISOString().substr(0,10);let[t,r]=e.split("T"),[a,l,f]=t.split("-"),[c,E,C]=r.substr(0,8).split(":");return l=`0${Math.max(1,Math.min(12,l))}`.slice(-2),f=`0${Math.max(1,Math.min(31,f))}`.slice(-2),c=`0${Math.max(1,Math.min(23,c))}`.slice(-2),E=`0${Math.max(1,Math.min(59,E))}`.slice(-2),C=`0${Math.max(1,Math.min(59,C))}`.slice(-2),`${a}-${l}-${f}T${c}:${E}:${C}.000Z`}function Si(e,t,r){let a={};switch(e||t.type){case"integer":case"number":if(typeof t.minimum!="undefined"&&(a.minimum=t.minimum),typeof t.maximum!="undefined"&&(a.maximum=t.maximum),t.enum){let f=Math.max(a.minimum||0,0),c=Math.min(a.maximum||1/0,1/0);t.exclusiveMinimum&&f===t.minimum&&(f+=t.multipleOf||1),t.exclusiveMaximum&&c===t.maximum&&(c-=t.multipleOf||1),(f||c!==1/0)&&(t.enum=t.enum.filter(E=>E>=f&&E<=c))}break;case"string":{a.minLength=z("minLength")||0,a.maxLength=z("maxLength")||Number.MAX_SAFE_INTEGER,typeof t.minLength!="undefined"&&(a.minLength=Math.max(a.minLength,t.minLength)),typeof t.maxLength!="undefined"&&(a.maxLength=Math.min(a.maxLength,t.maxLength));break}default:break}let l=r(a);if(l==null)return null;switch(e||t.type){case"number":l=wt(l)?parseFloat(l):l;break;case"integer":l=wt(l)?parseInt(l,10):l;break;case"boolean":l=!!l;break;case"string":{if(je(l))return l;l=String(l);let f=Math.max(a.minLength||0,0),c=Math.min(a.maxLength||1/0,1/0),E,C=0;for(;l.length<f;)if(E=l,t.pattern?l+=Q.randexp(t.pattern):l+=`${Q.pick([" ","/","_","-","+","=","@","^"])}${l}`,l===E){if(C+=1,C===3)break}else C=0;switch(l.length>c&&(l=l.substr(0,c)),t.format){case"date-time":case"datetime":l=new Date(wi(l)).toISOString().replace(/([0-9])0+Z$/,"$1Z");break;case"full-date":case"date":l=new Date(Tr(l)).toISOString().substr(0,10);break;case"time":l=new Date(`1969-01-01 ${l}`).toISOString().substr(11);break;default:break}break}default:break}return l}function ze(e,t){return Object.keys(t).forEach(r=>{typeof t[r]!="object"||t[r]===null?e[r]=t[r]:Array.isArray(t[r])?(e[r]=e[r]||[],t[r].forEach((a,l)=>{e.type==="array"&&t.type==="array"?e[r][l]=ze(e[r][l]||{},a,!0):Array.isArray(e[r])&&e[r].indexOf(a)===-1&&e[r].push(a)})):typeof e[r]!="object"||e[r]===null||Array.isArray(e[r])?e[r]=ze({},t[r]):e[r]=ze(e[r],t[r])}),e}function St(e,t=new Map){if(!e||typeof e!="object")return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){let a=[];return t.set(e,a),a.push(...e.map(l=>St(l,t))),a}let r={};return t.set(e,r),Object.keys(e).reduce((a,l)=>(a[l]=St(e[l],t),a),r)}function Ei(e){let t=JSON.stringify(e),r=JSON.stringify(e,null,2);return t.length>400?`${r.substr(0,400)}...`:r}function Pr(){return Q.pick([!1,!0,null,-1,NaN,Math.PI,1/0,void 0,[],{},Math.random(),Math.random().toString(36).substr(2)])}function vi(e,t){if(e.enum)return e.enum.includes(t);if(e.const)return e.const===t}function Oi(e,t){let r=ze({},t);if(typeof e.minimum!="undefined"&&(r.maximum=e.minimum,r.exclusiveMaximum=!0),typeof e.maximum!="undefined"&&(r.minimum=e.maximum>r.maximum?0:e.maximum,r.exclusiveMinimum=!0),typeof e.minLength!="undefined"&&(r.maxLength=e.minLength),typeof e.maxLength!="undefined"&&(r.minLength=e.maxLength>r.maxLength?0:e.maxLength),e.type)r.type=Q.pick(Ve.SCALAR_TYPES.filter(a=>(Array.isArray(e.type)?e.type:[e.type]).every(f=>a==="number"||a==="integer"?f!=="number"&&f!=="integer":a!==f)));else if(e.enum){let a;do a=Pr();while(e.enum.indexOf(a)!==-1);r.enum=[a]}return e.required&&r.properties&&e.required.forEach(a=>{delete r.properties[a]}),r}function Vt(e,t){let r=t.minimum!==void 0,a=t.maximum!==void 0;return(r||a)&&(!r||e>=t.minimum)&&(!a||e<=t.maximum)}function Ai(e,t){return!t.every(r=>Vt(e,r))}function bi(e,t){return t.reduce((a,l)=>a+(Vt(e,l)?1:0),0)===1}function Ti(e){return["enum","const","default","examples","required","definitions","items","properties"].includes(e)}function Pi(e,t){return Object.keys(e).filter(r=>!t.includes(r)).reduce((r,a)=>(Array.isArray(e[a])?r[a]=e[a].slice():r[a]=e[a]instanceof Object?ze({},e[a]):e[a],r),{})}function Rr(e,t){return Array.isArray(e)?e.map(r=>Rr(r,t)):(typeof e=="string"&&(e=e.replace(/#\{([\w.-]+)\}/g,(r,a)=>t[a])),e)}function Yt(e){return Object.prototype.toString.call(e)==="[object Object]"&&!Object.keys(e).length}function _r(e,t){t=t.items||t;let r=z("alwaysFakeOptionals"),a=Array.isArray(t.required)&&t.required.includes(e)||r,l=typeof t.thunk=="function"||t.additionalProperties&&typeof t.additionalProperties.thunk=="function";return!a&&!l}function Ht(e,t,r=!1){if(!e||typeof e!="object")return e;if(Array.isArray(e))return e.map(a=>Ht(a,t,!0)).filter(a=>typeof a!="undefined");if(Object.keys(e).forEach(a=>{if(Yt(e[a]))_r(a,t)&&delete e[a];else{let l=t;t&&t.properties&&t.properties[a]&&(l=t.properties[a]);let f=Ht(e[a],l);Yt(f)||(e[a]=f)}typeof e[a]=="undefined"&&delete e[a]}),!(!Object.keys(e).length&&r))return e}function Ri(e){return(t,r,a,l)=>{let f=t,c=[];typeof t=="object"&&(f=Object.keys(t)[0],Array.isArray(t[f])?c=t[f]:c.push(t[f]));let E=f.split("."),C=e();for(;E.length>1;)C=C[E.shift()];return t=typeof C=="object"?C[E[0]]:C,typeof t=="function"&&(t=t.apply(C,c.map(S=>ue.template(S,l)))),Object.prototype.toString.call(t)==="[object Object]"&&Object.keys(t).forEach(S=>{if(typeof t[S]=="function")throw new Error(`Cannot resolve value for '${a}: ${f}', given: ${t}`)}),t}}function _i(e,t){if(typeof e=="undefined")return et.list();if(typeof e=="string")if(typeof t=="function")et.register(e,t);else if(t===null||t===!1)et.unregister(e);else return et.get(e);else et.registerMany(e)}function Ii(e,t,r){return Object.keys(e).filter(a=>{let l=sn.indexOf(t)>-1;return r.indexOf(a)>-1&&!l}).length>0}function Mi(e,t){let r=Object.keys(lt);for(let a=0;a<r.length;a+=1){let l=r[a],f=t[t.length-1];if(Ii(e,f,lt[l]))return l}}function ki(){return z("random")()>.5}function Ni(){return null}function Li(e,t,r,a,l,f){let c=[],E=[];function C(D){let A=JSON.stringify(D.value);return E.indexOf(A)===-1?(E.push(A),c.push(D),!0):!1}t.forEach(C);let S=100;for(;c.length!==t.length&&(C(f(r.items||a,e,l))||(S-=1),!!S););return c}function Ci(e,t,r,a){let l=[];if(!(e.items||e.additionalItems)){if(ue.hasProperties(e,"minItems","maxItems","uniqueItems")&&(e.minItems!==0||e.maxItems!==0))throw new Ot(`missing items for ${ue.short(e)}`,t);return l}if(Array.isArray(e.items))return e.items.map((U,ie)=>{let G=t.concat(["items",ie]);return a(U,G,r)});let f=e.minItems,c=e.maxItems,E=z("minItems"),C=z("maxItems");E&&(f=typeof f=="undefined"?E:Math.min(E,f)),C&&(c=typeof c=="undefined"?C:Math.min(C,c),c&&c>C&&(c=C),f&&f>C&&(f=c));let S=z("alwaysFakeOptionals")===!0?1:z("optionalsProbability"),D=z("alwaysFakeOptionals")||z("fixedProbabilities")||!1,A=Q.number(f,c,1,5);S!==null&&(A=Math.max(D?Math.round((c||A)*S):Math.abs(Q.number(f,c)*S),f||0));let Y=typeof e.additionalItems=="object"?e.additionalItems:{};for(let U=l.length;U<A;U+=1){let ie=t.concat(["items",U]),G=a(e.items||Y,ie,r);l.push(G)}if(e.contains&&A>0){let U=Q.number(0,A-1);l[U]=a(e.contains,t.concat(["items",U]),r)}return e.uniqueItems?Li(t.concat(["items"]),l,e,Y,r,a):l}function $i(e){let t=typeof e.minimum=="undefined"||e.minimum===-Number.MAX_VALUE?Ve.MIN_INTEGER:e.minimum,r=typeof e.maximum=="undefined"||e.maximum===Number.MAX_VALUE?Ve.MAX_INTEGER:e.maximum,a=e.multipleOf,l=a&&String(a).match(/e-(\d)|\.(\d+)$/);if(l){let f=(Math.random()*Q.number(0,10)+1)*a,c=l[1]||l[2].length,E=parseFloat(f.toFixed(c)),C=Q.number(t,r-1);return String(E).includes(".")?C+E:(C+E).toExponential()}if(a&&(r=Math.floor(r/a)*a,t=Math.ceil(t/a)*a),e.exclusiveMinimum&&t===e.minimum&&(t+=a||1),e.exclusiveMaximum&&r===e.maximum&&(r-=a||1),t>r)return NaN;if(a){let f=Q.number(Math.floor(t/a),Math.floor(r/a))*a;for(;f<t;)f+=a;return f}return Q.number(t,r,void 0,void 0,e.type!=="integer")}function xi(e){return Math.floor(or({...e}))}function Di(e){return Q.shuffle(mn).slice(0,e)}function Fi(e,t,r,a){let l={},f=e.properties||{},c=e.patternProperties||{},E=typeof e.required=="boolean"?[]:(e.required||[]).slice(),C=e.additionalProperties!==!1,S=Object.keys(f),D=Object.keys(c),A=S.concat(D).reduce((W,p)=>(E.indexOf(p)===-1&&W.push(p),W),[]),Y=E.concat(A),U=C&&e.additionalProperties===!0?bt:e.additionalProperties;if(!C&&S.length===0&&D.length===0&&ue.hasProperties(e,"minProperties","maxProperties","dependencies","required"))return null;if(z("requiredOnly")===!0)return E.forEach(W=>{f[W]&&(l[W]=f[W])}),a(l,t.concat(["properties"]),r,e);let ie=z("alwaysFakeOptionals")===!0?1:z("optionalsProbability"),G=z("alwaysFakeOptionals")||z("fixedProbabilities")||!1,X=z("ignoreProperties")||[],fe=z("reuseProperties"),de=z("fillProperties"),F=e.maxProperties||Y.length+(C?Q.number(1,5):0),g=Math.max(e.minProperties||0,E.length),w=Math.max(0,Y.length-g);Y.length===1&&!E.length&&(g=Math.max(Q.number(de?1:0,F),g)),ie!==null&&(G===!0?w=Math.round(g-E.length+ie*(Y.length-g)):w=Q.number(g-E.length,ie*(Y.length-g)));let T=Q.shuffle(A).slice(0,w),_=A.filter(W=>T.indexOf(W)!==-1),N=ie!==null||E.length===F?F:Q.number(0,F),b=E.concat(Q.shuffle(_).slice(0,N)).slice(0,F),I=[],k=[];if(e.dependencies&&(Object.keys(e.dependencies).forEach(W=>{let p=e.dependencies[W];if(b.indexOf(W)!==-1)if(Array.isArray(p))p.forEach(M=>{b.indexOf(M)===-1&&b.push(M)});else if(Array.isArray(p.oneOf||p.anyOf)){let M=p.oneOf||p.anyOf;k.push({prop:W,values:M})}else I.push(p)}),I.length))return delete e.dependencies,a({allOf:I.concat(e)},t.concat(["properties"]),r,e);let B=[],H=[];b.forEach(W=>{if(f[W]&&["{}","true"].includes(JSON.stringify(f[W].not)))return;for(let M=0;M<X.length;M+=1)if(X[M]instanceof RegExp&&X[M].test(W)||typeof X[M]=="string"&&X[M]===W||typeof X[M]=="function"&&X[M](f[W],W)){B.push(W);return}U===!1&&E.indexOf(W)!==-1&&(l[W]=f[W]),f[W]&&(l[W]=f[W]);let p;if(D.forEach(M=>{W.match(new RegExp(M))&&(p=!0,l[W]?ue.merge(l[W],c[M]):l[Q.randexp(W)]=c[M])}),!p){let M=c[W]||U;M&&U!==!1?l[c[W]?Q.randexp(W):W]=f[W]||M:H.push(W)}});let Z=Object.keys(l).length+(de?0:B.length),we=W=>Q.randexp(`_?[_a-f\\d]{1,3}${W?"\\$?":""}`);function Se(W){let p;do{if(!W.length)break;p=W.shift()}while(l[p]);return p}let Oe=g;if(C&&!E.length&&(Oe=Math.max(ie===null||U?Q.number(de?1:0,F):0,g)),!_.length&&!w&&C&&G===!0&&de){let W=Q.number(0,F);for(let p=0;p<W;p+=1)l[At(1)+we(W[p])]=U||bt}for(;de&&!(!(D.length||C)||Z>=Oe);){if(C)if(fe&&S.length-Z>Oe){let W=0,p;do{if(W+=1,W>1e3)break;p=Se(E)||Q.pick(S)}while(typeof l[p]!="undefined");typeof l[p]=="undefined"&&(l[p]=f[p],Z+=1)}else if(D.length&&!U){let W=Q.pick(D),p=Q.randexp(W);l[p]||(l[p]=c[W],Z+=1)}else{let W=Se(E)||At(1)+we();l[W]||(l[W]=U||bt,Z+=1)}for(let W=0;Z<g&&W<D.length;W+=1){let p=D[W],M=Q.randexp(p);l[M]||(l[M]=c[p],Z+=1)}}if(E.length===0&&(!C||ie===!1)){let W=Q.number(g,F);for(;Z<W;){let p=Se(S);p&&(l[p]=f[p]),Z+=1}}let Te=l;if(z("sortProperties")!==null){let W=Object.keys(f);Te=Object.keys(l).sort((M,q)=>z("sortProperties")?M.localeCompare(q):W.indexOf(M)-W.indexOf(q)).reduce((M,q)=>(M[q]=l[q],M),{})}let _e=a(Te,t.concat(["properties"]),r,e);return k.forEach(W=>{for(let p of W.values)if(ue.hasValue(p.properties[W.prop],_e.value[W.prop])){Object.keys(p.properties).forEach(M=>{M!==W.prop&&ue.merge(_e.value,a(p.properties,t.concat(["properties"]),r,e).value)});break}}),_e}function Ir(){let e=Q.number(1,5);return At(e).join(" ")}function Wi(e=0,t=140){let r=Math.max(0,e),a=Q.number(r,t),l=Ir();for(;l.length<r;)l+=Ir();return l.length>a&&(l=l.substr(0,a)),l}function Ui(){return[0,0,0,0].map(()=>Q.number(0,255)).join(".")}function ji(){return Q.date().toISOString()}function Bi(){return Tt().slice(0,10)}function Vi(){return Tt().slice(11)}function Yi(e){return Q.randexp(xe[e]).replace(vn,(t,r)=>Q.randexp(xe[r]))}function Hi(e,t){let r=sr(e.format);if(typeof r=="function")return r(e);switch(e.format){case"date-time":case"datetime":return Tt();case"date":return wn();case"time":return Sn();case"ipv4":return yn();case"regex":return".+?";case"email":case"hostname":case"ipv6":case"uri":case"uri-reference":case"iri":case"iri-reference":case"idn-email":case"idn-hostname":case"json-pointer":case"slug":case"uri-template":case"uuid":case"duration":return On(e.format);default:if(typeof r=="undefined"){if(z("failOnInvalidFormat"))throw new Error(`unknown registry key ${ue.short(e.format)}`);return t()}throw new Error(`unsupported format '${e.format}'`)}}function qi(e){return ue.typecast("string",e,r=>e.format?Hi(e,()=>ar(r.minLength,r.maxLength)):e.pattern?Q.randexp(e.pattern):ar(r.minLength,r.maxLength))}function Ki({$comment:e,title:t,description:r}){return Object.entries({comment:e,title:t,description:r}).filter(([,a])=>a).reduce((a,[l,f])=>(a[l]=f,a),{})}function Xe(e,t,r,a){if(e=r(e,null,t),e&&(e.oneOf||e.anyOf||e.allOf)&&(e=r(e,null,t)),!e)throw new Error(`Cannot traverse at '${t.join(".")}', given '${JSON.stringify(a)}'`);let l={...Ki(e),schemaPath:t};if(t[t.length-1]!=="properties"){if(z("useExamplesValue")&&Array.isArray(e.examples)){let S=e.examples.concat("default"in e?[e.default]:[]);return{value:ue.typecast(null,e,()=>Q.pick(S)),context:l}}if(z("useExamplesValue")&&typeof e.example!="undefined")return{value:ue.typecast(null,e,()=>e.example),context:l};if(z("useDefaultValue")&&"default"in e&&(e.default!==""||!z("replaceEmptyByRandomValue")))return{value:e.default,context:l};if("template"in e)return{value:ue.template(e.template,a),context:l};if("const"in e)return{value:e.const,context:l}}if(e.not&&typeof e.not=="object"&&(e=ue.notValue(e.not,ue.omitProps(e,["not"])),e.type&&e.type==="object")){let{value:S,context:D}=Xe(e,t.concat(["not"]),r,a);return{value:ue.clean(S,e,!1),context:{...l,items:D}}}if(typeof e.thunk=="function"){let{value:S,context:D}=Xe(e.thunk(a),t,r);return{value:S,context:{...l,items:D}}}if(e.jsonPath)return{value:e,context:l};let f=e.type;if(Array.isArray(f)?f=Q.pick(f):typeof f=="undefined"&&(f=on(e,t)||f,f&&(e.type=f)),typeof e.generate=="function"){let S=ue.typecast(null,e,()=>e.generate(a,t)),D=S===null?"null":typeof S;if(D===f||D==="number"&&f==="integer"||Array.isArray(S)&&f==="array")return{value:S,context:l}}if(typeof e.pattern=="string")return{value:ue.typecast("string",e,()=>Q.randexp(e.pattern)),context:l};if(Array.isArray(e.enum))return{value:ue.typecast(null,e,()=>Q.pick(e.enum)),context:l};if(typeof f=="string")if(ut[f])try{let S=ut[f](e,t,r,Xe);return f==="array"?{value:S.map(({value:D})=>D),context:{...l,items:S.map(Array.isArray(e.items)?({context:D})=>D:({context:D})=>({...D,schemaPath:D.schemaPath.slice(0,-1)}))}}:f==="object"?S!==null?{value:S.value,context:{...l,items:S.context}}:{value:{},context:l}:{value:S,context:l}}catch(S){throw typeof S.path=="undefined"?new Ot(S.stack,t):S}else{if(z("failOnInvalidTypes"))throw new Ot(`unknown primitive ${ue.short(f)}`,t.concat(["type"]));{let S=z("defaultInvalidTypeProduct");return typeof S=="string"&&ut[S]?{value:ut[S](e,t,r,Xe),context:l}:{value:S,context:l}}}let c={},E={...l};Array.isArray(e)&&(c=[]);let C=z("pruneProperties")||[];return Object.keys(e).forEach(S=>{if(!C.includes(S)&&e[S]!==null)if(typeof e[S]=="object"&&S!=="definitions"){let{value:D,context:A}=Xe(e[S],t.concat([S]),r,c);c[S]=ue.clean(D,e[S],!1),E[S]=A,c[S]===null&&z("omitNulls")&&(delete c[S],delete E[S])}else c[S]=e[S]}),{value:c,context:E}}function Ji(e){return Array.isArray(e)?Q.pick(e):e}function Gi(e,t){if(!Array.isArray(e))return e;let r=t?e.pop():e.shift();return t?e.unshift(r):e.push(r),r}function qt(e,t,r,a){if(!e||typeof e!="object")return e;if(r||(r={}),t||(t=e),Array.isArray(e))return e.map(l=>qt(l,t,r,a));if(e.jsonPath){let{JSONPath:l}=er(),f=typeof e.jsonPath!="object"?{path:e.jsonPath}:e.jsonPath;f.group=e.group||f.group||a,f.cycle=e.cycle||f.cycle||!1,f.reverse=e.reverse||f.reverse||!1,f.count=e.count||f.count||1;let c=`${f.group}__${f.path}`;return r[c]||(f.count>1?r[c]=l(f.path,t).slice(0,f.count):r[c]=l(f.path,t)),f.cycle||f.reverse?Gi(r[c],f.reverse):Ji(r[c])}return Object.keys(e).forEach(l=>{e[l]=qt(e[l],t,r,l)}),e}function Qi(e,t,r,a){if(Object.prototype.toString.call(t)!=="[object Object]")throw new Error(`Invalid input, expecting object but given ${typeof t}`);let l=z("refDepthMin")||0,f=z("refDepthMax")||3;try{let{resolveSchema:c}=Rn({refs:e,schema:t,container:r,synchronous:a,refDepthMin:l,refDepthMax:f}),E=Tn(ue.clone(t),[],c);return z("resolveJsonPath")?{value:qt(E.value),context:E.context}:E}catch(c){throw c.path?new Error(`${c.message} in /${c.path.join("/")}`):c}}function Zi(e){return e.value}function zi(e,t){return t.reduce((r,a)=>a in r?r[a]:{},e)}function Kt(e,t,r,a=r){let{title:l,description:f,comment:c}=zi(e,t),E=[];z("renderTitle")&&l&&E.push(` ${l}`,""),z("renderDescription")&&f&&E.push(` ${f}`),z("renderComment")&&c&&E.push(` ${c} = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:146:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:229:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

Node.js v20.18.0
[nodemon] app crashed - waiting for file changes before starting...

@soccer99
Copy link
Author

Update! We were able to find that this error does not occur on @novu/[email protected].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant