tom-microservice 3.5.7 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,12 +8,12 @@
8
8
  [![Coverage Status](https://img.shields.io/coveralls/Kikobeats/tom-microservice.svg?style=flat-square)](https://coveralls.io/github/Kikobeats/tom-microservice)
9
9
  [![NPM Status](https://img.shields.io/npm/dm/tom-microservice.svg?style=flat-square)](https://www.npmjs.org/package/tom-microservice)
10
10
 
11
- > Stripe API version: [2022-11-15](https://stripe.com/docs/upgrades#2022-11-15)
11
+ > Stripe API version: [2023-08-16](https://stripe.com/docs/upgrades#2023-08-16)
12
12
 
13
13
  **tom** 🐶 is a backoffice for your projects, oriented for doing things like:
14
14
 
15
15
  - Handle [payments](#payment) workflow ( create customers, subscribe to plans) using Stripe.
16
- - Send notifications ([email](notificationemail)/[Slack](notificationslack)/[Twitter](notificationtwitter)/[Telegram](notificationtelegram)), even based on a template.
16
+ - Send notifications ([email](notificationemail)/[Slack](notificationslack)/[Telegram](notificationtelegram)), even based on a template.
17
17
  - Easy to extend & customize using [Event System](#event-system).
18
18
  - Chainable actions, running them on [series](batchseries) or [parallel](batchparallel).
19
19
  - Expose it over [HTTP](as-microservice) or as [CLI](from-cli).
@@ -349,44 +349,6 @@ type: `string`
349
349
 
350
350
  The message that will be sent.
351
351
 
352
- #### notification:twitter
353
-
354
- <small>`POST`</small>
355
-
356
- It sends a notification using Twitter as provider.
357
-
358
- ##### Data Parameters
359
-
360
- ###### templateId
361
-
362
- type: `string`
363
-
364
- If it is present, it will be generate `text` using the template.
365
-
366
- ###### text
367
-
368
- *Required*</br>
369
- type: `string`
370
-
371
- The text of the message.
372
-
373
- ###### type
374
-
375
- *Required*</br>
376
- type: `string`
377
-
378
- Choose one of the different ways the message can be send.
379
-
380
- The types availables are `tweet` or `dm`.
381
-
382
- ###### recipientId
383
-
384
- type: `string`
385
-
386
- It defines the user that will be receive the message.
387
-
388
- It is only necessary on `dm` mode.
389
-
390
352
  ### batch
391
353
 
392
354
  It runs more than one command in the same action.
@@ -512,34 +474,6 @@ Default: `config.email.transporter.auth.password`
512
474
 
513
475
  Your SMTP authentication password credential.
514
476
 
515
- #### TOM_TWITTER_CONSUMER_KEY
516
-
517
- Type: `string` </br>
518
- Default: `config.twitter.consumer_key`
519
-
520
- Your consumer secret key from [Twitter authentication credentials](https://developer.twitter.com/en/docs/basics/authentication/guides/access-tokens.html).
521
-
522
- #### TOM_TWITTER_CONSUMER_SECRET
523
-
524
- Type: `string` </br>
525
- Default: `config.twitter.consumer_secret`
526
-
527
- Your consumer secret [Twitter authentication credentials](https://developer.twitter.com/en/docs/basics/authentication/guides/access-tokens.html).
528
-
529
- #### TOM_TWITTER_ACCESS_TOKEN_SECRET
530
-
531
- Type: `string` </br>
532
- Default: `config.twitter.access_token_secret`
533
-
534
- Your access token secret from [Twitter authentication credentials](https://developer.twitter.com/en/docs/basics/authentication/guides/access-tokens.html).
535
-
536
- #### TOM_TWITTER_ACCESS_TOKEN
537
-
538
- Type: `string` </br>
539
- Default: `config.twitter.access_token`
540
-
541
- Your access token from [Twitter authentication credentials](https://developer.twitter.com/en/docs/basics/authentication/guides/access-tokens.html).
542
-
543
477
  #### TOM_TELEGRAM_KEY
544
478
 
545
479
  ![](https://i.imgur.com/xRAqBs6.png)
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "tom-microservice",
3
3
  "description": "Tom creates customers, subscriptions plans & send notifications.",
4
4
  "homepage": "https://tom.js.org",
5
- "version": "3.5.7",
5
+ "version": "3.7.0",
6
6
  "main": "src",
7
7
  "bin": {
8
8
  "tom": "bin/index.js"
@@ -68,16 +68,16 @@
68
68
  "request-ip": "~3.3.0",
69
69
  "router-http": "~1.0.1",
70
70
  "send-http": "~1.0.3",
71
- "stripe": "12",
71
+ "stripe": "13",
72
72
  "time-span": "~4.0.0",
73
73
  "to-query": "~1.6.12",
74
- "twit": "~2.2.11",
75
74
  "update-notifier": "~5.1.0"
76
75
  },
77
76
  "devDependencies": {
78
77
  "@commitlint/cli": "latest",
79
78
  "@commitlint/config-conventional": "latest",
80
79
  "@faker-js/faker": "latest",
80
+ "@ksmithut/prettier-standard": "latest",
81
81
  "async-listen": "latest",
82
82
  "ava": "latest",
83
83
  "browser-sync": "latest",
@@ -98,7 +98,6 @@
98
98
  "gulp-uglify": "latest",
99
99
  "nano-staged": "latest",
100
100
  "npm-check-updates": "latest",
101
- "prettier-standard": "latest",
102
101
  "simple-git-hooks": "latest",
103
102
  "standard": "latest",
104
103
  "standard-markdown": "latest",
@@ -38,14 +38,5 @@ module.exports = fn => {
38
38
  setEnv(config, 'email.transporter.auth.pass', 'TOM_EMAIL_PASSWORD')
39
39
  setEnv(config, 'telegram.token', 'TOM_TELEGRAM_KEY')
40
40
 
41
- setEnv(config, 'twitter.consumer_key', 'TOM_TWITTER_CONSUMER_KEY')
42
- setEnv(config, 'twitter.consumer_secret', 'TOM_TWITTER_CONSUMER_SECRET')
43
- setEnv(config, 'twitter.access_token', 'TOM_TWITTER_ACCESS_TOKEN')
44
- setEnv(
45
- config,
46
- 'twitter.access_token_secret',
47
- 'TOM_TWITTER_ACCESS_TOKEN_SECRET'
48
- )
49
-
50
41
  return { ...config, on, emit }
51
42
  }
@@ -1,76 +0,0 @@
1
- 'use strict'
2
-
3
- const { includes, get, isNil } = require('lodash')
4
- const Twit = require('twit')
5
-
6
- const { ward, wardCredential, is } = require('../../ward')
7
- const compile = require('../../compile')
8
-
9
- module.exports = ({ config }) => {
10
- const errFn = wardCredential(config, [
11
- { key: 'twitter.consumer_key', env: 'TOM_TWITTER_CONSUMER_KEY' },
12
- { key: 'twitter.consumer_secret', env: 'TOM_TWITTER_CONSUMER_SECRET' },
13
- { key: 'twitter.access_token', env: 'TOM_TWITTER_ACCESS_TOKEN' },
14
- {
15
- key: 'twitter.access_token_secret',
16
- env: 'TOM_TWITTER_ACCESS_TOKEN_SECRET'
17
- }
18
- ])
19
-
20
- if (errFn) return errFn
21
-
22
- const templates = get(config, 'twitter.template')
23
-
24
- const twit = new Twit({
25
- consumer_key: get(config, 'twitter.consumer_key'),
26
- consumer_secret: get(config, 'twitter.consumer_secret'),
27
- access_token: get(config, 'twitter.access_token'),
28
- access_token_secret: get(config, 'twitter.access_token_secret')
29
- })
30
-
31
- const apiEndpoint = {
32
- tweet: async ({ text: status, ...props }) => {
33
- const { data } = await twit.post('statuses/update', { ...props, status })
34
- const { id_str: id, user, text } = data
35
- const tweetUrl = `https://twitter.com/${user.screen_name}/status/${id}`
36
- return { text, tweetUrl }
37
- },
38
- dm: async ({ recipientId, text: message }) => {
39
- const { data } = await twit.post('direct_messages/events/new', {
40
- event: {
41
- type: 'message_create',
42
- message_create: {
43
- target: { recipient_id: recipientId },
44
- message_data: { text: message }
45
- }
46
- }
47
- })
48
-
49
- const { text } = data.event.message_create.message_data
50
- return { text }
51
- }
52
- }
53
-
54
- const twitter = async opts => {
55
- ward(opts.type, {
56
- label: 'type',
57
- test: is.string.is(x => includes(['tweet', 'dm'], x))
58
- })
59
-
60
- if (opts.templateId) {
61
- ward(opts.templateId, {
62
- label: 'templateId',
63
- test: is.string.is(x => !isNil(get(templates, x))),
64
- message: `Template '${opts.templateId}' not previously declared.`
65
- })
66
- }
67
-
68
- const template = get(templates, opts.templateId)
69
- const { type, ...props } = compile(template, { config, opts })
70
-
71
- const payload = await apiEndpoint[type](props)
72
- return payload
73
- }
74
-
75
- return twitter
76
- }