-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add d2 language support Co-authored-by: Colin Seymour <colin@github.com>
- Loading branch information
Showing
8 changed files
with
256 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
direction: down | ||
|
||
classes: { | ||
containers: { | ||
shape: rectangle | ||
} | ||
} | ||
|
||
user: "User" { | ||
shape: person | ||
} | ||
|
||
database: "SQLite3" { | ||
shape: cylinder | ||
} | ||
|
||
a { | ||
label: null | ||
style.fill: transparent | ||
style.stroke: transparent | ||
} | ||
|
||
b { | ||
label: null | ||
style.fill: transparent | ||
style.stroke: transparent | ||
} | ||
|
||
b.display: "Display (Monitor or TV)" { | ||
style.3d: true | ||
} | ||
|
||
anthias-nginx.class: containers | ||
b.anthias-viewer.class: containers | ||
a.anthias-server.class: containers | ||
a.anthias-websocket.class: containers | ||
a.anthias-celery.class: containers | ||
a.redis.class: containers | ||
|
||
user -> anthias-nginx | ||
anthias-nginx <-> a.anthias-server | ||
anthias-nginx -> a.anthias-websocket | ||
|
||
a.anthias-server <-> a.anthias-celery | ||
a.anthias-websocket <-> a.anthias-server | ||
a.anthias-celery -> a.redis: "in-memory data" | ||
a.redis <-> a.anthias-server | ||
|
||
b.anthias-viewer <-> database: "assets data" | ||
|
||
a.anthias-server <-> b.anthias-viewer: "assets data" | ||
a.anthias-server <-> database | ||
a.anthias-celery <-> database | ||
|
||
b.anthias-viewer -> b.display: "current asset" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
|
||
cTrnDao: CalcTrnDao { | ||
q: Query { | ||
ByTime | ||
ByCategory | ||
ByAccount | ||
ByPurpose | ||
} | ||
sql: "SQL: O(trns.count) time | O(trns.notDel.count) space" { | ||
"SELECT amount, currency, type FROM transactions WHERE ..." | ||
} | ||
trns: "List<CalcTrn>" { | ||
CalcTrn { | ||
shape: class | ||
|
||
amount: Double | ||
currency: String | ||
type: TransactionType | ||
} | ||
} | ||
|
||
q -> sql -> trns | ||
} | ||
|
||
rawStatsFlow: RawStatsFlow { | ||
in: Input { | ||
shape: class | ||
trns: List<CalcTrn> | ||
} | ||
|
||
p: "Process: O(trns.count) time | O(currs.unique.count) space" { | ||
"trns.forEach { aggregate incomes, expense by currencies + count them }" | ||
} | ||
|
||
out: RawStats { | ||
shape: class | ||
incomes: Map<CurrencyCode, Double> | ||
expenses: Map<CurrencyCode, Double> | ||
incomesCount: Int | ||
expensesCount: Int | ||
} | ||
|
||
in -> p -> out | ||
} | ||
|
||
cTrndao.trns -> rawStatsFlow.in.trns | ||
|
||
# RatesFlow | ||
ratesDao: RatesDao { | ||
sql: "SQL: O(rates.count) time | O(rates.baseCurr.count) space" { | ||
"SELECT rate, currency FROM exchange_rates WHERE baseCurrency = ?" | ||
} | ||
out: "List<Rate>" { | ||
Rate { | ||
shape: class | ||
rate: Double | ||
currency: String | ||
} | ||
} | ||
sql -> out | ||
} | ||
|
||
ratesOverrideDao: RateOverrideDao { | ||
sql: "SQL: O(rates.override.count) time | O(rates.override.baseCurr.count) space" { | ||
"SELECT rate, currency FROM exchange_rates_override WHERE baseCurrency = ? AND sync != $DELETING" | ||
} | ||
out: "List<Rate>" { | ||
Rate { | ||
shape: class | ||
rate: Double | ||
currency: String | ||
} | ||
} | ||
sql -> out | ||
} | ||
|
||
ratesFlow: RatesFlow { | ||
deps: Dependencies { | ||
ratesDao | ||
ratesOverrideDao | ||
baseCurrencyFlow | ||
} | ||
p: "Process: O(rates.override.count) time | O(1) space" { | ||
1: "baseCurrency.flatMapLatest {}" | ||
2: "combine(rateDao.findByBaseCurr(), ratesOverridedao.findByBaseCurr())" | ||
3: "Override rate with the manual set ones" | ||
|
||
1 -> 2 -> 3 | ||
|
||
} | ||
out: "RatesData" { | ||
shape: class | ||
baseCurrency: String | ||
rates: Map<CurrencyCode, Double> | ||
} | ||
|
||
deps.ratesDao -> p: Reacts | ||
deps.ratesOverrideDao -> p: Reacts | ||
deps.baseCurrencyFlow -> p: Reacts | ||
p -> out | ||
} | ||
|
||
ratesDao -> ratesFlow.deps | ||
ratesOverrideDao -> ratesFlow.deps | ||
|
||
|
||
# ExchangeStatsFlow | ||
exFlow: ExchangeStatsFlow { | ||
deps: Dependencies { | ||
ratesFlow: "rates: RatesFlow" | ||
} | ||
|
||
in: Input { | ||
shape: class | ||
rawStats: RawStats | ||
outputCurrency: String | ||
} | ||
|
||
p: "Process: O(curr.unique.count) space-time" { | ||
incs_loop: "rawStats.incomes.forEach {}" | ||
incs_exchange: "exchange to output currency" | ||
incs_sum: "sum & count" | ||
|
||
incs_loop -> incs_exchange -> incs_sum | ||
|
||
exps_loop: "rawStats.expenses.forEach {}" | ||
exps_exchange: "exchange to output currency" | ||
exps_sum: "sum & count" | ||
|
||
exps_loop -> exps_exchange -> exps_sum | ||
} | ||
|
||
out: Stats { | ||
shape: class | ||
income: Value | ||
expense: Value | ||
incomesCount: Int | ||
expensesCount: Int | ||
} | ||
|
||
deps.ratesFlow -> p: Reacts to rates changes | ||
in.rawStats -> p | ||
p.incs_sum -> out | ||
p.exps_sum -> out | ||
} | ||
|
||
ratesFlow.out -> exFlow.deps.ratesFlow: Reacts | ||
rawStatsFlow.out -> exFlow.in.rawStats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
name: d2-vscode | ||
version: 8f1fef4f732ffbf8a2cf70676c15bc9791c010a7 | ||
type: git_submodule | ||
homepage: https://github.com/terrastruct/d2-vscode.git | ||
license: bsd-3-clause | ||
licenses: | ||
- sources: LICENSE.txt | ||
text: | | ||
Copyright 2022 Terrastruct, Inc. | ||
Redistribution and use in source and binary forms, with or without modification, are | ||
permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, this list of | ||
conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, this list of | ||
conditions and the following disclaimer in the documentation and/or other materials | ||
provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its contributors may be used | ||
to endorse or promote products derived from this software without specific prior written | ||
permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | ||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
notices: [] |