@squiz/dxp-cli-next 5.33.0-develop.1 → 5.33.0-develop.10

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 (370) hide show
  1. package/README.md +1 -0
  2. package/bin/dxp.js +6 -1
  3. package/dist/dxp.js +4480 -0
  4. package/package.json +36 -30
  5. package/lib/ApiService.d.ts +0 -39
  6. package/lib/ApiService.js +0 -120
  7. package/lib/ApiService.spec.d.ts +0 -1
  8. package/lib/ApiService.spec.js +0 -182
  9. package/lib/ApplicationConfig.d.ts +0 -7
  10. package/lib/ApplicationConfig.js +0 -38
  11. package/lib/ApplicationConfig.spec.d.ts +0 -1
  12. package/lib/ApplicationConfig.spec.js +0 -84
  13. package/lib/ApplicationStore.d.ts +0 -13
  14. package/lib/ApplicationStore.js +0 -53
  15. package/lib/__tests__/cmp/dev-mode.spec.d.ts +0 -1
  16. package/lib/__tests__/cmp/dev-mode.spec.js +0 -54
  17. package/lib/__tests__/helpers.d.ts +0 -17
  18. package/lib/__tests__/helpers.js +0 -54
  19. package/lib/__tests__/integration/main.spec.d.ts +0 -1
  20. package/lib/__tests__/integration/main.spec.js +0 -45
  21. package/lib/__tests__/smoke/validate.spec.d.ts +0 -1
  22. package/lib/__tests__/smoke/validate.spec.js +0 -37
  23. package/lib/__tests__/unit/cli.d.ts +0 -0
  24. package/lib/__tests__/unit/cli.js +0 -7
  25. package/lib/auth/index.d.ts +0 -3
  26. package/lib/auth/index.js +0 -14
  27. package/lib/auth/login/login.d.ts +0 -22
  28. package/lib/auth/login/login.js +0 -268
  29. package/lib/auth/login/login.spec.d.ts +0 -1
  30. package/lib/auth/login/login.spec.js +0 -179
  31. package/lib/auth/logout/logout.d.ts +0 -3
  32. package/lib/auth/logout/logout.js +0 -115
  33. package/lib/auth/logout/logout.spec.d.ts +0 -1
  34. package/lib/auth/logout/logout.spec.js +0 -67
  35. package/lib/cdp/constants.d.ts +0 -1
  36. package/lib/cdp/constants.js +0 -4
  37. package/lib/cdp/index.d.ts +0 -3
  38. package/lib/cdp/index.js +0 -16
  39. package/lib/cdp/instance/activate/activate.d.ts +0 -5
  40. package/lib/cdp/instance/activate/activate.js +0 -107
  41. package/lib/cdp/instance/activate/activate.spec.d.ts +0 -1
  42. package/lib/cdp/instance/activate/activate.spec.js +0 -274
  43. package/lib/cdp/instance/instanceCommand.d.ts +0 -3
  44. package/lib/cdp/instance/instanceCommand.js +0 -15
  45. package/lib/cdp/schema/deploy/deploy.const.d.ts +0 -5
  46. package/lib/cdp/schema/deploy/deploy.const.js +0 -8
  47. package/lib/cdp/schema/deploy/deploy.d.ts +0 -4
  48. package/lib/cdp/schema/deploy/deploy.js +0 -107
  49. package/lib/cdp/schema/deploy/deploy.spec.d.ts +0 -1
  50. package/lib/cdp/schema/deploy/deploy.spec.js +0 -137
  51. package/lib/cdp/schema/schemaCommand.d.ts +0 -3
  52. package/lib/cdp/schema/schemaCommand.js +0 -15
  53. package/lib/cdp/utils.d.ts +0 -23
  54. package/lib/cdp/utils.js +0 -133
  55. package/lib/cmp/deploy.d.ts +0 -3
  56. package/lib/cmp/deploy.js +0 -124
  57. package/lib/cmp/dev-mode-ui.d.ts +0 -4
  58. package/lib/cmp/dev-mode-ui.js +0 -51
  59. package/lib/cmp/dev-mode.d.ts +0 -4
  60. package/lib/cmp/dev-mode.js +0 -58
  61. package/lib/cmp/edge-components/compiler.d.ts +0 -13
  62. package/lib/cmp/edge-components/compiler.js +0 -55
  63. package/lib/cmp/index.d.ts +0 -3
  64. package/lib/cmp/index.js +0 -18
  65. package/lib/cmp/init.d.ts +0 -3
  66. package/lib/cmp/init.js +0 -105
  67. package/lib/cmp/utils/definitions.d.ts +0 -481
  68. package/lib/cmp/utils/definitions.js +0 -262
  69. package/lib/cmp/utils/definitions.spec.d.ts +0 -1
  70. package/lib/cmp/utils/definitions.spec.js +0 -503
  71. package/lib/constants.d.ts +0 -1
  72. package/lib/constants.js +0 -4
  73. package/lib/datastore/blueprint/add/add.d.ts +0 -3
  74. package/lib/datastore/blueprint/add/add.js +0 -119
  75. package/lib/datastore/blueprint/add/add.spec.d.ts +0 -1
  76. package/lib/datastore/blueprint/add/add.spec.js +0 -134
  77. package/lib/datastore/blueprint/blueprintCommand.d.ts +0 -3
  78. package/lib/datastore/blueprint/blueprintCommand.js +0 -21
  79. package/lib/datastore/blueprint/list/list.d.ts +0 -3
  80. package/lib/datastore/blueprint/list/list.js +0 -76
  81. package/lib/datastore/blueprint/list/list.spec.d.ts +0 -1
  82. package/lib/datastore/blueprint/list/list.spec.js +0 -51
  83. package/lib/datastore/blueprint/rename/rename.d.ts +0 -3
  84. package/lib/datastore/blueprint/rename/rename.js +0 -93
  85. package/lib/datastore/blueprint/rename/rename.spec.d.ts +0 -1
  86. package/lib/datastore/blueprint/rename/rename.spec.js +0 -142
  87. package/lib/datastore/blueprint/update/update.d.ts +0 -3
  88. package/lib/datastore/blueprint/update/update.js +0 -89
  89. package/lib/datastore/blueprint/update/update.spec.d.ts +0 -1
  90. package/lib/datastore/blueprint/update/update.spec.js +0 -99
  91. package/lib/datastore/bundle/bundle.d.ts +0 -3
  92. package/lib/datastore/bundle/bundle.js +0 -176
  93. package/lib/datastore/bundle/bundle.spec.d.ts +0 -1
  94. package/lib/datastore/bundle/bundle.spec.js +0 -94
  95. package/lib/datastore/index.d.ts +0 -3
  96. package/lib/datastore/index.js +0 -16
  97. package/lib/datastore/simulator/add/add.d.ts +0 -3
  98. package/lib/datastore/simulator/add/add.js +0 -125
  99. package/lib/datastore/simulator/add/add.spec.d.ts +0 -1
  100. package/lib/datastore/simulator/add/add.spec.js +0 -114
  101. package/lib/datastore/simulator/clear/clear.d.ts +0 -3
  102. package/lib/datastore/simulator/clear/clear.js +0 -70
  103. package/lib/datastore/simulator/clear/clear.spec.d.ts +0 -1
  104. package/lib/datastore/simulator/clear/clear.spec.js +0 -224
  105. package/lib/datastore/simulator/list/list.d.ts +0 -3
  106. package/lib/datastore/simulator/list/list.js +0 -115
  107. package/lib/datastore/simulator/list/list.spec.d.ts +0 -1
  108. package/lib/datastore/simulator/list/list.spec.js +0 -95
  109. package/lib/datastore/simulator/pause/pause.d.ts +0 -3
  110. package/lib/datastore/simulator/pause/pause.js +0 -84
  111. package/lib/datastore/simulator/pause/pause.spec.d.ts +0 -1
  112. package/lib/datastore/simulator/pause/pause.spec.js +0 -90
  113. package/lib/datastore/simulator/remove/remove.d.ts +0 -3
  114. package/lib/datastore/simulator/remove/remove.js +0 -68
  115. package/lib/datastore/simulator/remove/remove.spec.d.ts +0 -1
  116. package/lib/datastore/simulator/remove/remove.spec.js +0 -224
  117. package/lib/datastore/simulator/resume/resume.d.ts +0 -3
  118. package/lib/datastore/simulator/resume/resume.js +0 -84
  119. package/lib/datastore/simulator/resume/resume.spec.d.ts +0 -1
  120. package/lib/datastore/simulator/resume/resume.spec.js +0 -90
  121. package/lib/datastore/simulator/simulatorCommand.d.ts +0 -3
  122. package/lib/datastore/simulator/simulatorCommand.js +0 -27
  123. package/lib/datastore/simulator/upgrade/upgrade.d.ts +0 -3
  124. package/lib/datastore/simulator/upgrade/upgrade.js +0 -157
  125. package/lib/datastore/simulator/upgrade/upgrade.spec.d.ts +0 -1
  126. package/lib/datastore/simulator/upgrade/upgrade.spec.js +0 -199
  127. package/lib/datastore/simulator/utils.d.ts +0 -29
  128. package/lib/datastore/simulator/utils.js +0 -218
  129. package/lib/datastore/simulator/utils.spec.d.ts +0 -1
  130. package/lib/datastore/simulator/utils.spec.js +0 -201
  131. package/lib/datastore/utils.d.ts +0 -20
  132. package/lib/datastore/utils.js +0 -241
  133. package/lib/datastore/utils.spec.d.ts +0 -1
  134. package/lib/datastore/utils.spec.js +0 -113
  135. package/lib/dxp.d.ts +0 -1
  136. package/lib/dxp.js +0 -57
  137. package/lib/job-runner/index.d.ts +0 -3
  138. package/lib/job-runner/index.js +0 -22
  139. package/lib/job-runner/job/listJobs/listJobs.d.ts +0 -3
  140. package/lib/job-runner/job/listJobs/listJobs.js +0 -66
  141. package/lib/job-runner/job/listJobs/listJobs.spec.d.ts +0 -1
  142. package/lib/job-runner/job/listJobs/listJobs.spec.js +0 -42
  143. package/lib/job-runner/job/uploadJob/uploadJob.d.ts +0 -3
  144. package/lib/job-runner/job/uploadJob/uploadJob.js +0 -56
  145. package/lib/job-runner/job/uploadJob/uploadJob.spec.d.ts +0 -1
  146. package/lib/job-runner/job/uploadJob/uploadJob.spec.js +0 -42
  147. package/lib/job-runner/jobContext/listJobContexts.d.ts +0 -3
  148. package/lib/job-runner/jobContext/listJobContexts.js +0 -66
  149. package/lib/job-runner/jobContext/listJobContexts.spec.d.ts +0 -1
  150. package/lib/job-runner/jobContext/listJobContexts.spec.js +0 -58
  151. package/lib/job-runner/jobExecution/beginJob/beginJob.d.ts +0 -3
  152. package/lib/job-runner/jobExecution/beginJob/beginJob.js +0 -68
  153. package/lib/job-runner/jobExecution/beginJob/beginJob.spec.d.ts +0 -1
  154. package/lib/job-runner/jobExecution/beginJob/beginJob.spec.js +0 -62
  155. package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.d.ts +0 -3
  156. package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.js +0 -67
  157. package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.spec.d.ts +0 -1
  158. package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.spec.js +0 -64
  159. package/lib/job-runner/jobExecution/terminateJob/terminateJob.d.ts +0 -3
  160. package/lib/job-runner/jobExecution/terminateJob/terminateJob.js +0 -64
  161. package/lib/job-runner/jobExecution/terminateJob/terminateJob.spec.d.ts +0 -1
  162. package/lib/job-runner/jobExecution/terminateJob/terminateJob.spec.js +0 -61
  163. package/lib/job-runner/utils.d.ts +0 -19
  164. package/lib/job-runner/utils.js +0 -145
  165. package/lib/job-runner/utils.spec.d.ts +0 -1
  166. package/lib/job-runner/utils.spec.js +0 -116
  167. package/lib/migration/create/create.d.ts +0 -3
  168. package/lib/migration/create/create.js +0 -56
  169. package/lib/migration/create/create.spec.d.ts +0 -1
  170. package/lib/migration/create/create.spec.js +0 -280
  171. package/lib/migration/get/get.d.ts +0 -3
  172. package/lib/migration/get/get.js +0 -46
  173. package/lib/migration/get/get.spec.d.ts +0 -1
  174. package/lib/migration/get/get.spec.js +0 -287
  175. package/lib/migration/index.d.ts +0 -3
  176. package/lib/migration/index.js +0 -24
  177. package/lib/migration/list/list.d.ts +0 -3
  178. package/lib/migration/list/list.js +0 -45
  179. package/lib/migration/list/list.spec.d.ts +0 -1
  180. package/lib/migration/list/list.spec.js +0 -138
  181. package/lib/migration/next/next.d.ts +0 -3
  182. package/lib/migration/next/next.js +0 -75
  183. package/lib/migration/next/next.spec.d.ts +0 -1
  184. package/lib/migration/next/next.spec.js +0 -253
  185. package/lib/migration/pre/pre.d.ts +0 -3
  186. package/lib/migration/pre/pre.js +0 -54
  187. package/lib/migration/pre/pre.spec.d.ts +0 -1
  188. package/lib/migration/pre/pre.spec.js +0 -269
  189. package/lib/migration/revert/revert.d.ts +0 -3
  190. package/lib/migration/revert/revert.js +0 -47
  191. package/lib/migration/revert/revert.spec.d.ts +0 -1
  192. package/lib/migration/revert/revert.spec.js +0 -153
  193. package/lib/migration/settings/settings.d.ts +0 -3
  194. package/lib/migration/settings/settings.js +0 -63
  195. package/lib/migration/settings/settings.spec.d.ts +0 -1
  196. package/lib/migration/settings/settings.spec.js +0 -339
  197. package/lib/migration/types/common.types.d.ts +0 -29
  198. package/lib/migration/types/common.types.js +0 -2
  199. package/lib/migration/types/createMigration.types.d.ts +0 -10
  200. package/lib/migration/types/createMigration.types.js +0 -2
  201. package/lib/migration/types/getMigration.types.d.ts +0 -5
  202. package/lib/migration/types/getMigration.types.js +0 -2
  203. package/lib/migration/types/index.d.ts +0 -7
  204. package/lib/migration/types/index.js +0 -23
  205. package/lib/migration/types/listMigrations.types.d.ts +0 -2
  206. package/lib/migration/types/listMigrations.types.js +0 -2
  207. package/lib/migration/types/nextStage.types.d.ts +0 -10
  208. package/lib/migration/types/nextStage.types.js +0 -2
  209. package/lib/migration/types/preMigration.types.d.ts +0 -10
  210. package/lib/migration/types/preMigration.types.js +0 -2
  211. package/lib/migration/types/revert.types.d.ts +0 -6
  212. package/lib/migration/types/revert.types.js +0 -2
  213. package/lib/migration/types/settings.types.d.ts +0 -15
  214. package/lib/migration/types/settings.types.js +0 -2
  215. package/lib/migration/utils/common.d.ts +0 -39
  216. package/lib/migration/utils/common.js +0 -134
  217. package/lib/migration/utils/common.spec.d.ts +0 -1
  218. package/lib/migration/utils/common.spec.js +0 -165
  219. package/lib/migration/utils/createMigration.d.ts +0 -33
  220. package/lib/migration/utils/createMigration.js +0 -125
  221. package/lib/migration/utils/createMigration.spec.d.ts +0 -1
  222. package/lib/migration/utils/createMigration.spec.js +0 -259
  223. package/lib/migration/utils/getMigration.d.ts +0 -2
  224. package/lib/migration/utils/getMigration.js +0 -41
  225. package/lib/migration/utils/getMigration.spec.d.ts +0 -1
  226. package/lib/migration/utils/getMigration.spec.js +0 -156
  227. package/lib/migration/utils/index.d.ts +0 -9
  228. package/lib/migration/utils/index.js +0 -25
  229. package/lib/migration/utils/listMigrations.d.ts +0 -3
  230. package/lib/migration/utils/listMigrations.js +0 -41
  231. package/lib/migration/utils/listMigrations.spec.d.ts +0 -1
  232. package/lib/migration/utils/listMigrations.spec.js +0 -108
  233. package/lib/migration/utils/loadCctIdsFromFile.d.ts +0 -1
  234. package/lib/migration/utils/loadCctIdsFromFile.js +0 -32
  235. package/lib/migration/utils/loadCctIdsFromFile.spec.d.ts +0 -1
  236. package/lib/migration/utils/loadCctIdsFromFile.spec.js +0 -91
  237. package/lib/migration/utils/loadStageOptionsFromFile.d.ts +0 -1
  238. package/lib/migration/utils/loadStageOptionsFromFile.js +0 -32
  239. package/lib/migration/utils/loadStageOptionsFromFile.spec.d.ts +0 -1
  240. package/lib/migration/utils/loadStageOptionsFromFile.spec.js +0 -77
  241. package/lib/migration/utils/nextStage.d.ts +0 -2
  242. package/lib/migration/utils/nextStage.js +0 -45
  243. package/lib/migration/utils/nextStage.spec.d.ts +0 -1
  244. package/lib/migration/utils/nextStage.spec.js +0 -151
  245. package/lib/migration/utils/options.d.ts +0 -15
  246. package/lib/migration/utils/options.js +0 -106
  247. package/lib/migration/utils/options.spec.d.ts +0 -1
  248. package/lib/migration/utils/options.spec.js +0 -115
  249. package/lib/migration/utils/promptForMorphConfirmation.d.ts +0 -5
  250. package/lib/migration/utils/promptForMorphConfirmation.js +0 -55
  251. package/lib/migration/utils/promptForMorphConfirmation.spec.d.ts +0 -1
  252. package/lib/migration/utils/promptForMorphConfirmation.spec.js +0 -101
  253. package/lib/migration/utils/revertMigration.d.ts +0 -2
  254. package/lib/migration/utils/revertMigration.js +0 -38
  255. package/lib/migration/utils/revertMigration.spec.d.ts +0 -1
  256. package/lib/migration/utils/revertMigration.spec.js +0 -95
  257. package/lib/migration/utils/setMigrationSettings.d.ts +0 -2
  258. package/lib/migration/utils/setMigrationSettings.js +0 -52
  259. package/lib/migration/utils/setMigrationSettings.spec.d.ts +0 -1
  260. package/lib/migration/utils/setMigrationSettings.spec.js +0 -163
  261. package/lib/page/index.d.ts +0 -3
  262. package/lib/page/index.js +0 -12
  263. package/lib/page/layouts/deploy/deploy.d.ts +0 -5
  264. package/lib/page/layouts/deploy/deploy.js +0 -157
  265. package/lib/page/layouts/deploy/deploy.spec.d.ts +0 -1
  266. package/lib/page/layouts/deploy/deploy.spec.js +0 -319
  267. package/lib/page/layouts/dev/dev.d.ts +0 -5
  268. package/lib/page/layouts/dev/dev.js +0 -84
  269. package/lib/page/layouts/dev/dev.spec.d.ts +0 -1
  270. package/lib/page/layouts/dev/dev.spec.js +0 -271
  271. package/lib/page/layouts/layouts.d.ts +0 -3
  272. package/lib/page/layouts/layouts.js +0 -17
  273. package/lib/page/layouts/layouts.spec.d.ts +0 -1
  274. package/lib/page/layouts/layouts.spec.js +0 -29
  275. package/lib/page/layouts/validation/index.d.ts +0 -3
  276. package/lib/page/layouts/validation/index.js +0 -9
  277. package/lib/page/layouts/validation/property-consistency.d.ts +0 -7
  278. package/lib/page/layouts/validation/property-consistency.js +0 -92
  279. package/lib/page/layouts/validation/property-consistency.spec.d.ts +0 -1
  280. package/lib/page/layouts/validation/property-consistency.spec.js +0 -305
  281. package/lib/page/layouts/validation/validateLayoutFormat.d.ts +0 -2
  282. package/lib/page/layouts/validation/validateLayoutFormat.js +0 -27
  283. package/lib/page/layouts/validation/validateLayoutFormat.spec.d.ts +0 -1
  284. package/lib/page/layouts/validation/validateLayoutFormat.spec.js +0 -42
  285. package/lib/page/layouts/validation/zone-consistency.d.ts +0 -7
  286. package/lib/page/layouts/validation/zone-consistency.js +0 -50
  287. package/lib/page/layouts/validation/zone-consistency.spec.d.ts +0 -1
  288. package/lib/page/layouts/validation/zone-consistency.spec.js +0 -99
  289. package/lib/page/templates/validation.d.ts +0 -11
  290. package/lib/page/templates/validation.js +0 -30
  291. package/lib/page/templates/validation.spec.d.ts +0 -1
  292. package/lib/page/templates/validation.spec.js +0 -89
  293. package/lib/page/utils/definitions.d.ts +0 -552
  294. package/lib/page/utils/definitions.js +0 -241
  295. package/lib/page/utils/definitions.spec.d.ts +0 -1
  296. package/lib/page/utils/definitions.spec.js +0 -749
  297. package/lib/page/utils/normalize.d.ts +0 -8
  298. package/lib/page/utils/normalize.js +0 -54
  299. package/lib/page/utils/normalize.spec.d.ts +0 -1
  300. package/lib/page/utils/normalize.spec.js +0 -315
  301. package/lib/page/utils/parse-args.d.ts +0 -44
  302. package/lib/page/utils/parse-args.js +0 -119
  303. package/lib/page/utils/parse-args.spec.d.ts +0 -1
  304. package/lib/page/utils/parse-args.spec.js +0 -284
  305. package/lib/page/utils/render.d.ts +0 -51
  306. package/lib/page/utils/render.js +0 -112
  307. package/lib/page/utils/render.spec.d.ts +0 -1
  308. package/lib/page/utils/render.spec.js +0 -134
  309. package/lib/page/utils/server.d.ts +0 -12
  310. package/lib/page/utils/server.js +0 -201
  311. package/lib/page/utils/server.spec.d.ts +0 -1
  312. package/lib/page/utils/server.spec.js +0 -275
  313. package/lib/porter/constants.d.ts +0 -11
  314. package/lib/porter/constants.js +0 -14
  315. package/lib/porter/index.d.ts +0 -3
  316. package/lib/porter/index.js +0 -24
  317. package/lib/porter/port/abort/abort.d.ts +0 -3
  318. package/lib/porter/port/abort/abort.js +0 -80
  319. package/lib/porter/port/abort/abort.spec.d.ts +0 -1
  320. package/lib/porter/port/abort/abort.spec.js +0 -182
  321. package/lib/porter/port/get/get.d.ts +0 -3
  322. package/lib/porter/port/get/get.js +0 -96
  323. package/lib/porter/port/get/get.spec.d.ts +0 -1
  324. package/lib/porter/port/get/get.spec.js +0 -277
  325. package/lib/porter/port/start/start.d.ts +0 -3
  326. package/lib/porter/port/start/start.js +0 -82
  327. package/lib/porter/port/start/start.spec.d.ts +0 -1
  328. package/lib/porter/port/start/start.spec.js +0 -198
  329. package/lib/porter/project/add/add.d.ts +0 -3
  330. package/lib/porter/project/add/add.js +0 -138
  331. package/lib/porter/project/add/add.spec.d.ts +0 -1
  332. package/lib/porter/project/add/add.spec.js +0 -269
  333. package/lib/porter/project/get/get.d.ts +0 -3
  334. package/lib/porter/project/get/get.js +0 -65
  335. package/lib/porter/project/get/get.spec.d.ts +0 -1
  336. package/lib/porter/project/get/get.spec.js +0 -185
  337. package/lib/porter/project/remove/remove.d.ts +0 -3
  338. package/lib/porter/project/remove/remove.js +0 -69
  339. package/lib/porter/project/remove/remove.spec.d.ts +0 -1
  340. package/lib/porter/project/remove/remove.spec.js +0 -201
  341. package/lib/porter/types.d.ts +0 -5
  342. package/lib/porter/types.js +0 -2
  343. package/lib/porter/utils/BuildDXPUrl/BuildDXPUrl.d.ts +0 -4
  344. package/lib/porter/utils/BuildDXPUrl/BuildDXPUrl.js +0 -34
  345. package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.d.ts +0 -1
  346. package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.js +0 -21
  347. package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.spec.d.ts +0 -1
  348. package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.spec.js +0 -52
  349. package/lib/porter/utils/CoreUtils/CoreUtils.d.ts +0 -2
  350. package/lib/porter/utils/CoreUtils/CoreUtils.js +0 -13
  351. package/lib/porter/utils/CoreUtils/CoreUtils.spec.d.ts +0 -1
  352. package/lib/porter/utils/CoreUtils/CoreUtils.spec.js +0 -36
  353. package/lib/porter/utils/DoesPathExist/DoesPathExist.d.ts +0 -1
  354. package/lib/porter/utils/DoesPathExist/DoesPathExist.js +0 -27
  355. package/lib/porter/utils/DoesPathExist/DoesPathExist.spec.d.ts +0 -1
  356. package/lib/porter/utils/DoesPathExist/DoesPathExist.spec.js +0 -40
  357. package/lib/porter/utils/ErrorUtils/ErrorUtils.d.ts +0 -4
  358. package/lib/porter/utils/ErrorUtils/ErrorUtils.js +0 -66
  359. package/lib/porter/utils/ErrorUtils/ErrorUtils.spec.d.ts +0 -1
  360. package/lib/porter/utils/ErrorUtils/ErrorUtils.spec.js +0 -176
  361. package/lib/porter/utils/GetProjectConfig/GetProjectConfig.d.ts +0 -2
  362. package/lib/porter/utils/GetProjectConfig/GetProjectConfig.js +0 -33
  363. package/lib/porter/utils/GetProjectConfig/GetProjectConfig.spec.d.ts +0 -1
  364. package/lib/porter/utils/GetProjectConfig/GetProjectConfig.spec.js +0 -50
  365. package/lib/porter/utils/GetProjectName/GetProjectName.d.ts +0 -4
  366. package/lib/porter/utils/GetProjectName/GetProjectName.js +0 -30
  367. package/lib/porter/utils/GetProjectName/GetProjectName.spec.d.ts +0 -1
  368. package/lib/porter/utils/GetProjectName/GetProjectName.spec.js +0 -91
  369. package/lib/porter/utils/index.d.ts +0 -7
  370. package/lib/porter/utils/index.js +0 -23
package/package.json CHANGED
@@ -1,20 +1,21 @@
1
1
  {
2
2
  "name": "@squiz/dxp-cli-next",
3
- "version": "5.33.0-develop.1",
3
+ "version": "5.33.0-develop.10",
4
4
  "repository": {
5
5
  "url": "https://gitlab.squiz.net/dxp/dxp-cli-next"
6
6
  },
7
7
  "files": [
8
- "!lib/__tests__/**/*",
9
- "lib/**/*",
10
- "bin/**/*"
8
+ "bin/**/*",
9
+ "dist/**/*"
11
10
  ],
12
11
  "bin": {
13
12
  "dxp-next": "./bin/dxp.js"
14
13
  },
15
14
  "scripts": {
16
15
  "build": "tsc",
17
- "clean": "rm -rf ./lib/",
16
+ "bundle": "node scripts/bundle.js",
17
+ "build:release": "npm run build && npm run bundle",
18
+ "clean": "rm -rf ./lib/ ./dist/",
18
19
  "cm": "cz",
19
20
  "coverage": "codecov",
20
21
  "lint": "eslint ./src/ --fix",
@@ -28,6 +29,12 @@
28
29
  "engines": {
29
30
  "node": ">=20.0"
30
31
  },
32
+ "dependencies": {
33
+ "esbuild": "^0.21.5",
34
+ "update-notifier": "5.1.0",
35
+ "workerd": "^1.20250428.0",
36
+ "@squiz/local-component-dev-ui": "0.6.20"
37
+ },
31
38
  "keywords": [
32
39
  "cli",
33
40
  "template",
@@ -39,34 +46,16 @@
39
46
  "semantic-release",
40
47
  "codecov"
41
48
  ],
42
- "dependencies": {
43
- "@apidevtools/swagger-parser": "10.1.0",
44
- "@squiz/component-cli-lib": "1.72.12",
45
- "@squiz/dx-logger-lib": "^1.65.1",
46
- "@squiz/dxp-porter-shared": "0.4.0",
47
- "@squiz/job-runner-lib": "2.3.0",
48
- "@squiz/local-component-dev-ui": "0.6.20",
49
- "axios": "1.11.0",
50
- "cli-color": "2.0.3",
51
- "commander": "9.4.0",
52
- "dotenv": "^16.3.1",
53
- "env-paths": "2.2.1",
54
- "esbuild": "^0.21.4",
55
- "handlebars": "^4.7.8",
56
- "inquirer": "8.2.5",
57
- "opener": "1.5.2",
58
- "ora": "^5.4.1",
59
- "prompt": "^1.3.0",
60
- "tough-cookie": "4.1.4",
61
- "update-notifier": "5.1.0",
62
- "yaml": "^2.3.4",
63
- "zod": "^3.23.8",
64
- "zod-validation-error": "^3.3.1"
65
- },
66
49
  "devDependencies": {
50
+ "@apidevtools/swagger-parser": "10.1.0",
51
+ "@vercel/ncc": "^0.38.3",
67
52
  "@semantic-release/git": "10.0.1",
68
53
  "@semantic-release/gitlab": "9.4.2",
69
54
  "@semantic-release/npm": "9.0.1",
55
+ "@squiz/component-cli-lib": "1.73.0",
56
+ "@squiz/dx-logger-lib": "^1.65.1",
57
+ "@squiz/dxp-porter-shared": "0.4.0",
58
+ "@squiz/job-runner-lib": "2.3.0",
70
59
  "@types/cli-color": "2.0.2",
71
60
  "@types/inquirer": "8.2.6",
72
61
  "@types/jest": "29.5.14",
@@ -77,25 +66,42 @@
77
66
  "@types/update-notifier": "5.1.0",
78
67
  "@typescript-eslint/eslint-plugin": "5.30.7",
79
68
  "@typescript-eslint/parser": "5.30.7",
69
+ "update-notifier": "5.1.0",
70
+ "axios": "1.11.0",
80
71
  "chalk": "4.1.2",
72
+ "cli-color": "2.0.3",
81
73
  "codecov": "3.8.3",
74
+ "commander": "9.4.0",
82
75
  "commitizen": "4.2.5",
83
76
  "cz-conventional-changelog": "3.3.0",
77
+ "dotenv": "^16.3.1",
78
+ "env-paths": "2.2.1",
79
+ "esbuild": "^0.21.5",
84
80
  "eslint": "8.19.0",
85
81
  "eslint-config-prettier": "8.5.0",
86
82
  "eslint-plugin-node": "11.1.0",
87
83
  "eslint-plugin-prettier": "4.2.1",
88
84
  "execa": "5.1.1",
85
+ "handlebars": "^4.7.8",
89
86
  "husky": "8.0.1",
87
+ "inquirer": "8.2.5",
90
88
  "jest": "29.7.0",
91
89
  "lint-staged": "13.0.3",
92
90
  "nock": "^13.3.1",
91
+ "opener": "1.5.2",
92
+ "ora": "^5.4.1",
93
93
  "prettier": "2.7.1",
94
+ "prompt": "^1.3.0",
94
95
  "semantic-release": "19.0.3",
95
96
  "supertest": "^6.3.4",
97
+ "tough-cookie": "4.1.4",
96
98
  "ts-jest": "29.2.5",
97
99
  "ts-node": "^10.9.1",
98
- "typescript": "4.7.4"
100
+ "typescript": "5.9.3",
101
+ "yaml": "^2.3.4",
102
+ "zod": "^3.23.8",
103
+ "zod-validation-error": "^3.3.1",
104
+ "cosmiconfig": "9.0.0"
99
105
  },
100
106
  "config": {
101
107
  "commitizen": {
@@ -1,39 +0,0 @@
1
- import { AxiosInstance, InternalAxiosRequestConfig, AxiosResponse } from 'axios';
2
- export declare const COOKIE_KEY = "dxp-sessionid";
3
- interface ApiServiceParameters {
4
- validateStatus?: (status: number) => boolean;
5
- baseUrl?: string;
6
- tenantId?: string;
7
- }
8
- /**
9
- * ApiService provides HTTP access to the DXP systems.
10
- * This class wraps the authorization model within the DXP system by seamlessly
11
- * adding the session cookie to requests.
12
- */
13
- export declare class ApiService {
14
- client: AxiosInstance;
15
- constructor({ validateStatus, baseUrl, tenantId, }?: ApiServiceParameters);
16
- }
17
- /**
18
- * The API Service requestInterceptor will load the session cookie from
19
- * storage and set it on any request. This ensures that post-login, all requests
20
- * will seamlessly have the authorization required.
21
- */
22
- export declare function requestInterceptor(request: InternalAxiosRequestConfig): Promise<InternalAxiosRequestConfig<any>>;
23
- /**
24
- * The API Service responseInterceptor will handle the case that a
25
- * "Set-Cookie" header has been returned from an API request and will
26
- * save it accordingly for future use.
27
- */
28
- export declare function responseInterceptor(response: AxiosResponse): Promise<AxiosResponse<any, any>>;
29
- export declare const MESSAGE_INVALID_REQUEST_NO_SESSIONID = "Invalid request: no session";
30
- export declare const MESSAGE_FAILED_TO_CREATE_SESSION = "Failed to create session";
31
- export declare const MESSAGE_FAILED_TO_REMOVE_SESSION = "Failed to remove user session";
32
- export declare const MESSAGE_FAILED_TO_CREATE_ORG_SESSION = "Failed to create organisation session";
33
- export declare class InvalidLoginSessionError extends Error {
34
- constructor();
35
- }
36
- export declare class InvalidTenantError extends Error {
37
- constructor();
38
- }
39
- export {};
package/lib/ApiService.js DELETED
@@ -1,120 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.InvalidTenantError = exports.InvalidLoginSessionError = exports.MESSAGE_FAILED_TO_CREATE_ORG_SESSION = exports.MESSAGE_FAILED_TO_REMOVE_SESSION = exports.MESSAGE_FAILED_TO_CREATE_SESSION = exports.MESSAGE_INVALID_REQUEST_NO_SESSIONID = exports.responseInterceptor = exports.requestInterceptor = exports.ApiService = exports.COOKIE_KEY = void 0;
16
- const axios_1 = __importDefault(require("axios"));
17
- const tough_cookie_1 = require("tough-cookie");
18
- const ApplicationStore_1 = require("./ApplicationStore");
19
- exports.COOKIE_KEY = 'dxp-sessionid';
20
- /**
21
- * ApiService provides HTTP access to the DXP systems.
22
- * This class wraps the authorization model within the DXP system by seamlessly
23
- * adding the session cookie to requests.
24
- */
25
- class ApiService {
26
- constructor({ validateStatus, baseUrl, tenantId = process.env.SQUIZ_DXP_TENANT_ID, } = {}) {
27
- this.client = axios_1.default.create({
28
- validateStatus: validateStatus,
29
- baseURL: baseUrl,
30
- headers: {
31
- 'x-dxp-tenant': tenantId,
32
- },
33
- });
34
- this.client.interceptors.request.use(requestInterceptor);
35
- this.client.interceptors.response.use(responseInterceptor);
36
- }
37
- }
38
- exports.ApiService = ApiService;
39
- /**
40
- * The API Service requestInterceptor will load the session cookie from
41
- * storage and set it on any request. This ensures that post-login, all requests
42
- * will seamlessly have the authorization required.
43
- */
44
- function requestInterceptor(request) {
45
- var _a;
46
- return __awaiter(this, void 0, void 0, function* () {
47
- const additionalHeaders = {};
48
- // Support usage of API Keys generated from API Key Service
49
- // @see - https://squizgroup.atlassian.net/wiki/spaces/PRODUCT/pages/2915959855/API+Key+Service+details
50
- if (process.env.SQUIZ_DXP_API_TOKEN) {
51
- additionalHeaders['x-api-key'] = process.env.SQUIZ_DXP_API_TOKEN;
52
- }
53
- else {
54
- const maybeSessionCookie = yield (0, ApplicationStore_1.getApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie);
55
- const maybeSessionCookieString = maybeSessionCookie && ((_a = tough_cookie_1.Cookie.fromJSON(maybeSessionCookie)) === null || _a === void 0 ? void 0 : _a.cookieString());
56
- if (maybeSessionCookieString) {
57
- additionalHeaders.cookie = maybeSessionCookieString;
58
- }
59
- }
60
- if (process.env.DXP_JWT) {
61
- additionalHeaders.authorization = `Bearer ${process.env.DXP_JWT}`;
62
- }
63
- if (Object.keys(additionalHeaders).length > 0) {
64
- request.headers = request.headers.concat(additionalHeaders);
65
- }
66
- return request;
67
- });
68
- }
69
- exports.requestInterceptor = requestInterceptor;
70
- /**
71
- * The API Service responseInterceptor will handle the case that a
72
- * "Set-Cookie" header has been returned from an API request and will
73
- * save it accordingly for future use.
74
- */
75
- function responseInterceptor(response) {
76
- var _a, _b;
77
- return __awaiter(this, void 0, void 0, function* () {
78
- if (response.status >= 400) {
79
- yield handleSessionErrors(response);
80
- }
81
- const maybeSessionCookie = (_b = (_a = response.headers['set-cookie']) === null || _a === void 0 ? void 0 : _a.map(cookieHeader => tough_cookie_1.Cookie.parse(cookieHeader))) === null || _b === void 0 ? void 0 : _b.find(cookie => (cookie === null || cookie === void 0 ? void 0 : cookie.key) === exports.COOKIE_KEY);
82
- if (!maybeSessionCookie) {
83
- return response;
84
- }
85
- yield (0, ApplicationStore_1.saveApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie, JSON.stringify(maybeSessionCookie.toJSON()));
86
- return response;
87
- });
88
- }
89
- exports.responseInterceptor = responseInterceptor;
90
- exports.MESSAGE_INVALID_REQUEST_NO_SESSIONID = 'Invalid request: no session';
91
- exports.MESSAGE_FAILED_TO_CREATE_SESSION = 'Failed to create session';
92
- exports.MESSAGE_FAILED_TO_REMOVE_SESSION = 'Failed to remove user session';
93
- exports.MESSAGE_FAILED_TO_CREATE_ORG_SESSION = 'Failed to create organisation session';
94
- class InvalidLoginSessionError extends Error {
95
- constructor() {
96
- super('Invalid session');
97
- }
98
- }
99
- exports.InvalidLoginSessionError = InvalidLoginSessionError;
100
- class InvalidTenantError extends Error {
101
- constructor() {
102
- super('Invalid tenant');
103
- }
104
- }
105
- exports.InvalidTenantError = InvalidTenantError;
106
- function handleSessionErrors(response) {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- if (response.data.message === exports.MESSAGE_INVALID_REQUEST_NO_SESSIONID) {
109
- yield (0, ApplicationStore_1.deleteApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie);
110
- throw new InvalidLoginSessionError();
111
- }
112
- if (response.data.message === exports.MESSAGE_FAILED_TO_CREATE_SESSION) {
113
- yield (0, ApplicationStore_1.deleteApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie);
114
- throw new InvalidLoginSessionError();
115
- }
116
- if (response.data.message === exports.MESSAGE_FAILED_TO_CREATE_ORG_SESSION) {
117
- throw new InvalidTenantError();
118
- }
119
- });
120
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,182 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const axios_1 = require("axios");
13
- const tough_cookie_1 = require("tough-cookie");
14
- const ApiService_1 = require("./ApiService");
15
- const ApplicationStore_1 = require("./ApplicationStore");
16
- const VALID_COOKIE = new tough_cookie_1.Cookie({
17
- key: ApiService_1.COOKIE_KEY,
18
- value: 'valid-cookie-value',
19
- });
20
- describe('ApiService', () => {
21
- describe('requestInterceptor', () => {
22
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
23
- delete process.env.DXP_JWT;
24
- delete process.env.SQUIZ_DXP_API_TOKEN;
25
- delete process.env.SQUIZ_DXP_TENANT_ID;
26
- yield (0, ApplicationStore_1.deleteApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie);
27
- }));
28
- it('loads stored session cookie into request config', () => __awaiter(void 0, void 0, void 0, function* () {
29
- yield (0, ApplicationStore_1.saveApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie, JSON.stringify(VALID_COOKIE.toJSON()));
30
- const requestConfig = yield (0, ApiService_1.requestInterceptor)({
31
- headers: new axios_1.AxiosHeaders(),
32
- });
33
- expect(requestConfig).toHaveProperty('headers');
34
- expect(requestConfig.headers).toHaveProperty('cookie');
35
- expect(tough_cookie_1.Cookie.parse(requestConfig.headers['cookie'])).toHaveProperty('value', 'valid-cookie-value');
36
- }));
37
- it('does not use session cookie if none stored', () => __awaiter(void 0, void 0, void 0, function* () {
38
- const requestConfig = yield (0, ApiService_1.requestInterceptor)({
39
- headers: new axios_1.AxiosHeaders(),
40
- });
41
- expect(requestConfig).toEqual({
42
- headers: new axios_1.AxiosHeaders(),
43
- });
44
- }));
45
- it('attaches DXP JWT as authorization header if environment variable defined', () => __awaiter(void 0, void 0, void 0, function* () {
46
- process.env.DXP_JWT = 'xxx.yyy.zzz';
47
- const requestConfig = yield (0, ApiService_1.requestInterceptor)({
48
- headers: new axios_1.AxiosHeaders({
49
- 'x-custom-header': 'header value',
50
- }),
51
- });
52
- expect(requestConfig).toMatchObject({
53
- headers: new axios_1.AxiosHeaders({
54
- 'x-custom-header': 'header value',
55
- authorization: 'Bearer xxx.yyy.zzz',
56
- }),
57
- });
58
- }));
59
- it('uses the SQUIZ_DXP_API_TOKEN variable instead of session if provided', () => __awaiter(void 0, void 0, void 0, function* () {
60
- process.env.SQUIZ_DXP_API_TOKEN = '123';
61
- yield (0, ApplicationStore_1.saveApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie, JSON.stringify(VALID_COOKIE.toJSON()));
62
- const headers = new axios_1.AxiosHeaders();
63
- yield expect((0, ApiService_1.requestInterceptor)({ headers })).resolves.toMatchObject({
64
- headers: new axios_1.AxiosHeaders({
65
- 'x-api-key': '123',
66
- }),
67
- });
68
- }));
69
- });
70
- describe('responseInterceptor', () => {
71
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
72
- yield (0, ApplicationStore_1.deleteApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie);
73
- }));
74
- it('saves the set-cookie for a session into the store', () => __awaiter(void 0, void 0, void 0, function* () {
75
- const setCookie = [VALID_COOKIE.toString()];
76
- const response = {
77
- config: { headers: new axios_1.AxiosHeaders() },
78
- data: {},
79
- status: 204,
80
- statusText: '',
81
- headers: { 'set-cookie': setCookie },
82
- };
83
- const postIntercept = yield (0, ApiService_1.responseInterceptor)(response);
84
- const stored = yield (0, ApplicationStore_1.getApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie);
85
- expect(stored).toBeDefined();
86
- expect(JSON.parse(stored)).toMatchObject({
87
- key: VALID_COOKIE.key,
88
- value: VALID_COOKIE.value,
89
- });
90
- expect(postIntercept).toEqual(response);
91
- }));
92
- it('does not error if no set-cookie', () => __awaiter(void 0, void 0, void 0, function* () {
93
- const response = {
94
- data: {},
95
- config: { headers: new axios_1.AxiosHeaders() },
96
- status: 204,
97
- statusText: '',
98
- headers: {},
99
- };
100
- const postIntercept = yield (0, ApiService_1.responseInterceptor)(response);
101
- expect(yield (0, ApplicationStore_1.getApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie)).toBeUndefined();
102
- expect(postIntercept).toEqual(response);
103
- }));
104
- it('does not delete existing session cookie if no set-cookie', () => __awaiter(void 0, void 0, void 0, function* () {
105
- yield (0, ApplicationStore_1.saveApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie, JSON.stringify(VALID_COOKIE.toJSON()));
106
- const response = {
107
- data: {},
108
- config: { headers: new axios_1.AxiosHeaders() },
109
- status: 204,
110
- statusText: '',
111
- headers: {},
112
- };
113
- const postIntercept = yield (0, ApiService_1.responseInterceptor)(response);
114
- expect(yield (0, ApplicationStore_1.getApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie)).toEqual(JSON.stringify(VALID_COOKIE.toJSON()));
115
- expect(postIntercept).toEqual(response);
116
- }));
117
- it('overwrites old session cookie when new set-cookie provided', () => __awaiter(void 0, void 0, void 0, function* () {
118
- yield (0, ApplicationStore_1.saveApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie, JSON.stringify(VALID_COOKIE.toJSON()));
119
- const response = {
120
- data: { nested: 'rest' },
121
- config: { headers: new axios_1.AxiosHeaders() },
122
- status: 204,
123
- statusText: '',
124
- headers: {
125
- 'set-cookie': [
126
- tough_cookie_1.Cookie.fromJSON({
127
- key: ApiService_1.COOKIE_KEY,
128
- value: 'another-value',
129
- }).toString(),
130
- ],
131
- },
132
- };
133
- const postIntercept = yield (0, ApiService_1.responseInterceptor)(response);
134
- expect(JSON.parse((yield (0, ApplicationStore_1.getApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie)))).toMatchObject({ key: ApiService_1.COOKIE_KEY, value: 'another-value' });
135
- expect(postIntercept).toEqual(response);
136
- }));
137
- it('errors with InvalidSession on failed session creation if no existing file', () => __awaiter(void 0, void 0, void 0, function* () {
138
- const response = {
139
- data: { message: ApiService_1.MESSAGE_FAILED_TO_CREATE_SESSION },
140
- config: { headers: new axios_1.AxiosHeaders() },
141
- status: 401,
142
- statusText: '',
143
- headers: {},
144
- };
145
- yield expect(() => (0, ApiService_1.responseInterceptor)(response)).rejects.toThrowError(ApiService_1.InvalidLoginSessionError);
146
- }));
147
- it('errors with InvalidSession on no session provided', () => __awaiter(void 0, void 0, void 0, function* () {
148
- const response = {
149
- data: { message: ApiService_1.MESSAGE_INVALID_REQUEST_NO_SESSIONID },
150
- config: { headers: new axios_1.AxiosHeaders() },
151
- status: 401,
152
- statusText: '',
153
- headers: {},
154
- };
155
- yield expect(() => (0, ApiService_1.responseInterceptor)(response)).rejects.toThrowError(ApiService_1.InvalidLoginSessionError);
156
- }));
157
- it('errors with InvalidSession on failed session creation and deletes existing session', () => __awaiter(void 0, void 0, void 0, function* () {
158
- yield (0, ApplicationStore_1.saveApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie, JSON.stringify(VALID_COOKIE.toJSON()));
159
- const response = {
160
- data: { message: ApiService_1.MESSAGE_FAILED_TO_CREATE_SESSION },
161
- config: { headers: new axios_1.AxiosHeaders() },
162
- status: 401,
163
- statusText: '',
164
- headers: {},
165
- };
166
- yield expect(() => (0, ApiService_1.responseInterceptor)(response)).rejects.toThrowError(ApiService_1.InvalidLoginSessionError);
167
- expect(yield (0, ApplicationStore_1.getApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie)).toBeFalsy();
168
- }));
169
- it('errors when organisation session cannot be created and does not delete session cookie', () => __awaiter(void 0, void 0, void 0, function* () {
170
- yield (0, ApplicationStore_1.saveApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie, JSON.stringify(VALID_COOKIE.toJSON()));
171
- const response = {
172
- data: { message: ApiService_1.MESSAGE_FAILED_TO_CREATE_ORG_SESSION },
173
- config: { headers: new axios_1.AxiosHeaders() },
174
- status: 401,
175
- statusText: '',
176
- headers: {},
177
- };
178
- yield expect(() => (0, ApiService_1.responseInterceptor)(response)).rejects.toThrowError(ApiService_1.InvalidTenantError);
179
- expect(yield (0, ApplicationStore_1.getApplicationFile)(ApplicationStore_1.STORE_FILES.sessionCookie)).toBeTruthy();
180
- }));
181
- });
182
- });
@@ -1,7 +0,0 @@
1
- export declare class ApplicationConfig {
2
- baseUrl: string;
3
- region: string;
4
- tenant: string;
5
- constructor(baseUrl: string, region: string, tenant: string);
6
- }
7
- export declare function fetchApplicationConfig(tenantOverride?: string): Promise<ApplicationConfig>;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.fetchApplicationConfig = exports.ApplicationConfig = void 0;
13
- const ApplicationStore_1 = require("./ApplicationStore");
14
- class ApplicationConfig {
15
- constructor(baseUrl, region, tenant) {
16
- this.baseUrl = baseUrl;
17
- this.region = region;
18
- this.tenant = tenant;
19
- if (!baseUrl)
20
- throw new Error('No baseUrl configured');
21
- if (!region)
22
- throw new Error('No region configured');
23
- if (!tenant)
24
- throw new Error('No tenant configured');
25
- }
26
- }
27
- exports.ApplicationConfig = ApplicationConfig;
28
- function fetchApplicationConfig(tenantOverride) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- const stored = yield (0, ApplicationStore_1.getApplicationFile)(ApplicationStore_1.STORE_FILES.sessionConfig);
31
- if (!stored) {
32
- throw new Error('No stored config');
33
- }
34
- const parsed = JSON.parse(stored);
35
- return new ApplicationConfig(parsed.baseUrl, parsed.region, tenantOverride || parsed.tenant);
36
- });
37
- }
38
- exports.fetchApplicationConfig = fetchApplicationConfig;
@@ -1 +0,0 @@
1
- export {};
@@ -1,84 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const ApplicationStore_1 = require("./ApplicationStore");
13
- const ApplicationConfig_1 = require("./ApplicationConfig");
14
- describe('ApplicationConfig', () => {
15
- it('asserts all fields to have non-empty string', () => {
16
- expect(() => new ApplicationConfig_1.ApplicationConfig('', 'region', 'tenant')).toThrowError();
17
- expect(() => new ApplicationConfig_1.ApplicationConfig('baseUrl', '', 'tenant')).toThrowError();
18
- expect(() => new ApplicationConfig_1.ApplicationConfig('baseUrl', 'region', '')).toThrowError();
19
- });
20
- it('asserts all fields to have a string value', () => {
21
- expect(
22
- // @ts-expect-error requires string values
23
- () => new ApplicationConfig_1.ApplicationConfig(undefined, 'region', 'tenant')).toThrowError();
24
- expect(
25
- // @ts-expect-error requires string values
26
- () => new ApplicationConfig_1.ApplicationConfig('baseUrl', undefined, 'tenant')).toThrowError();
27
- expect(
28
- // @ts-expect-error requires string values
29
- () => new ApplicationConfig_1.ApplicationConfig('baseUrl', 'region', undefined)).toThrowError();
30
- });
31
- describe('fetchApplicationConfig', () => {
32
- beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
33
- yield (0, ApplicationStore_1.deleteApplicationFile)(ApplicationStore_1.STORE_FILES.sessionConfig);
34
- }));
35
- it('loads previously saved config', () => __awaiter(void 0, void 0, void 0, function* () {
36
- yield (0, ApplicationStore_1.saveApplicationFile)(ApplicationStore_1.STORE_FILES.sessionConfig, JSON.stringify({
37
- baseUrl: 'baseUrl',
38
- region: 'region',
39
- tenant: 'tenant',
40
- }));
41
- const config = yield (0, ApplicationConfig_1.fetchApplicationConfig)();
42
- expect(config).toMatchObject({
43
- baseUrl: 'baseUrl',
44
- region: 'region',
45
- tenant: 'tenant',
46
- });
47
- }));
48
- it('loads previously saved config and allows tenant override', () => __awaiter(void 0, void 0, void 0, function* () {
49
- yield (0, ApplicationStore_1.saveApplicationFile)(ApplicationStore_1.STORE_FILES.sessionConfig, JSON.stringify({
50
- baseUrl: 'baseUrl',
51
- region: 'region',
52
- tenant: 'tenant',
53
- }));
54
- const config = yield (0, ApplicationConfig_1.fetchApplicationConfig)('another tenant');
55
- expect(config).toMatchObject({
56
- baseUrl: 'baseUrl',
57
- region: 'region',
58
- tenant: 'another tenant',
59
- });
60
- }));
61
- it('loads previously saved config with no tenant and with tenant override', () => __awaiter(void 0, void 0, void 0, function* () {
62
- yield (0, ApplicationStore_1.saveApplicationFile)(ApplicationStore_1.STORE_FILES.sessionConfig, JSON.stringify({
63
- baseUrl: 'baseUrl',
64
- region: 'region',
65
- }));
66
- const config = yield (0, ApplicationConfig_1.fetchApplicationConfig)('another tenant');
67
- expect(config).toMatchObject({
68
- baseUrl: 'baseUrl',
69
- region: 'region',
70
- tenant: 'another tenant',
71
- });
72
- }));
73
- it('errors when no tenant and no tenant override', () => __awaiter(void 0, void 0, void 0, function* () {
74
- yield (0, ApplicationStore_1.saveApplicationFile)(ApplicationStore_1.STORE_FILES.sessionConfig, JSON.stringify({
75
- baseUrl: 'baseUrl',
76
- region: 'region',
77
- }));
78
- yield expect(() => (0, ApplicationConfig_1.fetchApplicationConfig)()).rejects.toThrowError();
79
- }));
80
- it('errors when no file is saved', () => __awaiter(void 0, void 0, void 0, function* () {
81
- yield expect(() => (0, ApplicationConfig_1.fetchApplicationConfig)()).rejects.toThrowError();
82
- }));
83
- });
84
- });
@@ -1,13 +0,0 @@
1
- import type { Paths } from 'env-paths';
2
- export declare const APP_NAME: string;
3
- export interface FileStore {
4
- name: string;
5
- type: keyof Paths;
6
- }
7
- export declare const STORE_FILES: {
8
- sessionCookie: FileStore;
9
- sessionConfig: FileStore;
10
- };
11
- export declare function getApplicationFile({ name: filename, type }: FileStore): Promise<string | undefined>;
12
- export declare function saveApplicationFile({ name: filename, type }: FileStore, content: string): Promise<void>;
13
- export declare function deleteApplicationFile({ name: filename, type, }: FileStore): Promise<void>;