fatoority 0.5.1 → 0.6.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 +9 -9
- package/errors.d.mts +67 -0
- package/errors.mjs +94 -0
- package/fatoora_ffi.wasm +0 -0
- package/generated/Adjustment.d.mts +9 -3
- package/generated/Adjustment.mjs +12 -6
- package/generated/AdjustmentKind.d.mts +24 -0
- package/generated/AdjustmentKind.mjs +72 -0
- package/generated/AllowanceCharge.d.mts +6 -4
- package/generated/AllowanceCharge.mjs +10 -8
- package/generated/ClearanceMode.d.mts +30 -0
- package/generated/ClearanceMode.mjs +78 -0
- package/generated/ClearanceStatus.d.mts +34 -0
- package/generated/ClearanceStatus.mjs +84 -0
- package/generated/{CsidCompliance.d.mts → ComplianceCsid.d.mts} +4 -3
- package/generated/{CsidCompliance.mjs → ComplianceCsid.mjs} +21 -13
- package/generated/ComplianceRequest.d.mts +2 -2
- package/generated/ComplianceRequest.mjs +2 -2
- package/generated/Config.d.mts +3 -2
- package/generated/Config.mjs +11 -3
- package/generated/CsrProperties.d.mts +6 -2
- package/generated/CsrProperties.mjs +7 -3
- package/generated/Environment.d.mts +28 -0
- package/generated/Environment.mjs +78 -0
- package/generated/FinalizedInvoice.d.mts +1 -1
- package/generated/FinalizedInvoice.mjs +2 -2
- package/generated/InvoiceBuilder.d.mts +18 -21
- package/generated/InvoiceBuilder.mjs +31 -168
- package/generated/InvoiceData.d.mts +7 -4
- package/generated/InvoiceData.mjs +8 -5
- package/generated/InvoiceFlag.d.mts +36 -0
- package/generated/InvoiceFlag.mjs +105 -0
- package/generated/InvoiceLineItem.d.mts +5 -3
- package/generated/InvoiceLineItem.mjs +8 -6
- package/generated/{Signer.d.mts → InvoiceSigner.d.mts} +3 -3
- package/generated/{Signer.mjs → InvoiceSigner.mjs} +13 -13
- package/generated/InvoiceSubType.d.mts +26 -0
- package/generated/InvoiceSubType.mjs +74 -0
- package/generated/InvoiceTypeKind.d.mts +40 -0
- package/generated/InvoiceTypeKind.mjs +92 -0
- package/generated/LineItemBuilder.d.mts +2 -1
- package/generated/LineItemBuilder.mjs +2 -1
- package/generated/MessageType.d.mts +38 -0
- package/generated/MessageType.mjs +90 -0
- package/generated/{CsidProduction.d.mts → ProductionCsid.d.mts} +4 -3
- package/generated/{CsidProduction.mjs → ProductionCsid.mjs} +21 -13
- package/generated/ProductionRequest.d.mts +2 -2
- package/generated/ProductionRequest.mjs +2 -2
- package/generated/ReportingStatus.d.mts +34 -0
- package/generated/ReportingStatus.mjs +84 -0
- package/generated/Severity.d.mts +30 -0
- package/generated/Severity.mjs +78 -0
- package/generated/SignedInvoice.d.mts +1 -1
- package/generated/SignedInvoice.mjs +2 -2
- package/generated/ValidationLayer.d.mts +49 -0
- package/generated/ValidationLayer.mjs +107 -0
- package/generated/ValidationLocationKind.d.mts +37 -0
- package/generated/ValidationLocationKind.mjs +89 -0
- package/generated/ValidationMessage.d.mts +20 -2
- package/generated/ValidationMessage.mjs +52 -0
- package/generated/ValidationResponse.d.mts +21 -3
- package/generated/ValidationResponse.mjs +52 -0
- package/generated/ValidationResults.d.mts +10 -1
- package/generated/ValidationResults.mjs +26 -0
- package/generated/ValidationStatus.d.mts +38 -0
- package/generated/ValidationStatus.mjs +90 -0
- package/generated/VatBreakdown.d.mts +4 -3
- package/generated/VatBreakdown.mjs +5 -4
- package/generated/VatCategory.d.mts +40 -0
- package/generated/VatCategory.mjs +92 -0
- package/generated/Xml.d.mts +12 -5
- package/generated/Xml.mjs +15 -11
- package/generated/ZatcaClient.d.mts +10 -9
- package/generated/ZatcaClient.mjs +15 -14
- package/generated/ZatcaFinding.d.mts +59 -0
- package/generated/ZatcaFinding.mjs +239 -0
- package/generated/ZatcaRuleSource.d.mts +26 -0
- package/generated/ZatcaRuleSource.mjs +97 -0
- package/generated/ZatcaStage.d.mts +49 -0
- package/generated/ZatcaStage.mjs +107 -0
- package/generated/ZatcaStageReport.d.mts +41 -0
- package/generated/ZatcaStageReport.mjs +168 -0
- package/generated/ZatcaStageStatus.d.mts +45 -0
- package/generated/ZatcaStageStatus.mjs +101 -0
- package/generated/ZatcaValidationReport.d.mts +63 -0
- package/generated/ZatcaValidationReport.mjs +228 -0
- package/generated/index.d.mts +45 -5
- package/generated/index.mjs +45 -5
- package/index.d.mts +131 -15
- package/index.mjs +111 -33
- package/members.mjs +67 -0
- package/package.json +10 -4
- package/patch.mjs +121 -0
- package/raw.d.mts +731 -0
- package/raw.mjs +4 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import { BindingError } from "./BindingError.mjs"
|
|
3
|
+
import { ClearanceMode } from "./ClearanceMode.mjs"
|
|
4
|
+
import { ComplianceCsid } from "./ComplianceCsid.mjs"
|
|
3
5
|
import { ComplianceRequest } from "./ComplianceRequest.mjs"
|
|
4
6
|
import { Config } from "./Config.mjs"
|
|
5
|
-
import { CsidCompliance } from "./CsidCompliance.mjs"
|
|
6
|
-
import { CsidProduction } from "./CsidProduction.mjs"
|
|
7
7
|
import { Csr } from "./Csr.mjs"
|
|
8
8
|
import { InvoiceRequest } from "./InvoiceRequest.mjs"
|
|
9
|
+
import { ProductionCsid } from "./ProductionCsid.mjs"
|
|
9
10
|
import { ProductionRequest } from "./ProductionRequest.mjs"
|
|
10
11
|
import { SignedInvoice } from "./SignedInvoice.mjs"
|
|
11
12
|
import wasm from "./diplomat-wasm.mjs";
|
|
@@ -44,11 +45,11 @@ export class ZatcaClient {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
|
|
47
|
-
static
|
|
48
|
+
static new_(config) {
|
|
48
49
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
49
50
|
|
|
50
51
|
|
|
51
|
-
const result = wasm.
|
|
52
|
+
const result = wasm.fatoora_ZatcaClient_new(diplomatReceive.buffer, config instanceof Config ? config.ffiValue : typeError('config', 'Config'));
|
|
52
53
|
|
|
53
54
|
try {
|
|
54
55
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -64,14 +65,14 @@ export class ZatcaClient {
|
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
|
|
68
|
+
prepareRequestComplianceCsid(csr, otp) {
|
|
68
69
|
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
69
70
|
|
|
70
71
|
const otpSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, otp)));
|
|
71
72
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
72
73
|
|
|
73
74
|
|
|
74
|
-
const result = wasm.
|
|
75
|
+
const result = wasm.fatoora_ZatcaClient_prepare_request_compliance_csid(diplomatReceive.buffer, this.ffiValue, csr instanceof Csr ? csr.ffiValue : typeError('csr', 'Csr'), otpSlice.ptr);
|
|
75
76
|
|
|
76
77
|
try {
|
|
77
78
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -89,11 +90,11 @@ export class ZatcaClient {
|
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
|
|
93
|
+
prepareRequestProductionCsid(credentials) {
|
|
93
94
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
94
95
|
|
|
95
96
|
|
|
96
|
-
const result = wasm.
|
|
97
|
+
const result = wasm.fatoora_ZatcaClient_prepare_request_production_csid(diplomatReceive.buffer, this.ffiValue, credentials instanceof ComplianceCsid ? credentials.ffiValue : typeError('credentials', 'ComplianceCsid'));
|
|
97
98
|
|
|
98
99
|
try {
|
|
99
100
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -116,7 +117,7 @@ export class ZatcaClient {
|
|
|
116
117
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
117
118
|
|
|
118
119
|
|
|
119
|
-
const result = wasm.fatoora_ZatcaClient_prepare_renew_csid(diplomatReceive.buffer, this.ffiValue, credentials instanceof
|
|
120
|
+
const result = wasm.fatoora_ZatcaClient_prepare_renew_csid(diplomatReceive.buffer, this.ffiValue, credentials instanceof ProductionCsid ? credentials.ffiValue : typeError('credentials', 'ProductionCsid'), csr instanceof Csr ? csr.ffiValue : typeError('csr', 'Csr'), otpSlice.ptr, diplomatRuntime.optionToBufferForCalling(wasm, acceptLanguage, 8, 4, functionCleanupArena, (arrayBuffer, offset, jsValue) => [functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, jsValue)).writePtrLenToArrayBuffer(arrayBuffer, offset + 0)]));
|
|
120
121
|
|
|
121
122
|
try {
|
|
122
123
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -138,7 +139,7 @@ export class ZatcaClient {
|
|
|
138
139
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
139
140
|
|
|
140
141
|
|
|
141
|
-
const result = wasm.fatoora_ZatcaClient_prepare_check_invoice_compliance(diplomatReceive.buffer, this.ffiValue, invoice instanceof SignedInvoice ? invoice.ffiValue : typeError('invoice', 'SignedInvoice'), credentials instanceof
|
|
142
|
+
const result = wasm.fatoora_ZatcaClient_prepare_check_invoice_compliance(diplomatReceive.buffer, this.ffiValue, invoice instanceof SignedInvoice ? invoice.ffiValue : typeError('invoice', 'SignedInvoice'), credentials instanceof ComplianceCsid ? credentials.ffiValue : typeError('credentials', 'ComplianceCsid'));
|
|
142
143
|
|
|
143
144
|
try {
|
|
144
145
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -154,13 +155,13 @@ export class ZatcaClient {
|
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
157
|
|
|
157
|
-
prepareReportSimplifiedInvoice(invoice, credentials,
|
|
158
|
+
prepareReportSimplifiedInvoice(invoice, credentials, clearanceMode, acceptLanguage) {
|
|
158
159
|
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
159
160
|
|
|
160
161
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
161
162
|
|
|
162
163
|
|
|
163
|
-
const result = wasm.fatoora_ZatcaClient_prepare_report_simplified_invoice(diplomatReceive.buffer, this.ffiValue, invoice instanceof SignedInvoice ? invoice.ffiValue : typeError('invoice', 'SignedInvoice'), credentials instanceof
|
|
164
|
+
const result = wasm.fatoora_ZatcaClient_prepare_report_simplified_invoice(diplomatReceive.buffer, this.ffiValue, invoice instanceof SignedInvoice ? invoice.ffiValue : typeError('invoice', 'SignedInvoice'), credentials instanceof ProductionCsid ? credentials.ffiValue : typeError('credentials', 'ProductionCsid'), new ClearanceMode(clearanceMode).ffiValue, diplomatRuntime.optionToBufferForCalling(wasm, acceptLanguage, 8, 4, functionCleanupArena, (arrayBuffer, offset, jsValue) => [functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, jsValue)).writePtrLenToArrayBuffer(arrayBuffer, offset + 0)]));
|
|
164
165
|
|
|
165
166
|
try {
|
|
166
167
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -178,13 +179,13 @@ export class ZatcaClient {
|
|
|
178
179
|
}
|
|
179
180
|
}
|
|
180
181
|
|
|
181
|
-
prepareClearStandardInvoice(invoice, credentials,
|
|
182
|
+
prepareClearStandardInvoice(invoice, credentials, clearanceMode, acceptLanguage) {
|
|
182
183
|
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
183
184
|
|
|
184
185
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
185
186
|
|
|
186
187
|
|
|
187
|
-
const result = wasm.fatoora_ZatcaClient_prepare_clear_standard_invoice(diplomatReceive.buffer, this.ffiValue, invoice instanceof SignedInvoice ? invoice.ffiValue : typeError('invoice', 'SignedInvoice'), credentials instanceof
|
|
188
|
+
const result = wasm.fatoora_ZatcaClient_prepare_clear_standard_invoice(diplomatReceive.buffer, this.ffiValue, invoice instanceof SignedInvoice ? invoice.ffiValue : typeError('invoice', 'SignedInvoice'), credentials instanceof ProductionCsid ? credentials.ffiValue : typeError('credentials', 'ProductionCsid'), new ClearanceMode(clearanceMode).ffiValue, diplomatRuntime.optionToBufferForCalling(wasm, acceptLanguage, 8, 4, functionCleanupArena, (arrayBuffer, offset, jsValue) => [functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, jsValue)).writePtrLenToArrayBuffer(arrayBuffer, offset + 0)]));
|
|
188
189
|
|
|
189
190
|
try {
|
|
190
191
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { BindingError } from "./BindingError.mjs"
|
|
3
|
+
import type { Severity } from "./Severity.mjs"
|
|
4
|
+
import type { Text } from "./Text.mjs"
|
|
5
|
+
import type { ValidationLayer } from "./ValidationLayer.mjs"
|
|
6
|
+
import type { ValidationLocationKind } from "./ValidationLocationKind.mjs"
|
|
7
|
+
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* One validation finding with its source assertion, when applicable.
|
|
13
|
+
*/
|
|
14
|
+
export class ZatcaFinding {
|
|
15
|
+
/** @internal */
|
|
16
|
+
get ffiValue(): pointer;
|
|
17
|
+
/** @internal */
|
|
18
|
+
constructor();
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Rule assertion that produced the finding, for business-rule findings.
|
|
23
|
+
*/
|
|
24
|
+
assertionSite(): Text | null;
|
|
25
|
+
|
|
26
|
+
layer(): ValidationLayer;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Library-owned rule identifier, independent of message wording.
|
|
30
|
+
*/
|
|
31
|
+
code(): string;
|
|
32
|
+
|
|
33
|
+
severity(): Severity;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Human-readable text; the wording is not a stable API.
|
|
37
|
+
*/
|
|
38
|
+
message(): string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The kind of location, or null when the source cannot locate the finding.
|
|
42
|
+
*/
|
|
43
|
+
locationKind(): ValidationLocationKind | null;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The field path or XPath, or null for other location kinds.
|
|
47
|
+
*/
|
|
48
|
+
locationPath(): Text | null;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* One-based XML line, or null when the location is not XML coordinates.
|
|
52
|
+
*/
|
|
53
|
+
locationLine(): number | null;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* One-based XML column, or null when unknown.
|
|
57
|
+
*/
|
|
58
|
+
locationColumn(): number | null;
|
|
59
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import { BindingError } from "./BindingError.mjs"
|
|
3
|
+
import { Severity } from "./Severity.mjs"
|
|
4
|
+
import { Text } from "./Text.mjs"
|
|
5
|
+
import { ValidationLayer } from "./ValidationLayer.mjs"
|
|
6
|
+
import { ValidationLocationKind } from "./ValidationLocationKind.mjs"
|
|
7
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
8
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
9
|
+
|
|
10
|
+
const ZatcaFinding_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
11
|
+
wasm.fatoora_ZatcaFinding_destroy(ptr);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* One validation finding with its source assertion, when applicable.
|
|
16
|
+
*/
|
|
17
|
+
export class ZatcaFinding {
|
|
18
|
+
// Internal ptr reference:
|
|
19
|
+
#ptr = null;
|
|
20
|
+
|
|
21
|
+
// Lifetimes are only to keep dependencies alive.
|
|
22
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
23
|
+
#selfEdge = [];
|
|
24
|
+
|
|
25
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
26
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
27
|
+
console.error("ZatcaFinding is an Opaque type. You cannot call its constructor.");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
this.#ptr = ptr;
|
|
31
|
+
this.#selfEdge = selfEdge;
|
|
32
|
+
|
|
33
|
+
// Are we being borrowed? If not, we can register.
|
|
34
|
+
if (this.#selfEdge.length === 0) {
|
|
35
|
+
ZatcaFinding_box_destroy_registry.register(this, this.#ptr);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
/** @internal */
|
|
41
|
+
get ffiValue() {
|
|
42
|
+
return this.#ptr;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Rule assertion that produced the finding, for business-rule findings.
|
|
48
|
+
*/
|
|
49
|
+
assertionSite() {
|
|
50
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
const result = wasm.fatoora_ZatcaFinding_assertion_site(diplomatReceive.buffer, this.ffiValue);
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
if (!diplomatReceive.resultFlag) {
|
|
57
|
+
const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
58
|
+
throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
|
|
59
|
+
}
|
|
60
|
+
return diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer) === 0 ? null : new Text(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
finally {
|
|
64
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
65
|
+
diplomatReceive.free();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
layer() {
|
|
70
|
+
|
|
71
|
+
const result = wasm.fatoora_ZatcaFinding_layer(this.ffiValue);
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
return new ValidationLayer(diplomatRuntime.internalConstructor, result);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
finally {
|
|
78
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Library-owned rule identifier, independent of message wording.
|
|
84
|
+
*/
|
|
85
|
+
code() {
|
|
86
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
87
|
+
|
|
88
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
const result = wasm.fatoora_ZatcaFinding_code(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
if (!diplomatReceive.resultFlag) {
|
|
95
|
+
const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
96
|
+
throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
|
|
97
|
+
}
|
|
98
|
+
return write.readString8();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
finally {
|
|
102
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
103
|
+
diplomatReceive.free();
|
|
104
|
+
write.free();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
severity() {
|
|
109
|
+
|
|
110
|
+
const result = wasm.fatoora_ZatcaFinding_severity(this.ffiValue);
|
|
111
|
+
|
|
112
|
+
try {
|
|
113
|
+
return new Severity(diplomatRuntime.internalConstructor, result);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
finally {
|
|
117
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Human-readable text; the wording is not a stable API.
|
|
123
|
+
*/
|
|
124
|
+
message() {
|
|
125
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
126
|
+
|
|
127
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
const result = wasm.fatoora_ZatcaFinding_message(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
if (!diplomatReceive.resultFlag) {
|
|
134
|
+
const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
135
|
+
throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
|
|
136
|
+
}
|
|
137
|
+
return write.readString8();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
finally {
|
|
141
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
142
|
+
diplomatReceive.free();
|
|
143
|
+
write.free();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The kind of location, or null when the source cannot locate the finding.
|
|
149
|
+
*/
|
|
150
|
+
locationKind() {
|
|
151
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
const result = wasm.fatoora_ZatcaFinding_location_kind(diplomatReceive.buffer, this.ffiValue);
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
if (!diplomatReceive.resultFlag) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
return new ValidationLocationKind(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
finally {
|
|
164
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
165
|
+
diplomatReceive.free();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The field path or XPath, or null for other location kinds.
|
|
171
|
+
*/
|
|
172
|
+
locationPath() {
|
|
173
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
const result = wasm.fatoora_ZatcaFinding_location_path(diplomatReceive.buffer, this.ffiValue);
|
|
177
|
+
|
|
178
|
+
try {
|
|
179
|
+
if (!diplomatReceive.resultFlag) {
|
|
180
|
+
const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
181
|
+
throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
|
|
182
|
+
}
|
|
183
|
+
return diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer) === 0 ? null : new Text(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
finally {
|
|
187
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
188
|
+
diplomatReceive.free();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* One-based XML line, or null when the location is not XML coordinates.
|
|
194
|
+
*/
|
|
195
|
+
locationLine() {
|
|
196
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
const result = wasm.fatoora_ZatcaFinding_location_line(diplomatReceive.buffer, this.ffiValue);
|
|
200
|
+
|
|
201
|
+
try {
|
|
202
|
+
if (!diplomatReceive.resultFlag) {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
return (new Uint32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
finally {
|
|
209
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
210
|
+
diplomatReceive.free();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* One-based XML column, or null when unknown.
|
|
216
|
+
*/
|
|
217
|
+
locationColumn() {
|
|
218
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
const result = wasm.fatoora_ZatcaFinding_location_column(diplomatReceive.buffer, this.ffiValue);
|
|
222
|
+
|
|
223
|
+
try {
|
|
224
|
+
if (!diplomatReceive.resultFlag) {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
return (new Uint32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
finally {
|
|
231
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
232
|
+
diplomatReceive.free();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
constructor(symbol, ptr, selfEdge) {
|
|
237
|
+
return this.#internalConstructor(...arguments)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { BindingError } from "./BindingError.mjs"
|
|
3
|
+
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Pinned upstream rule source of a business-rule stage.
|
|
9
|
+
*/
|
|
10
|
+
export class ZatcaRuleSource {
|
|
11
|
+
/** @internal */
|
|
12
|
+
get ffiValue(): pointer;
|
|
13
|
+
/** @internal */
|
|
14
|
+
constructor();
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* File name of the upstream rule stylesheet.
|
|
19
|
+
*/
|
|
20
|
+
stylesheet(): string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Hex SHA-256 digest of the pinned stylesheet.
|
|
24
|
+
*/
|
|
25
|
+
sha256(): string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import { BindingError } from "./BindingError.mjs"
|
|
3
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
4
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
5
|
+
|
|
6
|
+
const ZatcaRuleSource_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
7
|
+
wasm.fatoora_ZatcaRuleSource_destroy(ptr);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Pinned upstream rule source of a business-rule stage.
|
|
12
|
+
*/
|
|
13
|
+
export class ZatcaRuleSource {
|
|
14
|
+
// Internal ptr reference:
|
|
15
|
+
#ptr = null;
|
|
16
|
+
|
|
17
|
+
// Lifetimes are only to keep dependencies alive.
|
|
18
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
19
|
+
#selfEdge = [];
|
|
20
|
+
|
|
21
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
22
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
23
|
+
console.error("ZatcaRuleSource is an Opaque type. You cannot call its constructor.");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.#ptr = ptr;
|
|
27
|
+
this.#selfEdge = selfEdge;
|
|
28
|
+
|
|
29
|
+
// Are we being borrowed? If not, we can register.
|
|
30
|
+
if (this.#selfEdge.length === 0) {
|
|
31
|
+
ZatcaRuleSource_box_destroy_registry.register(this, this.#ptr);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
/** @internal */
|
|
37
|
+
get ffiValue() {
|
|
38
|
+
return this.#ptr;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* File name of the upstream rule stylesheet.
|
|
44
|
+
*/
|
|
45
|
+
stylesheet() {
|
|
46
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
47
|
+
|
|
48
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
const result = wasm.fatoora_ZatcaRuleSource_stylesheet(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
if (!diplomatReceive.resultFlag) {
|
|
55
|
+
const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
56
|
+
throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
|
|
57
|
+
}
|
|
58
|
+
return write.readString8();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
finally {
|
|
62
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
63
|
+
diplomatReceive.free();
|
|
64
|
+
write.free();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Hex SHA-256 digest of the pinned stylesheet.
|
|
70
|
+
*/
|
|
71
|
+
sha256() {
|
|
72
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
73
|
+
|
|
74
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
const result = wasm.fatoora_ZatcaRuleSource_sha256(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
if (!diplomatReceive.resultFlag) {
|
|
81
|
+
const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
82
|
+
throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
|
|
83
|
+
}
|
|
84
|
+
return write.readString8();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
finally {
|
|
88
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
89
|
+
diplomatReceive.free();
|
|
90
|
+
write.free();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
constructor(symbol, ptr, selfEdge) {
|
|
95
|
+
return this.#internalConstructor(...arguments)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A stage of the local ZATCA validation profile.
|
|
8
|
+
*
|
|
9
|
+
* `Unknown` marks a stage this binding version does not recognize.
|
|
10
|
+
*/
|
|
11
|
+
export class ZatcaStage {
|
|
12
|
+
|
|
13
|
+
/** @internal */
|
|
14
|
+
static fromValue(value: ZatcaStage | string): ZatcaStage;
|
|
15
|
+
|
|
16
|
+
get value(): string;
|
|
17
|
+
|
|
18
|
+
/** @internal */
|
|
19
|
+
get ffiValue(): number;
|
|
20
|
+
|
|
21
|
+
static Unknown : ZatcaStage;
|
|
22
|
+
/**
|
|
23
|
+
* UBL XML schema (XSD) validation.
|
|
24
|
+
*/
|
|
25
|
+
static Xsd : ZatcaStage;
|
|
26
|
+
/**
|
|
27
|
+
* CEN EN 16931 business rules.
|
|
28
|
+
*/
|
|
29
|
+
static Cen : ZatcaStage;
|
|
30
|
+
/**
|
|
31
|
+
* ZATCA KSA-specific business rules.
|
|
32
|
+
*/
|
|
33
|
+
static Ksa : ZatcaStage;
|
|
34
|
+
/**
|
|
35
|
+
* Cryptographic signature, digest and certificate checks.
|
|
36
|
+
*/
|
|
37
|
+
static Signature : ZatcaStage;
|
|
38
|
+
/**
|
|
39
|
+
* QR payload consistency checks.
|
|
40
|
+
*/
|
|
41
|
+
static Qr : ZatcaStage;
|
|
42
|
+
/**
|
|
43
|
+
* Comparison of the embedded previous invoice hash with the supplied one.
|
|
44
|
+
*/
|
|
45
|
+
static PreviousInvoiceHash : ZatcaStage;
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
constructor(value: ZatcaStage | string );
|
|
49
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
3
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A stage of the local ZATCA validation profile.
|
|
9
|
+
*
|
|
10
|
+
* `Unknown` marks a stage this binding version does not recognize.
|
|
11
|
+
*/
|
|
12
|
+
export class ZatcaStage {
|
|
13
|
+
#value = undefined;
|
|
14
|
+
|
|
15
|
+
static #values = new Map([
|
|
16
|
+
["Unknown", 0],
|
|
17
|
+
["Xsd", 1],
|
|
18
|
+
["Cen", 2],
|
|
19
|
+
["Ksa", 3],
|
|
20
|
+
["Signature", 4],
|
|
21
|
+
["Qr", 5],
|
|
22
|
+
["PreviousInvoiceHash", 6]
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
static getAllEntries() {
|
|
26
|
+
return ZatcaStage.#values.entries();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
#internalConstructor(value) {
|
|
30
|
+
if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
|
|
31
|
+
// We pass in two internalConstructor arguments to create *new*
|
|
32
|
+
// instances of this type, otherwise the enums are treated as singletons.
|
|
33
|
+
if (arguments[1] === diplomatRuntime.internalConstructor ) {
|
|
34
|
+
this.#value = arguments[2];
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
return ZatcaStage.#objectValues[arguments[1]];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (value instanceof ZatcaStage) {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let intVal = ZatcaStage.#values.get(value);
|
|
45
|
+
|
|
46
|
+
// Nullish check, checks for null or undefined
|
|
47
|
+
if (intVal != null) {
|
|
48
|
+
return ZatcaStage.#objectValues[intVal];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
throw TypeError(value + " is not a ZatcaStage and does not correspond to any of its enumerator values.");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** @internal */
|
|
55
|
+
static fromValue(value) {
|
|
56
|
+
return new ZatcaStage(value);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
get value(){
|
|
60
|
+
return [...ZatcaStage.#values.keys()][this.#value];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** @internal */
|
|
64
|
+
get ffiValue(){
|
|
65
|
+
return this.#value;
|
|
66
|
+
}
|
|
67
|
+
static #objectValues = [
|
|
68
|
+
new ZatcaStage(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
|
|
69
|
+
new ZatcaStage(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
|
|
70
|
+
new ZatcaStage(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
|
|
71
|
+
new ZatcaStage(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
|
|
72
|
+
new ZatcaStage(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4),
|
|
73
|
+
new ZatcaStage(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5),
|
|
74
|
+
new ZatcaStage(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6),
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
static Unknown = ZatcaStage.#objectValues[0];
|
|
78
|
+
/**
|
|
79
|
+
* UBL XML schema (XSD) validation.
|
|
80
|
+
*/
|
|
81
|
+
static Xsd = ZatcaStage.#objectValues[1];
|
|
82
|
+
/**
|
|
83
|
+
* CEN EN 16931 business rules.
|
|
84
|
+
*/
|
|
85
|
+
static Cen = ZatcaStage.#objectValues[2];
|
|
86
|
+
/**
|
|
87
|
+
* ZATCA KSA-specific business rules.
|
|
88
|
+
*/
|
|
89
|
+
static Ksa = ZatcaStage.#objectValues[3];
|
|
90
|
+
/**
|
|
91
|
+
* Cryptographic signature, digest and certificate checks.
|
|
92
|
+
*/
|
|
93
|
+
static Signature = ZatcaStage.#objectValues[4];
|
|
94
|
+
/**
|
|
95
|
+
* QR payload consistency checks.
|
|
96
|
+
*/
|
|
97
|
+
static Qr = ZatcaStage.#objectValues[5];
|
|
98
|
+
/**
|
|
99
|
+
* Comparison of the embedded previous invoice hash with the supplied one.
|
|
100
|
+
*/
|
|
101
|
+
static PreviousInvoiceHash = ZatcaStage.#objectValues[6];
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
constructor(value) {
|
|
105
|
+
return this.#internalConstructor(...arguments)
|
|
106
|
+
}
|
|
107
|
+
}
|