@aspruyt/xfg 5.1.0 → 5.1.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.
@@ -15,8 +15,9 @@ export interface MergeContext {
15
15
  */
16
16
  export declare function deepMerge(base: Record<string, unknown>, overlay: Record<string, unknown>, ctx: MergeContext): Record<string, unknown>;
17
17
  /**
18
- * Strip merge directive keys ($arrayMerge, $override, etc.) from an object.
18
+ * Strip xfg merge directive keys ($arrayMerge, $values) from an object.
19
19
  * Works recursively on nested objects and arrays.
20
+ * Standard $-prefixed keys ($schema, $id, $ref, etc.) are preserved.
20
21
  */
21
22
  export declare function stripMergeDirectives(obj: Record<string, unknown>): Record<string, unknown>;
22
23
  /**
@@ -3,6 +3,12 @@
3
3
  * Supports per-field array merge strategies via $arrayMerge + $values directives.
4
4
  */
5
5
  import { isPlainObject } from "../shared/type-guards.js";
6
+ /**
7
+ * Keys reserved for xfg merge directives.
8
+ * Only these are stripped during merge — standard $-prefixed keys
9
+ * like $schema, $id, $ref, $generated are preserved.
10
+ */
11
+ const XFG_DIRECTIVES = new Set(["$arrayMerge", "$values"]);
6
12
  /**
7
13
  * Strategy map for array merge operations.
8
14
  * Extensible: add new strategies by adding to this map.
@@ -34,7 +40,7 @@ export function deepMerge(base, overlay, ctx) {
34
40
  const result = { ...base };
35
41
  for (const [key, overlayValue] of Object.entries(overlay)) {
36
42
  // Skip directive keys in output
37
- if (key.startsWith("$"))
43
+ if (XFG_DIRECTIVES.has(key))
38
44
  continue;
39
45
  const baseValue = base[key];
40
46
  // Per-field $arrayMerge + $values directive
@@ -66,14 +72,15 @@ export function deepMerge(base, overlay, ctx) {
66
72
  return result;
67
73
  }
68
74
  /**
69
- * Strip merge directive keys ($arrayMerge, $override, etc.) from an object.
75
+ * Strip xfg merge directive keys ($arrayMerge, $values) from an object.
70
76
  * Works recursively on nested objects and arrays.
77
+ * Standard $-prefixed keys ($schema, $id, $ref, etc.) are preserved.
71
78
  */
72
79
  export function stripMergeDirectives(obj) {
73
80
  const result = {};
74
81
  for (const [key, value] of Object.entries(obj)) {
75
- // Skip all $-prefixed keys (reserved for directives)
76
- if (key.startsWith("$"))
82
+ // Skip xfg directive keys only
83
+ if (XFG_DIRECTIVES.has(key))
77
84
  continue;
78
85
  if (isPlainObject(value)) {
79
86
  result[key] = stripMergeDirectives(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aspruyt/xfg",
3
- "version": "5.1.0",
3
+ "version": "5.1.2",
4
4
  "description": "Manage files, settings, and repositories across GitHub, Azure DevOps, and GitLab — declaratively, from a single YAML config",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",