@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
package/src/constants.ts CHANGED
@@ -4,7 +4,8 @@ export type Environment =
4
4
  | "dev"
5
5
  | "localhost"
6
6
  | "e2e-test"
7
- | "videoamp";
7
+ | "videoamp"
8
+ | "aws-dev";
8
9
 
9
10
  export const controlPlanesByEnv: Record<Environment, string> = {
10
11
  production: "https://admin.credibledata.com/api/v0",
@@ -13,6 +14,9 @@ export const controlPlanesByEnv: Record<Environment, string> = {
13
14
  localhost: "http://admin.ms2.localhost/api/v0",
14
15
  "e2e-test": "http://admin.ms2.localhost/api/v0",
15
16
  videoamp: "https://admin.videoamp-aws-us-east-1.credibledata.com/api/v0",
17
+ // The AWS development cell (credible/dev on EKS). Its public hostnames compose onto the shared
18
+ // apex as aws-dev-<service>.credibledata.com, unlike videoamp's, which live under its own zone.
19
+ "aws-dev": "https://aws-dev-admin.credibledata.com/api/v0",
16
20
  };
17
21
 
18
22
  /** Environments that must have an object in `~/.cred` `configPerEnvironment` (avoids undefined on write). */
@@ -61,6 +65,14 @@ export const auth0ConfigsByEnv: Record<
61
65
  clientId: "ge8JL5TJNwqy7bygAaJkD92KdluqEZgO",
62
66
  audience: "https://ms2data.us.auth0.com/api/v2/",
63
67
  },
68
+ // The DEV Auth0 tenant, not production: this cell takes its per-tier secrets from gcp/credible/dev,
69
+ // so it authenticates against the same tenant that dev, staging and localhost do. videoamp is the
70
+ // exception here, being a production cell.
71
+ "aws-dev": {
72
+ domain: "https://dev-auth.credibledata.com",
73
+ clientId: "rr6mzJNj9b104MjCc9xWKPPehq1MJx0L",
74
+ audience: "https://dev-ohaafogw5p8uyx1m.us.auth0.com/api/v2/",
75
+ },
64
76
  };
65
77
 
66
78
  /** Clusters a CLI org can target via `cred login <org> -c <cluster>`. */
@@ -74,6 +86,7 @@ export const CLUSTER_BY_ENVIRONMENT: Record<Environment, Cluster> = {
74
86
  localhost: "gcp",
75
87
  "e2e-test": "gcp",
76
88
  videoamp: "aws",
89
+ "aws-dev": "aws",
77
90
  };
78
91
 
79
92
  /**
@@ -122,6 +135,42 @@ const CLI_ORG_CONFIGS: CliOrgConfig[] = [
122
135
  aws: "org_nMRKafeSuxOiuJeG",
123
136
  },
124
137
  },
138
+ {
139
+ // Exists on both clouds -- gcp dev and the aws development cell both have a `demo` org -- so
140
+ // both are listed. Registered at all only because an UNREGISTERED org is assumed gcp-only
141
+ // (`supportedClusters ?? ["gcp"]`), which is why `cred login demo` on an aws cell reports the
142
+ // org as unavailable rather than anything about the cell.
143
+ //
144
+ // defaultCluster stays gcp so a bare `cred login demo` behaves exactly as it did before this
145
+ // entry existed; reach the aws cell with `-c aws`.
146
+ //
147
+ // No auth0OrganizationIds: their presence selects the PKCE + loopback flow, whose redirect
148
+ // (127.0.0.1:18240/callback) is registered on the production Auth0 tenant only. Omitting them
149
+ // selects the Device Authorization Flow, which needs no callback URL and therefore works on a
150
+ // cell authenticating against the dev tenant.
151
+ cliOrgName: "demo",
152
+ supportedClusters: ["gcp", "aws"],
153
+ defaultCluster: "gcp",
154
+ },
155
+ {
156
+ // The tenant the PROBES measure, on every cell in both clouds -- probe_organization in
157
+ // stacks/{aws,gcp}/services. Distinct from `demo` above, which is a cell's own first
158
+ // organization; a cell has both, and they were seeded by different bootstrap steps.
159
+ //
160
+ // Needed for the same reason the `demo` entry is, and missed for a reason worth naming: the
161
+ // gcp-only fallback (`supportedClusters ?? ["gcp"]`) makes an unregistered org work perfectly
162
+ // on gcp, so nothing surfaced until an operator tried to reach the fixture on an AWS cell and
163
+ // got "Organization 'k6-experiments' is not available on the aws cluster" -- a message about
164
+ // the org, for a fact about this list. Asserted against the recipe by
165
+ // test_probe_organization_is_reachable_on_its_cells_clusters.
166
+ //
167
+ // defaultCluster gcp and no auth0OrganizationIds, both for the reasons given on `demo`: a bare
168
+ // `cred login k6-experiments` keeps behaving exactly as it did before this entry existed, and
169
+ // the Device Authorization Flow is the one that works against a cell on the dev Auth0 tenant.
170
+ cliOrgName: "k6-experiments",
171
+ supportedClusters: ["gcp", "aws"],
172
+ defaultCluster: "gcp",
173
+ },
125
174
  ];
126
175
 
127
176
  const CLI_ORG_CONFIGS_BY_NAME: Record<string, CliOrgConfig> =
package/src/index.ts CHANGED
@@ -8,7 +8,7 @@ import { ClientConfiguration } from "./clientconfiguration";
8
8
  import { registerAddCommands } from "./commands/add";
9
9
  import { registerGetCommands } from "./commands/get";
10
10
  import { registerListCommands } from "./commands/list";
11
- import { login } from "./commands/misc/login";
11
+ import { isLoginInvocation, login } from "./commands/misc/login";
12
12
  import { logout } from "./commands/misc/logout";
13
13
  import { setAccessToken } from "./commands/misc/set-access-token";
14
14
  import { listPackages } from "./commands/package/listpackages";
@@ -21,6 +21,8 @@ import {
21
21
  archiveVersion,
22
22
  unarchiveVersion,
23
23
  } from "./commands/version/archive-unarchive-version";
24
+ import { rerun } from "./commands/materialization/rerun";
25
+ import { cancelRun } from "./commands/materialization/cancelrun";
24
26
  import {
25
27
  ASCII_TITLE,
26
28
  Cluster,
@@ -32,6 +34,18 @@ import {
32
34
 
33
35
  const clientConfig = new ClientConfiguration();
34
36
 
37
+ // `cred login` is the documented recovery path for a corrupt `~/.cred`, and the
38
+ // one command whose job is to (re)establish config. The startup reads below —
39
+ // the axios baseURL and every getActiveEnvironment() call during command
40
+ // registration — invoke loadConfig() eagerly at module load, so a corrupt
41
+ // config throws here, before the login action ever runs, dead-ending the very
42
+ // command meant to fix it. Recover up front, but ONLY for login: every other
43
+ // command stays fail-loud (the thrown error still names `cred login` as the
44
+ // fix) so a stray read never silently resets a user's tokens.
45
+ if (isLoginInvocation(process.argv)) {
46
+ clientConfig.recoverIfCorrupt();
47
+ }
48
+
35
49
  const getActiveEnvironment = () => {
36
50
  return clientConfig.getEnvironment();
37
51
  };
@@ -69,13 +83,6 @@ cli.command("publish")
69
83
  "Set this version as the latest version of the package.",
70
84
  false,
71
85
  )
72
- .option(
73
- "--async",
74
- "Return as soon as the package is uploaded and let indexing run in " +
75
- "the background. Without this flag, publish waits for indexing " +
76
- "to finish and exits non-zero if it fails.",
77
- false,
78
- )
79
86
  .action((options) => {
80
87
  publish(
81
88
  controlPlanesByEnv[getActiveEnvironment()],
@@ -83,7 +90,6 @@ cli.command("publish")
83
90
  options.debug,
84
91
  options.yes,
85
92
  options.setLatest,
86
- options.async,
87
93
  );
88
94
  });
89
95
 
@@ -125,6 +131,65 @@ cli.command("unarchive")
125
131
  );
126
132
  });
127
133
 
134
+ cli.command("rerun")
135
+ .description(
136
+ "Trigger an on-demand run (rebuild/refresh) for a package version. Defaults to a full run (all sources, indexes and pre-aggregations); use --source/--dimension/--measure/--model-file to scope it to a single unit.",
137
+ )
138
+ .argument("<packageName>", "The name of the package to run.")
139
+ .argument("<versionId>", "The version to (re)build (e.g. 0.1.21).")
140
+ .option("--debug")
141
+ .option("-y, --yes", "Skip confirmation.")
142
+ .option("--source <sourceName>", "Scope the run to a single persist source.")
143
+ .option(
144
+ "--dimension <dimension>",
145
+ "Scope the run to a single indexed dimension.",
146
+ )
147
+ .option(
148
+ "--measure <measure>",
149
+ "Scope the run to a single pre-aggregated measure. Rebuilds the rollup serving it; add --source when the measure is declared at more than one grain.",
150
+ )
151
+ .option(
152
+ "--model-file <modelFilePath>",
153
+ "Disambiguate a dimension/source defined in more than one model file.",
154
+ )
155
+ .option(
156
+ "--include-upstream",
157
+ "Also force-rebuild the target's upstream persisted closure (only meaningful with --source/--dimension/--measure).",
158
+ false,
159
+ )
160
+ .action((packageName, versionId, options) => {
161
+ rerun(
162
+ controlPlanesByEnv[getActiveEnvironment()],
163
+ packageName,
164
+ versionId,
165
+ {
166
+ source: options.source,
167
+ dimension: options.dimension,
168
+ measure: options.measure,
169
+ modelFile: options.modelFile,
170
+ includeUpstream: options.includeUpstream,
171
+ },
172
+ options.debug,
173
+ options.yes,
174
+ );
175
+ });
176
+
177
+ cli.command("cancel-run")
178
+ .description("Cancel an in-flight (non-terminal) run.")
179
+ .argument("<packageName>", "The name of the package that owns the run.")
180
+ .argument("<runId>", "The id of the run to cancel.")
181
+ .option("--debug")
182
+ .option("-y, --yes", "Skip confirmation.")
183
+ .action((packageName, runId, options) => {
184
+ cancelRun(
185
+ controlPlanesByEnv[getActiveEnvironment()],
186
+ packageName,
187
+ runId,
188
+ options.debug,
189
+ options.yes,
190
+ );
191
+ });
192
+
128
193
  cli.command("login")
129
194
  .description("Login into Credible service.")
130
195
  .argument("<organizationName>", "The organization to login to.")
@@ -201,7 +266,9 @@ cli.command("set-access-token")
201
266
  });
202
267
 
203
268
  cli.command("status")
204
- .description("Shows the currently active organization and environment.")
269
+ .description(
270
+ "Shows the cell this CLI targets, and the active organization and environment.",
271
+ )
205
272
  .action(() => {
206
273
  const config = new ClientConfiguration();
207
274
  config.printStatus();
@@ -209,15 +276,27 @@ cli.command("status")
209
276
 
210
277
  const complete = omelette("credible").tree({
211
278
  // CRUD commands
212
- get: ["environment", "project", "group"],
279
+ get: [
280
+ "environment",
281
+ "project",
282
+ "group",
283
+ "permission",
284
+ "materialization",
285
+ "index",
286
+ "run",
287
+ ],
213
288
  ls: [
214
289
  "environment",
215
290
  "project",
216
291
  "connection",
217
292
  "package",
218
293
  "version",
294
+ "materialization",
295
+ "index",
296
+ "run",
219
297
  "group",
220
298
  "group-access-token",
299
+ "permission",
221
300
  ],
222
301
  update: ["environment", "project", "package"],
223
302
  rm: [
@@ -228,6 +307,7 @@ const complete = omelette("credible").tree({
228
307
  "group",
229
308
  "member",
230
309
  "group-access-token",
310
+ "permission",
231
311
  ],
232
312
  add: [
233
313
  "environment",
@@ -236,6 +316,7 @@ const complete = omelette("credible").tree({
236
316
  "group",
237
317
  "member",
238
318
  "group-access-token",
319
+ "permission",
239
320
  ],
240
321
  // Misc commands
241
322
  set: ["environment", "project"],
@@ -246,6 +327,8 @@ const complete = omelette("credible").tree({
246
327
  publish: [],
247
328
  archive: [],
248
329
  unarchive: [],
330
+ rerun: [],
331
+ "cancel-run": [],
249
332
  });
250
333
 
251
334
  complete.onAsync("$3", async ({ reply, line }) => {
package/src/logger.ts CHANGED
@@ -25,9 +25,13 @@ export const logger = winston.createLogger({
25
25
  winston.format.splat(),
26
26
  ),
27
27
  transports: [
28
- // Console transport with colored logs
28
+ // Console transport with colored logs. Error/warn go to stderr so they
29
+ // never pollute stdout — commands like `cred ls packages` print JSON to
30
+ // stdout, and a log line landing there makes downstream `JSON.parse`
31
+ // (e.g. the e2e harness) fail cryptically.
29
32
  new winston.transports.Console({
30
33
  format: consoleFormat,
34
+ stderrLevels: ["error", "warn"],
31
35
  }),
32
36
 
33
37
  // NOTE disabled app.log logging