@squiz/dxp-cli-next 5.33.0-develop.4 → 5.33.0-develop.6
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.
- package/bin/dxp.js +6 -1
- package/dist/dxp.js +4319 -0
- package/package.json +37 -29
- package/lib/ApiService.d.ts +0 -39
- package/lib/ApiService.js +0 -120
- package/lib/ApiService.spec.d.ts +0 -1
- package/lib/ApiService.spec.js +0 -182
- package/lib/ApplicationConfig.d.ts +0 -7
- package/lib/ApplicationConfig.js +0 -38
- package/lib/ApplicationConfig.spec.d.ts +0 -1
- package/lib/ApplicationConfig.spec.js +0 -84
- package/lib/ApplicationStore.d.ts +0 -13
- package/lib/ApplicationStore.js +0 -53
- package/lib/__tests__/cmp/dev-mode.spec.d.ts +0 -1
- package/lib/__tests__/cmp/dev-mode.spec.js +0 -54
- package/lib/__tests__/helpers.d.ts +0 -17
- package/lib/__tests__/helpers.js +0 -54
- package/lib/__tests__/integration/main.spec.d.ts +0 -1
- package/lib/__tests__/integration/main.spec.js +0 -45
- package/lib/__tests__/smoke/validate.spec.d.ts +0 -1
- package/lib/__tests__/smoke/validate.spec.js +0 -37
- package/lib/__tests__/unit/cli.d.ts +0 -0
- package/lib/__tests__/unit/cli.js +0 -7
- package/lib/auth/index.d.ts +0 -3
- package/lib/auth/index.js +0 -14
- package/lib/auth/login/login.d.ts +0 -22
- package/lib/auth/login/login.js +0 -268
- package/lib/auth/login/login.spec.d.ts +0 -1
- package/lib/auth/login/login.spec.js +0 -179
- package/lib/auth/logout/logout.d.ts +0 -3
- package/lib/auth/logout/logout.js +0 -115
- package/lib/auth/logout/logout.spec.d.ts +0 -1
- package/lib/auth/logout/logout.spec.js +0 -67
- package/lib/cdp/constants.d.ts +0 -1
- package/lib/cdp/constants.js +0 -4
- package/lib/cdp/index.d.ts +0 -3
- package/lib/cdp/index.js +0 -16
- package/lib/cdp/instance/activate/activate.d.ts +0 -5
- package/lib/cdp/instance/activate/activate.js +0 -107
- package/lib/cdp/instance/activate/activate.spec.d.ts +0 -1
- package/lib/cdp/instance/activate/activate.spec.js +0 -274
- package/lib/cdp/instance/instanceCommand.d.ts +0 -3
- package/lib/cdp/instance/instanceCommand.js +0 -15
- package/lib/cdp/schema/deploy/deploy.const.d.ts +0 -5
- package/lib/cdp/schema/deploy/deploy.const.js +0 -8
- package/lib/cdp/schema/deploy/deploy.d.ts +0 -4
- package/lib/cdp/schema/deploy/deploy.js +0 -107
- package/lib/cdp/schema/deploy/deploy.spec.d.ts +0 -1
- package/lib/cdp/schema/deploy/deploy.spec.js +0 -137
- package/lib/cdp/schema/schemaCommand.d.ts +0 -3
- package/lib/cdp/schema/schemaCommand.js +0 -15
- package/lib/cdp/utils.d.ts +0 -23
- package/lib/cdp/utils.js +0 -133
- package/lib/cmp/deploy.d.ts +0 -3
- package/lib/cmp/deploy.js +0 -124
- package/lib/cmp/dev-mode-ui.d.ts +0 -4
- package/lib/cmp/dev-mode-ui.js +0 -51
- package/lib/cmp/dev-mode.d.ts +0 -4
- package/lib/cmp/dev-mode.js +0 -58
- package/lib/cmp/edge-components/compiler.d.ts +0 -13
- package/lib/cmp/edge-components/compiler.js +0 -55
- package/lib/cmp/index.d.ts +0 -3
- package/lib/cmp/index.js +0 -18
- package/lib/cmp/init.d.ts +0 -3
- package/lib/cmp/init.js +0 -105
- package/lib/cmp/utils/definitions.d.ts +0 -481
- package/lib/cmp/utils/definitions.js +0 -262
- package/lib/cmp/utils/definitions.spec.d.ts +0 -1
- package/lib/cmp/utils/definitions.spec.js +0 -503
- package/lib/constants.d.ts +0 -1
- package/lib/constants.js +0 -4
- package/lib/datastore/blueprint/add/add.d.ts +0 -3
- package/lib/datastore/blueprint/add/add.js +0 -119
- package/lib/datastore/blueprint/add/add.spec.d.ts +0 -1
- package/lib/datastore/blueprint/add/add.spec.js +0 -134
- package/lib/datastore/blueprint/blueprintCommand.d.ts +0 -3
- package/lib/datastore/blueprint/blueprintCommand.js +0 -21
- package/lib/datastore/blueprint/list/list.d.ts +0 -3
- package/lib/datastore/blueprint/list/list.js +0 -76
- package/lib/datastore/blueprint/list/list.spec.d.ts +0 -1
- package/lib/datastore/blueprint/list/list.spec.js +0 -51
- package/lib/datastore/blueprint/rename/rename.d.ts +0 -3
- package/lib/datastore/blueprint/rename/rename.js +0 -93
- package/lib/datastore/blueprint/rename/rename.spec.d.ts +0 -1
- package/lib/datastore/blueprint/rename/rename.spec.js +0 -142
- package/lib/datastore/blueprint/update/update.d.ts +0 -3
- package/lib/datastore/blueprint/update/update.js +0 -89
- package/lib/datastore/blueprint/update/update.spec.d.ts +0 -1
- package/lib/datastore/blueprint/update/update.spec.js +0 -99
- package/lib/datastore/bundle/bundle.d.ts +0 -3
- package/lib/datastore/bundle/bundle.js +0 -176
- package/lib/datastore/bundle/bundle.spec.d.ts +0 -1
- package/lib/datastore/bundle/bundle.spec.js +0 -94
- package/lib/datastore/index.d.ts +0 -3
- package/lib/datastore/index.js +0 -16
- package/lib/datastore/simulator/add/add.d.ts +0 -3
- package/lib/datastore/simulator/add/add.js +0 -125
- package/lib/datastore/simulator/add/add.spec.d.ts +0 -1
- package/lib/datastore/simulator/add/add.spec.js +0 -114
- package/lib/datastore/simulator/clear/clear.d.ts +0 -3
- package/lib/datastore/simulator/clear/clear.js +0 -70
- package/lib/datastore/simulator/clear/clear.spec.d.ts +0 -1
- package/lib/datastore/simulator/clear/clear.spec.js +0 -224
- package/lib/datastore/simulator/list/list.d.ts +0 -3
- package/lib/datastore/simulator/list/list.js +0 -115
- package/lib/datastore/simulator/list/list.spec.d.ts +0 -1
- package/lib/datastore/simulator/list/list.spec.js +0 -95
- package/lib/datastore/simulator/pause/pause.d.ts +0 -3
- package/lib/datastore/simulator/pause/pause.js +0 -84
- package/lib/datastore/simulator/pause/pause.spec.d.ts +0 -1
- package/lib/datastore/simulator/pause/pause.spec.js +0 -90
- package/lib/datastore/simulator/remove/remove.d.ts +0 -3
- package/lib/datastore/simulator/remove/remove.js +0 -68
- package/lib/datastore/simulator/remove/remove.spec.d.ts +0 -1
- package/lib/datastore/simulator/remove/remove.spec.js +0 -224
- package/lib/datastore/simulator/resume/resume.d.ts +0 -3
- package/lib/datastore/simulator/resume/resume.js +0 -84
- package/lib/datastore/simulator/resume/resume.spec.d.ts +0 -1
- package/lib/datastore/simulator/resume/resume.spec.js +0 -90
- package/lib/datastore/simulator/simulatorCommand.d.ts +0 -3
- package/lib/datastore/simulator/simulatorCommand.js +0 -27
- package/lib/datastore/simulator/upgrade/upgrade.d.ts +0 -3
- package/lib/datastore/simulator/upgrade/upgrade.js +0 -157
- package/lib/datastore/simulator/upgrade/upgrade.spec.d.ts +0 -1
- package/lib/datastore/simulator/upgrade/upgrade.spec.js +0 -199
- package/lib/datastore/simulator/utils.d.ts +0 -29
- package/lib/datastore/simulator/utils.js +0 -218
- package/lib/datastore/simulator/utils.spec.d.ts +0 -1
- package/lib/datastore/simulator/utils.spec.js +0 -201
- package/lib/datastore/utils.d.ts +0 -20
- package/lib/datastore/utils.js +0 -241
- package/lib/datastore/utils.spec.d.ts +0 -1
- package/lib/datastore/utils.spec.js +0 -113
- package/lib/dxp.d.ts +0 -1
- package/lib/dxp.js +0 -57
- package/lib/job-runner/index.d.ts +0 -3
- package/lib/job-runner/index.js +0 -22
- package/lib/job-runner/job/listJobs/listJobs.d.ts +0 -3
- package/lib/job-runner/job/listJobs/listJobs.js +0 -66
- package/lib/job-runner/job/listJobs/listJobs.spec.d.ts +0 -1
- package/lib/job-runner/job/listJobs/listJobs.spec.js +0 -42
- package/lib/job-runner/job/uploadJob/uploadJob.d.ts +0 -3
- package/lib/job-runner/job/uploadJob/uploadJob.js +0 -56
- package/lib/job-runner/job/uploadJob/uploadJob.spec.d.ts +0 -1
- package/lib/job-runner/job/uploadJob/uploadJob.spec.js +0 -42
- package/lib/job-runner/jobContext/listJobContexts.d.ts +0 -3
- package/lib/job-runner/jobContext/listJobContexts.js +0 -66
- package/lib/job-runner/jobContext/listJobContexts.spec.d.ts +0 -1
- package/lib/job-runner/jobContext/listJobContexts.spec.js +0 -58
- package/lib/job-runner/jobExecution/beginJob/beginJob.d.ts +0 -3
- package/lib/job-runner/jobExecution/beginJob/beginJob.js +0 -68
- package/lib/job-runner/jobExecution/beginJob/beginJob.spec.d.ts +0 -1
- package/lib/job-runner/jobExecution/beginJob/beginJob.spec.js +0 -62
- package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.d.ts +0 -3
- package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.js +0 -67
- package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.spec.d.ts +0 -1
- package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.spec.js +0 -64
- package/lib/job-runner/jobExecution/terminateJob/terminateJob.d.ts +0 -3
- package/lib/job-runner/jobExecution/terminateJob/terminateJob.js +0 -64
- package/lib/job-runner/jobExecution/terminateJob/terminateJob.spec.d.ts +0 -1
- package/lib/job-runner/jobExecution/terminateJob/terminateJob.spec.js +0 -61
- package/lib/job-runner/utils.d.ts +0 -19
- package/lib/job-runner/utils.js +0 -145
- package/lib/job-runner/utils.spec.d.ts +0 -1
- package/lib/job-runner/utils.spec.js +0 -116
- package/lib/migration/batch-get/batch-get.d.ts +0 -3
- package/lib/migration/batch-get/batch-get.js +0 -45
- package/lib/migration/batch-get/batch-get.spec.d.ts +0 -1
- package/lib/migration/batch-get/batch-get.spec.js +0 -182
- package/lib/migration/batch-next/batch-next.d.ts +0 -3
- package/lib/migration/batch-next/batch-next.js +0 -60
- package/lib/migration/batch-next/batch-next.spec.d.ts +0 -1
- package/lib/migration/batch-next/batch-next.spec.js +0 -251
- package/lib/migration/batch-revert/batch-revert.d.ts +0 -3
- package/lib/migration/batch-revert/batch-revert.js +0 -45
- package/lib/migration/batch-revert/batch-revert.spec.d.ts +0 -1
- package/lib/migration/batch-revert/batch-revert.spec.js +0 -197
- package/lib/migration/create/create.d.ts +0 -3
- package/lib/migration/create/create.js +0 -76
- package/lib/migration/create/create.spec.d.ts +0 -1
- package/lib/migration/create/create.spec.js +0 -308
- package/lib/migration/get/get.d.ts +0 -3
- package/lib/migration/get/get.js +0 -46
- package/lib/migration/get/get.spec.d.ts +0 -1
- package/lib/migration/get/get.spec.js +0 -276
- package/lib/migration/index.d.ts +0 -3
- package/lib/migration/index.js +0 -32
- package/lib/migration/list/list.d.ts +0 -3
- package/lib/migration/list/list.js +0 -45
- package/lib/migration/list/list.spec.d.ts +0 -1
- package/lib/migration/list/list.spec.js +0 -139
- package/lib/migration/mark-deployed/mark-deployed.d.ts +0 -3
- package/lib/migration/mark-deployed/mark-deployed.js +0 -55
- package/lib/migration/mark-deployed/mark-deployed.spec.d.ts +0 -1
- package/lib/migration/mark-deployed/mark-deployed.spec.js +0 -217
- package/lib/migration/next/next.d.ts +0 -3
- package/lib/migration/next/next.js +0 -75
- package/lib/migration/next/next.spec.d.ts +0 -1
- package/lib/migration/next/next.spec.js +0 -254
- package/lib/migration/pre/pre.d.ts +0 -3
- package/lib/migration/pre/pre.js +0 -54
- package/lib/migration/pre/pre.spec.d.ts +0 -1
- package/lib/migration/pre/pre.spec.js +0 -269
- package/lib/migration/revert/revert.d.ts +0 -3
- package/lib/migration/revert/revert.js +0 -47
- package/lib/migration/revert/revert.spec.d.ts +0 -1
- package/lib/migration/revert/revert.spec.js +0 -153
- package/lib/migration/settings/settings.d.ts +0 -3
- package/lib/migration/settings/settings.js +0 -63
- package/lib/migration/settings/settings.spec.d.ts +0 -1
- package/lib/migration/settings/settings.spec.js +0 -339
- package/lib/migration/types/common.types.d.ts +0 -60
- package/lib/migration/types/common.types.js +0 -19
- package/lib/migration/types/createMigration.types.d.ts +0 -48
- package/lib/migration/types/createMigration.types.js +0 -2
- package/lib/migration/types/getMigration.types.d.ts +0 -9
- package/lib/migration/types/getMigration.types.js +0 -2
- package/lib/migration/types/index.d.ts +0 -8
- package/lib/migration/types/index.js +0 -24
- package/lib/migration/types/listMigrations.types.d.ts +0 -2
- package/lib/migration/types/listMigrations.types.js +0 -2
- package/lib/migration/types/markDeployed.types.d.ts +0 -20
- package/lib/migration/types/markDeployed.types.js +0 -2
- package/lib/migration/types/nextStage.types.d.ts +0 -31
- package/lib/migration/types/nextStage.types.js +0 -2
- package/lib/migration/types/preMigration.types.d.ts +0 -10
- package/lib/migration/types/preMigration.types.js +0 -2
- package/lib/migration/types/revert.types.d.ts +0 -18
- package/lib/migration/types/revert.types.js +0 -2
- package/lib/migration/types/settings.types.d.ts +0 -15
- package/lib/migration/types/settings.types.js +0 -2
- package/lib/migration/utils/common.d.ts +0 -53
- package/lib/migration/utils/common.js +0 -166
- package/lib/migration/utils/common.spec.d.ts +0 -1
- package/lib/migration/utils/common.spec.js +0 -236
- package/lib/migration/utils/createMigration.d.ts +0 -16
- package/lib/migration/utils/createMigration.js +0 -116
- package/lib/migration/utils/createMigration.spec.d.ts +0 -1
- package/lib/migration/utils/createMigration.spec.js +0 -260
- package/lib/migration/utils/getMigration.d.ts +0 -3
- package/lib/migration/utils/getMigration.js +0 -46
- package/lib/migration/utils/getMigration.spec.d.ts +0 -1
- package/lib/migration/utils/getMigration.spec.js +0 -295
- package/lib/migration/utils/index.d.ts +0 -10
- package/lib/migration/utils/index.js +0 -26
- package/lib/migration/utils/listMigrations.d.ts +0 -3
- package/lib/migration/utils/listMigrations.js +0 -41
- package/lib/migration/utils/listMigrations.spec.d.ts +0 -1
- package/lib/migration/utils/listMigrations.spec.js +0 -109
- package/lib/migration/utils/loadAssetIdsFromFile.d.ts +0 -9
- package/lib/migration/utils/loadAssetIdsFromFile.js +0 -40
- package/lib/migration/utils/loadAssetIdsFromFile.spec.d.ts +0 -1
- package/lib/migration/utils/loadAssetIdsFromFile.spec.js +0 -91
- package/lib/migration/utils/loadStageOptionsFromFile.d.ts +0 -2
- package/lib/migration/utils/loadStageOptionsFromFile.js +0 -32
- package/lib/migration/utils/loadStageOptionsFromFile.spec.d.ts +0 -1
- package/lib/migration/utils/loadStageOptionsFromFile.spec.js +0 -77
- package/lib/migration/utils/markComponentsDeployed.d.ts +0 -2
- package/lib/migration/utils/markComponentsDeployed.js +0 -37
- package/lib/migration/utils/markComponentsDeployed.spec.d.ts +0 -1
- package/lib/migration/utils/markComponentsDeployed.spec.js +0 -222
- package/lib/migration/utils/nextStage.d.ts +0 -3
- package/lib/migration/utils/nextStage.js +0 -55
- package/lib/migration/utils/nextStage.spec.d.ts +0 -1
- package/lib/migration/utils/nextStage.spec.js +0 -323
- package/lib/migration/utils/options.d.ts +0 -18
- package/lib/migration/utils/options.js +0 -136
- package/lib/migration/utils/options.spec.d.ts +0 -1
- package/lib/migration/utils/options.spec.js +0 -115
- package/lib/migration/utils/promptForMorphConfirmation.d.ts +0 -5
- package/lib/migration/utils/promptForMorphConfirmation.js +0 -55
- package/lib/migration/utils/promptForMorphConfirmation.spec.d.ts +0 -1
- package/lib/migration/utils/promptForMorphConfirmation.spec.js +0 -101
- package/lib/migration/utils/revertMigration.d.ts +0 -3
- package/lib/migration/utils/revertMigration.js +0 -58
- package/lib/migration/utils/revertMigration.spec.d.ts +0 -1
- package/lib/migration/utils/revertMigration.spec.js +0 -210
- package/lib/migration/utils/setMigrationSettings.d.ts +0 -2
- package/lib/migration/utils/setMigrationSettings.js +0 -52
- package/lib/migration/utils/setMigrationSettings.spec.d.ts +0 -1
- package/lib/migration/utils/setMigrationSettings.spec.js +0 -163
- package/lib/page/index.d.ts +0 -3
- package/lib/page/index.js +0 -12
- package/lib/page/layouts/deploy/deploy.d.ts +0 -5
- package/lib/page/layouts/deploy/deploy.js +0 -157
- package/lib/page/layouts/deploy/deploy.spec.d.ts +0 -1
- package/lib/page/layouts/deploy/deploy.spec.js +0 -319
- package/lib/page/layouts/dev/dev.d.ts +0 -5
- package/lib/page/layouts/dev/dev.js +0 -84
- package/lib/page/layouts/dev/dev.spec.d.ts +0 -1
- package/lib/page/layouts/dev/dev.spec.js +0 -271
- package/lib/page/layouts/layouts.d.ts +0 -3
- package/lib/page/layouts/layouts.js +0 -17
- package/lib/page/layouts/layouts.spec.d.ts +0 -1
- package/lib/page/layouts/layouts.spec.js +0 -29
- package/lib/page/layouts/validation/index.d.ts +0 -3
- package/lib/page/layouts/validation/index.js +0 -9
- package/lib/page/layouts/validation/property-consistency.d.ts +0 -7
- package/lib/page/layouts/validation/property-consistency.js +0 -92
- package/lib/page/layouts/validation/property-consistency.spec.d.ts +0 -1
- package/lib/page/layouts/validation/property-consistency.spec.js +0 -307
- package/lib/page/layouts/validation/validateLayoutFormat.d.ts +0 -2
- package/lib/page/layouts/validation/validateLayoutFormat.js +0 -27
- package/lib/page/layouts/validation/validateLayoutFormat.spec.d.ts +0 -1
- package/lib/page/layouts/validation/validateLayoutFormat.spec.js +0 -42
- package/lib/page/layouts/validation/zone-consistency.d.ts +0 -7
- package/lib/page/layouts/validation/zone-consistency.js +0 -50
- package/lib/page/layouts/validation/zone-consistency.spec.d.ts +0 -1
- package/lib/page/layouts/validation/zone-consistency.spec.js +0 -94
- package/lib/page/templates/validation.d.ts +0 -11
- package/lib/page/templates/validation.js +0 -30
- package/lib/page/templates/validation.spec.d.ts +0 -1
- package/lib/page/templates/validation.spec.js +0 -89
- package/lib/page/utils/definitions.d.ts +0 -596
- package/lib/page/utils/definitions.js +0 -247
- package/lib/page/utils/definitions.spec.d.ts +0 -1
- package/lib/page/utils/definitions.spec.js +0 -778
- package/lib/page/utils/normalize.d.ts +0 -8
- package/lib/page/utils/normalize.js +0 -54
- package/lib/page/utils/normalize.spec.d.ts +0 -1
- package/lib/page/utils/normalize.spec.js +0 -309
- package/lib/page/utils/parse-args.d.ts +0 -44
- package/lib/page/utils/parse-args.js +0 -119
- package/lib/page/utils/parse-args.spec.d.ts +0 -1
- package/lib/page/utils/parse-args.spec.js +0 -284
- package/lib/page/utils/render.d.ts +0 -51
- package/lib/page/utils/render.js +0 -112
- package/lib/page/utils/render.spec.d.ts +0 -1
- package/lib/page/utils/render.spec.js +0 -134
- package/lib/page/utils/server.d.ts +0 -12
- package/lib/page/utils/server.js +0 -201
- package/lib/page/utils/server.spec.d.ts +0 -1
- package/lib/page/utils/server.spec.js +0 -275
- package/lib/porter/constants.d.ts +0 -11
- package/lib/porter/constants.js +0 -14
- package/lib/porter/index.d.ts +0 -3
- package/lib/porter/index.js +0 -24
- package/lib/porter/port/abort/abort.d.ts +0 -3
- package/lib/porter/port/abort/abort.js +0 -80
- package/lib/porter/port/abort/abort.spec.d.ts +0 -1
- package/lib/porter/port/abort/abort.spec.js +0 -182
- package/lib/porter/port/get/get.d.ts +0 -3
- package/lib/porter/port/get/get.js +0 -96
- package/lib/porter/port/get/get.spec.d.ts +0 -1
- package/lib/porter/port/get/get.spec.js +0 -277
- package/lib/porter/port/start/start.d.ts +0 -3
- package/lib/porter/port/start/start.js +0 -82
- package/lib/porter/port/start/start.spec.d.ts +0 -1
- package/lib/porter/port/start/start.spec.js +0 -198
- package/lib/porter/project/add/add.d.ts +0 -3
- package/lib/porter/project/add/add.js +0 -138
- package/lib/porter/project/add/add.spec.d.ts +0 -1
- package/lib/porter/project/add/add.spec.js +0 -269
- package/lib/porter/project/get/get.d.ts +0 -3
- package/lib/porter/project/get/get.js +0 -65
- package/lib/porter/project/get/get.spec.d.ts +0 -1
- package/lib/porter/project/get/get.spec.js +0 -185
- package/lib/porter/project/remove/remove.d.ts +0 -3
- package/lib/porter/project/remove/remove.js +0 -69
- package/lib/porter/project/remove/remove.spec.d.ts +0 -1
- package/lib/porter/project/remove/remove.spec.js +0 -201
- package/lib/porter/types.d.ts +0 -5
- package/lib/porter/types.js +0 -2
- package/lib/porter/utils/BuildDXPUrl/BuildDXPUrl.d.ts +0 -4
- package/lib/porter/utils/BuildDXPUrl/BuildDXPUrl.js +0 -34
- package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.d.ts +0 -1
- package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.js +0 -21
- package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.spec.d.ts +0 -1
- package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.spec.js +0 -52
- package/lib/porter/utils/CoreUtils/CoreUtils.d.ts +0 -2
- package/lib/porter/utils/CoreUtils/CoreUtils.js +0 -13
- package/lib/porter/utils/CoreUtils/CoreUtils.spec.d.ts +0 -1
- package/lib/porter/utils/CoreUtils/CoreUtils.spec.js +0 -36
- package/lib/porter/utils/DoesPathExist/DoesPathExist.d.ts +0 -1
- package/lib/porter/utils/DoesPathExist/DoesPathExist.js +0 -27
- package/lib/porter/utils/DoesPathExist/DoesPathExist.spec.d.ts +0 -1
- package/lib/porter/utils/DoesPathExist/DoesPathExist.spec.js +0 -40
- package/lib/porter/utils/ErrorUtils/ErrorUtils.d.ts +0 -4
- package/lib/porter/utils/ErrorUtils/ErrorUtils.js +0 -66
- package/lib/porter/utils/ErrorUtils/ErrorUtils.spec.d.ts +0 -1
- package/lib/porter/utils/ErrorUtils/ErrorUtils.spec.js +0 -176
- package/lib/porter/utils/GetProjectConfig/GetProjectConfig.d.ts +0 -2
- package/lib/porter/utils/GetProjectConfig/GetProjectConfig.js +0 -33
- package/lib/porter/utils/GetProjectConfig/GetProjectConfig.spec.d.ts +0 -1
- package/lib/porter/utils/GetProjectConfig/GetProjectConfig.spec.js +0 -50
- package/lib/porter/utils/GetProjectName/GetProjectName.d.ts +0 -4
- package/lib/porter/utils/GetProjectName/GetProjectName.js +0 -30
- package/lib/porter/utils/GetProjectName/GetProjectName.spec.d.ts +0 -1
- package/lib/porter/utils/GetProjectName/GetProjectName.spec.js +0 -91
- package/lib/porter/utils/index.d.ts +0 -7
- 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.
|
|
3
|
+
"version": "5.33.0-develop.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "https://gitlab.squiz.net/dxp/dxp-cli-next"
|
|
6
6
|
},
|
|
7
7
|
"files": [
|
|
8
|
-
"
|
|
9
|
-
"
|
|
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
|
-
"
|
|
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,13 @@
|
|
|
28
29
|
"engines": {
|
|
29
30
|
"node": ">=20.0"
|
|
30
31
|
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"esbuild": "^0.21.5",
|
|
34
|
+
"jsdom": "^25.0.1",
|
|
35
|
+
"update-notifier": "5.1.0",
|
|
36
|
+
"workerd": "^1.20250428.0",
|
|
37
|
+
"@squiz/local-component-dev-ui": "0.6.20"
|
|
38
|
+
},
|
|
31
39
|
"keywords": [
|
|
32
40
|
"cli",
|
|
33
41
|
"template",
|
|
@@ -39,34 +47,16 @@
|
|
|
39
47
|
"semantic-release",
|
|
40
48
|
"codecov"
|
|
41
49
|
],
|
|
42
|
-
"
|
|
50
|
+
"devDependencies": {
|
|
43
51
|
"@apidevtools/swagger-parser": "10.1.0",
|
|
52
|
+
"@vercel/ncc": "^0.38.3",
|
|
53
|
+
"@semantic-release/git": "10.0.1",
|
|
54
|
+
"@semantic-release/gitlab": "9.4.2",
|
|
55
|
+
"@semantic-release/npm": "9.0.1",
|
|
44
56
|
"@squiz/component-cli-lib": "1.72.12",
|
|
45
57
|
"@squiz/dx-logger-lib": "^1.65.1",
|
|
46
58
|
"@squiz/dxp-porter-shared": "0.4.0",
|
|
47
59
|
"@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
|
-
"devDependencies": {
|
|
67
|
-
"@semantic-release/git": "10.0.1",
|
|
68
|
-
"@semantic-release/gitlab": "9.4.2",
|
|
69
|
-
"@semantic-release/npm": "9.0.1",
|
|
70
60
|
"@types/cli-color": "2.0.2",
|
|
71
61
|
"@types/inquirer": "8.2.6",
|
|
72
62
|
"@types/jest": "29.5.14",
|
|
@@ -77,25 +67,43 @@
|
|
|
77
67
|
"@types/update-notifier": "5.1.0",
|
|
78
68
|
"@typescript-eslint/eslint-plugin": "5.30.7",
|
|
79
69
|
"@typescript-eslint/parser": "5.30.7",
|
|
70
|
+
"update-notifier": "5.1.0",
|
|
71
|
+
"axios": "1.11.0",
|
|
80
72
|
"chalk": "4.1.2",
|
|
73
|
+
"cli-color": "2.0.3",
|
|
81
74
|
"codecov": "3.8.3",
|
|
75
|
+
"commander": "9.4.0",
|
|
82
76
|
"commitizen": "4.2.5",
|
|
83
77
|
"cz-conventional-changelog": "3.3.0",
|
|
78
|
+
"dotenv": "^16.3.1",
|
|
79
|
+
"env-paths": "2.2.1",
|
|
80
|
+
"esbuild": "^0.21.5",
|
|
84
81
|
"eslint": "8.19.0",
|
|
85
82
|
"eslint-config-prettier": "8.5.0",
|
|
86
83
|
"eslint-plugin-node": "11.1.0",
|
|
87
84
|
"eslint-plugin-prettier": "4.2.1",
|
|
88
85
|
"execa": "5.1.1",
|
|
86
|
+
"handlebars": "^4.7.8",
|
|
89
87
|
"husky": "8.0.1",
|
|
88
|
+
"inquirer": "8.2.5",
|
|
90
89
|
"jest": "29.7.0",
|
|
90
|
+
"jsdom": "^25.0.1",
|
|
91
91
|
"lint-staged": "13.0.3",
|
|
92
92
|
"nock": "^13.3.1",
|
|
93
|
+
"opener": "1.5.2",
|
|
94
|
+
"ora": "^5.4.1",
|
|
93
95
|
"prettier": "2.7.1",
|
|
96
|
+
"prompt": "^1.3.0",
|
|
94
97
|
"semantic-release": "19.0.3",
|
|
95
98
|
"supertest": "^6.3.4",
|
|
99
|
+
"tough-cookie": "4.1.4",
|
|
96
100
|
"ts-jest": "29.2.5",
|
|
97
101
|
"ts-node": "^10.9.1",
|
|
98
|
-
"typescript": "
|
|
102
|
+
"typescript": "5.9.3",
|
|
103
|
+
"yaml": "^2.3.4",
|
|
104
|
+
"zod": "^3.23.8",
|
|
105
|
+
"zod-validation-error": "^3.3.1",
|
|
106
|
+
"cosmiconfig": "9.0.0"
|
|
99
107
|
},
|
|
100
108
|
"config": {
|
|
101
109
|
"commitizen": {
|
package/lib/ApiService.d.ts
DELETED
|
@@ -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
|
-
}
|
package/lib/ApiService.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/ApiService.spec.js
DELETED
|
@@ -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
|
-
});
|
package/lib/ApplicationConfig.js
DELETED
|
@@ -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>;
|