gagen 0.2.16 → 0.2.18

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.
@@ -20,6 +20,25 @@ export declare class ExpressionValue {
20
20
  startsWith(prefix: string): Condition;
21
21
  contains(substring: string): Condition;
22
22
  not(): Condition;
23
+ /** concatenate this value with additional strings, numbers, or expressions */
24
+ concat(...parts: ConcatPart[]): ExpressionValue;
25
+ /** add this value with additional numbers or expressions */
26
+ add(...parts: AddPart[]): ExpressionValue;
27
+ /** subtract a number or expression from this value */
28
+ subtract(right: AddPart): ExpressionValue;
29
+ /** multiply this value with additional numbers or expressions */
30
+ multiply(...parts: AddPart[]): ExpressionValue;
31
+ /** divide this value by a number or expression */
32
+ divide(right: AddPart): ExpressionValue;
33
+ /** compute the remainder of this value divided by a number or expression */
34
+ modulo(right: AddPart): ExpressionValue;
35
+ endsWith(suffix: string): Condition;
36
+ greaterThan(value: number): Condition;
37
+ greaterThanOrEqual(value: number): Condition;
38
+ lessThan(value: number): Condition;
39
+ lessThanOrEqual(value: number): Condition;
40
+ /** serialize this value as JSON */
41
+ toJSON(): ExpressionValue;
23
42
  /** wrap in `${{ }}` for use in YAML */
24
43
  toString(): string;
25
44
  }
@@ -63,10 +82,12 @@ export declare abstract class Condition {
63
82
  /** render wrapped in `${{ }}` for YAML `if` fields */
64
83
  toString(): string;
65
84
  }
66
- /** `left == right` or `left != right` */
85
+ /** comparison operators supported in GitHub Actions expressions */
86
+ export type ComparisonOp = "==" | "!=" | ">" | ">=" | "<" | "<=";
87
+ /** `left op right` where op is ==, !=, >, >=, <, or <= */
67
88
  export declare class ComparisonCondition extends Condition {
68
89
  #private;
69
- constructor(left: string, op: "==" | "!=", right: string | number | boolean, sources: ReadonlySet<ExpressionSource>);
90
+ constructor(left: string, op: ComparisonOp, right: string | number | boolean, sources: ReadonlySet<ExpressionSource>);
70
91
  not(): Condition;
71
92
  toExpression(): string;
72
93
  }
@@ -225,6 +246,113 @@ export declare class ElseIfBuilder {
225
246
  /** Provide the value for this branch. */
226
247
  then(value: TernaryValue): ThenBuilder;
227
248
  }
249
+ /** a part of a concatenation: plain string, number, or expression */
250
+ export type ConcatPart = string | number | ExpressionValue;
251
+ /**
252
+ * Concatenates strings, numbers, and expressions into a single value.
253
+ * Expression parts are wrapped in `${{ }}` when serialized for YAML,
254
+ * and use the `format()` function when used inside expression contexts.
255
+ *
256
+ * ```ts
257
+ * const name = concat("build-", expr("matrix.os"));
258
+ * name.toString() // => "build-${{ matrix.os }}"
259
+ * name.expression // => "format('build-{0}', matrix.os)"
260
+ *
261
+ * const full = concat("build-", expr("matrix.os"), "-", expr("matrix.arch"));
262
+ * full.toString() // => "build-${{ matrix.os }}-${{ matrix.arch }}"
263
+ * ```
264
+ */
265
+ export declare function concat(...parts: ConcatPart[]): ExpressionValue;
266
+ /** a part of an addition: plain number or expression */
267
+ export type AddPart = number | ExpressionValue;
268
+ /**
269
+ * Adds numbers and expressions together. Uses the `+` operator in GitHub
270
+ * Actions expression contexts.
271
+ *
272
+ * ```ts
273
+ * const total = add(1, expr("matrix.count"));
274
+ * total.toString() // => "${{ 1 + matrix.count }}"
275
+ * total.expression // => "1 + matrix.count"
276
+ *
277
+ * const sum = add(expr("steps.a.outputs.x"), expr("steps.b.outputs.y"), 10);
278
+ * sum.toString() // => "${{ steps.a.outputs.x + steps.b.outputs.y + 10 }}"
279
+ * ```
280
+ */
281
+ export declare function add(...parts: AddPart[]): ExpressionValue;
282
+ /**
283
+ * Subtracts the right operand from the left. Uses the `-` operator in GitHub
284
+ * Actions expression contexts.
285
+ *
286
+ * ```ts
287
+ * const diff = subtract(expr("matrix.total"), 1);
288
+ * diff.toString() // => "${{ matrix.total - 1 }}"
289
+ * diff.expression // => "matrix.total - 1"
290
+ * ```
291
+ */
292
+ export declare function subtract(left: AddPart, right: AddPart): ExpressionValue;
293
+ /**
294
+ * Multiplies numbers and expressions together. Uses the `*` operator in GitHub
295
+ * Actions expression contexts.
296
+ *
297
+ * ```ts
298
+ * const total = multiply(expr("matrix.count"), 2);
299
+ * total.toString() // => "${{ matrix.count * 2 }}"
300
+ * total.expression // => "matrix.count * 2"
301
+ * ```
302
+ */
303
+ export declare function multiply(...parts: AddPart[]): ExpressionValue;
304
+ /**
305
+ * Divides the left operand by the right. Uses the `/` operator in GitHub
306
+ * Actions expression contexts.
307
+ *
308
+ * ```ts
309
+ * const half = divide(expr("matrix.total"), 2);
310
+ * half.toString() // => "${{ matrix.total / 2 }}"
311
+ * ```
312
+ */
313
+ export declare function divide(left: AddPart, right: AddPart): ExpressionValue;
314
+ /**
315
+ * Computes the remainder of the left operand divided by the right. Uses the
316
+ * `%` operator in GitHub Actions expression contexts.
317
+ *
318
+ * ```ts
319
+ * const rem = modulo(expr("matrix.index"), 2);
320
+ * rem.toString() // => "${{ matrix.index % 2 }}"
321
+ * ```
322
+ */
323
+ export declare function modulo(left: AddPart, right: AddPart): ExpressionValue;
324
+ /**
325
+ * Parses a JSON string into an object/value. Wraps in `fromJSON()` in GitHub
326
+ * Actions expression contexts.
327
+ *
328
+ * ```ts
329
+ * const matrix = fromJSON(expr("needs.setup.outputs.matrix"));
330
+ * matrix.toString() // => "${{ fromJSON(needs.setup.outputs.matrix) }}"
331
+ * ```
332
+ */
333
+ export declare function fromJSON(value: string | ExpressionValue): ExpressionValue;
334
+ /**
335
+ * Serializes a value to JSON. Wraps in `toJSON()` in GitHub Actions expression
336
+ * contexts.
337
+ *
338
+ * ```ts
339
+ * const json = toJSON(expr("github.event"));
340
+ * json.toString() // => "${{ toJSON(github.event) }}"
341
+ * ```
342
+ */
343
+ export declare function toJSON(value: ExpressionValue): ExpressionValue;
344
+ /** Computes a hash of files matching the given glob patterns. */
345
+ export declare function hashFiles(...patterns: (string | ExpressionValue)[]): ExpressionValue;
346
+ /**
347
+ * Joins an array expression with an optional separator. Wraps in `join()` in
348
+ * GitHub Actions expression contexts.
349
+ *
350
+ * ```ts
351
+ * const labels = join(expr("github.event.pull_request.labels.*.name"), ", ");
352
+ * labels.toString() // => "${{ join(github.event.pull_request.labels.*.name, ', ') }}"
353
+ * ```
354
+ */
355
+ export declare function join(value: ExpressionValue, separator?: string): ExpressionValue;
228
356
  /** Creates an ExpressionValue or Condition from a literal value. */
229
357
  export declare function literal(value: boolean): Condition;
230
358
  export declare function literal(value: string | number): ExpressionValue;
@@ -1 +1 @@
1
- {"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../src/expression.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,gBAAgB,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAIvD,wEAAwE;AACxE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,eAAe,CAAC;AAEvE;;;GAGG;AACH,qBAAa,eAAe;;IAE1B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAAC;gBAI5C,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,gBAAgB,GAAG,WAAW,CAAC,gBAAgB,CAAC;IAa3D,sDAAsD;IACtD,IAAI,UAAU,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAE9C;IAED,oDAAoD;IACpD,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS;IASnD,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS;IAStD,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IAQrC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IAQtC,GAAG,IAAI,SAAS;IAIhB,uCAAuC;IACvC,QAAQ,IAAI,MAAM;CAGnB;AAED;;;;GAIG;AACH,8BAAsB,SAAS;IAC7B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC;gBAEpC,OAAO,EAAE,WAAW,C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nG,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,SAAS,GACjE,eAAe,CAAC;AAEpB,2EAA2E;AAC3E,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACvD,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnE,GAAG,EAAE,CAAC,GACL,OAAO,CAAC,CAAC,CAAC,CAkBZ"}
package/esm/expression.js CHANGED
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _ExpressionValue_expression, _ExpressionValue_allSources, _ComparisonCondition_left, _ComparisonCondition_op, _ComparisonCondition_right, _FunctionCallCondition_fn, _FunctionCallCondition_args, _LogicalCondition_instances, _a, _LogicalCondition_left, _LogicalCondition_right, _LogicalCondition_needsParens, _NotCondition_inner, _RawCondition_expression, _ThenBuilder_branches, _ThenBuilder_sources, _ElseIfBuilder_branches, _ElseIfBuilder_sources, _ElseIfBuilder_condition, _InlineValue_plainValue;
12
+ var _ExpressionValue_expression, _ExpressionValue_allSources, _ComparisonCondition_left, _ComparisonCondition_op, _ComparisonCondition_right, _FunctionCallCondition_fn, _FunctionCallCondition_args, _LogicalCondition_instances, _a, _LogicalCondition_left, _LogicalCondition_right, _LogicalCondition_needsParens, _NotCondition_inner, _RawCondition_expression, _ThenBuilder_branches, _ThenBuilder_sources, _ElseIfBuilder_branches, _ElseIfBuilder_sources, _ElseIfBuilder_condition, _ConcatValue_parts, _AddValue_parts, _MultiplyValue_parts, _InlineValue_plainValue;
13
13
  const EMPTY_SOURCES = new Set();
14
14
  /**
15
15
  * An expression that resolves to a value inside a GitHub Actions workflow.
@@ -69,6 +69,49 @@ export class ExpressionValue {
69
69
  not() {
70
70
  return new RawCondition(`!(${__classPrivateFieldGet(this, _ExpressionValue_expression, "f")})`, sourcesFrom(this));
71
71
  }
72
+ /** concatenate this value with additional strings, numbers, or expressions */
73
+ concat(...parts) {
74
+ return concat(this, ...parts);
75
+ }
76
+ /** add this value with additional numbers or expressions */
77
+ add(...parts) {
78
+ return add(this, ...parts);
79
+ }
80
+ /** subtract a number or expression from this value */
81
+ subtract(right) {
82
+ return subtract(this, right);
83
+ }
84
+ /** multiply this value with additional numbers or expressions */
85
+ multiply(...parts) {
86
+ return multiply(this, ...parts);
87
+ }
88
+ /** divide this value by a number or expression */
89
+ divide(right) {
90
+ return divide(this, right);
91
+ }
92
+ /** compute the remainder of this value divided by a number or expression */
93
+ modulo(right) {
94
+ return modulo(this, right);
95
+ }
96
+ endsWith(suffix) {
97
+ return new FunctionCallCondition("endsWith", [__classPrivateFieldGet(this, _ExpressionValue_expression, "f"), formatLiteral(suffix)], sourcesFrom(this));
98
+ }
99
+ greaterThan(value) {
100
+ return new ComparisonCondition(__classPrivateFieldGet(this, _ExpressionValue_expression, "f"), ">", value, sourcesFrom(this));
101
+ }
102
+ greaterThanOrEqual(value) {
103
+ return new ComparisonCondition(__classPrivateFieldGet(this, _ExpressionValue_expression, "f"), ">=", value, sourcesFrom(this));
104
+ }
105
+ lessThan(value) {
106
+ return new ComparisonCondition(__classPrivateFieldGet(this, _ExpressionValue_expression, "f"), "<", value, sourcesFrom(this));
107
+ }
108
+ lessThanOrEqual(value) {
109
+ return new ComparisonCondition(__classPrivateFieldGet(this, _ExpressionValue_expression, "f"), "<=", value, sourcesFrom(this));
110
+ }
111
+ /** serialize this value as JSON */
112
+ toJSON() {
113
+ return toJSON(this);
114
+ }
72
115
  /** wrap in `${{ }}` for use in YAML */
73
116
  toString() {
74
117
  return `\${{ ${__classPrivateFieldGet(this, _ExpressionValue_expression, "f")} }}`;
@@ -162,8 +205,15 @@ export class Condition {
162
205
  return `\${{ ${this.toExpression()} }}`;
163
206
  }
164
207
  }
165
- // --- concrete condition types ---
166
- /** `left == right` or `left != right` */
208
+ const NEGATED_OP = {
209
+ "==": "!=",
210
+ "!=": "==",
211
+ ">": "<=",
212
+ ">=": "<",
213
+ "<": ">=",
214
+ "<=": ">",
215
+ };
216
+ /** `left op right` where op is ==, !=, >, >=, <, or <= */
167
217
  export class ComparisonCondition extends Condition {
168
218
  constructor(left, op, right, sources) {
169
219
  super(sources);
@@ -175,7 +225,7 @@ export class ComparisonCondition extends Condition {
175
225
  __classPrivateFieldSet(this, _ComparisonCondition_right, right, "f");
176
226
  }
177
227
  not() {
178
- return new ComparisonCondition(__classPrivateFieldGet(this, _ComparisonCondition_left, "f"), __classPrivateFieldGet(this, _ComparisonCondition_op, "f") === "==" ? "!=" : "==", __classPrivateFieldGet(this, _ComparisonCondition_right, "f"), this.sources);
228
+ return new ComparisonCondition(__classPrivateFieldGet(this, _ComparisonCondition_left, "f"), NEGATED_OP[__classPrivateFieldGet(this, _ComparisonCondition_op, "f")], __classPrivateFieldGet(this, _ComparisonCondition_right, "f"), this.sources);
179
229
  }
180
230
  toExpression() {
181
231
  return `${__classPrivateFieldGet(this, _ComparisonCondition_left, "f")} ${__classPrivateFieldGet(this, _ComparisonCondition_op, "f")} ${formatLiteral(__classPrivateFieldGet(this, _ComparisonCondition_right, "f"))}`;
@@ -575,6 +625,416 @@ export class ElseIfBuilder {
575
625
  }
576
626
  }
577
627
  _ElseIfBuilder_branches = new WeakMap(), _ElseIfBuilder_sources = new WeakMap(), _ElseIfBuilder_condition = new WeakMap();
628
+ /**
629
+ * Concatenates strings, numbers, and expressions into a single value.
630
+ * Expression parts are wrapped in `${{ }}` when serialized for YAML,
631
+ * and use the `format()` function when used inside expression contexts.
632
+ *
633
+ * ```ts
634
+ * const name = concat("build-", expr("matrix.os"));
635
+ * name.toString() // => "build-${{ matrix.os }}"
636
+ * name.expression // => "format('build-{0}', matrix.os)"
637
+ *
638
+ * const full = concat("build-", expr("matrix.os"), "-", expr("matrix.arch"));
639
+ * full.toString() // => "build-${{ matrix.os }}-${{ matrix.arch }}"
640
+ * ```
641
+ */
642
+ export function concat(...parts) {
643
+ if (parts.length === 0) {
644
+ return new InlineValue("");
645
+ }
646
+ if (parts.length === 1) {
647
+ const p = parts[0];
648
+ if (p instanceof ExpressionValue)
649
+ return p;
650
+ return new InlineValue(String(p));
651
+ }
652
+ // flatten nested ConcatValues, inline literals, and convert numbers to strings
653
+ const flat = [];
654
+ for (const part of parts) {
655
+ if (part instanceof ConcatValue) {
656
+ flat.push(...part.concatParts);
657
+ }
658
+ else if (part instanceof InlineValue) {
659
+ flat.push(part.toString());
660
+ }
661
+ else if (typeof part === "number") {
662
+ flat.push(String(part));
663
+ }
664
+ else {
665
+ flat.push(part);
666
+ }
667
+ }
668
+ // merge adjacent string parts
669
+ const merged = [];
670
+ for (const part of flat) {
671
+ const last = merged.length > 0 ? merged[merged.length - 1] : undefined;
672
+ if (typeof part === "string" && typeof last === "string") {
673
+ merged[merged.length - 1] = last + part;
674
+ }
675
+ else {
676
+ merged.push(part);
677
+ }
678
+ }
679
+ // degenerate cases after merging
680
+ if (merged.length === 1) {
681
+ const p = merged[0];
682
+ if (typeof p === "string")
683
+ return new InlineValue(p);
684
+ return p;
685
+ }
686
+ // collect sources from all expression parts
687
+ const sources = new Set();
688
+ for (const part of merged) {
689
+ if (part instanceof ExpressionValue) {
690
+ for (const s of part.allSources)
691
+ sources.add(s);
692
+ }
693
+ }
694
+ // build format() expression for use inside ${{ }} contexts
695
+ const templateParts = [];
696
+ const args = [];
697
+ let argIndex = 0;
698
+ for (const part of merged) {
699
+ if (part instanceof ExpressionValue) {
700
+ templateParts.push(`{${argIndex++}}`);
701
+ args.push(part.expression);
702
+ }
703
+ else {
704
+ // escape single quotes and braces for GitHub Actions format()
705
+ templateParts.push(part.replace(/'/g, "''").replace(/\{/g, "{{").replace(/\}/g, "}}"));
706
+ }
707
+ }
708
+ const formatExpr = `format('${templateParts.join("")}', ${args.join(", ")})`;
709
+ return new ConcatValue(formatExpr, merged, sources);
710
+ }
711
+ class ConcatValue extends ExpressionValue {
712
+ constructor(formatExpr, parts, sources) {
713
+ super(formatExpr, sources);
714
+ _ConcatValue_parts.set(this, void 0);
715
+ __classPrivateFieldSet(this, _ConcatValue_parts, Object.freeze([...parts]), "f");
716
+ }
717
+ /** the individual parts of this concatenation (for flattening nested concats) */
718
+ get concatParts() {
719
+ return __classPrivateFieldGet(this, _ConcatValue_parts, "f");
720
+ }
721
+ toString() {
722
+ return __classPrivateFieldGet(this, _ConcatValue_parts, "f")
723
+ .map((p) => (p instanceof ExpressionValue ? p.toString() : p))
724
+ .join("");
725
+ }
726
+ }
727
+ _ConcatValue_parts = new WeakMap();
728
+ /**
729
+ * Adds numbers and expressions together. Uses the `+` operator in GitHub
730
+ * Actions expression contexts.
731
+ *
732
+ * ```ts
733
+ * const total = add(1, expr("matrix.count"));
734
+ * total.toString() // => "${{ 1 + matrix.count }}"
735
+ * total.expression // => "1 + matrix.count"
736
+ *
737
+ * const sum = add(expr("steps.a.outputs.x"), expr("steps.b.outputs.y"), 10);
738
+ * sum.toString() // => "${{ steps.a.outputs.x + steps.b.outputs.y + 10 }}"
739
+ * ```
740
+ */
741
+ export function add(...parts) {
742
+ if (parts.length === 0) {
743
+ return new InlineValue(0);
744
+ }
745
+ if (parts.length === 1) {
746
+ const p = parts[0];
747
+ if (p instanceof ExpressionValue)
748
+ return p;
749
+ return new InlineValue(p);
750
+ }
751
+ // flatten nested AddValues and collect all terms
752
+ const flat = [];
753
+ for (const part of parts) {
754
+ if (part instanceof AddValue) {
755
+ flat.push(...part.addParts);
756
+ }
757
+ else if (part instanceof InlineValue) {
758
+ // extract the numeric value from InlineValue
759
+ const n = Number(part.expression);
760
+ if (!Number.isNaN(n)) {
761
+ flat.push(n);
762
+ }
763
+ else {
764
+ flat.push(part);
765
+ }
766
+ }
767
+ else {
768
+ flat.push(part);
769
+ }
770
+ }
771
+ // merge adjacent numbers
772
+ const merged = [];
773
+ for (const part of flat) {
774
+ const last = merged.length > 0 ? merged[merged.length - 1] : undefined;
775
+ if (typeof part === "number" && typeof last === "number") {
776
+ merged[merged.length - 1] = last + part;
777
+ }
778
+ else {
779
+ merged.push(part);
780
+ }
781
+ }
782
+ // degenerate cases after merging
783
+ if (merged.length === 1) {
784
+ const p = merged[0];
785
+ if (typeof p === "number")
786
+ return new InlineValue(p);
787
+ return p;
788
+ }
789
+ // collect sources from all expression parts
790
+ const sources = new Set();
791
+ for (const part of merged) {
792
+ if (part instanceof ExpressionValue) {
793
+ for (const s of part.allSources)
794
+ sources.add(s);
795
+ }
796
+ }
797
+ // build expression using + operator
798
+ const exprParts = merged.map((p) => p instanceof ExpressionValue ? p.expression : String(p));
799
+ const addExpr = exprParts.join(" + ");
800
+ return new AddValue(addExpr, merged, sources);
801
+ }
802
+ class AddValue extends ExpressionValue {
803
+ constructor(addExpr, parts, sources) {
804
+ super(addExpr, sources);
805
+ _AddValue_parts.set(this, void 0);
806
+ __classPrivateFieldSet(this, _AddValue_parts, Object.freeze([...parts]), "f");
807
+ }
808
+ /** the individual parts of this addition (for flattening nested adds) */
809
+ get addParts() {
810
+ return __classPrivateFieldGet(this, _AddValue_parts, "f");
811
+ }
812
+ }
813
+ _AddValue_parts = new WeakMap();
814
+ // --- numeric subtraction ---
815
+ /**
816
+ * Subtracts the right operand from the left. Uses the `-` operator in GitHub
817
+ * Actions expression contexts.
818
+ *
819
+ * ```ts
820
+ * const diff = subtract(expr("matrix.total"), 1);
821
+ * diff.toString() // => "${{ matrix.total - 1 }}"
822
+ * diff.expression // => "matrix.total - 1"
823
+ * ```
824
+ */
825
+ export function subtract(left, right) {
826
+ // both literal numbers → compute at build time
827
+ if (typeof left === "number" && typeof right === "number") {
828
+ return new InlineValue(left - right);
829
+ }
830
+ const lhs = typeof left === "number" ? new InlineValue(left) : left;
831
+ const rhs = typeof right === "number" ? new InlineValue(right) : right;
832
+ const sources = new Set();
833
+ for (const s of lhs.allSources)
834
+ sources.add(s);
835
+ for (const s of rhs.allSources)
836
+ sources.add(s);
837
+ const subExpr = `${lhs.expression} - ${rhs.expression}`;
838
+ return new ExpressionValue(subExpr, sources);
839
+ }
840
+ // --- numeric multiplication ---
841
+ /**
842
+ * Multiplies numbers and expressions together. Uses the `*` operator in GitHub
843
+ * Actions expression contexts.
844
+ *
845
+ * ```ts
846
+ * const total = multiply(expr("matrix.count"), 2);
847
+ * total.toString() // => "${{ matrix.count * 2 }}"
848
+ * total.expression // => "matrix.count * 2"
849
+ * ```
850
+ */
851
+ export function multiply(...parts) {
852
+ if (parts.length === 0) {
853
+ return new InlineValue(1);
854
+ }
855
+ if (parts.length === 1) {
856
+ const p = parts[0];
857
+ if (p instanceof ExpressionValue)
858
+ return p;
859
+ return new InlineValue(p);
860
+ }
861
+ // flatten nested MultiplyValues and collect all terms
862
+ const flat = [];
863
+ for (const part of parts) {
864
+ if (part instanceof MultiplyValue) {
865
+ flat.push(...part.multiplyParts);
866
+ }
867
+ else if (part instanceof InlineValue) {
868
+ const n = Number(part.expression);
869
+ if (!Number.isNaN(n)) {
870
+ flat.push(n);
871
+ }
872
+ else {
873
+ flat.push(part);
874
+ }
875
+ }
876
+ else {
877
+ flat.push(part);
878
+ }
879
+ }
880
+ // merge adjacent numbers
881
+ const merged = [];
882
+ for (const part of flat) {
883
+ const last = merged.length > 0 ? merged[merged.length - 1] : undefined;
884
+ if (typeof part === "number" && typeof last === "number") {
885
+ merged[merged.length - 1] = last * part;
886
+ }
887
+ else {
888
+ merged.push(part);
889
+ }
890
+ }
891
+ // degenerate cases after merging
892
+ if (merged.length === 1) {
893
+ const p = merged[0];
894
+ if (typeof p === "number")
895
+ return new InlineValue(p);
896
+ return p;
897
+ }
898
+ // collect sources from all expression parts
899
+ const sources = new Set();
900
+ for (const part of merged) {
901
+ if (part instanceof ExpressionValue) {
902
+ for (const s of part.allSources)
903
+ sources.add(s);
904
+ }
905
+ }
906
+ const exprParts = merged.map((p) => p instanceof ExpressionValue ? p.expression : String(p));
907
+ const mulExpr = exprParts.join(" * ");
908
+ return new MultiplyValue(mulExpr, merged, sources);
909
+ }
910
+ class MultiplyValue extends ExpressionValue {
911
+ constructor(mulExpr, parts, sources) {
912
+ super(mulExpr, sources);
913
+ _MultiplyValue_parts.set(this, void 0);
914
+ __classPrivateFieldSet(this, _MultiplyValue_parts, Object.freeze([...parts]), "f");
915
+ }
916
+ /** the individual parts of this multiplication (for flattening nested multiplies) */
917
+ get multiplyParts() {
918
+ return __classPrivateFieldGet(this, _MultiplyValue_parts, "f");
919
+ }
920
+ }
921
+ _MultiplyValue_parts = new WeakMap();
922
+ // --- numeric division ---
923
+ /**
924
+ * Divides the left operand by the right. Uses the `/` operator in GitHub
925
+ * Actions expression contexts.
926
+ *
927
+ * ```ts
928
+ * const half = divide(expr("matrix.total"), 2);
929
+ * half.toString() // => "${{ matrix.total / 2 }}"
930
+ * ```
931
+ */
932
+ export function divide(left, right) {
933
+ if (typeof left === "number" && typeof right === "number") {
934
+ return new InlineValue(left / right);
935
+ }
936
+ const lhs = typeof left === "number" ? new InlineValue(left) : left;
937
+ const rhs = typeof right === "number" ? new InlineValue(right) : right;
938
+ const sources = new Set();
939
+ for (const s of lhs.allSources)
940
+ sources.add(s);
941
+ for (const s of rhs.allSources)
942
+ sources.add(s);
943
+ return new ExpressionValue(`${lhs.expression} / ${rhs.expression}`, sources);
944
+ }
945
+ // --- numeric modulo ---
946
+ /**
947
+ * Computes the remainder of the left operand divided by the right. Uses the
948
+ * `%` operator in GitHub Actions expression contexts.
949
+ *
950
+ * ```ts
951
+ * const rem = modulo(expr("matrix.index"), 2);
952
+ * rem.toString() // => "${{ matrix.index % 2 }}"
953
+ * ```
954
+ */
955
+ export function modulo(left, right) {
956
+ if (typeof left === "number" && typeof right === "number") {
957
+ return new InlineValue(left % right);
958
+ }
959
+ const lhs = typeof left === "number" ? new InlineValue(left) : left;
960
+ const rhs = typeof right === "number" ? new InlineValue(right) : right;
961
+ const sources = new Set();
962
+ for (const s of lhs.allSources)
963
+ sources.add(s);
964
+ for (const s of rhs.allSources)
965
+ sources.add(s);
966
+ return new ExpressionValue(`${lhs.expression} % ${rhs.expression}`, sources);
967
+ }
968
+ // --- JSON functions ---
969
+ /**
970
+ * Parses a JSON string into an object/value. Wraps in `fromJSON()` in GitHub
971
+ * Actions expression contexts.
972
+ *
973
+ * ```ts
974
+ * const matrix = fromJSON(expr("needs.setup.outputs.matrix"));
975
+ * matrix.toString() // => "${{ fromJSON(needs.setup.outputs.matrix) }}"
976
+ * ```
977
+ */
978
+ export function fromJSON(value) {
979
+ if (typeof value === "string") {
980
+ return new ExpressionValue(`fromJSON(${formatLiteral(value)})`);
981
+ }
982
+ const sources = new Set();
983
+ for (const s of value.allSources)
984
+ sources.add(s);
985
+ return new ExpressionValue(`fromJSON(${value.expression})`, sources);
986
+ }
987
+ /**
988
+ * Serializes a value to JSON. Wraps in `toJSON()` in GitHub Actions expression
989
+ * contexts.
990
+ *
991
+ * ```ts
992
+ * const json = toJSON(expr("github.event"));
993
+ * json.toString() // => "${{ toJSON(github.event) }}"
994
+ * ```
995
+ */
996
+ export function toJSON(value) {
997
+ const sources = new Set();
998
+ for (const s of value.allSources)
999
+ sources.add(s);
1000
+ return new ExpressionValue(`toJSON(${value.expression})`, sources);
1001
+ }
1002
+ // --- hashFiles ---
1003
+ /** Computes a hash of files matching the given glob patterns. */
1004
+ export function hashFiles(...patterns) {
1005
+ const sources = new Set();
1006
+ const args = [];
1007
+ for (const p of patterns) {
1008
+ if (p instanceof ExpressionValue) {
1009
+ for (const s of p.allSources)
1010
+ sources.add(s);
1011
+ args.push(p.expression);
1012
+ }
1013
+ else {
1014
+ args.push(formatLiteral(p));
1015
+ }
1016
+ }
1017
+ return new ExpressionValue(`hashFiles(${args.join(", ")})`, sources.size > 0 ? sources : undefined);
1018
+ }
1019
+ // --- join ---
1020
+ /**
1021
+ * Joins an array expression with an optional separator. Wraps in `join()` in
1022
+ * GitHub Actions expression contexts.
1023
+ *
1024
+ * ```ts
1025
+ * const labels = join(expr("github.event.pull_request.labels.*.name"), ", ");
1026
+ * labels.toString() // => "${{ join(github.event.pull_request.labels.*.name, ', ') }}"
1027
+ * ```
1028
+ */
1029
+ export function join(value, separator) {
1030
+ const sources = new Set();
1031
+ for (const s of value.allSources)
1032
+ sources.add(s);
1033
+ const args = separator != null
1034
+ ? `${value.expression}, ${formatLiteral(separator)}`
1035
+ : value.expression;
1036
+ return new ExpressionValue(`join(${args})`, sources.size > 0 ? sources : undefined);
1037
+ }
578
1038
  export function literal(value) {
579
1039
  if (typeof value === "boolean") {
580
1040
  return new RawCondition(String(value), EMPTY_SOURCES);
package/esm/mod.d.ts CHANGED
@@ -5,8 +5,8 @@ export { Job, job } from "./job.js";
5
5
  export type { JobConfig, JobDef, ReusableJobConfig, ReusableJobDef, ServiceContainer, StepsJobConfig, StepsJobDef, } from "./job.js";
6
6
  export { createWorkflow, isLinting, Workflow } from "./workflow.js";
7
7
  export type { WorkflowCallInput, WorkflowCallOutput, WorkflowCallSecret, WorkflowCallTrigger, WorkflowConfig, WorkflowTriggers, } from "./workflow.js";
8
- export { Condition, conditions, defineExprObj, ElseIfBuilder, expr, ExpressionValue, literal, ThenBuilder, } from "./expression.js";
9
- export type { ExpressionSource, ExprMap, ExprOf, TernaryValue, } from "./expression.js";
8
+ export { add, concat, Condition, conditions, defineExprObj, divide, ElseIfBuilder, expr, ExpressionValue, fromJSON, hashFiles, join, literal, modulo, multiply, subtract, ThenBuilder, toJSON, } from "./expression.js";
9
+ export type { AddPart, ComparisonOp, ConcatPart, ExpressionSource, ExprMap, ExprOf, TernaryValue, } from "./expression.js";
10
10
  export { defineMatrix, Matrix } from "./matrix.js";
11
11
  export type { PermissionLevel, Permissions, PermissionScope, } from "./permissions.js";
12
12
  export { Artifact, defineArtifact } from "./artifact.js";
package/esm/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAChD,YAAY,EACV,aAAa,EACb,WAAW,EACX,WAAW,EACX,UAAU,EACV,YAAY,EACZ,QAAQ,GACT,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,YAAY,EACV,SAAS,EACT,MAAM,EACN,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpE,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,UAAU,EACV,aAAa,EACb,aAAa,EACb,IAAI,EACJ,eAAe,EACf,OAAO,EACP,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,gBAAgB,EAChB,OAAO,EACP,MAAM,EACN,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EACV,eAAe,EACf,WAAW,EACX,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACzD,YAAY,EACV,eAAe,EACf,cAAc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,YAAY,EACV,eAAe,EACf,cAAc,EACd,YAAY,GACb,MAAM,eAAe,CAAC"}
package/esm/mod.js CHANGED
@@ -2,6 +2,6 @@ import "./_dnt.polyfills.js";
2
2
  export { Step, step, StepRef } from "./step.js";
3
3
  export { Job, job } from "./job.js";
4
4
  export { createWorkflow, isLinting, Workflow } from "./workflow.js";
5
- export { Condition, conditions, defineExprObj, ElseIfBuilder, expr, ExpressionValue, literal, ThenBuilder, } from "./expression.js";
5
+ export { add, concat, Condition, conditions, defineExprObj, divide, ElseIfBuilder, expr, ExpressionValue, fromJSON, hashFiles, join, literal, modulo, multiply, subtract, ThenBuilder, toJSON, } from "./expression.js";
6
6
  export { defineMatrix, Matrix } from "./matrix.js";
7
7
  export { Artifact, defineArtifact } from "./artifact.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gagen",
3
- "version": "0.2.16",
3
+ "version": "0.2.18",
4
4
  "description": "Generate complex GitHub Actions YAML files using a declarative API.",
5
5
  "repository": {
6
6
  "type": "git",