@remit/api-zod-schemas 0.0.59 → 0.0.61

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 CHANGED
@@ -8,6 +8,9 @@ Auto-generated Zod schemas from TypeSpec definitions.
8
8
  npm install @remit/api-zod-schemas zod
9
9
  ```
10
10
 
11
+ The schemas run on zod 3.23 and later and on zod 4; the peer range is
12
+ `^3.23.0 || ^4.0.0`.
13
+
11
14
  ## Usage
12
15
 
13
16
  ```typescript
@@ -31,6 +34,7 @@ type CognitoAuthorizer = z.infer<typeof CognitoAuthorizerSchema>;
31
34
  - `CanonicalMailboxRoleSchema` - Enum for CanonicalMailboxRole
32
35
  - `QuarantineFailureStageSchema` - Enum for QuarantineFailureStage
33
36
  - `QuarantineFailureCodeSchema` - Enum for QuarantineFailureCode
37
+ - `SyncWarningStageSchema` - Enum for SyncWarningStage
34
38
  - `AccountConfigStateSchema` - Enum for AccountConfigState
35
39
  - `AccountAuthTypeSchema` - Enum for AccountAuthType
36
40
  - `AccountServiceSchema` - Enum for AccountService
@@ -69,7 +73,6 @@ type CognitoAuthorizer = z.infer<typeof CognitoAuthorizerSchema>;
69
73
  - `MessageSyncStatusSchema` - Enum for MessageSyncStatus
70
74
  - `MessageMutationSchema` - Enum for MessageMutation
71
75
  - `PlacementActionSchema` - Enum for PlacementAction
72
- - `SemanticSearchChunkTypeSchema` - Enum for SemanticSearchChunkType
73
76
  - `OutboxMessageStatusSchema` - Enum for OutboxMessageStatus
74
77
  - `OutboxAttachmentStateSchema` - Enum for OutboxAttachmentState
75
78
  - `OutboxAttachmentRejectionReasonSchema` - Enum for OutboxAttachmentRejectionReason
@@ -99,6 +102,7 @@ type CognitoAuthorizer = z.infer<typeof CognitoAuthorizerSchema>;
99
102
  - `AccountSettingNameSchema` - Enum for AccountSettingName
100
103
  - `ConfigImportStateSchema` - Enum for ConfigImportState
101
104
  - `ConfigImportRefKindSchema` - Enum for ConfigImportRefKind
105
+ - `SyncWarningStateSchema` - Enum for SyncWarningState
102
106
  - `MessagePlacementMoveStateSchema` - Enum for MessagePlacementMoveState
103
107
  - `FlagPushOperationSchema` - Enum for FlagPushOperation
104
108
  - `MessageFlagPushStateSchema` - Enum for MessageFlagPushState
@@ -116,8 +120,9 @@ type CognitoAuthorizer = z.infer<typeof CognitoAuthorizerSchema>;
116
120
  - `AppointFolderRoleConflictSchema` - AppointFolderRoleConflict model
117
121
  - `MailboxNotSettledSchema` - MailboxNotSettled model
118
122
  - `PreconditionFailedErrorSchema` - PreconditionFailedError model
119
- - `DeleteMessagesConflictSchema` - DeleteMessagesConflict model
123
+ - `MessageNotFoundErrorSchema` - MessageNotFoundError model
120
124
  - `MessagePlacementConflictSchema` - MessagePlacementConflict model
125
+ - `DeleteMessagesConflictSchema` - DeleteMessagesConflict model
121
126
  - `AmazonApiGatewayIntegrationSchema` - AmazonApiGatewayIntegration model
122
127
  - `InternalServerErrorSchema` - InternalServerError model
123
128
  - `DeleteMeInputSchema` - DeleteMeInput model
@@ -131,6 +136,8 @@ type CognitoAuthorizer = z.infer<typeof CognitoAuthorizerSchema>;
131
136
  - `QuarantineSchema` - Quarantine model
132
137
  - `QuarantineMimeNodeSchema` - QuarantineMimeNode model
133
138
  - `QuarantineResponseSchema` - QuarantineResponse model
139
+ - `SyncWarningSchema` - SyncWarning model
140
+ - `SyncWarningResponseSchema` - SyncWarningResponse model
134
141
  - `ConfigDescriptionResponseSchema` - ConfigDescriptionResponse model
135
142
  - `AccountConfigSchema` - AccountConfig model
136
143
  - `AccountConfigResponseSchema` - AccountConfigResponse model
@@ -151,6 +158,7 @@ type CognitoAuthorizer = z.infer<typeof CognitoAuthorizerSchema>;
151
158
  - `ApplyUpdateInputSchema` - ApplyUpdateInput model
152
159
  - `MailboxSchema` - Mailbox model
153
160
  - `MailboxResponseSchema` - MailboxResponse model
161
+ - `MailboxListResponseSchema` - MailboxListResponse model
154
162
  - `CreateMailboxInputSchema` - CreateMailboxInput model
155
163
  - `RenameMailboxInputSchema` - RenameMailboxInput model
156
164
  - `AppointFolderRoleInputSchema` - AppointFolderRoleInput model
@@ -203,13 +211,14 @@ type CognitoAuthorizer = z.infer<typeof CognitoAuthorizerSchema>;
203
211
  - `AutoMovedInfoSchema` - AutoMovedInfo model
204
212
  - `LabelSummaryResponseSchema` - LabelSummaryResponse model
205
213
  - `MessageSpamReportSchema` - MessageSpamReport model
214
+ - `ThreadMessageListResponseSchema` - ThreadMessageListResponse model
206
215
  - `ThreadSearchResponseSchema` - ThreadSearchResponse model
207
- - `SemanticSearchResultSchema` - SemanticSearchResult model
208
216
  - `CreateOutboxMessageInputSchema` - CreateOutboxMessageInput model
209
217
  - `OutboxMessageSchema` - OutboxMessage model
210
218
  - `OutboxMessageResponseSchema` - OutboxMessageResponse model
211
219
  - `OutboxAttachmentSchema` - OutboxAttachment model
212
220
  - `OutboxAttachmentResponseSchema` - OutboxAttachmentResponse model
221
+ - `OutboxMessageListResponseSchema` - OutboxMessageListResponse model
213
222
  - `UpdateOutboxMessageInputSchema` - UpdateOutboxMessageInput model
214
223
  - `MintOutboxAttachmentInputSchema` - MintOutboxAttachmentInput model
215
224
  - `MintOutboxAttachmentResponseSchema` - MintOutboxAttachmentResponse model
@@ -230,11 +239,12 @@ type CognitoAuthorizer = z.infer<typeof CognitoAuthorizerSchema>;
230
239
  - `UpdateAddressInputSchema` - UpdateAddressInput model
231
240
  - `UpdateAddressFlagsInputSchema` - UpdateAddressFlagsInput model
232
241
  - `DescribeMessageResponseSchema` - DescribeMessageResponse model
233
- - `MessageSchema` - Message model
242
+ - `MessageRecordSchema` - MessageRecord model
234
243
  - `MessageAuthResultSchema` - MessageAuthResult model
235
244
  - `MessageProviderSpamSchema` - MessageProviderSpam model
236
245
  - `MessagePlacementVerdictSchema` - MessagePlacementVerdict model
237
246
  - `MessageFilterMoveSchema` - MessageFilterMove model
247
+ - `MessageSchema` - Message model
238
248
  - `MessageSummaryResponseSchema` - MessageSummaryResponse model
239
249
  - `EnvelopeResponseSchema` - EnvelopeResponse model
240
250
  - `EnvelopeAddressResponseSchema` - EnvelopeAddressResponse model
@@ -278,16 +288,35 @@ type CognitoAuthorizer = z.infer<typeof CognitoAuthorizerSchema>;
278
288
  - `EnvelopeSchema` - Envelope model
279
289
  - `SenderSignerStandingSchema` - SenderSignerStanding model
280
290
  - `BodyPartParameterSchema` - BodyPartParameter model
291
+ - `BodyStructureRefetchSchema` - BodyStructureRefetch model
281
292
  - `RawMessageStorageSchema` - RawMessageStorage model
282
293
  - `BodyPartStorageSchema` - BodyPartStorage model
283
- - `BodyPartContentSchema` - BodyPartContent model
284
294
  - `CalendarEventIndexSchema` - CalendarEventIndex model
285
295
  - `CalendarFeedTokenSchema` - CalendarFeedToken model
286
296
  - `MessageLabelSchema` - MessageLabel model
287
- - `FilterAnchorSchema` - FilterAnchor model
288
297
  - `MicrosoftOAuthStartRequestSchema` - MicrosoftOAuthStartRequest model
289
298
  - `MicrosoftOAuthStartResponseSchema` - MicrosoftOAuthStartResponse model
290
299
 
300
+ ## Request Validation
301
+
302
+ `@remit/api-zod-schemas/middleware` carries the operation map and a request-validation
303
+ middleware for an openapi-generator `typescript-fetch` client. Attach it to the
304
+ client configuration and every JSON request body is validated against its
305
+ operation schema before the request is sent.
306
+
307
+ ```typescript
308
+ import { Configuration, DefaultApi } from "./generated-client";
309
+ import { validationMiddleware } from "@remit/api-zod-schemas/middleware";
310
+
311
+ const api = new DefaultApi(
312
+ new Configuration({ basePath, middleware: [validationMiddleware] }),
313
+ );
314
+ ```
315
+
316
+ An invalid body rejects with a `RequestValidationError` carrying the zod
317
+ `issues`. Use `createValidationMiddleware({ validate: false })` to attach the
318
+ middleware with validation turned off.
319
+
291
320
  ## Generated by
292
321
 
293
322
  This package was generated using [@kattebak/typespec-zod-emitter](https://github.com/kattebak/typespec-zod-emitter).
@@ -0,0 +1,43 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Package: @remit/api-zod-schemas
4
+ * Version: 0.0.1
5
+ */
6
+ export interface OperationSchemas {
7
+ readonly operationId: string;
8
+ readonly method: string;
9
+ readonly path: string;
10
+ readonly pattern: RegExp;
11
+ readonly pathParameterNames: readonly string[];
12
+ readonly body?: z.ZodTypeAny;
13
+ readonly parameters: {
14
+ readonly path?: z.ZodTypeAny;
15
+ readonly query?: z.ZodTypeAny;
16
+ readonly header?: z.ZodTypeAny;
17
+ readonly cookie?: z.ZodTypeAny;
18
+ };
19
+ }
20
+ export declare const operations: readonly OperationSchemas[];
21
+ export interface RequestContext {
22
+ url: string;
23
+ init: RequestInit;
24
+ }
25
+ export interface ValidationMiddleware {
26
+ pre(context: RequestContext): Promise<void>;
27
+ }
28
+ export interface ValidationMiddlewareOptions {
29
+ validate?: boolean;
30
+ }
31
+ export declare class RequestValidationError extends Error {
32
+ readonly operationId: string;
33
+ readonly method: string;
34
+ readonly url: string;
35
+ readonly error: z.ZodError;
36
+ readonly name = "RequestValidationError";
37
+ readonly issues: z.ZodIssue[];
38
+ constructor(operationId: string, method: string, url: string, error: z.ZodError);
39
+ }
40
+ export declare function findOperation(method: string, url: string): OperationSchemas | undefined;
41
+ export declare function createValidationMiddleware(options?: ValidationMiddlewareOptions): ValidationMiddleware;
42
+ export declare const validationMiddleware: ValidationMiddleware;
43
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA4CxB;;;GAGG;AAEH,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C,QAA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