exact-mirror 0.0.3 → 0.0.4

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/dist/cjs/index.js CHANGED
@@ -96,7 +96,14 @@ var handleUnion = (schemas, property, instruction) => {
96
96
  `;
97
97
  for (let i = 0; i < schemas.length; i++) {
98
98
  typeChecks.push(import_compiler.TypeCompiler.Compile(schemas[i]));
99
- v += `if(d.unions[${ui}][${i}].Check(${property})){return ${mirror(schemas[i], property, instruction)}}
99
+ v += `if(d.unions[${ui}][${i}].Check(${property})){return ${mirror(
100
+ schemas[i],
101
+ property,
102
+ {
103
+ ...instruction,
104
+ parentIsOptional: true
105
+ }
106
+ )}}
100
107
  `;
101
108
  }
102
109
  v += `return undefined})()`;
@@ -191,7 +198,7 @@ var mirror = (schema, property, instruction) => {
191
198
  const prop = key.slice(1);
192
199
  v += `if(${key}===undefined`;
193
200
  if (instruction.unionKeys[key]) v += `||x${prop}===undefined`;
194
- v += `)delete x?${prop}
201
+ v += `)delete x${prop.charCodeAt(0) !== 63 ? "?" : ""}${prop}
195
202
  `;
196
203
  }
197
204
  return `${v}return x`;
package/dist/index.mjs CHANGED
@@ -70,7 +70,14 @@ var handleUnion = (schemas, property, instruction) => {
70
70
  `;
71
71
  for (let i = 0; i < schemas.length; i++) {
72
72
  typeChecks.push(TypeCompiler.Compile(schemas[i]));
73
- v += `if(d.unions[${ui}][${i}].Check(${property})){return ${mirror(schemas[i], property, instruction)}}
73
+ v += `if(d.unions[${ui}][${i}].Check(${property})){return ${mirror(
74
+ schemas[i],
75
+ property,
76
+ {
77
+ ...instruction,
78
+ parentIsOptional: true
79
+ }
80
+ )}}
74
81
  `;
75
82
  }
76
83
  v += `return undefined})()`;
@@ -165,7 +172,7 @@ var mirror = (schema, property, instruction) => {
165
172
  const prop = key.slice(1);
166
173
  v += `if(${key}===undefined`;
167
174
  if (instruction.unionKeys[key]) v += `||x${prop}===undefined`;
168
- v += `)delete x?${prop}
175
+ v += `)delete x${prop.charCodeAt(0) !== 63 ? "?" : ""}${prop}
169
176
  `;
170
177
  }
171
178
  return `${v}return x`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exact-mirror",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Mirror exact value to TypeBox/OpenAPI model",
5
5
  "license": "MIT",
6
6
  "scripts": {