@metabase/cli 0.1.0 → 0.1.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.
Files changed (187) hide show
  1. package/README.md +972 -57
  2. package/dist/add-collection--zwkmE1S.mjs +11 -0
  3. package/dist/add-collection-B1qe0D1U.mjs +54 -0
  4. package/dist/api-key-gzCbKDjL.mjs +13 -0
  5. package/dist/archive-CitmlD1e.mjs +39 -0
  6. package/dist/{archive-CsWeHXle.mjs → archive-CnhWegtR.mjs} +7 -4
  7. package/dist/archive-DQjBOXnx.mjs +44 -0
  8. package/dist/archive-Ni8-lQ1Y.mjs +44 -0
  9. package/dist/auth-BPjsrFxM.mjs +19 -0
  10. package/dist/{body-Dv9hQ0Qk.mjs → body-DRBgxS6-.mjs} +3 -2
  11. package/dist/{branches-BujtceGr.mjs → branches-C5Jcw8wu.mjs} +8 -6
  12. package/dist/cancel-Ca3r7Y6v.mjs +56 -0
  13. package/dist/{cancel-task-CT2xUMRg.mjs → cancel-task-C1-8vDKS.mjs} +9 -7
  14. package/dist/card-BGAy3eIb.mjs +20 -0
  15. package/dist/{card-CsXk8T6A.mjs → card-CAEZWixN.mjs} +34 -15
  16. package/dist/cards-CILfMPUP.mjs +37 -0
  17. package/dist/cli.mjs +33 -14
  18. package/dist/collection-B3sPXRLs.mjs +163 -0
  19. package/dist/collection-D8cnCB98.mjs +19 -0
  20. package/dist/create-3Z6rm-4O.mjs +44 -0
  21. package/dist/create-BsY5RrVY.mjs +44 -0
  22. package/dist/create-C4OCclBD.mjs +48 -0
  23. package/dist/create-COsD7Vzm.mjs +48 -0
  24. package/dist/create-CP8ou91U.mjs +125 -0
  25. package/dist/create-CeIi_QLj.mjs +66 -0
  26. package/dist/create-CqNw6PmR.mjs +50 -0
  27. package/dist/create-DE_5NrFy.mjs +48 -0
  28. package/dist/{create-B8ektf-R.mjs → create-MEhhhgMC.mjs} +8 -6
  29. package/dist/create-QxDmleKJ.mjs +48 -0
  30. package/dist/{create-branch-goZBTNnr.mjs → create-branch-CKMYaAHk.mjs} +9 -7
  31. package/dist/credentials-CwRKvdP2.mjs +85 -0
  32. package/dist/{current-task-DBjRNCFq.mjs → current-task-Dutjys16.mjs} +9 -7
  33. package/dist/dashboard-B4fVp392.mjs +20 -0
  34. package/dist/dashboard-CnMD04PQ.mjs +163 -0
  35. package/dist/database-BMTb0CzV.mjs +17 -0
  36. package/dist/database-Dvkfy3JM.mjs +51 -0
  37. package/dist/db-ACuuaEok.mjs +22 -0
  38. package/dist/{delete-8vGU35r3.mjs → delete-BMQZuVXZ.mjs} +7 -5
  39. package/dist/{delete-B27KLF5X.mjs → delete-BvcA4jPj.mjs} +7 -5
  40. package/dist/{delete-runtime-Byr60cR3.mjs → delete-runtime-BMzvfj_B.mjs} +4 -4
  41. package/dist/{delete-table-BNaJ_gA4.mjs → delete-table-DUPjHKk4.mjs} +7 -5
  42. package/dist/deprovision-Bsc1S15j.mjs +61 -0
  43. package/dist/{dirty-aNUuph4I.mjs → dirty-CXcdoUhY.mjs} +8 -6
  44. package/dist/docker-D-ieBsP7.mjs +612 -0
  45. package/dist/eid-pvOsEMPZ.mjs +13 -0
  46. package/dist/{export-QDkuuzSE.mjs → export-BjGhLEOi.mjs} +30 -23
  47. package/dist/field-BI2bt8e9.mjs +18 -0
  48. package/dist/field-DciLbuv-.mjs +276 -0
  49. package/dist/fields-Do8HHm_T.mjs +38 -0
  50. package/dist/flag-pair-DtR1AiBQ.mjs +17 -0
  51. package/dist/{get-BGBIzMKY.mjs → get-BGFGWkH0.mjs} +6 -4
  52. package/dist/get-BmE_VHdl.mjs +36 -0
  53. package/dist/{get-DI_IJvgk.mjs → get-C7sshmqF.mjs} +6 -4
  54. package/dist/get-CObKBj2J.mjs +36 -0
  55. package/dist/get-Cq5U_Eep.mjs +40 -0
  56. package/dist/get-D4GUJBiX.mjs +41 -0
  57. package/dist/{get-COXHplHP.mjs → get-DFrsi77F.mjs} +7 -5
  58. package/dist/get-DczxeETg.mjs +53 -0
  59. package/dist/{get-Cl8-IauC.mjs → get-DeQa3ThJ.mjs} +7 -4
  60. package/dist/get-DhZ_dGUb.mjs +36 -0
  61. package/dist/{get-i6LWOByV.mjs → get-DzCVafyO.mjs} +6 -4
  62. package/dist/get-YCnVqq-z.mjs +49 -0
  63. package/dist/get-run-CTyW29s3.mjs +36 -0
  64. package/dist/git-sync-BOmT8HEU.mjs +28 -0
  65. package/dist/{has-remote-changes-hjKoQuRy.mjs → has-remote-changes-xX8vMVsX.mjs} +8 -6
  66. package/dist/{import-HJsSKRYx.mjs → import-CaAUNtXz.mjs} +11 -9
  67. package/dist/{input-Dojr-RTw.mjs → input-ikCiip6x.mjs} +2 -1
  68. package/dist/is-dirty-CPu-xqkW.mjs +10 -0
  69. package/dist/{is-dirty-1Qy7hiHB.mjs → is-dirty-mgxEwEk4.mjs} +5 -4
  70. package/dist/items-Cg67tdto.mjs +77 -0
  71. package/dist/{key-DBxPSFwi.mjs → key-NDEARu2L.mjs} +1 -1
  72. package/dist/{license-MoWse3ZI.mjs → license-CwKzVMD0.mjs} +3 -3
  73. package/dist/list-BqdNQ1nU.mjs +47 -0
  74. package/dist/list-BwGdD45N.mjs +32 -0
  75. package/dist/list-CfOVsAZz.mjs +55 -0
  76. package/dist/list-CpyNn1Zn.mjs +32 -0
  77. package/dist/list-CwwOoGLK.mjs +40 -0
  78. package/dist/{list-C_PRdL5e.mjs → list-DD8CQx8l.mjs} +7 -5
  79. package/dist/{list-Bk6RsbJl.mjs → list-DL-RWpIE.mjs} +5 -3
  80. package/dist/list-DLlq3FyS.mjs +61 -0
  81. package/dist/list-DdQ4jmUQ.mjs +52 -0
  82. package/dist/{list-C4Ajrw8f.mjs → list-DshbLoqR.mjs} +6 -3
  83. package/dist/{list-C8tdLOH5.mjs → list-DzTMpoBs.mjs} +5 -3
  84. package/dist/list-JgRtCzz3.mjs +32 -0
  85. package/dist/{list-CWt3fqrZ.mjs → list-WzgJcwB5.mjs} +5 -3
  86. package/dist/{login-C9WTwNn6.mjs → login-DJnmR2wX.mjs} +14 -5
  87. package/dist/{logout-oLszGCOg.mjs → logout-BMe_1Zp8.mjs} +7 -6
  88. package/dist/logs-CQxKJ3HG.mjs +58 -0
  89. package/dist/{manifest-CAdjQYH8.mjs → manifest-Dv5B9Blc.mjs} +3 -7
  90. package/dist/measure-BEQfnLdN.mjs +67 -0
  91. package/dist/measure-BGyYbtqO.mjs +19 -0
  92. package/dist/metadata-CLIALntn.mjs +37 -0
  93. package/dist/metadata-T-fNUWg_.mjs +38 -0
  94. package/dist/{package-BGfw4ZWJ.mjs → package-DBsS7a5x.mjs} +7 -1
  95. package/dist/paginate-CTSfuYiF.mjs +49 -0
  96. package/dist/parse-id-BUOZQqjp.mjs +12 -0
  97. package/dist/parse-ref-DGvh4aDn.mjs +17 -0
  98. package/dist/parse-schemas-BnW4T1_I.mjs +12 -0
  99. package/dist/{poll-ILanYysl.mjs → poll-DMmmZWvi.mjs} +2 -1
  100. package/dist/{poll-task-DbpsiQhl.mjs → poll-task-2Ckiwp8U.mjs} +8 -7
  101. package/dist/predicates-DiIiS3k7.mjs +153 -0
  102. package/dist/preflight-CC_g6EWU.mjs +91 -0
  103. package/dist/{prompt-DpT8yAVy.mjs → prompt-Bf3DQ-qE.mjs} +1 -1
  104. package/dist/provision-BUgWJWAV.mjs +77 -0
  105. package/dist/ps-BUNHygf-.mjs +10 -0
  106. package/dist/ps-Yv0JjLVN.mjs +78 -0
  107. package/dist/{query-PihYi-UZ.mjs → query-CzfbuG8a.mjs} +38 -13
  108. package/dist/query-UIebHmbT.mjs +90 -0
  109. package/dist/remove-BAUbcwuF.mjs +98 -0
  110. package/dist/{remove-B2hVYn1v.mjs → remove-CN2PNGTR.mjs} +6 -5
  111. package/dist/remove-collection-C6NxEh53.mjs +38 -0
  112. package/dist/render-DXv-D6fU.mjs +182 -0
  113. package/dist/rescan-values-CcB4F9qa.mjs +43 -0
  114. package/dist/revision-message-flag-CWQbKhdl.mjs +11 -0
  115. package/dist/{run-C2so6Qp6.mjs → run-BjXZtu_6.mjs} +27 -36
  116. package/dist/runs-CXx7l1NY.mjs +54 -0
  117. package/dist/{runtime-C9CEZhcn.mjs → runtime-D7jihh81.mjs} +425 -442
  118. package/dist/schema-tables-BCJT2DM_.mjs +45 -0
  119. package/dist/schemas-DlNpbn4H.mjs +47 -0
  120. package/dist/{search-CopOytXY.mjs → search-Dt-6mdHZ.mjs} +6 -19
  121. package/dist/segment-BMrUBz94.mjs +70 -0
  122. package/dist/segment-C52QNnSs.mjs +19 -0
  123. package/dist/{set-BcF7M1GQ.mjs → set-DCESWpi3.mjs} +6 -4
  124. package/dist/{set-CbibegpA.mjs → set-L7cuHjVZ.mjs} +8 -6
  125. package/dist/{setting-U3NtBMFo.mjs → setting-DysGAuYS.mjs} +3 -3
  126. package/dist/setup-_ypJDPAY.mjs +71 -0
  127. package/dist/snippet-Dw0Sjzkr.mjs +64 -0
  128. package/dist/snippet-vb3G9R8a.mjs +19 -0
  129. package/dist/start-BokXnb0V.mjs +350 -0
  130. package/dist/{stash-DOBbYozC.mjs → stash-CaGX6PfX.mjs} +9 -7
  131. package/dist/{status-Buf1ZbNR.mjs → status-BaX9vedb.mjs} +10 -8
  132. package/dist/{status-CUcs8XBH.mjs → status-CyecXzN4.mjs} +4 -2
  133. package/dist/{status-D1F5XHae.mjs → status-RpVyPEty.mjs} +4 -2
  134. package/dist/stop-BRuF_Cg1.mjs +81 -0
  135. package/dist/summary-CpEOiOlZ.mjs +41 -0
  136. package/dist/sync-schema-4Cl4h8Jn.mjs +43 -0
  137. package/dist/table-BeMWuvzO.mjs +19 -0
  138. package/dist/{table-Cfk7oSvw.mjs → table-jljEqZ0R.mjs} +22 -9
  139. package/dist/transform-DwRc-w6y.mjs +24 -0
  140. package/dist/{transform-B5uRpg1G.mjs → transform-IEX4Mx3X.mjs} +56 -2
  141. package/dist/transform-job-BigWrctt.mjs +19 -0
  142. package/dist/{transform-job-C7QXWTVE.mjs → transform-job-Csr86muI.mjs} +7 -0
  143. package/dist/translate-DqLlXXUx.mjs +111 -0
  144. package/dist/tree-BT24nkLM.mjs +32 -0
  145. package/dist/update-BCXKQi2n.mjs +52 -0
  146. package/dist/{update-CL8tRbxr.mjs → update-BXbLmC2b.mjs} +9 -7
  147. package/dist/update-C1Frz9GR.mjs +52 -0
  148. package/dist/update-C5goGhNr.mjs +56 -0
  149. package/dist/update-CCOyB0iT.mjs +73 -0
  150. package/dist/update-D04NMueX.mjs +59 -0
  151. package/dist/update-D6WVtNV1.mjs +57 -0
  152. package/dist/update-DFR46LsB.mjs +56 -0
  153. package/dist/update-DyLItrpV.mjs +56 -0
  154. package/dist/update-dashcard-av0_PYeg.mjs +71 -0
  155. package/dist/update-mrgvQF4i.mjs +51 -0
  156. package/dist/url-x4wn_l3k.mjs +54 -0
  157. package/dist/uuid-BZHbti8B.mjs +47 -0
  158. package/dist/validate-DCYx6jdL.mjs +1496 -0
  159. package/dist/validate-query-B07oGG4K.mjs +37 -0
  160. package/dist/values-Be6i0Fs9.mjs +36 -0
  161. package/dist/{wait-Bugr9eXD.mjs → wait-BMqQD8k_.mjs} +10 -8
  162. package/dist/wait-CWizX_sR.mjs +19 -0
  163. package/dist/wait-flags-DO3ar2tf.mjs +35 -0
  164. package/dist/workspace-CG1xyJ86.mjs +24 -0
  165. package/dist/workspace-DVuqKJGG.mjs +72 -0
  166. package/dist/workspace-credentials-B6BL-X0d.mjs +139 -0
  167. package/package.json +7 -1
  168. package/dist/auth-BF7IjZIH.mjs +0 -18
  169. package/dist/card-_Ta7zdYe.mjs +0 -19
  170. package/dist/create-CI2Cunq5.mjs +0 -38
  171. package/dist/create-DdbU3TLX.mjs +0 -42
  172. package/dist/database-PA9Goi25.mjs +0 -33
  173. package/dist/db-DMghzgb6.mjs +0 -17
  174. package/dist/field-C8IVs6rp.mjs +0 -76
  175. package/dist/field-DaYo_90x.mjs +0 -13
  176. package/dist/get-Cwpj7lDe.mjs +0 -35
  177. package/dist/get-Dh_acl8q.mjs +0 -34
  178. package/dist/is-dirty-DpKn9HJp.mjs +0 -8
  179. package/dist/list-CBSBHtK-.mjs +0 -38
  180. package/dist/parse-id-BhmmfyCP.mjs +0 -14
  181. package/dist/sync-BPyGXfUk.mjs +0 -26
  182. package/dist/table-D7nJt7JO.mjs +0 -16
  183. package/dist/transform-UbyewMxY.mjs +0 -21
  184. package/dist/transform-job-CrYkr-Ma.mjs +0 -19
  185. package/dist/update-DU2oU2j-.mjs +0 -49
  186. /package/dist/{body-flags-BUA9XV1u.mjs → body-flags-BK7J6Daz.mjs} +0 -0
  187. /package/dist/{setting-26ckqHAP.mjs → setting-CTaAeMci.mjs} +0 -0
@@ -0,0 +1,48 @@
1
+ import "./package-DBsS7a5x.mjs";
2
+ import "./command-augment-D9pI9Vbh.mjs";
3
+ import { renderItem } from "./render-DXv-D6fU.mjs";
4
+ import "./predicates-DiIiS3k7.mjs";
5
+ import "./input-ikCiip6x.mjs";
6
+ import { connectionFlags, defineMetabaseCommand, outputFlags, profileFlag } from "./runtime-D7jihh81.mjs";
7
+ import { readBody } from "./body-DRBgxS6-.mjs";
8
+ import { bodyInputFlags } from "./body-flags-BK7J6Daz.mjs";
9
+ import "./validate-DCYx6jdL.mjs";
10
+ import { TRANSFORM_SOURCE_QUERY_LABELS, preflightMbql5Query, skipValidateFlag } from "./validate-query-B07oGG4K.mjs";
11
+ import { Transform, TransformCreateInput, transformView } from "./transform-IEX4Mx3X.mjs";
12
+
13
+ //#region src/commands/transform/create.ts
14
+ var create_default = defineMetabaseCommand({
15
+ meta: {
16
+ name: "create",
17
+ description: "Create a transform; if source.type is `query` and source.query is MBQL 5 (lib/type: mbql/query) it is pre-flight-validated against the same schema as `metabase query` (see `metabase query --print-schema`)"
18
+ },
19
+ args: {
20
+ ...outputFlags,
21
+ ...profileFlag,
22
+ ...connectionFlags,
23
+ ...bodyInputFlags,
24
+ ...skipValidateFlag
25
+ },
26
+ outputSchema: Transform,
27
+ examples: [
28
+ "cat transform.json | metabase transform create",
29
+ "metabase transform create --file transform.json",
30
+ "metabase transform create --file transform.json --skip-validate"
31
+ ],
32
+ async run({ args, ctx, getClient }) {
33
+ const body = await readBody({
34
+ flag: args.body,
35
+ file: args.file
36
+ }, TransformCreateInput);
37
+ if (body.source.type === "query") preflightMbql5Query(body.source.query, TRANSFORM_SOURCE_QUERY_LABELS, { skip: args["skip-validate"] === true });
38
+ const client = await getClient();
39
+ const created = await client.requestParsed(Transform, "/api/transform", {
40
+ method: "POST",
41
+ body
42
+ });
43
+ renderItem(created, transformView, ctx);
44
+ }
45
+ });
46
+
47
+ //#endregion
48
+ export { create_default as default };
@@ -1,11 +1,13 @@
1
- import "./package-BGfw4ZWJ.mjs";
1
+ import "./package-DBsS7a5x.mjs";
2
2
  import "./command-augment-D9pI9Vbh.mjs";
3
- import { ConfigError, connectionFlags, defineMetabaseCommand, outputFlags, profileFlag, renderItem } from "./runtime-C9CEZhcn.mjs";
4
- import { REMOTE_SYNC_PATHS } from "./poll-task-DbpsiQhl.mjs";
5
- import "./poll-ILanYysl.mjs";
3
+ import { renderItem } from "./render-DXv-D6fU.mjs";
4
+ import { ConfigError } from "./predicates-DiIiS3k7.mjs";
5
+ import { connectionFlags, defineMetabaseCommand, outputFlags, profileFlag } from "./runtime-D7jihh81.mjs";
6
+ import { REMOTE_SYNC_PATHS } from "./poll-task-2Ckiwp8U.mjs";
7
+ import "./poll-DMmmZWvi.mjs";
6
8
  import { z } from "zod";
7
9
 
8
- //#region src/commands/sync/create-branch.ts
10
+ //#region src/commands/git-sync/create-branch.ts
9
11
  const CreateBranchResult = z.object({
10
12
  status: z.literal("success"),
11
13
  message: z.string()
@@ -23,7 +25,7 @@ const createBranchView = {
23
25
  var create_branch_default = defineMetabaseCommand({
24
26
  meta: {
25
27
  name: "create-branch",
26
- description: "Create a new branch on the git remote and switch sync to it"
28
+ description: "Create a new branch on the git remote and switch git-sync to it"
27
29
  },
28
30
  args: {
29
31
  ...outputFlags,
@@ -36,7 +38,7 @@ var create_branch_default = defineMetabaseCommand({
36
38
  }
37
39
  },
38
40
  outputSchema: CreateBranchResult,
39
- examples: ["metabase sync create-branch feat/dashboards", "metabase sync create-branch feat/x --json"],
41
+ examples: ["metabase git-sync create-branch feat/dashboards", "metabase git-sync create-branch feat/x --json"],
40
42
  async run({ args, ctx, getClient }) {
41
43
  const name = args.name.trim();
42
44
  if (name === "") throw new ConfigError("invalid name: branch name must not be blank");
@@ -0,0 +1,85 @@
1
+ import "./package-DBsS7a5x.mjs";
2
+ import "./command-augment-D9pI9Vbh.mjs";
3
+ import { renderItem } from "./render-DXv-D6fU.mjs";
4
+ import "./predicates-DiIiS3k7.mjs";
5
+ import { defineMetabaseCommand, localUrl, outputFlags, parseJson } from "./runtime-D7jihh81.mjs";
6
+ import { parseId } from "./parse-id-BUOZQqjp.mjs";
7
+ import "./poll-DMmmZWvi.mjs";
8
+ import { checkDockerReady, readContainerCredentialsFile, requireWorkspaceContainerLocation } from "./docker-D-ieBsP7.mjs";
9
+ import { WorkspaceCredentials } from "./workspace-credentials-B6BL-X0d.mjs";
10
+ import { z } from "zod";
11
+
12
+ //#region src/commands/workspace/credentials.ts
13
+ const WorkspaceCredentialsResult = z.object({
14
+ workspace_id: z.number().int().positive(),
15
+ url: z.string(),
16
+ email: z.string(),
17
+ password: z.string(),
18
+ api_key_name: z.string(),
19
+ api_key: z.string()
20
+ });
21
+ const credentialsView = {
22
+ compactPick: WorkspaceCredentialsResult,
23
+ tableColumns: [
24
+ {
25
+ key: "workspace_id",
26
+ label: "ID"
27
+ },
28
+ {
29
+ key: "url",
30
+ label: "URL"
31
+ },
32
+ {
33
+ key: "email",
34
+ label: "Email"
35
+ },
36
+ {
37
+ key: "password",
38
+ label: "Password"
39
+ },
40
+ {
41
+ key: "api_key_name",
42
+ label: "API Key Name"
43
+ },
44
+ {
45
+ key: "api_key",
46
+ label: "API Key"
47
+ }
48
+ ]
49
+ };
50
+ const textDecoder = new TextDecoder("utf-8");
51
+ var credentials_default = defineMetabaseCommand({
52
+ meta: {
53
+ name: "credentials",
54
+ description: "Read the workspace child instance's admin credentials (email + password + API key) from the running container"
55
+ },
56
+ args: {
57
+ ...outputFlags,
58
+ id: {
59
+ type: "positional",
60
+ description: "Workspace id",
61
+ required: true
62
+ }
63
+ },
64
+ outputSchema: WorkspaceCredentialsResult,
65
+ examples: ["metabase workspace credentials 1", "metabase workspace credentials 1 --json"],
66
+ async run({ args, ctx }) {
67
+ const workspaceId = parseId(args.id);
68
+ await checkDockerReady();
69
+ const { containerName, hostPort } = await requireWorkspaceContainerLocation(workspaceId);
70
+ const bytes = await readContainerCredentialsFile(workspaceId);
71
+ const credentials = parseJson(textDecoder.decode(bytes), WorkspaceCredentials, { source: `${containerName}:credentials.json` });
72
+ const result = {
73
+ workspace_id: workspaceId,
74
+ url: localUrl(hostPort),
75
+ email: credentials.user.email,
76
+ password: credentials.user.password,
77
+ api_key_name: credentials.api_key.name,
78
+ api_key: credentials.api_key.key
79
+ };
80
+ renderItem(result, credentialsView, ctx);
81
+ }
82
+ });
83
+
84
+ //#endregion
85
+ export { credentials_default as default };
@@ -1,15 +1,17 @@
1
- import "./package-BGfw4ZWJ.mjs";
1
+ import "./package-DBsS7a5x.mjs";
2
2
  import "./command-augment-D9pI9Vbh.mjs";
3
- import { connectionFlags, defineMetabaseCommand, outputFlags, profileFlag, renderItem } from "./runtime-C9CEZhcn.mjs";
4
- import { SyncTaskOrIdle, fetchCurrentTask, syncTaskIdleView, syncTaskView } from "./poll-task-DbpsiQhl.mjs";
5
- import "./poll-ILanYysl.mjs";
3
+ import { renderItem } from "./render-DXv-D6fU.mjs";
4
+ import "./predicates-DiIiS3k7.mjs";
5
+ import { connectionFlags, defineMetabaseCommand, outputFlags, profileFlag } from "./runtime-D7jihh81.mjs";
6
+ import { SyncTaskOrIdle, fetchCurrentTask, syncTaskIdleView, syncTaskView } from "./poll-task-2Ckiwp8U.mjs";
7
+ import "./poll-DMmmZWvi.mjs";
6
8
 
7
- //#region src/commands/sync/current-task.ts
9
+ //#region src/commands/git-sync/current-task.ts
8
10
  const CurrentTaskResult = SyncTaskOrIdle;
9
11
  var current_task_default = defineMetabaseCommand({
10
12
  meta: {
11
13
  name: "current-task",
12
- description: "Get the most recent sync task (or idle if none)"
14
+ description: "Get the most recent git-sync task (or idle if none)"
13
15
  },
14
16
  args: {
15
17
  ...outputFlags,
@@ -17,7 +19,7 @@ var current_task_default = defineMetabaseCommand({
17
19
  ...connectionFlags
18
20
  },
19
21
  outputSchema: CurrentTaskResult,
20
- examples: ["metabase sync current-task", "metabase sync current-task --json"],
22
+ examples: ["metabase git-sync current-task", "metabase git-sync current-task --json"],
21
23
  async run({ ctx, getClient }) {
22
24
  const client = await getClient();
23
25
  const task = await fetchCurrentTask(client);
@@ -0,0 +1,20 @@
1
+ import { defineCommand } from "citty";
2
+
3
+ //#region src/commands/dashboard/index.ts
4
+ var dashboard_default = defineCommand({
5
+ meta: {
6
+ name: "dashboard",
7
+ description: "Manage Metabase dashboards"
8
+ },
9
+ subCommands: {
10
+ list: () => import("./list-BqdNQ1nU.mjs").then((mod) => mod.default),
11
+ get: () => import("./get-Cq5U_Eep.mjs").then((mod) => mod.default),
12
+ cards: () => import("./cards-CILfMPUP.mjs").then((mod) => mod.default),
13
+ create: () => import("./create-CeIi_QLj.mjs").then((mod) => mod.default),
14
+ update: () => import("./update-D6WVtNV1.mjs").then((mod) => mod.default),
15
+ "update-dashcard": () => import("./update-dashcard-av0_PYeg.mjs").then((mod) => mod.default)
16
+ }
17
+ });
18
+
19
+ //#endregion
20
+ export { dashboard_default as default };
@@ -0,0 +1,163 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/domain/dashboard.ts
4
+ const DashboardWidth = z.enum(["fixed", "full"]);
5
+ const Dashcard = z.object({
6
+ id: z.number().int(),
7
+ dashboard_id: z.number().int(),
8
+ card_id: z.number().int().nullable(),
9
+ dashboard_tab_id: z.number().int().nullable(),
10
+ row: z.number().int(),
11
+ col: z.number().int(),
12
+ size_x: z.number().int(),
13
+ size_y: z.number().int(),
14
+ entity_id: z.string().nullable(),
15
+ visualization_settings: z.unknown(),
16
+ parameter_mappings: z.array(z.unknown()).nullable(),
17
+ inline_parameters: z.array(z.string()).nullable()
18
+ }).loose();
19
+ const DashcardCompact = Dashcard.pick({
20
+ id: true,
21
+ dashboard_id: true,
22
+ card_id: true,
23
+ dashboard_tab_id: true,
24
+ row: true,
25
+ col: true,
26
+ size_x: true,
27
+ size_y: true
28
+ }).strip();
29
+ const dashcardView = {
30
+ compactPick: DashcardCompact,
31
+ tableColumns: [
32
+ {
33
+ key: "id",
34
+ label: "ID"
35
+ },
36
+ {
37
+ key: "card_id",
38
+ label: "Card"
39
+ },
40
+ {
41
+ key: "dashboard_tab_id",
42
+ label: "Tab"
43
+ },
44
+ {
45
+ key: "row",
46
+ label: "Row"
47
+ },
48
+ {
49
+ key: "col",
50
+ label: "Col"
51
+ },
52
+ {
53
+ key: "size_x",
54
+ label: "W"
55
+ },
56
+ {
57
+ key: "size_y",
58
+ label: "H"
59
+ }
60
+ ]
61
+ };
62
+ const DashboardTab = z.object({
63
+ id: z.number().int(),
64
+ dashboard_id: z.number().int(),
65
+ name: z.string(),
66
+ position: z.number().int().optional(),
67
+ entity_id: z.string().nullable().optional()
68
+ }).loose();
69
+ const DashboardTabCompact = DashboardTab.pick({
70
+ id: true,
71
+ dashboard_id: true,
72
+ name: true,
73
+ position: true
74
+ }).strip();
75
+ const Dashboard = z.object({
76
+ id: z.number().int(),
77
+ name: z.string(),
78
+ description: z.string().nullable(),
79
+ archived: z.boolean(),
80
+ collection_id: z.number().int().nullable(),
81
+ creator_id: z.number().int(),
82
+ entity_id: z.string().nullable(),
83
+ width: DashboardWidth,
84
+ auto_apply_filters: z.boolean(),
85
+ enable_embedding: z.boolean(),
86
+ public_uuid: z.string().nullable(),
87
+ cache_ttl: z.number().int().nullable(),
88
+ parameters: z.array(z.unknown()).nullable(),
89
+ dashcards: z.array(Dashcard).optional(),
90
+ tabs: z.array(DashboardTab).optional()
91
+ }).loose();
92
+ const DashboardDetail = Dashboard.extend({
93
+ dashcards: z.array(Dashcard),
94
+ tabs: z.array(DashboardTab)
95
+ });
96
+ const DashboardCompact = Dashboard.pick({
97
+ id: true,
98
+ name: true,
99
+ description: true,
100
+ archived: true,
101
+ collection_id: true
102
+ }).strip().extend({
103
+ dashcards: z.array(DashcardCompact).optional(),
104
+ tabs: z.array(DashboardTabCompact).optional()
105
+ });
106
+ const dashboardView = {
107
+ compactPick: DashboardCompact,
108
+ tableColumns: [
109
+ {
110
+ key: "id",
111
+ label: "ID"
112
+ },
113
+ {
114
+ key: "name",
115
+ label: "Name"
116
+ },
117
+ {
118
+ key: "collection_id",
119
+ label: "Collection"
120
+ },
121
+ {
122
+ key: "archived",
123
+ label: "Archived"
124
+ }
125
+ ]
126
+ };
127
+ const DashboardCreateInput = z.object({
128
+ name: z.string().min(1),
129
+ description: z.string().nullable().optional(),
130
+ parameters: z.array(z.unknown()).optional(),
131
+ cache_ttl: z.number().int().positive().optional(),
132
+ collection_id: z.number().int().positive().nullable().optional(),
133
+ collection_position: z.number().int().positive().nullable().optional(),
134
+ dashcards: z.array(z.unknown()).optional(),
135
+ tabs: z.array(DashboardTab.partial()).optional()
136
+ }).loose();
137
+ const DashboardUpdateInput = z.object({
138
+ name: z.string().min(1).optional(),
139
+ description: z.string().nullable().optional(),
140
+ archived: z.boolean().optional(),
141
+ width: DashboardWidth.optional(),
142
+ enable_embedding: z.boolean().optional(),
143
+ embedding_params: z.unknown().optional(),
144
+ parameters: z.array(z.unknown()).optional(),
145
+ cache_ttl: z.number().int().positive().nullable().optional(),
146
+ collection_id: z.number().int().positive().nullable().optional(),
147
+ collection_position: z.number().int().positive().nullable().optional(),
148
+ dashcards: z.array(z.unknown()).optional(),
149
+ tabs: z.array(DashboardTab.partial()).optional()
150
+ }).loose();
151
+ const DashcardPatchInput = z.object({
152
+ row: z.number().int().nonnegative().optional(),
153
+ col: z.number().int().nonnegative().optional(),
154
+ size_x: z.number().int().positive().optional(),
155
+ size_y: z.number().int().positive().optional(),
156
+ dashboard_tab_id: z.number().int().nullable().optional(),
157
+ parameter_mappings: z.array(z.unknown()).optional(),
158
+ inline_parameters: z.array(z.string()).optional(),
159
+ visualization_settings: z.unknown().optional()
160
+ }).strict().refine((value) => Object.keys(value).length > 0, { message: "patch must contain at least one field" });
161
+
162
+ //#endregion
163
+ export { Dashboard, DashboardCompact, DashboardCreateInput, DashboardDetail, DashboardUpdateInput, Dashcard, DashcardCompact, DashcardPatchInput, dashboardView, dashcardView };
@@ -0,0 +1,17 @@
1
+ import { defineCommand } from "citty";
2
+
3
+ //#region src/commands/workspace/database/index.ts
4
+ var database_default = defineCommand({
5
+ meta: {
6
+ name: "database",
7
+ description: "Manage databases provisioned to a workspace"
8
+ },
9
+ subCommands: {
10
+ provision: () => import("./provision-BUgWJWAV.mjs").then((mod) => mod.default),
11
+ update: () => import("./update-CCOyB0iT.mjs").then((mod) => mod.default),
12
+ deprovision: () => import("./deprovision-Bsc1S15j.mjs").then((mod) => mod.default)
13
+ }
14
+ });
15
+
16
+ //#endregion
17
+ export { database_default as default };
@@ -0,0 +1,51 @@
1
+ import { Table } from "./table-jljEqZ0R.mjs";
2
+ import { z } from "zod";
3
+
4
+ //#region src/domain/database.ts
5
+ const Database = z.object({
6
+ id: z.number().int(),
7
+ name: z.string(),
8
+ engine: z.string().optional(),
9
+ is_saved_questions: z.boolean().optional(),
10
+ tables: z.array(Table).optional()
11
+ }).loose();
12
+ const DatabaseCompact = Database.pick({
13
+ id: true,
14
+ name: true,
15
+ engine: true,
16
+ is_saved_questions: true
17
+ }).strip();
18
+ const databaseView = {
19
+ compactPick: DatabaseCompact,
20
+ tableColumns: [
21
+ {
22
+ key: "id",
23
+ label: "ID"
24
+ },
25
+ {
26
+ key: "name",
27
+ label: "Name"
28
+ },
29
+ {
30
+ key: "engine",
31
+ label: "Engine"
32
+ }
33
+ ]
34
+ };
35
+ const DatabaseSyncResult = z.object({
36
+ id: z.number().int(),
37
+ status: z.literal("ok")
38
+ });
39
+ const databaseSyncResultView = {
40
+ compactPick: DatabaseSyncResult,
41
+ tableColumns: [{
42
+ key: "id",
43
+ label: "Database"
44
+ }, {
45
+ key: "status",
46
+ label: "Status"
47
+ }]
48
+ };
49
+
50
+ //#endregion
51
+ export { Database, DatabaseCompact, DatabaseSyncResult, databaseSyncResultView, databaseView };
@@ -0,0 +1,22 @@
1
+ import { defineCommand } from "citty";
2
+
3
+ //#region src/commands/db/index.ts
4
+ var db_default = defineCommand({
5
+ meta: {
6
+ name: "db",
7
+ description: "Inspect Metabase databases",
8
+ alias: "database"
9
+ },
10
+ subCommands: {
11
+ list: () => import("./list-DLlq3FyS.mjs").then((m) => m.default),
12
+ get: () => import("./get-YCnVqq-z.mjs").then((m) => m.default),
13
+ metadata: () => import("./metadata-T-fNUWg_.mjs").then((m) => m.default),
14
+ schemas: () => import("./schemas-DlNpbn4H.mjs").then((m) => m.default),
15
+ "schema-tables": () => import("./schema-tables-BCJT2DM_.mjs").then((m) => m.default),
16
+ "sync-schema": () => import("./sync-schema-4Cl4h8Jn.mjs").then((m) => m.default),
17
+ "rescan-values": () => import("./rescan-values-CcB4F9qa.mjs").then((m) => m.default)
18
+ }
19
+ });
20
+
21
+ //#endregion
22
+ export { db_default as default };
@@ -1,9 +1,11 @@
1
- import "./package-BGfw4ZWJ.mjs";
1
+ import "./package-DBsS7a5x.mjs";
2
2
  import "./command-augment-D9pI9Vbh.mjs";
3
- import { connectionFlags, defineMetabaseCommand, outputFlags, profileFlag } from "./runtime-C9CEZhcn.mjs";
4
- import "./prompt-DpT8yAVy.mjs";
5
- import { parseId } from "./parse-id-BhmmfyCP.mjs";
6
- import { DeleteResult, confirmAndDelete } from "./delete-runtime-Byr60cR3.mjs";
3
+ import "./render-DXv-D6fU.mjs";
4
+ import "./predicates-DiIiS3k7.mjs";
5
+ import { connectionFlags, defineMetabaseCommand, outputFlags, profileFlag } from "./runtime-D7jihh81.mjs";
6
+ import { parseId } from "./parse-id-BUOZQqjp.mjs";
7
+ import "./prompt-Bf3DQ-qE.mjs";
8
+ import { DeleteResult, confirmAndDelete } from "./delete-runtime-BMzvfj_B.mjs";
7
9
 
8
10
  //#region src/commands/transform/delete.ts
9
11
  var delete_default = defineMetabaseCommand({
@@ -1,9 +1,11 @@
1
- import "./package-BGfw4ZWJ.mjs";
1
+ import "./package-DBsS7a5x.mjs";
2
2
  import "./command-augment-D9pI9Vbh.mjs";
3
- import { connectionFlags, defineMetabaseCommand, outputFlags, profileFlag } from "./runtime-C9CEZhcn.mjs";
4
- import "./prompt-DpT8yAVy.mjs";
5
- import { parseId } from "./parse-id-BhmmfyCP.mjs";
6
- import { DeleteResult, confirmAndDelete } from "./delete-runtime-Byr60cR3.mjs";
3
+ import "./render-DXv-D6fU.mjs";
4
+ import "./predicates-DiIiS3k7.mjs";
5
+ import { connectionFlags, defineMetabaseCommand, outputFlags, profileFlag } from "./runtime-D7jihh81.mjs";
6
+ import { parseId } from "./parse-id-BUOZQqjp.mjs";
7
+ import "./prompt-Bf3DQ-qE.mjs";
8
+ import { DeleteResult, confirmAndDelete } from "./delete-runtime-BMzvfj_B.mjs";
7
9
 
8
10
  //#region src/commands/transform-job/delete.ts
9
11
  var delete_default = defineMetabaseCommand({
@@ -1,5 +1,5 @@
1
- import { ConfigError, renderItem } from "./runtime-C9CEZhcn.mjs";
2
- import { promptConfirm } from "./prompt-DpT8yAVy.mjs";
1
+ import { renderItem } from "./render-DXv-D6fU.mjs";
2
+ import { promptConfirm } from "./prompt-Bf3DQ-qE.mjs";
3
3
  import { z } from "zod";
4
4
 
5
5
  //#region src/commands/delete-runtime.ts
@@ -26,8 +26,7 @@ const deleteResultView = {
26
26
  ]
27
27
  };
28
28
  async function confirmAndDelete(args) {
29
- if (!args.yes) {
30
- if (!process.stdin.isTTY) throw new ConfigError("--yes required to delete non-interactively");
29
+ if (!args.yes && process.stdin.isTTY === true) {
31
30
  const ok = await promptConfirm({
32
31
  message: args.promptMessage,
33
32
  initialValue: false
@@ -45,6 +44,7 @@ async function confirmAndDelete(args) {
45
44
  method: "DELETE",
46
45
  expectContentType: "binary"
47
46
  });
47
+ if (args.afterDelete) await args.afterDelete();
48
48
  renderItem({
49
49
  deleted: true,
50
50
  aborted: false,
@@ -1,9 +1,11 @@
1
- import "./package-BGfw4ZWJ.mjs";
1
+ import "./package-DBsS7a5x.mjs";
2
2
  import "./command-augment-D9pI9Vbh.mjs";
3
- import { connectionFlags, defineMetabaseCommand, outputFlags, profileFlag } from "./runtime-C9CEZhcn.mjs";
4
- import "./prompt-DpT8yAVy.mjs";
5
- import { parseId } from "./parse-id-BhmmfyCP.mjs";
6
- import { DeleteResult, confirmAndDelete } from "./delete-runtime-Byr60cR3.mjs";
3
+ import "./render-DXv-D6fU.mjs";
4
+ import "./predicates-DiIiS3k7.mjs";
5
+ import { connectionFlags, defineMetabaseCommand, outputFlags, profileFlag } from "./runtime-D7jihh81.mjs";
6
+ import { parseId } from "./parse-id-BUOZQqjp.mjs";
7
+ import "./prompt-Bf3DQ-qE.mjs";
8
+ import { DeleteResult, confirmAndDelete } from "./delete-runtime-BMzvfj_B.mjs";
7
9
 
8
10
  //#region src/commands/transform/delete-table.ts
9
11
  var delete_table_default = defineMetabaseCommand({
@@ -0,0 +1,61 @@
1
+ import "./package-DBsS7a5x.mjs";
2
+ import "./command-augment-D9pI9Vbh.mjs";
3
+ import "./render-DXv-D6fU.mjs";
4
+ import "./predicates-DiIiS3k7.mjs";
5
+ import { connectionFlags, defineMetabaseCommand, outputFlags, profileFlag } from "./runtime-D7jihh81.mjs";
6
+ import { parseId } from "./parse-id-BUOZQqjp.mjs";
7
+ import "./prompt-Bf3DQ-qE.mjs";
8
+ import "./poll-DMmmZWvi.mjs";
9
+ import { DeleteResult, confirmAndDelete } from "./delete-runtime-BMzvfj_B.mjs";
10
+ import { parseWaitFlags, waitFlags } from "./wait-flags-DO3ar2tf.mjs";
11
+ import "./workspace-DVuqKJGG.mjs";
12
+ import { waitForDatabaseGone } from "./wait-CWizX_sR.mjs";
13
+
14
+ //#region src/commands/workspace/database/deprovision.ts
15
+ var deprovision_default = defineMetabaseCommand({
16
+ meta: {
17
+ name: "deprovision",
18
+ description: "Deprovision a database from a workspace"
19
+ },
20
+ args: {
21
+ ...outputFlags,
22
+ ...profileFlag,
23
+ ...connectionFlags,
24
+ ...waitFlags,
25
+ yes: {
26
+ type: "boolean",
27
+ description: "Skip confirmation",
28
+ default: false
29
+ },
30
+ id: {
31
+ type: "positional",
32
+ description: "Workspace id",
33
+ required: true
34
+ },
35
+ "db-id": {
36
+ type: "positional",
37
+ description: "Database id",
38
+ required: true
39
+ }
40
+ },
41
+ outputSchema: DeleteResult,
42
+ examples: ["metabase workspace database deprovision 1 5 --yes", "metabase workspace database deprovision 1 5 --yes --wait"],
43
+ async run({ args, ctx, getClient }) {
44
+ const workspaceId = parseId(args.id);
45
+ const databaseId = parseId(args["db-id"], "db-id");
46
+ const wait = parseWaitFlags(args);
47
+ const client = await getClient();
48
+ await confirmAndDelete({
49
+ id: databaseId,
50
+ path: `/api/ee/workspace-manager/${workspaceId}/database/${databaseId}`,
51
+ yes: args.yes,
52
+ promptMessage: `Deprovision database ${databaseId} from workspace ${workspaceId}?`,
53
+ client,
54
+ ctx,
55
+ ...wait.enabled ? { afterDelete: () => waitForDatabaseGone(client, workspaceId, databaseId, wait.schedule) } : {}
56
+ });
57
+ }
58
+ });
59
+
60
+ //#endregion
61
+ export { deprovision_default as default };
@@ -1,11 +1,13 @@
1
- import "./package-BGfw4ZWJ.mjs";
1
+ import "./package-DBsS7a5x.mjs";
2
2
  import "./command-augment-D9pI9Vbh.mjs";
3
- import { connectionFlags, defineMetabaseCommand, listEnvelopeSchema, outputFlags, profileFlag, renderList, wrapList } from "./runtime-C9CEZhcn.mjs";
4
- import { REMOTE_SYNC_PATHS, SyncDirtyItem, SyncDirtyItemCompact, syncDirtyItemView } from "./poll-task-DbpsiQhl.mjs";
5
- import "./poll-ILanYysl.mjs";
3
+ import { renderList } from "./render-DXv-D6fU.mjs";
4
+ import "./predicates-DiIiS3k7.mjs";
5
+ import { connectionFlags, defineMetabaseCommand, listEnvelopeSchema, outputFlags, profileFlag, wrapList } from "./runtime-D7jihh81.mjs";
6
+ import { REMOTE_SYNC_PATHS, SyncDirtyItem, SyncDirtyItemCompact, syncDirtyItemView } from "./poll-task-2Ckiwp8U.mjs";
7
+ import "./poll-DMmmZWvi.mjs";
6
8
  import { z } from "zod";
7
9
 
8
- //#region src/commands/sync/dirty.ts
10
+ //#region src/commands/git-sync/dirty.ts
9
11
  const SyncDirtyApiResponse = z.object({ dirty: z.array(SyncDirtyItem) });
10
12
  const SyncDirtyListEnvelope = listEnvelopeSchema(SyncDirtyItemCompact);
11
13
  var dirty_default = defineMetabaseCommand({
@@ -19,7 +21,7 @@ var dirty_default = defineMetabaseCommand({
19
21
  ...connectionFlags
20
22
  },
21
23
  outputSchema: SyncDirtyListEnvelope,
22
- examples: ["metabase sync dirty", "metabase sync dirty --json"],
24
+ examples: ["metabase git-sync dirty", "metabase git-sync dirty --json"],
23
25
  async run({ ctx, getClient }) {
24
26
  const client = await getClient();
25
27
  const response = await client.requestParsed(SyncDirtyApiResponse, REMOTE_SYNC_PATHS.dirty);