revisium 2.4.0 → 2.5.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/.github/workflows/build.yml +11 -30
  2. package/.github/workflows/ci.yml +0 -6
  3. package/.github/workflows/npm-publish.yml +13 -78
  4. package/.github/workflows/release-train.yml +90 -0
  5. package/AGENTS.md +152 -0
  6. package/README.md +31 -13
  7. package/dist/e2e/utils/cli-runner.d.ts +1 -0
  8. package/dist/e2e/utils/cli-runner.js +32 -8
  9. package/dist/e2e/utils/cli-runner.js.map +1 -1
  10. package/dist/e2e/utils/matrix-fixtures.d.ts +26 -0
  11. package/dist/e2e/utils/matrix-fixtures.js +109 -0
  12. package/dist/e2e/utils/matrix-fixtures.js.map +1 -0
  13. package/dist/e2e/utils/matrix-workspace.d.ts +25 -0
  14. package/dist/e2e/utils/matrix-workspace.js +61 -0
  15. package/dist/e2e/utils/matrix-workspace.js.map +1 -0
  16. package/dist/e2e/utils/standalone-api.d.ts +52 -0
  17. package/dist/e2e/utils/standalone-api.js +156 -0
  18. package/dist/e2e/utils/standalone-api.js.map +1 -0
  19. package/dist/e2e/utils/standalone-runner.d.ts +22 -0
  20. package/dist/e2e/utils/standalone-runner.js +208 -0
  21. package/dist/e2e/utils/standalone-runner.js.map +1 -0
  22. package/dist/package.json +8 -4
  23. package/dist/src/app.module.js +51 -0
  24. package/dist/src/app.module.js.map +1 -1
  25. package/dist/src/commands/auth/auth-command.utils.d.ts +8 -0
  26. package/dist/src/commands/auth/auth-command.utils.js +28 -0
  27. package/dist/src/commands/auth/auth-command.utils.js.map +1 -0
  28. package/dist/src/commands/auth/auth-login.command.d.ts +29 -0
  29. package/dist/src/commands/auth/auth-login.command.js +155 -0
  30. package/dist/src/commands/auth/auth-login.command.js.map +1 -0
  31. package/dist/src/commands/auth/auth-logout.command.d.ts +19 -0
  32. package/dist/src/commands/auth/auth-logout.command.js +86 -0
  33. package/dist/src/commands/auth/auth-logout.command.js.map +1 -0
  34. package/dist/src/commands/auth/auth-status.command.d.ts +19 -0
  35. package/dist/src/commands/auth/auth-status.command.js +101 -0
  36. package/dist/src/commands/auth/auth-status.command.js.map +1 -0
  37. package/dist/src/commands/auth/auth.command.d.ts +5 -0
  38. package/dist/src/commands/auth/auth.command.js +35 -0
  39. package/dist/src/commands/auth/auth.command.js.map +1 -0
  40. package/dist/src/commands/base-sync.command.d.ts +2 -2
  41. package/dist/src/commands/base-sync.command.js +1 -2
  42. package/dist/src/commands/base-sync.command.js.map +1 -1
  43. package/dist/src/commands/base.command.d.ts +2 -0
  44. package/dist/src/commands/base.command.js +13 -0
  45. package/dist/src/commands/base.command.js.map +1 -1
  46. package/dist/src/commands/context/context-create.command.d.ts +28 -0
  47. package/dist/src/commands/context/context-create.command.js +172 -0
  48. package/dist/src/commands/context/context-create.command.js.map +1 -0
  49. package/dist/src/commands/context/context-list.command.d.ts +14 -0
  50. package/dist/src/commands/context/context-list.command.js +78 -0
  51. package/dist/src/commands/context/context-list.command.js.map +1 -0
  52. package/dist/src/commands/context/context-remove.command.d.ts +9 -0
  53. package/dist/src/commands/context/context-remove.command.js +48 -0
  54. package/dist/src/commands/context/context-remove.command.js.map +1 -0
  55. package/dist/src/commands/context/context-show.command.d.ts +9 -0
  56. package/dist/src/commands/context/context-show.command.js +64 -0
  57. package/dist/src/commands/context/context-show.command.js.map +1 -0
  58. package/dist/src/commands/context/context-use.command.d.ts +9 -0
  59. package/dist/src/commands/context/context-use.command.js +45 -0
  60. package/dist/src/commands/context/context-use.command.js.map +1 -0
  61. package/dist/src/commands/context/context.command.d.ts +5 -0
  62. package/dist/src/commands/context/context.command.js +43 -0
  63. package/dist/src/commands/context/context.command.js.map +1 -0
  64. package/dist/src/commands/endpoint/endpoint-ensure.command.d.ts +18 -0
  65. package/dist/src/commands/endpoint/endpoint-ensure.command.js +90 -0
  66. package/dist/src/commands/endpoint/endpoint-ensure.command.js.map +1 -0
  67. package/dist/src/commands/endpoint/endpoint-list.command.d.ts +14 -0
  68. package/dist/src/commands/endpoint/endpoint-list.command.js +62 -0
  69. package/dist/src/commands/endpoint/endpoint-list.command.js.map +1 -0
  70. package/dist/src/commands/endpoint/endpoint.command.d.ts +5 -0
  71. package/dist/src/commands/endpoint/endpoint.command.js +34 -0
  72. package/dist/src/commands/endpoint/endpoint.command.js.map +1 -0
  73. package/dist/src/commands/example/example-bootstrap.command.d.ts +24 -0
  74. package/dist/src/commands/example/example-bootstrap.command.js +133 -0
  75. package/dist/src/commands/example/example-bootstrap.command.js.map +1 -0
  76. package/dist/src/commands/example/example.command.d.ts +5 -0
  77. package/dist/src/commands/example/example.command.js +33 -0
  78. package/dist/src/commands/example/example.command.js.map +1 -0
  79. package/dist/src/commands/instance/instance-add.command.d.ts +18 -0
  80. package/dist/src/commands/instance/instance-add.command.js +99 -0
  81. package/dist/src/commands/instance/instance-add.command.js.map +1 -0
  82. package/dist/src/commands/instance/instance-list.command.d.ts +14 -0
  83. package/dist/src/commands/instance/instance-list.command.js +69 -0
  84. package/dist/src/commands/instance/instance-list.command.js.map +1 -0
  85. package/dist/src/commands/instance/instance-remove.command.d.ts +16 -0
  86. package/dist/src/commands/instance/instance-remove.command.js +87 -0
  87. package/dist/src/commands/instance/instance-remove.command.js.map +1 -0
  88. package/dist/src/commands/instance/instance-show.command.d.ts +9 -0
  89. package/dist/src/commands/instance/instance-show.command.js +50 -0
  90. package/dist/src/commands/instance/instance-show.command.js.map +1 -0
  91. package/dist/src/commands/instance/instance.command.d.ts +5 -0
  92. package/dist/src/commands/instance/instance.command.js +41 -0
  93. package/dist/src/commands/instance/instance.command.js.map +1 -0
  94. package/dist/src/commands/migration/apply-migrations.command.js +1 -0
  95. package/dist/src/commands/migration/apply-migrations.command.js.map +1 -1
  96. package/dist/src/commands/project/project-ensure.command.d.ts +16 -0
  97. package/dist/src/commands/project/project-ensure.command.js +71 -0
  98. package/dist/src/commands/project/project-ensure.command.js.map +1 -0
  99. package/dist/src/commands/project/project.command.d.ts +5 -0
  100. package/dist/src/commands/project/project.command.js +33 -0
  101. package/dist/src/commands/project/project.command.js.map +1 -0
  102. package/dist/src/services/bootstrap/bootstrap.service.d.ts +112 -0
  103. package/dist/src/services/bootstrap/bootstrap.service.js +439 -0
  104. package/dist/src/services/bootstrap/bootstrap.service.js.map +1 -0
  105. package/dist/src/services/bootstrap/index.d.ts +1 -0
  106. package/dist/src/services/bootstrap/index.js +6 -0
  107. package/dist/src/services/bootstrap/index.js.map +1 -0
  108. package/dist/src/services/common/logger.service.d.ts +1 -0
  109. package/dist/src/services/common/logger.service.js +3 -0
  110. package/dist/src/services/common/logger.service.js.map +1 -1
  111. package/dist/src/services/connection/api-client.d.ts +4 -0
  112. package/dist/src/services/connection/api-client.js +67 -5
  113. package/dist/src/services/connection/api-client.js.map +1 -1
  114. package/dist/src/services/connection/connection-factory.service.js +4 -3
  115. package/dist/src/services/connection/connection-factory.service.js.map +1 -1
  116. package/dist/src/services/connection/connection.service.d.ts +10 -2
  117. package/dist/src/services/connection/connection.service.js +49 -4
  118. package/dist/src/services/connection/connection.service.js.map +1 -1
  119. package/dist/src/services/credentials/credential-store.service.d.ts +19 -0
  120. package/dist/src/services/credentials/credential-store.service.js +112 -0
  121. package/dist/src/services/credentials/credential-store.service.js.map +1 -0
  122. package/dist/src/services/credentials/credential-target.service.d.ts +22 -0
  123. package/dist/src/services/credentials/credential-target.service.js +107 -0
  124. package/dist/src/services/credentials/credential-target.service.js.map +1 -0
  125. package/dist/src/services/credentials/index.d.ts +2 -0
  126. package/dist/src/services/credentials/index.js +8 -0
  127. package/dist/src/services/credentials/index.js.map +1 -0
  128. package/dist/src/services/index.d.ts +3 -0
  129. package/dist/src/services/index.js +3 -0
  130. package/dist/src/services/index.js.map +1 -1
  131. package/dist/src/services/url/auth-prompt.service.d.ts +3 -1
  132. package/dist/src/services/url/auth-prompt.service.js +3 -0
  133. package/dist/src/services/url/auth-prompt.service.js.map +1 -1
  134. package/dist/src/services/url/url-builder.service.js +3 -0
  135. package/dist/src/services/url/url-builder.service.js.map +1 -1
  136. package/dist/src/services/workspace/index.d.ts +1 -0
  137. package/dist/src/services/workspace/index.js +11 -0
  138. package/dist/src/services/workspace/index.js.map +1 -0
  139. package/dist/src/services/workspace/workspace-config.service.d.ts +66 -0
  140. package/dist/src/services/workspace/workspace-config.service.js +320 -0
  141. package/dist/src/services/workspace/workspace-config.service.js.map +1 -0
  142. package/dist/tsconfig.build.tsbuildinfo +1 -1
  143. package/docs/authentication.md +69 -26
  144. package/docs/bootstrap-commands.md +105 -0
  145. package/docs/configuration.md +49 -22
  146. package/docs/url-format.md +2 -2
  147. package/docs/workspace-config.md +135 -0
  148. package/e2e/jest-matrix.json +14 -0
  149. package/e2e/matrix/M01-auth-commands.e2e-spec.ts +241 -0
  150. package/e2e/matrix/M02-instance-commands.e2e-spec.ts +213 -0
  151. package/e2e/matrix/M03-context-commands.e2e-spec.ts +279 -0
  152. package/e2e/matrix/M04-project-ensure.e2e-spec.ts +218 -0
  153. package/e2e/matrix/M05-endpoint-commands.e2e-spec.ts +172 -0
  154. package/e2e/matrix/M06-example-bootstrap.e2e-spec.ts +437 -0
  155. package/e2e/matrix/M07-migrate.e2e-spec.ts +229 -0
  156. package/e2e/matrix/M08-schema.e2e-spec.ts +163 -0
  157. package/e2e/matrix/M09-rows.e2e-spec.ts +185 -0
  158. package/e2e/matrix/M10-sync.e2e-spec.ts +224 -0
  159. package/e2e/matrix/M11-target-resolution.e2e-spec.ts +177 -0
  160. package/e2e/matrix/M12-error-paths.e2e-spec.ts +162 -0
  161. package/e2e/matrix/M13-no-auth-mode.e2e-spec.ts +119 -0
  162. package/e2e/matrix/M14-multi-instance-workspace.e2e-spec.ts +182 -0
  163. package/e2e/matrix/README.md +388 -0
  164. package/e2e/tests/07-workspace-config.e2e-spec.ts +507 -0
  165. package/e2e/tests/08-bootstrap.e2e-spec.ts +304 -0
  166. package/e2e/utils/cli-runner.ts +69 -8
  167. package/e2e/utils/matrix-fixtures.ts +141 -0
  168. package/e2e/utils/matrix-workspace.ts +106 -0
  169. package/e2e/utils/standalone-api.ts +331 -0
  170. package/e2e/utils/standalone-runner.ts +335 -0
  171. package/package.json +8 -4
  172. package/src/app.module.ts +54 -0
  173. package/src/commands/auth/__tests__/auth-command.utils.spec.ts +41 -0
  174. package/src/commands/auth/__tests__/auth-login.command.spec.ts +131 -0
  175. package/src/commands/auth/__tests__/auth-logout.command.spec.ts +85 -0
  176. package/src/commands/auth/__tests__/auth-status.command.spec.ts +106 -0
  177. package/src/commands/auth/__tests__/auth.command.spec.ts +18 -0
  178. package/src/commands/auth/auth-command.utils.ts +36 -0
  179. package/src/commands/auth/auth-login.command.ts +146 -0
  180. package/src/commands/auth/auth-logout.command.ts +71 -0
  181. package/src/commands/auth/auth-status.command.ts +89 -0
  182. package/src/commands/auth/auth.command.ts +20 -0
  183. package/src/commands/base-sync.command.ts +2 -3
  184. package/src/commands/base.command.ts +11 -0
  185. package/src/commands/context/__tests__/context-list.command.spec.ts +102 -0
  186. package/src/commands/context/context-create.command.ts +173 -0
  187. package/src/commands/context/context-list.command.ts +76 -0
  188. package/src/commands/context/context-remove.command.ts +35 -0
  189. package/src/commands/context/context-show.command.ts +59 -0
  190. package/src/commands/context/context-use.command.ts +31 -0
  191. package/src/commands/context/context.command.ts +28 -0
  192. package/src/commands/endpoint/__tests__/endpoint-ensure.command.spec.ts +129 -0
  193. package/src/commands/endpoint/__tests__/endpoint-list.command.spec.ts +59 -0
  194. package/src/commands/endpoint/__tests__/endpoint.command.spec.ts +14 -0
  195. package/src/commands/endpoint/endpoint-ensure.command.ts +74 -0
  196. package/src/commands/endpoint/endpoint-list.command.ts +48 -0
  197. package/src/commands/endpoint/endpoint.command.ts +19 -0
  198. package/src/commands/example/__tests__/example-bootstrap.command.spec.ts +145 -0
  199. package/src/commands/example/__tests__/example.command.spec.ts +14 -0
  200. package/src/commands/example/example-bootstrap.command.ts +122 -0
  201. package/src/commands/example/example.command.ts +18 -0
  202. package/src/commands/instance/__tests__/instance-add.command.spec.ts +93 -0
  203. package/src/commands/instance/__tests__/instance-list.command.spec.ts +91 -0
  204. package/src/commands/instance/__tests__/instance-remove.command.spec.ts +113 -0
  205. package/src/commands/instance/instance-add.command.ts +88 -0
  206. package/src/commands/instance/instance-list.command.ts +57 -0
  207. package/src/commands/instance/instance-remove.command.ts +80 -0
  208. package/src/commands/instance/instance-show.command.ts +35 -0
  209. package/src/commands/instance/instance.command.ts +26 -0
  210. package/src/commands/migration/apply-migrations.command.ts +1 -0
  211. package/src/commands/project/__tests__/project-ensure.command.spec.ts +119 -0
  212. package/src/commands/project/__tests__/project.command.spec.ts +14 -0
  213. package/src/commands/project/project-ensure.command.ts +61 -0
  214. package/src/commands/project/project.command.ts +18 -0
  215. package/src/services/bootstrap/__tests__/bootstrap.service.spec.ts +812 -0
  216. package/src/services/bootstrap/bootstrap.service.ts +699 -0
  217. package/src/services/bootstrap/index.ts +12 -0
  218. package/src/services/common/logger.service.ts +9 -0
  219. package/src/services/connection/__tests__/api-client.spec.ts +262 -0
  220. package/src/services/connection/__tests__/connection-factory.service.spec.ts +2 -0
  221. package/src/services/connection/__tests__/connection.service.spec.ts +162 -0
  222. package/src/services/connection/api-client.ts +88 -5
  223. package/src/services/connection/connection-factory.service.ts +4 -3
  224. package/src/services/connection/connection.service.ts +74 -3
  225. package/src/services/credentials/__tests__/credential-store.service.spec.ts +128 -0
  226. package/src/services/credentials/__tests__/credential-target.service.spec.ts +126 -0
  227. package/src/services/credentials/credential-store.service.ts +145 -0
  228. package/src/services/credentials/credential-target.service.ts +145 -0
  229. package/src/services/credentials/index.ts +9 -0
  230. package/src/services/index.ts +3 -0
  231. package/src/services/url/__tests__/url-builder.service.spec.ts +17 -0
  232. package/src/services/url/auth-prompt.service.ts +6 -1
  233. package/src/services/url/url-builder.service.ts +4 -0
  234. package/src/services/workspace/__tests__/workspace-config.service.spec.ts +389 -0
  235. package/src/services/workspace/index.ts +14 -0
  236. package/src/services/workspace/workspace-config.service.ts +475 -0
  237. package/.github/workflows/bump-version.yml +0 -86
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tagSchema = tagSchema;
4
+ exports.faqSchema = faqSchema;
5
+ exports.questSchema = questSchema;
6
+ exports.tagRows = tagRows;
7
+ exports.faqRows = faqRows;
8
+ exports.questRows = questRows;
9
+ exports.bootstrapConfig = bootstrapConfig;
10
+ exports.tagBootstrapConfig = tagBootstrapConfig;
11
+ exports.faqBootstrapConfig = faqBootstrapConfig;
12
+ function tagSchema() {
13
+ return clone({
14
+ type: 'object',
15
+ required: ['label'],
16
+ additionalProperties: false,
17
+ properties: {
18
+ label: { type: 'string', default: '' },
19
+ slug: { type: 'string', default: '' },
20
+ },
21
+ });
22
+ }
23
+ function faqSchema() {
24
+ return clone({
25
+ type: 'object',
26
+ required: ['name'],
27
+ additionalProperties: false,
28
+ properties: {
29
+ name: { type: 'string', default: '' },
30
+ summary: { type: 'string', default: '' },
31
+ },
32
+ });
33
+ }
34
+ function questSchema() {
35
+ return clone({
36
+ type: 'object',
37
+ required: ['title'],
38
+ additionalProperties: false,
39
+ properties: {
40
+ title: { type: 'string', default: '' },
41
+ points: { type: 'number', default: 0 },
42
+ published: { type: 'boolean', default: false },
43
+ },
44
+ });
45
+ }
46
+ function tagRows(count = 3) {
47
+ return Array.from({ length: count }, (_, i) => ({
48
+ tableId: 'Tag',
49
+ rowId: `tag-${i + 1}`,
50
+ data: { label: `Tag ${i + 1}`, slug: `tag-${i + 1}` },
51
+ }));
52
+ }
53
+ function faqRows() {
54
+ return [
55
+ {
56
+ tableId: 'FaqCategory',
57
+ rowId: 'billing',
58
+ data: { name: 'Billing', summary: 'Payments and invoices' },
59
+ },
60
+ {
61
+ tableId: 'FaqCategory',
62
+ rowId: 'general',
63
+ data: { name: 'General', summary: 'Anything else' },
64
+ },
65
+ ];
66
+ }
67
+ function questRows(count = 50) {
68
+ return Array.from({ length: count }, (_, i) => ({
69
+ tableId: 'Quest',
70
+ rowId: `quest-${String(i + 1).padStart(3, '0')}`,
71
+ data: {
72
+ title: `Quest ${i + 1}`,
73
+ points: (i + 1) * 10,
74
+ published: i % 2 === 0,
75
+ },
76
+ }));
77
+ }
78
+ function bootstrapConfig(partial = {}) {
79
+ return clone({
80
+ endpoints: ['REST_API', 'GRAPHQL'],
81
+ tables: [],
82
+ rows: [],
83
+ ...partial,
84
+ });
85
+ }
86
+ function tagBootstrapConfig(projectName) {
87
+ return bootstrapConfig({
88
+ projectName,
89
+ branchName: 'master',
90
+ endpoints: ['REST_API'],
91
+ tables: [{ id: 'Tag', schema: tagSchema() }],
92
+ rows: tagRows(3),
93
+ commitMessage: 'Bootstrap tag fixture',
94
+ });
95
+ }
96
+ function faqBootstrapConfig(projectName) {
97
+ return bootstrapConfig({
98
+ projectName,
99
+ branchName: 'master',
100
+ endpoints: ['REST_API', 'GRAPHQL'],
101
+ tables: [{ id: 'FaqCategory', schema: faqSchema() }],
102
+ rows: faqRows(),
103
+ commitMessage: 'Bootstrap faq fixture',
104
+ });
105
+ }
106
+ function clone(value) {
107
+ return JSON.parse(JSON.stringify(value));
108
+ }
109
+ //# sourceMappingURL=matrix-fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrix-fixtures.js","sourceRoot":"","sources":["../../../e2e/utils/matrix-fixtures.ts"],"names":[],"mappings":";;AA2BA,8BAUC;AAED,8BAUC;AAED,kCAWC;AAID,0BAMC;AAED,0BAaC;AAED,8BAUC;AAID,0CASC;AAED,gDASC;AAED,gDASC;AA3GD,SAAgB,SAAS;IACvB,OAAO,KAAK,CAAC;QACX,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,OAAO,CAAC;QACnB,oBAAoB,EAAE,KAAK;QAC3B,UAAU,EAAE;YACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;YACtC,IAAI,EAAE,EAAE,IAAI,EA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CAAC,CAAC;QAChB,aAAa,EAAE,uBAAuB;KACvC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,kBAAkB,CAAC,WAAmB;IACpD,OAAO,eAAe,CAAC;QACrB,WAAW;QACX,UAAU,EAAE,QAAQ;QACpB,SAAS,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC;QAClC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC;QACpD,IAAI,EAAE,OAAO,EAAE;QACf,aAAa,EAAE,uBAAuB;KACvC,CAAC,CAAC;AACL,CAAC;AAID,SAAS,KAAK,CAAI,KAAQ;IACxB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAM,CAAC;AAChD,CAAC"}
@@ -0,0 +1,25 @@
1
+ export declare const CLEAR_REVISIUM_ENV: Record<string, string>;
2
+ export interface WorkspaceInstanceConfig {
3
+ baseUrl: string;
4
+ authMode?: 'none' | 'stored';
5
+ }
6
+ export interface WorkspaceContextConfig {
7
+ instance: string;
8
+ organization?: string;
9
+ project?: string;
10
+ branch?: string;
11
+ revision?: string;
12
+ credential?: string;
13
+ }
14
+ export interface WorkspaceConfigShape {
15
+ version?: number;
16
+ currentContext?: string;
17
+ instances?: Record<string, WorkspaceInstanceConfig>;
18
+ contexts?: Record<string, WorkspaceContextConfig>;
19
+ }
20
+ export declare function createWorkspace(prefix?: string): string;
21
+ export declare function writeWorkspaceConfig(workspace: string, config: WorkspaceConfigShape): string;
22
+ export declare function workspaceFile(workspace: string, ...segments: string[]): string;
23
+ export declare function uniqueCredentialStoreService(prefix?: string): string;
24
+ export declare function removeWorkspace(workspace: string): void;
25
+ export declare function writeBootstrapConfigFile(workspace: string, data: unknown, filename?: string): string;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CLEAR_REVISIUM_ENV = void 0;
4
+ exports.createWorkspace = createWorkspace;
5
+ exports.writeWorkspaceConfig = writeWorkspaceConfig;
6
+ exports.workspaceFile = workspaceFile;
7
+ exports.uniqueCredentialStoreService = uniqueCredentialStoreService;
8
+ exports.removeWorkspace = removeWorkspace;
9
+ exports.writeBootstrapConfigFile = writeBootstrapConfigFile;
10
+ const node_crypto_1 = require("node:crypto");
11
+ const fs = require("node:fs");
12
+ const os = require("node:os");
13
+ const path = require("node:path");
14
+ exports.CLEAR_REVISIUM_ENV = {
15
+ REVISIUM_URL: '',
16
+ REVISIUM_TOKEN: '',
17
+ REVISIUM_API_KEY: '',
18
+ REVISIUM_USERNAME: '',
19
+ REVISIUM_PASSWORD: '',
20
+ REVISIUM_HOST: '',
21
+ REVISIUM_ORG: '',
22
+ REVISIUM_PROJECT: '',
23
+ REVISIUM_BRANCH: '',
24
+ REVISIUM_REVISION: '',
25
+ REVISIUM_SOURCE_URL: '',
26
+ REVISIUM_SOURCE_TOKEN: '',
27
+ REVISIUM_SOURCE_API_KEY: '',
28
+ REVISIUM_SOURCE_USERNAME: '',
29
+ REVISIUM_SOURCE_PASSWORD: '',
30
+ REVISIUM_TARGET_URL: '',
31
+ REVISIUM_TARGET_TOKEN: '',
32
+ REVISIUM_TARGET_API_KEY: '',
33
+ REVISIUM_TARGET_USERNAME: '',
34
+ REVISIUM_TARGET_PASSWORD: '',
35
+ REVISIUM_ENV_FILE: '',
36
+ };
37
+ function createWorkspace(prefix = 'revisium-cli-matrix-') {
38
+ return fs.mkdtempSync(path.join(os.tmpdir(), prefix));
39
+ }
40
+ function writeWorkspaceConfig(workspace, config) {
41
+ const dir = path.join(workspace, '.revisium');
42
+ fs.mkdirSync(dir, { recursive: true });
43
+ const filePath = path.join(dir, 'revisium-cli.config.json');
44
+ fs.writeFileSync(filePath, JSON.stringify({ version: 1, ...config }, null, 2), 'utf-8');
45
+ return filePath;
46
+ }
47
+ function workspaceFile(workspace, ...segments) {
48
+ return path.join(workspace, ...segments);
49
+ }
50
+ function uniqueCredentialStoreService(prefix = 'revisium-cli-e2e') {
51
+ return `${prefix}-${(0, node_crypto_1.randomBytes)(6).toString('hex')}`;
52
+ }
53
+ function removeWorkspace(workspace) {
54
+ fs.rmSync(workspace, { recursive: true, force: true });
55
+ }
56
+ function writeBootstrapConfigFile(workspace, data, filename = 'bootstrap.config.json') {
57
+ const filePath = workspaceFile(workspace, filename);
58
+ fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
59
+ return filePath;
60
+ }
61
+ //# sourceMappingURL=matrix-workspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrix-workspace.js","sourceRoot":"","sources":["../../../e2e/utils/matrix-workspace.ts"],"names":[],"mappings":";;;AAqDA,0CAIC;AAGD,oDAaC;AAGD,sCAKC;AAID,oEAIC;AAID,0CAEC;AAED,4DAQC;AAzGD,6CAA0C;AAC1C,8BAA8B;AAC9B,8BAA8B;AAC9B,kCAAkC;AAIrB,QAAA,kBAAkB,GAA2B;IACxD,YAAY,EAAE,EAAE;IAChB,cAAc,EAAE,EAAE;IAClB,gBAAgB,EAAE,EAAE;IACpB,iBAAiB,EAAE,EAAE;IACrB,iBAAiB,EAAE,EAAE;IACrB,aAAa,EAAE,EAAE;IACjB,YAAY,EAAE,EAAE;IAChB,gBAAgB,EAAE,EAAE;IACpB,eAAe,EAAE,EAAE;IACnB,iBAAiB,EAAE,EAAE;IACrB,mBAAmB,EAAE,EAAE;IACvB,qBAAqB,EAAE,EAAE;IACzB,uBAAuB,EAAE,EAAE;IAC3B,wBAAwB,EAAE,EAAE;IAC5B,wBAAwB,EAAE,EAAE;IAC5B,mBAAmB,EAAE,EAAE;IACvB,qBAAqB,EAAE,EAAE;IACzB,uBAAuB,EAAE,EAAE;IAC3B,wBAAwB,EAAE,EAAE;IAC5B,wBAAwB,EAAE,EAAE;IAC5B,iBAAiB,EAAE,EAAE;CACtB,CAAC;AAwBF,SAAgB,eAAe,CAC7B,SAAiB,sBAAsB;IAEvC,OAAO,EAAE,C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EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACnE,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,52 @@
1
+ export interface MintApiKeyOptions {
2
+ name: string;
3
+ expiresAt?: string;
4
+ }
5
+ export interface ApiKeyRecord {
6
+ id: string;
7
+ apiKey: string;
8
+ name: string;
9
+ }
10
+ export interface SeedTableInput {
11
+ organization: string;
12
+ project: string;
13
+ branch?: string;
14
+ tableId: string;
15
+ schema: object;
16
+ }
17
+ export interface SeedRowInput {
18
+ organization: string;
19
+ project: string;
20
+ branch?: string;
21
+ tableId: string;
22
+ rowId: string;
23
+ data: object;
24
+ }
25
+ export declare class StandaloneApiClient {
26
+ readonly baseUrl: string;
27
+ private token;
28
+ constructor(baseUrl: string);
29
+ login(username?: string, password?: string): Promise<string>;
30
+ setToken(token: string): void;
31
+ clearToken(): void;
32
+ mintApiKey(organization: string, options: MintApiKeyOptions): Promise<ApiKeyRecord>;
33
+ createProject(organization: string, projectName: string, branchName?: string): Promise<void>;
34
+ deleteProject(organization: string, projectName: string): Promise<void>;
35
+ projectExists(organization: string, projectName: string): Promise<boolean>;
36
+ getDraftRevisionId(organization: string, projectName: string, branchName?: string): Promise<string>;
37
+ seedTable(input: SeedTableInput): Promise<void>;
38
+ seedRow(input: SeedRowInput): Promise<void>;
39
+ listTables(organization: string, projectName: string, branchName?: string): Promise<Array<{
40
+ id: string;
41
+ }>>;
42
+ listRows(organization: string, projectName: string, tableId: string, branchName?: string): Promise<Array<{
43
+ id: string;
44
+ data: unknown;
45
+ }>>;
46
+ listEndpoints(organization: string, projectName: string, branchName?: string): Promise<Array<{
47
+ id: string;
48
+ type: string;
49
+ }>>;
50
+ private request;
51
+ private graphql;
52
+ }
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StandaloneApiClient = void 0;
4
+ class StandaloneApiClient {
5
+ baseUrl;
6
+ token;
7
+ constructor(baseUrl) {
8
+ this.baseUrl = baseUrl;
9
+ }
10
+ async login(username = 'admin', password = 'test-admin') {
11
+ const data = await this.request('POST', '/api/auth/login', { emailOrUsername: username, password });
12
+ this.token = data.accessToken;
13
+ return this.token;
14
+ }
15
+ setToken(token) {
16
+ this.token = token;
17
+ }
18
+ clearToken() {
19
+ this.token = undefined;
20
+ }
21
+ async mintApiKey(organization, options) {
22
+ const data = await this.graphql(`mutation($data: CreatePersonalApiKeyInput!) {
23
+ createPersonalApiKey(data: $data) {
24
+ apiKey { id name }
25
+ secret
26
+ }
27
+ }`, {
28
+ data: {
29
+ name: options.name,
30
+ organizationId: organization,
31
+ ...(options.expiresAt ? { expiresAt: options.expiresAt } : {}),
32
+ },
33
+ });
34
+ return {
35
+ id: data.createPersonalApiKey.apiKey.id,
36
+ apiKey: data.createPersonalApiKey.secret,
37
+ name: data.createPersonalApiKey.apiKey.name,
38
+ };
39
+ }
40
+ async createProject(organization, projectName, branchName = 'master') {
41
+ await this.graphql(`mutation($data: CreateProjectInput!) { createProject(data: $data) { id } }`, { data: { organizationId: organization, projectName, branchName } });
42
+ }
43
+ async deleteProject(organization, projectName) {
44
+ await this.graphql(`mutation($data: DeleteProjectInput!) { deleteProject(data: $data) }`, { data: { organizationId: organization, projectName } });
45
+ }
46
+ async projectExists(organization, projectName) {
47
+ try {
48
+ await this.graphql(`query($data: GetProjectInput!) { project(data: $data) { id } }`, { data: { organizationId: organization, projectName } });
49
+ return true;
50
+ }
51
+ catch (error) {
52
+ if (isNotFoundError(error)) {
53
+ return false;
54
+ }
55
+ throw error;
56
+ }
57
+ }
58
+ async getDraftRevisionId(organization, projectName, branchName = 'master') {
59
+ const data = await this.graphql(`query($data: GetBranchInput!) {
60
+ branch(data: $data) { draft { id } }
61
+ }`, {
62
+ data: { organizationId: organization, projectName, branchName },
63
+ });
64
+ return data.branch.draft.id;
65
+ }
66
+ async seedTable(input) {
67
+ const revisionId = await this.getDraftRevisionId(input.organization, input.project, input.branch);
68
+ await this.graphql(`mutation($data: CreateTableInput!) {
69
+ createTable(data: $data) { table { versionId } }
70
+ }`, {
71
+ data: { revisionId, tableId: input.tableId, schema: input.schema },
72
+ });
73
+ }
74
+ async seedRow(input) {
75
+ const revisionId = await this.getDraftRevisionId(input.organization, input.project, input.branch);
76
+ await this.graphql(`mutation($data: CreateRowInput!) {
77
+ createRow(data: $data) { row { versionId } }
78
+ }`, {
79
+ data: {
80
+ revisionId,
81
+ tableId: input.tableId,
82
+ rowId: input.rowId,
83
+ data: input.data,
84
+ },
85
+ });
86
+ }
87
+ async listTables(organization, projectName, branchName = 'master') {
88
+ const revisionId = await this.getDraftRevisionId(organization, projectName, branchName);
89
+ const data = await this.graphql(`query($data: GetTablesInput!) {
90
+ tables(data: $data) { edges { node { id } } }
91
+ }`, { data: { revisionId, first: 100 } });
92
+ return data.tables.edges.map((edge) => edge.node);
93
+ }
94
+ async listRows(organization, projectName, tableId, branchName = 'master') {
95
+ const revisionId = await this.getDraftRevisionId(organization, projectName, branchName);
96
+ const data = await this.graphql(`query($data: GetRowsInput!) {
97
+ rows(data: $data) { edges { node { id data } } }
98
+ }`, { data: { revisionId, tableId, first: 1000 } });
99
+ return data.rows.edges.map((edge) => edge.node);
100
+ }
101
+ async listEndpoints(organization, projectName, branchName = 'master') {
102
+ const revisionId = await this.getDraftRevisionId(organization, projectName, branchName);
103
+ const data = await this.graphql(`query($data: GetRevisionInput!) {
104
+ revision(data: $data) { endpoints { id type } }
105
+ }`, { data: { revisionId } });
106
+ return data.revision.endpoints;
107
+ }
108
+ async request(method, path, body) {
109
+ const headers = {
110
+ 'Content-Type': 'application/json',
111
+ };
112
+ if (this.token) {
113
+ headers['Authorization'] = `Bearer ${this.token}`;
114
+ }
115
+ const response = await fetch(`${this.baseUrl}${path}`, {
116
+ method,
117
+ headers,
118
+ body: body === undefined ? undefined : JSON.stringify(body),
119
+ });
120
+ if (!response.ok) {
121
+ const text = await response.text();
122
+ throw new Error(`${method} ${path} failed: ${response.status} ${response.statusText} ${text}`);
123
+ }
124
+ return (await response.json());
125
+ }
126
+ async graphql(query, variables) {
127
+ const headers = {
128
+ 'Content-Type': 'application/json',
129
+ };
130
+ if (this.token) {
131
+ headers['Authorization'] = `Bearer ${this.token}`;
132
+ }
133
+ const response = await fetch(`${this.baseUrl}/graphql`, {
134
+ method: 'POST',
135
+ headers,
136
+ body: JSON.stringify({ query, variables }),
137
+ });
138
+ if (!response.ok) {
139
+ const text = await response.text();
140
+ throw new Error(`graphql failed: ${response.status} ${response.statusText} ${text}`);
141
+ }
142
+ const result = (await response.json());
143
+ if (result.errors?.length) {
144
+ throw new Error(`graphql error: ${result.errors[0].message}`);
145
+ }
146
+ return result.data;
147
+ }
148
+ }
149
+ exports.StandaloneApiClient = StandaloneApiClient;
150
+ function isNotFoundError(error) {
151
+ if (!(error instanceof Error)) {
152
+ return false;
153
+ }
154
+ return /not.?found|404/i.test(error.message);
155
+ }
156
+ //# sourceMappingURL=standalone-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standalone-api.js","sourceRoot":"","sources":["../../../e2e/utils/standalone-api.ts"],"names":[],"mappings":";;;AAsCA,MAAa,mBAAmB;IAGF;IAFpB,KAAK,CAAqB;IAElC,YAA4B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAI/C,KAAK,CAAC,KAAK,CACT,WAAmB,OAAO,EAC1B,WAAmB,YAAY;QAE/B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAC7B,MAAM,EACN,iBAAiB,EACjB,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,EAAE,CACxC,CAAC;QACF,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC;QAC9B,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,QAAQ,CAAC,KAAa;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAA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IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;SAC3C,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CACb,mBAAmB,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,IAAI,IAAI,EAAE,CACpE,CAAC;QACJ,CAAC;QACD,MAAM,MAAM,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAGpC,CAAC;QACF,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,kBAAkB,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,MAAM,CAAC,IAAS,CAAC;IAC1B,CAAC;CACF;AA7RD,kDA6RC;AAED,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { StandaloneApiClient } from './standalone-api';
2
+ export interface StartStandaloneOptions {
3
+ auth?: boolean;
4
+ adminPassword?: string;
5
+ version?: string;
6
+ env?: Record<string, string>;
7
+ readinessTimeoutMs?: number;
8
+ }
9
+ export interface StandaloneInstance {
10
+ baseUrl: string;
11
+ port: number;
12
+ auth: boolean;
13
+ api: StandaloneApiClient;
14
+ url: (parts?: {
15
+ organization?: string;
16
+ project?: string;
17
+ branch?: string;
18
+ revision?: string;
19
+ }) => string;
20
+ stop: () => Promise<void>;
21
+ }
22
+ export declare function startStandalone(options?: StartStandaloneOptions): Promise<StandaloneInstance>;
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startStandalone = startStandalone;
4
+ const node_child_process_1 = require("node:child_process");
5
+ const promises_1 = require("node:fs/promises");
6
+ const node_os_1 = require("node:os");
7
+ const node_path_1 = require("node:path");
8
+ const standalone_api_1 = require("./standalone-api");
9
+ async function startStandalone(options = {}) {
10
+ const { auth = false, adminPassword, version, env: extraEnv = {}, readinessTimeoutMs = 180_000, } = options;
11
+ if (auth && !adminPassword) {
12
+ throw new TypeError('startStandalone: adminPassword is required when auth=true');
13
+ }
14
+ const dataDir = await (0, promises_1.mkdtemp)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'revisium-standalone-'));
15
+ const args = [
16
+ '--yes',
17
+ version ? `@revisium/standalone@${version}` : '@revisium/standalone',
18
+ '--data',
19
+ dataDir,
20
+ ];
21
+ if (auth) {
22
+ args.push('--auth');
23
+ }
24
+ const child = (0, node_child_process_1.spawn)('npx', args, {
25
+ env: {
26
+ ...process.env,
27
+ ...(adminPassword ? { ADMIN_PASSWORD: adminPassword } : {}),
28
+ ...extraEnv,
29
+ },
30
+ stdio: ['ignore', 'pipe', 'pipe'],
31
+ });
32
+ let resolvedPort = null;
33
+ attachLogPipes(child, () => resolvedPort);
34
+ let port;
35
+ try {
36
+ port = await waitForBanner(child, readinessTimeoutMs);
37
+ resolvedPort = port;
38
+ await waitForReady(`http://localhost:${port}/health/readiness`, 30_000);
39
+ }
40
+ catch (error) {
41
+ await stopProcess(child, dataDir);
42
+ throw error;
43
+ }
44
+ const baseUrl = `http://localhost:${port}`;
45
+ const api = new standalone_api_1.StandaloneApiClient(baseUrl);
46
+ let stopped = false;
47
+ return {
48
+ baseUrl,
49
+ port,
50
+ auth,
51
+ api,
52
+ url: (parts) => buildRevisiumUrl(port, parts),
53
+ stop: async () => {
54
+ if (stopped) {
55
+ return;
56
+ }
57
+ stopped = true;
58
+ await stopProcess(child, dataDir);
59
+ },
60
+ };
61
+ }
62
+ function buildRevisiumUrl(port, parts = {}) {
63
+ const host = `localhost:${port}`;
64
+ if (!parts.project) {
65
+ return `revisium://${host}`;
66
+ }
67
+ const org = parts.organization ?? 'admin';
68
+ const branch = parts.branch ?? 'master';
69
+ const tail = parts.revision ? `:${parts.revision}` : '';
70
+ return `revisium://${host}/${org}/${parts.project}/${branch}${tail}`;
71
+ }
72
+ function waitForBanner(child, timeoutMs) {
73
+ return new Promise((resolve, reject) => {
74
+ let buffer = '';
75
+ let settled = false;
76
+ const bannerRegex = /URL:\s+http:\/\/localhost:(\d+)/;
77
+ const timer = setTimeout(() => {
78
+ if (!settled) {
79
+ settled = true;
80
+ cleanup();
81
+ const tail = buffer.slice(-2_000) || '<no output>';
82
+ reject(new Error(`Standalone did not announce a URL within ${timeoutMs}ms. Tail: ${tail}`));
83
+ }
84
+ }, timeoutMs);
85
+ const onData = (chunk) => {
86
+ if (settled)
87
+ return;
88
+ buffer += chunk.toString();
89
+ const match = bannerRegex.exec(buffer);
90
+ if (match) {
91
+ settled = true;
92
+ cleanup();
93
+ resolve(Number(match[1]));
94
+ }
95
+ };
96
+ const onExit = (code) => {
97
+ if (settled)
98
+ return;
99
+ settled = true;
100
+ cleanup();
101
+ const tail = buffer.slice(-2_000) || '<no output>';
102
+ reject(new Error(`Standalone exited (code=${code ?? 'null'}) before announcing a URL. Tail: ${tail}`));
103
+ };
104
+ const onError = (error) => {
105
+ if (settled)
106
+ return;
107
+ settled = true;
108
+ cleanup();
109
+ reject(error);
110
+ };
111
+ function cleanup() {
112
+ clearTimeout(timer);
113
+ child.stdout?.off('data', onData);
114
+ child.stderr?.off('data', onData);
115
+ child.off('exit', onExit);
116
+ child.off('error', onError);
117
+ }
118
+ child.stdout?.on('data', onData);
119
+ child.stderr?.on('data', onData);
120
+ child.once('exit', onExit);
121
+ child.once('error', onError);
122
+ });
123
+ }
124
+ async function waitForReady(url, timeoutMs) {
125
+ const start = Date.now();
126
+ let lastError;
127
+ const perRequestTimeoutMs = 5_000;
128
+ while (Date.now() - start < timeoutMs) {
129
+ const controller = new AbortController();
130
+ const abortTimer = setTimeout(() => controller.abort(), perRequestTimeoutMs);
131
+ try {
132
+ const response = await fetch(url, { signal: controller.signal });
133
+ if (response.ok) {
134
+ return;
135
+ }
136
+ lastError = new Error(`HTTP ${response.status}`);
137
+ }
138
+ catch (error) {
139
+ lastError = error;
140
+ }
141
+ finally {
142
+ clearTimeout(abortTimer);
143
+ }
144
+ await sleep(500);
145
+ }
146
+ throw new Error(`Standalone readiness check timed out at ${url}: ${formatError(lastError)}`);
147
+ }
148
+ async function stopProcess(child, dataDir) {
149
+ if (!child.killed && child.exitCode === null) {
150
+ child.kill('SIGTERM');
151
+ try {
152
+ await waitForExit(child, 5_000);
153
+ }
154
+ catch {
155
+ child.kill('SIGKILL');
156
+ await waitForExit(child, 5_000).catch(() => undefined);
157
+ }
158
+ }
159
+ await (0, promises_1.rm)(dataDir, { recursive: true, force: true });
160
+ }
161
+ function waitForExit(child, timeoutMs) {
162
+ return new Promise((resolve, reject) => {
163
+ const timer = setTimeout(() => reject(new Error('standalone exit timeout')), timeoutMs);
164
+ child.once('exit', () => {
165
+ clearTimeout(timer);
166
+ resolve();
167
+ });
168
+ });
169
+ }
170
+ function attachLogPipes(child, getPort) {
171
+ const tag = () => {
172
+ const port = getPort();
173
+ return port === null ? '[standalone:<pending>]' : `[standalone:${port}]`;
174
+ };
175
+ if (process.env.E2E_STANDALONE_LOGS === '1') {
176
+ child.stdout?.on('data', (chunk) => {
177
+ process.stderr.write(`${tag()} ${chunk.toString()}`);
178
+ });
179
+ child.stderr?.on('data', (chunk) => {
180
+ process.stderr.write(`${tag()} ${chunk.toString()}`);
181
+ });
182
+ }
183
+ else {
184
+ child.stdout?.on('data', () => { });
185
+ child.stderr?.on('data', () => { });
186
+ }
187
+ }
188
+ function sleep(ms) {
189
+ return new Promise((resolve) => setTimeout(resolve, ms));
190
+ }
191
+ function formatError(error) {
192
+ if (error instanceof Error) {
193
+ return error.message;
194
+ }
195
+ if (error === undefined || error === null) {
196
+ return 'unknown error';
197
+ }
198
+ if (typeof error === 'string') {
199
+ return error;
200
+ }
201
+ try {
202
+ return JSON.stringify(error);
203
+ }
204
+ catch {
205
+ return 'unknown error';
206
+ }
207
+ }
208
+ //# sourceMappingURL=standalone-runner.js.map