fatoority 0.4.4 → 0.5.1

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/fatoora_ffi.wasm CHANGED
Binary file
@@ -12,6 +12,10 @@ export class Address {
12
12
  constructor();
13
13
 
14
14
 
15
+ withProvince(value: string): Address;
16
+
17
+ province(): Text | null;
18
+
15
19
  static new_(countryCode: string, city: string, street: string, buildingNumber: string, postalCode: string, additionalStreet: string | null, additionalNumber: string | null, district: string | null): Address;
16
20
 
17
21
  city(): string;
@@ -37,6 +37,51 @@ export class Address {
37
37
  }
38
38
 
39
39
 
40
+ withProvince(value) {
41
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
42
+
43
+ const valueSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, value)));
44
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
45
+
46
+
47
+ const result = wasm.fatoora_Address_with_province(diplomatReceive.buffer, this.ffiValue, valueSlice.ptr);
48
+
49
+ try {
50
+ if (!diplomatReceive.resultFlag) {
51
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
52
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
53
+ }
54
+ return new Address(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
55
+ }
56
+
57
+ finally {
58
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
59
+ functionCleanupArena.free();
60
+
61
+ diplomatReceive.free();
62
+ }
63
+ }
64
+
65
+ province() {
66
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
67
+
68
+
69
+ const result = wasm.fatoora_Address_province(diplomatReceive.buffer, this.ffiValue);
70
+
71
+ try {
72
+ if (!diplomatReceive.resultFlag) {
73
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
74
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
75
+ }
76
+ return diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer) === 0 ? null : new Text(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
77
+ }
78
+
79
+ finally {
80
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
81
+ diplomatReceive.free();
82
+ }
83
+ }
84
+
40
85
  static new_(countryCode, city, street, buildingNumber, postalCode, additionalStreet, additionalNumber, district) {
41
86
  let functionCleanupArena = new diplomatRuntime.CleanupArena();
42
87
 
@@ -0,0 +1,32 @@
1
+ // generated by diplomat-tool
2
+ import type { BindingError } from "./BindingError.mjs"
3
+ import type { Text } from "./Text.mjs"
4
+ import type { pointer, codepoint } from "./diplomat-runtime.mjs";
5
+
6
+
7
+
8
+ export class Adjustment {
9
+ /** @internal */
10
+ get ffiValue(): pointer;
11
+ /** @internal */
12
+ constructor();
13
+
14
+
15
+ static amount(value: string): Adjustment;
16
+
17
+ static percentage(base: string, percent: string): Adjustment;
18
+
19
+ withSuppliedAmount(value: string): Adjustment;
20
+
21
+ withReason(reason: string | null, code: string | null): Adjustment;
22
+
23
+ value(): string;
24
+
25
+ baseAmount(): Text | null;
26
+
27
+ percent(): Text | null;
28
+
29
+ reason(): Text | null;
30
+
31
+ reasonCode(): Text | null;
32
+ }
@@ -0,0 +1,246 @@
1
+ // generated by diplomat-tool
2
+ import { BindingError } from "./BindingError.mjs"
3
+ import { Text } from "./Text.mjs"
4
+ import wasm from "./diplomat-wasm.mjs";
5
+ import * as diplomatRuntime from "./diplomat-runtime.mjs";
6
+
7
+ const Adjustment_box_destroy_registry = new FinalizationRegistry((ptr) => {
8
+ wasm.fatoora_Adjustment_destroy(ptr);
9
+ });
10
+
11
+ export class Adjustment {
12
+ // Internal ptr reference:
13
+ #ptr = null;
14
+
15
+ // Lifetimes are only to keep dependencies alive.
16
+ // Since JS won't garbage collect until there are no incoming edges.
17
+ #selfEdge = [];
18
+
19
+ #internalConstructor(symbol, ptr, selfEdge) {
20
+ if (symbol !== diplomatRuntime.internalConstructor) {
21
+ console.error("Adjustment is an Opaque type. You cannot call its constructor.");
22
+ return;
23
+ }
24
+ this.#ptr = ptr;
25
+ this.#selfEdge = selfEdge;
26
+
27
+ // Are we being borrowed? If not, we can register.
28
+ if (this.#selfEdge.length === 0) {
29
+ Adjustment_box_destroy_registry.register(this, this.#ptr);
30
+ }
31
+
32
+ return this;
33
+ }
34
+ /** @internal */
35
+ get ffiValue() {
36
+ return this.#ptr;
37
+ }
38
+
39
+
40
+ static amount(value) {
41
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
42
+
43
+ const valueSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, value)));
44
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
45
+
46
+
47
+ const result = wasm.fatoora_Adjustment_amount(diplomatReceive.buffer, valueSlice.ptr);
48
+
49
+ try {
50
+ if (!diplomatReceive.resultFlag) {
51
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
52
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
53
+ }
54
+ return new Adjustment(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
55
+ }
56
+
57
+ finally {
58
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
59
+ functionCleanupArena.free();
60
+
61
+ diplomatReceive.free();
62
+ }
63
+ }
64
+
65
+ static percentage(base, percent) {
66
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
67
+
68
+ const baseSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, base)));
69
+ const percentSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, percent)));
70
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
71
+
72
+
73
+ const result = wasm.fatoora_Adjustment_percentage(diplomatReceive.buffer, baseSlice.ptr, percentSlice.ptr);
74
+
75
+ try {
76
+ if (!diplomatReceive.resultFlag) {
77
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
78
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
79
+ }
80
+ return new Adjustment(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
81
+ }
82
+
83
+ finally {
84
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
85
+ functionCleanupArena.free();
86
+
87
+ diplomatReceive.free();
88
+ }
89
+ }
90
+
91
+ withSuppliedAmount(value) {
92
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
93
+
94
+ const valueSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, value)));
95
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
96
+
97
+
98
+ const result = wasm.fatoora_Adjustment_with_supplied_amount(diplomatReceive.buffer, this.ffiValue, valueSlice.ptr);
99
+
100
+ try {
101
+ if (!diplomatReceive.resultFlag) {
102
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
103
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
104
+ }
105
+ return new Adjustment(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
106
+ }
107
+
108
+ finally {
109
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
110
+ functionCleanupArena.free();
111
+
112
+ diplomatReceive.free();
113
+ }
114
+ }
115
+
116
+ withReason(reason, code) {
117
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
118
+
119
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
120
+
121
+
122
+ const result = wasm.fatoora_Adjustment_with_reason(diplomatReceive.buffer, this.ffiValue, diplomatRuntime.optionToBufferForCalling(wasm, reason, 8, 4, functionCleanupArena, (arrayBuffer, offset, jsValue) => [functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, jsValue)).writePtrLenToArrayBuffer(arrayBuffer, offset + 0)]), diplomatRuntime.optionToBufferForCalling(wasm, code, 8, 4, functionCleanupArena, (arrayBuffer, offset, jsValue) => [functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, jsValue)).writePtrLenToArrayBuffer(arrayBuffer, offset + 0)]));
123
+
124
+ try {
125
+ if (!diplomatReceive.resultFlag) {
126
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
127
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
128
+ }
129
+ return new Adjustment(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
130
+ }
131
+
132
+ finally {
133
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
134
+ functionCleanupArena.free();
135
+
136
+ diplomatReceive.free();
137
+ }
138
+ }
139
+
140
+ value() {
141
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
142
+
143
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
144
+
145
+
146
+ const result = wasm.fatoora_Adjustment_value(diplomatReceive.buffer, this.ffiValue, write.buffer);
147
+
148
+ try {
149
+ if (!diplomatReceive.resultFlag) {
150
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
151
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
152
+ }
153
+ return write.readString8();
154
+ }
155
+
156
+ finally {
157
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
158
+ diplomatReceive.free();
159
+ write.free();
160
+ }
161
+ }
162
+
163
+ baseAmount() {
164
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
165
+
166
+
167
+ const result = wasm.fatoora_Adjustment_base_amount(diplomatReceive.buffer, this.ffiValue);
168
+
169
+ try {
170
+ if (!diplomatReceive.resultFlag) {
171
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
172
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
173
+ }
174
+ return diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer) === 0 ? null : new Text(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
175
+ }
176
+
177
+ finally {
178
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
179
+ diplomatReceive.free();
180
+ }
181
+ }
182
+
183
+ percent() {
184
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
185
+
186
+
187
+ const result = wasm.fatoora_Adjustment_percent(diplomatReceive.buffer, this.ffiValue);
188
+
189
+ try {
190
+ if (!diplomatReceive.resultFlag) {
191
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
192
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
193
+ }
194
+ return diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer) === 0 ? null : new Text(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
195
+ }
196
+
197
+ finally {
198
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
199
+ diplomatReceive.free();
200
+ }
201
+ }
202
+
203
+ reason() {
204
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
205
+
206
+
207
+ const result = wasm.fatoora_Adjustment_reason(diplomatReceive.buffer, this.ffiValue);
208
+
209
+ try {
210
+ if (!diplomatReceive.resultFlag) {
211
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
212
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
213
+ }
214
+ return diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer) === 0 ? null : new Text(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
215
+ }
216
+
217
+ finally {
218
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
219
+ diplomatReceive.free();
220
+ }
221
+ }
222
+
223
+ reasonCode() {
224
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
225
+
226
+
227
+ const result = wasm.fatoora_Adjustment_reason_code(diplomatReceive.buffer, this.ffiValue);
228
+
229
+ try {
230
+ if (!diplomatReceive.resultFlag) {
231
+ const cause = new BindingError(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
232
+ throw new globalThis.Error('BindingError: ' + cause.toString(), { cause });
233
+ }
234
+ return diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer) === 0 ? null : new Text(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
235
+ }
236
+
237
+ finally {
238
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
239
+ diplomatReceive.free();
240
+ }
241
+ }
242
+
243
+ constructor(symbol, ptr, selfEdge) {
244
+ return this.#internalConstructor(...arguments)
245
+ }
246
+ }
@@ -0,0 +1,51 @@
1
+ // generated by diplomat-tool
2
+ import type { BindingError } from "./BindingError.mjs"
3
+ import type { TaxExemption } from "./TaxExemption.mjs"
4
+ import type { Text } from "./Text.mjs"
5
+ import type { pointer, codepoint } from "./diplomat-runtime.mjs";
6
+
7
+
8
+
9
+ export class AllowanceCharge {
10
+ /** @internal */
11
+ get ffiValue(): pointer;
12
+ /** @internal */
13
+ constructor();
14
+
15
+
16
+ hasVatRate(): boolean;
17
+
18
+ withoutVatRate(): AllowanceCharge;
19
+
20
+ /**
21
+ * Retain this adjustment's metadata and check its percentage calculation.
22
+ */
23
+ withPercentage(base: string, percent: string): AllowanceCharge;
24
+
25
+ baseAmount(): Text | null;
26
+
27
+ percentage(): Text | null;
28
+
29
+ static new_(charge: boolean, amount: string, reason: string | null, reasonCode: string | null, category: number, rate: string, exemption: TaxExemption): AllowanceCharge;
30
+
31
+ isCharge(): boolean;
32
+
33
+ amount(): string;
34
+
35
+ rate(): string;
36
+
37
+ category(): number;
38
+
39
+ /**
40
+ * Return an independent adjustment with the given number of identical tax classifications.
41
+ */
42
+ withTaxCategoryCount(count: number): AllowanceCharge;
43
+
44
+ taxCategoryCount(): number;
45
+
46
+ reason(): Text | null;
47
+
48
+ reasonCode(): Text | null;
49
+
50
+ exemption(): TaxExemption;
51
+ }