@effect/platform 0.71.1 → 0.71.3

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.
@@ -48,6 +48,30 @@ export const AnnotationParam: unique symbol = Symbol.for(
48
48
  "@effect/platform/HttpApiSchema/AnnotationParam"
49
49
  )
50
50
 
51
+ /**
52
+ * @since 1.0.0
53
+ * @category annotations
54
+ */
55
+ export const extractAnnotations = (ast: AST.Annotations): AST.Annotations => {
56
+ const result: Record<symbol, unknown> = {}
57
+ if (AnnotationStatus in ast) {
58
+ result[AnnotationStatus] = ast[AnnotationStatus]
59
+ }
60
+ if (AnnotationEmptyDecodeable in ast) {
61
+ result[AnnotationEmptyDecodeable] = ast[AnnotationEmptyDecodeable]
62
+ }
63
+ if (AnnotationEncoding in ast) {
64
+ result[AnnotationEncoding] = ast[AnnotationEncoding]
65
+ }
66
+ if (AnnotationParam in ast) {
67
+ result[AnnotationParam] = ast[AnnotationParam]
68
+ }
69
+ if (AnnotationMultipart in ast) {
70
+ result[AnnotationMultipart] = ast[AnnotationMultipart]
71
+ }
72
+ return result
73
+ }
74
+
51
75
  const mergedAnnotations = (ast: AST.AST): Record<symbol, unknown> =>
52
76
  ast._tag === "Transformation" ?
53
77
  {
@@ -4,7 +4,6 @@
4
4
  import * as JSONSchema from "effect/JSONSchema"
5
5
  import * as Record from "effect/Record"
6
6
  import type * as Schema from "effect/Schema"
7
- import type * as AST from "effect/SchemaAST"
8
7
 
9
8
  /**
10
9
  * @category model
@@ -24,6 +23,7 @@ export interface Annotations {
24
23
  export interface Never extends Annotations {
25
24
  $id: "/schemas/never"
26
25
  not: {}
26
+ nullable?: boolean
27
27
  }
28
28
 
29
29
  /**
@@ -60,6 +60,7 @@ export interface AnyObject extends Annotations {
60
60
  { type: "object" },
61
61
  { type: "array" }
62
62
  ]
63
+ nullable?: boolean
63
64
  }
64
65
 
65
66
  /**
@@ -72,6 +73,7 @@ export interface Empty extends Annotations {
72
73
  { type: "object" },
73
74
  { type: "array" }
74
75
  ]
76
+ nullable?: boolean
75
77
  }
76
78
 
77
79
  /**
@@ -80,6 +82,7 @@ export interface Empty extends Annotations {
80
82
  */
81
83
  export interface Ref extends Annotations {
82
84
  $ref: string
85
+ nullable?: boolean
83
86
  }
84
87
 
85
88
  /**
@@ -99,6 +102,7 @@ export interface String extends Annotations {
99
102
  maxLength?: number
100
103
  pattern?: string
101
104
  }>
105
+ nullable?: boolean
102
106
  }
103
107
 
104
108
  /**
@@ -119,6 +123,7 @@ export interface Numeric extends Annotations {
119
123
  exclusiveMaximum?: number
120
124
  multipleOf?: number
121
125
  }>
126
+ nullable?: boolean
122
127
  }
123
128
 
124
129
  /**
@@ -143,6 +148,7 @@ export interface Integer extends Numeric {
143
148
  */
144
149
  export interface Boolean extends Annotations {
145
150
  type: "boolean"
151
+ nullable?: boolean
146
152
  }
147
153
 
148
154
  /**
@@ -155,6 +161,7 @@ export interface Array extends Annotations {
155
161
  minItems?: number
156
162
  maxItems?: number
157
163
  additionalItems?: JsonSchema | boolean
164
+ nullable?: boolean
158
165
  }
159
166
 
160
167
  /**
@@ -162,7 +169,9 @@ export interface Array extends Annotations {
162
169
  * @since 1.0.0
163
170
  */
164
171
  export interface Enum extends Annotations {
165
- enum: globalThis.Array<AST.LiteralValue>
172
+ type?: "string" | "number" | "boolean"
173
+ enum: globalThis.Array<string | number | boolean | null>
174
+ nullable?: boolean
166
175
  }
167
176
 
168
177
  /**
@@ -172,9 +181,11 @@ export interface Enum extends Annotations {
172
181
  export interface Enums extends Annotations {
173
182
  $comment: "/schemas/enums"
174
183
  anyOf: globalThis.Array<{
184
+ type: "string" | "number"
175
185
  title: string
176
186
  enum: [string | number]
177
187
  }>
188
+ nullable?: boolean
178
189
  }
179
190
 
180
191
  /**
@@ -183,6 +194,7 @@ export interface Enums extends Annotations {
183
194
  */
184
195
  export interface AnyOf extends Annotations {
185
196
  anyOf: globalThis.Array<JsonSchema>
197
+ nullable?: boolean
186
198
  }
187
199
 
188
200
  /**
@@ -196,6 +208,7 @@ export interface Object extends Annotations {
196
208
  additionalProperties?: boolean | JsonSchema
197
209
  patternProperties?: Record<string, JsonSchema>
198
210
  propertyNames?: JsonSchema
211
+ nullable?: boolean
199
212
  }
200
213
 
201
214
  /**
@@ -254,14 +267,15 @@ export const make = <A, I, R>(schema: Schema.Schema<A, I, R>): Root => {
254
267
  * @since 1.0.0
255
268
  */
256
269
  export const makeWithDefs = <A, I, R>(schema: Schema.Schema<A, I, R>, options: {
257
- readonly defs: Record<string, JsonSchema>
270
+ readonly defs: Record<string, any>
258
271
  readonly defsPath?: string
259
272
  readonly topLevelReferenceStrategy?: "skip" | "keep"
260
273
  }): JsonSchema => {
261
- return JSONSchema.fromAST(schema.ast, {
274
+ const jsonSchema = JSONSchema.fromAST(schema.ast, {
262
275
  definitions: options.defs,
263
276
  definitionPath: options.defsPath ?? "#/components/schemas/",
264
277
  target: "openApi3.1",
265
278
  topLevelReferenceStrategy: options.topLevelReferenceStrategy ?? "keep"
266
279
  })
280
+ return jsonSchema as JsonSchema
267
281
  }