@likec4/core 1.41.0 → 1.42.1
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/builder/package.json +4 -0
- package/compute-view/package.json +4 -0
- package/compute-view/relationships/package.json +4 -0
- package/dist/builder/index.d.mts +13 -11
- package/dist/builder/index.mjs +111 -91
- package/dist/compute-view/index.d.mts +8 -7
- package/dist/compute-view/index.mjs +14 -11
- package/dist/compute-view/relationships-view/index.d.mts +9 -8
- package/dist/compute-view/relationships-view/index.mjs +6 -6
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +11 -11
- package/dist/model/connection/deployment/index.d.mts +11 -10
- package/dist/model/connection/deployment/index.mjs +2 -2
- package/dist/model/connection/index.d.mts +12 -11
- package/dist/model/connection/index.mjs +3 -3
- package/dist/model/connection/model/index.d.mts +11 -10
- package/dist/model/connection/model/index.mjs +2 -2
- package/dist/model/index.d.mts +14 -14
- package/dist/model/index.mjs +4 -5
- package/dist/shared/{core.Ae86Y3tB.mjs → core.01VTr9qu.mjs} +8 -26
- package/dist/shared/core.1vX5a9AY.mjs +86 -0
- package/dist/shared/{core.BVNaR17u.mjs → core.B7KhhkRY.mjs} +1 -1
- package/dist/shared/core.B85MJLTf.mjs +5 -0
- package/dist/shared/{core.DA5vzwZ9.mjs → core.BIqHjQiH.mjs} +56 -42
- package/dist/shared/core.BKlholso.mjs +3 -0
- package/dist/shared/core.BR4zXDH-.mjs +13 -0
- package/dist/shared/{core.CXy1NLUG.mjs → core.BYNkXQ8A.mjs} +21 -12
- package/dist/shared/{core.BuoXfSMj.mjs → core.BbE4y-yl.mjs} +1 -1
- package/dist/shared/core.BoYfZOBm.mjs +3 -0
- package/dist/shared/core.BsSXS-_R.mjs +7 -0
- package/dist/shared/{core.DJp8fgok.mjs → core.BzTakU3I.mjs} +14 -10
- package/dist/shared/{core.4u1dVmfX.mjs → core.C2TiyjI6.mjs} +2 -2
- package/dist/shared/{core.DLpidoWc.mjs → core.C3JowhaZ.mjs} +3 -3
- package/dist/shared/{core.CNGyqkJh.mjs → core.C4x8aaWa.mjs} +3 -1
- package/dist/shared/{core.BB6zA-UU.mjs → core.C8YY6Uub.mjs} +38 -9
- package/dist/shared/{core.Asc11Mjy.mjs → core.C8sl5Y8Z.mjs} +122 -58
- package/dist/shared/{core.BvMRMo7Z.mjs → core.CNgZvKb8.mjs} +3 -5198
- package/dist/shared/{core.CUG6vpyL.d.mts → core.CQngdcuj.d.mts} +85 -4
- package/dist/shared/{core.Be1n9a0i.mjs → core.C_Ni6yHl.mjs} +5 -4
- package/dist/shared/core.CbT8JVYL.mjs +5 -0
- package/dist/shared/core.CqAJJpK_.mjs +3 -0
- package/dist/shared/{core.BXsxn-hf.d.mts → core.D0PjZzIS.d.mts} +27 -15
- package/dist/shared/{core.DgesAwC8.d.mts → core.D5fzJWbF.d.mts} +2 -2
- package/dist/shared/{core.hfOE3RfK.d.mts → core.DACpKp35.d.mts} +5 -5
- package/dist/shared/core.DFi2dOTl.mjs +39548 -0
- package/dist/shared/{core.xSQO0XYD.d.mts → core.DIol3syK.d.mts} +2 -2
- package/dist/shared/{core.DlG1xWt2.mjs → core.DMMOWQqc.mjs} +3 -2
- package/dist/shared/core.DNbUPnve.mjs +3990 -0
- package/dist/shared/{core.CCD1ID81.mjs → core.DRJma0Ol.mjs} +4 -3
- package/dist/shared/{core.DgttqsJc.mjs → core.DRhg-gVU.mjs} +9 -9
- package/dist/shared/core.DSO_rTC2.mjs +5322 -0
- package/dist/shared/{core.FUPplpae.d.mts → core.D_vkffV4.d.mts} +4 -2
- package/dist/shared/core.DdMJk7nx.d.mts +476 -0
- package/dist/shared/{core.BhpgpOep.d.mts → core.Dgs6-nuz.d.mts} +2 -2
- package/dist/shared/{core.Be4Jy9Qx.mjs → core.FZ305VYd.mjs} +2 -2
- package/dist/shared/core.OHD4KXm9.mjs +5 -0
- package/dist/shared/{core.GTgsmXS_.mjs → core.QJD_fcrc.mjs} +2 -2
- package/dist/shared/core.RfnaEmgA.mjs +7 -0
- package/dist/shared/core.fHR_8Tnq.d.mts +450 -0
- package/dist/shared/{core.D0EgVMQK.mjs → core.lRvxPoao.mjs} +14 -12
- package/dist/shared/{core.CaT0SUUK.mjs → core.rCeaAqgW.mjs} +1 -84
- package/dist/shared/{core.zxTBF_PD.d.mts → core.s9uwOt60.d.mts} +4 -4
- package/dist/shared/core.yna0OdV5.d.mts +98 -0
- package/dist/styles/index.d.mts +106 -0
- package/dist/styles/index.mjs +1 -0
- package/dist/types/_aux.d.mts +2 -2
- package/dist/types/expression-model.d.mts +3 -4
- package/dist/types/expression.d.mts +3 -4
- package/dist/types/fqnRef.d.mts +2 -2
- package/dist/types/fqnRef.mjs +3 -3
- package/dist/types/index.d.mts +8 -8
- package/dist/types/index.mjs +150 -5
- package/dist/types/scalar.mjs +3 -2
- package/dist/utils/graphology/index.d.mts +1864 -0
- package/dist/utils/graphology/index.mjs +1 -0
- package/dist/utils/index.d.mts +11 -6
- package/dist/utils/index.mjs +21 -37
- package/dist/utils/iterable/index.d.mts +1 -1
- package/dist/utils/iterable/index.mjs +45 -7
- package/model/package.json +4 -0
- package/package.json +42 -24
- package/styles/package.json +4 -0
- package/types/package.json +4 -0
- package/utils/graphology/package.json +4 -0
- package/utils/package.json +4 -0
- package/dist/shared/core.6_Vp2iiN.mjs +0 -172
- package/dist/shared/core.CUw_2J9j.mjs +0 -47
- package/dist/shared/core.CzdwsPmY.d.mts +0 -69
- package/dist/shared/core.D-ZGWDDt.d.mts +0 -831
- package/dist/shared/core.DoM6aM9N.mjs +0 -7
- package/dist/shared/core.ILwny7BV.mjs +0 -38
- package/dist/theme/index.d.mts +0 -11
- package/dist/theme/index.mjs +0 -232
- package/src/builder/Builder.deployment.ts +0 -224
- package/src/builder/Builder.deploymentModel.ts +0 -449
- package/src/builder/Builder.element.ts +0 -241
- package/src/builder/Builder.model.ts +0 -494
- package/src/builder/Builder.ts +0 -946
- package/src/builder/Builder.view-common.ts +0 -273
- package/src/builder/Builder.view-deployment.ts +0 -135
- package/src/builder/Builder.view-element.ts +0 -202
- package/src/builder/Builder.views.ts +0 -399
- package/src/builder/Builder.with.ts +0 -156
- package/src/builder/_types.ts +0 -324
- package/src/builder/index.ts +0 -11
- package/src/compute-view/compute-view.ts +0 -80
- package/src/compute-view/deployment-view/_types.ts +0 -38
- package/src/compute-view/deployment-view/clean-connections.ts +0 -236
- package/src/compute-view/deployment-view/compute.ts +0 -94
- package/src/compute-view/deployment-view/memory/index.ts +0 -9
- package/src/compute-view/deployment-view/memory/memory.ts +0 -96
- package/src/compute-view/deployment-view/predicates/deploymentRefs-where.ts +0 -18
- package/src/compute-view/deployment-view/predicates/deploymentRefs.ts +0 -154
- package/src/compute-view/deployment-view/predicates/index.ts +0 -8
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +0 -243
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +0 -70
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +0 -101
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +0 -95
- package/src/compute-view/deployment-view/predicates/relation-where.ts +0 -18
- package/src/compute-view/deployment-view/predicates/utils.ts +0 -282
- package/src/compute-view/deployment-view/predicates/wildcard.ts +0 -41
- package/src/compute-view/deployment-view/stages/stage-exclude.ts +0 -5
- package/src/compute-view/deployment-view/stages/stage-final.ts +0 -245
- package/src/compute-view/deployment-view/stages/stage-include.ts +0 -95
- package/src/compute-view/deployment-view/utils.ts +0 -297
- package/src/compute-view/dynamic-view/compute.ts +0 -312
- package/src/compute-view/element-view/_types.ts +0 -47
- package/src/compute-view/element-view/clean-connections.ts +0 -117
- package/src/compute-view/element-view/compute.ts +0 -324
- package/src/compute-view/element-view/memory/NodeGroup.ts +0 -31
- package/src/compute-view/element-view/memory/index.ts +0 -10
- package/src/compute-view/element-view/memory/memory.ts +0 -178
- package/src/compute-view/element-view/memory/stage-exclude.ts +0 -59
- package/src/compute-view/element-view/memory/stage-final.ts +0 -129
- package/src/compute-view/element-view/memory/stage-include.ts +0 -130
- package/src/compute-view/element-view/predicates/_utils.ts +0 -91
- package/src/compute-view/element-view/predicates/element-expand.ts +0 -29
- package/src/compute-view/element-view/predicates/element-kind-tag.ts +0 -27
- package/src/compute-view/element-view/predicates/element-ref.ts +0 -24
- package/src/compute-view/element-view/predicates/relation-direct.ts +0 -321
- package/src/compute-view/element-view/predicates/relation-in-out.ts +0 -64
- package/src/compute-view/element-view/predicates/relation-in.ts +0 -115
- package/src/compute-view/element-view/predicates/relation-out.ts +0 -119
- package/src/compute-view/element-view/predicates/wildcard.ts +0 -88
- package/src/compute-view/element-view/utils.ts +0 -65
- package/src/compute-view/index.ts +0 -4
- package/src/compute-view/memory/AbstractMemory.ts +0 -45
- package/src/compute-view/memory/AbstractStageExclude.ts +0 -215
- package/src/compute-view/memory/AbstractStageInclude.ts +0 -200
- package/src/compute-view/memory/_types.ts +0 -148
- package/src/compute-view/memory/index.ts +0 -5
- package/src/compute-view/memory/ops.ts +0 -43
- package/src/compute-view/relationships-view/_types.ts +0 -16
- package/src/compute-view/relationships-view/compute.ts +0 -159
- package/src/compute-view/relationships-view/index.ts +0 -3
- package/src/compute-view/relationships-view/layout.ts +0 -358
- package/src/compute-view/relationships-view/utils.ts +0 -73
- package/src/compute-view/utils/ancestorsOfNode.ts +0 -19
- package/src/compute-view/utils/applyCustomElementProperties.ts +0 -107
- package/src/compute-view/utils/applyCustomRelationProperties.ts +0 -58
- package/src/compute-view/utils/applyViewRuleStyles.ts +0 -73
- package/src/compute-view/utils/buildComputedNodes.ts +0 -166
- package/src/compute-view/utils/buildElementNotations.ts +0 -64
- package/src/compute-view/utils/elementExpressionToPredicate.ts +0 -50
- package/src/compute-view/utils/link-nodes-with-edges.ts +0 -56
- package/src/compute-view/utils/merge-props-from-relationships.ts +0 -161
- package/src/compute-view/utils/relationExpressionToPredicates.ts +0 -55
- package/src/compute-view/utils/resolve-extended-views.ts +0 -85
- package/src/compute-view/utils/resolve-global-rules.ts +0 -88
- package/src/compute-view/utils/topological-sort.ts +0 -256
- package/src/compute-view/utils/view-hash.ts +0 -45
- package/src/compute-view/utils/with-readable-edges.ts +0 -40
- package/src/index.ts +0 -32
- package/src/model/DeploymentElementModel.ts +0 -712
- package/src/model/DeploymentModel.ts +0 -393
- package/src/model/ElementModel.ts +0 -316
- package/src/model/LikeC4Model.ts +0 -882
- package/src/model/RelationModel.ts +0 -152
- package/src/model/connection/Connection.ts +0 -72
- package/src/model/connection/deployment/DeploymentConnectionModel.ts +0 -185
- package/src/model/connection/deployment/find.ts +0 -120
- package/src/model/connection/deployment/index.ts +0 -8
- package/src/model/connection/index.ts +0 -22
- package/src/model/connection/model/ConnectionModel.ts +0 -158
- package/src/model/connection/model/find.ts +0 -117
- package/src/model/connection/model/index.ts +0 -8
- package/src/model/connection/ops.ts +0 -276
- package/src/model/guards.ts +0 -77
- package/src/model/index.ts +0 -72
- package/src/model/types.ts +0 -67
- package/src/model/utils.ts +0 -66
- package/src/model/view/EdgeModel.ts +0 -121
- package/src/model/view/LikeC4ViewModel.ts +0 -361
- package/src/model/view/LikeC4ViewsFolder.ts +0 -151
- package/src/model/view/NodeModel.ts +0 -247
- package/src/theme/element.ts +0 -61
- package/src/theme/index.ts +0 -127
- package/src/theme/relationships.ts +0 -54
- package/src/types/RichText.ts +0 -205
- package/src/types/_aux.ts +0 -317
- package/src/types/_common.ts +0 -102
- package/src/types/const.ts +0 -34
- package/src/types/expression-model.ts +0 -294
- package/src/types/expression.ts +0 -313
- package/src/types/fqnRef.ts +0 -91
- package/src/types/geometry.ts +0 -159
- package/src/types/global.ts +0 -21
- package/src/types/index.ts +0 -44
- package/src/types/model-data.ts +0 -77
- package/src/types/model-deployment.ts +0 -78
- package/src/types/model-dump.ts +0 -79
- package/src/types/model-logical.ts +0 -126
- package/src/types/model-spec.ts +0 -88
- package/src/types/operators.ts +0 -156
- package/src/types/project.ts +0 -14
- package/src/types/scalar.ts +0 -162
- package/src/types/styles.ts +0 -122
- package/src/types/view-changes.ts +0 -32
- package/src/types/view-common.ts +0 -157
- package/src/types/view-computed.ts +0 -126
- package/src/types/view-layouted.ts +0 -94
- package/src/types/view-parsed.deployment.ts +0 -39
- package/src/types/view-parsed.dynamic.ts +0 -89
- package/src/types/view-parsed.element.ts +0 -65
- package/src/types/view.ts +0 -113
- package/src/utils/common-head.ts +0 -22
- package/src/utils/compare-natural.ts +0 -60
- package/src/utils/const.ts +0 -1
- package/src/utils/fqn.ts +0 -302
- package/src/utils/getOrCreate.ts +0 -8
- package/src/utils/guards.ts +0 -9
- package/src/utils/index.ts +0 -68
- package/src/utils/invariant.ts +0 -29
- package/src/utils/iterable/_types.ts +0 -5
- package/src/utils/iterable/filter.ts +0 -55
- package/src/utils/iterable/find.ts +0 -38
- package/src/utils/iterable/first.ts +0 -48
- package/src/utils/iterable/flat.ts +0 -17
- package/src/utils/iterable/head.ts +0 -22
- package/src/utils/iterable/index.ts +0 -15
- package/src/utils/iterable/map.ts +0 -40
- package/src/utils/iterable/reduce.ts +0 -24
- package/src/utils/iterable/some.ts +0 -36
- package/src/utils/iterable/to.ts +0 -19
- package/src/utils/iterable/unique.ts +0 -23
- package/src/utils/markdown/index.ts +0 -2
- package/src/utils/markdown/to-html.ts +0 -32
- package/src/utils/markdown/to-text.ts +0 -14
- package/src/utils/memoize-prop.ts +0 -30
- package/src/utils/mnemonist.ts +0 -9
- package/src/utils/object-hash.ts +0 -14
- package/src/utils/promises.ts +0 -24
- package/src/utils/relations.ts +0 -36
- package/src/utils/set.ts +0 -83
- package/src/utils/string-hash.ts +0 -16
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { isFunction } from 'remeda'
|
|
2
|
-
import { invariant } from '../../utils/invariant'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Checks if at least one element in the iterable satisfies the predicate.
|
|
6
|
-
* Composable first version of `some`.
|
|
7
|
-
* @signature
|
|
8
|
-
* isome(predicate)(data)
|
|
9
|
-
*/
|
|
10
|
-
export function isome<T>(predicate: (item: T) => boolean): (iterable: Iterable<T>) => boolean
|
|
11
|
-
/**
|
|
12
|
-
* Checks if at least one element in the iterable satisfies the predicate.
|
|
13
|
-
* Data first version of `some`.
|
|
14
|
-
* @signature
|
|
15
|
-
* isome(data, predicate)
|
|
16
|
-
*/
|
|
17
|
-
export function isome<T>(iterable: Iterable<T>, predicate: (item: T) => boolean): boolean
|
|
18
|
-
|
|
19
|
-
export function isome<T>(arg1: unknown, arg2?: unknown): boolean | ((iterable: Iterable<T>) => boolean) {
|
|
20
|
-
const pred = (arg2 ?? arg1) as (v: any) => boolean
|
|
21
|
-
invariant(isFunction(pred))
|
|
22
|
-
|
|
23
|
-
function _some(iter: Iterable<unknown>): boolean {
|
|
24
|
-
for (const value of iter) {
|
|
25
|
-
if (pred(value)) {
|
|
26
|
-
return true
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return false
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!arg2) {
|
|
33
|
-
return _some
|
|
34
|
-
}
|
|
35
|
-
return _some(arg1 as Iterable<unknown>)
|
|
36
|
-
}
|
package/src/utils/iterable/to.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export function toArray(): <T>(iterable: Iterable<T> | ArrayLike<T>) => T[]
|
|
2
|
-
export function toArray<T>(iterable: Iterable<T> | ArrayLike<T>): T[]
|
|
3
|
-
export function toArray<T>(
|
|
4
|
-
iterable?: Iterable<T> | ArrayLike<T>
|
|
5
|
-
): T[] | (<T>(iterable: Iterable<T> | ArrayLike<T>) => T[]) {
|
|
6
|
-
if (iterable) {
|
|
7
|
-
return Array.from(iterable)
|
|
8
|
-
}
|
|
9
|
-
return (it) => Array.from(it)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function toSet(): <T>(iterable: Iterable<T>) => Set<T>
|
|
13
|
-
export function toSet<T>(iterable: Iterable<T>): Set<T>
|
|
14
|
-
export function toSet<T>(iterable?: Iterable<T>): Set<T> | ((iterable: Iterable<T>) => Set<T>) {
|
|
15
|
-
if (iterable) {
|
|
16
|
-
return new Set(iterable)
|
|
17
|
-
}
|
|
18
|
-
return (it) => new Set(it)
|
|
19
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { IteratorLike } from '../../types'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns an iterable that yields only unique values.
|
|
5
|
-
* It uses a Set to keep track of the values.
|
|
6
|
-
*/
|
|
7
|
-
export function iunique(): <T>(iterable: Iterable<T>) => IteratorLike<T>
|
|
8
|
-
export function iunique<T>(iterable: Iterable<T>): IteratorLike<T>
|
|
9
|
-
|
|
10
|
-
export function iunique<T>(iterable?: Iterable<T>): IteratorLike<T> | ((iterable: Iterable<T>) => IteratorLike<T>) {
|
|
11
|
-
return iterable ? _iunique(iterable) : _iunique
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function* _iunique<T>(iterable: Iterable<T>): IteratorLike<T> {
|
|
15
|
-
const seen = new Set<T>()
|
|
16
|
-
for (const item of iterable) {
|
|
17
|
-
if (!seen.has(item)) {
|
|
18
|
-
seen.add(item)
|
|
19
|
-
yield item
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return
|
|
23
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import rehypeRaw from 'rehype-raw'
|
|
2
|
-
import rehypeSanitize from 'rehype-sanitize'
|
|
3
|
-
import rehypeStringify from 'rehype-stringify'
|
|
4
|
-
import remarkGfm from 'remark-gfm'
|
|
5
|
-
import remarkParse from 'remark-parse'
|
|
6
|
-
import remarkRehype from 'remark-rehype'
|
|
7
|
-
import { unified } from 'unified'
|
|
8
|
-
|
|
9
|
-
// let _remark
|
|
10
|
-
function remark() {
|
|
11
|
-
return unified()
|
|
12
|
-
.use(remarkParse)
|
|
13
|
-
.use(remarkGfm)
|
|
14
|
-
.use(remarkRehype, {
|
|
15
|
-
// Tight paragraphs prevent extra newlines
|
|
16
|
-
allowDangerousHtml: true,
|
|
17
|
-
clobberPrefix: '',
|
|
18
|
-
tableCellPadding: false,
|
|
19
|
-
tight: true,
|
|
20
|
-
})
|
|
21
|
-
.use(rehypeRaw)
|
|
22
|
-
.use(rehypeSanitize)
|
|
23
|
-
.use(rehypeStringify, {
|
|
24
|
-
// Prevent extra closing newlines
|
|
25
|
-
closeSelfClosing: true,
|
|
26
|
-
tightSelfClosing: true,
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function markdownToHtml(markdown: string): string {
|
|
31
|
-
return String(remark().processSync(markdown.trim())).trim()
|
|
32
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { fromMarkdown } from 'mdast-util-from-markdown'
|
|
2
|
-
import { toString } from 'mdast-util-to-string'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Converts markdown to plain text, removing any markdown formatting.
|
|
6
|
-
* @param markdown - The markdown to convert.
|
|
7
|
-
* @returns The plain text.
|
|
8
|
-
*/
|
|
9
|
-
export function markdownToText(markdown: string): string {
|
|
10
|
-
return toString(fromMarkdown(markdown), {
|
|
11
|
-
includeHtml: false,
|
|
12
|
-
includeImageAlt: false,
|
|
13
|
-
})
|
|
14
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Saves the value returned by fn() in a hidden property tag of obj object, so next time memoizeProp() is called,
|
|
3
|
-
* that value will be returned, and fn won't be called.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* class Model {
|
|
8
|
-
* // using same Symbol
|
|
9
|
-
* get computed1() {
|
|
10
|
-
* return memoizeProp(this, Symbol.for('computed1'), () => doOnce())
|
|
11
|
-
* }
|
|
12
|
-
* // using string
|
|
13
|
-
* get computed2() {
|
|
14
|
-
* return memoizeProp(this, 'computed2', () => doOnce())
|
|
15
|
-
* }
|
|
16
|
-
*
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export function memoizeProp<Tag extends symbol | string, Res>(obj: object, tag: Tag, fn: () => Res): Res {
|
|
21
|
-
const tagSymbol = typeof tag === 'symbol' ? tag : Symbol.for(tag)
|
|
22
|
-
if (!obj.hasOwnProperty(tagSymbol)) {
|
|
23
|
-
Object.defineProperty(obj, tagSymbol, {
|
|
24
|
-
enumerable: false,
|
|
25
|
-
writable: false,
|
|
26
|
-
value: fn(),
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
return (obj as any)[tagSymbol]!
|
|
30
|
-
}
|
package/src/utils/mnemonist.ts
DELETED
package/src/utils/object-hash.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import objecthash from 'object-hash'
|
|
2
|
-
import { isNonNullish } from 'remeda'
|
|
3
|
-
import { invariant } from '../utils/invariant'
|
|
4
|
-
|
|
5
|
-
export function objectHash(value: any): string {
|
|
6
|
-
invariant(
|
|
7
|
-
typeof value === 'object' && isNonNullish(value),
|
|
8
|
-
'objectHash: value must be an object',
|
|
9
|
-
)
|
|
10
|
-
return objecthash(value, {
|
|
11
|
-
ignoreUnknown: true,
|
|
12
|
-
respectType: false,
|
|
13
|
-
})
|
|
14
|
-
}
|
package/src/utils/promises.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { randomInteger } from 'remeda'
|
|
2
|
-
|
|
3
|
-
const DELAY = 'LIKEC4_DELAY'
|
|
4
|
-
|
|
5
|
-
export function delay(): Promise<string>
|
|
6
|
-
export function delay(ms: number): Promise<string>
|
|
7
|
-
export function delay(randomFrom: number, randomTo: number): Promise<string>
|
|
8
|
-
export function delay(...args: number[]): Promise<string> {
|
|
9
|
-
let ms = 100
|
|
10
|
-
if (args.length === 2) {
|
|
11
|
-
ms = randomInteger(args[0]!, args[1]!)
|
|
12
|
-
} else if (args.length === 1) {
|
|
13
|
-
ms = args[0]!
|
|
14
|
-
}
|
|
15
|
-
return new Promise(resolve => {
|
|
16
|
-
setTimeout(() => {
|
|
17
|
-
resolve(DELAY)
|
|
18
|
-
}, ms ?? 100)
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function promiseNextTick(): Promise<void> {
|
|
23
|
-
return Promise.resolve().then(() => void 0)
|
|
24
|
-
}
|
package/src/utils/relations.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { commonAncestor, compareFqnHierarchically } from './fqn'
|
|
2
|
-
|
|
3
|
-
export type RelationshipLike = {
|
|
4
|
-
source: {
|
|
5
|
-
model: string
|
|
6
|
-
}
|
|
7
|
-
target: {
|
|
8
|
-
model: string
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type RelationPredicate = (rel: RelationshipLike) => boolean
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Compares two relations hierarchically.
|
|
16
|
-
* From the most general (implicit) to the most specific.
|
|
17
|
-
*/
|
|
18
|
-
export const compareRelations = <T extends RelationshipLike>(a: T, b: T): number => {
|
|
19
|
-
const parentA = commonAncestor(a.source.model, a.target.model)
|
|
20
|
-
const parentB = commonAncestor(b.source.model, b.target.model)
|
|
21
|
-
if (parentA && !parentB) {
|
|
22
|
-
return 1
|
|
23
|
-
}
|
|
24
|
-
if (!parentA && parentB) {
|
|
25
|
-
return -1
|
|
26
|
-
}
|
|
27
|
-
const compareParents = parentA && parentB ? compareFqnHierarchically(parentA, parentB) : 0
|
|
28
|
-
if (compareParents !== 0) {
|
|
29
|
-
return compareParents
|
|
30
|
-
}
|
|
31
|
-
const compareSource = compareFqnHierarchically(a.source.model, b.source.model)
|
|
32
|
-
if (compareSource !== 0) {
|
|
33
|
-
return compareSource
|
|
34
|
-
}
|
|
35
|
-
return compareFqnHierarchically(a.target.model, b.target.model)
|
|
36
|
-
}
|
package/src/utils/set.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
intersection as _intersection,
|
|
3
|
-
symmetricDifference as _symmetricDifference,
|
|
4
|
-
} from 'mnemonist/patch'
|
|
5
|
-
|
|
6
|
-
import { hasAtLeast } from 'remeda'
|
|
7
|
-
import type { NonEmptyArray } from '../types/_common'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Returns new set as a union of given sets
|
|
11
|
-
* Keeps order of elements
|
|
12
|
-
*/
|
|
13
|
-
export function union<T>(...sets: ReadonlySet<T>[]): Set<T> {
|
|
14
|
-
let result = new Set<T>()
|
|
15
|
-
for (const set of sets) {
|
|
16
|
-
for (const value of set) {
|
|
17
|
-
result.add(value)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return result
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Returns new set as an intersection of all sets
|
|
25
|
-
* Keeps order from the first set
|
|
26
|
-
*/
|
|
27
|
-
export function intersection<T>(first: ReadonlySet<T>, ...sets: NonEmptyArray<ReadonlySet<NoInfer<T>>>): Set<T> {
|
|
28
|
-
let result = new Set<T>()
|
|
29
|
-
// If first set is empty, return empty set
|
|
30
|
-
if (first.size === 0) {
|
|
31
|
-
return result
|
|
32
|
-
}
|
|
33
|
-
let other = hasAtLeast(sets, 2) ? _intersection(...sets) : sets[0]
|
|
34
|
-
if (other.size === 0) {
|
|
35
|
-
return result
|
|
36
|
-
}
|
|
37
|
-
for (const value of first) {
|
|
38
|
-
if (other.has(value)) {
|
|
39
|
-
result.add(value)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return result
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function difference<T>(a: ReadonlySet<T>, b: ReadonlySet<NoInfer<T>>): Set<T> {
|
|
46
|
-
if (a.size === 0) {
|
|
47
|
-
return new Set<T>()
|
|
48
|
-
}
|
|
49
|
-
if (b.size === 0) {
|
|
50
|
-
return new Set(a)
|
|
51
|
-
}
|
|
52
|
-
let result = new Set<T>()
|
|
53
|
-
for (const value of a) {
|
|
54
|
-
if (!b.has(value)) {
|
|
55
|
-
result.add(value)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return result
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function equals<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): boolean {
|
|
62
|
-
return a.size === b.size && [...a].every(value => b.has(value))
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function symmetricDifference<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): Set<T> {
|
|
66
|
-
return _symmetricDifference(a as Set<T>, b as Set<T>)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function hasIntersection<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): boolean {
|
|
70
|
-
if (a.size === 0 || b.size === 0) {
|
|
71
|
-
return false
|
|
72
|
-
}
|
|
73
|
-
// Swap sets to iterate over smaller set
|
|
74
|
-
if (b.size < a.size) {
|
|
75
|
-
;[a, b] = [b, a]
|
|
76
|
-
}
|
|
77
|
-
for (const value of a) {
|
|
78
|
-
if (b.has(value)) {
|
|
79
|
-
return true
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return false
|
|
83
|
-
}
|
package/src/utils/string-hash.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { invariant } from '../utils/invariant'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @see https://gist.github.com/victor-homyakov/bcb7d7911e4a388b1c810f8c3ce17bcf
|
|
5
|
-
*/
|
|
6
|
-
export function stringHash(str: string): string {
|
|
7
|
-
let hash = 5381
|
|
8
|
-
const len = str.length
|
|
9
|
-
invariant(len > 0, 'stringHash: empty string')
|
|
10
|
-
|
|
11
|
-
for (let i = 0; i < len; i++) {
|
|
12
|
-
hash = (hash * 33) ^ str.charCodeAt(i)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return (hash >>> 0).toString(36)
|
|
16
|
-
}
|