ResourceDeclaration class

Shared base for resource declaration implementations.

Extends

Remarks

Both represent one Bicep resource declaration in the component tree and share the same declaration-level state layout: identity fields (type, apiVersion, existing), the if(...) guard (condition), the optional cross-scope reference (scope), and the raw prop bag that becomes the resource body.

This class owns the common declaration state layout, raw-handle escape hatch, and identity accessors. Subclasses supply their construction and access behavior.

Properties

apiVersion
condition
dependsOn
deploymentContext

The effective deployment context inherited from ancestors, resolved by walking up the parent chain (this node's own local contribution is intentionally excluded — a node's contribution flows to its descendants, not to itself). Each field is resolved per its own rule:

  • location: nearest ancestor with a value wins.
  • namingPolicy: nearest ancestor with a value wins.
  • tags: flat-merged across all ancestors; innermost wins on key conflict.

Returns an object whose fields may all be undefined if no ancestor contributed anything.

existing
self

Public identity for this node.

type
[RESOURCE_DECLARATION_BRAND]

Brand marker for cross-realm isResourceDeclaration() checks. Uses Symbol.for so it survives multiple copies of @azure/provisioning-core. Inherited by every resource declaration implementation.

Inherited Properties

children
parent

Inherited Methods

isChildOf(ProvisioningComponent)
transform((component: ProvisioningComponent) => void)

Applies a callback to every descendant component/resource that matches the given constructor, including this when it matches.

transform<TComponent>(ProvisioningComponentConstructor<TComponent>, (component: TComponent) => void)
visit((component: ProvisioningComponent) => boolean | void)

Depth-first visit of this node and all descendants. Return false from the callback to skip visiting that node's children.

Constructor Details

ResourceDeclaration<TType>(ProvisioningComponent, ResourceProps<TType> & Record<string, unknown>, ResourceOptions, ResourceNamingRules)

Base constructor for every Bicep resource declaration.

new ResourceDeclaration(context: ProvisioningComponent, props: ResourceProps<TType> & Record<string, unknown>, options?: ResourceOptions, namingRules?: ResourceNamingRules)

Parameters

props

ResourceProps<TType> & Record<string, unknown>

options
ResourceOptions
namingRules
ResourceNamingRules

per-resource-type constraints for the naming policy. Resource reads this reflectively off the concrete subclass constructor; internal declaration implementations receive it from the concrete resource constructor they represent.

Remarks

Responsibilities:

  1. Register in the component tree (super(context)).
  2. Enforce a deployment context ancestor.
  3. Unwrap context if it's an indexed proxy from .at(i) / parent.at(loop.index), and stash parentIndex on state so the serializer can emit parent: parentSym[index] on the child.
  4. Inherit condition from the immediate parent resource declaration when the caller doesn't supply one (Bicep requires children of a conditional resource to share the same guard).
  5. Populate state — existing arm records only identity fields; deployable arm runs the naming policy and applies DeploymentContext defaults for location / tags per the shape descriptor.

Subclasses supply the last mile, including their public handle behavior.

Property Details

apiVersion

string apiVersion

Property Value

string

condition

ExpressionOrValue<boolean> | undefined condition

Property Value

ExpressionOrValue<boolean> | undefined

dependsOn

(readonly ResourceDeclaration<string>[]) | undefined dependsOn

Property Value

(readonly ResourceDeclaration<string>[]) | undefined

deploymentContext

The effective deployment context inherited from ancestors, resolved by walking up the parent chain (this node's own local contribution is intentionally excluded — a node's contribution flows to its descendants, not to itself). Each field is resolved per its own rule:

  • location: nearest ancestor with a value wins.
  • namingPolicy: nearest ancestor with a value wins.
  • tags: flat-merged across all ancestors; innermost wins on key conflict.

Returns an object whose fields may all be undefined if no ancestor contributed anything.

DeploymentContext deploymentContext

Property Value

existing

boolean | undefined existing

Property Value

boolean | undefined

self

Public identity for this node.

this self

Property Value

this

type

TType type

Property Value

TType

[RESOURCE_DECLARATION_BRAND]

Brand marker for cross-realm isResourceDeclaration() checks. Uses Symbol.for so it survives multiple copies of @azure/provisioning-core. Inherited by every resource declaration implementation.

[RESOURCE_DECLARATION_BRAND]: true

Property Value

true

Inherited Property Details

children

children: ProvisioningComponent[]

Property Value

Inherited From ProvisioningComponent.children

parent

parent: ProvisioningComponent | undefined

Property Value

ProvisioningComponent | undefined

Inherited From ProvisioningComponent.parent

Inherited Method Details

isChildOf(ProvisioningComponent)

function isChildOf(component: ProvisioningComponent): boolean

Parameters

Returns

boolean

Inherited From ProvisioningComponent.isChildOf

transform((component: ProvisioningComponent) => void)

Applies a callback to every descendant component/resource that matches the given constructor, including this when it matches.

function transform(callback: (component: ProvisioningComponent) => void): this

Parameters

callback

(component: ProvisioningComponent) => void

Returns

this

Inherited From ProvisioningComponent.transform

transform<TComponent>(ProvisioningComponentConstructor<TComponent>, (component: TComponent) => void)

function transform<TComponent>(ctor: ProvisioningComponentConstructor<TComponent>, callback: (component: TComponent) => void): this

Parameters

callback

(component: TComponent) => void

Returns

this

Inherited From ProvisioningComponent.transform

visit((component: ProvisioningComponent) => boolean | void)

Depth-first visit of this node and all descendants. Return false from the callback to skip visiting that node's children.

function visit(callback: (component: ProvisioningComponent) => boolean | void)

Parameters

callback

(component: ProvisioningComponent) => boolean | void

Inherited From ProvisioningComponent.visit