lib-fints 1.3.1 → 1.4.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/README.md +43 -40
- package/dist/camtParser.js +412 -0
- package/dist/client.js +58 -80
- package/dist/dataGroups/SepaAccount.js +17 -0
- package/dist/dataGroups/SepaAccountParameters.js +16 -0
- package/dist/dialog.js +126 -108
- package/dist/httpClient.js +17 -3
- package/dist/index.js +1 -0
- package/dist/interactions/balanceInteraction.js +1 -1
- package/dist/interactions/customerInteraction.js +6 -3
- package/dist/interactions/endDialogInteraction.js +17 -0
- package/dist/interactions/initDialogInteraction.js +18 -8
- package/dist/interactions/sepaAccountInteraction.js +48 -0
- package/dist/interactions/statementInteractionCAMT.js +54 -0
- package/dist/interactions/{statementInteraction.js → statementInteractionMT940.js} +11 -8
- package/dist/interactions/tanMediaInteraction.js +4 -0
- package/dist/segments/HICAZ.js +22 -0
- package/dist/segments/HICAZS.js +19 -0
- package/dist/segments/HISPA.js +14 -0
- package/dist/segments/HISPAS.js +14 -0
- package/dist/segments/HKCAZ.js +28 -0
- package/dist/segments/HKSPA.js +21 -0
- package/dist/segments/registry.js +16 -2
- package/dist/statement.js +1 -0
- package/dist/tests/HICAZS.test.js +18 -0
- package/dist/tests/HKCAZ.test.js +47 -0
- package/dist/tests/camtParser.test.js +673 -0
- package/dist/tests/client.test.js +21 -16
- package/dist/tests/dialog.test.js +234 -0
- package/dist/types/bankAccount.d.ts +2 -3
- package/dist/types/bankAccount.d.ts.map +1 -1
- package/dist/types/camtParser.d.ts +31 -0
- package/dist/types/camtParser.d.ts.map +1 -0
- package/dist/types/client.d.ts +4 -4
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/config.d.ts +2 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/dataGroups/SepaAccount.d.ts +11 -0
- package/dist/types/dataGroups/SepaAccount.d.ts.map +1 -0
- package/dist/types/dataGroups/SepaAccountParameters.d.ts +13 -0
- package/dist/types/dataGroups/SepaAccountParameters.d.ts.map +1 -0
- package/dist/types/dialog.d.ts +12 -8
- package/dist/types/dialog.d.ts.map +1 -1
- package/dist/types/httpClient.d.ts +2 -1
- package/dist/types/httpClient.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interactions/customerInteraction.d.ts +7 -3
- package/dist/types/interactions/customerInteraction.d.ts.map +1 -1
- package/dist/types/interactions/endDialogInteraction.d.ts +13 -0
- package/dist/types/interactions/endDialogInteraction.d.ts.map +1 -0
- package/dist/types/interactions/initDialogInteraction.d.ts +2 -3
- package/dist/types/interactions/initDialogInteraction.d.ts.map +1 -1
- package/dist/types/interactions/sepaAccountInteraction.d.ts +17 -0
- package/dist/types/interactions/sepaAccountInteraction.d.ts.map +1 -0
- package/dist/types/interactions/{statementInteraction.d.ts → statementInteractionCAMT.d.ts} +4 -7
- package/dist/types/interactions/statementInteractionCAMT.d.ts.map +1 -0
- package/dist/types/interactions/statementInteractionMT940.d.ts +13 -0
- package/dist/types/interactions/statementInteractionMT940.d.ts.map +1 -0
- package/dist/types/interactions/tanMediaInteraction.d.ts.map +1 -1
- package/dist/types/mt940parser.d.ts +2 -38
- package/dist/types/mt940parser.d.ts.map +1 -1
- package/dist/types/segments/HICAZ.d.ts +22 -0
- package/dist/types/segments/HICAZ.d.ts.map +1 -0
- package/dist/types/segments/HICAZS.d.ts +17 -0
- package/dist/types/segments/HICAZS.d.ts.map +1 -0
- package/dist/types/segments/HISPA.d.ts +17 -0
- package/dist/types/segments/HISPA.d.ts.map +1 -0
- package/dist/types/segments/HISPAS.d.ts +14 -0
- package/dist/types/segments/HISPAS.d.ts.map +1 -0
- package/dist/types/segments/HKCAZ.d.ts +27 -0
- package/dist/types/segments/HKCAZ.d.ts.map +1 -0
- package/dist/types/segments/HKKAZ.d.ts +1 -1
- package/dist/types/segments/HKSAL.d.ts +1 -1
- package/dist/types/segments/HKSPA.d.ts +21 -0
- package/dist/types/segments/HKSPA.d.ts.map +1 -0
- package/dist/types/segments/HKTAN.d.ts +1 -1
- package/dist/types/segments/registry.d.ts.map +1 -1
- package/dist/types/statement.d.ts +39 -0
- package/dist/types/statement.d.ts.map +1 -0
- package/dist/types/tests/HICAZS.test.d.ts +2 -0
- package/dist/types/tests/HICAZS.test.d.ts.map +1 -0
- package/dist/types/tests/HKCAZ.test.d.ts +2 -0
- package/dist/types/tests/HKCAZ.test.d.ts.map +1 -0
- package/dist/types/tests/camtParser.test.d.ts +2 -0
- package/dist/types/tests/camtParser.test.d.ts.map +1 -0
- package/dist/types/tests/dialog.test.d.ts +2 -0
- package/dist/types/tests/dialog.test.d.ts.map +1 -0
- package/package.json +4 -1
- package/dist/types/interactions/statementInteraction.d.ts.map +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CustomerInteraction } from './customerInteraction.js';
|
|
2
|
+
import { HKEND } from '../segments/HKEND.js';
|
|
3
|
+
export class EndDialogInteraction extends CustomerInteraction {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(HKEND.Id);
|
|
6
|
+
}
|
|
7
|
+
createSegments(init) {
|
|
8
|
+
const hkend = {
|
|
9
|
+
header: { segId: HKEND.Id, segNr: 0, version: HKEND.Version },
|
|
10
|
+
dialogId: this.dialog.dialogId,
|
|
11
|
+
};
|
|
12
|
+
return [hkend];
|
|
13
|
+
}
|
|
14
|
+
handleResponse(response, clientResponse) {
|
|
15
|
+
// no special response handling needed
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CustomerInteraction } from './customerInteraction.js';
|
|
2
2
|
import { HKIDN } from '../segments/HKIDN.js';
|
|
3
3
|
import { HKVVB } from '../segments/HKVVB.js';
|
|
4
|
-
import { Language, SyncMode } from '../codes.js';
|
|
4
|
+
import { Language, SyncMode, TanMediaRequirement } from '../codes.js';
|
|
5
5
|
import { HKSYN } from '../segments/HKSYN.js';
|
|
6
6
|
import { HISYN } from '../segments/HISYN.js';
|
|
7
7
|
import { HIBPA } from '../segments/HIBPA.js';
|
|
@@ -12,15 +12,17 @@ import { HIUPA } from '../segments/HIUPA.js';
|
|
|
12
12
|
import { finTsAccountTypeToEnum } from '../bankAccount.js';
|
|
13
13
|
import { HIKIM } from '../segments/HIKIM.js';
|
|
14
14
|
import { HIUPD } from '../segments/HIUPD.js';
|
|
15
|
+
import { HKTAB } from '../segments/HKTAB.js';
|
|
16
|
+
import { TanMediaInteraction } from './tanMediaInteraction.js';
|
|
17
|
+
import { HKSPA } from '../segments/HKSPA.js';
|
|
18
|
+
import { SepaAccountInteraction } from './sepaAccountInteraction.js';
|
|
15
19
|
export class InitDialogInteraction extends CustomerInteraction {
|
|
16
20
|
config;
|
|
17
21
|
syncSystemId;
|
|
18
|
-
|
|
19
|
-
constructor(config, syncSystemId = false, followUpInteraction) {
|
|
22
|
+
constructor(config, syncSystemId = false) {
|
|
20
23
|
super(HKIDN.Id);
|
|
21
24
|
this.config = config;
|
|
22
25
|
this.syncSystemId = syncSystemId;
|
|
23
|
-
this.followUpInteraction = followUpInteraction;
|
|
24
26
|
}
|
|
25
27
|
createSegments(init) {
|
|
26
28
|
const segments = [];
|
|
@@ -51,7 +53,6 @@ export class InitDialogInteraction extends CustomerInteraction {
|
|
|
51
53
|
return segments;
|
|
52
54
|
}
|
|
53
55
|
handleResponse(response, clientResponse) {
|
|
54
|
-
const currentBankingInformationSnapshot = JSON.stringify(this.config.bankingInformation);
|
|
55
56
|
const hisyn = response.findSegment(HISYN.Id);
|
|
56
57
|
if (hisyn && hisyn.systemId) {
|
|
57
58
|
this.config.bankingInformation.systemId = hisyn.systemId;
|
|
@@ -129,7 +130,6 @@ export class InitDialogInteraction extends CustomerInteraction {
|
|
|
129
130
|
this.config.bankingInformation.bpd = bpd;
|
|
130
131
|
}
|
|
131
132
|
const tanMethodMessaqe = bankAnswers.find((answer) => answer.code === 3920);
|
|
132
|
-
let availableTanMethodIds = [];
|
|
133
133
|
if (tanMethodMessaqe && this.config.bankingInformation.bpd) {
|
|
134
134
|
this.config.bankingInformation.bpd.availableTanMethodIds =
|
|
135
135
|
tanMethodMessaqe.params?.map((p) => Number.parseInt(p)) ?? [];
|
|
@@ -164,8 +164,18 @@ export class InitDialogInteraction extends CustomerInteraction {
|
|
|
164
164
|
const bankMessages = hikimSegments.map((s) => ({ subject: s.subject, text: s.text }));
|
|
165
165
|
this.config.bankingInformation.bankMessages = bankMessages;
|
|
166
166
|
clientResponse.bankingInformation = this.config.bankingInformation;
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
if (this.config.selectedTanMethod &&
|
|
168
|
+
this.config.selectedTanMethod.tanMediaRequirement > TanMediaRequirement.NotAllowed &&
|
|
169
|
+
this.config.isTransactionSupported(HKTAB.Id)) {
|
|
170
|
+
this.dialog.addCustomerInteraction(new TanMediaInteraction(), true);
|
|
171
|
+
}
|
|
172
|
+
const bankAccounts = this.config.bankingInformation?.upd?.bankAccounts;
|
|
173
|
+
if (bankAccounts) {
|
|
174
|
+
if (bankAccounts.some((account) => account.isSepaAccount === undefined) &&
|
|
175
|
+
this.config.isTransactionSupported(HKSPA.Id)) {
|
|
176
|
+
this.dialog.addCustomerInteraction(new SepaAccountInteraction(), true);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
169
179
|
}
|
|
170
180
|
}
|
|
171
181
|
function isDecoupledTanMethod(tanMethod) {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
2
|
+
import { HISPA } from '../segments/HISPA.js';
|
|
3
|
+
import { HKSPA } from '../segments/HKSPA.js';
|
|
4
|
+
export class SepaAccountInteraction extends CustomerOrderInteraction {
|
|
5
|
+
accounts;
|
|
6
|
+
maxEntries;
|
|
7
|
+
constructor(accounts, // optional specific account numbers
|
|
8
|
+
maxEntries) {
|
|
9
|
+
super(HKSPA.Id, HISPA.Id);
|
|
10
|
+
this.accounts = accounts;
|
|
11
|
+
this.maxEntries = maxEntries;
|
|
12
|
+
}
|
|
13
|
+
createSegments(init) {
|
|
14
|
+
if (!init.isTransactionSupported(this.segId)) {
|
|
15
|
+
throw Error(`Business transaction '${this.segId}' is not supported by this bank`);
|
|
16
|
+
}
|
|
17
|
+
const version = init.getMaxSupportedTransactionVersion(HKSPA.Id);
|
|
18
|
+
if (!version) {
|
|
19
|
+
throw Error(`There is no supported version for business transaction '${HKSPA.Id}'`);
|
|
20
|
+
}
|
|
21
|
+
const accounts = this.accounts?.map((accountNumber) => {
|
|
22
|
+
return init.getBankAccount(accountNumber);
|
|
23
|
+
});
|
|
24
|
+
const hkspa = {
|
|
25
|
+
header: { segId: HKSPA.Id, segNr: 0, version: version },
|
|
26
|
+
accounts: accounts,
|
|
27
|
+
maxEntries: this.maxEntries,
|
|
28
|
+
};
|
|
29
|
+
return [hkspa];
|
|
30
|
+
}
|
|
31
|
+
handleResponse(response, clientResponse) {
|
|
32
|
+
const hispa = response.findSegment(HISPA.Id);
|
|
33
|
+
if (hispa) {
|
|
34
|
+
clientResponse.sepaAccounts = hispa.sepaAccounts || [];
|
|
35
|
+
this.dialog.config.bankingInformation.upd.bankAccounts.forEach((bankAccount) => {
|
|
36
|
+
bankAccount.isSepaAccount = false;
|
|
37
|
+
});
|
|
38
|
+
clientResponse.sepaAccounts.forEach((sepaAccount) => {
|
|
39
|
+
const bankAccount = this.dialog.config.getBankAccount(sepaAccount.accountNumber);
|
|
40
|
+
if (bankAccount) {
|
|
41
|
+
bankAccount.isSepaAccount = sepaAccount.isSepaAccount;
|
|
42
|
+
bankAccount.iban = sepaAccount.iban;
|
|
43
|
+
bankAccount.bic = sepaAccount.bic;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
2
|
+
import { HKCAZ } from '../segments/HKCAZ.js';
|
|
3
|
+
import { HICAZ } from '../segments/HICAZ.js';
|
|
4
|
+
import { CamtParser } from '../camtParser.js';
|
|
5
|
+
export class StatementInteractionCAMT extends CustomerOrderInteraction {
|
|
6
|
+
accountNumber;
|
|
7
|
+
from;
|
|
8
|
+
to;
|
|
9
|
+
acceptedCamtFormats = ['urn:iso:std:iso:20022:tech:xsd:camt.052.001.08'];
|
|
10
|
+
constructor(accountNumber, from, to) {
|
|
11
|
+
super(HKCAZ.Id, HICAZ.Id);
|
|
12
|
+
this.accountNumber = accountNumber;
|
|
13
|
+
this.from = from;
|
|
14
|
+
this.to = to;
|
|
15
|
+
}
|
|
16
|
+
createSegments(init) {
|
|
17
|
+
const bankAccount = init.getBankAccount(this.accountNumber);
|
|
18
|
+
const version = init.getMaxSupportedTransactionVersion(HKCAZ.Id);
|
|
19
|
+
if (!version) {
|
|
20
|
+
throw Error(`There is no supported version for business transaction '${HKCAZ.Id}'`);
|
|
21
|
+
}
|
|
22
|
+
const hkcaz = {
|
|
23
|
+
header: { segId: HKCAZ.Id, segNr: 0, version: version },
|
|
24
|
+
account: bankAccount,
|
|
25
|
+
acceptedCamtFormats: this.acceptedCamtFormats,
|
|
26
|
+
allAccounts: false,
|
|
27
|
+
from: this.from,
|
|
28
|
+
to: this.to,
|
|
29
|
+
};
|
|
30
|
+
return [hkcaz];
|
|
31
|
+
}
|
|
32
|
+
handleResponse(response, clientResponse) {
|
|
33
|
+
const hicaz = response.findSegment(HICAZ.Id);
|
|
34
|
+
if (hicaz && hicaz.bookedTransactions && hicaz.bookedTransactions.length > 0) {
|
|
35
|
+
try {
|
|
36
|
+
// Parse all CAMT messages (one per booking day) and combine statements
|
|
37
|
+
const allStatements = [];
|
|
38
|
+
for (const camtMessage of hicaz.bookedTransactions) {
|
|
39
|
+
const parser = new CamtParser(camtMessage);
|
|
40
|
+
const statements = parser.parse();
|
|
41
|
+
allStatements.push(...statements);
|
|
42
|
+
}
|
|
43
|
+
clientResponse.statements = allStatements;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.warn('CAMT parsing failed:', error);
|
|
47
|
+
clientResponse.statements = [];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
clientResponse.statements = [];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -2,7 +2,7 @@ import { CustomerOrderInteraction } from './customerInteraction.js';
|
|
|
2
2
|
import { HKKAZ } from '../segments/HKKAZ.js';
|
|
3
3
|
import { HIKAZ } from '../segments/HIKAZ.js';
|
|
4
4
|
import { Mt940Parser } from '../mt940parser.js';
|
|
5
|
-
export class
|
|
5
|
+
export class StatementInteractionMT940 extends CustomerOrderInteraction {
|
|
6
6
|
accountNumber;
|
|
7
7
|
from;
|
|
8
8
|
to;
|
|
@@ -14,13 +14,10 @@ export class StatementInteraction extends CustomerOrderInteraction {
|
|
|
14
14
|
}
|
|
15
15
|
createSegments(init) {
|
|
16
16
|
const bankAccount = init.getBankAccount(this.accountNumber);
|
|
17
|
-
if (!init.isAccountTransactionSupported(this.accountNumber, this.segId)) {
|
|
18
|
-
throw Error(`Account ${this.accountNumber} does not support business transaction '${this.segId}'`);
|
|
19
|
-
}
|
|
20
17
|
const account = { ...bankAccount, iban: undefined };
|
|
21
18
|
const version = init.getMaxSupportedTransactionVersion(HKKAZ.Id);
|
|
22
19
|
if (!version) {
|
|
23
|
-
throw Error(`There is no supported version for business transaction '${HKKAZ.Id}`);
|
|
20
|
+
throw Error(`There is no supported version for business transaction '${HKKAZ.Id}'`);
|
|
24
21
|
}
|
|
25
22
|
const hkkaz = {
|
|
26
23
|
header: { segId: HKKAZ.Id, segNr: 0, version: version },
|
|
@@ -33,9 +30,15 @@ export class StatementInteraction extends CustomerOrderInteraction {
|
|
|
33
30
|
}
|
|
34
31
|
handleResponse(response, clientResponse) {
|
|
35
32
|
const hikaz = response.findSegment(HIKAZ.Id);
|
|
36
|
-
if (hikaz) {
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
if (hikaz && hikaz.bookedTransactions) {
|
|
34
|
+
try {
|
|
35
|
+
const parser = new Mt940Parser(hikaz.bookedTransactions);
|
|
36
|
+
clientResponse.statements = parser.parse();
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.warn('MT940 parsing failed:', error);
|
|
40
|
+
clientResponse.statements = [];
|
|
41
|
+
}
|
|
39
42
|
}
|
|
40
43
|
else {
|
|
41
44
|
clientResponse.statements = [];
|
|
@@ -24,6 +24,10 @@ export class TanMediaInteraction extends CustomerOrderInteraction {
|
|
|
24
24
|
clientResponse.tanMediaList = (hitab.mediaList ?? [])
|
|
25
25
|
.map((media) => media.name)
|
|
26
26
|
.filter((name) => name);
|
|
27
|
+
let tanMethod = this.dialog.config.selectedTanMethod;
|
|
28
|
+
if (tanMethod) {
|
|
29
|
+
tanMethod.activeTanMedia = clientResponse.tanMediaList;
|
|
30
|
+
}
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Binary } from '../dataElements/Binary.js';
|
|
2
|
+
import { Text } from '../dataElements/Text.js';
|
|
3
|
+
import { InternationalAccountGroup } from '../dataGroups/InternationalAccount.js';
|
|
4
|
+
import { DataGroup } from '../dataGroups/DataGroup.js';
|
|
5
|
+
import { SegmentDefinition } from '../segmentDefinition.js';
|
|
6
|
+
/**
|
|
7
|
+
* Account transactions within period response (CAMT format)
|
|
8
|
+
*/
|
|
9
|
+
export class HICAZ extends SegmentDefinition {
|
|
10
|
+
static Id = 'HICAZ';
|
|
11
|
+
static Version = 1;
|
|
12
|
+
constructor() {
|
|
13
|
+
super(HICAZ.Id);
|
|
14
|
+
}
|
|
15
|
+
version = HICAZ.Version;
|
|
16
|
+
elements = [
|
|
17
|
+
new InternationalAccountGroup('account', 1, 1),
|
|
18
|
+
new Text('camtDescriptor', 1, 1), // camt-Descriptor (single format used)
|
|
19
|
+
new DataGroup('bookedTransactions', [new Binary('camtMessage', 1, 99)], 1, 1), // Booked CAMT transactions
|
|
20
|
+
new DataGroup('notedTransactions', [new Binary('camtMessage', 1, 99)], 0, 1), // Noted CAMT transactions
|
|
21
|
+
];
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { YesNo } from '../dataElements/YesNo.js';
|
|
2
|
+
import { Numeric } from '../dataElements/Numeric.js';
|
|
3
|
+
import { BusinessTransactionParameter } from './businessTransactionParameter.js';
|
|
4
|
+
import { AlphaNumeric } from '../dataElements/AlphaNumeric.js';
|
|
5
|
+
/**
|
|
6
|
+
* Parameters for HKCAZ business transaction (CAMT format statement retrieval)
|
|
7
|
+
*/
|
|
8
|
+
export class HICAZS extends BusinessTransactionParameter {
|
|
9
|
+
static Id = 'HICAZS';
|
|
10
|
+
version = 1;
|
|
11
|
+
constructor() {
|
|
12
|
+
super(HICAZS.Id, [
|
|
13
|
+
new Numeric('maxDays', 1, 1, 4),
|
|
14
|
+
new YesNo('maxEntryCountAllowed', 1, 1),
|
|
15
|
+
new YesNo('allAccountsAllowed', 1, 1),
|
|
16
|
+
new AlphaNumeric('supportedCamtFormats', 1, 99),
|
|
17
|
+
]);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SepaAccountGroup } from '../dataGroups/SepaAccount.js';
|
|
2
|
+
import { SegmentDefinition } from '../segmentDefinition.js';
|
|
3
|
+
/**
|
|
4
|
+
* SEPA account connection response - returns IBAN/BIC information
|
|
5
|
+
* Version 3 - returns SEPA account data in ktz format
|
|
6
|
+
*/
|
|
7
|
+
export class HISPA extends SegmentDefinition {
|
|
8
|
+
static Id = 'HISPA';
|
|
9
|
+
version = 3;
|
|
10
|
+
constructor() {
|
|
11
|
+
super(HISPA.Id);
|
|
12
|
+
}
|
|
13
|
+
elements = [new SepaAccountGroup('sepaAccounts', 0, 999)];
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BusinessTransactionParameter } from './businessTransactionParameter.js';
|
|
2
|
+
import { SepaAccountParametersGroup } from '../dataGroups/SepaAccountParameters.js';
|
|
3
|
+
/**
|
|
4
|
+
* Parameters for HKSPA business transaction - SEPA account connection request
|
|
5
|
+
* Version 3 supports all parameters including reserved purpose positions
|
|
6
|
+
*/
|
|
7
|
+
export class HISPAS extends BusinessTransactionParameter {
|
|
8
|
+
static Id = 'HISPAS';
|
|
9
|
+
version = 3;
|
|
10
|
+
constructor() {
|
|
11
|
+
super(HISPAS.Id, [new SepaAccountParametersGroup('sepaAccountParams', 1, 1)], 1 // secClassMinVersion
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Dat } from '../dataElements/Dat.js';
|
|
2
|
+
import { YesNo } from '../dataElements/YesNo.js';
|
|
3
|
+
import { Numeric } from '../dataElements/Numeric.js';
|
|
4
|
+
import { AlphaNumeric } from '../dataElements/AlphaNumeric.js';
|
|
5
|
+
import { Text } from '../dataElements/Text.js';
|
|
6
|
+
import { InternationalAccountGroup } from '../dataGroups/InternationalAccount.js';
|
|
7
|
+
import { DataGroup } from '../dataGroups/DataGroup.js';
|
|
8
|
+
import { SegmentDefinition } from '../segmentDefinition.js';
|
|
9
|
+
/**
|
|
10
|
+
* Request account transactions in a given period (CAMT format)
|
|
11
|
+
*/
|
|
12
|
+
export class HKCAZ extends SegmentDefinition {
|
|
13
|
+
static Id = 'HKCAZ';
|
|
14
|
+
static Version = 1;
|
|
15
|
+
constructor() {
|
|
16
|
+
super(HKCAZ.Id);
|
|
17
|
+
}
|
|
18
|
+
version = HKCAZ.Version;
|
|
19
|
+
elements = [
|
|
20
|
+
new InternationalAccountGroup('account', 1, 1),
|
|
21
|
+
new DataGroup('acceptedCamtFormats', [new Text('camtFormat', 1, 99)], 1, 1), // Support multiple camt-formats
|
|
22
|
+
new YesNo('allAccounts', 1, 1),
|
|
23
|
+
new Dat('from', 0, 1),
|
|
24
|
+
new Dat('to', 0, 1),
|
|
25
|
+
new Numeric('maxEntries', 0, 1, 4),
|
|
26
|
+
new AlphaNumeric('continuationMark', 0, 1, 35),
|
|
27
|
+
];
|
|
28
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Numeric } from '../dataElements/Numeric.js';
|
|
2
|
+
import { AlphaNumeric } from '../dataElements/AlphaNumeric.js';
|
|
3
|
+
import { AccountGroup } from '../dataGroups/Account.js';
|
|
4
|
+
import { SegmentDefinition } from '../segmentDefinition.js';
|
|
5
|
+
/**
|
|
6
|
+
* Request SEPA account connections (IBAN/BIC information)
|
|
7
|
+
* Version 3 - supports account specification, max entries and continuation
|
|
8
|
+
*/
|
|
9
|
+
export class HKSPA extends SegmentDefinition {
|
|
10
|
+
static Id = 'HKSPA';
|
|
11
|
+
static Version = 3;
|
|
12
|
+
constructor() {
|
|
13
|
+
super(HKSPA.Id);
|
|
14
|
+
}
|
|
15
|
+
version = HKSPA.Version;
|
|
16
|
+
elements = [
|
|
17
|
+
new AccountGroup('accounts', 0, 999),
|
|
18
|
+
new Numeric('maxEntries', 0, 1, 4, 2),
|
|
19
|
+
new AlphaNumeric('continuationMark', 0, 1, 35, 2),
|
|
20
|
+
];
|
|
21
|
+
}
|
|
@@ -26,11 +26,17 @@ import { HISAL } from './HISAL.js';
|
|
|
26
26
|
import { HKKAZ } from './HKKAZ.js';
|
|
27
27
|
import { HIKAZ } from './HIKAZ.js';
|
|
28
28
|
import { HIKAZS } from './HIKAZS.js';
|
|
29
|
+
import { HKCAZ } from './HKCAZ.js';
|
|
30
|
+
import { HICAZ } from './HICAZ.js';
|
|
31
|
+
import { HICAZS } from './HICAZS.js';
|
|
29
32
|
import { HITAB } from './HITAB.js';
|
|
30
33
|
import { HKWPD } from './HKWPD.js';
|
|
31
34
|
import { HIWPD } from './HIWPD.js';
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
35
|
+
import { HKSPA } from './HKSPA.js';
|
|
36
|
+
import { HISPA } from './HISPA.js';
|
|
37
|
+
import { HISPAS } from './HISPAS.js';
|
|
38
|
+
import { DIKKU } from './DIKKU.js';
|
|
39
|
+
import { DKKKU } from './DKKKU.js';
|
|
34
40
|
import { UNKNOW } from '../unknownSegment.js';
|
|
35
41
|
import { PARTED } from '../partedSegment.js';
|
|
36
42
|
const registry = new Map();
|
|
@@ -66,8 +72,16 @@ export function registerSegments() {
|
|
|
66
72
|
registerSegmentDefinition(new DIKKU());
|
|
67
73
|
registerSegmentDefinition(new HIKAZ());
|
|
68
74
|
registerSegmentDefinition(new HIKAZS());
|
|
75
|
+
registerSegmentDefinition(new HKCAZ());
|
|
76
|
+
registerSegmentDefinition(new HICAZ());
|
|
77
|
+
registerSegmentDefinition(new HICAZS());
|
|
69
78
|
registerSegmentDefinition(new HKWPD());
|
|
70
79
|
registerSegmentDefinition(new HIWPD());
|
|
80
|
+
registerSegmentDefinition(new HKWPD());
|
|
81
|
+
registerSegmentDefinition(new HIWPD());
|
|
82
|
+
registerSegmentDefinition(new HKSPA());
|
|
83
|
+
registerSegmentDefinition(new HISPA());
|
|
84
|
+
registerSegmentDefinition(new HISPAS());
|
|
71
85
|
registerSegmentDefinition(new UNKNOW());
|
|
72
86
|
registerSegmentDefinition(new PARTED());
|
|
73
87
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { registerSegments } from '../segments/registry.js';
|
|
3
|
+
import { decode, encode } from '../segment.js';
|
|
4
|
+
registerSegments();
|
|
5
|
+
describe('HICAZS', () => {
|
|
6
|
+
it('decode and encode roundtrip matches', () => {
|
|
7
|
+
const text = "HICAZS:16:1:4+1+1+0+450:N:N:urn?:iso?:std?:iso?:20022?:tech?:xsd?:camt.052.001.08:urn?:iso?:std?:iso?:20022?:tech?:xsd?:camt.052.001.08'";
|
|
8
|
+
const segment = decode(text);
|
|
9
|
+
expect(segment.params.maxDays).toBe(450);
|
|
10
|
+
expect(segment.params.entryCountAllowed).toBeFalsy();
|
|
11
|
+
expect(segment.params.allAccountsAllowed).toBeFalsy();
|
|
12
|
+
expect(segment.params.supportedCamtFormats).toEqual([
|
|
13
|
+
'urn:iso:std:iso:20022:tech:xsd:camt.052.001.08',
|
|
14
|
+
'urn:iso:std:iso:20022:tech:xsd:camt.052.001.08',
|
|
15
|
+
]);
|
|
16
|
+
expect(encode(segment)).toBe(text);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { registerSegments } from '../segments/registry.js';
|
|
3
|
+
import { HKCAZ } from '../segments/HKCAZ.js';
|
|
4
|
+
import { decode, encode } from '../segment.js';
|
|
5
|
+
registerSegments();
|
|
6
|
+
describe('HKCAZ v1', () => {
|
|
7
|
+
it('encode', () => {
|
|
8
|
+
const segment = {
|
|
9
|
+
header: { segId: HKCAZ.Id, segNr: 1, version: 1 },
|
|
10
|
+
account: {
|
|
11
|
+
iban: 'DE991234567123456',
|
|
12
|
+
bic: 'BANK12',
|
|
13
|
+
accountNumber: '123456',
|
|
14
|
+
bank: { country: 280, bankId: '12030000' },
|
|
15
|
+
},
|
|
16
|
+
acceptedCamtFormats: ['urn:iso:std:iso:20022:tech:xsd:camt.052.001.08'],
|
|
17
|
+
allAccounts: false,
|
|
18
|
+
from: new Date('2023-01-01'),
|
|
19
|
+
to: new Date('2023-12-31'),
|
|
20
|
+
};
|
|
21
|
+
expect(encode(segment)).toBe("HKCAZ:1:1+DE991234567123456:BANK12:123456::280:12030000+urn?:iso?:std?:iso?:20022?:tech?:xsd?:camt.052.001.08+N+20230101+20231231'");
|
|
22
|
+
});
|
|
23
|
+
it('encode without optional dates', () => {
|
|
24
|
+
const segment = {
|
|
25
|
+
header: { segId: HKCAZ.Id, segNr: 2, version: 1 },
|
|
26
|
+
account: {
|
|
27
|
+
iban: 'DE991234567123456',
|
|
28
|
+
bic: 'BANK12',
|
|
29
|
+
accountNumber: '123456',
|
|
30
|
+
bank: { country: 280, bankId: '12030000' },
|
|
31
|
+
},
|
|
32
|
+
acceptedCamtFormats: ['urn:iso:std:iso:20022:tech:xsd:camt.052.001.08'],
|
|
33
|
+
allAccounts: true,
|
|
34
|
+
};
|
|
35
|
+
expect(encode(segment)).toBe("HKCAZ:2:1+DE991234567123456:BANK12:123456::280:12030000+urn?:iso?:std?:iso?:20022?:tech?:xsd?:camt.052.001.08+J'");
|
|
36
|
+
});
|
|
37
|
+
it('decode and encode roundtrip matches', () => {
|
|
38
|
+
const text = "HKCAZ:0:1+DE991234567123456:BANK12:123456::280:12030000+urn?:iso?:std?:iso?:20022?:tech?:xsd?:camt.052.001.08+N+20230101+20231231'";
|
|
39
|
+
const segment = decode(text);
|
|
40
|
+
expect(encode(segment)).toBe(text);
|
|
41
|
+
});
|
|
42
|
+
it('decode and encode roundtrip without dates', () => {
|
|
43
|
+
const text = "HKCAZ:0:1+DE991234567123456:BANK12+urn?:iso?:std?:iso?:20022?:tech?:xsd?:camt.052.001.08+J'";
|
|
44
|
+
const segment = decode(text);
|
|
45
|
+
expect(encode(segment)).toBe(text);
|
|
46
|
+
});
|
|
47
|
+
});
|