derive-dashboards 0.1.0 → 0.2.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/README.md +8 -5
- package/dist/adapter/sql-adapter.mjs +4 -4
- package/dist/body.mjs +11 -1
- package/dist/cache.d.mts +1 -1
- package/dist/cli/add.mjs +130 -0
- package/dist/cli/check.mjs +14 -1
- package/dist/cli/cli.mjs +14 -12
- package/dist/cli/config.mjs +12 -1
- package/dist/cli/doctor.mjs +147 -0
- package/dist/cli/import/dbt-schema.mjs +2 -2
- package/dist/cli/import/index.mjs +2 -2
- package/dist/cli/init.mjs +3 -2
- package/dist/cli/json.mjs +21 -0
- package/dist/cli/layers.mjs +33 -0
- package/dist/core/conformance/cases.d.mts +3 -0
- package/dist/core/conformance/cases.mjs +20 -4
- package/dist/core/conformance/check.mjs +6 -3
- package/dist/core/conformance/drill-cases.mjs +120 -0
- package/dist/core/document/layout.mjs +1 -1
- package/dist/core/document/view-layout.d.mts +14 -0
- package/dist/core/document/view-layout.mjs +157 -0
- package/dist/core/document/view.d.mts +26 -7
- package/dist/core/document/view.mjs +42 -11
- package/dist/core/engine/filter.mjs +2 -2
- package/dist/core/engine/index.d.mts +14 -2
- package/dist/core/engine/index.mjs +12 -1
- package/dist/core/engine/leaf.mjs +9 -4
- package/dist/core/engine/members.mjs +2 -2
- package/dist/core/engine/postgres.mjs +1 -1
- package/dist/core/engine/record-layout.d.mts +11 -0
- package/dist/core/engine/record-layout.mjs +7 -7
- package/dist/core/engine/records.d.mts +3 -2
- package/dist/core/engine/records.mjs +2 -1
- package/dist/core/engine/segmented.mjs +5 -2
- package/dist/core/engine/sql-records.mjs +2 -1
- package/dist/core/engine/statement.mjs +37 -3
- package/dist/core/engine/types.d.mts +3 -0
- package/dist/core/engine/version.d.mts +1 -1
- package/dist/core/engine/version.mjs +1 -1
- package/dist/core/error/codes.d.mts +33 -1
- package/dist/core/error/codes.mjs +30 -2
- package/dist/core/index.d.mts +13 -7
- package/dist/core/index.mjs +9 -5
- package/dist/core/model/catalog/check.mjs +1 -1
- package/dist/core/model/hints.d.mts +36 -0
- package/dist/core/model/member.d.mts +4 -2
- package/dist/core/model/member.mjs +19 -3
- package/dist/core/model/types.d.mts +21 -19
- package/dist/core/model/validate/drill.mjs +70 -0
- package/dist/core/model/validate/index.mjs +3 -0
- package/dist/core/model/validate/members.mjs +7 -4
- package/dist/core/model/validate/shape.mjs +150 -0
- package/dist/core/model/validate/source.mjs +5 -3
- package/dist/core/policy/bind-query.d.mts +12 -0
- package/dist/core/policy/bind-query.mjs +53 -0
- package/dist/core/query/alias.mjs +7 -1
- package/dist/core/query/drill/compose.d.mts +22 -0
- package/dist/core/query/drill/compose.mjs +85 -0
- package/dist/core/query/drill/fields.d.mts +21 -0
- package/dist/core/query/drill/fields.mjs +91 -0
- package/dist/core/query/drill/internal.d.mts +11 -0
- package/dist/core/query/drill/items.d.mts +29 -0
- package/dist/core/query/drill/items.mjs +98 -0
- package/dist/core/query/drill/line.d.mts +31 -0
- package/dist/core/query/drill/line.mjs +183 -0
- package/dist/core/query/drill/links.d.mts +33 -0
- package/dist/core/query/drill/links.mjs +31 -0
- package/dist/core/query/drill/operand.mjs +7 -0
- package/dist/core/query/drill/scopes.d.mts +22 -0
- package/dist/core/query/drill/scopes.mjs +58 -0
- package/dist/core/query/drill/selection.d.mts +37 -0
- package/dist/core/query/drill/selection.mjs +144 -0
- package/dist/core/query/drill/steps.d.mts +14 -0
- package/dist/core/query/drill/steps.mjs +35 -0
- package/dist/core/query/drill/synthetic-expr.mjs +85 -0
- package/dist/core/query/drill/synthetic.d.mts +22 -0
- package/dist/core/query/drill/synthetic.mjs +165 -0
- package/dist/core/query/drill/time.d.mts +11 -0
- package/dist/core/query/drill/time.mjs +71 -0
- package/dist/core/query/drill/types.d.mts +155 -0
- package/dist/core/query/drill/types.mjs +4 -0
- package/dist/core/query/drill/views.d.mts +62 -0
- package/dist/core/query/drill/views.mjs +257 -0
- package/dist/core/query/filter.d.mts +6 -0
- package/dist/core/query/picks.d.mts +8 -2
- package/dist/core/query/picks.mjs +11 -4
- package/dist/core/query/segments.d.mts +12 -2
- package/dist/core/query/segments.mjs +5 -2
- package/dist/core/result/columns.mjs +20 -4
- package/dist/core/result/types.d.mts +5 -1
- package/dist/core/schema/aliases.d.mts +7 -0
- package/dist/core/schema/aliases.mjs +77 -0
- package/dist/core/schema/answer-parts.mjs +117 -0
- package/dist/core/schema/answers.d.mts +2109 -128
- package/dist/core/schema/answers.mjs +11 -113
- package/dist/core/schema/commands.d.mts +2 -2
- package/dist/core/schema/document.d.mts +1 -1
- package/dist/core/schema/drill-answers.mjs +179 -0
- package/dist/core/schema/drill.d.mts +260 -0
- package/dist/core/schema/drill.mjs +107 -0
- package/dist/core/schema/index.d.mts +6 -3
- package/dist/core/schema/index.mjs +6 -3
- package/dist/core/schema/picks.d.mts +35 -0
- package/dist/core/schema/picks.mjs +23 -0
- package/dist/core/schema/query.d.mts +82 -1
- package/dist/core/schema/query.mjs +9 -5
- package/dist/core/schema/tools.mjs +1 -1
- package/dist/core/schema/view.d.mts +0 -35
- package/dist/core/schema/view.mjs +19 -24
- package/dist/core/store/schema.d.mts +5 -0
- package/dist/core/store/schema.mjs +10 -0
- package/dist/core/types/api.d.mts +21 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/core/types/drill-api.d.mts +210 -0
- package/dist/core/types/options.d.mts +21 -0
- package/dist/core/types/viewer.d.mts +5 -0
- package/dist/cursor-seal.d.mts +8 -0
- package/dist/cursor-seal.mjs +98 -0
- package/dist/dashboard-id.mjs +1 -1
- package/dist/dashboards.mjs +4 -0
- package/dist/drill-access.mjs +93 -0
- package/dist/drill-change.mjs +76 -0
- package/dist/drill-crumbs.mjs +113 -0
- package/dist/drill-distinct.mjs +130 -0
- package/dist/drill-explain.mjs +64 -0
- package/dist/drill-identity.mjs +35 -0
- package/dist/drill-item-id.mjs +35 -0
- package/dist/drill-items.mjs +132 -0
- package/dist/drill-open.mjs +169 -0
- package/dist/drill-seal.mjs +170 -0
- package/dist/drill-secret.mjs +14 -0
- package/dist/drill-share.mjs +53 -0
- package/dist/drill-summary.mjs +158 -0
- package/dist/drill-targets.mjs +53 -0
- package/dist/drill-totals.mjs +8 -0
- package/dist/drill-views.mjs +175 -0
- package/dist/drill.mjs +157 -0
- package/dist/editing.mjs +3 -3
- package/dist/endpoints/dashboards.mjs +28 -5
- package/dist/endpoints/drill.mjs +55 -0
- package/dist/endpoints/index.d.mts +245 -4
- package/dist/endpoints/index.mjs +5 -1
- package/dist/endpoints/meta.mjs +10 -1
- package/dist/endpoints/query.mjs +26 -4
- package/dist/execute.d.mts +19 -1
- package/dist/execute.mjs +34 -27
- package/dist/handler.mjs +5 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +29 -2
- package/dist/llms.txt +22 -0
- package/dist/mcp/drill.mjs +61 -0
- package/dist/mcp/format.mjs +69 -11
- package/dist/mcp/index.d.mts +15 -4
- package/dist/mcp/index.mjs +13 -7
- package/dist/mcp/query.d.mts +7 -2
- package/dist/mcp/query.mjs +40 -6
- package/dist/node-postgres.d.mts +8 -4
- package/dist/node-postgres.mjs +29 -6
- package/dist/owner.mjs +3 -3
- package/dist/postgres-connection.d.mts +8 -2
- package/dist/postgres-connection.mjs +2 -1
- package/dist/postgres-store.mjs +1 -0
- package/dist/react/Canvas.mjs +28 -5
- package/dist/react/Cell.mjs +2 -1
- package/dist/react/Dashboard.d.mts +10 -5
- package/dist/react/Dashboard.mjs +62 -22
- package/dist/react/DashboardList.mjs +52 -24
- package/dist/react/DashboardListRow.mjs +49 -0
- package/dist/react/Discard.mjs +12 -4
- package/dist/react/Editing.mjs +19 -5
- package/dist/react/FilterBar.d.mts +7 -9
- package/dist/react/Grid.mjs +19 -24
- package/dist/react/Header.mjs +10 -1
- package/dist/react/History.mjs +5 -0
- package/dist/react/Parts.mjs +6 -2
- package/dist/react/ReadFailed.mjs +23 -0
- package/dist/react/ReviewPanel.mjs +13 -2
- package/dist/react/RowBody.d.mts +19 -0
- package/dist/react/RowBody.mjs +55 -0
- package/dist/react/Spaces.mjs +15 -1
- package/dist/react/Tile.d.mts +3 -1
- package/dist/react/Tile.mjs +84 -32
- package/dist/react/_virtual/_rolldown/runtime.mjs +12 -0
- package/dist/react/arrange-steps.mjs +16 -13
- package/dist/react/arrange.mjs +10 -3
- package/dist/react/builder/Calcs.mjs +35 -11
- package/dist/react/builder/FilterEditor.mjs +196 -0
- package/dist/react/builder/Filters.mjs +172 -116
- package/dist/react/builder/Formula.mjs +82 -0
- package/dist/react/builder/Groups.mjs +1 -0
- package/dist/react/builder/Preview.mjs +1 -1
- package/dist/react/builder/RangeEditor.mjs +184 -0
- package/dist/react/builder/Sections.mjs +41 -6
- package/dist/react/builder/Time.mjs +138 -60
- package/dist/react/builder/Values.mjs +85 -0
- package/dist/react/builder/WidgetBuilder.mjs +50 -49
- package/dist/react/builder/base.d.mts +5 -0
- package/dist/react/builder/base.mjs +33 -8
- package/dist/react/builder/calc.mjs +15 -1
- package/dist/react/builder/escape.d.mts +1 -0
- package/dist/react/builder/escape.mjs +62 -0
- package/dist/react/builder/filter-tree.d.mts +9 -0
- package/dist/react/builder/filter-tree.mjs +186 -0
- package/dist/react/builder/formula-parse.d.mts +18 -0
- package/dist/react/builder/formula-parse.mjs +136 -0
- package/dist/react/builder/labels.d.mts +1 -1
- package/dist/react/builder/state.d.mts +2 -1
- package/dist/react/builder/state.mjs +23 -37
- package/dist/react/builder/useBuilder.d.mts +12 -1
- package/dist/react/builder/useBuilder.mjs +6 -3
- package/dist/react/builder/words.d.mts +59 -0
- package/dist/react/builder/words.mjs +73 -0
- package/dist/react/client.d.mts +2 -0
- package/dist/react/client.mjs +1 -0
- package/dist/react/context.d.mts +28 -1
- package/dist/react/context.mjs +25 -4
- package/dist/react/drill/Bars.mjs +179 -0
- package/dist/react/drill/Controls.mjs +173 -0
- package/dist/react/drill/DashboardTile.d.mts +18 -0
- package/dist/react/drill/DashboardTile.mjs +107 -0
- package/dist/react/drill/DrillPanel.d.mts +31 -0
- package/dist/react/drill/DrillPanel.mjs +104 -0
- package/dist/react/drill/DrillTabs.mjs +52 -0
- package/dist/react/drill/Header.mjs +131 -0
- package/dist/react/drill/Items.d.mts +22 -0
- package/dist/react/drill/Items.mjs +164 -0
- package/dist/react/drill/ItemsFoot.mjs +60 -0
- package/dist/react/drill/Notes.mjs +58 -0
- package/dist/react/drill/PanelBody.mjs +74 -0
- package/dist/react/drill/PanelStates.mjs +37 -0
- package/dist/react/drill/board.d.mts +18 -0
- package/dist/react/drill/board.mjs +91 -0
- package/dist/react/drill/counts.mjs +14 -0
- package/dist/react/drill/host.mjs +26 -0
- package/dist/react/drill/item-parts.d.mts +5 -0
- package/dist/react/drill/item-parts.mjs +76 -0
- package/dist/react/drill/item-type.d.mts +26 -0
- package/dist/react/drill/item-type.mjs +7 -0
- package/dist/react/drill/lazy.d.mts +6 -0
- package/dist/react/drill/lazy.mjs +17 -0
- package/dist/react/drill/pages.mjs +48 -0
- package/dist/react/drill/panel-focus.mjs +51 -0
- package/dist/react/drill/props.d.mts +25 -0
- package/dist/react/drill/props.mjs +72 -0
- package/dist/react/drill/state.d.mts +18 -0
- package/dist/react/drill/state.mjs +68 -0
- package/dist/react/drill/useDrill.d.mts +46 -0
- package/dist/react/drill/useDrill.mjs +194 -0
- package/dist/react/drill/words.d.mts +101 -0
- package/dist/react/drill/words.mjs +79 -0
- package/dist/react/english.mjs +29 -6
- package/dist/react/filters/bar.d.mts +12 -0
- package/dist/react/filters/bar.mjs +135 -0
- package/dist/react/filters/calendar.mjs +193 -0
- package/dist/react/filters/chip.mjs +174 -0
- package/dist/react/filters/context.d.mts +22 -0
- package/dist/react/filters/context.mjs +78 -0
- package/dist/react/filters/dates.mjs +89 -0
- package/dist/react/filters/days.d.mts +36 -0
- package/dist/react/filters/days.mjs +87 -0
- package/dist/react/filters/field-step.mjs +81 -0
- package/dist/react/filters/hooks.d.mts +34 -0
- package/dist/react/filters/hooks.mjs +94 -0
- package/dist/react/filters/listbox.mjs +131 -0
- package/dist/react/filters/logic.d.mts +59 -0
- package/dist/react/filters/logic.mjs +109 -0
- package/dist/react/filters/menu-search.mjs +211 -0
- package/dist/react/filters/menu.mjs +85 -0
- package/dist/react/filters/number.mjs +127 -0
- package/dist/react/filters/numbers.d.mts +47 -0
- package/dist/react/filters/numbers.mjs +151 -0
- package/dist/react/filters/operator.mjs +104 -0
- package/dist/react/filters/phone.mjs +104 -0
- package/dist/react/filters/popover.d.mts +19 -0
- package/dist/react/filters/popover.mjs +153 -0
- package/dist/react/filters/rules.d.mts +8 -0
- package/dist/react/filters/rules.mjs +55 -0
- package/dist/react/filters/sheet.mjs +196 -0
- package/dist/react/filters/state.mjs +132 -0
- package/dist/react/filters/suggest.d.mts +47 -0
- package/dist/react/filters/suggest.mjs +97 -0
- package/dist/react/filters/values.mjs +166 -0
- package/dist/react/filters/words.d.mts +81 -0
- package/dist/react/filters/words.mjs +73 -0
- package/dist/react/format.d.mts +3 -3
- package/dist/react/format.mjs +45 -16
- package/dist/react/index.d.mts +34 -5
- package/dist/react/index.mjs +15 -4
- package/dist/react/messages.d.mts +47 -2
- package/dist/react/place.mjs +7 -3
- package/dist/react/renderers/index.d.mts +10 -2
- package/dist/react/renderers/index.mjs +116 -14
- package/dist/react/renderers/list.d.mts +22 -0
- package/dist/react/renderers/list.mjs +118 -0
- package/dist/react/review-words.mjs +1 -1
- package/dist/react/review.mjs +2 -2
- package/dist/react/scope.mjs +2 -7
- package/dist/react/series.d.mts +54 -0
- package/dist/react/series.mjs +191 -0
- package/dist/react/theme.css +2734 -1296
- package/dist/react/theme.css.d.ts +1 -0
- package/dist/react/tile-store.mjs +15 -3
- package/dist/react/useBoard.d.mts +7 -0
- package/dist/react/useBoard.mjs +4 -1
- package/dist/react/useDashboard.d.mts +4 -0
- package/dist/react/useDashboard.mjs +8 -1
- package/dist/react/useTiles.mjs +50 -15
- package/dist/react/view-grid.mjs +16 -0
- package/dist/react/view.d.mts +9 -0
- package/dist/react/view.mjs +22 -10
- package/dist/reading.d.mts +2 -0
- package/dist/reading.mjs +9 -1
- package/dist/recharts/axes.mjs +28 -0
- package/dist/recharts/axis.mjs +84 -0
- package/dist/recharts/bar.d.mts +7 -0
- package/dist/recharts/bar.mjs +140 -0
- package/dist/recharts/charts.d.mts +4 -6
- package/dist/recharts/charts.mjs +2 -114
- package/dist/recharts/index.d.mts +5 -3
- package/dist/recharts/index.mjs +6 -3
- package/dist/recharts/line.d.mts +2 -0
- package/dist/recharts/line.mjs +111 -0
- package/dist/recharts/marks.mjs +112 -0
- package/dist/recharts/parts.mjs +88 -0
- package/dist/recharts/series.d.mts +2 -22
- package/dist/recharts/series.mjs +1 -64
- package/dist/recharts/table.mjs +71 -0
- package/dist/records-read.mjs +44 -0
- package/dist/registry/filter-bar.json +26 -0
- package/dist/skills/derive-dashboards/SKILL.md +69 -0
- package/dist/store/apply.mjs +5 -5
- package/dist/store/commands.mjs +4 -4
- package/dist/store/discard.mjs +7 -7
- package/dist/store/drafts.mjs +5 -5
- package/dist/store/editor.mjs +1 -1
- package/dist/store/publish.mjs +12 -12
- package/dist/store/reader.mjs +41 -22
- package/dist/store/review.mjs +16 -16
- package/dist/store/rows.mjs +20 -20
- package/dist/store/undo.mjs +3 -3
- package/dist/store/unpublished.mjs +4 -4
- package/dist/store/versions.mjs +14 -14
- package/dist/testing/adapter-suite.mjs +4 -4
- package/dist/tiles.mjs +37 -3
- package/package.json +12 -10
- package/dist/react/FilterBar.mjs +0 -119
- package/dist/react/Records.d.mts +0 -12
- package/dist/react/Records.mjs +0 -97
- package/src/adapter/sql-adapter.ts +0 -95
- package/src/adapter/statement.ts +0 -185
- package/src/authorize.ts +0 -73
- package/src/body.ts +0 -169
- package/src/bounded.ts +0 -43
- package/src/cache.ts +0 -192
- package/src/checks.ts +0 -170
- package/src/custom-source.ts +0 -59
- package/src/dashboard-id.ts +0 -36
- package/src/dashboards.ts +0 -132
- package/src/editing.ts +0 -148
- package/src/endpoints/access.ts +0 -41
- package/src/endpoints/dashboards.ts +0 -92
- package/src/endpoints/drafts.ts +0 -138
- package/src/endpoints/index.ts +0 -21
- package/src/endpoints/meta.ts +0 -137
- package/src/endpoints/query.ts +0 -86
- package/src/endpoints/read.ts +0 -92
- package/src/endpoints/review.ts +0 -89
- package/src/endpoints/values.ts +0 -62
- package/src/endpoints/versions.ts +0 -104
- package/src/execute.ts +0 -207
- package/src/handler.ts +0 -232
- package/src/http.ts +0 -66
- package/src/index.ts +0 -163
- package/src/introspect.ts +0 -205
- package/src/mcp/api.ts +0 -59
- package/src/mcp/format.ts +0 -67
- package/src/mcp/index.ts +0 -151
- package/src/mcp/query.ts +0 -153
- package/src/mcp/resolve.ts +0 -114
- package/src/node-postgres.ts +0 -81
- package/src/owner.ts +0 -36
- package/src/postgres-connection.ts +0 -143
- package/src/postgres-store.ts +0 -82
- package/src/principal.ts +0 -39
- package/src/reading.ts +0 -56
- package/src/request-rows.ts +0 -23
- package/src/request.ts +0 -22
- package/src/storage.ts +0 -63
- package/src/store/apply.ts +0 -129
- package/src/store/commands.ts +0 -75
- package/src/store/conflicts.ts +0 -98
- package/src/store/create-tables.ts +0 -104
- package/src/store/discard.ts +0 -42
- package/src/store/drafts.ts +0 -133
- package/src/store/editor.ts +0 -28
- package/src/store/log.ts +0 -28
- package/src/store/publish.ts +0 -199
- package/src/store/publisher.ts +0 -21
- package/src/store/reader.ts +0 -139
- package/src/store/review.ts +0 -239
- package/src/store/rows.ts +0 -250
- package/src/store/tenant.ts +0 -28
- package/src/store/undo.ts +0 -56
- package/src/store/unpublished.ts +0 -33
- package/src/store/versions.ts +0 -106
- package/src/store/writer.ts +0 -19
- package/src/testing/adapter-suite.ts +0 -239
- package/src/testing/index.ts +0 -2
- package/src/tile-doc.ts +0 -46
- package/src/tiles.ts +0 -120
package/dist/store/rows.mjs
CHANGED
|
@@ -35,11 +35,11 @@ async function dashboardRow(db, tenant, by) {
|
|
|
35
35
|
}
|
|
36
36
|
]
|
|
37
37
|
});
|
|
38
|
-
return row !== null && sameTenant(row
|
|
38
|
+
return row !== null && sameTenant(row.tenant, tenant) ? row : null;
|
|
39
39
|
}
|
|
40
40
|
/** A dashboard's document at its current version; a built-in or new one has none yet. */
|
|
41
41
|
async function headDoc(db, row) {
|
|
42
|
-
const version = row
|
|
42
|
+
const version = row.current_version === null ? 0 : Number(row.current_version);
|
|
43
43
|
if (version === 0) return { version };
|
|
44
44
|
return {
|
|
45
45
|
version,
|
|
@@ -47,12 +47,12 @@ async function headDoc(db, row) {
|
|
|
47
47
|
table: "dd_dashboard_version",
|
|
48
48
|
where: [{
|
|
49
49
|
field: "dashboard_id",
|
|
50
|
-
value: row
|
|
50
|
+
value: row.id
|
|
51
51
|
}, {
|
|
52
52
|
field: "n",
|
|
53
53
|
value: version
|
|
54
54
|
}]
|
|
55
|
-
}))?.
|
|
55
|
+
}))?.spec, `dashboard "${String(row.id)}"`)
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
/** A document's hash, by its canonical JSON. */
|
|
@@ -95,9 +95,9 @@ function draftAuthorId(author) {
|
|
|
95
95
|
}
|
|
96
96
|
/** The id an author is known by, from the id their draft row is kept under. */
|
|
97
97
|
function authorIdOf(row) {
|
|
98
|
-
const key = String(row
|
|
99
|
-
const person = row
|
|
100
|
-
if (row
|
|
98
|
+
const key = String(row.author_id);
|
|
99
|
+
const person = row.for_id;
|
|
100
|
+
if (row.author_kind !== "agent" || typeof person !== "string") return key;
|
|
101
101
|
return key.slice(`${String(person.length)}:${person}:`.length);
|
|
102
102
|
}
|
|
103
103
|
/** The author's draft row of a dashboard, open or closed; null when there has never been one. */
|
|
@@ -121,11 +121,11 @@ function draftRow(db, dashboardId, author) {
|
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
/** The document a draft holds now. */
|
|
124
|
-
const draftDoc = (row) => documentOf(row
|
|
124
|
+
const draftDoc = (row) => documentOf(row.spec, `the draft of "${String(row.dashboard_id)}"`);
|
|
125
125
|
/** The document a draft started from: the draft is this with its commands applied. */
|
|
126
|
-
const baseDoc = (row) => documentOf(row
|
|
126
|
+
const baseDoc = (row) => documentOf(row.base_spec, `the start of the draft of "${String(row.dashboard_id)}"`);
|
|
127
127
|
/** The document a draft first started from, once review moved it onto a newer version; else none. */
|
|
128
|
-
const originDoc = (row) => row
|
|
128
|
+
const originDoc = (row) => row.origin_spec === null || row.origin_spec === void 0 ? void 0 : documentOf(row.origin_spec, `the first start of the draft of "${String(row.dashboard_id)}"`);
|
|
129
129
|
/** Who a draft row names in a column pair, if anyone. */
|
|
130
130
|
function authorIn(row, prefix) {
|
|
131
131
|
const id = row[`${prefix}_id`];
|
|
@@ -136,19 +136,19 @@ function authorIn(row, prefix) {
|
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
/** The widgets a draft row says its commands name. */
|
|
139
|
-
const namedOf = (row) => new Set(Array.isArray(row
|
|
139
|
+
const namedOf = (row) => new Set(Array.isArray(row.named) ? row.named.map(String) : []);
|
|
140
140
|
/** A draft row as the client reads it: its document, changes and undo steps, from the row alone. */
|
|
141
141
|
function draftOf(row) {
|
|
142
142
|
const doc = draftDoc(row);
|
|
143
143
|
return {
|
|
144
|
-
dashboardId: String(row
|
|
144
|
+
dashboardId: String(row.dashboard_id),
|
|
145
145
|
authorId: authorIdOf(row),
|
|
146
|
-
generation: Number(row
|
|
147
|
-
revision: Number(row
|
|
148
|
-
baseVersion: Number(row
|
|
146
|
+
generation: Number(row.generation),
|
|
147
|
+
revision: Number(row.revision),
|
|
148
|
+
baseVersion: Number(row.base_version),
|
|
149
149
|
doc,
|
|
150
150
|
changes: markShifted(diffDocs(baseDoc(row), doc), namedOf(row)),
|
|
151
|
-
steps: Number(row
|
|
151
|
+
steps: Number(row.steps)
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
154
|
/** The refusal for an edit made against another revision of the draft: the one wording of it. */
|
|
@@ -159,7 +159,7 @@ const draftClosed = () => new HttpError(409, "DRAFT_CLOSED", "There is no open d
|
|
|
159
159
|
async function openDraft(db, a) {
|
|
160
160
|
const dashboard = await dashboardRow(db, a.tenant, { id: a.id });
|
|
161
161
|
const row = dashboard === null ? null : await draftRow(db, a.id, a.author);
|
|
162
|
-
if (dashboard === null || row === null || row
|
|
162
|
+
if (dashboard === null || row === null || row.state !== "open") throw draftClosed();
|
|
163
163
|
return {
|
|
164
164
|
row,
|
|
165
165
|
dashboard
|
|
@@ -167,7 +167,7 @@ async function openDraft(db, a) {
|
|
|
167
167
|
}
|
|
168
168
|
/** Refuses an edit made against another revision of the draft than the current one. */
|
|
169
169
|
function expectRevision(row, expected) {
|
|
170
|
-
expectDraftRevision(Number(row
|
|
170
|
+
expectDraftRevision(Number(row.revision), expected);
|
|
171
171
|
}
|
|
172
172
|
/** Refuses an edit made against another revision than `current`, with the one message for it. */
|
|
173
173
|
function expectDraftRevision(current, expected) {
|
|
@@ -194,10 +194,10 @@ async function advanceDraft(tx, row, set) {
|
|
|
194
194
|
table: "dd_dashboard_draft",
|
|
195
195
|
where: [{
|
|
196
196
|
field: "id",
|
|
197
|
-
value: row
|
|
197
|
+
value: row.id
|
|
198
198
|
}, {
|
|
199
199
|
field: "revision",
|
|
200
|
-
value: row
|
|
200
|
+
value: row.revision
|
|
201
201
|
}],
|
|
202
202
|
set
|
|
203
203
|
}) !== 1) throw draftConflict();
|
package/dist/store/undo.mjs
CHANGED
|
@@ -13,13 +13,13 @@ function undo(db, a) {
|
|
|
13
13
|
const { row } = await openDraft(tx, a);
|
|
14
14
|
expectRevision(row, a.expectedRevision);
|
|
15
15
|
const base = baseDoc(row);
|
|
16
|
-
const kept = await keptCommands(tx, row
|
|
16
|
+
const kept = await keptCommands(tx, row.id);
|
|
17
17
|
if (kept.length === 0) throw new HttpError(409, "NOTHING_TO_UNDO", "The draft has no edits left to undo.");
|
|
18
18
|
const last = Math.max(...kept.map((k) => k.revision));
|
|
19
19
|
const remaining = kept.filter((k) => k.revision !== last);
|
|
20
20
|
const outcome = reduceAll(base, remaining.map((k) => k.body));
|
|
21
21
|
if (!outcome.ok) throw new HttpError(409, "EDIT_REFUSED", outcome.issue.message, { issues: [outcome.issue] });
|
|
22
|
-
const revision = Number(row
|
|
22
|
+
const revision = Number(row.revision) + 1;
|
|
23
23
|
const set = {
|
|
24
24
|
spec: outcome.doc,
|
|
25
25
|
revision,
|
|
@@ -31,7 +31,7 @@ function undo(db, a) {
|
|
|
31
31
|
table: "dd_dashboard_draft_command",
|
|
32
32
|
where: [{
|
|
33
33
|
field: "draft_id",
|
|
34
|
-
value: row
|
|
34
|
+
value: row.id
|
|
35
35
|
}, {
|
|
36
36
|
field: "revision",
|
|
37
37
|
value: last
|
|
@@ -33,13 +33,13 @@ async function unpublished(db, a) {
|
|
|
33
33
|
}],
|
|
34
34
|
limit: 100
|
|
35
35
|
});
|
|
36
|
-
const rows = await Promise.all(drafts.map((d) => dashboardRow(db, a.tenant, { id: String(d
|
|
36
|
+
const rows = await Promise.all(drafts.map((d) => dashboardRow(db, a.tenant, { id: String(d.dashboard_id) })));
|
|
37
37
|
return drafts.flatMap((d, i) => {
|
|
38
38
|
const row = rows[i];
|
|
39
|
-
if (row === null || row === void 0 || row
|
|
40
|
-
if (row
|
|
39
|
+
if (row === null || row === void 0 || row.current_version !== null) return [];
|
|
40
|
+
if (row.default_of !== null) return [];
|
|
41
41
|
return [{
|
|
42
|
-
dashboardId: String(row
|
|
42
|
+
dashboardId: String(row.id),
|
|
43
43
|
title: draftDoc(d).meta.title
|
|
44
44
|
}];
|
|
45
45
|
});
|
package/dist/store/versions.mjs
CHANGED
|
@@ -16,12 +16,12 @@ const optional = (value) => value === null || value === void 0 ? void 0 : Number
|
|
|
16
16
|
*/
|
|
17
17
|
async function versions(db, a) {
|
|
18
18
|
const row = await existing(db, a.tenant, a.id);
|
|
19
|
-
if (row
|
|
19
|
+
if (row.current_version === null) throw new HttpError(404, "NOT_FOUND", `There is no dashboard "${a.id}".`);
|
|
20
20
|
return (await db.findMany({
|
|
21
21
|
table: "dd_dashboard_version",
|
|
22
22
|
where: [{
|
|
23
23
|
field: "dashboard_id",
|
|
24
|
-
value: row
|
|
24
|
+
value: row.id
|
|
25
25
|
}, ...a.before === void 0 ? [] : [{
|
|
26
26
|
field: "n",
|
|
27
27
|
op: "lt",
|
|
@@ -33,16 +33,16 @@ async function versions(db, a) {
|
|
|
33
33
|
}],
|
|
34
34
|
limit: Math.min(a.limit ?? PAGE, PAGE)
|
|
35
35
|
})).map((v) => {
|
|
36
|
-
const basedOn = optional(v
|
|
37
|
-
const restoredFrom = optional(v
|
|
38
|
-
const kind = v
|
|
36
|
+
const basedOn = optional(v.based_on);
|
|
37
|
+
const restoredFrom = optional(v.restored_from);
|
|
38
|
+
const kind = v.author_kind === "agent" ? "agent" : "user";
|
|
39
39
|
return {
|
|
40
|
-
version: Number(v
|
|
40
|
+
version: Number(v.n),
|
|
41
41
|
author: {
|
|
42
|
-
id: String(v
|
|
42
|
+
id: String(v.author_id),
|
|
43
43
|
kind
|
|
44
44
|
},
|
|
45
|
-
createdAt: String(v
|
|
45
|
+
createdAt: String(v.created_at),
|
|
46
46
|
...basedOn === void 0 ? {} : { basedOn },
|
|
47
47
|
...restoredFrom === void 0 ? {} : { restoredFrom }
|
|
48
48
|
};
|
|
@@ -55,16 +55,16 @@ async function versions(db, a) {
|
|
|
55
55
|
function restore(db, a) {
|
|
56
56
|
return inTransaction(db, async (tx) => {
|
|
57
57
|
const row = await existing(tx, a.tenant, a.id);
|
|
58
|
-
const done = await earlier(tx, row
|
|
58
|
+
const done = await earlier(tx, row.id, a.requestId, a.author);
|
|
59
59
|
if (done !== null) return {
|
|
60
60
|
dashboardId: a.id,
|
|
61
|
-
version: Number(done
|
|
61
|
+
version: Number(done.n)
|
|
62
62
|
};
|
|
63
63
|
const old = await tx.findOne({
|
|
64
64
|
table: "dd_dashboard_version",
|
|
65
65
|
where: [{
|
|
66
66
|
field: "dashboard_id",
|
|
67
|
-
value: row
|
|
67
|
+
value: row.id
|
|
68
68
|
}, {
|
|
69
69
|
field: "n",
|
|
70
70
|
value: a.version
|
|
@@ -74,16 +74,16 @@ function restore(db, a) {
|
|
|
74
74
|
const head = await headDoc(tx, row);
|
|
75
75
|
if (head.version !== a.expectedHead) throw new HttpError(409, "VERSION_CONFLICT", "The dashboard changed. Reload its history.");
|
|
76
76
|
if (head.version === a.version) throw new HttpError(409, "VERSION_CONFLICT", `Version ${a.version} is already current.`);
|
|
77
|
-
const doc = documentOf(old
|
|
77
|
+
const doc = documentOf(old.spec, `version ${a.version} of "${a.id}"`);
|
|
78
78
|
await insertVersion(tx, {
|
|
79
79
|
...a,
|
|
80
|
-
dashboardId: row
|
|
80
|
+
dashboardId: row.id,
|
|
81
81
|
n: head.version + 1,
|
|
82
82
|
doc,
|
|
83
83
|
basedOn: head.version,
|
|
84
84
|
restoredFrom: a.version
|
|
85
85
|
});
|
|
86
|
-
await advanceHead(tx, row
|
|
86
|
+
await advanceHead(tx, row.id, head.version, doc);
|
|
87
87
|
return {
|
|
88
88
|
dashboardId: a.id,
|
|
89
89
|
version: head.version + 1
|
|
@@ -119,7 +119,7 @@ function rowCases(get) {
|
|
|
119
119
|
limit: 1,
|
|
120
120
|
offset: 1
|
|
121
121
|
});
|
|
122
|
-
expect(ids.map((r) => r
|
|
122
|
+
expect(ids.map((r) => r.id)).toEqual(["d1"]);
|
|
123
123
|
expect(await get().count({
|
|
124
124
|
table: "dd_dashboard",
|
|
125
125
|
where: [{
|
|
@@ -181,9 +181,9 @@ function batchCases(get) {
|
|
|
181
181
|
}]
|
|
182
182
|
});
|
|
183
183
|
expect(read.map((r) => [
|
|
184
|
-
r
|
|
185
|
-
r
|
|
186
|
-
r
|
|
184
|
+
r.command_id,
|
|
185
|
+
r.body,
|
|
186
|
+
r.seq
|
|
187
187
|
])).toEqual(rows.map((r) => [
|
|
188
188
|
r.command_id,
|
|
189
189
|
r.body,
|
package/dist/tiles.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { issueDrill } from "./drill-seal.mjs";
|
|
2
|
+
import { execute, wire } from "./execute.mjs";
|
|
2
3
|
import { HttpError } from "./http.mjs";
|
|
3
4
|
import { calendarOf } from "./request.mjs";
|
|
4
5
|
import { composeTile } from "derive-dashboards/core";
|
|
@@ -27,11 +28,44 @@ function tileExecution(ctx, tile) {
|
|
|
27
28
|
dashboardId: ctx.dashboardId
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
|
-
/**
|
|
31
|
+
/** Where a drill into one of these tiles starts. */
|
|
32
|
+
function originOf(ctx, tile, document) {
|
|
33
|
+
return {
|
|
34
|
+
kind: "dashboard",
|
|
35
|
+
dashboardId: ctx.dashboardId,
|
|
36
|
+
widgetId: tile.widgetId,
|
|
37
|
+
...tile.query === void 0 ? {} : { query: tile.query },
|
|
38
|
+
picks: ctx.picks,
|
|
39
|
+
...document === void 0 ? {} : { document }
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* One tile by reference: composed from the document, planned under the viewer's access, run,
|
|
44
|
+
* with what a click on each of its rows drills into.
|
|
45
|
+
*/
|
|
31
46
|
async function runTile(ctx, tile) {
|
|
47
|
+
const x = tileExecution(ctx, tile);
|
|
48
|
+
const answer = await execute(x);
|
|
49
|
+
const { document } = ctx;
|
|
50
|
+
if (document === "merged") return {
|
|
51
|
+
widgetId: tile.widgetId,
|
|
52
|
+
...wire(answer)
|
|
53
|
+
};
|
|
54
|
+
const scope = {
|
|
55
|
+
rt: ctx.rt,
|
|
56
|
+
principal: ctx.principal,
|
|
57
|
+
origin: originOf(ctx, tile, document)
|
|
58
|
+
};
|
|
59
|
+
const version = document !== void 0 && "version" in document ? document.version : ctx.version;
|
|
60
|
+
const drill = await issueDrill(scope, answer, {
|
|
61
|
+
query: x.query,
|
|
62
|
+
now: x.now,
|
|
63
|
+
...version === void 0 ? {} : { version }
|
|
64
|
+
});
|
|
32
65
|
return {
|
|
33
66
|
widgetId: tile.widgetId,
|
|
34
|
-
...
|
|
67
|
+
...wire(answer),
|
|
68
|
+
...drill === void 0 ? {} : { drill }
|
|
35
69
|
};
|
|
36
70
|
}
|
|
37
71
|
/** An error a client can act on, as a line; anything else ends the stream. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "derive-dashboards",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Open-source embedded dashboards for your product: the server, the engine, React components, charts and the CLI, in one package.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,26 +13,21 @@
|
|
|
13
13
|
"**/*.css"
|
|
14
14
|
],
|
|
15
15
|
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
"src",
|
|
18
|
-
"!src/**/*.test.ts"
|
|
16
|
+
"dist"
|
|
19
17
|
],
|
|
20
18
|
"main": "./dist/index.mjs",
|
|
21
19
|
"module": "./dist/index.mjs",
|
|
22
20
|
"types": "./dist/index.d.mts",
|
|
23
21
|
"exports": {
|
|
24
22
|
".": {
|
|
25
|
-
"dev-source": "./src/index.ts",
|
|
26
23
|
"types": "./dist/index.d.mts",
|
|
27
24
|
"default": "./dist/index.mjs"
|
|
28
25
|
},
|
|
29
26
|
"./testing": {
|
|
30
|
-
"dev-source": "./src/testing/index.ts",
|
|
31
27
|
"types": "./dist/testing/index.d.mts",
|
|
32
28
|
"default": "./dist/testing/index.mjs"
|
|
33
29
|
},
|
|
34
30
|
"./mcp": {
|
|
35
|
-
"dev-source": "./src/mcp/index.ts",
|
|
36
31
|
"types": "./dist/mcp/index.d.mts",
|
|
37
32
|
"default": "./dist/mcp/index.mjs"
|
|
38
33
|
},
|
|
@@ -60,7 +55,10 @@
|
|
|
60
55
|
"types": "./dist/react/index.d.mts",
|
|
61
56
|
"default": "./dist/react/index.mjs"
|
|
62
57
|
},
|
|
63
|
-
"./react/theme.css":
|
|
58
|
+
"./react/theme.css": {
|
|
59
|
+
"types": "./dist/react/theme.css.d.ts",
|
|
60
|
+
"default": "./dist/react/theme.css"
|
|
61
|
+
},
|
|
64
62
|
"./recharts": {
|
|
65
63
|
"types": "./dist/recharts/index.d.mts",
|
|
66
64
|
"default": "./dist/recharts/index.mjs"
|
|
@@ -90,13 +88,17 @@
|
|
|
90
88
|
},
|
|
91
89
|
"peerDependencies": {
|
|
92
90
|
"react": "^19.0.0",
|
|
91
|
+
"react-dom": "^19.0.0",
|
|
93
92
|
"recharts": "^3.0.0",
|
|
94
|
-
"vitest": "^5.0.0"
|
|
93
|
+
"vitest": "^4.0.0 || ^5.0.0"
|
|
95
94
|
},
|
|
96
95
|
"peerDependenciesMeta": {
|
|
97
96
|
"react": {
|
|
98
97
|
"optional": true
|
|
99
98
|
},
|
|
99
|
+
"react-dom": {
|
|
100
|
+
"optional": true
|
|
101
|
+
},
|
|
100
102
|
"recharts": {
|
|
101
103
|
"optional": true
|
|
102
104
|
},
|
|
@@ -108,7 +110,7 @@
|
|
|
108
110
|
"derive-dashboards": "./dist/cli/bin.mjs"
|
|
109
111
|
},
|
|
110
112
|
"engines": {
|
|
111
|
-
"node": ">=
|
|
113
|
+
"node": ">=24"
|
|
112
114
|
},
|
|
113
115
|
"keywords": [
|
|
114
116
|
"dashboards",
|
package/dist/react/FilterBar.mjs
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { useDashboards } from "./context.mjs";
|
|
2
|
-
import { ScopeContext } from "./scope.mjs";
|
|
3
|
-
import { useContext } from "react";
|
|
4
|
-
import useSWR from "swr";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
// src/FilterBar.tsx
|
|
7
|
-
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
8
|
-
function without(picks, id) {
|
|
9
|
-
return Object.fromEntries(Object.entries(picks).filter(([key]) => key !== id));
|
|
10
|
-
}
|
|
11
|
-
function DateRangeControl({ control, picks, onChange }) {
|
|
12
|
-
const { messages } = useDashboards();
|
|
13
|
-
return /* @__PURE__ */ jsxs("fieldset", {
|
|
14
|
-
className: "dd-control",
|
|
15
|
-
children: [/* @__PURE__ */ jsx("legend", {
|
|
16
|
-
className: "dd-control-label",
|
|
17
|
-
children: control.label
|
|
18
|
-
}), control.presets.map((preset) => {
|
|
19
|
-
const active = same(picks[control.id], preset);
|
|
20
|
-
return /* @__PURE__ */ jsx("button", {
|
|
21
|
-
type: "button",
|
|
22
|
-
className: "dd-chip",
|
|
23
|
-
"aria-pressed": active,
|
|
24
|
-
onClick: () => {
|
|
25
|
-
onChange(active ? without(picks, control.id) : {
|
|
26
|
-
...picks,
|
|
27
|
-
[control.id]: preset
|
|
28
|
-
});
|
|
29
|
-
},
|
|
30
|
-
children: messages.range(preset)
|
|
31
|
-
}, messages.range(preset));
|
|
32
|
-
})]
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
function selected(picks, id) {
|
|
36
|
-
const pick = picks[id];
|
|
37
|
-
return typeof pick === "object" && pick !== null && "values" in pick ? pick.values : [];
|
|
38
|
-
}
|
|
39
|
-
const LOOKUP_LIMIT = 24;
|
|
40
|
-
/** A control's own values, or for "lookup" the values its member has that this viewer can see. */
|
|
41
|
-
function useValues(control) {
|
|
42
|
-
const { client } = useDashboards();
|
|
43
|
-
const scope = useContext(ScopeContext);
|
|
44
|
-
const own = control.values;
|
|
45
|
-
const draft = scope?.draft === true;
|
|
46
|
-
const lookup = typeof own === "object" || scope === null ? null : [
|
|
47
|
-
"dd-values",
|
|
48
|
-
scope.dashboardId,
|
|
49
|
-
control.id,
|
|
50
|
-
draft
|
|
51
|
-
];
|
|
52
|
-
const fetched = useSWR(lookup, () => client.controlValues({
|
|
53
|
-
dashboardId: scope?.dashboardId ?? "",
|
|
54
|
-
controlId: control.id,
|
|
55
|
-
limit: LOOKUP_LIMIT,
|
|
56
|
-
...draft ? { draft: true } : {}
|
|
57
|
-
}));
|
|
58
|
-
return typeof own === "object" ? own : fetched.data?.values ?? [];
|
|
59
|
-
}
|
|
60
|
-
function FilterControl({ control, picks, onChange }) {
|
|
61
|
-
const values = useValues(control);
|
|
62
|
-
if (values.length === 0) return null;
|
|
63
|
-
const chosen = selected(picks, control.id);
|
|
64
|
-
const toggle = (value) => {
|
|
65
|
-
const next = chosen.includes(value) ? chosen.filter((v) => v !== value) : control.multi ? [...chosen, value] : [value];
|
|
66
|
-
const op = next.length > 1 ? "in" : "equals";
|
|
67
|
-
onChange(next.length === 0 ? without(picks, control.id) : {
|
|
68
|
-
...picks,
|
|
69
|
-
[control.id]: {
|
|
70
|
-
op,
|
|
71
|
-
values: next
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
return /* @__PURE__ */ jsxs("fieldset", {
|
|
76
|
-
className: "dd-control",
|
|
77
|
-
children: [/* @__PURE__ */ jsx("legend", {
|
|
78
|
-
className: "dd-control-label",
|
|
79
|
-
children: control.label
|
|
80
|
-
}), values.map((value) => /* @__PURE__ */ jsx("button", {
|
|
81
|
-
type: "button",
|
|
82
|
-
className: "dd-chip",
|
|
83
|
-
"aria-pressed": chosen.includes(value),
|
|
84
|
-
onClick: () => {
|
|
85
|
-
toggle(value);
|
|
86
|
-
},
|
|
87
|
-
children: String(value)
|
|
88
|
-
}, String(value)))]
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
/** The dashboard's controls as toggles. A viewer's choices are picks; the server checks each one. */
|
|
92
|
-
function FilterBar({ controls, picks, onChange }) {
|
|
93
|
-
const { messages } = useDashboards();
|
|
94
|
-
if (controls.length === 0) return null;
|
|
95
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
96
|
-
className: "dd-filters",
|
|
97
|
-
children: [controls.map((control) => {
|
|
98
|
-
if (control.kind === "date_range") return /* @__PURE__ */ jsx(DateRangeControl, {
|
|
99
|
-
control,
|
|
100
|
-
picks,
|
|
101
|
-
onChange
|
|
102
|
-
}, control.id);
|
|
103
|
-
if (control.kind === "filter") return /* @__PURE__ */ jsx(FilterControl, {
|
|
104
|
-
control,
|
|
105
|
-
picks,
|
|
106
|
-
onChange
|
|
107
|
-
}, control.id);
|
|
108
|
-
return null;
|
|
109
|
-
}), Object.keys(picks).length === 0 ? null : /* @__PURE__ */ jsx("button", {
|
|
110
|
-
type: "button",
|
|
111
|
-
className: "dd-reset",
|
|
112
|
-
onClick: () => {
|
|
113
|
-
onChange({});
|
|
114
|
-
},
|
|
115
|
-
children: messages.reset
|
|
116
|
-
})]
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
export { FilterBar };
|
package/dist/react/Records.d.mts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Widget } from "derive-dashboards/core";
|
|
2
|
-
type Props = {
|
|
3
|
-
widgetId: string;
|
|
4
|
-
widget: Widget;
|
|
5
|
-
onClose: () => void;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* The rows behind a tile, in a modal dialog: the same tenant, policy, lock and filters as the
|
|
9
|
-
* tile, a page at a time. Escape or Close closes it.
|
|
10
|
-
*/
|
|
11
|
-
export declare function RecordsPanel({ widgetId, widget, onClose }: Props): import("react").JSX.Element;
|
|
12
|
-
export {};
|
package/dist/react/Records.mjs
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { useDashboards } from "./context.mjs";
|
|
2
|
-
import { formatCell } from "./format.mjs";
|
|
3
|
-
import { useDashboardScope } from "./scope.mjs";
|
|
4
|
-
import { useEffect, useRef } from "react";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import useSWRInfinite from "swr/infinite";
|
|
7
|
-
// src/Records.tsx
|
|
8
|
-
const PAGE = 50;
|
|
9
|
-
/**
|
|
10
|
-
* Pages of the rows behind a tile, fetched as the viewer asks for more: each after the last row
|
|
11
|
-
* of the page before (its `next` cursor), so a deep page costs what the first does.
|
|
12
|
-
*/
|
|
13
|
-
function usePages(widgetId) {
|
|
14
|
-
const { client } = useDashboards();
|
|
15
|
-
const { dashboardId, picks, draft } = useDashboardScope();
|
|
16
|
-
return useSWRInfinite((index, previous) => index > 0 && previous?.next === void 0 ? null : [
|
|
17
|
-
"dd-records",
|
|
18
|
-
dashboardId,
|
|
19
|
-
widgetId,
|
|
20
|
-
picks,
|
|
21
|
-
previous?.next ?? null,
|
|
22
|
-
draft
|
|
23
|
-
], ([, , , , after]) => client.records({
|
|
24
|
-
dashboardId,
|
|
25
|
-
widgetId,
|
|
26
|
-
picks,
|
|
27
|
-
...after === null ? {} : { after },
|
|
28
|
-
limit: PAGE,
|
|
29
|
-
...draft === void 0 ? {} : { draft }
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
function RowsTable({ page, rows }) {
|
|
33
|
-
const format = useDashboards();
|
|
34
|
-
if (rows.length === 0) return /* @__PURE__ */ jsx("p", {
|
|
35
|
-
className: "dd-tile-state",
|
|
36
|
-
children: format.messages.noRows
|
|
37
|
-
});
|
|
38
|
-
return /* @__PURE__ */ jsx("div", {
|
|
39
|
-
className: "dd-records-scroll",
|
|
40
|
-
children: /* @__PURE__ */ jsxs("table", {
|
|
41
|
-
className: "dd-table",
|
|
42
|
-
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: page.columns.map((c) => /* @__PURE__ */ jsx("th", {
|
|
43
|
-
scope: "col",
|
|
44
|
-
children: c.label
|
|
45
|
-
}, c.member)) }) }), /* @__PURE__ */ jsx("tbody", { children: rows.map((row, i) => /* @__PURE__ */ jsx("tr", { children: row.map((cell, j) => /* @__PURE__ */ jsx("td", { children: formatCell(cell, page.columns[j], format) }, page.columns[j]?.member ?? j)) }, i)) })]
|
|
46
|
-
})
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* The rows behind a tile, in a modal dialog: the same tenant, policy, lock and filters as the
|
|
51
|
-
* tile, a page at a time. Escape or Close closes it.
|
|
52
|
-
*/
|
|
53
|
-
function RecordsPanel({ widgetId, widget, onClose }) {
|
|
54
|
-
const dialog = useRef(null);
|
|
55
|
-
const pages = usePages(widgetId);
|
|
56
|
-
const { messages } = useDashboards();
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
dialog.current?.showModal();
|
|
59
|
-
}, []);
|
|
60
|
-
const first = pages.data?.[0];
|
|
61
|
-
const more = pages.data?.at(-1)?.next !== void 0;
|
|
62
|
-
return /* @__PURE__ */ jsxs("dialog", {
|
|
63
|
-
ref: dialog,
|
|
64
|
-
className: "dd-records",
|
|
65
|
-
"aria-label": messages.rowsBehind(widget.title),
|
|
66
|
-
onClose,
|
|
67
|
-
children: [
|
|
68
|
-
/* @__PURE__ */ jsxs("header", {
|
|
69
|
-
className: "dd-records-header",
|
|
70
|
-
children: [/* @__PURE__ */ jsx("h3", { children: widget.title }), /* @__PURE__ */ jsx("button", {
|
|
71
|
-
type: "button",
|
|
72
|
-
onClick: () => dialog.current?.close(),
|
|
73
|
-
children: messages.close
|
|
74
|
-
})]
|
|
75
|
-
}),
|
|
76
|
-
pages.error === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
77
|
-
role: "alert",
|
|
78
|
-
className: "dd-tile-error",
|
|
79
|
-
children: messages.rowsFailed
|
|
80
|
-
}),
|
|
81
|
-
first === void 0 ? /* @__PURE__ */ jsx("p", {
|
|
82
|
-
"aria-busy": "true",
|
|
83
|
-
children: messages.loading
|
|
84
|
-
}) : /* @__PURE__ */ jsx(RowsTable, {
|
|
85
|
-
page: first,
|
|
86
|
-
rows: (pages.data ?? []).flatMap((p) => p.rows)
|
|
87
|
-
}),
|
|
88
|
-
more ? /* @__PURE__ */ jsx("button", {
|
|
89
|
-
type: "button",
|
|
90
|
-
className: "dd-records-more",
|
|
91
|
-
onClick: () => void pages.setSize(pages.size + 1),
|
|
92
|
-
children: messages.showMore
|
|
93
|
-
}) : null
|
|
94
|
-
]
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
export { RecordsPanel };
|