@things-factory/integration-lmd 4.3.411 → 4.3.414
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/client/pages/integration-lmd-detail.js +105 -84
- package/dist-server/index.js +2 -1
- package/dist-server/index.js.map +1 -1
- package/dist-server/service/index.js +2 -1
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/last-mile-delivery/index.js +2 -1
- package/dist-server/service/last-mile-delivery/index.js.map +1 -1
- package/dist-server/service/last-mile-delivery/last-mile-delivery-mutation.js +73 -17
- package/dist-server/service/last-mile-delivery/last-mile-delivery-mutation.js.map +1 -1
- package/dist-server/service/last-mile-delivery/last-mile-delivery-type.js +8 -0
- package/dist-server/service/last-mile-delivery/last-mile-delivery-type.js.map +1 -1
- package/dist-server/service/last-mile-delivery/last-mile-delivery.js +8 -6
- package/dist-server/service/last-mile-delivery/last-mile-delivery.js.map +1 -1
- package/package.json +2 -2
- package/server/index.ts +1 -1
- package/server/service/index.ts +1 -1
- package/server/service/last-mile-delivery/index.ts +1 -1
- package/server/service/last-mile-delivery/last-mile-delivery-mutation.ts +132 -53
- package/server/service/last-mile-delivery/last-mile-delivery-type.ts +6 -0
- package/server/service/last-mile-delivery/last-mile-delivery.ts +9 -13
- package/translations/en.json +5 -2
- package/translations/ja.json +4 -1
- package/translations/ko.json +4 -1
- package/translations/ms.json +4 -1
- package/translations/zh.json +4 -1
|
@@ -13,7 +13,6 @@ import { css, html } from 'lit-element'
|
|
|
13
13
|
import { gqlBuilder, isMobileDevice } from '@things-factory/utils'
|
|
14
14
|
import { buildDomainContext } from './integration-lmd'
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
18
17
|
static get styles() {
|
|
19
18
|
return [
|
|
@@ -87,7 +86,7 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
87
86
|
.quick-find-content-container {
|
|
88
87
|
margin: 0 15px;
|
|
89
88
|
}
|
|
90
|
-
|
|
89
|
+
|
|
91
90
|
@media screen and (max-width: 480px) {
|
|
92
91
|
.section-header {
|
|
93
92
|
grid-column: span 12 / auto !important;
|
|
@@ -97,6 +96,15 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
97
96
|
margin: 0;
|
|
98
97
|
}
|
|
99
98
|
}
|
|
99
|
+
|
|
100
|
+
[options-wrap] *,
|
|
101
|
+
[options-wrap] input[type='checkbox'] {
|
|
102
|
+
left: 0;
|
|
103
|
+
}
|
|
104
|
+
[options-wrap] input[type='checkbox'] + label {
|
|
105
|
+
margin-right: 20px;
|
|
106
|
+
padding-left: 0;
|
|
107
|
+
}
|
|
100
108
|
`
|
|
101
109
|
]
|
|
102
110
|
}
|
|
@@ -110,6 +118,8 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
110
118
|
/* Tab Toggle*/
|
|
111
119
|
_showDetailSetting: Boolean,
|
|
112
120
|
_showBizplaceSetting: Boolean,
|
|
121
|
+
_awbCustomize: Boolean,
|
|
122
|
+
_staging: Boolean,
|
|
113
123
|
currentTab: Object,
|
|
114
124
|
bizplaceData: Array
|
|
115
125
|
}
|
|
@@ -117,14 +127,13 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
117
127
|
|
|
118
128
|
constructor() {
|
|
119
129
|
super()
|
|
120
|
-
this._data = { lmdSettingData: { records: [] },
|
|
121
|
-
lmdBizplaceData: { records: [] } }
|
|
130
|
+
this._data = { lmdSettingData: { records: [] }, lmdBizplaceData: { records: [] } }
|
|
122
131
|
this.bizplaceData = []
|
|
123
132
|
this.currentTab = {
|
|
124
133
|
selected: 'setting'
|
|
125
134
|
}
|
|
126
135
|
}
|
|
127
|
-
|
|
136
|
+
|
|
128
137
|
get context() {
|
|
129
138
|
var actions = [
|
|
130
139
|
{
|
|
@@ -154,15 +163,14 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
154
163
|
...CommonButtonStyles.delete
|
|
155
164
|
})
|
|
156
165
|
}
|
|
157
|
-
|
|
166
|
+
|
|
158
167
|
return {
|
|
159
168
|
title: i18next.t('title.last_mile_delivery_platform_detail'),
|
|
160
169
|
actions,
|
|
161
170
|
help: 'page/integration-lmd-detail'
|
|
162
171
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
172
|
+
}
|
|
173
|
+
|
|
166
174
|
get _lmdSettingForm() {
|
|
167
175
|
return this.shadowRoot.querySelector('form[name=integrationLmdDetails]')
|
|
168
176
|
}
|
|
@@ -191,29 +199,49 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
191
199
|
{ name: 'Poslaju', value: 'POSLAJU' },
|
|
192
200
|
{ name: 'Ninja Van', value: 'NINJA_VAN' },
|
|
193
201
|
{ name: 'EMS', value: 'EMS' },
|
|
202
|
+
{ name: 'Citylink', value: 'CITYLINK' },
|
|
194
203
|
{ name: 'Sapx', value: 'SAPX' },
|
|
195
204
|
{ name: 'Viettel Post', value: 'VIETTEL_POST' },
|
|
196
|
-
{ name: 'DHL Express', value: 'DHL_EXPRESS' }
|
|
205
|
+
{ name: 'DHL Express', value: 'DHL_EXPRESS' }
|
|
197
206
|
]
|
|
198
207
|
|
|
199
|
-
const LMD_TABS ={
|
|
208
|
+
const LMD_TABS = {
|
|
200
209
|
SETTING_DETAILS: i18next.t('label.setting'),
|
|
201
210
|
BIZPLACE_DETAILS: i18next.t('label.company')
|
|
202
211
|
}
|
|
203
212
|
|
|
204
213
|
const lmdInfo = {
|
|
205
|
-
[LMD_TABS.SETTING_DETAILS]
|
|
206
|
-
[LMD_TABS.BIZPLACE_DETAILS]
|
|
207
|
-
|
|
214
|
+
[LMD_TABS.SETTING_DETAILS]: {},
|
|
215
|
+
[LMD_TABS.BIZPLACE_DETAILS]: {}
|
|
208
216
|
}
|
|
209
217
|
|
|
210
218
|
return html`
|
|
211
|
-
|
|
212
|
-
<div class="form-container">
|
|
219
|
+
<div class="form-container">
|
|
213
220
|
<form name="integrationLmdDetails" class="multi-column-form">
|
|
214
221
|
<fieldset>
|
|
215
222
|
<legend>${i18next.t('title.last_mile_delivery_platform_detail')}${this?._data?.id ? '' : ': NEW'}</legend>
|
|
216
223
|
|
|
224
|
+
<label>${i18next.t('label.options')}</label>
|
|
225
|
+
<div options-wrap>
|
|
226
|
+
<input
|
|
227
|
+
id="awbCustomize"
|
|
228
|
+
type="checkbox"
|
|
229
|
+
name="awbCustomize"
|
|
230
|
+
?checked="${this._awbCustomize}"
|
|
231
|
+
@change="${e => (this._awbCustomize = e.currentTarget.checked)}"
|
|
232
|
+
/>
|
|
233
|
+
<label>${i18next.t('label.awb_customize')}</label>
|
|
234
|
+
|
|
235
|
+
<input
|
|
236
|
+
id="staging"
|
|
237
|
+
type="checkbox"
|
|
238
|
+
name="staging"
|
|
239
|
+
?checked="${this._staging}"
|
|
240
|
+
@change="${e => (this._staging = e.currentTarget.checked)}"
|
|
241
|
+
/>
|
|
242
|
+
<label>${i18next.t('label.staging')}</label>
|
|
243
|
+
</div>
|
|
244
|
+
|
|
217
245
|
<label>${i18next.t('label.name')}</label>
|
|
218
246
|
<input name="name" required .value="${this?._data?.name}" />
|
|
219
247
|
|
|
@@ -265,17 +293,17 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
265
293
|
</form>
|
|
266
294
|
</div>
|
|
267
295
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
296
|
+
<div class="quick-find-content-container">
|
|
297
|
+
<quick-find-content
|
|
298
|
+
id="lmd"
|
|
299
|
+
name="quickFindContent"
|
|
300
|
+
.data="${lmdInfo}"
|
|
301
|
+
@tabChanged="${e => {
|
|
302
|
+
this._tabChange(e.detail.currentTabKey)
|
|
303
|
+
}}"
|
|
304
|
+
></quick-find-content>
|
|
305
|
+
</div>
|
|
306
|
+
|
|
279
307
|
<div class="container" ?hidden="${this._showDetailSetting}">
|
|
280
308
|
<div class="grist">
|
|
281
309
|
<h2><mwc-icon>list_alt</mwc-icon>${i18next.t('title.detail_settings')}</h2>
|
|
@@ -290,19 +318,18 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
290
318
|
</div>
|
|
291
319
|
|
|
292
320
|
<div class="container" ?hidden="${this._showBizplaceSetting}">
|
|
293
|
-
|
|
294
|
-
|
|
321
|
+
<div class="grist">
|
|
322
|
+
<h2><mwc-icon>list_alt</mwc-icon>${i18next.t('title.bizplace_settings')}</h2>
|
|
295
323
|
|
|
296
|
-
|
|
297
|
-
|
|
324
|
+
<data-grist
|
|
325
|
+
id="lmd-bizplace-grist"
|
|
298
326
|
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
299
327
|
.data=${this._data.lmdBizplaceData}
|
|
300
328
|
.config=${this.bizplaceConfig}
|
|
301
329
|
@record-change="${this._updateBizplaceFilter.bind(this)}"
|
|
302
|
-
|
|
330
|
+
></data-grist>
|
|
331
|
+
</div>
|
|
303
332
|
</div>
|
|
304
|
-
</div>
|
|
305
|
-
|
|
306
333
|
`
|
|
307
334
|
}
|
|
308
335
|
|
|
@@ -364,14 +391,11 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
364
391
|
}
|
|
365
392
|
]
|
|
366
393
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
394
|
+
}
|
|
370
395
|
|
|
371
396
|
async pageUpdated(changes, lifecycle) {
|
|
372
|
-
if (changes.resourceId == 'new') this._data.id
|
|
397
|
+
if (changes.resourceId == 'new') this._data.id
|
|
373
398
|
try {
|
|
374
|
-
|
|
375
399
|
if (this.active) {
|
|
376
400
|
this._clearView()
|
|
377
401
|
await this.updateComplete
|
|
@@ -388,8 +412,7 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
388
412
|
} finally {
|
|
389
413
|
this.updateContext()
|
|
390
414
|
}
|
|
391
|
-
}
|
|
392
|
-
|
|
415
|
+
}
|
|
393
416
|
|
|
394
417
|
async _fetchOrder() {
|
|
395
418
|
if (this?._data?.id && this?._data?.id != 'new') {
|
|
@@ -412,6 +435,7 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
412
435
|
staging
|
|
413
436
|
accountNumber
|
|
414
437
|
prefix
|
|
438
|
+
awbCustomize
|
|
415
439
|
lastMileDeliverySettings {
|
|
416
440
|
id
|
|
417
441
|
name
|
|
@@ -423,9 +447,9 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
423
447
|
description
|
|
424
448
|
}
|
|
425
449
|
}
|
|
426
|
-
lastMileDeliveryBizplaces{
|
|
450
|
+
lastMileDeliveryBizplaces {
|
|
427
451
|
id
|
|
428
|
-
bizplace{
|
|
452
|
+
bizplace {
|
|
429
453
|
id
|
|
430
454
|
name
|
|
431
455
|
}
|
|
@@ -437,7 +461,7 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
437
461
|
context: gqlContext()
|
|
438
462
|
})
|
|
439
463
|
if (!response.errors) {
|
|
440
|
-
this.bizplaceData = response.data?.lastMileDelivery?.lastMileDeliveryBizplaces.map(itm=> itm.bizplace.id)
|
|
464
|
+
this.bizplaceData = response.data?.lastMileDelivery?.lastMileDeliveryBizplaces.map(itm => itm.bizplace.id)
|
|
441
465
|
this._data = {
|
|
442
466
|
...this._data,
|
|
443
467
|
...response.data.lastMileDelivery,
|
|
@@ -450,6 +474,8 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
450
474
|
total: response.data?.lastMileDelivery?.lastMileDeliveryBizplaces.length || 0
|
|
451
475
|
}
|
|
452
476
|
}
|
|
477
|
+
this._staging = response.data?.lastMileDelivery?.staging
|
|
478
|
+
this._awbCustomize = response.data?.lastMileDelivery?.awbCustomize
|
|
453
479
|
}
|
|
454
480
|
const test = this._data.platform
|
|
455
481
|
return
|
|
@@ -459,7 +485,7 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
459
485
|
}
|
|
460
486
|
|
|
461
487
|
_authenticate(e) {
|
|
462
|
-
let lmdId =this.___data.id
|
|
488
|
+
let lmdId = this.___data.id
|
|
463
489
|
location.href = this.getNinjavanAuthUrl(lmdId)
|
|
464
490
|
}
|
|
465
491
|
|
|
@@ -477,7 +503,7 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
477
503
|
const data = {
|
|
478
504
|
client_id,
|
|
479
505
|
scopes: scopes.join(' '),
|
|
480
|
-
state:lmdId
|
|
506
|
+
state: lmdId
|
|
481
507
|
}
|
|
482
508
|
|
|
483
509
|
const qs = Object.entries(data)
|
|
@@ -486,7 +512,7 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
486
512
|
|
|
487
513
|
return `${baseUrl}?${qs}`
|
|
488
514
|
}
|
|
489
|
-
|
|
515
|
+
|
|
490
516
|
async _updateLastMileDelivery(e) {
|
|
491
517
|
try {
|
|
492
518
|
this._validateForm()
|
|
@@ -525,7 +551,11 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
525
551
|
}
|
|
526
552
|
}
|
|
527
553
|
`,
|
|
528
|
-
variables: {
|
|
554
|
+
variables: {
|
|
555
|
+
lastMileDeliveryPatch,
|
|
556
|
+
lastMileDeliverySettingPatch: this._getLmdSettingData(),
|
|
557
|
+
lastMileDeliveryBizplacePatch: this._getLmdBizplaceData()
|
|
558
|
+
},
|
|
529
559
|
context: gqlContext()
|
|
530
560
|
})
|
|
531
561
|
|
|
@@ -544,9 +574,9 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
544
574
|
}
|
|
545
575
|
|
|
546
576
|
async _deleteLastMileDeliveryBizplace() {
|
|
547
|
-
const ids =this._lmdBizplaceGrist.selected.map(record => record.id)
|
|
577
|
+
const ids = this._lmdBizplaceGrist.selected.map(record => record.id)
|
|
548
578
|
|
|
549
|
-
if(!ids?.length){
|
|
579
|
+
if (!ids?.length) {
|
|
550
580
|
CustomAlert({
|
|
551
581
|
title: i18next.t('text.nothing_selected'),
|
|
552
582
|
text: i18next.t('text.there_is_nothing_to_delete')
|
|
@@ -562,25 +592,24 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
562
592
|
|
|
563
593
|
if (!answer.value) return
|
|
564
594
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
595
|
+
const response = await client.mutate({
|
|
596
|
+
mutation: gql`
|
|
597
|
+
mutation deleteLastMileDeliveryBizplaces($ids: [String!]!) {
|
|
598
|
+
deleteLastMileDeliveryBizplaces(ids: $ids)
|
|
599
|
+
}
|
|
600
|
+
`,
|
|
601
|
+
variables: { ids },
|
|
572
602
|
context: gqlContext()
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
603
|
+
})
|
|
604
|
+
if (!response.errors) {
|
|
605
|
+
this._showToast({ message: i18next.t('text.data_deleted_successfully') })
|
|
606
|
+
this._fetchOrder()
|
|
607
|
+
}
|
|
577
608
|
}
|
|
578
609
|
}
|
|
579
|
-
}
|
|
580
610
|
|
|
581
611
|
_validateForm() {
|
|
582
612
|
if (!this._lmdSettingForm.checkValidity()) throw new Error(i18next.t('text.lmd_setting_form_invalid'))
|
|
583
|
-
|
|
584
613
|
}
|
|
585
614
|
|
|
586
615
|
_getFormInfo() {
|
|
@@ -602,7 +631,7 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
602
631
|
})
|
|
603
632
|
}
|
|
604
633
|
|
|
605
|
-
_updateBizplaceGrist(){
|
|
634
|
+
_updateBizplaceGrist() {
|
|
606
635
|
this.bizplaceConfig = {
|
|
607
636
|
pagination: { infinite: true },
|
|
608
637
|
rows: { appendable: true },
|
|
@@ -616,7 +645,7 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
616
645
|
name: 'id',
|
|
617
646
|
hidden: true
|
|
618
647
|
},
|
|
619
|
-
|
|
648
|
+
{
|
|
620
649
|
type: 'object',
|
|
621
650
|
name: 'bizplace',
|
|
622
651
|
record: {
|
|
@@ -630,7 +659,7 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
630
659
|
},
|
|
631
660
|
select: [
|
|
632
661
|
{ name: 'id', hidden: true },
|
|
633
|
-
{ name: 'name', header: i18next.t('field.name') }
|
|
662
|
+
{ name: 'name', header: i18next.t('field.name') }
|
|
634
663
|
]
|
|
635
664
|
}
|
|
636
665
|
},
|
|
@@ -642,27 +671,22 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
642
671
|
}
|
|
643
672
|
}
|
|
644
673
|
|
|
645
|
-
_updateBizplaceFilter(event){
|
|
674
|
+
_updateBizplaceFilter(event) {
|
|
675
|
+
const newBizIds = event.detail.after.bizplace.id
|
|
676
|
+
const oldIds = event.detail.before
|
|
646
677
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
if(oldIds != undefined){
|
|
651
|
-
|
|
652
|
-
let removeIds =event.detail.before.bizplace.id
|
|
653
|
-
this.bizplaceData.pop(removeIds)
|
|
678
|
+
if (oldIds != undefined) {
|
|
679
|
+
let removeIds = event.detail.before.bizplace.id
|
|
680
|
+
this.bizplaceData.pop(removeIds)
|
|
654
681
|
}
|
|
655
682
|
this.bizplaceData.push(newBizIds)
|
|
656
|
-
|
|
657
|
-
|
|
658
683
|
}
|
|
659
684
|
|
|
660
685
|
_getLmdBizplaceData() {
|
|
661
|
-
|
|
662
686
|
return this._lmdBizplaceGrist.dirtyData.records.map(record => {
|
|
663
687
|
let data = {
|
|
664
688
|
id: record.id ? record.id.toString() : null,
|
|
665
|
-
bizplace: record.bizplace
|
|
689
|
+
bizplace: record.bizplace
|
|
666
690
|
}
|
|
667
691
|
|
|
668
692
|
return data
|
|
@@ -681,7 +705,6 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
681
705
|
this._data.lmdSettingData = data
|
|
682
706
|
}
|
|
683
707
|
|
|
684
|
-
|
|
685
708
|
async _tabChange(key) {
|
|
686
709
|
if (key == 'setting') {
|
|
687
710
|
this._showDetailSetting = false
|
|
@@ -693,8 +716,6 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
693
716
|
this.updateContext()
|
|
694
717
|
}
|
|
695
718
|
|
|
696
|
-
|
|
697
|
-
|
|
698
719
|
_clearView() {
|
|
699
720
|
this._data = {
|
|
700
721
|
...this._data,
|
|
@@ -708,9 +729,9 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
708
729
|
soldToAccountId: '',
|
|
709
730
|
accessToken: '',
|
|
710
731
|
accountNumber: '',
|
|
711
|
-
prefix:'',
|
|
732
|
+
prefix: '',
|
|
712
733
|
lmdSettingData: { records: [], total: 0 },
|
|
713
|
-
lmdBizplaceData: { records: [], total
|
|
734
|
+
lmdBizplaceData: { records: [], total: 0 }
|
|
714
735
|
}
|
|
715
736
|
}
|
|
716
737
|
|
|
@@ -729,7 +750,7 @@ class IntegrationLmdDetail extends localize(i18next)(PageView) {
|
|
|
729
750
|
value = parseFloat(field.value)
|
|
730
751
|
}
|
|
731
752
|
obj[field.name] = field.type === 'checkbox' ? field.checked : value
|
|
732
|
-
}else{
|
|
753
|
+
} else {
|
|
733
754
|
obj[field.name] = ''
|
|
734
755
|
}
|
|
735
756
|
})
|
package/dist-server/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getAccessTokenEfmx = exports.refreshAccessTokenNinjavan = exports.generateAccessTokenNinjavan = void 0;
|
|
17
|
+
exports.getAccessTokenCityLink = exports.getAccessTokenEfmx = exports.refreshAccessTokenNinjavan = exports.generateAccessTokenNinjavan = void 0;
|
|
18
18
|
__exportStar(require("./migrations"), exports);
|
|
19
19
|
__exportStar(require("./service"), exports);
|
|
20
20
|
__exportStar(require("./middlewares"), exports);
|
|
@@ -25,6 +25,7 @@ var last_mile_delivery_mutation_1 = require("./service/last-mile-delivery/last-m
|
|
|
25
25
|
Object.defineProperty(exports, "generateAccessTokenNinjavan", { enumerable: true, get: function () { return last_mile_delivery_mutation_1.generateAccessTokenNinjavan; } });
|
|
26
26
|
Object.defineProperty(exports, "refreshAccessTokenNinjavan", { enumerable: true, get: function () { return last_mile_delivery_mutation_1.refreshAccessTokenNinjavan; } });
|
|
27
27
|
Object.defineProperty(exports, "getAccessTokenEfmx", { enumerable: true, get: function () { return last_mile_delivery_mutation_1.getAccessTokenEfmx; } });
|
|
28
|
+
Object.defineProperty(exports, "getAccessTokenCityLink", { enumerable: true, get: function () { return last_mile_delivery_mutation_1.getAccessTokenCityLink; } });
|
|
28
29
|
require("./routes");
|
|
29
30
|
process.on('bootstrap-module-start', async ({ app, config, client }) => { });
|
|
30
31
|
//# sourceMappingURL=index.js.map
|
package/dist-server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,4CAAyB;AACzB,gDAA6B;AAE7B,sDAAmC;AACnC,wDAAqC;AACrC,+DAA4C;AAE5C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,4CAAyB;AACzB,gDAA6B;AAE7B,sDAAmC;AACnC,wDAAqC;AACrC,+DAA4C;AAE5C,wGAA2K;AAAlK,0IAAA,2BAA2B,OAAA;AAAC,yIAAA,0BAA0B,OAAA;AAAC,iIAAA,kBAAkB,OAAA;AAAE,qIAAA,sBAAsB,OAAA;AAE1G,oBAAiB;AAEjB,OAAO,CAAC,EAAE,CAAC,wBAA+B,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAO,EAAE,EAAE,GAAE,CAAC,CAAC,CAAA"}
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getAccessTokenEfmx = exports.refreshAccessTokenNinjavan = exports.generateAccessTokenNinjavan = exports.schema = exports.entities = void 0;
|
|
17
|
+
exports.getAccessTokenCityLink = exports.getAccessTokenEfmx = exports.refreshAccessTokenNinjavan = exports.generateAccessTokenNinjavan = exports.schema = exports.entities = void 0;
|
|
18
18
|
/* EXPORT ENTITY TYPES */
|
|
19
19
|
__exportStar(require("./last-mile-delivery-bizplace/last-mile-delivery-bizplace"), exports);
|
|
20
20
|
__exportStar(require("./last-mile-delivery-setting/last-mile-delivery-setting"), exports);
|
|
@@ -45,4 +45,5 @@ var last_mile_delivery_mutation_1 = require("./last-mile-delivery/last-mile-deli
|
|
|
45
45
|
Object.defineProperty(exports, "generateAccessTokenNinjavan", { enumerable: true, get: function () { return last_mile_delivery_mutation_1.generateAccessTokenNinjavan; } });
|
|
46
46
|
Object.defineProperty(exports, "refreshAccessTokenNinjavan", { enumerable: true, get: function () { return last_mile_delivery_mutation_1.refreshAccessTokenNinjavan; } });
|
|
47
47
|
Object.defineProperty(exports, "getAccessTokenEfmx", { enumerable: true, get: function () { return last_mile_delivery_mutation_1.getAccessTokenEfmx; } });
|
|
48
|
+
Object.defineProperty(exports, "getAccessTokenCityLink", { enumerable: true, get: function () { return last_mile_delivery_mutation_1.getAccessTokenCityLink; } });
|
|
48
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yBAAyB;AACzB,4FAAyE;AACzE,0FAAuE;AACvE,0EAAuD;AACvD,oEAAiD;AAEjD,mCAAmC;AACnC,+EAA4I;AAC5I,6EAAyI;AACzI,6DAAmH;AACnH,uDAA4G;AAE/F,QAAA,QAAQ,GAAG;IACtB,cAAc;IACf,GAAG,sCAAgC;IACnC,GAAG,qCAA+B;IAClC,GAAG,6BAAwB;IAC3B,GAAG,0BAAsB;CACzB,CAAA;AAGY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,sBAAsB;QACxB,GAAG,uCAAiC;QACpC,GAAG,sCAAgC;QACnC,GAAG,8BAAyB;QAC5B,GAAG,2BAAuB;KACzB;CACF,CAAA;AAED,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yBAAyB;AACzB,4FAAyE;AACzE,0FAAuE;AACvE,0EAAuD;AACvD,oEAAiD;AAEjD,mCAAmC;AACnC,+EAA4I;AAC5I,6EAAyI;AACzI,6DAAmH;AACnH,uDAA4G;AAE/F,QAAA,QAAQ,GAAG;IACtB,cAAc;IACf,GAAG,sCAAgC;IACnC,GAAG,qCAA+B;IAClC,GAAG,6BAAwB;IAC3B,GAAG,0BAAsB;CACzB,CAAA;AAGY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,sBAAsB;QACxB,GAAG,uCAAiC;QACpC,GAAG,sCAAgC;QACnC,GAAG,8BAAyB;QAC5B,GAAG,2BAAuB;KACzB;CACF,CAAA;AAED,gGAAqK;AAA5J,0IAAA,2BAA2B,OAAA;AAAC,yIAAA,0BAA0B,OAAA;AAAE,iIAAA,kBAAkB,OAAA;AAAE,qIAAA,sBAAsB,OAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAccessTokenEfmx = exports.refreshAccessTokenNinjavan = exports.generateAccessTokenNinjavan = exports.resolvers = exports.entities = void 0;
|
|
3
|
+
exports.getAccessTokenCityLink = exports.getAccessTokenEfmx = exports.refreshAccessTokenNinjavan = exports.generateAccessTokenNinjavan = exports.resolvers = exports.entities = void 0;
|
|
4
4
|
const last_mile_delivery_1 = require("./last-mile-delivery");
|
|
5
5
|
const last_mile_delivery_query_1 = require("./last-mile-delivery-query");
|
|
6
6
|
const last_mile_delivery_mutation_1 = require("./last-mile-delivery-mutation");
|
|
@@ -10,4 +10,5 @@ var last_mile_delivery_mutation_2 = require("./last-mile-delivery-mutation");
|
|
|
10
10
|
Object.defineProperty(exports, "generateAccessTokenNinjavan", { enumerable: true, get: function () { return last_mile_delivery_mutation_2.generateAccessTokenNinjavan; } });
|
|
11
11
|
Object.defineProperty(exports, "refreshAccessTokenNinjavan", { enumerable: true, get: function () { return last_mile_delivery_mutation_2.refreshAccessTokenNinjavan; } });
|
|
12
12
|
Object.defineProperty(exports, "getAccessTokenEfmx", { enumerable: true, get: function () { return last_mile_delivery_mutation_2.getAccessTokenEfmx; } });
|
|
13
|
+
Object.defineProperty(exports, "getAccessTokenCityLink", { enumerable: true, get: function () { return last_mile_delivery_mutation_2.getAccessTokenCityLink; } });
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/last-mile-delivery/index.ts"],"names":[],"mappings":";;;AAAA,6DAAuD;AACvD,yEAAkE;AAClE,+EAAgI;AAEnH,QAAA,QAAQ,GAAG,CAAC,qCAAgB,CAAC,CAAA;AAC7B,QAAA,SAAS,GAAG,CAAC,gDAAqB,EAAE,sDAAwB,CAAC,CAAA;AAE1E,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/last-mile-delivery/index.ts"],"names":[],"mappings":";;;AAAA,6DAAuD;AACvD,yEAAkE;AAClE,+EAAgI;AAEnH,QAAA,QAAQ,GAAG,CAAC,qCAAgB,CAAC,CAAA;AAC7B,QAAA,SAAS,GAAG,CAAC,gDAAqB,EAAE,sDAAwB,CAAC,CAAA;AAE1E,6EAAmJ;AAA1I,0IAAA,2BAA2B,OAAA;AAAE,yIAAA,0BAA0B,OAAA;AAAE,iIAAA,kBAAkB,OAAA;AAAE,qIAAA,sBAAsB,OAAA"}
|
|
@@ -12,17 +12,17 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getAccessTokenEfmx = exports.refreshAccessTokenNinjavan = exports.generateAccessTokenNinjavan = exports.LastMileDeliveryMutation = void 0;
|
|
15
|
+
exports.getAccessTokenCityLink = exports.getAccessTokenEfmx = exports.refreshAccessTokenNinjavan = exports.generateAccessTokenNinjavan = exports.LastMileDeliveryMutation = void 0;
|
|
16
16
|
const type_graphql_1 = require("type-graphql");
|
|
17
17
|
const typeorm_1 = require("typeorm");
|
|
18
|
-
const
|
|
19
|
-
const last_mile_delivery_type_1 = require("./last-mile-delivery-type");
|
|
18
|
+
const env_1 = require("@things-factory/env");
|
|
20
19
|
const constants_1 = require("../../constants");
|
|
21
|
-
const last_mile_delivery_setting_1 = require("../last-mile-delivery-setting/last-mile-delivery-setting");
|
|
22
|
-
const last_mile_delivery_setting_type_1 = require("../last-mile-delivery-setting/last-mile-delivery-setting-type");
|
|
23
20
|
const last_mile_delivery_bizplace_1 = require("../last-mile-delivery-bizplace/last-mile-delivery-bizplace");
|
|
24
21
|
const last_mile_delivery_bizplace_type_1 = require("../last-mile-delivery-bizplace/last-mile-delivery-bizplace-type");
|
|
25
|
-
const
|
|
22
|
+
const last_mile_delivery_setting_1 = require("../last-mile-delivery-setting/last-mile-delivery-setting");
|
|
23
|
+
const last_mile_delivery_setting_type_1 = require("../last-mile-delivery-setting/last-mile-delivery-setting-type");
|
|
24
|
+
const last_mile_delivery_1 = require("./last-mile-delivery");
|
|
25
|
+
const last_mile_delivery_type_1 = require("./last-mile-delivery-type");
|
|
26
26
|
let LastMileDeliveryMutation = class LastMileDeliveryMutation {
|
|
27
27
|
async createLastMileDelivery(lastMileDelivery, context) {
|
|
28
28
|
const { domain, user, tx } = context.state;
|
|
@@ -68,9 +68,12 @@ let LastMileDeliveryMutation = class LastMileDeliveryMutation {
|
|
|
68
68
|
let id = lmd.id;
|
|
69
69
|
let clientId = lmd.clientId;
|
|
70
70
|
let secretKey = lmd.secretKey;
|
|
71
|
-
if (lmd.platform == 'VIETTEL_POST') {
|
|
71
|
+
if ((lmd === null || lmd === void 0 ? void 0 : lmd.platform) == 'VIETTEL_POST') {
|
|
72
72
|
await this.getViettelTemporaryToken(id, clientId, secretKey, context);
|
|
73
73
|
}
|
|
74
|
+
else if ((lmd === null || lmd === void 0 ? void 0 : lmd.platform) == 'CITYLINK') {
|
|
75
|
+
await getAccessTokenCityLink(id, context);
|
|
76
|
+
}
|
|
74
77
|
await settingPatch.forEach(async (lmdSettingData) => {
|
|
75
78
|
delete lmdSettingData.id;
|
|
76
79
|
let excludePostalCode = lmdSettingData.excludePostalCode;
|
|
@@ -194,14 +197,14 @@ let LastMileDeliveryMutation = class LastMileDeliveryMutation {
|
|
|
194
197
|
const apiPath = '/v2/user/Login';
|
|
195
198
|
const body = {
|
|
196
199
|
USERNAME: lastMileDelivery.clientId,
|
|
197
|
-
PASSWORD: lastMileDelivery.secretKey
|
|
200
|
+
PASSWORD: lastMileDelivery.secretKey
|
|
198
201
|
};
|
|
199
202
|
const response = await fetch(baseUrl + apiPath, {
|
|
200
203
|
method: 'post',
|
|
201
204
|
headers: {
|
|
202
|
-
'Content-Type': 'application/json'
|
|
205
|
+
'Content-Type': 'application/json'
|
|
203
206
|
},
|
|
204
|
-
body: JSON.stringify(body)
|
|
207
|
+
body: JSON.stringify(body)
|
|
205
208
|
});
|
|
206
209
|
const result = await response.json();
|
|
207
210
|
if (response.status != 200) {
|
|
@@ -225,16 +228,16 @@ let LastMileDeliveryMutation = class LastMileDeliveryMutation {
|
|
|
225
228
|
const apiPath = '/v2/user/ownerconnect';
|
|
226
229
|
const body = {
|
|
227
230
|
USERNAME: lastMileDelivery.clientId,
|
|
228
|
-
PASSWORD: lastMileDelivery.secretKey
|
|
231
|
+
PASSWORD: lastMileDelivery.secretKey
|
|
229
232
|
};
|
|
230
233
|
const response = await fetch(baseUrl + apiPath, {
|
|
231
234
|
method: 'post',
|
|
232
235
|
headers: {
|
|
233
236
|
token: temporaryToken,
|
|
234
237
|
'Content-Type': 'application/json',
|
|
235
|
-
|
|
238
|
+
Cookie: 'SERVERID=A'
|
|
236
239
|
},
|
|
237
|
-
body: JSON.stringify(body)
|
|
240
|
+
body: JSON.stringify(body)
|
|
238
241
|
});
|
|
239
242
|
const result = await response.json();
|
|
240
243
|
if (response.status != 200) {
|
|
@@ -423,9 +426,11 @@ async function refreshAccessTokenNinjavan(id, context) {
|
|
|
423
426
|
const { refresh_token: refreshToken, expires_in: expiresIn, access_token: accessToken } = result;
|
|
424
427
|
const currentTimestamp = Math.floor(Date.now() / 1000);
|
|
425
428
|
const expiryTimestamp = currentTimestamp + expiresIn;
|
|
426
|
-
lastMileDelivery = await tx
|
|
429
|
+
lastMileDelivery = await tx
|
|
430
|
+
.getRepository(last_mile_delivery_1.LastMileDelivery)
|
|
431
|
+
.update({ id: lastMileDelivery.id }, { accessToken: accessToken, refreshToken: refreshToken, expiresIn: expiryTimestamp });
|
|
427
432
|
lastMileDelivery = await tx.getRepository(last_mile_delivery_1.LastMileDelivery).findOne({
|
|
428
|
-
where: { id }
|
|
433
|
+
where: { id }
|
|
429
434
|
});
|
|
430
435
|
}
|
|
431
436
|
catch (e) {
|
|
@@ -464,9 +469,11 @@ async function getAccessTokenEfmx(id, clientId, secretKey, context) {
|
|
|
464
469
|
const expiryTimestamp = currentTimestamp + expiresIn;
|
|
465
470
|
lastMileDelivery.expiresIn = expiryTimestamp;
|
|
466
471
|
lastMileDelivery.accessToken = accessToken;
|
|
467
|
-
lastMileDelivery = await tx
|
|
472
|
+
lastMileDelivery = await tx
|
|
473
|
+
.getRepository(last_mile_delivery_1.LastMileDelivery)
|
|
474
|
+
.update({ id: lastMileDelivery.id }, { accessToken: accessToken, refreshToken: refreshToken, expiresIn: expiryTimestamp });
|
|
468
475
|
lastMileDelivery = await tx.getRepository(last_mile_delivery_1.LastMileDelivery).findOne({
|
|
469
|
-
where: { id }
|
|
476
|
+
where: { id }
|
|
470
477
|
});
|
|
471
478
|
}
|
|
472
479
|
catch (e) {
|
|
@@ -475,4 +482,53 @@ async function getAccessTokenEfmx(id, clientId, secretKey, context) {
|
|
|
475
482
|
return lastMileDelivery;
|
|
476
483
|
}
|
|
477
484
|
exports.getAccessTokenEfmx = getAccessTokenEfmx;
|
|
485
|
+
async function getAccessTokenCityLink(id, context) {
|
|
486
|
+
const { tx } = context.state;
|
|
487
|
+
let lastMileDelivery = await tx.getRepository(last_mile_delivery_1.LastMileDelivery).findOne({ where: { id } });
|
|
488
|
+
try {
|
|
489
|
+
const staging = lastMileDelivery.staging;
|
|
490
|
+
const currentDate = new Date();
|
|
491
|
+
const transactionIdentifier = `CTL${currentDate.getFullYear()}${currentDate.getMonth() + 1}${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`;
|
|
492
|
+
const accountNumber = lastMileDelivery === null || lastMileDelivery === void 0 ? void 0 : lastMileDelivery.accountNumber;
|
|
493
|
+
const meterNumber = lastMileDelivery === null || lastMileDelivery === void 0 ? void 0 : lastMileDelivery.prefix;
|
|
494
|
+
const companyCode = lastMileDelivery === null || lastMileDelivery === void 0 ? void 0 : lastMileDelivery.clientId;
|
|
495
|
+
const url = staging
|
|
496
|
+
? 'https://devsvr2019a.citylinkexpress.com:21145/CitylinkService.svc/rest/requestToken'
|
|
497
|
+
: 'https://2802rj02.citylinkexpress.com:9289/CitylinkService.svc/rest/requestToken';
|
|
498
|
+
const response = await fetch(url, {
|
|
499
|
+
method: 'post',
|
|
500
|
+
headers: {
|
|
501
|
+
'Content-Type': 'application/json',
|
|
502
|
+
CompanyCode: companyCode,
|
|
503
|
+
AccountNumber: accountNumber,
|
|
504
|
+
MeterNumber: meterNumber,
|
|
505
|
+
TransactionIdentifier: transactionIdentifier
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
const result = await response.json();
|
|
509
|
+
if (result.returncode != '00') {
|
|
510
|
+
throw new Error(result.returnmessage);
|
|
511
|
+
}
|
|
512
|
+
const { expiryDate: expiryDate, token: token } = result;
|
|
513
|
+
let splitDate = expiryDate.split('/');
|
|
514
|
+
let dd = splitDate[0];
|
|
515
|
+
let mm = splitDate[1];
|
|
516
|
+
let yy = splitDate[2];
|
|
517
|
+
let formatDate = mm + '/' + dd + '/' + yy;
|
|
518
|
+
let newExpiryDate = new Date(formatDate);
|
|
519
|
+
lastMileDelivery.accessToken = token;
|
|
520
|
+
lastMileDelivery.expiresIn = newExpiryDate;
|
|
521
|
+
lastMileDelivery = await tx
|
|
522
|
+
.getRepository(last_mile_delivery_1.LastMileDelivery)
|
|
523
|
+
.update({ id: lastMileDelivery.id }, { accessToken: token, expiresIn: newExpiryDate });
|
|
524
|
+
lastMileDelivery = await tx.getRepository(last_mile_delivery_1.LastMileDelivery).findOne({
|
|
525
|
+
where: { id }
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
catch (e) {
|
|
529
|
+
env_1.logger.error(`[city-link-accessToken-log] ${e.message}`);
|
|
530
|
+
}
|
|
531
|
+
return lastMileDelivery;
|
|
532
|
+
}
|
|
533
|
+
exports.getAccessTokenCityLink = getAccessTokenCityLink;
|
|
478
534
|
//# sourceMappingURL=last-mile-delivery-mutation.js.map
|