@likec4/generators 1.55.1 → 1.57.0

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": "@likec4/generators",
3
- "version": "1.55.1",
3
+ "version": "1.57.0",
4
4
  "license": "MIT",
5
5
  "bugs": "https://github.com/likec4/likec4/issues",
6
6
  "homepage": "https://likec4.dev",
@@ -54,18 +54,18 @@
54
54
  "indent-string": "^5.0.0",
55
55
  "strip-indent": "^4.1.1",
56
56
  "zod": "^4.3.6",
57
- "@likec4/core": "1.55.1",
58
- "@likec4/config": "1.55.1",
59
- "@likec4/log": "1.55.1"
57
+ "@likec4/core": "1.57.0",
58
+ "@likec4/config": "1.57.0",
59
+ "@likec4/log": "1.57.0"
60
60
  },
61
61
  "devDependencies": {
62
- "@types/node": "~22.19.15",
62
+ "@types/node": "~22.19.19",
63
63
  "@types/pako": "^2.0.4",
64
64
  "typescript": "5.9.3",
65
65
  "obuild": "0.4.31",
66
66
  "vitest": "4.1.3",
67
- "@likec4/tsconfig": "1.55.1",
68
- "@likec4/devops": "1.42.0"
67
+ "@likec4/tsconfig": "1.57.0",
68
+ "@likec4/devops": "1.57.0"
69
69
  },
70
70
  "scripts": {
71
71
  "typecheck": "tsc -b --verbose",
@@ -1,4 +1,4 @@
1
- import * as operators from './operators'
1
+ import * as ops from './operators'
2
2
  import { type AnyOp, type ctxOf, materialize, withctx } from './operators/base'
3
3
  import { schemas } from './schemas'
4
4
 
@@ -6,22 +6,24 @@ type Params = {
6
6
  indentation?: string | number
7
7
  }
8
8
 
9
+ export { ops }
10
+
9
11
  export function generateLikeC4(input: schemas.likec4data.Input, params?: Params): string {
10
12
  params = {
11
13
  indentation: 2,
12
14
  ...params,
13
15
  }
14
- return materialize(withctx(input, operators.likec4data()), params.indentation)
16
+ return materialize(withctx(input, ops.likec4data()), params.indentation)
15
17
  }
16
18
 
17
19
  /**
18
20
  * Prints the result of an operation with the data
19
21
  *
20
- * @see operators
22
+ * @see ops
21
23
  *
22
24
  * @example
23
25
  * ```ts
24
- * print(operators.expression, {
26
+ * printOperation(ops.expression(), {
25
27
  * ref: {
26
28
  * model: 'some.el',
27
29
  * },
@@ -32,7 +34,7 @@ export function generateLikeC4(input: schemas.likec4data.Input, params?: Params)
32
34
  *
33
35
  * @example
34
36
  * ```ts
35
- * print(operators.model, {
37
+ * printOperation(ops.model(), {
36
38
  * elements: [
37
39
  * {
38
40
  * id: 'cloud',
@@ -58,15 +60,31 @@ export function generateLikeC4(input: schemas.likec4data.Input, params?: Params)
58
60
  * // }
59
61
  * ```
60
62
  */
61
- export function print<O extends () => AnyOp>(operator: O, data: ctxOf<O>, params?: Params): string {
62
- return materialize(withctx(data, operator()), params?.indentation)
63
+ export function printOperation<Operation extends AnyOp>(operation: Operation): string
64
+ export function printOperation<Operation extends AnyOp>(
65
+ operation: Operation,
66
+ data: ctxOf<Operation>,
67
+ params?: Params,
68
+ ): string
69
+ export function printOperation<Operation extends AnyOp>(
70
+ operation: Operation,
71
+ data?: ctxOf<Operation>,
72
+ params?: Params,
73
+ ): string {
74
+ return materialize(withctx(data ?? {}, operation), params?.indentation)
63
75
  }
64
76
 
65
77
  /**
66
- * Same as {@link print} but uses tab indentation
78
+ * Same as {@link printOperation} but uses tab indentation
67
79
  */
68
- export function printTabIndent<O extends () => AnyOp>(operator: O, data: ctxOf<O>): string {
69
- return materialize(withctx(data, operator()), '\t')
80
+ export function printWithTabIndent<Operation extends AnyOp>(operation: Operation): string
81
+ export function printWithTabIndent<Operation extends AnyOp>(
82
+ operation: Operation,
83
+ data: ctxOf<Operation>,
84
+ ): string
85
+ export function printWithTabIndent<Operation extends AnyOp>(
86
+ operation: Operation,
87
+ data?: ctxOf<Operation>,
88
+ ): string {
89
+ return materialize(withctx(data ?? {}, operation), '\t')
70
90
  }
71
-
72
- export { operators }
@@ -1,11 +1,11 @@
1
1
  export {
2
2
  generateLikeC4 as generate,
3
- operators,
4
- print,
5
- printTabIndent,
3
+ ops,
4
+ printOperation,
5
+ printWithTabIndent,
6
6
  } from './generate-likec4'
7
7
 
8
- export type * from './operators/base'
8
+ export * from './operators/base'
9
9
 
10
10
  export type {
11
11
  schemas,
@@ -131,6 +131,13 @@ export const viewRuleAutoLayout = zodOp(schemas.views.viewRuleAutoLayout)(
131
131
  ),
132
132
  )
133
133
 
134
+ export const deploymentViewRuleIncludeAncestors = zodOp(schemas.views.deploymentViewRuleIncludeAncestors)(
135
+ spaceBetween(
136
+ print('includeAncestors'),
137
+ printProperty('includeAncestors'),
138
+ ),
139
+ )
140
+
134
141
  export const viewRuleRank = zodOp(schemas.views.viewRuleRank)(({ ctx, exec }) => {
135
142
  throw new Error('not implemented')
136
143
  })
@@ -200,6 +207,9 @@ export const deploymentViewRule = zodOp(schemas.views.deploymentViewRule)(
200
207
  if ('include' in ctx || 'exclude' in ctx) {
201
208
  return exec(ctx, viewRulePredicate())
202
209
  }
210
+ if ('includeAncestors' in ctx) {
211
+ return exec(ctx, deploymentViewRuleIncludeAncestors())
212
+ }
203
213
  if ('direction' in ctx) {
204
214
  return exec(ctx, viewRuleAutoLayout())
205
215
  }
@@ -27,6 +27,11 @@ export const viewRuleAutoLayout = z
27
27
  })
28
28
  .transform(v => v as ViewAutoLayout)
29
29
 
30
+ export const deploymentViewRuleIncludeAncestors = z
31
+ .strictObject({
32
+ includeAncestors: z.boolean(),
33
+ })
34
+
30
35
  export const viewRuleInclude = z.strictObject({ include: z.array(schemas.expression) })
31
36
  export const viewRuleExclude = z.strictObject({ exclude: z.array(schemas.expression) })
32
37
 
@@ -146,6 +151,7 @@ export const deploymentViewRule = z
146
151
  viewRuleStyle,
147
152
  viewRuleGlobalStyle,
148
153
  viewRuleGlobalPredicate,
154
+ deploymentViewRuleIncludeAncestors,
149
155
  ])
150
156
 
151
157
  /**