ngx-iso-form-enterprise 1.0.0-beta

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/README.md ADDED
@@ -0,0 +1,391 @@
1
+ <div align="center">
2
+ <a href="https://github.com/pixelbyaj/ngx-iso-form">
3
+ <img src="https://raw.githubusercontent.com/pixelbyaj/ngx-form/main/anguar_logo.svg?sanitize=true" alt="Angular Logo" />
4
+ </a>
5
+ <br />
6
+ <h1>XSD - JSON Powered / Dynamic ISO 20022 Forms in Angular v20</h1>
7
+
8
+ ![npm](https://img.shields.io/npm/v/ngx-iso-form)
9
+ ![NPM](https://img.shields.io/npm/l/ngx-iso-form)
10
+ [![Downloads](https://img.shields.io/npm/dt/ngx-iso-form.svg)](https://npmjs.org/package/ngx-iso-form)
11
+ [![Downloads](https://img.shields.io/npm/dm/ngx-iso-form.svg)](https://npmjs.org/package/ngx-iso-form)
12
+ </div>
13
+
14
+ ---
15
+
16
+ # NgxIsoForm
17
+
18
+ NgxIsoForm is a Enterprise version of library for dynamically generating Angular Reactive Forms using JSON derived from XSD. It is primarily designed for ISO 20022 forms.
19
+
20
+ ## Features
21
+
22
+ - 🔥 Automatic form generation
23
+ - 📝 Extendable with custom field types
24
+ - ⚡️ Supports ISO 20022 schemas:
25
+ - XSD to JSON Schema conversion using XSDService NuGet
26
+ - Validation support: required, pattern, minlength, maxlength
27
+ - Translation support for labels, errors, and date formats
28
+ - 💪 Built on [Angular Reactive Forms](https://angular.dev/guide/forms/reactive-forms)
29
+
30
+ ## [Live Demo](https://swiftmx.co/#/ngx-iso-form-demo?json=pacs.009.001.10)
31
+
32
+ ## [StackBlitz Demo](https://stackblitz.com/edit/ngx-iso-form)
33
+
34
+ ## **NOTE**
35
+
36
+ The library does not directly execute XSD. Users must convert XSD to JSON using the [xsd-json-converter](https://www.npmjs.com/package/xsd-json-converter) npm package or the [.NET ISO20022.XSD](https://www.nuget.org/packages/iSO20022.XSD) NuGet package.
37
+
38
+
39
+ ## How to Use
40
+
41
+ ### Add Angular Material v20
42
+
43
+ ```bash
44
+ ng add @angular/material@20
45
+ ```
46
+
47
+ ### Install the Library
48
+
49
+ ```bash
50
+ npm install ngx-iso-form
51
+ ```
52
+
53
+ ### Import Module and SCSS
54
+
55
+ ```typescript
56
+ import { NgxIsoFormModule } from 'ngx-iso-form';
57
+ import { HttpClient, provideHttpClient } from '@angular/common/http';
58
+
59
+ // register license key
60
+ const licenseKey = 'eyJleHBpcn......wI=';
61
+ IsoLicenseManager.registerLicense(licenseKey);
62
+
63
+ initLicense();
64
+ @NgModule({
65
+ imports: [
66
+ NgxIsoFormModule,
67
+ TranslateModule.forRoot({
68
+ defaultLanguage: 'en',
69
+ loader: {
70
+ provide: TranslateLoader,
71
+ useFactory: HttpLoaderFactory,
72
+ deps: [HttpClient]
73
+ }
74
+ })
75
+ ],
76
+ providers: [provideHttpClient()]
77
+ })
78
+ export function HttpLoaderFactory(http: HttpClient) {
79
+ return new TranslateHttpLoader(http, '/i18n/', '.json');
80
+ }
81
+ ```
82
+
83
+ Add the style file to `angular.json`:
84
+
85
+ ```json
86
+ "styles": [
87
+ "node_modules/ngx-iso-form/lib/styles/index.scss"
88
+ ]
89
+ ```
90
+
91
+ ### Usage
92
+
93
+ #### New Option: `excludes`
94
+
95
+ ```html
96
+ <ngx-iso-form #isoForm [schema]="schema" [form]="form" [excludes]="excludes"></ngx-iso-form>
97
+ ```
98
+
99
+ **Note:** `excludes` (optional) accepts a `string[]` to exclude specific IDs from the form, allowing customization for business requirements.
100
+
101
+ ### Public APIs
102
+
103
+ - `FormReadyEvent`: Event once form get ready.
104
+ - `FormApi`: public api.
105
+
106
+ ```typescript
107
+ export class FormReadyEvent {
108
+ api: FormApi;
109
+ }
110
+
111
+ export interface FormApi {
112
+ invalid: boolean;
113
+ setXmlForm: (model: any) => void;
114
+ setJsonForm: (model: any) => void;
115
+ getForm: () => any;
116
+ getNamespace: () => string;
117
+ }
118
+ ```
119
+
120
+ ### Component Example
121
+
122
+ ```typescript
123
+ export class AppComponent implements OnInit {
124
+ formApi: FormApi;
125
+ schema: SchemaElement;
126
+ excludes: string[] = [];
127
+
128
+ constructor(private httpClient: HttpClient,private license: IsoLicenseService) {}
129
+
130
+ ngOnInit() {
131
+ //validate license
132
+ this.license.validate().then(() => {
133
+ this.httpClient.get("path/to/schema.json").subscribe((data) => {
134
+ this.schema = data as SchemaElement;
135
+ });
136
+ }):
137
+ }
138
+
139
+ setWithJsonModel() {
140
+ this.httpClient.get("path/to/model.json").subscribe((model) => {
141
+ this.formApi.setJsonForm(model);
142
+ });
143
+ }
144
+
145
+ // New Support of XML Message as a model
146
+ setWithXmlMessage() {
147
+ this.httpClient.get("path/to/message.xml").subscribe((xmlMessage) => {
148
+ this.formApi.setXmlForm(model);
149
+ });
150
+ }
151
+
152
+ onFormReadyEvent(data: FormReadyEvent) {
153
+ this.formApi = data.api; //FormApi
154
+ }
155
+ }
156
+ ```
157
+
158
+ ### Supported JSON Schema
159
+
160
+ ```typescript
161
+ export interface SchemaElement {
162
+ id: string;
163
+ name: string;
164
+ dataType: string;
165
+ minOccurs: string;
166
+ maxOccurs: string;
167
+ minLength: string;
168
+ maxLength: string;
169
+ pattern: string;
170
+ fractionDigits: string;
171
+ totalDigits: string;
172
+ minInclusive: string;
173
+ maxInclusive: string;
174
+ values: string[];
175
+ isCurrency: boolean;
176
+ xpath: string;
177
+ expanded: boolean;
178
+ elements: SchemaElement[];
179
+ isUETR: boolean;
180
+ defaultValue?: string;
181
+ }
182
+ ```
183
+
184
+ ### Translation Support
185
+
186
+ Translation is supported for the `name` and `id` properties of `SchemaElement`. Declare translation rules under the `iso` object.
187
+
188
+ ```json
189
+ {
190
+ "iso": {
191
+ "BkToCstmrStmt": {
192
+ "label": "Bank To Customer Statement"
193
+ },
194
+ "GrpHdr": {
195
+ "label": "Group Header"
196
+ },
197
+ "Document_BkToCstmrStmt_GrpHdr_CreDtTm": {
198
+ "label": "Create Datetime",
199
+ "general": {
200
+ "format": "YYYY-MM-DDThh:mm:ss.sss+/-"
201
+ },
202
+ "error": {
203
+ "required": "This field is required"
204
+ }
205
+ }
206
+ }
207
+ }
208
+ ```
209
+
210
+ ### Sample XML Model
211
+
212
+ ```xml
213
+ <?xml version="1.0" encoding="UTF-8"?>
214
+ <Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.09">
215
+ <CstmrCdtTrfInitn>
216
+ <GrpHdr>
217
+ <MsgId>123456</MsgId>
218
+ <CreDtTm>2025-03-27T10:00:00</CreDtTm>
219
+ <NbOfTxs>1</NbOfTxs>
220
+ <CtrlSum>1000.00</CtrlSum>
221
+ <InitgPty>
222
+ <Nm>Sender Company</Nm>
223
+ </InitgPty>
224
+ </GrpHdr>
225
+ <PmtInf>
226
+ <PmtInfId>PAY001</PmtInfId>
227
+ <PmtMtd>TRF</PmtMtd>
228
+ <BtchBookg>false</BtchBookg>
229
+ <Dbtr>
230
+ <Nm>John Doe</Nm>
231
+ </Dbtr>
232
+ <DbtrAcct>
233
+ <Id>
234
+ <IBAN>DE89370400440532013000</IBAN>
235
+ </Id>
236
+ </DbtrAcct>
237
+ <DbtrAgt>
238
+ <FinInstnId>
239
+ <BICFI>DEUTDEFFXXX</BICFI>
240
+ </FinInstnId>
241
+ </DbtrAgt>
242
+ <CdtTrfTxInf>
243
+ <PmtId>
244
+ <EndToEndId>TX123</EndToEndId>
245
+ </PmtId>
246
+ <Amt>
247
+ <InstdAmt Ccy="EUR">1000.00</InstdAmt>
248
+ </Amt>
249
+ <Cdtr>
250
+ <Nm>Jane Smith</Nm>
251
+ </Cdtr>
252
+ <CdtrAcct>
253
+ <Id>
254
+ <IBAN>FR7630006000011234567890189</IBAN>
255
+ </Id>
256
+ </CdtrAcct>
257
+ <CdtrAgt>
258
+ <FinInstnId>
259
+ <BICFI>BNPAFRPPXXX</BICFI>
260
+ </FinInstnId>
261
+ </CdtrAgt>
262
+ </CdtTrfTxInf>
263
+ </PmtInf>
264
+ </CstmrCdtTrfInitn>
265
+ </Document>
266
+ ```
267
+
268
+ ### Output JSON Example (pain.001.001.12)
269
+
270
+ ```json
271
+ {
272
+ "Document": {
273
+ "CstmrCdtTrfInitn": {
274
+ "GrpHdr": {
275
+ "MsgId": "123456",
276
+ "CreDtTm": "2025-03-27T10:00:00",
277
+ "NbOfTxs": "1",
278
+ "CtrlSum": "1000",
279
+ "InitgPty": {
280
+ "Nm": "Sender Company",
281
+ "CtryOfRes": "US"
282
+ }
283
+ },
284
+ "PmtInf": [
285
+ {
286
+ "PmtInfId": "PAY001",
287
+ "PmtMtd": "TRF",
288
+ "BtchBookg": "false",
289
+ "Dbtr": {
290
+ "Nm": "John Doe"
291
+ },
292
+ "DbtrAcct": {
293
+ "Nm": "DE89370400440532013000"
294
+ },
295
+ "DbtrAgt": {
296
+ "FinInstnId": {
297
+ "BICFI": "DEUTDEFFXXX"
298
+ }
299
+ },
300
+ "CdtTrfTxInf": [
301
+ {
302
+ "PmtId": {
303
+ "EndToEndId": "TX123"
304
+ },
305
+ "Amt": {
306
+ "InstdAmt": {
307
+ "Ccy": "USD",
308
+ "Amt": "1000"
309
+ }
310
+ },
311
+ "CdtrAgt": {
312
+ "FinInstnId": {
313
+ "BICFI": "BNPAFRPPXXX"
314
+ }
315
+ },
316
+ "Cdtr": {
317
+ "Nm": "Jane Smith"
318
+ },
319
+ "CdtrAcct": {
320
+ "Id": {
321
+ "IBAN": "FR7630006000011234567890189"
322
+ }
323
+ }
324
+ }
325
+ ]
326
+ }
327
+ ]
328
+ }
329
+ }
330
+ }
331
+ ```
332
+
333
+ ## Convert XSD to JSON
334
+
335
+ ### Global Installation (CLI)
336
+
337
+ ```bash
338
+ npm install -g xsd-json-converter
339
+ ```
340
+
341
+ ### Local Installation (Script)
342
+
343
+ ```bash
344
+ npm install xsd-json-converter
345
+ ```
346
+
347
+ ### CLI Usage
348
+
349
+ ```bash
350
+ xjc <source-path> <output-path>
351
+ ```
352
+
353
+ #### Example
354
+
355
+ ##### Linux
356
+
357
+ ```bash
358
+ xjc /mnt/c/source/xsd/camt.053.001.10.xsd /mnt/c/source/xsd/camt.053.json
359
+ ```
360
+
361
+ ##### Windows
362
+
363
+ ```bash
364
+ xjc C:/source/xsd/camt.053.001.10.xsd C:/source/xsd/camt.053.json
365
+ ```
366
+
367
+ ### Script Usage
368
+
369
+ #### JavaScript
370
+
371
+ ```javascript
372
+ const xsd = require("xsd-json-converter").default;
373
+
374
+ xsd
375
+ .convert("./camt.053.001.10.xsd")
376
+ .then((output) => console.log(output))
377
+ .catch((error) => console.error(error));
378
+ ```
379
+
380
+ #### TypeScript
381
+
382
+ ```typescript
383
+ import xsd from "xsd-json-converter";
384
+
385
+ xsd
386
+ .convert("./camt.053.001.10.xsd")
387
+ .then((output) => console.log(output))
388
+ .catch((error) => console.error(error));
389
+ ```
390
+
391
+ **Note:** For scripts, install the package locally.