@stamhoofd/metabase 2.148.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/LICENSE.md +32 -0
- package/README.md +136 -0
- package/dist/api.d.ts +217 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +334 -0
- package/dist/api.js.map +1 -0
- package/dist/naming.d.ts +36 -0
- package/dist/naming.d.ts.map +1 -0
- package/dist/naming.js +42 -0
- package/dist/naming.js.map +1 -0
- package/dist/report.d.ts +141 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +297 -0
- package/dist/report.js.map +1 -0
- package/dist/sync-report.d.ts +212 -0
- package/dist/sync-report.d.ts.map +1 -0
- package/dist/sync-report.js +653 -0
- package/dist/sync-report.js.map +1 -0
- package/package.json +33 -0
- package/report/eenheden.sql +459 -0
- package/report/filters.sql +65 -0
- package/report/includes/aangesloten.sql +23 -0
- package/report/includes/aansluiting.sql +26 -0
- package/report/includes/facts-alle-jaren.sql +53 -0
- package/report/includes/facts.sql +102 -0
- package/report/includes/gtp.sql +49 -0
- package/report/includes/ingeschreven-voor.sql +27 -0
- package/report/includes/jaren.sql +20 -0
- package/report/includes/keeo/tak-categorie.sql +30 -0
- package/report/includes/leden-per-jaar.sql +29 -0
- package/report/includes/leden.sql +39 -0
- package/report/includes/omkaderingscijfer.sql +17 -0
- package/report/includes/postcode-coordinaten.sql +8 -0
- package/report/includes/ravot/gtp.sql +32 -0
- package/report/includes/ravot/omkaderingscijfer.sql +25 -0
- package/report/includes/ravot/tak-categorie.sql +28 -0
- package/report/includes/ravot/type-deelnemers.sql +22 -0
- package/report/includes/tak-categorie.sql +18 -0
- package/report/includes/takken.sql +20 -0
- package/report/includes/tarief.sql +14 -0
- package/report/includes/type-deelnemers.sql +14 -0
- package/report/includes/uldk.sql +23 -0
- package/report/jeugdbewegingen.sql +221 -0
- package/report/nationaal.sql +229 -0
- package/report/netwerk.sql +70 -0
- package/report/varia.sql +35 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Free Use License for Non-Profit Organizations
|
|
2
|
+
|
|
3
|
+
Copyright 2020 Codawood BV
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any non-profit organization with fewer than 2,000 members (each, a “Licensee”), to use this software and associated documentation files (the “Software”), subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
1. Eligibility:
|
|
8
|
+
This license applies only if neither the Licensee nor, if applicable, its parent or umbrella organization, is already subject to an existing license for this project. For the purposes of this license, a “parent or umbrella organization” means any organization with which the Licensee is affiliated, coordinated, or represented as part of a larger collective, including but not limited to national associations or federations.
|
|
9
|
+
|
|
10
|
+
2. Modifications:
|
|
11
|
+
Modifications to the Software are permitted only if they are published publicly under the MIT License, covering only the modifications; the original Software remains under this license and may not be sublicensed without a separate agreement. Any modification made by a Licensee (other than modifications by the original author, its representatives, or the copyright owner) shall be deemed to be distributed under the MIT License. Submission of modifications through publicly accessible channels, including but not limited to pull requests on code repositories such as GitHub, shall be considered an explicit acknowledgment and grant by the Licensee that such modifications are made available under the MIT License. Licensees may not sublicense, transfer, or assign the rights granted under this license except as expressly permitted herein.
|
|
12
|
+
|
|
13
|
+
3. Precedence of Existing Licenses:
|
|
14
|
+
If the Licensee, or its parent or umbrella organization, is already subject to an existing license for this project, that license shall take precedence, and no additional free license is granted. Nothing in this license shall be construed to override any pre-existing exclusive license agreement.
|
|
15
|
+
|
|
16
|
+
4. Data Protection / GDPR Responsibility:
|
|
17
|
+
Licensees are solely responsible for ensuring that any processing of personal data using this software complies with applicable data protection laws, including the EU General Data Protection Regulation (GDPR).
|
|
18
|
+
|
|
19
|
+
5. Termination and Revocation:
|
|
20
|
+
The copyright holders may revoke this license at any time, at their sole discretion.
|
|
21
|
+
|
|
22
|
+
6. Governing Law:
|
|
23
|
+
This license shall be governed by and construed in accordance with the laws of Belgium, without regard to conflict of law principles.
|
|
24
|
+
|
|
25
|
+
7. Third-Party Licenses:
|
|
26
|
+
Certain files or components included in the Software may be governed by separate licenses, including open-source licenses, or contributed by third parties under different terms. Such files are not automatically covered by this license. Licensees are responsible for reviewing and complying with any additional license terms that apply to these files.
|
|
27
|
+
|
|
28
|
+
For the purposes of this license, a “non-profit organization” means an entity recognized as non-profit under applicable law in its jurisdiction, which does not distribute profits to its members or owners.
|
|
29
|
+
|
|
30
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
31
|
+
|
|
32
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Metabase
|
|
2
|
+
|
|
3
|
+
Everything that configures Metabase: the ledenstatistieken report and the API client that writes it.
|
|
4
|
+
|
|
5
|
+
| | |
|
|
6
|
+
|---|---|
|
|
7
|
+
| `report/*.sql` | The report, one file per tab, as queries on the platform statistics database |
|
|
8
|
+
| `src/report.ts` | Reads those files. Knows nothing about Metabase |
|
|
9
|
+
| `src/api.ts` | Minimal client for the Metabase HTTP API |
|
|
10
|
+
| `src/sync-report.ts` | Says the report in Metabase's vocabulary and writes it |
|
|
11
|
+
| `src/naming.ts` | What things are called in Metabase, so every caller agrees |
|
|
12
|
+
|
|
13
|
+
## What the report counts
|
|
14
|
+
|
|
15
|
+
Two fragments decide that, and every card opens with the pair:
|
|
16
|
+
|
|
17
|
+
| | |
|
|
18
|
+
|---|---|
|
|
19
|
+
| `includes/facts.sql` | one row per registration: who was registered where, in which tak, in which year |
|
|
20
|
+
| `includes/leden.sql` | that narrowed to one row per member per eenheid, carrying what they are |
|
|
21
|
+
|
|
22
|
+
The ledenstatistieken count members, not registrations, so every card of that dashboard reads `leden`
|
|
23
|
+
and none reads `facts` directly. Someone registered in two takken of the same eenheid stands twice in
|
|
24
|
+
`facts`, and counted there they land in two bars of the same chart, or -- if they are leiding in one
|
|
25
|
+
tak and lid in the other -- on both sides of the omkaderingscijfer at once. `leden` picks the one
|
|
26
|
+
registration that speaks for them: leiding beats lid, and the oldest tak wins between two.
|
|
27
|
+
|
|
28
|
+
The aanlevering is the exception and keeps reading its own rows. The department counts inschrijvingen
|
|
29
|
+
rather than inschrijvers, and reads what a member is from the cancelled registrations as well, so
|
|
30
|
+
`jeugdbewegingen.sql` decides it in its own `deelnemers`.
|
|
31
|
+
|
|
32
|
+
Which registrations reach either of those is the "Ingeschreven voor" filter, in
|
|
33
|
+
`includes/ingeschreven-voor.sql`: a registration stands in a leeftijdsgroep, an activiteit or a
|
|
34
|
+
wachtlijst, and only the first of the three is being a lid of the eenheid. It is the one filter that
|
|
35
|
+
opens on a value -- the leeftijdsgroepen -- because empty counts every registration, which would put
|
|
36
|
+
the people waiting for a place among the leden. The aanlevering is not offered it and pins itself to
|
|
37
|
+
the leeftijdsgroepen: an unconnected filter counts everything, which is the wrong way for a sheet
|
|
38
|
+
delivered to a department to fail.
|
|
39
|
+
|
|
40
|
+
## One report, several platforms
|
|
41
|
+
|
|
42
|
+
The same report is written for every platform, and they do not all count every figure the same way:
|
|
43
|
+
the GTP index weighs takken for keeo and the age of a lid for ravot, where leiding count as one and a
|
|
44
|
+
half. A statistics database holds one platform, so which variant a card gets is decided while the
|
|
45
|
+
report is loaded — `loadReport(env)` takes the environment, the same name the data source carries.
|
|
46
|
+
|
|
47
|
+
| | |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `report/includes/<env>/gtp.sql` | what `@include gtp` expands to in that environment |
|
|
50
|
+
| `-- description@ravot:` | what a card's `-- description:` says there |
|
|
51
|
+
|
|
52
|
+
A card names neither and keeps saying `@include gtp`, which is what keeps one report from quietly
|
|
53
|
+
becoming two. An override of a name no fragment carries is refused rather than ignored: nothing
|
|
54
|
+
includes it, so a misspelled file would change nothing and say nothing.
|
|
55
|
+
|
|
56
|
+
## What a tak counts as
|
|
57
|
+
|
|
58
|
+
Kinderen, leiding or volwassenen. Every figure that divides the one from the other reads it, and it
|
|
59
|
+
is the one thing about a tak that nothing in the administration knows: the platform configuration has
|
|
60
|
+
no such field, and the ages do not answer it, since leiding and stam carry no age range and a tak of
|
|
61
|
+
kinderen need not carry one either.
|
|
62
|
+
|
|
63
|
+
`includes/takken.sql` is where it is settled, and `includes/tak-categorie.sql` is the answer itself.
|
|
64
|
+
`includes/keeo/tak-categorie.sql` and `includes/ravot/tak-categorie.sql` name that platform's takken
|
|
65
|
+
by id; the unqualified fragment says nothing, which is what a platform that has not written its list
|
|
66
|
+
is left with.
|
|
67
|
+
|
|
68
|
+
The statistics database used to hold a hand-filled `category` column for this instead. It is dropped:
|
|
69
|
+
a column no rebuild survives, refilled by an UPDATE recorded nowhere, is not somewhere an answer can
|
|
70
|
+
live. A list in the query is in git, is checked by the tests, and stands in front of whoever opens
|
|
71
|
+
the question in Metabase. The cost is that it is now the whole answer — a tak missing from its
|
|
72
|
+
platform's list counts as nothing at all, so a tak added to the platform configuration has to be
|
|
73
|
+
added here too.
|
|
74
|
+
|
|
75
|
+
Ravot's list is the one to read before changing either. Its ondersteunende leden are volwassenen and
|
|
76
|
+
may not be categorised as leiding: the omkaderingscijfer and the GTP index would then count them as
|
|
77
|
+
leiding the kinderen of an eenheid are looked after by. The aanlevering delivers them among the
|
|
78
|
+
leiding anyway — the department has no third word for them — by naming the tak itself in
|
|
79
|
+
`ravot/type-deelnemers.sql`, which only works for as long as the category does not say it.
|
|
80
|
+
|
|
81
|
+
Standing in front of the reader only holds until the next `yarn metabase report`, which rewrites every
|
|
82
|
+
card from these files — an edit made in Metabase is a correction to bring back here, not a place to
|
|
83
|
+
keep one.
|
|
84
|
+
|
|
85
|
+
One tab is not part of the client's own report. `report/jeugdbewegingen.sql` is the dataset the
|
|
86
|
+
koepel delivers to the Departement Cultuur, Jeugd en Media every september, one card per sheet of the
|
|
87
|
+
delivery template: tables to download as .xlsx and paste into it rather than charts to read. It names
|
|
88
|
+
a `dashboard:` of its own, which writes it as a second dashboard in the collection instead of as a
|
|
89
|
+
page of the ledenstatistieken. That is also why those cards name their columns -- Metabase writes the
|
|
90
|
+
header of an export from the column's title, and a sheet read by a government department has to keep
|
|
91
|
+
the names the template gives it.
|
|
92
|
+
|
|
93
|
+
The koepel's own organization is treated the other way around by the two. The ledenstatistieken leave
|
|
94
|
+
it out wherever they count -- it is the national body, not an eenheid, and the client's own report
|
|
95
|
+
counts none of its structuurvrijwilligers -- while the aanlevering is about nothing else.
|
|
96
|
+
`platform.membershipOrganizationId` is the only thing that says which organization that is, so
|
|
97
|
+
`report/includes/facts.sql` offers the same rows under two names: `facts` without it, `all_facts` with
|
|
98
|
+
it. The import writes it under that same id, so both hold in the years imported from the client's own
|
|
99
|
+
statistics as well as in the years the sync owns.
|
|
100
|
+
|
|
101
|
+
Installing Metabase differs per environment — Docker locally (`stam platform-report start`), a jar
|
|
102
|
+
under systemd on a server (`yarn metabase install` in devops) — but configuring it is the same HTTP
|
|
103
|
+
calls either way. That is why this package holds no install logic and no credentials: a caller passes the
|
|
104
|
+
base URL, the credentials and the data source to write against.
|
|
105
|
+
|
|
106
|
+
| | Local | Server |
|
|
107
|
+
|---|---|---|
|
|
108
|
+
| Written by | `stam platform-report dashboards` | `yarn metabase report -s keeo/keeo-metabase-001` |
|
|
109
|
+
| Authenticates with | the admin account the CLI created | an api key from 1Password |
|
|
110
|
+
| Data source | registered by the CLI | added once by hand, looked up by name |
|
|
111
|
+
|
|
112
|
+
Nothing this writes carries the name of a platform: the collection is `Ledenstatistieken` and holds
|
|
113
|
+
the dashboards `Ledenstatistieken` and `Aanlevering ...`, whichever platform they count. A server
|
|
114
|
+
holds one platform, and a local Metabase shows the report of the environment written last — writing
|
|
115
|
+
another one points the same questions at its data source.
|
|
116
|
+
|
|
117
|
+
That is also why nothing here trashes a collection. There is one to write into, and a collection this
|
|
118
|
+
wrote under the older per-environment name (`Ledenstatistieken (keeo)`) is renamed into it, keeping
|
|
119
|
+
the id every question, dashboard, link and bookmark points at. The only thing a run ever trashes is a
|
|
120
|
+
dashboard this tool wrote itself under a layout it no longer writes.
|
|
121
|
+
|
|
122
|
+
The two auth modes exist because the environments differ in what they may hold. Locally the CLI
|
|
123
|
+
completes the setup wizard itself and knows the password. A server's first account is made by a
|
|
124
|
+
person, and nothing may store their password, so it uses an api key created under
|
|
125
|
+
Admin > Settings > Authentication > API keys. `verifyApiKey()` checks it belongs to an admin before
|
|
126
|
+
anything is written, so a revoked key fails up front instead of halfway through the report.
|
|
127
|
+
|
|
128
|
+
It deliberately depends on no part of the backend, not even in its tests: the schema the cards query
|
|
129
|
+
is owned by `@stamhoofd/backend-statistics-syncer`, and reaching for it here would make a shared
|
|
130
|
+
package depend on an app. So the tests check the shape of the report — its tabs, cards, parameters
|
|
131
|
+
and filters — and never run a card. A column renamed in the statistics migrations therefore surfaces
|
|
132
|
+
in Metabase rather than here.
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
yarn stam test metabase
|
|
136
|
+
```
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
export type MetabaseAdmin = {
|
|
2
|
+
email: string;
|
|
3
|
+
password: string;
|
|
4
|
+
firstName: string;
|
|
5
|
+
lastName: string;
|
|
6
|
+
};
|
|
7
|
+
export type MetabaseDatabaseInput = {
|
|
8
|
+
name: string;
|
|
9
|
+
host: string;
|
|
10
|
+
port: number;
|
|
11
|
+
database: string;
|
|
12
|
+
user: string;
|
|
13
|
+
password: string;
|
|
14
|
+
};
|
|
15
|
+
export type MetabaseDatabase = {
|
|
16
|
+
id: number;
|
|
17
|
+
name: string;
|
|
18
|
+
engine: string;
|
|
19
|
+
/** Metabase's own demo database, which it creates on setup unless told not to. */
|
|
20
|
+
is_sample?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type MetabaseTable = {
|
|
23
|
+
id: number;
|
|
24
|
+
name: string;
|
|
25
|
+
visibility_type: string | null;
|
|
26
|
+
};
|
|
27
|
+
export type MetabaseCollection = {
|
|
28
|
+
id: number;
|
|
29
|
+
name: string;
|
|
30
|
+
archived?: boolean;
|
|
31
|
+
};
|
|
32
|
+
export type MetabaseCardInput = {
|
|
33
|
+
name: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
display: string;
|
|
36
|
+
databaseId: number;
|
|
37
|
+
query: string;
|
|
38
|
+
templateTags: Record<string, unknown>;
|
|
39
|
+
visualizationSettings: Record<string, unknown>;
|
|
40
|
+
collectionId: number;
|
|
41
|
+
};
|
|
42
|
+
export type MetabaseCard = {
|
|
43
|
+
id: number;
|
|
44
|
+
name: string;
|
|
45
|
+
};
|
|
46
|
+
export type MetabaseDashboard = {
|
|
47
|
+
id: number;
|
|
48
|
+
name: string;
|
|
49
|
+
};
|
|
50
|
+
export type MetabaseDashboardLayout = {
|
|
51
|
+
tabs: {
|
|
52
|
+
id: number;
|
|
53
|
+
name: string;
|
|
54
|
+
}[];
|
|
55
|
+
/** The placed cards. A text box or heading holds no card, and has no `cardId`. */
|
|
56
|
+
cards: {
|
|
57
|
+
id: number;
|
|
58
|
+
cardId: number | null;
|
|
59
|
+
tabId: number | null;
|
|
60
|
+
}[];
|
|
61
|
+
};
|
|
62
|
+
export declare class MetabaseApiError extends Error {
|
|
63
|
+
readonly status: number;
|
|
64
|
+
constructor(message: string, status: number);
|
|
65
|
+
}
|
|
66
|
+
export type MetabaseUser = {
|
|
67
|
+
id: number;
|
|
68
|
+
email: string;
|
|
69
|
+
is_superuser?: boolean;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Minimal client for the Metabase HTTP API, enough to complete the setup wizard and register the
|
|
73
|
+
* databases Metabase reports on. Metabase has no declarative provisioning in the open source
|
|
74
|
+
* edition (the config file is an enterprise feature), so this is the only way to automate it.
|
|
75
|
+
*
|
|
76
|
+
* Two ways to authenticate, because the two environments differ in what they can hold:
|
|
77
|
+
*
|
|
78
|
+
* - An admin account, which also completes the setup wizard. Used against a local Metabase, where
|
|
79
|
+
* the CLI creates that account itself and knows the password.
|
|
80
|
+
* - An `apiKey`, created by hand in Metabase (Admin > Settings > Authentication > API keys) and kept
|
|
81
|
+
* in 1Password. Used against a server, where nothing may hold a human's password and where the
|
|
82
|
+
* first account was made by a person.
|
|
83
|
+
*/
|
|
84
|
+
export declare class MetabaseApi {
|
|
85
|
+
private readonly baseUrl;
|
|
86
|
+
private session;
|
|
87
|
+
private readonly apiKey;
|
|
88
|
+
constructor(baseUrl: string, options?: {
|
|
89
|
+
apiKey?: string;
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
92
|
+
* Metabase hands out a setup token until the wizard completed, which is also the only way to
|
|
93
|
+
* create the very first user. Absent means someone already set this instance up.
|
|
94
|
+
*/
|
|
95
|
+
getSetupToken(): Promise<string | undefined>;
|
|
96
|
+
/**
|
|
97
|
+
* Complete the setup wizard on a fresh instance and keep the session it returns.
|
|
98
|
+
*/
|
|
99
|
+
setup(token: string, admin: MetabaseAdmin): Promise<void>;
|
|
100
|
+
login(admin: MetabaseAdmin): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Set the wizard up when the instance is fresh, log in when it is not. Returns whether this
|
|
103
|
+
* call is what created the admin account.
|
|
104
|
+
*/
|
|
105
|
+
authenticate(admin: MetabaseAdmin): Promise<{
|
|
106
|
+
created: boolean;
|
|
107
|
+
}>;
|
|
108
|
+
/** Who the current credentials belong to. */
|
|
109
|
+
currentUser(): Promise<MetabaseUser>;
|
|
110
|
+
/**
|
|
111
|
+
* Check that the api key is accepted and belongs to an admin, before anything is written.
|
|
112
|
+
*
|
|
113
|
+
* A key is created by hand and can be revoked or downgraded there, so without this a stale one
|
|
114
|
+
* surfaces as a 401 somewhere halfway through writing the report.
|
|
115
|
+
*/
|
|
116
|
+
verifyApiKey(): Promise<MetabaseUser>;
|
|
117
|
+
listDatabases(): Promise<MetabaseDatabase[]>;
|
|
118
|
+
findDatabaseByName(name: string): Promise<MetabaseDatabase | undefined>;
|
|
119
|
+
/**
|
|
120
|
+
* The registered database to write questions against, which has to be there already.
|
|
121
|
+
*
|
|
122
|
+
* Deliberately not created here: on a server the data source holds credentials of its own and
|
|
123
|
+
* connects over SSL, so it is added once by hand and this only ever looks it up.
|
|
124
|
+
*/
|
|
125
|
+
requireDatabaseByName(name: string): Promise<MetabaseDatabase>;
|
|
126
|
+
/**
|
|
127
|
+
* Register `input` as a MySQL database unless a database with the same name is already
|
|
128
|
+
* registered. An existing one is left untouched, so changes made in the UI survive.
|
|
129
|
+
*/
|
|
130
|
+
ensureDatabase(input: MetabaseDatabaseInput): Promise<{
|
|
131
|
+
id: number;
|
|
132
|
+
created: boolean;
|
|
133
|
+
}>;
|
|
134
|
+
/**
|
|
135
|
+
* Make Metabase re-read the tables of a database. It caches the schema it found when the data
|
|
136
|
+
* source was registered and only refreshes on its own schedule, so a database that was still
|
|
137
|
+
* empty at that moment keeps showing no tables long after the migrations created them.
|
|
138
|
+
*/
|
|
139
|
+
syncDatabaseSchema(id: number): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Hide tables from the query builder and the data reference. Used for the schema-history table,
|
|
142
|
+
* which is part of the database but has nothing to report on.
|
|
143
|
+
*
|
|
144
|
+
* Metabase discovers tables in a background sync, so a table that was only just created may not
|
|
145
|
+
* be known yet; this waits a bounded time for it and otherwise leaves it for the next run rather
|
|
146
|
+
* than holding up the command.
|
|
147
|
+
*/
|
|
148
|
+
hideTables(databaseId: number, names: string[], options?: {
|
|
149
|
+
timeoutMs?: number;
|
|
150
|
+
}): Promise<string[]>;
|
|
151
|
+
/**
|
|
152
|
+
* Drop Metabase's demo database. Instances started before the image was told to skip it already
|
|
153
|
+
* have one, and it is only noise next to the platform statistics. Identified by the flag rather
|
|
154
|
+
* than by name, which is the only thing Metabase guarantees about it.
|
|
155
|
+
*/
|
|
156
|
+
removeSampleDatabase(): Promise<{
|
|
157
|
+
removed: boolean;
|
|
158
|
+
}>;
|
|
159
|
+
listCollections(): Promise<MetabaseCollection[]>;
|
|
160
|
+
/**
|
|
161
|
+
* The collection the report lives in, created if it is not there yet. Everything the CLI writes
|
|
162
|
+
* goes in one collection so it stays apart from whatever the client builds themselves.
|
|
163
|
+
*/
|
|
164
|
+
ensureCollection(name: string): Promise<{
|
|
165
|
+
id: number;
|
|
166
|
+
created: boolean;
|
|
167
|
+
}>;
|
|
168
|
+
/**
|
|
169
|
+
* Rename a collection, keeping its id and everything in it. Used to bring a collection this
|
|
170
|
+
* wrote under an earlier name along rather than leaving it beside a new one.
|
|
171
|
+
*/
|
|
172
|
+
renameCollection(id: number, name: string): Promise<void>;
|
|
173
|
+
listCards(collectionId: number): Promise<MetabaseCard[]>;
|
|
174
|
+
listDashboards(collectionId: number): Promise<MetabaseDashboard[]>;
|
|
175
|
+
/**
|
|
176
|
+
* Write a native question. Updating an existing card rather than replacing it keeps its id, and
|
|
177
|
+
* with it every dashboard that points at it and every link the client saved.
|
|
178
|
+
*/
|
|
179
|
+
saveCard(input: MetabaseCardInput, existingId?: number): Promise<number>;
|
|
180
|
+
/**
|
|
181
|
+
* Run a saved question and return the values of its first column. Used to read the values a
|
|
182
|
+
* filter offers straight out of the database Metabase is already connected to, so the CLI needs
|
|
183
|
+
* no database connection of its own.
|
|
184
|
+
*/
|
|
185
|
+
runCardValues(cardId: number): Promise<string[]>;
|
|
186
|
+
createDashboard(name: string, description: string | undefined, collectionId: number): Promise<number>;
|
|
187
|
+
/** The tabs and cards a dashboard already has, so writing it again can keep their ids. */
|
|
188
|
+
getDashboardLayout(id: number): Promise<MetabaseDashboardLayout>;
|
|
189
|
+
/**
|
|
190
|
+
* Lay out a dashboard: its tabs, its filters and which card sits where. Metabase replaces the
|
|
191
|
+
* whole set of tabs and cards with what is sent, so this is also what removes a card the report
|
|
192
|
+
* no longer has.
|
|
193
|
+
*/
|
|
194
|
+
updateDashboard(id: number, body: {
|
|
195
|
+
name: string;
|
|
196
|
+
description?: string;
|
|
197
|
+
parameters: unknown[];
|
|
198
|
+
tabs: unknown[];
|
|
199
|
+
dashcards: unknown[];
|
|
200
|
+
collectionPosition?: number;
|
|
201
|
+
}): Promise<void>;
|
|
202
|
+
/**
|
|
203
|
+
* Bookmark the dashboard, so it shows up under "Bookmarks" in the sidebar.
|
|
204
|
+
*
|
|
205
|
+
* A bookmark belongs to one account — the one the CLI signs in as — so this does nothing for
|
|
206
|
+
* anyone else who opens Metabase. Bookmarking twice is an error, hence the check first.
|
|
207
|
+
*/
|
|
208
|
+
bookmarkDashboard(id: number): Promise<{
|
|
209
|
+
created: boolean;
|
|
210
|
+
}>;
|
|
211
|
+
/** Move a question to the trash. */
|
|
212
|
+
archiveCard(id: number): Promise<void>;
|
|
213
|
+
/** Move a dashboard to the trash. Used to clear away the one-dashboard-per-page layout. */
|
|
214
|
+
archiveDashboard(id: number): Promise<void>;
|
|
215
|
+
private request;
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;I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