@remit/api-zod-schemas 0.0.60 → 0.0.62
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 +34 -5
- package/middleware.d.ts +43 -0
- package/middleware.d.ts.map +1 -0
- package/middleware.js +801 -0
- package/middleware.js.map +1 -0
- package/middleware.ts +918 -0
- package/package.json +6 -2
- package/schemas.d.ts +1779 -457
- package/schemas.d.ts.map +1 -1
- package/schemas.js +494 -457
- package/schemas.js.map +1 -1
- package/schemas.ts +504 -461
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
|
|
@@ -132,6 +136,8 @@ type CognitoAuthorizer = z.infer<typeof CognitoAuthorizerSchema>;
|
|
|
132
136
|
- `QuarantineSchema` - Quarantine model
|
|
133
137
|
- `QuarantineMimeNodeSchema` - QuarantineMimeNode model
|
|
134
138
|
- `QuarantineResponseSchema` - QuarantineResponse model
|
|
139
|
+
- `SyncWarningSchema` - SyncWarning model
|
|
140
|
+
- `SyncWarningResponseSchema` - SyncWarningResponse model
|
|
135
141
|
- `ConfigDescriptionResponseSchema` - ConfigDescriptionResponse model
|
|
136
142
|
- `AccountConfigSchema` - AccountConfig model
|
|
137
143
|
- `AccountConfigResponseSchema` - AccountConfigResponse model
|
|
@@ -152,6 +158,7 @@ type CognitoAuthorizer = z.infer<typeof CognitoAuthorizerSchema>;
|
|
|
152
158
|
- `ApplyUpdateInputSchema` - ApplyUpdateInput model
|
|
153
159
|
- `MailboxSchema` - Mailbox model
|
|
154
160
|
- `MailboxResponseSchema` - MailboxResponse model
|
|
161
|
+
- `MailboxListResponseSchema` - MailboxListResponse model
|
|
155
162
|
- `CreateMailboxInputSchema` - CreateMailboxInput model
|
|
156
163
|
- `RenameMailboxInputSchema` - RenameMailboxInput model
|
|
157
164
|
- `AppointFolderRoleInputSchema` - AppointFolderRoleInput model
|
|
@@ -204,13 +211,14 @@ type CognitoAuthorizer = z.infer<typeof CognitoAuthorizerSchema>;
|
|
|
204
211
|
- `AutoMovedInfoSchema` - AutoMovedInfo model
|
|
205
212
|
- `LabelSummaryResponseSchema` - LabelSummaryResponse model
|
|
206
213
|
- `MessageSpamReportSchema` - MessageSpamReport model
|
|
214
|
+
- `ThreadMessageListResponseSchema` - ThreadMessageListResponse model
|
|
207
215
|
- `ThreadSearchResponseSchema` - ThreadSearchResponse model
|
|
208
|
-
- `SemanticSearchResultSchema` - SemanticSearchResult model
|
|
209
216
|
- `CreateOutboxMessageInputSchema` - CreateOutboxMessageInput model
|
|
210
217
|
- `OutboxMessageSchema` - OutboxMessage model
|
|
211
218
|
- `OutboxMessageResponseSchema` - OutboxMessageResponse model
|
|
212
219
|
- `OutboxAttachmentSchema` - OutboxAttachment model
|
|
213
220
|
- `OutboxAttachmentResponseSchema` - OutboxAttachmentResponse model
|
|
221
|
+
- `OutboxMessageListResponseSchema` - OutboxMessageListResponse model
|
|
214
222
|
- `UpdateOutboxMessageInputSchema` - UpdateOutboxMessageInput model
|
|
215
223
|
- `MintOutboxAttachmentInputSchema` - MintOutboxAttachmentInput model
|
|
216
224
|
- `MintOutboxAttachmentResponseSchema` - MintOutboxAttachmentResponse model
|
|
@@ -231,11 +239,12 @@ type CognitoAuthorizer = z.infer<typeof CognitoAuthorizerSchema>;
|
|
|
231
239
|
- `UpdateAddressInputSchema` - UpdateAddressInput model
|
|
232
240
|
- `UpdateAddressFlagsInputSchema` - UpdateAddressFlagsInput model
|
|
233
241
|
- `DescribeMessageResponseSchema` - DescribeMessageResponse model
|
|
234
|
-
- `
|
|
242
|
+
- `MessageRecordSchema` - MessageRecord model
|
|
235
243
|
- `MessageAuthResultSchema` - MessageAuthResult model
|
|
236
244
|
- `MessageProviderSpamSchema` - MessageProviderSpam model
|
|
237
245
|
- `MessagePlacementVerdictSchema` - MessagePlacementVerdict model
|
|
238
246
|
- `MessageFilterMoveSchema` - MessageFilterMove model
|
|
247
|
+
- `MessageSchema` - Message model
|
|
239
248
|
- `MessageSummaryResponseSchema` - MessageSummaryResponse model
|
|
240
249
|
- `EnvelopeResponseSchema` - EnvelopeResponse model
|
|
241
250
|
- `EnvelopeAddressResponseSchema` - EnvelopeAddressResponse model
|
|
@@ -279,16 +288,36 @@ type CognitoAuthorizer = z.infer<typeof CognitoAuthorizerSchema>;
|
|
|
279
288
|
- `EnvelopeSchema` - Envelope model
|
|
280
289
|
- `SenderSignerStandingSchema` - SenderSignerStanding model
|
|
281
290
|
- `BodyPartParameterSchema` - BodyPartParameter model
|
|
291
|
+
- `BodyStructureRefetchSchema` - BodyStructureRefetch model
|
|
292
|
+
- `MessageSearchTextSchema` - MessageSearchText model
|
|
282
293
|
- `RawMessageStorageSchema` - RawMessageStorage model
|
|
283
294
|
- `BodyPartStorageSchema` - BodyPartStorage model
|
|
284
|
-
- `BodyPartContentSchema` - BodyPartContent model
|
|
285
295
|
- `CalendarEventIndexSchema` - CalendarEventIndex model
|
|
286
296
|
- `CalendarFeedTokenSchema` - CalendarFeedToken model
|
|
287
297
|
- `MessageLabelSchema` - MessageLabel model
|
|
288
|
-
- `FilterAnchorSchema` - FilterAnchor model
|
|
289
298
|
- `MicrosoftOAuthStartRequestSchema` - MicrosoftOAuthStartRequest model
|
|
290
299
|
- `MicrosoftOAuthStartResponseSchema` - MicrosoftOAuthStartResponse model
|
|
291
300
|
|
|
301
|
+
## Request Validation
|
|
302
|
+
|
|
303
|
+
`@remit/api-zod-schemas/middleware` carries the operation map and a request-validation
|
|
304
|
+
middleware for an openapi-generator `typescript-fetch` client. Attach it to the
|
|
305
|
+
client configuration and every JSON request body is validated against its
|
|
306
|
+
operation schema before the request is sent.
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
import { Configuration, DefaultApi } from "./generated-client";
|
|
310
|
+
import { validationMiddleware } from "@remit/api-zod-schemas/middleware";
|
|
311
|
+
|
|
312
|
+
const api = new DefaultApi(
|
|
313
|
+
new Configuration({ basePath, middleware: [validationMiddleware] }),
|
|
314
|
+
);
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
An invalid body rejects with a `RequestValidationError` carrying the zod
|
|
318
|
+
`issues`. Use `createValidationMiddleware({ validate: false })` to attach the
|
|
319
|
+
middleware with validation turned off.
|
|
320
|
+
|
|
292
321
|
## Generated by
|
|
293
322
|
|
|
294
323
|
This package was generated using [@kattebak/typespec-zod-emitter](https://github.com/kattebak/typespec-zod-emitter).
|
package/middleware.d.ts
ADDED
|
@@ -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,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE;QACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC;QAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC;QAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC;QAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC;KA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