@credibledata/cred-cli 0.0.102 → 0.0.103

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 (118) hide show
  1. package/README.md +1 -1
  2. package/coverage/coverage-summary.json +40 -0
  3. package/coverage/tmp/coverage-2152-1789496974457-0.json +1 -0
  4. package/coverage/tmp/coverage-2153-1789496954404-0.json +1 -0
  5. package/dist/client/api.js +4193 -1342
  6. package/dist/client/api.js.map +1 -1
  7. package/dist/clientconfiguration.js +57 -4
  8. package/dist/clientconfiguration.js.map +1 -1
  9. package/dist/clientconfiguration.spec.js +90 -0
  10. package/dist/clientconfiguration.spec.js.map +1 -1
  11. package/dist/commands/add.js +18 -0
  12. package/dist/commands/add.js.map +1 -1
  13. package/dist/commands/environment/updateenvironment.js +63 -1
  14. package/dist/commands/environment/updateenvironment.js.map +1 -1
  15. package/dist/commands/environment/updateenvironment.spec.js +84 -0
  16. package/dist/commands/environment/updateenvironment.spec.js.map +1 -1
  17. package/dist/commands/get.js +52 -1
  18. package/dist/commands/get.js.map +1 -1
  19. package/dist/commands/list.js +78 -0
  20. package/dist/commands/list.js.map +1 -1
  21. package/dist/commands/materialization/cancelrun.js +62 -0
  22. package/dist/commands/materialization/cancelrun.js.map +1 -0
  23. package/dist/commands/materialization/getindex.js +52 -0
  24. package/dist/commands/materialization/getindex.js.map +1 -0
  25. package/dist/commands/materialization/getmaterialization.js +54 -0
  26. package/dist/commands/materialization/getmaterialization.js.map +1 -0
  27. package/dist/commands/materialization/getpreaggregate.js +55 -0
  28. package/dist/commands/materialization/getpreaggregate.js.map +1 -0
  29. package/dist/commands/materialization/getrun.js +54 -0
  30. package/dist/commands/materialization/getrun.js.map +1 -0
  31. package/dist/commands/materialization/listindexes.js +58 -0
  32. package/dist/commands/materialization/listindexes.js.map +1 -0
  33. package/dist/commands/materialization/listmaterializations.js +52 -0
  34. package/dist/commands/materialization/listmaterializations.js.map +1 -0
  35. package/dist/commands/materialization/listpreaggregates.js +61 -0
  36. package/dist/commands/materialization/listpreaggregates.js.map +1 -0
  37. package/dist/commands/materialization/listruns.js +60 -0
  38. package/dist/commands/materialization/listruns.js.map +1 -0
  39. package/dist/commands/materialization/rerun.js +111 -0
  40. package/dist/commands/materialization/rerun.js.map +1 -0
  41. package/dist/commands/misc/login.js +14 -0
  42. package/dist/commands/misc/login.js.map +1 -1
  43. package/dist/commands/misc/login.spec.js +92 -0
  44. package/dist/commands/misc/login.spec.js.map +1 -1
  45. package/dist/commands/package/listpackages.js +7 -0
  46. package/dist/commands/package/listpackages.js.map +1 -1
  47. package/dist/commands/package/listpackages.spec.js +12 -0
  48. package/dist/commands/package/listpackages.spec.js.map +1 -1
  49. package/dist/commands/package/publish.js +34 -11
  50. package/dist/commands/package/publish.js.map +1 -1
  51. package/dist/commands/package/publish.spec.js +26 -28
  52. package/dist/commands/package/publish.spec.js.map +1 -1
  53. package/dist/commands/permission/createpermission.js +123 -0
  54. package/dist/commands/permission/createpermission.js.map +1 -0
  55. package/dist/commands/permission/createpermission.spec.js +360 -0
  56. package/dist/commands/permission/createpermission.spec.js.map +1 -0
  57. package/dist/commands/permission/deletepermission.js +86 -0
  58. package/dist/commands/permission/deletepermission.js.map +1 -0
  59. package/dist/commands/permission/getpermission.js +85 -0
  60. package/dist/commands/permission/getpermission.js.map +1 -0
  61. package/dist/commands/permission/listpermissions.js +75 -0
  62. package/dist/commands/permission/listpermissions.js.map +1 -0
  63. package/dist/commands/permission/scope.js +140 -0
  64. package/dist/commands/permission/scope.js.map +1 -0
  65. package/dist/commands/rm.js +11 -0
  66. package/dist/commands/rm.js.map +1 -1
  67. package/dist/commands/update.js +18 -12
  68. package/dist/commands/update.js.map +1 -1
  69. package/dist/common/UserGroupId.js +1 -1
  70. package/dist/common/UserGroupId.js.map +1 -1
  71. package/dist/common/UserGroupId.spec.js +2 -4
  72. package/dist/common/UserGroupId.spec.js.map +1 -1
  73. package/dist/constants.js +48 -0
  74. package/dist/constants.js.map +1 -1
  75. package/dist/index.js +61 -6
  76. package/dist/index.js.map +1 -1
  77. package/dist/logger.js +5 -1
  78. package/dist/logger.js.map +1 -1
  79. package/openapitools.json +4 -1
  80. package/package.json +5 -3
  81. package/src/client/api.ts +6433 -1533
  82. package/src/clientconfiguration.spec.ts +126 -0
  83. package/src/clientconfiguration.ts +64 -4
  84. package/src/commands/add.ts +43 -0
  85. package/src/commands/environment/updateenvironment.spec.ts +167 -0
  86. package/src/commands/environment/updateenvironment.ts +85 -1
  87. package/src/commands/get.ts +110 -1
  88. package/src/commands/list.ts +171 -0
  89. package/src/commands/materialization/cancelrun.ts +70 -0
  90. package/src/commands/materialization/getindex.ts +55 -0
  91. package/src/commands/materialization/getmaterialization.ts +57 -0
  92. package/src/commands/materialization/getpreaggregate.ts +58 -0
  93. package/src/commands/materialization/getrun.ts +55 -0
  94. package/src/commands/materialization/listindexes.ts +69 -0
  95. package/src/commands/materialization/listmaterializations.ts +53 -0
  96. package/src/commands/materialization/listpreaggregates.ts +74 -0
  97. package/src/commands/materialization/listruns.ts +77 -0
  98. package/src/commands/materialization/rerun.ts +123 -0
  99. package/src/commands/misc/login.spec.ts +118 -2
  100. package/src/commands/misc/login.ts +14 -0
  101. package/src/commands/package/listpackages.spec.ts +16 -0
  102. package/src/commands/package/listpackages.ts +7 -0
  103. package/src/commands/package/publish.spec.ts +45 -30
  104. package/src/commands/package/publish.ts +31 -10
  105. package/src/commands/permission/createpermission.spec.ts +507 -0
  106. package/src/commands/permission/createpermission.ts +181 -0
  107. package/src/commands/permission/deletepermission.ts +117 -0
  108. package/src/commands/permission/getpermission.ts +115 -0
  109. package/src/commands/permission/listpermissions.ts +101 -0
  110. package/src/commands/permission/scope.ts +180 -0
  111. package/src/commands/rm.ts +29 -0
  112. package/src/commands/update.ts +50 -27
  113. package/src/common/UserGroupId.spec.ts +2 -4
  114. package/src/common/UserGroupId.ts +1 -1
  115. package/src/constants.ts +50 -1
  116. package/src/index.ts +94 -11
  117. package/src/logger.ts +5 -1
  118. package/bun.lock +0 -934
@@ -3,13 +3,21 @@ import { Command } from "commander";
3
3
  import { controlPlanesByEnv, Environment } from "../constants";
4
4
  import { getGroup } from "./group/getgroup";
5
5
  import { getEnvironment } from "./environment/getenvironment";
6
+ import { getMaterialization } from "./materialization/getmaterialization";
7
+ import { getIndex } from "./materialization/getindex";
8
+ import { getPreaggregate } from "./materialization/getpreaggregate";
9
+ import { getRun } from "./materialization/getrun";
6
10
  import { warnProjectDeprecated } from "./legacy";
11
+ import { getPermission } from "./permission/getpermission";
7
12
 
8
13
  export const registerGetCommands = (cli: Command, environment: Environment) => {
9
14
  const get = cli
10
15
  .command("get")
11
16
  .description("Get a resource")
12
- .argument("<resource>", "The resource to get (environment | group)");
17
+ .argument(
18
+ "<resource>",
19
+ "The resource to get (environment | group | permission | materialization | index | preaggregate | run)",
20
+ );
13
21
 
14
22
  const getEnvironmentAction = (environmentName: string, options: any) => {
15
23
  getEnvironment(
@@ -41,4 +49,105 @@ export const registerGetCommands = (cli: Command, environment: Environment) => {
41
49
  .action((groupName, options) => {
42
50
  getGroup(controlPlanesByEnv[environment], groupName, options.debug);
43
51
  });
52
+
53
+ get.command("permission")
54
+ .description(
55
+ "Get a user or group's permission on the organization, an environment, or a package.",
56
+ )
57
+ .argument(
58
+ "<userGroupId>",
59
+ "Whose permission to get [user:{email}|group:{groupName}|user:*]",
60
+ )
61
+ .option(
62
+ "--environment <environmentName>",
63
+ "Get the permission on this environment instead of the organization.",
64
+ )
65
+ .option(
66
+ "--package <packageName>",
67
+ "Get the permission on this package. Uses --environment, or the current environment.",
68
+ )
69
+ .option("--debug")
70
+ .action((userGroupId, options) => {
71
+ getPermission(
72
+ controlPlanesByEnv[environment],
73
+ userGroupId,
74
+ options.debug || false,
75
+ { environment: options.environment, package: options.package },
76
+ );
77
+ });
78
+
79
+ get.command("materialization")
80
+ .alias("mat")
81
+ .description(
82
+ "Get a materialization anchor by id (status, physical table + connection, serving build, freshness, staleness).",
83
+ )
84
+ .argument("<packageName>", "The package that owns the materialization.")
85
+ .argument("<versionId>", "The version that binds it (e.g. 0.1.21).")
86
+ .argument("<materializationId>", "The materialization id.")
87
+ .option("--debug")
88
+ .action((packageName, versionId, materializationId, options) => {
89
+ getMaterialization(
90
+ controlPlanesByEnv[environment],
91
+ packageName,
92
+ versionId,
93
+ materializationId,
94
+ options.debug,
95
+ );
96
+ });
97
+
98
+ get.command("index")
99
+ .description(
100
+ "Get a dimensional index anchor by id (status, row count, lastIndexedAt, freshness, staleness).",
101
+ )
102
+ .argument("<packageName>", "The package that owns the index.")
103
+ .argument("<versionId>", "The version that binds it (e.g. 0.1.21).")
104
+ .argument("<indexId>", "The index (binding) id.")
105
+ .option("--debug")
106
+ .action((packageName, versionId, indexId, options) => {
107
+ getIndex(
108
+ controlPlanesByEnv[environment],
109
+ packageName,
110
+ versionId,
111
+ indexId,
112
+ options.debug,
113
+ );
114
+ });
115
+
116
+ get.command("preaggregate")
117
+ .alias("preagg")
118
+ .description(
119
+ "Get a pre-aggregated measure by id (status, grain, row count, lastBuiltAt, freshness, staleness).",
120
+ )
121
+ .argument("<packageName>", "The package that owns the pre-aggregation.")
122
+ .argument("<versionId>", "The version that binds it (e.g. 0.1.21).")
123
+ .argument(
124
+ "<preaggregateId>",
125
+ "The pre-aggregation id, as printed by `cred ls preaggregate`. It addresses a measure within a rollup — do not construct one by hand.",
126
+ )
127
+ .option("--debug")
128
+ .action((packageName, versionId, preaggregateId, options) => {
129
+ getPreaggregate(
130
+ controlPlanesByEnv[environment],
131
+ packageName,
132
+ versionId,
133
+ preaggregateId,
134
+ options.debug,
135
+ );
136
+ });
137
+
138
+ get.command("run")
139
+ .description(
140
+ "Get a run by id, including its build-plan graph (per-unit state, physical table names, row counts).",
141
+ )
142
+ .argument("<packageName>", "The package that owns the run.")
143
+ .argument("<runId>", "The run id.")
144
+ .option("--debug")
145
+ .action((packageName, runId, options) => {
146
+ getRun(
147
+ controlPlanesByEnv[environment],
148
+ packageName,
149
+ runId,
150
+ options.debug,
151
+ );
152
+ });
44
153
  };
@@ -8,7 +8,12 @@ import { listGroupAccessTokens } from "./groupaccesstoken/listTokens";
8
8
  import { printOutPackages } from "./package/listpackages";
9
9
  import { printOutEnvironments } from "./environment/listenvironments";
10
10
  import { listVersions } from "./version/listversions";
11
+ import { listMaterializations } from "./materialization/listmaterializations";
12
+ import { listIndexes } from "./materialization/listindexes";
13
+ import { listPreaggregates } from "./materialization/listpreaggregates";
14
+ import { listRuns } from "./materialization/listruns";
11
15
  import { warnProjectDeprecated } from "./legacy";
16
+ import { listPermissions } from "./permission/listpermissions";
12
17
 
13
18
  export const registerListCommands = (
14
19
  cli: Command,
@@ -130,6 +135,172 @@ export const registerListCommands = (
130
135
  );
131
136
  });
132
137
 
138
+ list
139
+ .command("materialization")
140
+ .alias("materializations")
141
+ .description(
142
+ "List the materializations of a package version (status + failure reason).",
143
+ )
144
+ .argument(
145
+ "<packageName>",
146
+ "The name of the package whose materializations to list.",
147
+ )
148
+ .argument(
149
+ "<versionId>",
150
+ "The version that binds the materializations (e.g. 0.1.21).",
151
+ )
152
+ .option("--debug")
153
+ .action((packageName, versionId, options) => {
154
+ listMaterializations(
155
+ controlPlanesByEnv[environment],
156
+ packageName,
157
+ versionId,
158
+ options.debug,
159
+ );
160
+ });
161
+
162
+ list
163
+ .command("index")
164
+ .alias("indexes")
165
+ .description(
166
+ "List the dimensional search indexes of a package version (status + failure reason + freshness).",
167
+ )
168
+ .argument(
169
+ "<packageName>",
170
+ "The name of the package whose indexes to list.",
171
+ )
172
+ .argument(
173
+ "<versionId>",
174
+ "The version that binds the indexes (e.g. 0.1.21).",
175
+ )
176
+ .option("--debug")
177
+ // No static defaults: a Commander default of "-1" for --page-size would make it
178
+ // always-set, so parsePaginationParams takes its "return all records" branch and
179
+ // silently ignores a lone --page N. Leaving both unset (undefined) preserves the
180
+ // all-records default (neither flag → branch 1) while letting --page N default the
181
+ // page size to a finite page (utils.parsePaginationParams).
182
+ .option("--page <number>", `Page number (starts at ${DEFAULT_PAGE})`)
183
+ .option(
184
+ "--page-size <number>",
185
+ `Items per page (default: all records, max: 500)`,
186
+ )
187
+ .action((packageName, versionId, options) => {
188
+ listIndexes(
189
+ controlPlanesByEnv[environment],
190
+ packageName,
191
+ versionId,
192
+ options.debug,
193
+ options.page,
194
+ options.pageSize,
195
+ );
196
+ });
197
+
198
+ list
199
+ .command("preaggregate")
200
+ .alias("preaggregates")
201
+ .alias("preaggs")
202
+ .description(
203
+ "List the pre-aggregated measures of a package version (status + failure reason + grain + freshness). One entry per measure, so several may share a rollup table.",
204
+ )
205
+ .argument(
206
+ "<packageName>",
207
+ "The name of the package whose pre-aggregations to list.",
208
+ )
209
+ .argument(
210
+ "<versionId>",
211
+ "The version that binds the pre-aggregations (e.g. 0.1.21).",
212
+ )
213
+ .option("--debug")
214
+ .option(
215
+ "--source <sourceName>",
216
+ "Only list the pre-aggregated measures of this authored source.",
217
+ )
218
+ // No static defaults — see the note on `ls index` above.
219
+ .option("--page <number>", `Page number (starts at ${DEFAULT_PAGE})`)
220
+ .option(
221
+ "--page-size <number>",
222
+ `Items per page (default: all records, max: 500)`,
223
+ )
224
+ .action((packageName, versionId, options) => {
225
+ listPreaggregates(
226
+ controlPlanesByEnv[environment],
227
+ packageName,
228
+ versionId,
229
+ options.source,
230
+ options.debug,
231
+ options.page,
232
+ options.pageSize,
233
+ );
234
+ });
235
+
236
+ list
237
+ .command("run")
238
+ .alias("runs")
239
+ .description(
240
+ "List the build/refresh runs of a package (most recent first). Runs are package-scoped and span all three families (materialized sources, dimensional indexes and pre-aggregations); pass a version to filter to the runs it initiated, or --source/--dimension/--measure to filter to a targeted unit.",
241
+ )
242
+ .argument("<packageName>", "The name of the package whose runs to list.")
243
+ .argument(
244
+ "[versionId]",
245
+ "Optional version to filter runs to (e.g. 0.1.21). Omit to list every run in the package.",
246
+ )
247
+ .option("--debug")
248
+ .option(
249
+ "--source <sourceName>",
250
+ "Only list runs targeting this persist source.",
251
+ )
252
+ .option(
253
+ "--dimension <dimension>",
254
+ "Only list runs targeting this indexed dimension.",
255
+ )
256
+ .option(
257
+ "--measure <measure>",
258
+ "Only list runs targeting this pre-aggregated measure.",
259
+ )
260
+ // No static defaults — see the note on `ls index` above: a "-1" --page-size default
261
+ // makes parsePaginationParams ignore a lone --page N. Undefined keeps the all-records
262
+ // default while honoring --page N.
263
+ .option("--page <number>", `Page number (starts at ${DEFAULT_PAGE})`)
264
+ .option(
265
+ "--page-size <number>",
266
+ `Items per page (default: all records, max: 500)`,
267
+ )
268
+ .action((packageName, versionId, options) => {
269
+ listRuns(
270
+ controlPlanesByEnv[environment],
271
+ packageName,
272
+ versionId,
273
+ options.debug,
274
+ options.source,
275
+ options.dimension,
276
+ options.measure,
277
+ options.page,
278
+ options.pageSize,
279
+ );
280
+ });
281
+
282
+ list
283
+ .command("permission")
284
+ .alias("permissions")
285
+ .description(
286
+ "List the permissions on the organization, an environment, or a package.",
287
+ )
288
+ .option(
289
+ "--environment <environmentName>",
290
+ "List this environment's permissions instead of the organization's.",
291
+ )
292
+ .option(
293
+ "--package <packageName>",
294
+ "List this package's permissions. Uses --environment, or the current environment.",
295
+ )
296
+ .option("--debug")
297
+ .action((options) => {
298
+ listPermissions(controlPlanesByEnv[environment], options.debug, {
299
+ environment: options.environment,
300
+ package: options.package,
301
+ });
302
+ });
303
+
133
304
  list
134
305
  .command("group")
135
306
  .alias("groups")
@@ -0,0 +1,70 @@
1
+ import { RunsApi, RunActionActionEnum } from "../../client/api";
2
+ import { Configuration } from "../../client/configuration";
3
+ import { ClientConfiguration } from "../../clientconfiguration";
4
+ import { logger } from "../../logger";
5
+ import { getConfirmation, prettifyJson, printOutError } from "../../utils";
6
+
7
+ const runsApi = new RunsApi(new Configuration());
8
+
9
+ /**
10
+ * Cancel an in-flight (non-terminal) build/refresh run. No-op-safe: the control
11
+ * plane returns 409 if the run is already terminal. Prints the run's updated
12
+ * state.
13
+ */
14
+ export async function cancelRun(
15
+ controlPlane: string,
16
+ packagePath: string,
17
+ runId: string,
18
+ debug: boolean,
19
+ autoConfirm: boolean,
20
+ ) {
21
+ const clientConfig = new ClientConfiguration();
22
+ const organizationName = clientConfig.getOrganization();
23
+ const environmentName = clientConfig.getProject();
24
+
25
+ if (!clientConfig.doesConfigExists()) {
26
+ logger.error("Please, make sure that you are logged in");
27
+ return;
28
+ }
29
+
30
+ if (!environmentName) {
31
+ logger.error("Please, make sure to set an environment");
32
+ return;
33
+ }
34
+
35
+ if (!runId) {
36
+ logger.error("Please provide a run ID");
37
+ return;
38
+ }
39
+
40
+ const packageName = packagePath.replace("/", "");
41
+
42
+ if (!autoConfirm) {
43
+ const confirmation = await getConfirmation(
44
+ `Cancel run ${runId} in ${packageName}?`,
45
+ );
46
+ if (!confirmation) {
47
+ return;
48
+ }
49
+ }
50
+
51
+ logger.info(`Cancelling run ${runId} in ${packageName}`);
52
+ try {
53
+ const response = await runsApi.runAction(
54
+ organizationName,
55
+ environmentName,
56
+ packageName,
57
+ runId,
58
+ RunActionActionEnum.Cancel,
59
+ {
60
+ baseURL: controlPlane,
61
+ headers: clientConfig.getHeaders(),
62
+ },
63
+ );
64
+
65
+ console.log(prettifyJson(response.data));
66
+ } catch (e) {
67
+ logger.error("Failed to cancel run");
68
+ printOutError(e, debug);
69
+ }
70
+ }
@@ -0,0 +1,55 @@
1
+ import { IndexesApi } from "../../client/api";
2
+ import { Configuration } from "../../client/configuration";
3
+ import { ClientConfiguration } from "../../clientconfiguration";
4
+ import { logger } from "../../logger";
5
+ import { prettifyJson, printOutError } from "../../utils";
6
+
7
+ const indexesApi = new IndexesApi(new Configuration());
8
+
9
+ /**
10
+ * Get a single dimensional search index anchor (binding) by id. Prints the full
11
+ * anchor state — `status`/`error`, the indexed `sourceName`/`dimension`, the
12
+ * serving `rowCount` (indexed values) and `lastIndexedAt`, scope, freshness
13
+ * policy, and the `stale`/`staleSince`/`staleReasons` triple.
14
+ */
15
+ export async function getIndex(
16
+ controlPlane: string,
17
+ packagePath: string,
18
+ versionId: string,
19
+ indexId: string,
20
+ debug: boolean,
21
+ ) {
22
+ const clientConfig = new ClientConfiguration();
23
+ const organizationName = clientConfig.getOrganization();
24
+ const environmentName = clientConfig.getProject();
25
+
26
+ if (!clientConfig.doesConfigExists()) {
27
+ logger.error("Please, make sure that you are logged in");
28
+ return;
29
+ }
30
+
31
+ if (!environmentName) {
32
+ logger.error("Please, make sure to set an environment");
33
+ return;
34
+ }
35
+
36
+ try {
37
+ const packageName = packagePath.replace("/", "");
38
+ const response = await indexesApi.getIndex(
39
+ organizationName,
40
+ environmentName,
41
+ packageName,
42
+ versionId,
43
+ indexId,
44
+ {
45
+ baseURL: controlPlane,
46
+ headers: clientConfig.getHeaders(),
47
+ },
48
+ );
49
+
50
+ console.log(prettifyJson(response.data));
51
+ } catch (e) {
52
+ logger.error("Failed to get index");
53
+ printOutError(e, debug);
54
+ }
55
+ }
@@ -0,0 +1,57 @@
1
+ import { MaterializationsApi } from "../../client/api";
2
+ import { Configuration } from "../../client/configuration";
3
+ import { ClientConfiguration } from "../../clientconfiguration";
4
+ import { logger } from "../../logger";
5
+ import { prettifyJson, printOutError } from "../../utils";
6
+
7
+ const materializationsApi = new MaterializationsApi(new Configuration());
8
+
9
+ /**
10
+ * Get a single Malloy Persistence materialization anchor by id. Prints the full
11
+ * anchor state — `status`/`error`, the physical `materializedTableName` and its
12
+ * `connectionName` (the underlying warehouse table currently serving the
13
+ * source), the serving run/build number, scope, freshness policy, and the
14
+ * `stale`/`staleSince`/`staleReasons` triple — so the state of the derived table
15
+ * is inspectable from the CLI without opening the app.
16
+ */
17
+ export async function getMaterialization(
18
+ controlPlane: string,
19
+ packagePath: string,
20
+ versionId: string,
21
+ materializationId: string,
22
+ debug: boolean,
23
+ ) {
24
+ const clientConfig = new ClientConfiguration();
25
+ const organizationName = clientConfig.getOrganization();
26
+ const environmentName = clientConfig.getProject();
27
+
28
+ if (!clientConfig.doesConfigExists()) {
29
+ logger.error("Please, make sure that you are logged in");
30
+ return;
31
+ }
32
+
33
+ if (!environmentName) {
34
+ logger.error("Please, make sure to set an environment");
35
+ return;
36
+ }
37
+
38
+ try {
39
+ const packageName = packagePath.replace("/", "");
40
+ const response = await materializationsApi.getMaterialization(
41
+ organizationName,
42
+ environmentName,
43
+ packageName,
44
+ versionId,
45
+ materializationId,
46
+ {
47
+ baseURL: controlPlane,
48
+ headers: clientConfig.getHeaders(),
49
+ },
50
+ );
51
+
52
+ console.log(prettifyJson(response.data));
53
+ } catch (e) {
54
+ logger.error("Failed to get materialization");
55
+ printOutError(e, debug);
56
+ }
57
+ }
@@ -0,0 +1,58 @@
1
+ import { PreaggregatesApi } from "../../client/api";
2
+ import { Configuration } from "../../client/configuration";
3
+ import { ClientConfiguration } from "../../clientconfiguration";
4
+ import { logger } from "../../logger";
5
+ import { prettifyJson, printOutError } from "../../utils";
6
+
7
+ const preaggregatesApi = new PreaggregatesApi(new Configuration());
8
+
9
+ /**
10
+ * Get a single pre-aggregated measure by id. Prints its full state — `status`/`error`,
11
+ * the authored `sourceName` and `measure`, the `grainDimensions` it is rolled up to, the
12
+ * serving table and its `rowCount`/`lastBuiltAt`, scope, freshness policy, and the
13
+ * `stale`/`staleSince`/`staleReasons` triple.
14
+ *
15
+ * <p>The id is opaque and comes from `cred ls preaggregate` — it addresses a measure
16
+ * within a rollup, not the rollup table, so do not construct one by hand.
17
+ */
18
+ export async function getPreaggregate(
19
+ controlPlane: string,
20
+ packagePath: string,
21
+ versionId: string,
22
+ preaggregateId: string,
23
+ debug: boolean,
24
+ ) {
25
+ const clientConfig = new ClientConfiguration();
26
+ const organizationName = clientConfig.getOrganization();
27
+ const environmentName = clientConfig.getProject();
28
+
29
+ if (!clientConfig.doesConfigExists()) {
30
+ logger.error("Please, make sure that you are logged in");
31
+ return;
32
+ }
33
+
34
+ if (!environmentName) {
35
+ logger.error("Please, make sure to set an environment");
36
+ return;
37
+ }
38
+
39
+ try {
40
+ const packageName = packagePath.replace("/", "");
41
+ const response = await preaggregatesApi.getPreaggregate(
42
+ organizationName,
43
+ environmentName,
44
+ packageName,
45
+ versionId,
46
+ preaggregateId,
47
+ {
48
+ baseURL: controlPlane,
49
+ headers: clientConfig.getHeaders(),
50
+ },
51
+ );
52
+
53
+ console.log(prettifyJson(response.data));
54
+ } catch (e) {
55
+ logger.error("Failed to get pre-aggregation");
56
+ printOutError(e, debug);
57
+ }
58
+ }
@@ -0,0 +1,55 @@
1
+ import { RunsApi } from "../../client/api";
2
+ import { Configuration } from "../../client/configuration";
3
+ import { ClientConfiguration } from "../../clientconfiguration";
4
+ import { logger } from "../../logger";
5
+ import { prettifyJson, printOutError } from "../../utils";
6
+
7
+ const runsApi = new RunsApi(new Configuration());
8
+
9
+ /**
10
+ * Get a single build/refresh run by id, including its stateful build plan. The
11
+ * `buildPlan.nodes` carry each produced unit's live state — per source node the
12
+ * physical `tableName` and `rowCount`, per index node the dimension and its
13
+ * status — and `buildPlan.edges` wire sources to the indexes that depend on
14
+ * them. This is the detailed view (`listRuns` omits the graph); use it to see
15
+ * exactly which physical tables a run produced and how the units relate.
16
+ */
17
+ export async function getRun(
18
+ controlPlane: string,
19
+ packagePath: string,
20
+ runId: string,
21
+ debug: boolean,
22
+ ) {
23
+ const clientConfig = new ClientConfiguration();
24
+ const organizationName = clientConfig.getOrganization();
25
+ const environmentName = clientConfig.getProject();
26
+
27
+ if (!clientConfig.doesConfigExists()) {
28
+ logger.error("Please, make sure that you are logged in");
29
+ return;
30
+ }
31
+
32
+ if (!environmentName) {
33
+ logger.error("Please, make sure to set an environment");
34
+ return;
35
+ }
36
+
37
+ try {
38
+ const packageName = packagePath.replace("/", "");
39
+ const response = await runsApi.getRun(
40
+ organizationName,
41
+ environmentName,
42
+ packageName,
43
+ runId,
44
+ {
45
+ baseURL: controlPlane,
46
+ headers: clientConfig.getHeaders(),
47
+ },
48
+ );
49
+
50
+ console.log(prettifyJson(response.data));
51
+ } catch (e) {
52
+ logger.error("Failed to get run");
53
+ printOutError(e, debug);
54
+ }
55
+ }
@@ -0,0 +1,69 @@
1
+ import { IndexesApi } from "../../client/api";
2
+ import { Configuration } from "../../client/configuration";
3
+ import { ClientConfiguration } from "../../clientconfiguration";
4
+ import { logger } from "../../logger";
5
+ import {
6
+ prettifyJson,
7
+ printOutError,
8
+ parsePaginationParams,
9
+ extractTotalCount,
10
+ } from "../../utils";
11
+
12
+ const indexesApi = new IndexesApi(new Configuration());
13
+
14
+ /**
15
+ * List the dimensional search indexes bound to a package version (the per-`#(index)`
16
+ * serving anchors). Each entry prints its `status` and, when FAILED, the `error`;
17
+ * plus the serving `rowCount`, `lastIndexedAt`, freshness policy, and the
18
+ * `stale`/`staleReasons` triple — so a failing or stale index is diagnosable
19
+ * from the CLI. The total available count is logged to stderr.
20
+ */
21
+ export async function listIndexes(
22
+ controlPlane: string,
23
+ packagePath: string,
24
+ versionId: string,
25
+ debug: boolean,
26
+ page?: string | number,
27
+ pageSize?: string | number,
28
+ ) {
29
+ const clientConfig = new ClientConfiguration();
30
+ const organizationName = clientConfig.getOrganization();
31
+ const environmentName = clientConfig.getProject();
32
+
33
+ if (!clientConfig.doesConfigExists()) {
34
+ logger.error("Please, make sure that you are logged in");
35
+ return;
36
+ }
37
+
38
+ if (!environmentName) {
39
+ logger.error("Please, make sure to set an environment");
40
+ return;
41
+ }
42
+
43
+ try {
44
+ const packageName = packagePath.replace("/", "");
45
+ const { limit, offset } = parsePaginationParams(page, pageSize);
46
+ const response = await indexesApi.listIndexes(
47
+ organizationName,
48
+ environmentName,
49
+ packageName,
50
+ versionId,
51
+ limit,
52
+ offset,
53
+ {
54
+ baseURL: controlPlane,
55
+ headers: clientConfig.getHeaders(),
56
+ },
57
+ );
58
+
59
+ const totalCount = extractTotalCount(response.headers);
60
+ if (totalCount !== undefined) {
61
+ logger.info(`Total indexes available: ${totalCount}`);
62
+ }
63
+
64
+ console.log(prettifyJson(response.data));
65
+ } catch (e) {
66
+ logger.error("Failed to list indexes");
67
+ printOutError(e, debug);
68
+ }
69
+ }