jsii-pacmak 1.69.0 → 1.71.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.
- package/lib/targets/go/package.d.ts +1 -1
- package/lib/targets/go/package.js +1 -3
- package/lib/targets/go.js +3 -5
- package/lib/targets/python/type-name.d.ts +0 -10
- package/lib/targets/python/type-name.js +1 -15
- package/lib/targets/python.d.ts +2 -0
- package/lib/targets/python.js +34 -15
- package/lib/version.d.ts +1 -1
- package/lib/version.js +3 -3
- package/package.json +15 -15
|
@@ -3,7 +3,7 @@ import { Assembly, ModuleLike as JsiiModuleLike, Submodule as JsiiSubmodule } fr
|
|
|
3
3
|
import { EmitContext } from './emit-context';
|
|
4
4
|
import { GoClass, GoType, GoInterface, GoTypeRef } from './types';
|
|
5
5
|
export declare const GOMOD_FILENAME = "go.mod";
|
|
6
|
-
export declare const GO_VERSION = "1.
|
|
6
|
+
export declare const GO_VERSION = "1.18";
|
|
7
7
|
export declare abstract class Package {
|
|
8
8
|
private readonly jsiiModule;
|
|
9
9
|
readonly packageName: string;
|
|
@@ -11,7 +11,7 @@ const types_1 = require("./types");
|
|
|
11
11
|
const util_1 = require("./util");
|
|
12
12
|
const version_file_1 = require("./version-file");
|
|
13
13
|
exports.GOMOD_FILENAME = 'go.mod';
|
|
14
|
-
exports.GO_VERSION = '1.
|
|
14
|
+
exports.GO_VERSION = '1.18';
|
|
15
15
|
/*
|
|
16
16
|
* Package represents a single `.go` source file within a package. This can be the root package file or a submodule
|
|
17
17
|
*/
|
|
@@ -191,8 +191,6 @@ class Package {
|
|
|
191
191
|
code.openFile(filePath);
|
|
192
192
|
// Conditional compilation tag...
|
|
193
193
|
code.line(`//go:build ${forNoOp ? '' : '!'}no_runtime_type_checking`);
|
|
194
|
-
// For go1.16 compatibility
|
|
195
|
-
code.line(`// +build ${forNoOp ? '' : '!'}no_runtime_type_checking`);
|
|
196
194
|
code.line();
|
|
197
195
|
this.emitHeader(code);
|
|
198
196
|
if (!forNoOp) {
|
package/lib/targets/go.js
CHANGED
|
@@ -33,11 +33,9 @@ class Golang extends target_1.Target {
|
|
|
33
33
|
const localGoMod = await this.writeLocalGoMod(pkgDir);
|
|
34
34
|
try {
|
|
35
35
|
// run `go build` with local.go.mod, go 1.16+ requires that we download
|
|
36
|
-
// modules explicit so go.sum is updated. We'd
|
|
37
|
-
// `go mod download`, but
|
|
38
|
-
// `go mod tidy`
|
|
39
|
-
//
|
|
40
|
-
// See: https://github.com/golang/go/issues/44129
|
|
36
|
+
// modules explicit so go.sum is updated. We'd want to use
|
|
37
|
+
// `go mod download`, but it does not add missing entries in the `go.sum`
|
|
38
|
+
// file while `go mod tidy` does.
|
|
41
39
|
await go('mod', ['tidy', '-modfile', localGoMod.path], {
|
|
42
40
|
cwd: pkgDir,
|
|
43
41
|
});
|
|
@@ -70,14 +70,4 @@ export declare function toPythonFqn(fqn: string, rootAssm: Assembly): {
|
|
|
70
70
|
packageName: string;
|
|
71
71
|
pythonFqn: string;
|
|
72
72
|
};
|
|
73
|
-
/**
|
|
74
|
-
* Computes the nesting-qualified name of a type.
|
|
75
|
-
*
|
|
76
|
-
* @param fqn the fully qualified jsii name of the type.
|
|
77
|
-
* @param rootAssm the root assembly for the project.
|
|
78
|
-
*
|
|
79
|
-
* @returns the nesting-qualified python type name (the name of the class,
|
|
80
|
-
* qualified with all nesting parent classes).
|
|
81
|
-
*/
|
|
82
|
-
export declare function toPythonFullName(fqn: string, rootAssm: Assembly): string;
|
|
83
73
|
//# sourceMappingURL=type-name.d.ts.map
|
|
@@ -12,7 +12,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
12
12
|
};
|
|
13
13
|
var _Dict_element, _List_element, _Optional_wrapped, _Primitive_pythonType, _Union_options, _UserType_fqn;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.toPythonFqn = exports.mergePythonImports = exports.toPackageName = exports.toTypeName = void 0;
|
|
16
16
|
const spec_1 = require("@jsii/spec");
|
|
17
17
|
const codemaker_1 = require("codemaker");
|
|
18
18
|
const crypto_1 = require("crypto");
|
|
@@ -269,20 +269,6 @@ function toPythonFqn(fqn, rootAssm) {
|
|
|
269
269
|
return { assemblyName, packageName, pythonFqn: fqnParts.join('.') };
|
|
270
270
|
}
|
|
271
271
|
exports.toPythonFqn = toPythonFqn;
|
|
272
|
-
/**
|
|
273
|
-
* Computes the nesting-qualified name of a type.
|
|
274
|
-
*
|
|
275
|
-
* @param fqn the fully qualified jsii name of the type.
|
|
276
|
-
* @param rootAssm the root assembly for the project.
|
|
277
|
-
*
|
|
278
|
-
* @returns the nesting-qualified python type name (the name of the class,
|
|
279
|
-
* qualified with all nesting parent classes).
|
|
280
|
-
*/
|
|
281
|
-
function toPythonFullName(fqn, rootAssm) {
|
|
282
|
-
const { packageName, pythonFqn } = toPythonFqn(fqn, rootAssm);
|
|
283
|
-
return pythonFqn.slice(packageName.length + 1);
|
|
284
|
-
}
|
|
285
|
-
exports.toPythonFullName = toPythonFullName;
|
|
286
272
|
/**
|
|
287
273
|
* Computes the python relative import path from `fromModule` to `toModule`.
|
|
288
274
|
*
|
package/lib/targets/python.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ interface EmitContext extends NamingContext {
|
|
|
15
15
|
readonly resolver: TypeResolver;
|
|
16
16
|
/** Whether to emit runtime type checking code */
|
|
17
17
|
readonly runtimeTypeChecking: boolean;
|
|
18
|
+
/** Whether to runtime type check keyword arguments (i.e: struct constructors) */
|
|
19
|
+
readonly runtimeTypeCheckKwargs?: boolean;
|
|
18
20
|
}
|
|
19
21
|
interface PythonBase {
|
|
20
22
|
readonly pythonName: string;
|
package/lib/targets/python.js
CHANGED
|
@@ -441,7 +441,7 @@ class BaseMethod {
|
|
|
441
441
|
});
|
|
442
442
|
if ((this.shouldEmitBody || forceEmitBody) &&
|
|
443
443
|
(!renderAbstract || !this.abstract)) {
|
|
444
|
-
emitParameterTypeChecks(code, context, pythonParams.slice(1)
|
|
444
|
+
emitParameterTypeChecks(code, context, pythonParams.slice(1));
|
|
445
445
|
}
|
|
446
446
|
this.emitBody(code, context, renderAbstract, forceEmitBody, liftedPropNames, pythonParams[0], returnType);
|
|
447
447
|
code.closeBlock();
|
|
@@ -598,11 +598,7 @@ class BaseProperty {
|
|
|
598
598
|
openSignature(code, 'def', this.pythonName, [this.implicitParameter, `value: ${pythonType}`], 'None');
|
|
599
599
|
if ((this.shouldEmitBody || forceEmitBody) &&
|
|
600
600
|
(!renderAbstract || !this.abstract)) {
|
|
601
|
-
emitParameterTypeChecks(code, context, [`value: ${pythonType}`]
|
|
602
|
-
// In order to get a property accessor, we must resort to getting the
|
|
603
|
-
// attribute on the type, instead of the value (where the getter would
|
|
604
|
-
// be implicitly invoked for us...)
|
|
605
|
-
`getattr(${(0, type_name_1.toPythonFullName)(this.parent.fqn, context.assembly)}, ${JSON.stringify(this.pythonName)}).fset`);
|
|
601
|
+
emitParameterTypeChecks(code, context, [`value: ${pythonType}`]);
|
|
606
602
|
code.line(`jsii.${this.jsiiSetMethod}(${this.implicitParameter}, "${this.jsName}", value)`);
|
|
607
603
|
}
|
|
608
604
|
else {
|
|
@@ -748,7 +744,11 @@ class Struct extends BasePythonClassType {
|
|
|
748
744
|
code.line(`${member.pythonName} = ${typeName}(**${member.pythonName})`);
|
|
749
745
|
code.closeBlock();
|
|
750
746
|
}
|
|
751
|
-
|
|
747
|
+
if (kwargs.length > 0) {
|
|
748
|
+
emitParameterTypeChecks(code,
|
|
749
|
+
// Runtime type check keyword args as this is a struct __init__ function.
|
|
750
|
+
{ ...context, runtimeTypeCheckKwargs: true }, ['*', ...kwargs]);
|
|
751
|
+
}
|
|
752
752
|
// Required properties, those will always be put into the dict
|
|
753
753
|
assignDictionary(code, `${implicitParameter}._values: typing.Dict[str, typing.Any]`, members
|
|
754
754
|
.filter((m) => !m.optional)
|
|
@@ -2015,10 +2015,10 @@ function openSignature(code, keyword, name, params, returnType, lineComment) {
|
|
|
2015
2015
|
* Emits runtime type checking code for parameters.
|
|
2016
2016
|
*
|
|
2017
2017
|
* @param code the CodeMaker to use for emitting code.
|
|
2018
|
+
* @param context the emit context used when emitting this code.
|
|
2018
2019
|
* @param params the parameter signatures to be type-checked.
|
|
2019
|
-
* @param typedEntity the type-annotated entity.
|
|
2020
2020
|
*/
|
|
2021
|
-
function emitParameterTypeChecks(code, context, params
|
|
2021
|
+
function emitParameterTypeChecks(code, context, params) {
|
|
2022
2022
|
if (!context.runtimeTypeChecking) {
|
|
2023
2023
|
return;
|
|
2024
2024
|
}
|
|
@@ -2032,19 +2032,38 @@ function emitParameterTypeChecks(code, context, params, typedEntity) {
|
|
|
2032
2032
|
}
|
|
2033
2033
|
return { name };
|
|
2034
2034
|
});
|
|
2035
|
-
const
|
|
2035
|
+
const paramNames = paramInfo
|
|
2036
2036
|
.filter((param) => param.name != null)
|
|
2037
|
-
.map((param) => param.name.split(/\s*:\s*/)[0])
|
|
2037
|
+
.map((param) => param.name.split(/\s*:\s*/)[0]);
|
|
2038
|
+
const typesVar = slugifyAsNeeded('type_hints', paramNames);
|
|
2038
2039
|
let openedBlock = false;
|
|
2039
2040
|
for (const { is_rest, kwargsMark, name } of paramInfo) {
|
|
2040
2041
|
if (kwargsMark) {
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2042
|
+
if (!context.runtimeTypeCheckKwargs) {
|
|
2043
|
+
// This is the keyword-args separator, we won't check keyword arguments here because the kwargs will be rolled
|
|
2044
|
+
// up into a struct instance, and that struct's constructor will be checking again...
|
|
2045
|
+
break;
|
|
2046
|
+
}
|
|
2047
|
+
// Skip this (there is nothing to be checked as this is just a marker...)
|
|
2048
|
+
continue;
|
|
2044
2049
|
}
|
|
2045
2050
|
if (!openedBlock) {
|
|
2046
2051
|
code.openBlock('if __debug__');
|
|
2047
|
-
|
|
2052
|
+
const stubVar = slugifyAsNeeded('stub', [...paramNames, typesVar]);
|
|
2053
|
+
// Inline a stub function to be able to have the required type hints regardless of what customers do with the
|
|
2054
|
+
// code. Using a reference to the `Type.function` may result in incorrect data if some function was replaced (e.g.
|
|
2055
|
+
// by a decorated version with different type annotations). We also cannot construct the actual value expected by
|
|
2056
|
+
// typeguard's `check_type` because Python does not expose the APIs necessary to build many of these objects in
|
|
2057
|
+
// regular Python code.
|
|
2058
|
+
//
|
|
2059
|
+
// Since the nesting function will only be callable once this module is fully loaded, we can convert forward type
|
|
2060
|
+
// references into regular references, so that the type checker is not confused by multiple type references
|
|
2061
|
+
// sharing the same leaf type name (the ForwardRef resolution may be cached in the execution scope, which causes
|
|
2062
|
+
// order-of-initialization problems, as can be seen in aws/jsii#3818).
|
|
2063
|
+
openSignature(code, 'def', stubVar, params.map((param) => param.replace(/"/g, '')), 'None');
|
|
2064
|
+
code.line('...');
|
|
2065
|
+
code.closeBlock();
|
|
2066
|
+
code.line(`${typesVar} = typing.get_type_hints(${stubVar})`);
|
|
2048
2067
|
openedBlock = true;
|
|
2049
2068
|
}
|
|
2050
2069
|
let expectedType = `${typesVar}[${JSON.stringify(name)}]`;
|
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
2
|
export declare const VERSION: string;
|
|
3
3
|
/** The qualified version number for this JSII compiler (e.g: `X.Y.Z (build #######)`) */
|
|
4
|
-
export declare const VERSION_DESC = "1.
|
|
4
|
+
export declare const VERSION_DESC = "1.71.0 (build f1f58ae)";
|
|
5
5
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/version.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Generated at 2022-
|
|
2
|
+
// Generated at 2022-11-09T12:10:33Z 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
6
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
7
|
-
exports.VERSION = '1.
|
|
7
|
+
exports.VERSION = '1.71.0';
|
|
8
8
|
/** The qualified version number for this JSII compiler (e.g: `X.Y.Z (build #######)`) */
|
|
9
|
-
exports.VERSION_DESC = '1.
|
|
9
|
+
exports.VERSION_DESC = '1.71.0 (build f1f58ae)';
|
|
10
10
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsii-pacmak",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.71.0",
|
|
4
4
|
"description": "A code generation framework for jsii backend languages",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,35 +37,35 @@
|
|
|
37
37
|
"package": "package-js"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@jsii/check-node": "1.
|
|
41
|
-
"@jsii/spec": "^1.
|
|
40
|
+
"@jsii/check-node": "1.71.0",
|
|
41
|
+
"@jsii/spec": "^1.71.0",
|
|
42
42
|
"clone": "^2.1.2",
|
|
43
|
-
"codemaker": "^1.
|
|
43
|
+
"codemaker": "^1.71.0",
|
|
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.
|
|
48
|
-
"jsii-rosetta": "^1.
|
|
49
|
-
"semver": "^7.3.
|
|
47
|
+
"jsii-reflect": "^1.71.0",
|
|
48
|
+
"jsii-rosetta": "^1.71.0",
|
|
49
|
+
"semver": "^7.3.8",
|
|
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.
|
|
56
|
-
"@jsii/java-runtime": "^1.
|
|
57
|
-
"@jsii/go-runtime": "^1.
|
|
58
|
-
"@scope/jsii-calc-lib": "^1.
|
|
55
|
+
"@jsii/dotnet-runtime": "^1.71.0",
|
|
56
|
+
"@jsii/java-runtime": "^1.71.0",
|
|
57
|
+
"@jsii/go-runtime": "^1.71.0",
|
|
58
|
+
"@scope/jsii-calc-lib": "^1.71.0",
|
|
59
59
|
"@types/clone": "^2.1.1",
|
|
60
60
|
"@types/diff": "^5.0.2",
|
|
61
61
|
"@types/commonmark": "^0.27.5",
|
|
62
62
|
"@types/fs-extra": "^9.0.13",
|
|
63
|
-
"@types/semver": "^7.3.
|
|
63
|
+
"@types/semver": "^7.3.13",
|
|
64
64
|
"diff": "^5.1.0",
|
|
65
|
-
"jsii": "^1.
|
|
66
|
-
"jsii-build-tools": "^1.
|
|
65
|
+
"jsii": "^1.71.0",
|
|
66
|
+
"jsii-build-tools": "^1.71.0",
|
|
67
67
|
"jsii-calc": "^3.20.120",
|
|
68
|
-
"pyright": "^1.1.
|
|
68
|
+
"pyright": "^1.1.278"
|
|
69
69
|
},
|
|
70
70
|
"keywords": [
|
|
71
71
|
"jsii",
|