@typespec/emitter-framework 0.1.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/LICENSE +21 -0
- package/babel.config.js +4 -0
- package/dist/src/core/context/index.d.ts +2 -0
- package/dist/src/core/context/index.d.ts.map +1 -0
- package/dist/src/core/context/index.js +1 -0
- package/dist/src/core/context/index.js.map +1 -0
- package/dist/src/core/context/name-policy-context.d.ts +5 -0
- package/dist/src/core/context/name-policy-context.d.ts.map +1 -0
- package/dist/src/core/context/name-policy-context.js +13 -0
- package/dist/src/core/context/name-policy-context.js.map +1 -0
- package/dist/src/core/index.d.ts +4 -0
- package/dist/src/core/index.d.ts.map +1 -0
- package/dist/src/core/index.js +4 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/transport-name-policy.d.ts +44 -0
- package/dist/src/core/transport-name-policy.d.ts.map +1 -0
- package/dist/src/core/transport-name-policy.js +42 -0
- package/dist/src/core/transport-name-policy.js.map +1 -0
- package/dist/src/core/write-output.d.ts +3 -0
- package/dist/src/core/write-output.d.ts.map +1 -0
- package/dist/src/core/write-output.js +20 -0
- package/dist/src/core/write-output.js.map +1 -0
- package/dist/src/lib.d.ts +23 -0
- package/dist/src/lib.d.ts.map +1 -0
- package/dist/src/lib.js +18 -0
- package/dist/src/lib.js.map +1 -0
- package/dist/src/testing/index.d.ts +4 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +9 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/testing/scenario-test/harness.d.ts +4 -0
- package/dist/src/testing/scenario-test/harness.d.ts.map +1 -0
- package/dist/src/testing/scenario-test/harness.js +278 -0
- package/dist/src/testing/scenario-test/harness.js.map +1 -0
- package/dist/src/testing/scenario-test/index.d.ts +4 -0
- package/dist/src/testing/scenario-test/index.d.ts.map +1 -0
- package/dist/src/testing/scenario-test/index.js +4 -0
- package/dist/src/testing/scenario-test/index.js.map +1 -0
- package/dist/src/testing/scenario-test/snippet-extractor.d.ts +30 -0
- package/dist/src/testing/scenario-test/snippet-extractor.d.ts.map +1 -0
- package/dist/src/testing/scenario-test/snippet-extractor.js +152 -0
- package/dist/src/testing/scenario-test/snippet-extractor.js.map +1 -0
- package/dist/src/testing/scenario-test/test-host.d.ts +8 -0
- package/dist/src/testing/scenario-test/test-host.d.ts.map +1 -0
- package/dist/src/testing/scenario-test/test-host.js +50 -0
- package/dist/src/testing/scenario-test/test-host.js.map +1 -0
- package/dist/src/typescript/components/array-expression.d.ts +6 -0
- package/dist/src/typescript/components/array-expression.d.ts.map +1 -0
- package/dist/src/typescript/components/array-expression.js +10 -0
- package/dist/src/typescript/components/array-expression.js.map +1 -0
- package/dist/src/typescript/components/class-method.d.ts +10 -0
- package/dist/src/typescript/components/class-method.d.ts.map +1 -0
- package/dist/src/typescript/components/class-method.js +39 -0
- package/dist/src/typescript/components/class-method.js.map +1 -0
- package/dist/src/typescript/components/enum-declaration.d.ts +14 -0
- package/dist/src/typescript/components/enum-declaration.d.ts.map +1 -0
- package/dist/src/typescript/components/enum-declaration.js +61 -0
- package/dist/src/typescript/components/enum-declaration.js.map +1 -0
- package/dist/src/typescript/components/function-declaration.d.ts +18 -0
- package/dist/src/typescript/components/function-declaration.d.ts.map +1 -0
- package/dist/src/typescript/components/function-declaration.js +71 -0
- package/dist/src/typescript/components/function-declaration.js.map +1 -0
- package/dist/src/typescript/components/index.d.ts +11 -0
- package/dist/src/typescript/components/index.d.ts.map +1 -0
- package/dist/src/typescript/components/index.js +11 -0
- package/dist/src/typescript/components/index.js.map +1 -0
- package/dist/src/typescript/components/interface-declaration.d.ts +13 -0
- package/dist/src/typescript/components/interface-declaration.d.ts.map +1 -0
- package/dist/src/typescript/components/interface-declaration.js +118 -0
- package/dist/src/typescript/components/interface-declaration.js.map +1 -0
- package/dist/src/typescript/components/interface-member.d.ts +7 -0
- package/dist/src/typescript/components/interface-member.d.ts.map +1 -0
- package/dist/src/typescript/components/interface-member.js +42 -0
- package/dist/src/typescript/components/interface-member.js.map +1 -0
- package/dist/src/typescript/components/record-expression.d.ts +6 -0
- package/dist/src/typescript/components/record-expression.d.ts.map +1 -0
- package/dist/src/typescript/components/record-expression.js +13 -0
- package/dist/src/typescript/components/record-expression.js.map +1 -0
- package/dist/src/typescript/components/static-serializers.d.ts +17 -0
- package/dist/src/typescript/components/static-serializers.d.ts.map +1 -0
- package/dist/src/typescript/components/static-serializers.js +190 -0
- package/dist/src/typescript/components/static-serializers.js.map +1 -0
- package/dist/src/typescript/components/type-alias-declaration.d.ts +9 -0
- package/dist/src/typescript/components/type-alias-declaration.d.ts.map +1 -0
- package/dist/src/typescript/components/type-alias-declaration.js +42 -0
- package/dist/src/typescript/components/type-alias-declaration.js.map +1 -0
- package/dist/src/typescript/components/type-declaration.d.ts +11 -0
- package/dist/src/typescript/components/type-declaration.d.ts.map +1 -0
- package/dist/src/typescript/components/type-declaration.js +35 -0
- package/dist/src/typescript/components/type-declaration.js.map +1 -0
- package/dist/src/typescript/components/type-expression.d.ts +7 -0
- package/dist/src/typescript/components/type-expression.d.ts.map +1 -0
- package/dist/src/typescript/components/type-expression.js +205 -0
- package/dist/src/typescript/components/type-expression.js.map +1 -0
- package/dist/src/typescript/components/type-transform.d.ts +65 -0
- package/dist/src/typescript/components/type-transform.d.ts.map +1 -0
- package/dist/src/typescript/components/type-transform.js +390 -0
- package/dist/src/typescript/components/type-transform.js.map +1 -0
- package/dist/src/typescript/components/union-declaration.d.ts +9 -0
- package/dist/src/typescript/components/union-declaration.d.ts.map +1 -0
- package/dist/src/typescript/components/union-declaration.js +45 -0
- package/dist/src/typescript/components/union-declaration.js.map +1 -0
- package/dist/src/typescript/components/union-expression.d.ts +8 -0
- package/dist/src/typescript/components/union-expression.d.ts.map +1 -0
- package/dist/src/typescript/components/union-expression.js +37 -0
- package/dist/src/typescript/components/union-expression.js.map +1 -0
- package/dist/src/typescript/index.d.ts +3 -0
- package/dist/src/typescript/index.d.ts.map +1 -0
- package/dist/src/typescript/index.js +3 -0
- package/dist/src/typescript/index.js.map +1 -0
- package/dist/src/typescript/lib.d.ts +113 -0
- package/dist/src/typescript/lib.d.ts.map +1 -0
- package/dist/src/typescript/lib.js +65 -0
- package/dist/src/typescript/lib.js.map +1 -0
- package/dist/src/typescript/utils/index.d.ts +2 -0
- package/dist/src/typescript/utils/index.d.ts.map +1 -0
- package/dist/src/typescript/utils/index.js +1 -0
- package/dist/src/typescript/utils/index.js.map +1 -0
- package/dist/src/typescript/utils/operation.d.ts +13 -0
- package/dist/src/typescript/utils/operation.d.ts.map +1 -0
- package/dist/src/typescript/utils/operation.js +47 -0
- package/dist/src/typescript/utils/operation.js.map +1 -0
- package/dist/test/testing/snippet-extractor-csharp.test.d.ts +2 -0
- package/dist/test/testing/snippet-extractor-csharp.test.d.ts.map +1 -0
- package/dist/test/testing/snippet-extractor-java.test.d.ts +2 -0
- package/dist/test/testing/snippet-extractor-java.test.d.ts.map +1 -0
- package/dist/test/testing/snippet-extractor-python.test.d.ts +2 -0
- package/dist/test/testing/snippet-extractor-python.test.d.ts.map +1 -0
- package/dist/test/testing/snippet-extractor-typescript.test.d.ts +2 -0
- package/dist/test/testing/snippet-extractor-typescript.test.d.ts.map +1 -0
- package/dist/test/typescript/components/enum-declaration.test.d.ts +2 -0
- package/dist/test/typescript/components/enum-declaration.test.d.ts.map +1 -0
- package/dist/test/typescript/components/function-declaration.test.d.ts +2 -0
- package/dist/test/typescript/components/function-declaration.test.d.ts.map +1 -0
- package/dist/test/typescript/components/interface-declaration.test.d.ts +2 -0
- package/dist/test/typescript/components/interface-declaration.test.d.ts.map +1 -0
- package/dist/test/typescript/components/member-expression.test.d.ts +2 -0
- package/dist/test/typescript/components/member-expression.test.d.ts.map +1 -0
- package/dist/test/typescript/components/type-alias-declaration.test.d.ts +2 -0
- package/dist/test/typescript/components/type-alias-declaration.test.d.ts.map +1 -0
- package/dist/test/typescript/components/type-transform.test.d.ts +2 -0
- package/dist/test/typescript/components/type-transform.test.d.ts.map +1 -0
- package/dist/test/typescript/components/union-declaration.test.d.ts +2 -0
- package/dist/test/typescript/components/union-declaration.test.d.ts.map +1 -0
- package/dist/test/typescript/test-host.d.ts +11 -0
- package/dist/test/typescript/test-host.d.ts.map +1 -0
- package/dist/test/utils.d.ts +4 -0
- package/dist/test/utils.d.ts.map +1 -0
- package/package.json +58 -0
- package/src/core/context/index.ts +1 -0
- package/src/core/context/name-policy-context.ts +16 -0
- package/src/core/index.ts +3 -0
- package/src/core/transport-name-policy.ts +67 -0
- package/src/core/write-output.ts +21 -0
- package/src/lib.ts +16 -0
- package/src/testing/index.ts +10 -0
- package/src/testing/scenario-test/harness.ts +398 -0
- package/src/testing/scenario-test/index.ts +3 -0
- package/src/testing/scenario-test/snippet-extractor.ts +200 -0
- package/src/testing/scenario-test/test-host.ts +83 -0
- package/src/typescript/components/array-expression.tsx +12 -0
- package/src/typescript/components/class-method.tsx +39 -0
- package/src/typescript/components/enum-declaration.tsx +63 -0
- package/src/typescript/components/function-declaration.tsx +128 -0
- package/src/typescript/components/index.ts +10 -0
- package/src/typescript/components/interface-declaration.tsx +137 -0
- package/src/typescript/components/interface-member.tsx +42 -0
- package/src/typescript/components/record-expression.tsx +13 -0
- package/src/typescript/components/static-serializers.tsx +136 -0
- package/src/typescript/components/type-alias-declaration.tsx +37 -0
- package/src/typescript/components/type-declaration.tsx +31 -0
- package/src/typescript/components/type-expression.tsx +166 -0
- package/src/typescript/components/type-transform.tsx +378 -0
- package/src/typescript/components/union-declaration.tsx +40 -0
- package/src/typescript/components/union-expression.tsx +37 -0
- package/src/typescript/index.ts +2 -0
- package/src/typescript/lib.ts +61 -0
- package/src/typescript/utils/index.ts +1 -0
- package/src/typescript/utils/operation.ts +61 -0
- package/test/testing/snippet-extractor-csharp.test.ts +113 -0
- package/test/testing/snippet-extractor-java.test.ts +122 -0
- package/test/testing/snippet-extractor-python.test.ts +43 -0
- package/test/testing/snippet-extractor-typescript.test.ts +181 -0
- package/test/typescript/components/enum-declaration.test.tsx +110 -0
- package/test/typescript/components/function-declaration.test.tsx +226 -0
- package/test/typescript/components/interface-declaration.test.tsx +690 -0
- package/test/typescript/components/member-expression.test.tsx +130 -0
- package/test/typescript/components/type-alias-declaration.test.tsx +120 -0
- package/test/typescript/components/type-transform.test.tsx +562 -0
- package/test/typescript/components/union-declaration.test.tsx +185 -0
- package/test/typescript/test-host.ts +41 -0
- package/test/utils.ts +14 -0
- package/tsconfig.json +21 -0
- package/vitest.config.js +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE
|
package/babel.config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./name-policy-context.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/core/context/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,0BAA0B","ignoreList":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ComponentContext } from "@alloy-js/core";
|
|
2
|
+
import { TransformNamePolicy } from "../transport-name-policy.js";
|
|
3
|
+
export declare const TransformNamePolicyContext: ComponentContext<TransformNamePolicy>;
|
|
4
|
+
export declare function useTransformNamePolicy(): TransformNamePolicy;
|
|
5
|
+
//# sourceMappingURL=name-policy-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"name-policy-context.d.ts","sourceRoot":"","sources":["../../../../src/core/context/name-policy-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAkC,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,eAAO,MAAM,0BAA0B,EAAE,gBAAgB,CAAC,mBAAmB,CAQzE,CAAC;AAEL,wBAAgB,sBAAsB,wBAErC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createNamedContext, useContext } from "@alloy-js/core";
|
|
2
|
+
export const TransformNamePolicyContext = createNamedContext("TransfromNamePolicy", {
|
|
3
|
+
getApplicationName(type) {
|
|
4
|
+
return typeof type.name === "string" ? type.name : "";
|
|
5
|
+
},
|
|
6
|
+
getTransportName(type) {
|
|
7
|
+
return typeof type.name === "string" ? type.name : "";
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
export function useTransformNamePolicy() {
|
|
11
|
+
return useContext(TransformNamePolicyContext);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=name-policy-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"name-policy-context.js","names":["createNamedContext","useContext","TransformNamePolicyContext","getApplicationName","type","name","getTransportName","useTransformNamePolicy"],"sources":["../../../../src/core/context/name-policy-context.ts"],"sourcesContent":[null],"mappings":"AAAA,SAA2BA,kBAAkB,EAAEC,UAAU,QAAQ,gBAAgB;AAGjF,OAAO,MAAMC,0BAAiE,GAC5EF,kBAAkB,CAAsB,qBAAqB,EAAE;EAC7DG,kBAAkBA,CAACC,IAAI,EAAE;IACvB,OAAO,OAAOA,IAAI,CAACC,IAAI,KAAK,QAAQ,GAAGD,IAAI,CAACC,IAAI,GAAG,EAAE;EACvD,CAAC;EACDC,gBAAgBA,CAACF,IAAI,EAAE;IACrB,OAAO,OAAOA,IAAI,CAACC,IAAI,KAAK,QAAQ,GAAGD,IAAI,CAACC,IAAI,GAAG,EAAE;EACvD;AACF,CAAC,CAAC;AAEJ,OAAO,SAASE,sBAAsBA,CAAA,EAAG;EACvC,OAAON,UAAU,CAACC,0BAA0B,CAAC;AAC/C","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/core/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,oBAAoB;AAClC,cAAc,4BAA4B;AAC1C,cAAc,mBAAmB","ignoreList":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Type } from "@typespec/compiler";
|
|
2
|
+
/**
|
|
3
|
+
* A type that extends `Type` and includes a `name` property that can either be a `string` or `symbol`.
|
|
4
|
+
* This type is used to represent objects that have a `name` of type `string` or `symbol`.
|
|
5
|
+
*
|
|
6
|
+
* @template T - The type that extends `Type` and includes a `name` property of type `string | symbol`.
|
|
7
|
+
*/
|
|
8
|
+
export type HasName<T extends Type> = T & {
|
|
9
|
+
name: string | symbol;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Interface defining the transformation policy for names.
|
|
13
|
+
* It contains methods for obtaining transport and application names based on the input `Type` objects.
|
|
14
|
+
*/
|
|
15
|
+
export interface TransformNamePolicy {
|
|
16
|
+
/**
|
|
17
|
+
* Transforms the name of the given `type` into a transport name.
|
|
18
|
+
* The `type` must have a `name` property that is a `string | symbol`.
|
|
19
|
+
*
|
|
20
|
+
* @param type - The object that has a `name` property of type `string | symbol`.
|
|
21
|
+
* @returns A string representing the transformed transport name.
|
|
22
|
+
*/
|
|
23
|
+
getTransportName<T extends HasName<Type>>(type: T): string;
|
|
24
|
+
/**
|
|
25
|
+
* Transforms the name of the given `type` into an application name.
|
|
26
|
+
* The `type` must have a `name` property that is a `string | symbol`.
|
|
27
|
+
*
|
|
28
|
+
* @param type - The object that has a `name` property of type `string | symbol`.
|
|
29
|
+
* @returns A string representing the transformed application name.
|
|
30
|
+
*/
|
|
31
|
+
getApplicationName<T extends HasName<Type>>(type: T): string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Factory function to create a `TransformNamePolicy` instance, which contains the logic for transforming
|
|
35
|
+
* transport and application names. The `namer` functions are used to generate the transport and application names.
|
|
36
|
+
*
|
|
37
|
+
* @param namer - An object with two functions: `transportNamer` and `applicationNamer`, each accepting a `Type` and returning a string.
|
|
38
|
+
* @returns A `TransformNamePolicy` object with the implemented methods for transforming names.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createTransformNamePolicy(namer: {
|
|
41
|
+
transportNamer: <T extends HasName<Type>>(type: T) => string;
|
|
42
|
+
applicationNamer: <T extends HasName<Type>>(type: T) => string;
|
|
43
|
+
}): TransformNamePolicy;
|
|
44
|
+
//# sourceMappingURL=transport-name-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport-name-policy.d.ts","sourceRoot":"","sources":["../../../src/core/transport-name-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEpE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;OAMG;IACH,gBAAgB,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC;IAE3D;;;;;;OAMG;IACH,kBAAkB,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC;CAC9D;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE;IAC/C,cAAc,EAAE,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAC7D,gBAAgB,EAAE,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;CAChE,GAAG,mBAAmB,CAsBtB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A type that extends `Type` and includes a `name` property that can either be a `string` or `symbol`.
|
|
3
|
+
* This type is used to represent objects that have a `name` of type `string` or `symbol`.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type that extends `Type` and includes a `name` property of type `string | symbol`.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Interface defining the transformation policy for names.
|
|
10
|
+
* It contains methods for obtaining transport and application names based on the input `Type` objects.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Factory function to create a `TransformNamePolicy` instance, which contains the logic for transforming
|
|
15
|
+
* transport and application names. The `namer` functions are used to generate the transport and application names.
|
|
16
|
+
*
|
|
17
|
+
* @param namer - An object with two functions: `transportNamer` and `applicationNamer`, each accepting a `Type` and returning a string.
|
|
18
|
+
* @returns A `TransformNamePolicy` object with the implemented methods for transforming names.
|
|
19
|
+
*/
|
|
20
|
+
export function createTransformNamePolicy(namer) {
|
|
21
|
+
return {
|
|
22
|
+
/**
|
|
23
|
+
* Transforms the transport name based on the provided `transportNamer` function.
|
|
24
|
+
*
|
|
25
|
+
* @param type - The object that has a `name` property of type `string | symbol`.
|
|
26
|
+
* @returns The transformed transport name as a string.
|
|
27
|
+
*/
|
|
28
|
+
getTransportName(type) {
|
|
29
|
+
return namer.transportNamer(type);
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* Transforms the application name based on the provided `applicationNamer` function.
|
|
33
|
+
*
|
|
34
|
+
* @param type - The object that has a `name` property of type `string | symbol`.
|
|
35
|
+
* @returns The transformed application name as a string.
|
|
36
|
+
*/
|
|
37
|
+
getApplicationName(type) {
|
|
38
|
+
return namer.applicationNamer(type);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=transport-name-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport-name-policy.js","names":["createTransformNamePolicy","namer","getTransportName","type","transportNamer","getApplicationName","applicationNamer"],"sources":["../../../src/core/transport-name-policy.ts"],"sourcesContent":[null],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,yBAAyBA,CAACC,KAGzC,EAAuB;EACtB,OAAO;IACL;AACJ;AACA;AACA;AACA;AACA;IACIC,gBAAgBA,CAACC,IAAI,EAAE;MACrB,OAAOF,KAAK,CAACG,cAAc,CAACD,IAAI,CAAC;IACnC,CAAC;IAED;AACJ;AACA;AACA;AACA;AACA;IACIE,kBAAkBA,CAACF,IAAI,EAAE;MACvB,OAAOF,KAAK,CAACK,gBAAgB,CAACH,IAAI,CAAC;IACrC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-output.d.ts","sourceRoot":"","sources":["../../../src/core/write-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA2B,MAAM,gBAAgB,CAAC;AAInE,wBAAsB,WAAW,CAAC,aAAa,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,iBAGlF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { render } from "@alloy-js/core";
|
|
2
|
+
import { emitFile, joinPaths } from "@typespec/compiler";
|
|
3
|
+
import { unsafe_$ as $ } from "@typespec/compiler/experimental";
|
|
4
|
+
export async function writeOutput(rootComponent, emitterOutputDir) {
|
|
5
|
+
const tree = render(rootComponent);
|
|
6
|
+
await writeOutputDirectory(tree, emitterOutputDir);
|
|
7
|
+
}
|
|
8
|
+
async function writeOutputDirectory(dir, emitterOutputDir) {
|
|
9
|
+
for (const sub of dir.contents) {
|
|
10
|
+
if (Array.isArray(sub.contents)) {
|
|
11
|
+
await writeOutputDirectory(sub, emitterOutputDir);
|
|
12
|
+
} else {
|
|
13
|
+
await emitFile($.program, {
|
|
14
|
+
content: sub.contents,
|
|
15
|
+
path: joinPaths(emitterOutputDir, sub.path)
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=write-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-output.js","names":["render","emitFile","joinPaths","unsafe_$","$","writeOutput","rootComponent","emitterOutputDir","tree","writeOutputDirectory","dir","sub","contents","Array","isArray","program","content","path"],"sources":["../../../src/core/write-output.ts"],"sourcesContent":[null],"mappings":"AAAA,SAAoCA,MAAM,QAAQ,gBAAgB;AAClE,SAASC,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;AACxD,SAASC,QAAQ,IAAIC,CAAC,QAAQ,iCAAiC;AAE/D,OAAO,eAAeC,WAAWA,CAACC,aAAuB,EAAEC,gBAAwB,EAAE;EACnF,MAAMC,IAAI,GAAGR,MAAM,CAACM,aAAa,CAAC;EAClC,MAAMG,oBAAoB,CAACD,IAAI,EAAED,gBAAgB,CAAC;AACpD;AAEA,eAAeE,oBAAoBA,CAACC,GAAoB,EAAEH,gBAAwB,EAAE;EAClF,KAAK,MAAMI,GAAG,IAAID,GAAG,CAACE,QAAQ,EAAE;IAC9B,IAAIC,KAAK,CAACC,OAAO,CAACH,GAAG,CAACC,QAAQ,CAAC,EAAE;MAC/B,MAAMH,oBAAoB,CAACE,GAAG,EAAqBJ,gBAAgB,CAAC;IACtE,CAAC,MAAM;MACL,MAAMN,QAAQ,CAACG,CAAC,CAACW,OAAO,EAAE;QACxBC,OAAO,EAAEL,GAAG,CAACC,QAAkB;QAC/BK,IAAI,EAAEf,SAAS,CAACK,gBAAgB,EAAEI,GAAG,CAACM,IAAI;MAC5C,CAAC,CAAC;IACJ;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
|
|
2
|
+
"type-declaration-missing-name": {
|
|
3
|
+
readonly default: "Can't declare a type without a name";
|
|
4
|
+
};
|
|
5
|
+
}, Record<string, any>, never>;
|
|
6
|
+
export declare const reportDiagnostic: <C extends "type-declaration-missing-name", M extends keyof {
|
|
7
|
+
"type-declaration-missing-name": {
|
|
8
|
+
readonly default: "Can't declare a type without a name";
|
|
9
|
+
};
|
|
10
|
+
}[C]>(program: import("@typespec/compiler").Program, diag: import("@typespec/compiler").DiagnosticReport<{
|
|
11
|
+
"type-declaration-missing-name": {
|
|
12
|
+
readonly default: "Can't declare a type without a name";
|
|
13
|
+
};
|
|
14
|
+
}, C, M>) => void, createDiagnostic: <C extends "type-declaration-missing-name", M extends keyof {
|
|
15
|
+
"type-declaration-missing-name": {
|
|
16
|
+
readonly default: "Can't declare a type without a name";
|
|
17
|
+
};
|
|
18
|
+
}[C]>(diag: import("@typespec/compiler").DiagnosticReport<{
|
|
19
|
+
"type-declaration-missing-name": {
|
|
20
|
+
readonly default: "Can't declare a type without a name";
|
|
21
|
+
};
|
|
22
|
+
}, C, M>) => import("@typespec/compiler").Diagnostic;
|
|
23
|
+
//# sourceMappingURL=lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI;;;;8BAWf,CAAC;AAEH,eAAO,MAAQ,gBAAgB;;;;;;;;mBAAE,gBAAgB;;;;;;;;oDAAS,CAAC"}
|
package/dist/src/lib.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createTypeSpecLibrary } from "@typespec/compiler";
|
|
2
|
+
export const $lib = createTypeSpecLibrary({
|
|
3
|
+
name: "emitter-framework",
|
|
4
|
+
diagnostics: {
|
|
5
|
+
"type-declaration-missing-name": {
|
|
6
|
+
messages: {
|
|
7
|
+
default: "Can't declare a type without a name"
|
|
8
|
+
},
|
|
9
|
+
severity: "error",
|
|
10
|
+
description: "A type declaration must have a name"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
export const {
|
|
15
|
+
reportDiagnostic,
|
|
16
|
+
createDiagnostic
|
|
17
|
+
} = $lib;
|
|
18
|
+
//# sourceMappingURL=lib.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.js","names":["createTypeSpecLibrary","$lib","name","diagnostics","messages","default","severity","description","reportDiagnostic","createDiagnostic"],"sources":["../../src/lib.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,oBAAoB;AAE1D,OAAO,MAAMC,IAAI,GAAGD,qBAAqB,CAAC;EACxCE,IAAI,EAAE,mBAAmB;EACzBC,WAAW,EAAE;IACX,+BAA+B,EAAE;MAC/BC,QAAQ,EAAE;QACRC,OAAO,EAAE;MACX,CAAC;MACDC,QAAQ,EAAE,OAAO;MACjBC,WAAW,EAAE;IACf;EACF;AACF,CAAC,CAAC;AAEF,OAAO,MAAM;EAAEC,gBAAgB;EAAEC;AAAiB,CAAC,GAAGR,IAAI","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGpF,eAAO,MAAM,2BAA2B,EAAE,mBAGxC,CAAC;AAEH,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { resolvePath } from "@typespec/compiler";
|
|
2
|
+
import { createTestLibrary } from "@typespec/compiler/testing";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
export const EmitterFrameworkTestLibrary = createTestLibrary({
|
|
5
|
+
name: "@typespec/emitter-framework",
|
|
6
|
+
packageRoot: resolvePath(fileURLToPath(import.meta.url), "../../../")
|
|
7
|
+
});
|
|
8
|
+
export * from "./scenario-test/index.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["resolvePath","createTestLibrary","fileURLToPath","EmitterFrameworkTestLibrary","name","packageRoot","import","meta","url"],"sources":["../../../src/testing/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAW,QAAQ,oBAAoB;AAChD,SAASC,iBAAiB,QAA6B,4BAA4B;AACnF,SAASC,aAAa,QAAQ,KAAK;AAEnC,OAAO,MAAMC,2BAAgD,GAAGF,iBAAiB,CAAC;EAChFG,IAAI,EAAE,6BAA6B;EACnCC,WAAW,EAAEL,WAAW,CAACE,aAAa,CAACI,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC,EAAE,WAAW;AACtE,CAAC,CAAC;AAEF,cAAc,0BAA0B","ignoreList":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TypeSpecTestLibrary } from "@typespec/compiler/testing";
|
|
2
|
+
import { LanguageConfiguration, SnippetExtractor } from "./snippet-extractor.js";
|
|
3
|
+
export declare function executeScenarios(testLibrary: TypeSpecTestLibrary, languageConfiguration: LanguageConfiguration, scenariosLocation: string, emitterOutputDir: string, snippetExtractor: SnippetExtractor): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=harness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness.d.ts","sourceRoot":"","sources":["../../../../src/testing/scenario-test/harness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAMjE,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AA6HjF,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,mBAAmB,EAChC,qBAAqB,EAAE,qBAAqB,EAC5C,iBAAiB,EAAE,MAAM,EACzB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,gBAAgB,iBAkBnC"}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { readdirSync, readFileSync, statSync, writeFileSync } from "fs";
|
|
2
|
+
import minimist from "minimist";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { format } from "prettier";
|
|
5
|
+
import { afterAll, describe, expect, it } from "vitest";
|
|
6
|
+
import { emitWithDiagnostics } from "./test-host.js";
|
|
7
|
+
const rawArgs = process.env.TEST_ARGS ? process.env.TEST_ARGS.split(" ") : [];
|
|
8
|
+
|
|
9
|
+
// Parse command-line arguments with minimist
|
|
10
|
+
const args = minimist(rawArgs, {
|
|
11
|
+
alias: {
|
|
12
|
+
filter: "f" // Short alias for `--filter`
|
|
13
|
+
},
|
|
14
|
+
default: {
|
|
15
|
+
filter: undefined // Default to undefined if no filter is provided
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Extract the filter paths from the parsed arguments
|
|
20
|
+
const filterPaths = args.filter ? Array.isArray(args.filter) // Handle single or multiple file paths
|
|
21
|
+
? args.filter : [args.filter] : undefined;
|
|
22
|
+
const SCENARIOS_UPDATE = process.env["SCENARIOS_UPDATE"] === "true";
|
|
23
|
+
async function assertGetEmittedFile(testLibrary, emitterOutputDir, file, code) {
|
|
24
|
+
const [emittedFiles, diagnostics] = await emitWithDiagnostics(testLibrary, emitterOutputDir, code);
|
|
25
|
+
const errors = diagnostics.filter(d => d.severity === "error");
|
|
26
|
+
const warnings = diagnostics.filter(d => d.severity === "warning");
|
|
27
|
+
if (warnings.length > 0) {
|
|
28
|
+
// eslint-disable-next-line no-console
|
|
29
|
+
console.warn(`Warning compiling code:\n ${warnings.map(x => x.message).join("\n")}`);
|
|
30
|
+
}
|
|
31
|
+
if (errors.length > 0) {
|
|
32
|
+
throw new Error(`Error compiling code:\n ${errors.map(x => x.message).join("\n")}`);
|
|
33
|
+
}
|
|
34
|
+
const sourceFile = emittedFiles.find(x => x.path === file);
|
|
35
|
+
if (!sourceFile) {
|
|
36
|
+
throw new Error(`File ${file} not found in emitted files:\n ${emittedFiles.map(f => f.path).join("\n")}`);
|
|
37
|
+
}
|
|
38
|
+
return sourceFile;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Mapping of different snapshot types to how to get them.
|
|
43
|
+
* Snapshot types can take single-word string arguments templated in curly braces {} and are otherwise regex
|
|
44
|
+
*/
|
|
45
|
+
function getCodeBlockTypes(testLibrary, languageConfiguration, emitterOutputDir, snippetExtractor) {
|
|
46
|
+
const languageTags = languageConfiguration.codeBlockTypes.join("|");
|
|
47
|
+
return {
|
|
48
|
+
// Snapshot of a particular interface named {name} in the models file
|
|
49
|
+
[`(${languageTags}) {file} interface {name}`]: async (code, {
|
|
50
|
+
file,
|
|
51
|
+
name
|
|
52
|
+
}) => {
|
|
53
|
+
const sourceFile = await assertGetEmittedFile(testLibrary, emitterOutputDir, file, code);
|
|
54
|
+
const snippet = snippetExtractor.getInterface(sourceFile.content, name);
|
|
55
|
+
if (!snippet) {
|
|
56
|
+
throw new Error(`Interface ${name} not found in ${file}`);
|
|
57
|
+
}
|
|
58
|
+
return snippet;
|
|
59
|
+
},
|
|
60
|
+
[`(${languageTags}) {file} type {name}`]: async (code, {
|
|
61
|
+
file,
|
|
62
|
+
name
|
|
63
|
+
}) => {
|
|
64
|
+
const sourceFile = await assertGetEmittedFile(testLibrary, emitterOutputDir, file, code);
|
|
65
|
+
const snippet = snippetExtractor.getTypeAlias(sourceFile.content, name);
|
|
66
|
+
if (!snippet) {
|
|
67
|
+
throw new Error(`Type alias ${name} not found in ${file}`);
|
|
68
|
+
}
|
|
69
|
+
return snippet;
|
|
70
|
+
},
|
|
71
|
+
// Snapshot of a particular function named {name} in the models file
|
|
72
|
+
[`(${languageTags}) {file} function {name}`]: async (code, {
|
|
73
|
+
file,
|
|
74
|
+
name
|
|
75
|
+
}) => {
|
|
76
|
+
const sourceFile = await assertGetEmittedFile(testLibrary, emitterOutputDir, file, code);
|
|
77
|
+
const snippet = snippetExtractor.getFunction(sourceFile.content, name);
|
|
78
|
+
if (!snippet) {
|
|
79
|
+
throw new Error(`Function ${name} not found in ${file}`);
|
|
80
|
+
}
|
|
81
|
+
return snippet;
|
|
82
|
+
},
|
|
83
|
+
// Snapshot of a particular class named {name} in the models file
|
|
84
|
+
[`(${languageTags}) {file} class {name}`]: async (code, {
|
|
85
|
+
file,
|
|
86
|
+
name
|
|
87
|
+
}) => {
|
|
88
|
+
const sourceFile = await assertGetEmittedFile(testLibrary, emitterOutputDir, file, code);
|
|
89
|
+
const snippet = snippetExtractor.getClass(sourceFile.content, name);
|
|
90
|
+
if (!snippet) {
|
|
91
|
+
throw new Error(`Class ${name} not found in ${file}`);
|
|
92
|
+
}
|
|
93
|
+
return snippet;
|
|
94
|
+
},
|
|
95
|
+
// Snapshot of the entire file
|
|
96
|
+
[`(${languageTags}) {file}`]: async (code, {
|
|
97
|
+
file
|
|
98
|
+
}) => {
|
|
99
|
+
const sourceFile = await assertGetEmittedFile(testLibrary, emitterOutputDir, file, code);
|
|
100
|
+
return sourceFile.content;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export async function executeScenarios(testLibrary, languageConfiguration, scenariosLocation, emitterOutputDir, snippetExtractor) {
|
|
105
|
+
const scenarioList = filterPaths ?? [];
|
|
106
|
+
// eslint-disable-next-line no-console
|
|
107
|
+
scenarioList.length && console.log("Filtering scenarios: ", scenarioList);
|
|
108
|
+
if (!scenarioList.length) {
|
|
109
|
+
// Add all scenarios.
|
|
110
|
+
discoverAllScenarios(scenariosLocation, scenarioList);
|
|
111
|
+
}
|
|
112
|
+
describeScenarios(scenarioList, testLibrary, languageConfiguration, emitterOutputDir, snippetExtractor);
|
|
113
|
+
}
|
|
114
|
+
function discoverAllScenarios(location, scenarios) {
|
|
115
|
+
const children = readdirSync(location);
|
|
116
|
+
for (const child of children) {
|
|
117
|
+
const fullPath = path.join(location, child);
|
|
118
|
+
const stat = statSync(fullPath);
|
|
119
|
+
if (stat.isDirectory()) {
|
|
120
|
+
discoverAllScenarios(fullPath, scenarios);
|
|
121
|
+
} else {
|
|
122
|
+
scenarios.push(fullPath);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return scenarios;
|
|
126
|
+
}
|
|
127
|
+
function parseFile(path, testLibrary, languageConfiguration, emitterOutputDir, snippetExtractor) {
|
|
128
|
+
// Read the whole file
|
|
129
|
+
const rawContent = readFileSync(path, {
|
|
130
|
+
encoding: "utf-8"
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Split the content by H1
|
|
134
|
+
const sections = splitByH1(rawContent);
|
|
135
|
+
const scenarioFile = {
|
|
136
|
+
path,
|
|
137
|
+
scenarios: []
|
|
138
|
+
};
|
|
139
|
+
for (const section of sections) {
|
|
140
|
+
const scenarioContent = parseScenario(section.content, testLibrary, languageConfiguration, emitterOutputDir, snippetExtractor);
|
|
141
|
+
const scenario = {
|
|
142
|
+
title: section.title,
|
|
143
|
+
content: scenarioContent
|
|
144
|
+
};
|
|
145
|
+
scenarioFile.scenarios.push(scenario);
|
|
146
|
+
}
|
|
147
|
+
return scenarioFile;
|
|
148
|
+
}
|
|
149
|
+
function isTestCodeBlock(codeBlock) {
|
|
150
|
+
return codeBlock.kind === "test";
|
|
151
|
+
}
|
|
152
|
+
function parseScenario(content, testLibrary, languageConfiguration, emitterOutputDir, snippetExtractor) {
|
|
153
|
+
const rawLines = content.split("\n");
|
|
154
|
+
const scenario = {
|
|
155
|
+
lines: [],
|
|
156
|
+
specBlock: {
|
|
157
|
+
kind: "spec",
|
|
158
|
+
content: []
|
|
159
|
+
},
|
|
160
|
+
testBlocks: []
|
|
161
|
+
};
|
|
162
|
+
let currentCodeBlock = null;
|
|
163
|
+
|
|
164
|
+
// Precompute output code block types once
|
|
165
|
+
const outputCodeBlockTypes = getCodeBlockTypes(testLibrary, languageConfiguration, emitterOutputDir, snippetExtractor);
|
|
166
|
+
for (const line of rawLines) {
|
|
167
|
+
if (line.startsWith("```")) {
|
|
168
|
+
if (currentCodeBlock) {
|
|
169
|
+
// Close the code block
|
|
170
|
+
scenario.lines.push(currentCodeBlock);
|
|
171
|
+
if (!isTestCodeBlock(currentCodeBlock)) {
|
|
172
|
+
scenario.specBlock.content = currentCodeBlock.content;
|
|
173
|
+
} else {
|
|
174
|
+
for (const [template, fn] of Object.entries(outputCodeBlockTypes)) {
|
|
175
|
+
const templateRegex = new RegExp("^" + template.replace(/\{(\w+)\}/g, "(?<$1>[^\\s]+)") + "$");
|
|
176
|
+
const match = currentCodeBlock.heading.match(templateRegex);
|
|
177
|
+
if (match) {
|
|
178
|
+
currentCodeBlock.matchedTemplate = {
|
|
179
|
+
template,
|
|
180
|
+
fn,
|
|
181
|
+
namedArgs: match.groups ?? null
|
|
182
|
+
};
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
scenario.testBlocks.push(currentCodeBlock);
|
|
187
|
+
}
|
|
188
|
+
currentCodeBlock = null;
|
|
189
|
+
} else {
|
|
190
|
+
const codeBlockKind = line.includes("tsp") || line.includes("typespec") ? "spec" : "test";
|
|
191
|
+
// Start a new code block
|
|
192
|
+
currentCodeBlock = {
|
|
193
|
+
kind: codeBlockKind,
|
|
194
|
+
heading: line.substring(3),
|
|
195
|
+
content: []
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
} else if (currentCodeBlock) {
|
|
199
|
+
// Append to code block content
|
|
200
|
+
currentCodeBlock.content.push(line);
|
|
201
|
+
} else {
|
|
202
|
+
// Add regular line
|
|
203
|
+
scenario.lines.push(line);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return scenario;
|
|
207
|
+
}
|
|
208
|
+
function describeScenarios(scenarioFiles, testLibrary, languageConfiguration, emitterOutputDir, snippetExtractor) {
|
|
209
|
+
const scenarios = scenarioFiles.map(f => parseFile(f, testLibrary, languageConfiguration, emitterOutputDir, snippetExtractor));
|
|
210
|
+
for (const scenarioFile of scenarios) {
|
|
211
|
+
describe(`Scenario File: ${scenarioFile.path}`, () => {
|
|
212
|
+
for (const scenario of scenarioFile.scenarios) {
|
|
213
|
+
const isOnly = scenario.title.includes("only:");
|
|
214
|
+
const isSkip = scenario.title.includes("skip:");
|
|
215
|
+
const describeFn = isSkip ? describe.skip : isOnly ? describe.only : describe;
|
|
216
|
+
describeFn(`Scenario: ${scenario.title}`, () => {
|
|
217
|
+
for (const testBlock of scenario.content.testBlocks) {
|
|
218
|
+
it(`Test: ${testBlock.heading}`, async () => {
|
|
219
|
+
const {
|
|
220
|
+
fn,
|
|
221
|
+
namedArgs
|
|
222
|
+
} = testBlock.matchedTemplate;
|
|
223
|
+
const result = await fn(scenario.content.specBlock.content.join("\n"), namedArgs ?? {});
|
|
224
|
+
if (SCENARIOS_UPDATE) {
|
|
225
|
+
testBlock.content = (await languageConfiguration.format(result)).split("\n");
|
|
226
|
+
} else {
|
|
227
|
+
const expected = await languageConfiguration.format(testBlock.content.join("\n"));
|
|
228
|
+
const actual = await languageConfiguration.format(result);
|
|
229
|
+
expect(actual).toBe(expected);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Update after all the tests in the scenario if write mode was enabled
|
|
237
|
+
afterAll(async function () {
|
|
238
|
+
if (SCENARIOS_UPDATE) {
|
|
239
|
+
await updateFile(scenarioFile);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
async function updateFile(scenarioFile) {
|
|
246
|
+
const newContent = [];
|
|
247
|
+
for (const scenario of scenarioFile.scenarios) {
|
|
248
|
+
newContent.push(`# ${scenario.title}`);
|
|
249
|
+
for (const line of scenario.content.lines) {
|
|
250
|
+
if (typeof line === "string") {
|
|
251
|
+
newContent.push(line);
|
|
252
|
+
} else {
|
|
253
|
+
const heading = isTestCodeBlock(line) ? line.heading : "tsp";
|
|
254
|
+
newContent.push("```" + heading);
|
|
255
|
+
newContent.push(...line.content);
|
|
256
|
+
newContent.push("```");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const formattedContent = await format(newContent.join("\n"), {
|
|
261
|
+
parser: "markdown"
|
|
262
|
+
});
|
|
263
|
+
writeFileSync(scenarioFile.path, formattedContent, {
|
|
264
|
+
encoding: "utf-8"
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
function splitByH1(content) {
|
|
268
|
+
const sections = content.split(/\n(?=# )/).map(section => {
|
|
269
|
+
const lines = section.split("\n");
|
|
270
|
+
const title = lines.shift().replace(/^#+\s+/, "");
|
|
271
|
+
return {
|
|
272
|
+
title,
|
|
273
|
+
content: lines.join("\n")
|
|
274
|
+
};
|
|
275
|
+
});
|
|
276
|
+
return sections;
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=harness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness.js","names":["readdirSync","readFileSync","statSync","writeFileSync","minimist","path","format","afterAll","describe","expect","it","emitWithDiagnostics","rawArgs","process","env","TEST_ARGS","split","args","alias","filter","default","undefined","filterPaths","Array","isArray","SCENARIOS_UPDATE","assertGetEmittedFile","testLibrary","emitterOutputDir","file","code","emittedFiles","diagnostics","errors","d","severity","warnings","length","console","warn","map","x","message","join","Error","sourceFile","find","f","getCodeBlockTypes","languageConfiguration","snippetExtractor","languageTags","codeBlockTypes","name","snippet","getInterface","content","getTypeAlias","getFunction","getClass","executeScenarios","scenariosLocation","scenarioList","log","discoverAllScenarios","describeScenarios","location","scenarios","children","child","fullPath","stat","isDirectory","push","parseFile","rawContent","encoding","sections","splitByH1","scenarioFile","section","scenarioContent","parseScenario","scenario","title","isTestCodeBlock","codeBlock","kind","rawLines","lines","specBlock","testBlocks","currentCodeBlock","outputCodeBlockTypes","line","startsWith","template","fn","Object","entries","templateRegex","RegExp","replace","match","heading","matchedTemplate","namedArgs","groups","codeBlockKind","includes","substring","scenarioFiles","isOnly","isSkip","describeFn","skip","only","testBlock","result","expected","actual","toBe","updateFile","newContent","formattedContent","parser","shift"],"sources":["../../../../src/testing/scenario-test/harness.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,WAAW,EAAEC,YAAY,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,IAAI;AACvE,OAAOC,QAAQ,MAAM,UAAU;AAC/B,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,MAAM,QAAQ,UAAU;AACjC,SAASC,QAAQ,E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AC5B6B,UAAU,CAAClD,IAAI,CAACqB,IAAI,CAAC;MACvB,CAAC,MAAM;QACL,MAAMU,OAAO,GAAGnB,eAAe,CAACS,IAAI,CAAC,GAAGA,IAAI,CAACU,OAAO,GAAG,KAAK;QAC5DmB,UAAU,CAAClD,IAAI,CAAC,KAAK,GAAG+B,OAAO,CAAC;QAChCmB,UAAU,CAAClD,IAAI,CAAC,GAAGqB,IAAI,CAACtC,OAAO,CAAC;QAChCmE,UAAU,CAAClD,IAAI,CAAC,KAAK,CAAC;MACxB;IACF;EACF;EAEA,MAAMmD,gBAAgB,GAAG,MAAMtH,MAAM,CAACqH,UAAU,CAAChF,IAAI,CAAC,IAAI,CAAC,EAAE;IAAEkF,MAAM,EAAE;EAAW,CAAC,CAAC;EACpF1H,aAAa,CAAC4E,YAAY,CAAC1E,IAAI,EAAEuH,gBAAgB,EAAE;IAAEhD,QAAQ,EAAE;EAAQ,CAAC,CAAC;AAC3E;AAEA,SAASE,SAASA,CAACtB,OAAe,EAAwC;EACxE,MAAMqB,QAAQ,GAAGrB,OAAO,CAACxC,KAAK,CAAC,UAAU,CAAC,CAACwB,GAAG,CAAEwC,OAAO,IAAK;IAC1D,MAAMS,KAAK,GAAGT,OAAO,CAAChE,KAAK,CAAC,IAAI,CAAC;IACjC,MAAMoE,KAAK,GAAGK,KAAK,CAACqC,KAAK,CAAC,CAAC,CAAExB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;IAClD,OAAO;MACLlB,KAAK;MACL5B,OAAO,EAAEiC,KAAK,CAAC9C,IAAI,CAAC,IAAI;IAC1B,CAAC;EACH,CAAC,CAAC;EAEF,OAAOkC,QAAQ;AACjB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/scenario-test/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/testing/scenario-test/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,wBAAwB;AACtC,cAAc,gBAAgB","ignoreList":[]}
|