@azure-tools/typespec-ts 0.31.0 → 0.32.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/CHANGELOG.md +25 -7
- package/README.md +8 -0
- package/dist/src/contextManager.d.ts +2 -0
- package/dist/src/contextManager.d.ts.map +1 -1
- package/dist/src/contextManager.js.map +1 -1
- package/dist/src/framework/dependency.d.ts +69 -0
- package/dist/src/framework/dependency.d.ts.map +1 -0
- package/dist/src/framework/dependency.js +2 -0
- package/dist/src/framework/dependency.js.map +1 -0
- package/dist/src/framework/hooks/binder.d.ts +8 -2
- package/dist/src/framework/hooks/binder.d.ts.map +1 -1
- package/dist/src/framework/hooks/binder.js +107 -20
- package/dist/src/framework/hooks/binder.js.map +1 -1
- package/dist/src/framework/hooks/useDependencies.d.ts +4 -0
- package/dist/src/framework/hooks/useDependencies.d.ts.map +1 -0
- package/dist/src/framework/hooks/useDependencies.js +13 -0
- package/dist/src/framework/hooks/useDependencies.js.map +1 -0
- package/dist/src/framework/load-static-helpers.d.ts +16 -0
- package/dist/src/framework/load-static-helpers.d.ts.map +1 -0
- package/dist/src/framework/load-static-helpers.js +93 -0
- package/dist/src/framework/load-static-helpers.js.map +1 -0
- package/dist/src/framework/reference.d.ts +1 -1
- package/dist/src/framework/reference.d.ts.map +1 -1
- package/dist/src/framework/reference.js +16 -2
- package/dist/src/framework/reference.js.map +1 -1
- package/dist/src/framework/sample.js +1 -1
- package/dist/src/framework/sample.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +113 -79
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +10 -1
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +8 -1
- package/dist/src/lib.js.map +1 -1
- package/dist/src/modular/buildClassicalClient.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalClient.js +12 -9
- package/dist/src/modular/buildClassicalClient.js.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.js +1 -11
- package/dist/src/modular/buildClassicalOperationGroups.js.map +1 -1
- package/dist/src/modular/buildClientContext.d.ts.map +1 -1
- package/dist/src/modular/buildClientContext.js +73 -52
- package/dist/src/modular/buildClientContext.js.map +1 -1
- package/dist/src/modular/buildCodeModel.d.ts +1 -1
- package/dist/src/modular/buildCodeModel.d.ts.map +1 -1
- package/dist/src/modular/buildCodeModel.js +36 -62
- package/dist/src/modular/buildCodeModel.js.map +1 -1
- package/dist/src/modular/buildHelperSerializers.d.ts.map +1 -1
- package/dist/src/modular/buildHelperSerializers.js.map +1 -1
- package/dist/src/modular/buildOperations.d.ts +1 -3
- package/dist/src/modular/buildOperations.d.ts.map +1 -1
- package/dist/src/modular/buildOperations.js +9 -69
- package/dist/src/modular/buildOperations.js.map +1 -1
- package/dist/src/modular/buildRestorePoller.d.ts +3 -0
- package/dist/src/modular/buildRestorePoller.d.ts.map +1 -0
- package/dist/src/modular/buildRestorePoller.js +203 -0
- package/dist/src/modular/buildRestorePoller.js.map +1 -0
- package/dist/src/modular/buildRootIndex.d.ts.map +1 -1
- package/dist/src/modular/buildRootIndex.js +37 -0
- package/dist/src/modular/buildRootIndex.js.map +1 -1
- package/dist/src/modular/emitLoggerFile.d.ts +4 -0
- package/dist/src/modular/emitLoggerFile.d.ts.map +1 -0
- package/dist/src/modular/emitLoggerFile.js +16 -0
- package/dist/src/modular/emitLoggerFile.js.map +1 -0
- package/dist/src/modular/emitModels.d.ts.map +1 -1
- package/dist/src/modular/emitModels.js +0 -5
- package/dist/src/modular/emitModels.js.map +1 -1
- package/dist/src/modular/external-dependencies.d.ts +26 -0
- package/dist/src/modular/external-dependencies.d.ts.map +1 -0
- package/dist/src/modular/external-dependencies.js +137 -0
- package/dist/src/modular/external-dependencies.js.map +1 -0
- package/dist/src/modular/helpers/clientHelpers.d.ts +13 -6
- package/dist/src/modular/helpers/clientHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.js +92 -7
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts +6 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.js +43 -69
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.d.ts +1 -0
- package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.js +6 -0
- package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
- package/dist/src/modular/interfaces.d.ts +1 -0
- package/dist/src/modular/interfaces.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.js +2 -20
- package/dist/src/modular/serialization/buildSerializerFunction.js.map +1 -1
- package/dist/src/modular/static-helpers-metadata.d.ts +72 -0
- package/dist/src/modular/static-helpers-metadata.d.ts.map +1 -0
- package/dist/src/modular/static-helpers-metadata.js +72 -0
- package/dist/src/modular/static-helpers-metadata.js.map +1 -0
- package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -1
- package/dist/src/transform/transfromRLCOptions.js +56 -49
- package/dist/src/transform/transfromRLCOptions.js.map +1 -1
- package/dist/src/utils/credentialUtils.d.ts +10 -0
- package/dist/src/utils/credentialUtils.d.ts.map +1 -0
- package/dist/src/utils/credentialUtils.js +37 -0
- package/dist/src/utils/credentialUtils.js.map +1 -0
- package/dist/src/utils/dirname.d.ts +9 -0
- package/dist/src/utils/dirname.d.ts.map +1 -0
- package/dist/src/utils/dirname.js +12 -0
- package/dist/src/utils/dirname.js.map +1 -0
- package/dist/src/utils/emitUtil.d.ts.map +1 -1
- package/dist/src/utils/emitUtil.js +3 -5
- package/dist/src/utils/emitUtil.js.map +1 -1
- package/dist/src/utils/modelUtils.d.ts +1 -1
- package/dist/src/utils/modelUtils.js +3 -2
- package/dist/src/utils/modelUtils.js.map +1 -1
- package/dist/src/utils/operationUtil.d.ts.map +1 -1
- package/dist/src/utils/operationUtil.js +20 -2
- package/dist/src/utils/operationUtil.js.map +1 -1
- package/dist/src/utils/resolve-project-root.d.ts +7 -0
- package/dist/src/utils/resolve-project-root.d.ts.map +1 -0
- package/dist/src/utils/resolve-project-root.js +22 -0
- package/dist/src/utils/resolve-project-root.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -25
- package/src/contextManager.ts +2 -0
- package/src/framework/dependency.ts +56 -0
- package/src/framework/hooks/binder.ts +144 -27
- package/src/framework/hooks/useDependencies.ts +18 -0
- package/src/framework/load-static-helpers.ts +174 -0
- package/src/framework/reference.ts +27 -3
- package/src/framework/sample.ts +1 -1
- package/src/index.ts +154 -113
- package/src/lib.ts +8 -1
- package/src/modular/buildClassicalClient.ts +14 -12
- package/src/modular/buildClassicalOperationGroups.ts +1 -24
- package/src/modular/buildClientContext.ts +93 -63
- package/src/modular/buildCodeModel.ts +93 -128
- package/src/modular/buildHelperSerializers.ts +1 -0
- package/src/modular/buildOperations.ts +9 -110
- package/src/modular/buildRestorePoller.ts +239 -0
- package/src/modular/buildRootIndex.ts +68 -0
- package/src/modular/emitLoggerFile.ts +28 -0
- package/src/modular/emitModels.ts +0 -8
- package/src/modular/external-dependencies.ts +140 -0
- package/src/modular/helpers/clientHelpers.ts +148 -14
- package/src/modular/helpers/operationHelpers.ts +72 -109
- package/src/modular/helpers/typeHelpers.ts +8 -0
- package/src/modular/interfaces.ts +1 -0
- package/src/modular/serialization/buildSerializerFunction.ts +3 -33
- package/src/modular/static-helpers-metadata.ts +73 -0
- package/src/transform/transfromRLCOptions.ts +61 -53
- package/src/utils/credentialUtils.ts +41 -0
- package/src/utils/dirname.ts +12 -0
- package/src/utils/emitUtil.ts +3 -2
- package/src/utils/modelUtils.ts +4 -4
- package/src/utils/operationUtil.ts +25 -2
- package/src/utils/resolve-project-root.ts +28 -0
- package/static/static-helpers/pagingHelpers.ts +274 -0
- package/static/static-helpers/pollingHelpers.ts +137 -0
- package/static/static-helpers/serialization/build-csv-collection.ts +6 -0
- package/static/static-helpers/serialization/build-multi-collection.ts +13 -0
- package/static/static-helpers/serialization/build-pipe-collection.ts +3 -0
- package/static/static-helpers/serialization/build-ssv-collection.ts +3 -0
- package/static/static-helpers/serialization/build-tsv-collection.ts +3 -0
- package/dist/src/modular/buildLroFiles.d.ts +0 -24
- package/dist/src/modular/buildLroFiles.d.ts.map +0 -1
- package/dist/src/modular/buildLroFiles.js +0 -393
- package/dist/src/modular/buildLroFiles.js.map +0 -1
- package/dist/src/modular/buildPagingFiles.d.ts +0 -4
- package/dist/src/modular/buildPagingFiles.d.ts.map +0 -1
- package/dist/src/modular/buildPagingFiles.js +0 -333
- package/dist/src/modular/buildPagingFiles.js.map +0 -1
- package/src/modular/buildLroFiles.ts +0 -429
- package/src/modular/buildPagingFiles.ts +0 -356
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
|
+
## 0.32.0 (2024-08-15)
|
|
2
|
+
|
|
3
|
+
- [Feature] Remove internal RLC layer from modular. Please refer to [#2728](https://github.com/Azure/autorest.typescript/pull/2728).
|
|
4
|
+
- [Feature] Upgrade TypeSpec compiler to 0.59. Please refer to [#2741](https://github.com/Azure/autorest.typescript/pull/2741).
|
|
5
|
+
- [Feature] Fix some issues with API version handling in new getClient. Please refer to [#2738](https://github.com/Azure/autorest.typescript/pull/2738).
|
|
6
|
+
- [Feature] Binder support external dependencies. Please refer to [#2728](https://github.com/Azure/autorest.typescript/pull/2728) and [#2716](https://github.com/Azure/autorest.typescript/pull/2716).
|
|
7
|
+
- [Feature] Update the existing package.json to correct lro or paging dependencies. Please refer to [#2732](https://github.com/Azure/autorest.typescript/pull/2732).
|
|
8
|
+
- [Feature] Engineering system related improvements.
|
|
9
|
+
- Upgrade dependency vitest version to ^2.0.5 in generated packages, please refer to [#2749](https://github.com/Azure/autorest.typescript/pull/2749);
|
|
10
|
+
- Use ESLint flat config files in generated package, please refer to [#2754](https://github.com/Azure/autorest.typescript/pull/2754);
|
|
11
|
+
- Upgrade tshy to v2, please refer to [#2751](https://github.com/Azure/autorest.typescript/pull/2751).
|
|
12
|
+
- [Bugfix] Enable changelog pack for RLC and Modular. Please refer to [#2695](https://github.com/Azure/autorest.typescript/pull/2695).
|
|
13
|
+
- [Bugfix] Disable sampleUrl generation if generateSample is false. Please refer to [#2713](https://github.com/Azure/autorest.typescript/pull/2713).
|
|
14
|
+
- [Bugfix] Fix resolve conflicts bug. Please refer to [#2717](https://github.com/Azure/autorest.typescript/pull/2717).
|
|
15
|
+
- [Bugfix] Fix client name issue in Modular. Please refer to [#2744](https://github.com/Azure/autorest.typescript/pull/2744).
|
|
16
|
+
- [Bugfix] Set as azure scope if package is under azure-rest. Please refer to [#2756](https://github.com/Azure/autorest.typescript/pull/2756).
|
|
17
|
+
- [Bugfix] Emit warnings for un-supported credential and filter out non-200 status code in response check. Please refer to [#2704](https://github.com/Azure/autorest.typescript/pull/2704).
|
|
18
|
+
|
|
1
19
|
## 0.31.0 (2024-07-23)
|
|
2
20
|
|
|
3
21
|
- [Feature] Set user agent prefix at different layer for modular. Please refer to [#2616](https://github.com/Azure/autorest.typescript/pull/2616).
|
|
4
22
|
- [Feature] Spread is spread support. Please refer to [#2653](https://github.com/Azure/autorest.typescript/pull/2653).
|
|
5
23
|
- [Feature] Upgrade TypeSpec compiler version to 0.58.x. Please refer to [#2679](https://github.com/Azure/autorest.typescript/pull/2679).
|
|
6
|
-
- [Feature] Support Modular readme.md generation. Please refer to [#2655](https://github.com/Azure/autorest.typescript/pull/2655).
|
|
24
|
+
- [Feature] Support Modular readme.md generation. Please refer to [#2655](https://github.com/Azure/autorest.typescript/pull/2655).
|
|
7
25
|
- [Feature] Engineering system related improvements.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
26
|
+
- Bump typescript version to ~5.5.3, please refer to [#2646](https://github.com/Azure/autorest.typescript/pull/2646);
|
|
27
|
+
- vitest timeout config, please refer to [#2632](https://github.com/Azure/autorest.typescript/pull/2632);
|
|
28
|
+
- recorded client for esm package improve, please refer to [#2632](https://github.com/Azure/autorest.typescript/pull/2632);
|
|
29
|
+
- skip sample validation if generateSample is false, please refer to [#2650](https://github.com/Azure/autorest.typescript/pull/2650);
|
|
30
|
+
- remove unused configuration files, please refer to [#2655](https://github.com/Azure/autorest.typescript/pull/2655);
|
|
31
|
+
- add and refine document for generated code, please refer to [#2661](https://github.com/Azure/autorest.typescript/pull/2661) and [#2621](https://github.com/Azure/autorest.typescript/pull/2621).
|
|
14
32
|
- [Bugfix] Fix the isUnexpected narrowing issue in Modular. Please refer to [#2654](https://github.com/Azure/autorest.typescript/pull/2654).
|
|
15
33
|
- [Bugfix] Fix the extensible enum with null union generation failure in RLC. Please refer to [#2682](https://github.com/Azure/autorest.typescript/pull/2682).
|
|
16
34
|
- [Bugfix] Remove hard code for lro in patch operation. Please refer to [#2583](https://github.com/Azure/autorest.typescript/pull/2583).
|
package/README.md
CHANGED
|
@@ -145,6 +145,14 @@ addCredentials: true
|
|
|
145
145
|
credentialKeyHeaderName: Your-Subscription-Key
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
+
### clearOutputFolder
|
|
149
|
+
|
|
150
|
+
If we enable this option `clearOutputFolder` we would empty the whole output folder. By default we only empty the sources folder which means any metadata files will not be removed if it is at project root. This would be useful in pipeline.
|
|
151
|
+
|
|
152
|
+
```yaml
|
|
153
|
+
clearOutputFolder: true
|
|
154
|
+
```
|
|
155
|
+
|
|
148
156
|
# Contributing
|
|
149
157
|
|
|
150
158
|
If you want to contribute on this project read the [contrubuting document](./CONTRIBUTING.md) for more details.
|
|
@@ -4,6 +4,7 @@ import { EmitContext } from "@typespec/compiler";
|
|
|
4
4
|
import { SdkContext } from "@azure-tools/typespec-client-generator-core";
|
|
5
5
|
import { SdkTypeContext } from "./framework/hooks/sdkTypes.js";
|
|
6
6
|
import { Binder } from "./framework/hooks/binder.js";
|
|
7
|
+
import { ExternalDependencies } from "./framework/dependency.js";
|
|
7
8
|
/**
|
|
8
9
|
* Contexts Object Guidelines
|
|
9
10
|
* --------------------------
|
|
@@ -28,6 +29,7 @@ type Contexts = {
|
|
|
28
29
|
tcgcContext: SdkContext;
|
|
29
30
|
};
|
|
30
31
|
binder: Binder;
|
|
32
|
+
dependencies: ExternalDependencies;
|
|
31
33
|
};
|
|
32
34
|
type ContextKey = keyof Contexts;
|
|
33
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextManager.d.ts","sourceRoot":"","sources":["../../src/contextManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"contextManager.d.ts","sourceRoot":"","sources":["../../src/contextManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,oBAAoB,EA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extManager.js","sourceRoot":"","sources":["../../src/contextManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contextManager.js","sourceRoot":"","sources":["../../src/contextManager.ts"],"names":[],"mappings":"AAqCA;;;GAGG;AACH,MAAM,cAAc;IAIlB;QAFQ,aAAQ,GAAyB,IAAI,GAAG,EAAE,CAAC;IAE5B,CAAC;IAExB;;;OAGG;IACI,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;YAC7B,cAAc,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;QACjD,CAAC;QACD,OAAO,cAAc,CAAC,QAAQ,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACI,UAAU,CAAuB,GAAM,EAAE,KAAkB;QAChE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,UAAU,CAAuB,GAAM;QAC5C,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAA4B,CAAC;IAC3D,CAAC;CACF;AAED,wDAAwD;AACxD,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAuB,GAAM;IACrD,MAAM,OAAO,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,WAAW,GAAG,YAAY,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAM,EACN,KAAkB;IAElB,cAAc,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export interface ReferenceableSymbol {
|
|
2
|
+
kind: string;
|
|
3
|
+
name: string;
|
|
4
|
+
module: string;
|
|
5
|
+
visibility?: "internal" | "public";
|
|
6
|
+
}
|
|
7
|
+
export type ExternalDependencies = CoreDependencies & Record<string, ReferenceableSymbol>;
|
|
8
|
+
/**
|
|
9
|
+
* This interface defines the well known Core dependencies that plugins can use to override and provide their own implementations if needed
|
|
10
|
+
*/
|
|
11
|
+
export interface CoreDependencies extends Record<string, ReferenceableSymbol> {
|
|
12
|
+
Client: {
|
|
13
|
+
kind: "externalDependency";
|
|
14
|
+
name: "Client";
|
|
15
|
+
module: string;
|
|
16
|
+
};
|
|
17
|
+
ClientOptions: {
|
|
18
|
+
kind: "externalDependency";
|
|
19
|
+
name: "ClientOptions";
|
|
20
|
+
module: string;
|
|
21
|
+
};
|
|
22
|
+
Pipeline: {
|
|
23
|
+
kind: "externalDependency";
|
|
24
|
+
name: "Pipeline";
|
|
25
|
+
module: string;
|
|
26
|
+
};
|
|
27
|
+
getClient: {
|
|
28
|
+
kind: "externalDependency";
|
|
29
|
+
name: "getClient";
|
|
30
|
+
module: string;
|
|
31
|
+
};
|
|
32
|
+
RestError: {
|
|
33
|
+
kind: "externalDependency";
|
|
34
|
+
name: "RestError";
|
|
35
|
+
module: string;
|
|
36
|
+
};
|
|
37
|
+
OperationOptions: {
|
|
38
|
+
kind: "externalDependency";
|
|
39
|
+
name: "OperationOptions";
|
|
40
|
+
module: string;
|
|
41
|
+
};
|
|
42
|
+
PathUncheckedResponse: {
|
|
43
|
+
kind: "externalDependency";
|
|
44
|
+
name: "PathUncheckedResponse";
|
|
45
|
+
module: string;
|
|
46
|
+
};
|
|
47
|
+
AbortSignalLike: {
|
|
48
|
+
kind: "externalDependency";
|
|
49
|
+
name: "AbortSignalLike";
|
|
50
|
+
module: string;
|
|
51
|
+
};
|
|
52
|
+
createRestError: {
|
|
53
|
+
kind: "externalDependency";
|
|
54
|
+
name: "createRestError";
|
|
55
|
+
module: string;
|
|
56
|
+
};
|
|
57
|
+
operationOptionsToRequestParameters: {
|
|
58
|
+
kind: "externalDependency";
|
|
59
|
+
name: "operationOptionsToRequestParameters";
|
|
60
|
+
module: string;
|
|
61
|
+
};
|
|
62
|
+
uint8ArrayToString: {
|
|
63
|
+
kind: "externalDependency";
|
|
64
|
+
name: "uint8ArrayToString";
|
|
65
|
+
module: string;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export type CoreDependency = keyof CoreDependencies;
|
|
69
|
+
//# sourceMappingURL=dependency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependency.d.ts","sourceRoot":"","sources":["../../../src/framework/dependency.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAC;CACpC;AAED,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GACjD,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC;IAC3E,MAAM,EAAE;QAAE,IAAI,EAAE,oBAAoB,CAAC;QAAC,IAAI,EAAE,QAAQ,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACvE,aAAa,EAAE;QACb,IAAI,EAAE,oBAAoB,CAAC;QAC3B,IAAI,EAAE,eAAe,CAAC;QACtB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,QAAQ,EAAE;QAAE,IAAI,EAAE,oBAAoB,CAAC;QAAC,IAAI,EAAE,UAAU,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3E,SAAS,EAAE;QAAE,IAAI,EAAE,oBAAoB,CAAC;QAAC,IAAI,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7E,SAAS,EAAE;QAAE,IAAI,EAAE,oBAAoB,CAAC;QAAC,IAAI,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7E,gBAAgB,EAAE;QAChB,IAAI,EAAE,oBAAoB,CAAC;QAC3B,IAAI,EAAE,kBAAkB,CAAC;QACzB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,qBAAqB,EAAE;QACrB,IAAI,EAAE,oBAAoB,CAAC;QAC3B,IAAI,EAAE,uBAAuB,CAAC;QAC9B,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,eAAe,EAAE;QACf,IAAI,EAAE,oBAAoB,CAAC;QAC3B,IAAI,EAAE,iBAAiB,CAAC;QACxB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,eAAe,EAAE;QACf,IAAI,EAAE,oBAAoB,CAAC;QAC3B,IAAI,EAAE,iBAAiB,CAAC;QACxB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,mCAAmC,EAAE;QACnC,IAAI,EAAE,oBAAoB,CAAC;QAC3B,IAAI,EAAE,qCAAqC,CAAC;QAC5C,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,kBAAkB,EAAE;QAClB,IAAI,EAAE,oBAAoB,CAAC;QAC3B,IAAI,EAAE,oBAAoB,CAAC;QAC3B,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependency.js","sourceRoot":"","sources":["../../../src/framework/dependency.ts"],"names":[],"mappings":""}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { SourceFile, Project } from "ts-morph";
|
|
2
|
+
import { ReferenceableSymbol } from "../dependency.js";
|
|
3
|
+
import { StaticHelperMetadata } from "../load-static-helpers.js";
|
|
2
4
|
export interface DeclarationInfo {
|
|
3
5
|
name: string;
|
|
4
6
|
sourceFile: SourceFile;
|
|
5
7
|
alias?: string;
|
|
6
8
|
}
|
|
9
|
+
export interface BinderOptions {
|
|
10
|
+
staticHelpers?: Map<string, StaticHelperMetadata>;
|
|
11
|
+
dependencies?: Record<string, ReferenceableSymbol>;
|
|
12
|
+
}
|
|
7
13
|
export interface Binder {
|
|
8
14
|
/**
|
|
9
15
|
* Tracks a new declaration.
|
|
@@ -14,9 +20,9 @@ export interface Binder {
|
|
|
14
20
|
*/
|
|
15
21
|
trackDeclaration(refkey: unknown, name: string, sourceFile: SourceFile): string;
|
|
16
22
|
resolveReference(refkey: unknown): string;
|
|
17
|
-
|
|
23
|
+
resolveAllReferences(): void;
|
|
18
24
|
}
|
|
19
|
-
export declare function provideBinder(project?:
|
|
25
|
+
export declare function provideBinder(project: Project, options?: BinderOptions): Binder;
|
|
20
26
|
/**
|
|
21
27
|
* Hook to use the binder context.
|
|
22
28
|
* @returns The binder instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binder.d.ts","sourceRoot":"","sources":["../../../../src/framework/hooks/binder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIV,OAAO,EACR,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"binder.d.ts","sourceRoot":"","sources":["../../../../src/framework/hooks/binder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIV,OAAO,EACR,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EAGL,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,MAAM;IACrB;;;;;;OAMG;IACH,gBAAgB,CACd,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,UAAU,GACrB,MAAM,CAAC;IACV,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1C,oBAAoB,IAAI,IAAI,CAAC;CAC9B;AAwRD,wBAAgB,aAAa,CAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,aAAkB,GAC1B,MAAM,CAIR;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAElC"}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import { StructureKind
|
|
1
|
+
import { StructureKind } from "ts-morph";
|
|
2
2
|
import { provideContext, useContext } from "../../contextManager.js";
|
|
3
|
+
import { provideDependencies, useDependencies } from "./useDependencies.js";
|
|
4
|
+
import { refkey } from "../refkey.js";
|
|
5
|
+
import { isStaticHelperMetadata, SourceFileSymbol } from "../load-static-helpers.js";
|
|
6
|
+
const PLACEHOLDER_PREFIX = "_PLACEHOLDER_";
|
|
3
7
|
class BinderImp {
|
|
4
|
-
constructor(project) {
|
|
8
|
+
constructor(project, options = {}) {
|
|
9
|
+
var _a;
|
|
5
10
|
this.declarations = new Map();
|
|
11
|
+
this.references = new Map();
|
|
6
12
|
this.imports = new Map();
|
|
7
13
|
this.symbolsBySourceFile = new Map();
|
|
8
|
-
this.project = project
|
|
14
|
+
this.project = project;
|
|
15
|
+
provideDependencies(options.dependencies);
|
|
16
|
+
this.staticHelpers = (_a = options.staticHelpers) !== null && _a !== void 0 ? _a : new Map();
|
|
17
|
+
this.dependencies = useDependencies();
|
|
9
18
|
}
|
|
10
19
|
trackDeclaration(refkey, name, sourceFile) {
|
|
11
20
|
const uniqueName = this.generateLocallyUniqueDeclarationName(name, sourceFile);
|
|
@@ -75,7 +84,7 @@ class BinderImp {
|
|
|
75
84
|
* @returns The serialized placeholder string.
|
|
76
85
|
*/
|
|
77
86
|
serializePlaceholder(refkey) {
|
|
78
|
-
return
|
|
87
|
+
return `${PLACEHOLDER_PREFIX}${String(refkey)}_`;
|
|
79
88
|
}
|
|
80
89
|
/**
|
|
81
90
|
* Adds an import declaration to a source file.
|
|
@@ -86,13 +95,20 @@ class BinderImp {
|
|
|
86
95
|
*/
|
|
87
96
|
addImport(fileWhereImportIsAdded, fileWhereImportPointsTo, name) {
|
|
88
97
|
const importAlias = this.generateLocallyUniqueImportName(name, fileWhereImportIsAdded);
|
|
89
|
-
|
|
98
|
+
let moduleSpecifier = "";
|
|
99
|
+
if (typeof fileWhereImportPointsTo === "string") {
|
|
100
|
+
moduleSpecifier = fileWhereImportPointsTo;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
moduleSpecifier =
|
|
104
|
+
fileWhereImportIsAdded.getRelativePathAsModuleSpecifierTo(fileWhereImportPointsTo) + ".js";
|
|
105
|
+
}
|
|
90
106
|
const importStructures = this.imports.get(fileWhereImportIsAdded) || [];
|
|
91
|
-
let importStructure = importStructures.find((imp) => imp.moduleSpecifier ===
|
|
107
|
+
let importStructure = importStructures.find((imp) => imp.moduleSpecifier === moduleSpecifier);
|
|
92
108
|
if (!importStructure) {
|
|
93
109
|
importStructure = {
|
|
94
110
|
kind: StructureKind.ImportDeclaration,
|
|
95
|
-
moduleSpecifier
|
|
111
|
+
moduleSpecifier,
|
|
96
112
|
namedImports: []
|
|
97
113
|
};
|
|
98
114
|
importStructures.push(importStructure);
|
|
@@ -114,29 +130,94 @@ class BinderImp {
|
|
|
114
130
|
/**
|
|
115
131
|
* Applies all tracked imports to their respective source files.
|
|
116
132
|
*/
|
|
117
|
-
|
|
118
|
-
var _a;
|
|
133
|
+
resolveAllReferences() {
|
|
119
134
|
for (const file of this.project.getSourceFiles()) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
let name = declaration.name;
|
|
123
|
-
if (file !== declaration.sourceFile) {
|
|
124
|
-
const importDec = this.addImport(file, declaration.sourceFile, declaration.name);
|
|
125
|
-
name = (_a = importDec.alias) !== null && _a !== void 0 ? _a : declaration.name;
|
|
126
|
-
}
|
|
127
|
-
replacePlaceholder(file, placeholderKey, name);
|
|
128
|
-
}
|
|
135
|
+
this.resolveDeclarationReferences(file);
|
|
136
|
+
this.resolveDependencyReferences(file);
|
|
129
137
|
}
|
|
130
138
|
for (const [sourceFile, importStructures] of this.imports) {
|
|
131
139
|
for (const importStructure of importStructures) {
|
|
132
140
|
sourceFile.addImportDeclaration(importStructure);
|
|
133
141
|
}
|
|
134
142
|
}
|
|
143
|
+
this.cleanUnreferencedHelpers();
|
|
144
|
+
}
|
|
145
|
+
resolveDependencyReferences(file) {
|
|
146
|
+
var _a;
|
|
147
|
+
if (!hasAnyPlaceholders(file)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
for (const dependency of Object.values(this.dependencies)) {
|
|
151
|
+
const placeholder = this.serializePlaceholder(refkey(dependency));
|
|
152
|
+
const { name, module } = dependency;
|
|
153
|
+
const occurences = countPlaceholderOccurrences(file, placeholder);
|
|
154
|
+
if (occurences > 0) {
|
|
155
|
+
const importDec = this.addImport(file, module, name);
|
|
156
|
+
const uniqueName = (_a = importDec.alias) !== null && _a !== void 0 ? _a : name;
|
|
157
|
+
replacePlaceholder(file, placeholder, uniqueName);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
resolveDeclarationReferences(file) {
|
|
162
|
+
var _a;
|
|
163
|
+
if (!hasAnyPlaceholders(file)) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
for (const [declarationKey, declaration] of [
|
|
167
|
+
...this.declarations,
|
|
168
|
+
...this.staticHelpers
|
|
169
|
+
]) {
|
|
170
|
+
const placeholderKey = this.serializePlaceholder(declarationKey);
|
|
171
|
+
if (isStaticHelperMetadata(declaration) &&
|
|
172
|
+
!countPlaceholderOccurrences(file, placeholderKey)) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
let name = declaration.name;
|
|
176
|
+
let declarationSourceFile;
|
|
177
|
+
if ("sourceFile" in declaration) {
|
|
178
|
+
declarationSourceFile = declaration.sourceFile;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
declarationSourceFile = declaration[SourceFileSymbol];
|
|
182
|
+
}
|
|
183
|
+
if (file !== declarationSourceFile) {
|
|
184
|
+
this.trackReference(declarationKey, file);
|
|
185
|
+
const importDec = this.addImport(file, declarationSourceFile, name);
|
|
186
|
+
name = (_a = importDec.alias) !== null && _a !== void 0 ? _a : name;
|
|
187
|
+
}
|
|
188
|
+
replacePlaceholder(file, placeholderKey, name);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
trackReference(refkey, sourceFile) {
|
|
192
|
+
if (!this.references.has(refkey)) {
|
|
193
|
+
this.references.set(refkey, new Set());
|
|
194
|
+
}
|
|
195
|
+
this.references.get(refkey).add(sourceFile);
|
|
196
|
+
}
|
|
197
|
+
cleanUnreferencedHelpers() {
|
|
198
|
+
const usedHelperFiles = new Set();
|
|
199
|
+
for (const helper of this.staticHelpers.values()) {
|
|
200
|
+
const sourceFile = helper[SourceFileSymbol];
|
|
201
|
+
if (!sourceFile) {
|
|
202
|
+
// This should be unreachable
|
|
203
|
+
throw new Error(`Static helper ${helper.name} does not have a source file. Make sure that loadStaticHelpers has been correctly initialized in index.ts`);
|
|
204
|
+
}
|
|
205
|
+
const referencedHelper = this.references.get(refkey(helper));
|
|
206
|
+
if (referencedHelper === null || referencedHelper === void 0 ? void 0 : referencedHelper.size) {
|
|
207
|
+
usedHelperFiles.add(sourceFile);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
this.project
|
|
211
|
+
.getSourceFiles("**/static-helpers/**/*.ts")
|
|
212
|
+
.filter((helperFile) => !usedHelperFiles.has(helperFile))
|
|
213
|
+
.forEach((helperFile) => helperFile.delete());
|
|
135
214
|
}
|
|
136
215
|
}
|
|
137
216
|
// Provide the binder context to be used globally
|
|
138
|
-
export function provideBinder(project) {
|
|
139
|
-
|
|
217
|
+
export function provideBinder(project, options = {}) {
|
|
218
|
+
const binder = new BinderImp(project, options);
|
|
219
|
+
provideContext("binder", binder);
|
|
220
|
+
return binder;
|
|
140
221
|
}
|
|
141
222
|
/**
|
|
142
223
|
* Hook to use the binder context.
|
|
@@ -157,6 +238,9 @@ function replacePlaceholder(sourceFile, placeholder, value) {
|
|
|
157
238
|
const updatedText = fileText.replace(regex, value);
|
|
158
239
|
sourceFile.replaceWithText(updatedText);
|
|
159
240
|
}
|
|
241
|
+
function countPlaceholderOccurrences(sourceFile, placeholder) {
|
|
242
|
+
return sourceFile.getFullText().split(placeholder).length - 1;
|
|
243
|
+
}
|
|
160
244
|
/**
|
|
161
245
|
* Escapes special characters in a string to be used in a regular expression.
|
|
162
246
|
* @param string - The input string.
|
|
@@ -165,4 +249,7 @@ function replacePlaceholder(sourceFile, placeholder, value) {
|
|
|
165
249
|
function escapeRegExp(string) {
|
|
166
250
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
167
251
|
}
|
|
252
|
+
function hasAnyPlaceholders(sourceFile) {
|
|
253
|
+
return sourceFile.getFullText().includes(PLACEHOLDER_PREFIX);
|
|
254
|
+
}
|
|
168
255
|
//# sourceMappingURL=binder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binder.js","sourceRoot":"","sources":["../../../../src/framework/hooks/binder.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,
|
|
1
|
+
{"version":3,"file":"binder.js","sourceRoot":"","sources":["../../../../src/framework/hooks/binder.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EAGd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,yBA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CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ExternalDependencies } from "../dependency.js";
|
|
2
|
+
export declare function provideDependencies(customDependencies?: Partial<ExternalDependencies>): void;
|
|
3
|
+
export declare function useDependencies(): ExternalDependencies;
|
|
4
|
+
//# sourceMappingURL=useDependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDependencies.d.ts","sourceRoot":"","sources":["../../../../src/framework/hooks/useDependencies.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,wBAAgB,mBAAmB,CACjC,kBAAkB,GAAE,OAAO,CAAC,oBAAoB,CAAM,QAQvD;AAED,wBAAgB,eAAe,IAAI,oBAAoB,CAEtD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { provideContext, useContext } from "../../contextManager.js";
|
|
2
|
+
import { DefaultCoreDependencies } from "../../modular/external-dependencies.js";
|
|
3
|
+
export function provideDependencies(customDependencies = {}) {
|
|
4
|
+
const dependencies = {
|
|
5
|
+
...DefaultCoreDependencies,
|
|
6
|
+
...customDependencies
|
|
7
|
+
};
|
|
8
|
+
provideContext("dependencies", dependencies);
|
|
9
|
+
}
|
|
10
|
+
export function useDependencies() {
|
|
11
|
+
return useContext("dependencies");
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=useDependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDependencies.js","sourceRoot":"","sources":["../../../../src/framework/hooks/useDependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAGjF,MAAM,UAAU,mBAAmB,CACjC,qBAAoD,EAAE;IAEtD,MAAM,YAAY,GAAG;QACnB,GAAG,uBAAuB;QAC1B,GAAG,kBAAkB;KACE,CAAC;IAE1B,cAAc,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,UAAU,CAAC,cAAc,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Project, SourceFile } from "ts-morph";
|
|
2
|
+
export declare const SourceFileSymbol: unique symbol;
|
|
3
|
+
export interface StaticHelperMetadata {
|
|
4
|
+
name: string;
|
|
5
|
+
kind: "function" | "interface" | "typeAlias" | "class";
|
|
6
|
+
location: string;
|
|
7
|
+
[SourceFileSymbol]?: SourceFile;
|
|
8
|
+
}
|
|
9
|
+
export declare function isStaticHelperMetadata(metadata: any): metadata is StaticHelperMetadata;
|
|
10
|
+
export type StaticHelpers = Record<string, StaticHelperMetadata>;
|
|
11
|
+
export interface LoadStaticHelpersOptions {
|
|
12
|
+
helpersAssetDirectory?: string;
|
|
13
|
+
sourcesDir?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function loadStaticHelpers(project: Project, helpers: StaticHelpers, options?: LoadStaticHelpersOptions): Promise<Map<string, StaticHelperMetadata>>;
|
|
16
|
+
//# sourceMappingURL=load-static-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-static-helpers.d.ts","sourceRoot":"","sources":["../../../src/framework/load-static-helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,OAAO,EACP,UAAU,EAEX,MAAM,UAAU,CAAC;AAGlB,eAAO,MAAM,gBAAgB,eAAuB,CAAC;AACrD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,CAAC;IACvD,QAAQ,EAAE,MAAM,CAAC;IACjB,CAAC,gBAAgB,CAAC,CAAC,EAAE,UAAU,CAAC;CACjC;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,GAAG,GACZ,QAAQ,IAAI,oBAAoB,CAQlC;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;AAIjE,MAAM,WAAW,wBAAwB;IACvC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,aAAa,EACtB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAsC5C"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { readdir, stat, readFile } from "fs/promises";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import { refkey } from "./refkey.js";
|
|
4
|
+
import { resolveProjectRoot } from "../utils/resolve-project-root.js";
|
|
5
|
+
export const SourceFileSymbol = Symbol("SourceFile");
|
|
6
|
+
export function isStaticHelperMetadata(metadata) {
|
|
7
|
+
return Boolean(metadata &&
|
|
8
|
+
metadata.name &&
|
|
9
|
+
metadata.kind &&
|
|
10
|
+
metadata.location &&
|
|
11
|
+
metadata[SourceFileSymbol]);
|
|
12
|
+
}
|
|
13
|
+
const DEFAULT_STATIC_HELPERS_PATH = "static/static-helpers";
|
|
14
|
+
export async function loadStaticHelpers(project, helpers, options = {}) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const sourcesDir = (_a = options.sourcesDir) !== null && _a !== void 0 ? _a : "";
|
|
17
|
+
const helpersMap = new Map();
|
|
18
|
+
const defaultStaticHelpersPath = path.join(resolveProjectRoot(), DEFAULT_STATIC_HELPERS_PATH);
|
|
19
|
+
const files = await traverseDirectory((_b = options.helpersAssetDirectory) !== null && _b !== void 0 ? _b : defaultStaticHelpersPath);
|
|
20
|
+
for (const file of files) {
|
|
21
|
+
const targetPath = path.join(sourcesDir, file.target);
|
|
22
|
+
const contents = await readFile(file.source, "utf-8");
|
|
23
|
+
const addedFile = project.createSourceFile(targetPath, contents, {
|
|
24
|
+
overwrite: true
|
|
25
|
+
});
|
|
26
|
+
for (const entry of Object.values(helpers)) {
|
|
27
|
+
if (!addedFile.getFilePath().endsWith(entry.location)) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const declaration = getDeclarationByMetadata(addedFile, entry);
|
|
31
|
+
if (!declaration) {
|
|
32
|
+
throw new Error(`Declaration ${entry.name} not found in file ${addedFile.getFilePath()}\n This is an Emitter bug, make sure that the map of static helpers passed to loadStaticHelpers matches what is in the file.`);
|
|
33
|
+
}
|
|
34
|
+
entry[SourceFileSymbol] = addedFile;
|
|
35
|
+
helpersMap.set(refkey(entry), entry);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return assertAllHelpersLoadedPresent(helpersMap);
|
|
39
|
+
}
|
|
40
|
+
function assertAllHelpersLoadedPresent(helpers) {
|
|
41
|
+
const missingHelpers = [];
|
|
42
|
+
for (const helper of helpers.values()) {
|
|
43
|
+
if (!helper[SourceFileSymbol]) {
|
|
44
|
+
missingHelpers.push(helper);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (missingHelpers.length > 0) {
|
|
48
|
+
const missingHelpersString = missingHelpers
|
|
49
|
+
.map((helper) => `${helper.name} - ${helper.location}`)
|
|
50
|
+
.join("\n");
|
|
51
|
+
throw new Error(`The following helpers were not found in the project, make sure they are defined in the expected static helper file: ${missingHelpersString}`);
|
|
52
|
+
}
|
|
53
|
+
return helpers;
|
|
54
|
+
}
|
|
55
|
+
function getDeclarationByMetadata(file, declaration) {
|
|
56
|
+
switch (declaration.kind) {
|
|
57
|
+
case "class":
|
|
58
|
+
return file.getClass(declaration.name);
|
|
59
|
+
case "function":
|
|
60
|
+
return file.getFunction(declaration.name);
|
|
61
|
+
case "interface":
|
|
62
|
+
return file.getInterface(declaration.name);
|
|
63
|
+
case "typeAlias":
|
|
64
|
+
return file.getTypeAlias(declaration.name);
|
|
65
|
+
default:
|
|
66
|
+
throw new Error(`invalid helper kind ${declaration.kind}\nAll helpers provided to loadStaticHelpers are of kind: function, interface, typeAlias, class`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const _targetStaticHelpersBaseDir = "static-helpers";
|
|
70
|
+
async function traverseDirectory(directory, result = [], relativePath = "") {
|
|
71
|
+
try {
|
|
72
|
+
const files = await readdir(directory);
|
|
73
|
+
await Promise.all(files.map(async (file) => {
|
|
74
|
+
const filePath = path.join(directory, file);
|
|
75
|
+
const fileStat = await stat(filePath);
|
|
76
|
+
if (fileStat.isDirectory()) {
|
|
77
|
+
await traverseDirectory(filePath, result, path.join(relativePath, file));
|
|
78
|
+
}
|
|
79
|
+
else if (fileStat.isFile() &&
|
|
80
|
+
!file.endsWith(".d.ts") &&
|
|
81
|
+
file.endsWith(".ts")) {
|
|
82
|
+
const target = path.join(_targetStaticHelpersBaseDir, relativePath, file);
|
|
83
|
+
result.push({ source: filePath, target });
|
|
84
|
+
}
|
|
85
|
+
}));
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
console.error(`Error traversing directory ${directory}:`, error);
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=load-static-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-static-helpers.js","sourceRoot":"","sources":["../../../src/framework/load-static-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAS7B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAQrD,MAAM,UAAU,sBAAsB,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AC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,8BAA8B,SAAS,GAAG,EAAE,KAAK,CAAC,CAAC;QACjE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function resolveReference(refkey: unknown): string
|
|
1
|
+
export declare function resolveReference(refkey: unknown): string;
|
|
2
2
|
//# sourceMappingURL=reference.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/framework/reference.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/framework/reference.ts"],"names":[],"mappings":"AAQA,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAgBxD"}
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { useBinder } from "./hooks/binder.js";
|
|
2
|
-
import { refkey as
|
|
2
|
+
import { refkey as getRefkey } from "./refkey.js";
|
|
3
|
+
import { SourceFileSymbol } from "./load-static-helpers.js";
|
|
3
4
|
export function resolveReference(refkey) {
|
|
4
5
|
const binder = useBinder();
|
|
5
|
-
|
|
6
|
+
let key = refkey;
|
|
7
|
+
if (isReferenceableSymbol(key)) {
|
|
8
|
+
key = getRefkey(key);
|
|
9
|
+
}
|
|
10
|
+
if (isStaticHelperMetadata(key)) {
|
|
11
|
+
key = getRefkey(key);
|
|
12
|
+
}
|
|
13
|
+
const stringRefkey = typeof key === "string" ? key : getRefkey(key);
|
|
6
14
|
return binder.resolveReference(stringRefkey);
|
|
7
15
|
}
|
|
16
|
+
function isReferenceableSymbol(obj) {
|
|
17
|
+
return (obj === null || obj === void 0 ? void 0 : obj.kind) === "externalDependency";
|
|
18
|
+
}
|
|
19
|
+
function isStaticHelperMetadata(obj) {
|
|
20
|
+
return Boolean(obj[SourceFileSymbol]);
|
|
21
|
+
}
|
|
8
22
|
//# sourceMappingURL=reference.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reference.js","sourceRoot":"","sources":["../../../src/framework/reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,UAAU,gBAAgB,CAAC,MAAe;IAC9C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"reference.js","sourceRoot":"","sources":["../../../src/framework/reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EACL,gBAAgB,EAEjB,MAAM,0BAA0B,CAAC;AAElC,MAAM,UAAU,gBAAgB,CAAC,MAAe;IAC9C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAE3B,IAAI,GAAG,GAAG,MAAM,CAAC;IAEjB,IAAI,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,IAAI,sBAAsB,CAAC,GAAG,CAAC,EAAE,CAAC;QAChC,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,YAAY,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAEpE,OAAO,MAAM,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,qBAAqB,CAAC,GAAQ;IACrC,OAAO,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,MAAK,oBAAoB,CAAC;AAC5C,CAAC;AAED,SAAS,sBAAsB,CAAC,GAAQ;IACtC,OAAO,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC;AACxC,CAAC"}
|