-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmsg_type_defs.js
executable file
·213 lines (197 loc) · 8.18 KB
/
msg_type_defs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
// Introduction to GDSN Messaging
//
// In each GDSN xml message file, there is a single "message" element (namespace eanucc="urn:ean.ucc:2")
// which contains a mandatory "entityIdentification" element and some number of "any" elements.
//
// The "type" of the xml message document tells us what kind of "any" elements to expect,
// and is specified by the following required header element: DocumentIdentification.Type
// (or StandardBusinessDocument.StandardBusinessDocumentHeader.DocumentIdentification.Type)
//
// Here is the list of message types we are concerned with:
//
// 1. basicPartyRegistration
// 2. catalogueItemRegistration
// 3. catalogueItemPublication
// 4. catalogueItemSubscription
// 5. catalogueItemNotification
// 6. catalogueItemConfirmation
// 7. requestForCatalogueItemNotification
// 8. registryPartyDataDump
// 9. gS1Response (includes partyRegistrationResponse and catalogueItemRegistrationResponse, transactionResponse (ACCEPTED), and gS1Exception)
//
// The first 8 types are straightforward: the message may contain several transaction/command/documentCommand structures,
// each containing:
//
// 1. documentCommandHeader@type (e.g. ADD, CHANGE_BY_REFRESH, CORRECT, DELETE)
// *. value should be the same throughout the message if present multiple times
//
// 2. documentCommandOperand containing some number of "document" instances of the msg type
// *. document subtype should be the same throughout the message if multiple instances present
//
// For the last type in the list (gS1Response), there are 4 subtypes (3 accepted and 1 exception),
// all are potentially multiple but should not be mixed in the same message:
//
// 1. partyRegistrationResponse (GR response to DP BPR)
// *. msg_info.status == "ACCEPTED"
// *. responseIdentification.uniqueCreatorIdentification (DOC level from orig BPR)
// *. partyRegistrationInformation.lastChangedDate
// *. partyRegistrationInformation.registrationDate
// *. partyRegistrationInformation.removedDate (optional)
// *. partyReference (GLN of modified party)
// *. msg_info.sender = config.gln_gdsn_gr
//
// 2. catalogueItemRegistrationResponse (GR response to DP CIR)
// *. msg_info.status == "ACCEPTED"
// *. responseIdentification.uniqueCreatorIdentification (DOC level from orig msg)
// *. catalogueItemRegistrationInformation @lastChangedDate @registrationDate
// *. catalogueItemReference
// .gtin
// .dataSource (provider GLN)
// .targetMarket.targetMarketCountryCode.countryISOCode (e.g. 840)
// .targetMarket.targetMarketSubdivisionCode.countrySubDivisionISOCode (e.g. US-CA)
//
// 3. gS1Response > transactionResponse (generic DP response to CIP, CIS, CIN, CIC, RFCIN, BPR)
// *. msg_info.status == "ACCEPTED"
// *. msg_info.transactions == $('transactionResponse > transactionIdentifier > entityIdentification', gS1Response)
//
// 4. gS1Response > gS1Exception: - some number of "gS1Error" and other elements:
// *. > messageException
// *. > transactionException > commandException > documentExcecption > attributeException
// each with optional gS1Error list:
// *. > gS1Error > errorCode
// *. > gS1Error > errorDateTime
// *. > gS1Error > errorDescription
//
module.exports = messageTypes = {
bpr : _.find(templates, function () { arguments[0]['name'] == 'bpr'})
,cir : _.find(templates, function () { arguments[0]['name'] == 'cir'})
,cip : _.find(templates, function () { arguments[0]['name'] == 'cip'})
,cis : _.find(templates, function () { arguments[0]['name'] == 'cis'})
,cin : _.find(templates, function () { arguments[0]['name'] == 'cin'})
,cic : _.find(templates, function () { arguments[0]['name'] == 'cic'})
,rfcin : _.find(templates, function () { arguments[0]['name'] == 'rfcin'})
,rpdd : _.find(templates, function () { arguments[0]['name'] == 'rpdd'})
,hier : _.find(templates, function () { arguments[0]['name'] == 'hier'})
,error : _.find(templates, function () { arguments[0]['name'] == 'error'})
,accepted: _.find(templates, function () { arguments[0]['name'] == 'accepted'})
}
messageTypes.msg_info = function (msg_type_code) {
return this[msg_type_code]
}
var templates = [
{ name: 'bpr'
, msg_type: 'basicPartyRegistration'
, status : ['ADD', 'CORRECT', 'CHANGE_BY_REFRESH', 'DELETE']
},
{ name: 'cir'
, msg_type: 'catalogueItemRegistration'
, gtin:
, provider:
, tm:
, tm_sub:
, status : ['ADD', 'CORRECT']
},
{ name: 'cip'
, msg_type: 'catalogueItemPublication'
, gtin:
, provider:
, tm:
, tm_sub:
, recipient:
, initial_load:
, status : ['ADD', 'DELETE']
},
{ name: 'cis'
, msg_type: 'catalogueItemSubscription'
, gtin:
, provider:
, tm:
, gpc:
, recipient:
, status : ['ADD', 'DELETE']
},
{ name: 'cin'
, gtin:
, provider:
, tm:
, tm_sub:
, recipient
, status : ['ADD', 'CORRECT', 'CHANGE_BY_REFRESH', 'DELETE']
},
{ name: 'cic'
, msg_type: 'catalogueItemConfirmation'
, status: ['ACCEPTED', 'REJECTED', 'REVIEW', 'SYNCHRONISED']
},
{ name: 'rfcin'
, msg_type: 'requestForCatalogueItemNotification'
, status : ['ADD']
},
{ name: 'rpdd'
, msg_type: 'registryPartyDataDump'
, status : ['ADD']
},
{ name: 'cih'
, msg_type: 'catalogueItemHierarchyWithdrawal'
, status : ['CORRECT']
},
{ name: 'accepted'
, msg_type: 'gS1Response'
, status: ['ACCEPTED']
},
{ name: 'error'
, msg_type: 'gS1Response'
, status: ['ERROR']
},
{ name: 'cin_from_local_tp',
direction: 'inbound',
description: 'can contain only one publication (item hierarchy)',
msg_type: 'catalogueItemNotification',
created: 'message timestamp, assume we can use this as trade item timestamp for update trigger',
sender: 'gln of local DSTP',
receiver: 'gln of home data pool',
dataRecipient: 'gln of home data pool',
infoProvider: 'gln of DSTP (local party)',
source_dp: 'gln of home data pool',
root_gtins: 'array of gtins for each hierarchy root trade item',
gtins: 'array of gtins for all trade items'
},
{ name: 'cin_from_other_dp',
direction: 'inbound',
description: 'can contain many publications (item hierarchies) from a single DSTP, sent via partner SDP',
msg_type: 'catalogueItemNotification',
created: 'message timestamp, assume we can use this as trade item timestamp for update trigger',
sender: 'gln of other data pool',
receiver: 'gln of home data pool',
dataRecipient: 'gln of DRTP (local subscribing party), assume only 1 per message',
infoProvider: 'gln of DSTP (remote publishing party), assume only 1 per message',
source_dp: 'gln of other data pool',
root_gtins: 'array of gtins for each hierarchy root trade item',
gtins: 'array of gtins for all trade items'
},
{ name: 'cin_to_local_tp_for_remote_ds',
direction: 'outbound',
description: 'can contain many publications (item hierarchies) from a single DSTP',
msg_type: 'catalogueItemNotification',
created: 'message timestamp, assume we can use this as trade item timestamp for update trigger',
sender: 'gln of home data pool',
receiver: 'gln of local party',
dataRecipient: 'gln of DRTP (local subscribing party), assume only 1 per message',
infoProvider: 'gln of DSTP (remote publishing party), assume only 1 per message',
source_dp: 'gln of other data pool',
root_gtins: 'array of gtins for each hierarchy root trade item',
gtins: 'array of gtins for all trade items'
},
{ name: 'cin_to_local_tp_for_local_ds',
direction: 'outbound',
description: 'can contain only one publication (item hierarchy) from a local DSTP',
msg_type: 'catalogueItemNotification',
created: 'message timestamp, assume we can use this as trade item timestamp for update trigger',
sender: 'gln of home data pool',
receiver: 'gln of local party',
dataRecipient: 'gln of DRTP (local subscribing party), assume only 1 per message',
infoProvider: 'gln of DSTP (local publishing party), assume only 1 per message',
source_dp: 'gln of home data pool',
root_gtins: 'array of gtins for each hierarchy root trade item',
gtins: 'array of gtins for all trade items'
}
]