@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
@@ -50,14 +50,20 @@ describe("publish", () => {
50
50
  debug: boolean,
51
51
  autoConfirm: boolean,
52
52
  setLatest: boolean,
53
- asyncIndexing?: boolean,
54
53
  ) => Promise<void>;
55
54
 
56
55
  // Store the original archiver module so we can restore it
57
56
  let originalArchiverModule: any;
58
57
  const archiverModulePath = require.resolve("archiver");
59
58
 
59
+ // publish reports failure by setting process.exitCode, so each test starts from a
60
+ // known 0 and the suite restores whatever the runner had — a leaked non-zero would
61
+ // fail the whole mocha run regardless of the assertions.
62
+ let originalExitCode: number | string | undefined;
63
+
60
64
  beforeEach(() => {
65
+ originalExitCode = process.exitCode;
66
+ process.exitCode = 0;
61
67
  sandbox = sinon.createSandbox();
62
68
 
63
69
  // Create mock archive
@@ -143,6 +149,7 @@ describe("publish", () => {
143
149
  });
144
150
 
145
151
  afterEach(() => {
152
+ process.exitCode = originalExitCode;
146
153
  sandbox.restore();
147
154
  // Restore original archiver module
148
155
  if (originalArchiverModule) {
@@ -184,14 +191,12 @@ describe("publish", () => {
184
191
  expect(createOrUpdatePackageStub.firstCall.args[2]).to.equal(
185
192
  "test-package",
186
193
  );
187
- // arg[3] is the new `async` flag; package/version shift by one.
188
- expect(createOrUpdatePackageStub.firstCall.args[3]).to.equal(false);
189
- expect(createOrUpdatePackageStub.firstCall.args[4]).to.deep.include({
194
+ expect(createOrUpdatePackageStub.firstCall.args[3]).to.deep.include({
190
195
  name: "test-package",
191
196
  description: "Test package",
192
197
  replicationCount: 2,
193
198
  });
194
- expect(createOrUpdatePackageStub.firstCall.args[5]).to.deep.include({
199
+ expect(createOrUpdatePackageStub.firstCall.args[4]).to.deep.include({
195
200
  id: "1.0.0",
196
201
  });
197
202
  expect(
@@ -220,7 +225,7 @@ describe("publish", () => {
220
225
 
221
226
  await publish("http://test-server", 2, false, true, true);
222
227
 
223
- expect(createOrUpdatePackageStub.firstCall.args[4]).to.deep.include({
228
+ expect(createOrUpdatePackageStub.firstCall.args[3]).to.deep.include({
224
229
  latestVersion: "1.0.0",
225
230
  });
226
231
  });
@@ -244,7 +249,7 @@ describe("publish", () => {
244
249
 
245
250
  await publish("http://test-server", 2, false, true, false);
246
251
 
247
- expect(createOrUpdatePackageStub.firstCall.args[4]).to.not.have.property(
252
+ expect(createOrUpdatePackageStub.firstCall.args[3]).to.not.have.property(
248
253
  "latestVersion",
249
254
  );
250
255
  });
@@ -318,7 +323,7 @@ describe("publish", () => {
318
323
 
319
324
  await publish("http://test-server", 2, false, true, false);
320
325
 
321
- expect(createOrUpdatePackageStub.firstCall.args[7]).to.equal(
326
+ expect(createOrUpdatePackageStub.firstCall.args[6]).to.equal(
322
327
  expectedHash,
323
328
  );
324
329
  });
@@ -354,6 +359,10 @@ describe("publish", () => {
354
359
  sinon.match("Please, make sure that you are logged in"),
355
360
  ),
356
361
  ).to.be.true;
362
+ expect(
363
+ process.exitCode,
364
+ "a publish that never ran must not exit 0",
365
+ ).to.equal(1);
357
366
  });
358
367
 
359
368
  it("should handle invalid token", async () => {
@@ -390,6 +399,10 @@ describe("publish", () => {
390
399
  sinon.match("No token found. Please login."),
391
400
  ),
392
401
  ).to.be.true;
402
+ expect(
403
+ process.exitCode,
404
+ "a publish that never ran must not exit 0",
405
+ ).to.equal(1);
393
406
  });
394
407
 
395
408
  it("should handle invalid manifest", async () => {
@@ -398,6 +411,11 @@ describe("publish", () => {
398
411
  await publish("http://test-server", 2, false, true, false);
399
412
 
400
413
  expect(createOrUpdatePackageStub.called).to.be.false;
414
+ // validateManifest logs its own reason, so only the exit code is asserted here.
415
+ expect(
416
+ process.exitCode,
417
+ "a publish that never ran must not exit 0",
418
+ ).to.equal(1);
401
419
  });
402
420
 
403
421
  it("should handle missing organization", async () => {
@@ -443,6 +461,10 @@ describe("publish", () => {
443
461
  sinon.match("Please, make sure that you are logged in"),
444
462
  ),
445
463
  ).to.be.true;
464
+ expect(
465
+ process.exitCode,
466
+ "a publish that never ran must not exit 0",
467
+ ).to.equal(1);
446
468
  });
447
469
 
448
470
  it("should handle missing project", async () => {
@@ -484,6 +506,10 @@ describe("publish", () => {
484
506
  sinon.match("Please, make sure to set an environment"),
485
507
  ),
486
508
  ).to.be.true;
509
+ expect(
510
+ process.exitCode,
511
+ "a publish that never ran must not exit 0",
512
+ ).to.equal(1);
487
513
  });
488
514
 
489
515
  it("should handle missing publisher.json", async () => {
@@ -503,6 +529,10 @@ describe("publish", () => {
503
529
  ),
504
530
  ),
505
531
  ).to.be.true;
532
+ expect(
533
+ process.exitCode,
534
+ "a publish that never ran must not exit 0",
535
+ ).to.equal(1);
506
536
  });
507
537
 
508
538
  it("should request confirmation when autoConfirm is false", async function () {
@@ -544,6 +574,9 @@ describe("publish", () => {
544
574
  expect(createOrUpdatePackageStub.called).to.be.false;
545
575
  expect(loggerStub.info.calledWith(sinon.match("Operation cancelled."))).to
546
576
  .be.true;
577
+ // Declining the prompt is an answer, not a failure: it can only happen
578
+ // interactively, and a human who said no does not want a failed command.
579
+ expect(process.exitCode, "cancelling is not a failure").to.equal(0);
547
580
  });
548
581
 
549
582
  it("should handle API errors", async function () {
@@ -570,28 +603,10 @@ describe("publish", () => {
570
603
  expect(
571
604
  loggerStub.error.calledWith(sinon.match("Failed to publish package")),
572
605
  ).to.be.true;
573
- });
574
-
575
- it("should pass async=true to the API when asyncIndexing is set", async function () {
576
- this.timeout(5000);
577
- const mockManifest = {
578
- name: "test-package",
579
- version: "1.0.0",
580
- description: "Test package",
581
- };
582
- const mockPackageData = Buffer.from("test package data");
583
-
584
- readFileSyncStub.callsFake((filePath: string) => {
585
- if (filePath === "publisher.json") return JSON.stringify(mockManifest);
586
- return mockPackageData;
587
- });
588
- getConfirmationStub.resolves(true);
589
- createOrUpdatePackageStub.resolves({ data: {} });
590
- unlinkStub.callsArg(1);
591
-
592
- await publish("http://test-server", 2, false, true, false, true);
593
-
594
- expect(createOrUpdatePackageStub.firstCall.args[3]).to.equal(true);
606
+ // The log alone is not the contract: CI and scripts wrap `cred publish` and
607
+ // read its exit code, so a rejected publish exiting 0 reports success for a
608
+ // package that was never published.
609
+ expect(process.exitCode).to.equal(1);
595
610
  });
596
611
 
597
612
  it("should log package URL after successful publish", async function () {
@@ -13,30 +13,48 @@ import { validateManifest } from "../../validator";
13
13
  const packagesApi = new PackagesApi(new Configuration());
14
14
  const PACKAGE_MANIFEST_NAME = "publisher.json";
15
15
 
16
+ /**
17
+ * Record a publish failure: log it (when the caller has a message of its own to give)
18
+ * and mark the process failed.
19
+ *
20
+ * Every early return below is a publish that did not happen, so each one has to carry the
21
+ * same non-zero exit as a server rejection. CI and scripts wrap `cred publish` and read
22
+ * its exit code; exiting 0 tells them a package is there when it is not. Declining the
23
+ * confirmation prompt is deliberately NOT routed through here — that is an answer rather
24
+ * than a failure, and it can only happen interactively.
25
+ */
26
+ function failPublish(message?: string): void {
27
+ if (message) {
28
+ logger.error(message);
29
+ }
30
+ process.exitCode = 1;
31
+ }
32
+
16
33
  export async function publish(
17
34
  controlPlane: string,
18
35
  replicationCount: number,
19
36
  debug: boolean,
20
37
  autoConfirm: boolean,
21
38
  setLatest: boolean,
22
- asyncIndexing: boolean = false,
23
39
  ) {
24
40
  const clientConfig = new ClientConfiguration();
25
41
 
26
42
  if (!clientConfig.doesConfigExists()) {
27
- logger.error("Please, make sure that you are logged in");
43
+ failPublish("Please, make sure that you are logged in");
28
44
  return;
29
45
  }
30
46
 
31
47
  const tokenValidation = clientConfig.isTokenValid();
32
48
  if (!tokenValidation.valid) {
33
- logger.error(
49
+ failPublish(
34
50
  tokenValidation.reason || "Please, make sure that you are logged in",
35
51
  );
36
52
  return;
37
53
  }
38
54
 
39
55
  if (!validateManifest()) {
56
+ // validateManifest logs its own reason; only the exit code is missing.
57
+ failPublish();
40
58
  return;
41
59
  }
42
60
 
@@ -44,17 +62,17 @@ export async function publish(
44
62
  const organizationName = clientConfig.getOrganization();
45
63
 
46
64
  if (!organizationName) {
47
- logger.error("Please, make sure that you are logged in");
65
+ failPublish("Please, make sure that you are logged in");
48
66
  return;
49
67
  }
50
68
 
51
69
  if (!environmentName) {
52
- logger.error("Please, make sure to set an environment");
70
+ failPublish("Please, make sure to set an environment");
53
71
  return;
54
72
  }
55
73
 
56
74
  if (!fs.existsSync(PACKAGE_MANIFEST_NAME)) {
57
- logger.error(
75
+ failPublish(
58
76
  `Failed to publish the package. Could not find ${PACKAGE_MANIFEST_NAME}, please ensure you are in a directory containing ${PACKAGE_MANIFEST_NAME}`,
59
77
  );
60
78
  return;
@@ -90,7 +108,6 @@ export async function publish(
90
108
  packageManifest.version,
91
109
  debug,
92
110
  setLatest,
93
- asyncIndexing,
94
111
  );
95
112
  await removeTmpPackage(tmpPackagePath);
96
113
  }
@@ -135,7 +152,6 @@ async function pushTmpPackageToRemoteServer(
135
152
  versionId: string,
136
153
  debug: boolean,
137
154
  setLatest: boolean,
138
- asyncIndexing: boolean,
139
155
  ): Promise<undefined> {
140
156
  logger.info("Pushing package " + name + " version " + versionId);
141
157
 
@@ -180,11 +196,14 @@ async function pushTmpPackageToRemoteServer(
180
196
  organizationName,
181
197
  environmentName,
182
198
  name,
183
- asyncIndexing,
184
199
  _package,
185
200
  version,
186
201
  packageContents,
187
202
  md5Hash,
203
+ // draftId / workspace: a zip upload has no git-backed draft, so the server
204
+ // records no provenance. Positional because `options` must stay last.
205
+ undefined,
206
+ undefined,
188
207
  {
189
208
  baseURL: controlPlane,
190
209
  headers: clientConfig.getHeaders(),
@@ -200,7 +219,9 @@ async function pushTmpPackageToRemoteServer(
200
219
  );
201
220
  logger.info(`Package available at: ${packageUrl}`);
202
221
  } catch (e) {
203
- logger.error("Failed to publish package");
222
+ // The server rejected it: a model that does not compile, or a `#@ persist`
223
+ // declaration the publisher refuses to load.
224
+ failPublish("Failed to publish package");
204
225
  printOutError(e, debug);
205
226
  }
206
227
  }