diff --git a/bin/lang-js/src/asset_builder.ts b/bin/lang-js/src/asset_builder.ts index 28aca94679..5fd45db8ba 100644 --- a/bin/lang-js/src/asset_builder.ts +++ b/bin/lang-js/src/asset_builder.ts @@ -895,6 +895,7 @@ export class SecretPropBuilder implements ISecretPropBuilder { export interface SecretDefinition { name: string; props: PropDefinition[]; + connectionAnnotations?: string; } export interface ISecretDefinitionBuilder { @@ -911,6 +912,7 @@ export interface ISecretDefinitionBuilder { * @example * const secretDefinition = new SecretDefinitionBuilder() * .setName("DigitalOcean Token") + * .setConnectionAnnotations("Registry Token") * .addProp( * new PropBuilder() * .setKind("string") @@ -931,6 +933,7 @@ export class SecretDefinitionBuilder implements ISecretDefinitionBuilder { this.definition = {}; this.definition.name = ""; this.definition.props = []; + this.definition.connectionAnnotations = ""; } /** @@ -967,6 +970,21 @@ export class SecretDefinitionBuilder implements ISecretDefinitionBuilder { return this; } + /** + * Adds the specified connection annotations to the output socket for the secret + * + * @param {string} connectionAnnotations - the connection annotations to create for the output socket. + * + * @returns this + * + * @example + * .setConnectionAnnotation("Registry Token") + */ + setConnectionAnnotation(connectionAnnotations: string): this { + this.definition.connectionAnnotations = connectionAnnotations; + return this; + } + build(): SecretDefinition { const def = this.definition; @@ -1070,18 +1088,27 @@ export class AssetBuilder implements IAssetBuilder { .build(), ); - this.addOutputSocket( - new SocketDefinitionBuilder() - .setArity("one") - .setName(definition.name) - .setValueFrom( - new ValueFromBuilder() - .setKind("prop") - .setPropPath(["root", "secrets", definition.name]) - .build(), - ) - .build(), - ); + const outputSocketBuilder = new SocketDefinitionBuilder() + .setArity("one") + .setName(definition.name) + .setValueFrom( + new ValueFromBuilder() + .setKind("prop") + .setPropPath(["root", "secrets", definition.name]) + .build(), + ); + + if ( + definition.connectionAnnotations + && definition.connectionAnnotations !== "" + ) { + outputSocketBuilder.setConnectionAnnotation( + definition.connectionAnnotations, + ); + } + + const outputSocket = outputSocketBuilder.build(); + this.addOutputSocket(outputSocket); return this; } diff --git a/lib/dal/src/func/authoring/data/ts_types/asset_types_with_secrets.d.ts b/lib/dal/src/func/authoring/data/ts_types/asset_types_with_secrets.d.ts index 0d454bb595..82fdce40f4 100644 --- a/lib/dal/src/func/authoring/data/ts_types/asset_types_with_secrets.d.ts +++ b/lib/dal/src/func/authoring/data/ts_types/asset_types_with_secrets.d.ts @@ -686,10 +686,12 @@ declare class SecretPropBuilder implements ISecretPropBuilder { interface SecretDefinition { name: string; props: PropDefinition[]; + connectionAnnotations?: string; } interface ISecretDefinitionBuilder { addProp(prop: PropDefinition): this; + setName(name: string): this; build(): SecretDefinition; } @@ -699,7 +701,8 @@ interface ISecretDefinitionBuilder { * * @example * const secretDefinition = new SecretDefinitionBuilder() - * .setName("DigitalOcean Token") + * .setName("DigitalOcean Token") + * .setConnectionAnnotations("Registry Token") * .addProp( * new PropBuilder() * .setKind("string") @@ -746,6 +749,18 @@ declare class SecretDefinitionBuilder implements ISecretDefinitionBuilder { */ addProp(prop: PropDefinition): this; + /** + * Adds the specified connection annotations to the output socket for the secret + * + * @param {string} connectionAnnotations - the connection annotations to create for the output socket. + * + * @returns this + * + * @example + * .setConnectionAnnotation("Registry Token") + */ + setConnectionAnnotation(connectionAnnotations: string): this; + build(): SecretDefinition; }