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.
Files changed (95) hide show
  1. package/README.md +9 -9
  2. package/errors.d.mts +67 -0
  3. package/errors.mjs +94 -0
  4. package/fatoora_ffi.wasm +0 -0
  5. package/generated/Adjustment.d.mts +9 -3
  6. package/generated/Adjustment.mjs +12 -6
  7. package/generated/AdjustmentKind.d.mts +24 -0
  8. package/generated/AdjustmentKind.mjs +72 -0
  9. package/generated/AllowanceCharge.d.mts +6 -4
  10. package/generated/AllowanceCharge.mjs +10 -8
  11. package/generated/ClearanceMode.d.mts +30 -0
  12. package/generated/ClearanceMode.mjs +78 -0
  13. package/generated/ClearanceStatus.d.mts +34 -0
  14. package/generated/ClearanceStatus.mjs +84 -0
  15. package/generated/{CsidCompliance.d.mts → ComplianceCsid.d.mts} +4 -3
  16. package/generated/{CsidCompliance.mjs → ComplianceCsid.mjs} +21 -13
  17. package/generated/ComplianceRequest.d.mts +2 -2
  18. package/generated/ComplianceRequest.mjs +2 -2
  19. package/generated/Config.d.mts +3 -2
  20. package/generated/Config.mjs +11 -3
  21. package/generated/CsrProperties.d.mts +6 -2
  22. package/generated/CsrProperties.mjs +7 -3
  23. package/generated/Environment.d.mts +28 -0
  24. package/generated/Environment.mjs +78 -0
  25. package/generated/FinalizedInvoice.d.mts +1 -1
  26. package/generated/FinalizedInvoice.mjs +2 -2
  27. package/generated/InvoiceBuilder.d.mts +18 -21
  28. package/generated/InvoiceBuilder.mjs +31 -168
  29. package/generated/InvoiceData.d.mts +7 -4
  30. package/generated/InvoiceData.mjs +8 -5
  31. package/generated/InvoiceFlag.d.mts +36 -0
  32. package/generated/InvoiceFlag.mjs +105 -0
  33. package/generated/InvoiceLineItem.d.mts +5 -3
  34. package/generated/InvoiceLineItem.mjs +8 -6
  35. package/generated/{Signer.d.mts → InvoiceSigner.d.mts} +3 -3
  36. package/generated/{Signer.mjs → InvoiceSigner.mjs} +13 -13
  37. package/generated/InvoiceSubType.d.mts +26 -0
  38. package/generated/InvoiceSubType.mjs +74 -0
  39. package/generated/InvoiceTypeKind.d.mts +40 -0
  40. package/generated/InvoiceTypeKind.mjs +92 -0
  41. package/generated/LineItemBuilder.d.mts +2 -1
  42. package/generated/LineItemBuilder.mjs +2 -1
  43. package/generated/MessageType.d.mts +38 -0
  44. package/generated/MessageType.mjs +90 -0
  45. package/generated/{CsidProduction.d.mts → ProductionCsid.d.mts} +4 -3
  46. package/generated/{CsidProduction.mjs → ProductionCsid.mjs} +21 -13
  47. package/generated/ProductionRequest.d.mts +2 -2
  48. package/generated/ProductionRequest.mjs +2 -2
  49. package/generated/ReportingStatus.d.mts +34 -0
  50. package/generated/ReportingStatus.mjs +84 -0
  51. package/generated/Severity.d.mts +30 -0
  52. package/generated/Severity.mjs +78 -0
  53. package/generated/SignedInvoice.d.mts +1 -1
  54. package/generated/SignedInvoice.mjs +2 -2
  55. package/generated/ValidationLayer.d.mts +49 -0
  56. package/generated/ValidationLayer.mjs +107 -0
  57. package/generated/ValidationLocationKind.d.mts +37 -0
  58. package/generated/ValidationLocationKind.mjs +89 -0
  59. package/generated/ValidationMessage.d.mts +20 -2
  60. package/generated/ValidationMessage.mjs +52 -0
  61. package/generated/ValidationResponse.d.mts +21 -3
  62. package/generated/ValidationResponse.mjs +52 -0
  63. package/generated/ValidationResults.d.mts +10 -1
  64. package/generated/ValidationResults.mjs +26 -0
  65. package/generated/ValidationStatus.d.mts +38 -0
  66. package/generated/ValidationStatus.mjs +90 -0
  67. package/generated/VatBreakdown.d.mts +4 -3
  68. package/generated/VatBreakdown.mjs +5 -4
  69. package/generated/VatCategory.d.mts +40 -0
  70. package/generated/VatCategory.mjs +92 -0
  71. package/generated/Xml.d.mts +12 -5
  72. package/generated/Xml.mjs +15 -11
  73. package/generated/ZatcaClient.d.mts +10 -9
  74. package/generated/ZatcaClient.mjs +15 -14
  75. package/generated/ZatcaFinding.d.mts +59 -0
  76. package/generated/ZatcaFinding.mjs +239 -0
  77. package/generated/ZatcaRuleSource.d.mts +26 -0
  78. package/generated/ZatcaRuleSource.mjs +97 -0
  79. package/generated/ZatcaStage.d.mts +49 -0
  80. package/generated/ZatcaStage.mjs +107 -0
  81. package/generated/ZatcaStageReport.d.mts +41 -0
  82. package/generated/ZatcaStageReport.mjs +168 -0
  83. package/generated/ZatcaStageStatus.d.mts +45 -0
  84. package/generated/ZatcaStageStatus.mjs +101 -0
  85. package/generated/ZatcaValidationReport.d.mts +63 -0
  86. package/generated/ZatcaValidationReport.mjs +228 -0
  87. package/generated/index.d.mts +45 -5
  88. package/generated/index.mjs +45 -5
  89. package/index.d.mts +131 -15
  90. package/index.mjs +111 -33
  91. package/members.mjs +67 -0
  92. package/package.json +11 -5
  93. package/patch.mjs +121 -0
  94. package/raw.d.mts +731 -0
  95. 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 CsidCompliance {
9
+ export class ComplianceCsid {
9
10
  /** @internal */
10
11
  get ffiValue(): pointer;
11
12
  /** @internal */
12
13
  constructor();
13
14
 
14
15
 
15
- static create(environment: number, requestId: string | null, token: string, secret: string): CsidCompliance;
16
+ static new_(environment: Environment, requestId: string | null, token: string, secret: string): ComplianceCsid;
16
17
 
17
- env(): number;
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 CsidCompliance_box_destroy_registry = new FinalizationRegistry((ptr) => {
8
- wasm.fatoora_CsidCompliance_destroy(ptr);
8
+ const ComplianceCsid_box_destroy_registry = new FinalizationRegistry((ptr) => {
9
+ wasm.fatoora_ComplianceCsid_destroy(ptr);
9
10
  });
10
11
 
11
- export class CsidCompliance {
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("CsidCompliance is an Opaque type. You cannot call its constructor.");
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
- CsidCompliance_box_destroy_registry.register(this, this.#ptr);
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 create(environment, requestId, token, secret) {
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.fatoora_CsidCompliance_create(diplomatReceive.buffer, environment, 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
+ 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 CsidCompliance(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
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.fatoora_CsidCompliance_env(this.ffiValue);
71
+ const result = wasm.fatoora_ComplianceCsid_env(diplomatReceive.buffer, this.ffiValue);
69
72
 
70
73
  try {
71
- return result;
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.fatoora_CsidCompliance_request_id(diplomatReceive.buffer, this.ffiValue);
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.fatoora_CsidCompliance_binary_security_token(diplomatReceive.buffer, this.ffiValue, write.buffer);
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.fatoora_CsidCompliance_secret(diplomatReceive.buffer, this.ffiValue, write.buffer);
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 { CsidCompliance } from "./CsidCompliance.mjs"
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>): CsidCompliance;
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 { CsidCompliance } from "./CsidCompliance.mjs"
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 CsidCompliance(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
147
+ return new ComplianceCsid(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
148
148
  }
149
149
 
150
150
  finally {
@@ -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: number): Config;
15
+ static new_(env: Environment): Config;
15
16
 
16
- env(): number;
17
+ env(): Environment;
17
18
  }
@@ -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
- return result;
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
- static fromPropertiesStr(properties: string): CsrProperties;
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: number): Csr;
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
- static fromPropertiesStr(properties) {
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.fatoora_CsrProperties_from_properties_str(diplomatReceive.buffer, propertiesSlice.ptr);
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
+ }
@@ -19,7 +19,7 @@ export class FinalizedInvoice {
19
19
 
20
20
  totals(): InvoiceTotals;
21
21
 
22
- hashBase64(): string;
22
+ hash(): string;
23
23
 
24
24
  xml(): string;
25
25
  }
@@ -103,13 +103,13 @@ export class FinalizedInvoice {
103
103
  }
104
104
  }
105
105
 
106
- hashBase64() {
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.fatoora_FinalizedInvoice_hash_base64(diplomatReceive.buffer, this.ffiValue, write.buffer);
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
- addDocumentAdjustment(charge: boolean, value: Adjustment, category: number, rate: string, exemption: TaxExemption): void;
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: number, subtype: number, reference: OriginalInvoiceRef, reason: string): InvoiceBuilder;
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
- setTaxExemption(category: number, rate: string, exemption: TaxExemption): void;
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: number, subtype: number, originalId: string | null, originalUuid: string | null, originalDate: string | null, reason: string | null): InvoiceBuilder;
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: number): void;
89
-
90
- flags(value: number): void;
91
-
92
- setNote(language: string, value: string): void;
89
+ setVatCategory(value: VatCategory): void;
93
90
 
94
- setAllowance(reason: string, amount: string): void;
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: number): void;
97
+ addLineItem(description: string, quantity: string, unitCode: string, unitPrice: string, vatRate: string, category: VatCategory): void;
101
98
 
102
99
  build(): FinalizedInvoice;
103
100
  }