@novu/framework 2.0.0-canary.3 → 2.0.0-canary.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -11
- package/dist/{handler-3oTUJvk2.d.ts → handler-RA4Feq8s.d.ts} +641 -98
- package/dist/index.d.ts +14 -11
- package/dist/index.js +74 -70
- package/dist/{express.d.ts → servers/express.d.ts} +1 -1
- package/dist/servers/express.js +30 -0
- package/dist/{h3.d.ts → servers/h3.d.ts} +1 -1
- package/dist/servers/h3.js +31 -0
- package/dist/servers/lambda.d.ts +24 -0
- package/dist/servers/lambda.js +30 -0
- package/dist/{next.d.ts → servers/next.d.ts} +1 -1
- package/dist/servers/next.js +30 -0
- package/dist/{nuxt.d.ts → servers/nuxt.d.ts} +1 -1
- package/dist/servers/nuxt.js +31 -0
- package/dist/{remix.d.ts → servers/remix.d.ts} +1 -1
- package/dist/servers/remix.js +30 -0
- package/dist/{sveltekit.d.ts → servers/sveltekit.d.ts} +1 -1
- package/dist/servers/sveltekit.js +30 -0
- package/package.json +40 -25
- package/dist/express.js +0 -28
- package/dist/h3.js +0 -29
- package/dist/next.js +0 -28
- package/dist/nuxt.js +0 -29
- package/dist/remix.js +0 -28
- package/dist/sveltekit.js +0 -28
package/dist/index.js
CHANGED
|
@@ -2,45 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
var jsonSchemaFaker = require('json-schema-faker');
|
|
4
4
|
var liquidjs = require('liquidjs');
|
|
5
|
-
var
|
|
5
|
+
var Ae = require('ora');
|
|
6
6
|
require('cross-fetch');
|
|
7
|
-
var
|
|
7
|
+
var j = require('chalk');
|
|
8
8
|
var shared = require('@novu/shared');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var Fe = require('sanitize-html');
|
|
10
|
+
var ht = require('ajv');
|
|
11
|
+
var ut = require('ajv-formats');
|
|
11
12
|
var zodToJsonSchema = require('zod-to-json-schema');
|
|
12
13
|
var crypto = require('crypto');
|
|
13
14
|
|
|
14
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
16
|
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
17
|
+
var Ae__default = /*#__PURE__*/_interopDefault(Ae);
|
|
18
|
+
var j__default = /*#__PURE__*/_interopDefault(j);
|
|
19
|
+
var Fe__default = /*#__PURE__*/_interopDefault(Fe);
|
|
20
|
+
var ht__default = /*#__PURE__*/_interopDefault(ht);
|
|
21
|
+
var ut__default = /*#__PURE__*/_interopDefault(ut);
|
|
20
22
|
|
|
21
|
-
var C=(i=>(i.TRIGGER="trigger",i.EXECUTE="execute",i.PREVIEW="preview",i))(C||{}),L=(i=>(i.DISCOVER="discover",i.HEALTH_CHECK="health-check",i.CODE="code",i))(L||{});var Je=(t=>(t.SYNC="/v1/bridge/sync",t.DIFF="/v1/bridge/diff",t))(Je||{}),ve=5,Oe=1500;var w=(h=>(h.WORKFLOW_NOT_FOUND_ERROR="WorkflowNotFoundError",h.WORKFLOW_ALREADY_EXISTS_ERROR="WorkflowAlreadyExistsError",h.WORKFLOW_EXECUTION_FAILED_ERROR="WorkflowExecutionFailedError",h.EXECUTION_STATE_OUTPUT_INVALID_ERROR="ExecutionStateOutputInvalidError",h.EXECUTION_STATE_RESULT_INVALID_ERROR="ExecutionStateResultInvalidError",h.EXECUTION_PROVIDER_OUTPUT_INVALID_ERROR="ExecutionProviderOutputInvalidError",h.PROVIDER_NOT_FOUND_ERROR="ProviderNotFoundError",h.PROVIDER_EXECUTION_FAILED_ERROR="ProviderExecutionFailedError",h.STEP_NOT_FOUND_ERROR="StepNotFoundError",h.STEP_ALREADY_EXISTS_ERROR="StepAlreadyExistsError",h.STEP_EXECUTION_FAILED_ERROR="StepExecutionFailedError",h.EXECUTION_STATE_CORRUPT_ERROR="ExecutionStateCorruptError",h.EXECUTION_EVENT_PAYLOAD_INVALID_ERROR="ExecutionEventPayloadInvalidError",h.EXECUTION_EVENT_CONTROL_INVALID_ERROR="ExecutionEventControlInvalidError",h.EXECUTION_STATE_CONTROL_INVALID_ERROR="ExecutionStateControlInvalidError",h.METHOD_NOT_ALLOWED_ERROR="MethodNotAllowedError",h.INVALID_ACTION_ERROR="InvalidActionError",h.MISSING_SECRET_KEY_ERROR="MissingSecretKeyError",h.SIGNATURE_MISMATCH_ERROR="SignatureMismatchError",h.SIGNATURE_NOT_FOUND_ERROR="SignatureNotFoundError",h.SIGNATURE_INVALID_ERROR="SignatureInvalidError",h.SIGNATURE_EXPIRED_ERROR="SignatureExpiredError",h.SIGNING_KEY_NOT_FOUND_ERROR="SigningKeyNotFoundError",h.BRIDGE_ERROR="BridgeError",h.SIGNATURE_VERSION_INVALID_ERROR="SignatureVersionInvalidError",h.WORKFLOW_PAYLOAD_INVALID_ERROR="WorkflowPayloadInvalidError",h))(w||{});var xe=(m=>(m.NOVU_SIGNATURE="novu-signature",m.NOVU_ANONYMOUS="novu-anonymous",m.NOVU_SIGNATURE_DEPRECATED="x-novu-signature",m.NOVU_ANONYMOUS_DEPRECATED="x-novu-anonymous",m.NOVU_FRAMEWORK_SDK="novu-framework-sdk",m.NOVU_FRAMEWORK_API="novu-framework-api",m.NOVU_FRAMEWORK_VERSION="novu-framework-version",m.USER_AGENT="user-agent",m.CONTENT_TYPE="content-type",m.ACCESS_CONTROL_ALLOW_ORIGIN="access-control-allow-origin",m.ACCESS_CONTROL_ALLOW_METHODS="access-control-allow-methods",m.ACCESS_CONTROL_ALLOW_HEADERS="access-control-allow-headers",m.ACCESS_CONTROL_MAX_AGE="access-control-max-age",m))(xe||{});var q=(i=>(i.POST="POST",i.GET="GET",i.OPTIONS="OPTIONS",i))(q||{});var Pe=(n=>(n.WORKFLOW_ID="workflowId",n.STEP_ID="stepId",n.ACTION="action",n.SOURCE="source",n))(Pe||{});var W=(o=>(o[o.CONTINUE=100]="CONTINUE",o[o.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",o[o.PROCESSING=102]="PROCESSING",o[o.EARLYHINTS=103]="EARLYHINTS",o[o.OK=200]="OK",o[o.CREATED=201]="CREATED",o[o.ACCEPTED=202]="ACCEPTED",o[o.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",o[o.NO_CONTENT=204]="NO_CONTENT",o[o.RESET_CONTENT=205]="RESET_CONTENT",o[o.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",o[o.AMBIGUOUS=300]="AMBIGUOUS",o[o.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",o[o.FOUND=302]="FOUND",o[o.SEE_OTHER=303]="SEE_OTHER",o[o.NOT_MODIFIED=304]="NOT_MODIFIED",o[o.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",o[o.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",o[o.BAD_REQUEST=400]="BAD_REQUEST",o[o.UNAUTHORIZED=401]="UNAUTHORIZED",o[o.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",o[o.FORBIDDEN=403]="FORBIDDEN",o[o.NOT_FOUND=404]="NOT_FOUND",o[o.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",o[o.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",o[o.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",o[o.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",o[o.CONFLICT=409]="CONFLICT",o[o.GONE=410]="GONE",o[o.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",o[o.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",o[o.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",o[o.URI_TOO_LONG=414]="URI_TOO_LONG",o[o.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",o[o.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",o[o.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",o[o.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",o[o.MISDIRECTED=421]="MISDIRECTED",o[o.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",o[o.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",o[o.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",o[o.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",o[o.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",o[o.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",o[o.BAD_GATEWAY=502]="BAD_GATEWAY",o[o.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",o[o.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",o[o.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",o))(W||{}),Ft=[500];var B=(i=>(i.WORKFLOW="workflow",i.PROVIDER="provider",i.STEP="step",i))(B||{});var G=(a=>(a.EMAIL="email",a.SMS="sms",a.PUSH="push",a.CHAT="chat",a.IN_APP="in_app",a))(G||{}),Qe=(i=>(i.DIGEST="digest",i.DELAY="delay",i.CUSTOM="custom",i))(Qe||{});var T=class extends Error{data},K=class extends T{statusCode=404},b=class extends T{statusCode=400},R=class extends T{statusCode=401},O=class extends T{statusCode=500},X=class extends T{statusCode=409};var z=class extends b{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};}},j=class extends b{code="ExecutionEventPayloadInvalidError";constructor(e,t){super(`Workflow with id: \`${e}\` has invalid \`payload\`. Please provide the correct event payload.`),this.data=t;}},J=class extends b{code="ExecutionEventControlInvalidError";constructor(e,t){super(`Workflow with id: \`${e}\` has invalid \`controls\`. Please provide the correct event controls.`),this.data=t;}},Q=class extends b{code="ExecutionStateControlInvalidError";constructor(e,t,i){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` has invalid \`controls\`. Please provide the correct step controls.`),this.data=i;}},Z=class extends b{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;}},H=class extends b{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;}},ee=class extends b{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;}},te=class extends b{code="WorkflowPayloadInvalidError";constructor(e,t){super(`Workflow with id: \`${e}\` has invalid \`payload\`. Please provide the correct payload.`),this.data=t;}},ie=class extends T{statusCode;data;code;constructor(e,t,i){super(),this.data={message:i},this.statusCode=e,this.code=t;}};var Ie=async()=>{if(process.env.NOVU_BRIDGE_ORIGIN)return `${process.env.NOVU_BRIDGE_ORIGIN}/api/novu`;if(process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"&&process.env.NEXT_PUBLIC_VERCEL_URL)return `https://${process.env.NEXT_PUBLIC_VERCEL_URL}/api/novu`;try{if(process.env.NODE_ENV==="development"){let e=await(await fetch("http://localhost:2022/.well-known/novu")).json();return `${e.tunnelOrigin}${e.route}`}}catch(s){console.error(s);}return ""};var d={info:s=>P__default.default.blue(s),warning:s=>P__default.default.yellow(s),error:s=>P__default.default.red(s),success:s=>P__default.default.green(s),underline:s=>P__default.default.underline(s),bold:s=>P__default.default.bold(s)},f={SUCCESS:d.success("\u2714"),ERROR:d.error("\u2717"),WARNING:d.warning("\u26A0"),INFO:d.info("\u2139"),ARROW:d.bold("\u2192"),MOCK:d.info("\u25CB"),HYDRATED:d.bold(d.info("\u2192")),STEP:d.info("\u03C3"),ACTION:d.info("\u03B1"),DURATION:d.info("\u0394"),PROVIDER:d.info("\u2699"),OUTPUT:d.info("\u21E2"),INPUT:d.info("\u21E0"),WORKFLOW:d.info("\u03C9"),STATE:d.info("\u03C3"),EXECUTE:d.info("\u03B5"),PREVIEW:d.info("\u03C1")};var ke=s=>Object.values(s).map(e=>`\`${e}\``).join(", "),oe=s=>s.replaceAll(/(\w)(\w*)/g,(e,t,i)=>t.toUpperCase()+i.toLowerCase()).replaceAll(/[\s-]+/g,"");var ne=(s,e="https://api.novu.co")=>{let t=process.env.NOVU_API_URL||e;return {post:async(i,n)=>{let a=await fetch(t+"/v1"+i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${s}`},body:JSON.stringify(n)}),l=await a.json();if(a.ok)return l;throw shared.checkIsResponseError(l)?new ie(l.statusCode,l.error,l.message):new I("Error processing API request to Novu Cloud from Bridge application.")},delete:async i=>(await fetch(t+"/v1"+i,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${s}`}})).json()}};var se=class extends T{code="MethodNotAllowedError";statusCode=405;message=`Method not allowed. Please use one of ${ke(q)}`},$=class extends b{code="InvalidActionError";constructor(e,t){super(`Invalid query string: \`action\`=\`${e}\`. Please use one of ${ke(t)}`);}},re=class extends b{code="MissingSecretKeyError";constructor(){super("Missing secret key. Set the `NOVU_SECRET_KEY` environment variable or pass `secretKey` to the client options.");}};var I=class extends O{code="BridgeError";message="Something went wrong. Please try again later."};var D=class extends X{constructor(e,t){super(`${oe(e)} with id: \`${t}\` already exists. Please use a different id.`);}},S=class extends K{constructor(e,t){super(`${oe(e)} with id: \`${t}\` does not exist. Please provide a valid id.`);}},N=class extends O{constructor(e,t){super(`Failed to execute ${oe(e)} with id: \`${t}\`. Please try again later.`);}};var ae=class extends S{code="ProviderNotFoundError";constructor(e){super("provider",e);}},le=class extends N{code="ProviderExecutionFailedError";constructor(e){super("workflow",e);}};var ce=class extends R{code="SignatureMismatchError";constructor(){super("Signature does not match the expected signature. Please ensure the signature provided in the `novu-signature` header is correct and try again.");}},pe=class extends R{code="SignatureNotFoundError";constructor(){super("Signature not found. Please provide a signature in the `novu-signature` header");}},de=class extends R{code="SignatureInvalidError";constructor(){super("Signature is invalid. Please provide a valid signature in the `novu-signature` header");}},he=class extends R{code="SignatureExpiredError";constructor(){super(`Signature expired. Please provide a signature with a timestamp no older than ${5} minutes in the \`novu-signature\` header`);}},ue=class extends R{code="SigningKeyNotFoundError";constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.secretKey`");}};var me=class extends S{code="StepNotFoundError";constructor(e){super("step",e);}},fe=class extends D{code="StepAlreadyExistsError";constructor(e){super("step",e);}};var U=class extends S{code="WorkflowNotFoundError";constructor(e){super("workflow",e);}},ye=class extends D{code="WorkflowAlreadyExistsError";constructor(e){super("workflow",e);}};var ge=class{ajv;compiledSchemas;constructor(){this.ajv=new He__default.default({useDefaults:!0,removeAdditional:"all"}),et__default.default(this.ajv),this.compiledSchemas=new Map;}isSchema(e){return typeof e=="boolean"?!1:e.type==="object"||!!e.anyOf||!!e.oneOf}async validate(e,t){let i=this.compiledSchemas.get(t);return i||(i=this.ajv.compile(t),this.compiledSchemas.set(t,i)),i(e)?{success:!0,data:e}:{success:!1,errors:i.errors.map(a=>({path:a.instancePath,message:a.message}))}}transformToJsonSchema(e){return e}};var _e=class{isSchema(e){return e.safeParseAsync!==void 0}async validate(e,t){let i=t.safeParse(e);return i.success?{success:!0,data:i.data}:{success:!1,errors:i.error.errors.map(n=>({path:`/${n.path.join("/")}`,message:n.message}))}}transformToJsonSchema(e){try{return zodToJsonSchema.zodToJsonSchema(e)}catch(t){throw t?.message?.includes("Cannot find module")&&console.error("Tried to use a zod schema in @novu/framework without `zod-to-json-schema` installed. Please install it by running `npm install zod-to-json-schema`."),t}}};var De=[new _e,new ge],be=async(s,e)=>{for(let t of De)if(t.isSchema(s))return t.validate(e,s);throw new Error("Invalid schema")},y=s=>{for(let e of De)if(e.isSchema(s))return e.transformToJsonSchema(s);throw new Error("Invalid schema")};var Ne={name:"@novu/framework",version:"2.0.0-canary.3",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"},keywords:["novu","code-first","workflows","durable","sdk","notifications","email","sms","push","webhooks","next","nuxt","h3","express"],author:"Novu Team <engineering@novu.co>",license:"ISC",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"}},peerDependencies:{"@sveltejs/kit":">=1.27.3","@vercel/node":">=2.15.9",express:">=4.19.2",h3:">=1.8.1",next:">=12.0.0",zod:">=3.0.0","zod-to-json-schema":">=3.0.0"},peerDependenciesMeta:{"@sveltejs/kit":{optional:!0},"@vercel/node":{optional:!0},express:{optional:!0},fastify:{optional:!0},h3:{optional:!0},next:{optional:!0},zod:{optional:!0},"zod-to-json-schema":{optional:!0}},devDependencies:{"@sveltejs/kit":"^1.27.3","@types/express":"^4.17.13","@types/json-schema":"^7.0.15","@types/node":"^20.11.20","@vercel/node":"^2.15.9",express:"^4.19.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",zod:"^3.23.0","zod-to-json-schema":"^3.23.0"},dependencies:{"@novu/shared":"^2.0.0-canary.0",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 Y=Ne.version,we="2024-06-26";jsonSchemaFaker.JSONSchemaFaker.random.shuffle=function(){return ["[placeholder]"]};jsonSchemaFaker.JSONSchemaFaker.option({useDefaultValue:!0,alwaysFakeOptionals:!0});function nt(){return process.env.NODE_ENV==="development"}var F=class{discoveredWorkflows=[];templateEngine=new liquidjs.Liquid;secretKey;version=Y;strictAuthentication;constructor(e){let t=this.buildOptions(e);this.secretKey=t.secretKey,this.strictAuthentication=t.strictAuthentication;}buildOptions(e){let t={secretKey:void 0,strictAuthentication:!nt()};return t.secretKey=e?.secretKey||process.env.NOVU_SECRET_KEY||process.env.NOVU_API_KEY,e?.strictAuthentication!==void 0?t.strictAuthentication=e.strictAuthentication:process.env.NOVU_STRICT_AUTHENTICATION_ENABLED!==void 0&&(t.strictAuthentication=process.env.NOVU_STRICT_AUTHENTICATION_ENABLED==="true"),t}addWorkflows(e){for(let t of e){if(this.discoveredWorkflows.some(i=>i.workflowId===t.definition.workflowId))throw new ye(t.definition.workflowId);this.discoveredWorkflows.push(t.definition);}}healthCheck(){let e=this.discoveredWorkflows.length,t=this.discoveredWorkflows.reduce((i,n)=>i+n.steps.length,0);return {status:"ok",sdkVersion:Y,frameworkVersion:we,discovered:{workflows:e,steps:t}}}getWorkflow(e){let t=this.discoveredWorkflows.find(i=>i.workflowId===e);if(t)return t;throw new U(e)}getStep(e,t){let n=this.getWorkflow(e).steps.find(a=>a.stepId===t);if(n)return n;throw new me(t)}getRegisteredWorkflows(){return this.discoveredWorkflows}discover(){return {workflows:this.getRegisteredWorkflows()}}mock(e){return jsonSchemaFaker.JSONSchemaFaker.generate(y(e))}async validate(e,t,i,n,a,l,c){let p=await be(t,e);if(p.success)return p.data;switch(i){case"event":this.throwInvalidEvent(n,a,p.errors);case"step":this.throwInvalidStep(l,n,a,p.errors);case"provider":this.throwInvalidProvider(l,c,n,a,p.errors);default:throw new Error(`Invalid component: '${i}'`)}}throwInvalidProvider(e,t,i,n,a){if(!e)throw new Error("stepId is required");if(!t)throw new Error("providerId is required");switch(i){case"output":throw new ee(n,e,t,a);default:throw new Error(`Invalid payload type: '${i}'`)}}throwInvalidStep(e,t,i,n){if(!e)throw new Error("stepId is required");switch(t){case"output":throw new Z(i,e,n);case"result":throw new H(i,e,n);case"controls":throw new Q(i,e,n);default:throw new Error(`Invalid payload type: '${t}'`)}}throwInvalidEvent(e,t,i){switch(e){case"controls":throw new J(t,i);case"payload":throw new j(t,i);default:throw new Error(`Invalid payload type: '${e}'`)}}executeStepFactory(e,t){return async(i,n,a)=>{let l=this.getStep(e.workflowId,i),c=st(e),p=await this.createStepControls(l,c),u=e.action==="preview";if(!u&&await this.shouldSkip(a?.skip,p))return t({options:{skip:!0}}),{};let g=this.previewStep.bind(this),k=this.executeStep.bind(this),m=await(u?g:k)(e,{...l,providers:l.providers.map(v=>{let M=a?.providers?.[v.type];if(!M)throw new ae(v.type);return {...v,resolve:M}}),resolve:n});return i===e.stepId&&t(m),m.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
|
-
${
|
|
23
|
-
${
|
|
24
|
-
`);}async executeProviders(e,t,i){return t.providers.reduce(async(n,a)=>{let
|
|
25
|
-
${l.message}`)}}async executeStep(e,t){if(e.stepId===t.stepId){let i=Te__default.default({indent:1}).start(`Executing stepId: \`${t.stepId}\``);try{let n=await this.createStepControls(t,e),a=await this.compileControls(n,e),l=await t.resolve(a),c=await this.validate(l,t.outputs.unknownSchema,"step","output",e.workflowId,t.stepId),p=await this.executeProviders(e,t,c);return i.succeed(`Executed stepId: \`${t.stepId}\``),{outputs:c,providers:p}}catch(n){throw i.stopAndPersist({prefixText:"",symbol:f.ERROR,text:`Failed to execute stepId: \`${t.stepId}\``}),n}}else {let i=Te__default.default({indent:1}).start(`Hydrating stepId: \`${t.stepId}\``);try{let n=e.state.find(a=>a.stepId===t.stepId);if(n){let a=await this.validate(n.outputs,t.results.unknownSchema,"step","result",e.workflowId,t.stepId);return i.stopAndPersist({symbol:f.HYDRATED,text:`Hydrated stepId: \`${t.stepId}\``}),{outputs:a,providers:await this.executeProviders(e,t,a)}}else throw new z(e.workflowId,t.stepId)}catch(n){throw i.stopAndPersist({symbol:f.ERROR,text:`Failed to hydrate stepId: \`${t.stepId}\``}),n}}}async compileControls(e,t){let i=this.templateEngine.parse(JSON.stringify(e)),n=await this.templateEngine.render(i,{...t.payload||t.data,subscriber:t.subscriber});return JSON.parse(n)}async createStepControls(e,t){let i=t.controls||t.inputs;return await this.validate(i,e.controls.unknownSchema,"step","controls",t.workflowId,e.stepId)}async previewStep(e,t){let i=Te__default.default({indent:1}).start(`Previewing stepId: \`${t.stepId}\``);try{if(e.stepId===t.stepId){let n=await this.createStepControls(t,e),a=await this.compileControls(n,e),l=await t.resolve(a),c=await this.validate(l,t.outputs.unknownSchema,"step","output",e.workflowId,t.stepId);return i.stopAndPersist({symbol:f.MOCK,text:`Mocked stepId: \`${t.stepId}\``}),{outputs:c,providers:await this.executeProviders(e,t,c)}}else {let n=this.mock(t.results.schema);return i.stopAndPersist({symbol:f.MOCK,text:`Mocked stepId: \`${t.stepId}\``}),{outputs:n,providers:await this.executeProviders(e,t,n)}}}catch(n){throw i.stopAndPersist({symbol:f.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 U(e);return i}};function st(s){return JSON.parse(JSON.stringify(s))}var rt=(r=>(r.EVERY_SECOND="* * * * * *",r.EVERY_5_SECONDS="*/5 * * * * *",r.EVERY_10_SECONDS="*/10 * * * * *",r.EVERY_30_SECONDS="*/30 * * * * *",r.EVERY_MINUTE="*/1 * * * *",r.EVERY_5_MINUTES="0 */5 * * * *",r.EVERY_10_MINUTES="0 */10 * * * *",r.EVERY_30_MINUTES="0 */30 * * * *",r.EVERY_HOUR="0 0-23/1 * * *",r.EVERY_2_HOURS="0 0-23/2 * * *",r.EVERY_3_HOURS="0 0-23/3 * * *",r.EVERY_4_HOURS="0 0-23/4 * * *",r.EVERY_5_HOURS="0 0-23/5 * * *",r.EVERY_6_HOURS="0 0-23/6 * * *",r.EVERY_7_HOURS="0 0-23/7 * * *",r.EVERY_8_HOURS="0 0-23/8 * * *",r.EVERY_9_HOURS="0 0-23/9 * * *",r.EVERY_10_HOURS="0 0-23/10 * * *",r.EVERY_11_HOURS="0 0-23/11 * * *",r.EVERY_12_HOURS="0 0-23/12 * * *",r.EVERY_DAY_AT_1AM="0 01 * * *",r.EVERY_DAY_AT_2AM="0 02 * * *",r.EVERY_DAY_AT_3AM="0 03 * * *",r.EVERY_DAY_AT_4AM="0 04 * * *",r.EVERY_DAY_AT_5AM="0 05 * * *",r.EVERY_DAY_AT_6AM="0 06 * * *",r.EVERY_DAY_AT_7AM="0 07 * * *",r.EVERY_DAY_AT_8AM="0 08 * * *",r.EVERY_DAY_AT_9AM="0 09 * * *",r.EVERY_DAY_AT_10AM="0 10 * * *",r.EVERY_DAY_AT_11AM="0 11 * * *",r.EVERY_DAY_AT_NOON="0 12 * * *",r.EVERY_DAY_AT_1PM="0 13 * * *",r.EVERY_DAY_AT_2PM="0 14 * * *",r.EVERY_DAY_AT_3PM="0 15 * * *",r.EVERY_DAY_AT_4PM="0 16 * * *",r.EVERY_DAY_AT_5PM="0 17 * * *",r.EVERY_DAY_AT_6PM="0 18 * * *",r.EVERY_DAY_AT_7PM="0 19 * * *",r.EVERY_DAY_AT_8PM="0 20 * * *",r.EVERY_DAY_AT_9PM="0 21 * * *",r.EVERY_DAY_AT_10PM="0 22 * * *",r.EVERY_DAY_AT_11PM="0 23 * * *",r.EVERY_DAY_AT_MIDNIGHT="0 0 * * *",r.EVERY_WEEK="0 0 * * 0",r.EVERY_WEEKDAY="0 0 * * 1-5",r.EVERY_WEEKEND="0 0 * * 6,0",r.EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT="0 0 1 * *",r.EVERY_1ST_DAY_OF_MONTH_AT_NOON="0 12 1 * *",r.EVERY_2ND_HOUR="0 */2 * * *",r.EVERY_2ND_HOUR_FROM_1AM_THROUGH_11PM="0 1-23/2 * * *",r.EVERY_2ND_MONTH="0 0 1 */2 *",r.EVERY_QUARTER="0 0 1 */3 *",r.EVERY_6_MONTHS="0 0 1 */6 *",r.EVERY_YEAR="0 0 1 0 *",r.EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM="0 */30 9-17 * * *",r.EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM="0 */30 9-18 * * *",r.EVERY_30_MINUTES_BETWEEN_10AM_AND_7PM="0 */30 10-19 * * *",r.MONDAY_TO_FRIDAY_AT_1AM="0 0 01 * * 1-5",r.MONDAY_TO_FRIDAY_AT_2AM="0 0 02 * * 1-5",r.MONDAY_TO_FRIDAY_AT_3AM="0 0 03 * * 1-5",r.MONDAY_TO_FRIDAY_AT_4AM="0 0 04 * * 1-5",r.MONDAY_TO_FRIDAY_AT_5AM="0 0 05 * * 1-5",r.MONDAY_TO_FRIDAY_AT_6AM="0 0 06 * * 1-5",r.MONDAY_TO_FRIDAY_AT_7AM="0 0 07 * * 1-5",r.MONDAY_TO_FRIDAY_AT_8AM="0 0 08 * * 1-5",r.MONDAY_TO_FRIDAY_AT_9AM="0 0 09 * * 1-5",r.MONDAY_TO_FRIDAY_AT_09_30AM="0 30 09 * * 1-5",r.MONDAY_TO_FRIDAY_AT_10AM="0 0 10 * * 1-5",r.MONDAY_TO_FRIDAY_AT_11AM="0 0 11 * * 1-5",r.MONDAY_TO_FRIDAY_AT_11_30AM="0 30 11 * * 1-5",r.MONDAY_TO_FRIDAY_AT_12PM="0 0 12 * * 1-5",r.MONDAY_TO_FRIDAY_AT_1PM="0 0 13 * * 1-5",r.MONDAY_TO_FRIDAY_AT_2PM="0 0 14 * * 1-5",r.MONDAY_TO_FRIDAY_AT_3PM="0 0 15 * * 1-5",r.MONDAY_TO_FRIDAY_AT_4PM="0 0 16 * * 1-5",r.MONDAY_TO_FRIDAY_AT_5PM="0 0 17 * * 1-5",r.MONDAY_TO_FRIDAY_AT_6PM="0 0 18 * * 1-5",r.MONDAY_TO_FRIDAY_AT_7PM="0 0 19 * * 1-5",r.MONDAY_TO_FRIDAY_AT_8PM="0 0 20 * * 1-5",r.MONDAY_TO_FRIDAY_AT_9PM="0 0 21 * * 1-5",r.MONDAY_TO_FRIDAY_AT_10PM="0 0 22 * * 1-5",r.MONDAY_TO_FRIDAY_AT_11PM="0 0 23 * * 1-5",r))(rt||{});var at=(u=>(u.PENDING="pending",u.QUEUED="queued",u.RUNNING="running",u.COMPLETED="completed",u.FAILED="failed",u.DELAYED="delayed",u.CANCELED="canceled",u.MERGED="merged",u.SKIPPED="skipped",u))(at||{});var Se=class{frameworkName;handler;client;hmacEnabled;http;constructor(e){this.handler=e.handler,this.client=e.client?e.client:new F,this.client.addWorkflows(e.workflows),this.http=ne(this.client.secretKey),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","novu-framework-version":we,"novu-framework-sdk":Y,"novu-framework-api":this.frameworkName,"user-agent":e}}createResponse(e,t){return {status:e,body:JSON.stringify(t),headers:{...this.getStaticHeaders()}}}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")||"",a=t.searchParams.get("workflowId")||"",l=t.searchParams.get("stepId")||"",c=await e.headers("novu-signature")||await e.headers("x-novu-signature")||"",p={};try{i==="POST"&&(p=await e.body());}catch{}try{n!=="health-check"&&this.validateHmac(p,c);let u=this.getPostActionMap(p,a,l,n),g=this.getGetActionMap(a,l);if(i==="POST")return await this.handlePostAction(n,u);if(i==="GET")return await this.handleGetAction(n,g);if(i==="OPTIONS")return this.createResponse(200,{})}catch(u){return this.handleError(u)}return this.createError(new se(i))}getPostActionMap(e,t,i,n){return {trigger:this.triggerAction({workflowId:t,...e}),execute:async()=>{let a=await this.client.executeWorkflow({...e,workflowId:t,stepId:i,action:n});return this.createResponse(200,a)},preview:async()=>{let a=await this.client.executeWorkflow({...e,workflowId:t,stepId:i,action:n});return this.createResponse(200,a)}}}triggerAction(e){return async()=>{let t={name:e.workflowId,to:e.to,payload:e?.payload||{},transactionId:e.transactionId,overrides:e.overrides||{},...e.actor&&{actor:e.actor},...e.tenant&&{tenant:e.tenant},...e.bridgeUrl&&{bridgeUrl:e.bridgeUrl},...e.controls&&{controls:e.controls}},i=await this.http.post("/events/trigger",t);return this.createResponse(200,i)}}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(C).includes(e)){let i=t[e];return i()}else throw new $(e,C)}async handleGetAction(e,t){if(Object.values(L).includes(e)){let i=t[e];return i()}else throw new $(e,L)}isBridgeError(e){return Object.values(w).includes(e?.code)}isPlatformError(e){return e?.statusCode>=400&&e?.statusCode<500}handleError(e){return this.isBridgeError(e)?(e.statusCode===500&&console.error(e),this.createError(e)):this.isPlatformError(e)?this.createError(e):(console.error(e),this.createError(new I))}validateHmac(e,t){if(!this.hmacEnabled)return;if(!t)throw new pe;if(!this.client.secretKey)throw new ue;let[i,n]=t.split(",");if(!i||!n)throw new de;let[a,l]=i.split("="),[c,p]=n.split("=");if(Number(a)<Date.now()-1500)throw new he;if(!(this.hashHmac(this.client.secretKey,`${l}.${JSON.stringify(e)}`)===p))throw new ce}hashHmac(e,t){return crypto.createHmac("sha256",e).update(t).digest("hex")}};var ct={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.
|
|
23
|
+
var V=(i=>(i.TRIGGER="trigger",i.EXECUTE="execute",i.PREVIEW="preview",i))(V||{}),X=(i=>(i.DISCOVER="discover",i.HEALTH_CHECK="health-check",i.CODE="code",i))(X||{});var st=(t=>(t.SYNC="/v1/bridge/sync",t.DIFF="/v1/bridge/diff",t))(st||{}),Me=5,Ce=1500;var at=(s=>(s.EVERY_SECOND="* * * * * *",s.EVERY_5_SECONDS="*/5 * * * * *",s.EVERY_10_SECONDS="*/10 * * * * *",s.EVERY_30_SECONDS="*/30 * * * * *",s.EVERY_MINUTE="*/1 * * * *",s.EVERY_5_MINUTES="0 */5 * * * *",s.EVERY_10_MINUTES="0 */10 * * * *",s.EVERY_30_MINUTES="0 */30 * * * *",s.EVERY_HOUR="0 0-23/1 * * *",s.EVERY_2_HOURS="0 0-23/2 * * *",s.EVERY_3_HOURS="0 0-23/3 * * *",s.EVERY_4_HOURS="0 0-23/4 * * *",s.EVERY_5_HOURS="0 0-23/5 * * *",s.EVERY_6_HOURS="0 0-23/6 * * *",s.EVERY_7_HOURS="0 0-23/7 * * *",s.EVERY_8_HOURS="0 0-23/8 * * *",s.EVERY_9_HOURS="0 0-23/9 * * *",s.EVERY_10_HOURS="0 0-23/10 * * *",s.EVERY_11_HOURS="0 0-23/11 * * *",s.EVERY_12_HOURS="0 0-23/12 * * *",s.EVERY_DAY_AT_1AM="0 01 * * *",s.EVERY_DAY_AT_2AM="0 02 * * *",s.EVERY_DAY_AT_3AM="0 03 * * *",s.EVERY_DAY_AT_4AM="0 04 * * *",s.EVERY_DAY_AT_5AM="0 05 * * *",s.EVERY_DAY_AT_6AM="0 06 * * *",s.EVERY_DAY_AT_7AM="0 07 * * *",s.EVERY_DAY_AT_8AM="0 08 * * *",s.EVERY_DAY_AT_9AM="0 09 * * *",s.EVERY_DAY_AT_10AM="0 10 * * *",s.EVERY_DAY_AT_11AM="0 11 * * *",s.EVERY_DAY_AT_NOON="0 12 * * *",s.EVERY_DAY_AT_1PM="0 13 * * *",s.EVERY_DAY_AT_2PM="0 14 * * *",s.EVERY_DAY_AT_3PM="0 15 * * *",s.EVERY_DAY_AT_4PM="0 16 * * *",s.EVERY_DAY_AT_5PM="0 17 * * *",s.EVERY_DAY_AT_6PM="0 18 * * *",s.EVERY_DAY_AT_7PM="0 19 * * *",s.EVERY_DAY_AT_8PM="0 20 * * *",s.EVERY_DAY_AT_9PM="0 21 * * *",s.EVERY_DAY_AT_10PM="0 22 * * *",s.EVERY_DAY_AT_11PM="0 23 * * *",s.EVERY_DAY_AT_MIDNIGHT="0 0 * * *",s.EVERY_WEEK="0 0 * * 0",s.EVERY_WEEKDAY="0 0 * * 1-5",s.EVERY_WEEKEND="0 0 * * 6,0",s.EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT="0 0 1 * *",s.EVERY_1ST_DAY_OF_MONTH_AT_NOON="0 12 1 * *",s.EVERY_2ND_HOUR="0 */2 * * *",s.EVERY_2ND_HOUR_FROM_1AM_THROUGH_11PM="0 1-23/2 * * *",s.EVERY_2ND_MONTH="0 0 1 */2 *",s.EVERY_QUARTER="0 0 1 */3 *",s.EVERY_6_MONTHS="0 0 1 */6 *",s.EVERY_YEAR="0 0 1 0 *",s.EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM="0 */30 9-17 * * *",s.EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM="0 */30 9-18 * * *",s.EVERY_30_MINUTES_BETWEEN_10AM_AND_7PM="0 */30 10-19 * * *",s.MONDAY_TO_FRIDAY_AT_1AM="0 0 01 * * 1-5",s.MONDAY_TO_FRIDAY_AT_2AM="0 0 02 * * 1-5",s.MONDAY_TO_FRIDAY_AT_3AM="0 0 03 * * 1-5",s.MONDAY_TO_FRIDAY_AT_4AM="0 0 04 * * 1-5",s.MONDAY_TO_FRIDAY_AT_5AM="0 0 05 * * 1-5",s.MONDAY_TO_FRIDAY_AT_6AM="0 0 06 * * 1-5",s.MONDAY_TO_FRIDAY_AT_7AM="0 0 07 * * 1-5",s.MONDAY_TO_FRIDAY_AT_8AM="0 0 08 * * 1-5",s.MONDAY_TO_FRIDAY_AT_9AM="0 0 09 * * 1-5",s.MONDAY_TO_FRIDAY_AT_09_30AM="0 30 09 * * 1-5",s.MONDAY_TO_FRIDAY_AT_10AM="0 0 10 * * 1-5",s.MONDAY_TO_FRIDAY_AT_11AM="0 0 11 * * 1-5",s.MONDAY_TO_FRIDAY_AT_11_30AM="0 30 11 * * 1-5",s.MONDAY_TO_FRIDAY_AT_12PM="0 0 12 * * 1-5",s.MONDAY_TO_FRIDAY_AT_1PM="0 0 13 * * 1-5",s.MONDAY_TO_FRIDAY_AT_2PM="0 0 14 * * 1-5",s.MONDAY_TO_FRIDAY_AT_3PM="0 0 15 * * 1-5",s.MONDAY_TO_FRIDAY_AT_4PM="0 0 16 * * 1-5",s.MONDAY_TO_FRIDAY_AT_5PM="0 0 17 * * 1-5",s.MONDAY_TO_FRIDAY_AT_6PM="0 0 18 * * 1-5",s.MONDAY_TO_FRIDAY_AT_7PM="0 0 19 * * 1-5",s.MONDAY_TO_FRIDAY_AT_8PM="0 0 20 * * 1-5",s.MONDAY_TO_FRIDAY_AT_9PM="0 0 21 * * 1-5",s.MONDAY_TO_FRIDAY_AT_10PM="0 0 22 * * 1-5",s.MONDAY_TO_FRIDAY_AT_11PM="0 0 23 * * 1-5",s))(at||{});var k=(m=>(m.WORKFLOW_NOT_FOUND_ERROR="WorkflowNotFoundError",m.WORKFLOW_ALREADY_EXISTS_ERROR="WorkflowAlreadyExistsError",m.WORKFLOW_EXECUTION_FAILED_ERROR="WorkflowExecutionFailedError",m.EXECUTION_STATE_OUTPUT_INVALID_ERROR="ExecutionStateOutputInvalidError",m.EXECUTION_STATE_RESULT_INVALID_ERROR="ExecutionStateResultInvalidError",m.EXECUTION_PROVIDER_OUTPUT_INVALID_ERROR="ExecutionProviderOutputInvalidError",m.PROVIDER_NOT_FOUND_ERROR="ProviderNotFoundError",m.PROVIDER_EXECUTION_FAILED_ERROR="ProviderExecutionFailedError",m.STEP_NOT_FOUND_ERROR="StepNotFoundError",m.STEP_ALREADY_EXISTS_ERROR="StepAlreadyExistsError",m.STEP_EXECUTION_FAILED_ERROR="StepExecutionFailedError",m.EXECUTION_STATE_CORRUPT_ERROR="ExecutionStateCorruptError",m.EXECUTION_EVENT_PAYLOAD_INVALID_ERROR="ExecutionEventPayloadInvalidError",m.EXECUTION_EVENT_CONTROL_INVALID_ERROR="ExecutionEventControlInvalidError",m.EXECUTION_STATE_CONTROL_INVALID_ERROR="ExecutionStateControlInvalidError",m.METHOD_NOT_ALLOWED_ERROR="MethodNotAllowedError",m.INVALID_ACTION_ERROR="InvalidActionError",m.MISSING_SECRET_KEY_ERROR="MissingSecretKeyError",m.SIGNATURE_MISMATCH_ERROR="SignatureMismatchError",m.SIGNATURE_NOT_FOUND_ERROR="SignatureNotFoundError",m.SIGNATURE_INVALID_ERROR="SignatureInvalidError",m.SIGNATURE_EXPIRED_ERROR="SignatureExpiredError",m.SIGNING_KEY_NOT_FOUND_ERROR="SigningKeyNotFoundError",m.BRIDGE_ERROR="BridgeError",m.SIGNATURE_VERSION_INVALID_ERROR="SignatureVersionInvalidError",m.WORKFLOW_PAYLOAD_INVALID_ERROR="WorkflowPayloadInvalidError",m))(k||{});var ve=(f=>(f.NOVU_SIGNATURE="novu-signature",f.NOVU_ANONYMOUS="novu-anonymous",f.NOVU_SIGNATURE_DEPRECATED="x-novu-signature",f.NOVU_ANONYMOUS_DEPRECATED="x-novu-anonymous",f.NOVU_FRAMEWORK_SDK="novu-framework-sdk",f.NOVU_FRAMEWORK_SERVER="novu-framework-server",f.NOVU_FRAMEWORK_VERSION="novu-framework-version",f.USER_AGENT="user-agent",f.CONTENT_TYPE="content-type",f.ACCESS_CONTROL_ALLOW_ORIGIN="access-control-allow-origin",f.ACCESS_CONTROL_ALLOW_METHODS="access-control-allow-methods",f.ACCESS_CONTROL_ALLOW_HEADERS="access-control-allow-headers",f.ACCESS_CONTROL_MAX_AGE="access-control-max-age",f))(ve||{});var z=(i=>(i.POST="POST",i.GET="GET",i.OPTIONS="OPTIONS",i))(z||{});var je=(n=>(n.WORKFLOW_ID="workflowId",n.STEP_ID="stepId",n.ACTION="action",n.SOURCE="source",n))(je||{});var J=(o=>(o[o.CONTINUE=100]="CONTINUE",o[o.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",o[o.PROCESSING=102]="PROCESSING",o[o.EARLYHINTS=103]="EARLYHINTS",o[o.OK=200]="OK",o[o.CREATED=201]="CREATED",o[o.ACCEPTED=202]="ACCEPTED",o[o.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",o[o.NO_CONTENT=204]="NO_CONTENT",o[o.RESET_CONTENT=205]="RESET_CONTENT",o[o.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",o[o.AMBIGUOUS=300]="AMBIGUOUS",o[o.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",o[o.FOUND=302]="FOUND",o[o.SEE_OTHER=303]="SEE_OTHER",o[o.NOT_MODIFIED=304]="NOT_MODIFIED",o[o.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",o[o.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",o[o.BAD_REQUEST=400]="BAD_REQUEST",o[o.UNAUTHORIZED=401]="UNAUTHORIZED",o[o.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",o[o.FORBIDDEN=403]="FORBIDDEN",o[o.NOT_FOUND=404]="NOT_FOUND",o[o.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",o[o.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",o[o.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",o[o.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",o[o.CONFLICT=409]="CONFLICT",o[o.GONE=410]="GONE",o[o.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",o[o.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",o[o.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",o[o.URI_TOO_LONG=414]="URI_TOO_LONG",o[o.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",o[o.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",o[o.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",o[o.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",o[o.MISDIRECTED=421]="MISDIRECTED",o[o.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",o[o.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",o[o.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",o[o.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",o[o.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",o[o.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",o[o.BAD_GATEWAY=502]="BAD_GATEWAY",o[o.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",o[o.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",o[o.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",o))(J||{}),ei=[500];var Q=(i=>(i.WORKFLOW="workflow",i.PROVIDER="provider",i.STEP="step",i))(Q||{});var P=(a=>(a.EMAIL="email",a.SMS="sms",a.PUSH="push",a.CHAT="chat",a.IN_APP="in_app",a))(P||{}),lt=(i=>(i.DIGEST="digest",i.DELAY="delay",i.CUSTOM="custom",i))(lt||{});var $e="2.0.0-canary.4";var L=$e,Z="2024-06-26";var R=class extends Error{data},H=class extends R{statusCode=404},x=class extends R{statusCode=400},v=class extends R{statusCode=401},C=class extends R{statusCode=500},ee=class extends R{statusCode=409};var te=class extends x{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};}},q=class extends x{code="ExecutionEventPayloadInvalidError";constructor(e,t){super(`Workflow with id: \`${e}\` has invalid \`payload\`. Please provide the correct event payload.`),this.data=t;}},ie=class extends x{code="ExecutionEventControlInvalidError";constructor(e,t){super(`Workflow with id: \`${e}\` has invalid \`controls\`. Please provide the correct event controls.`),this.data=t;}},oe=class extends x{code="ExecutionStateControlInvalidError";constructor(e,t,i){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` has invalid \`controls\`. Please provide the correct step controls.`),this.data=i;}},ne=class extends x{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;}},re=class extends x{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;}},se=class extends x{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;}},ae=class extends x{code="WorkflowPayloadInvalidError";constructor(e,t){super(`Workflow with id: \`${e}\` has invalid \`payload\`. Please provide the correct payload.`),this.data=t;}},le=class extends R{statusCode;data;code;constructor(e,t,i){super(),this.data={message:i},this.statusCode=e,this.code=t;}};var Ue=async()=>{if(process.env.NOVU_BRIDGE_ORIGIN)return `${process.env.NOVU_BRIDGE_ORIGIN}/api/novu`;if(process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"&&process.env.NEXT_PUBLIC_VERCEL_URL)return `https://${process.env.NEXT_PUBLIC_VERCEL_URL}/api/novu`;try{if(process.env.NODE_ENV==="development"){let e=await(await fetch("http://localhost:2022/.well-known/novu")).json();return `${e.tunnelOrigin}${e.route}`}}catch(r){console.error(r);}return ""};var u={info:r=>j__default.default.blue(r),warning:r=>j__default.default.yellow(r),error:r=>j__default.default.red(r),success:r=>j__default.default.green(r),underline:r=>j__default.default.underline(r),bold:r=>j__default.default.bold(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 Oe=r=>Object.values(r).map(e=>`\`${e}\``).join(", "),ce=r=>r.replaceAll(/(\w)(\w*)/g,(e,t,i)=>t.toUpperCase()+i.toLowerCase()).replaceAll(/[\s-]+/g,"");var pe=(r,e="https://api.novu.co")=>{let t=process.env.NOVU_API_URL||e;return {post:async(i,n)=>{let a=await fetch(t+"/v1"+i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${r}`},body:JSON.stringify(n)}),c=await a.json();if(a.ok)return c;throw shared.checkIsResponseError(c)?new le(c.statusCode,c.error,c.message):new $("Error processing API request to Novu Cloud from Bridge application.")},delete:async i=>(await fetch(t+"/v1"+i,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${r}`}})).json()}};var dt={allowedTags:Fe__default.default.defaults.allowedTags.concat(["style","img","html","head","body","link","meta","title"]),allowedAttributes:!1,allowVulnerableTags:!0,parseStyleAttributes:!1,parser:{lowerCaseAttributeNames:!0}},Ye=r=>{if(!r)return r;let e=new RegExp("^<!DOCTYPE .*?>"),t=r.match(e),i=Fe__default.default(r,dt);return t?t[0]+i:i},de=r=>Object.keys(r).reduce((e,t)=>{let i=r[t];return typeof i=="string"?e[t]=Ye(i):Array.isArray(i)?e[t]=i.map(n=>typeof n=="string"?Ye(n):typeof n=="object"?de(n):n):typeof i=="object"&&i!==null?e[t]=de(i):e[t]=i,e},{});var he=class extends R{code="MethodNotAllowedError";statusCode=405;message=`Method not allowed. Please use one of ${Oe(z)}`},W=class extends x{code="InvalidActionError";constructor(e,t){super(`Invalid query string: \`action\`=\`${e}\`. Please use one of ${Oe(t)}`);}},ue=class extends x{code="MissingSecretKeyError";constructor(){super("Missing secret key. Set the `NOVU_SECRET_KEY` environment variable or pass `secretKey` to the client options.");}};var $=class extends C{code="BridgeError";message="Something went wrong. Please try again later."};var U=class extends ee{constructor(e,t){super(`${ce(e)} with id: \`${t}\` already exists. Please use a different id.`);}},O=class extends H{constructor(e,t){super(`${ce(e)} with id: \`${t}\` does not exist. Please provide a valid id.`);}},Y=class extends C{constructor(e,t){super(`Failed to execute ${ce(e)} with id: \`${t}\`. Please try again later.`);}};var me=class extends O{code="ProviderNotFoundError";constructor(e){super("provider",e);}},fe=class extends Y{code="ProviderExecutionFailedError";constructor(e){super("workflow",e);}};var ye=class extends v{code="SignatureMismatchError";constructor(){super("Signature does not match the expected signature. Please ensure the signature provided in the `novu-signature` header is correct and try again.");}},ge=class extends v{code="SignatureNotFoundError";constructor(){super("Signature not found. Please provide a signature in the `novu-signature` header");}},_e=class extends v{code="SignatureInvalidError";constructor(){super("Signature is invalid. Please provide a valid signature in the `novu-signature` header");}},be=class extends v{code="SignatureExpiredError";constructor(){super(`Signature expired. Please provide a signature with a timestamp no older than ${5} minutes in the \`novu-signature\` header`);}},we=class extends v{code="SigningKeyNotFoundError";constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.secretKey`");}};var Te=class extends O{code="StepNotFoundError";constructor(e){super("step",e);}},xe=class extends U{code="StepAlreadyExistsError";constructor(e){super("step",e);}};var B=class extends O{code="WorkflowNotFoundError";constructor(e){super("workflow",e);}},ke=class extends U{code="WorkflowAlreadyExistsError";constructor(e){super("workflow",e);}};var Re=class{ajv;compiledSchemas;constructor(){this.ajv=new ht__default.default({useDefaults:!0,removeAdditional:"all"}),ut__default.default(this.ajv),this.compiledSchemas=new Map;}isSchema(e){return typeof e=="boolean"?!1:e.type==="object"||!!e.anyOf||!!e.oneOf}async validate(e,t){let i=this.compiledSchemas.get(t);return i||(i=this.ajv.compile(t),this.compiledSchemas.set(t,i)),i(e)?{success:!0,data:e}:{success:!1,errors:i.errors.map(a=>({path:a.instancePath,message:a.message}))}}transformToJsonSchema(e){return e}};var Se=class{isSchema(e){return e.safeParseAsync!==void 0}async validate(e,t){let i=t.safeParse(e);return i.success?{success:!0,data:i.data}:{success:!1,errors:i.error.errors.map(n=>({path:`/${n.path.join("/")}`,message:n.message}))}}transformToJsonSchema(e){try{return zodToJsonSchema.zodToJsonSchema(e)}catch(t){throw t?.message?.includes("Cannot find module")&&console.error("Tried to use a zod schema in @novu/framework without `zod-to-json-schema` installed. Please install it by running `npm install zod-to-json-schema`."),t}}};var Ve=[new Se,new Re],Ee=async(r,e)=>{for(let t of Ve)if(t.isSchema(r))return t.validate(e,r);throw new Error("Invalid schema")},b=r=>{for(let e of Ve)if(e.isSchema(r))return e.transformToJsonSchema(r);throw new Error("Invalid schema")};jsonSchemaFaker.JSONSchemaFaker.random.shuffle=function(){return ["[placeholder]"]};jsonSchemaFaker.JSONSchemaFaker.option({useDefaultValue:!0,alwaysFakeOptionals:!0});function yt(){return ["development",void 0].includes(process.env.NODE_ENV)}var G=class{discoveredWorkflows=[];templateEngine=new liquidjs.Liquid;secretKey;version=L;strictAuthentication;constructor(e){let t=this.buildOptions(e);this.secretKey=t.secretKey,this.strictAuthentication=t.strictAuthentication;}buildOptions(e){let t={secretKey:void 0,strictAuthentication:!yt()};return t.secretKey=e?.secretKey||process.env.NOVU_SECRET_KEY||process.env.NOVU_API_KEY,e?.strictAuthentication!==void 0?t.strictAuthentication=e.strictAuthentication:process.env.NOVU_STRICT_AUTHENTICATION_ENABLED!==void 0&&(t.strictAuthentication=process.env.NOVU_STRICT_AUTHENTICATION_ENABLED==="true"),t}addWorkflows(e){for(let t of e){if(this.discoveredWorkflows.some(i=>i.workflowId===t.definition.workflowId))throw new ke(t.definition.workflowId);this.discoveredWorkflows.push(t.definition);}}healthCheck(){let e=this.discoveredWorkflows.length,t=this.discoveredWorkflows.reduce((i,n)=>i+n.steps.length,0);return {status:"ok",sdkVersion:L,frameworkVersion:Z,discovered:{workflows:e,steps:t}}}getWorkflow(e){let t=this.discoveredWorkflows.find(i=>i.workflowId===e);if(t)return t;throw new B(e)}getStep(e,t){let n=this.getWorkflow(e).steps.find(a=>a.stepId===t);if(n)return n;throw new Te(t)}getRegisteredWorkflows(){return this.discoveredWorkflows}discover(){return {workflows:this.getRegisteredWorkflows()}}mock(e){return jsonSchemaFaker.JSONSchemaFaker.generate(b(e))}async validate(e,t,i,n,a,c,p){let h=await Ee(t,e);if(h.success)return h.data;switch(i){case"event":this.throwInvalidEvent(n,a,h.errors);case"step":this.throwInvalidStep(c,n,a,h.errors);case"provider":this.throwInvalidProvider(c,p,n,a,h.errors);default:throw new Error(`Invalid component: '${i}'`)}}throwInvalidProvider(e,t,i,n,a){if(!e)throw new Error("stepId is required");if(!t)throw new Error("providerId is required");switch(i){case"output":throw new se(n,e,t,a);default:throw new Error(`Invalid payload type: '${i}'`)}}throwInvalidStep(e,t,i,n){if(!e)throw new Error("stepId is required");switch(t){case"output":throw new ne(i,e,n);case"result":throw new re(i,e,n);case"controls":throw new oe(i,e,n);default:throw new Error(`Invalid payload type: '${t}'`)}}throwInvalidEvent(e,t,i){switch(e){case"controls":throw new ie(t,i);case"payload":throw new q(t,i);default:throw new Error(`Invalid payload type: '${e}'`)}}executeStepFactory(e,t){return async(i,n,a)=>{let c=this.getStep(e.workflowId,i),p=gt(e),h=await this.createStepControls(c,p),y=e.action==="preview";if(!y&&await this.shouldSkip(a?.skip,h))return t({options:{skip:!0}}),{};let w=this.previewStep.bind(this),E=this.executeStep.bind(this),f=await(y?w:E)(e,{...c,providers:c.providers.map(M=>{let F=a?.providers?.[M.type];if(!F)throw new me(M.type);return {...M,resolve:F}}),resolve:n});return Object.values(P).includes(c.type)&&(f={...f,outputs:de(f.outputs)}),i===e.stepId&&t(f),f.outputs}}async shouldSkip(e,t){return e?e(t):!1}async executeWorkflow(e){let n=`${{execute:"Executing",preview:"Previewing"}[e.action]} workflowId:`;console.log(`
|
|
24
|
+
${u.bold(u.underline(n))} '${e.workflowId}'`);let a=this.getWorkflow(e.workflowId),c=process.hrtime(),p={outputs:{},providers:{},options:{}},h,y=new Promise(I=>{h=I;}),w=I=>{h(),p=I;},E;try{if(e.action==="execute"&&!e.payload&&!e.data)throw new q(e.workflowId,{message:"Event `payload` is required"});let I=await this.createExecutionPayload(e,a);await Promise.race([y,a.execute({payload:I,environment:{},inputs:{},controls:{},subscriber:e.subscriber,step:{email:this.executeStepFactory(e,w),sms:this.executeStepFactory(e,w),inApp:this.executeStepFactory(e,w),digest:this.executeStepFactory(e,w),delay:this.executeStepFactory(e,w),push:this.executeStepFactory(e,w),chat:this.executeStepFactory(e,w),custom:this.executeStepFactory(e,w)}})]);}catch(I){E=I;}let K=process.hrtime(c),f=K[0],M=K[1],F=f*1e3+M/1e6,nt=E?_.ERROR:_.SUCCESS,rt=e.action==="execute"?"Executed":e.action==="preview"?"Previewed":"Invalid action";if(console.log(`${nt} ${rt} workflowId: \`${e.workflowId}\``),this.prettyPrintExecute(e,F,E),E)throw E;return {outputs:p.outputs,providers:p.providers,options:p.options,metadata:{status:"success",error:!1,duration:F}}}async createExecutionPayload(e,t){let i=e.payload||e.data;if(e.action==="preview"){let a=this.mock(t.payload.schema);i=Object.assign(a,i);}return await this.validate(i,t.payload.unknownSchema,"event","payload",e.workflowId)}prettyPrintExecute(e,t,i){let n=i?_.ERROR:_.SUCCESS,a=e.action==="execute"?"Executed":e.action==="preview"?"Previewed":"Invalid action",c=i?"Failed to execute":a,p=i?u.error:u.success,h=`${n} ${c} workflowId: '${e.workflowId}`;console.log(`
|
|
25
|
+
${u.bold(p(h))}'`),console.log(` \u251C ${_.STEP} stepId: '${e.stepId}'`),console.log(` \u251C ${_.ACTION} action: '${e.action}'`),console.log(` \u2514 ${_.DURATION} duration: '${t.toFixed(2)}ms'
|
|
26
|
+
`);}async executeProviders(e,t,i){return t.providers.reduce(async(n,a)=>{let c=await n,p=this.previewProvider.bind(this),h=this.executeProvider.bind(this),w=await(e.action==="preview"?p:h)(e,t,a,i);return {...c,[a.type]:w}},Promise.resolve({}))}previewProvider(e,t,i,n){return console.log(` ${_.MOCK} Mocked provider: \`${i.type}\``),this.mock(i.outputs.schema)}async executeProvider(e,t,i,n){let a=Ae__default.default({indent:2}).start(`Executing provider: \`${i.type}\``);try{if(e.stepId===t.stepId){let c=await this.createStepControls(t,e),p=await i.resolve({controls:c,outputs:n}),h=await this.validate(p,i.outputs.unknownSchema,"step","output",e.workflowId,t.stepId,i.type);return a.succeed(`Executed provider: \`${i.type}\``),h}else a.stopAndPersist({symbol:_.HYDRATED,text:`Hydrated provider: \`${i.type}\``});}catch(c){throw a.stopAndPersist({symbol:_.ERROR,text:`Failed to execute provider: \`${i.type}\``}),new fe(`Failed to execute provider: '${i.type}'.
|
|
27
|
+
${c.message}`)}}async executeStep(e,t){if(e.stepId===t.stepId){let i=Ae__default.default({indent:1}).start(`Executing stepId: \`${t.stepId}\``);try{let n=await this.createStepControls(t,e),a=await this.compileControls(n,e),c=await t.resolve(a),p=await this.validate(c,t.outputs.unknownSchema,"step","output",e.workflowId,t.stepId),h=await this.executeProviders(e,t,p);return i.succeed(`Executed stepId: \`${t.stepId}\``),{outputs:p,providers:h}}catch(n){throw i.stopAndPersist({prefixText:"",symbol:_.ERROR,text:`Failed to execute stepId: \`${t.stepId}\``}),n}}else {let i=Ae__default.default({indent:1}).start(`Hydrating stepId: \`${t.stepId}\``);try{let n=e.state.find(a=>a.stepId===t.stepId);if(n){let a=await this.validate(n.outputs,t.results.unknownSchema,"step","result",e.workflowId,t.stepId);return i.stopAndPersist({symbol:_.HYDRATED,text:`Hydrated stepId: \`${t.stepId}\``}),{outputs:a,providers:await this.executeProviders(e,t,a)}}else throw new te(e.workflowId,t.stepId)}catch(n){throw i.stopAndPersist({symbol:_.ERROR,text:`Failed to hydrate stepId: \`${t.stepId}\``}),n}}}async compileControls(e,t){let i=this.templateEngine.parse(JSON.stringify(e)),n=await this.templateEngine.render(i,{...t.payload||t.data,subscriber:t.subscriber});return JSON.parse(n)}async createStepControls(e,t){let i=t.controls||t.inputs;return await this.validate(i,e.controls.unknownSchema,"step","controls",t.workflowId,e.stepId)}async previewStep(e,t){let i=Ae__default.default({indent:1}).start(`Previewing stepId: \`${t.stepId}\``);try{if(e.stepId===t.stepId){let n=await this.createStepControls(t,e),a=await this.compileControls(n,e),c=await t.resolve(a),p=await this.validate(c,t.outputs.unknownSchema,"step","output",e.workflowId,t.stepId);return i.stopAndPersist({symbol:_.MOCK,text:`Mocked stepId: \`${t.stepId}\``}),{outputs:p,providers:await this.executeProviders(e,t,p)}}else {let n=this.mock(t.results.schema);return i.stopAndPersist({symbol:_.MOCK,text:`Mocked stepId: \`${t.stepId}\``}),{outputs:n,providers:await this.executeProviders(e,t,n)}}}catch(n){throw i.stopAndPersist({symbol:_.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 B(e);return i}};function gt(r){return JSON.parse(JSON.stringify(r))}var Pe=class{frameworkName;handler;client;hmacEnabled;http;constructor(e){this.handler=e.handler,this.client=e.client?e.client:new G,this.client.addWorkflows(e.workflows),this.http=pe(this.client.secretKey),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","novu-framework-version":Z,"novu-framework-sdk":L,"novu-framework-server":this.frameworkName,"user-agent":e}}createResponse(e,t){return {status:e,body:JSON.stringify(t),headers:{...this.getStaticHeaders()}}}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")||"",a=t.searchParams.get("workflowId")||"",c=t.searchParams.get("stepId")||"",p=await e.headers("novu-signature")||await e.headers("x-novu-signature")||"",h={};try{i==="POST"&&(h=await e.body());}catch{}try{n!=="health-check"&&this.validateHmac(h,p);let y=this.getPostActionMap(h,a,c,n),w=this.getGetActionMap(a,c);if(i==="POST")return await this.handlePostAction(n,y);if(i==="GET")return await this.handleGetAction(n,w);if(i==="OPTIONS")return this.createResponse(200,{})}catch(y){return this.handleError(y)}return this.createError(new he(i))}getPostActionMap(e,t,i,n){return {trigger:this.triggerAction({workflowId:t,...e}),execute:async()=>{let a=await this.client.executeWorkflow({...e,workflowId:t,stepId:i,action:n});return this.createResponse(200,a)},preview:async()=>{let a=await this.client.executeWorkflow({...e,workflowId:t,stepId:i,action:n});return this.createResponse(200,a)}}}triggerAction(e){return async()=>{let t={name:e.workflowId,to:e.to,payload:e?.payload||{},transactionId:e.transactionId,overrides:e.overrides||{},...e.actor&&{actor:e.actor},...e.tenant&&{tenant:e.tenant},...e.bridgeUrl&&{bridgeUrl:e.bridgeUrl},...e.controls&&{controls:e.controls}},i=await this.http.post("/events/trigger",t);return this.createResponse(200,i)}}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(V).includes(e)){let i=t[e];return i()}else throw new W(e,V)}async handleGetAction(e,t){if(Object.values(X).includes(e)){let i=t[e];return i()}else throw new W(e,X)}isBridgeError(e){return Object.values(k).includes(e?.code)}isPlatformError(e){return e?.statusCode>=400&&e?.statusCode<500}handleError(e){return this.isBridgeError(e)?(e.statusCode===500&&console.error(e),this.createError(e)):this.isPlatformError(e)?this.createError(e):(console.error(e),this.createError(new $))}validateHmac(e,t){if(!this.hmacEnabled)return;if(!t)throw new ge;if(!this.client.secretKey)throw new we;let[i,n]=t.split(",");if(!i||!n)throw new _e;let[a,c]=i.split("="),[p,h]=n.split("=");if(Number(a)<Date.now()-1500)throw new be;if(!(this.hashHmac(this.client.secretKey,`${c}.${JSON.stringify(e)}`)===h))throw new ye}hashHmac(e,t){return crypto.createHmac("sha256",e).update(t).digest("hex")}};var l={output:{type:"object",properties:{},required:[],additionalProperties:!0}};var bt={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
28
|
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:!
|
|
28
|
-
Maximum number of items is 10.`}},required:["elements","type"],additionalProperties:!
|
|
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:!
|
|
30
|
-
There is a maximum of 25 elements in each action block.`}},required:["elements","type"],additionalProperties:!
|
|
29
|
+
Maximum length for the text in this field is 2000 characters.`}},required:["alt_text","image_url","type"],additionalProperties:!0,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:!0,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.
|
|
30
|
+
Maximum number of items is 10.`}},required:["elements","type"],additionalProperties:!0,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:!0,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.
|
|
31
|
+
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:!0,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.
|
|
32
|
+
There is a maximum of 25 elements in each action block.`}},required:["elements","type"],additionalProperties:!0,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
33
|
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:!
|
|
33
|
-
with.`}},additionalProperties:!
|
|
34
|
+
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:!0,description:"Allows users a direct path to performing basic actions."},Actionable:{type:"object",additionalProperties:!0,properties:{type:{type:"string"},action_id:{type:"string"}},required:["type"]},Action:{type:"object",properties:{type:{type:"string"},action_id:{type:"string"}},required:["type"],additionalProperties:!0},Confirmable:{type:"object",properties:{confirm:{$ref:"#/definitions/ConfirmationDialog",description:`A {@link Confirm } object that defines an optional confirmation dialog after the element is interacted
|
|
35
|
+
with.`}},additionalProperties:!0},ConfirmationDialog:{type:"object",additionalProperties:!0,properties:{title:{$ref:"#/definitions/PlainTextElement",description:`A {@link PlainTextElement } text object that defines the dialog's title.
|
|
34
36
|
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:!
|
|
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:!
|
|
37
|
+
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:!0,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
|
|
38
|
+
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:!0,description:"Allows users to choose multiple items from a list of options."},Focusable:{type:"object",properties:{focus_on_load:{type:"boolean"}},additionalProperties:!0},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
39
|
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
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.
|
|
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:!
|
|
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/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:!0},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
42
|
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:!
|
|
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:!
|
|
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:!
|
|
43
|
+
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:!0},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
|
|
44
|
+
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:!0,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:!0},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
|
|
45
|
+
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:!0,description:`Allows users to select both a date and a time of day, formatted as a Unix timestamp. On desktop
|
|
44
46
|
clients, this time picker will take the form of a dropdown list and the date picker will take the form of a dropdown
|
|
45
47
|
calendar. Both options will have free-text entry for precise choices. On mobile clients, the time picker and date
|
|
46
48
|
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.
|
|
@@ -49,79 +51,81 @@ part or all of an option string to filter the list.
|
|
|
49
51
|
There are different types of multi-select menu that depend on different data sources for their lists of options:
|
|
50
52
|
{@link MultiStaticSelect }, {@link MultiExternalSelect }, {@link MultiUsersSelect }, {@link MultiConversationsSelect },
|
|
51
53
|
{@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:!
|
|
54
|
+
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:!0,description:`This multi-select menu will populate its options with a list of Slack users visible to the current user
|
|
53
55
|
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:!
|
|
56
|
+
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:!0},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:!0,description:`This is the simplest form of select menu, with a static list of options passed in when defining the
|
|
55
57
|
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:!
|
|
58
|
+
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:!0,description:"A filter object that reduces the list of available conversations using the specified criteria."}},required:["type"],additionalProperties:!0,description:`This multi-select menu will populate its options with a list of public and private channels, DMs, and
|
|
57
59
|
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:!
|
|
60
|
+
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:!0,description:`This multi-select menu will populate its options with a list of public channels visible to the current
|
|
59
61
|
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:!
|
|
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:!
|
|
62
|
+
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:!0,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
|
|
63
|
+
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:!0,description:`Allows users to press a button to view a list of options.
|
|
62
64
|
Unlike the select menu, there is no typeahead field, and the button always appears with an ellipsis ("\u2026") rather
|
|
63
65
|
than customizable text. As such, it is usually used if you want a more compact layout than a select menu, or to
|
|
64
66
|
supply a list of less visually important actions after a row of buttons. You can also specify simple URL links as
|
|
65
67
|
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:!
|
|
68
|
+
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:!0,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
69
|
The select menu also includes type-ahead functionality, where a user can type a part or all of an option string to
|
|
68
70
|
filter the list. There are different types of select menu elements that depend on different data sources for their
|
|
69
71
|
lists of options: {@link StaticSelect }, {@link ExternalSelect }, {@link UsersSelect }, {@link ConversationsSelect },
|
|
70
72
|
{@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:!
|
|
73
|
+
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:!0,description:`This select menu will populate its options with a list of Slack users visible to the current user in the
|
|
72
74
|
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:!
|
|
75
|
+
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:!0},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:!0,description:`This is the simplest form of select menu, with a static list of options passed in when defining the
|
|
74
76
|
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:!
|
|
77
|
+
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:!0,description:"A filter object that reduces the list of available conversations using the specified criteria."}},required:["type"],additionalProperties:!0,description:`This select menu will populate its options with a list of public and private channels, DMs, and MPIMs
|
|
76
78
|
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:!
|
|
79
|
+
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:!0,description:`This select menu will populate its options with a list of public channels visible to the current user
|
|
78
80
|
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:!
|
|
81
|
+
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:!0,description:`This select menu will load its options from an external data source, allowing for a dynamic list of
|
|
80
82
|
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
83
|
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:!
|
|
84
|
+
text underneath the time picker. It is also passed to the app upon certain interactions, such as view_submission.`}},required:["type"],additionalProperties:!0,description:`Allows users to choose a time from a rich dropdown UI. On desktop clients, this time picker will take
|
|
83
85
|
the form of a dropdown list with free-text entry for precise choices. On mobile clients, the time picker will use
|
|
84
86
|
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
87
|
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
88
|
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:!
|
|
88
|
-
the provided trigger.`}},required:["url"],additionalProperties:!
|
|
89
|
-
same experience you have writing messages in Slack.`},Dispatchable:{type:"object",properties:{dispatch_action_config:{$ref:"#/definitions/DispatchActionConfig"}},additionalProperties:!
|
|
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:!
|
|
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:!
|
|
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:!
|
|
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:!
|
|
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:!
|
|
89
|
+
specified type for the matching workflow input parameter.`}},required:["name","value"],additionalProperties:!0},description:`List of customizable input parameters and their values. Should match input parameters specified on
|
|
90
|
+
the provided trigger.`}},required:["url"],additionalProperties:!0,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:!0,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:!0,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:!0,description:`A rich text input creates a composer/WYSIWYG editor for entering formatted text, offering nearly the
|
|
91
|
+
same experience you have writing messages in Slack.`},Dispatchable:{type:"object",properties:{dispatch_action_config:{$ref:"#/definitions/DispatchActionConfig"}},additionalProperties:!0},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:!0,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:!0},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:!0,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:!0},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:!0,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:!0}},additionalProperties:!0,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:!0},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:!0,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:!0},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:!0,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:!0},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:!0,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:!0},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:!0,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:!0,description:`A limited style object for styling rich text message elements
|
|
92
|
+
(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:!0,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:!0,description:`A limited style object for styling rich text message elements
|
|
93
|
+
(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:!0,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:!0,description:`A limited style object for styling rich text message elements
|
|
94
|
+
(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:!0,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:!0,description:`A limited style object for styling rich text message elements
|
|
95
|
+
(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:!0,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:!0,description:`A limited style object for styling rich text message elements
|
|
96
|
+
(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:!0,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:!0,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:!0,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:!0,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:!0},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:!0,description:`Displays text, possibly alongside block elements. A section can be used as a simple text block, in
|
|
95
97
|
combination with text fields, or side-by-side with certain
|
|
96
98
|
{@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:!
|
|
99
|
+
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:!0,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
100
|
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:!
|
|
101
|
+
they will receive an error.`}},required:["type"],additionalProperties:!0,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:!0,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:!0,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:!0,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:!0,description:`Displays a {@link https://api.slack.com/messaging/files/remote remote file}. You can't add this block to
|
|
100
102
|
app surfaces directly, but it will show up when {@link https://api.slack.com/messaging/retrieving retrieving messages}
|
|
101
103
|
that contain remote files. If you want to add remote files to messages,
|
|
102
104
|
{@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:!
|
|
105
|
+
Maximum length for the text in this field is 150 characters.`}},required:["text","type"],additionalProperties:!0,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
106
|
{@link https://api.slack.com/reference/messaging/link-unfurling#configuring_domains unfurl domains} within the app
|
|
105
107
|
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:!
|
|
107
|
-
${
|
|
108
|
+
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:!0,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:!0},Le={output:bt};var qe={[shared.ChatProviderIdEnum.Slack]:Le,[shared.ChatProviderIdEnum.Discord]:l,[shared.ChatProviderIdEnum.GetStream]:l,[shared.ChatProviderIdEnum.GrafanaOnCall]:l,[shared.ChatProviderIdEnum.Mattermost]:l,[shared.ChatProviderIdEnum.MsTeams]:l,[shared.ChatProviderIdEnum.RocketChat]:l,[shared.ChatProviderIdEnum.Ryver]:l,[shared.ChatProviderIdEnum.WhatsAppBusiness]:l,[shared.ChatProviderIdEnum.Zulip]:l};var wt={type:"object",properties:{},required:[],additionalProperties:!1},We={output:wt};var Be={[shared.EmailProviderIdEnum.SendGrid]:l,[shared.EmailProviderIdEnum.EmailJS]:l,[shared.EmailProviderIdEnum.Mailgun]:l,[shared.EmailProviderIdEnum.Mailjet]:l,[shared.EmailProviderIdEnum.Mandrill]:l,[shared.EmailProviderIdEnum.CustomSMTP]:l,[shared.EmailProviderIdEnum.Postmark]:l,[shared.EmailProviderIdEnum.Sendinblue]:l,[shared.EmailProviderIdEnum.SES]:l,[shared.EmailProviderIdEnum.NetCore]:l,[shared.EmailProviderIdEnum.Infobip]:l,[shared.EmailProviderIdEnum.Resend]:l,[shared.EmailProviderIdEnum.Plunk]:l,[shared.EmailProviderIdEnum.MailerSend]:l,[shared.EmailProviderIdEnum.Mailtrap]:l,[shared.EmailProviderIdEnum.Clickatell]:l,[shared.EmailProviderIdEnum.Outlook365]:l,[shared.EmailProviderIdEnum.Novu]:We,[shared.EmailProviderIdEnum.SparkPost]:l,[shared.EmailProviderIdEnum.EmailWebhook]:l,[shared.EmailProviderIdEnum.Braze]:l};var Tt={type:"object",properties:{},required:[],additionalProperties:!1},Ge={output:Tt};var Ke={[shared.InAppProviderIdEnum.Novu]:Ge};var Xe={[shared.PushProviderIdEnum.FCM]:l,[shared.PushProviderIdEnum.APNS]:l,[shared.PushProviderIdEnum.EXPO]:l,[shared.PushProviderIdEnum.OneSignal]:l,[shared.PushProviderIdEnum.PushWebhook]:l,[shared.PushProviderIdEnum.PusherBeams]:l,[shared.PushProviderIdEnum.Pushpad]:l};var kt={type:"object",properties:{},required:[],additionalProperties:!1},ze={output:kt};var Je={[shared.SmsProviderIdEnum.Twilio]:l,[shared.SmsProviderIdEnum.Termii]:l,[shared.SmsProviderIdEnum.Telnyx]:l,[shared.SmsProviderIdEnum.SNS]:l,[shared.SmsProviderIdEnum.Sms77]:l,[shared.SmsProviderIdEnum.SmsCentral]:l,[shared.SmsProviderIdEnum.Simpletexting]:l,[shared.SmsProviderIdEnum.Sendchamp]:l,[shared.SmsProviderIdEnum.RingCentral]:l,[shared.SmsProviderIdEnum.Plivo]:l,[shared.SmsProviderIdEnum.Nexmo]:l,[shared.SmsProviderIdEnum.Mobishastra]:l,[shared.SmsProviderIdEnum.MessageBird]:l,[shared.SmsProviderIdEnum.Maqsam]:l,[shared.SmsProviderIdEnum.Kannel]:l,[shared.SmsProviderIdEnum.ISendSms]:l,[shared.SmsProviderIdEnum.Infobip]:l,[shared.SmsProviderIdEnum.Gupshup]:l,[shared.SmsProviderIdEnum.GenericSms]:l,[shared.SmsProviderIdEnum.FortySixElks]:l,[shared.SmsProviderIdEnum.Firetext]:l,[shared.SmsProviderIdEnum.Clickatell]:l,[shared.SmsProviderIdEnum.BurstSms]:l,[shared.SmsProviderIdEnum.BrevoSms]:l,[shared.SmsProviderIdEnum.Bandwidth]:l,[shared.SmsProviderIdEnum.AzureSms]:l,[shared.SmsProviderIdEnum.AfricasTalking]:l,[shared.SmsProviderIdEnum.Novu]:ze,[shared.SmsProviderIdEnum.BulkSms]:l,[shared.SmsProviderIdEnum.Clicksend]:l,[shared.SmsProviderIdEnum.EazySms]:l};var Qe={chat:qe,sms:Je,email:Be,push:Xe,in_app:Ke};var Rt={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},St={type:"object",properties:{duration:{type:"number"}},required:["duration"],additionalProperties:!1},De={output:Rt,result:St};var Et={type:"object",properties:{amount:{type:"number"},unit:{type:"string",enum:["seconds","minutes","hours","days","weeks","months"]},digestKey:{type:"string"},lookBackWindow:{type:"object",properties:{amount:{type:"number"},unit:{type:"string",enum:["seconds","minutes","hours","days","weeks","months"]}},required:["amount","unit"],additionalProperties:!1}},required:["amount","unit"],additionalProperties:!1},At={type:"object",properties:{cron:{type:"string"},digestKey:{type:"string"}},required:["cron"],additionalProperties:!1},vt={oneOf:[Et,At]},Ot={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},Ne={output:vt,result:Ot};var It={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},Pt={type:"object",properties:{},required:[],additionalProperties:!1},Ze={output:It,result:Pt};var Dt={type:"object",properties:{subject:{type:"string"},body:{type:"string"}},required:["subject","body"],additionalProperties:!1},Nt={type:"object",properties:{},required:[],additionalProperties:!1},He={output:Dt,result:Nt};var Mt={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},Ct={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},et={output:Mt,result:Ct};var jt={type:"object",properties:{subject:{type:"string"},body:{type:"string"}},required:["subject","body"],additionalProperties:!1},$t={type:"object",properties:{},required:[],additionalProperties:!1},tt={output:jt,result:$t};var Ut={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},Yt={type:"object",properties:{},required:[],additionalProperties:!1},it={output:Ut,result:Yt};var S={chat:Ze,sms:it,push:tt,email:He,in_app:et};var T={type:"object",properties:{},required:[],additionalProperties:!1};function tr(r,e,t){let i=t||{},n=pe(process.env.NOVU_SECRET_KEY),a=async p=>{if(!process.env.NOVU_SECRET_KEY)throw new ue;p.payload;if(i.payloadSchema){let f=await Ee(i.payloadSchema,p.payload);if(f.success===!1)throw new ae(r,f.errors);f.data;}let y=await Ue(),w={name:r,to:p.to,payload:{...p?.payload},...p.transactionId&&{transactionId:p.transactionId},...p.overrides&&{overrides:p.overrides},...p.actor&&{actor:p.actor},...p.tenant&&{tenant:p.tenant},...y&&{bridgeUrl:y}},E=await n.post("/events/trigger",w);return {cancel:async()=>n.delete(`/events/trigger/${E.transactionId}`),data:E}},c={workflowId:r,options:{...i,inputSchema:b(i.controlSchema||i.inputSchema||T),controlSchema:b(i.controlSchema||i.inputSchema||T),payloadSchema:b(i.payloadSchema||T)},steps:[],code:e.toString(),data:{schema:b(i.payloadSchema||T),unknownSchema:i.payloadSchema||T},payload:{schema:b(i.payloadSchema||T),unknownSchema:i.payloadSchema||T},inputs:{schema:b(i.controlSchema||i.inputSchema||T),unknownSchema:i.controlSchema||i.inputSchema||T},controls:{schema:b(i.controlSchema||i.inputSchema||T),unknownSchema:i.controlSchema||i.inputSchema||T},execute:e};return e({payload:{},subscriber:{},environment:{},controls:{},step:{push:N(c,"push",S.push.output,S.push.result),chat:N(c,"chat",S.chat.output,S.chat.result),email:N(c,"email",S.email.output,S.email.result),sms:N(c,"sms",S.sms.output,S.sms.result),inApp:N(c,"in_app",S.in_app.output,S.in_app.result),digest:N(c,"digest",Ne.output,Ne.result),delay:N(c,"delay",De.output,De.result),custom:Vt(c,"custom")}}),Lt(c),{trigger:a,definition:c}}function N(r,e,t,i){return async(n,a,c={})=>{let p=c?.controlSchema||c?.inputSchema||T,h={stepId:n,type:e,inputs:{schema:b(p),unknownSchema:p},controls:{schema:b(p),unknownSchema:p},outputs:{schema:b(t),unknownSchema:t},results:{schema:b(i),unknownSchema:i},resolve:a,code:a.toString(),options:c,providers:[]};ot(r,n,h),Object.values(P).includes(e)&&Object.keys(c.providers||{}).length>0&&Ft(h,e,c.providers||{});}}function ot(r,e,t){if(r.steps.some(i=>i.stepId===e))throw new xe(e);r.steps.push(t);}function Ft(r,e,t){let i=Qe[e];Object.entries(t).forEach(([n,a])=>{let c=i[n];r.providers.push({type:n,code:a.toString(),resolve:a,outputs:{schema:b(c.output),unknownSchema:c.output}});});}function Vt(r,e){return async(t,i,n={})=>{let a=n?.controlSchema||n?.inputSchema||T,c=n?.outputSchema||T;ot(r,t,{stepId:t,type:e,inputs:{schema:b(a),unknownSchema:a},controls:{schema:b(a),unknownSchema:a},outputs:{schema:b(c),unknownSchema:c},results:{schema:b(c),unknownSchema:c},resolve:i,code:i.toString(),options:n,providers:[]});}}function Lt(r){console.log(`
|
|
109
|
+
${u.bold(u.underline("Discovered workflowId:"))} '${r.workflowId}'`),r.steps.forEach((e,t)=>{let i=t===r.steps.length-1?"\u2514":"\u251C";console.log(`${i} ${_.STEP} Discovered stepId: '${e.stepId}' Type: '${e.type}'`),e.providers.forEach((n,a)=>{let c=a===e.providers.length-1?"\u2514":"\u251C";console.log(` ${c} ${_.PROVIDER} Discovered provider: '${n.type}'`);});});}var qt=(y=>(y.PENDING="pending",y.QUEUED="queued",y.RUNNING="running",y.COMPLETED="completed",y.FAILED="failed",y.DELAYED="delayed",y.CANCELED="canceled",y.MERGED="merged",y.SKIPPED="skipped",y))(qt||{});
|
|
108
110
|
|
|
109
|
-
exports.ActionStepEnum =
|
|
110
|
-
exports.ChannelStepEnum =
|
|
111
|
-
exports.Client =
|
|
112
|
-
exports.CronExpression =
|
|
113
|
-
exports.ErrorCodeEnum =
|
|
114
|
-
exports.
|
|
115
|
-
exports.
|
|
116
|
-
exports.
|
|
117
|
-
exports.
|
|
118
|
-
exports.
|
|
119
|
-
exports.
|
|
120
|
-
exports.
|
|
121
|
-
exports.
|
|
122
|
-
exports.
|
|
123
|
-
exports.
|
|
124
|
-
exports.
|
|
125
|
-
exports.
|
|
126
|
-
exports.
|
|
127
|
-
exports.
|
|
111
|
+
exports.ActionStepEnum = lt;
|
|
112
|
+
exports.ChannelStepEnum = P;
|
|
113
|
+
exports.Client = G;
|
|
114
|
+
exports.CronExpression = at;
|
|
115
|
+
exports.ErrorCodeEnum = k;
|
|
116
|
+
exports.FRAMEWORK_VERSION = Z;
|
|
117
|
+
exports.GetActionEnum = X;
|
|
118
|
+
exports.HttpHeaderKeysEnum = ve;
|
|
119
|
+
exports.HttpMethodEnum = z;
|
|
120
|
+
exports.HttpQueryKeysEnum = je;
|
|
121
|
+
exports.HttpStatusEnum = J;
|
|
122
|
+
exports.JobStatusEnum = qt;
|
|
123
|
+
exports.NovuApiEndpointsEnum = st;
|
|
124
|
+
exports.NovuRequestHandler = Pe;
|
|
125
|
+
exports.PostActionEnum = V;
|
|
126
|
+
exports.RETRYABLE_ERROR_STATUS_CODES = ei;
|
|
127
|
+
exports.ResourceEnum = Q;
|
|
128
|
+
exports.SDK_VERSION = L;
|
|
129
|
+
exports.SIGNATURE_TIMESTAMP_TOLERANCE = Ce;
|
|
130
|
+
exports.SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES = Me;
|
|
131
|
+
exports.workflow = tr;
|