@jsii/kernel 1.85.0 → 1.86.0

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.
@@ -58,62 +58,62 @@ exports.SERIALIZERS = {
58
58
  },
59
59
  // ----------------------------------------------------------------------
60
60
  ["Date" /* SerializationClass.Date */]: {
61
- serialize(value, optionalValue) {
62
- if (nullAndOk(value, optionalValue)) {
61
+ serialize(value, optionalValue, host) {
62
+ if (nullAndOk(value, optionalValue, host)) {
63
63
  return undefined;
64
64
  }
65
65
  assert(optionalValue !== VOID, 'Encountered unexpected void type!');
66
66
  if (!isDate(value)) {
67
- throw new SerializationError(`Value is not an instance of Date`, value);
67
+ throw new SerializationError(`Value is not an instance of Date`, value, host);
68
68
  }
69
69
  return serializeDate(value);
70
70
  },
71
- deserialize(value, optionalValue) {
72
- if (nullAndOk(value, optionalValue)) {
71
+ deserialize(value, optionalValue, host) {
72
+ if (nullAndOk(value, optionalValue, host)) {
73
73
  return undefined;
74
74
  }
75
75
  if (!(0, api_1.isWireDate)(value)) {
76
- throw new SerializationError(`Value does not have the "${api_1.TOKEN_DATE}" key`, value);
76
+ throw new SerializationError(`Value does not have the "${api_1.TOKEN_DATE}" key`, value, host);
77
77
  }
78
78
  return deserializeDate(value);
79
79
  },
80
80
  },
81
81
  // ----------------------------------------------------------------------
82
82
  ["Scalar" /* SerializationClass.Scalar */]: {
83
- serialize(value, optionalValue) {
84
- if (nullAndOk(value, optionalValue)) {
83
+ serialize(value, optionalValue, host) {
84
+ if (nullAndOk(value, optionalValue, host)) {
85
85
  return undefined;
86
86
  }
87
87
  assert(optionalValue !== VOID, 'Encountered unexpected void type!');
88
88
  const primitiveType = optionalValue.type;
89
89
  if (!isScalar(value)) {
90
- throw new SerializationError(`Value is not a ${spec.describeTypeReference(optionalValue.type)}`, value);
90
+ throw new SerializationError(`Value is not a ${spec.describeTypeReference(optionalValue.type)}`, value, host);
91
91
  }
92
92
  if (typeof value !== primitiveType.primitive) {
93
- throw new SerializationError(`Value is not a ${spec.describeTypeReference(optionalValue.type)}`, value);
93
+ throw new SerializationError(`Value is not a ${spec.describeTypeReference(optionalValue.type)}`, value, host);
94
94
  }
95
95
  return value;
96
96
  },
97
- deserialize(value, optionalValue) {
98
- if (nullAndOk(value, optionalValue)) {
97
+ deserialize(value, optionalValue, host) {
98
+ if (nullAndOk(value, optionalValue, host)) {
99
99
  return undefined;
100
100
  }
101
101
  assert(optionalValue !== VOID, 'Encountered unexpected void type!');
102
102
  const primitiveType = optionalValue.type;
103
103
  if (!isScalar(value)) {
104
- throw new SerializationError(`Value is not a ${spec.describeTypeReference(optionalValue.type)}`, value);
104
+ throw new SerializationError(`Value is not a ${spec.describeTypeReference(optionalValue.type)}`, value, host);
105
105
  }
106
106
  if (typeof value !== primitiveType.primitive) {
107
- throw new SerializationError(`Value is not a ${spec.describeTypeReference(optionalValue.type)}`, value);
107
+ throw new SerializationError(`Value is not a ${spec.describeTypeReference(optionalValue.type)}`, value, host);
108
108
  }
109
109
  return value;
110
110
  },
111
111
  },
112
112
  // ----------------------------------------------------------------------
113
113
  ["Json" /* SerializationClass.Json */]: {
114
- serialize(value, optionalValue) {
114
+ serialize(value, optionalValue, host) {
115
115
  // /!\ Top-level "null" will turn to undefined, but any null nested in the value is valid JSON, so it'll stay!
116
- if (nullAndOk(value, optionalValue)) {
116
+ if (nullAndOk(value, optionalValue, host)) {
117
117
  return undefined;
118
118
  }
119
119
  // Just whatever. Dates will automatically serialize themselves to strings.
@@ -121,7 +121,7 @@ exports.SERIALIZERS = {
121
121
  },
122
122
  deserialize(value, optionalValue, host) {
123
123
  // /!\ Top-level "null" will turn to undefined, but any null nested in the value is valid JSON, so it'll stay!
124
- if (nullAndOk(value, optionalValue)) {
124
+ if (nullAndOk(value, optionalValue, host)) {
125
125
  return undefined;
126
126
  }
127
127
  // A mapping object can arrive though here. This would be the case if anything that is valid into a Map<string, ?>
@@ -144,7 +144,7 @@ exports.SERIALIZERS = {
144
144
  if (Array.isArray(value)) {
145
145
  return value.map(mapJsonValue);
146
146
  }
147
- return mapValues(value, mapJsonValue);
147
+ return mapValues(value, mapJsonValue, host);
148
148
  function mapJsonValue(toMap, key) {
149
149
  if (toMap == null) {
150
150
  return toMap;
@@ -156,52 +156,52 @@ exports.SERIALIZERS = {
156
156
  // ----------------------------------------------------------------------
157
157
  ["Enum" /* SerializationClass.Enum */]: {
158
158
  serialize(value, optionalValue, host) {
159
- if (nullAndOk(value, optionalValue)) {
159
+ if (nullAndOk(value, optionalValue, host)) {
160
160
  return undefined;
161
161
  }
162
162
  assert(optionalValue !== VOID, 'Encountered unexpected void type!');
163
163
  if (typeof value !== 'string' && typeof value !== 'number') {
164
- throw new SerializationError(`Value is not a string or number`, value);
164
+ throw new SerializationError(`Value is not a string or number`, value, host);
165
165
  }
166
166
  host.debug('Serializing enum');
167
167
  const enumType = optionalValue.type;
168
168
  const enumMap = host.findSymbol(enumType.fqn);
169
169
  const enumEntry = Object.entries(enumMap).find(([, v]) => v === value);
170
170
  if (!enumEntry) {
171
- throw new SerializationError(`Value is not present in enum ${spec.describeTypeReference(enumType)}`, value);
171
+ throw new SerializationError(`Value is not present in enum ${spec.describeTypeReference(enumType)}`, value, host);
172
172
  }
173
173
  return { [api_1.TOKEN_ENUM]: `${enumType.fqn}/${enumEntry[0]}` };
174
174
  },
175
175
  deserialize(value, optionalValue, host) {
176
- if (nullAndOk(value, optionalValue)) {
176
+ if (nullAndOk(value, optionalValue, host)) {
177
177
  return undefined;
178
178
  }
179
179
  if (!(0, api_1.isWireEnum)(value)) {
180
- throw new SerializationError(`Value does not have the "${api_1.TOKEN_ENUM}" key`, value);
180
+ throw new SerializationError(`Value does not have the "${api_1.TOKEN_ENUM}" key`, value, host);
181
181
  }
182
- return deserializeEnum(value, host.findSymbol);
182
+ return deserializeEnum(value, host);
183
183
  },
184
184
  },
185
185
  // ----------------------------------------------------------------------
186
186
  ["Array" /* SerializationClass.Array */]: {
187
187
  serialize(value, optionalValue, host) {
188
- if (nullAndOk(value, optionalValue)) {
188
+ if (nullAndOk(value, optionalValue, host)) {
189
189
  return undefined;
190
190
  }
191
191
  assert(optionalValue !== VOID, 'Encountered unexpected void type!');
192
192
  if (!Array.isArray(value)) {
193
- throw new SerializationError(`Value is not an array`, value);
193
+ throw new SerializationError(`Value is not an array`, value, host);
194
194
  }
195
195
  const arrayType = optionalValue.type;
196
196
  return value.map((x, idx) => process(host, 'serialize', x, { type: arrayType.collection.elementtype }, `index ${(0, util_1.inspect)(idx)}`));
197
197
  },
198
198
  deserialize(value, optionalValue, host) {
199
- if (nullAndOk(value, optionalValue)) {
199
+ if (nullAndOk(value, optionalValue, host)) {
200
200
  return undefined;
201
201
  }
202
202
  assert(optionalValue !== VOID, 'Encountered unexpected void type!');
203
203
  if (!Array.isArray(value)) {
204
- throw new SerializationError(`Value is not an array`, value);
204
+ throw new SerializationError(`Value is not an array`, value, host);
205
205
  }
206
206
  const arrayType = optionalValue.type;
207
207
  return value.map((x, idx) => process(host, 'deserialize', x, { type: arrayType.collection.elementtype }, `index ${(0, util_1.inspect)(idx)}`));
@@ -210,17 +210,17 @@ exports.SERIALIZERS = {
210
210
  // ----------------------------------------------------------------------
211
211
  ["Map" /* SerializationClass.Map */]: {
212
212
  serialize(value, optionalValue, host) {
213
- if (nullAndOk(value, optionalValue)) {
213
+ if (nullAndOk(value, optionalValue, host)) {
214
214
  return undefined;
215
215
  }
216
216
  assert(optionalValue !== VOID, 'Encountered unexpected void type!');
217
217
  const mapType = optionalValue.type;
218
218
  return {
219
- [api_1.TOKEN_MAP]: mapValues(value, (v, key) => process(host, 'serialize', v, { type: mapType.collection.elementtype }, `key ${(0, util_1.inspect)(key)}`)),
219
+ [api_1.TOKEN_MAP]: mapValues(value, (v, key) => process(host, 'serialize', v, { type: mapType.collection.elementtype }, `key ${(0, util_1.inspect)(key)}`), host),
220
220
  };
221
221
  },
222
222
  deserialize(value, optionalValue, host, { allowNullishMapValue = false } = {}) {
223
- if (nullAndOk(value, optionalValue)) {
223
+ if (nullAndOk(value, optionalValue, host)) {
224
224
  return undefined;
225
225
  }
226
226
  assert(optionalValue !== VOID, 'Encountered unexpected void type!');
@@ -230,12 +230,12 @@ exports.SERIALIZERS = {
230
230
  return mapValues(value, (v, key) => process(host, 'deserialize', v, {
231
231
  optional: allowNullishMapValue,
232
232
  type: mapType.collection.elementtype,
233
- }, `key ${(0, util_1.inspect)(key)}`));
233
+ }, `key ${(0, util_1.inspect)(key)}`), host);
234
234
  }
235
235
  const result = mapValues(value[api_1.TOKEN_MAP], (v, key) => process(host, 'deserialize', v, {
236
236
  optional: allowNullishMapValue,
237
237
  type: mapType.collection.elementtype,
238
- }, `key ${(0, util_1.inspect)(key)}`));
238
+ }, `key ${(0, util_1.inspect)(key)}`), host);
239
239
  Object.defineProperty(result, exports.SYMBOL_WIRE_TYPE, {
240
240
  configurable: false,
241
241
  enumerable: false,
@@ -248,15 +248,15 @@ exports.SERIALIZERS = {
248
248
  // ----------------------------------------------------------------------
249
249
  ["Struct" /* SerializationClass.Struct */]: {
250
250
  serialize(value, optionalValue, host) {
251
- if (nullAndOk(value, optionalValue)) {
251
+ if (nullAndOk(value, optionalValue, host)) {
252
252
  return undefined;
253
253
  }
254
254
  assert(optionalValue !== VOID, 'Encountered unexpected void type!');
255
255
  if (typeof value !== 'object' || value == null || value instanceof Date) {
256
- throw new SerializationError(`Value is not an object`, value);
256
+ throw new SerializationError(`Value is not an object`, value, host);
257
257
  }
258
258
  if (Array.isArray(value)) {
259
- throw new SerializationError(`Value is an array`, value);
259
+ throw new SerializationError(`Value is an array`, value, host);
260
260
  }
261
261
  /*
262
262
  This is what we'd like to do, but we can't because at least the Java client
@@ -282,17 +282,17 @@ exports.SERIALIZERS = {
282
282
  // Treat empty structs as `undefined` (see https://github.com/aws/jsii/issues/411)
283
283
  value = undefined;
284
284
  }
285
- if (nullAndOk(value, optionalValue)) {
285
+ if (nullAndOk(value, optionalValue, host)) {
286
286
  return undefined;
287
287
  }
288
288
  assert(optionalValue !== VOID, 'Encountered unexpected void type!');
289
289
  if (typeof value !== 'object' || value == null) {
290
- throw new SerializationError(`Value is not an object`, value);
290
+ throw new SerializationError(`Value is not an object`, value, host);
291
291
  }
292
292
  const namedType = host.lookupType(optionalValue.type.fqn);
293
293
  const props = propertiesOf(namedType, host.lookupType);
294
294
  if (Array.isArray(value)) {
295
- throw new SerializationError('Value is an array (varargs may have been incorrectly supplied)', value);
295
+ throw new SerializationError('Value is an array (varargs may have been incorrectly supplied)', value, host);
296
296
  }
297
297
  // Similarly to serialization, we might be getting a reference type where we're
298
298
  // expecting a value type. Accept this for now (but also validate that object
@@ -300,12 +300,12 @@ exports.SERIALIZERS = {
300
300
  if ((0, api_1.isObjRef)(value)) {
301
301
  host.debug('Expected value type but got reference type, accepting for now (awslabs/jsii#400)');
302
302
  // Return same INSTANCE (shouldn't matter but we don't know for sure that it doesn't)
303
- return validateRequiredProps(host.objects.findObject(value).instance, namedType.fqn, props);
303
+ return validateRequiredProps(host.objects.findObject(value).instance, namedType.fqn, props, host);
304
304
  }
305
305
  if (_1.api.isWireStruct(value)) {
306
306
  const { fqn, data } = value[_1.api.TOKEN_STRUCT];
307
307
  if (!isAssignable(fqn, namedType, host.lookupType)) {
308
- throw new SerializationError(`Wired struct has type '${fqn}', which does not match expected type`, value);
308
+ throw new SerializationError(`Wired struct has type '${fqn}', which does not match expected type`, value, host);
309
309
  }
310
310
  value = data;
311
311
  }
@@ -313,46 +313,46 @@ exports.SERIALIZERS = {
313
313
  if (_1.api.isWireMap(value)) {
314
314
  value = value[_1.api.TOKEN_MAP];
315
315
  }
316
- value = validateRequiredProps(value, namedType.fqn, props);
316
+ value = validateRequiredProps(value, namedType.fqn, props, host);
317
317
  // Return a dict COPY, we have by-value semantics anyway.
318
318
  return mapValues(value, (v, key) => {
319
319
  if (!props[key]) {
320
320
  return undefined;
321
321
  } // Don't map if unknown property
322
322
  return process(host, 'deserialize', v, props[key], `key ${(0, util_1.inspect)(key)}`);
323
- });
323
+ }, host);
324
324
  },
325
325
  },
326
326
  // ----------------------------------------------------------------------
327
327
  ["RefType" /* SerializationClass.ReferenceType */]: {
328
328
  serialize(value, optionalValue, host) {
329
329
  var _a;
330
- if (nullAndOk(value, optionalValue)) {
330
+ if (nullAndOk(value, optionalValue, host)) {
331
331
  return undefined;
332
332
  }
333
333
  assert(optionalValue !== VOID, 'Encountered unexpected void type!');
334
334
  if (typeof value !== 'object' || value == null || Array.isArray(value)) {
335
- throw new SerializationError(`Value is not an object`, value);
335
+ throw new SerializationError(`Value is not an object`, value, host);
336
336
  }
337
337
  if (value instanceof Date) {
338
- throw new SerializationError(`Value is a Date`, value);
338
+ throw new SerializationError(`Value is a Date`, value, host);
339
339
  }
340
340
  const expectedType = host.lookupType(optionalValue.type.fqn);
341
341
  const interfaces = spec.isInterfaceType(expectedType)
342
342
  ? [expectedType.fqn]
343
343
  : undefined;
344
- const jsiiType = (_a = (0, objects_1.jsiiTypeFqn)(value)) !== null && _a !== void 0 ? _a : (spec.isClassType(expectedType) ? expectedType.fqn : exports.EMPTY_OBJECT_FQN);
344
+ const jsiiType = (_a = (0, objects_1.jsiiTypeFqn)(value, host.isVisibleType)) !== null && _a !== void 0 ? _a : (spec.isClassType(expectedType) ? expectedType.fqn : exports.EMPTY_OBJECT_FQN);
345
345
  return host.objects.registerObject(value, jsiiType, interfaces);
346
346
  },
347
347
  deserialize(value, optionalValue, host) {
348
- if (nullAndOk(value, optionalValue)) {
348
+ if (nullAndOk(value, optionalValue, host)) {
349
349
  return undefined;
350
350
  }
351
351
  assert(optionalValue !== VOID, 'Encountered unexpected void type!');
352
352
  // The only way to pass a by-ref object is to have created it
353
353
  // previously inside JSII kernel, so it must have an objref already.
354
354
  if (!(0, api_1.isObjRef)(value)) {
355
- throw new SerializationError(`Value does not have the "${api_1.TOKEN_REF}" key`, value);
355
+ throw new SerializationError(`Value does not have the "${api_1.TOKEN_REF}" key`, value, host);
356
356
  }
357
357
  const { instance, fqn } = host.objects.findObject(value);
358
358
  const namedTypeRef = optionalValue.type;
@@ -365,7 +365,7 @@ exports.SERIALIZERS = {
365
365
  const declaredType = optionalValue.type;
366
366
  if (spec.isClassType(namedType) &&
367
367
  !isAssignable(fqn, declaredType, host.lookupType)) {
368
- throw new SerializationError(`Object of type '${fqn}' is not convertible to ${spec.describeTypeReference(declaredType)}`, value);
368
+ throw new SerializationError(`Object of type '${fqn}' is not convertible to ${spec.describeTypeReference(declaredType)}`, value, host);
369
369
  }
370
370
  }
371
371
  return instance;
@@ -390,10 +390,10 @@ exports.SERIALIZERS = {
390
390
  // Note: no case for "ENUM" here, without type declaration we can't tell the difference
391
391
  // between an enum member and a scalar.
392
392
  if (typeof value === 'function') {
393
- throw new SerializationError('Functions cannot be passed across language boundaries', value);
393
+ throw new SerializationError('Functions cannot be passed across language boundaries', value, host);
394
394
  }
395
395
  if (typeof value !== 'object' || value == null) {
396
- throw new SerializationError(`A jsii kernel assumption was violated: value is not an object`, value);
396
+ throw new SerializationError(`A jsii kernel assumption was violated: value is not an object`, value, host);
397
397
  }
398
398
  if (exports.SYMBOL_WIRE_TYPE in value &&
399
399
  value[exports.SYMBOL_WIRE_TYPE] === api_1.TOKEN_MAP) {
@@ -410,7 +410,7 @@ exports.SERIALIZERS = {
410
410
  // those and throw a descriptive error message. We can't detect these cases any other
411
411
  // way, and the by-value serialized object will be quite useless.
412
412
  if (value instanceof Set || value instanceof Map) {
413
- throw new SerializationError('Set and Map instances cannot be sent across the language boundary', value);
413
+ throw new SerializationError('Set and Map instances cannot be sent across the language boundary', value, host);
414
414
  }
415
415
  // Use a previous reference to maintain object identity. NOTE: this may cause us to return
416
416
  // a different type than requested! This is just how it is right now.
@@ -421,7 +421,7 @@ exports.SERIALIZERS = {
421
421
  }
422
422
  // If this is or should be a reference type, pass or make the reference
423
423
  // (Like regular reftype serialization, but without the type derivation to an interface)
424
- const jsiiType = (_a = (0, objects_1.jsiiTypeFqn)(value)) !== null && _a !== void 0 ? _a : (isByReferenceOnly(value) ? exports.EMPTY_OBJECT_FQN : undefined);
424
+ const jsiiType = (_a = (0, objects_1.jsiiTypeFqn)(value, host.isVisibleType)) !== null && _a !== void 0 ? _a : (isByReferenceOnly(value) ? exports.EMPTY_OBJECT_FQN : undefined);
425
425
  if (jsiiType) {
426
426
  return host.objects.registerObject(value, jsiiType);
427
427
  }
@@ -430,7 +430,7 @@ exports.SERIALIZERS = {
430
430
  // We will serialize by-value, but recurse for serialization so that if
431
431
  // the object contains reference objects, they will be serialized appropriately.
432
432
  // (Basically, serialize anything else as a map of 'any').
433
- return mapValues(value, (v, key) => process(host, 'serialize', v, { type: spec.CANONICAL_ANY }, `key ${(0, util_1.inspect)(key)}`));
433
+ return mapValues(value, (v, key) => process(host, 'serialize', v, { type: spec.CANONICAL_ANY }, `key ${(0, util_1.inspect)(key)}`), host);
434
434
  },
435
435
  deserialize(value, _type, host) {
436
436
  if (value == null) {
@@ -450,7 +450,7 @@ exports.SERIALIZERS = {
450
450
  }
451
451
  if ((0, api_1.isWireEnum)(value)) {
452
452
  host.debug('ANY is an Enum');
453
- return deserializeEnum(value, host.findSymbol);
453
+ return deserializeEnum(value, host);
454
454
  }
455
455
  if ((0, api_1.isWireMap)(value)) {
456
456
  host.debug('ANY is a Map');
@@ -476,7 +476,7 @@ exports.SERIALIZERS = {
476
476
  }
477
477
  // At this point again, deserialize by-value.
478
478
  host.debug('ANY is a Map');
479
- return mapValues(value, (v, key) => process(host, 'deserialize', v, { type: spec.CANONICAL_ANY }, `key ${(0, util_1.inspect)(key)}`));
479
+ return mapValues(value, (v, key) => process(host, 'deserialize', v, { type: spec.CANONICAL_ANY }, `key ${(0, util_1.inspect)(key)}`), host);
480
480
  },
481
481
  },
482
482
  };
@@ -486,17 +486,17 @@ function serializeDate(value) {
486
486
  function deserializeDate(value) {
487
487
  return new Date(value[api_1.TOKEN_DATE]);
488
488
  }
489
- function deserializeEnum(value, lookup) {
489
+ function deserializeEnum(value, host) {
490
490
  const enumLocator = value[api_1.TOKEN_ENUM];
491
491
  const sep = enumLocator.lastIndexOf('/');
492
492
  if (sep === -1) {
493
- throw new SerializationError(`Invalid enum token value ${(0, util_1.inspect)(enumLocator)}`, value);
493
+ throw new SerializationError(`Invalid enum token value ${(0, util_1.inspect)(enumLocator)}`, value, host);
494
494
  }
495
495
  const typeName = enumLocator.slice(0, sep);
496
496
  const valueName = enumLocator.slice(sep + 1);
497
- const enumValue = lookup(typeName)[valueName];
497
+ const enumValue = host.findSymbol(typeName)[valueName];
498
498
  if (enumValue === undefined) {
499
- throw new SerializationError(`No such enum member: ${(0, util_1.inspect)(valueName)}`, value);
499
+ throw new SerializationError(`No such enum member: ${(0, util_1.inspect)(valueName)}`, value, host);
500
500
  }
501
501
  return enumValue;
502
502
  }
@@ -556,12 +556,12 @@ function serializationType(typeRef, lookup) {
556
556
  return [{ serializationClass: "RefType" /* SerializationClass.ReferenceType */, typeRef }];
557
557
  }
558
558
  exports.serializationType = serializationType;
559
- function nullAndOk(x, type) {
559
+ function nullAndOk(x, type, host) {
560
560
  if (x != null) {
561
561
  return false;
562
562
  }
563
563
  if (type !== 'void' && !type.optional) {
564
- throw new SerializationError(`A value is required (type is non-optional)`, x);
564
+ throw new SerializationError(`A value is required (type is non-optional)`, x, host);
565
565
  }
566
566
  return true;
567
567
  }
@@ -582,12 +582,12 @@ function flatMap(xs, fn) {
582
582
  /**
583
583
  * Map an object's values, skipping 'undefined' values'
584
584
  */
585
- function mapValues(value, fn) {
585
+ function mapValues(value, fn, host) {
586
586
  if (typeof value !== 'object' || value == null) {
587
- throw new SerializationError(`Value is not an object`, value);
587
+ throw new SerializationError(`Value is not an object`, value, host);
588
588
  }
589
589
  if (Array.isArray(value)) {
590
- throw new SerializationError(`Value is an array`, value);
590
+ throw new SerializationError(`Value is an array`, value, host);
591
591
  }
592
592
  const out = {};
593
593
  for (const [k, v] of Object.entries(value)) {
@@ -647,7 +647,7 @@ function isAssignable(actualTypeFqn, requiredType, lookup) {
647
647
  }
648
648
  return false;
649
649
  }
650
- function validateRequiredProps(actualProps, typeName, specProps) {
650
+ function validateRequiredProps(actualProps, typeName, specProps, host) {
651
651
  // Check for required properties
652
652
  const missingRequiredProps = Object.keys(specProps)
653
653
  .filter((name) => !specProps[name].optional)
@@ -655,7 +655,7 @@ function validateRequiredProps(actualProps, typeName, specProps) {
655
655
  if (missingRequiredProps.length > 0) {
656
656
  throw new SerializationError(`Missing required properties for ${typeName}: ${missingRequiredProps
657
657
  .map((p) => (0, util_1.inspect)(p))
658
- .join(', ')}`, actualProps);
658
+ .join(', ')}`, actualProps, host);
659
659
  }
660
660
  return actualProps;
661
661
  }
@@ -719,7 +719,7 @@ function process(host, serde, value, type, context) {
719
719
  }
720
720
  const typeDescr = type === VOID ? type : spec.describeTypeReference(type.type);
721
721
  const optionalTypeDescr = type !== VOID && type.optional ? `${typeDescr} | undefined` : typeDescr;
722
- throw new SerializationError(`${titleize(context)}: Unable to ${serde} value as ${optionalTypeDescr}`, value, errors, { renderValue: true });
722
+ throw new SerializationError(`${titleize(context)}: Unable to ${serde} value as ${optionalTypeDescr}`, value, host, errors, { renderValue: true });
723
723
  function titleize(text) {
724
724
  text = text.trim();
725
725
  if (text === '') {
@@ -731,12 +731,12 @@ function process(host, serde, value, type, context) {
731
731
  }
732
732
  exports.process = process;
733
733
  class SerializationError extends Error {
734
- constructor(message, value, causes = [], { renderValue = false } = {}) {
734
+ constructor(message, value, { isVisibleType }, causes = [], { renderValue = false } = {}) {
735
735
  super([
736
736
  message,
737
737
  ...(renderValue
738
738
  ? [
739
- `${causes.length > 0 ? '\u{251C}' : '\u{2570}'}\u{2500}\u{2500} \u{1F6D1} Failing value is ${describeTypeOf(value)}`,
739
+ `${causes.length > 0 ? '\u{251C}' : '\u{2570}'}\u{2500}\u{2500} \u{1F6D1} Failing value is ${describeTypeOf(value, isVisibleType)}`,
740
740
  ...(value == null
741
741
  ? []
742
742
  : (0, util_1.inspect)(value, false, 0)
@@ -762,7 +762,7 @@ class SerializationError extends Error {
762
762
  }
763
763
  }
764
764
  exports.SerializationError = SerializationError;
765
- function describeTypeOf(value) {
765
+ function describeTypeOf(value, isVisibleType) {
766
766
  const type = typeof value;
767
767
  switch (type) {
768
768
  case 'object':
@@ -772,7 +772,7 @@ function describeTypeOf(value) {
772
772
  if (Array.isArray(value)) {
773
773
  return 'an array';
774
774
  }
775
- const fqn = (0, objects_1.jsiiTypeFqn)(value);
775
+ const fqn = (0, objects_1.jsiiTypeFqn)(value, isVisibleType);
776
776
  if (fqn != null && fqn !== exports.EMPTY_OBJECT_FQN) {
777
777
  return `an instance of ${fqn}`;
778
778
  }
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- var _a;
2
+ var _a, _b;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.setPackageCacheEnabled = exports.getPackageCacheEnabled = exports.extract = void 0;
5
5
  const fs_1 = require("fs");
@@ -7,7 +7,8 @@ const tar = require("tar");
7
7
  const disk_cache_1 = require("../disk-cache");
8
8
  const link_1 = require("../link");
9
9
  const default_cache_root_1 = require("./default-cache-root");
10
- let packageCacheEnabled = ((_a = process.env.JSII_RUNTIME_PACKAGE_CACHE) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) === 'enabled';
10
+ let packageCacheEnabled = ((_b = (_a = process.env.JSII_RUNTIME_PACKAGE_CACHE) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) !== null && _b !== void 0 ? _b : 'enabled') ===
11
+ 'enabled';
11
12
  /**
12
13
  * Extracts the content of a tarball, possibly caching it on disk.
13
14
  *
@@ -18,7 +19,6 @@ let packageCacheEnabled = ((_a = process.env.JSII_RUNTIME_PACKAGE_CACHE) === nul
18
19
  * @returns the result of the extraction.
19
20
  */
20
21
  function extract(file, outDir, options, ...comments) {
21
- (0, fs_1.mkdirSync)(outDir, { recursive: true });
22
22
  try {
23
23
  return (packageCacheEnabled ? extractViaCache : extractToOutDir)(file, outDir, options, ...comments);
24
24
  }
@@ -61,6 +61,8 @@ function extractViaCache(file, outDir, options = {}, ...comments) {
61
61
  return { cache };
62
62
  }
63
63
  function extractToOutDir(file, cwd, options = {}) {
64
+ // The output directory must already exist...
65
+ (0, fs_1.mkdirSync)(cwd, { recursive: true });
64
66
  // !!!IMPORTANT!!!
65
67
  // Extract directly into the final target directory, as certain antivirus
66
68
  // software configurations on Windows will make a `renameSync` operation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsii/kernel",
3
- "version": "1.85.0",
3
+ "version": "1.86.0",
4
4
  "description": "kernel for jsii execution environment",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -31,19 +31,19 @@
31
31
  "package": "package-js"
32
32
  },
33
33
  "dependencies": {
34
- "@jsii/spec": "^1.85.0",
34
+ "@jsii/spec": "^1.86.0",
35
35
  "fs-extra": "^10.1.0",
36
36
  "lockfile": "^1.0.4",
37
37
  "tar": "^6.1.15"
38
38
  },
39
39
  "devDependencies": {
40
- "@scope/jsii-calc-base": "^1.85.0",
41
- "@scope/jsii-calc-lib": "^1.85.0",
40
+ "@scope/jsii-calc-base": "^1.86.0",
41
+ "@scope/jsii-calc-lib": "^1.86.0",
42
42
  "@types/fs-extra": "^9.0.13",
43
43
  "@types/lockfile": "^1.0.2",
44
44
  "@types/tar": "^6.1.5",
45
45
  "jest-expect-message": "^1.1.3",
46
- "jsii-build-tools": "^1.85.0",
46
+ "jsii-build-tools": "^1.86.0",
47
47
  "jsii-calc": "^3.20.120"
48
48
  }
49
49
  }