@typespec/emitter-framework 0.15.0-dev.3 → 0.15.0-dev.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/CHANGELOG.md +1 -16
- package/dist/src/python/builtins.d.ts +14 -0
- package/dist/src/python/builtins.d.ts.map +1 -0
- package/dist/src/python/builtins.js +29 -0
- package/dist/src/python/builtins.js.map +1 -0
- package/dist/src/python/components/array-expression/array-expression.d.ts +6 -0
- package/dist/src/python/components/array-expression/array-expression.d.ts.map +1 -0
- package/dist/src/python/components/array-expression/array-expression.js +11 -0
- package/dist/src/python/components/array-expression/array-expression.js.map +1 -0
- package/dist/src/python/components/array-expression/array-expression.test.d.ts +2 -0
- package/dist/src/python/components/array-expression/array-expression.test.d.ts.map +1 -0
- package/dist/src/python/components/array-expression/array-expression.test.js +19 -0
- package/dist/src/python/components/array-expression/array-expression.test.js.map +1 -0
- package/dist/src/python/components/array-expression/index.d.ts +2 -0
- package/dist/src/python/components/array-expression/index.d.ts.map +1 -0
- package/dist/src/python/components/array-expression/index.js +2 -0
- package/dist/src/python/components/array-expression/index.js.map +1 -0
- package/dist/src/python/components/atom/atom.d.ts +33 -0
- package/dist/src/python/components/atom/atom.d.ts.map +1 -0
- package/dist/src/python/components/atom/atom.js +88 -0
- package/dist/src/python/components/atom/atom.js.map +1 -0
- package/dist/src/python/components/atom/atom.test.d.ts +2 -0
- package/dist/src/python/components/atom/atom.test.d.ts.map +1 -0
- package/dist/src/python/components/atom/atom.test.js +224 -0
- package/dist/src/python/components/atom/atom.test.js.map +1 -0
- package/dist/src/python/components/atom/index.d.ts +2 -0
- package/dist/src/python/components/atom/index.d.ts.map +1 -0
- package/dist/src/python/components/atom/index.js +2 -0
- package/dist/src/python/components/atom/index.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-bases.d.ts +45 -0
- package/dist/src/python/components/class-declaration/class-bases.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-bases.js +84 -0
- package/dist/src/python/components/class-declaration/class-bases.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-body.d.ts +16 -0
- package/dist/src/python/components/class-declaration/class-body.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-body.js +52 -0
- package/dist/src/python/components/class-declaration/class-body.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-declaration.d.ts +23 -0
- package/dist/src/python/components/class-declaration/class-declaration.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-declaration.js +118 -0
- package/dist/src/python/components/class-declaration/class-declaration.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-declaration.test.d.ts +2 -0
- package/dist/src/python/components/class-declaration/class-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-declaration.test.js +1527 -0
- package/dist/src/python/components/class-declaration/class-declaration.test.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-member.d.ts +16 -0
- package/dist/src/python/components/class-declaration/class-member.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-member.js +71 -0
- package/dist/src/python/components/class-declaration/class-member.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-member.test.d.ts +2 -0
- package/dist/src/python/components/class-declaration/class-member.test.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-member.test.js +202 -0
- package/dist/src/python/components/class-declaration/class-member.test.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-method.d.ts +22 -0
- package/dist/src/python/components/class-declaration/class-method.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-method.js +76 -0
- package/dist/src/python/components/class-declaration/class-method.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-method.test.d.ts +2 -0
- package/dist/src/python/components/class-declaration/class-method.test.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-method.test.js +298 -0
- package/dist/src/python/components/class-declaration/class-method.test.js.map +1 -0
- package/dist/src/python/components/class-declaration/index.d.ts +7 -0
- package/dist/src/python/components/class-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/index.js +7 -0
- package/dist/src/python/components/class-declaration/index.js.map +1 -0
- package/dist/src/python/components/class-declaration/primitive-initializer.d.ts +22 -0
- package/dist/src/python/components/class-declaration/primitive-initializer.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/primitive-initializer.js +67 -0
- package/dist/src/python/components/class-declaration/primitive-initializer.js.map +1 -0
- package/dist/src/python/components/doc-element/doc-element.d.ts +46 -0
- package/dist/src/python/components/doc-element/doc-element.d.ts.map +1 -0
- package/dist/src/python/components/doc-element/doc-element.js +59 -0
- package/dist/src/python/components/doc-element/doc-element.js.map +1 -0
- package/dist/src/python/components/doc-element/index.d.ts +2 -0
- package/dist/src/python/components/doc-element/index.d.ts.map +1 -0
- package/dist/src/python/components/doc-element/index.js +2 -0
- package/dist/src/python/components/doc-element/index.js.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.d.ts +8 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.d.ts.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.js +80 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.js.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.test.d.ts +2 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.test.js +344 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.test.js.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-member.d.ts +9 -0
- package/dist/src/python/components/enum-declaration/enum-member.d.ts.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-member.js +22 -0
- package/dist/src/python/components/enum-declaration/enum-member.js.map +1 -0
- package/dist/src/python/components/enum-declaration/index.d.ts +3 -0
- package/dist/src/python/components/enum-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/enum-declaration/index.js +3 -0
- package/dist/src/python/components/enum-declaration/index.js.map +1 -0
- package/dist/src/python/components/function-declaration/function-declaration.d.ts +24 -0
- package/dist/src/python/components/function-declaration/function-declaration.d.ts.map +1 -0
- package/dist/src/python/components/function-declaration/function-declaration.js +68 -0
- package/dist/src/python/components/function-declaration/function-declaration.js.map +1 -0
- package/dist/src/python/components/function-declaration/function-declaration.test.d.ts +2 -0
- package/dist/src/python/components/function-declaration/function-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/function-declaration/function-declaration.test.js +682 -0
- package/dist/src/python/components/function-declaration/function-declaration.test.js.map +1 -0
- package/dist/src/python/components/function-declaration/index.d.ts +2 -0
- package/dist/src/python/components/function-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/function-declaration/index.js +2 -0
- package/dist/src/python/components/function-declaration/index.js.map +1 -0
- package/dist/src/python/components/index.d.ts +12 -0
- package/dist/src/python/components/index.d.ts.map +1 -0
- package/dist/src/python/components/index.js +12 -0
- package/dist/src/python/components/index.js.map +1 -0
- package/dist/src/python/components/protocol-declaration/callable-parameters.d.ts +25 -0
- package/dist/src/python/components/protocol-declaration/callable-parameters.d.ts.map +1 -0
- package/dist/src/python/components/protocol-declaration/callable-parameters.js +33 -0
- package/dist/src/python/components/protocol-declaration/callable-parameters.js.map +1 -0
- package/dist/src/python/components/protocol-declaration/index.d.ts +3 -0
- package/dist/src/python/components/protocol-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/protocol-declaration/index.js +3 -0
- package/dist/src/python/components/protocol-declaration/index.js.map +1 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.d.ts +8 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.d.ts.map +1 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.js +86 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.js.map +1 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.test.d.ts +2 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.test.js +117 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.test.js.map +1 -0
- package/dist/src/python/components/record-expression/index.d.ts +2 -0
- package/dist/src/python/components/record-expression/index.d.ts.map +1 -0
- package/dist/src/python/components/record-expression/index.js +2 -0
- package/dist/src/python/components/record-expression/index.js.map +1 -0
- package/dist/src/python/components/record-expression/record-expression.d.ts +6 -0
- package/dist/src/python/components/record-expression/record-expression.d.ts.map +1 -0
- package/dist/src/python/components/record-expression/record-expression.js +13 -0
- package/dist/src/python/components/record-expression/record-expression.js.map +1 -0
- package/dist/src/python/components/record-expression/record-expression.test.d.ts +2 -0
- package/dist/src/python/components/record-expression/record-expression.test.d.ts.map +1 -0
- package/dist/src/python/components/record-expression/record-expression.test.js +19 -0
- package/dist/src/python/components/record-expression/record-expression.test.js.map +1 -0
- package/dist/src/python/components/type-alias-declaration/index.d.ts +2 -0
- package/dist/src/python/components/type-alias-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/type-alias-declaration/index.js +2 -0
- package/dist/src/python/components/type-alias-declaration/index.js.map +1 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.d.ts +16 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.d.ts.map +1 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.js +75 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.js.map +1 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.d.ts +2 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.js +140 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.js.map +1 -0
- package/dist/src/python/components/type-declaration/index.d.ts +2 -0
- package/dist/src/python/components/type-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/type-declaration/index.js +2 -0
- package/dist/src/python/components/type-declaration/index.js.map +1 -0
- package/dist/src/python/components/type-declaration/type-declaration.d.ts +11 -0
- package/dist/src/python/components/type-declaration/type-declaration.d.ts.map +1 -0
- package/dist/src/python/components/type-declaration/type-declaration.js +31 -0
- package/dist/src/python/components/type-declaration/type-declaration.js.map +1 -0
- package/dist/src/python/components/type-declaration/type-declaration.test.d.ts +2 -0
- package/dist/src/python/components/type-declaration/type-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/type-declaration/type-declaration.test.js +69 -0
- package/dist/src/python/components/type-declaration/type-declaration.test.js.map +1 -0
- package/dist/src/python/components/type-expression/index.d.ts +2 -0
- package/dist/src/python/components/type-expression/index.d.ts.map +1 -0
- package/dist/src/python/components/type-expression/index.js +2 -0
- package/dist/src/python/components/type-expression/index.js.map +1 -0
- package/dist/src/python/components/type-expression/type-expression.d.ts +12 -0
- package/dist/src/python/components/type-expression/type-expression.d.ts.map +1 -0
- package/dist/src/python/components/type-expression/type-expression.js +348 -0
- package/dist/src/python/components/type-expression/type-expression.js.map +1 -0
- package/dist/src/python/components/type-expression/type-expression.test.d.ts +2 -0
- package/dist/src/python/components/type-expression/type-expression.test.d.ts.map +1 -0
- package/dist/src/python/components/type-expression/type-expression.test.js +503 -0
- package/dist/src/python/components/type-expression/type-expression.test.js.map +1 -0
- package/dist/src/python/index.d.ts +4 -0
- package/dist/src/python/index.d.ts.map +1 -0
- package/dist/src/python/index.js +4 -0
- package/dist/src/python/index.js.map +1 -0
- package/dist/src/python/lib.d.ts +68 -0
- package/dist/src/python/lib.d.ts.map +1 -0
- package/dist/src/python/lib.js +38 -0
- package/dist/src/python/lib.js.map +1 -0
- package/dist/src/python/test-utils.d.ts +8 -0
- package/dist/src/python/test-utils.d.ts.map +1 -0
- package/dist/src/python/test-utils.js +25 -0
- package/dist/src/python/test-utils.js.map +1 -0
- package/dist/src/python/utils/index.d.ts +4 -0
- package/dist/src/python/utils/index.d.ts.map +1 -0
- package/dist/src/python/utils/index.js +4 -0
- package/dist/src/python/utils/index.js.map +1 -0
- package/dist/src/python/utils/operation.d.ts +27 -0
- package/dist/src/python/utils/operation.d.ts.map +1 -0
- package/dist/src/python/utils/operation.js +139 -0
- package/dist/src/python/utils/operation.js.map +1 -0
- package/dist/src/python/utils/refkey.d.ts +23 -0
- package/dist/src/python/utils/refkey.d.ts.map +1 -0
- package/dist/src/python/utils/refkey.js +36 -0
- package/dist/src/python/utils/refkey.js.map +1 -0
- package/dist/src/python/utils/type.d.ts +19 -0
- package/dist/src/python/utils/type.d.ts.map +1 -0
- package/dist/src/python/utils/type.js +24 -0
- package/dist/src/python/utils/type.js.map +1 -0
- package/package.json +9 -1
- package/package.json.bak +10 -1
- package/src/python/builtins.ts +43 -0
- package/src/python/components/array-expression/array-expression.test.tsx +14 -0
- package/src/python/components/array-expression/array-expression.tsx +11 -0
- package/src/python/components/array-expression/index.ts +1 -0
- package/src/python/components/atom/atom.test.tsx +244 -0
- package/src/python/components/atom/atom.tsx +95 -0
- package/src/python/components/atom/index.ts +1 -0
- package/src/python/components/class-declaration/class-bases.tsx +92 -0
- package/src/python/components/class-declaration/class-body.tsx +56 -0
- package/src/python/components/class-declaration/class-declaration.test.tsx +1414 -0
- package/src/python/components/class-declaration/class-declaration.tsx +116 -0
- package/src/python/components/class-declaration/class-member.test.tsx +194 -0
- package/src/python/components/class-declaration/class-member.tsx +67 -0
- package/src/python/components/class-declaration/class-method.test.tsx +250 -0
- package/src/python/components/class-declaration/class-method.tsx +97 -0
- package/src/python/components/class-declaration/index.ts +6 -0
- package/src/python/components/class-declaration/primitive-initializer.tsx +62 -0
- package/src/python/components/doc-element/doc-element.tsx +83 -0
- package/src/python/components/doc-element/index.ts +1 -0
- package/src/python/components/enum-declaration/enum-declaration.test.tsx +319 -0
- package/src/python/components/enum-declaration/enum-declaration.tsx +77 -0
- package/src/python/components/enum-declaration/enum-member.tsx +21 -0
- package/src/python/components/enum-declaration/index.ts +2 -0
- package/src/python/components/function-declaration/function-declaration.test.tsx +582 -0
- package/src/python/components/function-declaration/function-declaration.tsx +90 -0
- package/src/python/components/function-declaration/index.ts +1 -0
- package/src/python/components/index.ts +11 -0
- package/src/python/components/protocol-declaration/callable-parameters.tsx +44 -0
- package/src/python/components/protocol-declaration/index.ts +2 -0
- package/src/python/components/protocol-declaration/protocol-declaration.test.tsx +106 -0
- package/src/python/components/protocol-declaration/protocol-declaration.tsx +73 -0
- package/src/python/components/record-expression/index.ts +1 -0
- package/src/python/components/record-expression/record-expression.test.tsx +14 -0
- package/src/python/components/record-expression/record-expression.tsx +13 -0
- package/src/python/components/type-alias-declaration/index.ts +1 -0
- package/src/python/components/type-alias-declaration/type-alias-declaration.test.tsx +117 -0
- package/src/python/components/type-alias-declaration/type-alias-declaration.tsx +67 -0
- package/src/python/components/type-declaration/index.ts +1 -0
- package/src/python/components/type-declaration/type-declaration.test.tsx +58 -0
- package/src/python/components/type-declaration/type-declaration.tsx +26 -0
- package/src/python/components/type-expression/index.ts +1 -0
- package/src/python/components/type-expression/type-expression.test.tsx +463 -0
- package/src/python/components/type-expression/type-expression.tsx +333 -0
- package/src/python/index.ts +3 -0
- package/src/python/lib.ts +40 -0
- package/src/python/test-utils.tsx +31 -0
- package/src/python/utils/index.ts +3 -0
- package/src/python/utils/operation.ts +161 -0
- package/src/python/utils/refkey.ts +36 -0
- package/src/python/utils/type.ts +31 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Output } from "#core/components/index.js";
|
|
3
|
+
import * as py from "@alloy-js/python";
|
|
4
|
+
import { abcModule, datetimeModule, decimalModule, typingModule } from "./builtins.js";
|
|
5
|
+
export const renderOptions = {
|
|
6
|
+
printWidth: 80,
|
|
7
|
+
tabWidth: 4
|
|
8
|
+
};
|
|
9
|
+
export function getOutput(program, children) {
|
|
10
|
+
const policy = py.createPythonNamePolicy();
|
|
11
|
+
return _$createComponent(Output, {
|
|
12
|
+
program: program,
|
|
13
|
+
get externals() {
|
|
14
|
+
return [abcModule, datetimeModule, decimalModule, typingModule, py.abcModule, py.dataclassesModule, py.enumModule];
|
|
15
|
+
},
|
|
16
|
+
namePolicy: policy,
|
|
17
|
+
get children() {
|
|
18
|
+
return _$createComponent(py.SourceFile, {
|
|
19
|
+
path: "test.py",
|
|
20
|
+
children: children
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=test-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Output","py","abcModule","datetimeModule","decimalModule","typingModule","renderOptions","printWidth","tabWidth","getOutput","program","children","policy","createPythonNamePolicy","_$createComponent","externals","dataclassesModule","enumModule","namePolicy","SourceFile","path"],"sources":["../../../src/python/test-utils.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,QAAQ,2BAA2B;AAElD,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AAEtC,SAASC,SAAS,EAAEC,cAAc,EAAEC,aAAa,EAAEC,YAAY,QAAQ,eAAe;AAEtF,OAAO,MAAMC,aAAa,GAAG;EAC3BC,UAAU,EAAE,EAAE;EACdC,QAAQ,EAAE;AACZ,CAAC;AAED,OAAO,SAASC,SAASA,CAACC,OAAgB,EAAEC,QAAoB,EAAY;EAC1E,MAAMC,MAAM,GAAGX,EAAE,CAACY,sBAAsB,CAAC,CAAC;EAC1C,OAAAC,iBAAA,CACGd,MAAM;IACLU,OAAO,EAAEA,OAAO;IAAA,IAChBK,SAASA,CAAA;MAAA,OAAE,CACTb,SAAS,EACTC,cAAc,EACdC,aAAa,EACbC,YAAY,EACZJ,EAAE,CAACC,SAAS,EACZD,EAAE,CAACe,iBAAiB,EACpBf,EAAE,CAACgB,UAAU,CACd;IAAA;IACDC,UAAU,EAAEN,MAAM;IAAA,IAAAD,SAAA;MAAA,OAAAG,iBAAA,CAEjBb,EAAE,CAACkB,UAAU;QAACC,IAAI;QAAAT,QAAA,EAAYA;MAAQ;IAAA;EAAA;AAG7C","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/python/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/python/utils/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,aAAa;AAC3B,cAAc,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Refkey } from "@alloy-js/core";
|
|
2
|
+
import * as py from "@alloy-js/python";
|
|
3
|
+
import type { Model, ModelProperty, Operation, Type } from "@typespec/compiler";
|
|
4
|
+
export declare function getReturnType(type: Operation, options?: {
|
|
5
|
+
skipErrorFiltering: boolean;
|
|
6
|
+
}): Type;
|
|
7
|
+
export interface BuildParameterDescriptorsOptions {
|
|
8
|
+
params?: (py.ParameterDescriptor | string)[];
|
|
9
|
+
suffixRefkey?: Refkey;
|
|
10
|
+
/** If true, params replaces operation parameters instead of adding to them */
|
|
11
|
+
replaceParameters?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Build a parameter descriptor array from a TypeSpec Model.
|
|
15
|
+
*
|
|
16
|
+
* Parameter ordering (unless replaceParameters is true):
|
|
17
|
+
* - Operation params without defaults: positional (e.g., URL path params)
|
|
18
|
+
* - "*" marker (if any keyword-only params exist)
|
|
19
|
+
* - Operation params with defaults: keyword-only (e.g., query params)
|
|
20
|
+
* - Additional params: keyword-only
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildParameterDescriptors(type: Model, options?: BuildParameterDescriptorsOptions): (py.ParameterDescriptor | string)[] | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Convert a TypeSpec ModelProperty into a Python ParameterDescriptor.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildParameterDescriptor(modelProperty: ModelProperty, suffixRefkey: Refkey): py.ParameterDescriptor;
|
|
27
|
+
//# sourceMappingURL=operation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../../src/python/utils/operation.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAMhF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,SAAS,EACf,OAAO,GAAE;IAAE,kBAAkB,EAAE,OAAO,CAAA;CAAkC,GACvE,IAAI,CASN;AAED,MAAM,WAAW,gCAAgC;IAC/C,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,mBAAmB,GAAG,MAAM,CAAC,EAAE,CAAC;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,KAAK,EACX,OAAO,GAAE,gCAAqC,GAC7C,CAAC,EAAE,CAAC,mBAAmB,GAAG,MAAM,CAAC,EAAE,GAAG,SAAS,CAwDjD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,MAAM,GACnB,EAAE,CAAC,mBAAmB,CAsBxB"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { typingModule } from "#python/builtins.js";
|
|
2
|
+
import { refkey } from "@alloy-js/core";
|
|
3
|
+
import * as py from "@alloy-js/python";
|
|
4
|
+
import { useTsp } from "../../core/index.js";
|
|
5
|
+
import { Atom } from "../components/atom/atom.js";
|
|
6
|
+
import { TypeExpression } from "../components/type-expression/type-expression.js";
|
|
7
|
+
import { efRefkey } from "./refkey.js";
|
|
8
|
+
export function getReturnType(type, options = {
|
|
9
|
+
skipErrorFiltering: false
|
|
10
|
+
}) {
|
|
11
|
+
const {
|
|
12
|
+
$
|
|
13
|
+
} = useTsp();
|
|
14
|
+
let returnType = type.returnType;
|
|
15
|
+
if (!options.skipErrorFiltering && type.returnType.kind === "Union") {
|
|
16
|
+
returnType = $.union.filter(type.returnType, variant => !$.type.isError(variant.type));
|
|
17
|
+
}
|
|
18
|
+
return returnType;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build a parameter descriptor array from a TypeSpec Model.
|
|
22
|
+
*
|
|
23
|
+
* Parameter ordering (unless replaceParameters is true):
|
|
24
|
+
* - Operation params without defaults: positional (e.g., URL path params)
|
|
25
|
+
* - "*" marker (if any keyword-only params exist)
|
|
26
|
+
* - Operation params with defaults: keyword-only (e.g., query params)
|
|
27
|
+
* - Additional params: keyword-only
|
|
28
|
+
*/
|
|
29
|
+
export function buildParameterDescriptors(type, options = {}) {
|
|
30
|
+
const {
|
|
31
|
+
$
|
|
32
|
+
} = useTsp();
|
|
33
|
+
const suffixRefkey = options.suffixRefkey ?? refkey();
|
|
34
|
+
const optionsParams = normalizeParameters(options.params ?? []);
|
|
35
|
+
|
|
36
|
+
// If replaceParameters is true, ignore operation params and just return options params
|
|
37
|
+
// All replacement parameters are keyword-only (following "additional parameters are keyword-only" principle)
|
|
38
|
+
if (options.replaceParameters) {
|
|
39
|
+
const withoutDefaults = optionsParams.filter(p => p.default === undefined);
|
|
40
|
+
const withDefaults = optionsParams.filter(p => p.default !== undefined);
|
|
41
|
+
|
|
42
|
+
// Always add "*" marker since all replacement params should be keyword-only
|
|
43
|
+
const allParams = optionsParams.length > 0 ? ["*", ...withoutDefaults, ...withDefaults] : [];
|
|
44
|
+
return allParams;
|
|
45
|
+
}
|
|
46
|
+
const modelProperties = $.model.getProperties(type);
|
|
47
|
+
const operationParams = [...modelProperties.values()].map(m => buildParameterDescriptor(m, suffixRefkey));
|
|
48
|
+
|
|
49
|
+
// Split operation params: params without defaults are positional, params with defaults are keyword-only
|
|
50
|
+
const opParamsWithoutDefaults = operationParams.filter(p => p.default === undefined);
|
|
51
|
+
const opParamsWithDefaults = operationParams.filter(p => p.default !== undefined);
|
|
52
|
+
|
|
53
|
+
// Reorder additional params: params without defaults before params with defaults
|
|
54
|
+
const optionsWithoutDefaults = optionsParams.filter(p => p.default === undefined);
|
|
55
|
+
const optionsWithDefaults = optionsParams.filter(p => p.default !== undefined);
|
|
56
|
+
|
|
57
|
+
// Build final parameter list:
|
|
58
|
+
// - Operation params without defaults: positional (e.g., URL path params)
|
|
59
|
+
// - "*" marker (if there are keyword-only params)
|
|
60
|
+
// - Operation params with defaults: keyword-only (e.g., query params with defaults)
|
|
61
|
+
// - Additional params: keyword-only
|
|
62
|
+
|
|
63
|
+
// If there are no operation params at all, treat additional params without defaults as positional
|
|
64
|
+
const hasOperationParams = operationParams.length > 0;
|
|
65
|
+
const positionalParams = hasOperationParams ? opParamsWithoutDefaults : [...opParamsWithoutDefaults, ...optionsWithoutDefaults];
|
|
66
|
+
const keywordOnlyParams = hasOperationParams ? [...optionsWithoutDefaults, ...opParamsWithDefaults, ...optionsWithDefaults] : [...opParamsWithDefaults, ...optionsWithDefaults];
|
|
67
|
+
|
|
68
|
+
// Add "*" marker if we have keyword-only params
|
|
69
|
+
// This enforces that params with defaults are truly keyword-only
|
|
70
|
+
const allParams = keywordOnlyParams.length > 0 ? [...positionalParams, "*", ...keywordOnlyParams] : [...positionalParams];
|
|
71
|
+
return allParams;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Convert a TypeSpec ModelProperty into a Python ParameterDescriptor.
|
|
76
|
+
*/
|
|
77
|
+
export function buildParameterDescriptor(modelProperty, suffixRefkey) {
|
|
78
|
+
const {
|
|
79
|
+
$
|
|
80
|
+
} = useTsp();
|
|
81
|
+
const namePolicy = py.usePythonNamePolicy();
|
|
82
|
+
const paramName = namePolicy.getName(modelProperty.name, "parameter");
|
|
83
|
+
const isOptional = modelProperty.optional || modelProperty.defaultValue !== undefined;
|
|
84
|
+
const doc = $.type.getDoc(modelProperty);
|
|
85
|
+
let defaultValueNode = undefined;
|
|
86
|
+
const hasDefault = modelProperty.defaultValue !== undefined && modelProperty.defaultValue !== null;
|
|
87
|
+
if (hasDefault) {
|
|
88
|
+
defaultValueNode = Atom({
|
|
89
|
+
value: modelProperty.defaultValue
|
|
90
|
+
});
|
|
91
|
+
} else if (isOptional) {
|
|
92
|
+
// Render Python None for optional parameters without explicit default
|
|
93
|
+
defaultValueNode = py.Atom({
|
|
94
|
+
jsValue: null
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
doc,
|
|
99
|
+
name: paramName,
|
|
100
|
+
refkey: efRefkey(modelProperty, suffixRefkey),
|
|
101
|
+
type: TypeExpression({
|
|
102
|
+
type: modelProperty.type
|
|
103
|
+
}),
|
|
104
|
+
...(defaultValueNode !== undefined ? {
|
|
105
|
+
default: defaultValueNode
|
|
106
|
+
} : {})
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const rawTypeMap = {
|
|
110
|
+
string: "str",
|
|
111
|
+
number: "float",
|
|
112
|
+
boolean: "bool",
|
|
113
|
+
any: typingModule["."]["Any"],
|
|
114
|
+
never: typingModule["."]["Never"]
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Convert a parameter descriptor array to normalized parameter descriptors.
|
|
119
|
+
* String parameter names are converted to basic parameter descriptors.
|
|
120
|
+
*/
|
|
121
|
+
function normalizeParameters(params) {
|
|
122
|
+
if (!params) return [];
|
|
123
|
+
return params.map(param => {
|
|
124
|
+
if (typeof param === "string") {
|
|
125
|
+
// Convert string names to parameter descriptors
|
|
126
|
+
return {
|
|
127
|
+
name: param
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (typeof param.type === "string") {
|
|
131
|
+
return {
|
|
132
|
+
...param,
|
|
133
|
+
type: rawTypeMap[param.type] ?? param.type
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return param;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["typingModule","refkey","py","useTsp","Atom","TypeExpression","efRefkey","getReturnType","type","options","skipErrorFiltering","$","returnType","kind","union","filter","variant","isError","buildParameterDescriptors","suffixRefkey","optionsParams","normalizeParameters","params","replaceParameters","withoutDefaults","p","default","undefined","withDefaults","allParams","length","modelProperties","model","getProperties","operationParams","values","map","m","buildParameterDescriptor","opParamsWithoutDefaults","opParamsWithDefaults","optionsWithoutDefaults","optionsWithDefaults","hasOperationParams","positionalParams","keywordOnlyParams","modelProperty","namePolicy","usePythonNamePolicy","paramName","getName","name","isOptional","optional","defaultValue","doc","getDoc","defaultValueNode","hasDefault","value","jsValue","rawTypeMap","string","number","boolean","any","never","param"],"sources":["../../../../src/python/utils/operation.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,YAAY,QAAQ,qBAAqB;AAClD,SAASC,MAAM,QAAoC,gBAAgB;AACnE,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AAEtC,SAASC,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,IAAI,QAAQ,4BAA4B;AACjD,SAASC,cAAc,QAAQ,kDAAkD;AACjF,SAASC,QAAQ,QAAQ,aAAa;AAEtC,OAAO,SAASC,aAAaA,CAC3BC,IAAe,EACfC,OAAwC,GAAG;EAAEC,kBAAkB,EAAE;AAAM,CAAC,EAClE;EACN,MAAM;IAAEC;EAAE,CAAC,GAAGR,MAAM,CAAC,CAAC;EACtB,IAAIS,UAAU,GAAGJ,IAAI,CAACI,UAAU;EAEhC,IAAI,CAACH,OAAO,CAACC,kBAAkB,IAAIF,IAAI,CAACI,UAAU,CAACC,IAAI,KAAK,OAAO,EAAE;IACnED,UAAU,GAAGD,CAAC,CAACG,KAAK,CAACC,MAAM,CAACP,IAAI,CAACI,UAAU,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AAQ,EAAE;MAC7B;MACA,OAAO;QAAEhB,IAAI,EAAEgB;MAAM,CAAC;IACxB;IACA,IAAI,OAAQA,KAAK,CAAS3D,IAAI,KAAK,QAAQ,EAAE;MAC3C,OAAO;QACL,GAAG2D,KAAK;QACR3D,IAAI,EAAEqD,UAAU,CAACM,KAAK,CAAC3D,IAAI,CAA4B,IAAI2D,KAAK,CAAC3D;MACnE,CAAC;IACH;IACA,OAAO2D,KAAK;EACd,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Refkey } from "@alloy-js/core";
|
|
2
|
+
/**
|
|
3
|
+
* A wrapper around `refkey` that uses a custom symbol to avoid collisions with
|
|
4
|
+
* other libraries that use `refkey`.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
*
|
|
8
|
+
* The underlying refkey function is called with the {@link refKeyPrefix} symbol as the first argument.
|
|
9
|
+
*
|
|
10
|
+
* @param args The parameters of the refkey.
|
|
11
|
+
* @returns A refkey object that can be used to identify the value.
|
|
12
|
+
*/
|
|
13
|
+
export declare function efRefkey(...args: unknown[]): Refkey;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a refkey for a declaration by combining the provided refkey with an internal
|
|
16
|
+
* refkey generated from the provided arguments.
|
|
17
|
+
*
|
|
18
|
+
* @param refkey The refkey provided by the user to be passed as is.
|
|
19
|
+
* @param args The parameters of the refkey.
|
|
20
|
+
* @returns An array of refkeys that can be passed to an Alloy declaration.
|
|
21
|
+
*/
|
|
22
|
+
export declare function declarationRefkeys(refkey?: Refkey | Refkey[], ...args: unknown[]): Refkey[];
|
|
23
|
+
//# sourceMappingURL=refkey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refkey.d.ts","sourceRoot":"","sources":["../../../../src/python/utils/refkey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAIjE;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAKnD;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAK3F"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { refkey as ayRefkey } from "@alloy-js/core";
|
|
2
|
+
const refKeyPrefix = Symbol.for("emitter-framework:python");
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A wrapper around `refkey` that uses a custom symbol to avoid collisions with
|
|
6
|
+
* other libraries that use `refkey`.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
*
|
|
10
|
+
* The underlying refkey function is called with the {@link refKeyPrefix} symbol as the first argument.
|
|
11
|
+
*
|
|
12
|
+
* @param args The parameters of the refkey.
|
|
13
|
+
* @returns A refkey object that can be used to identify the value.
|
|
14
|
+
*/
|
|
15
|
+
export function efRefkey(...args) {
|
|
16
|
+
if (args.length === 0) {
|
|
17
|
+
return ayRefkey(); // Generates a unique refkey
|
|
18
|
+
}
|
|
19
|
+
return ayRefkey(refKeyPrefix, ...args);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates a refkey for a declaration by combining the provided refkey with an internal
|
|
24
|
+
* refkey generated from the provided arguments.
|
|
25
|
+
*
|
|
26
|
+
* @param refkey The refkey provided by the user to be passed as is.
|
|
27
|
+
* @param args The parameters of the refkey.
|
|
28
|
+
* @returns An array of refkeys that can be passed to an Alloy declaration.
|
|
29
|
+
*/
|
|
30
|
+
export function declarationRefkeys(refkey, ...args) {
|
|
31
|
+
if (refkey) {
|
|
32
|
+
return [refkey, efRefkey(...args)].flat();
|
|
33
|
+
}
|
|
34
|
+
return [efRefkey(...args)];
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=refkey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["refkey","ayRefkey","refKeyPrefix","Symbol","for","efRefkey","args","length","declarationRefkeys","flat"],"sources":["../../../../src/python/utils/refkey.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,IAAIC,QAAQ,QAAqB,gBAAgB;AAEhE,MAAMC,YAAY,GAAGC,MAAM,CAACC,GAAG,CAAC,0BAA0B,CAAC;;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAAC,GAAGC,IAAe,EAAU;EACnD,IAAIA,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;IACrB,OAAON,QAAQ,CAAC,CAAC,CAAC,CAAC;EACrB;EACA,OAAOA,QAAQ,CAACC,YAAY,EAAE,GAAGI,IAAI,CAAC;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,kBAAkBA,CAACR,MAA0B,EAAE,GAAGM,IAAe,EAAY;EAC3F,IAAIN,MAAM,EAAE;IACV,OAAO,CAACA,MAAM,EAAEK,QAAQ,CAAC,GAAGC,IAAI,CAAC,CAAC,CAACG,IAAI,CAAC,CAAC;EAC3C;EACA,OAAO,CAACJ,QAAQ,CAAC,GAAGC,IAAI,CAAC,CAAC;AAC5B","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Typekit } from "@typespec/compiler/typekit";
|
|
2
|
+
/**
|
|
3
|
+
* Check if a type is a literal type (string, numeric, boolean, or union variant).
|
|
4
|
+
* This is useful for determining if a type can be used in a Python Literal[] type.
|
|
5
|
+
*
|
|
6
|
+
* @param $ - The Typekit instance
|
|
7
|
+
* @param type - The type to check
|
|
8
|
+
* @returns true if the type is a literal type
|
|
9
|
+
*/
|
|
10
|
+
export declare function isLiteral($: Typekit, type: any): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Check if all types in an array are literal types.
|
|
13
|
+
*
|
|
14
|
+
* @param $ - The Typekit instance
|
|
15
|
+
* @param types - Array of types to check
|
|
16
|
+
* @returns true if all types are literals
|
|
17
|
+
*/
|
|
18
|
+
export declare function areAllLiterals($: Typekit, types: any[]): boolean;
|
|
19
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../src/python/utils/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE1D;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CASxD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,OAAO,CAEhE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a type is a literal type (string, numeric, boolean, or union variant).
|
|
3
|
+
* This is useful for determining if a type can be used in a Python Literal[] type.
|
|
4
|
+
*
|
|
5
|
+
* @param $ - The Typekit instance
|
|
6
|
+
* @param type - The type to check
|
|
7
|
+
* @returns true if the type is a literal type
|
|
8
|
+
*/
|
|
9
|
+
export function isLiteral($, type) {
|
|
10
|
+
if (!type) return false;
|
|
11
|
+
return $.literal.isString(type) || $.literal.isNumeric(type) || $.literal.isBoolean(type) || type.kind === "UnionVariant";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Check if all types in an array are literal types.
|
|
16
|
+
*
|
|
17
|
+
* @param $ - The Typekit instance
|
|
18
|
+
* @param types - Array of types to check
|
|
19
|
+
* @returns true if all types are literals
|
|
20
|
+
*/
|
|
21
|
+
export function areAllLiterals($, types) {
|
|
22
|
+
return types.every(type => isLiteral($, type));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isLiteral","$","type","literal","isString","isNumeric","isBoolean","kind","areAllLiterals","types","every"],"sources":["../../../../src/python/utils/type.ts"],"sourcesContent":[null],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,SAASA,CAACC,CAAU,EAAEC,IAAS,EAAW;EACxD,IAAI,CAACA,IAAI,EAAE,OAAO,KAAK;EAEvB,OACED,CAAC,CAACE,OAAO,CAACC,QAAQ,CAACF,IAAI,CAAC,IACxBD,CAAC,CAACE,OAAO,CAACE,SAAS,CAACH,IAAI,CAAC,IACzBD,CAAC,CAACE,OAAO,CAACG,SAAS,CAACJ,IAAI,CAAC,IACzBA,IAAI,CAACK,IAAI,KAAK,cAAc;AAEhC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACP,CAAU,EAAEQ,KAAY,EAAW;EAChE,OAAOA,KAAK,CAACC,KAAK,CAAER,IAAI,IAAKF,SAAS,CAACC,CAAC,EAAEC,IAAI,CAAC,CAAC;AAClD","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/emitter-framework",
|
|
3
|
-
"version": "0.15.0-dev.
|
|
3
|
+
"version": "0.15.0-dev.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
"./typescript": {
|
|
18
18
|
"import": "./dist/src/typescript/index.js"
|
|
19
19
|
},
|
|
20
|
+
"./python": {
|
|
21
|
+
"import": "./dist/src/python/index.js"
|
|
22
|
+
},
|
|
20
23
|
"./testing": {
|
|
21
24
|
"import": "./dist/src/testing/index.js"
|
|
22
25
|
}
|
|
@@ -31,6 +34,9 @@
|
|
|
31
34
|
},
|
|
32
35
|
"#typescript/*": {
|
|
33
36
|
"default": "./dist/src/typescript/*"
|
|
37
|
+
},
|
|
38
|
+
"#python/*": {
|
|
39
|
+
"default": "./dist/src/python/*"
|
|
34
40
|
}
|
|
35
41
|
},
|
|
36
42
|
"keywords": [],
|
|
@@ -40,12 +46,14 @@
|
|
|
40
46
|
"peerDependencies": {
|
|
41
47
|
"@alloy-js/core": "^0.22.0",
|
|
42
48
|
"@alloy-js/csharp": "^0.22.0",
|
|
49
|
+
"@alloy-js/python": "^0.3.0",
|
|
43
50
|
"@alloy-js/typescript": "^0.22.0",
|
|
44
51
|
"@typespec/compiler": "^1.7.1"
|
|
45
52
|
},
|
|
46
53
|
"devDependencies": {
|
|
47
54
|
"@alloy-js/cli": "^0.22.0",
|
|
48
55
|
"@alloy-js/core": "^0.22.0",
|
|
56
|
+
"@alloy-js/python": "^0.3.0",
|
|
49
57
|
"@alloy-js/rollup-plugin": "^0.1.0",
|
|
50
58
|
"@alloy-js/typescript": "^0.22.0",
|
|
51
59
|
"@typespec/compiler": "^1.7.1",
|
package/package.json.bak
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/emitter-framework",
|
|
3
|
-
"version": "0.15.0-dev.
|
|
3
|
+
"version": "0.15.0-dev.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
"./typescript": {
|
|
32
32
|
"import": "./dist/src/typescript/index.js"
|
|
33
33
|
},
|
|
34
|
+
"./python": {
|
|
35
|
+
"import": "./dist/src/python/index.js"
|
|
36
|
+
},
|
|
34
37
|
"./testing": {
|
|
35
38
|
"import": "./dist/src/testing/index.js"
|
|
36
39
|
}
|
|
@@ -48,6 +51,10 @@
|
|
|
48
51
|
"#typescript/*": {
|
|
49
52
|
"development": "./src/typescript/*",
|
|
50
53
|
"default": "./dist/src/typescript/*"
|
|
54
|
+
},
|
|
55
|
+
"#python/*": {
|
|
56
|
+
"development": "./src/python/*",
|
|
57
|
+
"default": "./dist/src/python/*"
|
|
51
58
|
}
|
|
52
59
|
},
|
|
53
60
|
"keywords": [],
|
|
@@ -57,12 +64,14 @@
|
|
|
57
64
|
"peerDependencies": {
|
|
58
65
|
"@alloy-js/core": "^0.22.0",
|
|
59
66
|
"@alloy-js/csharp": "^0.22.0",
|
|
67
|
+
"@alloy-js/python": "^0.3.0",
|
|
60
68
|
"@alloy-js/typescript": "^0.22.0",
|
|
61
69
|
"@typespec/compiler": "^1.7.1"
|
|
62
70
|
},
|
|
63
71
|
"devDependencies": {
|
|
64
72
|
"@alloy-js/cli": "^0.22.0",
|
|
65
73
|
"@alloy-js/core": "^0.22.0",
|
|
74
|
+
"@alloy-js/python": "^0.3.0",
|
|
66
75
|
"@alloy-js/rollup-plugin": "^0.1.0",
|
|
67
76
|
"@alloy-js/typescript": "^0.22.0",
|
|
68
77
|
"@typespec/compiler": "^1.7.1",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { SymbolCreator } from "@alloy-js/core";
|
|
2
|
+
import { createModule } from "@alloy-js/python";
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
|
+
type dummy = SymbolCreator;
|
|
6
|
+
|
|
7
|
+
export const abcModule = createModule({
|
|
8
|
+
name: "abc",
|
|
9
|
+
descriptor: {
|
|
10
|
+
".": ["ABC"],
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const datetimeModule = createModule({
|
|
15
|
+
name: "datetime",
|
|
16
|
+
descriptor: {
|
|
17
|
+
".": ["datetime", "date", "time", "timedelta", "timezone"],
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const decimalModule = createModule({
|
|
22
|
+
name: "decimal",
|
|
23
|
+
descriptor: {
|
|
24
|
+
".": ["Decimal"],
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const typingModule = createModule({
|
|
29
|
+
name: "typing",
|
|
30
|
+
descriptor: {
|
|
31
|
+
".": [
|
|
32
|
+
"Any",
|
|
33
|
+
"Callable",
|
|
34
|
+
"Generic",
|
|
35
|
+
"Literal",
|
|
36
|
+
"Never",
|
|
37
|
+
"Optional",
|
|
38
|
+
"Protocol",
|
|
39
|
+
"TypeAlias",
|
|
40
|
+
"TypeVar",
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Tester } from "#test/test-host.js";
|
|
2
|
+
import { d } from "@alloy-js/core/testing";
|
|
3
|
+
import { t } from "@typespec/compiler/testing";
|
|
4
|
+
import { expect, it } from "vitest";
|
|
5
|
+
import { getOutput } from "../../test-utils.js";
|
|
6
|
+
import { TypeExpression } from "../type-expression/type-expression.js";
|
|
7
|
+
|
|
8
|
+
it("maps array expression to Python list", async () => {
|
|
9
|
+
const { program, TestArray } = await Tester.compile(t.code`
|
|
10
|
+
alias ${t.type("TestArray")} = string[];
|
|
11
|
+
`);
|
|
12
|
+
|
|
13
|
+
expect(getOutput(program, [<TypeExpression type={TestArray} />])).toRenderTo(d`list[str]`);
|
|
14
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { code } from "@alloy-js/core";
|
|
2
|
+
import type { Type } from "@typespec/compiler";
|
|
3
|
+
import { TypeExpression } from "../type-expression/type-expression.js";
|
|
4
|
+
|
|
5
|
+
export interface ArrayExpressionProps {
|
|
6
|
+
elementType: Type;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function ArrayExpression({ elementType }: ArrayExpressionProps) {
|
|
10
|
+
return code`list[${(<TypeExpression type={elementType} />)}]`;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./array-expression.js";
|