@contember/cli 2.1.0-alpha.15 → 2.1.0-alpha.17

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 (191) hide show
  1. package/dist/development/src/commands/actions/ActionsGetEventCommand.cjs +31 -0
  2. package/dist/development/src/commands/actions/ActionsGetEventCommand.cjs.map +1 -0
  3. package/dist/development/src/commands/actions/ActionsGetEventCommand.js +31 -0
  4. package/dist/development/src/commands/actions/ActionsGetEventCommand.js.map +1 -0
  5. package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.cjs +60 -0
  6. package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.cjs.map +1 -0
  7. package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.js +60 -0
  8. package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.js.map +1 -0
  9. package/dist/development/src/commands/actions/ActionsListVariablesCommand.cjs +29 -0
  10. package/dist/development/src/commands/actions/ActionsListVariablesCommand.cjs.map +1 -0
  11. package/dist/development/src/commands/actions/ActionsListVariablesCommand.js +29 -0
  12. package/dist/development/src/commands/actions/ActionsListVariablesCommand.js.map +1 -0
  13. package/dist/development/src/commands/actions/ActionsRetryEventCommand.cjs +32 -0
  14. package/dist/development/src/commands/actions/ActionsRetryEventCommand.cjs.map +1 -0
  15. package/dist/development/src/commands/actions/ActionsRetryEventCommand.js +32 -0
  16. package/dist/development/src/commands/actions/ActionsRetryEventCommand.js.map +1 -0
  17. package/dist/development/src/commands/actions/ActionsSetVariablesCommand.cjs +40 -0
  18. package/dist/development/src/commands/actions/ActionsSetVariablesCommand.cjs.map +1 -0
  19. package/dist/development/src/commands/actions/ActionsSetVariablesCommand.js +40 -0
  20. package/dist/development/src/commands/actions/ActionsSetVariablesCommand.js.map +1 -0
  21. package/dist/development/src/commands/actions/ActionsStopEventCommand.cjs +32 -0
  22. package/dist/development/src/commands/actions/ActionsStopEventCommand.cjs.map +1 -0
  23. package/dist/development/src/commands/actions/ActionsStopEventCommand.js +32 -0
  24. package/dist/development/src/commands/actions/ActionsStopEventCommand.js.map +1 -0
  25. package/dist/development/src/commands/migrations/MigrationStatusCommand.cjs +1 -1
  26. package/dist/development/src/commands/migrations/MigrationStatusCommand.cjs.map +1 -1
  27. package/dist/development/src/commands/migrations/MigrationStatusCommand.js +1 -1
  28. package/dist/development/src/commands/migrations/MigrationStatusCommand.js.map +1 -1
  29. package/dist/development/src/commands/transfer/ExportCommand.cjs +7 -2
  30. package/dist/development/src/commands/transfer/ExportCommand.cjs.map +1 -1
  31. package/dist/development/src/commands/transfer/ExportCommand.js +8 -3
  32. package/dist/development/src/commands/transfer/ExportCommand.js.map +1 -1
  33. package/dist/development/src/commands/transfer/ImportCommand.cjs +7 -4
  34. package/dist/development/src/commands/transfer/ImportCommand.cjs.map +1 -1
  35. package/dist/development/src/commands/transfer/ImportCommand.js +5 -2
  36. package/dist/development/src/commands/transfer/ImportCommand.js.map +1 -1
  37. package/dist/development/src/commands/transfer/TransferCommand.cjs +4 -5
  38. package/dist/development/src/commands/transfer/TransferCommand.cjs.map +1 -1
  39. package/dist/development/src/commands/transfer/TransferCommand.js +4 -5
  40. package/dist/development/src/commands/transfer/TransferCommand.js.map +1 -1
  41. package/dist/development/src/dic.cjs +14 -2
  42. package/dist/development/src/dic.cjs.map +1 -1
  43. package/dist/development/src/dic.js +14 -2
  44. package/dist/development/src/dic.js.map +1 -1
  45. package/dist/development/src/lib/VersionChecker.cjs +7 -9
  46. package/dist/development/src/lib/VersionChecker.cjs.map +1 -1
  47. package/dist/development/src/lib/VersionChecker.js +7 -9
  48. package/dist/development/src/lib/VersionChecker.js.map +1 -1
  49. package/dist/development/src/lib/actions/ActionsClient.cjs +91 -0
  50. package/dist/development/src/lib/actions/ActionsClient.cjs.map +1 -0
  51. package/dist/development/src/lib/actions/ActionsClient.js +91 -0
  52. package/dist/development/src/lib/actions/ActionsClient.js.map +1 -0
  53. package/dist/development/src/lib/migrations/MigrationPrinter.cjs +7 -2
  54. package/dist/development/src/lib/migrations/MigrationPrinter.cjs.map +1 -1
  55. package/dist/development/src/lib/migrations/MigrationPrinter.js +7 -2
  56. package/dist/development/src/lib/migrations/MigrationPrinter.js.map +1 -1
  57. package/dist/development/src/lib/migrations/MigrationsStatusFacade.cjs +3 -3
  58. package/dist/development/src/lib/migrations/MigrationsStatusFacade.cjs.map +1 -1
  59. package/dist/development/src/lib/migrations/MigrationsStatusFacade.js +3 -3
  60. package/dist/development/src/lib/migrations/MigrationsStatusFacade.js.map +1 -1
  61. package/dist/development/src/lib/stream.cjs +0 -7
  62. package/dist/development/src/lib/stream.cjs.map +1 -1
  63. package/dist/development/src/lib/stream.js +1 -8
  64. package/dist/development/src/lib/stream.js.map +1 -1
  65. package/dist/development/src/lib/transfer/DataTransferClient.cjs +23 -34
  66. package/dist/development/src/lib/transfer/DataTransferClient.cjs.map +1 -1
  67. package/dist/development/src/lib/transfer/DataTransferClient.js +25 -36
  68. package/dist/development/src/lib/transfer/DataTransferClient.js.map +1 -1
  69. package/dist/production/src/commands/actions/ActionsGetEventCommand.cjs +31 -0
  70. package/dist/production/src/commands/actions/ActionsGetEventCommand.cjs.map +1 -0
  71. package/dist/production/src/commands/actions/ActionsGetEventCommand.js +31 -0
  72. package/dist/production/src/commands/actions/ActionsGetEventCommand.js.map +1 -0
  73. package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.cjs +60 -0
  74. package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.cjs.map +1 -0
  75. package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.js +60 -0
  76. package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.js.map +1 -0
  77. package/dist/production/src/commands/actions/ActionsListVariablesCommand.cjs +29 -0
  78. package/dist/production/src/commands/actions/ActionsListVariablesCommand.cjs.map +1 -0
  79. package/dist/production/src/commands/actions/ActionsListVariablesCommand.js +29 -0
  80. package/dist/production/src/commands/actions/ActionsListVariablesCommand.js.map +1 -0
  81. package/dist/production/src/commands/actions/ActionsRetryEventCommand.cjs +32 -0
  82. package/dist/production/src/commands/actions/ActionsRetryEventCommand.cjs.map +1 -0
  83. package/dist/production/src/commands/actions/ActionsRetryEventCommand.js +32 -0
  84. package/dist/production/src/commands/actions/ActionsRetryEventCommand.js.map +1 -0
  85. package/dist/production/src/commands/actions/ActionsSetVariablesCommand.cjs +40 -0
  86. package/dist/production/src/commands/actions/ActionsSetVariablesCommand.cjs.map +1 -0
  87. package/dist/production/src/commands/actions/ActionsSetVariablesCommand.js +40 -0
  88. package/dist/production/src/commands/actions/ActionsSetVariablesCommand.js.map +1 -0
  89. package/dist/production/src/commands/actions/ActionsStopEventCommand.cjs +32 -0
  90. package/dist/production/src/commands/actions/ActionsStopEventCommand.cjs.map +1 -0
  91. package/dist/production/src/commands/actions/ActionsStopEventCommand.js +32 -0
  92. package/dist/production/src/commands/actions/ActionsStopEventCommand.js.map +1 -0
  93. package/dist/production/src/commands/migrations/MigrationStatusCommand.cjs +1 -1
  94. package/dist/production/src/commands/migrations/MigrationStatusCommand.cjs.map +1 -1
  95. package/dist/production/src/commands/migrations/MigrationStatusCommand.js +1 -1
  96. package/dist/production/src/commands/migrations/MigrationStatusCommand.js.map +1 -1
  97. package/dist/production/src/commands/transfer/ExportCommand.cjs +7 -2
  98. package/dist/production/src/commands/transfer/ExportCommand.cjs.map +1 -1
  99. package/dist/production/src/commands/transfer/ExportCommand.js +8 -3
  100. package/dist/production/src/commands/transfer/ExportCommand.js.map +1 -1
  101. package/dist/production/src/commands/transfer/ImportCommand.cjs +7 -4
  102. package/dist/production/src/commands/transfer/ImportCommand.cjs.map +1 -1
  103. package/dist/production/src/commands/transfer/ImportCommand.js +5 -2
  104. package/dist/production/src/commands/transfer/ImportCommand.js.map +1 -1
  105. package/dist/production/src/commands/transfer/TransferCommand.cjs +4 -5
  106. package/dist/production/src/commands/transfer/TransferCommand.cjs.map +1 -1
  107. package/dist/production/src/commands/transfer/TransferCommand.js +4 -5
  108. package/dist/production/src/commands/transfer/TransferCommand.js.map +1 -1
  109. package/dist/production/src/dic.cjs +14 -2
  110. package/dist/production/src/dic.cjs.map +1 -1
  111. package/dist/production/src/dic.js +14 -2
  112. package/dist/production/src/dic.js.map +1 -1
  113. package/dist/production/src/lib/VersionChecker.cjs +7 -9
  114. package/dist/production/src/lib/VersionChecker.cjs.map +1 -1
  115. package/dist/production/src/lib/VersionChecker.js +7 -9
  116. package/dist/production/src/lib/VersionChecker.js.map +1 -1
  117. package/dist/production/src/lib/actions/ActionsClient.cjs +91 -0
  118. package/dist/production/src/lib/actions/ActionsClient.cjs.map +1 -0
  119. package/dist/production/src/lib/actions/ActionsClient.js +91 -0
  120. package/dist/production/src/lib/actions/ActionsClient.js.map +1 -0
  121. package/dist/production/src/lib/migrations/MigrationPrinter.cjs +7 -2
  122. package/dist/production/src/lib/migrations/MigrationPrinter.cjs.map +1 -1
  123. package/dist/production/src/lib/migrations/MigrationPrinter.js +7 -2
  124. package/dist/production/src/lib/migrations/MigrationPrinter.js.map +1 -1
  125. package/dist/production/src/lib/migrations/MigrationsStatusFacade.cjs +3 -3
  126. package/dist/production/src/lib/migrations/MigrationsStatusFacade.cjs.map +1 -1
  127. package/dist/production/src/lib/migrations/MigrationsStatusFacade.js +3 -3
  128. package/dist/production/src/lib/migrations/MigrationsStatusFacade.js.map +1 -1
  129. package/dist/production/src/lib/stream.cjs +0 -7
  130. package/dist/production/src/lib/stream.cjs.map +1 -1
  131. package/dist/production/src/lib/stream.js +1 -8
  132. package/dist/production/src/lib/stream.js.map +1 -1
  133. package/dist/production/src/lib/transfer/DataTransferClient.cjs +23 -34
  134. package/dist/production/src/lib/transfer/DataTransferClient.cjs.map +1 -1
  135. package/dist/production/src/lib/transfer/DataTransferClient.js +25 -36
  136. package/dist/production/src/lib/transfer/DataTransferClient.js.map +1 -1
  137. package/dist/types/commands/actions/ActionsGetEventCommand.d.ts +16 -0
  138. package/dist/types/commands/actions/ActionsGetEventCommand.d.ts.map +1 -0
  139. package/dist/types/commands/actions/ActionsListFailedEventsCommand.d.ts +15 -0
  140. package/dist/types/commands/actions/ActionsListFailedEventsCommand.d.ts.map +1 -0
  141. package/dist/types/commands/actions/ActionsListVariablesCommand.d.ts +14 -0
  142. package/dist/types/commands/actions/ActionsListVariablesCommand.d.ts.map +1 -0
  143. package/dist/types/commands/actions/ActionsRetryEventCommand.d.ts +16 -0
  144. package/dist/types/commands/actions/ActionsRetryEventCommand.d.ts.map +1 -0
  145. package/dist/types/commands/actions/ActionsSetVariablesCommand.d.ts +19 -0
  146. package/dist/types/commands/actions/ActionsSetVariablesCommand.d.ts.map +1 -0
  147. package/dist/types/commands/actions/ActionsStopEventCommand.d.ts +16 -0
  148. package/dist/types/commands/actions/ActionsStopEventCommand.d.ts.map +1 -0
  149. package/dist/types/commands/transfer/ExportCommand.d.ts.map +1 -1
  150. package/dist/types/commands/transfer/ImportCommand.d.ts.map +1 -1
  151. package/dist/types/commands/transfer/TransferCommand.d.ts.map +1 -1
  152. package/dist/types/dic.d.ts +18 -0
  153. package/dist/types/dic.d.ts.map +1 -1
  154. package/dist/types/lib/VersionChecker.d.ts.map +1 -1
  155. package/dist/types/lib/actions/ActionsClient.d.ts +33 -0
  156. package/dist/types/lib/actions/ActionsClient.d.ts.map +1 -0
  157. package/dist/types/lib/migrations/MigrationPrinter.d.ts +1 -1
  158. package/dist/types/lib/migrations/MigrationPrinter.d.ts.map +1 -1
  159. package/dist/types/lib/migrations/MigrationsStatusFacade.d.ts +3 -1
  160. package/dist/types/lib/migrations/MigrationsStatusFacade.d.ts.map +1 -1
  161. package/dist/types/lib/transfer/DataTransferClient.d.ts +2 -4
  162. package/dist/types/lib/transfer/DataTransferClient.d.ts.map +1 -1
  163. package/dist/types/tsconfig.tsbuildinfo +1 -1
  164. package/package.json +1 -1
  165. package/src/commands/actions/ActionsGetEventCommand.ts +42 -0
  166. package/src/commands/actions/ActionsListFailedEventsCommand.ts +70 -0
  167. package/src/commands/actions/ActionsListVariablesCommand.ts +37 -0
  168. package/src/commands/actions/ActionsRetryEventCommand.ts +42 -0
  169. package/src/commands/actions/ActionsSetVariablesCommand.ts +56 -0
  170. package/src/commands/actions/ActionsStopEventCommand.ts +42 -0
  171. package/src/commands/migrations/MigrationStatusCommand.ts +1 -1
  172. package/src/commands/transfer/ExportCommand.ts +9 -4
  173. package/src/commands/transfer/ImportCommand.ts +6 -1
  174. package/src/commands/transfer/TransferCommand.ts +4 -3
  175. package/src/dic.ts +27 -2
  176. package/src/lib/VersionChecker.ts +13 -9
  177. package/src/lib/actions/ActionsClient.ts +112 -0
  178. package/src/lib/migrations/MigrationPrinter.ts +7 -2
  179. package/src/lib/migrations/MigrationsStatusFacade.ts +4 -3
  180. package/src/lib/transfer/DataTransferClient.ts +24 -43
  181. package/dist/development/src/lib/migrations/migrations.cjs +0 -43
  182. package/dist/development/src/lib/migrations/migrations.cjs.map +0 -1
  183. package/dist/development/src/lib/migrations/migrations.js +0 -43
  184. package/dist/development/src/lib/migrations/migrations.js.map +0 -1
  185. package/dist/production/src/lib/migrations/migrations.cjs +0 -43
  186. package/dist/production/src/lib/migrations/migrations.cjs.map +0 -1
  187. package/dist/production/src/lib/migrations/migrations.js +0 -43
  188. package/dist/production/src/lib/migrations/migrations.js.map +0 -1
  189. package/dist/types/lib/migrations/migrations.d.ts +0 -3
  190. package/dist/types/lib/migrations/migrations.d.ts.map +0 -1
  191. package/src/lib/migrations/migrations.ts +0 -45
@@ -1,20 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const migrations = require("./migrations.cjs");
4
3
  var __defProp = Object.defineProperty;
5
4
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
5
  var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
7
6
  class MigrationsStatusFacade {
8
- constructor(systemClientProvider, migrationsResolver, migrationsStatusResolver) {
7
+ constructor(systemClientProvider, migrationsResolver, migrationsStatusResolver, migrationPrinter) {
9
8
  this.systemClientProvider = systemClientProvider;
10
9
  this.migrationsResolver = migrationsResolver;
11
10
  this.migrationsStatusResolver = migrationsStatusResolver;
11
+ this.migrationPrinter = migrationPrinter;
12
12
  __publicField(this, "resolveMigrationsStatus", async ({ force, allowError }) => {
13
13
  const executedMigrations = await this.systemClientProvider.get().listExecutedMigrations();
14
14
  const localMigrations = await this.migrationsResolver.getMigrationFiles();
15
15
  const status = await this.migrationsStatusResolver.getMigrationsStatus(executedMigrations, localMigrations, force);
16
16
  if (status.errorMigrations.length > 0 && !allowError) {
17
- console.error(migrations.createMigrationStatusTable(status.errorMigrations));
17
+ console.error(this.migrationPrinter.printStatusTable(status.errorMigrations));
18
18
  if (!force) {
19
19
  throw `Cannot execute migrations`;
20
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationsStatusFacade.cjs","sources":["../../../../../../packages/cli/src/lib/migrations/MigrationsStatusFacade.ts"],"sourcesContent":["import { MigrationsResolver, MigrationsStatusResolver, SystemClient } from '@contember/migrations-client'\nimport { createMigrationStatusTable } from './migrations'\nimport { SystemClientProvider } from '../SystemClientProvider'\n\nexport class MigrationsStatusFacade {\n\tconstructor(\n\t\tprivate readonly systemClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly migrationsStatusResolver: MigrationsStatusResolver,\n\t) {\n\t}\n\n\n\tpublic resolveMigrationsStatus = async ({ force, allowError }: { force?: boolean; allowError?: boolean }) => {\n\t\tconst executedMigrations = await this.systemClientProvider.get().listExecutedMigrations()\n\t\tconst localMigrations = await this.migrationsResolver.getMigrationFiles()\n\t\tconst status = await this.migrationsStatusResolver.getMigrationsStatus(executedMigrations, localMigrations, force)\n\t\tif (status.errorMigrations.length > 0 && !allowError) {\n\t\t\tconsole.error(createMigrationStatusTable(status.errorMigrations))\n\t\t\tif (!force) {\n\t\t\t\tthrow `Cannot execute migrations`\n\t\t\t}\n\t\t}\n\n\t\treturn status\n\t}\n}\n"],"names":["createMigrationStatusTable"],"mappings":";;;;;;AAIO,MAAM,uBAAuB;AAAA,EACnC,YACkB,sBACA,oBACA,0BAChB;AAHgB,SAAA,uBAAA;AACA,SAAA,qBAAA;AACA,SAAA,2BAAA;AAKlB,kBAAA,MAAO,2BAA0B,OAAO,EAAE,OAAO,iBAA4D;AAC5G,YAAM,qBAAqB,MAAM,KAAK,qBAAqB,IAAA,EAAM,uBAAuB;AACxF,YAAM,kBAAkB,MAAM,KAAK,mBAAmB,kBAAkB;AACxE,YAAM,SAAS,MAAM,KAAK,yBAAyB,oBAAoB,oBAAoB,iBAAiB,KAAK;AACjH,UAAI,OAAO,gBAAgB,SAAS,KAAK,CAAC,YAAY;AACrD,gBAAQ,MAAMA,WAAAA,2BAA2B,OAAO,eAAe,CAAC;AAChE,YAAI,CAAC,OAAO;AACL,gBAAA;AAAA,QAAA;AAAA,MACP;AAGM,aAAA;AAAA,IAAA,CACR;AAAA,EAAA;AACD;;"}
1
+ {"version":3,"file":"MigrationsStatusFacade.cjs","sources":["../../../../../../packages/cli/src/lib/migrations/MigrationsStatusFacade.ts"],"sourcesContent":["import { MigrationsResolver, MigrationsStatusResolver } from '@contember/migrations-client'\nimport { SystemClientProvider } from '../SystemClientProvider'\nimport { MigrationPrinter } from './MigrationPrinter'\n\nexport class MigrationsStatusFacade {\n\tconstructor(\n\t\tprivate readonly systemClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly migrationsStatusResolver: MigrationsStatusResolver,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t) {\n\t}\n\n\n\tpublic resolveMigrationsStatus = async ({ force, allowError }: { force?: boolean; allowError?: boolean }) => {\n\t\tconst executedMigrations = await this.systemClientProvider.get().listExecutedMigrations()\n\t\tconst localMigrations = await this.migrationsResolver.getMigrationFiles()\n\t\tconst status = await this.migrationsStatusResolver.getMigrationsStatus(executedMigrations, localMigrations, force)\n\t\tif (status.errorMigrations.length > 0 && !allowError) {\n\t\t\tconsole.error(this.migrationPrinter.printStatusTable(status.errorMigrations))\n\t\t\tif (!force) {\n\t\t\t\tthrow `Cannot execute migrations`\n\t\t\t}\n\t\t}\n\n\t\treturn status\n\t}\n}\n"],"names":[],"mappings":";;;;;AAIO,MAAM,uBAAuB;AAAA,EACnC,YACkB,sBACA,oBACA,0BACA,kBAChB;AAJgB,SAAA,uBAAA;AACA,SAAA,qBAAA;AACA,SAAA,2BAAA;AACA,SAAA,mBAAA;AAKlB,kBAAA,MAAO,2BAA0B,OAAO,EAAE,OAAO,iBAA4D;AAC5G,YAAM,qBAAqB,MAAM,KAAK,qBAAqB,IAAA,EAAM,uBAAuB;AACxF,YAAM,kBAAkB,MAAM,KAAK,mBAAmB,kBAAkB;AACxE,YAAM,SAAS,MAAM,KAAK,yBAAyB,oBAAoB,oBAAoB,iBAAiB,KAAK;AACjH,UAAI,OAAO,gBAAgB,SAAS,KAAK,CAAC,YAAY;AACrD,gBAAQ,MAAM,KAAK,iBAAiB,iBAAiB,OAAO,eAAe,CAAC;AAC5E,YAAI,CAAC,OAAO;AACL,gBAAA;AAAA,QAAA;AAAA,MACP;AAGM,aAAA;AAAA,IAAA,CACR;AAAA,EAAA;AACD;;"}
@@ -1,18 +1,18 @@
1
- import { createMigrationStatusTable } from "./migrations.js";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
5
4
  class MigrationsStatusFacade {
6
- constructor(systemClientProvider, migrationsResolver, migrationsStatusResolver) {
5
+ constructor(systemClientProvider, migrationsResolver, migrationsStatusResolver, migrationPrinter) {
7
6
  this.systemClientProvider = systemClientProvider;
8
7
  this.migrationsResolver = migrationsResolver;
9
8
  this.migrationsStatusResolver = migrationsStatusResolver;
9
+ this.migrationPrinter = migrationPrinter;
10
10
  __publicField(this, "resolveMigrationsStatus", async ({ force, allowError }) => {
11
11
  const executedMigrations = await this.systemClientProvider.get().listExecutedMigrations();
12
12
  const localMigrations = await this.migrationsResolver.getMigrationFiles();
13
13
  const status = await this.migrationsStatusResolver.getMigrationsStatus(executedMigrations, localMigrations, force);
14
14
  if (status.errorMigrations.length > 0 && !allowError) {
15
- console.error(createMigrationStatusTable(status.errorMigrations));
15
+ console.error(this.migrationPrinter.printStatusTable(status.errorMigrations));
16
16
  if (!force) {
17
17
  throw `Cannot execute migrations`;
18
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationsStatusFacade.js","sources":["../../../../../../packages/cli/src/lib/migrations/MigrationsStatusFacade.ts"],"sourcesContent":["import { MigrationsResolver, MigrationsStatusResolver, SystemClient } from '@contember/migrations-client'\nimport { createMigrationStatusTable } from './migrations'\nimport { SystemClientProvider } from '../SystemClientProvider'\n\nexport class MigrationsStatusFacade {\n\tconstructor(\n\t\tprivate readonly systemClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly migrationsStatusResolver: MigrationsStatusResolver,\n\t) {\n\t}\n\n\n\tpublic resolveMigrationsStatus = async ({ force, allowError }: { force?: boolean; allowError?: boolean }) => {\n\t\tconst executedMigrations = await this.systemClientProvider.get().listExecutedMigrations()\n\t\tconst localMigrations = await this.migrationsResolver.getMigrationFiles()\n\t\tconst status = await this.migrationsStatusResolver.getMigrationsStatus(executedMigrations, localMigrations, force)\n\t\tif (status.errorMigrations.length > 0 && !allowError) {\n\t\t\tconsole.error(createMigrationStatusTable(status.errorMigrations))\n\t\t\tif (!force) {\n\t\t\t\tthrow `Cannot execute migrations`\n\t\t\t}\n\t\t}\n\n\t\treturn status\n\t}\n}\n"],"names":[],"mappings":";;;;AAIO,MAAM,uBAAuB;AAAA,EACnC,YACkB,sBACA,oBACA,0BAChB;AAHgB,SAAA,uBAAA;AACA,SAAA,qBAAA;AACA,SAAA,2BAAA;AAKlB,kBAAA,MAAO,2BAA0B,OAAO,EAAE,OAAO,iBAA4D;AAC5G,YAAM,qBAAqB,MAAM,KAAK,qBAAqB,IAAA,EAAM,uBAAuB;AACxF,YAAM,kBAAkB,MAAM,KAAK,mBAAmB,kBAAkB;AACxE,YAAM,SAAS,MAAM,KAAK,yBAAyB,oBAAoB,oBAAoB,iBAAiB,KAAK;AACjH,UAAI,OAAO,gBAAgB,SAAS,KAAK,CAAC,YAAY;AACrD,gBAAQ,MAAM,2BAA2B,OAAO,eAAe,CAAC;AAChE,YAAI,CAAC,OAAO;AACL,gBAAA;AAAA,QAAA;AAAA,MACP;AAGM,aAAA;AAAA,IAAA,CACR;AAAA,EAAA;AACD;"}
1
+ {"version":3,"file":"MigrationsStatusFacade.js","sources":["../../../../../../packages/cli/src/lib/migrations/MigrationsStatusFacade.ts"],"sourcesContent":["import { MigrationsResolver, MigrationsStatusResolver } from '@contember/migrations-client'\nimport { SystemClientProvider } from '../SystemClientProvider'\nimport { MigrationPrinter } from './MigrationPrinter'\n\nexport class MigrationsStatusFacade {\n\tconstructor(\n\t\tprivate readonly systemClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly migrationsStatusResolver: MigrationsStatusResolver,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t) {\n\t}\n\n\n\tpublic resolveMigrationsStatus = async ({ force, allowError }: { force?: boolean; allowError?: boolean }) => {\n\t\tconst executedMigrations = await this.systemClientProvider.get().listExecutedMigrations()\n\t\tconst localMigrations = await this.migrationsResolver.getMigrationFiles()\n\t\tconst status = await this.migrationsStatusResolver.getMigrationsStatus(executedMigrations, localMigrations, force)\n\t\tif (status.errorMigrations.length > 0 && !allowError) {\n\t\t\tconsole.error(this.migrationPrinter.printStatusTable(status.errorMigrations))\n\t\t\tif (!force) {\n\t\t\t\tthrow `Cannot execute migrations`\n\t\t\t}\n\t\t}\n\n\t\treturn status\n\t}\n}\n"],"names":[],"mappings":";;;AAIO,MAAM,uBAAuB;AAAA,EACnC,YACkB,sBACA,oBACA,0BACA,kBAChB;AAJgB,SAAA,uBAAA;AACA,SAAA,qBAAA;AACA,SAAA,2BAAA;AACA,SAAA,mBAAA;AAKlB,kBAAA,MAAO,2BAA0B,OAAO,EAAE,OAAO,iBAA4D;AAC5G,YAAM,qBAAqB,MAAM,KAAK,qBAAqB,IAAA,EAAM,uBAAuB;AACxF,YAAM,kBAAkB,MAAM,KAAK,mBAAmB,kBAAkB;AACxE,YAAM,SAAS,MAAM,KAAK,yBAAyB,oBAAoB,oBAAoB,iBAAiB,KAAK;AACjH,UAAI,OAAO,gBAAgB,SAAS,KAAK,CAAC,YAAY;AACrD,gBAAQ,MAAM,KAAK,iBAAiB,iBAAiB,OAAO,eAAe,CAAC;AAC5E,YAAI,CAAC,OAAO;AACL,gBAAA;AAAA,QAAA;AAAA,MACP;AAGM,aAAA;AAAA,IAAA,CACR;AAAA,EAAA;AACD;"}
@@ -32,12 +32,5 @@ class LineTransform extends node_stream.Transform {
32
32
  __publicField(this, "chunks", []);
33
33
  }
34
34
  }
35
- const readStream = async (stream) => new Promise((resolve, reject) => {
36
- const chunks = [];
37
- stream.on("error", (err) => reject(err));
38
- stream.on("data", (chunk) => chunks.push(chunk));
39
- stream.on("end", () => resolve(node_buffer.Buffer.concat(chunks)));
40
- });
41
35
  exports.LineTransform = LineTransform;
42
- exports.readStream = readStream;
43
36
  //# sourceMappingURL=stream.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream.cjs","sources":["../../../../../packages/cli/src/lib/stream.ts"],"sourcesContent":["import { Stream, Transform } from 'node:stream'\nimport { Buffer } from 'node:buffer'\n\n\nexport class LineTransform extends Transform {\n\tprivate chunks: Buffer[] = []\n\n\tconstructor(transform: (line: string) => string) {\n\t\tsuper({\n\t\t\ttransform: (chunk, encoding, done) => {\n\t\t\t\twhile (true) {\n\t\t\t\t\tconst eolIndex = chunk.indexOf('\\n')\n\n\t\t\t\t\tif (eolIndex < 0) {\n\t\t\t\t\t\tthis.chunks.push(chunk)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.chunks.push(chunk.slice(0, eolIndex))\n\t\t\t\t\tchunk = chunk.slice(eolIndex + 1)\n\t\t\t\t\tthis.push(transform(Buffer.concat(this.chunks).toString('utf8')) + '\\n', 'utf8')\n\t\t\t\t\tthis.chunks = []\n\t\t\t\t}\n\n\t\t\t\treturn done()\n\t\t\t},\n\n\t\t\tflush: done => {\n\t\t\t\tif (this.chunks.length) {\n\t\t\t\t\tthis.push(transform(Buffer.concat(this.chunks).toString('utf8')), 'utf8')\n\t\t\t\t\treturn done()\n\t\t\t\t}\n\t\t\t},\n\t\t})\n\t}\n}\n\n\nexport const readStream = async (stream: Stream) => new Promise<Buffer>((resolve, reject) => {\n\tconst chunks: Buffer[] = []\n\tstream.on('error', err => reject(err))\n\tstream.on('data', chunk => chunks.push(chunk))\n\tstream.on('end', () => resolve(Buffer.concat(chunks)))\n})\n"],"names":["Transform","Buffer"],"mappings":";;;;;;;AAIO,MAAM,sBAAsBA,YAAAA,UAAU;AAAA,EAG5C,YAAY,WAAqC;AAC1C,UAAA;AAAA,MACL,WAAW,CAAC,OAAO,UAAU,SAAS;AACrC,eAAO,MAAM;AACN,gBAAA,WAAW,MAAM,QAAQ,IAAI;AAEnC,cAAI,WAAW,GAAG;AACZ,iBAAA,OAAO,KAAK,KAAK;AACtB;AAAA,UAAA;AAGD,eAAK,OAAO,KAAK,MAAM,MAAM,GAAG,QAAQ,CAAC;AACjC,kBAAA,MAAM,MAAM,WAAW,CAAC;AAChC,eAAK,KAAK,UAAUC,YAAO,OAAA,OAAO,KAAK,MAAM,EAAE,SAAS,MAAM,CAAC,IAAI,MAAM,MAAM;AAC/E,eAAK,SAAS,CAAC;AAAA,QAAA;AAGhB,eAAO,KAAK;AAAA,MACb;AAAA,MAEA,OAAO,CAAQ,SAAA;AACV,YAAA,KAAK,OAAO,QAAQ;AAClB,eAAA,KAAK,UAAUA,YAAAA,OAAO,OAAO,KAAK,MAAM,EAAE,SAAS,MAAM,CAAC,GAAG,MAAM;AACxE,iBAAO,KAAK;AAAA,QAAA;AAAA,MACb;AAAA,IACD,CACA;AA5BF,kBAAA,MAAQ,UAAmB,EAAC;AAAA,EAAA;AA8B7B;AAGO,MAAM,aAAa,OAAO,WAAmB,IAAI,QAAgB,CAAC,SAAS,WAAW;AAC5F,QAAM,SAAmB,CAAC;AAC1B,SAAO,GAAG,SAAS,CAAO,QAAA,OAAO,GAAG,CAAC;AACrC,SAAO,GAAG,QAAQ,CAAA,UAAS,OAAO,KAAK,KAAK,CAAC;AACtC,SAAA,GAAG,OAAO,MAAM,QAAQA,YAAAA,OAAO,OAAO,MAAM,CAAC,CAAC;AACtD,CAAC;;;"}
1
+ {"version":3,"file":"stream.cjs","sources":["../../../../../packages/cli/src/lib/stream.ts"],"sourcesContent":["import { Stream, Transform } from 'node:stream'\nimport { Buffer } from 'node:buffer'\n\n\nexport class LineTransform extends Transform {\n\tprivate chunks: Buffer[] = []\n\n\tconstructor(transform: (line: string) => string) {\n\t\tsuper({\n\t\t\ttransform: (chunk, encoding, done) => {\n\t\t\t\twhile (true) {\n\t\t\t\t\tconst eolIndex = chunk.indexOf('\\n')\n\n\t\t\t\t\tif (eolIndex < 0) {\n\t\t\t\t\t\tthis.chunks.push(chunk)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.chunks.push(chunk.slice(0, eolIndex))\n\t\t\t\t\tchunk = chunk.slice(eolIndex + 1)\n\t\t\t\t\tthis.push(transform(Buffer.concat(this.chunks).toString('utf8')) + '\\n', 'utf8')\n\t\t\t\t\tthis.chunks = []\n\t\t\t\t}\n\n\t\t\t\treturn done()\n\t\t\t},\n\n\t\t\tflush: done => {\n\t\t\t\tif (this.chunks.length) {\n\t\t\t\t\tthis.push(transform(Buffer.concat(this.chunks).toString('utf8')), 'utf8')\n\t\t\t\t\treturn done()\n\t\t\t\t}\n\t\t\t},\n\t\t})\n\t}\n}\n\n\nexport const readStream = async (stream: Stream) => new Promise<Buffer>((resolve, reject) => {\n\tconst chunks: Buffer[] = []\n\tstream.on('error', err => reject(err))\n\tstream.on('data', chunk => chunks.push(chunk))\n\tstream.on('end', () => resolve(Buffer.concat(chunks)))\n})\n"],"names":["Transform","Buffer"],"mappings":";;;;;;;AAIO,MAAM,sBAAsBA,YAAAA,UAAU;AAAA,EAG5C,YAAY,WAAqC;AAC1C,UAAA;AAAA,MACL,WAAW,CAAC,OAAO,UAAU,SAAS;AACrC,eAAO,MAAM;AACN,gBAAA,WAAW,MAAM,QAAQ,IAAI;AAEnC,cAAI,WAAW,GAAG;AACZ,iBAAA,OAAO,KAAK,KAAK;AACtB;AAAA,UAAA;AAGD,eAAK,OAAO,KAAK,MAAM,MAAM,GAAG,QAAQ,CAAC;AACjC,kBAAA,MAAM,MAAM,WAAW,CAAC;AAChC,eAAK,KAAK,UAAUC,YAAO,OAAA,OAAO,KAAK,MAAM,EAAE,SAAS,MAAM,CAAC,IAAI,MAAM,MAAM;AAC/E,eAAK,SAAS,CAAC;AAAA,QAAA;AAGhB,eAAO,KAAK;AAAA,MACb;AAAA,MAEA,OAAO,CAAQ,SAAA;AACV,YAAA,KAAK,OAAO,QAAQ;AAClB,eAAA,KAAK,UAAUA,YAAAA,OAAO,OAAO,KAAK,MAAM,EAAE,SAAS,MAAM,CAAC,GAAG,MAAM;AACxE,iBAAO,KAAK;AAAA,QAAA;AAAA,MACb;AAAA,IACD,CACA;AA5BF,kBAAA,MAAQ,UAAmB,EAAC;AAAA,EAAA;AA8B7B;;"}
@@ -30,14 +30,7 @@ class LineTransform extends Transform {
30
30
  __publicField(this, "chunks", []);
31
31
  }
32
32
  }
33
- const readStream = async (stream) => new Promise((resolve, reject) => {
34
- const chunks = [];
35
- stream.on("error", (err) => reject(err));
36
- stream.on("data", (chunk) => chunks.push(chunk));
37
- stream.on("end", () => resolve(Buffer.concat(chunks)));
38
- });
39
33
  export {
40
- LineTransform,
41
- readStream
34
+ LineTransform
42
35
  };
43
36
  //# sourceMappingURL=stream.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream.js","sources":["../../../../../packages/cli/src/lib/stream.ts"],"sourcesContent":["import { Stream, Transform } from 'node:stream'\nimport { Buffer } from 'node:buffer'\n\n\nexport class LineTransform extends Transform {\n\tprivate chunks: Buffer[] = []\n\n\tconstructor(transform: (line: string) => string) {\n\t\tsuper({\n\t\t\ttransform: (chunk, encoding, done) => {\n\t\t\t\twhile (true) {\n\t\t\t\t\tconst eolIndex = chunk.indexOf('\\n')\n\n\t\t\t\t\tif (eolIndex < 0) {\n\t\t\t\t\t\tthis.chunks.push(chunk)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.chunks.push(chunk.slice(0, eolIndex))\n\t\t\t\t\tchunk = chunk.slice(eolIndex + 1)\n\t\t\t\t\tthis.push(transform(Buffer.concat(this.chunks).toString('utf8')) + '\\n', 'utf8')\n\t\t\t\t\tthis.chunks = []\n\t\t\t\t}\n\n\t\t\t\treturn done()\n\t\t\t},\n\n\t\t\tflush: done => {\n\t\t\t\tif (this.chunks.length) {\n\t\t\t\t\tthis.push(transform(Buffer.concat(this.chunks).toString('utf8')), 'utf8')\n\t\t\t\t\treturn done()\n\t\t\t\t}\n\t\t\t},\n\t\t})\n\t}\n}\n\n\nexport const readStream = async (stream: Stream) => new Promise<Buffer>((resolve, reject) => {\n\tconst chunks: Buffer[] = []\n\tstream.on('error', err => reject(err))\n\tstream.on('data', chunk => chunks.push(chunk))\n\tstream.on('end', () => resolve(Buffer.concat(chunks)))\n})\n"],"names":["Buffer"],"mappings":";;;;;AAIO,MAAM,sBAAsB,UAAU;AAAA,EAG5C,YAAY,WAAqC;AAC1C,UAAA;AAAA,MACL,WAAW,CAAC,OAAO,UAAU,SAAS;AACrC,eAAO,MAAM;AACN,gBAAA,WAAW,MAAM,QAAQ,IAAI;AAEnC,cAAI,WAAW,GAAG;AACZ,iBAAA,OAAO,KAAK,KAAK;AACtB;AAAA,UAAA;AAGD,eAAK,OAAO,KAAK,MAAM,MAAM,GAAG,QAAQ,CAAC;AACjC,kBAAA,MAAM,MAAM,WAAW,CAAC;AAChC,eAAK,KAAK,UAAUA,OAAO,OAAO,KAAK,MAAM,EAAE,SAAS,MAAM,CAAC,IAAI,MAAM,MAAM;AAC/E,eAAK,SAAS,CAAC;AAAA,QAAA;AAGhB,eAAO,KAAK;AAAA,MACb;AAAA,MAEA,OAAO,CAAQ,SAAA;AACV,YAAA,KAAK,OAAO,QAAQ;AAClB,eAAA,KAAK,UAAUA,OAAO,OAAO,KAAK,MAAM,EAAE,SAAS,MAAM,CAAC,GAAG,MAAM;AACxE,iBAAO,KAAK;AAAA,QAAA;AAAA,MACb;AAAA,IACD,CACA;AA5BF,kBAAA,MAAQ,UAAmB,EAAC;AAAA,EAAA;AA8B7B;AAGO,MAAM,aAAa,OAAO,WAAmB,IAAI,QAAgB,CAAC,SAAS,WAAW;AAC5F,QAAM,SAAmB,CAAC;AAC1B,SAAO,GAAG,SAAS,CAAO,QAAA,OAAO,GAAG,CAAC;AACrC,SAAO,GAAG,QAAQ,CAAA,UAAS,OAAO,KAAK,KAAK,CAAC;AACtC,SAAA,GAAG,OAAO,MAAM,QAAQA,OAAO,OAAO,MAAM,CAAC,CAAC;AACtD,CAAC;"}
1
+ {"version":3,"file":"stream.js","sources":["../../../../../packages/cli/src/lib/stream.ts"],"sourcesContent":["import { Stream, Transform } from 'node:stream'\nimport { Buffer } from 'node:buffer'\n\n\nexport class LineTransform extends Transform {\n\tprivate chunks: Buffer[] = []\n\n\tconstructor(transform: (line: string) => string) {\n\t\tsuper({\n\t\t\ttransform: (chunk, encoding, done) => {\n\t\t\t\twhile (true) {\n\t\t\t\t\tconst eolIndex = chunk.indexOf('\\n')\n\n\t\t\t\t\tif (eolIndex < 0) {\n\t\t\t\t\t\tthis.chunks.push(chunk)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.chunks.push(chunk.slice(0, eolIndex))\n\t\t\t\t\tchunk = chunk.slice(eolIndex + 1)\n\t\t\t\t\tthis.push(transform(Buffer.concat(this.chunks).toString('utf8')) + '\\n', 'utf8')\n\t\t\t\t\tthis.chunks = []\n\t\t\t\t}\n\n\t\t\t\treturn done()\n\t\t\t},\n\n\t\t\tflush: done => {\n\t\t\t\tif (this.chunks.length) {\n\t\t\t\t\tthis.push(transform(Buffer.concat(this.chunks).toString('utf8')), 'utf8')\n\t\t\t\t\treturn done()\n\t\t\t\t}\n\t\t\t},\n\t\t})\n\t}\n}\n\n\nexport const readStream = async (stream: Stream) => new Promise<Buffer>((resolve, reject) => {\n\tconst chunks: Buffer[] = []\n\tstream.on('error', err => reject(err))\n\tstream.on('data', chunk => chunks.push(chunk))\n\tstream.on('end', () => resolve(Buffer.concat(chunks)))\n})\n"],"names":["Buffer"],"mappings":";;;;;AAIO,MAAM,sBAAsB,UAAU;AAAA,EAG5C,YAAY,WAAqC;AAC1C,UAAA;AAAA,MACL,WAAW,CAAC,OAAO,UAAU,SAAS;AACrC,eAAO,MAAM;AACN,gBAAA,WAAW,MAAM,QAAQ,IAAI;AAEnC,cAAI,WAAW,GAAG;AACZ,iBAAA,OAAO,KAAK,KAAK;AACtB;AAAA,UAAA;AAGD,eAAK,OAAO,KAAK,MAAM,MAAM,GAAG,QAAQ,CAAC;AACjC,kBAAA,MAAM,MAAM,WAAW,CAAC;AAChC,eAAK,KAAK,UAAUA,OAAO,OAAO,KAAK,MAAM,EAAE,SAAS,MAAM,CAAC,IAAI,MAAM,MAAM;AAC/E,eAAK,SAAS,CAAC;AAAA,QAAA;AAGhB,eAAO,KAAK;AAAA,MACb;AAAA,MAEA,OAAO,CAAQ,SAAA;AACV,YAAA,KAAK,OAAO,QAAQ;AAClB,eAAA,KAAK,UAAUA,OAAO,OAAO,KAAK,MAAM,EAAE,SAAS,MAAM,CAAC,GAAG,MAAM;AACxE,iBAAO,KAAK;AAAA,QAAA;AAAA,MACb;AAAA,IACD,CACA;AA5BF,kBAAA,MAAQ,UAAmB,EAAC;AAAA,EAAA;AA8B7B;"}
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const http = require("node:http");
4
- const https = require("node:https");
5
3
  const stream = require("../stream.cjs");
6
4
  const node_stream = require("node:stream");
7
5
  const node_zlib = require("node:zlib");
@@ -43,53 +41,44 @@ class DataTransferClient {
43
41
  }
44
42
  return line;
45
43
  }));
46
- return await this.executeRequest({
47
- url: `${project.endpoint}/import`,
48
- token: project.token,
44
+ inputStream.on("error", (err) => {
45
+ throw new Error(`Input stream error: ${err}`);
46
+ });
47
+ const bodyStream = node_stream.Readable.toWeb(gzip ? inputStream.pipe(node_zlib.createGzip()) : inputStream);
48
+ const response = await fetch(`${project.endpoint}/import`, {
49
49
  headers: {
50
+ "Authorization": `Bearer ${project.token}`,
50
51
  "Content-type": "application/x-ndjson",
51
52
  ...gzip ? { "Content-Encoding": "gzip" } : {}
52
53
  },
53
- body: gzip ? inputStream.pipe(node_zlib.createGzip()) : inputStream
54
+ method: "POST",
55
+ body: bodyStream
54
56
  });
57
+ if (!response.ok) {
58
+ const responseBody = await response.text();
59
+ throw new Error(`Invalid response: ${response.statusText}
60
+ ${responseBody}`);
61
+ }
62
+ return response;
55
63
  });
56
64
  __publicField(this, "dataExport", async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem, excludeTables }) => {
57
- return await this.executeRequest({
58
- url: `${baseUrl}/export`,
59
- token,
65
+ const response = await fetch(`${baseUrl}/export`, {
60
66
  headers: {
67
+ "Authorization": `Bearer ${token}`,
61
68
  "Accept-Encoding": gzip ? "gzip" : "identity",
62
69
  "Content-type": "application/json"
63
70
  },
71
+ method: "POST",
64
72
  body: JSON.stringify({
65
73
  projects: [{ slug: project, system: includeSystem, excludeTables }]
66
74
  })
67
75
  });
68
- });
69
- __publicField(this, "executeRequest", async ({ url, token, headers, body }) => {
70
- return await new Promise((resolve, reject) => {
71
- const req = (url.startsWith("https://") ? https : http).request(url, {
72
- method: "POST",
73
- headers: {
74
- Authorization: `Bearer ${token}`,
75
- ...headers
76
- }
77
- }, async (res) => {
78
- if (res.statusCode !== 200) {
79
- const responseBody = (await stream.readStream(res)).toString();
80
- reject(new Error(`Invalid response: ${res.statusMessage}
81
- ${responseBody}`));
82
- } else {
83
- resolve(res);
84
- }
85
- });
86
- if (body instanceof node_stream.Stream) {
87
- body.pipe(req);
88
- } else {
89
- req.write(body);
90
- req.end();
91
- }
92
- });
76
+ if (!response.ok) {
77
+ const responseBody = await response.text();
78
+ throw new Error(`Invalid response: ${response.statusText}
79
+ ${responseBody}`);
80
+ }
81
+ return response;
93
82
  });
94
83
  }
95
84
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DataTransferClient.cjs","sources":["../../../../../../packages/cli/src/lib/transfer/DataTransferClient.ts"],"sourcesContent":["import http from 'node:http'\nimport https from 'node:https'\nimport { LineTransform, readStream } from '../stream'\nimport { Readable, Stream } from 'node:stream'\nimport { createGzip } from 'node:zlib'\nimport { RemoteProject } from '../project/RemoteProject'\n\nexport class DataTransferClient {\n\n\tdataImport = async ({ printProgress, stream, project, gzip }: {\n\t\tstream: Readable\n\t\tproject: RemoteProject\n\t\tprintProgress: (message: string) => void\n\t\tgzip: boolean\n\t}) => {\n\t\tlet table = ''\n\t\tlet rowCount = 0\n\t\tlet rowTotal = 0\n\t\tlet transferred = 0\n\t\tlet start = Date.now()\n\t\tconst inputStream = stream.pipe(new LineTransform(line => {\n\t\t\ttransferred += line.length + 1\n\t\t\tif (line === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst data = JSON.parse(line)\n\t\t\tswitch (data[0]) {\n\t\t\t\tcase 'importSystemSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'importContentSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'insertBegin':\n\t\t\t\t\ttable = data[1].table\n\t\t\t\t\trowCount = 0\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertRow':\n\t\t\t\t\trowCount++\n\t\t\t\t\trowTotal++\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertEnd':\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t\tif ((rowCount % 1000) === 0 || data[0] !== 'insertRow') {\n\t\t\t\tconst mbs = Math.floor(transferred / 1024 / 1024).toString()\n\t\t\t\tconst durationS = Math.floor((Date.now() - start) / 1000)\n\t\t\t\tprintProgress(`transferred ${mbs} MiB; inserted ${rowCount} ${table} rows, ${rowTotal} total; ${durationS} seconds`)\n\t\t\t}\n\t\t\treturn line\n\t\t}))\n\n\t\treturn await this.executeRequest({\n\t\t\turl: `${project.endpoint}/import`,\n\t\t\ttoken: project.token,\n\t\t\theaders: {\n\t\t\t\t'Content-type': 'application/x-ndjson',\n\t\t\t\t...(gzip ? { 'Content-Encoding': 'gzip' } : {}),\n\t\t\t},\n\t\t\tbody: gzip ? inputStream.pipe(createGzip()) : inputStream,\n\t\t})\n\t}\n\n\n\tdataExport = async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem, excludeTables }: {\n\t\tproject: RemoteProject\n\t\texcludeTables?: string[]\n\t\tincludeSystem: boolean\n\t\tgzip: boolean\n\t}) => {\n\t\treturn await this.executeRequest({\n\t\t\turl: `${baseUrl}/export`,\n\t\t\ttoken,\n\t\t\theaders: {\n\t\t\t\t'Accept-Encoding': gzip ? 'gzip' : 'identity',\n\t\t\t\t'Content-type': 'application/json',\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tprojects: [{ slug: project, system: includeSystem, excludeTables }],\n\t\t\t}),\n\t\t})\n\t}\n\n\n\tprivate executeRequest = async ({ url, token, headers, body }: {\n\t\turl: string\n\t\ttoken: string\n\t\theaders: Record<string, string>\n\t\tbody: any\n\t}) => {\n\t\treturn await new Promise<http.IncomingMessage>((resolve, reject) => {\n\t\t\tconst req = (url.startsWith('https://') ? https : http).request(url, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t\t...headers,\n\t\t\t\t},\n\t\t\t}, async res => {\n\t\t\t\tif (res.statusCode !== 200) {\n\t\t\t\t\tconst responseBody = (await readStream(res)).toString()\n\t\t\t\t\treject(new Error(`Invalid response: ${res.statusMessage}\\n${responseBody}`))\n\t\t\t\t} else {\n\t\t\t\t\tresolve(res)\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tif (body instanceof Stream) {\n\t\t\t\tbody.pipe(req)\n\t\t\t} else {\n\t\t\t\treq.write(body)\n\t\t\t\treq.end()\n\t\t\t}\n\t\t})\n\t}\n}\n"],"names":["stream","LineTransform","createGzip","readStream","Stream"],"mappings":"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"}
1
+ {"version":3,"file":"DataTransferClient.cjs","sources":["../../../../../../packages/cli/src/lib/transfer/DataTransferClient.ts"],"sourcesContent":["import { LineTransform } from '../stream'\nimport { Readable } from 'node:stream'\nimport { createGzip } from 'node:zlib'\nimport { RemoteProject } from '../project/RemoteProject'\n\nexport class DataTransferClient {\n\n\tdataImport = async ({ printProgress, stream, project, gzip }: {\n\t\tstream: Readable\n\t\tproject: RemoteProject\n\t\tprintProgress: (message: string) => void\n\t\tgzip: boolean\n\t}) => {\n\t\tlet table = ''\n\t\tlet rowCount = 0\n\t\tlet rowTotal = 0\n\t\tlet transferred = 0\n\t\tlet start = Date.now()\n\t\tconst inputStream = stream.pipe(new LineTransform(line => {\n\t\t\ttransferred += line.length + 1\n\t\t\tif (line === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst data = JSON.parse(line)\n\t\t\tswitch (data[0]) {\n\t\t\t\tcase 'importSystemSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'importContentSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'insertBegin':\n\t\t\t\t\ttable = data[1].table\n\t\t\t\t\trowCount = 0\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertRow':\n\t\t\t\t\trowCount++\n\t\t\t\t\trowTotal++\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertEnd':\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t\tif ((rowCount % 1000) === 0 || data[0] !== 'insertRow') {\n\t\t\t\tconst mbs = Math.floor(transferred / 1024 / 1024).toString()\n\t\t\t\tconst durationS = Math.floor((Date.now() - start) / 1000)\n\t\t\t\tprintProgress(`transferred ${mbs} MiB; inserted ${rowCount} ${table} rows, ${rowTotal} total; ${durationS} seconds`)\n\t\t\t}\n\t\t\treturn line\n\t\t}))\n\t\tinputStream.on('error', err => {\n\t\t\tthrow new Error(`Input stream error: ${err}`)\n\t\t})\n\n\t\tconst bodyStream = Readable.toWeb((gzip ? inputStream.pipe(createGzip()) : inputStream)) as unknown as BodyInit\n\n\t\tconst response = await fetch(`${project.endpoint}/import`, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': `Bearer ${project.token}`,\n\t\t\t\t'Content-type': 'application/x-ndjson',\n\t\t\t\t...(gzip ? { 'Content-Encoding': 'gzip' } : {}),\n\t\t\t},\n\t\t\tmethod: 'POST',\n\t\t\tbody: bodyStream,\n\t\t})\n\t\tif (!response.ok) {\n\t\t\tconst responseBody = await response.text()\n\t\t\tthrow new Error(`Invalid response: ${response.statusText}\\n${responseBody}`)\n\t\t}\n\t\treturn response\n\t}\n\n\n\tdataExport = async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem, excludeTables }: {\n\t\tproject: RemoteProject\n\t\texcludeTables?: string[]\n\t\tincludeSystem: boolean\n\t\tgzip: boolean\n\t}) => {\n\t\tconst response = await fetch(`${baseUrl}/export`, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': `Bearer ${token}`,\n\t\t\t\t'Accept-Encoding': gzip ? 'gzip' : 'identity',\n\t\t\t\t'Content-type': 'application/json',\n\t\t\t},\n\t\t\tmethod: 'POST',\n\t\t\tbody: JSON.stringify({\n\t\t\t\tprojects: [{ slug: project, system: includeSystem, excludeTables }],\n\t\t\t}),\n\t\t})\n\t\tif (!response.ok) {\n\t\t\tconst responseBody = await response.text()\n\t\t\tthrow new Error(`Invalid response: ${response.statusText}\\n${responseBody}`)\n\t\t}\n\t\treturn response\n\t}\n}\n"],"names":["stream","LineTransform","Readable","createGzip"],"mappings":";;;;;;;;AAKO,MAAM,mBAAmB;AAAA,EAAzB,cAAA;AAEN,kBAAA,MAAA,cAAa,OAAO,EAAE,eAAA,QAAeA,UAAQ,SAAS,WAKhD;AACL,UAAI,QAAQ;AACZ,UAAI,WAAW;AACf,UAAI,WAAW;AACf,UAAI,cAAc;AACd,UAAA,QAAQ,KAAK,IAAI;AACrB,YAAM,cAAcA,SAAO,KAAK,IAAIC,qBAAc,CAAQ,SAAA;AACzD,uBAAe,KAAK,SAAS;AAC7B,YAAI,SAAS,IAAI;AACT,iBAAA;AAAA,QAAA;AAEF,cAAA,OAAO,KAAK,MAAM,IAAI;AACpB,gBAAA,KAAK,CAAC,GAAG;AAAA,UAChB,KAAK;AACJ,mBAAO,KAAK,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,SAAS,QAAQ,KAAM,CAAA,CAAC;AAAA,UACvE,KAAK;AACJ,mBAAO,KAAK,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,SAAS,QAAQ,KAAM,CAAA,CAAC;AAAA,UACvE,KAAK;AACI,oBAAA,KAAK,CAAC,EAAE;AACL,uBAAA;AACX;AAAA,UACD,KAAK;AACJ;AACA;AACA;AAAA,QAEA;AAEF,YAAK,WAAW,QAAU,KAAK,KAAK,CAAC,MAAM,aAAa;AACvD,gBAAM,MAAM,KAAK,MAAM,cAAc,OAAO,IAAI,EAAE,SAAS;AAC3D,gBAAM,YAAY,KAAK,OAAO,KAAK,IAAI,IAAI,SAAS,GAAI;AAC1C,wBAAA,eAAe,GAAG,kBAAkB,QAAQ,IAAI,KAAK,UAAU,QAAQ,WAAW,SAAS,UAAU;AAAA,QAAA;AAE7G,eAAA;AAAA,MAAA,CACP,CAAC;AACU,kBAAA,GAAG,SAAS,CAAO,QAAA;AAC9B,cAAM,IAAI,MAAM,uBAAuB,GAAG,EAAE;AAAA,MAAA,CAC5C;AAEK,YAAA,aAAaC,qBAAS,MAAO,OAAO,YAAY,KAAKC,UAAAA,YAAY,IAAI,WAAY;AAEvF,YAAM,WAAW,MAAM,MAAM,GAAG,QAAQ,QAAQ,WAAW;AAAA,QAC1D,SAAS;AAAA,UACR,iBAAiB,UAAU,QAAQ,KAAK;AAAA,UACxC,gBAAgB;AAAA,UAChB,GAAI,OAAO,EAAE,oBAAoB,WAAW,CAAA;AAAA,QAC7C;AAAA,QACA,QAAQ;AAAA,QACR,MAAM;AAAA,MAAA,CACN;AACG,UAAA,CAAC,SAAS,IAAI;AACX,cAAA,eAAe,MAAM,SAAS,KAAK;AACzC,cAAM,IAAI,MAAM,qBAAqB,SAAS,UAAU;AAAA,EAAK,YAAY,EAAE;AAAA,MAAA;AAErE,aAAA;AAAA,IAAA,CACR;AAGA,kBAAA,MAAA,cAAa,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,OAAO,UAAU,QAAQ,GAAG,MAAM,eAAe,oBAK3F;AACL,YAAM,WAAW,MAAM,MAAM,GAAG,OAAO,WAAW;AAAA,QACjD,SAAS;AAAA,UACR,iBAAiB,UAAU,KAAK;AAAA,UAChC,mBAAmB,OAAO,SAAS;AAAA,UACnC,gBAAgB;AAAA,QACjB;AAAA,QACA,QAAQ;AAAA,QACR,MAAM,KAAK,UAAU;AAAA,UACpB,UAAU,CAAC,EAAE,MAAM,SAAS,QAAQ,eAAe,cAAe,CAAA;AAAA,QAClE,CAAA;AAAA,MAAA,CACD;AACG,UAAA,CAAC,SAAS,IAAI;AACX,cAAA,eAAe,MAAM,SAAS,KAAK;AACzC,cAAM,IAAI,MAAM,qBAAqB,SAAS,UAAU;AAAA,EAAK,YAAY,EAAE;AAAA,MAAA;AAErE,aAAA;AAAA,IAAA,CACR;AAAA,EAAA;AACD;;"}
@@ -1,7 +1,5 @@
1
- import http__default from "node:http";
2
- import https from "node:https";
3
- import { LineTransform, readStream } from "../stream.js";
4
- import { Stream } from "node:stream";
1
+ import { LineTransform } from "../stream.js";
2
+ import { Readable } from "node:stream";
5
3
  import { createGzip } from "node:zlib";
6
4
  var __defProp = Object.defineProperty;
7
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -41,53 +39,44 @@ class DataTransferClient {
41
39
  }
42
40
  return line;
43
41
  }));
44
- return await this.executeRequest({
45
- url: `${project.endpoint}/import`,
46
- token: project.token,
42
+ inputStream.on("error", (err) => {
43
+ throw new Error(`Input stream error: ${err}`);
44
+ });
45
+ const bodyStream = Readable.toWeb(gzip ? inputStream.pipe(createGzip()) : inputStream);
46
+ const response = await fetch(`${project.endpoint}/import`, {
47
47
  headers: {
48
+ "Authorization": `Bearer ${project.token}`,
48
49
  "Content-type": "application/x-ndjson",
49
50
  ...gzip ? { "Content-Encoding": "gzip" } : {}
50
51
  },
51
- body: gzip ? inputStream.pipe(createGzip()) : inputStream
52
+ method: "POST",
53
+ body: bodyStream
52
54
  });
55
+ if (!response.ok) {
56
+ const responseBody = await response.text();
57
+ throw new Error(`Invalid response: ${response.statusText}
58
+ ${responseBody}`);
59
+ }
60
+ return response;
53
61
  });
54
62
  __publicField(this, "dataExport", async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem, excludeTables }) => {
55
- return await this.executeRequest({
56
- url: `${baseUrl}/export`,
57
- token,
63
+ const response = await fetch(`${baseUrl}/export`, {
58
64
  headers: {
65
+ "Authorization": `Bearer ${token}`,
59
66
  "Accept-Encoding": gzip ? "gzip" : "identity",
60
67
  "Content-type": "application/json"
61
68
  },
69
+ method: "POST",
62
70
  body: JSON.stringify({
63
71
  projects: [{ slug: project, system: includeSystem, excludeTables }]
64
72
  })
65
73
  });
66
- });
67
- __publicField(this, "executeRequest", async ({ url, token, headers, body }) => {
68
- return await new Promise((resolve, reject) => {
69
- const req = (url.startsWith("https://") ? https : http__default).request(url, {
70
- method: "POST",
71
- headers: {
72
- Authorization: `Bearer ${token}`,
73
- ...headers
74
- }
75
- }, async (res) => {
76
- if (res.statusCode !== 200) {
77
- const responseBody = (await readStream(res)).toString();
78
- reject(new Error(`Invalid response: ${res.statusMessage}
79
- ${responseBody}`));
80
- } else {
81
- resolve(res);
82
- }
83
- });
84
- if (body instanceof Stream) {
85
- body.pipe(req);
86
- } else {
87
- req.write(body);
88
- req.end();
89
- }
90
- });
74
+ if (!response.ok) {
75
+ const responseBody = await response.text();
76
+ throw new Error(`Invalid response: ${response.statusText}
77
+ ${responseBody}`);
78
+ }
79
+ return response;
91
80
  });
92
81
  }
93
82
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DataTransferClient.js","sources":["../../../../../../packages/cli/src/lib/transfer/DataTransferClient.ts"],"sourcesContent":["import http from 'node:http'\nimport https from 'node:https'\nimport { LineTransform, readStream } from '../stream'\nimport { Readable, Stream } from 'node:stream'\nimport { createGzip } from 'node:zlib'\nimport { RemoteProject } from '../project/RemoteProject'\n\nexport class DataTransferClient {\n\n\tdataImport = async ({ printProgress, stream, project, gzip }: {\n\t\tstream: Readable\n\t\tproject: RemoteProject\n\t\tprintProgress: (message: string) => void\n\t\tgzip: boolean\n\t}) => {\n\t\tlet table = ''\n\t\tlet rowCount = 0\n\t\tlet rowTotal = 0\n\t\tlet transferred = 0\n\t\tlet start = Date.now()\n\t\tconst inputStream = stream.pipe(new LineTransform(line => {\n\t\t\ttransferred += line.length + 1\n\t\t\tif (line === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst data = JSON.parse(line)\n\t\t\tswitch (data[0]) {\n\t\t\t\tcase 'importSystemSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'importContentSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'insertBegin':\n\t\t\t\t\ttable = data[1].table\n\t\t\t\t\trowCount = 0\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertRow':\n\t\t\t\t\trowCount++\n\t\t\t\t\trowTotal++\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertEnd':\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t\tif ((rowCount % 1000) === 0 || data[0] !== 'insertRow') {\n\t\t\t\tconst mbs = Math.floor(transferred / 1024 / 1024).toString()\n\t\t\t\tconst durationS = Math.floor((Date.now() - start) / 1000)\n\t\t\t\tprintProgress(`transferred ${mbs} MiB; inserted ${rowCount} ${table} rows, ${rowTotal} total; ${durationS} seconds`)\n\t\t\t}\n\t\t\treturn line\n\t\t}))\n\n\t\treturn await this.executeRequest({\n\t\t\turl: `${project.endpoint}/import`,\n\t\t\ttoken: project.token,\n\t\t\theaders: {\n\t\t\t\t'Content-type': 'application/x-ndjson',\n\t\t\t\t...(gzip ? { 'Content-Encoding': 'gzip' } : {}),\n\t\t\t},\n\t\t\tbody: gzip ? inputStream.pipe(createGzip()) : inputStream,\n\t\t})\n\t}\n\n\n\tdataExport = async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem, excludeTables }: {\n\t\tproject: RemoteProject\n\t\texcludeTables?: string[]\n\t\tincludeSystem: boolean\n\t\tgzip: boolean\n\t}) => {\n\t\treturn await this.executeRequest({\n\t\t\turl: `${baseUrl}/export`,\n\t\t\ttoken,\n\t\t\theaders: {\n\t\t\t\t'Accept-Encoding': gzip ? 'gzip' : 'identity',\n\t\t\t\t'Content-type': 'application/json',\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tprojects: [{ slug: project, system: includeSystem, excludeTables }],\n\t\t\t}),\n\t\t})\n\t}\n\n\n\tprivate executeRequest = async ({ url, token, headers, body }: {\n\t\turl: string\n\t\ttoken: string\n\t\theaders: Record<string, string>\n\t\tbody: any\n\t}) => {\n\t\treturn await new Promise<http.IncomingMessage>((resolve, reject) => {\n\t\t\tconst req = (url.startsWith('https://') ? https : http).request(url, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t\t...headers,\n\t\t\t\t},\n\t\t\t}, async res => {\n\t\t\t\tif (res.statusCode !== 200) {\n\t\t\t\t\tconst responseBody = (await readStream(res)).toString()\n\t\t\t\t\treject(new Error(`Invalid response: ${res.statusMessage}\\n${responseBody}`))\n\t\t\t\t} else {\n\t\t\t\t\tresolve(res)\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tif (body instanceof Stream) {\n\t\t\t\tbody.pipe(req)\n\t\t\t} else {\n\t\t\t\treq.write(body)\n\t\t\t\treq.end()\n\t\t\t}\n\t\t})\n\t}\n}\n"],"names":["http"],"mappings":"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"}
1
+ {"version":3,"file":"DataTransferClient.js","sources":["../../../../../../packages/cli/src/lib/transfer/DataTransferClient.ts"],"sourcesContent":["import { LineTransform } from '../stream'\nimport { Readable } from 'node:stream'\nimport { createGzip } from 'node:zlib'\nimport { RemoteProject } from '../project/RemoteProject'\n\nexport class DataTransferClient {\n\n\tdataImport = async ({ printProgress, stream, project, gzip }: {\n\t\tstream: Readable\n\t\tproject: RemoteProject\n\t\tprintProgress: (message: string) => void\n\t\tgzip: boolean\n\t}) => {\n\t\tlet table = ''\n\t\tlet rowCount = 0\n\t\tlet rowTotal = 0\n\t\tlet transferred = 0\n\t\tlet start = Date.now()\n\t\tconst inputStream = stream.pipe(new LineTransform(line => {\n\t\t\ttransferred += line.length + 1\n\t\t\tif (line === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst data = JSON.parse(line)\n\t\t\tswitch (data[0]) {\n\t\t\t\tcase 'importSystemSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'importContentSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'insertBegin':\n\t\t\t\t\ttable = data[1].table\n\t\t\t\t\trowCount = 0\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertRow':\n\t\t\t\t\trowCount++\n\t\t\t\t\trowTotal++\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertEnd':\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t\tif ((rowCount % 1000) === 0 || data[0] !== 'insertRow') {\n\t\t\t\tconst mbs = Math.floor(transferred / 1024 / 1024).toString()\n\t\t\t\tconst durationS = Math.floor((Date.now() - start) / 1000)\n\t\t\t\tprintProgress(`transferred ${mbs} MiB; inserted ${rowCount} ${table} rows, ${rowTotal} total; ${durationS} seconds`)\n\t\t\t}\n\t\t\treturn line\n\t\t}))\n\t\tinputStream.on('error', err => {\n\t\t\tthrow new Error(`Input stream error: ${err}`)\n\t\t})\n\n\t\tconst bodyStream = Readable.toWeb((gzip ? inputStream.pipe(createGzip()) : inputStream)) as unknown as BodyInit\n\n\t\tconst response = await fetch(`${project.endpoint}/import`, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': `Bearer ${project.token}`,\n\t\t\t\t'Content-type': 'application/x-ndjson',\n\t\t\t\t...(gzip ? { 'Content-Encoding': 'gzip' } : {}),\n\t\t\t},\n\t\t\tmethod: 'POST',\n\t\t\tbody: bodyStream,\n\t\t})\n\t\tif (!response.ok) {\n\t\t\tconst responseBody = await response.text()\n\t\t\tthrow new Error(`Invalid response: ${response.statusText}\\n${responseBody}`)\n\t\t}\n\t\treturn response\n\t}\n\n\n\tdataExport = async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem, excludeTables }: {\n\t\tproject: RemoteProject\n\t\texcludeTables?: string[]\n\t\tincludeSystem: boolean\n\t\tgzip: boolean\n\t}) => {\n\t\tconst response = await fetch(`${baseUrl}/export`, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': `Bearer ${token}`,\n\t\t\t\t'Accept-Encoding': gzip ? 'gzip' : 'identity',\n\t\t\t\t'Content-type': 'application/json',\n\t\t\t},\n\t\t\tmethod: 'POST',\n\t\t\tbody: JSON.stringify({\n\t\t\t\tprojects: [{ slug: project, system: includeSystem, excludeTables }],\n\t\t\t}),\n\t\t})\n\t\tif (!response.ok) {\n\t\t\tconst responseBody = await response.text()\n\t\t\tthrow new Error(`Invalid response: ${response.statusText}\\n${responseBody}`)\n\t\t}\n\t\treturn response\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAKO,MAAM,mBAAmB;AAAA,EAAzB,cAAA;AAEN,kBAAA,MAAA,cAAa,OAAO,EAAE,eAAe,QAAQ,SAAS,WAKhD;AACL,UAAI,QAAQ;AACZ,UAAI,WAAW;AACf,UAAI,WAAW;AACf,UAAI,cAAc;AACd,UAAA,QAAQ,KAAK,IAAI;AACrB,YAAM,cAAc,OAAO,KAAK,IAAI,cAAc,CAAQ,SAAA;AACzD,uBAAe,KAAK,SAAS;AAC7B,YAAI,SAAS,IAAI;AACT,iBAAA;AAAA,QAAA;AAEF,cAAA,OAAO,KAAK,MAAM,IAAI;AACpB,gBAAA,KAAK,CAAC,GAAG;AAAA,UAChB,KAAK;AACJ,mBAAO,KAAK,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,SAAS,QAAQ,KAAM,CAAA,CAAC;AAAA,UACvE,KAAK;AACJ,mBAAO,KAAK,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,SAAS,QAAQ,KAAM,CAAA,CAAC;AAAA,UACvE,KAAK;AACI,oBAAA,KAAK,CAAC,EAAE;AACL,uBAAA;AACX;AAAA,UACD,KAAK;AACJ;AACA;AACA;AAAA,QAEA;AAEF,YAAK,WAAW,QAAU,KAAK,KAAK,CAAC,MAAM,aAAa;AACvD,gBAAM,MAAM,KAAK,MAAM,cAAc,OAAO,IAAI,EAAE,SAAS;AAC3D,gBAAM,YAAY,KAAK,OAAO,KAAK,IAAI,IAAI,SAAS,GAAI;AAC1C,wBAAA,eAAe,GAAG,kBAAkB,QAAQ,IAAI,KAAK,UAAU,QAAQ,WAAW,SAAS,UAAU;AAAA,QAAA;AAE7G,eAAA;AAAA,MAAA,CACP,CAAC;AACU,kBAAA,GAAG,SAAS,CAAO,QAAA;AAC9B,cAAM,IAAI,MAAM,uBAAuB,GAAG,EAAE;AAAA,MAAA,CAC5C;AAEK,YAAA,aAAa,SAAS,MAAO,OAAO,YAAY,KAAK,YAAY,IAAI,WAAY;AAEvF,YAAM,WAAW,MAAM,MAAM,GAAG,QAAQ,QAAQ,WAAW;AAAA,QAC1D,SAAS;AAAA,UACR,iBAAiB,UAAU,QAAQ,KAAK;AAAA,UACxC,gBAAgB;AAAA,UAChB,GAAI,OAAO,EAAE,oBAAoB,WAAW,CAAA;AAAA,QAC7C;AAAA,QACA,QAAQ;AAAA,QACR,MAAM;AAAA,MAAA,CACN;AACG,UAAA,CAAC,SAAS,IAAI;AACX,cAAA,eAAe,MAAM,SAAS,KAAK;AACzC,cAAM,IAAI,MAAM,qBAAqB,SAAS,UAAU;AAAA,EAAK,YAAY,EAAE;AAAA,MAAA;AAErE,aAAA;AAAA,IAAA,CACR;AAGA,kBAAA,MAAA,cAAa,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,OAAO,UAAU,QAAQ,GAAG,MAAM,eAAe,oBAK3F;AACL,YAAM,WAAW,MAAM,MAAM,GAAG,OAAO,WAAW;AAAA,QACjD,SAAS;AAAA,UACR,iBAAiB,UAAU,KAAK;AAAA,UAChC,mBAAmB,OAAO,SAAS;AAAA,UACnC,gBAAgB;AAAA,QACjB;AAAA,QACA,QAAQ;AAAA,QACR,MAAM,KAAK,UAAU;AAAA,UACpB,UAAU,CAAC,EAAE,MAAM,SAAS,QAAQ,eAAe,cAAe,CAAA;AAAA,QAClE,CAAA;AAAA,MAAA,CACD;AACG,UAAA,CAAC,SAAS,IAAI;AACX,cAAA,eAAe,MAAM,SAAS,KAAK;AACzC,cAAM,IAAI,MAAM,qBAAqB,SAAS,UAAU;AAAA,EAAK,YAAY,EAAE;AAAA,MAAA;AAErE,aAAA;AAAA,IAAA,CACR;AAAA,EAAA;AACD;"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const cliCommon = require("@contember/cli-common");
4
+ const ActionsClient = require("../../lib/actions/ActionsClient.cjs");
5
+ class ActionsGetEventCommand extends cliCommon.Command {
6
+ constructor(remoteProjectResolver) {
7
+ super();
8
+ this.remoteProjectResolver = remoteProjectResolver;
9
+ }
10
+ configure(configuration) {
11
+ configuration.description("Get single event");
12
+ configuration.argument("eventId");
13
+ configuration.option("project").valueRequired();
14
+ }
15
+ async execute(input) {
16
+ const dsn = input.getOption("project");
17
+ const project = await this.remoteProjectResolver.resolve(dsn);
18
+ if (!project) {
19
+ throw `Project not defined`;
20
+ }
21
+ const api = ActionsClient.ActionsClient.create(project.endpoint, project.name, project.token);
22
+ const result = await api.getEvent(input.getArgument("eventId"));
23
+ if (!result) {
24
+ console.log("Event not found");
25
+ return 1;
26
+ }
27
+ console.log(JSON.stringify(result, null, 2));
28
+ }
29
+ }
30
+ exports.ActionsGetEventCommand = ActionsGetEventCommand;
31
+ //# sourceMappingURL=ActionsGetEventCommand.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionsGetEventCommand.cjs","sources":["../../../../../../packages/cli/src/commands/actions/ActionsGetEventCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { ActionsClient } from '../../lib/actions/ActionsClient'\n\ntype Args = {\n\teventId: string\n}\n\ntype Options = {\n\tproject?: string\n}\n\nexport class ActionsGetEventCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Get single event')\n\t\tconfiguration.argument('eventId')\n\t\tconfiguration.option('project').valueRequired()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst dsn = input.getOption('project')\n\t\tconst project = await this.remoteProjectResolver.resolve(dsn)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\t\tconst api = ActionsClient.create(project.endpoint, project.name, project.token)\n\n\t\tconst result = await api.getEvent(input.getArgument('eventId'))\n\t\tif (!result) {\n\t\t\tconsole.log('Event not found')\n\t\t\treturn 1\n\t\t}\n\t\tconsole.log(JSON.stringify(result, null, 2))\n\n\t}\n}\n"],"names":["Command","ActionsClient"],"mappings":";;;;AAYO,MAAM,+BAA+BA,UAAAA,QAAuB;AAAA,EAClE,YACkB,uBAChB;AACK,UAAA;AAFW,SAAA,wBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kBAAkB;AAC5C,kBAAc,SAAS,SAAS;AAClB,kBAAA,OAAO,SAAS,EAAE,cAAc;AAAA,EAAA;AAAA,EAG/C,MAAgB,QAAQ,OAAqD;AACtE,UAAA,MAAM,MAAM,UAAU,SAAS;AACrC,UAAM,UAAU,MAAM,KAAK,sBAAsB,QAAQ,GAAG;AAC5D,QAAI,CAAC,SAAS;AACP,YAAA;AAAA,IAAA;AAED,UAAA,MAAMC,4BAAc,OAAO,QAAQ,UAAU,QAAQ,MAAM,QAAQ,KAAK;AAE9E,UAAM,SAAS,MAAM,IAAI,SAAS,MAAM,YAAY,SAAS,CAAC;AAC9D,QAAI,CAAC,QAAQ;AACZ,cAAQ,IAAI,iBAAiB;AACtB,aAAA;AAAA,IAAA;AAER,YAAQ,IAAI,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,EAAA;AAG7C;;"}
@@ -0,0 +1,31 @@
1
+ import { Command } from "@contember/cli-common";
2
+ import { ActionsClient } from "../../lib/actions/ActionsClient.js";
3
+ class ActionsGetEventCommand extends Command {
4
+ constructor(remoteProjectResolver) {
5
+ super();
6
+ this.remoteProjectResolver = remoteProjectResolver;
7
+ }
8
+ configure(configuration) {
9
+ configuration.description("Get single event");
10
+ configuration.argument("eventId");
11
+ configuration.option("project").valueRequired();
12
+ }
13
+ async execute(input) {
14
+ const dsn = input.getOption("project");
15
+ const project = await this.remoteProjectResolver.resolve(dsn);
16
+ if (!project) {
17
+ throw `Project not defined`;
18
+ }
19
+ const api = ActionsClient.create(project.endpoint, project.name, project.token);
20
+ const result = await api.getEvent(input.getArgument("eventId"));
21
+ if (!result) {
22
+ console.log("Event not found");
23
+ return 1;
24
+ }
25
+ console.log(JSON.stringify(result, null, 2));
26
+ }
27
+ }
28
+ export {
29
+ ActionsGetEventCommand
30
+ };
31
+ //# sourceMappingURL=ActionsGetEventCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionsGetEventCommand.js","sources":["../../../../../../packages/cli/src/commands/actions/ActionsGetEventCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { ActionsClient } from '../../lib/actions/ActionsClient'\n\ntype Args = {\n\teventId: string\n}\n\ntype Options = {\n\tproject?: string\n}\n\nexport class ActionsGetEventCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Get single event')\n\t\tconfiguration.argument('eventId')\n\t\tconfiguration.option('project').valueRequired()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst dsn = input.getOption('project')\n\t\tconst project = await this.remoteProjectResolver.resolve(dsn)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\t\tconst api = ActionsClient.create(project.endpoint, project.name, project.token)\n\n\t\tconst result = await api.getEvent(input.getArgument('eventId'))\n\t\tif (!result) {\n\t\t\tconsole.log('Event not found')\n\t\t\treturn 1\n\t\t}\n\t\tconsole.log(JSON.stringify(result, null, 2))\n\n\t}\n}\n"],"names":[],"mappings":";;AAYO,MAAM,+BAA+B,QAAuB;AAAA,EAClE,YACkB,uBAChB;AACK,UAAA;AAFW,SAAA,wBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kBAAkB;AAC5C,kBAAc,SAAS,SAAS;AAClB,kBAAA,OAAO,SAAS,EAAE,cAAc;AAAA,EAAA;AAAA,EAG/C,MAAgB,QAAQ,OAAqD;AACtE,UAAA,MAAM,MAAM,UAAU,SAAS;AACrC,UAAM,UAAU,MAAM,KAAK,sBAAsB,QAAQ,GAAG;AAC5D,QAAI,CAAC,SAAS;AACP,YAAA;AAAA,IAAA;AAED,UAAA,MAAM,cAAc,OAAO,QAAQ,UAAU,QAAQ,MAAM,QAAQ,KAAK;AAE9E,UAAM,SAAS,MAAM,IAAI,SAAS,MAAM,YAAY,SAAS,CAAC;AAC9D,QAAI,CAAC,QAAQ;AACZ,cAAQ,IAAI,iBAAiB;AACtB,aAAA;AAAA,IAAA;AAER,YAAQ,IAAI,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,EAAA;AAG7C;"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const cliCommon = require("@contember/cli-common");
4
+ const ActionsClient = require("../../lib/actions/ActionsClient.cjs");
5
+ const chalkTable = require("chalk-table");
6
+ class ActionsListFailedEventsCommand extends cliCommon.Command {
7
+ constructor(remoteProjectResolver) {
8
+ super();
9
+ this.remoteProjectResolver = remoteProjectResolver;
10
+ }
11
+ configure(configuration) {
12
+ configuration.description("Show failed events");
13
+ configuration.option("project").valueRequired();
14
+ configuration.option("json").valueNone();
15
+ }
16
+ async execute(input) {
17
+ const dsn = input.getOption("project");
18
+ const project = await this.remoteProjectResolver.resolve(dsn);
19
+ if (!project) {
20
+ throw `Project not defined`;
21
+ }
22
+ const api = ActionsClient.ActionsClient.create(project.endpoint, project.name, project.token);
23
+ const result = await api.listFailedEvents();
24
+ if (input.getOption("json")) {
25
+ console.log(JSON.stringify(result, null, 2));
26
+ return;
27
+ }
28
+ if (result.length === 0) {
29
+ console.log("No failed events");
30
+ return;
31
+ }
32
+ const table = chalkTable(
33
+ {
34
+ columns: [
35
+ { field: "id", name: "ID" },
36
+ { field: "createdAt", name: "Created at" },
37
+ { field: "lastStateChange", name: "Last state change" },
38
+ { field: "visibleAt", name: "Visible at" },
39
+ { field: "numRetries", name: "Retries" },
40
+ { field: "state", name: "State" },
41
+ { field: "target", name: "Target" },
42
+ { field: "log", name: "Log" }
43
+ ]
44
+ },
45
+ result.map((it) => ({
46
+ id: it.id,
47
+ createdAt: it.createdAt,
48
+ lastStateChange: it.lastStateChange,
49
+ visibleAt: it.visibleAt || "",
50
+ numRetries: it.numRetries.toString(),
51
+ state: it.state,
52
+ target: it.target,
53
+ log: JSON.stringify(it.log.length > 0 ? it.log[it.log.length - 1] : {})
54
+ }))
55
+ );
56
+ console.log(table);
57
+ }
58
+ }
59
+ exports.ActionsListFailedEventsCommand = ActionsListFailedEventsCommand;
60
+ //# sourceMappingURL=ActionsListFailedEventsCommand.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionsListFailedEventsCommand.cjs","sources":["../../../../../../packages/cli/src/commands/actions/ActionsListFailedEventsCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { ActionsClient } from '../../lib/actions/ActionsClient'\nimport chalkTable from 'chalk-table'\ntype Args = {\n}\n\ntype Options = {\n\tproject?: string\n\tjson?: boolean\n}\n\nexport class ActionsListFailedEventsCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Show failed events')\n\t\tconfiguration.option('project').valueRequired()\n\t\tconfiguration.option('json').valueNone()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst dsn = input.getOption('project')\n\t\tconst project = await this.remoteProjectResolver.resolve(dsn)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\t\tconst api = ActionsClient.create(project.endpoint, project.name, project.token)\n\n\t\tconst result = await api.listFailedEvents()\n\t\tif (input.getOption('json')) {\n\t\t\tconsole.log(JSON.stringify(result, null, 2))\n\t\t\treturn\n\t\t}\n\t\tif (result.length === 0) {\n\t\t\tconsole.log('No failed events')\n\t\t\treturn\n\t\t}\n\t\tconst table = chalkTable(\n\t\t\t{\n\t\t\t\tcolumns: [\n\t\t\t\t\t{ field: 'id', name: 'ID' },\n\t\t\t\t\t{ field: 'createdAt', name: 'Created at' },\n\t\t\t\t\t{ field: 'lastStateChange', name: 'Last state change' },\n\t\t\t\t\t{ field: 'visibleAt', name: 'Visible at' },\n\t\t\t\t\t{ field: 'numRetries', name: 'Retries' },\n\t\t\t\t\t{ field: 'state', name: 'State' },\n\t\t\t\t\t{ field: 'target', name: 'Target' },\n\t\t\t\t\t{ field: 'log', name: 'Log' },\n\t\t\t\t],\n\t\t\t},\n\t\t\tresult.map(it => ({\n\t\t\t\tid: it.id,\n\t\t\t\tcreatedAt: it.createdAt,\n\t\t\t\tlastStateChange: it.lastStateChange,\n\t\t\t\tvisibleAt: it.visibleAt || '',\n\t\t\t\tnumRetries: it.numRetries.toString(),\n\t\t\t\tstate: it.state,\n\t\t\t\ttarget: it.target,\n\t\t\t\tlog: JSON.stringify(it.log.length > 0 ? it.log[it.log.length - 1] : {}),\n\t\t\t})),\n\t\t)\n\t\tconsole.log(table)\n\n\t}\n}\n"],"names":["Command","ActionsClient"],"mappings":";;;;;AAYO,MAAM,uCAAuCA,UAAAA,QAAuB;AAAA,EAC1E,YACkB,uBAChB;AACK,UAAA;AAFW,SAAA,wBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,oBAAoB;AAChC,kBAAA,OAAO,SAAS,EAAE,cAAc;AAChC,kBAAA,OAAO,MAAM,EAAE,UAAU;AAAA,EAAA;AAAA,EAGxC,MAAgB,QAAQ,OAAqD;AACtE,UAAA,MAAM,MAAM,UAAU,SAAS;AACrC,UAAM,UAAU,MAAM,KAAK,sBAAsB,QAAQ,GAAG;AAC5D,QAAI,CAAC,SAAS;AACP,YAAA;AAAA,IAAA;AAED,UAAA,MAAMC,4BAAc,OAAO,QAAQ,UAAU,QAAQ,MAAM,QAAQ,KAAK;AAExE,UAAA,SAAS,MAAM,IAAI,iBAAiB;AACtC,QAAA,MAAM,UAAU,MAAM,GAAG;AAC5B,cAAQ,IAAI,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAC3C;AAAA,IAAA;AAEG,QAAA,OAAO,WAAW,GAAG;AACxB,cAAQ,IAAI,kBAAkB;AAC9B;AAAA,IAAA;AAED,UAAM,QAAQ;AAAA,MACb;AAAA,QACC,SAAS;AAAA,UACR,EAAE,OAAO,MAAM,MAAM,KAAK;AAAA,UAC1B,EAAE,OAAO,aAAa,MAAM,aAAa;AAAA,UACzC,EAAE,OAAO,mBAAmB,MAAM,oBAAoB;AAAA,UACtD,EAAE,OAAO,aAAa,MAAM,aAAa;AAAA,UACzC,EAAE,OAAO,cAAc,MAAM,UAAU;AAAA,UACvC,EAAE,OAAO,SAAS,MAAM,QAAQ;AAAA,UAChC,EAAE,OAAO,UAAU,MAAM,SAAS;AAAA,UAClC,EAAE,OAAO,OAAO,MAAM,MAAM;AAAA,QAAA;AAAA,MAE9B;AAAA,MACA,OAAO,IAAI,CAAO,QAAA;AAAA,QACjB,IAAI,GAAG;AAAA,QACP,WAAW,GAAG;AAAA,QACd,iBAAiB,GAAG;AAAA,QACpB,WAAW,GAAG,aAAa;AAAA,QAC3B,YAAY,GAAG,WAAW,SAAS;AAAA,QACnC,OAAO,GAAG;AAAA,QACV,QAAQ,GAAG;AAAA,QACX,KAAK,KAAK,UAAU,GAAG,IAAI,SAAS,IAAI,GAAG,IAAI,GAAG,IAAI,SAAS,CAAC,IAAI,CAAE,CAAA;AAAA,MAAA,EACrE;AAAA,IACH;AACA,YAAQ,IAAI,KAAK;AAAA,EAAA;AAGnB;;"}
@@ -0,0 +1,60 @@
1
+ import { Command } from "@contember/cli-common";
2
+ import { ActionsClient } from "../../lib/actions/ActionsClient.js";
3
+ import chalkTable from "chalk-table";
4
+ class ActionsListFailedEventsCommand extends Command {
5
+ constructor(remoteProjectResolver) {
6
+ super();
7
+ this.remoteProjectResolver = remoteProjectResolver;
8
+ }
9
+ configure(configuration) {
10
+ configuration.description("Show failed events");
11
+ configuration.option("project").valueRequired();
12
+ configuration.option("json").valueNone();
13
+ }
14
+ async execute(input) {
15
+ const dsn = input.getOption("project");
16
+ const project = await this.remoteProjectResolver.resolve(dsn);
17
+ if (!project) {
18
+ throw `Project not defined`;
19
+ }
20
+ const api = ActionsClient.create(project.endpoint, project.name, project.token);
21
+ const result = await api.listFailedEvents();
22
+ if (input.getOption("json")) {
23
+ console.log(JSON.stringify(result, null, 2));
24
+ return;
25
+ }
26
+ if (result.length === 0) {
27
+ console.log("No failed events");
28
+ return;
29
+ }
30
+ const table = chalkTable(
31
+ {
32
+ columns: [
33
+ { field: "id", name: "ID" },
34
+ { field: "createdAt", name: "Created at" },
35
+ { field: "lastStateChange", name: "Last state change" },
36
+ { field: "visibleAt", name: "Visible at" },
37
+ { field: "numRetries", name: "Retries" },
38
+ { field: "state", name: "State" },
39
+ { field: "target", name: "Target" },
40
+ { field: "log", name: "Log" }
41
+ ]
42
+ },
43
+ result.map((it) => ({
44
+ id: it.id,
45
+ createdAt: it.createdAt,
46
+ lastStateChange: it.lastStateChange,
47
+ visibleAt: it.visibleAt || "",
48
+ numRetries: it.numRetries.toString(),
49
+ state: it.state,
50
+ target: it.target,
51
+ log: JSON.stringify(it.log.length > 0 ? it.log[it.log.length - 1] : {})
52
+ }))
53
+ );
54
+ console.log(table);
55
+ }
56
+ }
57
+ export {
58
+ ActionsListFailedEventsCommand
59
+ };
60
+ //# sourceMappingURL=ActionsListFailedEventsCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionsListFailedEventsCommand.js","sources":["../../../../../../packages/cli/src/commands/actions/ActionsListFailedEventsCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\nimport { ActionsClient } from '../../lib/actions/ActionsClient'\nimport chalkTable from 'chalk-table'\ntype Args = {\n}\n\ntype Options = {\n\tproject?: string\n\tjson?: boolean\n}\n\nexport class ActionsListFailedEventsCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Show failed events')\n\t\tconfiguration.option('project').valueRequired()\n\t\tconfiguration.option('json').valueNone()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\t\tconst dsn = input.getOption('project')\n\t\tconst project = await this.remoteProjectResolver.resolve(dsn)\n\t\tif (!project) {\n\t\t\tthrow `Project not defined`\n\t\t}\n\t\tconst api = ActionsClient.create(project.endpoint, project.name, project.token)\n\n\t\tconst result = await api.listFailedEvents()\n\t\tif (input.getOption('json')) {\n\t\t\tconsole.log(JSON.stringify(result, null, 2))\n\t\t\treturn\n\t\t}\n\t\tif (result.length === 0) {\n\t\t\tconsole.log('No failed events')\n\t\t\treturn\n\t\t}\n\t\tconst table = chalkTable(\n\t\t\t{\n\t\t\t\tcolumns: [\n\t\t\t\t\t{ field: 'id', name: 'ID' },\n\t\t\t\t\t{ field: 'createdAt', name: 'Created at' },\n\t\t\t\t\t{ field: 'lastStateChange', name: 'Last state change' },\n\t\t\t\t\t{ field: 'visibleAt', name: 'Visible at' },\n\t\t\t\t\t{ field: 'numRetries', name: 'Retries' },\n\t\t\t\t\t{ field: 'state', name: 'State' },\n\t\t\t\t\t{ field: 'target', name: 'Target' },\n\t\t\t\t\t{ field: 'log', name: 'Log' },\n\t\t\t\t],\n\t\t\t},\n\t\t\tresult.map(it => ({\n\t\t\t\tid: it.id,\n\t\t\t\tcreatedAt: it.createdAt,\n\t\t\t\tlastStateChange: it.lastStateChange,\n\t\t\t\tvisibleAt: it.visibleAt || '',\n\t\t\t\tnumRetries: it.numRetries.toString(),\n\t\t\t\tstate: it.state,\n\t\t\t\ttarget: it.target,\n\t\t\t\tlog: JSON.stringify(it.log.length > 0 ? it.log[it.log.length - 1] : {}),\n\t\t\t})),\n\t\t)\n\t\tconsole.log(table)\n\n\t}\n}\n"],"names":[],"mappings":";;;AAYO,MAAM,uCAAuC,QAAuB;AAAA,EAC1E,YACkB,uBAChB;AACK,UAAA;AAFW,SAAA,wBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,oBAAoB;AAChC,kBAAA,OAAO,SAAS,EAAE,cAAc;AAChC,kBAAA,OAAO,MAAM,EAAE,UAAU;AAAA,EAAA;AAAA,EAGxC,MAAgB,QAAQ,OAAqD;AACtE,UAAA,MAAM,MAAM,UAAU,SAAS;AACrC,UAAM,UAAU,MAAM,KAAK,sBAAsB,QAAQ,GAAG;AAC5D,QAAI,CAAC,SAAS;AACP,YAAA;AAAA,IAAA;AAED,UAAA,MAAM,cAAc,OAAO,QAAQ,UAAU,QAAQ,MAAM,QAAQ,KAAK;AAExE,UAAA,SAAS,MAAM,IAAI,iBAAiB;AACtC,QAAA,MAAM,UAAU,MAAM,GAAG;AAC5B,cAAQ,IAAI,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAC3C;AAAA,IAAA;AAEG,QAAA,OAAO,WAAW,GAAG;AACxB,cAAQ,IAAI,kBAAkB;AAC9B;AAAA,IAAA;AAED,UAAM,QAAQ;AAAA,MACb;AAAA,QACC,SAAS;AAAA,UACR,EAAE,OAAO,MAAM,MAAM,KAAK;AAAA,UAC1B,EAAE,OAAO,aAAa,MAAM,aAAa;AAAA,UACzC,EAAE,OAAO,mBAAmB,MAAM,oBAAoB;AAAA,UACtD,EAAE,OAAO,aAAa,MAAM,aAAa;AAAA,UACzC,EAAE,OAAO,cAAc,MAAM,UAAU;AAAA,UACvC,EAAE,OAAO,SAAS,MAAM,QAAQ;AAAA,UAChC,EAAE,OAAO,UAAU,MAAM,SAAS;AAAA,UAClC,EAAE,OAAO,OAAO,MAAM,MAAM;AAAA,QAAA;AAAA,MAE9B;AAAA,MACA,OAAO,IAAI,CAAO,QAAA;AAAA,QACjB,IAAI,GAAG;AAAA,QACP,WAAW,GAAG;AAAA,QACd,iBAAiB,GAAG;AAAA,QACpB,WAAW,GAAG,aAAa;AAAA,QAC3B,YAAY,GAAG,WAAW,SAAS;AAAA,QACnC,OAAO,GAAG;AAAA,QACV,QAAQ,GAAG;AAAA,QACX,KAAK,KAAK,UAAU,GAAG,IAAI,SAAS,IAAI,GAAG,IAAI,GAAG,IAAI,SAAS,CAAC,IAAI,CAAE,CAAA;AAAA,MAAA,EACrE;AAAA,IACH;AACA,YAAQ,IAAI,KAAK;AAAA,EAAA;AAGnB;"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const cliCommon = require("@contember/cli-common");
4
+ const ActionsClient = require("../../lib/actions/ActionsClient.cjs");
5
+ const chalkTable = require("chalk-table");
6
+ class ActionsListVariablesCommand extends cliCommon.Command {
7
+ constructor(remoteProjectResolver) {
8
+ super();
9
+ this.remoteProjectResolver = remoteProjectResolver;
10
+ }
11
+ configure(configuration) {
12
+ configuration.description("Show action variables");
13
+ configuration.option("project").valueRequired();
14
+ }
15
+ async execute(input) {
16
+ const dsn = input.getOption("project");
17
+ const project = await this.remoteProjectResolver.resolve(dsn);
18
+ if (!project) {
19
+ throw `Project not defined`;
20
+ }
21
+ const api = ActionsClient.ActionsClient.create(project.endpoint, project.name, project.token);
22
+ const result = await api.listVariables();
23
+ console.log(chalkTable({
24
+ columns: ["name", "value"]
25
+ }, result));
26
+ }
27
+ }
28
+ exports.ActionsListVariablesCommand = ActionsListVariablesCommand;
29
+ //# sourceMappingURL=ActionsListVariablesCommand.cjs.map