@microsoft/teamsfx-core 3.0.13 → 3.0.14-alpha.1673f8d0ac.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/build/client/teamsGraphClient.d.ts +3 -0
- package/build/client/teamsGraphClient.d.ts.map +1 -1
- package/build/client/teamsGraphClient.js +17 -0
- package/build/client/teamsGraphClient.js.map +1 -1
- package/build/common/featureFlags.d.ts +12 -2
- package/build/common/featureFlags.d.ts.map +1 -1
- package/build/common/featureFlags.js +15 -3
- package/build/common/featureFlags.js.map +1 -1
- package/build/common/projectSettingsHelper.d.ts +0 -2
- package/build/common/projectSettingsHelper.d.ts.map +1 -1
- package/build/common/projectSettingsHelper.js +1 -56
- package/build/common/projectSettingsHelper.js.map +1 -1
- package/build/common/telemetry.d.ts +4 -15
- package/build/common/telemetry.d.ts.map +1 -1
- package/build/common/telemetry.js +5 -18
- package/build/common/telemetry.js.map +1 -1
- package/build/common/templates-config.json +9 -2
- package/build/component/configManager/validator.d.ts.map +1 -1
- package/build/component/configManager/validator.js +2 -0
- package/build/component/configManager/validator.js.map +1 -1
- package/build/component/coordinator/index.d.ts.map +1 -1
- package/build/component/coordinator/index.js +5 -1
- package/build/component/coordinator/index.js.map +1 -1
- package/build/component/driver/copilotAgent/interfaces/PublishArgs.d.ts +14 -0
- package/build/component/driver/copilotAgent/interfaces/PublishArgs.d.ts.map +1 -0
- package/build/component/driver/copilotAgent/interfaces/PublishArgs.js +5 -0
- package/build/component/driver/copilotAgent/interfaces/PublishArgs.js.map +1 -0
- package/build/component/driver/copilotAgent/publish.d.ts +16 -0
- package/build/component/driver/copilotAgent/publish.d.ts.map +1 -0
- package/build/component/driver/copilotAgent/publish.js +175 -0
- package/build/component/driver/copilotAgent/publish.js.map +1 -0
- package/build/component/driver/dcr/create.d.ts +10 -0
- package/build/component/driver/dcr/create.d.ts.map +1 -0
- package/build/component/driver/dcr/create.js +142 -0
- package/build/component/driver/dcr/create.js.map +1 -0
- package/build/component/driver/dcr/error/dcrNameTooLong.d.ts +5 -0
- package/build/component/driver/dcr/error/dcrNameTooLong.d.ts.map +1 -0
- package/build/component/driver/dcr/error/dcrNameTooLong.js +21 -0
- package/build/component/driver/dcr/error/dcrNameTooLong.js.map +1 -0
- package/build/component/driver/dcr/error/dcrWellKnownInvalid.d.ts +5 -0
- package/build/component/driver/dcr/error/dcrWellKnownInvalid.d.ts.map +1 -0
- package/build/component/driver/dcr/error/dcrWellKnownInvalid.js +21 -0
- package/build/component/driver/dcr/error/dcrWellKnownInvalid.js.map +1 -0
- package/build/component/driver/dcr/interface/createDcrArgs.d.ts +9 -0
- package/build/component/driver/dcr/interface/createDcrArgs.d.ts.map +1 -0
- package/build/component/driver/dcr/interface/createDcrArgs.js +5 -0
- package/build/component/driver/dcr/interface/createDcrArgs.js.map +1 -0
- package/build/component/driver/dcr/interface/createDcrOutputs.d.ts +7 -0
- package/build/component/driver/dcr/interface/createDcrOutputs.d.ts.map +1 -0
- package/build/component/driver/dcr/interface/createDcrOutputs.js +10 -0
- package/build/component/driver/dcr/interface/createDcrOutputs.js.map +1 -0
- package/build/component/driver/dcr/utility/constants.d.ts +7 -0
- package/build/component/driver/dcr/utility/constants.d.ts.map +1 -0
- package/build/component/driver/dcr/utility/constants.js +12 -0
- package/build/component/driver/dcr/utility/constants.js.map +1 -0
- package/build/component/driver/index.d.ts +2 -0
- package/build/component/driver/index.d.ts.map +1 -1
- package/build/component/driver/index.js +2 -0
- package/build/component/driver/index.js.map +1 -1
- package/build/component/driver/share/utils.d.ts.map +1 -1
- package/build/component/driver/share/utils.js +9 -7
- package/build/component/driver/share/utils.js.map +1 -1
- package/build/component/driver/teamsApp/constants.d.ts +1 -0
- package/build/component/driver/teamsApp/constants.d.ts.map +1 -1
- package/build/component/driver/teamsApp/constants.js +1 -0
- package/build/component/driver/teamsApp/constants.js.map +1 -1
- package/build/component/driver/teamsApp/createAppPackage.d.ts +2 -0
- package/build/component/driver/teamsApp/createAppPackage.d.ts.map +1 -1
- package/build/component/driver/teamsApp/createAppPackage.js +74 -10
- package/build/component/driver/teamsApp/createAppPackage.js.map +1 -1
- package/build/component/driver/teamsApp/interfaces/DcrRegistration.d.ts +10 -0
- package/build/component/driver/teamsApp/interfaces/DcrRegistration.d.ts.map +1 -0
- package/build/component/driver/teamsApp/interfaces/DcrRegistration.js +5 -0
- package/build/component/driver/teamsApp/interfaces/DcrRegistration.js.map +1 -0
- package/build/component/driver/teamsApp/publishAppPackage.d.ts +0 -2
- package/build/component/driver/teamsApp/publishAppPackage.d.ts.map +1 -1
- package/build/component/driver/teamsApp/publishAppPackage.js +2 -51
- package/build/component/driver/teamsApp/publishAppPackage.js.map +1 -1
- package/build/component/driver/teamsApp/utils/ManifestUtils.d.ts +1 -1
- package/build/component/driver/teamsApp/utils/ManifestUtils.d.ts.map +1 -1
- package/build/component/driver/teamsApp/utils/ManifestUtils.js +10 -2
- package/build/component/driver/teamsApp/utils/ManifestUtils.js.map +1 -1
- package/build/component/driver/teamsApp/utils/McpCertVerification.d.ts +13 -0
- package/build/component/driver/teamsApp/utils/McpCertVerification.d.ts.map +1 -0
- package/build/component/driver/teamsApp/utils/McpCertVerification.js +65 -0
- package/build/component/driver/teamsApp/utils/McpCertVerification.js.map +1 -0
- package/build/component/driver/teamsApp/validate.js +1 -1
- package/build/component/driver/teamsApp/validate.js.map +1 -1
- package/build/component/generator/declarativeAgent/generator.d.ts.map +1 -1
- package/build/component/generator/declarativeAgent/generator.js +1 -2
- package/build/component/generator/declarativeAgent/generator.js.map +1 -1
- package/build/component/generator/defaultGenerator.d.ts.map +1 -1
- package/build/component/generator/defaultGenerator.js +14 -1
- package/build/component/generator/defaultGenerator.js.map +1 -1
- package/build/component/generator/error.d.ts +3 -0
- package/build/component/generator/error.d.ts.map +1 -1
- package/build/component/generator/error.js +7 -1
- package/build/component/generator/error.js.map +1 -1
- package/build/component/generator/officeAddin/generator.d.ts +8 -0
- package/build/component/generator/officeAddin/generator.d.ts.map +1 -1
- package/build/component/generator/officeAddin/generator.js +47 -0
- package/build/component/generator/officeAddin/generator.js.map +1 -1
- package/build/component/generator/openPlugin/authorParser.d.ts +8 -0
- package/build/component/generator/openPlugin/authorParser.d.ts.map +1 -0
- package/build/component/generator/openPlugin/authorParser.js +49 -0
- package/build/component/generator/openPlugin/authorParser.js.map +1 -0
- package/build/component/generator/openPlugin/deterministicId.d.ts +6 -0
- package/build/component/generator/openPlugin/deterministicId.d.ts.map +1 -0
- package/build/component/generator/openPlugin/deterministicId.js +31 -0
- package/build/component/generator/openPlugin/deterministicId.js.map +1 -0
- package/build/component/generator/openPlugin/exporter.d.ts +18 -0
- package/build/component/generator/openPlugin/exporter.d.ts.map +1 -0
- package/build/component/generator/openPlugin/exporter.js +233 -0
- package/build/component/generator/openPlugin/exporter.js.map +1 -0
- package/build/component/generator/openPlugin/iconStrategy.d.ts +8 -0
- package/build/component/generator/openPlugin/iconStrategy.d.ts.map +1 -0
- package/build/component/generator/openPlugin/iconStrategy.js +62 -0
- package/build/component/generator/openPlugin/iconStrategy.js.map +1 -0
- package/build/component/generator/openPlugin/importer.d.ts +25 -0
- package/build/component/generator/openPlugin/importer.d.ts.map +1 -0
- package/build/component/generator/openPlugin/importer.js +140 -0
- package/build/component/generator/openPlugin/importer.js.map +1 -0
- package/build/component/generator/openPlugin/mapper.d.ts +6 -0
- package/build/component/generator/openPlugin/mapper.d.ts.map +1 -0
- package/build/component/generator/openPlugin/mapper.js +141 -0
- package/build/component/generator/openPlugin/mapper.js.map +1 -0
- package/build/component/generator/openPlugin/parser.d.ts +3 -0
- package/build/component/generator/openPlugin/parser.d.ts.map +1 -0
- package/build/component/generator/openPlugin/parser.js +153 -0
- package/build/component/generator/openPlugin/parser.js.map +1 -0
- package/build/component/generator/openPlugin/placeholderPng.d.ts +6 -0
- package/build/component/generator/openPlugin/placeholderPng.d.ts.map +1 -0
- package/build/component/generator/openPlugin/placeholderPng.js +71 -0
- package/build/component/generator/openPlugin/placeholderPng.js.map +1 -0
- package/build/component/generator/openPlugin/textUtils.d.ts +12 -0
- package/build/component/generator/openPlugin/textUtils.d.ts.map +1 -0
- package/build/component/generator/openPlugin/textUtils.js +43 -0
- package/build/component/generator/openPlugin/textUtils.js.map +1 -0
- package/build/component/generator/openPlugin/types.d.ts +128 -0
- package/build/component/generator/openPlugin/types.d.ts.map +1 -0
- package/build/component/generator/openPlugin/types.js.map +1 -0
- package/build/component/generator/templateHelper.d.ts +15 -0
- package/build/component/generator/templateHelper.d.ts.map +1 -1
- package/build/component/generator/templateHelper.js +28 -0
- package/build/component/generator/templateHelper.js.map +1 -1
- package/build/component/generator/templates/metadata/index.d.ts.map +1 -1
- package/build/component/generator/templates/metadata/index.js +9 -2
- package/build/component/generator/templates/metadata/index.js.map +1 -1
- package/build/component/generator/templates/templateNames.d.ts +2 -1
- package/build/component/generator/templates/templateNames.d.ts.map +1 -1
- package/build/component/generator/templates/templateNames.js +2 -0
- package/build/component/generator/templates/templateNames.js.map +1 -1
- package/build/component/generator/templates/templateReplaceMap.d.ts.map +1 -1
- package/build/component/generator/templates/templateReplaceMap.js +4 -1
- package/build/component/generator/templates/templateReplaceMap.js.map +1 -1
- package/build/component/generator/v4MetadataSource.d.ts +23 -0
- package/build/component/generator/v4MetadataSource.d.ts.map +1 -0
- package/build/component/generator/v4MetadataSource.js +42 -0
- package/build/component/generator/v4MetadataSource.js.map +1 -0
- package/build/component/generator/v4TemplateBridge.d.ts +29 -0
- package/build/component/generator/v4TemplateBridge.d.ts.map +1 -0
- package/build/component/generator/v4TemplateBridge.js +114 -0
- package/build/component/generator/v4TemplateBridge.js.map +1 -0
- package/build/component/m365/packageService.d.ts +5 -0
- package/build/component/m365/packageService.d.ts.map +1 -1
- package/build/component/m365/packageService.js +23 -1
- package/build/component/m365/packageService.js.map +1 -1
- package/build/core/FxCore.d.ts +2 -4
- package/build/core/FxCore.d.ts.map +1 -1
- package/build/core/FxCore.js +53 -78
- package/build/core/FxCore.js.map +1 -1
- package/build/core/FxCore.openPlugin.d.ts +23 -0
- package/build/core/FxCore.openPlugin.d.ts.map +1 -0
- package/build/core/FxCore.openPlugin.js +131 -0
- package/build/core/FxCore.openPlugin.js.map +1 -0
- package/build/core/middleware/concurrentLocker.d.ts.map +1 -1
- package/build/core/middleware/concurrentLocker.js +0 -3
- package/build/core/middleware/concurrentLocker.js.map +1 -1
- package/build/core/middleware/errorHandler.d.ts.map +1 -1
- package/build/core/middleware/errorHandler.js +9 -0
- package/build/core/middleware/errorHandler.js.map +1 -1
- package/build/core/middleware/utils/v3MigrationUtils.d.ts +1 -34
- package/build/core/middleware/utils/v3MigrationUtils.d.ts.map +1 -1
- package/build/core/middleware/utils/v3MigrationUtils.js +6 -245
- package/build/core/middleware/utils/v3MigrationUtils.js.map +1 -1
- package/build/question/constants.d.ts.map +1 -1
- package/build/question/constants.js +1 -6
- package/build/question/constants.js.map +1 -1
- package/build/question/inputs/ExportOpenPluginInputs.d.ts +10 -0
- package/build/question/inputs/ExportOpenPluginInputs.d.ts.map +1 -0
- package/build/question/inputs/ExportOpenPluginInputs.js +5 -0
- package/build/question/inputs/ExportOpenPluginInputs.js.map +1 -0
- package/build/question/inputs/ImportOpenPluginInputs.d.ts +28 -0
- package/build/question/inputs/ImportOpenPluginInputs.d.ts.map +1 -0
- package/build/question/inputs/ImportOpenPluginInputs.js +5 -0
- package/build/question/inputs/ImportOpenPluginInputs.js.map +1 -0
- package/build/question/inputs/index.d.ts +2 -0
- package/build/question/inputs/index.d.ts.map +1 -1
- package/build/question/inputs/index.js +2 -0
- package/build/question/inputs/index.js.map +1 -1
- package/build/question/options/ExportOpenPluginOptions.d.ts +4 -0
- package/build/question/options/ExportOpenPluginOptions.d.ts.map +1 -0
- package/build/question/options/ExportOpenPluginOptions.js +29 -0
- package/build/question/options/ExportOpenPluginOptions.js.map +1 -0
- package/build/question/options/ImportOpenPluginOptions.d.ts +4 -0
- package/build/question/options/ImportOpenPluginOptions.d.ts.map +1 -0
- package/build/question/options/ImportOpenPluginOptions.js +54 -0
- package/build/question/options/ImportOpenPluginOptions.js.map +1 -0
- package/build/question/options/index.d.ts +2 -0
- package/build/question/options/index.d.ts.map +1 -1
- package/build/question/options/index.js +2 -0
- package/build/question/options/index.js.map +1 -1
- package/build/question/scaffold/vsc/daProjectTypeNode.d.ts.map +1 -1
- package/build/question/scaffold/vsc/daProjectTypeNode.js +1 -3
- package/build/question/scaffold/vsc/daProjectTypeNode.js.map +1 -1
- package/build/question/scaffold/vsc/rootNode.d.ts.map +1 -1
- package/build/question/scaffold/vsc/rootNode.js +1 -1
- package/build/question/scaffold/vsc/rootNode.js.map +1 -1
- package/build/v4/distribution/bundledFloor.d.ts +12 -0
- package/build/v4/distribution/bundledFloor.d.ts.map +1 -0
- package/build/v4/distribution/bundledFloor.js +80 -0
- package/build/v4/distribution/bundledFloor.js.map +1 -0
- package/build/v4/distribution/templateConfig.d.ts +53 -0
- package/build/v4/distribution/templateConfig.d.ts.map +1 -0
- package/build/v4/distribution/templateConfig.js +43 -0
- package/build/v4/distribution/templateConfig.js.map +1 -0
- package/build/v4/distribution/templatePackage.d.ts +29 -0
- package/build/v4/distribution/templatePackage.d.ts.map +1 -0
- package/build/v4/distribution/templatePackage.js +82 -0
- package/build/v4/distribution/templatePackage.js.map +1 -0
- package/build/v4/distribution/templateSource.d.ts +67 -0
- package/build/v4/distribution/templateSource.d.ts.map +1 -0
- package/build/v4/distribution/templateSource.js +220 -0
- package/build/v4/distribution/templateSource.js.map +1 -0
- package/build/v4/distribution/templateSourcePort.d.ts +50 -0
- package/build/v4/distribution/templateSourcePort.d.ts.map +1 -0
- package/build/v4/distribution/templateSourcePort.js +207 -0
- package/build/v4/distribution/templateSourcePort.js.map +1 -0
- package/build/v4/index.d.ts +13 -0
- package/build/v4/index.d.ts.map +1 -0
- package/build/v4/index.js +18 -0
- package/build/v4/index.js.map +1 -0
- package/package.json +4 -4
- package/resource/package.nls.cs.json +12 -14
- package/resource/package.nls.de.json +13 -15
- package/resource/package.nls.es.json +12 -14
- package/resource/package.nls.fr.json +12 -14
- package/resource/package.nls.it.json +13 -15
- package/resource/package.nls.ja.json +12 -14
- package/resource/package.nls.json +10 -13
- package/resource/package.nls.ko.json +12 -14
- package/resource/package.nls.pl.json +13 -15
- package/resource/package.nls.pt-BR.json +12 -14
- package/resource/package.nls.ru.json +13 -15
- package/resource/package.nls.tr.json +14 -16
- package/resource/package.nls.zh-Hans.json +12 -14
- package/resource/package.nls.zh-Hant.json +24 -26
- package/resource/yaml-schema/v1.12/yaml.schema.json +2132 -0
- package/resource/yaml-schema/v1.13/yaml.schema.json +2193 -0
- package/resource/yaml-schema/yaml.schema.json +124 -2
- package/templates/fallback/common.zip +0 -0
- package/templates/fallback/csharp.zip +0 -0
- package/templates/fallback/js.zip +0 -0
- package/templates/fallback/python.zip +0 -0
- package/templates/fallback/ts.zip +0 -0
- package/templates/metadata.zip +0 -0
- package/templates/ui/tdpNode.json +1 -2
- package/templates/ui/wizardNode.json +1 -2
- package/templates/v4/floor.json +3 -0
- package/templates/v4/templates.zip +0 -0
- package/build/core/middleware/projectMigratorV3.d.ts +0 -39
- package/build/core/middleware/projectMigratorV3.d.ts.map +0 -1
- package/build/core/middleware/projectMigratorV3.js +0 -694
- package/build/core/middleware/projectMigratorV3.js.map +0 -1
- package/build/core/middleware/projectVersionChecker.d.ts +0 -3
- package/build/core/middleware/projectVersionChecker.d.ts.map +0 -1
- package/build/core/middleware/projectVersionChecker.js +0 -60
- package/build/core/middleware/projectVersionChecker.js.map +0 -1
- package/build/core/middleware/types.d.ts +0 -9
- package/build/core/middleware/types.d.ts.map +0 -1
- package/build/core/middleware/types.js.map +0 -1
- package/build/core/middleware/utils/MigrationUtils.d.ts +0 -13
- package/build/core/middleware/utils/MigrationUtils.d.ts.map +0 -1
- package/build/core/middleware/utils/MigrationUtils.js +0 -212
- package/build/core/middleware/utils/MigrationUtils.js.map +0 -1
- package/build/core/middleware/utils/appYmlGenerator.d.ts +0 -34
- package/build/core/middleware/utils/appYmlGenerator.d.ts.map +0 -1
- package/build/core/middleware/utils/appYmlGenerator.js +0 -158
- package/build/core/middleware/utils/appYmlGenerator.js.map +0 -1
- package/build/core/middleware/utils/debug/appLocalYmlGenerator.d.ts +0 -65
- package/build/core/middleware/utils/debug/appLocalYmlGenerator.d.ts.map +0 -1
- package/build/core/middleware/utils/debug/appLocalYmlGenerator.js +0 -61
- package/build/core/middleware/utils/debug/appLocalYmlGenerator.js.map +0 -1
- package/build/core/middleware/utils/debug/constants.d.ts +0 -20
- package/build/core/middleware/utils/debug/constants.d.ts.map +0 -1
- package/build/core/middleware/utils/debug/constants.js +0 -28
- package/build/core/middleware/utils/debug/constants.js.map +0 -1
- package/build/core/middleware/utils/debug/debugMigrationContext.d.ts +0 -14
- package/build/core/middleware/utils/debug/debugMigrationContext.d.ts.map +0 -1
- package/build/core/middleware/utils/debug/debugMigrationContext.js +0 -23
- package/build/core/middleware/utils/debug/debugMigrationContext.js.map +0 -1
- package/build/core/middleware/utils/debug/debugV3MigrationUtils.d.ts +0 -37
- package/build/core/middleware/utils/debug/debugV3MigrationUtils.d.ts.map +0 -1
- package/build/core/middleware/utils/debug/debugV3MigrationUtils.js +0 -291
- package/build/core/middleware/utils/debug/debugV3MigrationUtils.js.map +0 -1
- package/build/core/middleware/utils/debug/taskMigrator.d.ts +0 -22
- package/build/core/middleware/utils/debug/taskMigrator.d.ts.map +0 -1
- package/build/core/middleware/utils/debug/taskMigrator.js +0 -935
- package/build/core/middleware/utils/debug/taskMigrator.js.map +0 -1
- package/build/core/middleware/utils/migrationContext.d.ts +0 -32
- package/build/core/middleware/utils/migrationContext.d.ts.map +0 -1
- package/build/core/middleware/utils/migrationContext.js +0 -104
- package/build/core/middleware/utils/migrationContext.js.map +0 -1
- /package/build/{core/middleware → component/generator/openPlugin}/types.js +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { FxError } from "@microsoft/teamsfx-api";
|
|
2
|
+
import { Result } from "neverthrow";
|
|
3
|
+
/** Where the resolved template-package bytes come from. */
|
|
4
|
+
export type TemplateOrigin = "bundled" | "online" | "cache" | "bundled-fallback";
|
|
5
|
+
/** A single channel-published version paired with its expected content digest (model A). */
|
|
6
|
+
export interface TagEntry {
|
|
7
|
+
version: string;
|
|
8
|
+
digest: string;
|
|
9
|
+
}
|
|
10
|
+
/** A cached template package: its content digest and the bytes themselves. */
|
|
11
|
+
export interface CachedPackage {
|
|
12
|
+
digest: string;
|
|
13
|
+
bytes: Buffer;
|
|
14
|
+
}
|
|
15
|
+
/** The bundled floor baked into the engine binary. */
|
|
16
|
+
export interface BundledFloor {
|
|
17
|
+
version: string;
|
|
18
|
+
digest: string;
|
|
19
|
+
location: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The narrow port `resolveTemplateSource` depends on (interface-segregation).
|
|
23
|
+
* The full `ScaffoldRuntime` composes this later; this operation never reaches
|
|
24
|
+
* for faces it does not use.
|
|
25
|
+
*/
|
|
26
|
+
export interface TemplateSourcePort {
|
|
27
|
+
/** Read an environment variable (e.g. `TEMPLATE_VERSION`). */
|
|
28
|
+
env(name: string): string | undefined;
|
|
29
|
+
/** The channel's published `{ version, digest }` entries. */
|
|
30
|
+
tagList(): Promise<TagEntry[]>;
|
|
31
|
+
/** Download a package's bytes for a version (verified against `expectedDigest` by the caller). */
|
|
32
|
+
packages(version: string, expectedDigest: string): Promise<Buffer>;
|
|
33
|
+
/** The local digest-keyed package cache. */
|
|
34
|
+
cache: {
|
|
35
|
+
get(version: string): CachedPackage | undefined;
|
|
36
|
+
put(version: string, digest: string, bytes: Buffer): void;
|
|
37
|
+
keys(): string[];
|
|
38
|
+
};
|
|
39
|
+
/** The bundled floor baked into the engine. */
|
|
40
|
+
floor: BundledFloor;
|
|
41
|
+
}
|
|
42
|
+
/** The single resolved source a scaffold run will use. */
|
|
43
|
+
export interface TemplateSource {
|
|
44
|
+
origin: TemplateOrigin;
|
|
45
|
+
version: string;
|
|
46
|
+
digest: string;
|
|
47
|
+
location: string;
|
|
48
|
+
/** Set when the resolved source diverged from the intended online source (observable, never silent). */
|
|
49
|
+
warning?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ResolveTemplateSourceInput {
|
|
52
|
+
/** SemVer range the build is permitted to resolve within. */
|
|
53
|
+
range: string;
|
|
54
|
+
/** `true` for test/offline/daily builds (bundled floor); `false` for shipped builds (release channel). */
|
|
55
|
+
bundled: boolean;
|
|
56
|
+
port: TemplateSourcePort;
|
|
57
|
+
}
|
|
58
|
+
/** sha256 content hash of a package's bytes, prefixed `sha256:`. */
|
|
59
|
+
export declare function computeDigest(bytes: Buffer): string;
|
|
60
|
+
/**
|
|
61
|
+
* Resolve `(range, bundled, port)` to exactly one `TemplateSource` before any
|
|
62
|
+
* template is read or rendered. Pure with respect to its inputs and the
|
|
63
|
+
* current tag-list state (INV-6). Returns `Result` rather than throwing,
|
|
64
|
+
* consistent with the toolkit-wide neverthrow rule.
|
|
65
|
+
*/
|
|
66
|
+
export declare function resolveTemplateSource(input: ResolveTemplateSourceInput): Promise<Result<TemplateSource, FxError>>;
|
|
67
|
+
//# sourceMappingURL=templateSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateSource.d.ts","sourceRoot":"","sources":["../../../src/v4/distribution/templateSource.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAA0B,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,MAAM,EAAW,MAAM,YAAY,CAAC;AAgB7C,2DAA2D;AAC3D,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,kBAAkB,CAAC;AAEjF,4FAA4F;AAC5F,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;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CACzC,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAc1C"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.computeDigest = computeDigest;
|
|
6
|
+
exports.resolveTemplateSource = resolveTemplateSource;
|
|
7
|
+
const tslib_1 = require("tslib");
|
|
8
|
+
const teamsfx_api_1 = require("@microsoft/teamsfx-api");
|
|
9
|
+
const neverthrow_1 = require("neverthrow");
|
|
10
|
+
const crypto = tslib_1.__importStar(require("crypto"));
|
|
11
|
+
const semver_1 = tslib_1.__importDefault(require("semver"));
|
|
12
|
+
/**
|
|
13
|
+
* The v4 template-distribution resolution operation.
|
|
14
|
+
*
|
|
15
|
+
* Spec: docs/03-specs/operations/scaffolding/resolve-template-source.md
|
|
16
|
+
* Decision: docs/02-architecture/adr/ADR-0006-template-distribution-channel.md
|
|
17
|
+
*
|
|
18
|
+
* This module is part of the v4 world. It imports no v3 symbol; v3 code may
|
|
19
|
+
* call `resolveTemplateSource`, but nothing here is tailored for v3.
|
|
20
|
+
*/
|
|
21
|
+
const SOURCE = "Scaffold";
|
|
22
|
+
/** sha256 content hash of a package's bytes, prefixed `sha256:`. */
|
|
23
|
+
function computeDigest(bytes) {
|
|
24
|
+
return "sha256:" + crypto.createHash("sha256").update(bytes).digest("hex");
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Resolve `(range, bundled, port)` to exactly one `TemplateSource` before any
|
|
28
|
+
* template is read or rendered. Pure with respect to its inputs and the
|
|
29
|
+
* current tag-list state (INV-6). Returns `Result` rather than throwing,
|
|
30
|
+
* consistent with the toolkit-wide neverthrow rule.
|
|
31
|
+
*/
|
|
32
|
+
async function resolveTemplateSource(input) {
|
|
33
|
+
const { range, bundled, port } = input;
|
|
34
|
+
const templateVersion = port.env("TEMPLATE_VERSION");
|
|
35
|
+
if (templateVersion === "local") {
|
|
36
|
+
return (0, neverthrow_1.ok)(floorSource(port.floor)); // AC-02 (override beats bundled=false)
|
|
37
|
+
}
|
|
38
|
+
if (templateVersion) {
|
|
39
|
+
return pinnedOnline(templateVersion, port); // AC-03
|
|
40
|
+
}
|
|
41
|
+
if (bundled) {
|
|
42
|
+
return (0, neverthrow_1.ok)(floorSource(port.floor)); // AC-01, AC-12 (never sniff package.json#version)
|
|
43
|
+
}
|
|
44
|
+
return resolveOnline(range, port);
|
|
45
|
+
}
|
|
46
|
+
function floorSource(floor) {
|
|
47
|
+
return {
|
|
48
|
+
origin: "bundled",
|
|
49
|
+
version: floor.version,
|
|
50
|
+
digest: floor.digest,
|
|
51
|
+
location: floor.location,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function pinnedOnline(version, port) {
|
|
55
|
+
let tags;
|
|
56
|
+
try {
|
|
57
|
+
tags = await port.tagList();
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
// A pin never falls back (AC-16 intent): surface the channel failure as a
|
|
61
|
+
// Result instead of letting the rejection escape (neverthrow contract).
|
|
62
|
+
return (0, neverthrow_1.err)(asTagListError(e));
|
|
63
|
+
}
|
|
64
|
+
const entry = tags.find((t) => t.version === version);
|
|
65
|
+
if (!entry) {
|
|
66
|
+
return (0, neverthrow_1.err)(new teamsfx_api_1.UserError({
|
|
67
|
+
source: SOURCE,
|
|
68
|
+
name: "TemplatePinnedVersionNotFound",
|
|
69
|
+
message: `Pinned template version "${version}" is not published on the release channel.`,
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
return fetchVerify(entry, port, "online");
|
|
73
|
+
}
|
|
74
|
+
async function resolveOnline(range, port) {
|
|
75
|
+
let tags;
|
|
76
|
+
try {
|
|
77
|
+
tags = await port.tagList();
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
// A malformed channel document is a hard error (spec decision #7 / AC-17),
|
|
81
|
+
// distinct from an unreachable channel: it must never be masked as an
|
|
82
|
+
// offline fallback. Only a genuine reachability failure falls back.
|
|
83
|
+
if (isMalformedTagList(e)) {
|
|
84
|
+
return (0, neverthrow_1.err)(e);
|
|
85
|
+
}
|
|
86
|
+
return (0, neverthrow_1.ok)(offlineFallback(range, port)); // AC-07, AC-08 (unreachable only)
|
|
87
|
+
}
|
|
88
|
+
const picked = semver_1.default.maxSatisfying(tags.map((t) => t.version), range); // AC-09 (stable excludes -beta), AC-10 (range names -beta)
|
|
89
|
+
if (!picked) {
|
|
90
|
+
// Channel reachable but no version satisfies range (AC-14 / AC-15).
|
|
91
|
+
if (semver_1.default.satisfies(port.floor.version, range)) {
|
|
92
|
+
return (0, neverthrow_1.ok)(floorFallback(port.floor)); // AC-14
|
|
93
|
+
}
|
|
94
|
+
return (0, neverthrow_1.err)(new teamsfx_api_1.UserError({
|
|
95
|
+
source: SOURCE,
|
|
96
|
+
name: "TemplateVersionMismatch",
|
|
97
|
+
message: `No published template version satisfies range "${range}", and the bundled floor "${port.floor.version}" does not satisfy it either. The engine and template versions are incompatible.`,
|
|
98
|
+
})); // AC-15
|
|
99
|
+
}
|
|
100
|
+
if (picked === port.floor.version) {
|
|
101
|
+
return (0, neverthrow_1.ok)(floorSource(port.floor)); // AC-05 (floor is highest satisfier; no download)
|
|
102
|
+
}
|
|
103
|
+
const entry = tags.find((t) => t.version === picked);
|
|
104
|
+
/* istanbul ignore if -- defensive: `picked` is drawn from `tags`, so a miss
|
|
105
|
+
means the tag list mutated mid-resolution; not reproducible in a unit. */
|
|
106
|
+
if (!entry) {
|
|
107
|
+
return (0, neverthrow_1.err)(new teamsfx_api_1.SystemError({
|
|
108
|
+
source: SOURCE,
|
|
109
|
+
name: "TemplateTagListInconsistent",
|
|
110
|
+
message: `Resolved version "${picked}" is no longer present in the tag list.`,
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
return fetchVerify(entry, port, "online"); // AC-04, AC-06, AC-11
|
|
114
|
+
}
|
|
115
|
+
/** A malformed channel tag-list (decision #7) is a hard error, distinct from an unreachable channel. */
|
|
116
|
+
function isMalformedTagList(e) {
|
|
117
|
+
return e instanceof teamsfx_api_1.SystemError && e.name === "TemplateTagListMalformed";
|
|
118
|
+
}
|
|
119
|
+
/** Preserve an existing FxError; wrap any other tag-list failure as a SystemError (neverthrow contract). */
|
|
120
|
+
function asTagListError(e) {
|
|
121
|
+
if (e instanceof teamsfx_api_1.UserError || e instanceof teamsfx_api_1.SystemError) {
|
|
122
|
+
return e;
|
|
123
|
+
}
|
|
124
|
+
/* istanbul ignore next -- the port rejects with an Error; the String(e)
|
|
125
|
+
fallback is defensive for non-Error rejections, not reproducible in a unit. */
|
|
126
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
127
|
+
return new teamsfx_api_1.SystemError({
|
|
128
|
+
source: SOURCE,
|
|
129
|
+
name: "TemplateTagListUnavailable",
|
|
130
|
+
message: `Failed to read the template release channel: ${message}.`,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/** Preserve an existing FxError; wrap any other download failure as a SystemError (neverthrow contract). */
|
|
134
|
+
function asDownloadError(e, version) {
|
|
135
|
+
if (e instanceof teamsfx_api_1.UserError || e instanceof teamsfx_api_1.SystemError) {
|
|
136
|
+
return e;
|
|
137
|
+
}
|
|
138
|
+
/* istanbul ignore next -- the port rejects with an Error; the String(e)
|
|
139
|
+
fallback is defensive for non-Error rejections, not reproducible in a unit. */
|
|
140
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
141
|
+
return new teamsfx_api_1.SystemError({
|
|
142
|
+
source: SOURCE,
|
|
143
|
+
name: "TemplateDownloadFailed",
|
|
144
|
+
message: `Failed to download template "${version}" from the release channel: ${message}.`,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
async function fetchVerify(entry, port, origin) {
|
|
148
|
+
const cached = port.cache.get(entry.version);
|
|
149
|
+
if (cached && cached.digest === entry.digest) {
|
|
150
|
+
return (0, neverthrow_1.ok)({
|
|
151
|
+
origin: "cache",
|
|
152
|
+
version: entry.version,
|
|
153
|
+
digest: entry.digest,
|
|
154
|
+
location: cacheLocation(entry.version),
|
|
155
|
+
}); // AC-06 (zero download)
|
|
156
|
+
}
|
|
157
|
+
let bytes;
|
|
158
|
+
try {
|
|
159
|
+
bytes = await port.packages(entry.version, entry.digest);
|
|
160
|
+
}
|
|
161
|
+
catch (e) {
|
|
162
|
+
// The download (sendRequestWithRetry) can reject; surface it as a Result
|
|
163
|
+
// rather than letting it escape resolveTemplateSource (neverthrow contract).
|
|
164
|
+
return (0, neverthrow_1.err)(asDownloadError(e, entry.version));
|
|
165
|
+
}
|
|
166
|
+
const computed = computeDigest(bytes);
|
|
167
|
+
if (computed !== entry.digest) {
|
|
168
|
+
return (0, neverthrow_1.err)(new teamsfx_api_1.SystemError({
|
|
169
|
+
source: SOURCE,
|
|
170
|
+
name: "TemplateDigestMismatch",
|
|
171
|
+
message: `Downloaded template "${entry.version}" failed integrity check: expected ${entry.digest}, got ${computed}.`,
|
|
172
|
+
})); // AC-11 (cache not written, corrupt bytes never returned)
|
|
173
|
+
}
|
|
174
|
+
port.cache.put(entry.version, entry.digest, bytes);
|
|
175
|
+
return (0, neverthrow_1.ok)({
|
|
176
|
+
origin,
|
|
177
|
+
version: entry.version,
|
|
178
|
+
digest: entry.digest,
|
|
179
|
+
location: cacheLocation(entry.version),
|
|
180
|
+
}); // AC-04
|
|
181
|
+
}
|
|
182
|
+
/** Reached when the channel is unreachable: max(highest cached satisfying range, floor). */
|
|
183
|
+
function offlineFallback(range, port) {
|
|
184
|
+
const cachedSatisfying = port.cache.keys().filter((v) => semver_1.default.satisfies(v, range));
|
|
185
|
+
const highestCached = semver_1.default.maxSatisfying(cachedSatisfying, range);
|
|
186
|
+
const floorSatisfies = semver_1.default.satisfies(port.floor.version, range);
|
|
187
|
+
// Cache wins only when strictly higher than the floor; a tie goes to the floor (decision #2).
|
|
188
|
+
if (highestCached && (!floorSatisfies || semver_1.default.gt(highestCached, port.floor.version))) {
|
|
189
|
+
const cached = port.cache.get(highestCached);
|
|
190
|
+
/* istanbul ignore else -- highestCached is drawn from cache.keys(); a miss
|
|
191
|
+
means the cache mutated mid-resolution, so we degrade to the floor. */
|
|
192
|
+
if (cached) {
|
|
193
|
+
return {
|
|
194
|
+
origin: "cache",
|
|
195
|
+
version: highestCached,
|
|
196
|
+
digest: cached.digest,
|
|
197
|
+
location: cacheLocation(highestCached),
|
|
198
|
+
warning: offlineWarning(range),
|
|
199
|
+
}; // AC-07
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return { ...floorFallback(port.floor), warning: offlineWarning(range) }; // AC-08
|
|
203
|
+
}
|
|
204
|
+
function floorFallback(floor) {
|
|
205
|
+
return {
|
|
206
|
+
origin: "bundled-fallback",
|
|
207
|
+
version: floor.version,
|
|
208
|
+
digest: floor.digest,
|
|
209
|
+
location: floor.location,
|
|
210
|
+
warning: `Falling back to the bundled template floor "${floor.version}".`,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function offlineWarning(range) {
|
|
214
|
+
return `The template release channel was unreachable; resolved offline within range "${range}".`;
|
|
215
|
+
}
|
|
216
|
+
function cacheLocation(version) {
|
|
217
|
+
// eslint-disable-next-line no-secrets/no-secrets
|
|
218
|
+
return `templates-v4@${version}`;
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=templateSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateSource.js","sourceRoot":"","sources":["../../../src/v4/distribution/templateSource.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAkFlC,sCAEC;AAQD,sDAgBC;;AA1GD,wDAAyE;AACzE,2CAA6C;AAC7C,uDAAiC;AACjC,4DAA4B;AAE5B;;;;;;;;GAQG;AAEH,MAAM,MAAM,GAAG,UAAU,CAAC;AAgE1B,oEAAoE;AACpE,SA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|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { FxError } from "@microsoft/teamsfx-api";
|
|
2
|
+
import { Result } from "neverthrow";
|
|
3
|
+
import { BundledFloor, TagEntry, TemplateSource, TemplateSourcePort } from "./templateSource";
|
|
4
|
+
/** v4 channel prefix and naming (ADR-0006 channel isolation). */
|
|
5
|
+
export declare const V4_TAG_PREFIX = "templates-v4@";
|
|
6
|
+
export declare const ZIP_EXT = ".zip";
|
|
7
|
+
export interface TemplateChannelConfig {
|
|
8
|
+
/** NDJSON tag-list URL for the v4 channel (separate from the frozen v3 `tagListURL`). */
|
|
9
|
+
templatesV4TagListURL: string;
|
|
10
|
+
/** Base URL release assets are downloaded from. */
|
|
11
|
+
templateDownloadBaseURL: string;
|
|
12
|
+
/** Network retry budget. */
|
|
13
|
+
tryLimits: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parse the model-A NDJSON tag list: one `{ version, digest }` object per
|
|
17
|
+
* line. Blank lines and trailing `\r` are ignored; a malformed line is a hard
|
|
18
|
+
* error (no silent skip) — spec decision #7.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseTagList(ndjson: string): TagEntry[];
|
|
21
|
+
/** The download URL for a v4 template package version. */
|
|
22
|
+
export declare function templateZipUrl(baseURL: string, version: string): string;
|
|
23
|
+
/** The on-disk cache directory for the v4 template packages. */
|
|
24
|
+
export declare function cacheDir(): string;
|
|
25
|
+
/** The cache file path for one version. */
|
|
26
|
+
export declare function cacheFile(version: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Build the production port. `floor` is injected (it comes from the engine's
|
|
29
|
+
* baked bundled package); this factory does not fabricate it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createTemplateSourcePort(config: TemplateChannelConfig, floor: BundledFloor): TemplateSourcePort;
|
|
32
|
+
/**
|
|
33
|
+
* Load the bytes for an already-resolved {@link TemplateSource}.
|
|
34
|
+
*
|
|
35
|
+
* `resolveTemplateSource` decides *which* package a scaffold run uses but
|
|
36
|
+
* returns only the descriptor; this is the companion IO step that produces the
|
|
37
|
+
* bytes, the boundary the v3 chokepoint calls before `openTemplatePackage`.
|
|
38
|
+
*
|
|
39
|
+
* It never reaches the network: an `online`/`cache` source was already
|
|
40
|
+
* downloaded, verified, and cached during resolution, so re-downloading here
|
|
41
|
+
* would defeat the digest-keyed cache and reintroduce the v3 re-fetch churn. A
|
|
42
|
+
* cache miss is therefore an invariant violation (hard error), not a silent
|
|
43
|
+
* re-fetch. Every path re-checks the bytes against `source.digest` so
|
|
44
|
+
* `computeDigest` stays the single integrity authority and a corrupt package is
|
|
45
|
+
* never handed back.
|
|
46
|
+
*
|
|
47
|
+
* Spec: docs/03-specs/operations/scaffolding/resolve-template-source.md
|
|
48
|
+
*/
|
|
49
|
+
export declare function loadResolvedPackage(source: TemplateSource, port: TemplateSourcePort): Result<Buffer, FxError>;
|
|
50
|
+
//# sourceMappingURL=templateSourcePort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateSourcePort.d.ts","sourceRoot":"","sources":["../../../src/v4/distribution/templateSourcePort.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAe,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAW,MAAM,YAAY,CAAC;AAK7C,OAAO,EACL,YAAY,EAEZ,QAAQ,EACR,cAAc,EACd,kBAAkB,EAEnB,MAAM,kBAAkB,CAAC;AAc1B,iEAAiE;AAEjE,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,eAAO,MAAM,OAAO,SAAS,CAAC;AAE9B,MAAM,WAAW,qBAAqB;IACpC,yFAAyF;IACzF,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mDAAmD;IACnD,uBAAuB,EAAE,MAAM,CAAC;IAChC,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE,CA4BvD;AAUD,0DAA0D;AAC1D,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED,gEAAgE;AAChE,wBAAgB,QAAQ,IAAI,MAAM,CAEjC;AAED,2CAA2C;AAC3C,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,qBAAqB,EAC7B,KAAK,EAAE,YAAY,GAClB,kBAAkB,CAwEpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,kBAAkB,GACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuCzB"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.ZIP_EXT = exports.V4_TAG_PREFIX = void 0;
|
|
6
|
+
exports.parseTagList = parseTagList;
|
|
7
|
+
exports.templateZipUrl = templateZipUrl;
|
|
8
|
+
exports.cacheDir = cacheDir;
|
|
9
|
+
exports.cacheFile = cacheFile;
|
|
10
|
+
exports.createTemplateSourcePort = createTemplateSourcePort;
|
|
11
|
+
exports.loadResolvedPackage = loadResolvedPackage;
|
|
12
|
+
const tslib_1 = require("tslib");
|
|
13
|
+
const teamsfx_api_1 = require("@microsoft/teamsfx-api");
|
|
14
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
15
|
+
const neverthrow_1 = require("neverthrow");
|
|
16
|
+
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
17
|
+
const path = tslib_1.__importStar(require("path"));
|
|
18
|
+
const os_1 = tslib_1.__importDefault(require("os"));
|
|
19
|
+
const requestUtils_1 = require("../../common/requestUtils");
|
|
20
|
+
const templateSource_1 = require("./templateSource");
|
|
21
|
+
/**
|
|
22
|
+
* Production wiring of the narrow {@link TemplateSourcePort} over real
|
|
23
|
+
* environment / network / filesystem. The pure helpers (`parseTagList`,
|
|
24
|
+
* `templateZipUrl`, `cacheDir`) are exported and unit-tested; the IO faces
|
|
25
|
+
* are thin wrappers around them.
|
|
26
|
+
*
|
|
27
|
+
* Spec: docs/03-specs/operations/scaffolding/resolve-template-source.md
|
|
28
|
+
* (decisions #6 digest = sha256 of zip bytes, #7 NDJSON tag list).
|
|
29
|
+
*/
|
|
30
|
+
const SOURCE = "Scaffold";
|
|
31
|
+
/** v4 channel prefix and naming (ADR-0006 channel isolation). */
|
|
32
|
+
// eslint-disable-next-line no-secrets/no-secrets
|
|
33
|
+
exports.V4_TAG_PREFIX = "templates-v4@";
|
|
34
|
+
exports.ZIP_EXT = ".zip";
|
|
35
|
+
/**
|
|
36
|
+
* Parse the model-A NDJSON tag list: one `{ version, digest }` object per
|
|
37
|
+
* line. Blank lines and trailing `\r` are ignored; a malformed line is a hard
|
|
38
|
+
* error (no silent skip) — spec decision #7.
|
|
39
|
+
*/
|
|
40
|
+
function parseTagList(ndjson) {
|
|
41
|
+
const entries = [];
|
|
42
|
+
const lines = ndjson.split("\n");
|
|
43
|
+
for (let i = 0; i < lines.length; i++) {
|
|
44
|
+
const line = lines[i].replace(/\r$/, "").trim();
|
|
45
|
+
if (line.length === 0) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
let parsed;
|
|
49
|
+
try {
|
|
50
|
+
parsed = JSON.parse(line);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new teamsfx_api_1.SystemError({
|
|
54
|
+
source: SOURCE,
|
|
55
|
+
name: "TemplateTagListMalformed",
|
|
56
|
+
message: `Malformed v4 tag-list entry on line ${i + 1}: not valid JSON.`,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (!isTagEntry(parsed)) {
|
|
60
|
+
throw new teamsfx_api_1.SystemError({
|
|
61
|
+
source: SOURCE,
|
|
62
|
+
name: "TemplateTagListMalformed",
|
|
63
|
+
message: `Malformed v4 tag-list entry on line ${i + 1}: missing "version" or "digest".`,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
entries.push({ version: parsed.version, digest: parsed.digest });
|
|
67
|
+
}
|
|
68
|
+
return entries;
|
|
69
|
+
}
|
|
70
|
+
function isTagEntry(value) {
|
|
71
|
+
if (typeof value !== "object" || value === null) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
const v = value;
|
|
75
|
+
return typeof v.version === "string" && typeof v.digest === "string";
|
|
76
|
+
}
|
|
77
|
+
/** The download URL for a v4 template package version. */
|
|
78
|
+
function templateZipUrl(baseURL, version) {
|
|
79
|
+
return `${baseURL}/${exports.V4_TAG_PREFIX}${version}/templates${exports.ZIP_EXT}`;
|
|
80
|
+
}
|
|
81
|
+
/** The on-disk cache directory for the v4 template packages. */
|
|
82
|
+
function cacheDir() {
|
|
83
|
+
return path.join(os_1.default.homedir(), ".fx", "templates-cache");
|
|
84
|
+
}
|
|
85
|
+
/** The cache file path for one version. */
|
|
86
|
+
function cacheFile(version) {
|
|
87
|
+
return path.join(cacheDir(), `${exports.V4_TAG_PREFIX}${version}${exports.ZIP_EXT}`);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Build the production port. `floor` is injected (it comes from the engine's
|
|
91
|
+
* baked bundled package); this factory does not fabricate it.
|
|
92
|
+
*/
|
|
93
|
+
function createTemplateSourcePort(config, floor) {
|
|
94
|
+
const memo = new Map();
|
|
95
|
+
// Warm the in-memory index from disk so `keys()` reflects prior downloads
|
|
96
|
+
// for the offline `max(cache, floor)` fallback.
|
|
97
|
+
let warmed = false;
|
|
98
|
+
const warm = () => {
|
|
99
|
+
if (warmed) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
warmed = true;
|
|
103
|
+
let names = [];
|
|
104
|
+
try {
|
|
105
|
+
names = fs.readdirSync(cacheDir());
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return; // EAFP: no cache dir yet → empty index
|
|
109
|
+
}
|
|
110
|
+
for (const name of names) {
|
|
111
|
+
if (!name.startsWith(exports.V4_TAG_PREFIX) || !name.endsWith(exports.ZIP_EXT)) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const version = name.slice(exports.V4_TAG_PREFIX.length, name.length - exports.ZIP_EXT.length);
|
|
115
|
+
try {
|
|
116
|
+
const bytes = fs.readFileSync(path.join(cacheDir(), name));
|
|
117
|
+
memo.set(version, { digest: (0, templateSource_1.computeDigest)(bytes), bytes });
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
/* istanbul ignore next -- defensive: a listed cache file vanishing/locked between readdir and read is not reproducible */
|
|
121
|
+
continue; // a vanished/locked file is simply not indexed
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
env: (name) => process.env[name],
|
|
127
|
+
tagList: async () => {
|
|
128
|
+
const res = await (0, requestUtils_1.sendRequestWithRetry)(() => axios_1.default.get(config.templatesV4TagListURL, { responseType: "text" }), config.tryLimits);
|
|
129
|
+
return parseTagList(res.data);
|
|
130
|
+
},
|
|
131
|
+
packages: async (version) => {
|
|
132
|
+
const res = await (0, requestUtils_1.sendRequestWithRetry)(() => axios_1.default.get(templateZipUrl(config.templateDownloadBaseURL, version), {
|
|
133
|
+
responseType: "arraybuffer",
|
|
134
|
+
}), config.tryLimits);
|
|
135
|
+
return Buffer.from(res.data);
|
|
136
|
+
},
|
|
137
|
+
cache: {
|
|
138
|
+
get: (version) => {
|
|
139
|
+
warm();
|
|
140
|
+
return memo.get(version);
|
|
141
|
+
},
|
|
142
|
+
put: (version, digest, bytes) => {
|
|
143
|
+
fs.ensureDirSync(cacheDir());
|
|
144
|
+
fs.writeFileSync(cacheFile(version), bytes);
|
|
145
|
+
memo.set(version, { digest, bytes });
|
|
146
|
+
},
|
|
147
|
+
keys: () => {
|
|
148
|
+
warm();
|
|
149
|
+
return [...memo.keys()];
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
floor,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Load the bytes for an already-resolved {@link TemplateSource}.
|
|
157
|
+
*
|
|
158
|
+
* `resolveTemplateSource` decides *which* package a scaffold run uses but
|
|
159
|
+
* returns only the descriptor; this is the companion IO step that produces the
|
|
160
|
+
* bytes, the boundary the v3 chokepoint calls before `openTemplatePackage`.
|
|
161
|
+
*
|
|
162
|
+
* It never reaches the network: an `online`/`cache` source was already
|
|
163
|
+
* downloaded, verified, and cached during resolution, so re-downloading here
|
|
164
|
+
* would defeat the digest-keyed cache and reintroduce the v3 re-fetch churn. A
|
|
165
|
+
* cache miss is therefore an invariant violation (hard error), not a silent
|
|
166
|
+
* re-fetch. Every path re-checks the bytes against `source.digest` so
|
|
167
|
+
* `computeDigest` stays the single integrity authority and a corrupt package is
|
|
168
|
+
* never handed back.
|
|
169
|
+
*
|
|
170
|
+
* Spec: docs/03-specs/operations/scaffolding/resolve-template-source.md
|
|
171
|
+
*/
|
|
172
|
+
function loadResolvedPackage(source, port) {
|
|
173
|
+
let bytes;
|
|
174
|
+
if (source.origin === "bundled" || source.origin === "bundled-fallback") {
|
|
175
|
+
try {
|
|
176
|
+
bytes = fs.readFileSync(source.location);
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
return (0, neverthrow_1.err)(new teamsfx_api_1.SystemError({
|
|
180
|
+
source: SOURCE,
|
|
181
|
+
name: "TemplatePackageUnreadable",
|
|
182
|
+
message: `The resolved bundled template package at "${source.location}" is missing or unreadable.`,
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
const cached = port.cache.get(source.version);
|
|
188
|
+
if (cached === undefined) {
|
|
189
|
+
return (0, neverthrow_1.err)(new teamsfx_api_1.SystemError({
|
|
190
|
+
source: SOURCE,
|
|
191
|
+
name: "TemplatePackageNotCached",
|
|
192
|
+
message: `The resolved template package "${source.version}" is not present in the local cache.`,
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
bytes = cached.bytes;
|
|
196
|
+
}
|
|
197
|
+
const digest = (0, templateSource_1.computeDigest)(bytes);
|
|
198
|
+
if (digest !== source.digest) {
|
|
199
|
+
return (0, neverthrow_1.err)(new teamsfx_api_1.SystemError({
|
|
200
|
+
source: SOURCE,
|
|
201
|
+
name: "TemplateDigestMismatch",
|
|
202
|
+
message: `The resolved template package "${source.version}" failed its integrity check: expected ${source.digest}, got ${digest}.`,
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
return (0, neverthrow_1.ok)(bytes);
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=templateSourcePort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateSourcePort.js","sourceRoot":"","sources":["../../../src/v4/distribution/templateSourcePort.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAiDlC,oCA4BC;AAWD,wCAEC;AAGD,4BAEC;AAGD,8BAEC;AAMD,4DA2EC;AAmBD,kDA0CC;;AAhPD,wDAA8D;AAC9D,0DAA6C;AAC7C,2CAA6C;AAC7C,qDAA+B;AAC/B,mDAA6B;AAC7B,oDAAoB;AACpB,4DAAiE;AACjE,qDAO0B;AAE1B;;;;;;;;GAQG;AAEH,MAAM,MAAM,GAAG,UAAU,CAAC;AAE1B,iEAAiE;AACjE,iDAAiD;AACpC,QAAA,aAAa,GAAG,eAAe,CAAC;AAChC,QAAA,OAAO,GAAG,MAAM,CAAC;AAW9B;;;;GAIG;AACH,SAAgB,YAAY,CAAC,MAAc;IACzC,MAAM,OAAO,GAAe,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,C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AO,IAAA,gBAAG,EACR,IAAI,yBAAW,CAAC;gBACd,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,0BAA0B;gBAChC,OAAO,EAAE,kCAAkC,MAAM,CAAC,OAAO,sCAAsC;aAChG,CAAC,CACH,CAAC;QACJ,CAAC;QACD,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IACvB,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,8BAAa,EAAC,KAAK,CAAC,CAAC;IACpC,IAAI,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;QAC7B,OAAO,IAAA,gBAAG,EACR,IAAI,yBAAW,CAAC;YACd,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,wBAAwB;YAC9B,OAAO,EAAE,kCAAkC,MAAM,CAAC,OAAO,0CAA0C,MAAM,CAAC,MAAM,SAAS,MAAM,GAAG;SACnI,CAAC,CACH,CAAC;IACJ,CAAC;IACD,OAAO,IAAA,eAAE,EAAC,KAAK,CAAC,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public surface of the v4 scaffolding world.
|
|
3
|
+
*
|
|
4
|
+
* v4 lives isolated from v3 (see scaffolding.create.proposal.md §5.1). It
|
|
5
|
+
* imports no v3 symbol; v3 may call into this barrel, but nothing here is
|
|
6
|
+
* tailored for v3.
|
|
7
|
+
*/
|
|
8
|
+
export * from "./distribution/templateSource";
|
|
9
|
+
export * from "./distribution/templateSourcePort";
|
|
10
|
+
export * from "./distribution/bundledFloor";
|
|
11
|
+
export * from "./distribution/templateConfig";
|
|
12
|
+
export * from "./distribution/templatePackage";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v4/index.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AAEH,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
/**
|
|
7
|
+
* Public surface of the v4 scaffolding world.
|
|
8
|
+
*
|
|
9
|
+
* v4 lives isolated from v3 (see scaffolding.create.proposal.md §5.1). It
|
|
10
|
+
* imports no v3 symbol; v3 may call into this barrel, but nothing here is
|
|
11
|
+
* tailored for v3.
|
|
12
|
+
*/
|
|
13
|
+
tslib_1.__exportStar(require("./distribution/templateSource"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./distribution/templateSourcePort"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./distribution/bundledFloor"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./distribution/templateConfig"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./distribution/templatePackage"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v4/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;;;;;GAMG;AAEH,wEAA8C;AAC9C,4EAAkD;AAClD,sEAA4C;AAC5C,wEAA8C;AAC9C,yEAA+C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/teamsfx-core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.14-alpha.1673f8d0ac.0",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"types": "build/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -108,8 +108,8 @@
|
|
|
108
108
|
"@microsoft/dev-tunnels-contracts": "1.1.9",
|
|
109
109
|
"@microsoft/dev-tunnels-management": "1.1.9",
|
|
110
110
|
"@microsoft/kiota": "1.31.1",
|
|
111
|
-
"@microsoft/m365-spec-parser": "^0.2.
|
|
112
|
-
"@microsoft/teamsfx-api": "0.23.
|
|
111
|
+
"@microsoft/m365-spec-parser": "^0.2.14-alpha.1673f8d0ac.0",
|
|
112
|
+
"@microsoft/teamsfx-api": "0.23.15-alpha.1673f8d0ac.0",
|
|
113
113
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
114
114
|
"adm-zip": "^0.5.10",
|
|
115
115
|
"ajv": "^8.18.0",
|
|
@@ -233,7 +233,7 @@
|
|
|
233
233
|
"resource/**/*",
|
|
234
234
|
"templates/**/*"
|
|
235
235
|
],
|
|
236
|
-
"gitHead": "
|
|
236
|
+
"gitHead": "cb6454f2020e8b509b8625f6e28ec9f39a757a89",
|
|
237
237
|
"publishConfig": {
|
|
238
238
|
"access": "public"
|
|
239
239
|
},
|