jsii-pacmak 1.63.0 → 1.63.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.
@@ -1,4 +1,4 @@
1
- import { Assembly, OptionalValue, TypeReference } from '@jsii/spec';
1
+ import { Assembly, OptionalValue, TypeReference, Type } from '@jsii/spec';
2
2
  export interface TypeName {
3
3
  pythonType(context: NamingContext): string;
4
4
  requiredImports(context: NamingContext): PythonImports;
@@ -17,6 +17,8 @@ export interface PythonImports {
17
17
  export interface NamingContext {
18
18
  /** The assembly in which the PythonType is expressed. */
19
19
  readonly assembly: Assembly;
20
+ /** A resolver to obtain complete information about a type. */
21
+ readonly typeResolver: (fqn: string) => Type;
20
22
  /** The submodule of the assembly in which the PythonType is expressed (could be the module root) */
21
23
  readonly submodule: string;
22
24
  /**
@@ -193,11 +193,18 @@ class UserType {
193
193
  }
194
194
  return { [requiredImport.sourcePackage]: new Set([requiredImport.item]) };
195
195
  }
196
- resolve({ assembly, emittedTypes, submodule, surroundingTypeFqns, typeAnnotation = true, }) {
196
+ resolve({ assembly, emittedTypes, submodule, surroundingTypeFqns, typeAnnotation = true, parameterType, typeResolver, }) {
197
197
  const { assemblyName, packageName, pythonFqn } = toPythonFqn(__classPrivateFieldGet(this, _UserType_fqn, "f"), assembly);
198
+ // If this is a type annotation for a parameter, allow dicts to be passed where structs are expected.
199
+ const type = typeResolver(__classPrivateFieldGet(this, _UserType_fqn, "f"));
200
+ const isStruct = (0, spec_1.isInterfaceType)(type) && !!type.datatype;
201
+ const wrapType = typeAnnotation && parameterType && isStruct
202
+ ? (pyType) => `typing.Union[${pyType}, typing.Dict[str, typing.Any]]`
203
+ : (pyType) => pyType;
198
204
  if (assemblyName !== assembly.name) {
199
205
  return {
200
- pythonType: pythonFqn,
206
+ // If it's a struct, then we allow passing as a dict, too...
207
+ pythonType: wrapType(pythonFqn),
201
208
  requiredImport: {
202
209
  sourcePackage: packageName,
203
210
  item: '',
@@ -219,7 +226,7 @@ class UserType {
219
226
  (!emittedTypes.has(__classPrivateFieldGet(this, _UserType_fqn, "f")) || nestingParent != null)) {
220
227
  // Possibly a forward reference, outputting the stringifierd python FQN
221
228
  return {
222
- pythonType: JSON.stringify(pythonFqn.substring(submodulePythonName.length + 1)),
229
+ pythonType: wrapType(JSON.stringify(pythonFqn.substring(submodulePythonName.length + 1))),
223
230
  };
224
231
  }
225
232
  if (!typeAnnotation && nestingParent) {
@@ -230,7 +237,7 @@ class UserType {
230
237
  }
231
238
  // We'll just make a module-qualified reference at this point.
232
239
  return {
233
- pythonType: pythonFqn.substring(submodulePythonName.length + 1),
240
+ pythonType: wrapType(pythonFqn.substring(submodulePythonName.length + 1)),
234
241
  };
235
242
  }
236
243
  const [toImport, ...nested] = pythonFqn
@@ -1726,6 +1726,7 @@ class PythonGenerator extends generator_1.Generator {
1726
1726
  emittedTypes: new Set(),
1727
1727
  resolver,
1728
1728
  submodule: assm.name,
1729
+ typeResolver: (fqn) => resolver.dereference(fqn),
1729
1730
  });
1730
1731
  }
1731
1732
  /**
package/lib/version.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** The short version number for this JSII compiler (e.g: `X.Y.Z`) */
2
- export declare const VERSION = "1.63.0";
2
+ export declare const VERSION = "1.63.1";
3
3
  /** The qualified version number for this JSII compiler (e.g: `X.Y.Z (build #######)`) */
4
- export declare const VERSION_DESC = "1.63.0 (build 7c24e36)";
4
+ export declare const VERSION_DESC = "1.63.1 (build 185bb34)";
5
5
  //# sourceMappingURL=version.d.ts.map
package/lib/version.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
- // Generated at 2022-07-26T16:29:28Z by generate.sh
2
+ // Generated at 2022-07-27T18:06:20Z by generate.sh
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.VERSION_DESC = exports.VERSION = void 0;
5
5
  /** The short version number for this JSII compiler (e.g: `X.Y.Z`) */
6
- exports.VERSION = '1.63.0';
6
+ exports.VERSION = '1.63.1';
7
7
  /** The qualified version number for this JSII compiler (e.g: `X.Y.Z (build #######)`) */
8
- exports.VERSION_DESC = '1.63.0 (build 7c24e36)';
8
+ exports.VERSION_DESC = '1.63.1 (build 185bb34)';
9
9
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsii-pacmak",
3
- "version": "1.63.0",
3
+ "version": "1.63.1",
4
4
  "description": "A code generation framework for jsii backend languages",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -37,31 +37,31 @@
37
37
  "package": "package-js"
38
38
  },
39
39
  "dependencies": {
40
- "@jsii/check-node": "1.63.0",
41
- "@jsii/spec": "^1.63.0",
40
+ "@jsii/check-node": "1.63.1",
41
+ "@jsii/spec": "^1.63.1",
42
42
  "clone": "^2.1.2",
43
- "codemaker": "^1.63.0",
43
+ "codemaker": "^1.63.1",
44
44
  "commonmark": "^0.30.0",
45
45
  "escape-string-regexp": "^4.0.0",
46
46
  "fs-extra": "^10.1.0",
47
- "jsii-reflect": "^1.63.0",
48
- "jsii-rosetta": "^1.63.0",
47
+ "jsii-reflect": "^1.63.1",
48
+ "jsii-rosetta": "^1.63.1",
49
49
  "semver": "^7.3.7",
50
50
  "spdx-license-list": "^6.6.0",
51
51
  "xmlbuilder": "^15.1.1",
52
52
  "yargs": "^16.2.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@jsii/dotnet-runtime": "^1.63.0",
56
- "@jsii/java-runtime": "^1.63.0",
57
- "@jsii/go-runtime": "^1.63.0",
58
- "@scope/jsii-calc-lib": "^1.63.0",
55
+ "@jsii/dotnet-runtime": "^1.63.1",
56
+ "@jsii/java-runtime": "^1.63.1",
57
+ "@jsii/go-runtime": "^1.63.1",
58
+ "@scope/jsii-calc-lib": "^1.63.1",
59
59
  "@types/clone": "^2.1.1",
60
60
  "@types/commonmark": "^0.27.5",
61
61
  "@types/fs-extra": "^9.0.13",
62
62
  "@types/semver": "^7.3.10",
63
- "jsii": "^1.63.0",
64
- "jsii-build-tools": "^1.63.0",
63
+ "jsii": "^1.63.1",
64
+ "jsii-build-tools": "^1.63.1",
65
65
  "jsii-calc": "^3.20.120"
66
66
  },
67
67
  "keywords": [