@intentius/chant 0.1.1 → 0.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "description": "Declarative infrastructure-as-code toolkit — TypeScript on Bun",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -21,7 +21,7 @@ export class LexiconOutput implements Intrinsic {
21
21
  /** @internal Intrinsic value when constructed from an Intrinsic rather than AttrRef */
22
22
  private readonly _intrinsic: Intrinsic | null;
23
23
 
24
- constructor(ref: AttrRef | Intrinsic, name: string) {
24
+ constructor(ref: AttrRef | Intrinsic | string, name: string) {
25
25
  if (ref instanceof AttrRef) {
26
26
  const parent = ref.parent.deref();
27
27
  if (!parent) {
@@ -40,12 +40,14 @@ export class LexiconOutput implements Intrinsic {
40
40
  this._intrinsic = null;
41
41
  } else {
42
42
  // Intrinsic (Sub, Join, Ref, etc.) — no parent entity tracking needed
43
+ // Note: `string` in the union is for attribute accessors typed as string at the
44
+ // TypeScript level (they are AttrRef at runtime, caught by instanceof above).
43
45
  this.sourceLexicon = "";
44
46
  this.sourceEntity = "";
45
47
  this.sourceAttribute = null;
46
48
  this.outputName = name;
47
49
  this._sourceParent = null;
48
- this._intrinsic = ref;
50
+ this._intrinsic = typeof ref !== "string" ? ref : null;
49
51
  }
50
52
  }
51
53
 
@@ -103,7 +105,7 @@ export class LexiconOutput implements Intrinsic {
103
105
  * const solrUrl = output(Sub`http://${Ref(albDnsName)}/solr`, "solrUrl");
104
106
  * ```
105
107
  */
106
- export function output(ref: AttrRef | Intrinsic, name: string): LexiconOutput {
108
+ export function output(ref: AttrRef | Intrinsic | string, name: string): LexiconOutput {
107
109
  return new LexiconOutput(ref, name);
108
110
  }
109
111
 
package/src/runtime.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * lexicon, entityType, kind, and attribute references.
6
6
  */
7
7
 
8
- import { DECLARABLE_MARKER } from "./declarable";
8
+ import { DECLARABLE_MARKER, type Declarable } from "./declarable";
9
9
  import { AttrRef } from "./attrref";
10
10
 
11
11
  /**
@@ -22,7 +22,7 @@ export function createResource(
22
22
  type: string,
23
23
  lexicon: string,
24
24
  attrMap: Record<string, string>,
25
- ): new (props: Record<string, unknown>, attributes?: Record<string, unknown>) => Record<string, unknown> {
25
+ ): new (props: Record<string, unknown>, attributes?: Record<string, unknown>) => Declarable & Record<string, string> {
26
26
  const ResourceClass = function (this: Record<string, unknown>, props: Record<string, unknown>, attributes?: Record<string, unknown>) {
27
27
  Object.defineProperty(this, DECLARABLE_MARKER, { value: true, enumerable: false });
28
28
  Object.defineProperty(this, "lexicon", { value: lexicon, enumerable: false });
@@ -44,7 +44,7 @@ export function createResource(
44
44
  writable: false,
45
45
  });
46
46
  }
47
- } as unknown as new (props: Record<string, unknown>, attributes?: Record<string, unknown>) => Record<string, unknown>;
47
+ } as unknown as new (props: Record<string, unknown>, attributes?: Record<string, unknown>) => Declarable & Record<string, string>;
48
48
 
49
49
  // Set the constructor name for debugging
50
50
  Object.defineProperty(ResourceClass, "name", { value: type.split("::").pop() ?? type });
package/src/yaml.ts CHANGED
@@ -188,7 +188,10 @@ export function parseYAMLLines(
188
188
  if (i + 1 < lines.length) {
189
189
  const nextLine = lines[i + 1];
190
190
  const nextIndent = nextLine.search(/\S/);
191
- if (nextIndent > indent && nextLine.trimStart().startsWith("- ")) {
191
+ if (nextLine.trimStart().startsWith("- ") && nextIndent >= indent) {
192
+ // Same-indent arrays are valid YAML (e.g. controller-gen output):
193
+ // versions:
194
+ // - name: v1
192
195
  const arr = parseYAMLArray(lines, i + 1, nextIndent);
193
196
  result[key] = arr.value;
194
197
  i = arr.endIndex;