@mark1russell7/stack-tofu 0.2.0 → 0.2.2

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/add-on.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as checkTofu, t as joinTofu } from "./join-Ba3zzNsN.js";
1
+ import { a as checkTofu, t as joinTofu } from "./join-Bzyt9lhB.js";
2
2
  import { n as TOFU_SCHEMA } from "./layer-CS1ZZFFP.js";
3
3
  import { parseTofu } from "./schema.js";
4
4
  // src/add-on.ts
package/build/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { C as typeProvider, S as resourceProvider, _ as isBuiltin, a as GroupParam, b as resourceAddress, c as Resource, d as TofuObject, f as TofuValue, g as copyName, h as VariableType, i as Group, l as TOFU_SCHEMA, m as Variable, n as Backend, o as GroupResource, p as VARIABLE_TYPES, r as Copy, s as Provider, t as BUILTIN_PROVIDER, u as TofuLayer, v as partName, x as resourceName, y as providerAddress } from "./layer-Cz0jBEel.js";
2
2
  import { C as resourceKey, S as plannedTotal, _ as accountStates, a as TofuFault, b as evaluateCost, c as AccountState, d as PLANNED, f as PLANNED_OVER, g as accountKey, h as UNKNOWN_COSTS, i as TofuCode, l as Budget, m as PLANNED_TOTAL, n as RESOURCE_META, o as TofuOptions, p as PLANNED_ROOM, r as TOFU_CODES, s as checkTofu, t as PROVIDER_META, u as COST_LAYER_KEY, v as budgetsByPart, x as isZeroOrMore, y as costSpace } from "./check-B-gwXACy.js";
3
3
  import { a as PlanOptions, i as PlanFault, n as PlanChange, o as TofuPlan, r as PlanCode, s as checkPlan, t as PLAN_CODES } from "./plan-D04Q_k6n.js";
4
- import { Fault, LayerParse, LayerPiece, Stack } from "@mark1russell7/system-stack";
4
+ import { Fault, LayerParse, LayerPiece, Stack, neededParts } from "@mark1russell7/system-stack";
5
5
  /** The form of the type of a resource and of the type of a backend. */
6
6
  export declare const TYPE_FORM: RegExp;
7
7
  /** The form of the local name of a provider, for example `example` or `example-beta`. */
@@ -125,11 +125,6 @@ export declare function resourcesByPart(layer: TofuLayer): Map<string, string[]>
125
125
  * Each address comes one time. An address can name a resource that the layer does not have.
126
126
  */
127
127
  export declare function resourceRefs(resource: Resource): string[];
128
- /**
129
- * This function gives the `id` of each part that a part needs, directly or through other parts.
130
- * The part itself is not in the result. A need that names no part of the stack is in the result.
131
- */
132
- export declare function neededParts(stack: Stack, part: string): Set<string>;
133
128
  /**
134
129
  * This function gives the dependencies of each resource that come from the needs of the stack, by the address of the resource.
135
130
  *
@@ -211,5 +206,5 @@ export declare const SAMPLE_BUDGETS: readonly Budget[];
211
206
  * The gate of a plan passes for it.
212
207
  */
213
208
  export declare const SAMPLE_PLAN: TofuPlan;
214
- export { AccountState, BUILTIN_PROVIDER, Backend, Budget, COST_LAYER_KEY, Copy, Group, GroupParam, GroupResource, PLANNED, PLANNED_OVER, PLANNED_ROOM, PLANNED_TOTAL, PLAN_CODES, PROVIDER_META, PlanChange, PlanCode, PlanFault, PlanOptions, Provider, RESOURCE_META, Resource, TOFU_CODES, TOFU_SCHEMA, TofuCode, TofuFault, TofuLayer, TofuObject, TofuOptions, TofuPlan, TofuValue, UNKNOWN_COSTS, VARIABLE_TYPES, Variable, VariableType, accountKey, accountStates, budgetsByPart, checkPlan, checkTofu, copyName, costSpace, evaluateCost, isBuiltin, isZeroOrMore, partName, plannedTotal, providerAddress, resourceAddress, resourceKey, resourceName, resourceProvider, typeProvider };
209
+ export { AccountState, BUILTIN_PROVIDER, Backend, Budget, COST_LAYER_KEY, Copy, Group, GroupParam, GroupResource, PLANNED, PLANNED_OVER, PLANNED_ROOM, PLANNED_TOTAL, PLAN_CODES, PROVIDER_META, PlanChange, PlanCode, PlanFault, PlanOptions, Provider, RESOURCE_META, Resource, TOFU_CODES, TOFU_SCHEMA, TofuCode, TofuFault, TofuLayer, TofuObject, TofuOptions, TofuPlan, TofuValue, UNKNOWN_COSTS, VARIABLE_TYPES, Variable, VariableType, accountKey, accountStates, budgetsByPart, checkPlan, checkTofu, copyName, costSpace, evaluateCost, isBuiltin, isZeroOrMore, neededParts, partName, plannedTotal, providerAddress, resourceAddress, resourceKey, resourceName, resourceProvider, typeProvider };
215
210
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/values.ts","../src/groups.ts","../src/queries.ts","../src/join.ts","../src/generate.ts","../src/sample.ts"],"mappings":";;;;;qBAMa,WAAW;;qBAGX,eAAe;;qBAGf,WAAW;;;;;qBAMX,WAAW;;qBAGX,aAAa;;qBAGb,cAAc;;iBAGV;WACN;WACA;;;;;;wBAOK,SAAS,cAAc;;wBAUvB,OAAO,OAAO,YAAY,kBAAkB;;wBAK5C,SAAS,OAAO,YAAY,SAAS;;wBAKrC,OAAO,OAAO;;wBAYd,MAAM,OAAO;;wBAMb,MAAM,OAAO;;wBAMb,QAAQ,OAAO;;;;;wBASf,eAAe;;;;;;;;;wBAaf,YAAY,OAAO,YAAY;;YAYnC;;iBAGK;WACN;WACA,MAAM;WACN;;;iBAIM;WACN,MAAM;WACN;;;iBAIM;WACN,gBAAgB;WAChB,kBAAkB;;;wBAIb,UAAU,OAAO,YAAY;;wBA8B7B,SAAS,MAAM;;wBClJf,aAAa,UAAU;;wBAKvB,iBAAiB,MAAM,MAAM,UAAU;;;;;;;;;;;;wBAoEvC,cAAc,OAAO,YAAY;;wBAyBjC,eAAe,OAAO,qBAAqB;;;;;;;;;;;;;;;;;;;;wBAqD3C,YAAY,OAAO,YAAY;;wBCjK/B,eAAe,OAAO,qBAAqB;;;;;wBAc3C,gBAAgB,OAAO,YAAY;;;;;wBAenC,aAAa,UAAU;;;;;wBAoCvB,YAAY,OAAO,OAAO,eAAe;;;;;;;;;;wBAazC,UAAU,OAAO,WAAW,OAAO,QAAQ;;;;;;wBAoB3C,eAAe,OAAO,WAAW,OAAO;;;;;;;;;;;;;;;;;;wBCtFxC,SAAS,iBAAiB,WAAW,eAAe,WAAW;;qBCZlE;;qBAGA;;YAGD,eAAe;;;;;YAMf;WAAuB;WAAmB,UAAU;WAAuB,iBAAiB;;WAAuB;WAAoB,iBAAiB;;;;;;;;;;;;;wBAqHpJ,aAAa,OAAO,WAAW,OAAO,OAAO,UAAS,cAAmB;;wBAOzE,aAAa,UAAU;;;;;qBC1I1B,aAAa;;;;;qBAwBb,yBAAyB;;;;;qBAMzB,aAAa"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/values.ts","../src/groups.ts","../src/queries.ts","../src/join.ts","../src/generate.ts","../src/sample.ts"],"mappings":";;;;;qBAMa,WAAW;;qBAGX,eAAe;;qBAGf,WAAW;;;;;qBAMX,WAAW;;qBAGX,aAAa;;qBAGb,cAAc;;iBAGV;WACN;WACA;;;;;;wBAOK,SAAS,cAAc;;wBAUvB,OAAO,OAAO,YAAY,kBAAkB;;wBAK5C,SAAS,OAAO,YAAY,SAAS;;wBAKrC,OAAO,OAAO;;wBAYd,MAAM,OAAO;;wBAMb,MAAM,OAAO;;wBAMb,QAAQ,OAAO;;;;;wBASf,eAAe;;;;;;;;;wBAaf,YAAY,OAAO,YAAY;;YAYnC;;iBAGK;WACN;WACA,MAAM;WACN;;;iBAIM;WACN,MAAM;WACN;;;iBAIM;WACN,gBAAgB;WAChB,kBAAkB;;;wBAIb,UAAU,OAAO,YAAY;;wBA8B7B,SAAS,MAAM;;wBClJf,aAAa,UAAU;;wBAKvB,iBAAiB,MAAM,MAAM,UAAU;;;;;;;;;;;;wBAoEvC,cAAc,OAAO,YAAY;;wBAyBjC,eAAe,OAAO,qBAAqB;;;;;;;;;;;;;;;;;;;;wBAqD3C,YAAY,OAAO,YAAY;;wBCjK/B,eAAe,OAAO,qBAAqB;;;;;wBAc3C,gBAAgB,OAAO,YAAY;;;;;wBAenC,aAAa,UAAU;;;;;;;;;;wBA4CvB,UAAU,OAAO,WAAW,OAAO,QAAQ;;;;;;wBAoB3C,eAAe,OAAO,WAAW,OAAO;;;;;;;;;;;;;;;;;;wBCjFxC,SAAS,iBAAiB,WAAW,eAAe,WAAW;;qBCZlE;;qBAGA;;YAGD,eAAe;;;;;YAMf;WAAuB;WAAmB,UAAU;WAAuB,iBAAiB;;WAAuB;WAAoB,iBAAiB;;;;;;;;;;;;;wBAqHpJ,aAAa,OAAO,WAAW,OAAO,OAAO,UAAS,cAAmB;;wBAOzE,aAAa,UAAU;;;;;qBC1I1B,aAAa;;;;;qBAwBb,yBAAyB;;;;;qBAMzB,aAAa"}
package/build/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as isBuiltin, c as resourceAddress, d as typeProvider, i as copyName, l as resourceName, n as TOFU_SCHEMA, o as partName, r as VARIABLE_TYPES, s as providerAddress, t as BUILTIN_PROVIDER, u as resourceProvider } from "./layer-CS1ZZFFP.js";
2
- import { A as localAddress, B as isObject, C as resourceCycles, D as copyResources, E as copyResourceName, F as TYPE_FORM, G as renderValue, H as pathText, I as VERSION_FORM, K as valueUses, L as escapeTemplate, M as PATH_FORM, N as PROVIDER_FORM, O as groupFaults, P as SOURCE_FORM, R as isForm, S as neededParts, T as resourcesByPart, U as refOf, V as paramOf, W as refParts, _ as isZeroOrMore, a as checkTofu, b as dependsOn, c as PLANNED_OVER, d as UNKNOWN_COSTS, f as accountKey, g as evaluateCost, h as costSpace, i as TOFU_CODES, j as NAME_FORM, k as layerResources, l as PLANNED_ROOM, m as budgetsByPart, n as PROVIDER_META, o as COST_LAYER_KEY, p as accountStates, q as varOf, r as RESOURCE_META, s as PLANNED, t as joinTofu, u as PLANNED_TOTAL, v as plannedTotal, w as resourceRefs, x as firstResources, y as resourceKey, z as isList } from "./join-Ba3zzNsN.js";
2
+ import { A as localAddress, B as isObject, C as resourceCycles, D as copyResources, E as copyResourceName, F as TYPE_FORM, G as renderValue, H as pathText, I as VERSION_FORM, K as valueUses, L as escapeTemplate, M as PATH_FORM, N as PROVIDER_FORM, O as groupFaults, P as SOURCE_FORM, R as isForm, S as neededParts, T as resourcesByPart, U as refOf, V as paramOf, W as refParts, _ as isZeroOrMore, a as checkTofu, b as dependsOn, c as PLANNED_OVER, d as UNKNOWN_COSTS, f as accountKey, g as evaluateCost, h as costSpace, i as TOFU_CODES, j as NAME_FORM, k as layerResources, l as PLANNED_ROOM, m as budgetsByPart, n as PROVIDER_META, o as COST_LAYER_KEY, p as accountStates, q as varOf, r as RESOURCE_META, s as PLANNED, t as joinTofu, u as PLANNED_TOTAL, v as plannedTotal, w as resourceRefs, x as firstResources, y as resourceKey, z as isList } from "./join-Bzyt9lhB.js";
3
3
  import { checkStack } from "@mark1russell7/system-stack";
4
4
  // src/generate.ts
5
5
  /** The name of the file of a document. OpenTofu reads each file with the end `.tf.json` as its JSON syntax. */
@@ -1,6 +1,6 @@
1
1
  import { a as isBuiltin, c as resourceAddress, d as typeProvider, i as copyName, l as resourceName, n as TOFU_SCHEMA, s as providerAddress, t as BUILTIN_PROVIDER, u as resourceProvider } from "./layer-CS1ZZFFP.js";
2
2
  import { stronglyConnectedComponents } from "@mark1russell7/collections/graph";
3
- import { joinRecords, joinSetting, partNeeds, partsById } from "@mark1russell7/system-stack";
3
+ import { joinRecords, joinSetting, neededParts, neededParts as neededParts$1, partNeeds, partsById } from "@mark1russell7/system-stack";
4
4
  import { app, axes, each, evaluate, lit, ref, space } from "@mark1russell7/vex";
5
5
  import { BoolDomain, NumDomain, TextDomain } from "@mark1russell7/vex-domains";
6
6
  // src/values.ts
@@ -419,13 +419,6 @@ function walkNeeds(parts, from, stop) {
419
419
  return found;
420
420
  }
421
421
  /**
422
- * This function gives the `id` of each part that a part needs, directly or through other parts.
423
- * The part itself is not in the result. A need that names no part of the stack is in the result.
424
- */
425
- function neededParts(stack, part) {
426
- return new Set(walkNeeds(partsById(stack), part, () => false));
427
- }
428
- /**
429
422
  * This function gives the dependencies of each resource that come from the needs of the stack, by the address of the resource.
430
423
  *
431
424
  * - A resource depends on the resources of each part that its part needs.
@@ -819,7 +812,7 @@ function checkTofu(layer, stack, options = {}) {
819
812
  else if (builtin) {
820
813
  if (resource.cost !== void 0 && resource.cost > 0) error("cost-builtin", at, `The resource "${at}" is a part of OpenTofu, and its record has a planned cost of ${money(resource.cost)}. It counts against no account.`, more);
821
814
  } else if (resource.cost === void 0) error("cost-none", at, `The resource "${at}" has no planned cost. A cost that is not known is not 0: give the cost of a month, or 0 for a resource with no price.`, more);
822
- if (provider !== void 0 && provider.part !== resource.part && parts.has(resource.part) && parts.has(provider.part) && !neededParts(stack, resource.part).has(provider.part)) add("warning", "provider-need", at, `The resource "${at}" makes the part "${resource.part}" with the provider configuration of "${provider.part}", and "${resource.part}" does not need "${provider.part}" in the stack.`, {
815
+ if (provider !== void 0 && provider.part !== resource.part && parts.has(resource.part) && parts.has(provider.part) && !neededParts$1(stack, resource.part).has(provider.part)) add("warning", "provider-need", at, `The resource "${at}" makes the part "${resource.part}" with the provider configuration of "${provider.part}", and "${resource.part}" does not need "${provider.part}" in the stack.`, {
823
816
  ...more,
824
817
  other: provider.part
825
818
  });
@@ -904,4 +897,4 @@ function joinTofu(pieces) {
904
897
  }
905
898
  export { localAddress as A, isObject as B, resourceCycles as C, copyResources as D, copyResourceName as E, TYPE_FORM as F, renderValue as G, pathText as H, VERSION_FORM as I, valueUses as K, escapeTemplate as L, PATH_FORM as M, PROVIDER_FORM as N, groupFaults as O, SOURCE_FORM as P, isForm as R, neededParts as S, resourcesByPart as T, refOf as U, paramOf as V, refParts as W, isZeroOrMore as _, checkTofu as a, dependsOn as b, PLANNED_OVER as c, UNKNOWN_COSTS as d, accountKey as f, evaluateCost as g, costSpace as h, TOFU_CODES as i, NAME_FORM as j, layerResources as k, PLANNED_ROOM as l, budgetsByPart as m, PROVIDER_META as n, COST_LAYER_KEY as o, accountStates as p, varOf as q, RESOURCE_META as r, PLANNED as s, joinTofu as t, PLANNED_TOTAL as u, plannedTotal as v, resourceRefs as w, firstResources as x, resourceKey as y, isList as z };
906
899
 
907
- //# sourceMappingURL=join-Ba3zzNsN.js.map
900
+ //# sourceMappingURL=join-Bzyt9lhB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"join-Bzyt9lhB.js","names":["neededParts"],"sources":["../src/values.ts","../src/groups.ts","../src/queries.ts","../src/cost.ts","../src/check.ts","../src/join.ts"],"sourcesContent":["import type { TofuObject, TofuValue } from \"./layer.ts\";\n\n// The forms of a value, and the text of each value in the files.\n// In the JSON syntax of OpenTofu, each text is a template. Thus the generator escapes each text of a record.\n\n/** The form of the type of a resource and of the type of a backend. */\nexport const TYPE_FORM: RegExp = /^[a-z][a-z0-9_]*$/;\n\n/** The form of the local name of a provider, for example `example` or `example-beta`. */\nexport const PROVIDER_FORM: RegExp = /^[a-z][a-z0-9_-]*$/;\n\n/** The form of a name in the files: the name of a resource, of a variable, of an alias and of an argument. */\nexport const NAME_FORM: RegExp = /^[A-Za-z_][A-Za-z0-9_-]*$/;\n\n/**\n * The form of a path of attributes, for example `network[0].address` or `metadata[\"ssh-keys\"]`. A key of a map in quotes has\n * letters, digits and the characters `_ . : / -` only. Thus a path holds no template sequence and no quote of its own.\n */\nexport const PATH_FORM: RegExp = /^[A-Za-z_][A-Za-z0-9_-]*(\\.[A-Za-z_][A-Za-z0-9_-]*|\\[[0-9]+\\]|\\[\"[A-Za-z0-9_.:/-]+\"\\])*$/;\n\n/** The form of the address of a provider in a registry: two or three words with `/` between them. */\nexport const SOURCE_FORM: RegExp = /^[a-z0-9][a-z0-9.-]*(\\/[a-z0-9][a-z0-9_-]*){1,2}$/;\n\n/** The form of a list of versions, for example `>= 1.8, < 2.0`. */\nexport const VERSION_FORM: RegExp = /^[0-9A-Za-z .,<>=~!+-]+$/;\n\n/** The parts of a reference: the address of a resource, and a path of attributes of it. */\nexport interface RefParts {\n readonly address: string;\n readonly attribute: string;\n}\n\n/**\n * This function gives the parts of the text of a reference, for example `example_server.web.address`.\n * It gives `undefined` for a text with a different form.\n */\nexport function refParts(ref: string): RefParts | undefined {\n const [type, name, ...rest] = ref.split(\".\");\n if (type === undefined || name === undefined || rest.length === 0) return undefined;\n // An index stays with the word before it, so the name of the resource can not have one.\n const attribute = rest.join(\".\");\n if (!TYPE_FORM.test(type) || !NAME_FORM.test(name) || !PATH_FORM.test(attribute)) return undefined;\n return { address: `${type}.${name}`, attribute };\n}\n\n/** This function tells if a value is a list. */\nexport function isList(value: TofuValue): value is readonly TofuValue[] {\n return Array.isArray(value);\n}\n\n/** This function tells if a value is an object of values. A list and `null` are not objects. */\nexport function isObject(value: TofuValue): value is TofuObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** This function tells if an object has a key that starts with `$`: the object is a form, not a map of arguments. */\nexport function isForm(value: TofuObject): boolean {\n return Object.keys(value).some((key) => key.startsWith(\"$\"));\n}\n\n/** This function gives the one value of a form with the one key `key`, when that value is a text. */\nfunction formText(value: TofuObject, key: string): string | undefined {\n const keys = Object.keys(value);\n const text = value[key];\n return keys.length === 1 && keys[0] === key && typeof text === \"string\" ? text : undefined;\n}\n\n/** This function gives the text of a correct reference form, `{ \"$ref\": \"type.name.attribute\" }`. */\nexport function refOf(value: TofuObject): string | undefined {\n const text = formText(value, \"$ref\");\n return text !== undefined && refParts(text) !== undefined ? text : undefined;\n}\n\n/** This function gives the name of a correct variable form, `{ \"$var\": \"name\" }`. */\nexport function varOf(value: TofuObject): string | undefined {\n const text = formText(value, \"$var\");\n return text !== undefined && NAME_FORM.test(text) ? text : undefined;\n}\n\n/** This function gives the name of a correct parameter form, `{ \"$param\": \"name\" }`. Only a resource of a group can have one. */\nexport function paramOf(value: TofuObject): string | undefined {\n const text = formText(value, \"$param\");\n return text !== undefined && NAME_FORM.test(text) ? text : undefined;\n}\n\n/**\n * This function escapes the template sequences of a text. OpenTofu then reads the text as it is in the record.\n * `$${` is the escape of `${`, and `%%{` is the escape of `%{`.\n */\nexport function escapeTemplate(text: string): string {\n // A function gives each replacement: in a replacement text, `$$` is the escape of one `$`.\n return text.replaceAll(\"${\", () => \"$${\").replaceAll(\"%{\", () => \"%%{\");\n}\n\n/**\n * This function gives a value as OpenTofu reads it in a JSON file.\n *\n * - A text and each key of an object are escaped.\n * - A reference form becomes the expression of the attribute, and a variable form the expression of the variable.\n *\n * A form that is not correct stays an object with an escaped key. The gate `checkTofu` refuses such a layer.\n */\nexport function renderValue(value: TofuValue): TofuValue {\n if (typeof value === \"string\") return escapeTemplate(value);\n if (isList(value)) return value.map(renderValue);\n if (!isObject(value)) return value;\n const ref = refOf(value);\n if (ref !== undefined) return `\\${${ref}}`;\n const variable = varOf(value);\n if (variable !== undefined) return `\\${var.${variable}}`;\n return Object.fromEntries(Object.entries(value).map(([key, item]) => [escapeTemplate(key), renderValue(item)]));\n}\n\n/** A place in a value: the keys and the positions from the value to the place. */\nexport type ValuePath = readonly (string | number)[];\n\n/** A form of a value, with its place. `text` is absent when the form is not correct. */\nexport interface FormUse {\n readonly kind: \"ref\" | \"var\" | \"bad\";\n readonly path: ValuePath;\n readonly text?: string | undefined;\n}\n\n/** One number of a value that is not finite, with its place. */\nexport interface NumberUse {\n readonly path: ValuePath;\n readonly value: number;\n}\n\n/** The forms and the numbers that are not finite of a value. */\nexport interface ValueUses {\n readonly forms: readonly FormUse[];\n readonly numbers: readonly NumberUse[];\n}\n\n/** This function gives each form of a value and each number that is not finite, in the sequence of the value. */\nexport function valueUses(value: TofuValue): ValueUses {\n const forms: FormUse[] = [];\n const numbers: NumberUse[] = [];\n const walk = (item: TofuValue, path: ValuePath): void => {\n if (typeof item === \"number\") {\n if (!Number.isFinite(item)) numbers.push({ path, value: item });\n return;\n }\n if (isList(item)) {\n item.forEach((child, index) => {\n walk(child, [...path, index]);\n });\n return;\n }\n if (!isObject(item)) return;\n if (isForm(item)) {\n const ref = refOf(item);\n const variable = varOf(item);\n if (ref !== undefined) forms.push({ kind: \"ref\", path, text: ref });\n else if (variable !== undefined) forms.push({ kind: \"var\", path, text: variable });\n else forms.push({ kind: \"bad\", path });\n return;\n }\n for (const [key, child] of Object.entries(item)) walk(child, [...path, key]);\n };\n walk(value, []);\n return { forms, numbers };\n}\n\n/** This function gives a place in a value as a text, for example `disk.0.size`. The place of the value is `(the value)`. */\nexport function pathText(path: ValuePath): string {\n return path.length === 0 ? \"(the value)\" : path.join(\".\");\n}\n","import type { TofuFault } from \"./check.ts\";\nimport {\n BUILTIN_PROVIDER,\n copyName,\n resourceAddress,\n typeProvider,\n type Copy,\n type Group,\n type GroupResource,\n type Resource,\n type TofuLayer,\n type TofuObject,\n type TofuValue,\n} from \"./layer.ts\";\nimport { isForm, isList, isObject, NAME_FORM, paramOf, pathText, refOf, refParts, type ValuePath } from \"./values.ts\";\n\n// The groups of resources and their copies. The resources of a copy are a view of its group. Each function of the package\n// reads the resources of a layer through `layerResources`, so each gate, each query and the files cover the copies.\n\n/** This function gives the local address of a resource of a group: its type, a point and its local name. */\nexport function localAddress(resource: GroupResource): string {\n return `${resource.type}.${resource.name}`;\n}\n\n/** This function gives the name in the files of a resource of a copy: the name of the copy, `_` and the local name. */\nexport function copyResourceName(copy: Copy, resource: GroupResource): string {\n return `${copyName(copy)}_${resource.name}`;\n}\n\n/** This function gives the provider name of the address of a provider configuration: the word before the point. */\nfunction providerName(address: string): string {\n const end = address.indexOf(\".\");\n return end === -1 ? address : address.slice(0, end);\n}\n\n/** This function tells if a resource of a group is a part of OpenTofu, with no provider configuration. */\nfunction isBuiltinMember(resource: GroupResource): boolean {\n return resource.provider === undefined && typeProvider(resource.type) === BUILTIN_PROVIDER;\n}\n\n/** This function gives the value of each parameter of a group for a copy. It gives `undefined` when a parameter has no value. */\nfunction paramValues(group: Group, copy: Copy): Map<string, TofuValue> | undefined {\n const values = new Map<string, TofuValue>();\n for (const param of group.params ?? []) {\n const value = copy.values !== undefined && Object.hasOwn(copy.values, param.name) ? copy.values[param.name] : param.default;\n if (value === undefined) return undefined;\n values.set(param.name, value);\n }\n return values;\n}\n\n/**\n * This function fills a value of a resource of a group for one copy. A parameter form becomes the value of the parameter.\n * A reference to a local address of the group becomes a reference to the resource of the copy. The value of a parameter does not change.\n */\nfunction fill(value: TofuValue, params: ReadonlyMap<string, TofuValue>, addresses: ReadonlyMap<string, string>): TofuValue {\n if (isList(value)) return value.map((item) => fill(item, params, addresses));\n if (!isObject(value)) return value;\n if (isForm(value)) {\n const param = paramOf(value);\n const given = param === undefined ? undefined : params.get(param);\n if (given !== undefined) return given;\n const ref = refOf(value);\n const parts = ref === undefined ? undefined : refParts(ref);\n const address = parts === undefined ? undefined : addresses.get(parts.address);\n return parts !== undefined && address !== undefined ? { $ref: `${address}.${parts.attribute}` } : value;\n }\n return fillObject(value, params, addresses);\n}\n\n/** This function fills each argument of an object. The object itself is not a form, also when it has a key that starts with `$`. */\nfunction fillObject(values: TofuObject, params: ReadonlyMap<string, TofuValue>, addresses: ReadonlyMap<string, string>): TofuObject {\n return Object.fromEntries(Object.entries(values).map(([key, item]) => [key, fill(item, params, addresses)]));\n}\n\n/** This function gives the provider configuration of a resource of a copy. A configuration of the copy with the same provider name replaces that of the group. */\nfunction copyProvider(copy: Copy, resource: GroupResource): string | undefined {\n if (isBuiltinMember(resource)) return undefined;\n const name = providerName(resource.provider ?? typeProvider(resource.type));\n return copy.providers?.find((address) => providerName(address) === name) ?? resource.provider;\n}\n\n/**\n * This function gives the resources of the copies of a layer, in the sequence of the copies and of the resources of each group.\n *\n * - A resource of a copy makes the part of the copy. Its name is the name of the copy, `_` and its local name.\n * - A parameter form becomes the value of the copy, or the default of the parameter.\n * - A reference to a local address of the group reads the resource of the same copy.\n * - A configuration of the copy replaces the configuration of the same provider name.\n *\n * A copy whose group the layer does not have, or that gives no value for a parameter with no default, makes no resource.\n * For two groups with one name, the copies use the first one. The gate `checkTofu` gives a fault for each such record.\n */\nexport function copyResources(layer: TofuLayer): Resource[] {\n const groups = new Map<string, Group>();\n for (const group of layer.groups ?? []) if (!groups.has(group.name)) groups.set(group.name, group);\n return (layer.copies ?? []).flatMap((copy) => {\n const group = groups.get(copy.group);\n const params = group === undefined ? undefined : paramValues(group, copy);\n if (group === undefined || params === undefined) return [];\n const addresses = new Map(group.resources.map((resource) => [localAddress(resource), `${resource.type}.${copyResourceName(copy, resource)}`]));\n return group.resources.map((resource): Resource => {\n const provider = copyProvider(copy, resource);\n return {\n part: copy.part,\n type: resource.type,\n name: copyResourceName(copy, resource),\n ...(provider === undefined ? {} : { provider }),\n ...(resource.values === undefined ? {} : { values: fillObject(resource.values, params, addresses) }),\n ...(resource.cost === undefined ? {} : { cost: resource.cost }),\n ...(resource.keep === undefined ? {} : { keep: resource.keep }),\n ...(resource.ignore === undefined ? {} : { ignore: resource.ignore }),\n };\n });\n });\n}\n\n/** This function gives each resource of a layer: the resources of the field `resources`, and then the resources of the copies. */\nexport function layerResources(layer: TofuLayer): readonly Resource[] {\n return (layer.copies ?? []).length === 0 ? layer.resources : [...layer.resources, ...copyResources(layer)];\n}\n\n/** One parameter form of a value, with its place. */\ninterface ParamUse {\n readonly name: string;\n readonly path: ValuePath;\n}\n\n/** This function gives each correct parameter form of the arguments of a record, in the sequence of the arguments. */\nfunction paramUses(values: TofuObject): ParamUse[] {\n const uses: ParamUse[] = [];\n const walk = (item: TofuValue, path: ValuePath): void => {\n if (isList(item)) {\n item.forEach((child, index) => {\n walk(child, [...path, index]);\n });\n return;\n }\n if (!isObject(item)) return;\n const name = isForm(item) ? paramOf(item) : undefined;\n if (name !== undefined) uses.push({ name, path });\n else if (!isForm(item)) for (const [key, child] of Object.entries(item)) walk(child, [...path, key]);\n };\n for (const [key, child] of Object.entries(values)) walk(child, [key]);\n return uses;\n}\n\n/** This function gives a list of names for a message, for example `\"a\", \"b\"`. */\nfunction quoted(items: readonly string[]): string {\n return items.map((item) => `\"${item}\"`).join(\", \");\n}\n\n/**\n * This function gives the faults of the groups and of the copies of a layer. `checkTofu` gives them with its other faults.\n * The resources of the copies get the faults of each resource there: the gate examines them as resources.\n *\n * The errors:\n * - `group-form`: the name of a group, of a parameter or of a copy does not have the form of a name. Or a group has no resource.\n * - `group-duplicate`: two groups, two parameters of a group, two resources of a group with one local address, or two copies have one name.\n * - `group-shadow`: a local address of a group is the address of a resource of the layer. A reference in the group then reads the copy.\n * - `group-none`: a copy names a group that the layer does not have.\n * - `param-none`: a parameter form of a group names a parameter that the group does not have.\n * - `param-missing`: a copy gives no value for a parameter with no default.\n * - `param-unknown`: a copy gives a value for a parameter that the group does not have.\n * - `copy-provider`: a configuration of a copy replaces no configuration of the group, or two of them have one provider name.\n * A configuration that the layer does not have gives `provider-none` at each resource of the copy.\n *\n * The warnings:\n * - `group-unused`: no copy names a group.\n * - `param-unused`: no resource of a group reads a parameter.\n */\nexport function groupFaults(layer: TofuLayer): TofuFault[] {\n const faults: TofuFault[] = [];\n const add = (level: TofuFault[\"level\"], code: TofuFault[\"code\"], at: string, message: string, more: { readonly other?: string; readonly part?: string } = {}): void => {\n faults.push({ level, code, at, message, ...more });\n };\n const top = new Set(layer.resources.map(resourceAddress));\n const groups = new Map<string, Group>();\n for (const group of layer.groups ?? []) {\n const at = `group.${group.name}`;\n if (groups.has(group.name)) {\n add(\"error\", \"group-duplicate\", at, `Two groups have the name \"${group.name}\".`);\n continue;\n }\n groups.set(group.name, group);\n if (!NAME_FORM.test(group.name)) add(\"error\", \"group-form\", at, `The name \"${group.name}\" of a group does not have the form of a name.`);\n if (group.resources.length === 0) add(\"error\", \"group-form\", at, `The group \"${group.name}\" has no resource.`);\n const params = new Set<string>();\n for (const param of group.params ?? []) {\n if (params.has(param.name)) add(\"error\", \"group-duplicate\", at, `Two parameters of the group \"${group.name}\" have the name \"${param.name}\".`);\n else if (!NAME_FORM.test(param.name)) add(\"error\", \"group-form\", at, `The name \"${param.name}\" of a parameter of the group \"${group.name}\" does not have the form of a name.`);\n params.add(param.name);\n }\n const locals = new Set<string>();\n const read = new Set<string>();\n for (const resource of group.resources) {\n const local = localAddress(resource);\n if (locals.has(local)) add(\"error\", \"group-duplicate\", at, `Two resources of the group \"${group.name}\" have the local address \"${local}\".`);\n locals.add(local);\n if (top.has(local)) {\n add(\"error\", \"group-shadow\", at, `The group \"${group.name}\" has the local address \"${local}\", and the layer has a resource with that address. A reference in the group reads the resource of the copy.`, {\n other: local,\n });\n }\n for (const use of paramUses(resource.values ?? {})) {\n if (params.has(use.name)) read.add(use.name);\n else add(\"error\", \"param-none\", at, `The value at \"${pathText(use.path)}\" of the resource \"${local}\" of the group \"${group.name}\" names the parameter \"${use.name}\", which the group does not have.`);\n }\n }\n for (const name of params) {\n if (!read.has(name)) add(\"warning\", \"param-unused\", at, `No resource of the group \"${group.name}\" reads the parameter \"${name}\".`);\n }\n }\n\n const copies = new Set<string>();\n const copied = new Set<string>();\n for (const copy of layer.copies ?? []) {\n const name = copyName(copy);\n const at = `copy.${name}`;\n const more = { part: copy.part };\n if (copies.has(name)) {\n add(\"error\", \"group-duplicate\", at, `Two copies have the name \"${name}\".`, more);\n continue;\n }\n copies.add(name);\n if (!NAME_FORM.test(name)) add(\"error\", \"group-form\", at, `The name \"${name}\" of a copy does not have the form of a name.`, more);\n const group = groups.get(copy.group);\n if (group === undefined) {\n add(\"error\", \"group-none\", at, `The copy \"${name}\" names the group \"${copy.group}\", which the layer does not have. It makes no resource.`, { ...more, other: `group.${copy.group}` });\n continue;\n }\n copied.add(group.name);\n const params = group.params ?? [];\n const given = Object.keys(copy.values ?? {});\n for (const key of given) {\n if (!params.some((param) => param.name === key)) add(\"error\", \"param-unknown\", at, `The copy \"${name}\" gives the parameter \"${key}\", which the group \"${group.name}\" does not have.`, more);\n }\n const missing = params.filter((param) => param.default === undefined && !given.includes(param.name)).map((param) => param.name);\n if (missing.length > 0) add(\"error\", \"param-missing\", at, `The copy \"${name}\" gives no value for the parameters ${quoted(missing)} of the group \"${group.name}\". It makes no resource.`, more);\n const used = new Set(group.resources.filter((resource) => !isBuiltinMember(resource)).map((resource) => providerName(resource.provider ?? typeProvider(resource.type))));\n const replaced = new Set<string>();\n for (const address of copy.providers ?? []) {\n const provider = providerName(address);\n if (replaced.has(provider)) {\n add(\"error\", \"copy-provider\", at, `The copy \"${name}\" has two configurations of the provider \"${provider}\". Each one replaces the configuration of its provider name.`, more);\n } else if (!used.has(provider)) {\n add(\"error\", \"copy-provider\", at, `The configuration \"${address}\" of the copy \"${name}\" replaces no configuration: no resource of the group \"${group.name}\" uses the provider \"${provider}\".`, more);\n }\n replaced.add(provider);\n }\n }\n for (const group of groups.values()) {\n if (!copied.has(group.name)) add(\"warning\", \"group-unused\", `group.${group.name}`, `No copy names the group \"${group.name}\". It makes no resource.`);\n }\n return faults;\n}\n","import { stronglyConnectedComponents } from \"@mark1russell7/collections/graph\";\nimport { partNeeds, partsById, type Part, type Stack } from \"@mark1russell7/system-stack\";\nimport { layerResources } from \"./groups.ts\";\nimport { resourceAddress, type Resource, type TofuLayer } from \"./layer.ts\";\nimport { refParts, valueUses } from \"./values.ts\";\n\n// The queries over the records. The sequence of the resources in the files comes from the needs of the stack,\n// so a person writes each dependence one time: in the stack.\n\n/** This function gives the first resource of each address of a layer, in the sequence of the records. The resources of the copies come last. */\nexport function firstResources(layer: TofuLayer): readonly Resource[] {\n const seen = new Set<string>();\n return layerResources(layer).filter((resource) => {\n const address = resourceAddress(resource);\n if (seen.has(address)) return false;\n seen.add(address);\n return true;\n });\n}\n\n/**\n * This function gives the addresses of the resources of each part, by the `id` of the part.\n * The addresses of a part are sorted. With them, a host joins a plan or a state to the parts of the stack.\n */\nexport function resourcesByPart(layer: TofuLayer): Map<string, string[]> {\n const byPart = new Map<string, string[]>();\n for (const resource of firstResources(layer)) {\n const addresses = byPart.get(resource.part) ?? [];\n addresses.push(resourceAddress(resource));\n byPart.set(resource.part, addresses);\n }\n for (const addresses of byPart.values()) addresses.sort();\n return byPart;\n}\n\n/**\n * This function gives the address of each resource that the arguments of a resource read, sorted.\n * Each address comes one time. An address can name a resource that the layer does not have.\n */\nexport function resourceRefs(resource: Resource): string[] {\n const addresses = new Set<string>();\n for (const form of valueUses(resource.values ?? {}).forms) {\n // The arguments as a whole are not a value, so a form at the empty place reads nothing.\n const parts = form.kind === \"ref\" && form.text !== undefined && form.path.length > 0 ? refParts(form.text) : undefined;\n if (parts !== undefined) addresses.add(parts.address);\n }\n return [...addresses].sort();\n}\n\n/**\n * This function walks the needs of a part, nearest first. It gives the `id` of each part where the walk stops or goes on.\n * The walk does not go past a part for which `stop` gives `true`. It does not come back to the first part.\n */\nfunction walkNeeds(parts: ReadonlyMap<string, Part>, from: string, stop: (id: string) => boolean): string[] {\n const seen = new Set<string>([from]);\n const found: string[] = [];\n let level = partNeeds(parts.get(from) ?? { id: from, kind: \"\" });\n while (level.length > 0) {\n const next: string[] = [];\n for (const id of level) {\n if (seen.has(id)) continue;\n seen.add(id);\n found.push(id);\n const part = parts.get(id);\n if (part !== undefined && !stop(id)) next.push(...partNeeds(part));\n }\n level = next;\n }\n return found;\n}\n\n// The core has `neededParts` since system-stack 0.1.6. This entry gives it again, so the API of the package does not change.\nexport { neededParts } from \"@mark1russell7/system-stack\";\n\n/**\n * This function gives the dependencies of each resource that come from the needs of the stack, by the address of the resource.\n *\n * - A resource depends on the resources of each part that its part needs.\n * - For a needed part with no resource, the walk goes on to the needs of that part. It stops at the nearest parts with resources.\n * - An address that the arguments of the resource read is not in the list: OpenTofu knows that dependence from the arguments.\n *\n * The addresses of a resource are sorted. The generator writes them as `depends_on`.\n */\nexport function dependsOn(layer: TofuLayer, stack: Stack): Map<string, string[]> {\n const parts = partsById(stack);\n const byPart = resourcesByPart(layer);\n const result = new Map<string, string[]>();\n for (const resource of firstResources(layer)) {\n const read = new Set(resourceRefs(resource));\n const addresses = walkNeeds(parts, resource.part, (id) => byPart.has(id)).flatMap((id) => byPart.get(id) ?? []);\n result.set(\n resourceAddress(resource),\n addresses.filter((address) => !read.has(address)).sort(),\n );\n }\n return result;\n}\n\n/**\n * This function gives the cycles of the resources of a layer. In a cycle, each resource waits for a different one, and OpenTofu can make none of them.\n * A resource waits for each resource that its arguments read, and for each one of `dependsOn`.\n * Each cycle is a sorted list of addresses. A resource that reads its own attribute is a cycle of one resource.\n */\nexport function resourceCycles(layer: TofuLayer, stack: Stack): string[][] {\n const depends = dependsOn(layer, stack);\n const waits = new Map<string, string[]>();\n for (const resource of firstResources(layer)) {\n const address = resourceAddress(resource);\n waits.set(address, [...resourceRefs(resource), ...(depends.get(address) ?? [])]);\n }\n const nodes = [...waits.keys()].sort();\n return stronglyConnectedComponents(nodes, (address) => waits.get(address) ?? []).filter((component) => {\n const [only = \"\"] = component;\n return component.length > 1 || (waits.get(only) ?? []).includes(only);\n });\n}\n","import { app, axes, each, evaluate, lit, ref, space, type Expr, type Result, type Space } from \"@mark1russell7/vex\";\nimport { BoolDomain, NumDomain, TextDomain } from \"@mark1russell7/vex-domains\";\nimport { isBuiltin, resourceAddress, resourceProvider, type TofuLayer } from \"./layer.ts\";\nimport { firstResources } from \"./queries.ts\";\n\n// The planned cost of the resources, as Vex programs. A program is data: `explain` of Vex shows each step.\n// The layer becomes a tree: the layer, then each account, then each resource of the account.\n\n/**\n * The limit of the cost of a part for a month. A state of a service of the spend add-on has this form.\n * Thus a host gives the states of a spend layer as the budgets, and the two add-ons do not know each other.\n */\nexport interface Budget {\n /** The `id` of the part: an account, a project or a tenant. */\n readonly part: string;\n /** The hard limit of the cost of the part for a month. A part with no hard limit has none. */\n readonly hardLimit?: number | undefined;\n}\n\n/** The key of the layer node: the root of the cost tree. */\nexport const COST_LAYER_KEY = \"layer\";\n\n/** This function gives the key of the node of an account: the text `account:` and the `id` of its part. */\nexport function accountKey(part: string): string {\n return `account:${part}`;\n}\n\n/** This function gives the key of the node of a resource: the text `resource:` and its address. */\nexport function resourceKey(address: string): string {\n return `resource:${address}`;\n}\n\n/** This function tells if a value is a finite number, 0 or more. */\nexport function isZeroOrMore(value: number): boolean {\n return Number.isFinite(value) && value >= 0;\n}\n\n/** This function gives the first budget of each part, by the `id` of the part. */\nexport function budgetsByPart(budgets: readonly Budget[]): Map<string, Budget> {\n const byPart = new Map<string, Budget>();\n for (const budget of budgets) if (!byPart.has(budget.part)) byPart.set(budget.part, budget);\n return byPart;\n}\n\n/** The planned cost of each resource of an account. A resource with no known cost gives an error value. */\nconst COSTS: Expr = each(axes.children, ref(\"cost\"));\n\n/** The planned cost of an account in a month: the sum of the known costs of its resources. The program evaluates at an account node. */\nexport const PLANNED: Expr = app(\"sum\", COSTS);\n\n/** This test tells if a resource node has a known cost. */\nconst HAS_COST: Expr = app(\"ifError\", app(\"eq\", ref(\"cost\"), ref(\"cost\")), lit(false));\n\n/** The count of the resources of an account with no known cost. The program evaluates at an account node. */\nexport const UNKNOWN_COSTS: Expr = app(\"count\", each(axes.where(axes.children, app(\"not\", HAS_COST)), ref(\"kind\")));\n\n/** This test tells if the planned cost of an account is more than its hard limit. An account with no hard limit gives an error value. */\nexport const PLANNED_OVER: Expr = app(\"gt\", PLANNED, ref(\"limit\"));\n\n/** The room of an account: its hard limit less its planned cost. An account with no hard limit gives an error value. */\nexport const PLANNED_ROOM: Expr = app(\"subtract\", ref(\"limit\"), PLANNED);\n\n/** The planned cost of the layer in a month: the sum of the planned costs of its accounts. The program evaluates at the layer node. */\nexport const PLANNED_TOTAL: Expr = app(\"sum\", each(axes.children, PLANNED));\n\n/**\n * This function gives the cost tree of a layer, as a space of Vex.\n *\n * - The layer is the root, with the key `COST_LAYER_KEY`.\n * - An account is a child of the layer: the part of a provider configuration that has one resource or more. Its field `limit` is its hard limit.\n * - A resource is a child of the account of its provider configuration. Its field `cost` is its planned cost.\n *\n * A cost or a limit that is less than 0 or not finite is not in the tree: it is not known.\n * A resource with no provider configuration is not in the tree, because it counts against no account.\n */\nexport function costSpace(layer: TofuLayer, budgets: readonly Budget[] = []): Space {\n const limits = budgetsByPart(budgets);\n const records: Record<string, Readonly<Record<string, unknown>>> = { [COST_LAYER_KEY]: { kind: \"layer\" } };\n const parents: Record<string, string | null> = { [COST_LAYER_KEY]: null };\n for (const resource of firstResources(layer)) {\n const provider = isBuiltin(resource) ? undefined : resourceProvider(layer, resource);\n if (provider === undefined) continue;\n const account = accountKey(provider.part);\n if (records[account] === undefined) {\n const limit = limits.get(provider.part)?.hardLimit;\n records[account] = { kind: \"account\", part: provider.part, ...(limit !== undefined && isZeroOrMore(limit) ? { limit } : {}) };\n parents[account] = COST_LAYER_KEY;\n }\n const key = resourceKey(resourceAddress(resource));\n records[key] = { kind: \"resource\", ...(resource.cost !== undefined && isZeroOrMore(resource.cost) ? { cost: resource.cost } : {}) };\n parents[key] = account;\n }\n return space.tree(records, parents);\n}\n\n/**\n * This function evaluates a program of this module at a node of a cost tree. It gives the value, or the error value.\n * `tree` is the result of `costSpace`, and `key` is the key of a node.\n */\nexport function evaluateCost(program: Expr, tree: Space, key: string): Result<unknown> {\n return evaluate(program, { space: tree, origin: key, domains: [NumDomain, BoolDomain, TextDomain] });\n}\n\n/** This function gives the number of a result, or `undefined` for an error value. */\nfunction numberOf(result: Result<unknown>): number | undefined {\n return result.ok && typeof result.value === \"number\" ? result.value : undefined;\n}\n\n/** The state of the planned cost of one account of a layer. */\nexport interface AccountState {\n /** The `id` of the part of the account. */\n readonly part: string;\n /** The addresses of the resources that count against the account, sorted. */\n readonly resources: readonly string[];\n /** The planned cost of the account in a month: the sum of the known costs of its resources. */\n readonly planned: number;\n /** The count of the resources with no known cost. With one or more, `planned` is not the whole cost. */\n readonly unknown: number;\n /** The hard limit of the account for a month. An account with no budget, or with a budget with no hard limit, has none. */\n readonly limit?: number | undefined;\n /** `true`: the planned cost is more than the hard limit. An account with no hard limit has no value. */\n readonly over?: boolean | undefined;\n /** The hard limit less the planned cost. An account with no hard limit has no value. */\n readonly room?: number | undefined;\n}\n\n/** This function gives the state of the planned cost of each account of a layer, in the sequence of the first resource of each account. */\nexport function accountStates(layer: TofuLayer, budgets: readonly Budget[] = []): AccountState[] {\n const tree = costSpace(layer, budgets);\n const accounts = new Map<string, string[]>();\n for (const resource of firstResources(layer)) {\n const provider = isBuiltin(resource) ? undefined : resourceProvider(layer, resource);\n if (provider === undefined) continue;\n const addresses = accounts.get(provider.part) ?? [];\n addresses.push(resourceAddress(resource));\n accounts.set(provider.part, addresses);\n }\n return [...accounts].map(([part, addresses]) => {\n const key = accountKey(part);\n const limit = numberOf(evaluateCost(ref(\"limit\"), tree, key));\n const over = evaluateCost(PLANNED_OVER, tree, key);\n const room = numberOf(evaluateCost(PLANNED_ROOM, tree, key));\n return {\n part,\n resources: [...addresses].sort(),\n planned: numberOf(evaluateCost(PLANNED, tree, key)) ?? 0,\n unknown: numberOf(evaluateCost(UNKNOWN_COSTS, tree, key)) ?? 0,\n ...(limit === undefined ? {} : { limit }),\n ...(over.ok && typeof over.value === \"boolean\" ? { over: over.value } : {}),\n ...(room === undefined ? {} : { room }),\n };\n });\n}\n\n/** This function gives the planned cost of a layer in a month: the sum of the planned costs of its accounts. */\nexport function plannedTotal(layer: TofuLayer): number {\n return numberOf(evaluateCost(PLANNED_TOTAL, costSpace(layer), COST_LAYER_KEY)) ?? 0;\n}\n","import { neededParts, partsById, type Fault, type FaultLevel, type Stack } from \"@mark1russell7/system-stack\";\nimport { accountStates, isZeroOrMore, type Budget } from \"./cost.ts\";\nimport { BUILTIN_PROVIDER, isBuiltin, providerAddress, resourceAddress, resourceName, resourceProvider, typeProvider, type Provider, type TofuLayer, type TofuObject } from \"./layer.ts\";\nimport { groupFaults, layerResources } from \"./groups.ts\";\nimport { firstResources, resourceCycles } from \"./queries.ts\";\nimport { isForm, NAME_FORM, PATH_FORM, pathText, PROVIDER_FORM, refParts, SOURCE_FORM, TYPE_FORM, valueUses, VERSION_FORM } from \"./values.ts\";\n\n// The gate of the OpenTofu layer. A gate that passes tells that the files are safe to write:\n// each record has a correct form, no resource waits in a cycle, and the planned cost of each account is known and not more than its hard limit.\n\n/** These are the codes of the faults of an OpenTofu layer. */\nexport const TOFU_CODES: readonly [\n \"version\",\n \"backend\",\n \"variable-form\",\n \"variable-duplicate\",\n \"provider-form\",\n \"provider-duplicate\",\n \"provider-source\",\n \"provider-part\",\n \"provider-value\",\n \"resource-form\",\n \"resource-duplicate\",\n \"resource-part\",\n \"provider-none\",\n \"ignore-form\",\n \"value-name\",\n \"value-meta\",\n \"value-form\",\n \"value-number\",\n \"ref-none\",\n \"var-none\",\n \"cycle\",\n \"cost-amount\",\n \"cost-none\",\n \"cost-builtin\",\n \"budget-duplicate\",\n \"budget-amount\",\n \"budget-none\",\n \"limit-none\",\n \"cost-over\",\n \"provider-need\",\n \"variable-unused\",\n \"group-form\",\n \"group-duplicate\",\n \"group-shadow\",\n \"group-none\",\n \"param-none\",\n \"param-missing\",\n \"param-unknown\",\n \"copy-provider\",\n \"group-unused\",\n \"param-unused\",\n] = [\n \"version\",\n \"backend\",\n \"variable-form\",\n \"variable-duplicate\",\n \"provider-form\",\n \"provider-duplicate\",\n \"provider-source\",\n \"provider-part\",\n \"provider-value\",\n \"resource-form\",\n \"resource-duplicate\",\n \"resource-part\",\n \"provider-none\",\n \"ignore-form\",\n \"value-name\",\n \"value-meta\",\n \"value-form\",\n \"value-number\",\n \"ref-none\",\n \"var-none\",\n \"cycle\",\n \"cost-amount\",\n \"cost-none\",\n \"cost-builtin\",\n \"budget-duplicate\",\n \"budget-amount\",\n \"budget-none\",\n \"limit-none\",\n \"cost-over\",\n \"provider-need\",\n \"variable-unused\",\n \"group-form\",\n \"group-duplicate\",\n \"group-shadow\",\n \"group-none\",\n \"param-none\",\n \"param-missing\",\n \"param-unknown\",\n \"copy-provider\",\n \"group-unused\",\n \"param-unused\",\n];\n\n/** A code of a fault of an OpenTofu layer. */\nexport type TofuCode = (typeof TOFU_CODES)[number];\n\n/**\n * A fault of an OpenTofu layer. Its field `at` is the place of the fault in the files.\n *\n * - For a resource, `at` is its address.\n * - For a provider configuration, `at` is `provider.` and its address.\n * - For a variable, `at` is `var.` and its name.\n * - For the settings, `at` is `terraform`.\n *\n * For a fault of a budget or of an account, `at` is the `id` of the part.\n */\nexport interface TofuFault extends Fault {\n readonly code: TofuCode;\n /** The `id` of the part of the stack of the record with the fault. */\n readonly part?: string | undefined;\n}\n\n/** The options of the gate and of the generator. */\nexport interface TofuOptions {\n /**\n * The limit of the cost of each account for a month. The states of a spend layer have this form.\n * An account with resources and no budget stops the gate: the gate has no read of its limit.\n */\n readonly budgets?: readonly Budget[] | undefined;\n /** The currency of the costs and of the budgets, for the text of a fault. */\n readonly currency?: string | undefined;\n}\n\n/** These arguments of a resource are meta-arguments. The generator writes them from the records, so the arguments of a record cannot have them. */\nexport const RESOURCE_META: readonly string[] = [\"provider\", \"depends_on\", \"lifecycle\", \"count\", \"for_each\", \"provisioner\", \"connection\", \"dynamic\"];\n\n/** These arguments of a provider configuration are meta-arguments. The generator writes them from the records. */\nexport const PROVIDER_META: readonly string[] = [\"alias\", \"version\", \"for_each\"];\n\n/** This function gives a list of names for a message, for example `\"a\", \"b\"`. */\nfunction names(items: readonly string[]): string {\n return items.map((item) => `\"${item}\"`).join(\", \");\n}\n\n/**\n * This function gives each fault of an OpenTofu layer for a stack. A list with no error tells that the gate passes.\n *\n * The settings, the variables and the providers, as errors:\n * - `version`: the versions of OpenTofu do not have the form of a list of versions.\n * - `backend`: the type of the backend does not have the form of a type, or a value of the backend is not literal.\n * - `variable-form`: the name of a variable does not have the form of a name.\n * - `variable-duplicate`: two variables have one name.\n * - `provider-form`: the name, the alias, the source or the versions of a provider configuration do not have their form.\n * - `provider-duplicate`: two provider configurations have one address.\n * - `provider-source`: two configurations of one provider have different sources or versions.\n * - `provider-part`: a provider configuration names no part of the stack.\n * - `provider-value`: a value of a provider configuration reads a resource.\n *\n * The resources, as errors:\n * - `resource-form`: the type, the name or the import id of a resource does not have its form.\n * - `resource-duplicate`: two resources have one address.\n * - `resource-part`: a resource names no part of the stack.\n * - `provider-none`: the layer does not have the provider configuration of a resource.\n * - `ignore-form`: an attribute of `ignore` does not have the form of a path.\n *\n * The values, as errors:\n * - `value-name`: the name of an argument does not have the form of a name.\n * - `value-meta`: an argument is a meta-argument. The generator writes each meta-argument.\n * - `value-form`: an object has a key that starts with `$`, and it is not a correct reference or variable.\n * - `value-number`: a number is not finite. JSON cannot hold it.\n * - `ref-none`: a reference names a resource that the layer does not have.\n * - `var-none`: a value names a variable that the layer does not have.\n *\n * The queries, as errors:\n * - `cycle`: resources wait for each other, so OpenTofu can make none of them.\n *\n * The costs, as errors:\n * - `cost-amount`: the planned cost of a resource is less than 0 or not finite.\n * - `cost-none`: a resource of a provider has no planned cost. A cost that is not known is not 0.\n * - `cost-builtin`: a resource that is a part of OpenTofu has a planned cost above 0. It counts against no account.\n * - `budget-duplicate`: two budgets name one part.\n * - `budget-amount`: the hard limit of a budget is less than 0 or not finite.\n * - `budget-none`: no budget names an account with resources. The gate has no read of its limit, so it does not pass.\n * - `limit-none`: the resources of an account have a planned cost above 0, and the account has no hard limit.\n * - `cost-over`: the planned cost of an account is more than its hard limit.\n *\n * The groups and the copies, as errors: `group-form`, `group-duplicate`, `group-shadow`, `group-none`, `param-none`,\n * `param-missing`, `param-unknown` and `copy-provider`. `groupFaults` tells each one. The gate also examines each resource of\n * each copy as a resource, so a fault of a resource of a group comes at each copy.\n *\n * The warnings:\n * - `provider-need`: the part of a resource does not need the part of its provider configuration. The stack does not show that dependence.\n * - `variable-unused`: no value reads a variable.\n * - `group-unused`: no copy names a group.\n * - `param-unused`: no resource of a group reads a parameter.\n *\n * The gate does not examine the stack: `checkStack` of the core does. The function is pure.\n */\nexport function checkTofu(layer: TofuLayer, stack: Stack, options: TofuOptions = {}): TofuFault[] {\n const faults: TofuFault[] = [];\n const add = (level: FaultLevel, code: TofuCode, at: string, message: string, more: { readonly other?: string; readonly part?: string } = {}): void => {\n faults.push({ level, code, at, message, ...more });\n };\n const error = (code: TofuCode, at: string, message: string, more: { readonly other?: string; readonly part?: string } = {}): void => {\n add(\"error\", code, at, message, more);\n };\n const money = (amount: number): string => (options.currency === undefined ? String(amount) : `${String(amount)} ${options.currency}`);\n const parts = partsById(stack);\n const addresses = new Set(firstResources(layer).map(resourceAddress));\n\n const variables = new Set<string>();\n const readVariables = new Set<string>();\n for (const variable of layer.variables ?? []) {\n const at = `var.${variable.name}`;\n if (variables.has(variable.name)) {\n error(\"variable-duplicate\", at, `Two variables have the name \"${variable.name}\".`);\n continue;\n }\n variables.add(variable.name);\n if (!NAME_FORM.test(variable.name)) error(\"variable-form\", at, `The name \"${variable.name}\" of a variable does not have the form of a name.`);\n }\n\n /** This function examines the arguments of one record. `owner` is the record in words, for a message. */\n const checkValues = (values: TofuObject | undefined, at: string, owner: string, kind: \"resource\" | \"provider\" | \"backend\", meta: readonly string[], part?: string): void => {\n if (values === undefined) return;\n const more = part === undefined ? {} : { part };\n if (isForm(values)) {\n error(\"value-form\", at, `The arguments of ${owner} have a key that starts with \"$\". The arguments of a record are not a reference and not a variable.`, more);\n return;\n }\n for (const name of Object.keys(values)) {\n if (meta.includes(name)) error(\"value-meta\", at, `The argument \"${name}\" of ${owner} is a meta-argument. The generator writes it from the records.`, more);\n else if (!NAME_FORM.test(name)) error(\"value-name\", at, `The name \"${name}\" of an argument of ${owner} does not have the form of a name.`, more);\n }\n const uses = valueUses(values);\n for (const number of uses.numbers) error(\"value-number\", at, `The number ${String(number.value)} at \"${pathText(number.path)}\" of ${owner} is not finite.`, more);\n for (const form of uses.forms) {\n const place = pathText(form.path);\n if (form.kind === \"bad\" || form.text === undefined) {\n error(\"value-form\", at, `The object at \"${place}\" of ${owner} has a key that starts with \"$\", and it is not a correct reference or variable.`, more);\n } else if (kind === \"backend\") {\n error(\"backend\", at, `The value at \"${place}\" of ${owner} is not literal. A backend reads no variable and no resource.`, more);\n } else if (form.kind === \"var\") {\n if (variables.has(form.text)) readVariables.add(form.text);\n else error(\"var-none\", at, `The value at \"${place}\" of ${owner} names the variable \"${form.text}\", which the layer does not have.`, { ...more, other: `var.${form.text}` });\n } else if (kind === \"provider\") {\n error(\"provider-value\", at, `The value at \"${place}\" of ${owner} reads the resource attribute \"${form.text}\". A provider configuration reads no resource.`, more);\n } else {\n const address = refParts(form.text)?.address ?? \"\";\n if (!addresses.has(address)) error(\"ref-none\", at, `The value at \"${place}\" of ${owner} reads \"${form.text}\", and the layer has no resource \"${address}\".`, { ...more, other: address });\n }\n }\n };\n\n if (layer.version !== undefined && !VERSION_FORM.test(layer.version)) {\n error(\"version\", \"terraform\", `The versions \"${layer.version}\" of OpenTofu do not have the form of a list of versions, for example \">= 1.8\".`);\n }\n if (layer.backend !== undefined) {\n if (!TYPE_FORM.test(layer.backend.type)) error(\"backend\", \"terraform\", `The type \"${layer.backend.type}\" of the backend does not have the form of a type.`);\n checkValues(layer.backend.values, \"terraform\", \"the backend\", \"backend\", []);\n }\n\n const providers = new Set<string>();\n const firstOfName = new Map<string, Provider>();\n for (const provider of layer.providers ?? []) {\n const address = providerAddress(provider);\n const at = `provider.${address}`;\n const more = { part: provider.part };\n if (providers.has(address)) {\n error(\"provider-duplicate\", at, `Two provider configurations have the address \"${address}\".`, more);\n continue;\n }\n providers.add(address);\n if (!PROVIDER_FORM.test(provider.name)) error(\"provider-form\", at, `The name \"${provider.name}\" of a provider does not have the form of a provider name.`, more);\n else if (provider.name === BUILTIN_PROVIDER) error(\"provider-form\", at, `The provider \"${BUILTIN_PROVIDER}\" is a part of OpenTofu. It has no configuration.`, more);\n if (provider.alias !== undefined && !NAME_FORM.test(provider.alias)) error(\"provider-form\", at, `The alias \"${provider.alias}\" of the provider \"${provider.name}\" does not have the form of a name.`, more);\n if (!SOURCE_FORM.test(provider.source)) error(\"provider-form\", at, `The source \"${provider.source}\" of the provider \"${provider.name}\" does not have the form of a source, for example \"example-org/example\".`, more);\n if (provider.version !== undefined && !VERSION_FORM.test(provider.version)) {\n error(\"provider-form\", at, `The versions \"${provider.version}\" of the provider \"${provider.name}\" do not have the form of a list of versions, for example \"~> 2.0\".`, more);\n }\n const first = firstOfName.get(provider.name);\n if (first === undefined) firstOfName.set(provider.name, provider);\n else if (first.source !== provider.source || first.version !== provider.version) {\n error(\"provider-source\", at, `Two configurations of the provider \"${provider.name}\" have different sources or versions. A provider has one source and one list of versions.`, more);\n }\n if (!parts.has(provider.part)) error(\"provider-part\", at, `The provider configuration \"${address}\" names \"${provider.part}\", which is no part of the stack.`, { ...more, other: provider.part });\n checkValues(provider.values, at, `the provider configuration \"${address}\"`, \"provider\", PROVIDER_META, provider.part);\n }\n\n const seen = new Set<string>();\n for (const resource of layerResources(layer)) {\n const at = resourceAddress(resource);\n const more = { part: resource.part };\n if (seen.has(at)) {\n error(\"resource-duplicate\", at, `Two resources have the address \"${at}\".`, more);\n continue;\n }\n seen.add(at);\n if (!TYPE_FORM.test(resource.type)) error(\"resource-form\", at, `The type \"${resource.type}\" of a resource of \"${resource.part}\" does not have the form of a type.`, more);\n if (!NAME_FORM.test(resourceName(resource))) error(\"resource-form\", at, `The name \"${resourceName(resource)}\" of a resource of \"${resource.part}\" does not have the form of a name.`, more);\n if (resource.import === \"\") error(\"resource-form\", at, `The import id of the resource \"${at}\" is empty.`, more);\n if (!parts.has(resource.part)) error(\"resource-part\", at, `The resource \"${at}\" names \"${resource.part}\", which is no part of the stack.`, { ...more, other: resource.part });\n for (const path of resource.ignore ?? []) {\n if (!PATH_FORM.test(path)) error(\"ignore-form\", at, `The attribute \"${path}\" of the field \"ignore\" of the resource \"${at}\" does not have the form of a path.`, more);\n }\n checkValues(resource.values, at, `the resource \"${at}\"`, \"resource\", RESOURCE_META, resource.part);\n\n const builtin = isBuiltin(resource);\n const provider = builtin ? undefined : resourceProvider(layer, resource);\n if (!builtin && provider === undefined) {\n const wanted = resource.provider ?? typeProvider(resource.type);\n error(\"provider-none\", at, `The resource \"${at}\" uses the provider configuration \"${wanted}\", which the layer does not have.`, more);\n }\n if (resource.cost !== undefined && !isZeroOrMore(resource.cost)) {\n error(\"cost-amount\", at, `The planned cost ${String(resource.cost)} of the resource \"${at}\" is less than 0 or not finite.`, more);\n } else if (builtin) {\n if (resource.cost !== undefined && resource.cost > 0) {\n error(\"cost-builtin\", at, `The resource \"${at}\" is a part of OpenTofu, and its record has a planned cost of ${money(resource.cost)}. It counts against no account.`, more);\n }\n } else if (resource.cost === undefined) {\n error(\"cost-none\", at, `The resource \"${at}\" has no planned cost. A cost that is not known is not 0: give the cost of a month, or 0 for a resource with no price.`, more);\n }\n if (provider !== undefined && provider.part !== resource.part && parts.has(resource.part) && parts.has(provider.part) && !neededParts(stack, resource.part).has(provider.part)) {\n add(\n \"warning\",\n \"provider-need\",\n at,\n `The resource \"${at}\" makes the part \"${resource.part}\" with the provider configuration of \"${provider.part}\", and \"${resource.part}\" does not need \"${provider.part}\" in the stack.`,\n { ...more, other: provider.part },\n );\n }\n }\n faults.push(...groupFaults(layer));\n\n for (const cycle of resourceCycles(layer, stack)) {\n const [first = \"\", second] = cycle;\n const message = cycle.length === 1 ? `The resource \"${first}\" reads its own attribute, so OpenTofu cannot make it.` : `The resources ${names(cycle)} wait for each other, so OpenTofu can make none of them.`;\n error(\"cycle\", first, message, second === undefined ? {} : { other: second });\n }\n\n const budgets = options.budgets ?? [];\n const budgetParts = new Set<string>();\n const wrongBudgets = new Set<string>();\n for (const budget of budgets) {\n if (budgetParts.has(budget.part)) {\n error(\"budget-duplicate\", budget.part, `Two budgets name the part \"${budget.part}\".`, { part: budget.part });\n continue;\n }\n budgetParts.add(budget.part);\n if (budget.hardLimit !== undefined && !isZeroOrMore(budget.hardLimit)) {\n wrongBudgets.add(budget.part);\n error(\"budget-amount\", budget.part, `The hard limit ${String(budget.hardLimit)} of the budget of \"${budget.part}\" is less than 0 or not finite.`, { part: budget.part });\n }\n }\n for (const state of accountStates(layer, budgets)) {\n const at = state.part;\n const more = { part: at };\n if (!budgetParts.has(at)) {\n error(\"budget-none\", at, `The resources ${names(state.resources)} count against \"${at}\", and no budget names \"${at}\". The gate has no read of its limit.`, more);\n } else if (state.limit === undefined) {\n // A hard limit with a wrong amount has its own fault.\n if (state.planned > 0 && !wrongBudgets.has(at)) error(\"limit-none\", at, `The planned cost of the resources of \"${at}\" is ${money(state.planned)} for a month, and \"${at}\" has no hard limit.`, more);\n } else if (state.over === true) {\n error(\"cost-over\", at, `The planned cost of the resources of \"${at}\" is ${money(state.planned)} for a month. Its hard limit is ${money(state.limit)}.`, more);\n }\n }\n\n for (const name of variables) {\n if (!readVariables.has(name)) add(\"warning\", \"variable-unused\", `var.${name}`, `No value reads the variable \"${name}\".`);\n }\n return faults;\n}\n","import { joinRecords, joinSetting, type LayerParse, type LayerPiece } from \"@mark1russell7/system-stack\";\nimport { copyName, providerAddress, resourceAddress, TOFU_SCHEMA, type TofuLayer } from \"./layer.ts\";\n\n// The join of the OpenTofu layers of the fragments of a stack, for example one file of resources for each owner.\n\n/**\n * This function joins the OpenTofu layers of the fragments of a stack into one layer.\n *\n * - The resources, the provider configurations and the variables are in the order of the fragments.\n * - A resource address in two or more fragments is a fault, also when the resources are equal.\n * - The same rule holds for the address of a provider configuration, the name of a variable, of a group and of a copy.\n * - The layer has one version of OpenTofu. A fragment with a different value is a fault.\n * - The state has one place. Thus a backend in two or more fragments is a fault, also when the backends are equal.\n *\n * A resource of one fragment can use a provider configuration or a variable of a different fragment.\n * A copy of one fragment can name a group of a different fragment.\n * The joined layer has the field `providers`, `variables`, `groups` or `copies` when a fragment has it. The function is pure, and it\n * changes no layer. The gate `checkTofu` examines the joined layer afterward.\n *\n * @param pieces - The layers, with the name of the fragment of each one, in the order of the fragments.\n * @returns The joined layer, or the faults of the join.\n */\nexport function joinTofu(pieces: readonly LayerPiece<TofuLayer>[]): LayerParse<TofuLayer> {\n const version = joinSetting(pieces, (layer) => layer.version, \"version of OpenTofu\");\n const backends = pieces.filter((piece) => piece.layer.backend !== undefined);\n const providers = joinRecords(pieces, (layer) => layer.providers, providerAddress, \"provider configuration\");\n const variables = joinRecords(\n pieces,\n (layer) => layer.variables,\n (variable) => variable.name,\n \"variable\",\n );\n const resources = joinRecords(pieces, (layer) => layer.resources, resourceAddress, \"resource\");\n const groups = joinRecords(\n pieces,\n (layer) => layer.groups,\n (group) => group.name,\n \"group\",\n );\n const copies = joinRecords(pieces, (layer) => layer.copies, copyName, \"copy\");\n const errors = [...version.errors];\n if (backends.length > 1) errors.push(`The fragments ${backends.map((piece) => `\"${piece.from}\"`).join(\", \")} each have a backend. The state has one place.`);\n errors.push(...providers.errors, ...variables.errors, ...resources.errors, ...groups.errors, ...copies.errors);\n if (errors.length > 0) return { ok: false, errors };\n const backend = backends[0]?.layer.backend;\n return {\n ok: true,\n layer: {\n schema: TOFU_SCHEMA,\n ...(version.value === undefined ? {} : { version: version.value }),\n ...(backend === undefined ? {} : { backend }),\n ...(pieces.some((piece) => piece.layer.providers !== undefined) ? { providers: providers.items } : {}),\n ...(pieces.some((piece) => piece.layer.variables !== undefined) ? { variables: variables.items } : {}),\n resources: resources.items,\n ...(pieces.some((piece) => piece.layer.groups !== undefined) ? { groups: groups.items } : {}),\n ...(pieces.some((piece) => piece.layer.copies !== undefined) ? { copies: copies.items } : {}),\n },\n };\n}\n"],"mappings":";;;;;;;AAMA,MAAa,YAAoB;;AAGjC,MAAa,gBAAwB;;AAGrC,MAAa,YAAoB;;;;;AAMjC,MAAa,YAAoB;;AAGjC,MAAa,cAAsB;;AAGnC,MAAa,eAAuB;;;;;AAYpC,SAAgB,SAAS,KAAmC;CAC1D,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,IAAI,MAAM,GAAG;CAC3C,IAAI,SAAS,KAAA,KAAa,SAAS,KAAA,KAAa,KAAK,WAAW,GAAG,OAAO,KAAA;CAE1E,MAAM,YAAY,KAAK,KAAK,GAAG;CAC/B,IAAI,CAAC,UAAU,KAAK,IAAI,KAAK,CAAC,UAAU,KAAK,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS,GAAG,OAAO,KAAA;CACzF,OAAO;EAAE,SAAS,GAAG,KAAK,GAAG;EAAQ;CAAU;AACjD;;AAGA,SAAgB,OAAO,OAAiD;CACtE,OAAO,MAAM,QAAQ,KAAK;AAC5B;;AAGA,SAAgB,SAAS,OAAuC;CAC9D,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;AAGA,SAAgB,OAAO,OAA4B;CACjD,OAAO,OAAO,KAAK,K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;EACL,IAAI;EACJ,OAAO;GACL,QAAQ;GACR,GAAI,QAAQ,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,QAAQ,MAAM;GAChE,GAAI,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ;GAC3C,GAAI,OAAO,MAAM,UAAU,MAAM,MAAM,cAAc,KAAA,CAAS,IAAI,EAAE,WAAW,UAAU,MAAM,IAAI,CAAC;GACpG,GAAI,OAAO,MAAM,UAAU,MAAM,MAAM,cAAc,KAAA,CAAS,IAAI,EAAE,WAAW,UAAU,MAAM,IAAI,CAAC;GACpG,WAAW,UAAU;GACrB,GAAI,OAAO,MAAM,UAAU,MAAM,MAAM,WAAW,KAAA,CAAS,IAAI,EAAE,QAAQ,OAAO,MAAM,IAAI,CAAC;GAC3F,GAAI,OAAO,MAAM,UAAU,MAAM,MAAM,WAAW,KAAA,CAAS,IAAI,EAAE,QAAQ,OAAO,MAAM,IAAI,CAAC;EAC7F;CACF;AACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/stack-tofu",
4
- "version": "0.2.0",
4
+ "version": "0.2.2",
5
5
  "description": "OpenTofu files from the records of a system stack: the resources of each part as data, a generator of the JSON files, a cost gate before the files exist, and a gate of a plan. An add-on of system-stack.",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -49,7 +49,7 @@
49
49
  ],
50
50
  "dependencies": {
51
51
  "@mark1russell7/collections": "^0.11.2",
52
- "@mark1russell7/system-stack": "0.1.5",
52
+ "@mark1russell7/system-stack": "0.1.7",
53
53
  "@mark1russell7/vex": "^0.19.1",
54
54
  "@mark1russell7/vex-domains": "^0.19.1",
55
55
  "zod": "^4.6.7"
@@ -1 +0,0 @@
1
- {"version":3,"file":"join-Ba3zzNsN.js","names":[],"sources":["../src/values.ts","../src/groups.ts","../src/queries.ts","../src/cost.ts","../src/check.ts","../src/join.ts"],"sourcesContent":["import type { TofuObject, TofuValue } from \"./layer.ts\";\n\n// The forms of a value, and the text of each value in the files.\n// In the JSON syntax of OpenTofu, each text is a template. Thus the generator escapes each text of a record.\n\n/** The form of the type of a resource and of the type of a backend. */\nexport const TYPE_FORM: RegExp = /^[a-z][a-z0-9_]*$/;\n\n/** The form of the local name of a provider, for example `example` or `example-beta`. */\nexport const PROVIDER_FORM: RegExp = /^[a-z][a-z0-9_-]*$/;\n\n/** The form of a name in the files: the name of a resource, of a variable, of an alias and of an argument. */\nexport const NAME_FORM: RegExp = /^[A-Za-z_][A-Za-z0-9_-]*$/;\n\n/**\n * The form of a path of attributes, for example `network[0].address` or `metadata[\"ssh-keys\"]`. A key of a map in quotes has\n * letters, digits and the characters `_ . : / -` only. Thus a path holds no template sequence and no quote of its own.\n */\nexport const PATH_FORM: RegExp = /^[A-Za-z_][A-Za-z0-9_-]*(\\.[A-Za-z_][A-Za-z0-9_-]*|\\[[0-9]+\\]|\\[\"[A-Za-z0-9_.:/-]+\"\\])*$/;\n\n/** The form of the address of a provider in a registry: two or three words with `/` between them. */\nexport const SOURCE_FORM: RegExp = /^[a-z0-9][a-z0-9.-]*(\\/[a-z0-9][a-z0-9_-]*){1,2}$/;\n\n/** The form of a list of versions, for example `>= 1.8, < 2.0`. */\nexport const VERSION_FORM: RegExp = /^[0-9A-Za-z .,<>=~!+-]+$/;\n\n/** The parts of a reference: the address of a resource, and a path of attributes of it. */\nexport interface RefParts {\n readonly address: string;\n readonly attribute: string;\n}\n\n/**\n * This function gives the parts of the text of a reference, for example `example_server.web.address`.\n * It gives `undefined` for a text with a different form.\n */\nexport function refParts(ref: string): RefParts | undefined {\n const [type, name, ...rest] = ref.split(\".\");\n if (type === undefined || name === undefined || rest.length === 0) return undefined;\n // An index stays with the word before it, so the name of the resource can not have one.\n const attribute = rest.join(\".\");\n if (!TYPE_FORM.test(type) || !NAME_FORM.test(name) || !PATH_FORM.test(attribute)) return undefined;\n return { address: `${type}.${name}`, attribute };\n}\n\n/** This function tells if a value is a list. */\nexport function isList(value: TofuValue): value is readonly TofuValue[] {\n return Array.isArray(value);\n}\n\n/** This function tells if a value is an object of values. A list and `null` are not objects. */\nexport function isObject(value: TofuValue): value is TofuObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** This function tells if an object has a key that starts with `$`: the object is a form, not a map of arguments. */\nexport function isForm(value: TofuObject): boolean {\n return Object.keys(value).some((key) => key.startsWith(\"$\"));\n}\n\n/** This function gives the one value of a form with the one key `key`, when that value is a text. */\nfunction formText(value: TofuObject, key: string): string | undefined {\n const keys = Object.keys(value);\n const text = value[key];\n return keys.length === 1 && keys[0] === key && typeof text === \"string\" ? text : undefined;\n}\n\n/** This function gives the text of a correct reference form, `{ \"$ref\": \"type.name.attribute\" }`. */\nexport function refOf(value: TofuObject): string | undefined {\n const text = formText(value, \"$ref\");\n return text !== undefined && refParts(text) !== undefined ? text : undefined;\n}\n\n/** This function gives the name of a correct variable form, `{ \"$var\": \"name\" }`. */\nexport function varOf(value: TofuObject): string | undefined {\n const text = formText(value, \"$var\");\n return text !== undefined && NAME_FORM.test(text) ? text : undefined;\n}\n\n/** This function gives the name of a correct parameter form, `{ \"$param\": \"name\" }`. Only a resource of a group can have one. */\nexport function paramOf(value: TofuObject): string | undefined {\n const text = formText(value, \"$param\");\n return text !== undefined && NAME_FORM.test(text) ? text : undefined;\n}\n\n/**\n * This function escapes the template sequences of a text. OpenTofu then reads the text as it is in the record.\n * `$${` is the escape of `${`, and `%%{` is the escape of `%{`.\n */\nexport function escapeTemplate(text: string): string {\n // A function gives each replacement: in a replacement text, `$$` is the escape of one `$`.\n return text.replaceAll(\"${\", () => \"$${\").replaceAll(\"%{\", () => \"%%{\");\n}\n\n/**\n * This function gives a value as OpenTofu reads it in a JSON file.\n *\n * - A text and each key of an object are escaped.\n * - A reference form becomes the expression of the attribute, and a variable form the expression of the variable.\n *\n * A form that is not correct stays an object with an escaped key. The gate `checkTofu` refuses such a layer.\n */\nexport function renderValue(value: TofuValue): TofuValue {\n if (typeof value === \"string\") return escapeTemplate(value);\n if (isList(value)) return value.map(renderValue);\n if (!isObject(value)) return value;\n const ref = refOf(value);\n if (ref !== undefined) return `\\${${ref}}`;\n const variable = varOf(value);\n if (variable !== undefined) return `\\${var.${variable}}`;\n return Object.fromEntries(Object.entries(value).map(([key, item]) => [escapeTemplate(key), renderValue(item)]));\n}\n\n/** A place in a value: the keys and the positions from the value to the place. */\nexport type ValuePath = readonly (string | number)[];\n\n/** A form of a value, with its place. `text` is absent when the form is not correct. */\nexport interface FormUse {\n readonly kind: \"ref\" | \"var\" | \"bad\";\n readonly path: ValuePath;\n readonly text?: string | undefined;\n}\n\n/** One number of a value that is not finite, with its place. */\nexport interface NumberUse {\n readonly path: ValuePath;\n readonly value: number;\n}\n\n/** The forms and the numbers that are not finite of a value. */\nexport interface ValueUses {\n readonly forms: readonly FormUse[];\n readonly numbers: readonly NumberUse[];\n}\n\n/** This function gives each form of a value and each number that is not finite, in the sequence of the value. */\nexport function valueUses(value: TofuValue): ValueUses {\n const forms: FormUse[] = [];\n const numbers: NumberUse[] = [];\n const walk = (item: TofuValue, path: ValuePath): void => {\n if (typeof item === \"number\") {\n if (!Number.isFinite(item)) numbers.push({ path, value: item });\n return;\n }\n if (isList(item)) {\n item.forEach((child, index) => {\n walk(child, [...path, index]);\n });\n return;\n }\n if (!isObject(item)) return;\n if (isForm(item)) {\n const ref = refOf(item);\n const variable = varOf(item);\n if (ref !== undefined) forms.push({ kind: \"ref\", path, text: ref });\n else if (variable !== undefined) forms.push({ kind: \"var\", path, text: variable });\n else forms.push({ kind: \"bad\", path });\n return;\n }\n for (const [key, child] of Object.entries(item)) walk(child, [...path, key]);\n };\n walk(value, []);\n return { forms, numbers };\n}\n\n/** This function gives a place in a value as a text, for example `disk.0.size`. The place of the value is `(the value)`. */\nexport function pathText(path: ValuePath): string {\n return path.length === 0 ? \"(the value)\" : path.join(\".\");\n}\n","import type { TofuFault } from \"./check.ts\";\nimport {\n BUILTIN_PROVIDER,\n copyName,\n resourceAddress,\n typeProvider,\n type Copy,\n type Group,\n type GroupResource,\n type Resource,\n type TofuLayer,\n type TofuObject,\n type TofuValue,\n} from \"./layer.ts\";\nimport { isForm, isList, isObject, NAME_FORM, paramOf, pathText, refOf, refParts, type ValuePath } from \"./values.ts\";\n\n// The groups of resources and their copies. The resources of a copy are a view of its group. Each function of the package\n// reads the resources of a layer through `layerResources`, so each gate, each query and the files cover the copies.\n\n/** This function gives the local address of a resource of a group: its type, a point and its local name. */\nexport function localAddress(resource: GroupResource): string {\n return `${resource.type}.${resource.name}`;\n}\n\n/** This function gives the name in the files of a resource of a copy: the name of the copy, `_` and the local name. */\nexport function copyResourceName(copy: Copy, resource: GroupResource): string {\n return `${copyName(copy)}_${resource.name}`;\n}\n\n/** This function gives the provider name of the address of a provider configuration: the word before the point. */\nfunction providerName(address: string): string {\n const end = address.indexOf(\".\");\n return end === -1 ? address : address.slice(0, end);\n}\n\n/** This function tells if a resource of a group is a part of OpenTofu, with no provider configuration. */\nfunction isBuiltinMember(resource: GroupResource): boolean {\n return resource.provider === undefined && typeProvider(resource.type) === BUILTIN_PROVIDER;\n}\n\n/** This function gives the value of each parameter of a group for a copy. It gives `undefined` when a parameter has no value. */\nfunction paramValues(group: Group, copy: Copy): Map<string, TofuValue> | undefined {\n const values = new Map<string, TofuValue>();\n for (const param of group.params ?? []) {\n const value = copy.values !== undefined && Object.hasOwn(copy.values, param.name) ? copy.values[param.name] : param.default;\n if (value === undefined) return undefined;\n values.set(param.name, value);\n }\n return values;\n}\n\n/**\n * This function fills a value of a resource of a group for one copy. A parameter form becomes the value of the parameter.\n * A reference to a local address of the group becomes a reference to the resource of the copy. The value of a parameter does not change.\n */\nfunction fill(value: TofuValue, params: ReadonlyMap<string, TofuValue>, addresses: ReadonlyMap<string, string>): TofuValue {\n if (isList(value)) return value.map((item) => fill(item, params, addresses));\n if (!isObject(value)) return value;\n if (isForm(value)) {\n const param = paramOf(value);\n const given = param === undefined ? undefined : params.get(param);\n if (given !== undefined) return given;\n const ref = refOf(value);\n const parts = ref === undefined ? undefined : refParts(ref);\n const address = parts === undefined ? undefined : addresses.get(parts.address);\n return parts !== undefined && address !== undefined ? { $ref: `${address}.${parts.attribute}` } : value;\n }\n return fillObject(value, params, addresses);\n}\n\n/** This function fills each argument of an object. The object itself is not a form, also when it has a key that starts with `$`. */\nfunction fillObject(values: TofuObject, params: ReadonlyMap<string, TofuValue>, addresses: ReadonlyMap<string, string>): TofuObject {\n return Object.fromEntries(Object.entries(values).map(([key, item]) => [key, fill(item, params, addresses)]));\n}\n\n/** This function gives the provider configuration of a resource of a copy. A configuration of the copy with the same provider name replaces that of the group. */\nfunction copyProvider(copy: Copy, resource: GroupResource): string | undefined {\n if (isBuiltinMember(resource)) return undefined;\n const name = providerName(resource.provider ?? typeProvider(resource.type));\n return copy.providers?.find((address) => providerName(address) === name) ?? resource.provider;\n}\n\n/**\n * This function gives the resources of the copies of a layer, in the sequence of the copies and of the resources of each group.\n *\n * - A resource of a copy makes the part of the copy. Its name is the name of the copy, `_` and its local name.\n * - A parameter form becomes the value of the copy, or the default of the parameter.\n * - A reference to a local address of the group reads the resource of the same copy.\n * - A configuration of the copy replaces the configuration of the same provider name.\n *\n * A copy whose group the layer does not have, or that gives no value for a parameter with no default, makes no resource.\n * For two groups with one name, the copies use the first one. The gate `checkTofu` gives a fault for each such record.\n */\nexport function copyResources(layer: TofuLayer): Resource[] {\n const groups = new Map<string, Group>();\n for (const group of layer.groups ?? []) if (!groups.has(group.name)) groups.set(group.name, group);\n return (layer.copies ?? []).flatMap((copy) => {\n const group = groups.get(copy.group);\n const params = group === undefined ? undefined : paramValues(group, copy);\n if (group === undefined || params === undefined) return [];\n const addresses = new Map(group.resources.map((resource) => [localAddress(resource), `${resource.type}.${copyResourceName(copy, resource)}`]));\n return group.resources.map((resource): Resource => {\n const provider = copyProvider(copy, resource);\n return {\n part: copy.part,\n type: resource.type,\n name: copyResourceName(copy, resource),\n ...(provider === undefined ? {} : { provider }),\n ...(resource.values === undefined ? {} : { values: fillObject(resource.values, params, addresses) }),\n ...(resource.cost === undefined ? {} : { cost: resource.cost }),\n ...(resource.keep === undefined ? {} : { keep: resource.keep }),\n ...(resource.ignore === undefined ? {} : { ignore: resource.ignore }),\n };\n });\n });\n}\n\n/** This function gives each resource of a layer: the resources of the field `resources`, and then the resources of the copies. */\nexport function layerResources(layer: TofuLayer): readonly Resource[] {\n return (layer.copies ?? []).length === 0 ? layer.resources : [...layer.resources, ...copyResources(layer)];\n}\n\n/** One parameter form of a value, with its place. */\ninterface ParamUse {\n readonly name: string;\n readonly path: ValuePath;\n}\n\n/** This function gives each correct parameter form of the arguments of a record, in the sequence of the arguments. */\nfunction paramUses(values: TofuObject): ParamUse[] {\n const uses: ParamUse[] = [];\n const walk = (item: TofuValue, path: ValuePath): void => {\n if (isList(item)) {\n item.forEach((child, index) => {\n walk(child, [...path, index]);\n });\n return;\n }\n if (!isObject(item)) return;\n const name = isForm(item) ? paramOf(item) : undefined;\n if (name !== undefined) uses.push({ name, path });\n else if (!isForm(item)) for (const [key, child] of Object.entries(item)) walk(child, [...path, key]);\n };\n for (const [key, child] of Object.entries(values)) walk(child, [key]);\n return uses;\n}\n\n/** This function gives a list of names for a message, for example `\"a\", \"b\"`. */\nfunction quoted(items: readonly string[]): string {\n return items.map((item) => `\"${item}\"`).join(\", \");\n}\n\n/**\n * This function gives the faults of the groups and of the copies of a layer. `checkTofu` gives them with its other faults.\n * The resources of the copies get the faults of each resource there: the gate examines them as resources.\n *\n * The errors:\n * - `group-form`: the name of a group, of a parameter or of a copy does not have the form of a name. Or a group has no resource.\n * - `group-duplicate`: two groups, two parameters of a group, two resources of a group with one local address, or two copies have one name.\n * - `group-shadow`: a local address of a group is the address of a resource of the layer. A reference in the group then reads the copy.\n * - `group-none`: a copy names a group that the layer does not have.\n * - `param-none`: a parameter form of a group names a parameter that the group does not have.\n * - `param-missing`: a copy gives no value for a parameter with no default.\n * - `param-unknown`: a copy gives a value for a parameter that the group does not have.\n * - `copy-provider`: a configuration of a copy replaces no configuration of the group, or two of them have one provider name.\n * A configuration that the layer does not have gives `provider-none` at each resource of the copy.\n *\n * The warnings:\n * - `group-unused`: no copy names a group.\n * - `param-unused`: no resource of a group reads a parameter.\n */\nexport function groupFaults(layer: TofuLayer): TofuFault[] {\n const faults: TofuFault[] = [];\n const add = (level: TofuFault[\"level\"], code: TofuFault[\"code\"], at: string, message: string, more: { readonly other?: string; readonly part?: string } = {}): void => {\n faults.push({ level, code, at, message, ...more });\n };\n const top = new Set(layer.resources.map(resourceAddress));\n const groups = new Map<string, Group>();\n for (const group of layer.groups ?? []) {\n const at = `group.${group.name}`;\n if (groups.has(group.name)) {\n add(\"error\", \"group-duplicate\", at, `Two groups have the name \"${group.name}\".`);\n continue;\n }\n groups.set(group.name, group);\n if (!NAME_FORM.test(group.name)) add(\"error\", \"group-form\", at, `The name \"${group.name}\" of a group does not have the form of a name.`);\n if (group.resources.length === 0) add(\"error\", \"group-form\", at, `The group \"${group.name}\" has no resource.`);\n const params = new Set<string>();\n for (const param of group.params ?? []) {\n if (params.has(param.name)) add(\"error\", \"group-duplicate\", at, `Two parameters of the group \"${group.name}\" have the name \"${param.name}\".`);\n else if (!NAME_FORM.test(param.name)) add(\"error\", \"group-form\", at, `The name \"${param.name}\" of a parameter of the group \"${group.name}\" does not have the form of a name.`);\n params.add(param.name);\n }\n const locals = new Set<string>();\n const read = new Set<string>();\n for (const resource of group.resources) {\n const local = localAddress(resource);\n if (locals.has(local)) add(\"error\", \"group-duplicate\", at, `Two resources of the group \"${group.name}\" have the local address \"${local}\".`);\n locals.add(local);\n if (top.has(local)) {\n add(\"error\", \"group-shadow\", at, `The group \"${group.name}\" has the local address \"${local}\", and the layer has a resource with that address. A reference in the group reads the resource of the copy.`, {\n other: local,\n });\n }\n for (const use of paramUses(resource.values ?? {})) {\n if (params.has(use.name)) read.add(use.name);\n else add(\"error\", \"param-none\", at, `The value at \"${pathText(use.path)}\" of the resource \"${local}\" of the group \"${group.name}\" names the parameter \"${use.name}\", which the group does not have.`);\n }\n }\n for (const name of params) {\n if (!read.has(name)) add(\"warning\", \"param-unused\", at, `No resource of the group \"${group.name}\" reads the parameter \"${name}\".`);\n }\n }\n\n const copies = new Set<string>();\n const copied = new Set<string>();\n for (const copy of layer.copies ?? []) {\n const name = copyName(copy);\n const at = `copy.${name}`;\n const more = { part: copy.part };\n if (copies.has(name)) {\n add(\"error\", \"group-duplicate\", at, `Two copies have the name \"${name}\".`, more);\n continue;\n }\n copies.add(name);\n if (!NAME_FORM.test(name)) add(\"error\", \"group-form\", at, `The name \"${name}\" of a copy does not have the form of a name.`, more);\n const group = groups.get(copy.group);\n if (group === undefined) {\n add(\"error\", \"group-none\", at, `The copy \"${name}\" names the group \"${copy.group}\", which the layer does not have. It makes no resource.`, { ...more, other: `group.${copy.group}` });\n continue;\n }\n copied.add(group.name);\n const params = group.params ?? [];\n const given = Object.keys(copy.values ?? {});\n for (const key of given) {\n if (!params.some((param) => param.name === key)) add(\"error\", \"param-unknown\", at, `The copy \"${name}\" gives the parameter \"${key}\", which the group \"${group.name}\" does not have.`, more);\n }\n const missing = params.filter((param) => param.default === undefined && !given.includes(param.name)).map((param) => param.name);\n if (missing.length > 0) add(\"error\", \"param-missing\", at, `The copy \"${name}\" gives no value for the parameters ${quoted(missing)} of the group \"${group.name}\". It makes no resource.`, more);\n const used = new Set(group.resources.filter((resource) => !isBuiltinMember(resource)).map((resource) => providerName(resource.provider ?? typeProvider(resource.type))));\n const replaced = new Set<string>();\n for (const address of copy.providers ?? []) {\n const provider = providerName(address);\n if (replaced.has(provider)) {\n add(\"error\", \"copy-provider\", at, `The copy \"${name}\" has two configurations of the provider \"${provider}\". Each one replaces the configuration of its provider name.`, more);\n } else if (!used.has(provider)) {\n add(\"error\", \"copy-provider\", at, `The configuration \"${address}\" of the copy \"${name}\" replaces no configuration: no resource of the group \"${group.name}\" uses the provider \"${provider}\".`, more);\n }\n replaced.add(provider);\n }\n }\n for (const group of groups.values()) {\n if (!copied.has(group.name)) add(\"warning\", \"group-unused\", `group.${group.name}`, `No copy names the group \"${group.name}\". It makes no resource.`);\n }\n return faults;\n}\n","import { stronglyConnectedComponents } from \"@mark1russell7/collections/graph\";\nimport { partNeeds, partsById, type Part, type Stack } from \"@mark1russell7/system-stack\";\nimport { layerResources } from \"./groups.ts\";\nimport { resourceAddress, type Resource, type TofuLayer } from \"./layer.ts\";\nimport { refParts, valueUses } from \"./values.ts\";\n\n// The queries over the records. The sequence of the resources in the files comes from the needs of the stack,\n// so a person writes each dependence one time: in the stack.\n\n/** This function gives the first resource of each address of a layer, in the sequence of the records. The resources of the copies come last. */\nexport function firstResources(layer: TofuLayer): readonly Resource[] {\n const seen = new Set<string>();\n return layerResources(layer).filter((resource) => {\n const address = resourceAddress(resource);\n if (seen.has(address)) return false;\n seen.add(address);\n return true;\n });\n}\n\n/**\n * This function gives the addresses of the resources of each part, by the `id` of the part.\n * The addresses of a part are sorted. With them, a host joins a plan or a state to the parts of the stack.\n */\nexport function resourcesByPart(layer: TofuLayer): Map<string, string[]> {\n const byPart = new Map<string, string[]>();\n for (const resource of firstResources(layer)) {\n const addresses = byPart.get(resource.part) ?? [];\n addresses.push(resourceAddress(resource));\n byPart.set(resource.part, addresses);\n }\n for (const addresses of byPart.values()) addresses.sort();\n return byPart;\n}\n\n/**\n * This function gives the address of each resource that the arguments of a resource read, sorted.\n * Each address comes one time. An address can name a resource that the layer does not have.\n */\nexport function resourceRefs(resource: Resource): string[] {\n const addresses = new Set<string>();\n for (const form of valueUses(resource.values ?? {}).forms) {\n // The arguments as a whole are not a value, so a form at the empty place reads nothing.\n const parts = form.kind === \"ref\" && form.text !== undefined && form.path.length > 0 ? refParts(form.text) : undefined;\n if (parts !== undefined) addresses.add(parts.address);\n }\n return [...addresses].sort();\n}\n\n/**\n * This function walks the needs of a part, nearest first. It gives the `id` of each part where the walk stops or goes on.\n * The walk does not go past a part for which `stop` gives `true`. It does not come back to the first part.\n */\nfunction walkNeeds(parts: ReadonlyMap<string, Part>, from: string, stop: (id: string) => boolean): string[] {\n const seen = new Set<string>([from]);\n const found: string[] = [];\n let level = partNeeds(parts.get(from) ?? { id: from, kind: \"\" });\n while (level.length > 0) {\n const next: string[] = [];\n for (const id of level) {\n if (seen.has(id)) continue;\n seen.add(id);\n found.push(id);\n const part = parts.get(id);\n if (part !== undefined && !stop(id)) next.push(...partNeeds(part));\n }\n level = next;\n }\n return found;\n}\n\n/**\n * This function gives the `id` of each part that a part needs, directly or through other parts.\n * The part itself is not in the result. A need that names no part of the stack is in the result.\n */\nexport function neededParts(stack: Stack, part: string): Set<string> {\n return new Set(walkNeeds(partsById(stack), part, () => false));\n}\n\n/**\n * This function gives the dependencies of each resource that come from the needs of the stack, by the address of the resource.\n *\n * - A resource depends on the resources of each part that its part needs.\n * - For a needed part with no resource, the walk goes on to the needs of that part. It stops at the nearest parts with resources.\n * - An address that the arguments of the resource read is not in the list: OpenTofu knows that dependence from the arguments.\n *\n * The addresses of a resource are sorted. The generator writes them as `depends_on`.\n */\nexport function dependsOn(layer: TofuLayer, stack: Stack): Map<string, string[]> {\n const parts = partsById(stack);\n const byPart = resourcesByPart(layer);\n const result = new Map<string, string[]>();\n for (const resource of firstResources(layer)) {\n const read = new Set(resourceRefs(resource));\n const addresses = walkNeeds(parts, resource.part, (id) => byPart.has(id)).flatMap((id) => byPart.get(id) ?? []);\n result.set(\n resourceAddress(resource),\n addresses.filter((address) => !read.has(address)).sort(),\n );\n }\n return result;\n}\n\n/**\n * This function gives the cycles of the resources of a layer. In a cycle, each resource waits for a different one, and OpenTofu can make none of them.\n * A resource waits for each resource that its arguments read, and for each one of `dependsOn`.\n * Each cycle is a sorted list of addresses. A resource that reads its own attribute is a cycle of one resource.\n */\nexport function resourceCycles(layer: TofuLayer, stack: Stack): string[][] {\n const depends = dependsOn(layer, stack);\n const waits = new Map<string, string[]>();\n for (const resource of firstResources(layer)) {\n const address = resourceAddress(resource);\n waits.set(address, [...resourceRefs(resource), ...(depends.get(address) ?? [])]);\n }\n const nodes = [...waits.keys()].sort();\n return stronglyConnectedComponents(nodes, (address) => waits.get(address) ?? []).filter((component) => {\n const [only = \"\"] = component;\n return component.length > 1 || (waits.get(only) ?? []).includes(only);\n });\n}\n","import { app, axes, each, evaluate, lit, ref, space, type Expr, type Result, type Space } from \"@mark1russell7/vex\";\nimport { BoolDomain, NumDomain, TextDomain } from \"@mark1russell7/vex-domains\";\nimport { isBuiltin, resourceAddress, resourceProvider, type TofuLayer } from \"./layer.ts\";\nimport { firstResources } from \"./queries.ts\";\n\n// The planned cost of the resources, as Vex programs. A program is data: `explain` of Vex shows each step.\n// The layer becomes a tree: the layer, then each account, then each resource of the account.\n\n/**\n * The limit of the cost of a part for a month. A state of a service of the spend add-on has this form.\n * Thus a host gives the states of a spend layer as the budgets, and the two add-ons do not know each other.\n */\nexport interface Budget {\n /** The `id` of the part: an account, a project or a tenant. */\n readonly part: string;\n /** The hard limit of the cost of the part for a month. A part with no hard limit has none. */\n readonly hardLimit?: number | undefined;\n}\n\n/** The key of the layer node: the root of the cost tree. */\nexport const COST_LAYER_KEY = \"layer\";\n\n/** This function gives the key of the node of an account: the text `account:` and the `id` of its part. */\nexport function accountKey(part: string): string {\n return `account:${part}`;\n}\n\n/** This function gives the key of the node of a resource: the text `resource:` and its address. */\nexport function resourceKey(address: string): string {\n return `resource:${address}`;\n}\n\n/** This function tells if a value is a finite number, 0 or more. */\nexport function isZeroOrMore(value: number): boolean {\n return Number.isFinite(value) && value >= 0;\n}\n\n/** This function gives the first budget of each part, by the `id` of the part. */\nexport function budgetsByPart(budgets: readonly Budget[]): Map<string, Budget> {\n const byPart = new Map<string, Budget>();\n for (const budget of budgets) if (!byPart.has(budget.part)) byPart.set(budget.part, budget);\n return byPart;\n}\n\n/** The planned cost of each resource of an account. A resource with no known cost gives an error value. */\nconst COSTS: Expr = each(axes.children, ref(\"cost\"));\n\n/** The planned cost of an account in a month: the sum of the known costs of its resources. The program evaluates at an account node. */\nexport const PLANNED: Expr = app(\"sum\", COSTS);\n\n/** This test tells if a resource node has a known cost. */\nconst HAS_COST: Expr = app(\"ifError\", app(\"eq\", ref(\"cost\"), ref(\"cost\")), lit(false));\n\n/** The count of the resources of an account with no known cost. The program evaluates at an account node. */\nexport const UNKNOWN_COSTS: Expr = app(\"count\", each(axes.where(axes.children, app(\"not\", HAS_COST)), ref(\"kind\")));\n\n/** This test tells if the planned cost of an account is more than its hard limit. An account with no hard limit gives an error value. */\nexport const PLANNED_OVER: Expr = app(\"gt\", PLANNED, ref(\"limit\"));\n\n/** The room of an account: its hard limit less its planned cost. An account with no hard limit gives an error value. */\nexport const PLANNED_ROOM: Expr = app(\"subtract\", ref(\"limit\"), PLANNED);\n\n/** The planned cost of the layer in a month: the sum of the planned costs of its accounts. The program evaluates at the layer node. */\nexport const PLANNED_TOTAL: Expr = app(\"sum\", each(axes.children, PLANNED));\n\n/**\n * This function gives the cost tree of a layer, as a space of Vex.\n *\n * - The layer is the root, with the key `COST_LAYER_KEY`.\n * - An account is a child of the layer: the part of a provider configuration that has one resource or more. Its field `limit` is its hard limit.\n * - A resource is a child of the account of its provider configuration. Its field `cost` is its planned cost.\n *\n * A cost or a limit that is less than 0 or not finite is not in the tree: it is not known.\n * A resource with no provider configuration is not in the tree, because it counts against no account.\n */\nexport function costSpace(layer: TofuLayer, budgets: readonly Budget[] = []): Space {\n const limits = budgetsByPart(budgets);\n const records: Record<string, Readonly<Record<string, unknown>>> = { [COST_LAYER_KEY]: { kind: \"layer\" } };\n const parents: Record<string, string | null> = { [COST_LAYER_KEY]: null };\n for (const resource of firstResources(layer)) {\n const provider = isBuiltin(resource) ? undefined : resourceProvider(layer, resource);\n if (provider === undefined) continue;\n const account = accountKey(provider.part);\n if (records[account] === undefined) {\n const limit = limits.get(provider.part)?.hardLimit;\n records[account] = { kind: \"account\", part: provider.part, ...(limit !== undefined && isZeroOrMore(limit) ? { limit } : {}) };\n parents[account] = COST_LAYER_KEY;\n }\n const key = resourceKey(resourceAddress(resource));\n records[key] = { kind: \"resource\", ...(resource.cost !== undefined && isZeroOrMore(resource.cost) ? { cost: resource.cost } : {}) };\n parents[key] = account;\n }\n return space.tree(records, parents);\n}\n\n/**\n * This function evaluates a program of this module at a node of a cost tree. It gives the value, or the error value.\n * `tree` is the result of `costSpace`, and `key` is the key of a node.\n */\nexport function evaluateCost(program: Expr, tree: Space, key: string): Result<unknown> {\n return evaluate(program, { space: tree, origin: key, domains: [NumDomain, BoolDomain, TextDomain] });\n}\n\n/** This function gives the number of a result, or `undefined` for an error value. */\nfunction numberOf(result: Result<unknown>): number | undefined {\n return result.ok && typeof result.value === \"number\" ? result.value : undefined;\n}\n\n/** The state of the planned cost of one account of a layer. */\nexport interface AccountState {\n /** The `id` of the part of the account. */\n readonly part: string;\n /** The addresses of the resources that count against the account, sorted. */\n readonly resources: readonly string[];\n /** The planned cost of the account in a month: the sum of the known costs of its resources. */\n readonly planned: number;\n /** The count of the resources with no known cost. With one or more, `planned` is not the whole cost. */\n readonly unknown: number;\n /** The hard limit of the account for a month. An account with no budget, or with a budget with no hard limit, has none. */\n readonly limit?: number | undefined;\n /** `true`: the planned cost is more than the hard limit. An account with no hard limit has no value. */\n readonly over?: boolean | undefined;\n /** The hard limit less the planned cost. An account with no hard limit has no value. */\n readonly room?: number | undefined;\n}\n\n/** This function gives the state of the planned cost of each account of a layer, in the sequence of the first resource of each account. */\nexport function accountStates(layer: TofuLayer, budgets: readonly Budget[] = []): AccountState[] {\n const tree = costSpace(layer, budgets);\n const accounts = new Map<string, string[]>();\n for (const resource of firstResources(layer)) {\n const provider = isBuiltin(resource) ? undefined : resourceProvider(layer, resource);\n if (provider === undefined) continue;\n const addresses = accounts.get(provider.part) ?? [];\n addresses.push(resourceAddress(resource));\n accounts.set(provider.part, addresses);\n }\n return [...accounts].map(([part, addresses]) => {\n const key = accountKey(part);\n const limit = numberOf(evaluateCost(ref(\"limit\"), tree, key));\n const over = evaluateCost(PLANNED_OVER, tree, key);\n const room = numberOf(evaluateCost(PLANNED_ROOM, tree, key));\n return {\n part,\n resources: [...addresses].sort(),\n planned: numberOf(evaluateCost(PLANNED, tree, key)) ?? 0,\n unknown: numberOf(evaluateCost(UNKNOWN_COSTS, tree, key)) ?? 0,\n ...(limit === undefined ? {} : { limit }),\n ...(over.ok && typeof over.value === \"boolean\" ? { over: over.value } : {}),\n ...(room === undefined ? {} : { room }),\n };\n });\n}\n\n/** This function gives the planned cost of a layer in a month: the sum of the planned costs of its accounts. */\nexport function plannedTotal(layer: TofuLayer): number {\n return numberOf(evaluateCost(PLANNED_TOTAL, costSpace(layer), COST_LAYER_KEY)) ?? 0;\n}\n","import { partsById, type Fault, type FaultLevel, type Stack } from \"@mark1russell7/system-stack\";\nimport { accountStates, isZeroOrMore, type Budget } from \"./cost.ts\";\nimport { BUILTIN_PROVIDER, isBuiltin, providerAddress, resourceAddress, resourceName, resourceProvider, typeProvider, type Provider, type TofuLayer, type TofuObject } from \"./layer.ts\";\nimport { groupFaults, layerResources } from \"./groups.ts\";\nimport { firstResources, neededParts, resourceCycles } from \"./queries.ts\";\nimport { isForm, NAME_FORM, PATH_FORM, pathText, PROVIDER_FORM, refParts, SOURCE_FORM, TYPE_FORM, valueUses, VERSION_FORM } from \"./values.ts\";\n\n// The gate of the OpenTofu layer. A gate that passes tells that the files are safe to write:\n// each record has a correct form, no resource waits in a cycle, and the planned cost of each account is known and not more than its hard limit.\n\n/** These are the codes of the faults of an OpenTofu layer. */\nexport const TOFU_CODES: readonly [\n \"version\",\n \"backend\",\n \"variable-form\",\n \"variable-duplicate\",\n \"provider-form\",\n \"provider-duplicate\",\n \"provider-source\",\n \"provider-part\",\n \"provider-value\",\n \"resource-form\",\n \"resource-duplicate\",\n \"resource-part\",\n \"provider-none\",\n \"ignore-form\",\n \"value-name\",\n \"value-meta\",\n \"value-form\",\n \"value-number\",\n \"ref-none\",\n \"var-none\",\n \"cycle\",\n \"cost-amount\",\n \"cost-none\",\n \"cost-builtin\",\n \"budget-duplicate\",\n \"budget-amount\",\n \"budget-none\",\n \"limit-none\",\n \"cost-over\",\n \"provider-need\",\n \"variable-unused\",\n \"group-form\",\n \"group-duplicate\",\n \"group-shadow\",\n \"group-none\",\n \"param-none\",\n \"param-missing\",\n \"param-unknown\",\n \"copy-provider\",\n \"group-unused\",\n \"param-unused\",\n] = [\n \"version\",\n \"backend\",\n \"variable-form\",\n \"variable-duplicate\",\n \"provider-form\",\n \"provider-duplicate\",\n \"provider-source\",\n \"provider-part\",\n \"provider-value\",\n \"resource-form\",\n \"resource-duplicate\",\n \"resource-part\",\n \"provider-none\",\n \"ignore-form\",\n \"value-name\",\n \"value-meta\",\n \"value-form\",\n \"value-number\",\n \"ref-none\",\n \"var-none\",\n \"cycle\",\n \"cost-amount\",\n \"cost-none\",\n \"cost-builtin\",\n \"budget-duplicate\",\n \"budget-amount\",\n \"budget-none\",\n \"limit-none\",\n \"cost-over\",\n \"provider-need\",\n \"variable-unused\",\n \"group-form\",\n \"group-duplicate\",\n \"group-shadow\",\n \"group-none\",\n \"param-none\",\n \"param-missing\",\n \"param-unknown\",\n \"copy-provider\",\n \"group-unused\",\n \"param-unused\",\n];\n\n/** A code of a fault of an OpenTofu layer. */\nexport type TofuCode = (typeof TOFU_CODES)[number];\n\n/**\n * A fault of an OpenTofu layer. Its field `at` is the place of the fault in the files.\n *\n * - For a resource, `at` is its address.\n * - For a provider configuration, `at` is `provider.` and its address.\n * - For a variable, `at` is `var.` and its name.\n * - For the settings, `at` is `terraform`.\n *\n * For a fault of a budget or of an account, `at` is the `id` of the part.\n */\nexport interface TofuFault extends Fault {\n readonly code: TofuCode;\n /** The `id` of the part of the stack of the record with the fault. */\n readonly part?: string | undefined;\n}\n\n/** The options of the gate and of the generator. */\nexport interface TofuOptions {\n /**\n * The limit of the cost of each account for a month. The states of a spend layer have this form.\n * An account with resources and no budget stops the gate: the gate has no read of its limit.\n */\n readonly budgets?: readonly Budget[] | undefined;\n /** The currency of the costs and of the budgets, for the text of a fault. */\n readonly currency?: string | undefined;\n}\n\n/** These arguments of a resource are meta-arguments. The generator writes them from the records, so the arguments of a record cannot have them. */\nexport const RESOURCE_META: readonly string[] = [\"provider\", \"depends_on\", \"lifecycle\", \"count\", \"for_each\", \"provisioner\", \"connection\", \"dynamic\"];\n\n/** These arguments of a provider configuration are meta-arguments. The generator writes them from the records. */\nexport const PROVIDER_META: readonly string[] = [\"alias\", \"version\", \"for_each\"];\n\n/** This function gives a list of names for a message, for example `\"a\", \"b\"`. */\nfunction names(items: readonly string[]): string {\n return items.map((item) => `\"${item}\"`).join(\", \");\n}\n\n/**\n * This function gives each fault of an OpenTofu layer for a stack. A list with no error tells that the gate passes.\n *\n * The settings, the variables and the providers, as errors:\n * - `version`: the versions of OpenTofu do not have the form of a list of versions.\n * - `backend`: the type of the backend does not have the form of a type, or a value of the backend is not literal.\n * - `variable-form`: the name of a variable does not have the form of a name.\n * - `variable-duplicate`: two variables have one name.\n * - `provider-form`: the name, the alias, the source or the versions of a provider configuration do not have their form.\n * - `provider-duplicate`: two provider configurations have one address.\n * - `provider-source`: two configurations of one provider have different sources or versions.\n * - `provider-part`: a provider configuration names no part of the stack.\n * - `provider-value`: a value of a provider configuration reads a resource.\n *\n * The resources, as errors:\n * - `resource-form`: the type, the name or the import id of a resource does not have its form.\n * - `resource-duplicate`: two resources have one address.\n * - `resource-part`: a resource names no part of the stack.\n * - `provider-none`: the layer does not have the provider configuration of a resource.\n * - `ignore-form`: an attribute of `ignore` does not have the form of a path.\n *\n * The values, as errors:\n * - `value-name`: the name of an argument does not have the form of a name.\n * - `value-meta`: an argument is a meta-argument. The generator writes each meta-argument.\n * - `value-form`: an object has a key that starts with `$`, and it is not a correct reference or variable.\n * - `value-number`: a number is not finite. JSON cannot hold it.\n * - `ref-none`: a reference names a resource that the layer does not have.\n * - `var-none`: a value names a variable that the layer does not have.\n *\n * The queries, as errors:\n * - `cycle`: resources wait for each other, so OpenTofu can make none of them.\n *\n * The costs, as errors:\n * - `cost-amount`: the planned cost of a resource is less than 0 or not finite.\n * - `cost-none`: a resource of a provider has no planned cost. A cost that is not known is not 0.\n * - `cost-builtin`: a resource that is a part of OpenTofu has a planned cost above 0. It counts against no account.\n * - `budget-duplicate`: two budgets name one part.\n * - `budget-amount`: the hard limit of a budget is less than 0 or not finite.\n * - `budget-none`: no budget names an account with resources. The gate has no read of its limit, so it does not pass.\n * - `limit-none`: the resources of an account have a planned cost above 0, and the account has no hard limit.\n * - `cost-over`: the planned cost of an account is more than its hard limit.\n *\n * The groups and the copies, as errors: `group-form`, `group-duplicate`, `group-shadow`, `group-none`, `param-none`,\n * `param-missing`, `param-unknown` and `copy-provider`. `groupFaults` tells each one. The gate also examines each resource of\n * each copy as a resource, so a fault of a resource of a group comes at each copy.\n *\n * The warnings:\n * - `provider-need`: the part of a resource does not need the part of its provider configuration. The stack does not show that dependence.\n * - `variable-unused`: no value reads a variable.\n * - `group-unused`: no copy names a group.\n * - `param-unused`: no resource of a group reads a parameter.\n *\n * The gate does not examine the stack: `checkStack` of the core does. The function is pure.\n */\nexport function checkTofu(layer: TofuLayer, stack: Stack, options: TofuOptions = {}): TofuFault[] {\n const faults: TofuFault[] = [];\n const add = (level: FaultLevel, code: TofuCode, at: string, message: string, more: { readonly other?: string; readonly part?: string } = {}): void => {\n faults.push({ level, code, at, message, ...more });\n };\n const error = (code: TofuCode, at: string, message: string, more: { readonly other?: string; readonly part?: string } = {}): void => {\n add(\"error\", code, at, message, more);\n };\n const money = (amount: number): string => (options.currency === undefined ? String(amount) : `${String(amount)} ${options.currency}`);\n const parts = partsById(stack);\n const addresses = new Set(firstResources(layer).map(resourceAddress));\n\n const variables = new Set<string>();\n const readVariables = new Set<string>();\n for (const variable of layer.variables ?? []) {\n const at = `var.${variable.name}`;\n if (variables.has(variable.name)) {\n error(\"variable-duplicate\", at, `Two variables have the name \"${variable.name}\".`);\n continue;\n }\n variables.add(variable.name);\n if (!NAME_FORM.test(variable.name)) error(\"variable-form\", at, `The name \"${variable.name}\" of a variable does not have the form of a name.`);\n }\n\n /** This function examines the arguments of one record. `owner` is the record in words, for a message. */\n const checkValues = (values: TofuObject | undefined, at: string, owner: string, kind: \"resource\" | \"provider\" | \"backend\", meta: readonly string[], part?: string): void => {\n if (values === undefined) return;\n const more = part === undefined ? {} : { part };\n if (isForm(values)) {\n error(\"value-form\", at, `The arguments of ${owner} have a key that starts with \"$\". The arguments of a record are not a reference and not a variable.`, more);\n return;\n }\n for (const name of Object.keys(values)) {\n if (meta.includes(name)) error(\"value-meta\", at, `The argument \"${name}\" of ${owner} is a meta-argument. The generator writes it from the records.`, more);\n else if (!NAME_FORM.test(name)) error(\"value-name\", at, `The name \"${name}\" of an argument of ${owner} does not have the form of a name.`, more);\n }\n const uses = valueUses(values);\n for (const number of uses.numbers) error(\"value-number\", at, `The number ${String(number.value)} at \"${pathText(number.path)}\" of ${owner} is not finite.`, more);\n for (const form of uses.forms) {\n const place = pathText(form.path);\n if (form.kind === \"bad\" || form.text === undefined) {\n error(\"value-form\", at, `The object at \"${place}\" of ${owner} has a key that starts with \"$\", and it is not a correct reference or variable.`, more);\n } else if (kind === \"backend\") {\n error(\"backend\", at, `The value at \"${place}\" of ${owner} is not literal. A backend reads no variable and no resource.`, more);\n } else if (form.kind === \"var\") {\n if (variables.has(form.text)) readVariables.add(form.text);\n else error(\"var-none\", at, `The value at \"${place}\" of ${owner} names the variable \"${form.text}\", which the layer does not have.`, { ...more, other: `var.${form.text}` });\n } else if (kind === \"provider\") {\n error(\"provider-value\", at, `The value at \"${place}\" of ${owner} reads the resource attribute \"${form.text}\". A provider configuration reads no resource.`, more);\n } else {\n const address = refParts(form.text)?.address ?? \"\";\n if (!addresses.has(address)) error(\"ref-none\", at, `The value at \"${place}\" of ${owner} reads \"${form.text}\", and the layer has no resource \"${address}\".`, { ...more, other: address });\n }\n }\n };\n\n if (layer.version !== undefined && !VERSION_FORM.test(layer.version)) {\n error(\"version\", \"terraform\", `The versions \"${layer.version}\" of OpenTofu do not have the form of a list of versions, for example \">= 1.8\".`);\n }\n if (layer.backend !== undefined) {\n if (!TYPE_FORM.test(layer.backend.type)) error(\"backend\", \"terraform\", `The type \"${layer.backend.type}\" of the backend does not have the form of a type.`);\n checkValues(layer.backend.values, \"terraform\", \"the backend\", \"backend\", []);\n }\n\n const providers = new Set<string>();\n const firstOfName = new Map<string, Provider>();\n for (const provider of layer.providers ?? []) {\n const address = providerAddress(provider);\n const at = `provider.${address}`;\n const more = { part: provider.part };\n if (providers.has(address)) {\n error(\"provider-duplicate\", at, `Two provider configurations have the address \"${address}\".`, more);\n continue;\n }\n providers.add(address);\n if (!PROVIDER_FORM.test(provider.name)) error(\"provider-form\", at, `The name \"${provider.name}\" of a provider does not have the form of a provider name.`, more);\n else if (provider.name === BUILTIN_PROVIDER) error(\"provider-form\", at, `The provider \"${BUILTIN_PROVIDER}\" is a part of OpenTofu. It has no configuration.`, more);\n if (provider.alias !== undefined && !NAME_FORM.test(provider.alias)) error(\"provider-form\", at, `The alias \"${provider.alias}\" of the provider \"${provider.name}\" does not have the form of a name.`, more);\n if (!SOURCE_FORM.test(provider.source)) error(\"provider-form\", at, `The source \"${provider.source}\" of the provider \"${provider.name}\" does not have the form of a source, for example \"example-org/example\".`, more);\n if (provider.version !== undefined && !VERSION_FORM.test(provider.version)) {\n error(\"provider-form\", at, `The versions \"${provider.version}\" of the provider \"${provider.name}\" do not have the form of a list of versions, for example \"~> 2.0\".`, more);\n }\n const first = firstOfName.get(provider.name);\n if (first === undefined) firstOfName.set(provider.name, provider);\n else if (first.source !== provider.source || first.version !== provider.version) {\n error(\"provider-source\", at, `Two configurations of the provider \"${provider.name}\" have different sources or versions. A provider has one source and one list of versions.`, more);\n }\n if (!parts.has(provider.part)) error(\"provider-part\", at, `The provider configuration \"${address}\" names \"${provider.part}\", which is no part of the stack.`, { ...more, other: provider.part });\n checkValues(provider.values, at, `the provider configuration \"${address}\"`, \"provider\", PROVIDER_META, provider.part);\n }\n\n const seen = new Set<string>();\n for (const resource of layerResources(layer)) {\n const at = resourceAddress(resource);\n const more = { part: resource.part };\n if (seen.has(at)) {\n error(\"resource-duplicate\", at, `Two resources have the address \"${at}\".`, more);\n continue;\n }\n seen.add(at);\n if (!TYPE_FORM.test(resource.type)) error(\"resource-form\", at, `The type \"${resource.type}\" of a resource of \"${resource.part}\" does not have the form of a type.`, more);\n if (!NAME_FORM.test(resourceName(resource))) error(\"resource-form\", at, `The name \"${resourceName(resource)}\" of a resource of \"${resource.part}\" does not have the form of a name.`, more);\n if (resource.import === \"\") error(\"resource-form\", at, `The import id of the resource \"${at}\" is empty.`, more);\n if (!parts.has(resource.part)) error(\"resource-part\", at, `The resource \"${at}\" names \"${resource.part}\", which is no part of the stack.`, { ...more, other: resource.part });\n for (const path of resource.ignore ?? []) {\n if (!PATH_FORM.test(path)) error(\"ignore-form\", at, `The attribute \"${path}\" of the field \"ignore\" of the resource \"${at}\" does not have the form of a path.`, more);\n }\n checkValues(resource.values, at, `the resource \"${at}\"`, \"resource\", RESOURCE_META, resource.part);\n\n const builtin = isBuiltin(resource);\n const provider = builtin ? undefined : resourceProvider(layer, resource);\n if (!builtin && provider === undefined) {\n const wanted = resource.provider ?? typeProvider(resource.type);\n error(\"provider-none\", at, `The resource \"${at}\" uses the provider configuration \"${wanted}\", which the layer does not have.`, more);\n }\n if (resource.cost !== undefined && !isZeroOrMore(resource.cost)) {\n error(\"cost-amount\", at, `The planned cost ${String(resource.cost)} of the resource \"${at}\" is less than 0 or not finite.`, more);\n } else if (builtin) {\n if (resource.cost !== undefined && resource.cost > 0) {\n error(\"cost-builtin\", at, `The resource \"${at}\" is a part of OpenTofu, and its record has a planned cost of ${money(resource.cost)}. It counts against no account.`, more);\n }\n } else if (resource.cost === undefined) {\n error(\"cost-none\", at, `The resource \"${at}\" has no planned cost. A cost that is not known is not 0: give the cost of a month, or 0 for a resource with no price.`, more);\n }\n if (provider !== undefined && provider.part !== resource.part && parts.has(resource.part) && parts.has(provider.part) && !neededParts(stack, resource.part).has(provider.part)) {\n add(\n \"warning\",\n \"provider-need\",\n at,\n `The resource \"${at}\" makes the part \"${resource.part}\" with the provider configuration of \"${provider.part}\", and \"${resource.part}\" does not need \"${provider.part}\" in the stack.`,\n { ...more, other: provider.part },\n );\n }\n }\n faults.push(...groupFaults(layer));\n\n for (const cycle of resourceCycles(layer, stack)) {\n const [first = \"\", second] = cycle;\n const message = cycle.length === 1 ? `The resource \"${first}\" reads its own attribute, so OpenTofu cannot make it.` : `The resources ${names(cycle)} wait for each other, so OpenTofu can make none of them.`;\n error(\"cycle\", first, message, second === undefined ? {} : { other: second });\n }\n\n const budgets = options.budgets ?? [];\n const budgetParts = new Set<string>();\n const wrongBudgets = new Set<string>();\n for (const budget of budgets) {\n if (budgetParts.has(budget.part)) {\n error(\"budget-duplicate\", budget.part, `Two budgets name the part \"${budget.part}\".`, { part: budget.part });\n continue;\n }\n budgetParts.add(budget.part);\n if (budget.hardLimit !== undefined && !isZeroOrMore(budget.hardLimit)) {\n wrongBudgets.add(budget.part);\n error(\"budget-amount\", budget.part, `The hard limit ${String(budget.hardLimit)} of the budget of \"${budget.part}\" is less than 0 or not finite.`, { part: budget.part });\n }\n }\n for (const state of accountStates(layer, budgets)) {\n const at = state.part;\n const more = { part: at };\n if (!budgetParts.has(at)) {\n error(\"budget-none\", at, `The resources ${names(state.resources)} count against \"${at}\", and no budget names \"${at}\". The gate has no read of its limit.`, more);\n } else if (state.limit === undefined) {\n // A hard limit with a wrong amount has its own fault.\n if (state.planned > 0 && !wrongBudgets.has(at)) error(\"limit-none\", at, `The planned cost of the resources of \"${at}\" is ${money(state.planned)} for a month, and \"${at}\" has no hard limit.`, more);\n } else if (state.over === true) {\n error(\"cost-over\", at, `The planned cost of the resources of \"${at}\" is ${money(state.planned)} for a month. Its hard limit is ${money(state.limit)}.`, more);\n }\n }\n\n for (const name of variables) {\n if (!readVariables.has(name)) add(\"warning\", \"variable-unused\", `var.${name}`, `No value reads the variable \"${name}\".`);\n }\n return faults;\n}\n","import { joinRecords, joinSetting, type LayerParse, type LayerPiece } from \"@mark1russell7/system-stack\";\nimport { copyName, providerAddress, resourceAddress, TOFU_SCHEMA, type TofuLayer } from \"./layer.ts\";\n\n// The join of the OpenTofu layers of the fragments of a stack, for example one file of resources for each owner.\n\n/**\n * This function joins the OpenTofu layers of the fragments of a stack into one layer.\n *\n * - The resources, the provider configurations and the variables are in the order of the fragments.\n * - A resource address in two or more fragments is a fault, also when the resources are equal.\n * - The same rule holds for the address of a provider configuration, the name of a variable, of a group and of a copy.\n * - The layer has one version of OpenTofu. A fragment with a different value is a fault.\n * - The state has one place. Thus a backend in two or more fragments is a fault, also when the backends are equal.\n *\n * A resource of one fragment can use a provider configuration or a variable of a different fragment.\n * A copy of one fragment can name a group of a different fragment.\n * The joined layer has the field `providers`, `variables`, `groups` or `copies` when a fragment has it. The function is pure, and it\n * changes no layer. The gate `checkTofu` examines the joined layer afterward.\n *\n * @param pieces - The layers, with the name of the fragment of each one, in the order of the fragments.\n * @returns The joined layer, or the faults of the join.\n */\nexport function joinTofu(pieces: readonly LayerPiece<TofuLayer>[]): LayerParse<TofuLayer> {\n const version = joinSetting(pieces, (layer) => layer.version, \"version of OpenTofu\");\n const backends = pieces.filter((piece) => piece.layer.backend !== undefined);\n const providers = joinRecords(pieces, (layer) => layer.providers, providerAddress, \"provider configuration\");\n const variables = joinRecords(\n pieces,\n (layer) => layer.variables,\n (variable) => variable.name,\n \"variable\",\n );\n const resources = joinRecords(pieces, (layer) => layer.resources, resourceAddress, \"resource\");\n const groups = joinRecords(\n pieces,\n (layer) => layer.groups,\n (group) => group.name,\n \"group\",\n );\n const copies = joinRecords(pieces, (layer) => layer.copies, copyName, \"copy\");\n const errors = [...version.errors];\n if (backends.length > 1) errors.push(`The fragments ${backends.map((piece) => `\"${piece.from}\"`).join(\", \")} each have a backend. The state has one place.`);\n errors.push(...providers.errors, ...variables.errors, ...resources.errors, ...groups.errors, ...copies.errors);\n if (errors.length > 0) return { ok: false, errors };\n const backend = backends[0]?.layer.backend;\n return {\n ok: true,\n layer: {\n schema: TOFU_SCHEMA,\n ...(version.value === undefined ? {} : { version: version.value }),\n ...(backend === undefined ? {} : { backend }),\n ...(pieces.some((piece) => piece.layer.providers !== undefined) ? { providers: providers.items } : {}),\n ...(pieces.some((piece) => piece.layer.variables !== undefined) ? { variables: variables.items } : {}),\n resources: resources.items,\n ...(pieces.some((piece) => piece.layer.groups !== undefined) ? { groups: groups.items } : {}),\n ...(pieces.some((piece) => piece.layer.copies !== undefined) ? { copies: copies.items } : {}),\n },\n };\n}\n"],"mappings":";;;;;;;AAMA,MAAa,YAAoB;;AAGjC,MAAa,gBAAwB;;AAGrC,MAAa,YAAoB;;;;;AAMjC,MAAa,YAAoB;;AAGjC,MAAa,cAAsB;;AAGnC,MAAa,eAAuB;;;;;AAYpC,SAAgB,SAAS,KAAmC;CAC1D,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,IAAI,MAAM,GAAG;CAC3C,IAAI,SAAS,KAAA,KAAa,SAAS,KAAA,KAAa,KAAK,WAAW,GAAG,OAAO,KAAA;CAE1E,MAAM,YAAY,KAAK,KAAK,GAAG;CAC/B,IAAI,CAAC,UAAU,KAAK,IAAI,KAAK,CAAC,UAAU,KAAK,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS,GAAG,OAAO,KAAA;CACzF,OAAO;EAAE,SAAS,GAAG,KAAK,GAAG;EAAQ;CAAU;AACjD;;AAGA,SAAgB,OAAO,OAAiD;CACtE,OAAO,MAAM,QAAQ,KAAK;AAC5B;;AAGA,SAAgB,SAAS,OAAuC;CAC9D,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;AAGA,SAAgB,OAAO,OAA4B;CACjD,OAAO,OAAO,KAAK,KAAK,CAAC,CAAC,MAAM,QAAQ,IAAI,WAAW,GAAG,CAAC;AAC7D;;AAGA,SAAS,SAAS,OAAmB,KAAiC;C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