@likec4/generators 1.56.0 → 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/dist/likec4/index.d.mts +58 -18
- package/dist/likec4/index.mjs +76 -117
- package/package.json +7 -7
- package/src/likec4/generate-likec4.ts +30 -12
- package/src/likec4/index.ts +4 -4
- package/src/likec4/operators/views.ts +10 -0
- package/src/likec4/schemas/views.ts +6 -0
package/dist/likec4/index.d.mts
CHANGED
|
@@ -8,7 +8,7 @@ import * as z4 from "zod/v4/core";
|
|
|
8
8
|
|
|
9
9
|
//#region src/likec4/operators/base.d.ts
|
|
10
10
|
declare namespace base_d_exports {
|
|
11
|
-
export { AnyCtx, AnyOp, Ctx, CtxOp, InferOp, Op, Ops, Output, body, ctxOf, eachOnFresh, eq, executeOnCtx, executeOnFresh, foreach, foreachNewLine, fresh, guard, indent, inlineText, join, lazy, lines, markdown, markdownOrString, materialize, merge, newline, noop, operation, print
|
|
11
|
+
export { AnyCtx, AnyOp, Ctx, CtxOp, InferOp, Op, Ops, Output, body, ctxOf, eachOnFresh, eq, executeOnCtx, executeOnFresh, foreach, foreachNewLine, fresh, guard, indent, inlineText, join, lazy, lines, markdown, markdownOrString, materialize, merge, newline, noop, operation, print, printProperty, property, select, separateComma, separateNewLine, separateWith, space, spaceBetween, text, when, withctx, zodOp };
|
|
12
12
|
}
|
|
13
13
|
type Output = CompositeGeneratorNode;
|
|
14
14
|
/**
|
|
@@ -90,9 +90,9 @@ declare function operation<A>(name: string, fn: (input: Ctx<A>) => any): Op<A>;
|
|
|
90
90
|
* // Output: #one
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
|
-
declare function print
|
|
94
|
-
declare function print
|
|
95
|
-
declare function print
|
|
93
|
+
declare function print<A extends string | number | boolean>(): Op<A>;
|
|
94
|
+
declare function print<A>(format: (value: A) => string): Op<A>;
|
|
95
|
+
declare function print(value: string | number | boolean): InferOp;
|
|
96
96
|
declare const eq: () => InferOp;
|
|
97
97
|
declare const space: () => InferOp;
|
|
98
98
|
declare function noop(): <A>(input: A) => A;
|
|
@@ -6184,7 +6184,7 @@ declare const schema: z$1.ZodObject<{
|
|
|
6184
6184
|
}>>>, z$1.ZodPipe<z$1.ZodArray<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<any, string>>>, z$1.ZodTransform<Record<any, Record<string, any>>, any[]>>]>>;
|
|
6185
6185
|
}, z$1.core.$strip>;
|
|
6186
6186
|
declare namespace views_d_exports$1 {
|
|
6187
|
-
export { ViewRuleGroupInput, ViewRuleGroupOutput, anyView$1 as anyView, autoLayoutDirection, deploymentView$1 as deploymentView, deploymentViewRule$1 as deploymentViewRule, dynamicStep$1 as dynamicStep, dynamicStepsParallel$1 as dynamicStepsParallel, dynamicStepsSeries$1 as dynamicStepsSeries, dynamicView$1 as dynamicView, dynamicViewIncludeRule$1 as dynamicViewIncludeRule, dynamicViewRule$1 as dynamicViewRule, dynamicViewStep$1 as dynamicViewStep, dynamicViewVariant, elementView$1 as elementView, elementViewRule$1 as elementViewRule, viewRuleAutoLayout$1 as viewRuleAutoLayout, viewRuleExclude, viewRuleGlobalPredicate$1 as viewRuleGlobalPredicate, viewRuleGlobalStyle$1 as viewRuleGlobalStyle, viewRuleGroup$1 as viewRuleGroup, viewRuleInclude, viewRulePredicate$1 as viewRulePredicate, viewRuleRank$1 as viewRuleRank, viewRuleStyle$1 as viewRuleStyle, views$1 as views };
|
|
6187
|
+
export { ViewRuleGroupInput, ViewRuleGroupOutput, anyView$1 as anyView, autoLayoutDirection, deploymentView$1 as deploymentView, deploymentViewRule$1 as deploymentViewRule, deploymentViewRuleIncludeAncestors$1 as deploymentViewRuleIncludeAncestors, dynamicStep$1 as dynamicStep, dynamicStepsParallel$1 as dynamicStepsParallel, dynamicStepsSeries$1 as dynamicStepsSeries, dynamicView$1 as dynamicView, dynamicViewIncludeRule$1 as dynamicViewIncludeRule, dynamicViewRule$1 as dynamicViewRule, dynamicViewStep$1 as dynamicViewStep, dynamicViewVariant, elementView$1 as elementView, elementViewRule$1 as elementViewRule, viewRuleAutoLayout$1 as viewRuleAutoLayout, viewRuleExclude, viewRuleGlobalPredicate$1 as viewRuleGlobalPredicate, viewRuleGlobalStyle$1 as viewRuleGlobalStyle, viewRuleGroup$1 as viewRuleGroup, viewRuleInclude, viewRulePredicate$1 as viewRulePredicate, viewRuleRank$1 as viewRuleRank, viewRuleStyle$1 as viewRuleStyle, views$1 as views };
|
|
6188
6188
|
}
|
|
6189
6189
|
declare const autoLayoutDirection: z$1.ZodLiteral<"TB" | "BT" | "LR" | "RL">;
|
|
6190
6190
|
declare const viewRuleAutoLayout$1: z$1.ZodPipe<z$1.ZodObject<{
|
|
@@ -6196,6 +6196,9 @@ declare const viewRuleAutoLayout$1: z$1.ZodPipe<z$1.ZodObject<{
|
|
|
6196
6196
|
nodeSep?: number | undefined;
|
|
6197
6197
|
rankSep?: number | undefined;
|
|
6198
6198
|
}>>;
|
|
6199
|
+
declare const deploymentViewRuleIncludeAncestors$1: z$1.ZodObject<{
|
|
6200
|
+
includeAncestors: z$1.ZodBoolean;
|
|
6201
|
+
}, z$1.core.$strict>;
|
|
6199
6202
|
declare const viewRuleInclude: z$1.ZodObject<{
|
|
6200
6203
|
include: z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodUnion<readonly [z$1.ZodObject<{
|
|
6201
6204
|
wildcard: z$1.ZodLiteral<true>;
|
|
@@ -41987,7 +41990,9 @@ declare const deploymentViewRule$1: z$1.ZodUnion<readonly [z$1.ZodPipe<z$1.ZodUn
|
|
|
41987
41990
|
predicateId: z$1.ZodString;
|
|
41988
41991
|
}, z$1.core.$strip>, z$1.ZodTransform<any, {
|
|
41989
41992
|
predicateId: string;
|
|
41990
|
-
}
|
|
41993
|
+
}>>, z$1.ZodObject<{
|
|
41994
|
+
includeAncestors: z$1.ZodBoolean;
|
|
41995
|
+
}, z$1.core.$strict>]>;
|
|
41991
41996
|
/**
|
|
41992
41997
|
* Replicates ParsedElementView from the core,
|
|
41993
41998
|
* less strict, as the generator should be able to handle missing fields and provide defaults.
|
|
@@ -50466,7 +50471,9 @@ declare const deploymentView$1: z$1.ZodObject<{
|
|
|
50466
50471
|
predicateId: z$1.ZodString;
|
|
50467
50472
|
}, z$1.core.$strip>, z$1.ZodTransform<any, {
|
|
50468
50473
|
predicateId: string;
|
|
50469
|
-
}
|
|
50474
|
+
}>>, z$1.ZodObject<{
|
|
50475
|
+
includeAncestors: z$1.ZodBoolean;
|
|
50476
|
+
}, z$1.core.$strict>]>>>>;
|
|
50470
50477
|
}, z$1.core.$strip>;
|
|
50471
50478
|
declare const dynamicStep$1: z$1.ZodPipe<z$1.ZodReadonly<z$1.ZodObject<{
|
|
50472
50479
|
source: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<any, string>>;
|
|
@@ -70577,7 +70584,9 @@ declare const anyView$1: z$1.ZodUnion<readonly [z$1.ZodObject<{
|
|
|
70577
70584
|
predicateId: z$1.ZodString;
|
|
70578
70585
|
}, z$1.core.$strip>, z$1.ZodTransform<any, {
|
|
70579
70586
|
predicateId: string;
|
|
70580
|
-
}
|
|
70587
|
+
}>>, z$1.ZodObject<{
|
|
70588
|
+
includeAncestors: z$1.ZodBoolean;
|
|
70589
|
+
}, z$1.core.$strict>]>>>>;
|
|
70581
70590
|
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
70582
70591
|
id: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<any, string>>;
|
|
70583
70592
|
_stage: z$1.ZodDefault<z$1.ZodLiteral<"parsed">>;
|
|
@@ -88650,7 +88659,9 @@ declare const views$1: z$1.ZodRecord<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform
|
|
|
88650
88659
|
predicateId: z$1.ZodString;
|
|
88651
88660
|
}, z$1.core.$strip>, z$1.ZodTransform<any, {
|
|
88652
88661
|
predicateId: string;
|
|
88653
|
-
}
|
|
88662
|
+
}>>, z$1.ZodObject<{
|
|
88663
|
+
includeAncestors: z$1.ZodBoolean;
|
|
88664
|
+
}, z$1.core.$strict>]>>>>;
|
|
88654
88665
|
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
88655
88666
|
id: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<any, string>>;
|
|
88656
88667
|
_stage: z$1.ZodDefault<z$1.ZodLiteral<"parsed">>;
|
|
@@ -106733,7 +106744,9 @@ declare const schemas: {
|
|
|
106733
106744
|
predicateId: z.ZodString;
|
|
106734
106745
|
}, z.core.$strip>, z.ZodTransform<any, {
|
|
106735
106746
|
predicateId: string;
|
|
106736
|
-
}
|
|
106747
|
+
}>>, z.ZodObject<{
|
|
106748
|
+
includeAncestors: z.ZodBoolean;
|
|
106749
|
+
}, z.core.$strict>]>>>>;
|
|
106737
106750
|
}, z.core.$strip>, z.ZodObject<{
|
|
106738
106751
|
id: z.ZodPipe<z.ZodString, z.ZodTransform<any, string>>;
|
|
106739
106752
|
_stage: z.ZodDefault<z.ZodLiteral<"parsed">>;
|
|
@@ -142042,6 +142055,8 @@ declare const likec4data: <A extends Readonly<{
|
|
|
142042
142055
|
styleId: string;
|
|
142043
142056
|
} | {
|
|
142044
142057
|
predicateId: string;
|
|
142058
|
+
} | {
|
|
142059
|
+
includeAncestors: boolean;
|
|
142045
142060
|
})[] | undefined;
|
|
142046
142061
|
} | {
|
|
142047
142062
|
id: string;
|
|
@@ -153296,6 +153311,8 @@ declare const likec4data: <A extends Readonly<{
|
|
|
153296
153311
|
styleId: string;
|
|
153297
153312
|
} | {
|
|
153298
153313
|
predicateId: string;
|
|
153314
|
+
} | {
|
|
153315
|
+
includeAncestors: boolean;
|
|
153299
153316
|
})[] | undefined;
|
|
153300
153317
|
} | {
|
|
153301
153318
|
id: string;
|
|
@@ -156957,7 +156974,7 @@ declare const specification: <A extends {
|
|
|
156957
156974
|
}> | undefined;
|
|
156958
156975
|
}>() => Op<A>;
|
|
156959
156976
|
declare namespace views_d_exports {
|
|
156960
|
-
export { anyView, deploymentView, deploymentViewRule, dynamicStep, dynamicStepsParallel, dynamicStepsSeries, dynamicView, dynamicViewIncludeRule, dynamicViewRule, dynamicViewStep, elementView, elementViewRule, viewRuleAutoLayout, viewRuleGlobalPredicate, viewRuleGlobalStyle, viewRuleGroup, viewRulePredicate, viewRuleRank, viewRuleStyle, views };
|
|
156977
|
+
export { anyView, deploymentView, deploymentViewRule, deploymentViewRuleIncludeAncestors, dynamicStep, dynamicStepsParallel, dynamicStepsSeries, dynamicView, dynamicViewIncludeRule, dynamicViewRule, dynamicViewStep, elementView, elementViewRule, viewRuleAutoLayout, viewRuleGlobalPredicate, viewRuleGlobalStyle, viewRuleGroup, viewRulePredicate, viewRuleRank, viewRuleStyle, views };
|
|
156961
156978
|
}
|
|
156962
156979
|
declare const viewRulePredicate: <A extends {
|
|
156963
156980
|
include: ({
|
|
@@ -167925,6 +167942,11 @@ declare const viewRuleAutoLayout: <A extends {
|
|
|
167925
167942
|
nodeSep?: number | undefined;
|
|
167926
167943
|
rankSep?: number | undefined;
|
|
167927
167944
|
}>() => Op<A>;
|
|
167945
|
+
declare const deploymentViewRuleIncludeAncestors: <A extends {
|
|
167946
|
+
includeAncestors: boolean;
|
|
167947
|
+
} = {
|
|
167948
|
+
includeAncestors: boolean;
|
|
167949
|
+
}>() => Op<A>;
|
|
167928
167950
|
declare const viewRuleRank: <A extends {
|
|
167929
167951
|
targets: ({
|
|
167930
167952
|
wildcard: true;
|
|
@@ -194572,6 +194594,8 @@ declare const deploymentViewRule: <A extends {
|
|
|
194572
194594
|
styleId: string;
|
|
194573
194595
|
} | {
|
|
194574
194596
|
predicateId: string;
|
|
194597
|
+
} | {
|
|
194598
|
+
includeAncestors: boolean;
|
|
194575
194599
|
} = {
|
|
194576
194600
|
include: ({
|
|
194577
194601
|
wildcard: true;
|
|
@@ -200052,6 +200076,8 @@ declare const deploymentViewRule: <A extends {
|
|
|
200052
200076
|
styleId: string;
|
|
200053
200077
|
} | {
|
|
200054
200078
|
predicateId: string;
|
|
200079
|
+
} | {
|
|
200080
|
+
includeAncestors: boolean;
|
|
200055
200081
|
}>() => Op<A>;
|
|
200056
200082
|
declare const deploymentView: <A extends {
|
|
200057
200083
|
id: string;
|
|
@@ -205092,6 +205118,8 @@ declare const deploymentView: <A extends {
|
|
|
205092
205118
|
styleId: string;
|
|
205093
205119
|
} | {
|
|
205094
205120
|
predicateId: string;
|
|
205121
|
+
} | {
|
|
205122
|
+
includeAncestors: boolean;
|
|
205095
205123
|
})[] | undefined;
|
|
205096
205124
|
} = {
|
|
205097
205125
|
id: string;
|
|
@@ -210132,6 +210160,8 @@ declare const deploymentView: <A extends {
|
|
|
210132
210160
|
styleId: string;
|
|
210133
210161
|
} | {
|
|
210134
210162
|
predicateId: string;
|
|
210163
|
+
} | {
|
|
210164
|
+
includeAncestors: boolean;
|
|
210135
210165
|
})[] | undefined;
|
|
210136
210166
|
}>() => Op<A>;
|
|
210137
210167
|
declare const dynamicStep: <A extends Readonly<{
|
|
@@ -236478,6 +236508,8 @@ declare const anyView: <A extends {
|
|
|
236478
236508
|
styleId: string;
|
|
236479
236509
|
} | {
|
|
236480
236510
|
predicateId: string;
|
|
236511
|
+
} | {
|
|
236512
|
+
includeAncestors: boolean;
|
|
236481
236513
|
})[] | undefined;
|
|
236482
236514
|
} | {
|
|
236483
236515
|
id: string;
|
|
@@ -249160,6 +249192,8 @@ declare const anyView: <A extends {
|
|
|
249160
249192
|
styleId: string;
|
|
249161
249193
|
} | {
|
|
249162
249194
|
predicateId: string;
|
|
249195
|
+
} | {
|
|
249196
|
+
includeAncestors: boolean;
|
|
249163
249197
|
})[] | undefined;
|
|
249164
249198
|
} | {
|
|
249165
249199
|
id: string;
|
|
@@ -261843,6 +261877,8 @@ declare const views: <A extends Record<string, {
|
|
|
261843
261877
|
styleId: string;
|
|
261844
261878
|
} | {
|
|
261845
261879
|
predicateId: string;
|
|
261880
|
+
} | {
|
|
261881
|
+
includeAncestors: boolean;
|
|
261846
261882
|
})[] | undefined;
|
|
261847
261883
|
} | {
|
|
261848
261884
|
id: string;
|
|
@@ -274525,6 +274561,8 @@ declare const views: <A extends Record<string, {
|
|
|
274525
274561
|
styleId: string;
|
|
274526
274562
|
} | {
|
|
274527
274563
|
predicateId: string;
|
|
274564
|
+
} | {
|
|
274565
|
+
includeAncestors: boolean;
|
|
274528
274566
|
})[] | undefined;
|
|
274529
274567
|
} | {
|
|
274530
274568
|
id: string;
|
|
@@ -277119,11 +277157,11 @@ declare function generateLikeC4(input: schemas.likec4data.Input, params?: Params
|
|
|
277119
277157
|
/**
|
|
277120
277158
|
* Prints the result of an operation with the data
|
|
277121
277159
|
*
|
|
277122
|
-
* @see
|
|
277160
|
+
* @see ops
|
|
277123
277161
|
*
|
|
277124
277162
|
* @example
|
|
277125
277163
|
* ```ts
|
|
277126
|
-
*
|
|
277164
|
+
* printOperation(ops.expression(), {
|
|
277127
277165
|
* ref: {
|
|
277128
277166
|
* model: 'some.el',
|
|
277129
277167
|
* },
|
|
@@ -277134,7 +277172,7 @@ declare function generateLikeC4(input: schemas.likec4data.Input, params?: Params
|
|
|
277134
277172
|
*
|
|
277135
277173
|
* @example
|
|
277136
277174
|
* ```ts
|
|
277137
|
-
*
|
|
277175
|
+
* printOperation(ops.model(), {
|
|
277138
277176
|
* elements: [
|
|
277139
277177
|
* {
|
|
277140
277178
|
* id: 'cloud',
|
|
@@ -277160,10 +277198,12 @@ declare function generateLikeC4(input: schemas.likec4data.Input, params?: Params
|
|
|
277160
277198
|
* // }
|
|
277161
277199
|
* ```
|
|
277162
277200
|
*/
|
|
277163
|
-
declare function
|
|
277201
|
+
declare function printOperation<Operation extends AnyOp>(operation: Operation): string;
|
|
277202
|
+
declare function printOperation<Operation extends AnyOp>(operation: Operation, data: ctxOf<Operation>, params?: Params): string;
|
|
277164
277203
|
/**
|
|
277165
|
-
* Same as {@link
|
|
277204
|
+
* Same as {@link printOperation} but uses tab indentation
|
|
277166
277205
|
*/
|
|
277167
|
-
declare function
|
|
277206
|
+
declare function printWithTabIndent<Operation extends AnyOp>(operation: Operation): string;
|
|
277207
|
+
declare function printWithTabIndent<Operation extends AnyOp>(operation: Operation, data: ctxOf<Operation>): string;
|
|
277168
277208
|
//#endregion
|
|
277169
|
-
export { AnyCtx, AnyOp, Ctx, CtxOp, InferOp, Op, Ops, Output, body, ctxOf, eachOnFresh, eq, executeOnCtx, executeOnFresh, foreach, foreachNewLine, fresh, generateLikeC4 as generate, guard, indent, inlineText, join, lazy, lines, markdown, markdownOrString, materialize, merge, newline, noop, operation, index_d_exports as
|
|
277209
|
+
export { AnyCtx, AnyOp, Ctx, CtxOp, InferOp, Op, Ops, Output, body, ctxOf, eachOnFresh, eq, executeOnCtx, executeOnFresh, foreach, foreachNewLine, fresh, generateLikeC4 as generate, guard, indent, inlineText, join, lazy, lines, markdown, markdownOrString, materialize, merge, newline, noop, operation, index_d_exports as ops, print, printOperation, printProperty, printWithTabIndent, property, type schemas, select, separateComma, separateNewLine, separateWith, space, spaceBetween, text, when, withctx, zodOp };
|
package/dist/likec4/index.mjs
CHANGED
|
@@ -26,13 +26,13 @@ var base_exports = /* @__PURE__ */ __exportAll({
|
|
|
26
26
|
lazy: () => lazy,
|
|
27
27
|
lines: () => lines,
|
|
28
28
|
markdown: () => markdown,
|
|
29
|
-
markdownOrString: () => markdownOrString
|
|
29
|
+
markdownOrString: () => markdownOrString,
|
|
30
30
|
materialize: () => materialize,
|
|
31
31
|
merge: () => merge,
|
|
32
32
|
newline: () => newline,
|
|
33
33
|
noop: () => noop,
|
|
34
34
|
operation: () => operation,
|
|
35
|
-
print: () => print
|
|
35
|
+
print: () => print,
|
|
36
36
|
printProperty: () => printProperty,
|
|
37
37
|
property: () => property,
|
|
38
38
|
select: () => select,
|
|
@@ -104,7 +104,7 @@ function operation(opOrName, fn) {
|
|
|
104
104
|
function isPrintable(value) {
|
|
105
105
|
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
106
106
|
}
|
|
107
|
-
function print
|
|
107
|
+
function print(value) {
|
|
108
108
|
return operation(function printOp({ ctx, out }) {
|
|
109
109
|
let v = typeof value === "function" ? value(ctx) : value ?? ctx;
|
|
110
110
|
if (isNullish(v) || v === "") return;
|
|
@@ -112,8 +112,8 @@ function print$1(value) {
|
|
|
112
112
|
out.append(String(v));
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
const eq = () => print
|
|
116
|
-
const space = () => print
|
|
115
|
+
const eq = () => print("=");
|
|
116
|
+
const space = () => print(" ");
|
|
117
117
|
function noop() {
|
|
118
118
|
return identity();
|
|
119
119
|
}
|
|
@@ -179,7 +179,7 @@ function body(...args) {
|
|
|
179
179
|
return body("{", "}")(...ops);
|
|
180
180
|
}
|
|
181
181
|
const QUOTE = "'";
|
|
182
|
-
const ESCAPED_QUOTE = "\\"
|
|
182
|
+
const ESCAPED_QUOTE = "\\'";
|
|
183
183
|
function inlineText(value) {
|
|
184
184
|
return operation(({ ctx, out }) => {
|
|
185
185
|
let v = value ?? ctx;
|
|
@@ -190,7 +190,7 @@ function inlineText(value) {
|
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
function multilineText(value, quotes = QUOTE) {
|
|
193
|
-
return merge(print
|
|
193
|
+
return merge(print(quotes), indent(value.replaceAll(QUOTE, ESCAPED_QUOTE)), print(quotes));
|
|
194
194
|
}
|
|
195
195
|
function text(value) {
|
|
196
196
|
return operation(function text({ ctx, out }) {
|
|
@@ -216,7 +216,7 @@ function markdown(value) {
|
|
|
216
216
|
return multilineText(v, TRIPLE_QUOTE)(ctx);
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
|
-
function markdownOrString
|
|
219
|
+
function markdownOrString(value) {
|
|
220
220
|
return operation(function markdownOrString(ctx) {
|
|
221
221
|
let v = value ?? ctx.ctx;
|
|
222
222
|
if (isNullish(v)) return;
|
|
@@ -355,7 +355,7 @@ function property(propertyName, op) {
|
|
|
355
355
|
* ```
|
|
356
356
|
*/
|
|
357
357
|
function printProperty(propertyName) {
|
|
358
|
-
return property(propertyName, print
|
|
358
|
+
return property(propertyName, print());
|
|
359
359
|
}
|
|
360
360
|
function foreach(...args) {
|
|
361
361
|
const [arg1, arg2] = args;
|
|
@@ -543,7 +543,7 @@ var common_exports = /* @__PURE__ */ __exportAll({
|
|
|
543
543
|
line: () => line,
|
|
544
544
|
link: () => link,
|
|
545
545
|
links: () => links,
|
|
546
|
-
markdownOrString: () => markdownOrString,
|
|
546
|
+
markdownOrString: () => markdownOrString$1,
|
|
547
547
|
metadata: () => metadata,
|
|
548
548
|
metadataValue: () => metadataValue$1,
|
|
549
549
|
opacity: () => opacity,
|
|
@@ -581,7 +581,7 @@ const themeColor = z$1.literal(ThemeColors);
|
|
|
581
581
|
const customColor = z$1.custom().refine((v) => typeof v === "string", "Custom color name must be a string").transform((value) => value);
|
|
582
582
|
const tag = z$1.string().nonempty("Tag cannot be empty").transform((tag) => tag.startsWith("#") ? tag.slice(1) : tag);
|
|
583
583
|
const tags = z$1.array(tag).readonly();
|
|
584
|
-
const markdownOrString = z$1.union([
|
|
584
|
+
const markdownOrString$1 = z$1.union([
|
|
585
585
|
z$1.string(),
|
|
586
586
|
z$1.strictObject({ md: z$1.string() }),
|
|
587
587
|
z$1.strictObject({ txt: z$1.string() })
|
|
@@ -610,8 +610,8 @@ const metadata = z$1.record(z$1.string(), metadataValue$1.or(z$1.array(metadataV
|
|
|
610
610
|
const props = z$1.object({
|
|
611
611
|
tags: tags.nullable(),
|
|
612
612
|
title: z$1.string(),
|
|
613
|
-
summary: markdownOrString.nullable(),
|
|
614
|
-
description: markdownOrString.nullable(),
|
|
613
|
+
summary: markdownOrString$1.nullable(),
|
|
614
|
+
description: markdownOrString$1.nullable(),
|
|
615
615
|
notation: z$1.string().nullable(),
|
|
616
616
|
technology: z$1.string().nullable(),
|
|
617
617
|
links: links.nullable(),
|
|
@@ -737,10 +737,10 @@ const fqnExprOrWhere$1 = z$1.union([fqnExpr$1, fqnExprWhere]);
|
|
|
737
737
|
*/
|
|
738
738
|
const commonCustomProperties = z$1.object({
|
|
739
739
|
title: z$1.string(),
|
|
740
|
-
description: markdownOrString,
|
|
740
|
+
description: markdownOrString$1,
|
|
741
741
|
technology: z$1.string(),
|
|
742
742
|
notation: z$1.string(),
|
|
743
|
-
notes: markdownOrString,
|
|
743
|
+
notes: markdownOrString$1,
|
|
744
744
|
navigateTo: viewId,
|
|
745
745
|
color
|
|
746
746
|
});
|
|
@@ -947,8 +947,8 @@ var specification_exports$1 = /* @__PURE__ */ __exportAll({
|
|
|
947
947
|
const element$1 = z$1.object({
|
|
948
948
|
tags: tags.nullable(),
|
|
949
949
|
title: z$1.string().nullable(),
|
|
950
|
-
summary: markdownOrString.nullable(),
|
|
951
|
-
description: markdownOrString.nullable(),
|
|
950
|
+
summary: markdownOrString$1.nullable(),
|
|
951
|
+
description: markdownOrString$1.nullable(),
|
|
952
952
|
technology: z$1.string().nullable(),
|
|
953
953
|
notation: z$1.string().nullable(),
|
|
954
954
|
links: links.nullable(),
|
|
@@ -993,6 +993,7 @@ var views_exports$1 = /* @__PURE__ */ __exportAll({
|
|
|
993
993
|
autoLayoutDirection: () => autoLayoutDirection,
|
|
994
994
|
deploymentView: () => deploymentView$1,
|
|
995
995
|
deploymentViewRule: () => deploymentViewRule$1,
|
|
996
|
+
deploymentViewRuleIncludeAncestors: () => deploymentViewRuleIncludeAncestors$1,
|
|
996
997
|
dynamicStep: () => dynamicStep$1,
|
|
997
998
|
dynamicStepsParallel: () => dynamicStepsParallel$1,
|
|
998
999
|
dynamicStepsSeries: () => dynamicStepsSeries$1,
|
|
@@ -1025,6 +1026,7 @@ const viewRuleAutoLayout$1 = z$1.object({
|
|
|
1025
1026
|
nodeSep: z$1.number().optional(),
|
|
1026
1027
|
rankSep: z$1.number().optional()
|
|
1027
1028
|
}).transform((v) => v);
|
|
1029
|
+
const deploymentViewRuleIncludeAncestors$1 = z$1.strictObject({ includeAncestors: z$1.boolean() });
|
|
1028
1030
|
const viewRuleInclude = z$1.strictObject({ include: z$1.array(expression$1) });
|
|
1029
1031
|
const viewRuleExclude = z$1.strictObject({ exclude: z$1.array(expression$1) });
|
|
1030
1032
|
const viewRulePredicate$1 = z$1.union([viewRuleInclude, viewRuleExclude]).transform((v) => v);
|
|
@@ -1070,7 +1072,7 @@ const viewProps = z$1.object({
|
|
|
1070
1072
|
id: viewId,
|
|
1071
1073
|
_stage: z$1.literal("parsed").default("parsed"),
|
|
1072
1074
|
title: z$1.string().nullish(),
|
|
1073
|
-
description: markdownOrString.nullish(),
|
|
1075
|
+
description: markdownOrString$1.nullish(),
|
|
1074
1076
|
tags: tags.nullish(),
|
|
1075
1077
|
links: links.nullish()
|
|
1076
1078
|
});
|
|
@@ -1089,7 +1091,8 @@ const deploymentViewRule$1 = z$1.union([
|
|
|
1089
1091
|
viewRuleAutoLayout$1,
|
|
1090
1092
|
viewRuleStyle$1,
|
|
1091
1093
|
viewRuleGlobalStyle$1,
|
|
1092
|
-
viewRuleGlobalPredicate$1
|
|
1094
|
+
viewRuleGlobalPredicate$1,
|
|
1095
|
+
deploymentViewRuleIncludeAncestors$1
|
|
1093
1096
|
]);
|
|
1094
1097
|
/**
|
|
1095
1098
|
* Replicates ParsedElementView from the core,
|
|
@@ -1104,10 +1107,10 @@ const dynamicStep$1 = z$1.object({
|
|
|
1104
1107
|
target: fqn,
|
|
1105
1108
|
title: z$1.string().nullish().default(null),
|
|
1106
1109
|
kind: z$1.string().nullish(),
|
|
1107
|
-
description: markdownOrString.nullish(),
|
|
1110
|
+
description: markdownOrString$1.nullish(),
|
|
1108
1111
|
technology: z$1.string().nullish(),
|
|
1109
1112
|
notation: z$1.string().nullish(),
|
|
1110
|
-
notes: markdownOrString.nullish(),
|
|
1113
|
+
notes: markdownOrString$1.nullish(),
|
|
1111
1114
|
color: color.optional(),
|
|
1112
1115
|
line: line.optional(),
|
|
1113
1116
|
head: arrow.optional(),
|
|
@@ -1228,27 +1231,27 @@ var properties_exports = /* @__PURE__ */ __exportAll({
|
|
|
1228
1231
|
* Print a property from the context as a text.
|
|
1229
1232
|
*/
|
|
1230
1233
|
function textProperty(propertyName, keyword) {
|
|
1231
|
-
return select((e) => e[propertyName], spaceBetween(print
|
|
1234
|
+
return select((e) => e[propertyName], spaceBetween(print(keyword ?? propertyName), text()));
|
|
1232
1235
|
}
|
|
1233
1236
|
/**
|
|
1234
1237
|
* Print a property from the context as a markdown string.
|
|
1235
1238
|
*/
|
|
1236
1239
|
function markdownProperty(propertyName, keyword) {
|
|
1237
|
-
return select((e) => e[propertyName], spaceBetween(print
|
|
1238
|
-
}
|
|
1239
|
-
const titleProperty = () => property("title", spaceBetween(print
|
|
1240
|
-
const summaryProperty = () => property("summary", spaceBetween(print
|
|
1241
|
-
const descriptionProperty = () => property("description", spaceBetween(print
|
|
1242
|
-
const notesProperty = () => property("notes", spaceBetween(print
|
|
1243
|
-
const technologyProperty = () => property("technology", spaceBetween(print
|
|
1244
|
-
const notationProperty = () => property("notation", spaceBetween(print
|
|
1240
|
+
return select((e) => e[propertyName], spaceBetween(print(keyword ?? propertyName), markdownOrString()));
|
|
1241
|
+
}
|
|
1242
|
+
const titleProperty = () => property("title", spaceBetween(print("title"), text()));
|
|
1243
|
+
const summaryProperty = () => property("summary", spaceBetween(print("summary"), markdownOrString()));
|
|
1244
|
+
const descriptionProperty = () => property("description", spaceBetween(print("description"), markdownOrString()));
|
|
1245
|
+
const notesProperty = () => property("notes", spaceBetween(print("notes"), markdownOrString()));
|
|
1246
|
+
const technologyProperty = () => property("technology", spaceBetween(print("technology"), text()));
|
|
1247
|
+
const notationProperty = () => property("notation", spaceBetween(print("notation"), text()));
|
|
1245
1248
|
function printMetadataValue() {
|
|
1246
1249
|
return operation(({ ctx, out }) => {
|
|
1247
1250
|
if (isString(ctx)) return text()({
|
|
1248
1251
|
ctx,
|
|
1249
1252
|
out
|
|
1250
1253
|
});
|
|
1251
|
-
return print
|
|
1254
|
+
return print()({
|
|
1252
1255
|
ctx,
|
|
1253
1256
|
out
|
|
1254
1257
|
});
|
|
@@ -1262,26 +1265,26 @@ function metadataValue() {
|
|
|
1262
1265
|
}
|
|
1263
1266
|
}))));
|
|
1264
1267
|
}
|
|
1265
|
-
const metadataProperty = () => select((e) => e.metadata ? entries(e.metadata) : void 0, body("metadata")(foreach(spaceBetween(print
|
|
1266
|
-
const tagsProperty = () => property("tags", print
|
|
1268
|
+
const metadataProperty = () => select((e) => e.metadata ? entries(e.metadata) : void 0, body("metadata")(foreach(spaceBetween(print((v) => v[0]), property("1", metadataValue())), separateNewLine())));
|
|
1269
|
+
const tagsProperty = () => property("tags", print((v) => v.map((t) => `#${t}`).join(", ")));
|
|
1267
1270
|
function linkProperty() {
|
|
1268
1271
|
return spaceBetween(select((l) => typeof l === "string" ? { url: l } : exact({
|
|
1269
1272
|
url: l.url,
|
|
1270
1273
|
title: l.title
|
|
1271
|
-
}), print
|
|
1274
|
+
}), print("link"), print((v) => v.url), property("title", inlineText())));
|
|
1272
1275
|
}
|
|
1273
1276
|
const linksProperty = () => property("links", foreachNewLine(linkProperty()));
|
|
1274
1277
|
function styleBlockProperty() {
|
|
1275
1278
|
return select((e) => e.style, body("style")(styleProperties()));
|
|
1276
1279
|
}
|
|
1277
1280
|
function colorProperty() {
|
|
1278
|
-
return property("color", spaceBetween(print
|
|
1281
|
+
return property("color", spaceBetween(print("color"), print()));
|
|
1279
1282
|
}
|
|
1280
1283
|
function opacityProperty() {
|
|
1281
|
-
return property("opacity", spaceBetween(print
|
|
1284
|
+
return property("opacity", spaceBetween(print("opacity"), print((v) => `${v}%`)));
|
|
1282
1285
|
}
|
|
1283
1286
|
function iconProperty() {
|
|
1284
|
-
return property("icon", spaceBetween(print
|
|
1287
|
+
return property("icon", spaceBetween(print("icon"), print()));
|
|
1285
1288
|
}
|
|
1286
1289
|
const styleProperties = zodOp(style)(lines(property("shape"), colorProperty(), iconProperty(), property("iconColor"), property("iconSize"), property("iconPosition"), property("border"), opacityProperty(), property("size"), property("padding"), property("textSize"), property("multiple")));
|
|
1287
1290
|
//#endregion
|
|
@@ -1345,7 +1348,7 @@ const whereMetadataEqual = zodOp(whereMetadata)(function whereMetadataEqualOp({
|
|
|
1345
1348
|
if ("neq" in value) return out.append(`metadata.${key} is not ${quoteMetadataValue(value.neq)}`);
|
|
1346
1349
|
nonexhaustive(value);
|
|
1347
1350
|
});
|
|
1348
|
-
const whereNot = zodOp(whereNot$1)(property("not", spaceBetween(print
|
|
1351
|
+
const whereNot = zodOp(whereNot$1)(property("not", spaceBetween(print("not ("), lazy(() => whereOperator()), print(")"))));
|
|
1349
1352
|
const whereParticipant = zodOp(whereParticipant$1)(function whereParticipantOp({ ctx: { participant, operator }, out }) {
|
|
1350
1353
|
out.append(participant, ".");
|
|
1351
1354
|
if ("tag" in operator) {
|
|
@@ -1437,7 +1440,7 @@ const fqnExprCustom = zodOp(fqnExprCustom$1)(({ ctx: { custom }, exec }) => {
|
|
|
1437
1440
|
const fqnExprOrWhere = zodOp(fqnExprOrWhere$1)(({ ctx, exec }) => {
|
|
1438
1441
|
if ("where" in ctx) {
|
|
1439
1442
|
exec(ctx.where.expr, fqnExpr());
|
|
1440
|
-
exec(ctx.where.condition, indent(print
|
|
1443
|
+
exec(ctx.where.condition, indent(print("where"), indent(whereOperator())));
|
|
1441
1444
|
return;
|
|
1442
1445
|
}
|
|
1443
1446
|
exec(ctx, fqnExpr());
|
|
@@ -1452,10 +1455,10 @@ const fqnExprAny = zodOp(fqnExprAny$1)(({ ctx, out }) => {
|
|
|
1452
1455
|
out
|
|
1453
1456
|
});
|
|
1454
1457
|
});
|
|
1455
|
-
const directRelationExpr = zodOp(directRelationExpr$1)(merge(property("source", fqnExpr()), print
|
|
1456
|
-
const incomingRelationExpr = zodOp(incomingRelationExpr$1)(merge(print
|
|
1457
|
-
const outgoingRelationExpr = zodOp(outgoingRelationExpr$1)(merge(property("outgoing", fqnExpr()), print
|
|
1458
|
-
const inOutRelationExpr = zodOp(inoutRelationExpr)(merge(print
|
|
1458
|
+
const directRelationExpr = zodOp(directRelationExpr$1)(merge(property("source", fqnExpr()), print((v) => v.isBidirectional ? " <-> " : " -> "), property("target", fqnExpr())));
|
|
1459
|
+
const incomingRelationExpr = zodOp(incomingRelationExpr$1)(merge(print("-> "), property("incoming", fqnExpr())));
|
|
1460
|
+
const outgoingRelationExpr = zodOp(outgoingRelationExpr$1)(merge(property("outgoing", fqnExpr()), print(" ->")));
|
|
1461
|
+
const inOutRelationExpr = zodOp(inoutRelationExpr)(merge(print("-> "), property("inout", fqnExpr()), print(" ->")));
|
|
1459
1462
|
const relationExpr = zodOp(relationExpr$1)(({ ctx, exec }) => {
|
|
1460
1463
|
if ("source" in ctx) return exec(ctx, directRelationExpr());
|
|
1461
1464
|
if ("incoming" in ctx) return exec(ctx, incomingRelationExpr());
|
|
@@ -1464,7 +1467,7 @@ const relationExpr = zodOp(relationExpr$1)(({ ctx, exec }) => {
|
|
|
1464
1467
|
nonexhaustive(ctx);
|
|
1465
1468
|
});
|
|
1466
1469
|
const relationExprOrWhere = zodOp(relationExprOrWhere$1)(({ ctx, out }) => {
|
|
1467
|
-
if ("where" in ctx) return merge(withctx(ctx.where.expr)(relationExpr()), indent(print
|
|
1470
|
+
if ("where" in ctx) return merge(withctx(ctx.where.expr)(relationExpr()), indent(print("where"), indent(withctx(ctx.where.condition)(whereOperator()))))({
|
|
1468
1471
|
ctx,
|
|
1469
1472
|
out
|
|
1470
1473
|
});
|
|
@@ -1539,7 +1542,7 @@ function hasElementProps$1(el) {
|
|
|
1539
1542
|
return !!(el.description || el.summary || el.technology || el.notation || el.tags && el.tags.length > 0 || el.links && el.links.length > 0 || !isEmptyish(el.metadata) || hasStyleProps$1(el));
|
|
1540
1543
|
}
|
|
1541
1544
|
const elementProperties$1 = zodOp(schemas.deployment.element)(lines(tagsProperty(), technologyProperty(), summaryProperty(), descriptionProperty(), linksProperty(), metadataProperty(), select((e) => hasStyleProps$1(e) ? e.style : void 0, body("style")(styleProperties()))));
|
|
1542
|
-
const instance = zodOp(schemas.deployment.instance)(spaceBetween(when((v) => nameFromFqn(v.id) !== nameFromFqn(v.element), print
|
|
1545
|
+
const instance = zodOp(schemas.deployment.instance)(spaceBetween(when((v) => nameFromFqn(v.id) !== nameFromFqn(v.element), print((v) => nameFromFqn(v.id)), print(" =")), print("instanceOf"), printProperty("element"), when((v) => !!v.title && v.title !== nameFromFqn(v.id), property("title", inlineText())), when((e) => hasElementProps$1(e), body(elementProperties$1()))));
|
|
1543
1546
|
function node() {
|
|
1544
1547
|
return function nodeOp({ ctx, out }) {
|
|
1545
1548
|
const el = ctx;
|
|
@@ -1557,9 +1560,9 @@ function node() {
|
|
|
1557
1560
|
const needsBody = el.children.length > 0 || hasElementProps$1(el);
|
|
1558
1561
|
const name = nameFromFqn(el.id);
|
|
1559
1562
|
const inline = [
|
|
1560
|
-
print
|
|
1561
|
-
print
|
|
1562
|
-
print
|
|
1563
|
+
print(name),
|
|
1564
|
+
print("="),
|
|
1565
|
+
print(el.kind)
|
|
1563
1566
|
];
|
|
1564
1567
|
if (el.title && el.title !== name) inline.push(inlineText(el.title));
|
|
1565
1568
|
if (needsBody) inline.push(body(lines(2)(withctx(el, elementProperties$1()), ...el.children.map((node) => withctx(node, nodeOp)))));
|
|
@@ -1575,7 +1578,7 @@ function hasRelationStyle$1(rel) {
|
|
|
1575
1578
|
function hasRelationProps$1(rel) {
|
|
1576
1579
|
return !!(rel.description || rel.summary || rel.technology || rel.tags && rel.tags.length > 0 || rel.links && rel.links.length > 0 || !isEmptyish(rel.metadata) || hasRelationStyle$1(rel) || rel.navigateTo);
|
|
1577
1580
|
}
|
|
1578
|
-
const relationship$1 = zodOp(schemas.deployment.relationship)(spaceBetween(property("source", fqnRef()), print
|
|
1581
|
+
const relationship$1 = zodOp(schemas.deployment.relationship)(spaceBetween(property("source", fqnRef()), print((rel) => rel.kind ? `-[${rel.kind}]->` : "->"), property("target", fqnRef()), property("title", inlineText()), when(hasRelationProps$1, body(tagsProperty(), technologyProperty(), summaryProperty(), descriptionProperty(), property("navigateTo"), linksProperty(), metadataProperty(), when(hasRelationStyle$1, body("style")(colorProperty(), property("line"), property("head"), property("tail")))))));
|
|
1579
1582
|
const deployment = zodOp(schemas.deployment.schema)(body("deployment")(lines(2)(select((d) => buildTree$1(d.elements ? values(d.elements) : []).roots, lines(2)(foreach(node()))), select((d) => d.relations ? values(d.relations) : void 0, lines(2)(foreach(relationship$1()))))));
|
|
1580
1583
|
//#endregion
|
|
1581
1584
|
//#region src/likec4/operators/model.ts
|
|
@@ -1618,9 +1621,9 @@ function elementTree() {
|
|
|
1618
1621
|
const needsBody = (ctx.children?.length ?? 0) > 0 || hasElementProps(el);
|
|
1619
1622
|
const name = nameFromFqn(el.id);
|
|
1620
1623
|
const inline = [
|
|
1621
|
-
print
|
|
1622
|
-
print
|
|
1623
|
-
print
|
|
1624
|
+
print(name),
|
|
1625
|
+
print("="),
|
|
1626
|
+
print(el.kind)
|
|
1624
1627
|
];
|
|
1625
1628
|
if (el.title && el.title !== name) inline.push(inlineText(el.title));
|
|
1626
1629
|
if (needsBody) inline.push(body(lines(2)(withctx(el, elementProperties()), ...(ctx.children ?? []).map((node) => withctx(node, elementTree())))));
|
|
@@ -1636,7 +1639,7 @@ function hasRelationStyle(rel) {
|
|
|
1636
1639
|
function hasRelationProps(rel) {
|
|
1637
1640
|
return !!(rel.description || rel.summary || rel.technology || rel.tags && rel.tags.length > 0 || rel.links && rel.links.length > 0 || !isEmptyish(rel.metadata) || hasRelationStyle(rel) || rel.navigateTo);
|
|
1638
1641
|
}
|
|
1639
|
-
const relationship = zodOp(schemas.model.relationship)(spaceBetween(property("source", fqnRef()), print
|
|
1642
|
+
const relationship = zodOp(schemas.model.relationship)(spaceBetween(property("source", fqnRef()), print((rel) => rel.kind ? `-[${rel.kind}]->` : "->"), property("target", fqnRef()), property("title", inlineText()), when(hasRelationProps, body(tagsProperty(), technologyProperty(), summaryProperty(), descriptionProperty(), property("navigateTo"), linksProperty(), metadataProperty(), when(hasRelationStyle, body("style")(colorProperty(), property("line"), property("head"), property("tail")))))));
|
|
1640
1643
|
const element = zodOp(schemas.model.element)(elementTree());
|
|
1641
1644
|
const model = zodOp(schemas.model.schema)(body("model")(lines(2)(select((d) => buildTree(d.elements ? values(d.elements) : []).roots, lines(2)(foreach(elementTree()))), select((d) => d.relations ? values(d.relations) : void 0, lines(2)(foreach(relationship()))))));
|
|
1642
1645
|
//#endregion
|
|
@@ -1647,9 +1650,9 @@ var specification_exports = /* @__PURE__ */ __exportAll({
|
|
|
1647
1650
|
specification: () => specification,
|
|
1648
1651
|
tagSpecification: () => tagSpecification
|
|
1649
1652
|
});
|
|
1650
|
-
const tagSpecification = zodOp(z$1.tuple([z$1.string(), tagSpec]))(spaceBetween(print
|
|
1651
|
-
const elementKind = (keyword) => zodOp(z$1.tuple([z$1.string(), element$1]))(spaceBetween(print
|
|
1652
|
-
const relationshipKind = zodOp(z$1.tuple([z$1.string(), relationship$2]))(spaceBetween(print
|
|
1653
|
+
const tagSpecification = zodOp(z$1.tuple([z$1.string(), tagSpec]))(spaceBetween(print("tag"), printProperty("0"), property("1", property("color", body(spaceBetween(print("color"), print()))))));
|
|
1654
|
+
const elementKind = (keyword) => zodOp(z$1.tuple([z$1.string(), element$1]))(spaceBetween(print(keyword), printProperty("0"), property("1", body(tagsProperty(), titleProperty(), summaryProperty(), descriptionProperty(), technologyProperty(), notationProperty(), linksProperty(), property("style", body("style")(styleProperties()))))));
|
|
1655
|
+
const relationshipKind = zodOp(z$1.tuple([z$1.string(), relationship$2]))(spaceBetween(print("relationship"), printProperty("0"), property("1", body(technologyProperty(), notationProperty(), colorProperty(), property("line"), property("head"), property("tail")))));
|
|
1653
1656
|
const specification = zodOp(schema)(body("specification")(lines(2)(select((c) => c.elements && entries(c.elements), foreachNewLine(elementKind("element")())), select((c) => c.deployments && entries(c.deployments), foreachNewLine(elementKind("deploymentNode")())), select((c) => c.relationships && entries(c.relationships), foreachNewLine(relationshipKind())), select((c) => c.tags && entries(c.tags), foreachNewLine(tagSpecification())))));
|
|
1654
1657
|
//#endregion
|
|
1655
1658
|
//#region src/likec4/operators/views.ts
|
|
@@ -1657,6 +1660,7 @@ var views_exports = /* @__PURE__ */ __exportAll({
|
|
|
1657
1660
|
anyView: () => anyView,
|
|
1658
1661
|
deploymentView: () => deploymentView,
|
|
1659
1662
|
deploymentViewRule: () => deploymentViewRule,
|
|
1663
|
+
deploymentViewRuleIncludeAncestors: () => deploymentViewRuleIncludeAncestors,
|
|
1660
1664
|
dynamicStep: () => dynamicStep,
|
|
1661
1665
|
dynamicStepsParallel: () => dynamicStepsParallel,
|
|
1662
1666
|
dynamicStepsSeries: () => dynamicStepsSeries,
|
|
@@ -1675,7 +1679,7 @@ var views_exports = /* @__PURE__ */ __exportAll({
|
|
|
1675
1679
|
viewRuleStyle: () => viewRuleStyle,
|
|
1676
1680
|
views: () => views
|
|
1677
1681
|
});
|
|
1678
|
-
const viewTitleProperty = () => property("title", spaceBetween(print
|
|
1682
|
+
const viewTitleProperty = () => property("title", spaceBetween(print("title"), inlineText()));
|
|
1679
1683
|
const viewRulePredicate = zodOp(schemas.views.viewRulePredicate)(({ ctx, exec }) => {
|
|
1680
1684
|
let exprs;
|
|
1681
1685
|
let type;
|
|
@@ -1690,9 +1694,9 @@ const viewRulePredicate = zodOp(schemas.views.viewRulePredicate)(({ ctx, exec })
|
|
|
1690
1694
|
if (!hasAtLeast(exprs, 1)) return;
|
|
1691
1695
|
const isMultiple = hasAtLeast(exprs, 2);
|
|
1692
1696
|
const exprOp = withctx(exprs)(foreach(expression(), separateComma(isMultiple)));
|
|
1693
|
-
exec(ctx, merge(print
|
|
1697
|
+
exec(ctx, merge(print(type), ...isMultiple ? [indent(exprOp)] : [space(), exprOp]));
|
|
1694
1698
|
});
|
|
1695
|
-
const viewRuleStyle = zodOp(schemas.views.viewRuleStyle)(spaceBetween(print
|
|
1699
|
+
const viewRuleStyle = zodOp(schemas.views.viewRuleStyle)(spaceBetween(print("style"), property("targets", foreach(expression(), separateComma())), body("{", "}")(notationProperty(), property("style", styleProperties()))));
|
|
1696
1700
|
const viewRuleGroup = zodOp(schemas.views.viewRuleGroup)(({ ctx, exec }) => {
|
|
1697
1701
|
throw new Error("not implemented");
|
|
1698
1702
|
});
|
|
@@ -1708,7 +1712,8 @@ const mapping = {
|
|
|
1708
1712
|
"LR": "LeftRight",
|
|
1709
1713
|
"RL": "RightLeft"
|
|
1710
1714
|
};
|
|
1711
|
-
const viewRuleAutoLayout = zodOp(schemas.views.viewRuleAutoLayout)(spaceBetween(print
|
|
1715
|
+
const viewRuleAutoLayout = zodOp(schemas.views.viewRuleAutoLayout)(spaceBetween(print("autoLayout"), property("direction", print((v) => mapping[v])), guard(hasProp("rankSep"), spaceBetween(printProperty("rankSep"), printProperty("nodeSep")))));
|
|
1716
|
+
const deploymentViewRuleIncludeAncestors = zodOp(schemas.views.deploymentViewRuleIncludeAncestors)(spaceBetween(print("includeAncestors"), printProperty("includeAncestors")));
|
|
1712
1717
|
const viewRuleRank = zodOp(schemas.views.viewRuleRank)(({ ctx, exec }) => {
|
|
1713
1718
|
throw new Error("not implemented");
|
|
1714
1719
|
});
|
|
@@ -1722,17 +1727,18 @@ const elementViewRule = zodOp(schemas.views.elementViewRule)(({ ctx, exec }) =>
|
|
|
1722
1727
|
if ("targets" in ctx && "style" in ctx) return exec(ctx, viewRuleStyle());
|
|
1723
1728
|
nonexhaustive(ctx);
|
|
1724
1729
|
});
|
|
1725
|
-
const elementView = zodOp(schemas.views.elementView.partial({ _type: true }))(spaceBetween(print
|
|
1730
|
+
const elementView = zodOp(schemas.views.elementView.partial({ _type: true }))(spaceBetween(print("view"), print((v) => v.id), property("viewOf", spaceBetween(print("of"), print())), body(lines(2)(lines(tagsProperty(), viewTitleProperty(), descriptionProperty(), linksProperty()), property("rules", foreachNewLine(elementViewRule()))))));
|
|
1726
1731
|
const deploymentViewRule = zodOp(schemas.views.deploymentViewRule)(({ ctx, exec }) => {
|
|
1727
1732
|
if ("include" in ctx || "exclude" in ctx) return exec(ctx, viewRulePredicate());
|
|
1733
|
+
if ("includeAncestors" in ctx) return exec(ctx, deploymentViewRuleIncludeAncestors());
|
|
1728
1734
|
if ("direction" in ctx) return exec(ctx, viewRuleAutoLayout());
|
|
1729
1735
|
if ("styleId" in ctx) return exec(ctx, viewRuleGlobalStyle());
|
|
1730
1736
|
if ("predicateId" in ctx) return exec(ctx, viewRuleGlobalPredicate());
|
|
1731
1737
|
if ("targets" in ctx && "style" in ctx) return exec(ctx, viewRuleStyle());
|
|
1732
1738
|
nonexhaustive(ctx);
|
|
1733
1739
|
});
|
|
1734
|
-
const deploymentView = zodOp(schemas.views.deploymentView.partial({ _type: true }))(spaceBetween(print
|
|
1735
|
-
const dynamicStep = zodOp(schemas.views.dynamicStep)(spaceBetween(print
|
|
1740
|
+
const deploymentView = zodOp(schemas.views.deploymentView.partial({ _type: true }))(spaceBetween(print("deployment view"), print((v) => v.id), body(lines(2)(lines(tagsProperty(), viewTitleProperty(), descriptionProperty(), linksProperty()), property("rules", foreachNewLine(deploymentViewRule()))))));
|
|
1741
|
+
const dynamicStep = zodOp(schemas.views.dynamicStep)(spaceBetween(print((v) => v.source), print((v) => v.isBackward ? "<-" : "->"), print((v) => v.target), body(lines(titleProperty(), technologyProperty(), descriptionProperty(), notesProperty(), property("navigateTo"), notationProperty(), colorProperty(), property("line"), property("head"), property("tail")))));
|
|
1736
1742
|
const dynamicStepsSeries = zodOp(schemas.views.dynamicStepsSeries)(({ ctx, exec }) => {
|
|
1737
1743
|
throw new Error("Not implemented");
|
|
1738
1744
|
});
|
|
@@ -1748,7 +1754,7 @@ const dynamicViewIncludeRule = zodOp(schemas.views.dynamicViewIncludeRule)(({ ct
|
|
|
1748
1754
|
if (!hasAtLeast(ctx.include, 1)) return;
|
|
1749
1755
|
const isMultiple = hasAtLeast(ctx.include, 2);
|
|
1750
1756
|
const exprOp = withctx(ctx.include)(foreach(expression(), separateComma(isMultiple)));
|
|
1751
|
-
exec(ctx, merge(print
|
|
1757
|
+
exec(ctx, merge(print("include"), ...isMultiple ? [indent(exprOp)] : [space(), exprOp]));
|
|
1752
1758
|
});
|
|
1753
1759
|
const dynamicViewRule = zodOp(schemas.views.dynamicViewRule)(({ ctx, exec }) => {
|
|
1754
1760
|
if ("include" in ctx) return exec(ctx, dynamicViewIncludeRule());
|
|
@@ -1758,7 +1764,7 @@ const dynamicViewRule = zodOp(schemas.views.dynamicViewRule)(({ ctx, exec }) =>
|
|
|
1758
1764
|
if ("direction" in ctx) return exec(ctx, viewRuleAutoLayout());
|
|
1759
1765
|
nonexhaustive(ctx);
|
|
1760
1766
|
});
|
|
1761
|
-
const dynamicView = zodOp(schemas.views.dynamicView.partial({ _type: true }))(spaceBetween(print
|
|
1767
|
+
const dynamicView = zodOp(schemas.views.dynamicView.partial({ _type: true }))(spaceBetween(print("dynamic view"), print((v) => v.id), body(lines(2)(lines(tagsProperty(), viewTitleProperty(), descriptionProperty(), linksProperty(), property("variant")), property("steps", foreachNewLine(dynamicViewStep())), property("rules", foreachNewLine(dynamicViewRule()))))));
|
|
1762
1768
|
const anyView = zodOp(schemas.views.anyView)(({ ctx, exec }) => {
|
|
1763
1769
|
if ("_type" in ctx) {
|
|
1764
1770
|
if (ctx._type == "element") return exec(ctx, elementView());
|
|
@@ -1803,58 +1809,11 @@ function generateLikeC4(input, params) {
|
|
|
1803
1809
|
};
|
|
1804
1810
|
return materialize(withctx(input, likec4data()), params.indentation);
|
|
1805
1811
|
}
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
*
|
|
1809
|
-
* @see operators
|
|
1810
|
-
*
|
|
1811
|
-
* @example
|
|
1812
|
-
* ```ts
|
|
1813
|
-
* print(operators.expression, {
|
|
1814
|
-
* ref: {
|
|
1815
|
-
* model: 'some.el',
|
|
1816
|
-
* },
|
|
1817
|
-
* selector: 'descendants',
|
|
1818
|
-
* })
|
|
1819
|
-
* // "some.el.**"
|
|
1820
|
-
* ```
|
|
1821
|
-
*
|
|
1822
|
-
* @example
|
|
1823
|
-
* ```ts
|
|
1824
|
-
* print(operators.model, {
|
|
1825
|
-
* elements: [
|
|
1826
|
-
* {
|
|
1827
|
-
* id: 'cloud',
|
|
1828
|
-
* kind: 'system',
|
|
1829
|
-
* },
|
|
1830
|
-
* {
|
|
1831
|
-
* id: 'cloud.mobile',
|
|
1832
|
-
* kind: 'mobileapp',
|
|
1833
|
-
* shape: 'mobile',
|
|
1834
|
-
* color: 'amber',
|
|
1835
|
-
* }
|
|
1836
|
-
* ],
|
|
1837
|
-
* })
|
|
1838
|
-
* // model {
|
|
1839
|
-
* // cloud = system {
|
|
1840
|
-
* // mobile = mobileapp {
|
|
1841
|
-
* // style {
|
|
1842
|
-
* // shape mobile
|
|
1843
|
-
* // color amber
|
|
1844
|
-
* // }
|
|
1845
|
-
* // }
|
|
1846
|
-
* // }
|
|
1847
|
-
* // }
|
|
1848
|
-
* ```
|
|
1849
|
-
*/
|
|
1850
|
-
function print(operator, data, params) {
|
|
1851
|
-
return materialize(withctx(data, operator()), params?.indentation);
|
|
1812
|
+
function printOperation(operation, data, params) {
|
|
1813
|
+
return materialize(withctx(data ?? {}, operation), params?.indentation);
|
|
1852
1814
|
}
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
*/
|
|
1856
|
-
function printTabIndent(operator, data) {
|
|
1857
|
-
return materialize(withctx(data, operator()), " ");
|
|
1815
|
+
function printWithTabIndent(operation, data) {
|
|
1816
|
+
return materialize(withctx(data ?? {}, operation), " ");
|
|
1858
1817
|
}
|
|
1859
1818
|
//#endregion
|
|
1860
|
-
export { generateLikeC4 as generate, operators_exports as
|
|
1819
|
+
export { body, eachOnFresh, eq, executeOnCtx, executeOnFresh, foreach, foreachNewLine, fresh, generateLikeC4 as generate, guard, indent, inlineText, join, lazy, lines, markdown, markdownOrString, materialize, merge, newline, noop, operation, operators_exports as ops, print, printOperation, printProperty, printWithTabIndent, property, select, separateComma, separateNewLine, separateWith, space, spaceBetween, text, when, withctx, zodOp };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/generators",
|
|
3
|
-
"version": "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.
|
|
58
|
-
"@likec4/config": "1.
|
|
59
|
-
"@likec4/log": "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.
|
|
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/
|
|
68
|
-
"@likec4/
|
|
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
|
|
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,
|
|
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
|
|
22
|
+
* @see ops
|
|
21
23
|
*
|
|
22
24
|
* @example
|
|
23
25
|
* ```ts
|
|
24
|
-
*
|
|
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
|
-
*
|
|
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
|
|
62
|
-
|
|
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
|
|
78
|
+
* Same as {@link printOperation} but uses tab indentation
|
|
67
79
|
*/
|
|
68
|
-
export function
|
|
69
|
-
|
|
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 }
|
package/src/likec4/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export {
|
|
2
2
|
generateLikeC4 as generate,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
ops,
|
|
4
|
+
printOperation,
|
|
5
|
+
printWithTabIndent,
|
|
6
6
|
} from './generate-likec4'
|
|
7
7
|
|
|
8
|
-
export
|
|
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
|
/**
|