@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,163 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/domain/collection.ts
4
+ const CollectionId = z.union([z.number().int(), z.string()]);
5
+ const CollectionAuthorityLevel = z.enum(["official"]);
6
+ const CollectionType = z.enum([
7
+ "instance-analytics",
8
+ "trash",
9
+ "library",
10
+ "library-data",
11
+ "library-metrics",
12
+ "tenant-specific-root-collection"
13
+ ]);
14
+ const CollectionNamespace = z.string().min(1);
15
+ const COLLECTION_ITEM_FILTER_MODELS = [
16
+ "card",
17
+ "dataset",
18
+ "metric",
19
+ "dashboard",
20
+ "snippet",
21
+ "collection",
22
+ "document",
23
+ "table",
24
+ "transform",
25
+ "measure",
26
+ "pulse",
27
+ "timeline",
28
+ "no_models"
29
+ ];
30
+ const CollectionItemFilterModel = z.enum(COLLECTION_ITEM_FILTER_MODELS);
31
+ const COLLECTION_ITEM_MODELS = [...COLLECTION_ITEM_FILTER_MODELS, "indexed-entity"];
32
+ const CollectionItemModel = z.enum(COLLECTION_ITEM_MODELS);
33
+ const COLLECTION_PINNED_STATES = [
34
+ "all",
35
+ "is_pinned",
36
+ "is_not_pinned"
37
+ ];
38
+ const CollectionPinnedState = z.enum(COLLECTION_PINNED_STATES);
39
+ const Collection = z.object({
40
+ id: CollectionId,
41
+ name: z.string(),
42
+ description: z.string().nullable().optional(),
43
+ archived: z.boolean().optional(),
44
+ location: z.string().nullable().optional(),
45
+ parent_id: CollectionId.nullable().optional(),
46
+ personal_owner_id: z.number().int().nullable().optional(),
47
+ is_personal: z.boolean().optional(),
48
+ authority_level: CollectionAuthorityLevel.nullable().optional(),
49
+ type: CollectionType.nullable().optional(),
50
+ namespace: CollectionNamespace.nullable().optional(),
51
+ entity_id: z.string().nullable().optional(),
52
+ slug: z.string().optional(),
53
+ can_write: z.boolean().optional()
54
+ }).loose();
55
+ const CollectionCompact = Collection.pick({
56
+ id: true,
57
+ name: true,
58
+ description: true,
59
+ archived: true,
60
+ location: true,
61
+ parent_id: true,
62
+ type: true,
63
+ authority_level: true,
64
+ is_personal: true
65
+ }).strip();
66
+ const collectionView = {
67
+ compactPick: CollectionCompact,
68
+ tableColumns: [
69
+ {
70
+ key: "id",
71
+ label: "ID"
72
+ },
73
+ {
74
+ key: "name",
75
+ label: "Name"
76
+ },
77
+ {
78
+ key: "location",
79
+ label: "Location"
80
+ },
81
+ {
82
+ key: "type",
83
+ label: "Type"
84
+ },
85
+ {
86
+ key: "authority_level",
87
+ label: "Authority"
88
+ },
89
+ {
90
+ key: "archived",
91
+ label: "Archived"
92
+ }
93
+ ]
94
+ };
95
+ const CollectionItem = z.object({
96
+ id: z.number().int(),
97
+ model: CollectionItemModel,
98
+ name: z.string(),
99
+ description: z.string().nullable().optional(),
100
+ archived: z.boolean().nullable(),
101
+ collection_id: CollectionId.nullable().optional(),
102
+ collection_position: z.number().int().nullable().optional(),
103
+ display: z.string().nullable().optional(),
104
+ location: z.string().nullable().optional(),
105
+ entity_id: z.string().nullable().optional(),
106
+ database_id: z.number().int().nullable().optional(),
107
+ dashboard_id: z.number().int().nullable().optional()
108
+ }).loose();
109
+ const CollectionItemCompact = CollectionItem.pick({
110
+ id: true,
111
+ model: true,
112
+ name: true,
113
+ description: true,
114
+ archived: true,
115
+ collection_id: true
116
+ }).strip();
117
+ const collectionItemView = {
118
+ compactPick: CollectionItemCompact,
119
+ tableColumns: [
120
+ {
121
+ key: "id",
122
+ label: "ID"
123
+ },
124
+ {
125
+ key: "model",
126
+ label: "Model"
127
+ },
128
+ {
129
+ key: "name",
130
+ label: "Name"
131
+ },
132
+ {
133
+ key: "collection_id",
134
+ label: "Collection"
135
+ },
136
+ {
137
+ key: "archived",
138
+ label: "Archived"
139
+ }
140
+ ]
141
+ };
142
+ const CollectionTreeNodeBase = z.object({
143
+ id: CollectionId,
144
+ name: z.string(),
145
+ description: z.string().nullable().optional(),
146
+ archived: z.boolean().optional(),
147
+ location: z.string().nullable().optional(),
148
+ type: CollectionType.nullable().optional(),
149
+ authority_level: CollectionAuthorityLevel.nullable().optional(),
150
+ here: z.array(CollectionItemModel).optional(),
151
+ below: z.array(CollectionItemModel).optional()
152
+ }).loose();
153
+ const CollectionTreeNode = CollectionTreeNodeBase.extend({ children: z.lazy(() => z.array(CollectionTreeNode)) });
154
+ const CollectionCreateInput = z.object({
155
+ name: z.string().min(1),
156
+ description: z.string().nullable().optional(),
157
+ parent_id: z.number().int().positive().nullable().optional(),
158
+ namespace: CollectionNamespace.nullable().optional(),
159
+ authority_level: CollectionAuthorityLevel.nullable().optional()
160
+ }).loose();
161
+
162
+ //#endregion
163
+ export { COLLECTION_ITEM_FILTER_MODELS, COLLECTION_PINNED_STATES, Collection, CollectionCompact, CollectionCreateInput, CollectionItem, CollectionItemCompact, CollectionItemFilterModel, CollectionPinnedState, CollectionTreeNode, collectionItemView, collectionView };
@@ -0,0 +1,19 @@
1
+ import { defineCommand } from "citty";
2
+
3
+ //#region src/commands/collection/index.ts
4
+ var collection_default = defineCommand({
5
+ meta: {
6
+ name: "collection",
7
+ description: "Browse Metabase collections"
8
+ },
9
+ subCommands: {
10
+ list: () => import("./list-DdQ4jmUQ.mjs").then((mod) => mod.default),
11
+ get: () => import("./get-D4GUJBiX.mjs").then((mod) => mod.default),
12
+ items: () => import("./items-Cg67tdto.mjs").then((mod) => mod.default),
13
+ tree: () => import("./tree-BT24nkLM.mjs").then((mod) => mod.default),
14
+ create: () => import("./create-3Z6rm-4O.mjs").then((mod) => mod.default)
15
+ }
16
+ });
17
+
18
+ //#endregion
19
+ export { collection_default as default };
@@ -0,0 +1,44 @@
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 { Collection, CollectionCreateInput, collectionView } from "./collection-B3sPXRLs.mjs";
10
+
11
+ //#region src/commands/collection/create.ts
12
+ var create_default = defineMetabaseCommand({
13
+ meta: {
14
+ name: "create",
15
+ description: "Create a collection from a JSON spec"
16
+ },
17
+ args: {
18
+ ...outputFlags,
19
+ ...profileFlag,
20
+ ...connectionFlags,
21
+ ...bodyInputFlags
22
+ },
23
+ outputSchema: Collection,
24
+ examples: [
25
+ "cat collection.json | metabase collection create",
26
+ "metabase collection create --file collection.json",
27
+ "metabase collection create --body '{\"name\":\"My Collection\",\"parent_id\":4}'"
28
+ ],
29
+ async run({ args, ctx, getClient }) {
30
+ const body = await readBody({
31
+ flag: args.body,
32
+ file: args.file
33
+ }, CollectionCreateInput);
34
+ const client = await getClient();
35
+ const created = await client.requestParsed(Collection, "/api/collection", {
36
+ method: "POST",
37
+ body
38
+ });
39
+ renderItem(created, collectionView, ctx);
40
+ }
41
+ });
42
+
43
+ //#endregion
44
+ export { create_default as default };
@@ -0,0 +1,44 @@
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 { Snippet, SnippetCreateInput, snippetView } from "./snippet-Dw0Sjzkr.mjs";
10
+
11
+ //#region src/commands/snippet/create.ts
12
+ var create_default = defineMetabaseCommand({
13
+ meta: {
14
+ name: "create",
15
+ description: "Create a native query snippet from a JSON spec"
16
+ },
17
+ args: {
18
+ ...outputFlags,
19
+ ...profileFlag,
20
+ ...connectionFlags,
21
+ ...bodyInputFlags
22
+ },
23
+ outputSchema: Snippet,
24
+ examples: [
25
+ "cat snippet.json | metabase snippet create",
26
+ "metabase snippet create --file snippet.json",
27
+ "metabase snippet create --body '{\"name\":\"active\",\"content\":\"WHERE active = true\"}'"
28
+ ],
29
+ async run({ args, ctx, getClient }) {
30
+ const body = await readBody({
31
+ flag: args.body,
32
+ file: args.file
33
+ }, SnippetCreateInput);
34
+ const client = await getClient();
35
+ const created = await client.requestParsed(Snippet, "/api/native-query-snippet", {
36
+ method: "POST",
37
+ body
38
+ });
39
+ renderItem(created, snippetView, ctx);
40
+ }
41
+ });
42
+
43
+ //#endregion
44
+ export { create_default as default };
@@ -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 { Workspace, WorkspaceCreateInput, workspaceView } from "./workspace-DVuqKJGG.mjs";
10
+
11
+ //#region src/commands/workspace/create.ts
12
+ var create_default = defineMetabaseCommand({
13
+ meta: {
14
+ name: "create",
15
+ description: "Create a workspace"
16
+ },
17
+ args: {
18
+ ...outputFlags,
19
+ ...profileFlag,
20
+ ...connectionFlags,
21
+ ...bodyInputFlags,
22
+ name: {
23
+ type: "string",
24
+ description: "Workspace name (alternative to --body / --file)"
25
+ }
26
+ },
27
+ outputSchema: Workspace,
28
+ examples: [
29
+ "metabase workspace create --name \"analytics\"",
30
+ "echo '{\"name\":\"analytics\"}' | metabase workspace create",
31
+ "metabase workspace create --file workspace.json"
32
+ ],
33
+ async run({ args, ctx, getClient }) {
34
+ const body = args.name !== void 0 && args.name !== "" ? WorkspaceCreateInput.parse({ name: args.name }) : await readBody({
35
+ flag: args.body,
36
+ file: args.file
37
+ }, WorkspaceCreateInput);
38
+ const client = await getClient();
39
+ const created = await client.requestParsed(Workspace, "/api/ee/workspace-manager", {
40
+ method: "POST",
41
+ body
42
+ });
43
+ renderItem(created, workspaceView, ctx);
44
+ }
45
+ });
46
+
47
+ //#endregion
48
+ export { create_default as default };
@@ -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 { MEASURE_DEFINITION_LABELS, preflightMbql5Query, skipValidateFlag } from "./validate-query-B07oGG4K.mjs";
11
+ import { Measure, MeasureCreateInput, measureView } from "./measure-BEQfnLdN.mjs";
12
+
13
+ //#region src/commands/measure/create.ts
14
+ var create_default = defineMetabaseCommand({
15
+ meta: {
16
+ name: "create",
17
+ description: "Create a measure from a JSON spec; if definition 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: Measure,
27
+ examples: [
28
+ "cat measure.json | metabase measure create",
29
+ "metabase measure create --file measure.json",
30
+ "metabase measure create --file measure.json --skip-validate"
31
+ ],
32
+ async run({ args, ctx, getClient }) {
33
+ const body = await readBody({
34
+ flag: args.body,
35
+ file: args.file
36
+ }, MeasureCreateInput);
37
+ preflightMbql5Query(body.definition, MEASURE_DEFINITION_LABELS, { skip: args["skip-validate"] === true });
38
+ const client = await getClient();
39
+ const created = await client.requestParsed(Measure, "/api/measure", {
40
+ method: "POST",
41
+ body
42
+ });
43
+ renderItem(created, measureView, ctx);
44
+ }
45
+ });
46
+
47
+ //#endregion
48
+ export { create_default as default };
@@ -0,0 +1,125 @@
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 { requireBothOrNeither } from "./flag-pair-DtR1AiBQ.mjs";
10
+ import { parseId } from "./parse-id-BUOZQqjp.mjs";
11
+ import { z } from "zod";
12
+
13
+ //#region src/domain/api-key.ts
14
+ const ApiKeyCreateInput = z.object({
15
+ name: z.string().min(1),
16
+ group_id: z.number().int().positive()
17
+ }).loose();
18
+ const ApiKeyGroup = z.object({
19
+ id: z.number().int().nullable(),
20
+ name: z.string().nullable()
21
+ }).loose();
22
+ const ApiKeyUpdatedBy = z.object({
23
+ id: z.number().int(),
24
+ common_name: z.string().nullable().optional()
25
+ }).loose();
26
+ const ApiKey = z.object({
27
+ id: z.number().int(),
28
+ name: z.string(),
29
+ group: ApiKeyGroup.nullable().optional(),
30
+ unmasked_key: z.string().nullable().optional(),
31
+ masked_key: z.string().nullable().optional(),
32
+ updated_by: ApiKeyUpdatedBy.nullable().optional(),
33
+ created_at: z.string().nullable().optional(),
34
+ updated_at: z.string().nullable().optional()
35
+ }).loose();
36
+ const ApiKeyCompact = ApiKey.pick({
37
+ id: true,
38
+ name: true,
39
+ group: true,
40
+ masked_key: true
41
+ }).strip();
42
+ const apiKeyView = {
43
+ compactPick: ApiKeyCompact,
44
+ tableColumns: [
45
+ {
46
+ key: "id",
47
+ label: "ID"
48
+ },
49
+ {
50
+ key: "name",
51
+ label: "Name"
52
+ },
53
+ {
54
+ key: "group",
55
+ label: "Group",
56
+ format: (value) => formatGroup(value)
57
+ },
58
+ {
59
+ key: "unmasked_key",
60
+ label: "Key"
61
+ }
62
+ ]
63
+ };
64
+ function formatGroup(value) {
65
+ const parsed = ApiKeyGroup.nullable().safeParse(value);
66
+ if (!parsed.success || parsed.data === null) return "";
67
+ const { id, name } = parsed.data;
68
+ if (name === null && id === null) return "";
69
+ if (name === null) return String(id);
70
+ return id === null ? name : `${name} (${id})`;
71
+ }
72
+
73
+ //#endregion
74
+ //#region src/commands/api-key/create.ts
75
+ var create_default = defineMetabaseCommand({
76
+ meta: {
77
+ name: "create",
78
+ description: "Create a new API key"
79
+ },
80
+ args: {
81
+ ...outputFlags,
82
+ ...profileFlag,
83
+ ...connectionFlags,
84
+ ...bodyInputFlags,
85
+ name: {
86
+ type: "string",
87
+ description: "API key name (alternative to --body / --file)"
88
+ },
89
+ "group-id": {
90
+ type: "string",
91
+ description: "Permission group id (alternative to --body / --file)"
92
+ }
93
+ },
94
+ outputSchema: ApiKey,
95
+ examples: [
96
+ "metabase api-key create --name \"deploy-bot\" --group-id 2",
97
+ "echo '{\"name\":\"k\",\"group_id\":2}' | metabase api-key create",
98
+ "metabase api-key create --file key.json"
99
+ ],
100
+ async run({ args, ctx, getClient }) {
101
+ const pair = requireBothOrNeither({
102
+ name: "--name",
103
+ value: args.name
104
+ }, {
105
+ name: "--group-id",
106
+ value: args["group-id"]
107
+ });
108
+ const body = pair ? ApiKeyCreateInput.parse({
109
+ name: pair.first,
110
+ group_id: parseId(pair.second, "--group-id")
111
+ }) : await readBody({
112
+ flag: args.body,
113
+ file: args.file
114
+ }, ApiKeyCreateInput);
115
+ const client = await getClient();
116
+ const created = await client.requestParsed(ApiKey, "/api/api-key", {
117
+ method: "POST",
118
+ body
119
+ });
120
+ renderItem(created, apiKeyView, ctx);
121
+ }
122
+ });
123
+
124
+ //#endregion
125
+ export { create_default as default };
@@ -0,0 +1,66 @@
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 "./field-DciLbuv-.mjs";
10
+ import "./card-CAEZWixN.mjs";
11
+ import "./validate-DCYx6jdL.mjs";
12
+ import { Dashboard, DashboardCreateInput, DashboardDetail, dashboardView } from "./dashboard-CnMD04PQ.mjs";
13
+ import { preflightDashcardCardReferences, wrapChainedDashboardWriteError } from "./preflight-CC_g6EWU.mjs";
14
+
15
+ //#region src/commands/dashboard/create.ts
16
+ var create_default = defineMetabaseCommand({
17
+ meta: {
18
+ name: "create",
19
+ description: "Create a dashboard from a JSON spec; any positive card_id referenced from dashcards is pre-flight-validated against /api/card/:id (exists, not archived) before the dashboard is created"
20
+ },
21
+ args: {
22
+ ...outputFlags,
23
+ ...profileFlag,
24
+ ...connectionFlags,
25
+ ...bodyInputFlags
26
+ },
27
+ outputSchema: Dashboard,
28
+ examples: [
29
+ "cat dashboard.json | metabase dashboard create",
30
+ "metabase dashboard create --file dashboard.json",
31
+ "metabase dashboard create --body '{\"name\":\"My Dashboard\",\"collection_id\":4}'",
32
+ "metabase dashboard create --body '{\"name\":\"D\",\"dashcards\":[{\"id\":-1,\"card_id\":42,\"row\":0,\"col\":0,\"size_x\":12,\"size_y\":6}]}'"
33
+ ],
34
+ async run({ args, ctx, getClient }) {
35
+ const body = await readBody({
36
+ flag: args.body,
37
+ file: args.file
38
+ }, DashboardCreateInput);
39
+ const { dashcards, tabs,...createOnly } = body;
40
+ const client = await getClient();
41
+ await preflightDashcardCardReferences(client, dashcards);
42
+ const created = await client.requestParsed(Dashboard, "/api/dashboard", {
43
+ method: "POST",
44
+ body: createOnly
45
+ });
46
+ if (dashcards === void 0 && tabs === void 0) {
47
+ renderItem(created, dashboardView, ctx);
48
+ return;
49
+ }
50
+ try {
51
+ const updated = await client.requestParsed(DashboardDetail, `/api/dashboard/${created.id}`, {
52
+ method: "PUT",
53
+ body: {
54
+ dashcards,
55
+ tabs
56
+ }
57
+ });
58
+ renderItem(updated, dashboardView, ctx);
59
+ } catch (error) {
60
+ throw wrapChainedDashboardWriteError(error, created.id);
61
+ }
62
+ }
63
+ });
64
+
65
+ //#endregion
66
+ export { create_default as default };
@@ -0,0 +1,50 @@
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 "./field-DciLbuv-.mjs";
10
+ import { Card, CardCreateInput, cardView } from "./card-CAEZWixN.mjs";
11
+ import "./validate-DCYx6jdL.mjs";
12
+ import { CARD_DATASET_QUERY_LABELS, preflightMbql5Query, skipValidateFlag } from "./validate-query-B07oGG4K.mjs";
13
+
14
+ //#region src/commands/card/create.ts
15
+ var create_default = defineMetabaseCommand({
16
+ meta: {
17
+ name: "create",
18
+ description: "Create a card from a JSON spec; if dataset_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`)"
19
+ },
20
+ args: {
21
+ ...outputFlags,
22
+ ...profileFlag,
23
+ ...connectionFlags,
24
+ ...bodyInputFlags,
25
+ ...skipValidateFlag
26
+ },
27
+ outputSchema: Card,
28
+ examples: [
29
+ "cat card.json | metabase card create",
30
+ "metabase card create --file card.json",
31
+ "metabase card create --body '{\"name\":\"x\",\"display\":\"table\",\"dataset_query\":{...},\"visualization_settings\":{}}'",
32
+ "metabase card create --file card.json --skip-validate"
33
+ ],
34
+ async run({ args, ctx, getClient }) {
35
+ const body = await readBody({
36
+ flag: args.body,
37
+ file: args.file
38
+ }, CardCreateInput);
39
+ preflightMbql5Query(body.dataset_query, CARD_DATASET_QUERY_LABELS, { skip: args["skip-validate"] === true });
40
+ const client = await getClient();
41
+ const created = await client.requestParsed(Card, "/api/card", {
42
+ method: "POST",
43
+ body
44
+ });
45
+ renderItem(created, cardView, ctx);
46
+ }
47
+ });
48
+
49
+ //#endregion
50
+ export { create_default as default };
@@ -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 { SEGMENT_DEFINITION_LABELS, preflightMbql5Query, skipValidateFlag } from "./validate-query-B07oGG4K.mjs";
11
+ import { Segment, SegmentCreateInput, segmentView } from "./segment-BMrUBz94.mjs";
12
+
13
+ //#region src/commands/segment/create.ts
14
+ var create_default = defineMetabaseCommand({
15
+ meta: {
16
+ name: "create",
17
+ description: "Create a segment from a JSON spec; if definition 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: Segment,
27
+ examples: [
28
+ "cat segment.json | metabase segment create",
29
+ "metabase segment create --file segment.json",
30
+ "metabase segment create --file segment.json --skip-validate"
31
+ ],
32
+ async run({ args, ctx, getClient }) {
33
+ const body = await readBody({
34
+ flag: args.body,
35
+ file: args.file
36
+ }, SegmentCreateInput);
37
+ preflightMbql5Query(body.definition, SEGMENT_DEFINITION_LABELS, { skip: args["skip-validate"] === true });
38
+ const client = await getClient();
39
+ const created = await client.requestParsed(Segment, "/api/segment", {
40
+ method: "POST",
41
+ body
42
+ });
43
+ renderItem(created, segmentView, ctx);
44
+ }
45
+ });
46
+
47
+ //#endregion
48
+ export { create_default as default };
@@ -1,10 +1,12 @@
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 "./input-Dojr-RTw.mjs";
5
- import { readBody } from "./body-Dv9hQ0Qk.mjs";
6
- import { bodyInputFlags } from "./body-flags-BUA9XV1u.mjs";
7
- import { TransformJob, TransformJobCreateInput, transformJobView } from "./transform-job-C7QXWTVE.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 { TransformJob, TransformJobCreateInput, transformJobView } from "./transform-job-Csr86muI.mjs";
8
10
 
9
11
  //#region src/commands/transform-job/create.ts
10
12
  var create_default = defineMetabaseCommand({