xml-toolkit 1.0.31 → 1.0.33

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.
Files changed (38) hide show
  1. package/lib/XMLMarshaller.js +1 -1
  2. package/package.json +4 -2
  3. package/test/20040.wsdl +0 -1812
  4. package/test/20186.wsdl +0 -114
  5. package/test/30017.xsd +0 -62
  6. package/test/30282.xsd +0 -29
  7. package/test/E05a.xml +0 -5
  8. package/test/F9ASyncService.xsd +0 -33
  9. package/test/F9ASyncService_1.wsdl +0 -72
  10. package/test/F9ASyncService_1.xsd +0 -43
  11. package/test/F9ASyncService_1_2.xsd +0 -42
  12. package/test/F9SyncService.xsd +0 -19
  13. package/test/F9SyncService_1.xsd +0 -33
  14. package/test/F9SyncService_1_2.xsd +0 -42
  15. package/test/commons/dom-gosuslugi-ru-smev3-common.xsd +0 -465
  16. package/test/commons/fns-common-types.xsd +0 -1993
  17. package/test/commons/fns-dohflna-types.xsd +0 -524
  18. package/test/commons/pfr-common-types-1.0.0.xsd +0 -29
  19. package/test/commons/smev-supplementary-commons-1.0.1.xsd +0 -689
  20. package/test/commons/smev-supplementary-commons.xsd +0 -689
  21. package/test/dom-gosuslugi-ru-smev3-debt-responses.xsd +0 -776
  22. package/test/ent.xml +0 -6
  23. package/test/fns-dohflna-ru-root.xsd +0 -299
  24. package/test/fns-inn-singular-ru-root.xsd +0 -62
  25. package/test/fns-innfdrfio-root.xsd +0 -89
  26. package/test/not-sa01.xml +0 -10
  27. package/test/not-sa02.xml +0 -30
  28. package/test/param_types.xml +0 -1
  29. package/test/sign.xsd +0 -71
  30. package/test/smev-message-exchange-basic-1.1.xsd +0 -380
  31. package/test/smev-message-exchange-faults-1.1.xsd +0 -365
  32. package/test/smev-message-exchange-service-1.1.xsd +0 -643
  33. package/test/smev-message-exchange-types-1.1.xsd +0 -697
  34. package/test/snils-by-additionalData-1.0.1.xsd +0 -29
  35. package/test/soap.xml +0 -40
  36. package/test/supplementary/fns-common-types.xsd +0 -430
  37. package/test/supplementary/smev-supplementary-commons.xsd +0 -689
  38. package/test/test.js +0 -520
package/test/test.js DELETED
@@ -1,520 +0,0 @@
1
- const fs = require ('fs')
2
- const assert = require ('assert')
3
- const {XMLReader, SAXEvent, XMLLexer, AttributesMap, XMLNode, XMLSchemata, SOAP11, SOAP12, EntityResolver, XMLIterator, XMLParser, SOAPFault, SOAP} = require ('../')
4
-
5
- async function test_001_lexer_sync (fn) {
6
-
7
- const xml = fs.readFileSync (
8
- 'test/' + fn
9
- // , 'utf-8'
10
- )
11
-
12
- console.log (xml)
13
-
14
- const lexer = new XMLLexer ({
15
- // maxLength: 40,
16
- // encoding: 'ascii',
17
- })
18
-
19
-
20
- lexer.on ('data', data => {
21
-
22
- const e = new SAXEvent (data)
23
-
24
- console.log ([e, e.type])
25
-
26
- })
27
-
28
- // for (let c of xml) lexer.write (c); lexer.end ()
29
- // for (let c of xml) lexer.write (Buffer.from ([c])); lexer.end ()
30
-
31
- lexer.end (xml)
32
-
33
- }
34
-
35
- async function test_002_lexer_stream (fn) {
36
-
37
- const is = fs.createReadStream ('test/' + fn, {
38
- // encoding: 'utf8',
39
- })
40
-
41
- const lexer = new XMLLexer ({
42
- // maxLength: 40,
43
- // encoding: 'ascii',
44
- })
45
-
46
- is.pipe (lexer)
47
-
48
- for await (const i of lexer)
49
- // if (/^<PARAMTYPE /.test (i))
50
- {
51
- console.log ({i})
52
-
53
- }
54
-
55
- }
56
-
57
-
58
- async function test_003_emitter_sync (fn) {
59
-
60
- const xml = fs.readFileSync (
61
- 'test/' + fn
62
- , 'utf-8'
63
- )
64
-
65
- console.log (xml)
66
-
67
- const sax = new XMLReader ({
68
- // stripSpace: true,
69
- // filterElements: 'root',
70
- // filterElements: 'PARAMTYPES'
71
- filterElements: 'SendRequestRequest',
72
- map: n => n.detach ({nsMap: true}),
73
- // map: XMLNode.toObject ({
74
- // wrap: 1,
75
- // getName: (localName, namespaceURI) => (!namespaceURI ? '' : '{' + namespaceURI + '}') + localName,
76
- // map: o => Object.fromEntries (Object.entries (o).map (([k, v]) => [k + '111', v]))
77
- // })
78
- })
79
-
80
- /*
81
- for (let event of [
82
- 'data',
83
- 'close',
84
- 'end',
85
- 'finish',
86
- // 'EndElement',
87
- ]) sax.on (event, data => {
88
-
89
- console.log ([JSON.stringify (data, null, 2), event])
90
-
91
- })
92
- */
93
-
94
-
95
- //console.log (sax)
96
- //console.log (sax.isSAX)
97
-
98
- /*
99
- let s = ''
100
- for await (const e of sax) {
101
- s += xml
102
- // console.log ([e.type, e.isStartElement, e.isEndElement , e.isCharacters])
103
- }
104
- */
105
- //console.log ([xml, s])
106
-
107
- const v = await sax.process (xml).findFirst ()
108
-
109
- console.log (JSON.stringify (v, null, 2))
110
-
111
- }
112
-
113
- async function test_004_schemata (fn) {
114
-
115
- let xs = await XMLSchemata.fromFile ('test/dom-gosuslugi-ru-smev3-debt-responses.xsd')
116
- let xss = new XMLSchemata ('test/dom-gosuslugi-ru-smev3-debt-responses.xsd')
117
- /*
118
- const localName = 'ImportDebtRequestsRequest'
119
-
120
- const s = xs.getSchemaByLocalName (localName)
121
-
122
- const o = s.get (localName)
123
-
124
- const nspm = xs.getNamespacePrefixesMap (o)
125
-
126
- console.log (xs.stringify ({
127
- "ExportDebtRequestsRequest": {Id: 1}
128
- }))
129
- */
130
-
131
- const d = {
132
- "ExportDebtRequestsResponse": {
133
- "request-data": {
134
- "request-id": "bac4c940-6ad3-11eb-9439-0242ac130002",
135
- "request-number": "022021173",
136
- "applicant-info": {
137
- "firstname": "Иван",
138
- "lastname": "Иванов",
139
- "middlename": "Иванович",
140
- "snils": "11111111145",
141
- "document": {
142
- "type": "1",
143
- "series": "1234",
144
- "number": "123456"
145
- }
146
- },
147
- "housing-fund-object": {
148
- "house-id": "e786b770-28e6-4557-8dde-86e8e347587e",
149
- "address-details": "кв. 27",
150
- "fias-house-id": "497cdeef-0388-466b-a063-36f51d94800c",
151
- "address": "153045, Ивановская обл, г. Иваново, ул. 3 Июня, д. 14"
152
- },
153
- "period": {
154
- "start-date": "2018-02-01",
155
- "end-date": new Date ()
156
- },
157
- "organization": {
158
- "organization-root-id": "6eef689e-48bb-4eb0-9c11-18b6db9909b7",
159
- "name": "Администрация г. Иваново",
160
- "tel": "+7(4932)32-80-83"
161
- },
162
- "executor-info": {
163
- "id": "84b12e02-6ad8-11eb-9439-0242ac130002",
164
- "fio": "Четвертак Иван Иванович"
165
- },
166
- "status": "PROCESSED",
167
- "result": 4,
168
- "creation-date": "2021-02-04",
169
- "sent-date": "2021-02-04",
170
- "response-date": "2021-02-08",
171
- "subrequest": {
172
- "organization": {
173
- "organization-root-id": "ad50290c-6ad9-11eb-9439-0242ac130002",
174
- "name": "УК ООО \"ГУЖФ\"",
175
- "tel": "8-800-200-50-58"
176
- },
177
- "response": {
178
- "type": "PROVIDED",
179
- "has-debt": true,
180
- "debt-info": [
181
- {
182
- "person": {
183
- "firstname": "Петр",
184
- "lastname": "Петров",
185
- "middlename": "Петрович",
186
- "snils": "11111111146",
187
- "document": {
188
- "type": "1",
189
- "series": "1235",
190
- "number": "123455"
191
- }
192
- }
193
- },
194
- {
195
- "person": {
196
- "firstname": "Сидор",
197
- "lastname": "Сидоров",
198
- "middlename": "Сидорович",
199
- "snils": "11111111146",
200
- "document": {
201
- "type": "1",
202
- "series": "1235",
203
- "number": "123455"
204
- }
205
- }
206
- }
207
- ],
208
- "executor-info": {
209
- "id": "38a794b8-6ada-11eb-9439-0242ac130002",
210
- "fio": "Герасимова Ольга Ивановна"
211
- }
212
- }
213
- }
214
- }
215
- }
216
- }
217
- console.log (xs.stringify (d))
218
- console.log (xss.stringify (d))
219
-
220
- //getNamespacePrefixesMap
221
- /*
222
- console.log (xs.get ('urn:dom.gosuslugi.ru/debt-requests/1.0.0').get ('ImportDebtRequestsRequest').complexType.complexContent.extension)
223
-
224
- console.log (xs.get ('urn:dom.gosuslugi.ru/common/1.2.0').get ('BaseRequestType').sequence )
225
-
226
- console.log (xs.get ('urn:dom.gosuslugi.ru/debt-requests/1.0.0').get ('ActionType').restriction)
227
- */
228
-
229
- console.log (xs.stringify ({
230
- "ExportDebtRequestsRequest": {Id: 1}
231
- }))
232
- console.log (xss.stringify ({
233
- "ExportDebtRequestsRequest": {Id: 1}
234
- }))
235
-
236
- // console.log (xs.get ('urn:dom.gosuslugi.ru/debt-responses/1.0.0').get ('AttachmentType'))
237
-
238
- }
239
-
240
- async function test_005_schemata (fn) {
241
-
242
- const xs = await XMLSchemata.fromFile ('test/20040.wsdl')
243
- const xss = new XMLSchemata ('test/20040.wsdl')
244
-
245
- const data = {
246
-
247
- "AppData": {
248
- "info": {
249
- "person": {
250
- "fNameCiv": "ППП",
251
- "iNameCiv": "ППП",
252
- "mNameCiv": null,
253
- "docDatCiv": "1973-03-01"
254
- },
255
- "snils": "022-114-680 91",
256
- "document": {
257
- "codeKind": "01",
258
- "numDoc": "999999",
259
- "seriesDoc": "9999",
260
- "dateDoc": "2022-03-05"
261
- },
262
- "startDate": "2021-08-01",
263
- "endDate": "2022-01-31T00:00:00",
264
- "child": {
265
- "fNameCiv": "ООО",
266
- "iNameCiv": "ООО",
267
- "mNameCiv": null,
268
- "docDatCiv": "2022-02-08"
269
- },
270
- "childDocument": {
271
- "codeKind": "03",
272
- "numDoc": "333333",
273
- "seriesDoc": "333333333",
274
- "dateDoc": "2022-03-01"
275
- },
276
- "childSnils": "109-598-827 12"
277
- }
278
- }
279
-
280
- }, {info} = data.AppData
281
-
282
- // const m = xs.createMarshaller ('AppDataChildDotation', 'http://smev.gosuslugi.ru/rev111111')
283
-
284
- const d = {childDotation2Request: {
285
- Message: {
286
- TestMsg: "Тестовый запроc",
287
- },
288
- MessageData: {
289
- AppData: {
290
- info
291
- }
292
- }
293
- }}
294
-
295
- console.log (xs.stringify (d))
296
- console.log (xss.stringify (d))
297
-
298
- }
299
-
300
- async function test_006_schemata (fn) {
301
-
302
- const xs = await XMLSchemata.fromFile ('test/snils-by-additionalData-1.0.1.xsd')
303
- const xss = new XMLSchemata ('test/snils-by-additionalData-1.0.1.xsd')
304
-
305
- const data = {
306
- "SnilsByAdditionalDataRequest": {
307
- "FamilyName": "ИВАНОВ",
308
- "FirstName": "ИВАН",
309
- "Patronymic": "ИВАНОВИЧ",
310
- "BirthDate": "1967-05-21",
311
- "Gender": "Male",
312
- "BirthPlace": {
313
- "PlaceType": "ОСОБОЕ",
314
- "Settlement": "ЗАГОРСК",
315
- "District": "ЛЕНИНСКИЙ",
316
- "Region": "МОСКОВСКАЯ ОБЛАСТЬ",
317
- "Country": "РФ"
318
- },
319
- "PassportRF": {
320
- "Series": "0005",
321
- "Number": "777777",
322
- "IssueDate": "1986-06-13",
323
- "Issuer": "ОВД"
324
- }
325
- }
326
- }
327
-
328
- // const m = xs.createMarshaller ('AppDataChildDotation', 'http://smev.gosuslugi.ru/rev111111')
329
-
330
- console.log (xs.stringify (data))
331
- console.log (xss.stringify (data))
332
-
333
- }
334
-
335
- function test_007_wsdl (fn) {
336
-
337
- const soap11 = new SOAP11 ('test/20186.wsdl')
338
- const soap12 = new SOAP12 ('test/20186.wsdl')
339
-
340
- const d = {"GetForm9Sync":{"person":{"LastName":"ИВАНОВА","FirstName":"ПЕТР","SecondName":null,"BirthDate":"1970-11-11"},"address":{"Region":{"Code":"78","Name":"Санкт-Петербург"},"Street":{"Code":6597,"Name":"Московский пр-кт"},"House":"д. 18 литера Е","Flat":"33"}}}
341
-
342
- console.log (soap11.http (d))
343
- console.log (soap12.http (d))
344
-
345
- }
346
-
347
- async function test_008_schemata (fn) {
348
-
349
- const xs = await XMLSchemata.fromFile ('test/30017.xsd')
350
- const xss = new XMLSchemata ('test/30017.xsd')
351
-
352
- const data =
353
-
354
- {"FNSINNSingularRequest":
355
- {
356
- "СведЮЛ": {
357
- "ОГРН":"1037843048880",
358
- "ИННЮЛ":"7825497650",
359
- "НаимОрг":"Нагрузочное тестирование"
360
- },
361
- "СведФЛ": {
362
- "ДатаРожд":"1973-07-14",
363
- "МестоРожд":null,
364
- "ФИО":{
365
- "Фамилия":"ВАЛЕРЬЕВНА",
366
- "Имя":"1973-07-14",
367
- "Отчество":"1973-07-14"
368
- },
369
- "УдЛичнФЛ":{
370
- "КодВидДок":"21",
371
- "ВыдДок":"11",
372
- "КодВыдДок":"111 111",
373
- "ДатаДок":"2022-10-01",
374
- "СерНомДок":"11 11 111111"}
375
- },
376
- "ИдЗапрос":"7daf950d-d71c-ea20-eaa9-5096324ca3b3"
377
- }
378
- }
379
-
380
- // console.log (xs)
381
-
382
- console.log (xs.stringify (data))
383
- console.log (xss.stringify (data))
384
-
385
- }
386
-
387
- async function test_009_schemata (fn) {
388
-
389
- const xs = new XMLSchemata ('test/' + fn)
390
-
391
- // console.log (xs)
392
-
393
- // console.log (xs.stringify ({AckResponse: null}))
394
-
395
- const data = {
396
- AckRequest: {
397
- // AckTargetMessage: {Id: 1, accepted: true, null: 2},
398
- AckTargetMessage: 11111,
399
- }
400
- }
401
-
402
- console.log (xs.stringify (data))
403
-
404
- }
405
-
406
- function test_010_node () {
407
-
408
- for (const s of
409
- [
410
- '<a />zzz',
411
- 'zzz<b>',
412
- '<!-- 111 -->222',
413
- '<![CDATA[ >>]>>]]>zzz',
414
- '<?xml version="3.11"?><a/>',
415
- ]
416
- ) {
417
-
418
- let n = new XMLNode (s)
419
-
420
- n.trim ()
421
-
422
- console.log (n)
423
-
424
- }
425
-
426
- }
427
-
428
- function test_011_iterator (fn) {
429
-
430
- const xml = fs.readFileSync (
431
- 'test/' + fn
432
- , 'utf-8'
433
- )
434
-
435
- console.log (xml)
436
-
437
- for (const i of new XMLIterator (xml)) {
438
-
439
- console.log ([i, i.detach ()])
440
-
441
- }
442
-
443
- }
444
-
445
- function test_012_parser (fn) {
446
-
447
- const xml = fs.readFileSync (
448
- 'test/' + fn
449
- , 'utf-8'
450
- )
451
-
452
- //console.log (new XMLParser ().process (xml).detach ())
453
-
454
- const parser = new XMLParser ({})
455
- const doc = parser.process (xml)
456
-
457
- for (const element of doc.children) {
458
- console.log (element)
459
- }
460
-
461
- }
462
-
463
- function test_013_soap () {
464
-
465
- const xs11 = new XMLSchemata ('lib/soap-1.1.xsd')
466
-
467
- const detail = `
468
- <PO:order xmlns:PO="http://gizmos.com/orders/">Quantity element does not have a value</PO:order>
469
- <PO:confirmation xmlns:PO="http://gizmos.com/confirm">Incomplete address: no zip code</PO:confirmation>
470
- `
471
-
472
- const f =
473
- new SOAPFault ('Message does not have necessary info', {
474
- code: 'Client',
475
- actor: 'http://gizmos.com/order',
476
- detail
477
- })
478
-
479
- console.log (SOAP (1.1).message (f, '', {declaration: {}}))
480
- // console.log (SOAP (1.2).message (f))
481
-
482
- }
483
-
484
-
485
- async function main () {
486
-
487
- // await test_001_lexer_sync ('E05a.xml')
488
- //await test_001_lexer_sync ('not-sa01.xml')
489
- // await test_001_lexer_sync ('not-sa02.xml')
490
- // await test_001_lexer_sync ('param_types.xml')
491
- // await test_002_lexer_stream ('E05a.xml')
492
- // await test_002_lexer_stream ('param_types.xml')
493
- // await test_002_lexer_stream ('not-sa02.xml')
494
- // await test_003_emitter_sync ('E05a.xml')
495
- // await test_003_emitter_sync ('param_types.xml')
496
- // await test_003_emitter_sync ('not-sa01.xml')
497
- // await test_003_emitter_sync ('ent.xml')
498
- // await test_003_emitter_sync ('soap.xml')
499
-
500
- // await test_004_schemata ()
501
- // await test_005_schemata ()
502
- // await test_006_schemata ()
503
- // test_007_wsdl ()
504
- // await test_008_schemata ()
505
-
506
- // test_009_schemata ('smev-message-exchange-service-1.1.xsd')
507
- // test_009_schemata ('sign.xsd')
508
-
509
- // test_010_node ()
510
- // test_011_iterator ('param_types.xml')
511
- // test_011_iterator ('20040.wsdl')
512
-
513
- // test_012_parser ('param_types.xml')
514
- // test_012_parser ('20040.wsdl')
515
-
516
- test_013_soap ()
517
-
518
- }
519
-
520
- main ()