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,6 +1,8 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import type { BindingError } from "./BindingError.mjs"
|
|
3
|
+
import type { ClearanceStatus } from "./ClearanceStatus.mjs"
|
|
3
4
|
import type { InvoiceOutcome } from "./InvoiceOutcome.mjs"
|
|
5
|
+
import type { ReportingStatus } from "./ReportingStatus.mjs"
|
|
4
6
|
import type { Text } from "./Text.mjs"
|
|
5
7
|
import type { ValidationResults } from "./ValidationResults.mjs"
|
|
6
8
|
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
@@ -26,9 +28,25 @@ export class ValidationResponse {
|
|
|
26
28
|
|
|
27
29
|
clearedInvoiceBase64(): Text | null;
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The parsed `reportingStatus`, or null when the response has none.
|
|
33
|
+
*/
|
|
34
|
+
reportingStatus(): ReportingStatus | null;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The `reportingStatus` exactly as ZATCA sent it, or null when absent.
|
|
38
|
+
*/
|
|
39
|
+
reportingStatusRaw(): Text | null;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The parsed `clearanceStatus`, or null when the response has none.
|
|
43
|
+
*/
|
|
44
|
+
clearanceStatus(): ClearanceStatus | null;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The `clearanceStatus` exactly as ZATCA sent it, or null when absent.
|
|
48
|
+
*/
|
|
49
|
+
clearanceStatusRaw(): Text | null;
|
|
32
50
|
|
|
33
51
|
qrSellerStatus(): Text | null;
|
|
34
52
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import { BindingError } from "./BindingError.mjs"
|
|
3
|
+
import { ClearanceStatus } from "./ClearanceStatus.mjs"
|
|
3
4
|
import { InvoiceOutcome } from "./InvoiceOutcome.mjs"
|
|
5
|
+
import { ReportingStatus } from "./ReportingStatus.mjs"
|
|
4
6
|
import { Text } from "./Text.mjs"
|
|
5
7
|
import { ValidationResults } from "./ValidationResults.mjs"
|
|
6
8
|
import wasm from "./diplomat-wasm.mjs";
|
|
@@ -150,12 +152,37 @@ export class ValidationResponse {
|
|
|
150
152
|
}
|
|
151
153
|
}
|
|
152
154
|
|
|
155
|
+
/**
|
|
156
|
+
* The parsed `reportingStatus`, or null when the response has none.
|
|
157
|
+
*/
|
|
153
158
|
reportingStatus() {
|
|
154
159
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
155
160
|
|
|
156
161
|
|
|
157
162
|
const result = wasm.fatoora_ValidationResponse_reporting_status(diplomatReceive.buffer, this.ffiValue);
|
|
158
163
|
|
|
164
|
+
try {
|
|
165
|
+
if (!diplomatReceive.resultFlag) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
return new ReportingStatus(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
finally {
|
|
172
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
173
|
+
diplomatReceive.free();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The `reportingStatus` exactly as ZATCA sent it, or null when absent.
|
|
179
|
+
*/
|
|
180
|
+
reportingStatusRaw() {
|
|
181
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
const result = wasm.fatoora_ValidationResponse_reporting_status_raw(diplomatReceive.buffer, this.ffiValue);
|
|
185
|
+
|
|
159
186
|
try {
|
|
160
187
|
if (!diplomatReceive.resultFlag) {
|
|
161
188
|
const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
@@ -170,12 +197,37 @@ export class ValidationResponse {
|
|
|
170
197
|
}
|
|
171
198
|
}
|
|
172
199
|
|
|
200
|
+
/**
|
|
201
|
+
* The parsed `clearanceStatus`, or null when the response has none.
|
|
202
|
+
*/
|
|
173
203
|
clearanceStatus() {
|
|
174
204
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
175
205
|
|
|
176
206
|
|
|
177
207
|
const result = wasm.fatoora_ValidationResponse_clearance_status(diplomatReceive.buffer, this.ffiValue);
|
|
178
208
|
|
|
209
|
+
try {
|
|
210
|
+
if (!diplomatReceive.resultFlag) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
return new ClearanceStatus(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
finally {
|
|
217
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
218
|
+
diplomatReceive.free();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* The `clearanceStatus` exactly as ZATCA sent it, or null when absent.
|
|
224
|
+
*/
|
|
225
|
+
clearanceStatusRaw() {
|
|
226
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
const result = wasm.fatoora_ValidationResponse_clearance_status_raw(diplomatReceive.buffer, this.ffiValue);
|
|
230
|
+
|
|
179
231
|
try {
|
|
180
232
|
if (!diplomatReceive.resultFlag) {
|
|
181
233
|
const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { BindingError } from "./BindingError.mjs"
|
|
3
3
|
import type { Text } from "./Text.mjs"
|
|
4
4
|
import type { ValidationMessage } from "./ValidationMessage.mjs"
|
|
5
|
+
import type { ValidationStatus } from "./ValidationStatus.mjs"
|
|
5
6
|
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
6
7
|
|
|
7
8
|
|
|
@@ -13,7 +14,15 @@ export class ValidationResults {
|
|
|
13
14
|
constructor();
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The parsed overall status, or null when the response has none.
|
|
19
|
+
*/
|
|
20
|
+
status(): ValidationStatus | null;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The overall status exactly as ZATCA sent it, or null when absent.
|
|
24
|
+
*/
|
|
25
|
+
statusRaw(): Text | null;
|
|
17
26
|
|
|
18
27
|
infoLen(): number;
|
|
19
28
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { BindingError } from "./BindingError.mjs"
|
|
3
3
|
import { Text } from "./Text.mjs"
|
|
4
4
|
import { ValidationMessage } from "./ValidationMessage.mjs"
|
|
5
|
+
import { ValidationStatus } from "./ValidationStatus.mjs"
|
|
5
6
|
import wasm from "./diplomat-wasm.mjs";
|
|
6
7
|
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
7
8
|
|
|
@@ -38,12 +39,37 @@ export class ValidationResults {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
|
|
42
|
+
/**
|
|
43
|
+
* The parsed overall status, or null when the response has none.
|
|
44
|
+
*/
|
|
41
45
|
status() {
|
|
42
46
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
43
47
|
|
|
44
48
|
|
|
45
49
|
const result = wasm.fatoora_ValidationResults_status(diplomatReceive.buffer, this.ffiValue);
|
|
46
50
|
|
|
51
|
+
try {
|
|
52
|
+
if (!diplomatReceive.resultFlag) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return new ValidationStatus(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
finally {
|
|
59
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
60
|
+
diplomatReceive.free();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The overall status exactly as ZATCA sent it, or null when absent.
|
|
66
|
+
*/
|
|
67
|
+
statusRaw() {
|
|
68
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
const result = wasm.fatoora_ValidationResults_status_raw(diplomatReceive.buffer, this.ffiValue);
|
|
72
|
+
|
|
47
73
|
try {
|
|
48
74
|
if (!diplomatReceive.resultFlag) {
|
|
49
75
|
const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Overall `validationResults.status`, or the `status` of one validation message.
|
|
8
|
+
*
|
|
9
|
+
* `Unknown` marks a value this binding version does not recognize; read the
|
|
10
|
+
* verbatim wire value with the sibling `*_raw` getter.
|
|
11
|
+
*/
|
|
12
|
+
export class ValidationStatus {
|
|
13
|
+
|
|
14
|
+
/** @internal */
|
|
15
|
+
static fromValue(value: ValidationStatus | string): ValidationStatus;
|
|
16
|
+
|
|
17
|
+
get value(): string;
|
|
18
|
+
|
|
19
|
+
/** @internal */
|
|
20
|
+
get ffiValue(): number;
|
|
21
|
+
|
|
22
|
+
static Unknown : ValidationStatus;
|
|
23
|
+
/**
|
|
24
|
+
* Wire value `PASS`.
|
|
25
|
+
*/
|
|
26
|
+
static Pass : ValidationStatus;
|
|
27
|
+
/**
|
|
28
|
+
* Wire value `WARNING`.
|
|
29
|
+
*/
|
|
30
|
+
static Warning : ValidationStatus;
|
|
31
|
+
/**
|
|
32
|
+
* Wire value `ERROR`.
|
|
33
|
+
*/
|
|
34
|
+
static Error : ValidationStatus;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
constructor(value: ValidationStatus | string );
|
|
38
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
* Overall `validationResults.status`, or the `status` of one validation message.
|
|
9
|
+
*
|
|
10
|
+
* `Unknown` marks a value this binding version does not recognize; read the
|
|
11
|
+
* verbatim wire value with the sibling `*_raw` getter.
|
|
12
|
+
*/
|
|
13
|
+
export class ValidationStatus {
|
|
14
|
+
#value = undefined;
|
|
15
|
+
|
|
16
|
+
static #values = new Map([
|
|
17
|
+
["Unknown", 0],
|
|
18
|
+
["Pass", 1],
|
|
19
|
+
["Warning", 2],
|
|
20
|
+
["Error", 3]
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
static getAllEntries() {
|
|
24
|
+
return ValidationStatus.#values.entries();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#internalConstructor(value) {
|
|
28
|
+
if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
|
|
29
|
+
// We pass in two internalConstructor arguments to create *new*
|
|
30
|
+
// instances of this type, otherwise the enums are treated as singletons.
|
|
31
|
+
if (arguments[1] === diplomatRuntime.internalConstructor ) {
|
|
32
|
+
this.#value = arguments[2];
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
return ValidationStatus.#objectValues[arguments[1]];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (value instanceof ValidationStatus) {
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let intVal = ValidationStatus.#values.get(value);
|
|
43
|
+
|
|
44
|
+
// Nullish check, checks for null or undefined
|
|
45
|
+
if (intVal != null) {
|
|
46
|
+
return ValidationStatus.#objectValues[intVal];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
throw TypeError(value + " is not a ValidationStatus and does not correspond to any of its enumerator values.");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** @internal */
|
|
53
|
+
static fromValue(value) {
|
|
54
|
+
return new ValidationStatus(value);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get value(){
|
|
58
|
+
return [...ValidationStatus.#values.keys()][this.#value];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** @internal */
|
|
62
|
+
get ffiValue(){
|
|
63
|
+
return this.#value;
|
|
64
|
+
}
|
|
65
|
+
static #objectValues = [
|
|
66
|
+
new ValidationStatus(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
|
|
67
|
+
new ValidationStatus(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
|
|
68
|
+
new ValidationStatus(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
|
|
69
|
+
new ValidationStatus(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
static Unknown = ValidationStatus.#objectValues[0];
|
|
73
|
+
/**
|
|
74
|
+
* Wire value `PASS`.
|
|
75
|
+
*/
|
|
76
|
+
static Pass = ValidationStatus.#objectValues[1];
|
|
77
|
+
/**
|
|
78
|
+
* Wire value `WARNING`.
|
|
79
|
+
*/
|
|
80
|
+
static Warning = ValidationStatus.#objectValues[2];
|
|
81
|
+
/**
|
|
82
|
+
* Wire value `ERROR`.
|
|
83
|
+
*/
|
|
84
|
+
static Error = ValidationStatus.#objectValues[3];
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
constructor(value) {
|
|
88
|
+
return this.#internalConstructor(...arguments)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import type { BindingError } from "./BindingError.mjs"
|
|
3
3
|
import type { TaxExemption } from "./TaxExemption.mjs"
|
|
4
|
+
import type { VatCategory } from "./VatCategory.mjs"
|
|
4
5
|
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
5
6
|
|
|
6
7
|
|
|
@@ -14,11 +15,11 @@ export class VatBreakdown {
|
|
|
14
15
|
|
|
15
16
|
hasVatRate(): boolean;
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
omitVatRate(): VatBreakdown;
|
|
18
19
|
|
|
19
|
-
static new_(category:
|
|
20
|
+
static new_(category: VatCategory, rate: string, taxableAmount: string, taxAmount: string, exemption: TaxExemption): VatBreakdown;
|
|
20
21
|
|
|
21
|
-
category():
|
|
22
|
+
category(): VatCategory;
|
|
22
23
|
|
|
23
24
|
rate(): string;
|
|
24
25
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import { BindingError } from "./BindingError.mjs"
|
|
3
3
|
import { TaxExemption } from "./TaxExemption.mjs"
|
|
4
|
+
import { VatCategory } from "./VatCategory.mjs"
|
|
4
5
|
import wasm from "./diplomat-wasm.mjs";
|
|
5
6
|
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
6
7
|
|
|
@@ -50,11 +51,11 @@ export class VatBreakdown {
|
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
omitVatRate() {
|
|
54
55
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
55
56
|
|
|
56
57
|
|
|
57
|
-
const result = wasm.
|
|
58
|
+
const result = wasm.fatoora_VatBreakdown_omit_vat_rate(diplomatReceive.buffer, this.ffiValue);
|
|
58
59
|
|
|
59
60
|
try {
|
|
60
61
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -79,7 +80,7 @@ export class VatBreakdown {
|
|
|
79
80
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
80
81
|
|
|
81
82
|
|
|
82
|
-
const result = wasm.fatoora_VatBreakdown_new(diplomatReceive.buffer, category, rateSlice.ptr, taxableAmountSlice.ptr, taxAmountSlice.ptr, exemption instanceof TaxExemption ? exemption.ffiValue : typeError('exemption', 'TaxExemption'));
|
|
83
|
+
const result = wasm.fatoora_VatBreakdown_new(diplomatReceive.buffer, new VatCategory(category).ffiValue, rateSlice.ptr, taxableAmountSlice.ptr, taxAmountSlice.ptr, exemption instanceof TaxExemption ? exemption.ffiValue : typeError('exemption', 'TaxExemption'));
|
|
83
84
|
|
|
84
85
|
try {
|
|
85
86
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -102,7 +103,7 @@ export class VatBreakdown {
|
|
|
102
103
|
const result = wasm.fatoora_VatBreakdown_category(this.ffiValue);
|
|
103
104
|
|
|
104
105
|
try {
|
|
105
|
-
return result;
|
|
106
|
+
return new VatCategory(diplomatRuntime.internalConstructor, result);
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
finally {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* VAT category of a line, breakdown, or document-level adjustment.
|
|
8
|
+
*
|
|
9
|
+
* Discriminants match the `u8` codes used before 0.6.
|
|
10
|
+
*/
|
|
11
|
+
export class VatCategory {
|
|
12
|
+
|
|
13
|
+
/** @internal */
|
|
14
|
+
static fromValue(value: VatCategory | string): VatCategory;
|
|
15
|
+
|
|
16
|
+
get value(): string;
|
|
17
|
+
|
|
18
|
+
/** @internal */
|
|
19
|
+
get ffiValue(): number;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* UNCL5305 `E`.
|
|
23
|
+
*/
|
|
24
|
+
static Exempt : VatCategory;
|
|
25
|
+
/**
|
|
26
|
+
* UNCL5305 `S`.
|
|
27
|
+
*/
|
|
28
|
+
static Standard : VatCategory;
|
|
29
|
+
/**
|
|
30
|
+
* UNCL5305 `Z`.
|
|
31
|
+
*/
|
|
32
|
+
static Zero : VatCategory;
|
|
33
|
+
/**
|
|
34
|
+
* UNCL5305 `O`.
|
|
35
|
+
*/
|
|
36
|
+
static OutOfScope : VatCategory;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
constructor(value: VatCategory | string );
|
|
40
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
* VAT category of a line, breakdown, or document-level adjustment.
|
|
9
|
+
*
|
|
10
|
+
* Discriminants match the `u8` codes used before 0.6.
|
|
11
|
+
*/
|
|
12
|
+
export class VatCategory {
|
|
13
|
+
#value = undefined;
|
|
14
|
+
|
|
15
|
+
static #values = new Map([
|
|
16
|
+
["Exempt", 0],
|
|
17
|
+
["Standard", 1],
|
|
18
|
+
["Zero", 2],
|
|
19
|
+
["OutOfScope", 3]
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
static getAllEntries() {
|
|
23
|
+
return VatCategory.#values.entries();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#internalConstructor(value) {
|
|
27
|
+
if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
|
|
28
|
+
// We pass in two internalConstructor arguments to create *new*
|
|
29
|
+
// instances of this type, otherwise the enums are treated as singletons.
|
|
30
|
+
if (arguments[1] === diplomatRuntime.internalConstructor ) {
|
|
31
|
+
this.#value = arguments[2];
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
return VatCategory.#objectValues[arguments[1]];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (value instanceof VatCategory) {
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let intVal = VatCategory.#values.get(value);
|
|
42
|
+
|
|
43
|
+
// Nullish check, checks for null or undefined
|
|
44
|
+
if (intVal != null) {
|
|
45
|
+
return VatCategory.#objectValues[intVal];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
throw TypeError(value + " is not a VatCategory and does not correspond to any of its enumerator values.");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** @internal */
|
|
52
|
+
static fromValue(value) {
|
|
53
|
+
return new VatCategory(value);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get value(){
|
|
57
|
+
return [...VatCategory.#values.keys()][this.#value];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** @internal */
|
|
61
|
+
get ffiValue(){
|
|
62
|
+
return this.#value;
|
|
63
|
+
}
|
|
64
|
+
static #objectValues = [
|
|
65
|
+
new VatCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
|
|
66
|
+
new VatCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
|
|
67
|
+
new VatCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
|
|
68
|
+
new VatCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* UNCL5305 `E`.
|
|
73
|
+
*/
|
|
74
|
+
static Exempt = VatCategory.#objectValues[0];
|
|
75
|
+
/**
|
|
76
|
+
* UNCL5305 `S`.
|
|
77
|
+
*/
|
|
78
|
+
static Standard = VatCategory.#objectValues[1];
|
|
79
|
+
/**
|
|
80
|
+
* UNCL5305 `Z`.
|
|
81
|
+
*/
|
|
82
|
+
static Zero = VatCategory.#objectValues[2];
|
|
83
|
+
/**
|
|
84
|
+
* UNCL5305 `O`.
|
|
85
|
+
*/
|
|
86
|
+
static OutOfScope = VatCategory.#objectValues[3];
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
constructor(value) {
|
|
90
|
+
return this.#internalConstructor(...arguments)
|
|
91
|
+
}
|
|
92
|
+
}
|
package/generated/Xml.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import type { BindingError } from "./BindingError.mjs"
|
|
3
|
-
import type {
|
|
3
|
+
import type { ZatcaValidationReport } from "./ZatcaValidationReport.mjs"
|
|
4
4
|
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
5
5
|
|
|
6
6
|
|
|
@@ -13,12 +13,19 @@ export class Xml {
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* Run the local ZATCA validation profile and return its owned report.
|
|
17
|
+
*
|
|
18
|
+
* Inspect `is_valid` before acceptance. Options default when absent;
|
|
19
|
+
* `options_json` is limited to 4 KiB. Validation needs no configuration:
|
|
20
|
+
* it mirrors the stateless core `Validator::validate_zatca`.
|
|
18
21
|
*/
|
|
19
|
-
static validateZatca(
|
|
22
|
+
static validateZatca(xml: string, optionsJson: string | null): ZatcaValidationReport;
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Check the XML against the UBL schema and business rules, mirroring core
|
|
26
|
+
* `Validator::validate_xml`. Returns true or a validation error.
|
|
27
|
+
*/
|
|
28
|
+
static validate(xml: string): boolean;
|
|
22
29
|
|
|
23
30
|
static hash(xml: string): string;
|
|
24
31
|
}
|
package/generated/Xml.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import { BindingError } from "./BindingError.mjs"
|
|
3
|
-
import {
|
|
3
|
+
import { ZatcaValidationReport } from "./ZatcaValidationReport.mjs"
|
|
4
4
|
import wasm from "./diplomat-wasm.mjs";
|
|
5
5
|
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
6
6
|
|
|
@@ -38,26 +38,27 @@ export class Xml {
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* Run the local ZATCA validation profile and return its owned report.
|
|
42
|
+
*
|
|
43
|
+
* Inspect `is_valid` before acceptance. Options default when absent;
|
|
44
|
+
* `options_json` is limited to 4 KiB. Validation needs no configuration:
|
|
45
|
+
* it mirrors the stateless core `Validator::validate_zatca`.
|
|
43
46
|
*/
|
|
44
|
-
static validateZatca(
|
|
47
|
+
static validateZatca(xml, optionsJson) {
|
|
45
48
|
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
46
49
|
|
|
47
50
|
const xmlSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, xml)));
|
|
48
51
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
49
52
|
|
|
50
|
-
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
51
|
-
|
|
52
53
|
|
|
53
|
-
const result = wasm.fatoora_Xml_validate_zatca(diplomatReceive.buffer,
|
|
54
|
+
const result = wasm.fatoora_Xml_validate_zatca(diplomatReceive.buffer, xmlSlice.ptr, diplomatRuntime.optionToBufferForCalling(wasm, optionsJson, 8, 4, functionCleanupArena, (arrayBuffer, offset, jsValue) => [functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, jsValue)).writePtrLenToArrayBuffer(arrayBuffer, offset + 0)]));
|
|
54
55
|
|
|
55
56
|
try {
|
|
56
57
|
if (!diplomatReceive.resultFlag) {
|
|
57
58
|
const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
58
59
|
throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
|
|
59
60
|
}
|
|
60
|
-
return
|
|
61
|
+
return new ZatcaValidationReport(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
finally {
|
|
@@ -65,18 +66,21 @@ export class Xml {
|
|
|
65
66
|
functionCleanupArena.free();
|
|
66
67
|
|
|
67
68
|
diplomatReceive.free();
|
|
68
|
-
write.free();
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Check the XML against the UBL schema and business rules, mirroring core
|
|
74
|
+
* `Validator::validate_xml`. Returns true or a validation error.
|
|
75
|
+
*/
|
|
76
|
+
static validate(xml) {
|
|
73
77
|
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
74
78
|
|
|
75
79
|
const xmlSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, xml)));
|
|
76
80
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 1, true);
|
|
77
81
|
|
|
78
82
|
|
|
79
|
-
const result = wasm.fatoora_Xml_validate(diplomatReceive.buffer,
|
|
83
|
+
const result = wasm.fatoora_Xml_validate(diplomatReceive.buffer, xmlSlice.ptr);
|
|
80
84
|
|
|
81
85
|
try {
|
|
82
86
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import type { BindingError } from "./BindingError.mjs"
|
|
3
|
+
import type { ClearanceMode } from "./ClearanceMode.mjs"
|
|
4
|
+
import type { ComplianceCsid } from "./ComplianceCsid.mjs"
|
|
3
5
|
import type { ComplianceRequest } from "./ComplianceRequest.mjs"
|
|
4
6
|
import type { Config } from "./Config.mjs"
|
|
5
|
-
import type { CsidCompliance } from "./CsidCompliance.mjs"
|
|
6
|
-
import type { CsidProduction } from "./CsidProduction.mjs"
|
|
7
7
|
import type { Csr } from "./Csr.mjs"
|
|
8
8
|
import type { InvoiceRequest } from "./InvoiceRequest.mjs"
|
|
9
|
+
import type { ProductionCsid } from "./ProductionCsid.mjs"
|
|
9
10
|
import type { ProductionRequest } from "./ProductionRequest.mjs"
|
|
10
11
|
import type { SignedInvoice } from "./SignedInvoice.mjs"
|
|
11
12
|
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
@@ -19,17 +20,17 @@ export class ZatcaClient {
|
|
|
19
20
|
constructor();
|
|
20
21
|
|
|
21
22
|
|
|
22
|
-
static
|
|
23
|
+
static new_(config: Config): ZatcaClient;
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
prepareRequestComplianceCsid(csr: Csr, otp: string): ComplianceRequest;
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
prepareRequestProductionCsid(credentials: ComplianceCsid): ProductionRequest;
|
|
27
28
|
|
|
28
|
-
prepareRenewCsid(credentials:
|
|
29
|
+
prepareRenewCsid(credentials: ProductionCsid, csr: Csr, otp: string, acceptLanguage: string | null): ProductionRequest;
|
|
29
30
|
|
|
30
|
-
prepareCheckInvoiceCompliance(invoice: SignedInvoice, credentials:
|
|
31
|
+
prepareCheckInvoiceCompliance(invoice: SignedInvoice, credentials: ComplianceCsid): InvoiceRequest;
|
|
31
32
|
|
|
32
|
-
prepareReportSimplifiedInvoice(invoice: SignedInvoice, credentials:
|
|
33
|
+
prepareReportSimplifiedInvoice(invoice: SignedInvoice, credentials: ProductionCsid, clearanceMode: ClearanceMode, acceptLanguage: string | null): InvoiceRequest;
|
|
33
34
|
|
|
34
|
-
prepareClearStandardInvoice(invoice: SignedInvoice, credentials:
|
|
35
|
+
prepareClearStandardInvoice(invoice: SignedInvoice, credentials: ProductionCsid, clearanceMode: ClearanceMode, acceptLanguage: string | null): InvoiceRequest;
|
|
35
36
|
}
|