quicktype-core 23.0.76 → 23.0.78

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.
@@ -56,21 +56,21 @@ class TypeScriptEffectSchemaRenderer extends ConvenienceRenderer_1.ConvenienceRe
56
56
  }
57
57
  emitImports() {
58
58
  this.ensureBlankLine();
59
- this.emitLine(this.importStatement("* as Schema", '"@effect/schema/Schema"'));
59
+ this.emitLine(this.importStatement("* as S", '"@effect/schema/Schema"'));
60
60
  }
61
61
  typeMapTypeForProperty(p) {
62
62
  const typeMap = this.typeMapTypeFor(p.type);
63
- return p.isOptional ? ["Schema.optional(", typeMap, ")"] : typeMap;
63
+ return p.isOptional ? ["S.optional(", typeMap, ")"] : typeMap;
64
64
  }
65
65
  typeMapTypeFor(t, required = true) {
66
66
  if (["class", "object", "enum"].indexOf(t.kind) >= 0) {
67
- return ["Schema.lazy(() => ", this.nameForNamedType(t), "Schema)"];
67
+ return ["S.lazy(() => ", this.nameForNamedType(t), ")"];
68
68
  }
69
- const match = (0, TypeUtils_1.matchType)(t, _anyType => "Schema.any", _nullType => "Schema.null", _boolType => "Schema.boolean", _integerType => "Schema.number", _doubleType => "Schema.number", _stringType => "Schema.string", arrayType => ["Schema.array(", this.typeMapTypeFor(arrayType.items, false), ")"], _classType => (0, Support_1.panic)("Should already be handled."), _mapType => ["Schema.record(Schema.string, ", this.typeMapTypeFor(_mapType.values, false), ")"], _enumType => (0, Support_1.panic)("Should already be handled."), unionType => {
69
+ const match = (0, TypeUtils_1.matchType)(t, _anyType => "S.any", _nullType => "S.null", _boolType => "S.boolean", _integerType => "S.number", _doubleType => "S.number", _stringType => "S.string", arrayType => ["S.array(", this.typeMapTypeFor(arrayType.items, false), ")"], _classType => (0, Support_1.panic)("Should already be handled."), _mapType => ["S.record(S.string, ", this.typeMapTypeFor(_mapType.values, false), ")"], _enumType => (0, Support_1.panic)("Should already be handled."), unionType => {
70
70
  const children = Array.from(unionType.getChildren()).map((type) => this.typeMapTypeFor(type, false));
71
- return ["Schema.union(", ...(0, collection_utils_1.arrayIntercalate)(", ", children), ")"];
71
+ return ["S.union(", ...(0, collection_utils_1.arrayIntercalate)(", ", children), ")"];
72
72
  }, _transformedStringType => {
73
- return "Schema.string";
73
+ return "S.string";
74
74
  });
75
75
  if (required) {
76
76
  return [match];
@@ -79,7 +79,12 @@ class TypeScriptEffectSchemaRenderer extends ConvenienceRenderer_1.ConvenienceRe
79
79
  }
80
80
  emitObject(name, t) {
81
81
  this.ensureBlankLine();
82
- this.emitLine("\nexport const ", name, "Schema = ", "Schema.struct({");
82
+ if (this._options.justSchema) {
83
+ this.emitLine("\nexport const ", name, " = S.struct({");
84
+ }
85
+ else {
86
+ this.emitLine("\nconst ", name, "_ = S.struct({");
87
+ }
83
88
  this.indent(() => {
84
89
  this.forEachClassProperty(t, "none", (_, jsonName, property) => {
85
90
  this.emitLine(`"${(0, Strings_1.utf16StringEscape)(jsonName)}"`, ": ", this.typeMapTypeForProperty(property), ",");
@@ -87,20 +92,21 @@ class TypeScriptEffectSchemaRenderer extends ConvenienceRenderer_1.ConvenienceRe
87
92
  });
88
93
  this.emitLine("});");
89
94
  if (!this._options.justSchema) {
90
- this.emitLine("export type ", name, " = Schema.From<typeof ", name, "Schema>;");
95
+ this.emitLine("export interface ", name, " extends S.Schema.To<typeof ", name, "_> {}");
96
+ this.emitLine("export const ", name, ": S.Schema<S.Schema.From<typeof ", name, "_>, ", name, "> = ", name, "_;");
91
97
  }
92
98
  }
93
99
  emitEnum(e, enumName) {
94
100
  this.ensureBlankLine();
95
101
  this.emitDescription(this.descriptionForType(e));
96
- this.emitLine("\nexport const ", enumName, "Schema = ", "Schema.enums({");
102
+ this.emitLine("\nexport const ", enumName, " = ", "S.enums({");
97
103
  this.indent(() => this.forEachEnumCase(e, "none", (_, jsonName) => {
98
104
  const name = (0, Strings_1.stringEscape)(jsonName);
99
105
  this.emitLine('"', name, '": "', name, '",');
100
106
  }));
101
107
  this.emitLine("});");
102
108
  if (!this._options.justSchema) {
103
- this.emitLine("export type ", enumName, " = Schema.From<typeof ", enumName, "Schema>;");
109
+ this.emitLine("export type ", enumName, " = S.Schema.To<typeof ", enumName, ">;");
104
110
  }
105
111
  }
106
112
  emitSchemas() {
@@ -38,7 +38,8 @@ class TypeScriptFlowBaseTargetLanguage extends JavaScript_1.JavaScriptTargetLang
38
38
  exports.tsFlowOptions.converters,
39
39
  exports.tsFlowOptions.rawType,
40
40
  exports.tsFlowOptions.preferUnions,
41
- exports.tsFlowOptions.preferTypes
41
+ exports.tsFlowOptions.preferTypes,
42
+ exports.tsFlowOptions.preferConstValues
42
43
  ];
43
44
  }
44
45
  get supportsOptionalClassProperties() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quicktype-core",
3
- "version": "23.0.76",
3
+ "version": "23.0.78",
4
4
  "description": "The quicktype engine as a library",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",