Socket
Socket
Sign inDemoInstall

@reuters-graphics/teams-klaxon

Package Overview
Dependencies
Maintainers
5
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reuters-graphics/teams-klaxon - npm Package Compare versions

Comparing version 0.0.3 to 1.0.0-next.1

dist/elements.d.ts

3313

dist/index.js

@@ -1,142 +0,3197 @@

'use strict';
import Ajv from 'ajv';
import addFormats from 'ajv-formats';
import axios from 'axios';
var Ajv = require('ajv');
var axios = require('axios');
var stripEmoji = require('emoji-strip');
/**
* @example
* ```javascript
* import { Elements } from '@reuters-graphics/teams-klaxons';
*
* Elements.TextBlock('👋 Hello _world_!');
* ```
*
* @param text Markdown-friendly string.
* @param options Additional {@link types.TextBlock TextBlock} options
*/
const TextBlock = (text, options) => {
return {
type: 'TextBlock',
text,
...(options || {}),
};
};
/**
* @example
* ```javascript
* import { Elements } from '@reuters-graphics/teams-klaxons';
*
* Elements.Fact('name', 'Jane Doe');
* ```
*
* **Note:** Use this within a {@link FactSet}, not on its own.
*
* @param title Title
* @param value Markdown-friendly value
*/
const Fact = (title, value) => {
return {
title,
value,
};
};
/**
* @example
* ```javascript
* import { Elements } from '@reuters-graphics/teams-klaxons';
*
* Elements.FactSet([
* Elements.Fact('name', 'Jane Doe'),
* Elements.Fact('age', '33'),
* ]);
* ```
* @param facts Facts
* @param options Additional {@link types.FactSet FactSet} options
*/
const FactSet = (facts, options) => {
return {
type: 'FactSet',
facts,
...(options || {}),
};
};
/**
* @example
* ```javascript
* import { Elements } from '@reuters-graphics/teams-klaxons';
*
* Elements.Image('https://.../image.jpg');
* ```
*
* @param url The image's URL
* @param openUrl A URL to open when the image is clicked
* @param options Additional {@link types.Image Image} options
*/
const Image = (url, openUrl, options) => {
return {
type: 'Image',
url,
selectAction: openUrl ? ActionOpenUrl(openUrl, 'Open') : undefined,
...(options || {}),
};
};
/**
* @example
* ```javascript
* import { Elements } from '@reuters-graphics/teams-klaxons';
*
* Elements.ImageSet([
* Elements.Image('https://...'),
* Elements.Image('https://...'),
* ]);
* ```
*
* @param images Array of images
* @param options Addition {@link types.ImageSet ImageSet} options
*/
const ImageSet = (images, options) => {
return {
type: 'ImageSet',
images,
...(options || {}),
};
};
/**
* @example
* ```javascript
* import { Elements } from '@reuters-graphics/teams-klaxons';
*
* Elements.ActionOpenUrl('https://...', 'My site');
* ```
*
* **Note:** Use this element within an {@link ActionSet}, not on its own.
*
* @param url URL of link to open
* @param title Title of the link
*/
const ActionOpenUrl = (url, title) => {
return {
type: 'Action.OpenUrl',
url,
title,
};
};
/**
* @example
* ```javascript
* import { Elements } from '@reuters-graphics/teams-klaxons';
*
* Elements.ActionSet([
* Elements.ActionOpenUrl('https://...', 'My site'),
* Elements.ActionOpenUrl('https://...', 'My other site'),
* ]);
* ```
* @param actions Actions
* @param options Additional {@link types.ActionSet ActionSet} options
*/
const ActionSet = (actions, options) => {
return {
type: 'ActionSet',
actions,
...(options || {}),
};
};
/**
* @example
* ```javascript
* import { Elements } from '@reuters-graphics/teams-klaxons';
*
* const backgroundImage = Elements.BackgroundImage('https://.../image.jpg');
*
* Elements.Container([
* Element.TextBox('Hello'),
* ], { backgroundImage });
* ```
*
* **Note:** Use this element within a {@link Container}, not on its own.
*
* @param url Image URL
* @param options Addition {@link types.BackgroundImage BackgroundImage} options
*/
const BackgroundImage = (url, options) => {
return {
url,
...(options || {}),
};
};
/**
* @example
* ```javascript
* import { Elements } from '@reuters-graphics/teams-klaxons';
*
* Elements.Container([
* Element.TextBox('Hello'),
* ], { minHeight: '60px' });
* ```
*
* @param items Content items
* @param options Additional {@link types.Container Container} options
*/
const Container = (items, options) => {
return {
type: 'Container',
items,
...(options || {}),
};
};
/**
* @example
* ```javascript
* import { Elements } from '@reuters-graphics/teams-klaxons';
*
* Elements.Column([
* Element.FactSet([
* Element.Fact('Name', 'Bot'),
* Element.Fact('Age', '23'),
* ]),
* ]);
* ```
*
* **Note:** Use this element within a {@link ColumnSet}, not on its own.
*
* @param items Content items
* @param options Additional {@link types.Column Column} options
*/
const Column = (items, options) => {
return {
type: 'Column',
items,
...(options || {}),
};
};
/**
* @example
* ```javascript
* import { Elements } from '@reuters-graphics/teams-klaxons';
*
* const column1 = Elements.Column([
* Elements.Image('https://.../image.jpg');
* ], { width: '50px' });
*
* const column2 = Elements.Column([
* Element.TextBox('Jane Doe'),
* ]);
*
* Elements.ColumnSet([
* column1,
* column2,
* ]);
* ```
* @param columns {@link Column Columns}
* @param options Additional {@link types.ColumnSet ColumnSet} options
* @returns
*/
const ColumnSet = (columns, options) => {
return {
type: 'ColumnSet',
columns,
...(options || {}),
};
};
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv);
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
var stripEmoji__default = /*#__PURE__*/_interopDefaultLegacy(stripEmoji);
var getFacts = (facts) => ({
facts: Object.keys(facts).map((name) => ({
name,
value: facts[name],
})),
var elements = /*#__PURE__*/Object.freeze({
__proto__: null,
ActionOpenUrl: ActionOpenUrl,
ActionSet: ActionSet,
BackgroundImage: BackgroundImage,
Column: Column,
ColumnSet: ColumnSet,
Container: Container,
Fact: Fact,
FactSet: FactSet,
Image: Image,
ImageSet: ImageSet,
TextBlock: TextBlock
});
var getImages = (images) => ({
images: images.map(image => ({ image })),
});
var getLinkButtons = (linkButtons) => linkButtons.map(linkButton => ({
'@type': 'OpenUri',
name: linkButton.name,
targets: [
{
os: 'default',
uri: linkButton.link,
},
],
}));
var getStackTrace = (stackTrace) => {
return {
activityImage: 'http://icons.iconarchive.com/icons/thehoth/seo/256/seo-web-code-icon.png',
activityTitle: stackTrace.title || 'Stack trace',
activityText: `\`${stackTrace.code}\``,
};
var $schema$1 = "http://json-schema.org/draft-06/schema#";
var $id$1 = "http://adaptivecards.io/schemas/adaptive-card.json";
var definitions$1 = {
"Action.OpenUrl": {
description: "When invoked, show the given url either by launching it in an external web browser or showing within an embedded web browser.",
properties: {
type: {
"enum": [
"Action.OpenUrl"
],
description: "Must be `Action.OpenUrl`"
},
url: {
type: "string",
format: "uri-reference",
description: "The URL to open."
},
title: {
},
iconUrl: {
},
style: {
},
fallback: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
required: [
"url"
],
allOf: [
{
$ref: "#/definitions/Extendable.Action"
}
]
},
"Action.ShowCard": {
description: "Defines an AdaptiveCard which is shown to the user when the button or link is clicked.",
properties: {
type: {
"enum": [
"Action.ShowCard"
],
description: "Must be `Action.ShowCard`"
},
card: {
$ref: "#/definitions/AdaptiveCard",
description: "The Adaptive Card to show."
},
title: {
},
iconUrl: {
},
style: {
},
fallback: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
allOf: [
{
$ref: "#/definitions/Extendable.Action"
}
]
},
"Action.Submit": {
description: "Gathers input fields, merges with optional data field, and sends an event to the client. It is up to the client to determine how this data is processed. For example: With BotFramework bots, the client would send an activity through the messaging medium to the bot.",
properties: {
type: {
"enum": [
"Action.Submit"
],
description: "Must be `Action.Submit`"
},
data: {
anyOf: [
{
type: "string"
},
{
type: "object"
}
],
description: "Initial data that input fields will be combined with. These are essentially ‘hidden’ properties."
},
title: {
},
iconUrl: {
},
style: {
},
fallback: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
allOf: [
{
$ref: "#/definitions/Extendable.Action"
}
]
},
"Action.ToggleVisibility": {
description: "An action that toggles the visibility of associated card elements.",
version: "1.2",
properties: {
type: {
"enum": [
"Action.ToggleVisibility"
],
description: "Must be `Action.ToggleVisibility`"
},
targetElements: {
type: "array",
items: {
$ref: "#/definitions/TargetElement"
},
description: "The array of TargetElements"
},
title: {
},
iconUrl: {
},
style: {
},
fallback: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
allOf: [
{
$ref: "#/definitions/Extendable.Action"
}
]
},
TargetElement: {
description: "Represents an entry for Action.ToggleVisibility's targetElements property",
anyOf: [
{
type: "string",
description: "Element ID of element to toggle"
},
{
type: "object",
properties: {
type: {
"enum": [
"TargetElement"
],
description: "Must be `TargetElement`"
},
elementId: {
type: "string",
description: "Element ID of element to toggle"
},
isVisible: {
anyOf: [
{
type: "boolean"
},
{
type: "null"
}
],
description: "If `true`, always show target element. If `false`, always hide target element. If not supplied, toggle target element's visibility. "
}
},
required: [
"elementId"
],
additionalProperties: false
}
]
},
AdaptiveCard: {
description: "An Adaptive Card",
properties: {
type: {
"enum": [
"AdaptiveCard"
],
description: "Must be `AdaptiveCard`"
},
version: {
type: "string",
description: "Schema version that this card requires. If a client is **lower** than this version, the `fallbackText` will be rendered. NOTE: Version is not required for cards within an `Action.ShowCard`. However, it *is* required for the top-level card.",
examples: [
"1.0",
"1.1",
"1.2"
]
},
body: {
type: "array",
items: {
$ref: "#/definitions/ImplementationsOf.Element"
},
description: "The card elements to show in the primary card region."
},
actions: {
type: "array",
items: {
$ref: "#/definitions/ImplementationsOf.Action"
},
description: "The Actions to show in the card's action bar."
},
selectAction: {
$ref: "#/definitions/ImplementationsOf.ISelectAction",
description: "An Action that will be invoked when the card is tapped or selected. `Action.ShowCard` is not supported.",
version: "1.1"
},
style: {
$ref: "#/definitions/ContainerStyle",
description: "Style hint for the Adaptive Card.",
version: "1.2"
},
fallbackText: {
type: "string",
description: "Text shown when the client doesn't support the version specified (may contain markdown)."
},
backgroundImage: {
anyOf: [
{
$ref: "#/definitions/BackgroundImage"
},
{
type: "string",
format: "uri-reference",
description: "The URL (or data url) to use as the background image. Supports data URI in version 1.2+",
version: "1.0"
}
],
description: "Specifies the background image of the card.",
version: "1.2"
},
minHeight: {
type: "string",
description: "Specifies the minimum height of the card.",
examples: [
"50px"
],
version: "1.2",
features: [
2293
]
},
speak: {
type: "string",
description: "Specifies what should be spoken for this entire card. This is simple text or SSML fragment."
},
lang: {
type: "string",
description: "The 2-letter ISO-639-1 language used in the card. Used to localize any date/time functions.",
examples: [
"en",
"fr",
"es"
]
},
verticalContentAlignment: {
$ref: "#/definitions/VerticalContentAlignment",
description: "Defines how the content should be aligned vertically within the container. Only relevant for fixed-height cards, or cards with a `minHeight` specified.",
version: "1.1"
},
$schema: {
type: "string",
format: "uri",
description: "The Adaptive Card schema."
}
},
type: "object",
additionalProperties: false
},
ActionSet: {
description: "Displays a set of actions.",
properties: {
type: {
"enum": [
"ActionSet"
],
description: "Must be `ActionSet`"
},
actions: {
type: "array",
items: {
$ref: "#/definitions/ImplementationsOf.Action"
},
description: "The array of `Image` elements to show."
},
fallback: {
},
height: {
},
separator: {
},
spacing: {
},
id: {
},
isVisible: {
},
requires: {
}
},
version: "1.2",
type: "object",
additionalProperties: false,
required: [
"actions"
],
allOf: [
{
$ref: "#/definitions/Extendable.Element"
}
]
},
Column: {
description: "Defines a container that is part of a ColumnSet.",
properties: {
type: {
"enum": [
"Column"
],
description: "Must be `Column`"
},
items: {
type: "array",
items: {
$ref: "#/definitions/ImplementationsOf.Element"
},
description: "The card elements to render inside the `Column`."
},
backgroundImage: {
anyOf: [
{
$ref: "#/definitions/BackgroundImage"
},
{
type: "string",
format: "uri-reference",
description: "The URL (or data url) to use as the background image. Supports data URI."
}
],
description: "Specifies the background image.",
version: "1.2"
},
bleed: {
type: "boolean",
description: "Determines whether the column should bleed through its parent's padding.",
version: "1.2",
features: [
2109
]
},
fallback: {
anyOf: [
{
$ref: "#/definitions/Column"
},
{
$ref: "#/definitions/FallbackOption"
}
],
description: "Describes what to do when an unknown item is encountered or the requires of this or any children can't be met.",
version: "1.2"
},
minHeight: {
type: "string",
description: "Specifies the minimum height of the column in pixels, like `\"80px\"`.",
examples: [
"50px"
],
version: "1.2",
features: [
2293
]
},
separator: {
type: "boolean",
description: "When `true`, draw a separating line between this column and the previous column."
},
spacing: {
$ref: "#/definitions/Spacing",
description: "Controls the amount of spacing between this column and the preceding column."
},
selectAction: {
$ref: "#/definitions/ImplementationsOf.ISelectAction",
description: "An Action that will be invoked when the `Column` is tapped or selected. `Action.ShowCard` is not supported.",
version: "1.1"
},
style: {
anyOf: [
{
$ref: "#/definitions/ContainerStyle"
},
{
type: "null"
}
],
description: "Style hint for `Column`."
},
verticalContentAlignment: {
$ref: "#/definitions/VerticalContentAlignment",
description: "Defines how the content should be aligned vertically within the column.",
"default": "top",
version: "1.1"
},
width: {
anyOf: [
{
type: "string"
},
{
type: "number"
}
],
description: "`\"auto\"`, `\"stretch\"`, a number representing relative width of the column in the column group, or in version 1.1 and higher, a specific pixel width, like `\"50px\"`."
},
id: {
},
isVisible: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
allOf: [
{
$ref: "#/definitions/Extendable.ToggleableItem"
}
]
},
ColumnSet: {
description: "ColumnSet divides a region into Columns, allowing elements to sit side-by-side.",
properties: {
type: {
"enum": [
"ColumnSet"
],
description: "Must be `ColumnSet`"
},
columns: {
type: "array",
items: {
$ref: "#/definitions/Column"
},
description: "The array of `Columns` to divide the region into."
},
selectAction: {
$ref: "#/definitions/ImplementationsOf.ISelectAction",
description: "An Action that will be invoked when the `ColumnSet` is tapped or selected. `Action.ShowCard` is not supported.",
version: "1.1"
},
style: {
anyOf: [
{
$ref: "#/definitions/ContainerStyle"
},
{
type: "null"
}
],
description: "Style hint for `ColumnSet`.",
version: "1.2"
},
bleed: {
type: "boolean",
description: "Determines whether the element should bleed through its parent's padding.",
version: "1.2",
features: [
2109
]
},
backgroundImage: {
anyOf: [
{
$ref: "#/definitions/BackgroundImage"
},
{
type: "string",
format: "uri-reference",
description: "The URL (or data url) to use as the background image. Supports data URI."
}
],
description: "Specifies the background image.",
version: "1.2"
},
minHeight: {
type: "string",
description: "Specifies the minimum height of the column set in pixels, like `\"80px\"`.",
examples: [
"50px"
],
version: "1.2",
features: [
2293
]
},
fallback: {
},
height: {
},
separator: {
},
spacing: {
},
id: {
},
isVisible: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
allOf: [
{
$ref: "#/definitions/Extendable.Element"
}
]
},
Container: {
description: "Containers group items together.",
properties: {
type: {
"enum": [
"Container"
],
description: "Must be `Container`"
},
items: {
type: "array",
items: {
$ref: "#/definitions/ImplementationsOf.Element"
},
description: "The card elements to render inside the `Container`."
},
selectAction: {
$ref: "#/definitions/ImplementationsOf.ISelectAction",
description: "An Action that will be invoked when the `Container` is tapped or selected. `Action.ShowCard` is not supported.",
version: "1.1"
},
style: {
anyOf: [
{
$ref: "#/definitions/ContainerStyle"
},
{
type: "null"
}
],
description: "Style hint for `Container`."
},
verticalContentAlignment: {
$ref: "#/definitions/VerticalContentAlignment",
description: "Defines how the content should be aligned vertically within the container.",
"default": "top",
version: "1.1"
},
bleed: {
type: "boolean",
description: "Determines whether the element should bleed through its parent's padding.",
version: "1.2",
features: [
2109
]
},
backgroundImage: {
anyOf: [
{
$ref: "#/definitions/BackgroundImage"
},
{
type: "string",
format: "uri-reference",
description: "The URL (or data url) to use as the background image. Supports data URI."
}
],
description: "Specifies the background image.",
version: "1.2"
},
minHeight: {
type: "string",
description: "Specifies the minimum height of the container in pixels, like `\"80px\"`.",
examples: [
"50px"
],
version: "1.2",
features: [
2293
]
},
fallback: {
},
height: {
},
separator: {
},
spacing: {
},
id: {
},
isVisible: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
required: [
"items"
],
allOf: [
{
$ref: "#/definitions/Extendable.Element"
}
]
},
Fact: {
description: "Describes a Fact in a FactSet as a key/value pair.",
properties: {
type: {
"enum": [
"Fact"
],
description: "Must be `Fact`"
},
title: {
type: "string",
description: "The title of the fact."
},
value: {
type: "string",
description: "The value of the fact."
}
},
type: "object",
additionalProperties: false,
required: [
"title",
"value"
]
},
FactSet: {
description: "The FactSet element displays a series of facts (i.e. name/value pairs) in a tabular form.",
properties: {
type: {
"enum": [
"FactSet"
],
description: "Must be `FactSet`"
},
facts: {
type: "array",
items: {
$ref: "#/definitions/Fact"
},
description: "The array of `Fact`'s."
},
fallback: {
},
height: {
},
separator: {
},
spacing: {
},
id: {
},
isVisible: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
required: [
"facts"
],
allOf: [
{
$ref: "#/definitions/Extendable.Element"
}
]
},
Image: {
description: "Displays an image.",
properties: {
type: {
"enum": [
"Image"
],
description: "Must be `Image`"
},
url: {
type: "string",
format: "uri-reference",
description: "The URL to the image. Supports data URI in version 1.2+"
},
altText: {
type: "string",
description: "Alternate text describing the image."
},
backgroundColor: {
type: "string",
description: "Applies a background to a transparent image. This property will respect the image style.",
example: "#DDDDDD",
version: "1.1"
},
height: {
anyOf: [
{
type: "string"
},
{
$ref: "#/definitions/BlockElementHeight"
}
],
description: "The desired height of the image. If specified as a pixel value, ending in 'px', E.g., 50px, the image will distort to fit that exact height. This overrides the `size` property.",
examples: [
"50px"
],
"default": "auto",
version: "1.1"
},
horizontalAlignment: {
$ref: "#/definitions/HorizontalAlignment",
description: "Controls how this element is horizontally positioned within its parent."
},
selectAction: {
$ref: "#/definitions/ImplementationsOf.ISelectAction",
description: "An Action that will be invoked when the `Image` is tapped or selected. `Action.ShowCard` is not supported.",
version: "1.1"
},
size: {
$ref: "#/definitions/ImageSize",
description: "Controls the approximate size of the image. The physical dimensions will vary per host."
},
style: {
$ref: "#/definitions/ImageStyle",
description: "Controls how this `Image` is displayed."
},
width: {
type: "string",
description: "The desired on-screen width of the image, ending in 'px'. E.g., 50px. This overrides the `size` property.",
examples: [
"50px"
],
version: "1.1"
},
fallback: {
anyOf: [
{
$ref: "#/definitions/ImplementationsOf.Element"
},
{
$ref: "#/definitions/FallbackOption"
}
],
description: "Describes what to do when an unknown element is encountered or the requires of this or any children can't be met.",
version: "1.2"
},
separator: {
type: "boolean",
description: "When `true`, draw a separating line at the top of the element."
},
spacing: {
$ref: "#/definitions/Spacing",
description: "Controls the amount of spacing between this element and the preceding element."
},
id: {
type: "string",
description: "A unique identifier associated with the item."
},
isVisible: {
type: "boolean",
description: "If `false`, this item will be removed from the visual tree.",
"default": true,
version: "1.2"
},
requires: {
type: "object",
additionalProperties: {
type: "string"
},
description: "A series of key/value pairs indicating features that the item requires with corresponding minimum version. When a feature is missing or of insufficient version, fallback is triggered.",
version: "1.2"
}
},
type: "object",
additionalProperties: false,
required: [
"url"
]
},
ImageSet: {
description: "The ImageSet displays a collection of Images similar to a gallery.",
properties: {
type: {
"enum": [
"ImageSet"
],
description: "Must be `ImageSet`"
},
images: {
type: "array",
items: {
$ref: "#/definitions/Image"
},
description: "The array of `Image` elements to show."
},
imageSize: {
$ref: "#/definitions/ImageSize",
description: "Controls the approximate size of each image. The physical dimensions will vary per host."
},
fallback: {
},
height: {
},
separator: {
},
spacing: {
},
id: {
},
isVisible: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
required: [
"images"
],
allOf: [
{
$ref: "#/definitions/Extendable.Element"
}
]
},
TextRun: {
description: "Defines a single run of formatted text",
version: "1.2",
anyOf: [
{
type: "string",
description: "Text to display"
},
{
type: "object",
properties: {
type: {
"enum": [
"TextRun"
],
description: "Must be `TextRun`"
},
text: {
type: "string",
description: "Text to display"
},
color: {
$ref: "#/definitions/Colors",
description: "Controls the color of the text."
},
fontType: {
$ref: "#/definitions/FontType",
description: "The type of font to use"
},
highlight: {
type: "boolean",
description: "If `true`, displays the text highlighted."
},
isSubtle: {
type: "boolean",
description: "If `true`, displays text slightly toned down to appear less prominent.",
"default": false
},
italic: {
type: "boolean",
description: "If `true`, displays the text using italic font."
},
selectAction: {
$ref: "#/definitions/ImplementationsOf.ISelectAction",
description: "Action to invoke when this text run is clicked. Visually changes the text run into a hyperlink. `Action.ShowCard` is not supported."
},
size: {
$ref: "#/definitions/FontSize",
description: "Controls size of text."
},
strikethrough: {
type: "boolean",
description: "If `true`, displays the text with strikethrough."
},
weight: {
$ref: "#/definitions/FontWeight",
description: "Controls the weight of the text."
}
},
required: [
"text"
],
additionalProperties: false
}
]
},
"Input.Choice": {
description: "Describes a choice for use in a ChoiceSet.",
properties: {
type: {
"enum": [
"Input.Choice"
],
description: "Must be `Input.Choice`"
},
title: {
type: "string",
description: "Text to display."
},
value: {
type: "string",
description: "The raw value for the choice. **NOTE:** do not use a `,` in the value, since a `ChoiceSet` with `isMultiSelect` set to `true` returns a comma-delimited string of choice values."
}
},
type: "object",
additionalProperties: false,
required: [
"title",
"value"
]
},
"Input.ChoiceSet": {
description: "Allows a user to input a Choice.",
properties: {
type: {
"enum": [
"Input.ChoiceSet"
],
description: "Must be `Input.ChoiceSet`"
},
choices: {
type: "array",
items: {
$ref: "#/definitions/Input.Choice"
},
description: "`Choice` options."
},
isMultiSelect: {
type: "boolean",
description: "Allow multiple choices to be selected.",
"default": false
},
style: {
$ref: "#/definitions/ChoiceInputStyle"
},
value: {
type: "string",
description: "The initial choice (or set of choices) that should be selected. For multi-select, specify a comma-separated string of values."
},
wrap: {
type: "boolean",
description: "If `true`, allow text to wrap. Otherwise, text is clipped.",
version: "1.2"
},
id: {
},
fallback: {
},
height: {
},
separator: {
},
spacing: {
},
isVisible: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
required: [
"choices"
],
allOf: [
{
$ref: "#/definitions/Extendable.Input"
}
]
},
"Input.Date": {
description: "Lets a user choose a date.",
properties: {
type: {
"enum": [
"Input.Date"
],
description: "Must be `Input.Date`"
},
max: {
type: "string",
description: "Hint of maximum value expressed in ISO-8601 format (may be ignored by some clients)."
},
min: {
type: "string",
description: "Hint of minimum value expressed in ISO-8601 format (may be ignored by some clients)."
},
placeholder: {
type: "string",
description: "Description of the input desired. Displayed when no selection has been made."
},
value: {
type: "string",
description: "The initial value for this field expressed in ISO-8601 format."
},
id: {
},
fallback: {
},
height: {
},
separator: {
},
spacing: {
},
isVisible: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
allOf: [
{
$ref: "#/definitions/Extendable.Input"
}
]
},
"Input.Number": {
description: "Allows a user to enter a number.",
properties: {
type: {
"enum": [
"Input.Number"
],
description: "Must be `Input.Number`"
},
max: {
type: "number",
description: "Hint of maximum value (may be ignored by some clients)."
},
min: {
type: "number",
description: "Hint of minimum value (may be ignored by some clients)."
},
placeholder: {
type: "string",
description: "Description of the input desired. Displayed when no selection has been made."
},
value: {
type: "number",
description: "Initial value for this field."
},
id: {
},
fallback: {
},
height: {
},
separator: {
},
spacing: {
},
isVisible: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
allOf: [
{
$ref: "#/definitions/Extendable.Input"
}
]
},
"Input.Text": {
description: "Lets a user enter text.",
properties: {
type: {
"enum": [
"Input.Text"
],
description: "Must be `Input.Text`"
},
isMultiline: {
type: "boolean",
description: "If `true`, allow multiple lines of input.",
"default": false
},
maxLength: {
type: "number",
description: "Hint of maximum length characters to collect (may be ignored by some clients)."
},
placeholder: {
type: "string",
description: "Description of the input desired. Displayed when no text has been input."
},
style: {
$ref: "#/definitions/TextInputStyle"
},
inlineAction: {
$ref: "#/definitions/ImplementationsOf.ISelectAction",
description: "The inline action for the input. Typically displayed to the right of the input. It is strongly recommended to provide an icon on the action (which will be displayed instead of the title of the action).",
version: "1.2"
},
value: {
type: "string",
description: "The initial value for this field."
},
id: {
},
fallback: {
},
height: {
},
separator: {
},
spacing: {
},
isVisible: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
allOf: [
{
$ref: "#/definitions/Extendable.Input"
}
]
},
"Input.Time": {
description: "Lets a user select a time.",
properties: {
type: {
"enum": [
"Input.Time"
],
description: "Must be `Input.Time`"
},
max: {
type: "string",
description: "Hint of maximum value (may be ignored by some clients)."
},
min: {
type: "string",
description: "Hint of minimum value (may be ignored by some clients)."
},
placeholder: {
type: "string",
description: "Description of the input desired. Displayed when no time has been selected."
},
value: {
type: "string",
description: "The initial value for this field expressed in ISO-8601 format."
},
id: {
},
fallback: {
},
height: {
},
separator: {
},
spacing: {
},
isVisible: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
allOf: [
{
$ref: "#/definitions/Extendable.Input"
}
]
},
"Input.Toggle": {
description: "Lets a user choose between two options.",
properties: {
type: {
"enum": [
"Input.Toggle"
],
description: "Must be `Input.Toggle`"
},
title: {
type: "string",
description: "Title for the toggle"
},
value: {
type: "string",
description: "The current selected value. If the item is selected then \"valueOn\" will be used, otherwise \"valueOff\" will be used.",
"default": "false"
},
valueOff: {
type: "string",
description: "The value when toggle is off",
"default": "false"
},
valueOn: {
type: "string",
description: "The value when toggle is on",
"default": "true"
},
wrap: {
type: "boolean",
description: "If `true`, allow text to wrap. Otherwise, text is clipped.",
version: "1.2"
},
id: {
},
fallback: {
},
height: {
},
separator: {
},
spacing: {
},
isVisible: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
required: [
"title"
],
allOf: [
{
$ref: "#/definitions/Extendable.Input"
}
]
},
Media: {
description: "Displays a media player for audio or video content.",
version: "1.1",
features: [
196
],
properties: {
type: {
"enum": [
"Media"
],
description: "Must be `Media`"
},
sources: {
type: "array",
items: {
$ref: "#/definitions/MediaSource"
},
description: "Array of media sources to attempt to play."
},
poster: {
type: "string",
format: "uri-reference",
description: "URL of an image to display before playing. Supports data URI in version 1.2+"
},
altText: {
type: "string",
description: "Alternate text describing the audio or video."
},
fallback: {
},
height: {
},
separator: {
},
spacing: {
},
id: {
},
isVisible: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
required: [
"sources"
],
allOf: [
{
$ref: "#/definitions/Extendable.Element"
}
]
},
MediaSource: {
description: "Defines a source for a Media element",
version: "1.1",
features: [
196
],
properties: {
type: {
"enum": [
"MediaSource"
],
description: "Must be `MediaSource`"
},
mimeType: {
type: "string",
description: "Mime type of associated media (e.g. `\"video/mp4\"`)."
},
url: {
type: "string",
format: "uri-reference",
description: "URL to media. Supports data URI in version 1.2+"
}
},
type: "object",
additionalProperties: false,
required: [
"mimeType",
"url"
]
},
RichTextBlock: {
description: "Defines an array of inlines, allowing for inline text formatting.",
version: "1.2",
features: [
1933
],
properties: {
type: {
"enum": [
"RichTextBlock"
],
description: "Must be `RichTextBlock`"
},
inlines: {
type: "array",
items: {
$ref: "#/definitions/ImplementationsOf.Inline"
},
description: "The array of inlines."
},
horizontalAlignment: {
$ref: "#/definitions/HorizontalAlignment",
description: "Controls the horizontal text alignment."
},
fallback: {
},
height: {
},
separator: {
},
spacing: {
},
id: {
},
isVisible: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
required: [
"inlines"
],
allOf: [
{
$ref: "#/definitions/Extendable.Element"
}
]
},
TextBlock: {
description: "Displays text, allowing control over font sizes, weight, and color.",
properties: {
type: {
"enum": [
"TextBlock"
],
description: "Must be `TextBlock`"
},
text: {
type: "string",
description: "Text to display"
},
color: {
$ref: "#/definitions/Colors",
description: "Controls the color of `TextBlock` elements."
},
fontType: {
$ref: "#/definitions/FontType",
description: "Type of font to use for rendering",
version: "1.2"
},
horizontalAlignment: {
$ref: "#/definitions/HorizontalAlignment",
description: "Controls the horizontal text alignment."
},
isSubtle: {
type: "boolean",
description: "If `true`, displays text slightly toned down to appear less prominent.",
"default": false
},
maxLines: {
type: "number",
description: "Specifies the maximum number of lines to display."
},
size: {
$ref: "#/definitions/FontSize",
description: "Controls size of text."
},
weight: {
$ref: "#/definitions/FontWeight",
description: "Controls the weight of `TextBlock` elements."
},
wrap: {
type: "boolean",
description: "If `true`, allow text to wrap. Otherwise, text is clipped.",
"default": false
},
fallback: {
},
height: {
},
separator: {
},
spacing: {
},
id: {
},
isVisible: {
},
requires: {
}
},
type: "object",
additionalProperties: false,
required: [
"text"
],
allOf: [
{
$ref: "#/definitions/Extendable.Element"
}
]
},
ActionStyle: {
description: "Controls the style of an Action, which influences how the action is displayed, spoken, etc.",
features: [
861
],
version: "1.2",
anyOf: [
{
"enum": [
"default",
"positive",
"destructive"
]
},
{
pattern: "^([d|D][e|E][f|F][a|A][u|U][l|L][t|T])|([p|P][o|O][s|S][i|I][t|T][i|I][v|V][e|E])|([d|D][e|E][s|S][t|T][r|R][u|U][c|C][t|T][i|I][v|V][e|E])$"
}
]
},
BlockElementHeight: {
anyOf: [
{
"enum": [
"auto",
"stretch"
]
},
{
pattern: "^([a|A][u|U][t|T][o|O])|([s|S][t|T][r|R][e|E][t|T][c|C][h|H])$"
}
]
},
ChoiceInputStyle: {
description: "Style hint for `Input.ChoiceSet`.",
anyOf: [
{
"enum": [
"compact",
"expanded"
]
},
{
pattern: "^([c|C][o|O][m|M][p|P][a|A][c|C][t|T])|([e|E][x|X][p|P][a|A][n|N][d|D][e|E][d|D])$"
}
]
},
Colors: {
anyOf: [
{
"enum": [
"default",
"dark",
"light",
"accent",
"good",
"warning",
"attention"
]
},
{
pattern: "^([d|D][e|E][f|F][a|A][u|U][l|L][t|T])|([d|D][a|A][r|R][k|K])|([l|L][i|I][g|G][h|H][t|T])|([a|A][c|C][c|C][e|E][n|N][t|T])|([g|G][o|O][o|O][d|D])|([w|W][a|A][r|R][n|N][i|I][n|N][g|G])|([a|A][t|T][t|T][e|E][n|N][t|T][i|I][o|O][n|N])$"
}
]
},
ContainerStyle: {
anyOf: [
{
"enum": [
"default",
"emphasis",
"good",
"attention",
"warning",
"accent"
]
},
{
pattern: "^([d|D][e|E][f|F][a|A][u|U][l|L][t|T])|([e|E][m|M][p|P][h|H][a|A][s|S][i|I][s|S])|([g|G][o|O][o|O][d|D])|([a|A][t|T][t|T][e|E][n|N][t|T][i|I][o|O][n|N])|([w|W][a|A][r|R][n|N][i|I][n|N][g|G])|([a|A][c|C][c|C][e|E][n|N][t|T])$"
}
]
},
FallbackOption: {
anyOf: [
{
"enum": [
"drop"
]
},
{
pattern: "^([d|D][r|R][o|O][p|P])$"
}
]
},
FontSize: {
anyOf: [
{
"enum": [
"default",
"small",
"medium",
"large",
"extraLarge"
]
},
{
pattern: "^([d|D][e|E][f|F][a|A][u|U][l|L][t|T])|([s|S][m|M][a|A][l|L][l|L])|([m|M][e|E][d|D][i|I][u|U][m|M])|([l|L][a|A][r|R][g|G][e|E])|([e|E][x|X][t|T][r|R][a|A][l|L][a|A][r|R][g|G][e|E])$"
}
]
},
FontType: {
anyOf: [
{
"enum": [
"default",
"monospace"
]
},
{
pattern: "^([d|D][e|E][f|F][a|A][u|U][l|L][t|T])|([m|M][o|O][n|N][o|O][s|S][p|P][a|A][c|C][e|E])$"
}
]
},
FontWeight: {
anyOf: [
{
"enum": [
"default",
"lighter",
"bolder"
]
},
{
pattern: "^([d|D][e|E][f|F][a|A][u|U][l|L][t|T])|([l|L][i|I][g|G][h|H][t|T][e|E][r|R])|([b|B][o|O][l|L][d|D][e|E][r|R])$"
}
]
},
HorizontalAlignment: {
description: "Controls how content is horizontally positioned within its container.",
anyOf: [
{
"enum": [
"left",
"center",
"right"
]
},
{
pattern: "^([l|L][e|E][f|F][t|T])|([c|C][e|E][n|N][t|T][e|E][r|R])|([r|R][i|I][g|G][h|H][t|T])$"
}
]
},
ImageFillMode: {
anyOf: [
{
"enum": [
"cover",
"repeatHorizontally",
"repeatVertically",
"repeat"
]
},
{
pattern: "^([c|C][o|O][v|V][e|E][r|R])|([r|R][e|E][p|P][e|E][a|A][t|T][h|H][o|O][r|R][i|I][z|Z][o|O][n|N][t|T][a|A][l|L][l|L][y|Y])|([r|R][e|E][p|P][e|E][a|A][t|T][v|V][e|E][r|R][t|T][i|I][c|C][a|A][l|L][l|L][y|Y])|([r|R][e|E][p|P][e|E][a|A][t|T])$"
}
]
},
ImageSize: {
description: "Controls the approximate size of the image. The physical dimensions will vary per host. Every option preserves aspect ratio.",
anyOf: [
{
"enum": [
"auto",
"stretch",
"small",
"medium",
"large"
]
},
{
pattern: "^([a|A][u|U][t|T][o|O])|([s|S][t|T][r|R][e|E][t|T][c|C][h|H])|([s|S][m|M][a|A][l|L][l|L])|([m|M][e|E][d|D][i|I][u|U][m|M])|([l|L][a|A][r|R][g|G][e|E])$"
}
]
},
ImageStyle: {
description: "Controls how this `Image` is displayed.",
anyOf: [
{
"enum": [
"default",
"person"
]
},
{
pattern: "^([d|D][e|E][f|F][a|A][u|U][l|L][t|T])|([p|P][e|E][r|R][s|S][o|O][n|N])$"
}
]
},
Spacing: {
description: "Specifies how much spacing. Hosts pick the exact pixel amounts for each of these.",
anyOf: [
{
"enum": [
"default",
"none",
"small",
"medium",
"large",
"extraLarge",
"padding"
]
},
{
pattern: "^([d|D][e|E][f|F][a|A][u|U][l|L][t|T])|([n|N][o|O][n|N][e|E])|([s|S][m|M][a|A][l|L][l|L])|([m|M][e|E][d|D][i|I][u|U][m|M])|([l|L][a|A][r|R][g|G][e|E])|([e|E][x|X][t|T][r|R][a|A][l|L][a|A][r|R][g|G][e|E])|([p|P][a|A][d|D][d|D][i|I][n|N][g|G])$"
}
]
},
TextInputStyle: {
description: "Style hint for text input.",
anyOf: [
{
"enum": [
"text",
"tel",
"url",
"email"
]
},
{
pattern: "^([t|T][e|E][x|X][t|T])|([t|T][e|E][l|L])|([u|U][r|R][l|L])|([e|E][m|M][a|A][i|I][l|L])$"
}
]
},
VerticalAlignment: {
anyOf: [
{
"enum": [
"top",
"center",
"bottom"
]
},
{
pattern: "^([t|T][o|O][p|P])|([c|C][e|E][n|N][t|T][e|E][r|R])|([b|B][o|O][t|T][t|T][o|O][m|M])$"
}
]
},
VerticalContentAlignment: {
anyOf: [
{
"enum": [
"top",
"center",
"bottom"
]
},
{
pattern: "^([t|T][o|O][p|P])|([c|C][e|E][n|N][t|T][e|E][r|R])|([b|B][o|O][t|T][t|T][o|O][m|M])$"
}
]
},
BackgroundImage: {
description: "Specifies a background image.",
properties: {
type: {
"enum": [
"BackgroundImage"
],
description: "Must be `BackgroundImage`"
},
url: {
type: "string",
format: "uri-reference",
description: "The URL (or data url) of the image."
},
fillMode: {
$ref: "#/definitions/ImageFillMode",
description: "Describes how the image should fill the area."
},
horizontalAlignment: {
$ref: "#/definitions/HorizontalAlignment",
description: "Describes how the image should be aligned if it must be cropped or if using repeat fill mode."
},
verticalAlignment: {
$ref: "#/definitions/VerticalAlignment",
description: "Describes how the image should be aligned if it must be cropped or if using repeat fill mode."
}
},
version: "1.2",
type: "object",
additionalProperties: false,
required: [
"url"
]
},
"ImplementationsOf.Item": {
anyOf: [
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Action.OpenUrl"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Action.ShowCard"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Action.Submit"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Action.ToggleVisibility"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/ActionSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Column"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/ColumnSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Container"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/FactSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Image"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/ImageSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.ChoiceSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Date"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Number"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Text"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Time"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Toggle"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Media"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/RichTextBlock"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/TextBlock"
}
]
}
]
},
"ImplementationsOf.Action": {
anyOf: [
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Action.OpenUrl"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Action.ShowCard"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Action.Submit"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Action.ToggleVisibility"
}
]
}
]
},
"ImplementationsOf.ISelectAction": {
anyOf: [
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Action.OpenUrl"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Action.Submit"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Action.ToggleVisibility"
}
]
}
]
},
"ImplementationsOf.Element": {
anyOf: [
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/ActionSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/ColumnSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Container"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/FactSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Image"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/ImageSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.ChoiceSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Date"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Number"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Text"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Time"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Toggle"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Media"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/RichTextBlock"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/TextBlock"
}
]
}
]
},
"ImplementationsOf.ToggleableItem": {
anyOf: [
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/ActionSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Column"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/ColumnSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Container"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/FactSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Image"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/ImageSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.ChoiceSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Date"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Number"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Text"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Time"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Toggle"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Media"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/RichTextBlock"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/TextBlock"
}
]
}
]
},
"ImplementationsOf.Inline": {
anyOf: [
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/TextRun"
}
]
}
]
},
"ImplementationsOf.Input": {
anyOf: [
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.ChoiceSet"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Date"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Number"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Text"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Time"
}
]
},
{
required: [
"type"
],
allOf: [
{
$ref: "#/definitions/Input.Toggle"
}
]
}
]
},
"Extendable.Action": {
properties: {
title: {
type: "string",
description: "Label for button or link that represents this action."
},
iconUrl: {
type: "string",
format: "uri-reference",
description: "Optional icon to be shown on the action in conjunction with the title. Supports data URI in version 1.2+",
version: "1.1"
},
style: {
$ref: "#/definitions/ActionStyle",
description: "Controls the style of an Action, which influences how the action is displayed, spoken, etc.",
version: "1.2"
},
fallback: {
anyOf: [
{
$ref: "#/definitions/ImplementationsOf.Action"
},
{
$ref: "#/definitions/FallbackOption"
}
],
description: "Describes what to do when an unknown element is encountered or the requires of this or any children can't be met.",
version: "1.2"
},
requires: {
}
},
type: "object",
allOf: [
{
$ref: "#/definitions/Extendable.Item"
}
]
},
"Extendable.Element": {
properties: {
fallback: {
anyOf: [
{
$ref: "#/definitions/ImplementationsOf.Element"
},
{
$ref: "#/definitions/FallbackOption"
}
],
description: "Describes what to do when an unknown element is encountered or the requires of this or any children can't be met.",
version: "1.2"
},
height: {
$ref: "#/definitions/BlockElementHeight",
description: "Specifies the height of the element.",
version: "1.1"
},
separator: {
type: "boolean",
description: "When `true`, draw a separating line at the top of the element."
},
spacing: {
$ref: "#/definitions/Spacing",
description: "Controls the amount of spacing between this element and the preceding element."
},
id: {
},
isVisible: {
},
requires: {
}
},
type: "object",
allOf: [
{
$ref: "#/definitions/Extendable.ToggleableItem"
}
]
},
"Extendable.Input": {
description: "Base input class",
properties: {
id: {
type: "string",
description: "Unique identifier for the value. Used to identify collected input when the Submit action is performed."
},
fallback: {
anyOf: [
{
$ref: "#/definitions/ImplementationsOf.Element"
},
{
$ref: "#/definitions/FallbackOption"
}
],
description: "Describes what to do when an unknown element is encountered or the requires of this or any children can't be met.",
version: "1.2"
},
height: {
$ref: "#/definitions/BlockElementHeight",
description: "Specifies the height of the element.",
version: "1.1"
},
separator: {
type: "boolean",
description: "When `true`, draw a separating line at the top of the element."
},
spacing: {
$ref: "#/definitions/Spacing",
description: "Controls the amount of spacing between this element and the preceding element."
},
isVisible: {
type: "boolean",
description: "If `false`, this item will be removed from the visual tree.",
"default": true,
version: "1.2"
},
requires: {
type: "object",
additionalProperties: {
type: "string"
},
description: "A series of key/value pairs indicating features that the item requires with corresponding minimum version. When a feature is missing or of insufficient version, fallback is triggered.",
version: "1.2"
}
},
type: "object",
required: [
"id"
]
},
"Extendable.Item": {
properties: {
requires: {
type: "object",
additionalProperties: {
type: "string"
},
description: "A series of key/value pairs indicating features that the item requires with corresponding minimum version. When a feature is missing or of insufficient version, fallback is triggered.",
version: "1.2"
}
},
type: "object"
},
"Extendable.ToggleableItem": {
properties: {
id: {
type: "string",
description: "A unique identifier associated with the item."
},
isVisible: {
type: "boolean",
description: "If `false`, this item will be removed from the visual tree.",
"default": true,
version: "1.2"
},
requires: {
}
},
type: "object",
allOf: [
{
$ref: "#/definitions/Extendable.Item"
}
]
}
};
const formatMessage = ({ color = '666666', title, text, facts, images, stackTrace, linkButtons }) => {
const message = {
'@context': 'https://schema.org/extensions',
'@type': 'MessageCard',
version: '1.0',
themeColor: color,
text,
};
if (!title && !text) {
throw new Error('Message must have a title or text.');
}
if (title) {
message.title = title;
message.summary = stripEmoji__default['default'](title);
delete message.version;
}
if (facts || images || stackTrace) message.sections = [];
if (facts) message.sections.push(getFacts(facts));
if (images) message.sections.push(getImages(images));
if (stackTrace) message.sections.push(getStackTrace(stackTrace));
if (linkButtons) message.potentialAction = getLinkButtons(linkButtons);
return message;
var anyOf = [
{
allOf: [
{
$ref: "#/definitions/AdaptiveCard"
}
]
}
];
var adaptiveCardSchema = {
$schema: $schema$1,
$id: $id$1,
definitions: definitions$1,
anyOf: anyOf
};
const schema = {
type: 'object',
properties: {
title: { type: 'string' },
text: { type: 'string' },
color: {
type: 'string',
pattern: '^[A-Fa-f0-9]{6}$',
},
facts: {
type: 'object',
patternProperties: {
'.*': { type: 'string' },
},
additionalProperties: false,
},
images: {
type: 'array',
items: [
{
type: 'string',
format: 'uri',
},
],
},
stackTrace: {
type: 'object',
properties: {
title: { type: 'string' },
code: { type: 'string' },
},
required: ['code'],
},
linkButtons: {
type: 'array',
items: [{
type: 'object',
properties: {
name: { type: 'string' },
link: {
type: 'string',
format: 'uri',
},
},
required: ['name', 'link'],
}],
},
},
var $schema = "http://json-schema.org/draft-06/schema#";
var $id = "http://json-schema.org/draft-06/schema#";
var title = "Core schema meta-schema";
var definitions = {
schemaArray: {
type: "array",
minItems: 1,
items: {
$ref: "#"
}
},
nonNegativeInteger: {
type: "integer",
minimum: 0
},
nonNegativeIntegerDefault0: {
allOf: [
{
$ref: "#/definitions/nonNegativeInteger"
},
{
"default": 0
}
]
},
simpleTypes: {
"enum": [
"array",
"boolean",
"integer",
"null",
"number",
"object",
"string"
]
},
stringArray: {
type: "array",
items: {
type: "string"
},
uniqueItems: true,
"default": [
]
}
};
var type = [
"object",
"boolean"
];
var properties = {
$id: {
type: "string",
format: "uri-reference"
},
$schema: {
type: "string",
format: "uri"
},
$ref: {
type: "string",
format: "uri-reference"
},
title: {
type: "string"
},
description: {
type: "string"
},
"default": {
},
examples: {
type: "array",
items: {
}
},
multipleOf: {
type: "number",
exclusiveMinimum: 0
},
maximum: {
type: "number"
},
exclusiveMaximum: {
type: "number"
},
minimum: {
type: "number"
},
exclusiveMinimum: {
type: "number"
},
maxLength: {
$ref: "#/definitions/nonNegativeInteger"
},
minLength: {
$ref: "#/definitions/nonNegativeIntegerDefault0"
},
pattern: {
type: "string",
format: "regex"
},
additionalItems: {
$ref: "#"
},
items: {
anyOf: [
{
$ref: "#"
},
{
$ref: "#/definitions/schemaArray"
}
],
"default": {
}
},
maxItems: {
$ref: "#/definitions/nonNegativeInteger"
},
minItems: {
$ref: "#/definitions/nonNegativeIntegerDefault0"
},
uniqueItems: {
type: "boolean",
"default": false
},
contains: {
$ref: "#"
},
maxProperties: {
$ref: "#/definitions/nonNegativeInteger"
},
minProperties: {
$ref: "#/definitions/nonNegativeIntegerDefault0"
},
required: {
$ref: "#/definitions/stringArray"
},
additionalProperties: {
$ref: "#"
},
definitions: {
type: "object",
additionalProperties: {
$ref: "#"
},
"default": {
}
},
properties: {
type: "object",
additionalProperties: {
$ref: "#"
},
"default": {
}
},
patternProperties: {
type: "object",
additionalProperties: {
$ref: "#"
},
propertyNames: {
format: "regex"
},
"default": {
}
},
dependencies: {
type: "object",
additionalProperties: {
anyOf: [
{
$ref: "#"
},
{
$ref: "#/definitions/stringArray"
}
]
}
},
propertyNames: {
$ref: "#"
},
"const": {
},
"enum": {
type: "array",
minItems: 1,
uniqueItems: true
},
type: {
anyOf: [
{
$ref: "#/definitions/simpleTypes"
},
{
type: "array",
items: {
$ref: "#/definitions/simpleTypes"
},
minItems: 1,
uniqueItems: true
}
]
},
format: {
type: "string"
},
allOf: {
$ref: "#/definitions/schemaArray"
},
anyOf: {
$ref: "#/definitions/schemaArray"
},
oneOf: {
$ref: "#/definitions/schemaArray"
},
not: {
$ref: "#"
}
};
var metaSchema = {
$schema: $schema,
$id: $id,
title: title,
definitions: definitions,
type: type,
properties: properties,
"default": {
}
};
const ajv = new Ajv({ strict: false });
ajv.addMetaSchema(metaSchema);
addFormats(ajv);
const validate = ajv.compile(adaptiveCardSchema);
class TeamsKlaxon {
constructor(webhook) {
this.webhook = webhook;
}
async log(message) {
const ajv = new Ajv__default['default']();
const valid = ajv.validate(schema, message);
if (!valid) throw new Error(ajv.errors);
const formattedMessage = formatMessage(message);
try {
await axios__default['default'].post(this.webhook, formattedMessage);
} catch (e) {
console.log(e);
throw new Error('Error logging message.');
/** @private */
_webhook;
/** @private */
_card;
/**
* @example
* ```javascript
* const klaxon = new TeamsKlaxon('https://trten.webhook.office.com/...');
* ```
*
* @param webhook A Teams [Incoming Webhook](https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook?tabs=dotnet)
*/
constructor(webhook) {
this._webhook = webhook;
}
}
/**
* Make an adaptive card.
* @param contentItems Card contents
*/
makeCard(contentItems) {
this._card = {
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json',
type: 'AdaptiveCard',
version: '1.2',
body: contentItems,
};
}
/** @private */
_formatMessage() {
if (!this._card)
return;
const adaptiveCard = {
contentType: 'application/vnd.microsoft.card.adaptive',
contentUrl: null,
content: this._card,
};
const message = {
type: 'message',
attachments: [adaptiveCard],
};
return message;
}
/**
* Verify a card is valid.
* @returns {Boolean}
*/
cardIsValid() {
return validate(this._card);
}
/**
* Post your card to Teams.
* @returns
*/
async postCard() {
if (!this._card)
throw new Error('No card made yet');
if (!this.cardIsValid())
throw new Error('Invalid content');
const message = this._formatMessage();
if (!message)
return;
try {
const response = await axios.post(this._webhook, message, {
headers: { 'Content-Type': 'application/json' },
});
return response;
}
catch (e) {
console.error('Error posting message');
throw e;
}
}
}
module.exports = TeamsKlaxon;
export { elements as Elements, TeamsKlaxon };

52

package.json
{
"name": "@reuters-graphics/teams-klaxon",
"version": "0.0.3",
"version": "1.0.0-next.1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"repository": "https://github.com/reuters-graphics/teams-klaxon",

@@ -11,27 +13,47 @@ "author": "Jon McClure <jon.r.mcclure@gmail.com>",

"files": [
"dist/**/*",
"badge.svg"
"dist/**/*"
],
"engines": {
"node": ">=16.0.0"
},
"scripts": {
"prepublishOnly": "yarn test",
"build": "rollup --config rollup.config.js",
"test": "yarn build && mocha"
"build": "rimraf ./dist && rollup -c rollup.config.js",
"build:docs": "typedoc",
"preview:docs": "live-server ./docs",
"test": "yarn build && mocha",
"test:demo": "yarn build && DEMO_TESTS=1 mocha"
},
"devDependencies": {
"@reuters-graphics/eslint-config": "^0.0.2",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^8.0.1",
"dotenv": "^8.2.0",
"eslint": "^6.8.0",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-typescript": "^11.0.0",
"@tsconfig/recommended": "^1.0.2",
"@types/axios": "^0.14.0",
"@types/node": "^18.14.0",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"dotenv": "^16.0.3",
"eslint": "^7.24.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-standard": "^5.0.0",
"expect.js": "^0.3.1",
"mocha": "^7.1.2",
"rollup": "^2.10.5",
"rollup-plugin-node-externals": "^2.2.0",
"rollup-plugin-size-snapshot": "^0.12.0"
"lefthook": "^1.2.9",
"live-server": "1.2.1",
"mocha": "^10.2.0",
"prettier": "^2.8.4",
"rimraf": "^4.1.2",
"rollup": "^3.17.0",
"rollup-plugin-dts": "^5.2.0",
"tslib": "^2.5.0",
"typedoc": "^0.23.25",
"typescript": "^4.9.5"
},
"dependencies": {
"ajv": "^6.12.4",
"axios": "^0.20.0",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"emoji-strip": "^1.0.1"
}
}

@@ -1,2 +0,2 @@

![](badge.svg)
![logo](https://graphics.thomsonreuters.com/style-assets/images/logos/reuters-graphics-logo/svg/graphics-logo-color-dark.svg)

@@ -7,14 +7,16 @@ # @reuters-graphics/teams-klaxon

Send messages to a Microsoft Teams channel.
Create and send [Adaptive Cards](https://adaptivecards.io/) to a Microsoft Teams channel.
## Quickstart
## Usage
Setup a Microsoft Teams [incoming webhook](https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook) in a channel, then install the library.
```bash
yarn add @reuters-graphics/teams-klaxon
```
$ yarn add @reuters-graphics/teams-klaxon
```
Import and create a new `TeamsKlaxon` instance with your webhook URL.
```javascript
const TeamsKlaxon = require('@reuters-graphics/teams-klaxon');
import { TeamsKlaxon } from '@reuters-graphics/teams-klaxon';

@@ -25,123 +27,56 @@ // Your incoming webhook

const klaxon = new TeamsKlaxon(webhook);
await klaxon.log({
text: 'A simple message',
});
```
## Message formats
#### Text
Use element constructors to create your card's content...
```javascript
await klaxon.log({
text: 'A simple message',
});
```
import { Elements } from '@reuters-graphics/teams-klaxon';
![](./images/text.png)
#### Facts
```javascript
await klaxon.log({
title: '⚙️ Testing facts',
facts: {
Name: 'Jon McClure',
Age: '35',
},
});
const cardContent = [
Elements.TextBox('Hello _world_!', { size: 'Large' }),
];
```
![](./images/facts.png)
... or create your card content [from scratch](https://adaptivecards.io/explorer/).
#### Images
```javascript
await klaxon.log({
title: '⚙️ Testing images',
images: [
'https://scitechdaily.com/images/Great-White-Shark-Smile-1536x1152.jpg',
'https://cdn.britannica.com/79/65379-050-5CF52BAC/Shortfin-mako-shark-seas.jpg',
],
});
```
![](./images/images.png)
#### Stack trace
```javascript
await klaxon.log({
title: '⚙️ Testing stack trace',
stackTrace: {
title: 'Stack trace',
code: 'console.log(\'hello world\'!)',
const cardContent = [
{
type: 'TextBox',
text: 'Hello _world_!',
size: 'Large',
},
});
];
```
![](./images/stack-trace.png)
Then make and post your card.
#### Link buttons
```javascript
await klaxon.log({
title: '⚙️ Testing link buttons',
linkButtons: [{
name: 'Google',
link: 'https://www.google.com',
}, {
name: 'Twitter',
link: 'https://www.twitter.com',
}],
});
```
klaxon.makeCard(cardContent);
![](./images/link-buttons.png)
const response = await klaxon.postCard();
#### Color
```javascript
await klaxon.log({
title: '⚙️ Testing color',
color: 'FF0000'
});
response.status
// 200
```
![](./images/color.png)
**[Read the API docs](https://reuters-graphics.github.io/teams-klaxon/modules/index.html) for more info.**
#### Multiple options
## Constructor coverage
Element constructors cover a subset of the available [Adaptive Card schema](https://adaptivecards.io/explorer/AdaptiveCard.html), including:
```javascript
await klaxon.log({
title: '⚙️ Testing multiple options',
color: 'FF0000',
facts: {
Name: 'Jon McClure',
Age: '35',
},
images: [
'https://scitechdaily.com/images/Great-White-Shark-Smile-1536x1152.jpg',
'https://cdn.britannica.com/79/65379-050-5CF52BAC/Shortfin-mako-shark-seas.jpg',
],
stackTrace: {
code: 'console.log(\'hello world!\')',
},
linkButtons: [{
name: 'Google',
link: 'https://www.google.com',
}, {
name: 'Twitter',
link: 'https://www.twitter.com',
}],
});
```
|_Elements_||
| -- | -- |
|TextBlock|✅|
|Image|✅|
![](./images/multiple.png)
## Testing
```
$ yarn test
```
|_Containers_||
| -- | -- |
|ActionSet|✅|
|Container|✅|
|ColumnSet|✅|
|Column|✅|
|FactSet|✅|
|Fact|✅|
|ImageSet|✅|

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc