@go-mailer/jarvis 8.1.0 → 9.1.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/.env +119 -0
- package/lib/clients/iam.js +2 -1
- package/lib/clients/users.js +9 -9
- package/lib/constants/automation.js +18 -18
- package/lib/middlewares/client.js +4 -4
- package/lib/redis/schemas/iam/Key.js +1 -1
- package/lib/redis/schemas/index.js +14 -13
- package/lib/redis/schemas/mailing/Campaign.js +11 -11
- package/lib/redis/schemas/mailing/Transactonal.js +15 -15
- package/lib/redis/schemas/sales/Subscription.js +6 -6
- package/lib/redis/schemas/user/Contact.js +17 -0
- package/lib/utilitiy/index.js +6 -6
- package/lib/utilitiy/number.js +7 -7
- package/lib/utilitiy/text.js +16 -16
- package/package.json +1 -1
- package/lib/redis/schemas/Contact.js +0 -9
- /package/lib/redis/schemas/{Postal.js → postal/index.js} +0 -0
package/.env
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
NODE_ENV=development
|
|
2
|
+
REACT_APP_ENV=development
|
|
3
|
+
|
|
4
|
+
JWT_ISSUER=go-mailer.com
|
|
5
|
+
|
|
6
|
+
LOG_DB_HOST=mongo:27017
|
|
7
|
+
LOG_DB_USER=
|
|
8
|
+
LOG_DB_PASS=
|
|
9
|
+
LOG_DB_SLUG=mongodb://
|
|
10
|
+
|
|
11
|
+
MAIN_DB_HOST=mongo:27017
|
|
12
|
+
MAIN_DB_USER=
|
|
13
|
+
MAIN_DB_PASS=
|
|
14
|
+
MAIN_DB_SLUG=mongodb://
|
|
15
|
+
|
|
16
|
+
EMAIL_DB_HOST="45.94.209.67"
|
|
17
|
+
EMAIL_DB_PORT="3306"
|
|
18
|
+
EMAIL_DB_USER="logger"
|
|
19
|
+
EMAIL_DB_PASS="now.you.see.me.0110"
|
|
20
|
+
EMAIL_DB_NAME="emaillogs"
|
|
21
|
+
|
|
22
|
+
ADMIN_URI="http://localhost:3002"
|
|
23
|
+
EDITOR_URI="http://localhost:3003"
|
|
24
|
+
FRONTEND_URI="http://localhost:3000"
|
|
25
|
+
LANDING_URI="http://localhost:3001"
|
|
26
|
+
|
|
27
|
+
API_SERVICE_URI="http://api:4018"
|
|
28
|
+
AUTOMATA_SERVICE_URI="http://automata:4016"
|
|
29
|
+
AUTOMATA_API_SERVICE_URI="http://automata-api:4009"
|
|
30
|
+
AUTOMATOR_SERVICE_URI="http://automator:4015"
|
|
31
|
+
CAMPAIGN_PROCESSOR_SERVICE_URI="http://automator:4019"
|
|
32
|
+
FILES_SERVICE_URI="http://files:4010"
|
|
33
|
+
IAM_SERVICE_URI="http://iam:4011"
|
|
34
|
+
IMPORTER_SERVICE_URI="http://importer:4013"
|
|
35
|
+
JANITOR_SERVICE_URI="http://janitor:4004"
|
|
36
|
+
MAILING_SERVICE_URI="http://mailing:4017"
|
|
37
|
+
MAILING_API_SERVICE_URI="http://mailing-api:4002"
|
|
38
|
+
MESSAGING_SERVICE_URI="http://messaging:4014"
|
|
39
|
+
MESSENGER_SERVICE_URI="http://messaging:4020"
|
|
40
|
+
NOTIFICATIONS_SERVICE_URI="http://notifications:4007"
|
|
41
|
+
POSTAL_SERVICE_URI="http://postal:4008"
|
|
42
|
+
REPORTS_SERVICE_URI="http://reports:4012"
|
|
43
|
+
SALES_SERVICE_URI="http://sales:4003"
|
|
44
|
+
SCHEDULE_SERVICE_URI="http://sales:4003"
|
|
45
|
+
USERS_SERVICE_URI="http://users:4001"
|
|
46
|
+
|
|
47
|
+
API_FQDN="http://localhost:4018"
|
|
48
|
+
AUTOMATA_FQDN="http://localhost:4016"
|
|
49
|
+
AUTOMATA_API_FQDN="http://localhost:4009"
|
|
50
|
+
AUTOMATOR_FQDN="http://localhost:4015"
|
|
51
|
+
CAMPAIGN_PROCESSOR_FQDN="http://localhost:4019"
|
|
52
|
+
FILES_FQDN="http://localhost:4010"
|
|
53
|
+
IAM_FQDN="http://localhost:4011"
|
|
54
|
+
IMPORTER_FQDN="http://localhost:4013"
|
|
55
|
+
JANITOR_FQDN="http://localhost:4004"
|
|
56
|
+
MAILING_FQDN="http://localhost:4017"
|
|
57
|
+
MAILING_API_FQDN="http://localhost:4002"
|
|
58
|
+
MESSAGING_FQDN="http://localhost:4014"
|
|
59
|
+
MESSENGER_FQDN="http://localhost:4020"
|
|
60
|
+
NOTIFICATIONS_FQDN="http://localhost:4007"
|
|
61
|
+
POSTAL_FQDN="http://localhost:4008"
|
|
62
|
+
REPORTS_FQDN="http://localhost:4012"
|
|
63
|
+
SALES_FQDN="http://localhost:4003"
|
|
64
|
+
SCHEDULE_FQDN="http://localhost:4003"
|
|
65
|
+
USERS_FQDN="http://localhost:4001"
|
|
66
|
+
|
|
67
|
+
BOUNCE_MAIL_USER="bounces-dev"
|
|
68
|
+
BOUNCE_MAIL_PASS=bounces.andolini.2021
|
|
69
|
+
MAIL_HOST="mail.go-mailer.net"
|
|
70
|
+
MAIL_PORT=25
|
|
71
|
+
IMAP_HOST="mail.go-mailer.xyz"
|
|
72
|
+
IMAP_PORT=993
|
|
73
|
+
MAILER_MAIL_USER=mailer
|
|
74
|
+
MAILER_MAIL_PASS=mailer.go-mailer.2021
|
|
75
|
+
PEOPLE_MAIL_USER=people
|
|
76
|
+
PEOPLE_MAIL_PASS=people.go-mailer.2021
|
|
77
|
+
|
|
78
|
+
RABBIT_HOST=rabbitmq
|
|
79
|
+
RABBIT_PORT=5672
|
|
80
|
+
RABBIT_USER=app
|
|
81
|
+
RABBIT_PASS=app.password.0110
|
|
82
|
+
|
|
83
|
+
REDIS_URL=redis://redis:6379
|
|
84
|
+
|
|
85
|
+
RAVE_URI='https://api.flutterwave.com/v3'
|
|
86
|
+
RAVE_KEY=FLWSECK_TEST-9e78fd97aef9bbbeda7a7d9507b6a680-X
|
|
87
|
+
RAVE_HASH=ksjdriweindcq3847que9wejd8q43wurwdseioj
|
|
88
|
+
|
|
89
|
+
ONEAPP_URI='https://api.oneappgo.com/v1'
|
|
90
|
+
ONEAPP_SECRET_KEY=1applive_sk_6313b0be9086988a71cb673cdd65a0f4
|
|
91
|
+
ONEAPP_PUBLIC_KEY=1applive_pb_2bc999e8ecbc2645ba950b6a66818dcc
|
|
92
|
+
|
|
93
|
+
GIBISEND_URI="http://lm_sales:6003"
|
|
94
|
+
|
|
95
|
+
GO_FLAGS_ENV=`development`
|
|
96
|
+
GO_FLAGS_KEY='quD7$GqrvwJJurLNhKF4JCyyF'
|
|
97
|
+
GO_FLAGS_URI='https://api.go-flags.com'
|
|
98
|
+
|
|
99
|
+
GM_API_KEY='TmF0aGFuLTExNjYwNDA4NjY2NjcuNTc0Mi0x'
|
|
100
|
+
|
|
101
|
+
LOGTAIL_SECRET=k2JiNWArbwNWpeh5nZJnZE52
|
|
102
|
+
|
|
103
|
+
# AWS
|
|
104
|
+
S3_REGION=us-east-1
|
|
105
|
+
S3_FILES_BUCKET_NAME=go-mailer-dev-files
|
|
106
|
+
S3_ACCESS_KEY=AKIA5WDKPKBDEMFHONPH
|
|
107
|
+
S3_SECRET_KEY=qoI3EYN7EZ/h9zKZkb8LJsrsiemq2KSMqwyzgy1Y
|
|
108
|
+
|
|
109
|
+
# TERMII
|
|
110
|
+
TERMII_URL=https://v3.api.termii.com
|
|
111
|
+
|
|
112
|
+
# WEB PUSH
|
|
113
|
+
VAPID_PUBLIC_KEY="BGlX_kj-D7u2_D0A-kBLEiXFfg9zY6-S6CPvAuTlU-c0sz8Z63rt4woH0jvcCiYdFPLBV6QAcLsXRKtiHXi4JMg"
|
|
114
|
+
VAPID_PRIVATE_KEY="eUQ7O7XH95rTT158p42OMr48cAMxZjW3VQFn_OAyp2o"
|
|
115
|
+
VAPID_SUBJECT="mailto:test@test.test"
|
|
116
|
+
DEFAULT_TOKEN=eab2ow4ahngeeh7cahdoo5ang7chugoo2oozoroos8de2ieGeepah5ath9ohngoh
|
|
117
|
+
JWT_SECRET=euGuxahgh9OhRul9BeiBi6ooquebiixahmut7ahPh2aich3bo7jithahGaphei2v
|
|
118
|
+
DEFAULT_TOKEN=eab2ow4ahngeeh7cahdoo5ang7chugoo2oozoroos8de2ieGeepah5ath9ohngoh
|
|
119
|
+
JWT_SECRET=euGuxahgh9OhRul9BeiBi6ooquebiixahmut7ahPh2aich3bo7jithahGaphei2v
|
package/lib/clients/iam.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const axios = require('axios').default
|
|
2
2
|
const Env = require('../env')
|
|
3
3
|
const IAM_URI = Env.fetch('IAM_SERVICE_URI', true)
|
|
4
|
+
const API_SERVICE_URI = Env.fetch('API_SERVICE_URI', true)
|
|
4
5
|
const DEFAULT_TOKEN = Env.fetch('DEFAULT_TOKEN', true)
|
|
5
6
|
|
|
6
7
|
const checkAuthority = async ({ action, resource, user_id, tenant_id }) => {
|
|
@@ -33,7 +34,7 @@ const fetchTenants = async (query = '') => {
|
|
|
33
34
|
|
|
34
35
|
const verifyAPIKey = async (key) => {
|
|
35
36
|
const { error, payload } = (
|
|
36
|
-
await axios.get(`${
|
|
37
|
+
await axios.get(`${API_SERVICE_URI}/keys/verify/${key}`, {
|
|
37
38
|
headers: {
|
|
38
39
|
authorization: `Bearer ${DEFAULT_TOKEN}`
|
|
39
40
|
}
|
package/lib/clients/users.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const axios = require(
|
|
2
|
-
const Env = require(
|
|
3
|
-
const { fetchTenants } = require(
|
|
4
|
-
const USERS_URI = Env.fetch(
|
|
5
|
-
const GM_API_KEY = Env.fetch(
|
|
1
|
+
const axios = require('axios').default
|
|
2
|
+
const Env = require('../env')
|
|
3
|
+
const { fetchTenants } = require('./iam')
|
|
4
|
+
const USERS_URI = Env.fetch('USERS_SERVICE_URI', true)
|
|
5
|
+
const GM_API_KEY = Env.fetch('GM_API_KEY', true)
|
|
6
6
|
|
|
7
7
|
const updateContact = async (tenant_id, data = {}) => {
|
|
8
8
|
const {
|
|
@@ -14,12 +14,12 @@ const updateContact = async (tenant_id, data = {}) => {
|
|
|
14
14
|
emails: [email],
|
|
15
15
|
name
|
|
16
16
|
} = tenant
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
await axios.post(
|
|
19
19
|
`${USERS_URI}/api/contacts`,
|
|
20
20
|
{ email, name, ...data },
|
|
21
21
|
{ headers: { Authorization: `Bearer ${GM_API_KEY}` } }
|
|
22
|
-
)
|
|
23
|
-
}
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
24
|
|
|
25
|
-
module.exports = { updateContact }
|
|
25
|
+
module.exports = { updateContact }
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
EVENT_ANNIVERSARY:
|
|
3
|
-
EVENT_BIRTHDAY:
|
|
4
|
-
EVENT_CLICKED_LINK:
|
|
5
|
-
EVENT_NEW_CONTACT:
|
|
6
|
-
EVENT_OPENED_CAMPAIGN:
|
|
7
|
-
EVENT_OPENED_TRANSACTIONAL:
|
|
8
|
-
EVENT_SUBSCRIPTION:
|
|
9
|
-
EVENT_UNSUBSCRIPTION:
|
|
2
|
+
EVENT_ANNIVERSARY: 'anniversary',
|
|
3
|
+
EVENT_BIRTHDAY: 'birthday',
|
|
4
|
+
EVENT_CLICKED_LINK: 'clicked_link',
|
|
5
|
+
EVENT_NEW_CONTACT: 'new_contact',
|
|
6
|
+
EVENT_OPENED_CAMPAIGN: 'opened_campaign',
|
|
7
|
+
EVENT_OPENED_TRANSACTIONAL: 'opened_transactional',
|
|
8
|
+
EVENT_SUBSCRIPTION: 'joined_audience',
|
|
9
|
+
EVENT_UNSUBSCRIPTION: 'left_audience',
|
|
10
10
|
|
|
11
11
|
//
|
|
12
|
-
EFFECT_ADD_CONTACT_ATTRIBUTE:
|
|
13
|
-
EFFECT_ADD_CONTACT_TAG:
|
|
14
|
-
EFFECT_REMOVE_CONTACT_TAG:
|
|
15
|
-
EFFECT_REMOVE_CONTACT:
|
|
16
|
-
EFFECT_SEND_TRANSACTIONAL:
|
|
17
|
-
EFFECT_SEND_SMS:
|
|
18
|
-
EFFECT_SEND_WEB_PUSH:
|
|
19
|
-
EFFECT_SUBSCRIBE:
|
|
20
|
-
EFFECT_UNSUBSCRIBE:
|
|
21
|
-
}
|
|
12
|
+
EFFECT_ADD_CONTACT_ATTRIBUTE: 'add_attribute_to_contact',
|
|
13
|
+
EFFECT_ADD_CONTACT_TAG: 'add_tag_to_contact',
|
|
14
|
+
EFFECT_REMOVE_CONTACT_TAG: 'remove_tag_from_contact',
|
|
15
|
+
EFFECT_REMOVE_CONTACT: 'delete_contact',
|
|
16
|
+
EFFECT_SEND_TRANSACTIONAL: 'send_transactional_email',
|
|
17
|
+
EFFECT_SEND_SMS: 'send_sms',
|
|
18
|
+
EFFECT_SEND_WEB_PUSH: 'send_web_push_message',
|
|
19
|
+
EFFECT_SUBSCRIBE: 'add_to_audience',
|
|
20
|
+
EFFECT_UNSUBSCRIBE: 'remove_from_audience'
|
|
21
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const { triggerEvent } = require(
|
|
2
|
-
const { updateContact } = require(
|
|
1
|
+
const { triggerEvent } = require('../clients/automata')
|
|
2
|
+
const { updateContact } = require('../clients/users')
|
|
3
3
|
|
|
4
4
|
module.exports = {
|
|
5
5
|
triggerEvent,
|
|
6
|
-
updateContact
|
|
7
|
-
}
|
|
6
|
+
updateContact
|
|
7
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const { ActivityLogSchema } = require(
|
|
2
|
-
const { ContactImportSchema } = require(
|
|
3
|
-
const { PostalSchema } = require(
|
|
4
|
-
const { TaskSchema } = require(
|
|
5
|
-
const { CampaignSchema, CampaignConversionSchema } = require(
|
|
6
|
-
const { LinkSchema } = require(
|
|
7
|
-
const { MailActionSchema } = require(
|
|
8
|
-
const { SubscriptionSchema } = require(
|
|
9
|
-
const { AutoTopUpSchema } = require(
|
|
10
|
-
const { APIKeySchema } = require(
|
|
11
|
-
const { TransactionalSchema } = require(
|
|
1
|
+
const { ActivityLogSchema } = require('./iam/Activity')
|
|
2
|
+
const { ContactDownloadSchema, ContactImportSchema } = require('./user/Contact')
|
|
3
|
+
const { PostalSchema } = require('./postal')
|
|
4
|
+
const { TaskSchema } = require('./automation/Task')
|
|
5
|
+
const { CampaignSchema, CampaignConversionSchema } = require('./mailing/Campaign')
|
|
6
|
+
const { LinkSchema } = require('./mailing/Link')
|
|
7
|
+
const { MailActionSchema } = require('./mailing/Mailaction')
|
|
8
|
+
const { SubscriptionSchema } = require('./sales/Subscription')
|
|
9
|
+
const { AutoTopUpSchema } = require('./sales/Wallet')
|
|
10
|
+
const { APIKeySchema } = require('./iam/Key')
|
|
11
|
+
const { TransactionalSchema } = require('./mailing/Transactonal')
|
|
12
12
|
|
|
13
13
|
module.exports = {
|
|
14
14
|
ActivityLogSchema,
|
|
@@ -17,10 +17,11 @@ module.exports = {
|
|
|
17
17
|
AutoTopUpSchema,
|
|
18
18
|
CampaignConversionSchema,
|
|
19
19
|
CampaignSchema,
|
|
20
|
+
ContactDownloadSchema,
|
|
20
21
|
ContactImportSchema,
|
|
21
22
|
LinkSchema,
|
|
22
23
|
MailActionSchema,
|
|
23
24
|
PostalSchema,
|
|
24
25
|
SubscriptionSchema,
|
|
25
|
-
TransactionalSchema
|
|
26
|
-
}
|
|
26
|
+
TransactionalSchema
|
|
27
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const { Schema } = require(
|
|
1
|
+
const { Schema } = require('redis-om')
|
|
2
2
|
|
|
3
|
-
const CampaignSchema = new Schema(
|
|
4
|
-
id: { type:
|
|
5
|
-
status: { type:
|
|
6
|
-
})
|
|
3
|
+
const CampaignSchema = new Schema('campaign', {
|
|
4
|
+
id: { type: 'number' },
|
|
5
|
+
status: { type: 'string' }
|
|
6
|
+
})
|
|
7
7
|
|
|
8
|
-
const CampaignConversionSchema = new Schema(
|
|
9
|
-
id: { type:
|
|
10
|
-
campaign_id: { type:
|
|
11
|
-
})
|
|
8
|
+
const CampaignConversionSchema = new Schema('campaign_conversion', {
|
|
9
|
+
id: { type: 'string' },
|
|
10
|
+
campaign_id: { type: 'string' }
|
|
11
|
+
})
|
|
12
12
|
|
|
13
13
|
module.exports = {
|
|
14
14
|
CampaignConversionSchema,
|
|
15
|
-
CampaignSchema
|
|
16
|
-
}
|
|
15
|
+
CampaignSchema
|
|
16
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
const { Schema } = require(
|
|
1
|
+
const { Schema } = require('redis-om')
|
|
2
2
|
|
|
3
|
-
const TransactionalSchema = new Schema(
|
|
4
|
-
id: { type:
|
|
5
|
-
tenant_id: { type:
|
|
6
|
-
body: { type:
|
|
7
|
-
code: { type:
|
|
8
|
-
subject: { type:
|
|
9
|
-
sender_email: { type:
|
|
10
|
-
sender_name: { type:
|
|
11
|
-
is_active: { type:
|
|
12
|
-
is_deleted: { type:
|
|
13
|
-
is_marketer_managed: { type:
|
|
14
|
-
})
|
|
3
|
+
const TransactionalSchema = new Schema('transactional', {
|
|
4
|
+
id: { type: 'number' },
|
|
5
|
+
tenant_id: { type: 'number' },
|
|
6
|
+
body: { type: 'string' },
|
|
7
|
+
code: { type: 'string' },
|
|
8
|
+
subject: { type: 'string' },
|
|
9
|
+
sender_email: { type: 'string' },
|
|
10
|
+
sender_name: { type: 'string' },
|
|
11
|
+
is_active: { type: 'boolean' },
|
|
12
|
+
is_deleted: { type: 'boolean' },
|
|
13
|
+
is_marketer_managed: { type: 'boolean' }
|
|
14
|
+
})
|
|
15
15
|
|
|
16
16
|
module.exports = {
|
|
17
|
-
TransactionalSchema
|
|
18
|
-
}
|
|
17
|
+
TransactionalSchema
|
|
18
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const { Schema } = require(
|
|
1
|
+
const { Schema } = require('redis-om')
|
|
2
2
|
|
|
3
|
-
const SubscriptionSchema = new Schema(
|
|
4
|
-
tenant_id: { type:
|
|
5
|
-
})
|
|
3
|
+
const SubscriptionSchema = new Schema('subscription', {
|
|
4
|
+
tenant_id: { type: 'string' }
|
|
5
|
+
})
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
8
|
-
SubscriptionSchema
|
|
9
|
-
}
|
|
8
|
+
SubscriptionSchema
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { Schema } = require('redis-om')
|
|
2
|
+
|
|
3
|
+
const ContactDownloadSchema = new Schema('contactdownload', {
|
|
4
|
+
tenant_id: { type: 'number' },
|
|
5
|
+
contact_count: { type: 'number' },
|
|
6
|
+
file_name: { type: 'string' },
|
|
7
|
+
last_batch_processed: { type: 'number' }
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const ContactImportSchema = new Schema('contactimport', {
|
|
11
|
+
data: { type: 'string' }
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
ContactDownloadSchema,
|
|
16
|
+
ContactImportSchema
|
|
17
|
+
}
|
package/lib/utilitiy/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const Chart = require(
|
|
2
|
-
const Date = require(
|
|
3
|
-
const Number = require(
|
|
4
|
-
const Text = require(
|
|
1
|
+
const Chart = require('./chart')
|
|
2
|
+
const Date = require('./date')
|
|
3
|
+
const Number = require('./number')
|
|
4
|
+
const Text = require('./text')
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
Chart,
|
|
8
8
|
Date,
|
|
9
9
|
Number,
|
|
10
|
-
Text
|
|
11
|
-
}
|
|
10
|
+
Text
|
|
11
|
+
}
|
package/lib/utilitiy/number.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
convertToPercent: (value, total) => {
|
|
3
|
-
if (!value || !total) return 0
|
|
4
|
-
return (Number(value) / Number(total)) * 100
|
|
3
|
+
if (!value || !total) return 0
|
|
4
|
+
return (Number(value) / Number(total)) * 100
|
|
5
5
|
},
|
|
6
6
|
toReadableNumber: (value) => {
|
|
7
|
-
if (!value) return 0
|
|
8
|
-
if (isNaN(value)) return value
|
|
9
|
-
return Number(Number(value).toFixed(2)).toLocaleString()
|
|
10
|
-
}
|
|
11
|
-
}
|
|
7
|
+
if (!value) return 0
|
|
8
|
+
if (isNaN(value)) return value
|
|
9
|
+
return Number(Number(value).toFixed(2)).toLocaleString()
|
|
10
|
+
}
|
|
11
|
+
}
|
package/lib/utilitiy/text.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
const flattenObject = (object = {}, result = {}, concatenate_keys = false, root_key =
|
|
2
|
-
let flattened_object = {}
|
|
1
|
+
const flattenObject = (object = {}, result = {}, concatenate_keys = false, root_key = '') => {
|
|
2
|
+
let flattened_object = {}
|
|
3
3
|
|
|
4
|
-
const entries = Object.entries(object)
|
|
4
|
+
const entries = Object.entries(object)
|
|
5
5
|
|
|
6
|
-
for (
|
|
7
|
-
const item_key = root_key && concatenate_keys ? `${root_key}.${key}` : key
|
|
8
|
-
if (value && typeof value ===
|
|
9
|
-
flattened_object = { ...flattenObject(value, { ...flattened_object }, concatenate_keys, item_key) }
|
|
6
|
+
for (const [key, value] of entries) {
|
|
7
|
+
const item_key = root_key && concatenate_keys ? `${root_key}.${key}` : key
|
|
8
|
+
if (value && typeof value === 'object') {
|
|
9
|
+
flattened_object = { ...flattenObject(value, { ...flattened_object }, concatenate_keys, item_key) }
|
|
10
10
|
} else {
|
|
11
|
-
flattened_object[item_key] = value
|
|
11
|
+
flattened_object[item_key] = value
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
return { ...result, ...flattened_object }
|
|
16
|
-
}
|
|
15
|
+
return { ...result, ...flattened_object }
|
|
16
|
+
}
|
|
17
17
|
|
|
18
18
|
const scrambleSensitiveData = (SENSITIVE_DATA_KEYS = [], object = {}) => {
|
|
19
|
-
const scrambled_data = {}
|
|
19
|
+
const scrambled_data = {}
|
|
20
20
|
for (const [key, value] of Object.entries(object)) {
|
|
21
|
-
scrambled_data[key] = value
|
|
21
|
+
scrambled_data[key] = value
|
|
22
22
|
for (const piid_key of SENSITIVE_DATA_KEYS) {
|
|
23
23
|
if (key.toLowerCase().includes(piid_key.toLowerCase())) {
|
|
24
|
-
scrambled_data[key] = value.toString().replace(/\w/gi,
|
|
24
|
+
scrambled_data[key] = value.toString().replace(/\w/gi, '*')
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
return scrambled_data
|
|
30
|
-
}
|
|
29
|
+
return scrambled_data
|
|
30
|
+
}
|
|
31
31
|
|
|
32
|
-
module.exports = { flattenObject, scrambleSensitiveData }
|
|
32
|
+
module.exports = { flattenObject, scrambleSensitiveData }
|
package/package.json
CHANGED
|
File without changes
|