@novu/framework 0.24.3-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ import { E as Execute, W as WorkflowOptions, D as DiscoverWorkflowOutput } from './handler-58kccf2b.js';
2
+ export { j as ActionStep, A as ActionStepOptions, y as Awaitable, l as ChannelStep, r as ChatOutput, s as ChatResult, C as Client, b as ClientOptions, a as CodeResult, k as CustomStep, f as DiscoverOutput, d as DiscoverProviderOutput, e as DiscoverStepOutput, x as Either, m as EmailOutput, n as EmailResult, z as ExecuteInput, h as ExecuteOutput, g as ExecuteOutputMetadata, H as HealthCheck, I as IEvent, t as InAppOutput, u as InAppResult, J as JobStatusEnum, N as NovuRequestHandler, P as PushOutput, q as PushResult, S as ServeHandlerOptions, o as SmsOutput, p as SmsResult, v as Step, c as StepType, w as Subscriber, i as SupportedFrameworkName, V as Validate } from './handler-58kccf2b.js';
3
+ import { Schema } from 'ajv';
4
+ import { FromSchema } from 'json-schema-to-ts';
5
+
6
+ /**
7
+ * Define a new notification workflow.
8
+ */
9
+ declare function workflow<T_PayloadSchema extends Schema, T_InputSchema extends Schema, T_Payload = FromSchema<T_PayloadSchema>, T_Input = FromSchema<T_InputSchema>>(workflowId: string, execute: Execute<T_Payload, T_Input>, workflowOptions?: WorkflowOptions<T_PayloadSchema, T_InputSchema>): DiscoverWorkflowOutput;
10
+
11
+ export { DiscoverWorkflowOutput, Execute, WorkflowOptions, workflow };
package/dist/index.js ADDED
@@ -0,0 +1,112 @@
1
+ 'use strict';
2
+
3
+ var Me = require('ajv');
4
+ var Ue = require('ajv-formats');
5
+ var qe = require('better-ajv-errors');
6
+ var jsonSchemaFaker = require('json-schema-faker');
7
+ var se = require('ora');
8
+ var v = require('chalk');
9
+ var liquidjs = require('liquidjs');
10
+ var crypto = require('crypto');
11
+
12
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
+
14
+ var Me__default = /*#__PURE__*/_interopDefault(Me);
15
+ var Ue__default = /*#__PURE__*/_interopDefault(Ue);
16
+ var qe__default = /*#__PURE__*/_interopDefault(qe);
17
+ var se__default = /*#__PURE__*/_interopDefault(se);
18
+ var v__default = /*#__PURE__*/_interopDefault(v);
19
+
20
+ var $=(n=>(n.EXECUTE="execute",n.PREVIEW="preview",n.SYNC="sync",n.DIFF="diff",n))($||{}),M=(i=>(i.DISCOVER="discover",i.HEALTH_CHECK="health-check",i.CODE="code",i))(M||{});var ue="https://api.novu.co";var y=(c=>(c.WORKFLOW_NOT_FOUND_ERROR="WorkflowNotFoundError",c.WORKFLOW_ALREADY_EXISTS_ERROR="WorkflowAlreadyExistsError",c.WORKFLOW_EXECUTION_FAILED_ERROR="WorkflowExecutionFailedError",c.EXECUTION_STATE_OUTPUT_INVALID_ERROR="ExecutionStateOutputInvalidError",c.EXECUTION_STATE_RESULT_INVALID_ERROR="ExecutionStateResultInvalidError",c.EXECUTION_PROVIDER_OUTPUT_INVALID_ERROR="ExecutionProviderOutputInvalidError",c.PROVIDER_NOT_FOUND_ERROR="ProviderNotFoundError",c.PROVIDER_EXECUTION_FAILED_ERROR="ProviderExecutionFailedError",c.STEP_NOT_FOUND_ERROR="StepNotFoundError",c.STEP_ALREADY_EXISTS_ERROR="StepAlreadyExistsError",c.STEP_EXECUTION_FAILED_ERROR="StepExecutionFailedError",c.EXECUTION_STATE_CORRUPT_ERROR="ExecutionStateCorruptError",c.EXECUTION_EVENT_DATA_INVALID_ERROR="ExecutionEventDataInvalidError",c.EXECUTION_EVENT_INPUT_INVALID_ERROR="ExecutionEventInputInvalidError",c.EXECUTION_STATE_INPUT_INVALID_ERROR="ExecutionStateInputInvalidError",c.METHOD_NOT_ALLOWED_ERROR="MethodNotAllowedError",c.INVALID_ACTION_ERROR="InvalidActionError",c.MISSING_API_KEY_ERROR="MissingApiKeyError",c.SIGNATURE_MISMATCH_ERROR="SignatureMismatchError",c.SIGNATURE_NOT_FOUND_ERROR="SignatureNotFoundError",c.SIGNATURE_INVALID_ERROR="SignatureInvalidError",c.SIGNATURE_EXPIRED_ERROR="SignatureExpiredError",c.SIGNING_KEY_NOT_FOUND_ERROR="SigningKeyNotFoundError",c.PLATFORM_ERROR="PlatformError",c.SIGNATURE_VERSION_INVALID_ERROR="SignatureVersionInvalidError",c))(y||{});var S=(i=>(i.POST="POST",i.GET="GET",i.OPTIONS="OPTIONS",i))(S||{});var g=class extends Error{data},U=class extends g{statusCode=404},f=class extends g{statusCode=400},b=class extends g{statusCode=401},T=class extends g{statusCode=500},q=class extends g{statusCode=409};var L=class extends f{code="ExecutionStateCorruptError";constructor(e,t){super(`Workflow with id: \`${e}\` has a corrupt state. Step with id: \`${t}\` does not exist. Please provide the missing state.`),this.data={workflowId:e,stepId:t};}},F=class extends f{code="ExecutionEventDataInvalidError";constructor(e,t){super(`Workflow with id: \`${e}\` has invalid \`data\`. Please provide the correct event data.`),this.data=t;}},A=class extends f{code="ExecutionEventInputInvalidError";constructor(e,t){super(`Workflow with id: \`${e}\` has invalid \`inputs\`. Please provide the correct event inputs.`),this.data=t;}},W=class extends f{code="ExecutionStateInputInvalidError";constructor(e,t,i){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` has invalid input. Please provide the correct step input.`),this.data=i;}},Y=class extends f{code="ExecutionStateOutputInvalidError";constructor(e,t,i){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` has invalid output. Please provide the correct step output.`),this.data=i;}},V=class extends f{code="ExecutionStateResultInvalidError";constructor(e,t,i){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` has invalid result. Please provide the correct step result.`),this.data=i;}},B=class extends f{code="ExecutionProviderOutputInvalidError";constructor(e,t,i,n){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` and provider with id: \`${i}\` has invalid output. Please provide the correct provider output.`),this.data=n;}};var l={info:o=>v__default.default.blue(o),warning:o=>v__default.default.yellow(o),error:o=>v__default.default.red(o),success:o=>v__default.default.green(o),underline:o=>v__default.default.underline(o),bold:o=>v__default.default.bold(o)},d={SUCCESS:l.success("\u2714"),ERROR:l.error("\u2717"),WARNING:l.warning("\u26A0"),INFO:l.info("\u2139"),ARROW:l.bold("\u2192"),MOCK:l.info("\u25CB"),HYDRATED:l.bold(l.info("\u2192")),STEP:l.info("\u03C3"),ACTION:l.info("\u03B1"),DURATION:l.info("\u0394"),PROVIDER:l.info("\u2699"),OUTPUT:l.info("\u21E2"),INPUT:l.info("\u21E0"),WORKFLOW:l.info("\u03C9"),STATE:l.info("\u03C3"),EXECUTE:l.info("\u03B5"),PREVIEW:l.info("\u03C1")};var le=o=>Object.values(o).map(e=>`\`${e}\``).join(", "),G=o=>o.replaceAll(/(\w)(\w*)/g,(e,t,i)=>t.toUpperCase()+i.toLowerCase()).replaceAll(/[\s-]+/g,"");var K=class extends g{code="MethodNotAllowedError";statusCode=405;message=`Method not allowed. Please use one of ${le(S)}`},P=class extends f{code="InvalidActionError";constructor(e,t){super(`Invalid query string: \`action\`=\`${e}\`. Please use one of ${le(t)}`);}},C=class extends f{code="MissingApiKeyError";constructor(){super("API Key is missing. Please add the API Key during Client initialization.");}};var X=class extends T{code="PlatformError";message="Something went wrong. Please try again later."};var R=class extends q{constructor(e,t){super(`${G(e)} with id: \`${t}\` already exists. Please use a different id.`);}},w=class extends U{constructor(e,t){super(`${G(e)} with id: \`${t}\` does not exist. Please provide a valid id.`);}},E=class extends T{constructor(e,t){super(`Failed to execute ${G(e)} with id: \`${t}\`. Please try again later.`);}};var z=class extends w{code="ProviderNotFoundError";constructor(e){super("provider",e);}},J=class extends E{code="ProviderExecutionFailedError";constructor(e){super("workflow",e);}};var Q=class extends b{code="SignatureMismatchError";constructor(){super("Signature does not match the expected signature. Please ensure the signature provided in the `x-novu-signature` header is correct and try again.");}},Z=class extends b{code="SignatureNotFoundError";constructor(){super("Signature not found. Please provide a signature in the `x-novu-signature` header");}},H=class extends b{code="SignatureInvalidError";constructor(){super("Signature is invalid. Please provide a valid signature in the `x-novu-signature` header");}},ee=class extends b{code="SignatureExpiredError";constructor(){super(`Signature expired. Please provide a signature with a timestamp no older than ${5} minutes in the \`x-novu-signature\` header`);}},te=class extends b{code="SigningKeyNotFoundError";constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.apiKey`");}};var ie=class extends w{code="StepNotFoundError";constructor(e){super("step",e);}},ne=class extends R{code="StepAlreadyExistsError";constructor(e){super("step",e);}};var D=class extends w{code="WorkflowNotFoundError";constructor(e){super("workflow",e);}},oe=class extends R{code="WorkflowAlreadyExistsError";constructor(e){super("workflow",e);}};var ge={name:"@novu/framework",version:"0.24.3-alpha.5",description:"The Code-First Notifications Workflow SDK.",main:"./dist/index.js",types:"./dist/index.d.ts",publishConfig:{registry:"https://registry.npmjs.org",access:"public"},private:!1,repository:{type:"git",url:"git+https://github.com/novuhq/novu.git"},files:["dist","README.md"],scripts:{preinstall:"npx only-allow pnpm",test:"vitest","test:watch":"vitest --watch",lint:"eslint src --ext .ts","lint:fix":"eslint src --ext .ts --fix",format:"prettier --check --ignore-path .gitignore .","format:fix":"prettier --write --ignore-path .gitignore .",build:"tsup","build:watch":"tsup --watch","$comment:bump:prerelease":"This is a workaround to support `npm version prerelease` with lerna","bump:prerelease":"npm version prerelease --preid=alpha & PID=$!; (sleep 1 && kill -9 $PID) & wait $PID","release:alpha":"pnpm bump:prerelease || pnpm build && npm publish --dry-run"},keywords:["novu","code-first","workflows","durable","sdk","notifications","email","sms","push","webhooks","next","nuxt","h3","express"],author:"Novu",license:"MIT",exports:{".":{require:"./dist/index.js",import:"./dist/index.js",types:"./dist/index.d.ts"},"./express":{require:"./dist/express.js",import:"./dist/express.js",types:"./dist/express.d.ts"},"./next":{require:"./dist/next.js",import:"./dist/next.js",types:"./dist/next.d.ts"},"./nuxt":{require:"./dist/nuxt.js",import:"./dist/nuxt.js",types:"./dist/nuxt.d.ts"},"./h3":{require:"./dist/h3.js",import:"./dist/h3.js",types:"./dist/h3.d.ts"},"./sveltekit":{require:"./dist/sveltekit.js",import:"./dist/sveltekit.js",types:"./dist/sveltekit.d.ts"},"./remix":{require:"./dist/remix.js",import:"./dist/remix.js",types:"./dist/remix.d.ts"}},devDependencies:{"@sveltejs/kit":"^2.5.10","@types/express":"^4.17.13","@types/json-schema":"^7.0.15","@types/node":"^20.11.20","@vercel/node":"^2.15.9",express:"^4.18.2",h3:"^1.11.1",next:"^13.5.4",prettier:"^3.2.5","ts-node":"^10.9.2",tsup:"^8.0.2",typescript:"^5.3.3",vitest:"^1.2.1"},dependencies:{ajv:"^8.12.0","ajv-formats":"^2.1.1","better-ajv-errors":"^1.2.0",chalk:"^4.1.2","cross-fetch":"^4.0.0","json-schema-faker":"^0.5.6","json-schema-to-ts":"^3.0.0",liquidjs:"^10.13.1",ora:"^5.4.1"}};var ce=ge.version;jsonSchemaFaker.JSONSchemaFaker.option({useDefaultValue:!0,alwaysFakeOptionals:!0});var N=class{discoveredWorkflows=[];ajv;templateEngine=new liquidjs.Liquid;apiUrl;apiKey;version=ce;strictAuthentication;static NOVU_SIGNATURE_HEADER="x-novu-signature";constructor(e){let t=this.buildOptions(e);this.apiKey=t.apiKey,this.apiUrl=t.apiUrl,this.strictAuthentication=t.strictAuthentication;let i=new Me__default.default({useDefaults:!0});Ue__default.default(i),this.ajv=i;}buildOptions(e){let t={apiKey:void 0,apiUrl:ue,strictAuthentication:!0};return e?.apiKey!==void 0?t.apiKey=e.apiKey:process.env.NOVU_API_KEY!==void 0&&(t.apiKey=process.env.NOVU_API_KEY),e?.apiUrl!==void 0?t.apiUrl=e.apiUrl:process.env.NOVU_API_URL!==void 0&&(t.apiUrl=process.env.NOVU_API_URL),e?.strictAuthentication!==void 0?t.strictAuthentication=e.strictAuthentication:process.env.NOVU_STRICT_AUTHENTICATION!==void 0&&(t.strictAuthentication=process.env.NOVU_STRICT_AUTHENTICATION==="true"),t}addWorkflows(e){for(let t of e){if(this.discoveredWorkflows.some(i=>i.workflowId===t.workflowId))throw new oe(t.workflowId);this.discoveredWorkflows.push(t);}}healthCheck(){let e=this.discoveredWorkflows.length,t=this.discoveredWorkflows.reduce((i,n)=>i+n.steps.length,0);return {status:"ok",version:ce,discovered:{workflows:e,steps:t}}}getWorkflow(e){let t=this.discoveredWorkflows.find(i=>i.workflowId===e);if(t)return t;throw new D(e)}getStep(e,t){let n=this.getWorkflow(e).steps.find(s=>s.stepId===t);if(n)return n;throw new ie(t)}getRegisteredWorkflows(){return this.discoveredWorkflows}discover(){return {workflows:this.getRegisteredWorkflows()}}getHeaders(e){let t={"content-type":"application/json",authorization:`ApiKey ${this.apiKey}`};return e&&(t["x-novu-anonymous"]=e),t}async diff(e,t){let i=this.discover()?.workflows||[];return (await fetch(this.apiUrl+"/v1/bridge/diff",{method:"POST",headers:this.getHeaders(t),body:JSON.stringify({workflows:i,bridgeUrl:e})})).json()}async sync(e,t,i){let{workflows:n}=this.discover();return (await fetch(`${this.apiUrl}/v1/bridge/sync?source=${i||"sdk"}`,{method:"POST",headers:this.getHeaders(t),body:JSON.stringify({workflows:n,bridgeUrl:e})})).json()}mock(e){return jsonSchemaFaker.JSONSchemaFaker.generate(e)}validate(e,t,i,n,s,a,r,h){if(!t(e)){let u=qe__default.default(i,e,t.errors||[]);switch(console.error(`
21
+ ${u}`),n){case"event":this.validateEvent(s,a,t);case"step":this.validateStep(r,s,a,t);case"provider":this.validateProvider(r,h,s,a,t);}}}validateProvider(e,t,i,n,s){if(!e)throw new Error("stepId is required");if(!t)throw new Error("providerId is required");switch(i){case"output":throw new B(n,e,t,s.errors);default:throw new Error(`Invalid payload type: '${i}'`)}}validateStep(e,t,i,n){if(!e)throw new Error("stepId is required");switch(t){case"output":throw new Y(i,e,n.errors);case"result":throw new V(i,e,n.errors);case"input":throw new W(i,e,n.errors);default:throw new Error(`Invalid payload type: '${t}'`)}}validateEvent(e,t,i){switch(e){case"input":throw new A(t,i.errors);case"data":throw new F(t,i.errors);default:throw new Error(`Invalid payload type: '${e}'`)}}executeStepFactory(e,t){return async(i,n,s)=>{let a=this.getStep(e.workflowId,i),r=Fe(e),h=this.createStepInputs(a,r),p=e.action==="preview";if(!p&&await this.shouldSkip(s?.skip,h))return t({options:{skip:!0}}),{};let u=this.previewStep.bind(this),m=this.executeStep.bind(this),j=await(p?u:m)(e,{...a,providers:a.providers.map(k=>{let O=s?.providers?.[k.type];if(!O)throw new z(k.type);return {...k,resolve:O}}),resolve:n});return i===e.stepId&&t(j),j.outputs}}async shouldSkip(e,t){return e?e(t):!1}async executeWorkflow(e){let n=`${{execute:"Executing",preview:"Previewing"}[e.action]} workflowId:`;console.log(`
22
+ ${l.bold(l.underline(n))} '${e.workflowId}'`);let s=this.getWorkflow(e.workflowId),a=process.hrtime(),r={outputs:{},providers:{},options:{}},h,p=new Promise(_=>{h=_;}),u=_=>{h(),r=_;},m;try{if(e.action==="execute"&&!e.data)throw new A(e.workflowId,{message:"Event `data` is required"});let _=this.createExecutionInputs(e,s);await Promise.race([p,s.execute({payload:_,environment:{},input:{},subscriber:e.subscriber,step:{email:this.executeStepFactory(e,u),sms:this.executeStepFactory(e,u),inApp:this.executeStepFactory(e,u),digest:this.executeStepFactory(e,u),delay:this.executeStepFactory(e,u),push:this.executeStepFactory(e,u),chat:this.executeStepFactory(e,u),custom:this.executeStepFactory(e,u)}})]);}catch(_){m=_;}let I=process.hrtime(a),j=I[0],k=I[1],O=j*1e3+k/1e6,De=m?d.ERROR:d.SUCCESS,Ne=e.action==="execute"?"Executed":e.action==="preview"?"Previewed":"Invalid action";if(console.log(`${De} ${Ne} workflowId: \`${e.workflowId}\``),this.prettyPrintExecute(e,O,m),m)throw m;return {outputs:r.outputs,providers:r.providers,options:r.options,metadata:{status:"success",error:!1,duration:O}}}createExecutionInputs(e,t){let i=e.data;return this.validate(e.data,t.data.validate,t.data.schema,"event","input",e.workflowId),i}prettyPrintExecute(e,t,i){let n=i?d.ERROR:d.SUCCESS,s=e.action==="execute"?"Executed":e.action==="preview"?"Previewed":"Invalid action",a=i?"Failed to execute":s,r=i?l.error:l.success,h=`${n} ${a} workflowId: '${e.workflowId}`;console.log(`
23
+ ${l.bold(r(h))}'`),console.log(` \u251C ${d.STEP} stepId: '${e.stepId}'`),console.log(` \u251C ${d.ACTION} action: '${e.action}'`),console.log(` \u2514 ${d.DURATION} duration: '${t.toFixed(2)}ms'
24
+ `);}async executeProviders(e,t){return t.providers.reduce(async(i,n)=>{let s=await i,a=this.previewProvider.bind(this),r=this.executeProvider.bind(this),p=await(e.action==="preview"?a:r)(e,t,n);return {...s,[n.type]:p}},Promise.resolve({}))}previewProvider(e,t,i){return console.log(` ${d.MOCK} Mocked provider: \`${i.type}\``),this.mock(i.outputs.schema)}async executeProvider(e,t,i){let n=se__default.default({indent:2}).start(`Executing provider: \`${i.type}\``);try{if(e.stepId===t.stepId){let s=this.createStepInputs(t,e),a=await i.resolve({inputs:s});return this.validate(a,i.outputs.validate,i.outputs.schema,"step","output",e.workflowId,t.stepId,i.type),n.succeed(`Executed provider: \`${i.type}\``),a}else n.stopAndPersist({symbol:d.HYDRATED,text:`Hydrated provider: \`${i.type}\``});}catch(s){throw n.stopAndPersist({symbol:d.ERROR,text:`Failed to execute provider: \`${i.type}\``}),new J(`Failed to execute provider: '${i.type}'.
25
+ ${s.message}`)}}async executeStep(e,t){if(e.stepId===t.stepId){let i=se__default.default({indent:1}).start(`Executing stepId: \`${t.stepId}\``);try{let n=this.createStepInputs(t,e),s=await this.compileInputs(n,e),a=await t.resolve(s);this.validate(a,t.outputs.validate,t.outputs.schema,"step","output",e.workflowId,t.stepId);let r=await this.executeProviders(e,t);return i.succeed(`Executed stepId: \`${t.stepId}\``),{outputs:a,providers:r}}catch(n){throw i.stopAndPersist({prefixText:"",symbol:d.ERROR,text:`Failed to execute stepId: \`${t.stepId}\``}),n}}else {let i=se__default.default({indent:1}).start(`Hydrating stepId: \`${t.stepId}\``);try{let n=e.state.find(s=>s.stepId===t.stepId);if(n)return this.validate(n.outputs,t.results.validate,t.results.schema,"step","result",e.workflowId,t.stepId),i.stopAndPersist({symbol:d.HYDRATED,text:`Hydrated stepId: \`${t.stepId}\``}),{outputs:n.outputs,providers:await this.executeProviders(e,t)};throw new L(e.workflowId,t.stepId)}catch(n){throw i.stopAndPersist({symbol:d.ERROR,text:`Failed to hydrate stepId: \`${t.stepId}\``}),n}}}async compileInputs(e,t){let i=this.templateEngine.parse(JSON.stringify(e)),n=await this.templateEngine.render(i,{...t.data,subscriber:t.subscriber});return JSON.parse(n)}createStepInputs(e,t){let i=t.inputs;return this.validate(i,e.inputs.validate,e.inputs.schema,"step","input",t.workflowId,e.stepId),i}async previewStep(e,t){let i=se__default.default({indent:1}).start(`Previewing stepId: \`${t.stepId}\``);try{if(e.stepId===t.stepId){let n=this.createStepInputs(t,e),s=await t.resolve(n);return this.validate(s,t.outputs.validate,t.outputs.schema,"step","output",e.workflowId,t.stepId),i.stopAndPersist({symbol:d.MOCK,text:`Mocked stepId: \`${t.stepId}\``}),{outputs:s,providers:await this.executeProviders(e,t)}}else {let n=this.mock(t.results.schema);return i.stopAndPersist({symbol:d.MOCK,text:`Mocked stepId: \`${t.stepId}\``}),{outputs:n,providers:await this.executeProviders(e,t)}}}catch(n){throw i.stopAndPersist({symbol:d.ERROR,text:`Failed to preview stepId: \`${t.stepId}\``}),n}}getStepCode(e,t){return {code:this.getStep(e,t).resolve.toString()}}getWorkflowCode(e){return {code:this.getWorkflow(e).execute.toString()}}getCode(e,t){let i;if(e)t?i=this.getStepCode(e,t):i=this.getWorkflowCode(e);else throw new D(e);return i}};function Fe(o){return JSON.parse(JSON.stringify(o))}var We=(p=>(p.PENDING="pending",p.QUEUED="queued",p.RUNNING="running",p.COMPLETED="completed",p.FAILED="failed",p.DELAYED="delayed",p.CANCELED="canceled",p.MERGED="merged",p.SKIPPED="skipped",p))(We||{});var pe=class{frameworkName;handler;client;hmacEnabled;constructor(e){this.handler=e.handler,this.client=e.client?e.client:new N,this.client.addWorkflows(e.workflows),this.frameworkName=e.frameworkName,this.hmacEnabled=this.client.strictAuthentication;}createHandler(){return async(...e)=>{let t=await this.handler(...e),i=await this.handleAction({actions:t});return t.transformResponse(i)}}getStaticHeaders(){let e=`novu-framework:v${this.client.version}`;return {"content-type":"application/json","access-control-allow-origin":"*","access-control-allow-methods":"GET, POST","access-control-allow-headers":"*","access-control-max-age":"604800","x-novu-framework":this.frameworkName,"user-agent":e,"x-novu-sdk":e}}createResponse(e,t,i={}){return {status:e,body:JSON.stringify(t),headers:{...this.getStaticHeaders(),...i}}}createError(e){return {status:e.statusCode,body:JSON.stringify({message:e.message,data:e.data,code:e.code}),headers:this.getStaticHeaders()}}async handleAction({actions:e}){let t=await e.url(),i=await e.method(),n=t.searchParams.get("action")||"",s=t.searchParams.get("workflowId")||"",a=t.searchParams.get("stepId")||"",r=await e.headers("x-novu-signature")||"",h=await e.headers("x-novu-anonymous")||"",p=t.searchParams.get("source")||"",u={};try{i==="POST"&&(u=await e.body());}catch{}try{n!=="health-check"&&this.validateHmac(u,r);let m=this.getPostActionMap(u,s,a,n,h,p),I=this.getGetActionMap(s,a);if(i==="POST")return await this.handlePostAction(n,m);if(i==="GET")return await this.handleGetAction(n,I);if(i==="OPTIONS")return this.createResponse(200,{},{...this.getStaticHeaders()})}catch(m){return this.handleError(m)}return this.createError(new K(i))}getPostActionMap(e,t,i,n,s,a){return {execute:async()=>{let r=await this.client.executeWorkflow({...e,workflowId:t,stepId:i,action:n});return this.createResponse(200,r,{"x-novu-execution-duration":r.metadata.duration.toString()})},preview:async()=>{let r=await this.client.executeWorkflow({...e,workflowId:t,stepId:i,action:n});return this.createResponse(200,r,{"x-novu-execution-duration":r.metadata.duration.toString()})},sync:async()=>{if(!this.client.apiKey)throw new C;let r=await this.client.sync(e.bridgeUrl,s,a);return this.createResponse(200,r)},diff:async()=>{if(!this.client.apiKey)throw new C;let r=await this.client.diff(e.bridgeUrl,s);return this.createResponse(200,r)}}}getGetActionMap(e,t){return {discover:async()=>{let i=await this.client.discover();return this.createResponse(200,i)},"health-check":async()=>{let i=await this.client.healthCheck();return this.createResponse(200,i)},code:async()=>{let i=await this.client.getCode(e,t);return this.createResponse(200,i)}}}async handlePostAction(e,t){if(Object.values($).includes(e)){let i=t[e];return i()}else throw new P(e,$)}async handleGetAction(e,t){if(Object.values(M).includes(e)){let i=t[e];return i()}else throw new P(e,M)}isClientError(e){return Object.values(y).includes(e.code)}handleError(e){return this.isClientError(e)?(e.statusCode===500&&console.error(e),this.createError(e)):(console.error(e),this.createError(new X))}validateHmac(e,t){if(!this.hmacEnabled)return;if(!t)throw new Z;if(!this.client.apiKey)throw new te;let[i,n]=t.split(",");if(!i||!n)throw new H;let[s,a]=i.split("="),[r,h]=n.split("=");if(Number(s)<Date.now()-1500)throw new ee;if(!(this.hashHmac(this.client.apiKey,`${a}.${JSON.stringify(e)}`)===h))throw new Q}hashHmac(e,t){return crypto.createHmac("sha256",e).update(t).digest("hex")}};var Be={type:"object",properties:{webhookUrl:{type:"string",format:"uri"},text:{type:"string"},blocks:{type:"array",items:{type:"object",properties:{type:{enum:["image","context","actions","divider","section","input","file","header","video","rich_text"]}},required:["type"],additionalProperties:!0,allOf:[{if:{properties:{type:{const:"image"}}},then:{$ref:"#/definitions/ImageBlock"}},{if:{properties:{type:{const:"context"}}},then:{$ref:"#/definitions/ContextBlock"}},{if:{properties:{type:{const:"actions"}}},then:{$ref:"#/definitions/ActionsBlock"}},{if:{properties:{type:{const:"divider"}}},then:{$ref:"#/definitions/DividerBlock"}},{if:{properties:{type:{const:"section"}}},then:{$ref:"#/definitions/SectionBlock"}},{if:{properties:{type:{const:"Input"}}},then:{$ref:"#/definitions/InputBlock"}},{if:{properties:{type:{const:"Video"}}},then:{$ref:"#/definitions/VideoBlock"}},{if:{properties:{type:{const:"rich_text"}}},then:{$ref:"#/definitions/RichTextBlock"}}]}}},definitions:{KnownBlock:{oneOf:[{$ref:"#/definitions/ImageBlock"},{$ref:"#/definitions/ContextBlock"},{$ref:"#/definitions/ActionsBlock"},{$ref:"#/definitions/DividerBlock"},{$ref:"#/definitions/SectionBlock"},{$ref:"#/definitions/InputBlock"},{$ref:"#/definitions/FileBlock"},{$ref:"#/definitions/HeaderBlock"},{$ref:"#/definitions/VideoBlock"},{$ref:"#/definitions/RichTextBlock"}]},ImageBlock:{type:"object",properties:{type:{type:"string",const:"image",description:"The type of block. For an image block, `type` is always `image`."},block_id:{type:"string"},image_url:{type:"string",description:"The URL of the image to be displayed. Maximum length for this field is 3000 characters."},alt_text:{type:"string",description:`A plain-text summary of the image. This should not contain any markup.
26
+ Maximum length for this field is 2000 characters.`},title:{$ref:"#/definitions/PlainTextElement",description:`An optional title for the image in the form of a {@link PlainTextElement } object.
27
+ Maximum length for the text in this field is 2000 characters.`}},required:["alt_text","image_url","type"],additionalProperties:!1,description:"Displays an image. A simple image block, designed to make those cat photos really pop."},PlainTextElement:{type:"object",properties:{type:{type:"string",const:"plain_text",description:"The formatting to use for this text object."},text:{type:"string",description:"The text for the block. The minimum length is 1 and maximum length is 3000 characters."},emoji:{type:"boolean",description:"Indicates whether emojis in a text field should be escaped into the colon emoji format."}},required:["type","text"],additionalProperties:!1,description:"Defines an object containing some text."},ContextBlock:{type:"object",properties:{type:{type:"string",const:"context",description:"The type of block. For a context block, `type` is always `context`."},block_id:{type:"string"},elements:{type:"array",items:{anyOf:[{$ref:"#/definitions/ImageElement"},{$ref:"#/definitions/PlainTextElement"},{$ref:"#/definitions/MrkdwnElement"}]},description:`An array of {@link ImageElement }, {@link PlainTextElement } or {@link MrkdwnElement } objects.
28
+ Maximum number of items is 10.`}},required:["elements","type"],additionalProperties:!1,description:"Displays contextual info, which can include both images and text."},ImageElement:{type:"object",properties:{type:{type:"string",const:"image",description:"The type of element. In this case `type` is always `image`."},image_url:{type:"string",description:"The URL of the image to be displayed."},alt_text:{type:"string",description:"A plain-text summary of the image. This should not contain any markup."}},required:["type","image_url","alt_text"],additionalProperties:!1,description:"Displays an image as part of a larger block of content. Use this `image` block if you want a block with\nonly an image in it."},MrkdwnElement:{type:"object",properties:{type:{type:"string",const:"mrkdwn",description:"The formatting to use for this text object."},text:{type:"string",description:`The text for the block. This field accepts any of the standard text formatting markup.
29
+ The minimum length is 1 and maximum length is 3000 characters.`},verbatim:{type:"boolean",description:"When set to `false` (as is default) URLs will be auto-converted into links, conversation names will\nbe converted to links, and certain mentions will be {@link https://api.slack.com/reference/surfaces/formatting#automatic-parsing automatically parsed}.\nUsing a value of `true` will skip any preprocessing of this nature, although you can still include\n{@link https://api.slack.com/reference/surfaces/formatting#advanced manual parsing strings}."}},required:["type","text"],additionalProperties:!1,description:"Defines an object containing some text."},ActionsBlock:{type:"object",properties:{type:{type:"string",const:"actions",description:"The type of block. For an actions block, `type` is always `actions`."},block_id:{type:"string",description:"A string acting as a unique identifier for a block. If not specified, a `block_id` will be generated.\nYou can use this `block_id` when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}.\nMaximum length for this field is 255 characters. `block_id` should be unique for each message and each iteration of\na message. If a message is updated, use a new `block_id`."},elements:{type:"array",items:{anyOf:[{$ref:"#/definitions/Button"},{$ref:"#/definitions/Checkboxes"},{$ref:"#/definitions/Datepicker"},{$ref:"#/definitions/DateTimepicker"},{$ref:"#/definitions/MultiSelect"},{$ref:"#/definitions/Overflow"},{$ref:"#/definitions/RadioButtons"},{$ref:"#/definitions/Select"},{$ref:"#/definitions/Timepicker"},{$ref:"#/definitions/WorkflowButton"},{$ref:"#/definitions/RichTextInput"}]},description:`An array of {@link InteractiveElements } objects.
30
+ There is a maximum of 25 elements in each action block.`}},required:["elements","type"],additionalProperties:!1,description:"Holds multiple interactive elements."},Button:{type:"object",properties:{confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
31
+ with.`},type:{type:"string",const:"button",description:"The type of element. In this case `type` is always `button`."},action_id:{type:"string"},text:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } that defines the button's text. `text` may truncate with ~30 characters.\nMaximum length for the text in this field is 75 characters."},value:{type:"string",description:`The value to send along with the {@link https://api.slack.com/interactivity/handling#payloads interaction payload}.
32
+ Maximum length for this field is 2000 characters.`},url:{type:"string",description:"A URL to load in the user's browser when the button is clicked. Maximum length for this field is 3000\ncharacters. If you're using `url`, you'll still receive an {@link https://api.slack.com/interactivity/handling#payloads interaction payload}\nand will need to send an {@link https://api.slack.com/interactivity/handling#acknowledgment_response acknowledgement response}."},style:{type:"string",enum:["danger","primary"],description:"Decorates buttons with alternative visual color schemes. Use this option with restraint.\n`primary` gives buttons a green outline and text, ideal for affirmation or confirmation actions. `primary` should\nonly be used for one button within a set.\n`danger` gives buttons a red outline and text, and should be used when the action is destructive. Use `danger` even\nmore sparingly than primary.\nIf you don't include this field, the default button style will be used."},accessibility_label:{type:"string",description:"A label for longer descriptive text about a button element. This label will be read out by screen\nreaders instead of the button `text` object. Maximum length for this field is 75 characters."}},required:["text","type"],additionalProperties:!1,description:"Allows users a direct path to performing basic actions."},Actionable:{type:"object",additionalProperties:!1,properties:{type:{type:"string"},action_id:{type:"string"}},required:["type"]},Action:{type:"object",properties:{type:{type:"string"},action_id:{type:"string"}},required:["type"],additionalProperties:!1},Confirmable:{type:"object",properties:{confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
33
+ with.`}},additionalProperties:!1},ConfirmationDialog:{type:"object",additionalProperties:!1,properties:{title:{$ref:"#/definitions/PlainTextElement",description:`A {@link PlainTextElement } text object that defines the dialog's title.
34
+ Maximum length for this field is 100 characters.`},text:{anyOf:[{$ref:"#/definitions/PlainTextElement"},{$ref:"#/definitions/MrkdwnElement"}],description:"A {@link PlainTextElement } text object that defines the explanatory text that appears in the confirm\ndialog. Maximum length for the `text` in this field is 300 characters."},confirm:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } text object to define the text of the button that confirms the action.\nMaximum length for the `text` in this field is 30 characters."},deny:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } text object to define the text of the button that cancels the action.\nMaximum length for the `text` in this field is 30 characters."},style:{type:"string",enum:["primary","danger"],description:"Defines the color scheme applied to the `confirm` button. A value of `danger` will display the button\nwith a red background on desktop, or red text on mobile. A value of `primary` will display the button with a green\nbackground on desktop, or blue text on mobile. If this field is not provided, the default value will be `primary`."}},required:["text"],description:"Defines a dialog that adds a confirmation step to interactive elements."},Confirm:{type:"object",properties:{title:{$ref:"#/definitions/PlainTextElement",description:`A {@link PlainTextElement } text object that defines the dialog's title.
35
+ Maximum length for this field is 100 characters.`},text:{anyOf:[{$ref:"#/definitions/PlainTextElement"},{$ref:"#/definitions/MrkdwnElement"}],description:"A {@link PlainTextElement } text object that defines the explanatory text that appears in the confirm\ndialog. Maximum length for the `text` in this field is 300 characters."},confirm:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } text object to define the text of the button that confirms the action.\nMaximum length for the `text` in this field is 30 characters."},deny:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } text object to define the text of the button that cancels the action.\nMaximum length for the `text` in this field is 30 characters."},style:{type:"string",enum:["primary","danger"],description:"Defines the color scheme applied to the `confirm` button. A value of `danger` will display the button\nwith a red background on desktop, or red text on mobile. A value of `primary` will display the button with a green\nbackground on desktop, or blue text on mobile. If this field is not provided, the default value will be `primary`."}},required:["text"],additionalProperties:!1,description:"Defines a dialog that adds a confirmation step to interactive elements."},Checkboxes:{type:"object",properties:{focus_on_load:{type:"boolean"},confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
36
+ with.`},type:{type:"string",const:"checkboxes",description:"The type of element. In this case `type` is always `checkboxes`."},action_id:{type:"string"},initial_options:{type:"array",items:{$ref:"#/definitions/Option"},description:"An array of {@link Option } objects that exactly matches one or more of the options within `options`.\nThese options will be selected when the checkbox group initially loads."},options:{type:"array",items:{$ref:"#/definitions/Option"},description:"An array of {@link Option } objects. A maximum of 10 options are allowed."}},required:["options","type"],additionalProperties:!1,description:"Allows users to choose multiple items from a list of options."},Focusable:{type:"object",properties:{focus_on_load:{type:"boolean"}},additionalProperties:!1},Option:{anyOf:[{$ref:"#/definitions/MrkdwnOption"},{$ref:"#/definitions/PlainTextOption"}],description:`Defines a single item in a number of item selection elements. An object that represents a single
37
+ selectable item in a select menu, multi-select menu, checkbox group, radio button group, or overflow menu.`},MrkdwnOption:{type:"object",properties:{value:{type:"string",description:`A unique string value that will be passed to your app when this option is chosen.
38
+ Maximum length for this field is 75 characters.`},url:{type:"string",description:`Only available in overflow menus! A URL to load in the user's browser when the option is clicked.
39
+ Maximum length for this field is 3000 characters.`},description:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } that defines a line of descriptive text shown below the `text` field.\nMaximum length for the `text` within this field is 75 characters."},text:{$ref:"#/definitions/MrkdwnElement",description:"A {@link MrkdwnElement } that defines the text shown in the option on the menu. To be used with\nradio buttons and checkboxes. Maximum length for the `text` in this field is 75 characters."}},required:["text"],additionalProperties:!1},PlainTextOption:{type:"object",properties:{value:{type:"string",description:`A unique string value that will be passed to your app when this option is chosen.
40
+ Maximum length for this field is 75 characters.`},url:{type:"string",description:`Only available in overflow menus! A URL to load in the user's browser when the option is clicked.
41
+ Maximum length for this field is 3000 characters.`},description:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } that defines a line of descriptive text shown below the `text` field.\nMaximum length for the `text` within this field is 75 characters."},text:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } that defines the text shown in the option on the menu. To be used with\noverflow, select and multi-select menus. Maximum length for the `text` in this field is 75 characters."}},required:["text"],additionalProperties:!1},Datepicker:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
42
+ with.`},type:{type:"string",const:"datepicker",description:"The type of element. In this case `type` is always `datepicker`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_date:{type:"string",description:"The initial date that is selected when the element is loaded.\nThis should be in the format `YYYY-MM-DD`."}},required:["type"],additionalProperties:!1,description:"Allows users to select a date from a calendar style UI."},Placeholdable:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."}},additionalProperties:!1},DateTimepicker:{type:"object",properties:{focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
43
+ with.`},type:{type:"string",const:"datetimepicker",description:"The type of element. In this case `type` is always `datetimepicker`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_date_time:{type:"number"}},required:["type"],additionalProperties:!1,description:`Allows users to select both a date and a time of day, formatted as a Unix timestamp. On desktop
44
+ clients, this time picker will take the form of a dropdown list and the date picker will take the form of a dropdown
45
+ calendar. Both options will have free-text entry for precise choices. On mobile clients, the time picker and date
46
+ picker will use native UIs.`},MultiSelect:{anyOf:[{$ref:"#/definitions/MultiUsersSelect"},{$ref:"#/definitions/MultiStaticSelect"},{$ref:"#/definitions/MultiConversationsSelect"},{$ref:"#/definitions/MultiChannelsSelect"},{$ref:"#/definitions/MultiExternalSelect"}],description:`Allows users to select multiple items from a list of options.
47
+ Just like regular {@link Select }, multi-select menus also include type-ahead functionality, where a user can type a
48
+ part or all of an option string to filter the list.
49
+ There are different types of multi-select menu that depend on different data sources for their lists of options:
50
+ {@link MultiStaticSelect }, {@link MultiExternalSelect }, {@link MultiUsersSelect }, {@link MultiConversationsSelect },
51
+ {@link MultiChannelsSelect }.`},MultiUsersSelect:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
52
+ with.`},type:{type:"string",const:"multi_users_select",description:"The type of element. In this case `type` is always `multi_users_select`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_users:{type:"array",items:{type:"string"},description:"An array of user IDs of any valid users to be pre-selected when the menu loads."},max_selected_items:{type:"number",description:"Specifies the maximum number of items that can be selected in the menu. Minimum number is `1`."}},required:["type"],additionalProperties:!1,description:`This multi-select menu will populate its options with a list of Slack users visible to the current user
53
+ in the active workspace.`},MultiStaticSelect:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
54
+ with.`},type:{type:"string",const:"multi_static_select",description:"The type of element. In this case `type` is always `multi_static_select`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_options:{type:"array",items:{$ref:"#/definitions/PlainTextOption"},description:"An array of option objects that exactly match one or more of the options within `options` or\n`option_groups`. These options will be selected when the menu initially loads."},options:{type:"array",items:{$ref:"#/definitions/PlainTextOption"},description:"An array of {@link PlainTextOption }. Maximum number of options is 100. If `option_groups` is\nspecified, this field should not be."},option_groups:{type:"array",items:{type:"object",properties:{label:{$ref:"#/definitions/PlainTextElement"},options:{type:"array",items:{$ref:"#/definitions/PlainTextOption"}}},required:["label","options"],additionalProperties:!1},description:"An array of option group objects. Maximum number of option groups is 100. If `options` is specified,\nthis field should not be."},max_selected_items:{type:"number",description:"Specifies the maximum number of items that can be selected in the menu. Minimum number is 1."}},required:["type"],additionalProperties:!1,description:`This is the simplest form of select menu, with a static list of options passed in when defining the
55
+ element.`},MultiConversationsSelect:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
56
+ with.`},type:{type:"string",const:"multi_conversations_select",description:"The type of element. In this case `type` is always `conversations_select`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_conversations:{type:"array",items:{type:"string"},description:"An array of one or more IDs of any valid conversations to be pre-selected when the menu loads. If\n`default_to_current_conversation` is also supplied, `initial_conversation` will be ignored."},max_selected_items:{type:"number",description:"Specifies the maximum number of items that can be selected in the menu. Minimum number is 1."},default_to_current_conversation:{type:"boolean",description:"Pre-populates the select menu with the conversation that the user was viewing when they opened the\nmodal, if available. Default is `false`."},filter:{type:"object",properties:{include:{type:"array",items:{type:"string",enum:["im","mpim","private","public"]}},exclude_external_shared_channels:{type:"boolean"},exclude_bot_users:{type:"boolean"}},additionalProperties:!1,description:"A filter object that reduces the list of available conversations using the specified criteria."}},required:["type"],additionalProperties:!1,description:`This multi-select menu will populate its options with a list of public and private channels, DMs, and
57
+ MPIMs visible to the current user in the active workspace.`},MultiChannelsSelect:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
58
+ with.`},type:{type:"string",const:"multi_channels_select",description:"The type of element. In this case `type` is always `multi_channels_select`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_channels:{type:"array",items:{type:"string"},description:"An array of one or more IDs of any valid public channel to be pre-selected when the menu loads."},max_selected_items:{type:"number",description:"Specifies the maximum number of items that can be selected in the menu. Minimum number is 1."}},required:["type"],additionalProperties:!1,description:`This multi-select menu will populate its options with a list of public channels visible to the current
59
+ user in the active workspace.`},MultiExternalSelect:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
60
+ with.`},type:{type:"string",const:"multi_external_select",description:"The type of element. In this case `type` is always `multi_external_select`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_options:{type:"array",items:{$ref:"#/definitions/PlainTextOption"},description:"An array of options to be selected when the menu initially loads."},min_query_length:{type:"number",description:"When the typeahead field is used, a request will be sent on every character change. If you prefer\nfewer requests or more fully ideated queries, use the `min_query_length` attribute to tell Slack the fewest number\nof typed characters required before dispatch. The default value is `3`."},max_selected_items:{type:"number",description:"Specifies the maximum number of items that can be selected in the menu. Minimum number is 1."}},required:["type"],additionalProperties:!1,description:"This menu will load its options from an external data source, allowing for a dynamic list of options."},Overflow:{type:"object",properties:{confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
61
+ with.`},type:{type:"string",const:"overflow",description:"The type of element. In this case `type` is always `number_input`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},options:{type:"array",items:{$ref:"#/definitions/PlainTextOption"},description:"An array of up to 5 {@link PlainTextOption } to display in the menu."}},required:["options","type"],additionalProperties:!1,description:`Allows users to press a button to view a list of options.
62
+ Unlike the select menu, there is no typeahead field, and the button always appears with an ellipsis ("\u2026") rather
63
+ than customizable text. As such, it is usually used if you want a more compact layout than a select menu, or to
64
+ supply a list of less visually important actions after a row of buttons. You can also specify simple URL links as
65
+ overflow menu options, instead of actions.`},RadioButtons:{type:"object",properties:{focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
66
+ with.`},type:{type:"string",const:"radio_buttons",description:"The type of element. In this case `type` is always `radio_buttons`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_option:{$ref:"#/definitions/Option",description:"An {@link Option } object that exactly matches one of the options within `options`. This option will\nbe selected when the radio button group initially loads."},options:{type:"array",items:{$ref:"#/definitions/Option"},description:"An array of {@link Option } objects. A maximum of 10 options are allowed."}},required:["options","type"],additionalProperties:!1,description:"Allows users to choose one item from a list of possible options."},Select:{anyOf:[{$ref:"#/definitions/UsersSelect"},{$ref:"#/definitions/StaticSelect"},{$ref:"#/definitions/ConversationsSelect"},{$ref:"#/definitions/ChannelsSelect"},{$ref:"#/definitions/ExternalSelect"}],description:`Allows users to choose an option from a drop down menu.
67
+ The select menu also includes type-ahead functionality, where a user can type a part or all of an option string to
68
+ filter the list. There are different types of select menu elements that depend on different data sources for their
69
+ lists of options: {@link StaticSelect }, {@link ExternalSelect }, {@link UsersSelect }, {@link ConversationsSelect },
70
+ {@link ChannelsSelect }.`},UsersSelect:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
71
+ with.`},type:{type:"string",const:"users_select",description:"The type of element. In this case `type` is always `users_select`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_user:{type:"string",description:"The user ID of any valid user to be pre-selected when the menu loads."}},required:["type"],additionalProperties:!1,description:`This select menu will populate its options with a list of Slack users visible to the current user in the
72
+ active workspace.`},StaticSelect:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
73
+ with.`},type:{type:"string",const:"static_select",description:"The type of element. In this case `type` is always `static_select`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_option:{$ref:"#/definitions/PlainTextOption",description:"A single option that exactly matches one of the options within `options` or `option_groups`.\nThis option will be selected when the menu initially loads."},options:{type:"array",items:{$ref:"#/definitions/PlainTextOption"},description:"An array of {@link PlainTextOption }. Maximum number of options is 100. If `option_groups` is\nspecified, this field should not be."},option_groups:{type:"array",items:{type:"object",properties:{label:{$ref:"#/definitions/PlainTextElement"},options:{type:"array",items:{$ref:"#/definitions/PlainTextOption"}}},required:["label","options"],additionalProperties:!1},description:"An array of option group objects. Maximum number of option groups is 100. If `options` is specified,\nthis field should not be."}},required:["type"],additionalProperties:!1,description:`This is the simplest form of select menu, with a static list of options passed in when defining the
74
+ element.`},ConversationsSelect:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
75
+ with.`},type:{type:"string",const:"conversations_select",description:"The type of element. In this case `type` is always `conversations_select`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_conversation:{type:"string",description:"The ID of any valid conversation to be pre-selected when the menu loads. If\n`default_to_current_conversation` is also supplied, `initial_conversation` will take precedence."},response_url_enabled:{type:"boolean",description:"When set to `true`, the {@link https://api.slack.com/reference/interaction-payloads/views#view_submission `view_submission` payload}\nfrom the menu's parent view will contain a `response_url`. This `response_url` can be used for\n{@link https://api.slack.com/interactivity/handling#message_responses message responses}. The target conversation\nfor the message will be determined by the value of this select menu."},default_to_current_conversation:{type:"boolean",description:"Pre-populates the select menu with the conversation that the user was viewing when they opened the\nmodal, if available. Default is `false`."},filter:{type:"object",properties:{include:{type:"array",items:{type:"string",enum:["im","mpim","private","public"]}},exclude_external_shared_channels:{type:"boolean"},exclude_bot_users:{type:"boolean"}},additionalProperties:!1,description:"A filter object that reduces the list of available conversations using the specified criteria."}},required:["type"],additionalProperties:!1,description:`This select menu will populate its options with a list of public and private channels, DMs, and MPIMs
76
+ visible to the current user in the active workspace.`},ChannelsSelect:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
77
+ with.`},type:{type:"string",const:"channels_select",description:"The type of element. In this case `type` is always `channels_select`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_channel:{type:"string",description:"The ID of any valid public channel to be pre-selected when the menu loads."},response_url_enabled:{type:"boolean",description:"When set to `true`, the {@link https://api.slack.com/reference/interaction-payloads/views#view_submission `view_submission` payload}\nfrom the menu's parent view will contain a `response_url`. This `response_url` can be used for\n{@link https://api.slack.com/interactivity/handling#message_responses message responses}. The target channel\nfor the message will be determined by the value of this select menu."}},required:["type"],additionalProperties:!1,description:`This select menu will populate its options with a list of public channels visible to the current user
78
+ in the active workspace.`},ExternalSelect:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
79
+ with.`},type:{type:"string",const:"external_select",description:"The type of element. In this case `type` is always `external_select`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_option:{$ref:"#/definitions/PlainTextOption",description:"A single option to be selected when the menu initially loads."},min_query_length:{type:"number",description:"When the typeahead field is used, a request will be sent on every character change. If you prefer\nfewer requests or more fully ideated queries, use the `min_query_length` attribute to tell Slack the fewest number\nof typed characters required before dispatch. The default value is `3`."}},required:["type"],additionalProperties:!1,description:`This select menu will load its options from an external data source, allowing for a dynamic list of
80
+ options.`},Timepicker:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
81
+ with.`},type:{type:"string",const:"timepicker",description:"The type of element. In this case `type` is always `timepicker`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_time:{type:"string",description:"The initial time that is selected when the element is loaded. This should be in the format `HH:mm`,\nwhere `HH` is the 24-hour format of an hour (00 to 23) and `mm` is minutes with leading zeros (00 to 59),\nfor example 22:25 for 10:25pm."},timezone:{type:"string",description:`A string in the IANA format, e.g. "America/Chicago". The timezone is displayed to end users as hint
82
+ text underneath the time picker. It is also passed to the app upon certain interactions, such as view_submission.`}},required:["type"],additionalProperties:!1,description:`Allows users to choose a time from a rich dropdown UI. On desktop clients, this time picker will take
83
+ the form of a dropdown list with free-text entry for precise choices. On mobile clients, the time picker will use
84
+ native time picker UIs.`},WorkflowButton:{type:"object",properties:{confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
85
+ with.`},type:{type:"string",const:"workflow_button",description:"The type of element. In this case `type` is always `workflow_button`."},text:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } that defines the button's text. `text` may truncate with ~30 characters.\nMaximum length for the `text` in this field is 75 characters."},workflow:{type:"object",properties:{trigger:{type:"object",properties:{url:{type:"string",description:"The trigger URL of the {@link https://api.slack.com/automation/triggers/link#workflow_buttons link trigger}"},customizable_input_parameters:{type:"array",items:{type:"object",properties:{name:{type:"string",description:`Name of the customizable input, which should be the name of a workflow input parameter for the
86
+ matching workflow of the link trigger.`},value:{type:"string",description:`The value of the customizable input parameter. The type of the value is expected to match the
87
+ specified type for the matching workflow input parameter.`}},required:["name","value"],additionalProperties:!1},description:`List of customizable input parameters and their values. Should match input parameters specified on
88
+ the provided trigger.`}},required:["url"],additionalProperties:!1,description:"Properties of the {@link https://api.slack.com/automation/triggers/link#workflow_buttons link trigger}that will be invoked via this button."}},required:["trigger"],additionalProperties:!1,description:"A workflow object that contains details about the workflow that will run when the button is clicked."},style:{type:"string",enum:["danger","primary"],description:"Decorates buttons with alternative visual color schemes. Use this option with restraint.\n`primary` gives buttons a green outline and text, ideal for affirmation or confirmation actions. `primary` should\nonly be used for one button within a set.\n`danger` gives buttons a red outline and text, and should be used when the action is destructive. Use `danger` even\nmore sparingly than primary.\nIf you don't include this field, the default button style will be used."},accessibility_label:{type:"string",description:"A label for longer descriptive text about a button element. This label will be read out by screen\nreaders instead of the button `text` object. Maximum length for this field is 75 characters."}},required:["type","text","workflow"],additionalProperties:!1,description:"Allows users to run a {@link https://api.slack.com/automation/triggers/link#workflow_buttons link trigger} with customizable inputs."},RichTextInput:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},dispatch_action_config:{$ref:"#/definitions/DispatchActionConfig"},type:{type:"string",const:"rich_text_input",description:"The type of element. In this case `type` is always `rich_text_input`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_value:{$ref:"#/definitions/RichTextBlock",description:"Initial contents of the input when it is loaded."}},required:["type"],additionalProperties:!1,description:`A rich text input creates a composer/WYSIWYG editor for entering formatted text, offering nearly the
89
+ same experience you have writing messages in Slack.`},Dispatchable:{type:"object",properties:{dispatch_action_config:{$ref:"#/definitions/DispatchActionConfig"}},additionalProperties:!1},DispatchActionConfig:{type:"object",properties:{trigger_actions_on:{type:"array",items:{type:"string",enum:["on_enter_pressed","on_character_entered"]},description:"An array of interaction types that you would like to receive a\n{@link https://api.slack.com/reference/interaction-payloads/block-actions `block_actions` payload} for. Should be\none or both of:\n`on_enter_pressed` \u2014 payload is dispatched when user presses the enter key while the input is in focus. Hint\ntext will appear underneath the input explaining to the user to press enter to submit.\n`on_character_entered` \u2014 payload is dispatched when a character is entered (or removed) in the input."}},additionalProperties:!1,description:"Defines when a {@link PlainTextElement } will return a {@link https://api.slack.com/reference/interaction-payloads/block-actions `block_actions` interaction payload}."},RichTextBlock:{type:"object",properties:{type:{type:"string",const:"rich_text",description:"The type of block. For a rich text block, `type` is always `rich_text`."},block_id:{type:"string",description:"A string acting as a unique identifier for a block. If not specified, a `block_id` will be generated.\nYou can use this `block_id` when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}.\nMaximum length for this field is 255 characters. `block_id` should be unique for each message and each iteration of\na message. If a message is updated, use a new `block_id`."},elements:{type:"array",items:{anyOf:[{$ref:"#/definitions/RichTextSection"},{$ref:"#/definitions/RichTextList"},{$ref:"#/definitions/RichTextQuote"},{$ref:"#/definitions/RichTextPreformatted"}]}}},required:["elements","type"],additionalProperties:!1},RichTextSection:{type:"object",properties:{type:{type:"string",const:"rich_text_section",description:"The type of element. In this case `type` is always `rich_text_section`."},elements:{type:"array",items:{$ref:"#/definitions/RichTextElement"}}},required:["type","elements"],additionalProperties:!1,description:"A section block within a rich text field."},RichTextElement:{anyOf:[{$ref:"#/definitions/RichTextBroadcastMention"},{$ref:"#/definitions/RichTextColor"},{$ref:"#/definitions/RichTextChannelMention"},{$ref:"#/definitions/RichTextDate"},{$ref:"#/definitions/RichTextEmoji"},{$ref:"#/definitions/RichTextLink"},{$ref:"#/definitions/RichTextTeamMention"},{$ref:"#/definitions/RichTextText"},{$ref:"#/definitions/RichTextUserMention"},{$ref:"#/definitions/RichTextUsergroupMention"}],description:"Union of rich text sub-elements for use within rich text blocks."},RichTextBroadcastMention:{type:"object",properties:{style:{type:"object",properties:{bold:{type:"boolean"},italic:{type:"boolean"},strike:{type:"boolean"},highlight:{type:"boolean"}},additionalProperties:!1},type:{type:"string",const:"broadcast",description:"The type of element. In this case `type` is always `broadcast`."},range:{type:"string",enum:["here","channel","everyone"],description:"The range of the broadcast; can be one of `here`, `channel` and `everyone`."}},required:["type","range"],additionalProperties:!1,description:"A broadcast mention element for use in a rich text message."},RichTextStyleable:{type:"object",properties:{style:{type:"object",properties:{bold:{type:"boolean"},italic:{type:"boolean"},strike:{type:"boolean"},highlight:{type:"boolean"}},additionalProperties:!1}},additionalProperties:!1,description:"For use styling Rich Text message sub-elements."},RichTextColor:{type:"object",properties:{style:{type:"object",properties:{bold:{type:"boolean"},italic:{type:"boolean"},strike:{type:"boolean"},highlight:{type:"boolean"}},additionalProperties:!1},type:{type:"string",const:"color",description:"The type of element. In this case `type` is always `color`."},value:{type:"string",description:"The hex value for the color."}},required:["type","value"],additionalProperties:!1,description:"A hex color element for use in a rich text message."},RichTextChannelMention:{type:"object",properties:{style:{type:"object",properties:{bold:{type:"boolean"},italic:{type:"boolean"},strike:{type:"boolean"},highlight:{type:"boolean"}},additionalProperties:!1},type:{type:"string",const:"channel",description:"The type of element. In this case `type` is always `channel`."},channel_id:{type:"string",description:"The encoded channel ID, e.g. C1234ABCD."}},required:["type","channel_id"],additionalProperties:!1,description:"A channel mention element for use in a rich text message."},RichTextDate:{type:"object",properties:{style:{type:"object",properties:{bold:{type:"boolean"},italic:{type:"boolean"},strike:{type:"boolean"},highlight:{type:"boolean"}},additionalProperties:!1},type:{type:"string",const:"date",description:"The type of element. In this case `type` is always `date`."},timestamp:{type:"number",description:"A UNIX timestamp for the date to be displayed in seconds."},format:{type:"string",description:"A template string containing curly-brace-enclosed tokens to substitute your provided `timestamp`\nin a particularly-formatted way. For example: `Posted at {date_long}`. The available date formatting tokens are:\n- `{day_divider_pretty}`: Shows `today`, `yesterday` or `tomorrow` if applicable. Otherwise, if the date is in\ncurrent year, uses the `{date_long}` format without the year. Otherwise, falls back to using the `{date_long}`\nformat.\n- `{date_num}`: Shows date as YYYY-MM-DD.\n- `{date_slash}`: Shows date as DD/MM/YYYY (subject to locale preferences).\n- `{date_long}`: Shows date as a long-form sentence including day-of-week, e.g. `Monday, December 23rd, 2013`.\n- `{date_long_full}`: Shows date as a long-form sentence without day-of-week, e.g. `August 9, 2020`.\n- `{date_long_pretty}`: Shows `yesterday`, `today` or `tomorrow`, otherwise uses the `{date_long}` format.\n- `{date}`: Same as `{date_long_full}` but without the year.\n- `{date_pretty}`: Shows `today`, `yesterday` or `tomorrow` if applicable, otherwise uses the `{date}` format.\n- `{date_short}`: Shows date using short month names without day-of-week, e.g. `Aug 9, 2020`.\n- `{date_short_pretty}`: Shows `today`, `yesterday` or `tomorrow` if applicable, otherwise uses the `{date_short}`\nformat.\n- `{time}`: Depending on user preferences, shows just the time-of-day portion of the timestamp using either 12 or\n24 hour clock formats, e.g. `2:34 PM` or `14:34`.\n- `{time_secs}`: Depending on user preferences, shows just the time-of-day portion of the timestamp using either 12\nor 24 hour clock formats, including seconds, e.g. `2:34:56 PM` or `14:34:56`.\n- `{ago}`: A human-readable period of time, e.g. `3 minutes ago`, `4 hours ago`, `2 days ago`.\nTODO: test/document `{member_local_time}`, `{status_expiration}` and `{calendar_header}`"},url:{type:"string",description:"URL to link the entire `format` string to."},fallback:{type:"string",description:"Text to display in place of the date should parsing, formatting or displaying fails."}},required:["type","timestamp","format"],additionalProperties:!1,description:"A date element for use in a rich text message."},RichTextEmoji:{type:"object",properties:{style:{type:"object",properties:{bold:{type:"boolean"},italic:{type:"boolean"},strike:{type:"boolean"},highlight:{type:"boolean"}},additionalProperties:!1},type:{type:"string",const:"emoji",description:"The type of element. In this case `type` is always `emoji`."},name:{type:"string",description:"Name of emoji, without colons or skin tones, e.g. `wave`"},unicode:{type:"string",description:"Lowercase hexadecimal Unicode representation of a standard emoji (not for use with custom emoji)."},url:{type:"string",description:"URL of emoji asset. Only used when sharing custom emoji across workspaces."}},required:["type","name"],additionalProperties:!1,description:"An emoji element for use in a rich text message."},RichTextLink:{type:"object",properties:{style:{type:"object",properties:{bold:{type:"boolean"},italic:{type:"boolean"},strike:{type:"boolean"},highlight:{type:"boolean"}},additionalProperties:!1,description:`A limited style object for styling rich text message elements
90
+ (excluding pre-formatted, or code, elements).`},type:{type:"string",const:"link",description:"The type of element. In this case `type` is always `link`."},text:{type:"string",description:"The text to link."},unsafe:{type:"boolean",description:"TODO: ?"},url:{type:"string",description:"URL to link to."}},required:["type","url"],additionalProperties:!1,description:"A link element for use in a rich text message."},RichTextTeamMention:{type:"object",properties:{style:{type:"object",properties:{bold:{type:"boolean"},italic:{type:"boolean"},strike:{type:"boolean"},highlight:{type:"boolean"}},additionalProperties:!1,description:`A limited style object for styling rich text message elements
91
+ (excluding pre-formatted, or code, elements).`},type:{type:"string",const:"team",description:"The type of element. In this case `type` is always `team`."},team_id:{type:"string",description:"The encoded team ID, e.g. T1234ABCD."}},required:["type","team_id"],additionalProperties:!1,description:"A workspace or team mention element for use in a rich text message."},RichTextText:{type:"object",properties:{style:{type:"object",properties:{bold:{type:"boolean"},italic:{type:"boolean"},strike:{type:"boolean"},highlight:{type:"boolean"}},additionalProperties:!1,description:`A limited style object for styling rich text message elements
92
+ (excluding pre-formatted, or code, elements).`},type:{type:"string",const:"text",description:"The type of element. In this case `type` is always `text`."},text:{type:"string",description:"The text to render."}},required:["type","text"],additionalProperties:!1,description:"A generic text element for use in a rich text message."},RichTextUserMention:{type:"object",properties:{style:{type:"object",properties:{bold:{type:"boolean"},italic:{type:"boolean"},strike:{type:"boolean"},highlight:{type:"boolean"}},additionalProperties:!1,description:`A limited style object for styling rich text message elements
93
+ (excluding pre-formatted, or code, elements).`},type:{type:"string",const:"user",description:"The type of element. In this case `type` is always `user`."},user_id:{type:"string",description:"The encoded user ID, e.g. U1234ABCD."}},required:["type","user_id"],additionalProperties:!1,description:"A user mention element for use in a rich text message."},RichTextUsergroupMention:{type:"object",properties:{style:{type:"object",properties:{bold:{type:"boolean"},italic:{type:"boolean"},strike:{type:"boolean"},highlight:{type:"boolean"}},additionalProperties:!1,description:`A limited style object for styling rich text message elements
94
+ (excluding pre-formatted, or code, elements).`},type:{type:"string",const:"usergroup",description:"The type of element. In this case `type` is always `usergroup`."},usergroup_id:{type:"string",description:"The encoded usergroup ID, e.g. S1234ABCD."}},required:["type","usergroup_id"],additionalProperties:!1,description:"A usergroup mention element for use in a rich text message."},RichTextList:{type:"object",properties:{type:{type:"string",const:"rich_text_list",description:"The type of element. In this case `type` is always `rich_text_list`."},elements:{type:"array",items:{$ref:"#/definitions/RichTextSection"},description:"An array of {@link RichTextSection } elements comprising each list item."},style:{type:"string",enum:["bullet","ordered"],description:"The type of list. Can be either `bullet` (the list points are all rendered the same way) or `ordered`\n(the list points increase numerically from 1)."},indent:{type:"number",description:"The style of the list points. Can be a number from `0` (default) to `8`. Yields a different character\nor characters rendered as the list points. Also affected by the `style` property."},border:{type:"number",enum:[0,1],description:"Whether to render a quote-block-like border on the inline side of the list. `0` renders no border\nwhile `1` renders a border."}},required:["type","elements","style"],additionalProperties:!1,description:"A list block within a rich text field."},RichTextQuote:{type:"object",properties:{type:{type:"string",const:"rich_text_quote",description:"The type of element. In this case `type` is always `rich_text_quote`."},elements:{type:"array",items:{$ref:"#/definitions/RichTextElement"},description:"An array of {@link RichTextElement } comprising the quote block."}},required:["type","elements"],additionalProperties:!1,description:"A quote block within a rich text field."},RichTextPreformatted:{type:"object",properties:{type:{type:"string",const:"rich_text_preformatted",description:"The type of element. In this case `type` is always `rich_text_preformatted`."},elements:{type:"array",items:{anyOf:[{$ref:"#/definitions/RichTextText"},{$ref:"#/definitions/RichTextLink"}]},description:"An array of either {@link RichTextLink } or {@link RichTextText } comprising the preformatted text."},border:{type:"number",enum:[0,1],description:"Whether to render a quote-block-like border on the inline side of the preformatted text.\n`0` renders no border, while `1` renders a border. Defaults to `0`."}},required:["type","elements"],additionalProperties:!1,description:"A block of preformatted text within a rich text field."},DividerBlock:{type:"object",properties:{type:{type:"string",const:"divider",description:"The type of block. For a divider block, `type` is always `divider`."},block_id:{type:"string",description:"A string acting as a unique identifier for a block. If not specified, a `block_id` will be generated.\nYou can use this `block_id` when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}.\nMaximum length for this field is 255 characters. `block_id` should be unique for each message and each iteration of\na message. If a message is updated, use a new `block_id`."}},required:["type"],additionalProperties:!1},SectionBlock:{type:"object",properties:{type:{type:"string",const:"section",description:"The type of block. For a section block, `type` is always `section`."},block_id:{type:"string",description:"A string acting as a unique identifier for a block. If not specified, a `block_id` will be generated.\nYou can use this `block_id` when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}.\nMaximum length for this field is 255 characters. `block_id` should be unique for each message and each iteration of\na message. If a message is updated, use a new `block_id`."},text:{anyOf:[{$ref:"#/definitions/PlainTextElement"},{$ref:"#/definitions/MrkdwnElement"}],description:"The text for the block, in the form of a text object. Minimum length for the `text` in this field is\n1 and maximum length is 3000 characters. This field is not required if a valid array of `fields` objects is\nprovided instead."},fields:{type:"array",items:{anyOf:[{$ref:"#/definitions/PlainTextElement"},{$ref:"#/definitions/MrkdwnElement"}]},description:"Required if no `text` is provided. An array of text objects. Any text objects included with `fields`\nwill be rendered in a compact format that allows for 2 columns of side-by-side text. Maximum number of items is 10.\nMaximum length for the text in each item is 2000 characters.\n{@link https://app.slack.com/block-kit-builder/#%7B%22blocks%22:%5B%7B%22type%22:%22section%22,%22text%22:%7B%22text%22:%22A%20message%20*with%20some%20bold%20text*%20and%20_some%20italicized%20text_.%22,%22type%22:%22mrkdwn%22%7D,%22fields%22:%5B%7B%22type%22:%22mrkdwn%22,%22text%22:%22*Priority*%22%7D,%7B%22type%22:%22mrkdwn%22,%22text%22:%22*Type*%22%7D,%7B%22type%22:%22plain_text%22,%22text%22:%22High%22%7D,%7B%22type%22:%22plain_text%22,%22text%22:%22String%22%7D%5D%7D%5D%7D Click here for an example}."},accessory:{anyOf:[{$ref:"#/definitions/Button"},{$ref:"#/definitions/Overflow"},{$ref:"#/definitions/Datepicker"},{$ref:"#/definitions/Timepicker"},{$ref:"#/definitions/Select"},{$ref:"#/definitions/MultiSelect"},{$ref:"#/definitions/Actionable"},{$ref:"#/definitions/ImageElement"},{$ref:"#/definitions/RadioButtons"},{$ref:"#/definitions/Checkboxes"}],description:"One of the compatible element objects."}},required:["type"],additionalProperties:!1,description:`Displays text, possibly alongside block elements. A section can be used as a simple text block, in
95
+ combination with text fields, or side-by-side with certain
96
+ {@link https://api.slack.com/reference/messaging/block-elements block elements}.`},InputBlock:{type:"object",properties:{type:{type:"string",const:"input",description:"The type of block. For an input block, `type` is always `input`."},block_id:{type:"string",description:"A string acting as a unique identifier for a block. If not specified, a `block_id` will be generated.\nYou can use this `block_id` when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}.\nMaximum length for this field is 255 characters. `block_id` should be unique for each message and each iteration of\na message. If a message is updated, use a new `block_id`."},label:{$ref:"#/definitions/PlainTextElement",description:`A label that appears above an input element in the form of a {@link PlainTextElement } object.
97
+ Maximum length for the text in this field is 2000 characters.`},hint:{$ref:"#/definitions/PlainTextElement",description:"An optional hint that appears below an input element in a lighter grey. It must be a\n{@link PlainTextElement object}. Maximum length for the `text` in this field is 2000 characters."},optional:{type:"boolean",description:"A boolean that indicates whether the input element may be empty when a user submits the modal.\nDefaults to `false`."},element:{anyOf:[{$ref:"#/definitions/Select"},{$ref:"#/definitions/MultiSelect"},{$ref:"#/definitions/Datepicker"},{$ref:"#/definitions/Timepicker"},{$ref:"#/definitions/DateTimepicker"},{$ref:"#/definitions/PlainTextInput"},{$ref:"#/definitions/URLInput"},{$ref:"#/definitions/EmailInput"},{$ref:"#/definitions/NumberInput"},{$ref:"#/definitions/RadioButtons"},{$ref:"#/definitions/Checkboxes"},{$ref:"#/definitions/RichTextInput"}],description:"A block element."},dispatch_action:{type:"boolean",description:"A boolean that indicates whether or not the use of elements in this block should dispatch a\n{@link https://api.slack.com/reference/interaction-payloads/block-actions block_actions payload}. Defaults to `false`."}},required:["element","label","type"],additionalProperties:!1,description:"Collects information from users via block elements."},PlainTextInput:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},dispatch_action_config:{$ref:"#/definitions/DispatchActionConfig"},type:{type:"string",const:"plain_text_input",description:"The type of element. In this case `type` is always `plain_text_input`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_value:{type:"string",description:"The initial value in the plain-text input when it is loaded."},multiline:{type:"boolean",description:"Indicates whether the input will be a single line (`false`) or a larger textarea (`true`).\nDefaults to `false`."},min_length:{type:"number",description:`The minimum length of input that the user must provide. If the user provides less, they will receive
98
+ an error. Maximum value is 3000.`},max_length:{type:"number",description:`The maximum length of input that the user can provide. If the user provides more,
99
+ they will receive an error.`}},required:["type"],additionalProperties:!1,description:"Allows users to enter freeform text data into a single-line or multi-line field."},URLInput:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},dispatch_action_config:{$ref:"#/definitions/DispatchActionConfig"},type:{type:"string",const:"url_text_input",description:"The type of element. In this case `type` is always `url_text_input`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_value:{type:"string",description:"The initial value in the URL input when it is loaded."}},required:["type"],additionalProperties:!1,description:"Allows user to enter a URL into a single-line field."},EmailInput:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},dispatch_action_config:{$ref:"#/definitions/DispatchActionConfig",description:"A {@link DispatchActionConfig } object that determines when during text input the element returns a\n{@link https://api.slack.com/reference/interaction-payloads/block-actions `block_actions` payload}."},type:{type:"string",const:"email_text_input",description:"The type of element. In this case `type` is always `email_text_input`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},initial_value:{type:"string",description:"The initial value in the email input when it is loaded."}},required:["type"],additionalProperties:!1,description:"Allows user to enter an email into a single-line field."},NumberInput:{type:"object",properties:{placeholder:{$ref:"#/definitions/PlainTextElement",description:"A {@link PlainTextElement } object that defines the placeholder text shown on the element. Maximum\nlength for the `text` field in this object is 150 characters."},focus_on_load:{type:"boolean",description:"Indicates whether the element will be set to auto focus within the\n{@link https://api.slack.com/reference/surfaces/views `view` object}. Only one element can be set to `true`.\nDefaults to `false`."},dispatch_action_config:{$ref:"#/definitions/DispatchActionConfig",description:"A {@link DispatchActionConfig } object that determines when during text input the element returns a\n{@link https://api.slack.com/reference/interaction-payloads/block-actions `block_actions` payload}."},type:{type:"string",const:"number_input",description:"The type of element. In this case `type` is always `number_input`."},action_id:{type:"string",description:": An identifier for this action. You can use this when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}. Should be unique\namong all other `action_id`s in the containing block. Maximum length for this field is 255 characters."},is_decimal_allowed:{type:"boolean",description:"Decimal numbers are allowed if this property is `true`, set the value to `false` otherwise."},initial_value:{type:"string",description:"The initial value in the input when it is loaded."},min_value:{type:"string",description:"The minimum value, cannot be greater than `max_value`."},max_value:{type:"string",description:"The maximum value, cannot be less than `min_value`."}},required:["is_decimal_allowed","type"],additionalProperties:!1,description:"Allows user to enter a number into a single-line field. The number input element accepts both whole and\ndecimal numbers. For example, 0.25, 5.5, and -10 are all valid input values. Decimal numbers are only allowed when\n`is_decimal_allowed` is equal to `true`."},FileBlock:{type:"object",properties:{type:{type:"string",const:"file",description:"The type of block. For a file block, `type` is always `file`."},block_id:{type:"string",description:"A string acting as a unique identifier for a block. If not specified, a `block_id` will be generated.\nYou can use this `block_id` when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}.\nMaximum length for this field is 255 characters. `block_id` should be unique for each message and each iteration of\na message. If a message is updated, use a new `block_id`."},source:{type:"string",description:"At the moment, source will always be `remote` for a remote file."},external_id:{type:"string",description:"The external unique ID for this file."}},required:["external_id","source","type"],additionalProperties:!1,description:`Displays a {@link https://api.slack.com/messaging/files/remote remote file}. You can't add this block to
100
+ app surfaces directly, but it will show up when {@link https://api.slack.com/messaging/retrieving retrieving messages}
101
+ that contain remote files. If you want to add remote files to messages,
102
+ {@link https://api.slack.com/messaging/files/remote follow our guide}.`},HeaderBlock:{type:"object",properties:{type:{type:"string",const:"header",description:"The type of block. For a header block, `type` is always `header`."},block_id:{type:"string",description:"A string acting as a unique identifier for a block. If not specified, a `block_id` will be generated.\nYou can use this `block_id` when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}.\nMaximum length for this field is 255 characters. `block_id` should be unique for each message and each iteration of\na message. If a message is updated, use a new `block_id`."},text:{$ref:"#/definitions/PlainTextElement",description:`The text for the block, in the form of a {@link PlainTextElement }.
103
+ Maximum length for the text in this field is 150 characters.`}},required:["text","type"],additionalProperties:!1,description:"Displays a larger-sized text block. A `header` is a plain-text block that displays in a larger, bold\nfont. Use it to delineate between different groups of content in your app's surfaces."},VideoBlock:{type:"object",properties:{type:{type:"string",const:"video",description:"The type of block. For a video block, `type` is always `video`."},block_id:{type:"string",description:"A string acting as a unique identifier for a block. If not specified, a `block_id` will be generated.\nYou can use this `block_id` when you receive an interaction payload to\n{@link https://api.slack.com/interactivity/handling#payloads identify the source of the action}.\nMaximum length for this field is 255 characters. `block_id` should be unique for each message and each iteration of\na message. If a message is updated, use a new `block_id`."},video_url:{type:"string",description:`The URL to be embedded. Must match any existing
104
+ {@link https://api.slack.com/reference/messaging/link-unfurling#configuring_domains unfurl domains} within the app
105
+ and point to a HTTPS URL.`},thumbnail_url:{type:"string",description:"The thumbnail image URL."},alt_text:{type:"string",description:"A tooltip for the video. Required for accessibility."},title:{$ref:"#/definitions/PlainTextElement",description:"Video title as a {@link PlainTextElement } object. `text` within must be less than 200 characters."},title_url:{type:"string",description:`Hyperlink for the title text. Must correspond to the non-embeddable URL for the video.
106
+ Must go to an HTTPS URL.`},author_name:{type:"string",description:"Author name to be displayed. Must be less than 50 characters."},provider_name:{type:"string",description:"The originating application or domain of the video, e.g. YouTube."},provider_icon_url:{type:"string",description:"Icon for the video provider, e.g. YouTube icon."},description:{$ref:"#/definitions/PlainTextElement",description:"Description for video using a {@link PlainTextElement } object."}},required:["alt_text","thumbnail_url","title","type","video_url"],additionalProperties:!1,description:"Displays an embedded video player. A video block is designed to embed videos in all app surfaces (e.g.\nlink unfurls, messages, modals, App Home) \u2014 anywhere you can put blocks! To use the video block within your app, you\nmust have the {@link https://api.slack.com/scopes/links.embed:write `links.embed:write` scope}."}},additionalProperties:!1},we={output:Be};var xe={slack:we};var Ge={type:"object",properties:{ipPoolName:{type:"string"}},required:["ipPoolName"],additionalProperties:!1},_e={output:Ge};var ke={sendgrid:_e};var Te={};var ve={};var Re={};var Ee={chat:xe,sms:Re,email:ke,push:ve,in_app:Te};var Ke={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},Xe={type:"object",properties:{duration:{type:"number"}},required:["duration"],additionalProperties:!1},de={output:Ke,result:Xe};var ze={type:"object",properties:{amount:{type:"number"},unit:{type:"string",enum:["seconds","minutes","hours","days","weeks","months"]}},required:["amount","unit"],additionalProperties:!1},Je={type:"object",properties:{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},he={output:ze,result:Je};var Qe={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},Ze={type:"object",properties:{},required:[],additionalProperties:!1},Ie={output:Qe,result:Ze};var He={type:"object",properties:{subject:{type:"string"},body:{type:"string"}},required:["subject","body"],additionalProperties:!1},et={type:"object",properties:{},required:[],additionalProperties:!1},Oe={output:He,result:et};var tt={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},it={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},Se={output:tt,result:it};var nt={type:"object",properties:{subject:{type:"string"},body:{type:"string"}},required:["subject","body"],additionalProperties:!1},ot={type:"object",properties:{},required:[],additionalProperties:!1},Ae={output:nt,result:ot};var st={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},rt={type:"object",properties:{},required:[],additionalProperties:!1},Pe={output:st,result:rt};var re={chat:Ie,sms:Pe,push:Ae,email:Oe,in_app:Se};var x={type:"object",properties:{},required:[],additionalProperties:!1};function ct(o,e,t){let i=t||{},n=new Me__default.default({useDefaults:!0});Ue__default.default(n);let s={workflowId:o,options:i,steps:[],code:e.toString(),data:{schema:i.payloadSchema||x,validate:n.compile(i.payloadSchema||x)},inputs:{schema:i.inputSchema||x,validate:n.compile(i.inputSchema||x)},execute:e};return e({payload:{},subscriber:{},environment:{},input:{},step:{...Object.entries(re).reduce((a,[r,h])=>(a[r]=ae(s,r,n,h.output,h.result),a),{}),inApp:ae(s,"in_app",n,re.in_app.output,re.in_app.result),digest:ae(s,"digest",n,he.output,he.result),delay:ae(s,"delay",n,de.output,de.result),custom:dt(s,"custom",n)}}),ht(s),s}function ae(o,e,t,i,n){return async(s,a,r={})=>{let h=r?.inputSchema||x,p={stepId:s,type:e,inputs:{schema:h,validate:t.compile(h)},outputs:{schema:i,validate:t.compile(i)},results:{schema:n,validate:t.compile(n)},resolve:a,code:a.toString(),options:r,providers:[]};Ce(o,s,p),Object.keys(r.providers||{}).length>0&&pt(p,t,e,r.providers||{});}}function Ce(o,e,t){if(o.steps.some(i=>i.stepId===e))throw new ne(e);o.steps.push(t);}function pt(o,e,t,i){let n=Ee[t];Object.entries(i).forEach(([s,a])=>{let r=n[s];o.providers.push({type:s,code:a.toString(),resolve:a,outputs:{schema:r.output,validate:e.compile(r.output)}});});}function dt(o,e,t){return async(i,n,s={})=>{let a=s?.inputSchema||x,r=s?.outputSchema||x;Ce(o,i,{stepId:i,type:e,inputs:{schema:a,validate:t.compile(a)},outputs:{schema:r,validate:t.compile(r)},results:{schema:r,validate:t.compile(r)},resolve:n,code:n.toString(),options:s,providers:[]});}}function ht(o){console.log(`
107
+ ${l.bold(l.underline("Discovered workflowId:"))} '${o.workflowId}'`),o.steps.forEach((e,t)=>{let i=t===o.steps.length-1?"\u2514":"\u251C";console.log(`${i} ${d.STEP} Discovered stepId: '${e.stepId}' Type: '${e.type}'`),e.providers.forEach((n,s)=>{let a=s===e.providers.length-1?"\u2514":"\u251C";console.log(` ${a} ${d.PROVIDER} Discovered provider: '${n.type}'`);});});}
108
+
109
+ exports.Client = N;
110
+ exports.JobStatusEnum = We;
111
+ exports.NovuRequestHandler = pe;
112
+ exports.workflow = ct;
package/dist/next.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { i as SupportedFrameworkName, S as ServeHandlerOptions } from './handler-58kccf2b.js';
2
+ import 'ajv';
3
+ import 'json-schema-to-ts';
4
+
5
+ declare const frameworkName: SupportedFrameworkName;
6
+ /**
7
+ * In Next.js, serve and register any declared workflows with Novu, making
8
+ * them available to be triggered by events.
9
+ *
10
+ * Supports Next.js 12+, both serverless and edge.
11
+ *
12
+ * @example Next.js <=12 or the pages router can export the handler directly
13
+ * ```ts
14
+ * export default serve({ workflows: [yourWorkflow] });
15
+ * ```
16
+ *
17
+ * @example Next.js >=13 with the `app` dir must export individual methods
18
+ * ```ts
19
+ * export const { GET, POST, PUT } = serve({ workflows: [yourWorkflow] });
20
+ * ```
21
+ */
22
+ declare const serve: (options: ServeHandlerOptions) => any;
23
+
24
+ export { frameworkName, serve };
package/dist/next.js ADDED
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var crypto = require('crypto');
4
+ var fe = require('ajv');
5
+ var we = require('ajv-formats');
6
+ var _e = require('better-ajv-errors');
7
+ var jsonSchemaFaker = require('json-schema-faker');
8
+ var re = require('ora');
9
+ var v = require('chalk');
10
+ var liquidjs = require('liquidjs');
11
+
12
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
+
14
+ var fe__default = /*#__PURE__*/_interopDefault(fe);
15
+ var we__default = /*#__PURE__*/_interopDefault(we);
16
+ var _e__default = /*#__PURE__*/_interopDefault(_e);
17
+ var re__default = /*#__PURE__*/_interopDefault(re);
18
+ var v__default = /*#__PURE__*/_interopDefault(v);
19
+
20
+ var he=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var k=(s=>(s.EXECUTE="execute",s.PREVIEW="preview",s.SYNC="sync",s.DIFF="diff",s))(k||{}),L=(r=>(r.DISCOVER="discover",r.HEALTH_CHECK="health-check",r.CODE="code",r))(L||{});var ae="https://api.novu.co";var f=(d=>(d.WORKFLOW_NOT_FOUND_ERROR="WorkflowNotFoundError",d.WORKFLOW_ALREADY_EXISTS_ERROR="WorkflowAlreadyExistsError",d.WORKFLOW_EXECUTION_FAILED_ERROR="WorkflowExecutionFailedError",d.EXECUTION_STATE_OUTPUT_INVALID_ERROR="ExecutionStateOutputInvalidError",d.EXECUTION_STATE_RESULT_INVALID_ERROR="ExecutionStateResultInvalidError",d.EXECUTION_PROVIDER_OUTPUT_INVALID_ERROR="ExecutionProviderOutputInvalidError",d.PROVIDER_NOT_FOUND_ERROR="ProviderNotFoundError",d.PROVIDER_EXECUTION_FAILED_ERROR="ProviderExecutionFailedError",d.STEP_NOT_FOUND_ERROR="StepNotFoundError",d.STEP_ALREADY_EXISTS_ERROR="StepAlreadyExistsError",d.STEP_EXECUTION_FAILED_ERROR="StepExecutionFailedError",d.EXECUTION_STATE_CORRUPT_ERROR="ExecutionStateCorruptError",d.EXECUTION_EVENT_DATA_INVALID_ERROR="ExecutionEventDataInvalidError",d.EXECUTION_EVENT_INPUT_INVALID_ERROR="ExecutionEventInputInvalidError",d.EXECUTION_STATE_INPUT_INVALID_ERROR="ExecutionStateInputInvalidError",d.METHOD_NOT_ALLOWED_ERROR="MethodNotAllowedError",d.INVALID_ACTION_ERROR="InvalidActionError",d.MISSING_API_KEY_ERROR="MissingApiKeyError",d.SIGNATURE_MISMATCH_ERROR="SignatureMismatchError",d.SIGNATURE_NOT_FOUND_ERROR="SignatureNotFoundError",d.SIGNATURE_INVALID_ERROR="SignatureInvalidError",d.SIGNATURE_EXPIRED_ERROR="SignatureExpiredError",d.SIGNING_KEY_NOT_FOUND_ERROR="SigningKeyNotFoundError",d.PLATFORM_ERROR="PlatformError",d.SIGNATURE_VERSION_INVALID_ERROR="SignatureVersionInvalidError",d))(f||{});var m=(r=>(r.POST="POST",r.GET="GET",r.OPTIONS="OPTIONS",r))(m||{});var w=class extends Error{data},b=class extends w{statusCode=404},T=class extends w{statusCode=400},_=class extends w{statusCode=401},x=class extends w{statusCode=500},F=class extends w{statusCode=409};var W=class extends T{code="ExecutionStateCorruptError";constructor(e,t){super(`Workflow with id: \`${e}\` has a corrupt state. Step with id: \`${t}\` does not exist. Please provide the missing state.`),this.data={workflowId:e,stepId:t};}},$=class extends T{code="ExecutionEventDataInvalidError";constructor(e,t){super(`Workflow with id: \`${e}\` has invalid \`data\`. Please provide the correct event data.`),this.data=t;}},y=class extends T{code="ExecutionEventInputInvalidError";constructor(e,t){super(`Workflow with id: \`${e}\` has invalid \`inputs\`. Please provide the correct event inputs.`),this.data=t;}},M=class extends T{code="ExecutionStateInputInvalidError";constructor(e,t,r){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` has invalid input. Please provide the correct step input.`),this.data=r;}},V=class extends T{code="ExecutionStateOutputInvalidError";constructor(e,t,r){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` has invalid output. Please provide the correct step output.`),this.data=r;}},G=class extends T{code="ExecutionStateResultInvalidError";constructor(e,t,r){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` has invalid result. Please provide the correct step result.`),this.data=r;}},K=class extends T{code="ExecutionProviderOutputInvalidError";constructor(e,t,r,s){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` and provider with id: \`${r}\` has invalid output. Please provide the correct provider output.`),this.data=s;}};var de=()=>typeof Response<"u"?Response:he("cross-fetch").Response;var u={info:o=>v__default.default.blue(o),warning:o=>v__default.default.yellow(o),error:o=>v__default.default.red(o),success:o=>v__default.default.green(o),underline:o=>v__default.default.underline(o),bold:o=>v__default.default.bold(o)},R={SUCCESS:u.success("\u2714"),ERROR:u.error("\u2717"),WARNING:u.warning("\u26A0"),INFO:u.info("\u2139"),ARROW:u.bold("\u2192"),MOCK:u.info("\u25CB"),HYDRATED:u.bold(u.info("\u2192")),STEP:u.info("\u03C3"),ACTION:u.info("\u03B1"),DURATION:u.info("\u0394"),PROVIDER:u.info("\u2699"),OUTPUT:u.info("\u21E2"),INPUT:u.info("\u21E0"),WORKFLOW:u.info("\u03C9"),STATE:u.info("\u03C3"),EXECUTE:u.info("\u03B5"),PREVIEW:u.info("\u03C1")};var ie=o=>Object.values(o).map(e=>`\`${e}\``).join(", "),j=o=>o.replaceAll(/(\w)(\w*)/g,(e,t,r)=>t.toUpperCase()+r.toLowerCase()).replaceAll(/[\s-]+/g,"");var Y=class extends w{code="MethodNotAllowedError";statusCode=405;message=`Method not allowed. Please use one of ${ie(m)}`},S=class extends T{code="InvalidActionError";constructor(e,t){super(`Invalid query string: \`action\`=\`${e}\`. Please use one of ${ie(t)}`);}},C=class extends T{code="MissingApiKeyError";constructor(){super("API Key is missing. Please add the API Key during Client initialization.");}};var X=class extends x{code="PlatformError";message="Something went wrong. Please try again later."};var U=class extends F{constructor(e,t){super(`${j(e)} with id: \`${t}\` already exists. Please use a different id.`);}},N=class extends b{constructor(e,t){super(`${j(e)} with id: \`${t}\` does not exist. Please provide a valid id.`);}},P=class extends x{constructor(e,t){super(`Failed to execute ${j(e)} with id: \`${t}\`. Please try again later.`);}};var q=class extends N{code="ProviderNotFoundError";constructor(e){super("provider",e);}},B=class extends P{code="ProviderExecutionFailedError";constructor(e){super("workflow",e);}};var J=class extends _{code="SignatureMismatchError";constructor(){super("Signature does not match the expected signature. Please ensure the signature provided in the `x-novu-signature` header is correct and try again.");}},Q=class extends _{code="SignatureNotFoundError";constructor(){super("Signature not found. Please provide a signature in the `x-novu-signature` header");}},z=class extends _{code="SignatureInvalidError";constructor(){super("Signature is invalid. Please provide a valid signature in the `x-novu-signature` header");}},Z=class extends _{code="SignatureExpiredError";constructor(){super(`Signature expired. Please provide a signature with a timestamp no older than ${5} minutes in the \`x-novu-signature\` header`);}},H=class extends _{code="SigningKeyNotFoundError";constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.apiKey`");}};var ee=class extends N{code="StepNotFoundError";constructor(e){super("step",e);}};var D=class extends N{code="WorkflowNotFoundError";constructor(e){super("workflow",e);}},te=class extends U{code="WorkflowAlreadyExistsError";constructor(e){super("workflow",e);}};var ue={name:"@novu/framework",version:"0.24.3-alpha.5",description:"The Code-First Notifications Workflow SDK.",main:"./dist/index.js",types:"./dist/index.d.ts",publishConfig:{registry:"https://registry.npmjs.org",access:"public"},private:!1,repository:{type:"git",url:"git+https://github.com/novuhq/novu.git"},files:["dist","README.md"],scripts:{preinstall:"npx only-allow pnpm",test:"vitest","test:watch":"vitest --watch",lint:"eslint src --ext .ts","lint:fix":"eslint src --ext .ts --fix",format:"prettier --check --ignore-path .gitignore .","format:fix":"prettier --write --ignore-path .gitignore .",build:"tsup","build:watch":"tsup --watch","$comment:bump:prerelease":"This is a workaround to support `npm version prerelease` with lerna","bump:prerelease":"npm version prerelease --preid=alpha & PID=$!; (sleep 1 && kill -9 $PID) & wait $PID","release:alpha":"pnpm bump:prerelease || pnpm build && npm publish --dry-run"},keywords:["novu","code-first","workflows","durable","sdk","notifications","email","sms","push","webhooks","next","nuxt","h3","express"],author:"Novu",license:"MIT",exports:{".":{require:"./dist/index.js",import:"./dist/index.js",types:"./dist/index.d.ts"},"./express":{require:"./dist/express.js",import:"./dist/express.js",types:"./dist/express.d.ts"},"./next":{require:"./dist/next.js",import:"./dist/next.js",types:"./dist/next.d.ts"},"./nuxt":{require:"./dist/nuxt.js",import:"./dist/nuxt.js",types:"./dist/nuxt.d.ts"},"./h3":{require:"./dist/h3.js",import:"./dist/h3.js",types:"./dist/h3.d.ts"},"./sveltekit":{require:"./dist/sveltekit.js",import:"./dist/sveltekit.js",types:"./dist/sveltekit.d.ts"},"./remix":{require:"./dist/remix.js",import:"./dist/remix.js",types:"./dist/remix.d.ts"}},devDependencies:{"@sveltejs/kit":"^2.5.10","@types/express":"^4.17.13","@types/json-schema":"^7.0.15","@types/node":"^20.11.20","@vercel/node":"^2.15.9",express:"^4.18.2",h3:"^1.11.1",next:"^13.5.4",prettier:"^3.2.5","ts-node":"^10.9.2",tsup:"^8.0.2",typescript:"^5.3.3",vitest:"^1.2.1"},dependencies:{ajv:"^8.12.0","ajv-formats":"^2.1.1","better-ajv-errors":"^1.2.0",chalk:"^4.1.2","cross-fetch":"^4.0.0","json-schema-faker":"^0.5.6","json-schema-to-ts":"^3.0.0",liquidjs:"^10.13.1",ora:"^5.4.1"}};var ne=ue.version;jsonSchemaFaker.JSONSchemaFaker.option({useDefaultValue:!0,alwaysFakeOptionals:!0});var se=class{discoveredWorkflows=[];ajv;templateEngine=new liquidjs.Liquid;apiUrl;apiKey;version=ne;strictAuthentication;static NOVU_SIGNATURE_HEADER="x-novu-signature";constructor(e){let t=this.buildOptions(e);this.apiKey=t.apiKey,this.apiUrl=t.apiUrl,this.strictAuthentication=t.strictAuthentication;let r=new fe__default.default({useDefaults:!0});we__default.default(r),this.ajv=r;}buildOptions(e){let t={apiKey:void 0,apiUrl:ae,strictAuthentication:!0};return e?.apiKey!==void 0?t.apiKey=e.apiKey:process.env.NOVU_API_KEY!==void 0&&(t.apiKey=process.env.NOVU_API_KEY),e?.apiUrl!==void 0?t.apiUrl=e.apiUrl:process.env.NOVU_API_URL!==void 0&&(t.apiUrl=process.env.NOVU_API_URL),e?.strictAuthentication!==void 0?t.strictAuthentication=e.strictAuthentication:process.env.NOVU_STRICT_AUTHENTICATION!==void 0&&(t.strictAuthentication=process.env.NOVU_STRICT_AUTHENTICATION==="true"),t}addWorkflows(e){for(let t of e){if(this.discoveredWorkflows.some(r=>r.workflowId===t.workflowId))throw new te(t.workflowId);this.discoveredWorkflows.push(t);}}healthCheck(){let e=this.discoveredWorkflows.length,t=this.discoveredWorkflows.reduce((r,s)=>r+s.steps.length,0);return {status:"ok",version:ne,discovered:{workflows:e,steps:t}}}getWorkflow(e){let t=this.discoveredWorkflows.find(r=>r.workflowId===e);if(t)return t;throw new D(e)}getStep(e,t){let s=this.getWorkflow(e).steps.find(i=>i.stepId===t);if(s)return s;throw new ee(t)}getRegisteredWorkflows(){return this.discoveredWorkflows}discover(){return {workflows:this.getRegisteredWorkflows()}}getHeaders(e){let t={"content-type":"application/json",authorization:`ApiKey ${this.apiKey}`};return e&&(t["x-novu-anonymous"]=e),t}async diff(e,t){let r=this.discover()?.workflows||[];return (await fetch(this.apiUrl+"/v1/bridge/diff",{method:"POST",headers:this.getHeaders(t),body:JSON.stringify({workflows:r,bridgeUrl:e})})).json()}async sync(e,t,r){let{workflows:s}=this.discover();return (await fetch(`${this.apiUrl}/v1/bridge/sync?source=${r||"sdk"}`,{method:"POST",headers:this.getHeaders(t),body:JSON.stringify({workflows:s,bridgeUrl:e})})).json()}mock(e){return jsonSchemaFaker.JSONSchemaFaker.generate(e)}validate(e,t,r,s,i,c,a,l){if(!t(e)){let n=_e__default.default(r,e,t.errors||[]);switch(console.error(`
21
+ ${n}`),s){case"event":this.validateEvent(i,c,t);case"step":this.validateStep(a,i,c,t);case"provider":this.validateProvider(a,l,i,c,t);}}}validateProvider(e,t,r,s,i){if(!e)throw new Error("stepId is required");if(!t)throw new Error("providerId is required");switch(r){case"output":throw new K(s,e,t,i.errors);default:throw new Error(`Invalid payload type: '${r}'`)}}validateStep(e,t,r,s){if(!e)throw new Error("stepId is required");switch(t){case"output":throw new V(r,e,s.errors);case"result":throw new G(r,e,s.errors);case"input":throw new M(r,e,s.errors);default:throw new Error(`Invalid payload type: '${t}'`)}}validateEvent(e,t,r){switch(e){case"input":throw new y(t,r.errors);case"data":throw new $(t,r.errors);default:throw new Error(`Invalid payload type: '${e}'`)}}executeStepFactory(e,t){return async(r,s,i)=>{let c=this.getStep(e.workflowId,r),a=Ae(e),l=this.createStepInputs(c,a),O=e.action==="preview";if(!O&&await this.shouldSkip(i?.skip,l))return t({options:{skip:!0}}),{};let n=this.previewStep.bind(this),p=this.executeStep.bind(this),A=await(O?n:p)(e,{...c,providers:c.providers.map(h=>{let I=i?.providers?.[h.type];if(!I)throw new q(h.type);return {...h,resolve:I}}),resolve:s});return r===e.stepId&&t(A),A.outputs}}async shouldSkip(e,t){return e?e(t):!1}async executeWorkflow(e){let s=`${{execute:"Executing",preview:"Previewing"}[e.action]} workflowId:`;console.log(`
22
+ ${u.bold(u.underline(s))} '${e.workflowId}'`);let i=this.getWorkflow(e.workflowId),c=process.hrtime(),a={outputs:{},providers:{},options:{}},l,O=new Promise(g=>{l=g;}),n=g=>{l(),a=g;},p;try{if(e.action==="execute"&&!e.data)throw new y(e.workflowId,{message:"Event `data` is required"});let g=this.createExecutionInputs(e,i);await Promise.race([O,i.execute({payload:g,environment:{},input:{},subscriber:e.subscriber,step:{email:this.executeStepFactory(e,n),sms:this.executeStepFactory(e,n),inApp:this.executeStepFactory(e,n),digest:this.executeStepFactory(e,n),delay:this.executeStepFactory(e,n),push:this.executeStepFactory(e,n),chat:this.executeStepFactory(e,n),custom:this.executeStepFactory(e,n)}})]);}catch(g){p=g;}let E=process.hrtime(c),A=E[0],h=E[1],I=A*1e3+h/1e6,Oe=p?R.ERROR:R.SUCCESS,Ee=e.action==="execute"?"Executed":e.action==="preview"?"Previewed":"Invalid action";if(console.log(`${Oe} ${Ee} workflowId: \`${e.workflowId}\``),this.prettyPrintExecute(e,I,p),p)throw p;return {outputs:a.outputs,providers:a.providers,options:a.options,metadata:{status:"success",error:!1,duration:I}}}createExecutionInputs(e,t){let r=e.data;return this.validate(e.data,t.data.validate,t.data.schema,"event","input",e.workflowId),r}prettyPrintExecute(e,t,r){let s=r?R.ERROR:R.SUCCESS,i=e.action==="execute"?"Executed":e.action==="preview"?"Previewed":"Invalid action",c=r?"Failed to execute":i,a=r?u.error:u.success,l=`${s} ${c} workflowId: '${e.workflowId}`;console.log(`
23
+ ${u.bold(a(l))}'`),console.log(` \u251C ${R.STEP} stepId: '${e.stepId}'`),console.log(` \u251C ${R.ACTION} action: '${e.action}'`),console.log(` \u2514 ${R.DURATION} duration: '${t.toFixed(2)}ms'
24
+ `);}async executeProviders(e,t){return t.providers.reduce(async(r,s)=>{let i=await r,c=this.previewProvider.bind(this),a=this.executeProvider.bind(this),O=await(e.action==="preview"?c:a)(e,t,s);return {...i,[s.type]:O}},Promise.resolve({}))}previewProvider(e,t,r){return console.log(` ${R.MOCK} Mocked provider: \`${r.type}\``),this.mock(r.outputs.schema)}async executeProvider(e,t,r){let s=re__default.default({indent:2}).start(`Executing provider: \`${r.type}\``);try{if(e.stepId===t.stepId){let i=this.createStepInputs(t,e),c=await r.resolve({inputs:i});return this.validate(c,r.outputs.validate,r.outputs.schema,"step","output",e.workflowId,t.stepId,r.type),s.succeed(`Executed provider: \`${r.type}\``),c}else s.stopAndPersist({symbol:R.HYDRATED,text:`Hydrated provider: \`${r.type}\``});}catch(i){throw s.stopAndPersist({symbol:R.ERROR,text:`Failed to execute provider: \`${r.type}\``}),new B(`Failed to execute provider: '${r.type}'.
25
+ ${i.message}`)}}async executeStep(e,t){if(e.stepId===t.stepId){let r=re__default.default({indent:1}).start(`Executing stepId: \`${t.stepId}\``);try{let s=this.createStepInputs(t,e),i=await this.compileInputs(s,e),c=await t.resolve(i);this.validate(c,t.outputs.validate,t.outputs.schema,"step","output",e.workflowId,t.stepId);let a=await this.executeProviders(e,t);return r.succeed(`Executed stepId: \`${t.stepId}\``),{outputs:c,providers:a}}catch(s){throw r.stopAndPersist({prefixText:"",symbol:R.ERROR,text:`Failed to execute stepId: \`${t.stepId}\``}),s}}else {let r=re__default.default({indent:1}).start(`Hydrating stepId: \`${t.stepId}\``);try{let s=e.state.find(i=>i.stepId===t.stepId);if(s)return this.validate(s.outputs,t.results.validate,t.results.schema,"step","result",e.workflowId,t.stepId),r.stopAndPersist({symbol:R.HYDRATED,text:`Hydrated stepId: \`${t.stepId}\``}),{outputs:s.outputs,providers:await this.executeProviders(e,t)};throw new W(e.workflowId,t.stepId)}catch(s){throw r.stopAndPersist({symbol:R.ERROR,text:`Failed to hydrate stepId: \`${t.stepId}\``}),s}}}async compileInputs(e,t){let r=this.templateEngine.parse(JSON.stringify(e)),s=await this.templateEngine.render(r,{...t.data,subscriber:t.subscriber});return JSON.parse(s)}createStepInputs(e,t){let r=t.inputs;return this.validate(r,e.inputs.validate,e.inputs.schema,"step","input",t.workflowId,e.stepId),r}async previewStep(e,t){let r=re__default.default({indent:1}).start(`Previewing stepId: \`${t.stepId}\``);try{if(e.stepId===t.stepId){let s=this.createStepInputs(t,e),i=await t.resolve(s);return this.validate(i,t.outputs.validate,t.outputs.schema,"step","output",e.workflowId,t.stepId),r.stopAndPersist({symbol:R.MOCK,text:`Mocked stepId: \`${t.stepId}\``}),{outputs:i,providers:await this.executeProviders(e,t)}}else {let s=this.mock(t.results.schema);return r.stopAndPersist({symbol:R.MOCK,text:`Mocked stepId: \`${t.stepId}\``}),{outputs:s,providers:await this.executeProviders(e,t)}}}catch(s){throw r.stopAndPersist({symbol:R.ERROR,text:`Failed to preview stepId: \`${t.stepId}\``}),s}}getStepCode(e,t){return {code:this.getStep(e,t).resolve.toString()}}getWorkflowCode(e){return {code:this.getWorkflow(e).execute.toString()}}getCode(e,t){let r;if(e)t?r=this.getStepCode(e,t):r=this.getWorkflowCode(e);else throw new D(e);return r}};function Ae(o){return JSON.parse(JSON.stringify(o))}var oe=class{frameworkName;handler;client;hmacEnabled;constructor(e){this.handler=e.handler,this.client=e.client?e.client:new se,this.client.addWorkflows(e.workflows),this.frameworkName=e.frameworkName,this.hmacEnabled=this.client.strictAuthentication;}createHandler(){return async(...e)=>{let t=await this.handler(...e),r=await this.handleAction({actions:t});return t.transformResponse(r)}}getStaticHeaders(){let e=`novu-framework:v${this.client.version}`;return {"content-type":"application/json","access-control-allow-origin":"*","access-control-allow-methods":"GET, POST","access-control-allow-headers":"*","access-control-max-age":"604800","x-novu-framework":this.frameworkName,"user-agent":e,"x-novu-sdk":e}}createResponse(e,t,r={}){return {status:e,body:JSON.stringify(t),headers:{...this.getStaticHeaders(),...r}}}createError(e){return {status:e.statusCode,body:JSON.stringify({message:e.message,data:e.data,code:e.code}),headers:this.getStaticHeaders()}}async handleAction({actions:e}){let t=await e.url(),r=await e.method(),s=t.searchParams.get("action")||"",i=t.searchParams.get("workflowId")||"",c=t.searchParams.get("stepId")||"",a=await e.headers("x-novu-signature")||"",l=await e.headers("x-novu-anonymous")||"",O=t.searchParams.get("source")||"",n={};try{r==="POST"&&(n=await e.body());}catch{}try{s!=="health-check"&&this.validateHmac(n,a);let p=this.getPostActionMap(n,i,c,s,l,O),E=this.getGetActionMap(i,c);if(r==="POST")return await this.handlePostAction(s,p);if(r==="GET")return await this.handleGetAction(s,E);if(r==="OPTIONS")return this.createResponse(200,{},{...this.getStaticHeaders()})}catch(p){return this.handleError(p)}return this.createError(new Y(r))}getPostActionMap(e,t,r,s,i,c){return {execute:async()=>{let a=await this.client.executeWorkflow({...e,workflowId:t,stepId:r,action:s});return this.createResponse(200,a,{"x-novu-execution-duration":a.metadata.duration.toString()})},preview:async()=>{let a=await this.client.executeWorkflow({...e,workflowId:t,stepId:r,action:s});return this.createResponse(200,a,{"x-novu-execution-duration":a.metadata.duration.toString()})},sync:async()=>{if(!this.client.apiKey)throw new C;let a=await this.client.sync(e.bridgeUrl,i,c);return this.createResponse(200,a)},diff:async()=>{if(!this.client.apiKey)throw new C;let a=await this.client.diff(e.bridgeUrl,i);return this.createResponse(200,a)}}}getGetActionMap(e,t){return {discover:async()=>{let r=await this.client.discover();return this.createResponse(200,r)},"health-check":async()=>{let r=await this.client.healthCheck();return this.createResponse(200,r)},code:async()=>{let r=await this.client.getCode(e,t);return this.createResponse(200,r)}}}async handlePostAction(e,t){if(Object.values(k).includes(e)){let r=t[e];return r()}else throw new S(e,k)}async handleGetAction(e,t){if(Object.values(L).includes(e)){let r=t[e];return r()}else throw new S(e,L)}isClientError(e){return Object.values(f).includes(e.code)}handleError(e){return this.isClientError(e)?(e.statusCode===500&&console.error(e),this.createError(e)):(console.error(e),this.createError(new X))}validateHmac(e,t){if(!this.hmacEnabled)return;if(!t)throw new Q;if(!this.client.apiKey)throw new H;let[r,s]=t.split(",");if(!r||!s)throw new z;let[i,c]=r.split("="),[a,l]=s.split("=");if(Number(i)<Date.now()-1500)throw new Z;if(!(this.hashHmac(this.client.apiKey,`${c}.${JSON.stringify(e)}`)===l))throw new J}hashHmac(e,t){return crypto.createHmac("sha256",e).update(t).digest("hex")}};var ve="next",Or=o=>{let t=new oe({frameworkName:ve,...o,handler:(i,c,a)=>{let l=c,O=n=>{let p=typeof l.headers.get=="function"?l.headers.get(n):l.headers[n];return Array.isArray(p)?p[0]:p};return {body:()=>typeof l.json=="function"?l.json():l.body,headers:O,method:()=>i||l.method||"",queryString:(n,p)=>{let E=l.query?.[n]||p.searchParams.get(n);return Array.isArray(E)?E[0]:E},url:()=>{let n;try{n=new URL(l.url);}catch{}if(n){let h=O("host");if(h){let I=new URL(h.includes("://")?h:`${n.protocol}//${h}`);n.protocol=I.protocol,n.host=I.host,n.port=I.port,n.username=I.username,n.password=I.password;}return n}let p="https",E=O("host")||"";try{process.env.NODE_ENV==="development"&&(p="http");}catch{}return new URL(l.url,`${p}://${E}`)},transformResponse:({body:n,headers:p,status:E})=>{if(typeof a?.setHeader=="function"&&Object.entries(p).forEach(([h,I])=>{a.setHeader(h,I);}),typeof a?.status=="function"&&typeof a?.send=="function"){a.status(E).send(n);return}let A=de();return new A(n,{status:E,headers:p})}}}}).createHandler(),r=t.bind(null,void 0);return Object.defineProperties(r,{GET:{value:t.bind(null,"GET")},POST:{value:t.bind(null,"POST")},PUT:{value:t.bind(null,"PUT")},OPTIONS:{value:t.bind(null,"OPTIONS")}})};
26
+
27
+ exports.frameworkName = ve;
28
+ exports.serve = Or;
package/dist/nuxt.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import * as h3 from 'h3';
2
+ import { H3Event } from 'h3';
3
+ import { i as SupportedFrameworkName, S as ServeHandlerOptions } from './handler-58kccf2b.js';
4
+ import 'ajv';
5
+ import 'json-schema-to-ts';
6
+
7
+ declare const frameworkName: SupportedFrameworkName;
8
+ declare const serve: (options: ServeHandlerOptions) => (event: H3Event<h3.EventHandlerRequest>) => Promise<Promise<void>>;
9
+
10
+ export { frameworkName, serve };