@maesn/typescript-sdk 0.8.22 → 0.8.23

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 (30) hide show
  1. package/README.md +2 -0
  2. package/esm/funcs/accounting-create-booking-proposal-attachment.d.ts +11 -0
  3. package/esm/funcs/accounting-create-booking-proposal-attachment.d.ts.map +1 -0
  4. package/esm/funcs/accounting-create-booking-proposal-attachment.js +103 -0
  5. package/esm/funcs/accounting-create-booking-proposal-attachment.js.map +1 -0
  6. package/esm/lib/config.d.ts +3 -3
  7. package/esm/lib/config.js +3 -3
  8. package/esm/models/operations/create-booking-proposal-attachment.d.ts +109 -0
  9. package/esm/models/operations/create-booking-proposal-attachment.d.ts.map +1 -0
  10. package/esm/models/operations/create-booking-proposal-attachment.js +90 -0
  11. package/esm/models/operations/create-booking-proposal-attachment.js.map +1 -0
  12. package/esm/models/operations/index.d.ts +1 -0
  13. package/esm/models/operations/index.d.ts.map +1 -1
  14. package/esm/models/operations/index.js +1 -0
  15. package/esm/models/operations/index.js.map +1 -1
  16. package/esm/sdk/accounting.d.ts +1 -0
  17. package/esm/sdk/accounting.d.ts.map +1 -1
  18. package/esm/sdk/accounting.js +4 -0
  19. package/esm/sdk/accounting.js.map +1 -1
  20. package/esm/types/smart-union.d.ts.map +1 -1
  21. package/esm/types/smart-union.js +13 -8
  22. package/esm/types/smart-union.js.map +1 -1
  23. package/jsr.json +1 -1
  24. package/package.json +1 -1
  25. package/src/funcs/accounting-create-booking-proposal-attachment.ts +227 -0
  26. package/src/lib/config.ts +3 -3
  27. package/src/models/operations/create-booking-proposal-attachment.ts +297 -0
  28. package/src/models/operations/index.ts +1 -0
  29. package/src/sdk/accounting.ts +12 -0
  30. package/src/types/smart-union.ts +17 -8
@@ -0,0 +1,297 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { safeParse } from "../../lib/schemas.js";
7
+ import { blobLikeSchema } from "../../types/blobs.js";
8
+ import { ClosedEnum } from "../../types/enums.js";
9
+ import { Result as SafeParseResult } from "../../types/fp.js";
10
+ import * as types from "../../types/primitives.js";
11
+ import { SDKValidationError } from "../errors/sdk-validation-error.js";
12
+ import * as models from "../index.js";
13
+
14
+ export type CreateBookingProposalAttachmentGlobals = {
15
+ apiKey?: string | undefined;
16
+ accountKey?: string | undefined;
17
+ };
18
+
19
+ export type CreateBookingProposalAttachmentFile = {
20
+ fileName: string;
21
+ content: ReadableStream<Uint8Array> | Blob | ArrayBuffer | Uint8Array;
22
+ };
23
+
24
+ export const DocumentType = {
25
+ Bill: "BILL",
26
+ Invoice: "INVOICE",
27
+ } as const;
28
+ export type DocumentType = ClosedEnum<typeof DocumentType>;
29
+
30
+ export type CreateBookingProposalAttachmentRequestBody = {
31
+ file?: CreateBookingProposalAttachmentFile | Blob | undefined;
32
+ documentType?: DocumentType | undefined;
33
+ };
34
+
35
+ export type CreateBookingProposalAttachmentRequest = {
36
+ bookingProposalId: string;
37
+ /**
38
+ * ID of the company (required for multi-company target systems)
39
+ */
40
+ companyId?: string | undefined;
41
+ /**
42
+ * Environment name (required for multi-environment systems such as Business Central)
43
+ */
44
+ environmentName?: string | undefined;
45
+ /**
46
+ * API key
47
+ */
48
+ apiKey?: string | undefined;
49
+ /**
50
+ * Account key
51
+ */
52
+ accountKey?: string | undefined;
53
+ body: CreateBookingProposalAttachmentRequestBody;
54
+ };
55
+
56
+ export type CreateBookingProposalAttachmentPagination = {
57
+ total: number;
58
+ perPage: number;
59
+ currentPage: number;
60
+ totalPages: number;
61
+ };
62
+
63
+ export type CreateBookingProposalAttachmentMeta = {
64
+ warnings?: Array<string> | null | undefined;
65
+ pagination?: CreateBookingProposalAttachmentPagination | null | undefined;
66
+ };
67
+
68
+ export type CreateBookingProposalAttachmentErrors = {};
69
+
70
+ export type CreateBookingProposalAttachmentRawData = {};
71
+
72
+ /**
73
+ * Booking proposal attachment uploaded successfully
74
+ */
75
+ export type CreateBookingProposalAttachmentResponse = {
76
+ meta?: CreateBookingProposalAttachmentMeta | null | undefined;
77
+ data: models.DocumentResponseDto;
78
+ errors: CreateBookingProposalAttachmentErrors | null;
79
+ rawData: CreateBookingProposalAttachmentRawData | null;
80
+ };
81
+
82
+ /** @internal */
83
+ export type CreateBookingProposalAttachmentFile$Outbound = {
84
+ fileName: string;
85
+ content: ReadableStream<Uint8Array> | Blob | ArrayBuffer | Uint8Array;
86
+ };
87
+
88
+ /** @internal */
89
+ export const CreateBookingProposalAttachmentFile$outboundSchema: z.ZodMiniType<
90
+ CreateBookingProposalAttachmentFile$Outbound,
91
+ CreateBookingProposalAttachmentFile
92
+ > = z.object({
93
+ fileName: z.string(),
94
+ content: z.union([
95
+ z.custom<ReadableStream<Uint8Array>>(x => x instanceof ReadableStream),
96
+ z.custom<Blob>(x => x instanceof Blob),
97
+ z.custom<ArrayBuffer>(x => x instanceof ArrayBuffer),
98
+ z.custom<Uint8Array>(x => x instanceof Uint8Array),
99
+ ]),
100
+ });
101
+
102
+ export function createBookingProposalAttachmentFileToJSON(
103
+ createBookingProposalAttachmentFile: CreateBookingProposalAttachmentFile,
104
+ ): string {
105
+ return JSON.stringify(
106
+ CreateBookingProposalAttachmentFile$outboundSchema.parse(
107
+ createBookingProposalAttachmentFile,
108
+ ),
109
+ );
110
+ }
111
+
112
+ /** @internal */
113
+ export const DocumentType$outboundSchema: z.ZodMiniEnum<typeof DocumentType> = z
114
+ .enum(DocumentType);
115
+
116
+ /** @internal */
117
+ export type CreateBookingProposalAttachmentRequestBody$Outbound = {
118
+ file?: CreateBookingProposalAttachmentFile$Outbound | Blob | undefined;
119
+ documentType?: string | undefined;
120
+ };
121
+
122
+ /** @internal */
123
+ export const CreateBookingProposalAttachmentRequestBody$outboundSchema:
124
+ z.ZodMiniType<
125
+ CreateBookingProposalAttachmentRequestBody$Outbound,
126
+ CreateBookingProposalAttachmentRequestBody
127
+ > = z.object({
128
+ file: z.optional(
129
+ z.union([
130
+ z.lazy(() => CreateBookingProposalAttachmentFile$outboundSchema),
131
+ blobLikeSchema,
132
+ ]),
133
+ ),
134
+ documentType: z.optional(DocumentType$outboundSchema),
135
+ });
136
+
137
+ export function createBookingProposalAttachmentRequestBodyToJSON(
138
+ createBookingProposalAttachmentRequestBody:
139
+ CreateBookingProposalAttachmentRequestBody,
140
+ ): string {
141
+ return JSON.stringify(
142
+ CreateBookingProposalAttachmentRequestBody$outboundSchema.parse(
143
+ createBookingProposalAttachmentRequestBody,
144
+ ),
145
+ );
146
+ }
147
+
148
+ /** @internal */
149
+ export type CreateBookingProposalAttachmentRequest$Outbound = {
150
+ bookingProposalId: string;
151
+ companyId?: string | undefined;
152
+ environmentName?: string | undefined;
153
+ apiKey?: string | undefined;
154
+ accountKey?: string | undefined;
155
+ body: CreateBookingProposalAttachmentRequestBody$Outbound;
156
+ };
157
+
158
+ /** @internal */
159
+ export const CreateBookingProposalAttachmentRequest$outboundSchema:
160
+ z.ZodMiniType<
161
+ CreateBookingProposalAttachmentRequest$Outbound,
162
+ CreateBookingProposalAttachmentRequest
163
+ > = z.object({
164
+ bookingProposalId: z.string(),
165
+ companyId: z.optional(z.string()),
166
+ environmentName: z.optional(z.string()),
167
+ apiKey: z.optional(z.string()),
168
+ accountKey: z.optional(z.string()),
169
+ body: z.lazy(() =>
170
+ CreateBookingProposalAttachmentRequestBody$outboundSchema
171
+ ),
172
+ });
173
+
174
+ export function createBookingProposalAttachmentRequestToJSON(
175
+ createBookingProposalAttachmentRequest:
176
+ CreateBookingProposalAttachmentRequest,
177
+ ): string {
178
+ return JSON.stringify(
179
+ CreateBookingProposalAttachmentRequest$outboundSchema.parse(
180
+ createBookingProposalAttachmentRequest,
181
+ ),
182
+ );
183
+ }
184
+
185
+ /** @internal */
186
+ export const CreateBookingProposalAttachmentPagination$inboundSchema:
187
+ z.ZodMiniType<CreateBookingProposalAttachmentPagination, unknown> = z.object({
188
+ total: types.number(),
189
+ perPage: types.number(),
190
+ currentPage: types.number(),
191
+ totalPages: types.number(),
192
+ });
193
+
194
+ export function createBookingProposalAttachmentPaginationFromJSON(
195
+ jsonString: string,
196
+ ): SafeParseResult<
197
+ CreateBookingProposalAttachmentPagination,
198
+ SDKValidationError
199
+ > {
200
+ return safeParse(
201
+ jsonString,
202
+ (x) =>
203
+ CreateBookingProposalAttachmentPagination$inboundSchema.parse(
204
+ JSON.parse(x),
205
+ ),
206
+ `Failed to parse 'CreateBookingProposalAttachmentPagination' from JSON`,
207
+ );
208
+ }
209
+
210
+ /** @internal */
211
+ export const CreateBookingProposalAttachmentMeta$inboundSchema: z.ZodMiniType<
212
+ CreateBookingProposalAttachmentMeta,
213
+ unknown
214
+ > = z.object({
215
+ warnings: z.optional(z.nullable(z.array(types.string()))),
216
+ pagination: z.optional(
217
+ z.nullable(z.lazy(() =>
218
+ CreateBookingProposalAttachmentPagination$inboundSchema
219
+ )),
220
+ ),
221
+ });
222
+
223
+ export function createBookingProposalAttachmentMetaFromJSON(
224
+ jsonString: string,
225
+ ): SafeParseResult<CreateBookingProposalAttachmentMeta, SDKValidationError> {
226
+ return safeParse(
227
+ jsonString,
228
+ (x) =>
229
+ CreateBookingProposalAttachmentMeta$inboundSchema.parse(JSON.parse(x)),
230
+ `Failed to parse 'CreateBookingProposalAttachmentMeta' from JSON`,
231
+ );
232
+ }
233
+
234
+ /** @internal */
235
+ export const CreateBookingProposalAttachmentErrors$inboundSchema: z.ZodMiniType<
236
+ CreateBookingProposalAttachmentErrors,
237
+ unknown
238
+ > = z.object({});
239
+
240
+ export function createBookingProposalAttachmentErrorsFromJSON(
241
+ jsonString: string,
242
+ ): SafeParseResult<CreateBookingProposalAttachmentErrors, SDKValidationError> {
243
+ return safeParse(
244
+ jsonString,
245
+ (x) =>
246
+ CreateBookingProposalAttachmentErrors$inboundSchema.parse(JSON.parse(x)),
247
+ `Failed to parse 'CreateBookingProposalAttachmentErrors' from JSON`,
248
+ );
249
+ }
250
+
251
+ /** @internal */
252
+ export const CreateBookingProposalAttachmentRawData$inboundSchema:
253
+ z.ZodMiniType<CreateBookingProposalAttachmentRawData, unknown> = z.object({});
254
+
255
+ export function createBookingProposalAttachmentRawDataFromJSON(
256
+ jsonString: string,
257
+ ): SafeParseResult<CreateBookingProposalAttachmentRawData, SDKValidationError> {
258
+ return safeParse(
259
+ jsonString,
260
+ (x) =>
261
+ CreateBookingProposalAttachmentRawData$inboundSchema.parse(JSON.parse(x)),
262
+ `Failed to parse 'CreateBookingProposalAttachmentRawData' from JSON`,
263
+ );
264
+ }
265
+
266
+ /** @internal */
267
+ export const CreateBookingProposalAttachmentResponse$inboundSchema:
268
+ z.ZodMiniType<CreateBookingProposalAttachmentResponse, unknown> = z.object({
269
+ meta: z.optional(
270
+ z.nullable(
271
+ z.lazy(() => CreateBookingProposalAttachmentMeta$inboundSchema),
272
+ ),
273
+ ),
274
+ data: models.DocumentResponseDto$inboundSchema,
275
+ errors: types.nullable(
276
+ z.lazy(() => CreateBookingProposalAttachmentErrors$inboundSchema),
277
+ ),
278
+ rawData: types.nullable(
279
+ z.lazy(() => CreateBookingProposalAttachmentRawData$inboundSchema),
280
+ ),
281
+ });
282
+
283
+ export function createBookingProposalAttachmentResponseFromJSON(
284
+ jsonString: string,
285
+ ): SafeParseResult<
286
+ CreateBookingProposalAttachmentResponse,
287
+ SDKValidationError
288
+ > {
289
+ return safeParse(
290
+ jsonString,
291
+ (x) =>
292
+ CreateBookingProposalAttachmentResponse$inboundSchema.parse(
293
+ JSON.parse(x),
294
+ ),
295
+ `Failed to parse 'CreateBookingProposalAttachmentResponse' from JSON`,
296
+ );
297
+ }
@@ -10,6 +10,7 @@ export * from "./create-bank-account.js";
10
10
  export * from "./create-bill-line-item.js";
11
11
  export * from "./create-bill.js";
12
12
  export * from "./create-booking-proposal-async.js";
13
+ export * from "./create-booking-proposal-attachment.js";
13
14
  export * from "./create-booking-proposal-v2.js";
14
15
  export * from "./create-booking-proposal.js";
15
16
  export * from "./create-contact-v2.js";
@@ -7,6 +7,7 @@ import { accountingCreateBankAccount } from "../funcs/accounting-create-bank-acc
7
7
  import { accountingCreateBillLineItem } from "../funcs/accounting-create-bill-line-item.js";
8
8
  import { accountingCreateBill } from "../funcs/accounting-create-bill.js";
9
9
  import { accountingCreateBookingProposalAsync } from "../funcs/accounting-create-booking-proposal-async.js";
10
+ import { accountingCreateBookingProposalAttachment } from "../funcs/accounting-create-booking-proposal-attachment.js";
10
11
  import { accountingCreateBookingProposal } from "../funcs/accounting-create-booking-proposal.js";
11
12
  import { accountingCreateContact } from "../funcs/accounting-create-contact.js";
12
13
  import { accountingCreateContactsV1 } from "../funcs/accounting-create-contacts-v1.js";
@@ -1189,6 +1190,17 @@ export class Accounting extends ClientSDK {
1189
1190
  ));
1190
1191
  }
1191
1192
 
1193
+ async createBookingProposalAttachment(
1194
+ request: operations.CreateBookingProposalAttachmentRequest,
1195
+ options?: RequestOptions,
1196
+ ): Promise<operations.CreateBookingProposalAttachmentResponse> {
1197
+ return unwrapAsync(accountingCreateBookingProposalAttachment(
1198
+ this,
1199
+ request,
1200
+ options,
1201
+ ));
1202
+ }
1203
+
1192
1204
  async getBookingProposal(
1193
1205
  request: operations.GetBookingProposalRequest,
1194
1206
  options?: RequestOptions,
@@ -31,28 +31,33 @@ export function smartUnion<
31
31
  z.unknown(),
32
32
  z.transform((input, ctx) => {
33
33
  const candidates: Candidate[] = [];
34
- const errors: z.core.$ZodIssue[][] = options.map(() => []);
34
+ const errors: z.core.$ZodRawIssue[][] = [];
35
35
 
36
36
  const parentUnrecognizedCtr = startCountingUnrecognized();
37
37
  const parentZeroDefaultCtr = startCountingDefaultToZeroValue();
38
38
 
39
39
  // Filter out invalid options
40
- for (const [i, option] of options.entries()) {
40
+ for (const option of options) {
41
41
  const unrecognizedCtr = startCountingUnrecognized();
42
42
  const zeroDefaultCtr = startCountingDefaultToZeroValue();
43
- const result = option.safeParse(input);
43
+ const result = option._zod.run({ value: input, issues: [] }, {
44
+ async: false,
45
+ });
46
+ if (result instanceof Promise) {
47
+ throw new z.core.$ZodAsyncError();
48
+ }
44
49
  const inexactCount = unrecognizedCtr.end();
45
50
  const zeroDefaultCount = zeroDefaultCtr.end();
46
- if (result.success) {
51
+ if (result.issues.length === 0) {
47
52
  candidates.push({
48
- data: result.data,
53
+ data: result.value,
49
54
  inexactCount,
50
55
  zeroDefaultCount,
51
56
  fieldCount: -1, // We'll count this later if needed
52
57
  });
53
58
  continue;
54
59
  }
55
- errors[i]!.push(...result.error.issues);
60
+ errors.push(result.issues);
56
61
  }
57
62
 
58
63
  // No valid options
@@ -62,9 +67,13 @@ export function smartUnion<
62
67
  ctx.issues.push({
63
68
  input: input,
64
69
  code: "invalid_union",
65
- errors: errors,
70
+ errors: errors.map(issues =>
71
+ issues.map(issue =>
72
+ z.core.util.finalizeIssue(issue, {}, z.core.config())
73
+ )
74
+ ),
66
75
  });
67
- return z.NEVER;
76
+ return undefined;
68
77
  }
69
78
 
70
79
  let best = candidates[0]!;