@clientcasa/sdk 0.4.0 → 0.5.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 (99) hide show
  1. package/README.md +7 -0
  2. package/esm/funcs/document-versions-get.d.ts +16 -0
  3. package/esm/funcs/document-versions-get.d.ts.map +1 -0
  4. package/esm/funcs/document-versions-get.js +107 -0
  5. package/esm/funcs/document-versions-get.js.map +1 -0
  6. package/esm/funcs/document-versions-list.d.ts +21 -0
  7. package/esm/funcs/document-versions-list.d.ts.map +1 -0
  8. package/esm/funcs/document-versions-list.js +145 -0
  9. package/esm/funcs/document-versions-list.js.map +1 -0
  10. package/esm/funcs/invoices-create.d.ts +1 -1
  11. package/esm/funcs/invoices-create.js +1 -1
  12. package/esm/funcs/invoices-list.js +2 -0
  13. package/esm/funcs/invoices-list.js.map +1 -1
  14. package/esm/lib/config.d.ts +3 -3
  15. package/esm/lib/config.js +3 -3
  16. package/esm/lib/sdks.d.ts.map +1 -1
  17. package/esm/lib/sdks.js +37 -12
  18. package/esm/lib/sdks.js.map +1 -1
  19. package/esm/models/client-create.d.ts +5 -0
  20. package/esm/models/client-create.d.ts.map +1 -1
  21. package/esm/models/client-create.js +3 -0
  22. package/esm/models/client-create.js.map +1 -1
  23. package/esm/models/client-tax-settings.d.ts +21 -0
  24. package/esm/models/client-tax-settings.d.ts.map +1 -0
  25. package/esm/models/client-tax-settings.js +25 -0
  26. package/esm/models/client-tax-settings.js.map +1 -0
  27. package/esm/models/client-update.d.ts +5 -0
  28. package/esm/models/client-update.d.ts.map +1 -1
  29. package/esm/models/client-update.js +3 -0
  30. package/esm/models/client-update.js.map +1 -1
  31. package/esm/models/client.d.ts +25 -0
  32. package/esm/models/client.d.ts.map +1 -1
  33. package/esm/models/client.js +22 -0
  34. package/esm/models/client.js.map +1 -1
  35. package/esm/models/document-version-list.d.ts +13 -0
  36. package/esm/models/document-version-list.d.ts.map +1 -0
  37. package/esm/models/document-version-list.js +16 -0
  38. package/esm/models/document-version-list.js.map +1 -0
  39. package/esm/models/document-version.d.ts +106 -0
  40. package/esm/models/document-version.d.ts.map +1 -0
  41. package/esm/models/document-version.js +67 -0
  42. package/esm/models/document-version.js.map +1 -0
  43. package/esm/models/index.d.ts +3 -0
  44. package/esm/models/index.d.ts.map +1 -1
  45. package/esm/models/index.js +3 -0
  46. package/esm/models/index.js.map +1 -1
  47. package/esm/models/invoice.d.ts +8 -1
  48. package/esm/models/invoice.d.ts.map +1 -1
  49. package/esm/models/invoice.js +2 -1
  50. package/esm/models/invoice.js.map +1 -1
  51. package/esm/models/operations/get-document-version.d.ts +27 -0
  52. package/esm/models/operations/get-document-version.d.ts.map +1 -0
  53. package/esm/models/operations/get-document-version.js +20 -0
  54. package/esm/models/operations/get-document-version.js.map +1 -0
  55. package/esm/models/operations/index.d.ts +2 -0
  56. package/esm/models/operations/index.d.ts.map +1 -1
  57. package/esm/models/operations/index.js +2 -0
  58. package/esm/models/operations/index.js.map +1 -1
  59. package/esm/models/operations/list-document-versions.d.ts +61 -0
  60. package/esm/models/operations/list-document-versions.d.ts.map +1 -0
  61. package/esm/models/operations/list-document-versions.js +47 -0
  62. package/esm/models/operations/list-document-versions.js.map +1 -0
  63. package/esm/models/operations/list-invoices.d.ts +23 -1
  64. package/esm/models/operations/list-invoices.d.ts.map +1 -1
  65. package/esm/models/operations/list-invoices.js +11 -1
  66. package/esm/models/operations/list-invoices.js.map +1 -1
  67. package/esm/sdk/document-versions.d.ts +20 -0
  68. package/esm/sdk/document-versions.d.ts.map +1 -0
  69. package/esm/sdk/document-versions.js +26 -0
  70. package/esm/sdk/document-versions.js.map +1 -0
  71. package/esm/sdk/invoices.d.ts +1 -1
  72. package/esm/sdk/invoices.js +1 -1
  73. package/esm/sdk/sdk.d.ts +3 -0
  74. package/esm/sdk/sdk.d.ts.map +1 -1
  75. package/esm/sdk/sdk.js +5 -0
  76. package/esm/sdk/sdk.js.map +1 -1
  77. package/jsr.json +1 -1
  78. package/package.json +1 -1
  79. package/src/funcs/document-versions-get.ts +203 -0
  80. package/src/funcs/document-versions-list.ts +284 -0
  81. package/src/funcs/invoices-create.ts +1 -1
  82. package/src/funcs/invoices-list.ts +2 -0
  83. package/src/lib/config.ts +3 -3
  84. package/src/lib/sdks.ts +41 -13
  85. package/src/models/client-create.ts +11 -0
  86. package/src/models/client-tax-settings.ts +58 -0
  87. package/src/models/client-update.ts +11 -0
  88. package/src/models/client.ts +56 -0
  89. package/src/models/document-version-list.ts +40 -0
  90. package/src/models/document-version.ts +175 -0
  91. package/src/models/index.ts +3 -0
  92. package/src/models/invoice.ts +10 -1
  93. package/src/models/operations/get-document-version.ts +61 -0
  94. package/src/models/operations/index.ts +2 -0
  95. package/src/models/operations/list-document-versions.ts +132 -0
  96. package/src/models/operations/list-invoices.ts +29 -1
  97. package/src/sdk/document-versions.ts +50 -0
  98. package/src/sdk/invoices.ts +1 -1
  99. package/src/sdk/sdk.ts +6 -0
@@ -0,0 +1,203 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { ClientCasaCore } from "../core.js";
7
+ import { encodeSimple } from "../lib/encodings.js";
8
+ import { matchStatusCode } from "../lib/http.js";
9
+ import * as M from "../lib/matchers.js";
10
+ import { compactMap } from "../lib/primitives.js";
11
+ import { safeParse } from "../lib/schemas.js";
12
+ import { RequestOptions } from "../lib/sdks.js";
13
+ import { resolveSecurity } from "../lib/security.js";
14
+ import { pathToFunc } from "../lib/url.js";
15
+ import { ClientCasaError } from "../models/errors/client-casa-error.js";
16
+ import {
17
+ ConnectionError,
18
+ InvalidRequestError,
19
+ RequestAbortedError,
20
+ RequestTimeoutError,
21
+ UnexpectedClientError,
22
+ } from "../models/errors/http-client-errors.js";
23
+ import * as errors from "../models/errors/index.js";
24
+ import { ResponseValidationError } from "../models/errors/response-validation-error.js";
25
+ import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
26
+ import * as models from "../models/index.js";
27
+ import * as operations from "../models/operations/index.js";
28
+ import { APICall, APIPromise } from "../types/async.js";
29
+ import { Result } from "../types/fp.js";
30
+
31
+ /**
32
+ * Get a document version
33
+ */
34
+ export function documentVersionsGet(
35
+ client: ClientCasaCore,
36
+ security: operations.GetDocumentVersionSecurity,
37
+ request: operations.GetDocumentVersionRequest,
38
+ options?: RequestOptions,
39
+ ): APIPromise<
40
+ Result<
41
+ models.DocumentVersion,
42
+ | errors.ApiError
43
+ | ClientCasaError
44
+ | ResponseValidationError
45
+ | ConnectionError
46
+ | RequestAbortedError
47
+ | RequestTimeoutError
48
+ | InvalidRequestError
49
+ | UnexpectedClientError
50
+ | SDKValidationError
51
+ >
52
+ > {
53
+ return new APIPromise($do(
54
+ client,
55
+ security,
56
+ request,
57
+ options,
58
+ ));
59
+ }
60
+
61
+ async function $do(
62
+ client: ClientCasaCore,
63
+ security: operations.GetDocumentVersionSecurity,
64
+ request: operations.GetDocumentVersionRequest,
65
+ options?: RequestOptions,
66
+ ): Promise<
67
+ [
68
+ Result<
69
+ models.DocumentVersion,
70
+ | errors.ApiError
71
+ | ClientCasaError
72
+ | ResponseValidationError
73
+ | ConnectionError
74
+ | RequestAbortedError
75
+ | RequestTimeoutError
76
+ | InvalidRequestError
77
+ | UnexpectedClientError
78
+ | SDKValidationError
79
+ >,
80
+ APICall,
81
+ ]
82
+ > {
83
+ const parsed = safeParse(
84
+ request,
85
+ (value) =>
86
+ z.parse(operations.GetDocumentVersionRequest$outboundSchema, value),
87
+ "Input validation failed",
88
+ );
89
+ if (!parsed.ok) {
90
+ return [parsed, { status: "invalid" }];
91
+ }
92
+ const payload = parsed.value;
93
+ const body = null;
94
+
95
+ const pathParams = {
96
+ id: encodeSimple("id", payload.id, {
97
+ explode: false,
98
+ charEncoding: "percent",
99
+ }),
100
+ };
101
+ const path = pathToFunc("/api/v1/document-versions/{id}")(pathParams);
102
+
103
+ const headers = new Headers(compactMap({
104
+ Accept: "application/json",
105
+ }));
106
+
107
+ const requestSecurity = resolveSecurity(
108
+ [
109
+ {
110
+ fieldName: "x-api-key",
111
+ type: "apiKey:header",
112
+ value: security?.apiKey,
113
+ },
114
+ ],
115
+ [
116
+ {
117
+ fieldName: "Authorization",
118
+ type: "http:bearer",
119
+ value: security?.bearer,
120
+ },
121
+ ],
122
+ );
123
+
124
+ const context = {
125
+ options: client._options,
126
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
127
+ operationID: "getDocumentVersion",
128
+ oAuth2Scopes: null,
129
+
130
+ resolvedSecurity: requestSecurity,
131
+
132
+ securitySource: security,
133
+ retryConfig: options?.retries
134
+ || client._options.retryConfig
135
+ || {
136
+ strategy: "backoff",
137
+ backoff: {
138
+ initialInterval: 500,
139
+ maxInterval: 30000,
140
+ exponent: 1.5,
141
+ maxElapsedTime: 30000,
142
+ },
143
+ retryConnectionErrors: true,
144
+ }
145
+ || { strategy: "none" },
146
+ retryCodes: options?.retryCodes || ["429", "5XX"],
147
+ };
148
+
149
+ const requestRes = client._createRequest(context, {
150
+ security: requestSecurity,
151
+ method: "GET",
152
+ baseURL: options?.serverURL,
153
+ path: path,
154
+ headers: headers,
155
+ body: body,
156
+ userAgent: client._options.userAgent,
157
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
158
+ }, options);
159
+ if (!requestRes.ok) {
160
+ return [requestRes, { status: "invalid" }];
161
+ }
162
+ const req = requestRes.value;
163
+
164
+ const doResult = await client._do(req, {
165
+ context,
166
+ isErrorStatusCode: (statusCode: number) =>
167
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
168
+ retryConfig: context.retryConfig,
169
+ retryCodes: context.retryCodes,
170
+ });
171
+ if (!doResult.ok) {
172
+ return [doResult, { status: "request-error", request: req }];
173
+ }
174
+ const response = doResult.value;
175
+
176
+ const responseFields = {
177
+ HttpMeta: { Response: response, Request: req },
178
+ };
179
+
180
+ const [result] = await M.match<
181
+ models.DocumentVersion,
182
+ | errors.ApiError
183
+ | ClientCasaError
184
+ | ResponseValidationError
185
+ | ConnectionError
186
+ | RequestAbortedError
187
+ | RequestTimeoutError
188
+ | InvalidRequestError
189
+ | UnexpectedClientError
190
+ | SDKValidationError
191
+ >(
192
+ M.json(200, models.DocumentVersion$inboundSchema),
193
+ M.jsonErr([401, 403, 404, 429], errors.ApiError$inboundSchema),
194
+ M.jsonErr(500, errors.ApiError$inboundSchema),
195
+ M.fail("4XX"),
196
+ M.fail("5XX"),
197
+ )(response, req, { extraFields: responseFields });
198
+ if (!result.ok) {
199
+ return [result, { status: "complete", request: req, response }];
200
+ }
201
+
202
+ return [result, { status: "complete", request: req, response }];
203
+ }
@@ -0,0 +1,284 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { ClientCasaCore } from "../core.js";
7
+ import { dlv } from "../lib/dlv.js";
8
+ import { encodeFormQuery } from "../lib/encodings.js";
9
+ import { matchStatusCode } from "../lib/http.js";
10
+ import * as M from "../lib/matchers.js";
11
+ import { compactMap } from "../lib/primitives.js";
12
+ import { safeParse } from "../lib/schemas.js";
13
+ import { RequestOptions } from "../lib/sdks.js";
14
+ import { resolveSecurity } from "../lib/security.js";
15
+ import { pathToFunc } from "../lib/url.js";
16
+ import { ClientCasaError } from "../models/errors/client-casa-error.js";
17
+ import {
18
+ ConnectionError,
19
+ InvalidRequestError,
20
+ RequestAbortedError,
21
+ RequestTimeoutError,
22
+ UnexpectedClientError,
23
+ } from "../models/errors/http-client-errors.js";
24
+ import * as errors from "../models/errors/index.js";
25
+ import { ResponseValidationError } from "../models/errors/response-validation-error.js";
26
+ import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
27
+ import * as operations from "../models/operations/index.js";
28
+ import { APICall, APIPromise } from "../types/async.js";
29
+ import { Result } from "../types/fp.js";
30
+ import {
31
+ createPageIterator,
32
+ haltIterator,
33
+ PageIterator,
34
+ Paginator,
35
+ } from "../types/operations.js";
36
+
37
+ /**
38
+ * List document versions
39
+ *
40
+ * @remarks
41
+ * Read-only audit trail of issued document versions across smart-files, invoices, and standalone contracts. Checkpoints (internal draft edit-history) are never returned. Frozen content and client access tokens are not exposed.
42
+ */
43
+ export function documentVersionsList(
44
+ client: ClientCasaCore,
45
+ security: operations.ListDocumentVersionsSecurity,
46
+ request?: operations.ListDocumentVersionsRequest | undefined,
47
+ options?: RequestOptions,
48
+ ): APIPromise<
49
+ PageIterator<
50
+ Result<
51
+ operations.ListDocumentVersionsResponse,
52
+ | errors.ApiError
53
+ | ClientCasaError
54
+ | ResponseValidationError
55
+ | ConnectionError
56
+ | RequestAbortedError
57
+ | RequestTimeoutError
58
+ | InvalidRequestError
59
+ | UnexpectedClientError
60
+ | SDKValidationError
61
+ >,
62
+ { page: number }
63
+ >
64
+ > {
65
+ return new APIPromise($do(
66
+ client,
67
+ security,
68
+ request,
69
+ options,
70
+ ));
71
+ }
72
+
73
+ async function $do(
74
+ client: ClientCasaCore,
75
+ security: operations.ListDocumentVersionsSecurity,
76
+ request?: operations.ListDocumentVersionsRequest | undefined,
77
+ options?: RequestOptions,
78
+ ): Promise<
79
+ [
80
+ PageIterator<
81
+ Result<
82
+ operations.ListDocumentVersionsResponse,
83
+ | errors.ApiError
84
+ | ClientCasaError
85
+ | ResponseValidationError
86
+ | ConnectionError
87
+ | RequestAbortedError
88
+ | RequestTimeoutError
89
+ | InvalidRequestError
90
+ | UnexpectedClientError
91
+ | SDKValidationError
92
+ >,
93
+ { page: number }
94
+ >,
95
+ APICall,
96
+ ]
97
+ > {
98
+ const parsed = safeParse(
99
+ request,
100
+ (value) =>
101
+ z.parse(
102
+ z.optional(operations.ListDocumentVersionsRequest$outboundSchema),
103
+ value,
104
+ ),
105
+ "Input validation failed",
106
+ );
107
+ if (!parsed.ok) {
108
+ return [haltIterator(parsed), { status: "invalid" }];
109
+ }
110
+ const payload = parsed.value;
111
+ const body = null;
112
+
113
+ const path = pathToFunc("/api/v1/document-versions")();
114
+
115
+ const query = encodeFormQuery({
116
+ "contractId": payload?.contractId,
117
+ "documentId": payload?.documentId,
118
+ "documentType": payload?.documentType,
119
+ "invoiceId": payload?.invoiceId,
120
+ "page": payload?.page,
121
+ "pageSize": payload?.pageSize,
122
+ });
123
+
124
+ const headers = new Headers(compactMap({
125
+ Accept: "application/json",
126
+ }));
127
+
128
+ const requestSecurity = resolveSecurity(
129
+ [
130
+ {
131
+ fieldName: "x-api-key",
132
+ type: "apiKey:header",
133
+ value: security?.apiKey,
134
+ },
135
+ ],
136
+ [
137
+ {
138
+ fieldName: "Authorization",
139
+ type: "http:bearer",
140
+ value: security?.bearer,
141
+ },
142
+ ],
143
+ );
144
+
145
+ const context = {
146
+ options: client._options,
147
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
148
+ operationID: "listDocumentVersions",
149
+ oAuth2Scopes: null,
150
+
151
+ resolvedSecurity: requestSecurity,
152
+
153
+ securitySource: security,
154
+ retryConfig: options?.retries
155
+ || client._options.retryConfig
156
+ || {
157
+ strategy: "backoff",
158
+ backoff: {
159
+ initialInterval: 500,
160
+ maxInterval: 30000,
161
+ exponent: 1.5,
162
+ maxElapsedTime: 30000,
163
+ },
164
+ retryConnectionErrors: true,
165
+ }
166
+ || { strategy: "none" },
167
+ retryCodes: options?.retryCodes || ["429", "5XX"],
168
+ };
169
+
170
+ const requestRes = client._createRequest(context, {
171
+ security: requestSecurity,
172
+ method: "GET",
173
+ baseURL: options?.serverURL,
174
+ path: path,
175
+ headers: headers,
176
+ query: query,
177
+ body: body,
178
+ userAgent: client._options.userAgent,
179
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
180
+ }, options);
181
+ if (!requestRes.ok) {
182
+ return [haltIterator(requestRes), { status: "invalid" }];
183
+ }
184
+ const req = requestRes.value;
185
+
186
+ const doResult = await client._do(req, {
187
+ context,
188
+ isErrorStatusCode: (statusCode: number) =>
189
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
190
+ retryConfig: context.retryConfig,
191
+ retryCodes: context.retryCodes,
192
+ });
193
+ if (!doResult.ok) {
194
+ return [haltIterator(doResult), { status: "request-error", request: req }];
195
+ }
196
+ const response = doResult.value;
197
+
198
+ const responseFields = {
199
+ HttpMeta: { Response: response, Request: req },
200
+ };
201
+
202
+ const [result, raw] = await M.match<
203
+ operations.ListDocumentVersionsResponse,
204
+ | errors.ApiError
205
+ | ClientCasaError
206
+ | ResponseValidationError
207
+ | ConnectionError
208
+ | RequestAbortedError
209
+ | RequestTimeoutError
210
+ | InvalidRequestError
211
+ | UnexpectedClientError
212
+ | SDKValidationError
213
+ >(
214
+ M.json(200, operations.ListDocumentVersionsResponse$inboundSchema, {
215
+ key: "Result",
216
+ }),
217
+ M.jsonErr([400, 401, 403, 429], errors.ApiError$inboundSchema),
218
+ M.jsonErr(500, errors.ApiError$inboundSchema),
219
+ M.fail("4XX"),
220
+ M.fail("5XX"),
221
+ )(response, req, { extraFields: responseFields });
222
+ if (!result.ok) {
223
+ return [haltIterator(result), {
224
+ status: "complete",
225
+ request: req,
226
+ response,
227
+ }];
228
+ }
229
+
230
+ const nextFunc = (
231
+ responseData: unknown,
232
+ ): {
233
+ next: Paginator<
234
+ Result<
235
+ operations.ListDocumentVersionsResponse,
236
+ | errors.ApiError
237
+ | ClientCasaError
238
+ | ResponseValidationError
239
+ | ConnectionError
240
+ | RequestAbortedError
241
+ | RequestTimeoutError
242
+ | InvalidRequestError
243
+ | UnexpectedClientError
244
+ | SDKValidationError
245
+ >
246
+ >;
247
+ "~next"?: { page: number };
248
+ } => {
249
+ const page = request?.page ?? 1;
250
+ const nextPage = page + 1;
251
+
252
+ if (!responseData) {
253
+ return { next: () => null };
254
+ }
255
+ const results = dlv(responseData, "data");
256
+ if (!Array.isArray(results) || !results.length) {
257
+ return { next: () => null };
258
+ }
259
+ const limit = request?.pageSize ?? 25;
260
+ if (results.length < limit) {
261
+ return { next: () => null };
262
+ }
263
+
264
+ const nextVal = () =>
265
+ documentVersionsList(
266
+ client,
267
+ security,
268
+ {
269
+ ...request!,
270
+ page: nextPage,
271
+ },
272
+ options,
273
+ );
274
+
275
+ return { next: nextVal, "~next": { page: nextPage } };
276
+ };
277
+
278
+ const page = { ...result, ...nextFunc(raw) };
279
+ return [{ ...page, ...createPageIterator(page, (v) => !v.ok) }, {
280
+ status: "complete",
281
+ request: req,
282
+ response,
283
+ }];
284
+ }
@@ -32,7 +32,7 @@ import { Result } from "../types/fp.js";
32
32
  * Create an invoice
33
33
  *
34
34
  * @remarks
35
- * Status `paid`, `partial`, and `overdue` are system-derived from Payments and the due date; do not set them directly.
35
+ * Status `paid` and `partial` are system-derived from Payments; do not set them directly. `overdue` is not a status — it is a derived read-only boolean field (past due with a balance owing).
36
36
  */
37
37
  export function invoicesCreate(
38
38
  client: ClientCasaCore,
@@ -108,9 +108,11 @@ async function $do(
108
108
 
109
109
  const query = encodeFormQuery({
110
110
  "clientId": payload?.clientId,
111
+ "overdue": payload?.overdue,
111
112
  "page": payload?.page,
112
113
  "pageSize": payload?.pageSize,
113
114
  "status": payload?.status,
115
+ "supersedesInvoice": payload?.supersedesInvoice,
114
116
  });
115
117
 
116
118
  const headers = new Headers(compactMap({
package/src/lib/config.ts CHANGED
@@ -61,7 +61,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
61
61
  export const SDK_METADATA = {
62
62
  language: "typescript",
63
63
  openapiDocVersion: "1.0.0",
64
- sdkVersion: "0.4.0",
65
- genVersion: "2.899.0",
66
- userAgent: "speakeasy-sdk/typescript 0.4.0 2.899.0 1.0.0 @clientcasa/sdk",
64
+ sdkVersion: "0.5.0",
65
+ genVersion: "2.900.1",
66
+ userAgent: "speakeasy-sdk/typescript 0.5.0 2.900.1 1.0.0 @clientcasa/sdk",
67
67
  } as const;
package/src/lib/sdks.ts CHANGED
@@ -132,27 +132,55 @@ export class ClientSDK {
132
132
  if (path) {
133
133
  baseURL.pathname = baseURL.pathname.replace(/\/+$/, "") + "/";
134
134
  reqURL = new URL(path, baseURL);
135
+ if (!reqURL.search && baseURL.search) {
136
+ reqURL.search = baseURL.search;
137
+ }
135
138
  } else {
136
139
  reqURL = baseURL;
137
140
  }
138
141
  reqURL.hash = "";
139
142
 
140
- let finalQuery = query || "";
141
-
142
- const secQuery: string[] = [];
143
- for (const [k, v] of Object.entries(security?.queryParams || {})) {
144
- const q = encodeForm(k, v, { charEncoding: "percent" });
145
- if (typeof q !== "undefined") {
146
- secQuery.push(q);
143
+ // Appends already-encoded query pairs to a query string, replacing any
144
+ // existing pairs with the same key so later sources take precedence.
145
+ const mergeQuery = (current: string, additions: string): string => {
146
+ if (!additions) {
147
+ return current;
147
148
  }
148
- }
149
- if (secQuery.length) {
150
- finalQuery += `&${secQuery.join("&")}`;
151
- }
149
+ const additionKeys = new Set(
150
+ additions
151
+ .split("&")
152
+ .filter((pair) => pair !== "")
153
+ .map((pair) => pair.split("=")[0] ?? ""),
154
+ );
155
+ const kept = current.split("&").filter((pair) => {
156
+ return pair !== "" && !additionKeys.has(pair.split("=")[0] ?? "");
157
+ });
158
+ return [...kept, additions].join("&");
159
+ };
160
+
161
+ const encodeQueryRecord = (record: Record<string, unknown>): string => {
162
+ return Object.entries(record)
163
+ .map(([k, v]) => {
164
+ if (v == null) {
165
+ return undefined;
166
+ }
167
+ const value = v;
168
+ return encodeForm(k, value, {
169
+ explode: Array.isArray(value),
170
+ charEncoding: "percent",
171
+ });
172
+ })
173
+ .filter((pair): pair is string => typeof pair !== "undefined")
174
+ .join("&");
175
+ };
176
+
177
+ const finalQuery = [
178
+ query || "",
179
+ encodeQueryRecord(security?.queryParams || {}),
180
+ ].reduce(mergeQuery, reqURL.search.slice(1));
152
181
 
153
182
  if (finalQuery) {
154
- const q = finalQuery.startsWith("&") ? finalQuery.slice(1) : finalQuery;
155
- reqURL.search = `?${q}`;
183
+ reqURL.search = `?${finalQuery}`;
156
184
  }
157
185
 
158
186
  const headers = new Headers(opHeaders);
@@ -4,6 +4,11 @@
4
4
 
5
5
  import * as z from "zod/v4-mini";
6
6
  import { ClosedEnum } from "../types/enums.js";
7
+ import {
8
+ ClientTaxSettings,
9
+ ClientTaxSettings$Outbound,
10
+ ClientTaxSettings$outboundSchema,
11
+ } from "./client-tax-settings.js";
7
12
 
8
13
  export const ClientCreateStatus = {
9
14
  New: "new",
@@ -20,6 +25,8 @@ export type ClientCreate = {
20
25
  name: string;
21
26
  status?: ClientCreateStatus | undefined;
22
27
  notes?: string | undefined;
28
+ taxSettings?: ClientTaxSettings | undefined;
29
+ invoiceRemindersEnabled?: boolean | undefined;
23
30
  };
24
31
 
25
32
  /** @internal */
@@ -32,6 +39,8 @@ export type ClientCreate$Outbound = {
32
39
  name: string;
33
40
  status: string;
34
41
  notes?: string | undefined;
42
+ taxSettings?: ClientTaxSettings$Outbound | undefined;
43
+ invoiceRemindersEnabled?: boolean | undefined;
35
44
  };
36
45
 
37
46
  /** @internal */
@@ -42,6 +51,8 @@ export const ClientCreate$outboundSchema: z.ZodMiniType<
42
51
  name: z.string(),
43
52
  status: z._default(ClientCreateStatus$outboundSchema, "active"),
44
53
  notes: z.optional(z.string()),
54
+ taxSettings: z.optional(ClientTaxSettings$outboundSchema),
55
+ invoiceRemindersEnabled: z.optional(z.boolean()),
45
56
  });
46
57
 
47
58
  export function clientCreateToJSON(clientCreate: ClientCreate): string {
@@ -0,0 +1,58 @@
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 { Result as SafeParseResult } from "../types/fp.js";
8
+ import * as types from "../types/primitives.js";
9
+ import { SDKValidationError } from "./errors/sdk-validation-error.js";
10
+
11
+ export type ClientTaxSettings = {
12
+ defaultTaxable: boolean;
13
+ overrideTaxRate: boolean;
14
+ taxRate: number | null;
15
+ };
16
+
17
+ /** @internal */
18
+ export const ClientTaxSettings$inboundSchema: z.ZodMiniType<
19
+ ClientTaxSettings,
20
+ unknown
21
+ > = z.object({
22
+ defaultTaxable: types.boolean(),
23
+ overrideTaxRate: types.boolean(),
24
+ taxRate: types.nullable(types.number()),
25
+ });
26
+ /** @internal */
27
+ export type ClientTaxSettings$Outbound = {
28
+ defaultTaxable: boolean;
29
+ overrideTaxRate: boolean;
30
+ taxRate: number | null;
31
+ };
32
+
33
+ /** @internal */
34
+ export const ClientTaxSettings$outboundSchema: z.ZodMiniType<
35
+ ClientTaxSettings$Outbound,
36
+ ClientTaxSettings
37
+ > = z.object({
38
+ defaultTaxable: z.boolean(),
39
+ overrideTaxRate: z.boolean(),
40
+ taxRate: z.nullable(z.number()),
41
+ });
42
+
43
+ export function clientTaxSettingsToJSON(
44
+ clientTaxSettings: ClientTaxSettings,
45
+ ): string {
46
+ return JSON.stringify(
47
+ ClientTaxSettings$outboundSchema.parse(clientTaxSettings),
48
+ );
49
+ }
50
+ export function clientTaxSettingsFromJSON(
51
+ jsonString: string,
52
+ ): SafeParseResult<ClientTaxSettings, SDKValidationError> {
53
+ return safeParse(
54
+ jsonString,
55
+ (x) => ClientTaxSettings$inboundSchema.parse(JSON.parse(x)),
56
+ `Failed to parse 'ClientTaxSettings' from JSON`,
57
+ );
58
+ }