rust_iso20022 0.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/LICENSE +201 -0
- package/README.md +139 -0
- package/package.json +28 -0
- package/rust_iso20022.d.ts +177 -0
- package/rust_iso20022.js +626 -0
- package/rust_iso20022_bg.wasm +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2022 rust-iso3166 contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# rust_iso20022
|
|
2
|
+
|
|
3
|
+
A Rust library for ISO 20022 (MX / SWIFT) financial messages, generated from the
|
|
4
|
+
official iso20022.org XSD schemas. It provides a strongly-typed model for MX
|
|
5
|
+
messages with XML and JSON parsing/serialization, message identification, a
|
|
6
|
+
generic message tree for reading any message without the model, and business
|
|
7
|
+
metadata extraction.
|
|
8
|
+
|
|
9
|
+
## What's in the crate
|
|
10
|
+
|
|
11
|
+
| Layer | Module | Always available? |
|
|
12
|
+
|-------|--------|-------------------|
|
|
13
|
+
| Core | (root) | yes — `MxId`, `BusinessArea`, `from_xml`/`to_xml`, `detect`, `MxNode`, `Error` |
|
|
14
|
+
| Catalogue | `catalogue` | yes — every message id + namespace as static [`phf`](https://crates.io/crates/phf) tables |
|
|
15
|
+
| Model | `generated` | per area — `generated::<area>::<msg>::Document`, enable with `model-<area>` |
|
|
16
|
+
|
|
17
|
+
**Coverage:** a typed model is generated for **1130** message versions across
|
|
18
|
+
**32** business areas (`acmt`, `admi`, `auth`, `caaa`, `caad`, `caam`, `cafc`,
|
|
19
|
+
`cafm`, `cafr`, `cain`, `camt`, `canm`, `casp`, `casr`, `catm`, `catp`, `colr`,
|
|
20
|
+
`fxtr`, `head`, `pacs`, `pain`, `reda`, `remt`, `secl`, `seev`, `semt`, `sese`,
|
|
21
|
+
`setr`, `tsin`, `tsmt`, `tsrv`, `trck`). This is the current iso20022.org
|
|
22
|
+
catalogue (latest versions) plus the earlier versions, so older in-circulation
|
|
23
|
+
messages still parse.
|
|
24
|
+
|
|
25
|
+
The generated types derive [`yaserde`](https://crates.io/crates/yaserde) for XML
|
|
26
|
+
and (with the `serde` feature) `serde::{Serialize, Deserialize}` for JSON.
|
|
27
|
+
|
|
28
|
+
## Capabilities
|
|
29
|
+
|
|
30
|
+
| Capability | API |
|
|
31
|
+
|---|---|
|
|
32
|
+
| Typed model, all message versions | `generated::<area>::<msg>::Document` |
|
|
33
|
+
| XML parse / serialize | `from_xml` / `to_xml` |
|
|
34
|
+
| JSON parse / serialize (ISO element names) | `from_json` / `to_json` (feature `serde`) |
|
|
35
|
+
| Per-message identity (namespace, MxId, area, functionality, variant, version) | the `MxMessage` trait on every `Document` |
|
|
36
|
+
| Auto-detect & parse | `detect`, `parse_as::<T>()`, `generated::any::parse_auto` → `AnyMessage` |
|
|
37
|
+
| Business Application Header — read & build | `app_hdr::parse_business_header` / `BusinessHeader::to_app_hdr_xml` |
|
|
38
|
+
| Business metadata extraction | `metadata::extract` |
|
|
39
|
+
| Business message (header + typed document) | `Envelope<D>` / `parse_envelope`, `read_business_message` |
|
|
40
|
+
| Generic tree — read any message without the model | `MxNode::parse` |
|
|
41
|
+
| Typed scalars (amount → `Decimal`, dates → `chrono`) | `convert::{to_decimal, to_date, to_datetime}` (feature `convert`) |
|
|
42
|
+
| Message catalogue | `catalogue` |
|
|
43
|
+
| WebAssembly / JS bindings | `src/wasm.rs` (build via `scripts/build-wasm.sh`; see [docs/wasm-api.md](docs/wasm-api.md)) |
|
|
44
|
+
|
|
45
|
+
## Quick start
|
|
46
|
+
|
|
47
|
+
Identify a message and read its metadata — no `model` feature needed:
|
|
48
|
+
|
|
49
|
+
```rust
|
|
50
|
+
use rust_iso20022::{detect, BusinessArea, MxNode};
|
|
51
|
+
|
|
52
|
+
let xml = r#"<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.08">
|
|
53
|
+
<FIToFICstmrCdtTrf><GrpHdr><MsgId>ABC-1</MsgId></GrpHdr>
|
|
54
|
+
<CdtTrfTxInf><IntrBkSttlmAmt Ccy="EUR">1234.56</IntrBkSttlmAmt></CdtTrfTxInf>
|
|
55
|
+
</FIToFICstmrCdtTrf></Document>"#;
|
|
56
|
+
|
|
57
|
+
let id = detect(xml).unwrap();
|
|
58
|
+
assert_eq!(id.message_name(), "pacs.008.001.08");
|
|
59
|
+
assert_eq!(id.business_area, BusinessArea::pacs);
|
|
60
|
+
|
|
61
|
+
// Read fields from the generic tree without the typed model:
|
|
62
|
+
let doc = MxNode::parse(xml).unwrap();
|
|
63
|
+
assert_eq!(doc.find("MsgId").and_then(|n| n.text()), Some("ABC-1"));
|
|
64
|
+
let amt = doc.find("IntrBkSttlmAmt").unwrap();
|
|
65
|
+
assert_eq!((amt.text(), amt.attr("Ccy")), (Some("1234.56"), Some("EUR")));
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Typed parse / serialize (enable the area's model, e.g.
|
|
69
|
+
`cargo add rust_iso20022 -F model-pacs`):
|
|
70
|
+
|
|
71
|
+
```rust,ignore
|
|
72
|
+
use rust_iso20022::generated::pacs::pacs_008_001_08::Document;
|
|
73
|
+
|
|
74
|
+
let doc: Document = rust_iso20022::from_xml(&xml)?;
|
|
75
|
+
let back: String = rust_iso20022::to_xml(&doc)?;
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
See the runnable examples:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
cargo run --example inspect_message # no features
|
|
82
|
+
cargo run --example typed_payment --features model-pacs,serde,convert # typed
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Features
|
|
86
|
+
|
|
87
|
+
| Feature | Default | Effect |
|
|
88
|
+
|---------|---------|--------|
|
|
89
|
+
| `model-<area>` | no | the typed model for one business area, e.g. `model-pacs`. Enable only what you need — a single area compiles in seconds vs many minutes for all |
|
|
90
|
+
| `model` | no | all `model-<area>` at once (~1130 modules; slow to compile) |
|
|
91
|
+
| `serde` | no | `serde` + JSON (`to_json`/`from_json`) for the core, catalogue and message types |
|
|
92
|
+
| `convert` | no | typed scalar conversions (`to_decimal`/`to_date`/`to_datetime`) via `rust_decimal`/`chrono` |
|
|
93
|
+
| `cli` | no | the `iso20022` command-line catalogue lookup tool |
|
|
94
|
+
| `catalogue` | no | runtime XSD fetcher (`fetch` module): pulls in `tokio`, `reqwest`, `regex` |
|
|
95
|
+
|
|
96
|
+
The core (`MxId`, `BusinessArea`, `MxNode`, `detect`) and the `catalogue` are
|
|
97
|
+
always available. The XSD → Rust generator is a separate, unpublished workspace
|
|
98
|
+
crate (`tools/codegen`), so the published crate has **no git dependencies**.
|
|
99
|
+
|
|
100
|
+
## Command-line tool
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
cargo run --features cli --bin iso20022 -- pacs.008 # all pacs.008 versions
|
|
104
|
+
# or after `cargo install rust_iso20022 --features cli`:
|
|
105
|
+
iso20022 camt # every message in the camt business area
|
|
106
|
+
iso20022 # the whole catalogue
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Regenerating the model
|
|
110
|
+
|
|
111
|
+
The model and catalogue are produced from the XSD schemas in `xsds/` by the
|
|
112
|
+
codegen tool:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
cargo run -p rust_iso20022_codegen -- --input xsds --output src/generated
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
To (re)download schemas, the `catalogue` feature provides a `Fetcher`. The
|
|
119
|
+
authoritative source is iso20022.org; its static schema path
|
|
120
|
+
(`/sites/default/files/documents/messages/<area>/schemas/<name>.xsd`) is the
|
|
121
|
+
reliable programmatic download path (`Fetcher::download_schema`).
|
|
122
|
+
|
|
123
|
+
## Design notes
|
|
124
|
+
|
|
125
|
+
- **Scalars are `String`** — lossless (exact text, no float rounding, ideal for
|
|
126
|
+
money) and keeps XML and JSON in sync. Convert on demand with the `convert`
|
|
127
|
+
feature.
|
|
128
|
+
- **Choices** are modelled as a struct of `Option<…>` fields (the same shape
|
|
129
|
+
JAXB uses), so an amount inside a `<xsd:choice>` round-trips with its `Ccy`
|
|
130
|
+
attribute and unset choices are simply omitted.
|
|
131
|
+
- **JSON** uses the ISO 20022 element names (`MsgId`, `IBAN`, …); `to_json` /
|
|
132
|
+
`from_json` round-trip.
|
|
133
|
+
- A value that is not a known member of a coded enumeration parses to an
|
|
134
|
+
`__Unknown__(String)` fallback (surfaces only for invalid input).
|
|
135
|
+
- XML round-tripping preserves the data model, not byte-for-byte formatting.
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
Apache-2.0.
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rust_iso20022",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "ISO 20022 message definitions and external code sets for Rust, generated from the official XSD schemas.",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/rust-iso/rust_iso20022"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"rust_iso20022_bg.wasm",
|
|
13
|
+
"rust_iso20022.js",
|
|
14
|
+
"rust_iso20022.d.ts"
|
|
15
|
+
],
|
|
16
|
+
"main": "rust_iso20022.js",
|
|
17
|
+
"types": "rust_iso20022.d.ts",
|
|
18
|
+
"sideEffects": [
|
|
19
|
+
"./snippets/*"
|
|
20
|
+
],
|
|
21
|
+
"keywords": [
|
|
22
|
+
"ISO20022",
|
|
23
|
+
"SWIFT",
|
|
24
|
+
"payments",
|
|
25
|
+
"finance",
|
|
26
|
+
"iso"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Build a `head.001` `<AppHdr>` XML from header fields.
|
|
6
|
+
*/
|
|
7
|
+
export function build_app_hdr(from?: string | null, to?: string | null, biz_msg_idr?: string | null, msg_def_idr?: string | null, cre_dt?: string | null): string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Human-readable description of a business-area code, e.g. `"pacs"` →
|
|
11
|
+
* `"Payments Clearing and Settlement"`.
|
|
12
|
+
*/
|
|
13
|
+
export function business_area_description(code: string): string | undefined;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The business-area code of a message name, e.g. `"pacs"`.
|
|
17
|
+
*/
|
|
18
|
+
export function business_area_of(message_name: string): string | undefined;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Every business-area code, as a JS array of strings.
|
|
22
|
+
*/
|
|
23
|
+
export function business_areas(): Array<any>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Every message name in the catalogue, as a JS array of strings.
|
|
27
|
+
*/
|
|
28
|
+
export function catalogue_all(): Array<any>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Whether the catalogue contains the given message name.
|
|
32
|
+
*/
|
|
33
|
+
export function catalogue_contains(message_name: string): boolean;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A catalogue entry as JSON: `{messageName, namespace, businessArea, hasModel}`.
|
|
37
|
+
*/
|
|
38
|
+
export function catalogue_entry(message_name: string): string | undefined;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Detect the message name from an XML document, e.g. `"pacs.008.001.08"`.
|
|
42
|
+
*/
|
|
43
|
+
export function detect(xml: string): string | undefined;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Extract business metadata from a message, as JSON.
|
|
47
|
+
*/
|
|
48
|
+
export function extract_metadata(xml: string): string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Parse a namespace or bare name into the canonical message name.
|
|
52
|
+
*/
|
|
53
|
+
export function from_namespace(namespace: string): string | undefined;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Whether a typed model exists for the message.
|
|
57
|
+
*/
|
|
58
|
+
export function has_model(message_name: string): boolean;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Structured identification as JSON:
|
|
62
|
+
* `{messageName, namespace, businessArea, functionality, variant, version}`.
|
|
63
|
+
*/
|
|
64
|
+
export function mx_id(namespace_or_name: string): string | undefined;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The XSD namespace for a message name, or `undefined`.
|
|
68
|
+
*/
|
|
69
|
+
export function namespace_of(message_name: string): string | undefined;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Value of an attribute on the element at a `/`-separated path of local names,
|
|
73
|
+
* e.g. the `Ccy` of `"FIToFICstmrCdtTrf/CdtTrfTxInf/IntrBkSttlmAmt"`.
|
|
74
|
+
*/
|
|
75
|
+
export function node_attr(xml: string, path: string, attr: string): string | undefined;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Text of the first descendant element with the given local name.
|
|
79
|
+
*/
|
|
80
|
+
export function node_find(xml: string, local: string): string | undefined;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The texts of every descendant element with the given local name.
|
|
84
|
+
*/
|
|
85
|
+
export function node_find_all(xml: string, local: string): Array<any>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Value of an attribute on the first descendant element with the given local
|
|
89
|
+
* name, e.g. `node_find_attr(xml, "IntrBkSttlmAmt", "Ccy")` → `"EUR"`.
|
|
90
|
+
*/
|
|
91
|
+
export function node_find_attr(xml: string, local: string, attr: string): string | undefined;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Text at a `/`-separated path of local element names, e.g.
|
|
95
|
+
* `"FIToFICstmrCdtTrf/GrpHdr/MsgId"` — read any message without the model.
|
|
96
|
+
*/
|
|
97
|
+
export function node_text(xml: string, path: string): string | undefined;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The whole parsed message tree as JSON, recursively:
|
|
101
|
+
* `{name, value, attributes: {…}, children: [...]}`. Lets JS walk any message
|
|
102
|
+
* without the typed model.
|
|
103
|
+
*/
|
|
104
|
+
export function node_to_json(xml: string): string | undefined;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Business Application Header fields as JSON, or `undefined` if no header.
|
|
108
|
+
*/
|
|
109
|
+
export function parse_app_hdr(xml: string): string | undefined;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Read a full business message (header + detected type + metadata) as JSON:
|
|
113
|
+
* `{messageName, header, metadata}`.
|
|
114
|
+
*/
|
|
115
|
+
export function read_business_message(xml: string): string;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Module entry point: install a panic hook that routes Rust panics to
|
|
119
|
+
* `console.error`, so wasm failures show a readable message and stack trace
|
|
120
|
+
* instead of an opaque `unreachable`. Runs automatically on module load.
|
|
121
|
+
*/
|
|
122
|
+
export function start(): void;
|
|
123
|
+
|
|
124
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
125
|
+
|
|
126
|
+
export interface InitOutput {
|
|
127
|
+
readonly memory: WebAssembly.Memory;
|
|
128
|
+
readonly build_app_hdr: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
|
|
129
|
+
readonly business_area_description: (a: number, b: number) => [number, number];
|
|
130
|
+
readonly business_area_of: (a: number, b: number) => [number, number];
|
|
131
|
+
readonly business_areas: () => any;
|
|
132
|
+
readonly catalogue_all: () => any;
|
|
133
|
+
readonly catalogue_contains: (a: number, b: number) => number;
|
|
134
|
+
readonly catalogue_entry: (a: number, b: number) => [number, number];
|
|
135
|
+
readonly detect: (a: number, b: number) => [number, number];
|
|
136
|
+
readonly extract_metadata: (a: number, b: number) => [number, number];
|
|
137
|
+
readonly from_namespace: (a: number, b: number) => [number, number];
|
|
138
|
+
readonly has_model: (a: number, b: number) => number;
|
|
139
|
+
readonly mx_id: (a: number, b: number) => [number, number];
|
|
140
|
+
readonly namespace_of: (a: number, b: number) => [number, number];
|
|
141
|
+
readonly node_attr: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
142
|
+
readonly node_find: (a: number, b: number, c: number, d: number) => [number, number];
|
|
143
|
+
readonly node_find_all: (a: number, b: number, c: number, d: number) => any;
|
|
144
|
+
readonly node_find_attr: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
145
|
+
readonly node_text: (a: number, b: number, c: number, d: number) => [number, number];
|
|
146
|
+
readonly node_to_json: (a: number, b: number) => [number, number];
|
|
147
|
+
readonly parse_app_hdr: (a: number, b: number) => [number, number];
|
|
148
|
+
readonly read_business_message: (a: number, b: number) => [number, number];
|
|
149
|
+
readonly start: () => void;
|
|
150
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
151
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
152
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
153
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
154
|
+
readonly __wbindgen_start: () => void;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
161
|
+
* a precompiled `WebAssembly.Module`.
|
|
162
|
+
*
|
|
163
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
164
|
+
*
|
|
165
|
+
* @returns {InitOutput}
|
|
166
|
+
*/
|
|
167
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
171
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
172
|
+
*
|
|
173
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
174
|
+
*
|
|
175
|
+
* @returns {Promise<InitOutput>}
|
|
176
|
+
*/
|
|
177
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/rust_iso20022.js
ADDED
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
/* @ts-self-types="./rust_iso20022.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Build a `head.001` `<AppHdr>` XML from header fields.
|
|
5
|
+
* @param {string | null} [from]
|
|
6
|
+
* @param {string | null} [to]
|
|
7
|
+
* @param {string | null} [biz_msg_idr]
|
|
8
|
+
* @param {string | null} [msg_def_idr]
|
|
9
|
+
* @param {string | null} [cre_dt]
|
|
10
|
+
* @returns {string}
|
|
11
|
+
*/
|
|
12
|
+
export function build_app_hdr(from, to, biz_msg_idr, msg_def_idr, cre_dt) {
|
|
13
|
+
let deferred6_0;
|
|
14
|
+
let deferred6_1;
|
|
15
|
+
try {
|
|
16
|
+
var ptr0 = isLikeNone(from) ? 0 : passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
17
|
+
var len0 = WASM_VECTOR_LEN;
|
|
18
|
+
var ptr1 = isLikeNone(to) ? 0 : passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
19
|
+
var len1 = WASM_VECTOR_LEN;
|
|
20
|
+
var ptr2 = isLikeNone(biz_msg_idr) ? 0 : passStringToWasm0(biz_msg_idr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
21
|
+
var len2 = WASM_VECTOR_LEN;
|
|
22
|
+
var ptr3 = isLikeNone(msg_def_idr) ? 0 : passStringToWasm0(msg_def_idr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
23
|
+
var len3 = WASM_VECTOR_LEN;
|
|
24
|
+
var ptr4 = isLikeNone(cre_dt) ? 0 : passStringToWasm0(cre_dt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
25
|
+
var len4 = WASM_VECTOR_LEN;
|
|
26
|
+
const ret = wasm.build_app_hdr(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
27
|
+
deferred6_0 = ret[0];
|
|
28
|
+
deferred6_1 = ret[1];
|
|
29
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
30
|
+
} finally {
|
|
31
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Human-readable description of a business-area code, e.g. `"pacs"` →
|
|
37
|
+
* `"Payments Clearing and Settlement"`.
|
|
38
|
+
* @param {string} code
|
|
39
|
+
* @returns {string | undefined}
|
|
40
|
+
*/
|
|
41
|
+
export function business_area_description(code) {
|
|
42
|
+
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
43
|
+
const len0 = WASM_VECTOR_LEN;
|
|
44
|
+
const ret = wasm.business_area_description(ptr0, len0);
|
|
45
|
+
let v2;
|
|
46
|
+
if (ret[0] !== 0) {
|
|
47
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
48
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
49
|
+
}
|
|
50
|
+
return v2;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The business-area code of a message name, e.g. `"pacs"`.
|
|
55
|
+
* @param {string} message_name
|
|
56
|
+
* @returns {string | undefined}
|
|
57
|
+
*/
|
|
58
|
+
export function business_area_of(message_name) {
|
|
59
|
+
const ptr0 = passStringToWasm0(message_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
60
|
+
const len0 = WASM_VECTOR_LEN;
|
|
61
|
+
const ret = wasm.business_area_of(ptr0, len0);
|
|
62
|
+
let v2;
|
|
63
|
+
if (ret[0] !== 0) {
|
|
64
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
65
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
66
|
+
}
|
|
67
|
+
return v2;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Every business-area code, as a JS array of strings.
|
|
72
|
+
* @returns {Array<any>}
|
|
73
|
+
*/
|
|
74
|
+
export function business_areas() {
|
|
75
|
+
const ret = wasm.business_areas();
|
|
76
|
+
return ret;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Every message name in the catalogue, as a JS array of strings.
|
|
81
|
+
* @returns {Array<any>}
|
|
82
|
+
*/
|
|
83
|
+
export function catalogue_all() {
|
|
84
|
+
const ret = wasm.catalogue_all();
|
|
85
|
+
return ret;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Whether the catalogue contains the given message name.
|
|
90
|
+
* @param {string} message_name
|
|
91
|
+
* @returns {boolean}
|
|
92
|
+
*/
|
|
93
|
+
export function catalogue_contains(message_name) {
|
|
94
|
+
const ptr0 = passStringToWasm0(message_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
95
|
+
const len0 = WASM_VECTOR_LEN;
|
|
96
|
+
const ret = wasm.catalogue_contains(ptr0, len0);
|
|
97
|
+
return ret !== 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* A catalogue entry as JSON: `{messageName, namespace, businessArea, hasModel}`.
|
|
102
|
+
* @param {string} message_name
|
|
103
|
+
* @returns {string | undefined}
|
|
104
|
+
*/
|
|
105
|
+
export function catalogue_entry(message_name) {
|
|
106
|
+
const ptr0 = passStringToWasm0(message_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
107
|
+
const len0 = WASM_VECTOR_LEN;
|
|
108
|
+
const ret = wasm.catalogue_entry(ptr0, len0);
|
|
109
|
+
let v2;
|
|
110
|
+
if (ret[0] !== 0) {
|
|
111
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
112
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
113
|
+
}
|
|
114
|
+
return v2;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Detect the message name from an XML document, e.g. `"pacs.008.001.08"`.
|
|
119
|
+
* @param {string} xml
|
|
120
|
+
* @returns {string | undefined}
|
|
121
|
+
*/
|
|
122
|
+
export function detect(xml) {
|
|
123
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
124
|
+
const len0 = WASM_VECTOR_LEN;
|
|
125
|
+
const ret = wasm.detect(ptr0, len0);
|
|
126
|
+
let v2;
|
|
127
|
+
if (ret[0] !== 0) {
|
|
128
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
129
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
130
|
+
}
|
|
131
|
+
return v2;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Extract business metadata from a message, as JSON.
|
|
136
|
+
* @param {string} xml
|
|
137
|
+
* @returns {string}
|
|
138
|
+
*/
|
|
139
|
+
export function extract_metadata(xml) {
|
|
140
|
+
let deferred2_0;
|
|
141
|
+
let deferred2_1;
|
|
142
|
+
try {
|
|
143
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
144
|
+
const len0 = WASM_VECTOR_LEN;
|
|
145
|
+
const ret = wasm.extract_metadata(ptr0, len0);
|
|
146
|
+
deferred2_0 = ret[0];
|
|
147
|
+
deferred2_1 = ret[1];
|
|
148
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
149
|
+
} finally {
|
|
150
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Parse a namespace or bare name into the canonical message name.
|
|
156
|
+
* @param {string} namespace
|
|
157
|
+
* @returns {string | undefined}
|
|
158
|
+
*/
|
|
159
|
+
export function from_namespace(namespace) {
|
|
160
|
+
const ptr0 = passStringToWasm0(namespace, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
161
|
+
const len0 = WASM_VECTOR_LEN;
|
|
162
|
+
const ret = wasm.from_namespace(ptr0, len0);
|
|
163
|
+
let v2;
|
|
164
|
+
if (ret[0] !== 0) {
|
|
165
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
166
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
167
|
+
}
|
|
168
|
+
return v2;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Whether a typed model exists for the message.
|
|
173
|
+
* @param {string} message_name
|
|
174
|
+
* @returns {boolean}
|
|
175
|
+
*/
|
|
176
|
+
export function has_model(message_name) {
|
|
177
|
+
const ptr0 = passStringToWasm0(message_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
178
|
+
const len0 = WASM_VECTOR_LEN;
|
|
179
|
+
const ret = wasm.has_model(ptr0, len0);
|
|
180
|
+
return ret !== 0;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Structured identification as JSON:
|
|
185
|
+
* `{messageName, namespace, businessArea, functionality, variant, version}`.
|
|
186
|
+
* @param {string} namespace_or_name
|
|
187
|
+
* @returns {string | undefined}
|
|
188
|
+
*/
|
|
189
|
+
export function mx_id(namespace_or_name) {
|
|
190
|
+
const ptr0 = passStringToWasm0(namespace_or_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
191
|
+
const len0 = WASM_VECTOR_LEN;
|
|
192
|
+
const ret = wasm.mx_id(ptr0, len0);
|
|
193
|
+
let v2;
|
|
194
|
+
if (ret[0] !== 0) {
|
|
195
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
196
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
197
|
+
}
|
|
198
|
+
return v2;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* The XSD namespace for a message name, or `undefined`.
|
|
203
|
+
* @param {string} message_name
|
|
204
|
+
* @returns {string | undefined}
|
|
205
|
+
*/
|
|
206
|
+
export function namespace_of(message_name) {
|
|
207
|
+
const ptr0 = passStringToWasm0(message_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
208
|
+
const len0 = WASM_VECTOR_LEN;
|
|
209
|
+
const ret = wasm.namespace_of(ptr0, len0);
|
|
210
|
+
let v2;
|
|
211
|
+
if (ret[0] !== 0) {
|
|
212
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
213
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
214
|
+
}
|
|
215
|
+
return v2;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Value of an attribute on the element at a `/`-separated path of local names,
|
|
220
|
+
* e.g. the `Ccy` of `"FIToFICstmrCdtTrf/CdtTrfTxInf/IntrBkSttlmAmt"`.
|
|
221
|
+
* @param {string} xml
|
|
222
|
+
* @param {string} path
|
|
223
|
+
* @param {string} attr
|
|
224
|
+
* @returns {string | undefined}
|
|
225
|
+
*/
|
|
226
|
+
export function node_attr(xml, path, attr) {
|
|
227
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
228
|
+
const len0 = WASM_VECTOR_LEN;
|
|
229
|
+
const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
230
|
+
const len1 = WASM_VECTOR_LEN;
|
|
231
|
+
const ptr2 = passStringToWasm0(attr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
232
|
+
const len2 = WASM_VECTOR_LEN;
|
|
233
|
+
const ret = wasm.node_attr(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
234
|
+
let v4;
|
|
235
|
+
if (ret[0] !== 0) {
|
|
236
|
+
v4 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
237
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
238
|
+
}
|
|
239
|
+
return v4;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Text of the first descendant element with the given local name.
|
|
244
|
+
* @param {string} xml
|
|
245
|
+
* @param {string} local
|
|
246
|
+
* @returns {string | undefined}
|
|
247
|
+
*/
|
|
248
|
+
export function node_find(xml, local) {
|
|
249
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
250
|
+
const len0 = WASM_VECTOR_LEN;
|
|
251
|
+
const ptr1 = passStringToWasm0(local, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
252
|
+
const len1 = WASM_VECTOR_LEN;
|
|
253
|
+
const ret = wasm.node_find(ptr0, len0, ptr1, len1);
|
|
254
|
+
let v3;
|
|
255
|
+
if (ret[0] !== 0) {
|
|
256
|
+
v3 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
257
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
258
|
+
}
|
|
259
|
+
return v3;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* The texts of every descendant element with the given local name.
|
|
264
|
+
* @param {string} xml
|
|
265
|
+
* @param {string} local
|
|
266
|
+
* @returns {Array<any>}
|
|
267
|
+
*/
|
|
268
|
+
export function node_find_all(xml, local) {
|
|
269
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
270
|
+
const len0 = WASM_VECTOR_LEN;
|
|
271
|
+
const ptr1 = passStringToWasm0(local, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
272
|
+
const len1 = WASM_VECTOR_LEN;
|
|
273
|
+
const ret = wasm.node_find_all(ptr0, len0, ptr1, len1);
|
|
274
|
+
return ret;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Value of an attribute on the first descendant element with the given local
|
|
279
|
+
* name, e.g. `node_find_attr(xml, "IntrBkSttlmAmt", "Ccy")` → `"EUR"`.
|
|
280
|
+
* @param {string} xml
|
|
281
|
+
* @param {string} local
|
|
282
|
+
* @param {string} attr
|
|
283
|
+
* @returns {string | undefined}
|
|
284
|
+
*/
|
|
285
|
+
export function node_find_attr(xml, local, attr) {
|
|
286
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
287
|
+
const len0 = WASM_VECTOR_LEN;
|
|
288
|
+
const ptr1 = passStringToWasm0(local, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
289
|
+
const len1 = WASM_VECTOR_LEN;
|
|
290
|
+
const ptr2 = passStringToWasm0(attr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
291
|
+
const len2 = WASM_VECTOR_LEN;
|
|
292
|
+
const ret = wasm.node_find_attr(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
293
|
+
let v4;
|
|
294
|
+
if (ret[0] !== 0) {
|
|
295
|
+
v4 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
296
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
297
|
+
}
|
|
298
|
+
return v4;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Text at a `/`-separated path of local element names, e.g.
|
|
303
|
+
* `"FIToFICstmrCdtTrf/GrpHdr/MsgId"` — read any message without the model.
|
|
304
|
+
* @param {string} xml
|
|
305
|
+
* @param {string} path
|
|
306
|
+
* @returns {string | undefined}
|
|
307
|
+
*/
|
|
308
|
+
export function node_text(xml, path) {
|
|
309
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
310
|
+
const len0 = WASM_VECTOR_LEN;
|
|
311
|
+
const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
312
|
+
const len1 = WASM_VECTOR_LEN;
|
|
313
|
+
const ret = wasm.node_text(ptr0, len0, ptr1, len1);
|
|
314
|
+
let v3;
|
|
315
|
+
if (ret[0] !== 0) {
|
|
316
|
+
v3 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
317
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
318
|
+
}
|
|
319
|
+
return v3;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* The whole parsed message tree as JSON, recursively:
|
|
324
|
+
* `{name, value, attributes: {…}, children: [...]}`. Lets JS walk any message
|
|
325
|
+
* without the typed model.
|
|
326
|
+
* @param {string} xml
|
|
327
|
+
* @returns {string | undefined}
|
|
328
|
+
*/
|
|
329
|
+
export function node_to_json(xml) {
|
|
330
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
331
|
+
const len0 = WASM_VECTOR_LEN;
|
|
332
|
+
const ret = wasm.node_to_json(ptr0, len0);
|
|
333
|
+
let v2;
|
|
334
|
+
if (ret[0] !== 0) {
|
|
335
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
336
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
337
|
+
}
|
|
338
|
+
return v2;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Business Application Header fields as JSON, or `undefined` if no header.
|
|
343
|
+
* @param {string} xml
|
|
344
|
+
* @returns {string | undefined}
|
|
345
|
+
*/
|
|
346
|
+
export function parse_app_hdr(xml) {
|
|
347
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
348
|
+
const len0 = WASM_VECTOR_LEN;
|
|
349
|
+
const ret = wasm.parse_app_hdr(ptr0, len0);
|
|
350
|
+
let v2;
|
|
351
|
+
if (ret[0] !== 0) {
|
|
352
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
353
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
354
|
+
}
|
|
355
|
+
return v2;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Read a full business message (header + detected type + metadata) as JSON:
|
|
360
|
+
* `{messageName, header, metadata}`.
|
|
361
|
+
* @param {string} xml
|
|
362
|
+
* @returns {string}
|
|
363
|
+
*/
|
|
364
|
+
export function read_business_message(xml) {
|
|
365
|
+
let deferred2_0;
|
|
366
|
+
let deferred2_1;
|
|
367
|
+
try {
|
|
368
|
+
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
369
|
+
const len0 = WASM_VECTOR_LEN;
|
|
370
|
+
const ret = wasm.read_business_message(ptr0, len0);
|
|
371
|
+
deferred2_0 = ret[0];
|
|
372
|
+
deferred2_1 = ret[1];
|
|
373
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
374
|
+
} finally {
|
|
375
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Module entry point: install a panic hook that routes Rust panics to
|
|
381
|
+
* `console.error`, so wasm failures show a readable message and stack trace
|
|
382
|
+
* instead of an opaque `unreachable`. Runs automatically on module load.
|
|
383
|
+
*/
|
|
384
|
+
export function start() {
|
|
385
|
+
wasm.start();
|
|
386
|
+
}
|
|
387
|
+
function __wbg_get_imports() {
|
|
388
|
+
const import0 = {
|
|
389
|
+
__proto__: null,
|
|
390
|
+
__wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
|
|
391
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
392
|
+
},
|
|
393
|
+
__wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
|
|
394
|
+
let deferred0_0;
|
|
395
|
+
let deferred0_1;
|
|
396
|
+
try {
|
|
397
|
+
deferred0_0 = arg0;
|
|
398
|
+
deferred0_1 = arg1;
|
|
399
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
400
|
+
} finally {
|
|
401
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
405
|
+
const ret = new Error();
|
|
406
|
+
return ret;
|
|
407
|
+
},
|
|
408
|
+
__wbg_new_32b398fb48b6d94a: function() {
|
|
409
|
+
const ret = new Array();
|
|
410
|
+
return ret;
|
|
411
|
+
},
|
|
412
|
+
__wbg_push_d2ae3af0c1217ae6: function(arg0, arg1) {
|
|
413
|
+
const ret = arg0.push(arg1);
|
|
414
|
+
return ret;
|
|
415
|
+
},
|
|
416
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
417
|
+
const ret = arg1.stack;
|
|
418
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
419
|
+
const len1 = WASM_VECTOR_LEN;
|
|
420
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
421
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
422
|
+
},
|
|
423
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
424
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
425
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
426
|
+
return ret;
|
|
427
|
+
},
|
|
428
|
+
__wbindgen_init_externref_table: function() {
|
|
429
|
+
const table = wasm.__wbindgen_externrefs;
|
|
430
|
+
const offset = table.grow(4);
|
|
431
|
+
table.set(0, undefined);
|
|
432
|
+
table.set(offset + 0, undefined);
|
|
433
|
+
table.set(offset + 1, null);
|
|
434
|
+
table.set(offset + 2, true);
|
|
435
|
+
table.set(offset + 3, false);
|
|
436
|
+
},
|
|
437
|
+
};
|
|
438
|
+
return {
|
|
439
|
+
__proto__: null,
|
|
440
|
+
"./rust_iso20022_bg.js": import0,
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
let cachedDataViewMemory0 = null;
|
|
445
|
+
function getDataViewMemory0() {
|
|
446
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
447
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
448
|
+
}
|
|
449
|
+
return cachedDataViewMemory0;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function getStringFromWasm0(ptr, len) {
|
|
453
|
+
return decodeText(ptr >>> 0, len);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
let cachedUint8ArrayMemory0 = null;
|
|
457
|
+
function getUint8ArrayMemory0() {
|
|
458
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
459
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
460
|
+
}
|
|
461
|
+
return cachedUint8ArrayMemory0;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function isLikeNone(x) {
|
|
465
|
+
return x === undefined || x === null;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
469
|
+
if (realloc === undefined) {
|
|
470
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
471
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
472
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
473
|
+
WASM_VECTOR_LEN = buf.length;
|
|
474
|
+
return ptr;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
let len = arg.length;
|
|
478
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
479
|
+
|
|
480
|
+
const mem = getUint8ArrayMemory0();
|
|
481
|
+
|
|
482
|
+
let offset = 0;
|
|
483
|
+
|
|
484
|
+
for (; offset < len; offset++) {
|
|
485
|
+
const code = arg.charCodeAt(offset);
|
|
486
|
+
if (code > 0x7F) break;
|
|
487
|
+
mem[ptr + offset] = code;
|
|
488
|
+
}
|
|
489
|
+
if (offset !== len) {
|
|
490
|
+
if (offset !== 0) {
|
|
491
|
+
arg = arg.slice(offset);
|
|
492
|
+
}
|
|
493
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
494
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
495
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
496
|
+
|
|
497
|
+
offset += ret.written;
|
|
498
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
WASM_VECTOR_LEN = offset;
|
|
502
|
+
return ptr;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
506
|
+
cachedTextDecoder.decode();
|
|
507
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
508
|
+
let numBytesDecoded = 0;
|
|
509
|
+
function decodeText(ptr, len) {
|
|
510
|
+
numBytesDecoded += len;
|
|
511
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
512
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
513
|
+
cachedTextDecoder.decode();
|
|
514
|
+
numBytesDecoded = len;
|
|
515
|
+
}
|
|
516
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
const cachedTextEncoder = new TextEncoder();
|
|
520
|
+
|
|
521
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
522
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
523
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
524
|
+
view.set(buf);
|
|
525
|
+
return {
|
|
526
|
+
read: arg.length,
|
|
527
|
+
written: buf.length
|
|
528
|
+
};
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
let WASM_VECTOR_LEN = 0;
|
|
533
|
+
|
|
534
|
+
let wasmModule, wasmInstance, wasm;
|
|
535
|
+
function __wbg_finalize_init(instance, module) {
|
|
536
|
+
wasmInstance = instance;
|
|
537
|
+
wasm = instance.exports;
|
|
538
|
+
wasmModule = module;
|
|
539
|
+
cachedDataViewMemory0 = null;
|
|
540
|
+
cachedUint8ArrayMemory0 = null;
|
|
541
|
+
wasm.__wbindgen_start();
|
|
542
|
+
return wasm;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
async function __wbg_load(module, imports) {
|
|
546
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
547
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
548
|
+
try {
|
|
549
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
550
|
+
} catch (e) {
|
|
551
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
552
|
+
|
|
553
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
554
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
555
|
+
|
|
556
|
+
} else { throw e; }
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const bytes = await module.arrayBuffer();
|
|
561
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
562
|
+
} else {
|
|
563
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
564
|
+
|
|
565
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
566
|
+
return { instance, module };
|
|
567
|
+
} else {
|
|
568
|
+
return instance;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
function expectedResponseType(type) {
|
|
573
|
+
switch (type) {
|
|
574
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
575
|
+
}
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
function initSync(module) {
|
|
581
|
+
if (wasm !== undefined) return wasm;
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
if (module !== undefined) {
|
|
585
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
586
|
+
({module} = module)
|
|
587
|
+
} else {
|
|
588
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
const imports = __wbg_get_imports();
|
|
593
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
594
|
+
module = new WebAssembly.Module(module);
|
|
595
|
+
}
|
|
596
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
597
|
+
return __wbg_finalize_init(instance, module);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
async function __wbg_init(module_or_path) {
|
|
601
|
+
if (wasm !== undefined) return wasm;
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
if (module_or_path !== undefined) {
|
|
605
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
606
|
+
({module_or_path} = module_or_path)
|
|
607
|
+
} else {
|
|
608
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
if (module_or_path === undefined) {
|
|
613
|
+
module_or_path = new URL('rust_iso20022_bg.wasm', import.meta.url);
|
|
614
|
+
}
|
|
615
|
+
const imports = __wbg_get_imports();
|
|
616
|
+
|
|
617
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
618
|
+
module_or_path = fetch(module_or_path);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
622
|
+
|
|
623
|
+
return __wbg_finalize_init(instance, module);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|