fatoority 0.5.0 → 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 +11 -5
- package/patch.mjs +121 -0
- package/raw.d.mts +731 -0
- package/raw.mjs +4 -0
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
* `clearanceStatus` of a clearance response.
|
|
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 ClearanceStatus {
|
|
14
|
+
#value = undefined;
|
|
15
|
+
|
|
16
|
+
static #values = new Map([
|
|
17
|
+
["Unknown", 0],
|
|
18
|
+
["Cleared", 1],
|
|
19
|
+
["NotCleared", 2]
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
static getAllEntries() {
|
|
23
|
+
return ClearanceStatus.#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 ClearanceStatus.#objectValues[arguments[1]];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (value instanceof ClearanceStatus) {
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let intVal = ClearanceStatus.#values.get(value);
|
|
42
|
+
|
|
43
|
+
// Nullish check, checks for null or undefined
|
|
44
|
+
if (intVal != null) {
|
|
45
|
+
return ClearanceStatus.#objectValues[intVal];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
throw TypeError(value + " is not a ClearanceStatus and does not correspond to any of its enumerator values.");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** @internal */
|
|
52
|
+
static fromValue(value) {
|
|
53
|
+
return new ClearanceStatus(value);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get value(){
|
|
57
|
+
return [...ClearanceStatus.#values.keys()][this.#value];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** @internal */
|
|
61
|
+
get ffiValue(){
|
|
62
|
+
return this.#value;
|
|
63
|
+
}
|
|
64
|
+
static #objectValues = [
|
|
65
|
+
new ClearanceStatus(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
|
|
66
|
+
new ClearanceStatus(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
|
|
67
|
+
new ClearanceStatus(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
static Unknown = ClearanceStatus.#objectValues[0];
|
|
71
|
+
/**
|
|
72
|
+
* Wire value `CLEARED`.
|
|
73
|
+
*/
|
|
74
|
+
static Cleared = ClearanceStatus.#objectValues[1];
|
|
75
|
+
/**
|
|
76
|
+
* Wire value `NOT_CLEARED`.
|
|
77
|
+
*/
|
|
78
|
+
static NotCleared = ClearanceStatus.#objectValues[2];
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
constructor(value) {
|
|
82
|
+
return this.#internalConstructor(...arguments)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import type { BindingError } from "./BindingError.mjs"
|
|
3
|
+
import type { Environment } from "./Environment.mjs"
|
|
3
4
|
import type { Text } from "./Text.mjs"
|
|
4
5
|
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
export class
|
|
9
|
+
export class ComplianceCsid {
|
|
9
10
|
/** @internal */
|
|
10
11
|
get ffiValue(): pointer;
|
|
11
12
|
/** @internal */
|
|
12
13
|
constructor();
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
static
|
|
16
|
+
static new_(environment: Environment, requestId: string | null, token: string, secret: string): ComplianceCsid;
|
|
16
17
|
|
|
17
|
-
env():
|
|
18
|
+
env(): Environment;
|
|
18
19
|
|
|
19
20
|
requestId(): Text | null;
|
|
20
21
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import { BindingError } from "./BindingError.mjs"
|
|
3
|
+
import { Environment } from "./Environment.mjs"
|
|
3
4
|
import { Text } from "./Text.mjs"
|
|
4
5
|
import wasm from "./diplomat-wasm.mjs";
|
|
5
6
|
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
-
wasm.
|
|
8
|
+
const ComplianceCsid_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
9
|
+
wasm.fatoora_ComplianceCsid_destroy(ptr);
|
|
9
10
|
});
|
|
10
11
|
|
|
11
|
-
export class
|
|
12
|
+
export class ComplianceCsid {
|
|
12
13
|
// Internal ptr reference:
|
|
13
14
|
#ptr = null;
|
|
14
15
|
|
|
@@ -18,7 +19,7 @@ export class CsidCompliance {
|
|
|
18
19
|
|
|
19
20
|
#internalConstructor(symbol, ptr, selfEdge) {
|
|
20
21
|
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
21
|
-
console.error("
|
|
22
|
+
console.error("ComplianceCsid is an Opaque type. You cannot call its constructor.");
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
25
|
this.#ptr = ptr;
|
|
@@ -26,7 +27,7 @@ export class CsidCompliance {
|
|
|
26
27
|
|
|
27
28
|
// Are we being borrowed? If not, we can register.
|
|
28
29
|
if (this.#selfEdge.length === 0) {
|
|
29
|
-
|
|
30
|
+
ComplianceCsid_box_destroy_registry.register(this, this.#ptr);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
return this;
|
|
@@ -37,7 +38,7 @@ export class CsidCompliance {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
|
|
40
|
-
static
|
|
41
|
+
static new_(environment, requestId, token, secret) {
|
|
41
42
|
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
42
43
|
|
|
43
44
|
const tokenSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, token)));
|
|
@@ -45,14 +46,14 @@ export class CsidCompliance {
|
|
|
45
46
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
46
47
|
|
|
47
48
|
|
|
48
|
-
const result = wasm.
|
|
49
|
+
const result = wasm.fatoora_ComplianceCsid_new(diplomatReceive.buffer, new Environment(environment).ffiValue, diplomatRuntime.optionToBufferForCalling(wasm, requestId, 8, 4, functionCleanupArena, (arrayBuffer, offset, jsValue) => [functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, jsValue)).writePtrLenToArrayBuffer(arrayBuffer, offset + 0)]), tokenSlice.ptr, secretSlice.ptr);
|
|
49
50
|
|
|
50
51
|
try {
|
|
51
52
|
if (!diplomatReceive.resultFlag) {
|
|
52
53
|
const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
53
54
|
throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
|
|
54
55
|
}
|
|
55
|
-
return new
|
|
56
|
+
return new ComplianceCsid(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
finally {
|
|
@@ -64,15 +65,22 @@ export class CsidCompliance {
|
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
env() {
|
|
68
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
69
|
+
|
|
67
70
|
|
|
68
|
-
const result = wasm.
|
|
71
|
+
const result = wasm.fatoora_ComplianceCsid_env(diplomatReceive.buffer, this.ffiValue);
|
|
69
72
|
|
|
70
73
|
try {
|
|
71
|
-
|
|
74
|
+
if (!diplomatReceive.resultFlag) {
|
|
75
|
+
const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
76
|
+
throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
|
|
77
|
+
}
|
|
78
|
+
return new Environment(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
finally {
|
|
75
82
|
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
83
|
+
diplomatReceive.free();
|
|
76
84
|
}
|
|
77
85
|
}
|
|
78
86
|
|
|
@@ -80,7 +88,7 @@ export class CsidCompliance {
|
|
|
80
88
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
81
89
|
|
|
82
90
|
|
|
83
|
-
const result = wasm.
|
|
91
|
+
const result = wasm.fatoora_ComplianceCsid_request_id(diplomatReceive.buffer, this.ffiValue);
|
|
84
92
|
|
|
85
93
|
try {
|
|
86
94
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -102,7 +110,7 @@ export class CsidCompliance {
|
|
|
102
110
|
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
103
111
|
|
|
104
112
|
|
|
105
|
-
const result = wasm.
|
|
113
|
+
const result = wasm.fatoora_ComplianceCsid_binary_security_token(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
106
114
|
|
|
107
115
|
try {
|
|
108
116
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -125,7 +133,7 @@ export class CsidCompliance {
|
|
|
125
133
|
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
126
134
|
|
|
127
135
|
|
|
128
|
-
const result = wasm.
|
|
136
|
+
const result = wasm.fatoora_ComplianceCsid_secret(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
129
137
|
|
|
130
138
|
try {
|
|
131
139
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import type { BindingError } from "./BindingError.mjs"
|
|
3
3
|
import type { Bytes } from "./Bytes.mjs"
|
|
4
|
-
import type {
|
|
4
|
+
import type { ComplianceCsid } from "./ComplianceCsid.mjs"
|
|
5
5
|
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
6
6
|
|
|
7
7
|
|
|
@@ -24,5 +24,5 @@ export class ComplianceRequest {
|
|
|
24
24
|
|
|
25
25
|
body(): Bytes;
|
|
26
26
|
|
|
27
|
-
decode(status: number, body: Array<number>):
|
|
27
|
+
decode(status: number, body: Array<number>): ComplianceCsid;
|
|
28
28
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import { BindingError } from "./BindingError.mjs"
|
|
3
3
|
import { Bytes } from "./Bytes.mjs"
|
|
4
|
-
import {
|
|
4
|
+
import { ComplianceCsid } from "./ComplianceCsid.mjs"
|
|
5
5
|
import wasm from "./diplomat-wasm.mjs";
|
|
6
6
|
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
7
7
|
|
|
@@ -144,7 +144,7 @@ export class ComplianceRequest {
|
|
|
144
144
|
const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
145
145
|
throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
|
|
146
146
|
}
|
|
147
|
-
return new
|
|
147
|
+
return new ComplianceCsid(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
finally {
|
package/generated/Config.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import type { BindingError } from "./BindingError.mjs"
|
|
3
|
+
import type { Environment } from "./Environment.mjs"
|
|
3
4
|
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
4
5
|
|
|
5
6
|
|
|
@@ -11,7 +12,7 @@ export class Config {
|
|
|
11
12
|
constructor();
|
|
12
13
|
|
|
13
14
|
|
|
14
|
-
static new_(env:
|
|
15
|
+
static new_(env: Environment): Config;
|
|
15
16
|
|
|
16
|
-
env():
|
|
17
|
+
env(): Environment;
|
|
17
18
|
}
|
package/generated/Config.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import { BindingError } from "./BindingError.mjs"
|
|
3
|
+
import { Environment } from "./Environment.mjs"
|
|
3
4
|
import wasm from "./diplomat-wasm.mjs";
|
|
4
5
|
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
5
6
|
|
|
@@ -40,7 +41,7 @@ export class Config {
|
|
|
40
41
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
41
42
|
|
|
42
43
|
|
|
43
|
-
const result = wasm.fatoora_Config_new(diplomatReceive.buffer, env);
|
|
44
|
+
const result = wasm.fatoora_Config_new(diplomatReceive.buffer, new Environment(env).ffiValue);
|
|
44
45
|
|
|
45
46
|
try {
|
|
46
47
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -57,15 +58,22 @@ export class Config {
|
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
env() {
|
|
61
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
62
|
+
|
|
60
63
|
|
|
61
|
-
const result = wasm.fatoora_Config_env(this.ffiValue);
|
|
64
|
+
const result = wasm.fatoora_Config_env(diplomatReceive.buffer, this.ffiValue);
|
|
62
65
|
|
|
63
66
|
try {
|
|
64
|
-
|
|
67
|
+
if (!diplomatReceive.resultFlag) {
|
|
68
|
+
const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
69
|
+
throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
|
|
70
|
+
}
|
|
71
|
+
return new Environment(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
65
72
|
}
|
|
66
73
|
|
|
67
74
|
finally {
|
|
68
75
|
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
76
|
+
diplomatReceive.free();
|
|
69
77
|
}
|
|
70
78
|
}
|
|
71
79
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import type { BindingError } from "./BindingError.mjs"
|
|
3
3
|
import type { Csr } from "./Csr.mjs"
|
|
4
|
+
import type { Environment } from "./Environment.mjs"
|
|
4
5
|
import type { SigningKey } from "./SigningKey.mjs"
|
|
5
6
|
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
6
7
|
|
|
@@ -15,7 +16,10 @@ export class CsrProperties {
|
|
|
15
16
|
|
|
16
17
|
static new_(commonName: string, serialNumber: string, organizationIdentifier: string, organizationUnitName: string, organizationName: string, countryName: string, invoiceType: string, locationAddress: string, industryBusinessCategory: string): CsrProperties;
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Parse `csr.*` properties text, mirroring core `CsrProperties::from_str`.
|
|
21
|
+
*/
|
|
22
|
+
static fromStr(properties: string): CsrProperties;
|
|
19
23
|
|
|
20
|
-
build(key: SigningKey, env:
|
|
24
|
+
build(key: SigningKey, env: Environment): Csr;
|
|
21
25
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import { BindingError } from "./BindingError.mjs"
|
|
3
3
|
import { Csr } from "./Csr.mjs"
|
|
4
|
+
import { Environment } from "./Environment.mjs"
|
|
4
5
|
import { SigningKey } from "./SigningKey.mjs"
|
|
5
6
|
import wasm from "./diplomat-wasm.mjs";
|
|
6
7
|
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
@@ -71,14 +72,17 @@ export class CsrProperties {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Parse `csr.*` properties text, mirroring core `CsrProperties::from_str`.
|
|
77
|
+
*/
|
|
78
|
+
static fromStr(properties) {
|
|
75
79
|
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
76
80
|
|
|
77
81
|
const propertiesSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, properties)));
|
|
78
82
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
79
83
|
|
|
80
84
|
|
|
81
|
-
const result = wasm.
|
|
85
|
+
const result = wasm.fatoora_CsrProperties_from_str(diplomatReceive.buffer, propertiesSlice.ptr);
|
|
82
86
|
|
|
83
87
|
try {
|
|
84
88
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -100,7 +104,7 @@ export class CsrProperties {
|
|
|
100
104
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
101
105
|
|
|
102
106
|
|
|
103
|
-
const result = wasm.fatoora_CsrProperties_build(diplomatReceive.buffer, this.ffiValue, key instanceof SigningKey ? key.ffiValue : typeError('key', 'SigningKey'), env);
|
|
107
|
+
const result = wasm.fatoora_CsrProperties_build(diplomatReceive.buffer, this.ffiValue, key instanceof SigningKey ? key.ffiValue : typeError('key', 'SigningKey'), new Environment(env).ffiValue);
|
|
104
108
|
|
|
105
109
|
try {
|
|
106
110
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ZATCA environment selecting the API base URL and certificate profile.
|
|
8
|
+
*
|
|
9
|
+
* Discriminants match the `u8` codes used before 0.6. .NET names it
|
|
10
|
+
* `ZatcaEnvironment` so it cannot be confused with `System.Environment`.
|
|
11
|
+
*/
|
|
12
|
+
export class Environment {
|
|
13
|
+
|
|
14
|
+
/** @internal */
|
|
15
|
+
static fromValue(value: Environment | string): Environment;
|
|
16
|
+
|
|
17
|
+
get value(): string;
|
|
18
|
+
|
|
19
|
+
/** @internal */
|
|
20
|
+
get ffiValue(): number;
|
|
21
|
+
|
|
22
|
+
static NonProduction : Environment;
|
|
23
|
+
static Simulation : Environment;
|
|
24
|
+
static Production : Environment;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
constructor(value: Environment | string );
|
|
28
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
* ZATCA environment selecting the API base URL and certificate profile.
|
|
9
|
+
*
|
|
10
|
+
* Discriminants match the `u8` codes used before 0.6. .NET names it
|
|
11
|
+
* `ZatcaEnvironment` so it cannot be confused with `System.Environment`.
|
|
12
|
+
*/
|
|
13
|
+
export class Environment {
|
|
14
|
+
#value = undefined;
|
|
15
|
+
|
|
16
|
+
static #values = new Map([
|
|
17
|
+
["NonProduction", 0],
|
|
18
|
+
["Simulation", 1],
|
|
19
|
+
["Production", 2]
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
static getAllEntries() {
|
|
23
|
+
return Environment.#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 Environment.#objectValues[arguments[1]];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (value instanceof Environment) {
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let intVal = Environment.#values.get(value);
|
|
42
|
+
|
|
43
|
+
// Nullish check, checks for null or undefined
|
|
44
|
+
if (intVal != null) {
|
|
45
|
+
return Environment.#objectValues[intVal];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
throw TypeError(value + " is not a Environment and does not correspond to any of its enumerator values.");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** @internal */
|
|
52
|
+
static fromValue(value) {
|
|
53
|
+
return new Environment(value);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get value(){
|
|
57
|
+
return [...Environment.#values.keys()][this.#value];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** @internal */
|
|
61
|
+
get ffiValue(){
|
|
62
|
+
return this.#value;
|
|
63
|
+
}
|
|
64
|
+
static #objectValues = [
|
|
65
|
+
new Environment(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
|
|
66
|
+
new Environment(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
|
|
67
|
+
new Environment(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
static NonProduction = Environment.#objectValues[0];
|
|
71
|
+
static Simulation = Environment.#objectValues[1];
|
|
72
|
+
static Production = Environment.#objectValues[2];
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
constructor(value) {
|
|
76
|
+
return this.#internalConstructor(...arguments)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -103,13 +103,13 @@ export class FinalizedInvoice {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
hash() {
|
|
107
107
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
108
108
|
|
|
109
109
|
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
110
110
|
|
|
111
111
|
|
|
112
|
-
const result = wasm.
|
|
112
|
+
const result = wasm.fatoora_FinalizedInvoice_hash(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
113
113
|
|
|
114
114
|
try {
|
|
115
115
|
if (!diplomatReceive.resultFlag) {
|
|
@@ -5,10 +5,13 @@ import type { AllowanceCharge } from "./AllowanceCharge.mjs"
|
|
|
5
5
|
import type { BindingError } from "./BindingError.mjs"
|
|
6
6
|
import type { FinalizedInvoice } from "./FinalizedInvoice.mjs"
|
|
7
7
|
import type { InvoiceLineItem } from "./InvoiceLineItem.mjs"
|
|
8
|
+
import type { InvoiceSubType } from "./InvoiceSubType.mjs"
|
|
9
|
+
import type { InvoiceTypeKind } from "./InvoiceTypeKind.mjs"
|
|
8
10
|
import type { OriginalInvoiceRef } from "./OriginalInvoiceRef.mjs"
|
|
9
11
|
import type { PaymentMeans } from "./PaymentMeans.mjs"
|
|
10
12
|
import type { TaxExemption } from "./TaxExemption.mjs"
|
|
11
13
|
import type { VatBreakdown } from "./VatBreakdown.mjs"
|
|
14
|
+
import type { VatCategory } from "./VatCategory.mjs"
|
|
12
15
|
import type { pointer, codepoint } from "./diplomat-runtime.mjs";
|
|
13
16
|
|
|
14
17
|
|
|
@@ -30,16 +33,22 @@ export class InvoiceBuilder {
|
|
|
30
33
|
|
|
31
34
|
addNote(language: string | null, value: string): void;
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Append a document-level allowance (discount), mirroring core `InvoiceBuilder::allowance`.
|
|
38
|
+
*/
|
|
39
|
+
addAllowance(value: Adjustment, category: VatCategory, rate: string, exemption: TaxExemption): void;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Append a document-level charge, mirroring core `InvoiceBuilder::charge`.
|
|
43
|
+
*/
|
|
44
|
+
addCharge(value: Adjustment, category: VatCategory, rate: string, exemption: TaxExemption): void;
|
|
34
45
|
|
|
35
46
|
setBuyerWithoutAddress(name: string, vatId: string | null, otherId: string | null, scheme: string | null): void;
|
|
36
47
|
|
|
37
48
|
/**
|
|
38
49
|
* Construct a credit or debit note with a complete billing reference.
|
|
39
50
|
*/
|
|
40
|
-
static newWithReference(kind:
|
|
41
|
-
|
|
42
|
-
setNoteWithoutLanguage(value: string): void;
|
|
51
|
+
static newWithReference(kind: InvoiceTypeKind, subtype: InvoiceSubType, reference: OriginalInvoiceRef, reason: string): InvoiceBuilder;
|
|
43
52
|
|
|
44
53
|
setPaymentInstruction(instruction: string): void;
|
|
45
54
|
|
|
@@ -51,13 +60,13 @@ export class InvoiceBuilder {
|
|
|
51
60
|
|
|
52
61
|
setTaxCurrency(currency: string, amount: string): void;
|
|
53
62
|
|
|
54
|
-
|
|
63
|
+
addTaxExemption(category: VatCategory, rate: string, exemption: TaxExemption): void;
|
|
55
64
|
|
|
56
65
|
addAdjustment(adjustment: AllowanceCharge): void;
|
|
57
66
|
|
|
58
67
|
addItem(item: InvoiceLineItem): void;
|
|
59
68
|
|
|
60
|
-
static new_(kind:
|
|
69
|
+
static new_(kind: InvoiceTypeKind, subtype: InvoiceSubType, originalId: string | null, originalUuid: string | null, originalDate: string | null, reason: string | null): InvoiceBuilder;
|
|
61
70
|
|
|
62
71
|
addBillingReference(value: OriginalInvoiceRef): void;
|
|
63
72
|
|
|
@@ -75,29 +84,17 @@ export class InvoiceBuilder {
|
|
|
75
84
|
|
|
76
85
|
setPreviousInvoiceHash(value: string): void;
|
|
77
86
|
|
|
78
|
-
setPaymentMeansCode(value: string): void;
|
|
79
|
-
|
|
80
|
-
allowanceReason(value: string): void;
|
|
81
|
-
|
|
82
|
-
invoiceLevelCharge(value: string): void;
|
|
83
|
-
|
|
84
|
-
invoiceLevelDiscount(value: string): void;
|
|
85
|
-
|
|
86
87
|
setInvoiceCounter(value: bigint): void;
|
|
87
88
|
|
|
88
|
-
setVatCategory(value:
|
|
89
|
-
|
|
90
|
-
flags(value: number): void;
|
|
91
|
-
|
|
92
|
-
setNote(language: string, value: string): void;
|
|
89
|
+
setVatCategory(value: VatCategory): void;
|
|
93
90
|
|
|
94
|
-
|
|
91
|
+
setFlags(value: number): void;
|
|
95
92
|
|
|
96
93
|
setSeller(name: string, address: Address, vatId: string, otherId: string | null, scheme: string | null): void;
|
|
97
94
|
|
|
98
95
|
setBuyer(name: string, address: Address, vatId: string | null, otherId: string | null, scheme: string | null): void;
|
|
99
96
|
|
|
100
|
-
addLineItem(description: string, quantity: string, unitCode: string, unitPrice: string, vatRate: string, category:
|
|
97
|
+
addLineItem(description: string, quantity: string, unitCode: string, unitPrice: string, vatRate: string, category: VatCategory): void;
|
|
101
98
|
|
|
102
99
|
build(): FinalizedInvoice;
|
|
103
100
|
}
|