@effect/platform 0.65.5 → 0.66.1

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.
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../dist/cjs/OpenApiJsonSchema.js",
3
+ "module": "../dist/esm/OpenApiJsonSchema.js",
4
+ "types": "../dist/dts/OpenApiJsonSchema.d.ts",
5
+ "sideEffects": []
6
+ }
package/README.md CHANGED
@@ -837,6 +837,34 @@ Output:
837
837
  */
838
838
  ```
839
839
 
840
+ ### Persisting Cookies
841
+
842
+ You can manage cookies across requests using the `HttpClient.withCookiesRef` function, which associates a reference to a `Cookies` object with the client.
843
+
844
+ ```ts
845
+ import { Cookies, FetchHttpClient, HttpClient } from "@effect/platform"
846
+ import { Effect, Ref } from "effect"
847
+
848
+ const program = Effect.gen(function* () {
849
+ // Create a reference to store cookies
850
+ const ref = yield* Ref.make(Cookies.empty)
851
+
852
+ // Access the HttpClient and associate the cookies reference with it
853
+ const client = (yield* HttpClient.HttpClient).pipe(
854
+ HttpClient.withCookiesRef(ref)
855
+ )
856
+
857
+ // Make a GET request to the specified URL
858
+ yield* client.get("https://www.google.com/")
859
+
860
+ // Log the keys of the cookies stored in the reference
861
+ console.log(Object.keys((yield* ref).cookies))
862
+ }).pipe(Effect.scoped, Effect.provide(FetchHttpClient.layer))
863
+
864
+ Effect.runPromise(program)
865
+ // Output: [ 'SOCS', 'AEC', '__Secure-ENID' ]
866
+ ```
867
+
840
868
  ## RequestInit Options
841
869
 
842
870
  You can customize the `HttpClient` by passing `RequestInit` options to configure aspects of the HTTP requests, such as credentials, headers, and more.
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.fromApi = exports.annotations = exports.annotate = exports.Version = exports.Title = exports.Security = exports.License = exports.Identifier = exports.ExternalDocs = exports.Description = void 0;
7
7
  var AST = _interopRequireWildcard(require("@effect/schema/AST"));
8
- var JSONSchema = _interopRequireWildcard(require("@effect/schema/JSONSchema"));
9
8
  var Schema = _interopRequireWildcard(require("@effect/schema/Schema"));
10
9
  var Context = _interopRequireWildcard(require("effect/Context"));
11
10
  var _Function = require("effect/Function");
@@ -13,6 +12,7 @@ var Option = _interopRequireWildcard(require("effect/Option"));
13
12
  var HttpApi = _interopRequireWildcard(require("./HttpApi.js"));
14
13
  var HttpApiSchema = _interopRequireWildcard(require("./HttpApiSchema.js"));
15
14
  var HttpMethod = _interopRequireWildcard(require("./HttpMethod.js"));
15
+ var JsonSchema = _interopRequireWildcard(require("./OpenApiJsonSchema.js"));
16
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
18
  /**
@@ -198,7 +198,7 @@ const fromApi = api => {
198
198
  op.requestBody = {
199
199
  content: {
200
200
  [HttpApiSchema.getMultipart(schema.ast) ? "multipart/form-data" : "application/json"]: {
201
- schema: makeJsonSchema(schema)
201
+ schema: JsonSchema.make(schema)
202
202
  }
203
203
  },
204
204
  required: true
@@ -207,12 +207,12 @@ const fromApi = api => {
207
207
  successAST.pipe(Option.map(ast => {
208
208
  op.responses[successStatus].content = {
209
209
  [successEncoding.contentType]: {
210
- schema: makeJsonSchema(Schema.make(ast))
210
+ schema: JsonSchema.make(Schema.make(ast))
211
211
  }
212
212
  };
213
213
  }));
214
214
  if (Option.isSome(endpoint.pathSchema)) {
215
- const schema = makeJsonSchema(endpoint.pathSchema.value);
215
+ const schema = JsonSchema.make(endpoint.pathSchema.value);
216
216
  if ("properties" in schema) {
217
217
  Object.entries(schema.properties).forEach(([name, jsonSchema]) => {
218
218
  op.parameters.push({
@@ -225,7 +225,7 @@ const fromApi = api => {
225
225
  }
226
226
  }
227
227
  if (!HttpMethod.hasBody(endpoint.method) && Option.isSome(endpoint.payloadSchema)) {
228
- const schema = makeJsonSchema(endpoint.payloadSchema.value);
228
+ const schema = JsonSchema.make(endpoint.payloadSchema.value);
229
229
  if ("properties" in schema) {
230
230
  Object.entries(schema.properties).forEach(([name, jsonSchema]) => {
231
231
  op.parameters.push({
@@ -238,7 +238,7 @@ const fromApi = api => {
238
238
  }
239
239
  }
240
240
  if (Option.isSome(endpoint.headersSchema)) {
241
- const schema = makeJsonSchema(endpoint.headersSchema.value);
241
+ const schema = JsonSchema.make(endpoint.headersSchema.value);
242
242
  if ("properties" in schema) {
243
243
  Object.entries(schema.properties).forEach(([name, jsonSchema]) => {
244
244
  op.parameters.push({
@@ -258,7 +258,7 @@ const fromApi = api => {
258
258
  ast.pipe(Option.filter(ast => !HttpApiSchema.getEmptyDecodeable(ast)), Option.map(ast => {
259
259
  op.responses[status].content = {
260
260
  "application/json": {
261
- schema: makeJsonSchema(Schema.make(ast))
261
+ schema: JsonSchema.make(Schema.make(ast))
262
262
  }
263
263
  };
264
264
  }));
@@ -309,9 +309,4 @@ const getDescriptionOrIdentifier = ast => ast.pipe(Option.map(ast => "to" in ast
309
309
  ...ast.to.annotations,
310
310
  ...ast.annotations
311
311
  } : ast.annotations), Option.flatMapNullable(annotations => annotations[AST.DescriptionAnnotationId] ?? annotations[AST.IdentifierAnnotationId]));
312
- const makeJsonSchema = schema => {
313
- const jsonSchema = JSONSchema.make(schema);
314
- delete jsonSchema.$schema;
315
- return jsonSchema;
316
- };
317
312
  //# sourceMappingURL=OpenApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OpenApi.js","names":["AST","_interopRequireWildcard","require","JSONSchema","Schema","Context","_Function","Option","HttpApi","HttpApiSchema","HttpMethod","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Identifier","Tag","exports","Title","Version","Description","License","Security","ExternalDocs","annotations","context","empty","identifier","undefined","add","title","description","version","license","security","externalDocs","annotate","dual","self","annotations_","base","setPrototypeOf","getPrototypeOf","merge","assign","fromApi","api","spec","openapi","info","getOrElse","paths","tags","components","schemas","securitySchemes","securityMap","Map","securityCount","registerSecurity","count","id","_tag","scheme","makeSecurityScheme","map","getOption","apiSecurity","push","reflect","onGroup","group","tag","name","onEndpoint","endpoint","errors","mergedAnnotations","successAST","successEncoding","successStatus","path","replace","method","toLowerCase","op","operationId","parameters","responses","getDescriptionOrIdentifier","payloadSchema","pipe","filter","hasBody","schema","requestBody","content","getMultipart","ast","makeJsonSchema","required","contentType","make","isSome","pathSchema","value","entries","properties","forEach","jsonSchema","in","includes","headersSchema","status","getEmptyDecodeable","meta","type","key","to","flatMapNullable","DescriptionAnnotationId","IdentifierAnnotationId","$schema"],"sources":["../../src/OpenApi.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,uBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAJ,uBAAA,CAAAC,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAN,uBAAA,CAAAC,OAAA;AAGA,IAAAM,OAAA,GAAAP,uBAAA,CAAAC,OAAA;AACA,IAAAO,aAAA,GAAAR,uBAAA,CAAAC,OAAA;AAEA,IAAAQ,UAAA,GAAAT,uBAAA,CAAAC,OAAA;AAA6C,SAAAS,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD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W;EAChC,CAAC,CAAC;EACF,QAAQG,QAAQ,CAAC4B,IAAI;IACnB,KAAK,OAAO;MAAE;QACZ,OAAO;UACL,GAAGqD,IAAI;UACPC,IAAI,EAAE,MAAM;UACZrD,MAAM,EAAE;SACT;MACH;IACA,KAAK,QAAQ;MAAE;QACb,OAAO;UACL,GAAGoD,IAAI;UACPC,IAAI,EAAE,MAAM;UACZrD,MAAM,EAAE;SACT;MACH;IACA,KAAK,QAAQ;MAAE;QACb,OAAO;UACL,GAAGoD,IAAI;UACPC,IAAI,EAAE,QAAQ;UACd3C,IAAI,EAAEvC,QAAQ,CAACmF,GAAG;UAClBP,EAAE,EAAE5E,QAAQ,CAAC4E;SACd;MACH;EACF;AACF,CAAC;AAED,MAAMrB,0BAA0B,GAAIS,GAAmD,IACrFA,GAAG,CAACP,IAAI,CACNpG,MAAM,CAAC0E,GAAG,CAAEiC,GAAG,IACb,IAAI,IAAIA,GAAG,GACT;EACE,GAAGA,GAAG,CAACoB,EAAE,CAAC9F,WAAW;EACrB,GAAG0E,GAAG,CAAC1E;CACR,GACD0E,GAAG,CAAC1E,WAAW,CAClB,EACDjC,MAAM,CAACgI,eAAe,CAAE/F,WAAW,IACjCA,WAAW,CAACxC,GAAG,CAACwI,uBAAuB,CAAC,IAAIhG,WAAW,CAACxC,GAAG,CAACyI,sBAAsB,CAAQ,CAC3F,CACF;AAEH,MAAMtB,cAAc,GAAIL,MAAyB,IAAuB;EACtE,MAAMe,UAAU,GAAG1H,UAAU,CAACmH,IAAI,CAACR,MAAa,CAAC;EACjD,OAAOe,UAAU,CAACa,OAAO;EACzB,OAAOb,UAAU;AACnB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"OpenApi.js","names":["AST","_interopRequireWildcard","require","Schema","Context","_Function","Option","HttpApi","HttpApiSchema","HttpMethod","JsonSchema","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Identifier","Tag","exports","Title","Version","Description","License","Security","ExternalDocs","annotations","context","empty","identifier","undefined","add","title","description","version","license","security","externalDocs","annotate","dual","self","annotations_","base","setPrototypeOf","getPrototypeOf","merge","assign","fromApi","api","spec","openapi","info","getOrElse","paths","tags","components","schemas","securitySchemes","securityMap","Map","securityCount","registerSecurity","count","id","_tag","scheme","makeSecurityScheme","map","getOption","apiSecurity","push","reflect","onGroup","group","tag","name","onEndpoint","endpoint","errors","mergedAnnotations","successAST","successEncoding","successStatus","path","replace","method","toLowerCase","op","operationId","parameters","responses","getDescriptionOrIdentifier","payloadSchema","pipe","filter","hasBody","schema","requestBody","content","getMultipart","ast","make","required","contentType","isSome","pathSchema","value","entries","properties","forEach","jsonSchema","in","includes","headersSchema","status","getEmptyDecodeable","meta","type","key","to","flatMapNullable","DescriptionAnnotationId","IdentifierAnnotationId"],"sources":["../../src/OpenApi.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,uBAAA,CAAAC,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAL,uBAAA,CAAAC,OAAA;AAGA,IAAAK,OAAA,GAAAN,uBAAA,CAAAC,OAAA;AACA,IAAAM,aAAA,GAAAP,uBAAA,CAAAC,OAAA;AAEA,IAAAO,UAAA,GAAAR,uBAAA,CAAAC,OAAA;AACA,IAAAQ,UAAA,GAAAT,uBAAA,CAAAC,OAAA;AAAoD,SAAAS,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAA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PC,IAAI,EAAE,MAAM;UACZpD,MAAM,EAAE;SACT;MACH;IACA,KAAK,QAAQ;MAAE;QACb,OAAO;UACL,GAAGmD,IAAI;UACPC,IAAI,EAAE,MAAM;UACZpD,MAAM,EAAE;SACT;MACH;IACA,KAAK,QAAQ;MAAE;QACb,OAAO;UACL,GAAGmD,IAAI;UACPC,IAAI,EAAE,QAAQ;UACd1C,IAAI,EAAEvC,QAAQ,CAACkF,GAAG;UAClBP,EAAE,EAAE3E,QAAQ,CAAC2E;SACd;MACH;EACF;AACF,CAAC;AAED,MAAMpB,0BAA0B,GAAIS,GAAmD,IACrFA,GAAG,CAACP,IAAI,CACNrG,MAAM,CAAC2E,GAAG,CAAEiC,GAAG,IACb,IAAI,IAAIA,GAAG,GACT;EACE,GAAGA,GAAG,CAACmB,EAAE,CAAC7F,WAAW;EACrB,GAAG0E,GAAG,CAAC1E;CACR,GACD0E,GAAG,CAAC1E,WAAW,CAClB,EACDlC,MAAM,CAACgI,eAAe,CAAE9F,WAAW,IACjCA,WAAW,CAACxC,GAAG,CAACuI,uBAAuB,CAAC,IAAI/F,WAAW,CAACxC,GAAG,CAACwI,sBAAsB,CAAQ,CAC3F,CACF","ignoreList":[]}
@@ -0,0 +1,479 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.make = void 0;
7
+ var AST = _interopRequireWildcard(require("@effect/schema/AST"));
8
+ var Arr = _interopRequireWildcard(require("effect/Array"));
9
+ var Option = _interopRequireWildcard(require("effect/Option"));
10
+ var Predicate = _interopRequireWildcard(require("effect/Predicate"));
11
+ var Record = _interopRequireWildcard(require("effect/Record"));
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ /**
15
+ * @since 1.0.0
16
+ */
17
+
18
+ /**
19
+ * @category encoding
20
+ * @since 1.0.0
21
+ */
22
+ const make = schema => {
23
+ const $defs = {};
24
+ const out = go(schema.ast, $defs, true, []);
25
+ // clean up self-referencing entries
26
+ for (const id in $defs) {
27
+ if ($defs[id]["$ref"] === get$ref(id)) {
28
+ delete $defs[id];
29
+ }
30
+ }
31
+ if (!Record.isEmptyRecord($defs)) {
32
+ out.$defs = $defs;
33
+ }
34
+ return out;
35
+ };
36
+ exports.make = make;
37
+ const constAny = {
38
+ $id: "/schemas/any"
39
+ };
40
+ const constUnknown = {
41
+ $id: "/schemas/unknown"
42
+ };
43
+ const constVoid = {
44
+ $id: "/schemas/void"
45
+ };
46
+ const constAnyObject = {
47
+ "$id": "/schemas/object",
48
+ "anyOf": [{
49
+ "type": "object"
50
+ }, {
51
+ "type": "array"
52
+ }]
53
+ };
54
+ const constEmpty = {
55
+ "$id": "/schemas/{}",
56
+ "anyOf": [{
57
+ "type": "object"
58
+ }, {
59
+ "type": "array"
60
+ }]
61
+ };
62
+ const getJsonSchemaAnnotations = annotated => Record.getSomes({
63
+ description: AST.getDescriptionAnnotation(annotated),
64
+ title: AST.getTitleAnnotation(annotated),
65
+ examples: AST.getExamplesAnnotation(annotated),
66
+ default: AST.getDefaultAnnotation(annotated)
67
+ });
68
+ const pruneUndefinedKeyword = ps => {
69
+ const type = ps.type;
70
+ if (AST.isUnion(type) && Option.isNone(AST.getJSONSchemaAnnotation(type))) {
71
+ const types = type.types.filter(type => !AST.isUndefinedKeyword(type));
72
+ if (types.length < type.types.length) {
73
+ return AST.Union.make(types, type.annotations);
74
+ }
75
+ }
76
+ };
77
+ const DEFINITION_PREFIX = "#/$defs/";
78
+ const get$ref = id => `${DEFINITION_PREFIX}${id}`;
79
+ const getRefinementInnerTransformation = ast => {
80
+ switch (ast.from._tag) {
81
+ case "Transformation":
82
+ return ast.from;
83
+ case "Refinement":
84
+ return getRefinementInnerTransformation(ast.from);
85
+ case "Suspend":
86
+ {
87
+ const from = ast.from.f();
88
+ if (AST.isRefinement(from)) {
89
+ return getRefinementInnerTransformation(from);
90
+ }
91
+ }
92
+ }
93
+ };
94
+ const isParseJsonTransformation = ast => ast.annotations[AST.TypeAnnotationId] === ParseJsonTypeId;
95
+ const isOverrideAnnotation = jsonSchema => {
96
+ return "type" in jsonSchema || "oneOf" in jsonSchema || "anyOf" in jsonSchema || "const" in jsonSchema || "enum" in jsonSchema || "$ref" in jsonSchema;
97
+ };
98
+ const go = (ast, $defs, handleIdentifier, path) => {
99
+ const hook = AST.getJSONSchemaAnnotation(ast);
100
+ if (Option.isSome(hook)) {
101
+ const handler = hook.value;
102
+ if (AST.isRefinement(ast)) {
103
+ const t = getRefinementInnerTransformation(ast);
104
+ if (t === undefined) {
105
+ try {
106
+ return {
107
+ ...go(ast.from, $defs, true, path),
108
+ ...getJsonSchemaAnnotations(ast),
109
+ ...handler
110
+ };
111
+ } catch (e) {
112
+ return {
113
+ ...getJsonSchemaAnnotations(ast),
114
+ ...handler
115
+ };
116
+ }
117
+ } else if (!isOverrideAnnotation(handler)) {
118
+ return {
119
+ ...go(t, $defs, true, path),
120
+ ...getJsonSchemaAnnotations(ast)
121
+ };
122
+ }
123
+ }
124
+ return handler;
125
+ }
126
+ const surrogate = getSurrogateAnnotation(ast);
127
+ if (Option.isSome(surrogate)) {
128
+ return {
129
+ ...(ast._tag === "Transformation" ? getJsonSchemaAnnotations(ast.to) : {}),
130
+ ...go(surrogate.value, $defs, handleIdentifier, path),
131
+ ...getJsonSchemaAnnotations(ast)
132
+ };
133
+ }
134
+ if (handleIdentifier && !AST.isTransformation(ast)) {
135
+ const identifier = getJSONIdentifier(ast);
136
+ if (Option.isSome(identifier)) {
137
+ const id = identifier.value;
138
+ const out = {
139
+ $ref: get$ref(id)
140
+ };
141
+ if (!Record.has($defs, id)) {
142
+ $defs[id] = out;
143
+ $defs[id] = go(ast, $defs, false, path);
144
+ }
145
+ return out;
146
+ }
147
+ }
148
+ switch (ast._tag) {
149
+ case "Declaration":
150
+ throw new Error(getJSONSchemaMissingAnnotationErrorMessage(path, ast));
151
+ case "Literal":
152
+ {
153
+ const literal = ast.literal;
154
+ if (literal === null) {
155
+ return {
156
+ enum: [null],
157
+ ...getJsonSchemaAnnotations(ast)
158
+ };
159
+ } else if (Predicate.isString(literal) || Predicate.isNumber(literal) || Predicate.isBoolean(literal)) {
160
+ return {
161
+ enum: [literal],
162
+ ...getJsonSchemaAnnotations(ast)
163
+ };
164
+ }
165
+ throw new Error(getJSONSchemaMissingAnnotationErrorMessage(path, ast));
166
+ }
167
+ case "UniqueSymbol":
168
+ throw new Error(getJSONSchemaMissingAnnotationErrorMessage(path, ast));
169
+ case "UndefinedKeyword":
170
+ throw new Error(getJSONSchemaMissingAnnotationErrorMessage(path, ast));
171
+ case "VoidKeyword":
172
+ return {
173
+ ...constVoid,
174
+ ...getJsonSchemaAnnotations(ast)
175
+ };
176
+ case "NeverKeyword":
177
+ throw new Error(getJSONSchemaMissingAnnotationErrorMessage(path, ast));
178
+ case "UnknownKeyword":
179
+ return {
180
+ ...constUnknown,
181
+ ...getJsonSchemaAnnotations(ast)
182
+ };
183
+ case "AnyKeyword":
184
+ return {
185
+ ...constAny,
186
+ ...getJsonSchemaAnnotations(ast)
187
+ };
188
+ case "ObjectKeyword":
189
+ return {
190
+ ...constAnyObject,
191
+ ...getJsonSchemaAnnotations(ast)
192
+ };
193
+ case "StringKeyword":
194
+ {
195
+ return ast === AST.stringKeyword ? {
196
+ type: "string"
197
+ } : {
198
+ type: "string",
199
+ ...getJsonSchemaAnnotations(ast)
200
+ };
201
+ }
202
+ case "NumberKeyword":
203
+ {
204
+ return ast === AST.numberKeyword ? {
205
+ type: "number"
206
+ } : {
207
+ type: "number",
208
+ ...getJsonSchemaAnnotations(ast)
209
+ };
210
+ }
211
+ case "BooleanKeyword":
212
+ {
213
+ return ast === AST.booleanKeyword ? {
214
+ type: "boolean"
215
+ } : {
216
+ type: "boolean",
217
+ ...getJsonSchemaAnnotations(ast)
218
+ };
219
+ }
220
+ case "BigIntKeyword":
221
+ throw new Error(getJSONSchemaMissingAnnotationErrorMessage(path, ast));
222
+ case "SymbolKeyword":
223
+ throw new Error(getJSONSchemaMissingAnnotationErrorMessage(path, ast));
224
+ case "TupleType":
225
+ {
226
+ const elements = ast.elements.map((e, i) => ({
227
+ ...go(e.type, $defs, true, path.concat(i)),
228
+ ...getJsonSchemaAnnotations(e)
229
+ }));
230
+ const rest = ast.rest.map(annotatedAST => ({
231
+ ...go(annotatedAST.type, $defs, true, path),
232
+ ...getJsonSchemaAnnotations(annotatedAST)
233
+ }));
234
+ const output = {
235
+ type: "array"
236
+ };
237
+ // ---------------------------------------------
238
+ // handle elements
239
+ // ---------------------------------------------
240
+ const len = ast.elements.length;
241
+ if (len > 0) {
242
+ output.minItems = len - ast.elements.filter(element => element.isOptional).length;
243
+ output.items = elements;
244
+ }
245
+ // ---------------------------------------------
246
+ // handle rest element
247
+ // ---------------------------------------------
248
+ const restLength = rest.length;
249
+ if (restLength > 0) {
250
+ const head = rest[0];
251
+ const isHomogeneous = restLength === 1 && ast.elements.every(e => e.type === ast.rest[0].type);
252
+ if (isHomogeneous) {
253
+ output.items = head;
254
+ } else {
255
+ output.additionalItems = head;
256
+ }
257
+ // ---------------------------------------------
258
+ // handle post rest elements
259
+ // ---------------------------------------------
260
+ if (restLength > 1) {
261
+ throw new Error(getJSONSchemaUnsupportedPostRestElementsErrorMessage(path));
262
+ }
263
+ } else {
264
+ if (len > 0) {
265
+ output.additionalItems = false;
266
+ } else {
267
+ output.maxItems = 0;
268
+ }
269
+ }
270
+ return {
271
+ ...output,
272
+ ...getJsonSchemaAnnotations(ast)
273
+ };
274
+ }
275
+ case "TypeLiteral":
276
+ {
277
+ if (ast.propertySignatures.length === 0 && ast.indexSignatures.length === 0) {
278
+ return {
279
+ ...constEmpty,
280
+ ...getJsonSchemaAnnotations(ast)
281
+ };
282
+ }
283
+ let patternProperties = undefined;
284
+ let propertyNames = undefined;
285
+ for (const is of ast.indexSignatures) {
286
+ const parameter = is.parameter;
287
+ switch (parameter._tag) {
288
+ case "StringKeyword":
289
+ {
290
+ patternProperties = go(is.type, $defs, true, path);
291
+ break;
292
+ }
293
+ case "TemplateLiteral":
294
+ {
295
+ patternProperties = go(is.type, $defs, true, path);
296
+ propertyNames = {
297
+ type: "string",
298
+ pattern: AST.getTemplateLiteralRegExp(parameter).source
299
+ };
300
+ break;
301
+ }
302
+ case "Refinement":
303
+ {
304
+ patternProperties = go(is.type, $defs, true, path);
305
+ propertyNames = go(parameter, $defs, true, path);
306
+ break;
307
+ }
308
+ case "SymbolKeyword":
309
+ throw new Error(getJSONSchemaUnsupportedParameterErrorMessage(path, parameter));
310
+ }
311
+ }
312
+ const output = {
313
+ type: "object",
314
+ required: [],
315
+ properties: {},
316
+ additionalProperties: false
317
+ };
318
+ // ---------------------------------------------
319
+ // handle property signatures
320
+ // ---------------------------------------------
321
+ for (let i = 0; i < ast.propertySignatures.length; i++) {
322
+ const ps = ast.propertySignatures[i];
323
+ const name = ps.name;
324
+ if (Predicate.isString(name)) {
325
+ const pruned = pruneUndefinedKeyword(ps);
326
+ output.properties[name] = {
327
+ ...go(pruned ? pruned : ps.type, $defs, true, path.concat(ps.name)),
328
+ ...getJsonSchemaAnnotations(ps)
329
+ };
330
+ // ---------------------------------------------
331
+ // handle optional property signatures
332
+ // ---------------------------------------------
333
+ if (!ps.isOptional && pruned === undefined) {
334
+ output.required.push(name);
335
+ }
336
+ } else {
337
+ throw new Error(getJSONSchemaUnsupportedKeyErrorMessage(name, path));
338
+ }
339
+ }
340
+ // ---------------------------------------------
341
+ // handle index signatures
342
+ // ---------------------------------------------
343
+ if (patternProperties !== undefined) {
344
+ delete output.additionalProperties;
345
+ output.patternProperties = {
346
+ "": patternProperties
347
+ };
348
+ }
349
+ if (propertyNames !== undefined) {
350
+ output.propertyNames = propertyNames;
351
+ }
352
+ return {
353
+ ...output,
354
+ ...getJsonSchemaAnnotations(ast)
355
+ };
356
+ }
357
+ case "Union":
358
+ {
359
+ const enums = [];
360
+ const anyOf = [];
361
+ for (const type of ast.types) {
362
+ const schema = go(type, $defs, true, path);
363
+ if ("enum" in schema) {
364
+ if (Object.keys(schema).length > 1) {
365
+ anyOf.push(schema);
366
+ } else {
367
+ for (const e of schema.enum) {
368
+ enums.push(e);
369
+ }
370
+ }
371
+ } else {
372
+ anyOf.push(schema);
373
+ }
374
+ }
375
+ if (anyOf.length === 0) {
376
+ return {
377
+ enum: enums,
378
+ ...getJsonSchemaAnnotations(ast)
379
+ };
380
+ } else {
381
+ if (enums.length >= 1) {
382
+ anyOf.push({
383
+ enum: enums
384
+ });
385
+ }
386
+ return {
387
+ anyOf,
388
+ ...getJsonSchemaAnnotations(ast)
389
+ };
390
+ }
391
+ }
392
+ case "Enums":
393
+ {
394
+ return {
395
+ $comment: "/schemas/enums",
396
+ anyOf: ast.enums.map(e => ({
397
+ title: e[0],
398
+ enum: [e[1]]
399
+ })),
400
+ ...getJsonSchemaAnnotations(ast)
401
+ };
402
+ }
403
+ case "Refinement":
404
+ {
405
+ throw new Error(getJSONSchemaMissingAnnotationErrorMessage(path, ast));
406
+ }
407
+ case "TemplateLiteral":
408
+ {
409
+ const regex = AST.getTemplateLiteralRegExp(ast);
410
+ return {
411
+ type: "string",
412
+ description: "a template literal",
413
+ pattern: regex.source,
414
+ ...getJsonSchemaAnnotations(ast)
415
+ };
416
+ }
417
+ case "Suspend":
418
+ {
419
+ const identifier = Option.orElse(getJSONIdentifier(ast), () => getJSONIdentifier(ast.f()));
420
+ if (Option.isNone(identifier)) {
421
+ throw new Error(getJSONSchemaMissingIdentifierAnnotationErrorMessage(path, ast));
422
+ }
423
+ return {
424
+ ...go(ast.f(), $defs, true, path),
425
+ ...getJsonSchemaAnnotations(ast)
426
+ };
427
+ }
428
+ case "Transformation":
429
+ {
430
+ // Properly handle S.parseJson transformations by focusing on
431
+ // the 'to' side of the AST. This approach prevents the generation of useless schemas
432
+ // derived from the 'from' side (type: string), ensuring the output matches the intended
433
+ // complex schema type.
434
+ if (isParseJsonTransformation(ast.from)) {
435
+ return {
436
+ type: "string",
437
+ contentMediaType: "application/json",
438
+ contentSchema: go(ast.to, $defs, true, path),
439
+ ...getJsonSchemaAnnotations(ast)
440
+ };
441
+ }
442
+ return {
443
+ ...getJsonSchemaAnnotations(ast.to),
444
+ ...go(ast.from, $defs, true, path),
445
+ ...getJsonSchemaAnnotations(ast)
446
+ };
447
+ }
448
+ }
449
+ };
450
+ const getJSONSchemaMissingAnnotationErrorMessage = (path, ast) => getMissingAnnotationErrorMessage(`Generating a JSON Schema for this schema requires a "jsonSchema" annotation`, path, ast);
451
+ const getJSONSchemaMissingIdentifierAnnotationErrorMessage = (path, ast) => getMissingAnnotationErrorMessage(`Generating a JSON Schema for this schema requires an "identifier" annotation`, path, ast);
452
+ const getJSONSchemaUnsupportedParameterErrorMessage = (path, parameter) => getErrorMessage("Unsupported index signature parameter", undefined, path, parameter);
453
+ const getJSONSchemaUnsupportedPostRestElementsErrorMessage = path => getErrorMessage("Generating a JSON Schema for post-rest elements is not currently supported. You're welcome to contribute by submitting a Pull Request", undefined, path);
454
+ const getJSONSchemaUnsupportedKeyErrorMessage = (key, path) => getErrorMessage("Unsupported key", `Cannot encode ${formatPropertyKey(key)} key to JSON Schema`, path);
455
+ const getMissingAnnotationErrorMessage = (details, path, ast) => getErrorMessage("Missing annotation", details, path, ast);
456
+ const getErrorMessage = (reason, details, path, ast) => {
457
+ let out = reason;
458
+ if (path && Arr.isNonEmptyReadonlyArray(path)) {
459
+ out += `\nat path: ${formatPath(path)}`;
460
+ }
461
+ if (details !== undefined) {
462
+ out += `\ndetails: ${details}`;
463
+ }
464
+ if (ast) {
465
+ out += `\nschema (${ast._tag}): ${ast}`;
466
+ }
467
+ return out;
468
+ };
469
+ const formatPathKey = key => `[${formatPropertyKey(key)}]`;
470
+ const formatPath = path => isNonEmpty(path) ? path.map(formatPathKey).join("") : formatPathKey(path);
471
+ const isNonEmpty = x => Array.isArray(x);
472
+ const formatPropertyKey = name => typeof name === "string" ? JSON.stringify(name) : String(name);
473
+ const ParseJsonTypeId = /*#__PURE__*/Symbol.for("@effect/schema/TypeId/ParseJson");
474
+ const SurrogateAnnotationId = /*#__PURE__*/Symbol.for("@effect/schema/annotation/Surrogate");
475
+ const JSONIdentifierAnnotationId = /*#__PURE__*/Symbol.for("@effect/schema/annotation/JSONIdentifier");
476
+ const getSurrogateAnnotation = /*#__PURE__*/AST.getAnnotation(SurrogateAnnotationId);
477
+ const getJSONIdentifierAnnotation = /*#__PURE__*/AST.getAnnotation(JSONIdentifierAnnotationId);
478
+ const getJSONIdentifier = annotated => Option.orElse(getJSONIdentifierAnnotation(annotated), () => AST.getIdentifierAnnotation(annotated));
479
+ //# sourceMappingURL=OpenApiJsonSchema.js.map