From 7b2f4c279ecd2d959a618007a231be4545731698 Mon Sep 17 00:00:00 2001 From: chentsulin Date: Mon, 21 Sep 2020 11:20:48 +0800 Subject: [PATCH] chore: remove namespace and export types from module instead --- packages/facebook-batch/src/index.ts | 7 +- packages/messaging-api-line/src/Line.ts | 2 +- packages/messaging-api-line/src/LineClient.ts | 2 +- packages/messaging-api-line/src/LineNotify.ts | 2 +- packages/messaging-api-line/src/LinePay.ts | 2 +- packages/messaging-api-line/src/LineTypes.ts | 4462 ++++++++------- packages/messaging-api-line/src/browser.ts | 4 +- packages/messaging-api-line/src/index.ts | 11 +- .../messaging-api-messenger/src/Messenger.ts | 2 +- .../src/MessengerBatch.ts | 2 +- .../src/MessengerClient.ts | 2 +- .../src/MessengerTypes.ts | 1136 ++-- .../messaging-api-messenger/src/browser.ts | 6 +- packages/messaging-api-messenger/src/index.ts | 9 +- .../src/SlackOAuthClient.ts | 2 +- .../messaging-api-slack/src/SlackTypes.ts | 1720 +++--- .../src/SlackWebhookClient.ts | 2 +- packages/messaging-api-slack/src/index.ts | 7 +- .../src/TelegramClient.ts | 2 +- .../src/TelegramTypes.ts | 5024 ++++++++--------- .../src/__tests__/TelegramClient-send.spec.ts | 2 +- .../__tests__/TelegramClient-update.spec.ts | 2 +- packages/messaging-api-telegram/src/index.ts | 5 +- .../messaging-api-viber/src/ViberClient.ts | 2 +- .../messaging-api-viber/src/ViberTypes.ts | 726 ++- .../src/__tests__/ViberClient.spec.ts | 2 +- packages/messaging-api-viber/src/index.ts | 5 +- .../messaging-api-wechat/src/WechatClient.ts | 2 +- .../messaging-api-wechat/src/WechatTypes.ts | 148 +- .../src/__tests__/WechatClient.spec.ts | 2 +- packages/messaging-api-wechat/src/index.ts | 5 +- 31 files changed, 6644 insertions(+), 6663 deletions(-) diff --git a/packages/facebook-batch/src/index.ts b/packages/facebook-batch/src/index.ts index 8c9279fc..a9f98fbb 100644 --- a/packages/facebook-batch/src/index.ts +++ b/packages/facebook-batch/src/index.ts @@ -1,6 +1,5 @@ -import BatchRequestError from './BatchRequestError'; -import FacebookBatchQueue from './FacebookBatchQueue'; -import { getErrorMessage, isError613 } from './utils'; +export { default as BatchRequestError } from './BatchRequestError'; +export { default as FacebookBatchQueue } from './FacebookBatchQueue'; +export { getErrorMessage, isError613 } from './utils'; -export { getErrorMessage, isError613, FacebookBatchQueue, BatchRequestError }; export * from './types'; diff --git a/packages/messaging-api-line/src/Line.ts b/packages/messaging-api-line/src/Line.ts index 8cbc0443..66a21dc6 100644 --- a/packages/messaging-api-line/src/Line.ts +++ b/packages/messaging-api-line/src/Line.ts @@ -1,4 +1,4 @@ -import type { LineTypes } from './LineTypes'; +import * as LineTypes from './LineTypes'; function createText( text: string, diff --git a/packages/messaging-api-line/src/LineClient.ts b/packages/messaging-api-line/src/LineClient.ts index 80c537cf..d3cd5ae2 100644 --- a/packages/messaging-api-line/src/LineClient.ts +++ b/packages/messaging-api-line/src/LineClient.ts @@ -12,7 +12,7 @@ import { } from 'messaging-api-common'; import Line from './Line'; -import type { LineTypes } from './LineTypes'; +import * as LineTypes from './LineTypes'; function handleError( err: BaseAxiosError<{ diff --git a/packages/messaging-api-line/src/LineNotify.ts b/packages/messaging-api-line/src/LineNotify.ts index 3edf39fc..068341dc 100644 --- a/packages/messaging-api-line/src/LineNotify.ts +++ b/packages/messaging-api-line/src/LineNotify.ts @@ -9,7 +9,7 @@ import axios, { import warning from 'warning'; import { JsonObject } from 'type-fest'; -import type { LineTypes } from './LineTypes'; +import * as LineTypes from './LineTypes'; function handleError( err: BaseAxiosError<{ diff --git a/packages/messaging-api-line/src/LinePay.ts b/packages/messaging-api-line/src/LinePay.ts index d8cd0198..7d61bf60 100644 --- a/packages/messaging-api-line/src/LinePay.ts +++ b/packages/messaging-api-line/src/LinePay.ts @@ -9,7 +9,7 @@ import axios, { import invariant from 'ts-invariant'; import warning from 'warning'; -import type { LineTypes } from './LineTypes'; +import * as LineTypes from './LineTypes'; function handleError( err: BaseAxiosError<{ diff --git a/packages/messaging-api-line/src/LineTypes.ts b/packages/messaging-api-line/src/LineTypes.ts index 57ba2473..a13fd6fa 100644 --- a/packages/messaging-api-line/src/LineTypes.ts +++ b/packages/messaging-api-line/src/LineTypes.ts @@ -1,2526 +1,2524 @@ import { OnRequestFunction } from 'messaging-api-common'; -export namespace LineTypes { - export type ClientConfig = { - accessToken: string; - channelSecret?: string; - origin?: string; - dataOrigin?: string; - onRequest?: OnRequestFunction; - }; +export type ClientConfig = { + accessToken: string; + channelSecret?: string; + origin?: string; + dataOrigin?: string; + onRequest?: OnRequestFunction; +}; + +/** + * User Profile + * + */ +export type User = { + /** User's display name */ + displayName: string; + + /** User ID */ + userId: string; + + language?: string; + + /** Profile image URL. "https" image URL. Not included in the response if the user doesn't have a profile image. */ + pictureUrl: string; + + /** User's status message. Not included in the response if the user doesn't have a status message. */ + statusMessage: string; +}; + +/** + * Group Summary + */ +export type Group = { + /** Group ID */ + groupId: string; + + /** Group Name */ + groupName: string; + + /** Group icon URL */ + pictureUrl: string; +}; + +export type ImageMessage = { + type: 'image'; /** - * User Profile - * + * Image URL (Max character limit: 1000) + * - HTTPS over TLS 1.2 or later + * - JPEG + * - Max: 4096 x 4096 + * - Max: 1 MB */ - export type User = { - /** User's display name */ - displayName: string; - - /** User ID */ - userId: string; - - language?: string; - - /** Profile image URL. "https" image URL. Not included in the response if the user doesn't have a profile image. */ - pictureUrl: string; - - /** User's status message. Not included in the response if the user doesn't have a status message. */ - statusMessage: string; - }; + originalContentUrl: string; /** - * Group Summary + * Preview image URL (Max character limit: 1000) + * - HTTPS over TLS 1.2 or later + * - JPEG + * - Max: 240 x 240 + * - Max: 1 MB */ - export type Group = { - /** Group ID */ - groupId: string; + previewImageUrl: string; +}; - /** Group Name */ - groupName: string; +/** + * Defines the size of a tappable area. The top left is used as the origin of the area. Set these properties based on the `baseSize.width` property and the `baseSize.height` property. + */ +export type ImageMapArea = { + /** Horizontal position relative to the left edge of the area. Value must be 0 or higher. */ + x: number; - /** Group icon URL */ - pictureUrl: string; - }; + /** Vertical position relative to the top of the area. Value must be 0 or higher. */ + y: number; - export type ImageMessage = { - type: 'image'; + /** Width of the tappable area */ + width: number; - /** - * Image URL (Max character limit: 1000) - * - HTTPS over TLS 1.2 or later - * - JPEG - * - Max: 4096 x 4096 - * - Max: 1 MB - */ - originalContentUrl: string; + /** Height of the tappable area */ + height: number; +}; - /** - * Preview image URL (Max character limit: 1000) - * - HTTPS over TLS 1.2 or later - * - JPEG - * - Max: 240 x 240 - * - Max: 1 MB - */ - previewImageUrl: string; - }; +export type ImageMapUriAction = { + type: 'uri'; /** - * Defines the size of a tappable area. The top left is used as the origin of the area. Set these properties based on the `baseSize.width` property and the `baseSize.height` property. + * Label for the action. Spoken when the accessibility feature is enabled on the client device. + * - Max character limit: 50 + * - Supported on LINE 8.2.0 and later for iOS. */ - export type ImageMapArea = { - /** Horizontal position relative to the left edge of the area. Value must be 0 or higher. */ - x: number; - - /** Vertical position relative to the top of the area. Value must be 0 or higher. */ - y: number; + label?: string; - /** Width of the tappable area */ - width: number; + /** + * - Webpage URL + * - Max character limit: 1000 + * + * The available schemes are http, https, line, and tel. For more information about the LINE URL scheme, see Using the LINE URL scheme. + */ + linkUri: string; - /** Height of the tappable area */ - height: number; - }; + /** + * Defined tappable area + */ + area: ImageMapArea; +}; - export type ImageMapUriAction = { - type: 'uri'; +export type ImageMapMessageAction = { + type: 'message'; - /** - * Label for the action. Spoken when the accessibility feature is enabled on the client device. - * - Max character limit: 50 - * - Supported on LINE 8.2.0 and later for iOS. - */ - label?: string; + /** + * Label for the action. Spoken when the accessibility feature is enabled on the client device. + * - Max character limit: 50 + * - Supported on LINE 8.2.0 and later for iOS. + */ + label?: string; - /** - * - Webpage URL - * - Max character limit: 1000 - * - * The available schemes are http, https, line, and tel. For more information about the LINE URL scheme, see Using the LINE URL scheme. - */ - linkUri: string; + /** + * Message to send + * - Max character limit: 400 + * - Supported on LINE for iOS and Android only. + */ + text: string; - /** - * Defined tappable area - */ - area: ImageMapArea; - }; + /** + * Defined tappable area + */ + area: ImageMapArea; +}; + +/** + * Imagemap message + * + * Imagemap messages are messages configured with an image that has multiple tappable areas. You can assign one tappable area for the entire image or different tappable areas on divided areas of the image. + * + * You can also play a video on the image and display a label with a hyperlink after the video is finished. + * + * [Official document - imagemap message](https://developers.line.biz/en/reference/messaging-api/#imagemap-message) + */ +export type ImagemapMessage = { + type: 'imagemap'; - export type ImageMapMessageAction = { - type: 'message'; + /** + * Base URL of the image + * - Max character limit: 1000 + * - `HTTPS` over `TLS` 1.2 or later + * - For more information about supported images in imagemap messages, see [How to configure an image](https://developers.line.biz/en/reference/messaging-api/#base-url). + */ + baseUrl: string; - /** - * Label for the action. Spoken when the accessibility feature is enabled on the client device. - * - Max character limit: 50 - * - Supported on LINE 8.2.0 and later for iOS. - */ - label?: string; + /** + * Alternative text + * - Max character limit: 400 + */ + altText: string; + baseSize: { /** - * Message to send - * - Max character limit: 400 - * - Supported on LINE for iOS and Android only. + * Height of base image. Set to the height that corresponds to a width of 1040 pixels. */ - text: string; + height: number; /** - * Defined tappable area + * Width of base image in pixels. Set to 1040. */ - area: ImageMapArea; + width: number; }; + video?: ImageMapVideo; + /** - * Imagemap message + * Imagemap action objects * - * Imagemap messages are messages configured with an image that has multiple tappable areas. You can assign one tappable area for the entire image or different tappable areas on divided areas of the image. + * Object which specifies the actions and tappable areas of an imagemap. * - * You can also play a video on the image and display a label with a hyperlink after the video is finished. + * When an area is tapped, the user is redirected to the URI specified in `uri` and the message specified in `message` is sent. * - * [Official document - imagemap message](https://developers.line.biz/en/reference/messaging-api/#imagemap-message) + * - Action when tapped + * - Max: 50 */ - export type ImagemapMessage = { - type: 'imagemap'; + actions: (ImageMapUriAction | ImageMapMessageAction)[]; +}; - /** - * Base URL of the image - * - Max character limit: 1000 - * - `HTTPS` over `TLS` 1.2 or later - * - For more information about supported images in imagemap messages, see [How to configure an image](https://developers.line.biz/en/reference/messaging-api/#base-url). - */ - baseUrl: string; +export type VideoMessage = { + type: 'video'; - /** - * Alternative text - * - Max character limit: 400 - */ - altText: string; + /** + * URL of video file + * - Max character limit: 1000 + * - HTTPS over TLS 1.2 or later + * - mp4 + * - Max: 1 minute + * - Max: 10 MB + * + * A very wide or tall video may be cropped when played in some environments. + */ + originalContentUrl: string; - baseSize: { - /** - * Height of base image. Set to the height that corresponds to a width of 1040 pixels. - */ - height: number; + /** + * URL of preview image + * - Max character limit: 1000 + * - HTTPS over TLS 1.2 or later + * - JPEG + * - Max: 240 x 240 + * - Max: 1 MB + */ + previewImageUrl: string; +}; - /** - * Width of base image in pixels. Set to 1040. - */ - width: number; - }; +export type AudioMessage = { + type: 'audio'; - video?: ImageMapVideo; + /** + * URL of audio file + * - Max character limit: 1000 + * - HTTPS over TLS 1.2 or later + * - m4a + * - Max: 1 minute + * - Max: 10 MB + */ + originalContentUrl: string; - /** - * Imagemap action objects - * - * Object which specifies the actions and tappable areas of an imagemap. - * - * When an area is tapped, the user is redirected to the URI specified in `uri` and the message specified in `message` is sent. - * - * - Action when tapped - * - Max: 50 - */ - actions: (ImageMapUriAction | ImageMapMessageAction)[]; - }; + /** + * Length of audio file (milliseconds) + */ + duration: number; +}; - export type VideoMessage = { - type: 'video'; +export type Location = { + /** + * Title + * - Max character limit: 100 + */ + title: string; - /** - * URL of video file - * - Max character limit: 1000 - * - HTTPS over TLS 1.2 or later - * - mp4 - * - Max: 1 minute - * - Max: 10 MB - * - * A very wide or tall video may be cropped when played in some environments. - */ - originalContentUrl: string; + /** + * Address + * - Max character limit: 100 + */ + address: string; - /** - * URL of preview image - * - Max character limit: 1000 - * - HTTPS over TLS 1.2 or later - * - JPEG - * - Max: 240 x 240 - * - Max: 1 MB - */ - previewImageUrl: string; - }; + /** Latitude */ + latitude: number; - export type AudioMessage = { - type: 'audio'; + /** Longitude */ + longitude: number; +}; - /** - * URL of audio file - * - Max character limit: 1000 - * - HTTPS over TLS 1.2 or later - * - m4a - * - Max: 1 minute - * - Max: 10 MB - */ - originalContentUrl: string; +export type LocationMessage = { + type: 'location'; - /** - * Length of audio file (milliseconds) - */ - duration: number; - }; + /** + * Title + * - Max character limit: 100 + */ + title: string; - export type Location = { - /** - * Title - * - Max character limit: 100 - */ - title: string; + /** + * Address + * - Max character limit: 100 + */ + address: string; - /** - * Address - * - Max character limit: 100 - */ - address: string; + /** Latitude */ + latitude: number; - /** Latitude */ - latitude: number; + /** Longitude */ + longitude: number; +}; - /** Longitude */ - longitude: number; - }; +export type StickerMessage = { + type: 'sticker'; - export type LocationMessage = { - type: 'location'; + /** + * Package ID for a set of stickers. For information on package IDs, see the [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf). + */ + packageId: string; - /** - * Title - * - Max character limit: 100 - */ - title: string; + /** + * Sticker ID. For a list of sticker IDs for stickers that can be sent with the Messaging API, see the [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf). + */ + stickerId: string; +}; - /** - * Address - * - Max character limit: 100 - */ - address: string; +/** + * When a control associated with this action is tapped, a [postback event](https://developers.line.biz/en/reference/messaging-api/#postback-event) is returned via webhook with the specified string in the data property. + */ +export type PostbackAction = { + type: 'postback'; - /** Latitude */ - latitude: number; + /** + * Label for the action + * - Required for templates other than image carousel. Max character limit: 20 + * - Optional for image carousel templates. Max character limit: 12 + * - Optional for rich menus. Spoken when the accessibility feature is enabled on the client device. Max character limit: 20. Supported on LINE 8.2.0 and later for iOS. + * - Required for quick reply buttons. Max character limit: 20. Supported on LINE 8.11.0 and later for iOS and Android. + * - Required for the button of Flex Message. This property can be specified for the box, image, and text but its value is not displayed. Max character limit: 20 + */ + label?: string; - /** Longitude */ - longitude: number; - }; + /** + * String returned via webhook in the postback.data property of the postback event + * - Max character limit: 300 + */ + data: string; - export type StickerMessage = { - type: 'sticker'; + /** + * 【Deprecated】 Text displayed in the chat as a message sent by the user when the action is performed. Returned from the server through a webhook. This property shouldn't be used with quick reply buttons. + * - Max character limit: 300 + * - The displayText and text properties cannot both be used at the same time. + */ + text?: string; - /** - * Package ID for a set of stickers. For information on package IDs, see the [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf). - */ - packageId: string; + /** + * Text displayed in the chat as a message sent by the user when the action is performed. Required for quick reply buttons. Optional for the other message types. + * - Max character limit: 300 + * - The displayText and text properties cannot both be used at the same time. + */ + displayText?: string; +}; - /** - * Sticker ID. For a list of sticker IDs for stickers that can be sent with the Messaging API, see the [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf). - */ - stickerId: string; - }; +/** + * When a control associated with this action is tapped, the string in the `text` property is sent as a message from the user. + */ +export type MessageAction = { + type: 'message'; /** - * When a control associated with this action is tapped, a [postback event](https://developers.line.biz/en/reference/messaging-api/#postback-event) is returned via webhook with the specified string in the data property. + * Label for the action + * - Required for templates other than image carousel. Max character limit: 20 + * - Optional for image carousel templates. Max character limit: 12 + * - Optional for rich menus. Spoken when the accessibility feature is enabled on the client device. Max character limit: 20. Supported on LINE 8.2.0 and later for iOS. + * - Required for quick reply buttons. Max character limit: 20. Supported on LINE 8.11.0 and later for iOS and Android. + * - Required for the button of Flex Message. This property can be specified for the box, image, and text but its value is not displayed. Max charater limit: 20 */ - export type PostbackAction = { - type: 'postback'; + label?: string; - /** - * Label for the action - * - Required for templates other than image carousel. Max character limit: 20 - * - Optional for image carousel templates. Max character limit: 12 - * - Optional for rich menus. Spoken when the accessibility feature is enabled on the client device. Max character limit: 20. Supported on LINE 8.2.0 and later for iOS. - * - Required for quick reply buttons. Max character limit: 20. Supported on LINE 8.11.0 and later for iOS and Android. - * - Required for the button of Flex Message. This property can be specified for the box, image, and text but its value is not displayed. Max character limit: 20 - */ - label?: string; + /** + * Text sent when the action is performed + * - Max character limit: 300 + */ + text: string; +}; - /** - * String returned via webhook in the postback.data property of the postback event - * - Max character limit: 300 - */ - data: string; +/** + * When a control associated with this action is tapped, the URI specified in the `uri` property is opened. + */ +export type URIAction = { + type: 'uri'; - /** - * 【Deprecated】 Text displayed in the chat as a message sent by the user when the action is performed. Returned from the server through a webhook. This property shouldn't be used with quick reply buttons. - * - Max character limit: 300 - * - The displayText and text properties cannot both be used at the same time. - */ - text?: string; + /** + * Label for the action + * - Required for templates other than image carousel. Max character limit: 20 + * - Optional for image carousel templates. Max character limit: 12 + * - Optional for rich menus. Spoken when the accessibility feature is enabled on the client device. Max character limit: 20. Supported on LINE 8.2.0 and later for iOS. + * - Required for the button of Flex Message. This property can be specified for the box, image, and text but its value is not displayed. Max character limit: 20 + */ + label?: string; - /** - * Text displayed in the chat as a message sent by the user when the action is performed. Required for quick reply buttons. Optional for the other message types. - * - Max character limit: 300 - * - The displayText and text properties cannot both be used at the same time. - */ - displayText?: string; - }; + /** + * URI opened when the action is performed (Max character limit: 1000) + * + * The available schemes are `http`, `https`, `line`, and `tel`. For more information about the LINE URL scheme, see Using the LINE URL scheme. + */ + uri: string; +}; + +/** + * When a control associated with this action is tapped, a [postback event](https://developers.line.biz/en/reference/messaging-api/#postback-event) is returned via webhook with the date and time selected by the user from the date and time selection dialog. The datetime picker action does not support time zones. + */ +export type DatetimePickerAction = { + type: 'datetimepicker'; + /** + * Label for the action + * - Required for templates other than image carousel. Max character limit: 20 + * - Optional for image carousel templates. Max character limit: 12 + * - Optional for rich menus. Spoken when the accessibility feature is enabled on the client device. Max character limit: 20. Supported on LINE 8.2.0 and later for iOS. + * - Required for quick reply buttons. Max character limit: 20. Supported on LINE 8.11.0 and later for iOS and Android. + * - Required for the button of Flex Message. This property can be specified for the box, image, and text but its value is not displayed. Max character limit: 20 + */ + label?: string; + /** + * String returned via webhook in the `postback.data` property of the [postback event](https://developers.line.biz/en/reference/messaging-api/#postback-event) + * - Max character limit: 300 + */ + data: 'string'; + /** + * Action mode + * - date: Pick date + * - time: Pick time + * - datetime: Pick date and time + */ + mode: 'date' | 'time' | 'datetime'; + /** + * Initial value of date or time. + * + * [Date and time format](https://developers.line.biz/en/reference/messaging-api/#date-and-time-format) + */ + initial?: string; /** - * When a control associated with this action is tapped, the string in the `text` property is sent as a message from the user. + * Largest date or time value that can be selected. Must be greater than the `min` value. + * + * [Date and time format](https://developers.line.biz/en/reference/messaging-api/#date-and-time-format) */ - export type MessageAction = { - type: 'message'; + max?: string; - /** - * Label for the action - * - Required for templates other than image carousel. Max character limit: 20 - * - Optional for image carousel templates. Max character limit: 12 - * - Optional for rich menus. Spoken when the accessibility feature is enabled on the client device. Max character limit: 20. Supported on LINE 8.2.0 and later for iOS. - * - Required for quick reply buttons. Max character limit: 20. Supported on LINE 8.11.0 and later for iOS and Android. - * - Required for the button of Flex Message. This property can be specified for the box, image, and text but its value is not displayed. Max charater limit: 20 - */ - label?: string; + /** + * Smallest date or time value that can be selected. Must be less than the `max` value. + * + * [Date and time format](https://developers.line.biz/en/reference/messaging-api/#date-and-time-format) + */ + min?: string; +}; - /** - * Text sent when the action is performed - * - Max character limit: 300 - */ - text: string; - }; +/** + * This action can be configured only with quick reply buttons. When a button associated with this action is tapped, the camera screen in LINE is opened. + */ +export type CameraAction = { + type: 'camera'; /** - * When a control associated with this action is tapped, the URI specified in the `uri` property is opened. + * Label for the action + * - Max character limit: 20 */ - export type URIAction = { - type: 'uri'; - - /** - * Label for the action - * - Required for templates other than image carousel. Max character limit: 20 - * - Optional for image carousel templates. Max character limit: 12 - * - Optional for rich menus. Spoken when the accessibility feature is enabled on the client device. Max character limit: 20. Supported on LINE 8.2.0 and later for iOS. - * - Required for the button of Flex Message. This property can be specified for the box, image, and text but its value is not displayed. Max character limit: 20 - */ - label?: string; + label: string; +}; + +/** + * This action can be configured only with quick reply buttons. When a button associated with this action is tapped, the camera roll screen in LINE is opened. + */ +export type CameraRollAction = { + type: 'cameraRoll'; + /** + * Label for the action + * - Max character limit: 20 + */ + label: string; +}; - /** - * URI opened when the action is performed (Max character limit: 1000) - * - * The available schemes are `http`, `https`, `line`, and `tel`. For more information about the LINE URL scheme, see Using the LINE URL scheme. - */ - uri: string; - }; +/** + * This action can be configured only with quick reply buttons. When a button associated with this action is tapped, the location screen in LINE is opened. + */ +export type LocationAction = { + type: 'location'; /** - * When a control associated with this action is tapped, a [postback event](https://developers.line.biz/en/reference/messaging-api/#postback-event) is returned via webhook with the date and time selected by the user from the date and time selection dialog. The datetime picker action does not support time zones. + * Label for the action + * - Max character limit: 20 */ - export type DatetimePickerAction = { - type: 'datetimepicker'; - /** - * Label for the action - * - Required for templates other than image carousel. Max character limit: 20 - * - Optional for image carousel templates. Max character limit: 12 - * - Optional for rich menus. Spoken when the accessibility feature is enabled on the client device. Max character limit: 20. Supported on LINE 8.2.0 and later for iOS. - * - Required for quick reply buttons. Max character limit: 20. Supported on LINE 8.11.0 and later for iOS and Android. - * - Required for the button of Flex Message. This property can be specified for the box, image, and text but its value is not displayed. Max character limit: 20 - */ - label?: string; - /** - * String returned via webhook in the `postback.data` property of the [postback event](https://developers.line.biz/en/reference/messaging-api/#postback-event) - * - Max character limit: 300 - */ - data: 'string'; - /** - * Action mode - * - date: Pick date - * - time: Pick time - * - datetime: Pick date and time - */ - mode: 'date' | 'time' | 'datetime'; - /** - * Initial value of date or time. - * - * [Date and time format](https://developers.line.biz/en/reference/messaging-api/#date-and-time-format) - */ - initial?: string; + label: string; +}; + +export type Action = + | PostbackAction + | MessageAction + | URIAction + | DatetimePickerAction + | CameraAction + | CameraRollAction + | LocationAction; + +export type QuickReplyAction = + | PostbackAction + | MessageAction + | DatetimePickerAction + | CameraAction + | CameraRollAction + | LocationAction; + +/** + * This is a container that contains quick reply buttons. + * + * If a version of LINE that doesn't support the quick reply feature receives a message that contains quick reply buttons, only the message is displayed. + */ +export type QuickReply = { + /** + * This is a quick reply option that is displayed as a button. + * + * - Max: 13 objects + */ + items: { + type: 'action'; /** - * Largest date or time value that can be selected. Must be greater than the `min` value. + * URL of the icon that is displayed at the beginning of the button + * - Max character limit: 1000 + * - URL scheme: https + * - Image format: PNG + * - Aspect ratio: 1:1 + * - Data size: Up to 1 MB * - * [Date and time format](https://developers.line.biz/en/reference/messaging-api/#date-and-time-format) + * There is no limit on the image size. + * + * If the action property has a camera action, camera roll action, or location action, and the imageUrl property is not set, the default icon is displayed. */ - max?: string; + imageUrl?: string; /** - * Smallest date or time value that can be selected. Must be less than the `max` value. - * - * [Date and time format](https://developers.line.biz/en/reference/messaging-api/#date-and-time-format) + * Action performed when this button is tapped. Specify an action object. The following is a list of the available actions: + * - Postback action + * - Message action + * - Datetime picker action + * - Camera action + * - Camera roll action + * - Location action */ - min?: string; - }; + action: QuickReplyAction; + }[]; +}; +/** + * When sending a message from the LINE Official Account, you can specify the `sender.name` and the `sender.iconUrl` properties in Message objects. + */ +export type Sender = { /** - * This action can be configured only with quick reply buttons. When a button associated with this action is tapped, the camera screen in LINE is opened. + * Display name. Certain words such as LINE may not be used. + * + * - Max character limit: 20 */ - export type CameraAction = { - type: 'camera'; - - /** - * Label for the action - * - Max character limit: 20 - */ - label: string; - }; + name?: string; /** - * This action can be configured only with quick reply buttons. When a button associated with this action is tapped, the camera roll screen in LINE is opened. + * URL of the image to display as an icon when sending a message + * + * - Max character limit: 1000 + * - URL scheme: https */ - export type CameraRollAction = { - type: 'cameraRoll'; - /** - * Label for the action - * - Max character limit: 20 - */ - label: string; - }; + iconUrl?: string; +}; + +/** + * Common properties for messages + * + * The following properties can be specified in all the message objects. + * - Quick reply + * - sender + */ +export type MessageOptions = { + /** + * These properties are used for the quick reply feature. Supported on LINE 8.11.0 and later for iOS and Android. For more information, see [Using quick replies](https://developers.line.biz/en/docs/messaging-api/using-quick-reply/). + */ + quickReply?: QuickReply; + + sender?: Sender; +}; + +/** + * Template messages are messages with predefined layouts which you can customize. For more information, see Template messages. + * + * The following template types are available: + * + * - Buttons + * - Confirm + * - Carousel + * - Image carousel + */ +export type TemplateMessage