@hubspot/cli 5.2.1-beta.9 → 5.3.0
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/commands/functions/deploy.js +2 -2
- package/commands/project/__tests__/deploy.test.js +432 -0
- package/commands/project/cloneApp.js +208 -0
- package/commands/project/deploy.js +82 -27
- package/commands/project/listBuilds.js +1 -1
- package/commands/project/logs.js +1 -1
- package/commands/project/migrateApp.js +66 -24
- package/commands/project/upload.js +1 -1
- package/commands/project.js +15 -12
- package/commands/sandbox/create.js +12 -43
- package/commands/sandbox/delete.js +5 -2
- package/commands/sandbox/sync.js +12 -2
- package/commands/sandbox.js +2 -1
- package/lang/en.lyaml +56 -48
- package/lib/LocalDevManager.js +12 -9
- package/lib/constants.js +3 -1
- package/lib/interpolationHelpers.js +3 -0
- package/lib/localDev.js +1 -2
- package/lib/polling.js +16 -10
- package/lib/projects.js +143 -100
- package/lib/prompts/accountNamePrompt.js +1 -4
- package/lib/prompts/createProjectPrompt.js +12 -2
- package/lib/prompts/deployBuildIdPrompt.js +22 -0
- package/lib/prompts/installPublicAppPrompt.js +13 -4
- package/lib/prompts/selectPublicAppPrompt.js +34 -10
- package/lib/sandboxSync.js +49 -68
- package/lib/sandboxes.js +8 -149
- package/lib/serverlessLogs.js +2 -2
- package/lib/ui/index.js +74 -0
- package/package.json +5 -4
- package/lib/prompts/buildIdPrompt.js +0 -35
- package/lib/ui/CliProgressMultibarManager.js +0 -66
package/lang/en.lyaml
CHANGED
|
@@ -527,7 +527,25 @@ en:
|
|
|
527
527
|
invalidAccountTypeTitle: "{{#bold}}Developer account not targeted{{/bold}}"
|
|
528
528
|
invalidAccountTypeDescription: "Only public apps created in a developer account can be converted to a project component. Select a connected developer account with {{useCommand}} or {{authCommand}} and try again."
|
|
529
529
|
projectAlreadyExists: "A project with name {{ projectName }} already exists. Please choose another name."
|
|
530
|
-
|
|
530
|
+
invalidApp: "Could not migrate appId {{ appId }}. This app cannot be migrated at this time. Please choose another public app."
|
|
531
|
+
cloneApp:
|
|
532
|
+
describe: "Clone a public app using the projects framework"
|
|
533
|
+
examples:
|
|
534
|
+
default: "Clone a public app using the projects framework"
|
|
535
|
+
options:
|
|
536
|
+
appId:
|
|
537
|
+
describe: "The ID for the public app being cloned"
|
|
538
|
+
location:
|
|
539
|
+
describe: "Directory where project should be created"
|
|
540
|
+
cloneStatus:
|
|
541
|
+
inProgress: "Cloning app configuration to {{#bold}}public-app.json{{/bold}} component definition ..."
|
|
542
|
+
done: "Cloning app configuration to public-app.json component definition ... DONE"
|
|
543
|
+
success: "Your cloned project was created in {{ location }}"
|
|
544
|
+
failure: "Cloning app configuration to public-app.json component definition ... FAILED"
|
|
545
|
+
errors:
|
|
546
|
+
invalidAccountTypeTitle: "{{#bold}}Developer account not targeted{{/bold}}"
|
|
547
|
+
invalidAccountTypeDescription: "Only public apps created in a developer account can be converted to a project component. Select a connected developer account with {{useCommand}} or {{authCommand}} and try again."
|
|
548
|
+
couldNotWriteConfigPath: "Failed to write project config at {{ configPath }}"
|
|
531
549
|
add:
|
|
532
550
|
describe: "Create a new component within a project"
|
|
533
551
|
options:
|
|
@@ -551,12 +569,15 @@ en:
|
|
|
551
569
|
deploy: "Deploy error: {{ details }}"
|
|
552
570
|
noBuilds: "Deploy error: no builds for this project were found."
|
|
553
571
|
noBuildId: "You must specify a build to deploy"
|
|
554
|
-
projectNotFound: "{{ projectName }} does not exist in account {{ accountIdentifier }}. Run {{ command }} to upload your project files to HubSpot."
|
|
572
|
+
projectNotFound: "The project {{ projectName }} does not exist in account {{ accountIdentifier }}. Run {{ command }} to upload your project files to HubSpot."
|
|
573
|
+
buildIdDoesNotExist: "Build {{ buildId }} does not exist for project {{ projectName }}. {{ linkToProject }}"
|
|
574
|
+
buildAlreadyDeployed: "Build {{ buildId }} is already deployed. {{ linkToProject}}"
|
|
575
|
+
viewProjectsBuilds: 'View project builds in HubSpot'
|
|
555
576
|
examples:
|
|
556
577
|
default: "Deploy the latest build of the current project"
|
|
557
578
|
withOptions: "Deploy build 5 of the project my-project"
|
|
558
579
|
options:
|
|
559
|
-
|
|
580
|
+
build:
|
|
560
581
|
describe: "Project build ID to be deployed"
|
|
561
582
|
project:
|
|
562
583
|
describe: "Project name"
|
|
@@ -1031,9 +1052,12 @@ en:
|
|
|
1031
1052
|
successStatusText: "DONE"
|
|
1032
1053
|
failedStatusText: "FAILED"
|
|
1033
1054
|
errorFetchingTaskStatus: "Error fetching {{ taskType }} status"
|
|
1055
|
+
pollBuildAutodeployStatusError: "Error fetching autodeploy status for build #{{ buildId }}"
|
|
1034
1056
|
pollProjectBuildAndDeploy:
|
|
1035
1057
|
buildSucceededAutomaticallyDeploying: "Build #{{ buildId }} succeeded. {{#bold}}Automatically deploying{{/bold}} to {{ accountIdentifier }}\n"
|
|
1036
1058
|
cleanedUpTempFile: "Cleaned up temporary file {{ path }}"
|
|
1059
|
+
viewDeploys: "View all deploys for this project in HubSpot"
|
|
1060
|
+
unableToFindAutodeployStatus: "Unable to find the auto deploy for build #{{ buildId }}. This deploy may have been skipped. {{ viewDeploysLink }}."
|
|
1037
1061
|
logFeedbackMessage:
|
|
1038
1062
|
feedbackHeader: "We'd love to hear your feedback!"
|
|
1039
1063
|
feedbackMessage: "How are you liking the new projects and developer tools? \n > Run `{{#yellow}}hs feedback{{/yellow}}` to let us know what you think!\n"
|
|
@@ -1042,6 +1066,14 @@ en:
|
|
|
1042
1066
|
betaWarning:
|
|
1043
1067
|
header: "{{#yellow}}***************************** WARNING ****************************{{/yellow}}"
|
|
1044
1068
|
footer: "{{#yellow}}******************************************************************{{/yellow}}"
|
|
1069
|
+
infoTag: "{{#bold}}[INFO]{{/bold}}"
|
|
1070
|
+
deprecatedTag: "{{#bold}}[DEPRECATED]{{/bold}}"
|
|
1071
|
+
errorTag: "{{#bold}}[ERROR]{{/bold}}"
|
|
1072
|
+
deprecatedMessage: "The {{ command }} command is deprecated and will be disabled soon. {{ url }}"
|
|
1073
|
+
deprecatedDescription: "{{ message }}. The {{ command }} command is deprecated and will be disabled soon. {{ url }}"
|
|
1074
|
+
deprecatedUrlText: 'Learn more.'
|
|
1075
|
+
disabledMessage: "The {{ command }} command is disabled. Run {{ npmCommand }} to update to the latest HubSpot CLI version. {{ url }}"
|
|
1076
|
+
disabledUrlText: "See all HubSpot CLI commands here."
|
|
1045
1077
|
featureHighlight:
|
|
1046
1078
|
defaultTitle: "What's next?"
|
|
1047
1079
|
commandKeys:
|
|
@@ -1210,6 +1242,7 @@ en:
|
|
|
1210
1242
|
nameRequired: "A project name is required"
|
|
1211
1243
|
locationRequired: "A project location is required"
|
|
1212
1244
|
invalidLocation: "The selected destination already exists. Please provide a new path for this project."
|
|
1245
|
+
invalidCharacters: "The selected destination contains invalid characters. Please provide a new path and try again."
|
|
1213
1246
|
invalidTemplate: "[--template] Could not find template {{ template }}. Please choose an available template."
|
|
1214
1247
|
noProjectsInConfig: "Please ensure that there is a config.json file that contains a \"projects\" field."
|
|
1215
1248
|
missingPropertiesInConfig: "Please ensure that each of the projects in your config.json file contain the following properties: [\"name\", \"label\", \"path\", \"insertPath\"]."
|
|
@@ -1217,11 +1250,12 @@ en:
|
|
|
1217
1250
|
selectAppIdMigrate: "[--appId] Choose an app under {{ accountName }} to migrate:"
|
|
1218
1251
|
selectAppIdClone: "[--appId] Choose an app under {{ accountName }} to clone:"
|
|
1219
1252
|
errors:
|
|
1220
|
-
|
|
1221
|
-
|
|
1253
|
+
noAppsMigration: "{{#bold}}No apps to migrate{{/bold}}"
|
|
1254
|
+
noAppsClone: "{{#bold}}No apps to clone{{/bold}}"
|
|
1255
|
+
noAppsMigrationMessage: "The selected developer account {{#bold}}{{ accountName }}{{/bold}} doesn't have any apps that can be migrated to the projects framework."
|
|
1256
|
+
noAppsCloneMessage: "The selected developer account {{#bold}}{{ accountName }}{{/bold}} doesn't have any apps that can be cloned to the projects framework."
|
|
1222
1257
|
errorFetchingApps: "There was an error fetching public apps."
|
|
1223
|
-
|
|
1224
|
-
marketplaceApp: "Marketplace app"
|
|
1258
|
+
cannotBeMigrated: "Cannot be migrated"
|
|
1225
1259
|
downloadProjectPrompt:
|
|
1226
1260
|
selectProject: "Select a project to download:"
|
|
1227
1261
|
errors:
|
|
@@ -1240,9 +1274,9 @@ en:
|
|
|
1240
1274
|
selectAccountName: "Select the sandbox account you want to delete"
|
|
1241
1275
|
selectParentAccountName: "Select the account that the sandbox belongs to"
|
|
1242
1276
|
type:
|
|
1243
|
-
message: "
|
|
1244
|
-
developer: "Development sandbox (
|
|
1245
|
-
standard: "Standard sandbox (
|
|
1277
|
+
message: "Choose the type of sandbox you want to create"
|
|
1278
|
+
developer: "Development sandbox (Includes production's object definitions)"
|
|
1279
|
+
standard: "Standard sandbox (Includes partial copy of production's assets)"
|
|
1246
1280
|
uploadPrompt:
|
|
1247
1281
|
enterDest: "[--dest] Enter the destination path: "
|
|
1248
1282
|
enterSrc: "[--src] Enter the source path: "
|
|
@@ -1262,11 +1296,8 @@ en:
|
|
|
1262
1296
|
general: "[--general] Tell us about your experience with HubSpot's developer tools"
|
|
1263
1297
|
bugPrompt: "Create an issue on Github in your browser?"
|
|
1264
1298
|
generalPrompt: "Create an issue on Github in your browser?"
|
|
1265
|
-
|
|
1299
|
+
deployBuildIdPrompt:
|
|
1266
1300
|
enterBuildId: "[--build] Deploy which build?"
|
|
1267
|
-
errors:
|
|
1268
|
-
buildIdDoesNotExist: "Build {{ buildId }} does not exist for project {{ projectName }}."
|
|
1269
|
-
buildAlreadyDeployed: "Build {{ buildId }} is already deployed."
|
|
1270
1301
|
previewPrompt:
|
|
1271
1302
|
enterSrc: "[--src] Enter a local theme directory to preview."
|
|
1272
1303
|
enterDest: "[--dest] Enter the destination path for the src theme in HubSpot Design Tools."
|
|
@@ -1278,7 +1309,9 @@ en:
|
|
|
1278
1309
|
message: "You are about to remove any remote files in \"{{ filePath }}\" on HubSpot account {{ accountId }} that don't exist locally. Are you sure you want to do this?"
|
|
1279
1310
|
installPublicAppPrompt:
|
|
1280
1311
|
explanation: "Local development requires this app to be installed in the target test account"
|
|
1312
|
+
reinstallExplanation: "This app's required scopes have been updated since it was last installed on the target test account. To avoid issues with local development, we recommend reinstalling the app with the updated scopes."
|
|
1281
1313
|
prompt: "Open hubspot.com to install this app?"
|
|
1314
|
+
reinstallPrompt: "Open hubspot.com to reinstall this app?"
|
|
1282
1315
|
decline: "To continue local development of this app, install it in your target test account and re-run {{#bold}}`hs project dev`{{/bold}}"
|
|
1283
1316
|
activeInstallConfirmationPrompt:
|
|
1284
1317
|
message: "Proceed with local development of this {{#bold}}production{{/bold}} app?"
|
|
@@ -1314,11 +1347,11 @@ en:
|
|
|
1314
1347
|
developer:
|
|
1315
1348
|
add: "Creating development sandbox {{#bold}}{{ accountName }}{{/bold}}"
|
|
1316
1349
|
fail: "Failed to create a development sandbox {{#bold}}{{ accountName }}{{/bold}}."
|
|
1317
|
-
succeed: "
|
|
1350
|
+
succeed: "Created {{#bold}}{{ accountName }} [dev sandbox] ({{ accountId }}){{/bold}}."
|
|
1318
1351
|
standard:
|
|
1319
1352
|
add: "Creating standard sandbox {{#bold}}{{ accountName }}{{/bold}}"
|
|
1320
1353
|
fail: "Failed to create a standard sandbox {{#bold}}{{ accountName }}{{/bold}}."
|
|
1321
|
-
succeed: "
|
|
1354
|
+
succeed: "Created {{#bold}}{{ accountName }} [standard sandbox] ({{ accountId }}){{/bold}}."
|
|
1322
1355
|
failure:
|
|
1323
1356
|
invalidUser: "Couldn't create {{#bold}}{{ accountName }}{{/bold}} because your account has been removed from {{#bold}}{{ parentAccountName }}{{/bold}} or your permission set doesn't allow you to create the sandbox. To update your permissions, contact a super admin in {{#bold}}{{ parentAccountName }}{{/bold}}."
|
|
1324
1357
|
403Gating: "Couldn't create {{#bold}}{{ accountName }}{{/bold}} because {{#bold}}{{ parentAccountName }}{{/bold}} does not have access to development sandboxes. To opt in to the CRM Development Beta and use development sandboxes, visit https://app.hubspot.com/l/product-updates/in-beta?update=13899236."
|
|
@@ -1360,53 +1393,28 @@ en:
|
|
|
1360
1393
|
sync:
|
|
1361
1394
|
info:
|
|
1362
1395
|
syncStatus: "View the sync status details at: {{#bold}}{{ url }}{{/bold}}"
|
|
1363
|
-
|
|
1396
|
+
syncMessage: "Asset sync from production to the sandbox is in progress and is running in the background. It may take some time. {{ url }}"
|
|
1397
|
+
syncMessageDevSb: "Sync of object definitions from production to the sandbox is in progress and is running in the background. It may take some time. {{ url }}"
|
|
1398
|
+
syncStatusDetailsLinkText: "View sync status details here"
|
|
1364
1399
|
confirm:
|
|
1365
1400
|
createFlow:
|
|
1366
1401
|
standard: "Sync all supported assets to {{#cyan}}{{#bold}}{{ sandboxName }}{{/bold}}{{/cyan}} from {{#bold}}{{ parentAccountName }}{{/bold}}?"
|
|
1367
1402
|
developer: "Sync CRM object definitions to {{#cyan}}{{#bold}}{{ sandboxName }}{{/bold}}{{/cyan}} from {{#bold}}{{ parentAccountName }}{{/bold}}?"
|
|
1368
1403
|
syncContactRecords:
|
|
1369
|
-
standard: "
|
|
1404
|
+
standard: "Copy up to 5000 most recently updated contacts? This includes up to 100 of each of the following: associated deals, tickets, and companies."
|
|
1370
1405
|
developer: "Include up to 100 most recently updated contacts? This includes up to 100 of each of the following: associated deals, tickets, and companies. This can be done once per sandbox."
|
|
1371
1406
|
loading:
|
|
1372
1407
|
startSync: "Initiating sync..."
|
|
1373
1408
|
fail: "Failed to sync sandbox."
|
|
1374
|
-
succeed: "
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
polling:
|
|
1378
|
-
syncing: "Syncing sandbox..."
|
|
1379
|
-
fail: "Failed to fetch sync updates. View the sync status at: {{ url }}"
|
|
1380
|
-
succeed: "Sandbox sync complete."
|
|
1409
|
+
succeed: "Initiated asset sync from production to {{ accountName }}"
|
|
1410
|
+
succeedDevSb: "Initiated sync of object definitions from production to {{ accountName }}"
|
|
1411
|
+
successDevSbInfo: "Initiated sync of object definitions from production to {{ accountName }}. It may take some time. {{ url }}"
|
|
1381
1412
|
failure:
|
|
1382
1413
|
invalidUser: "Couldn't sync {{ accountName }} because your account has been removed from {{ parentAccountName }} or your permission set doesn't allow you to sync the sandbox. To update your permissions, contact a super admin in {{ parentAccountName }}."
|
|
1383
1414
|
missingScopes: "Couldn’t run the sync because there are scopes missing in your production account. To update scopes, deactivate your current personal access key for {{#bold}}{{ accountName }}{{/bold}}, and generate a new one. Then run `hs auth` to update the CLI with the new key."
|
|
1384
1415
|
syncInProgress: "Couldn’t run the sync because there’s another sync in progress. Wait for the current sync to finish and then try again. To check the sync status, visit the sync activity log: {{ url }}."
|
|
1385
1416
|
notSuperAdmin: "Couldn't run the sync because you are not a super admin in {{ account }}. Ask the account owner for super admin access to the sandbox."
|
|
1386
1417
|
objectNotFound: "Couldn't sync the sandbox because {{#bold}}{{ account }}{{/bold}} may have been deleted through the UI. Run {{#bold}}hs sandbox delete{{/bold}} to remove this account from the config. "
|
|
1387
|
-
types:
|
|
1388
|
-
parcels:
|
|
1389
|
-
label: "Account tools and features"
|
|
1390
|
-
super-admins:
|
|
1391
|
-
label: "Super Admins"
|
|
1392
|
-
object-schemas:
|
|
1393
|
-
label: "Object definitions"
|
|
1394
|
-
object-records:
|
|
1395
|
-
label: "Contacts and associated records"
|
|
1396
|
-
cms-developer-assets:
|
|
1397
|
-
label: "Themes, templates, and modules"
|
|
1398
|
-
object-pipelines:
|
|
1399
|
-
label: "Pipelines"
|
|
1400
|
-
object-lists:
|
|
1401
|
-
label: "Lists"
|
|
1402
|
-
workflows:
|
|
1403
|
-
label: "Workflows"
|
|
1404
|
-
forms:
|
|
1405
|
-
label: "Forms"
|
|
1406
|
-
lead-flows:
|
|
1407
|
-
label: "Lead Flows"
|
|
1408
|
-
marketing-email:
|
|
1409
|
-
label: "Marketing emails"
|
|
1410
1418
|
errorHandlers:
|
|
1411
1419
|
standardErrors:
|
|
1412
1420
|
errorOccurred: "Error: {{ error }}"
|
package/lib/LocalDevManager.js
CHANGED
|
@@ -9,7 +9,7 @@ const {
|
|
|
9
9
|
} = require('@hubspot/local-dev-lib/api/localDevAuth');
|
|
10
10
|
const {
|
|
11
11
|
fetchPublicAppsForPortal,
|
|
12
|
-
|
|
12
|
+
fetchPublicAppProductionInstallCounts,
|
|
13
13
|
} = require('@hubspot/local-dev-lib/api/appsDev');
|
|
14
14
|
const {
|
|
15
15
|
getAccountId,
|
|
@@ -138,17 +138,16 @@ class LocalDevManager {
|
|
|
138
138
|
({ sourceId }) => sourceId === this.activeApp.config.uid
|
|
139
139
|
);
|
|
140
140
|
|
|
141
|
+
// TODO: Update to account for new API with { data }
|
|
141
142
|
const {
|
|
142
|
-
|
|
143
|
-
} = await
|
|
143
|
+
uniquePortalInstallCount,
|
|
144
|
+
} = await fetchPublicAppProductionInstallCounts(
|
|
144
145
|
activePublicAppData.id,
|
|
145
146
|
this.targetProjectAccountId
|
|
146
147
|
);
|
|
147
148
|
|
|
148
149
|
this.activePublicAppData = activePublicAppData;
|
|
149
|
-
this.publicAppActiveInstalls =
|
|
150
|
-
activePublicAppData.publicApplicationInstallCounts
|
|
151
|
-
.uniquePortalInstallCount - testPortalInstallCount;
|
|
150
|
+
this.publicAppActiveInstalls = uniquePortalInstallCount;
|
|
152
151
|
}
|
|
153
152
|
|
|
154
153
|
async checkActivePublicAppInstalls() {
|
|
@@ -298,16 +297,20 @@ class LocalDevManager {
|
|
|
298
297
|
|
|
299
298
|
async checkPublicAppInstallation() {
|
|
300
299
|
const {
|
|
301
|
-
isInstalledWithScopeGroups
|
|
300
|
+
isInstalledWithScopeGroups,
|
|
301
|
+
previouslyAuthorizedScopeGroups,
|
|
302
302
|
} = await this.getActiveAppInstallationData();
|
|
303
303
|
|
|
304
|
-
|
|
304
|
+
const isReinstall = previouslyAuthorizedScopeGroups.length > 0;
|
|
305
|
+
|
|
306
|
+
if (!isInstalledWithScopeGroups) {
|
|
305
307
|
await installPublicAppPrompt(
|
|
306
308
|
this.env,
|
|
307
309
|
this.targetAccountId,
|
|
308
310
|
this.activePublicAppData.clientId,
|
|
309
311
|
this.activeApp.config.auth.requiredScopes,
|
|
310
|
-
this.activeApp.config.auth.redirectUrls
|
|
312
|
+
this.activeApp.config.auth.redirectUrls,
|
|
313
|
+
isReinstall
|
|
311
314
|
);
|
|
312
315
|
}
|
|
313
316
|
}
|
package/lib/constants.js
CHANGED
|
@@ -25,6 +25,7 @@ const POLLING_DELAY = 2000;
|
|
|
25
25
|
const POLLING_STATUS = {
|
|
26
26
|
SUCCESS: 'SUCCESS',
|
|
27
27
|
ERROR: 'ERROR',
|
|
28
|
+
REVERTED: 'REVERTED',
|
|
28
29
|
FAILURE: 'FAILURE',
|
|
29
30
|
};
|
|
30
31
|
|
|
@@ -65,8 +66,9 @@ const PROJECT_ERROR_TYPES = {
|
|
|
65
66
|
};
|
|
66
67
|
const PROJECT_TASK_TYPES = {
|
|
67
68
|
PRIVATE_APP: 'private app',
|
|
69
|
+
PUBLIC_APP: 'public app',
|
|
68
70
|
APP_FUNCTION: 'function',
|
|
69
|
-
CRM_CARD_V2: '
|
|
71
|
+
CRM_CARD_V2: 'card',
|
|
70
72
|
};
|
|
71
73
|
const PROJECT_COMPONENT_TYPES = {
|
|
72
74
|
PROJECTS: 'projects',
|
package/lib/localDev.js
CHANGED
|
@@ -192,8 +192,7 @@ const createSandboxForLocalDev = async (accountId, accountConfig, env) => {
|
|
|
192
192
|
parentAccountConfig: accountConfig,
|
|
193
193
|
env,
|
|
194
194
|
syncTasks,
|
|
195
|
-
|
|
196
|
-
skipPolling: true, // Skip polling, sync will run and complete in the background
|
|
195
|
+
slimInfoMessage: true,
|
|
197
196
|
});
|
|
198
197
|
return targetAccountId;
|
|
199
198
|
} catch (err) {
|
package/lib/polling.js
CHANGED
|
@@ -3,18 +3,24 @@ const { POLLING_DELAY, POLLING_STATUS } = require('./constants');
|
|
|
3
3
|
const poll = (callback, accountId, taskId) => {
|
|
4
4
|
return new Promise((resolve, reject) => {
|
|
5
5
|
const pollInterval = setInterval(async () => {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
try {
|
|
7
|
+
const pollResp = await callback(accountId, taskId);
|
|
8
|
+
const { status } = pollResp;
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
if (status === POLLING_STATUS.SUCCESS) {
|
|
11
|
+
clearInterval(pollInterval);
|
|
12
|
+
resolve(pollResp);
|
|
13
|
+
} else if (
|
|
14
|
+
status === POLLING_STATUS.ERROR ||
|
|
15
|
+
status === POLLING_STATUS.REVERTED ||
|
|
16
|
+
status === POLLING_STATUS.FAILURE
|
|
17
|
+
) {
|
|
18
|
+
clearInterval(pollInterval);
|
|
19
|
+
reject(pollResp);
|
|
20
|
+
}
|
|
21
|
+
} catch (error) {
|
|
10
22
|
clearInterval(pollInterval);
|
|
11
|
-
|
|
12
|
-
} else if (
|
|
13
|
-
status === POLLING_STATUS.ERROR ||
|
|
14
|
-
status === POLLING_STATUS.FAILURE
|
|
15
|
-
) {
|
|
16
|
-
clearInterval(pollInterval);
|
|
17
|
-
reject(pollResp);
|
|
23
|
+
reject(error);
|
|
18
24
|
}
|
|
19
25
|
}, POLLING_DELAY);
|
|
20
26
|
});
|