New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@yoctol/kurator

Package Overview
Dependencies
Maintainers
6
Versions
703
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yoctol/kurator - npm Package Compare versions

Comparing version 0.4.12 to 0.4.14

2

package.json
{
"name": "@yoctol/kurator",
"license": "UNLICENSED",
"version": "0.4.12",
"version": "0.4.14",
"main": "src/index.js",

@@ -6,0 +6,0 @@ "files": [

@@ -194,2 +194,129 @@ const BottenderTransformer = require('../BottenderTransformer');

it('should support carousel (includes webUrl)', async () => {
const { context } = setup();
const action = BottenderTransformer.toBottenderComposeAction({
type: 'carousel',
descriptor: {},
actions: [
{
type: 'image',
descriptor: {
title: '小可樂',
webUrl: 'https://yoctol.com',
buttons: [
{
id: 'dlf7nZarC',
type: 'postback',
title: '來一杯',
payload: '__來一杯__',
},
],
imageUrl:
'https://sales.vscinemas.com.tw/CDN/media/entity/get/ItemGraphic/10004659',
subtitle: '$34',
},
},
{
type: 'image',
descriptor: {
title: '中可樂',
webUrl: 'https://yoctol.com',
buttons: [
{
id: 'lclAuJsmF3',
type: 'postback',
title: '來一杯',
payload: '__來一杯__',
},
],
imageUrl:
'https://sales.vscinemas.com.tw/CDN/media/entity/get/ItemGraphic/10004658',
subtitle: '$43',
},
},
{
type: 'image',
descriptor: {
title: '大可樂',
webUrl: 'https://yoctol.com',
buttons: [
{
id: '7yR381reSL',
type: 'postback',
title: '來一杯',
payload: '__來一杯__',
},
],
imageUrl:
'https://sales.vscinemas.com.tw/CDN/media/entity/get/ItemGraphic/10004657',
subtitle: '$51',
},
},
],
});
await action(context);
expect(context.sendGenericTemplate).toBeCalledWith([
{
title: '小可樂',
image_url:
'https://sales.vscinemas.com.tw/CDN/media/entity/get/ItemGraphic/10004659',
subtitle: '$34',
default_action: {
type: 'web_url',
url: 'https://yoctol.com',
messenger_extensions: false,
webview_height_ratio: 'tall',
},
buttons: [
{
type: 'postback',
title: '來一杯',
payload: '__來一杯__',
},
],
},
{
title: '中可樂',
image_url:
'https://sales.vscinemas.com.tw/CDN/media/entity/get/ItemGraphic/10004658',
subtitle: '$43',
default_action: {
type: 'web_url',
url: 'https://yoctol.com',
messenger_extensions: false,
webview_height_ratio: 'tall',
},
buttons: [
{
type: 'postback',
title: '來一杯',
payload: '__來一杯__',
},
],
},
{
title: '大可樂',
image_url:
'https://sales.vscinemas.com.tw/CDN/media/entity/get/ItemGraphic/10004657',
subtitle: '$51',
default_action: {
type: 'web_url',
url: 'https://yoctol.com',
messenger_extensions: false,
webview_height_ratio: 'tall',
},
buttons: [
{
type: 'postback',
title: '來一杯',
payload: '__來一杯__',
},
],
},
]);
});
it('should support image with buttons (without webUrl)', async () => {

@@ -247,18 +374,17 @@ const { context } = setup();

type: 'weight',
descriptor: {
actions: [
{
type: 'text',
descriptor: {
text: 'hello',
},
descriptor: {},
actions: [
{
type: 'text',
descriptor: {
text: 'hello',
},
{
type: 'text',
descriptor: {
text: 'world',
},
},
{
type: 'text',
descriptor: {
text: 'world',
},
],
},
},
],
});

@@ -279,18 +405,17 @@

type: 'weight',
descriptor: {
actions: [
{
type: 'image',
descriptor: {
imageUrl: 'https://example.com/image1.jpg',
},
descriptor: {},
actions: [
{
type: 'image',
descriptor: {
imageUrl: 'https://example.com/image1.jpg',
},
{
type: 'image',
descriptor: {
imageUrl: 'https://example.com/image2.jpg',
},
},
{
type: 'image',
descriptor: {
imageUrl: 'https://example.com/image2.jpg',
},
],
},
},
],
});

@@ -312,18 +437,18 @@

descriptor: {
actions: [
{
type: 'text',
descriptor: {
text: 'hello',
},
probabilities: [0.5, 0.5],
},
actions: [
{
type: 'text',
descriptor: {
text: 'hello',
},
{
type: 'text',
descriptor: {
text: 'world',
},
},
{
type: 'text',
descriptor: {
text: 'world',
},
],
probabilities: [0.5, 0.5],
},
},
],
});

@@ -345,18 +470,18 @@

descriptor: {
actions: [
{
type: 'image',
descriptor: {
imageUrl: 'https://example.com/image1.jpg',
},
probabilities: [0.5, 0.5],
},
actions: [
{
type: 'image',
descriptor: {
imageUrl: 'https://example.com/image1.jpg',
},
{
type: 'image',
descriptor: {
imageUrl: 'https://example.com/image2.jpg',
},
},
{
type: 'image',
descriptor: {
imageUrl: 'https://example.com/image2.jpg',
},
],
probabilities: [0.5, 0.5],
},
},
],
});

@@ -363,0 +488,0 @@

@@ -32,3 +32,3 @@ const B = require('bottender-compose');

// TODO: should handle platforms...
function toTextAction({ text, buttons }) {
function toTextAction({ descriptor: { text, buttons } }) {
if (Array.isArray(buttons) && buttons.length >= 1) {

@@ -40,22 +40,28 @@ return B.sendButtonTemplate(text, transformButtons(buttons));

function toCarouselItem({ imageUrl, title, subtitle, webUrl, buttons }) {
return {
title,
image_url: imageUrl,
subtitle,
buttons: transformButtons(buttons),
...(webUrl
? {
default_action: {
type: 'web_url',
url: webUrl,
messenger_extensions: false,
webview_height_ratio: 'tall',
},
}
: {}),
};
}
// TODO: should handle platforms...
function toImageAction({ imageUrl, title, subtitle, webUrl, buttons }) {
function toImageAction({
descriptor: { imageUrl, title, subtitle, webUrl, buttons },
}) {
if (title && subtitle && buttons && Array.isArray(buttons)) {
return B.sendGenericTemplate([
{
title,
image_url: imageUrl,
subtitle,
buttons: transformButtons(buttons),
...(webUrl
? {
default_action: {
type: 'web_url',
url: webUrl,
messenger_extensions: false,
webview_height_ratio: 'tall',
},
}
: {}),
},
toCarouselItem({ imageUrl, title, subtitle, webUrl, buttons }),
]);

@@ -66,3 +72,3 @@ }

function toWeightAction({ probabilities, actions }) {
function toWeightAction({ descriptor: { probabilities }, actions }) {
if (probabilities) {

@@ -77,4 +83,5 @@ // eslint-disable-next-line no-use-before-define

function toCarouselAction({ actions }) {
// FIXME: wrong format
return actions.map(toImageAction);
return B.sendGenericTemplate(
actions.map(action => toCarouselItem(action.descriptor))
);
}

@@ -84,12 +91,12 @@

if (action.type === 'text') {
return toTextAction(action.descriptor);
return toTextAction(action);
}
if (action.type === 'image') {
return toImageAction(action.descriptor);
return toImageAction(action);
}
if (action.type === 'weight') {
return toWeightAction(action.descriptor);
return toWeightAction(action);
}
if (action.type === 'carousel') {
return toCarouselAction(action.descriptor);
return toCarouselAction(action);
}

@@ -96,0 +103,0 @@ }

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