@likec4/generators 1.56.0 → 1.58.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/index.mjs +18 -13
- package/dist/likec4/index.d.mts +63 -205
- package/dist/likec4/index.mjs +76 -117
- package/package.json +12 -12
- 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/src/model/generate-aux.ts +28 -17
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CompositeGeneratorNode, NL, expandToNode, joinToNode, toString } from "langium/generate";
|
|
2
|
-
import { isEmptyish, isNullish, keys, map, pipe, values } from "remeda";
|
|
2
|
+
import { filter, isEmptyish, isNullish, isTruthy, keys, map, pipe, sort, unique, values } from "remeda";
|
|
3
3
|
import { LikeC4Styles, nonexhaustive } from "@likec4/core";
|
|
4
4
|
import { RichText, flattenMarkdownOrString } from "@likec4/core/types";
|
|
5
5
|
import pako from "pako";
|
|
@@ -2375,14 +2375,19 @@ function generateMermaid(viewmodel) {
|
|
|
2375
2375
|
}
|
|
2376
2376
|
//#endregion
|
|
2377
2377
|
//#region src/model/generate-aux.ts
|
|
2378
|
+
/**
|
|
2379
|
+
* Converts an array of strings or a record keys to a TypeScript union type string
|
|
2380
|
+
* Handles empty arrays/records by returning 'never'
|
|
2381
|
+
*/
|
|
2378
2382
|
function toUnion(elements) {
|
|
2379
|
-
if (elements
|
|
2380
|
-
|
|
2383
|
+
if (isEmptyish(elements)) return "never";
|
|
2384
|
+
if (typeof elements === "object" && !Array.isArray(elements)) elements = keys(elements);
|
|
2385
|
+
return pipe(elements, unique(), sort(compareNatural), map((v) => ` | ${JSON.stringify(v)}`)).join("\n").trimStart();
|
|
2381
2386
|
}
|
|
2382
|
-
function elementIdToUnion(
|
|
2383
|
-
|
|
2384
|
-
if (
|
|
2385
|
-
return
|
|
2387
|
+
function elementIdToUnion(elements) {
|
|
2388
|
+
let union = pipe(elements, values(), filter((i) => !!i && isTruthy(i.id)), sortNaturalByFqn, map((v) => ` | ${JSON.stringify(v.id)}`));
|
|
2389
|
+
if (union.length === 0) return "never";
|
|
2390
|
+
return union.join("\n").trimStart();
|
|
2386
2391
|
}
|
|
2387
2392
|
function generateAux(model, options = {}) {
|
|
2388
2393
|
const { useCorePackage = false } = options;
|
|
@@ -2391,15 +2396,15 @@ import type { Aux, SpecAux } from '${useCorePackage ? "@likec4/core/types" : "li
|
|
|
2391
2396
|
|
|
2392
2397
|
export type $Specs = SpecAux<
|
|
2393
2398
|
// Element kinds
|
|
2394
|
-
${toUnion(
|
|
2399
|
+
${toUnion(model.specification.elements)},
|
|
2395
2400
|
// Deployment kinds
|
|
2396
|
-
${toUnion(
|
|
2401
|
+
${toUnion(model.specification.deployments)},
|
|
2397
2402
|
// Relationship kinds
|
|
2398
|
-
${toUnion(
|
|
2403
|
+
${toUnion(model.specification.relationships)},
|
|
2399
2404
|
// Tags
|
|
2400
|
-
${toUnion(
|
|
2405
|
+
${toUnion(model.specification.tags)},
|
|
2401
2406
|
// Metadata keys
|
|
2402
|
-
${toUnion(model.specification.metadataKeys
|
|
2407
|
+
${toUnion(model.specification.metadataKeys)}
|
|
2403
2408
|
>
|
|
2404
2409
|
|
|
2405
2410
|
export type $Aux = Aux<
|
|
@@ -2409,7 +2414,7 @@ export type $Aux = Aux<
|
|
|
2409
2414
|
// Deployments
|
|
2410
2415
|
${elementIdToUnion(model.$data.deployments.elements)},
|
|
2411
2416
|
// Views
|
|
2412
|
-
${toUnion(
|
|
2417
|
+
${toUnion(model.$data.views)},
|
|
2413
2418
|
// Project ID
|
|
2414
2419
|
${JSON.stringify(model.projectId)},
|
|
2415
2420
|
$Specs
|
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">>;
|
|
@@ -107817,111 +107830,7 @@ declare const schemas: {
|
|
|
107817
107830
|
}, z.core.$strip>]>>>;
|
|
107818
107831
|
project: z.ZodOptional<z.ZodObject<{
|
|
107819
107832
|
id: z.ZodString;
|
|
107820
|
-
styles:
|
|
107821
|
-
theme: z.ZodOptional<z.ZodPipe<z.ZodObject<{
|
|
107822
|
-
colors: z.ZodOptional<z.ZodPipe<z.ZodRecord<z.ZodPipe<z.ZodUnion<[z.ZodEnum<{
|
|
107823
|
-
[x: string]: any;
|
|
107824
|
-
}>, z.ZodPipe<z.ZodCustom<string & Record<never, never>, string & Record<never, never>>, z.ZodTransform<any, string & Record<never, never>>>]>, z.ZodTransform<any, any>> & z.core.$partial, z.ZodPipe<z.ZodUnion<[z.ZodPipe<z.ZodObject<{
|
|
107825
|
-
elements: z.ZodUnion<[z.ZodPipe<z.ZodObject<{
|
|
107826
|
-
fill: z.ZodString;
|
|
107827
|
-
stroke: z.ZodString;
|
|
107828
|
-
hiContrast: z.ZodString;
|
|
107829
|
-
loContrast: z.ZodString;
|
|
107830
|
-
}, z.core.$strict>, z.ZodTransform<any, {
|
|
107831
|
-
fill: string;
|
|
107832
|
-
stroke: string;
|
|
107833
|
-
hiContrast: string;
|
|
107834
|
-
loContrast: string;
|
|
107835
|
-
}>>, z.ZodPipe<z.ZodString, z.ZodTransform<any, string>>]>;
|
|
107836
|
-
relationships: z.ZodUnion<[z.ZodPipe<z.ZodObject<{
|
|
107837
|
-
line: z.ZodString;
|
|
107838
|
-
label: z.ZodString;
|
|
107839
|
-
labelBg: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
107840
|
-
}, z.core.$strict>, z.ZodTransform<any, {
|
|
107841
|
-
line: string;
|
|
107842
|
-
label: string;
|
|
107843
|
-
labelBg: string;
|
|
107844
|
-
}>>, z.ZodPipe<z.ZodString, z.ZodTransform<any, string>>]>;
|
|
107845
|
-
}, z.core.$strict>, z.ZodTransform<any, {
|
|
107846
|
-
elements: any;
|
|
107847
|
-
relationships: any;
|
|
107848
|
-
}>>, z.ZodPipe<z.ZodString, z.ZodTransform<any, string>>]>, z.ZodTransform<any, any>>>, z.ZodTransform<Record<ThemeColor, ThemeColorValues>, Partial<Record<any, any>>>>>;
|
|
107849
|
-
sizes: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
107850
|
-
[x: string]: any;
|
|
107851
|
-
}> & z.core.$partial, z.ZodObject<{
|
|
107852
|
-
width: z.ZodNumber;
|
|
107853
|
-
height: z.ZodNumber;
|
|
107854
|
-
}, z.core.$strict>>>;
|
|
107855
|
-
}, z.core.$strict>, z.ZodTransform<any, {
|
|
107856
|
-
colors?: Record<ThemeColor, ThemeColorValues> | undefined;
|
|
107857
|
-
sizes?: Partial<Record<any, {
|
|
107858
|
-
width: number;
|
|
107859
|
-
height: number;
|
|
107860
|
-
}>> | undefined;
|
|
107861
|
-
}>>>;
|
|
107862
|
-
defaults: z.ZodOptional<z.ZodObject<{
|
|
107863
|
-
color: z.ZodOptional<z.ZodPipe<z.ZodUnion<[z.ZodEnum<{
|
|
107864
|
-
[x: string]: any;
|
|
107865
|
-
}>, z.ZodPipe<z.ZodCustom<string & Record<never, never>, string & Record<never, never>>, z.ZodTransform<any, string & Record<never, never>>>]>, z.ZodTransform<any, any>>>;
|
|
107866
|
-
opacity: z.ZodOptional<z.ZodInt>;
|
|
107867
|
-
border: z.ZodOptional<z.ZodEnum<{
|
|
107868
|
-
[x: string]: any;
|
|
107869
|
-
}>>;
|
|
107870
|
-
size: z.ZodOptional<z.ZodEnum<{
|
|
107871
|
-
[x: string]: any;
|
|
107872
|
-
}>>;
|
|
107873
|
-
shape: z.ZodOptional<z.ZodEnum<{
|
|
107874
|
-
[x: string]: any;
|
|
107875
|
-
}>>;
|
|
107876
|
-
iconPosition: z.ZodOptional<z.ZodEnum<{
|
|
107877
|
-
[x: string]: any;
|
|
107878
|
-
}>>;
|
|
107879
|
-
group: z.ZodOptional<z.ZodObject<{
|
|
107880
|
-
color: z.ZodOptional<z.ZodPipe<z.ZodUnion<[z.ZodEnum<{
|
|
107881
|
-
[x: string]: any;
|
|
107882
|
-
}>, z.ZodPipe<z.ZodCustom<string & Record<never, never>, string & Record<never, never>>, z.ZodTransform<any, string & Record<never, never>>>]>, z.ZodTransform<any, any>>>;
|
|
107883
|
-
opacity: z.ZodOptional<z.ZodInt>;
|
|
107884
|
-
border: z.ZodOptional<z.ZodEnum<{
|
|
107885
|
-
[x: string]: any;
|
|
107886
|
-
}>>;
|
|
107887
|
-
}, z.core.$strict>>;
|
|
107888
|
-
relationship: z.ZodOptional<z.ZodObject<{
|
|
107889
|
-
color: z.ZodOptional<z.ZodPipe<z.ZodUnion<[z.ZodEnum<{
|
|
107890
|
-
[x: string]: any;
|
|
107891
|
-
}>, z.ZodPipe<z.ZodCustom<string & Record<never, never>, string & Record<never, never>>, z.ZodTransform<any, string & Record<never, never>>>]>, z.ZodTransform<any, any>>>;
|
|
107892
|
-
line: z.ZodOptional<z.ZodEnum<{
|
|
107893
|
-
dashed: "dashed";
|
|
107894
|
-
solid: "solid";
|
|
107895
|
-
dotted: "dotted";
|
|
107896
|
-
}>>;
|
|
107897
|
-
arrow: z.ZodOptional<z.ZodEnum<{
|
|
107898
|
-
[x: string]: any;
|
|
107899
|
-
}>>;
|
|
107900
|
-
}, z.core.$strict>>;
|
|
107901
|
-
}, z.core.$strict>>;
|
|
107902
|
-
customCss: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
107903
|
-
}, z.core.$strict>, z.ZodTransform<any, {
|
|
107904
|
-
theme?: any;
|
|
107905
|
-
defaults?: {
|
|
107906
|
-
color?: any;
|
|
107907
|
-
opacity?: number | undefined;
|
|
107908
|
-
border?: any;
|
|
107909
|
-
size?: any;
|
|
107910
|
-
shape?: any;
|
|
107911
|
-
iconPosition?: any;
|
|
107912
|
-
group?: {
|
|
107913
|
-
color?: any;
|
|
107914
|
-
opacity?: number | undefined;
|
|
107915
|
-
border?: any;
|
|
107916
|
-
} | undefined;
|
|
107917
|
-
relationship?: {
|
|
107918
|
-
color?: any;
|
|
107919
|
-
line?: "dashed" | "solid" | "dotted" | undefined;
|
|
107920
|
-
arrow?: any;
|
|
107921
|
-
} | undefined;
|
|
107922
|
-
} | undefined;
|
|
107923
|
-
customCss?: string | string[] | undefined;
|
|
107924
|
-
}>>>>;
|
|
107833
|
+
styles: any;
|
|
107925
107834
|
}, z.core.$strip>>;
|
|
107926
107835
|
deployment: z.ZodOptional<z.ZodObject<{
|
|
107927
107836
|
elements: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodRecord<z.ZodPipe<z.ZodString, z.ZodTransform<any, string>>, z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodReadonly<z.ZodObject<{
|
|
@@ -109803,8 +109712,8 @@ declare const schemas: {
|
|
|
109803
109712
|
rules?: any[] | undefined;
|
|
109804
109713
|
}> | undefined;
|
|
109805
109714
|
project?: {
|
|
109715
|
+
[x: string]: any;
|
|
109806
109716
|
id: string;
|
|
109807
|
-
styles?: any;
|
|
109808
109717
|
} | undefined;
|
|
109809
109718
|
deployment?: {
|
|
109810
109719
|
elements?: Record<any, {
|
|
@@ -109888,8 +109797,8 @@ declare const schemas: {
|
|
|
109888
109797
|
rules?: any[] | undefined;
|
|
109889
109798
|
}> | undefined;
|
|
109890
109799
|
project?: {
|
|
109800
|
+
[x: string]: any;
|
|
109891
109801
|
id: string;
|
|
109892
|
-
styles?: any;
|
|
109893
109802
|
} | undefined;
|
|
109894
109803
|
deployment?: {
|
|
109895
109804
|
elements?: Record<any, {
|
|
@@ -142042,6 +141951,8 @@ declare const likec4data: <A extends Readonly<{
|
|
|
142042
141951
|
styleId: string;
|
|
142043
141952
|
} | {
|
|
142044
141953
|
predicateId: string;
|
|
141954
|
+
} | {
|
|
141955
|
+
includeAncestors: boolean;
|
|
142045
141956
|
})[] | undefined;
|
|
142046
141957
|
} | {
|
|
142047
141958
|
id: string;
|
|
@@ -144193,47 +144104,8 @@ declare const likec4data: <A extends Readonly<{
|
|
|
144193
144104
|
})[] | undefined;
|
|
144194
144105
|
}> | undefined;
|
|
144195
144106
|
project?: {
|
|
144107
|
+
[x: string]: any;
|
|
144196
144108
|
id: string;
|
|
144197
|
-
styles?: {
|
|
144198
|
-
theme?: {
|
|
144199
|
-
colors?: Partial<Record<any, string | {
|
|
144200
|
-
elements: string | {
|
|
144201
|
-
fill: string;
|
|
144202
|
-
stroke: string;
|
|
144203
|
-
hiContrast: string;
|
|
144204
|
-
loContrast: string;
|
|
144205
|
-
};
|
|
144206
|
-
relationships: string | {
|
|
144207
|
-
line: string;
|
|
144208
|
-
label: string;
|
|
144209
|
-
labelBg?: string | undefined;
|
|
144210
|
-
};
|
|
144211
|
-
}>> | undefined;
|
|
144212
|
-
sizes?: Partial<Record<any, {
|
|
144213
|
-
width: number;
|
|
144214
|
-
height: number;
|
|
144215
|
-
}>> | undefined;
|
|
144216
|
-
} | undefined;
|
|
144217
|
-
defaults?: {
|
|
144218
|
-
color?: any;
|
|
144219
|
-
opacity?: number | undefined;
|
|
144220
|
-
border?: any;
|
|
144221
|
-
size?: any;
|
|
144222
|
-
shape?: any;
|
|
144223
|
-
iconPosition?: any;
|
|
144224
|
-
group?: {
|
|
144225
|
-
color?: any;
|
|
144226
|
-
opacity?: number | undefined;
|
|
144227
|
-
border?: any;
|
|
144228
|
-
} | undefined;
|
|
144229
|
-
relationship?: {
|
|
144230
|
-
color?: any;
|
|
144231
|
-
line?: "dashed" | "solid" | "dotted" | undefined;
|
|
144232
|
-
arrow?: any;
|
|
144233
|
-
} | undefined;
|
|
144234
|
-
} | undefined;
|
|
144235
|
-
customCss?: string | string[] | undefined;
|
|
144236
|
-
} | null | undefined;
|
|
144237
144109
|
} | undefined;
|
|
144238
144110
|
deployment?: {
|
|
144239
144111
|
elements?: Record<string, Readonly<{
|
|
@@ -153296,6 +153168,8 @@ declare const likec4data: <A extends Readonly<{
|
|
|
153296
153168
|
styleId: string;
|
|
153297
153169
|
} | {
|
|
153298
153170
|
predicateId: string;
|
|
153171
|
+
} | {
|
|
153172
|
+
includeAncestors: boolean;
|
|
153299
153173
|
})[] | undefined;
|
|
153300
153174
|
} | {
|
|
153301
153175
|
id: string;
|
|
@@ -155447,47 +155321,8 @@ declare const likec4data: <A extends Readonly<{
|
|
|
155447
155321
|
})[] | undefined;
|
|
155448
155322
|
}> | undefined;
|
|
155449
155323
|
project?: {
|
|
155324
|
+
[x: string]: any;
|
|
155450
155325
|
id: string;
|
|
155451
|
-
styles?: {
|
|
155452
|
-
theme?: {
|
|
155453
|
-
colors?: Partial<Record<any, string | {
|
|
155454
|
-
elements: string | {
|
|
155455
|
-
fill: string;
|
|
155456
|
-
stroke: string;
|
|
155457
|
-
hiContrast: string;
|
|
155458
|
-
loContrast: string;
|
|
155459
|
-
};
|
|
155460
|
-
relationships: string | {
|
|
155461
|
-
line: string;
|
|
155462
|
-
label: string;
|
|
155463
|
-
labelBg?: string | undefined;
|
|
155464
|
-
};
|
|
155465
|
-
}>> | undefined;
|
|
155466
|
-
sizes?: Partial<Record<any, {
|
|
155467
|
-
width: number;
|
|
155468
|
-
height: number;
|
|
155469
|
-
}>> | undefined;
|
|
155470
|
-
} | undefined;
|
|
155471
|
-
defaults?: {
|
|
155472
|
-
color?: any;
|
|
155473
|
-
opacity?: number | undefined;
|
|
155474
|
-
border?: any;
|
|
155475
|
-
size?: any;
|
|
155476
|
-
shape?: any;
|
|
155477
|
-
iconPosition?: any;
|
|
155478
|
-
group?: {
|
|
155479
|
-
color?: any;
|
|
155480
|
-
opacity?: number | undefined;
|
|
155481
|
-
border?: any;
|
|
155482
|
-
} | undefined;
|
|
155483
|
-
relationship?: {
|
|
155484
|
-
color?: any;
|
|
155485
|
-
line?: "dashed" | "solid" | "dotted" | undefined;
|
|
155486
|
-
arrow?: any;
|
|
155487
|
-
} | undefined;
|
|
155488
|
-
} | undefined;
|
|
155489
|
-
customCss?: string | string[] | undefined;
|
|
155490
|
-
} | null | undefined;
|
|
155491
155326
|
} | undefined;
|
|
155492
155327
|
deployment?: {
|
|
155493
155328
|
elements?: Record<string, Readonly<{
|
|
@@ -156957,7 +156792,7 @@ declare const specification: <A extends {
|
|
|
156957
156792
|
}> | undefined;
|
|
156958
156793
|
}>() => Op<A>;
|
|
156959
156794
|
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 };
|
|
156795
|
+
export { anyView, deploymentView, deploymentViewRule, deploymentViewRuleIncludeAncestors, dynamicStep, dynamicStepsParallel, dynamicStepsSeries, dynamicView, dynamicViewIncludeRule, dynamicViewRule, dynamicViewStep, elementView, elementViewRule, viewRuleAutoLayout, viewRuleGlobalPredicate, viewRuleGlobalStyle, viewRuleGroup, viewRulePredicate, viewRuleRank, viewRuleStyle, views };
|
|
156961
156796
|
}
|
|
156962
156797
|
declare const viewRulePredicate: <A extends {
|
|
156963
156798
|
include: ({
|
|
@@ -167925,6 +167760,11 @@ declare const viewRuleAutoLayout: <A extends {
|
|
|
167925
167760
|
nodeSep?: number | undefined;
|
|
167926
167761
|
rankSep?: number | undefined;
|
|
167927
167762
|
}>() => Op<A>;
|
|
167763
|
+
declare const deploymentViewRuleIncludeAncestors: <A extends {
|
|
167764
|
+
includeAncestors: boolean;
|
|
167765
|
+
} = {
|
|
167766
|
+
includeAncestors: boolean;
|
|
167767
|
+
}>() => Op<A>;
|
|
167928
167768
|
declare const viewRuleRank: <A extends {
|
|
167929
167769
|
targets: ({
|
|
167930
167770
|
wildcard: true;
|
|
@@ -194572,6 +194412,8 @@ declare const deploymentViewRule: <A extends {
|
|
|
194572
194412
|
styleId: string;
|
|
194573
194413
|
} | {
|
|
194574
194414
|
predicateId: string;
|
|
194415
|
+
} | {
|
|
194416
|
+
includeAncestors: boolean;
|
|
194575
194417
|
} = {
|
|
194576
194418
|
include: ({
|
|
194577
194419
|
wildcard: true;
|
|
@@ -200052,6 +199894,8 @@ declare const deploymentViewRule: <A extends {
|
|
|
200052
199894
|
styleId: string;
|
|
200053
199895
|
} | {
|
|
200054
199896
|
predicateId: string;
|
|
199897
|
+
} | {
|
|
199898
|
+
includeAncestors: boolean;
|
|
200055
199899
|
}>() => Op<A>;
|
|
200056
199900
|
declare const deploymentView: <A extends {
|
|
200057
199901
|
id: string;
|
|
@@ -205092,6 +204936,8 @@ declare const deploymentView: <A extends {
|
|
|
205092
204936
|
styleId: string;
|
|
205093
204937
|
} | {
|
|
205094
204938
|
predicateId: string;
|
|
204939
|
+
} | {
|
|
204940
|
+
includeAncestors: boolean;
|
|
205095
204941
|
})[] | undefined;
|
|
205096
204942
|
} = {
|
|
205097
204943
|
id: string;
|
|
@@ -210132,6 +209978,8 @@ declare const deploymentView: <A extends {
|
|
|
210132
209978
|
styleId: string;
|
|
210133
209979
|
} | {
|
|
210134
209980
|
predicateId: string;
|
|
209981
|
+
} | {
|
|
209982
|
+
includeAncestors: boolean;
|
|
210135
209983
|
})[] | undefined;
|
|
210136
209984
|
}>() => Op<A>;
|
|
210137
209985
|
declare const dynamicStep: <A extends Readonly<{
|
|
@@ -236478,6 +236326,8 @@ declare const anyView: <A extends {
|
|
|
236478
236326
|
styleId: string;
|
|
236479
236327
|
} | {
|
|
236480
236328
|
predicateId: string;
|
|
236329
|
+
} | {
|
|
236330
|
+
includeAncestors: boolean;
|
|
236481
236331
|
})[] | undefined;
|
|
236482
236332
|
} | {
|
|
236483
236333
|
id: string;
|
|
@@ -249160,6 +249010,8 @@ declare const anyView: <A extends {
|
|
|
249160
249010
|
styleId: string;
|
|
249161
249011
|
} | {
|
|
249162
249012
|
predicateId: string;
|
|
249013
|
+
} | {
|
|
249014
|
+
includeAncestors: boolean;
|
|
249163
249015
|
})[] | undefined;
|
|
249164
249016
|
} | {
|
|
249165
249017
|
id: string;
|
|
@@ -261843,6 +261695,8 @@ declare const views: <A extends Record<string, {
|
|
|
261843
261695
|
styleId: string;
|
|
261844
261696
|
} | {
|
|
261845
261697
|
predicateId: string;
|
|
261698
|
+
} | {
|
|
261699
|
+
includeAncestors: boolean;
|
|
261846
261700
|
})[] | undefined;
|
|
261847
261701
|
} | {
|
|
261848
261702
|
id: string;
|
|
@@ -274525,6 +274379,8 @@ declare const views: <A extends Record<string, {
|
|
|
274525
274379
|
styleId: string;
|
|
274526
274380
|
} | {
|
|
274527
274381
|
predicateId: string;
|
|
274382
|
+
} | {
|
|
274383
|
+
includeAncestors: boolean;
|
|
274528
274384
|
})[] | undefined;
|
|
274529
274385
|
} | {
|
|
274530
274386
|
id: string;
|
|
@@ -277119,11 +276975,11 @@ declare function generateLikeC4(input: schemas.likec4data.Input, params?: Params
|
|
|
277119
276975
|
/**
|
|
277120
276976
|
* Prints the result of an operation with the data
|
|
277121
276977
|
*
|
|
277122
|
-
* @see
|
|
276978
|
+
* @see ops
|
|
277123
276979
|
*
|
|
277124
276980
|
* @example
|
|
277125
276981
|
* ```ts
|
|
277126
|
-
*
|
|
276982
|
+
* printOperation(ops.expression(), {
|
|
277127
276983
|
* ref: {
|
|
277128
276984
|
* model: 'some.el',
|
|
277129
276985
|
* },
|
|
@@ -277134,7 +276990,7 @@ declare function generateLikeC4(input: schemas.likec4data.Input, params?: Params
|
|
|
277134
276990
|
*
|
|
277135
276991
|
* @example
|
|
277136
276992
|
* ```ts
|
|
277137
|
-
*
|
|
276993
|
+
* printOperation(ops.model(), {
|
|
277138
276994
|
* elements: [
|
|
277139
276995
|
* {
|
|
277140
276996
|
* id: 'cloud',
|
|
@@ -277160,10 +277016,12 @@ declare function generateLikeC4(input: schemas.likec4data.Input, params?: Params
|
|
|
277160
277016
|
* // }
|
|
277161
277017
|
* ```
|
|
277162
277018
|
*/
|
|
277163
|
-
declare function
|
|
277019
|
+
declare function printOperation<Operation extends AnyOp>(operation: Operation): string;
|
|
277020
|
+
declare function printOperation<Operation extends AnyOp>(operation: Operation, data: ctxOf<Operation>, params?: Params): string;
|
|
277164
277021
|
/**
|
|
277165
|
-
* Same as {@link
|
|
277022
|
+
* Same as {@link printOperation} but uses tab indentation
|
|
277166
277023
|
*/
|
|
277167
|
-
declare function
|
|
277024
|
+
declare function printWithTabIndent<Operation extends AnyOp>(operation: Operation): string;
|
|
277025
|
+
declare function printWithTabIndent<Operation extends AnyOp>(operation: Operation, data: ctxOf<Operation>): string;
|
|
277168
277026
|
//#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
|
|
277027
|
+
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.58.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
6
6
|
"homepage": "https://likec4.dev",
|
|
@@ -47,25 +47,25 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"langium": "3.5.0",
|
|
49
49
|
"pako": "^2.1.0",
|
|
50
|
-
"remeda": "^2.
|
|
51
|
-
"immer": "^11.1.
|
|
50
|
+
"remeda": "^2.37.0",
|
|
51
|
+
"immer": "^11.1.8",
|
|
52
52
|
"json5": "^2.2.3",
|
|
53
53
|
"type-fest": "^4.41.0",
|
|
54
54
|
"indent-string": "^5.0.0",
|
|
55
55
|
"strip-indent": "^4.1.1",
|
|
56
|
-
"zod": "^4.3
|
|
57
|
-
"@likec4/
|
|
58
|
-
"@likec4/
|
|
59
|
-
"@likec4/
|
|
56
|
+
"zod": "^4.4.3",
|
|
57
|
+
"@likec4/config": "1.58.0",
|
|
58
|
+
"@likec4/log": "1.58.0",
|
|
59
|
+
"@likec4/core": "1.58.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
|
-
"typescript": "
|
|
64
|
+
"typescript": "6.0.3",
|
|
65
65
|
"obuild": "0.4.31",
|
|
66
|
-
"vitest": "4.1.
|
|
67
|
-
"@likec4/
|
|
68
|
-
"@likec4/
|
|
66
|
+
"vitest": "4.1.8",
|
|
67
|
+
"@likec4/tsconfig": "1.58.0",
|
|
68
|
+
"@likec4/devops": "1.58.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
|
/**
|
|
@@ -3,28 +3,39 @@ import {
|
|
|
3
3
|
compareNatural,
|
|
4
4
|
sortNaturalByFqn,
|
|
5
5
|
} from '@likec4/core/utils'
|
|
6
|
-
import { keys, map, pipe, values } from 'remeda'
|
|
6
|
+
import { filter, isEmptyish, isTruthy, keys, map, pipe, sort, unique, values } from 'remeda'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Converts an array of strings or a record keys to a TypeScript union type string
|
|
10
|
+
* Handles empty arrays/records by returning 'never'
|
|
11
|
+
*/
|
|
12
|
+
function toUnion(elements: string[] | Record<string, unknown> | undefined) {
|
|
13
|
+
if (isEmptyish(elements)) {
|
|
10
14
|
return 'never'
|
|
11
15
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
if (typeof elements === 'object' && !Array.isArray(elements)) {
|
|
17
|
+
elements = keys(elements)
|
|
18
|
+
}
|
|
19
|
+
let union = pipe(
|
|
20
|
+
elements,
|
|
21
|
+
unique(),
|
|
22
|
+
sort(compareNatural),
|
|
23
|
+
map(v => ` | ${JSON.stringify(v)}`),
|
|
24
|
+
)
|
|
15
25
|
return union.join('\n').trimStart()
|
|
16
26
|
}
|
|
17
27
|
|
|
18
|
-
function elementIdToUnion(
|
|
19
|
-
const elements = values(_elements)
|
|
20
|
-
if (elements.length === 0) {
|
|
21
|
-
return 'never'
|
|
22
|
-
}
|
|
28
|
+
function elementIdToUnion(elements: Record<string, { id: string }>) {
|
|
23
29
|
let union = pipe(
|
|
24
30
|
elements,
|
|
31
|
+
values(),
|
|
32
|
+
filter(i => !!i && isTruthy(i.id)),
|
|
25
33
|
sortNaturalByFqn,
|
|
26
34
|
map(v => ` | ${JSON.stringify(v.id)}`),
|
|
27
35
|
)
|
|
36
|
+
if (union.length === 0) {
|
|
37
|
+
return 'never'
|
|
38
|
+
}
|
|
28
39
|
return union.join('\n').trimStart()
|
|
29
40
|
}
|
|
30
41
|
|
|
@@ -35,15 +46,15 @@ import type { Aux, SpecAux } from '${useCorePackage ? '@likec4/core/types' : 'li
|
|
|
35
46
|
|
|
36
47
|
export type $Specs = SpecAux<
|
|
37
48
|
// Element kinds
|
|
38
|
-
${toUnion(
|
|
49
|
+
${toUnion(model.specification.elements)},
|
|
39
50
|
// Deployment kinds
|
|
40
|
-
${toUnion(
|
|
51
|
+
${toUnion(model.specification.deployments)},
|
|
41
52
|
// Relationship kinds
|
|
42
|
-
${toUnion(
|
|
53
|
+
${toUnion(model.specification.relationships)},
|
|
43
54
|
// Tags
|
|
44
|
-
${toUnion(
|
|
55
|
+
${toUnion(model.specification.tags)},
|
|
45
56
|
// Metadata keys
|
|
46
|
-
${toUnion(model.specification.metadataKeys
|
|
57
|
+
${toUnion(model.specification.metadataKeys)}
|
|
47
58
|
>
|
|
48
59
|
|
|
49
60
|
export type $Aux = Aux<
|
|
@@ -53,7 +64,7 @@ export type $Aux = Aux<
|
|
|
53
64
|
// Deployments
|
|
54
65
|
${elementIdToUnion(model.$data.deployments.elements)},
|
|
55
66
|
// Views
|
|
56
|
-
${toUnion(
|
|
67
|
+
${toUnion(model.$data.views)},
|
|
57
68
|
// Project ID
|
|
58
69
|
${JSON.stringify(model.projectId)},
|
|
59
70
|
$Specs
|