@kineticdata/react 6.0.5 → 6.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +110 -110
  2. package/assets/task/icons/defer.svg +12 -12
  3. package/assets/task/icons/drag-handle.svg +3 -3
  4. package/assets/task/icons/filter.svg +11 -11
  5. package/assets/task/icons/loop.svg +10 -10
  6. package/assets/task/icons/plus_small.svg +5 -5
  7. package/assets/task/icons/routine.svg +9 -9
  8. package/assets/task/icons/scale-minus.svg +11 -11
  9. package/assets/task/icons/scale-plus.svg +13 -13
  10. package/assets/task/icons/start.svg +11 -11
  11. package/assets/task/icons/stop.svg +8 -8
  12. package/lib/apis/core/activity.js +4 -4
  13. package/lib/apis/core/attributeDefinitions.js +64 -6
  14. package/lib/apis/core/attributeDefinitions.test.js +7 -4
  15. package/lib/apis/core/authentication.js +12 -1
  16. package/lib/apis/core/bridgeModels.test.js +46 -23
  17. package/lib/apis/core/bridgedresources.js +41 -41
  18. package/lib/apis/core/fileResources.js +2 -6
  19. package/lib/apis/core/forms.js +51 -2
  20. package/lib/apis/core/forms.test.js +32 -19
  21. package/lib/apis/core/integrations.js +61 -0
  22. package/lib/apis/core/kapps.js +49 -0
  23. package/lib/apis/core/kapps.test.js +16 -10
  24. package/lib/apis/core/notices.js +7 -0
  25. package/lib/apis/core/securityPolicyDefinitions.test.js +7 -4
  26. package/lib/apis/core/space.js +18 -0
  27. package/lib/apis/core/space.test.js +16 -10
  28. package/lib/apis/core/submissionActivities.js +38 -0
  29. package/lib/apis/core/submissions.js +114 -15
  30. package/lib/apis/core/translations.test.js +126 -55
  31. package/lib/apis/core/userPreferences.js +59 -0
  32. package/lib/apis/core/webApis.js +32 -2
  33. package/lib/apis/core/webhooks.test.js +7 -4
  34. package/lib/apis/http.js +30 -5
  35. package/lib/apis/index.js +48 -0
  36. package/lib/apis/integrator/index.js +337 -0
  37. package/lib/apis/system/index.js +64 -12
  38. package/lib/apis/task/index.js +9 -2
  39. package/lib/components/agent/filestore/FilestoreForm.js +1 -1
  40. package/lib/components/common/AttributeSelect.js +11 -2
  41. package/lib/components/common/BridgeSelect.js +3 -1
  42. package/lib/components/common/ConnectionSelect.js +73 -0
  43. package/lib/components/common/FormSelect.js +3 -1
  44. package/lib/components/common/NodeSelect.js +1 -0
  45. package/lib/components/common/StaticSelect.js +16 -6
  46. package/lib/components/common/TableInput.js +4 -1
  47. package/lib/components/common/TeamSelect.js +3 -1
  48. package/lib/components/common/ToastContainer.js +34 -10
  49. package/lib/components/common/Typeahead.js +62 -23
  50. package/lib/components/common/UserSelect.js +3 -1
  51. package/lib/components/common/authentication/AuthenticationContainer.js +121 -55
  52. package/lib/components/common/authentication/RequestInterceptor.js +1 -1
  53. package/lib/components/common/preferences/PreferencesProvider.js +461 -0
  54. package/lib/components/core/attribute_definition/AttributeDefinitionForm.js +10 -7
  55. package/lib/components/core/bridge_model/BridgeModelTable.js +19 -0
  56. package/lib/components/core/bridge_model_attribute/BridgeModelAttributeForm.js +6 -9
  57. package/lib/components/core/bridge_model_attribute/BridgeModelAttributeTable.js +0 -4
  58. package/lib/components/core/bridge_model_qualification/BridgeModelQualificationForm.js +7 -10
  59. package/lib/components/core/bridge_model_qualification/BridgeModelQualificationTable.js +2 -15
  60. package/lib/components/core/category/CategoryForm.js +4 -1
  61. package/lib/components/core/category/CategoryTable.js +2 -2
  62. package/lib/components/core/core_form/CoreForm.js +18 -10
  63. package/lib/components/core/field_definition/FieldDefinitionForm.js +3 -3
  64. package/lib/components/core/file_resource/FileResourceForm.js +2 -1
  65. package/lib/components/core/file_resource/FileResourceTable.js +14 -7
  66. package/lib/components/core/form/FormForm.js +42 -19
  67. package/lib/components/core/form/FormTable.js +13 -14
  68. package/lib/components/core/form_type/FormTypeForm.js +3 -0
  69. package/lib/components/core/i18n/Moment.js +1 -0
  70. package/lib/components/core/integration/IntegrationForm.js +232 -0
  71. package/lib/components/core/integration/IntegrationTable.js +142 -0
  72. package/lib/components/core/kapp/KappForm.js +18 -5
  73. package/lib/components/core/kapp/KappTable.js +3 -3
  74. package/lib/components/core/log/LogTable.js +1 -1
  75. package/lib/components/core/security_definition/SecurityDefinitionForm.js +48 -10
  76. package/lib/components/core/space/SpaceForm.js +17 -36
  77. package/lib/components/core/submission/DatastoreSubmissionTable.js +4 -4
  78. package/lib/components/core/submission/FormSubmissionTable.js +12 -7
  79. package/lib/components/core/submission/KappSubmissionTable.js +4 -4
  80. package/lib/components/core/submission/SubmissionActivityForm.js +79 -0
  81. package/lib/components/core/submission/SubmissionForm.js +15 -3
  82. package/lib/components/core/team/TeamTable.js +17 -7
  83. package/lib/components/core/translation/EntryTable.js +8 -7
  84. package/lib/components/core/user/UserForm.js +2 -0
  85. package/lib/components/core/user/UserTable.js +22 -22
  86. package/lib/components/core/webapi/WebApiForm.js +5 -2
  87. package/lib/components/core/webapi/WebApiTable.js +2 -2
  88. package/lib/components/core/webhook/WebhookForm.js +43 -33
  89. package/lib/components/core/webhook/WebhookTable.js +16 -16
  90. package/lib/components/core/webhook_job/WebhookJobTable.js +17 -6
  91. package/lib/components/form/Form.helpers.js +10 -4
  92. package/lib/components/form/Form.js +264 -171
  93. package/lib/components/form/Form.models.js +6 -1
  94. package/lib/components/form/FormState.js +9 -5
  95. package/lib/components/form/SimpleForm.js +2 -2
  96. package/lib/components/form/defaults/CodeField.js +44 -1
  97. package/lib/components/index.js +152 -3
  98. package/lib/components/integrator/connection/ConnectionForm.js +156 -0
  99. package/lib/components/integrator/connection/ConnectionTable.js +82 -0
  100. package/lib/components/integrator/connection/config_fields/http.js +570 -0
  101. package/lib/components/integrator/connection/config_fields/sql.js +123 -0
  102. package/lib/components/integrator/integrationTypes.js +120 -0
  103. package/lib/components/integrator/operation/OperationForm.js +148 -0
  104. package/lib/components/integrator/operation/OperationTable.js +62 -0
  105. package/lib/components/integrator/operation/config_fields/http.js +185 -0
  106. package/lib/components/integrator/operation/config_fields/sql.js +81 -0
  107. package/lib/components/system/SystemSecurityForm.js +1 -1
  108. package/lib/components/system/SystemTaskAdapterForm.js +9 -9
  109. package/lib/components/system/SystemUserForm.js +2 -0
  110. package/lib/components/system/helpers.js +123 -100
  111. package/lib/components/system/spaces/SystemSpaceForm.js +9 -37
  112. package/lib/components/system/spaces/SystemTenantForm.js +276 -104
  113. package/lib/components/system/spaces/SystemTenantMigrateForm.js +449 -0
  114. package/lib/components/system/spaces/SystemTenantTable.js +20 -16
  115. package/lib/components/table/Table.js +75 -15
  116. package/lib/components/table/Table.redux.js +297 -73
  117. package/lib/components/table/defaults/FilterControl.js +24 -0
  118. package/lib/components/table/defaults/index.js +2 -0
  119. package/lib/components/table/tests/Table.test.js +22 -22
  120. package/lib/components/table/tests/components.js +9 -2
  121. package/lib/components/task/builder/Connector.js +51 -41
  122. package/lib/components/task/builder/ConnectorForm.js +11 -7
  123. package/lib/components/task/builder/Node.js +31 -35
  124. package/lib/components/task/builder/NodeForm.js +93 -22
  125. package/lib/components/task/builder/NodeParametersForm.js +29 -17
  126. package/lib/components/task/builder/SvgCanvas.js +3 -17
  127. package/lib/components/task/builder/TaskDefinitionConfigForm.js +18 -50
  128. package/lib/components/task/builder/TreeBuilder.js +23 -3
  129. package/lib/components/task/builder/builder.redux.js +342 -197
  130. package/lib/components/task/builder/constants.js +10 -2
  131. package/lib/components/task/builder/helpers.js +231 -81
  132. package/lib/components/task/builder/models.js +7 -6
  133. package/lib/components/task/category/TaskCategoryTable.js +3 -3
  134. package/lib/components/task/common/UsageTable.js +9 -2
  135. package/lib/components/task/handlers/HandlerTable.js +44 -37
  136. package/lib/components/task/policy_rule/PolicyRuleTable.js +3 -3
  137. package/lib/components/task/runs/CreateManualTriggerForm.js +2 -0
  138. package/lib/components/task/runs/RunTable.js +10 -14
  139. package/lib/components/task/runs/RunTaskTable.js +1 -1
  140. package/lib/components/task/sources/SourceTable.js +2 -2
  141. package/lib/components/task/triggers/TriggerTable.js +2 -2
  142. package/lib/components/task/workflows/LinkedWorkflowTable.js +16 -11
  143. package/lib/components/task/workflows/WorkflowForm.js +27 -8
  144. package/lib/components/task/workflows/WorkflowTable.js +27 -26
  145. package/lib/helpers/index.js +307 -74
  146. package/lib/index.js +2 -1
  147. package/lib/saga.js +4 -4
  148. package/lib/store.js +2 -1
  149. package/package.json +7 -6
  150. package/proxyhelper.js +201 -176
  151. package/CHANGELOG.md +0 -94
@@ -4,7 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/regeneratorRuntime"));
5
5
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
6
6
  var _axios = _interopRequireDefault(require("axios"));
7
- var _createError = _interopRequireDefault(require("axios/lib/core/createError"));
8
7
  var _securityPolicyDefinitions = require("./securityPolicyDefinitions");
9
8
  jest.mock('axios');
10
9
 
@@ -160,9 +159,13 @@ describe('securityPolicyDefinitions api', function () {
160
159
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee3$(_context3) {
161
160
  while (1) switch (_context3.prev = _context3.next) {
162
161
  case 0:
163
- _axios["default"].get.mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
164
- status: 403,
165
- statusText: 'Forbidden'
162
+ _axios["default"].get.mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
163
+ name: 'AxiosError',
164
+ isAxiosError: true,
165
+ response: {
166
+ status: 403,
167
+ statusText: 'Forbidden'
168
+ }
166
169
  }));
167
170
  _context3.next = 3;
168
171
  return (0, _securityPolicyDefinitions.fetchSecurityPolicyDefinitions)();
@@ -8,6 +8,14 @@ exports.updateSpace = exports.fetchSpace = void 0;
8
8
  var _axios = _interopRequireDefault(require("axios"));
9
9
  var _helpers = require("../../helpers");
10
10
  var _http = require("../http");
11
+ /**
12
+ * Fetches the current space or a specific space by slug.
13
+ *
14
+ * @param {Object} options - Options for fetching the space.
15
+ * @param {string} [options.slug] - The space slug to retrieve, defaults to the bundle kapp slug.
16
+ * @returns {Promise<{space: Object}>} Resolves with the fetched space object.
17
+ */
18
+
11
19
  var fetchSpace = exports.fetchSpace = function fetchSpace() {
12
20
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
13
21
  // Build URL and fetch the space.
@@ -20,6 +28,16 @@ var fetchSpace = exports.fetchSpace = function fetchSpace() {
20
28
  };
21
29
  })["catch"](_http.handleErrors);
22
30
  };
31
+
32
+ /**
33
+ * Updates a space with the provided space object.
34
+ *
35
+ * @param {Object} options - Options for updating the space.
36
+ * @param {Object} options.space - The space object containing updated values.
37
+ * @param {string} [options.slug] - The space slug to retrieve, defaults to the bundle kapp slug.
38
+ * @returns {Promise<{space: Object}>}
39
+ */
40
+
23
41
  var updateSpace = exports.updateSpace = function updateSpace() {
24
42
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
25
43
  var space = options.space;
@@ -4,7 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/regeneratorRuntime"));
5
5
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
6
6
  var _axios = _interopRequireDefault(require("axios"));
7
- var _createError = _interopRequireDefault(require("axios/lib/core/createError"));
8
7
  var _space = require("./space");
9
8
  jest.mock('axios');
10
9
  describe('space api', function () {
@@ -155,11 +154,15 @@ describe('space api', function () {
155
154
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee3$(_context3) {
156
155
  while (1) switch (_context3.prev = _context3.next) {
157
156
  case 0:
158
- _axios["default"].put.mockRejectedValue((0, _createError["default"])('Request failed with status code 400', null, 400, null, {
159
- status: 400,
160
- statusText: 'Bad Request',
161
- data: {
162
- error: 'Invalid space'
157
+ _axios["default"].put.mockRejectedValue(Object.assign(new Error('Request failed with status code 400'), {
158
+ name: 'AxiosError',
159
+ isAxiosError: true,
160
+ response: {
161
+ status: 400,
162
+ statusText: 'Bad Request',
163
+ data: {
164
+ error: 'Invalid space'
165
+ }
163
166
  }
164
167
  }));
165
168
  _context3.next = 3;
@@ -190,10 +193,13 @@ describe('space api', function () {
190
193
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee4$(_context4) {
191
194
  while (1) switch (_context4.prev = _context4.next) {
192
195
  case 0:
193
- _axios["default"].put.mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
194
- status: 403,
195
- statusText: 'Forbidden',
196
- data: {}
196
+ _axios["default"].put.mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
197
+ name: 'AxiosError',
198
+ isAxiosError: true,
199
+ response: {
200
+ status: 403,
201
+ statusText: 'Forbidden'
202
+ }
197
203
  }));
198
204
  _context4.next = 3;
199
205
  return (0, _space.updateSpace)({
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.updateSubmissionActivity = exports.fetchSubmissionActivity = exports.fetchSubmissionActivities = exports.deleteSubmissionActivity = exports.createSubmissionActivity = void 0;
7
+ var _http = require("../http");
8
+ var _apiGroup = (0, _http.apiGroup)({
9
+ name: 'SubmissionActivity',
10
+ pluralName: 'SubmissionActivities',
11
+ dataOption: 'activity',
12
+ plural: {
13
+ requiredOptions: ['submissionId'],
14
+ url: function url(_ref) {
15
+ var submissionId = _ref.submissionId;
16
+ return "/submissions/".concat(submissionId, "/activities");
17
+ },
18
+ transform: function transform(response) {
19
+ return response.data;
20
+ }
21
+ },
22
+ singular: {
23
+ requiredOptions: ['submissionId', 'activityId'],
24
+ url: function url(_ref2) {
25
+ var submissionId = _ref2.submissionId,
26
+ activityId = _ref2.activityId;
27
+ return "/submissions/".concat(submissionId, "/activities/").concat(activityId);
28
+ },
29
+ transform: function transform(response) {
30
+ return response.data;
31
+ }
32
+ }
33
+ }),
34
+ fetchSubmissionActivities = exports.fetchSubmissionActivities = _apiGroup.fetchSubmissionActivities,
35
+ fetchSubmissionActivity = exports.fetchSubmissionActivity = _apiGroup.fetchSubmissionActivity,
36
+ createSubmissionActivity = exports.createSubmissionActivity = _apiGroup.createSubmissionActivity,
37
+ updateSubmissionActivity = exports.updateSubmissionActivity = _apiGroup.updateSubmissionActivity,
38
+ deleteSubmissionActivity = exports.deleteSubmissionActivity = _apiGroup.deleteSubmissionActivity;
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.updateSubmission = exports.submitSubmission = exports.searchSubmissions = exports.saveSubmissionMultipart = exports.importSubmissions = exports.importSubmissionStatus = exports.fetchSubmission = exports.exportSubmissions = exports.deleteSubmission = exports.createSubmission = exports.VALID_TIMELINES = exports.VALID_KAPP_CORE_STATES = exports.VALID_DS_CORE_STATES = exports.SubmissionSearch = exports.MODE_IMPORT = exports.MODE_BULK = void 0;
7
+ exports.updateSubmission = exports.submitSubmission = exports.searchSubmissions = exports.saveSubmissionMultipart = exports.importSubmissions = exports.importSubmissionStatus = exports.fetchSubmission = exports.exportSubmissions = exports.deleteSubmission = exports.createSubmission = exports.cloneSubmission = exports.VALID_TIMELINES = exports.VALID_KAPP_CORE_STATES = exports.VALID_DS_CORE_STATES = exports.SubmissionSearch = exports.MODE_IMPORT = exports.MODE_BULK = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
9
9
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/classCallCheck"));
@@ -40,8 +40,8 @@ var SubmissionSearch = exports.SubmissionSearch = /*#__PURE__*/function () {
40
40
  this.isDatastore = datastore;
41
41
  }
42
42
 
43
- /*
44
- * Context Management
43
+ /*
44
+ * Context Management
45
45
  */
46
46
  (0, _createClass2["default"])(SubmissionSearch, [{
47
47
  key: "currentContext",
@@ -59,8 +59,8 @@ var SubmissionSearch = exports.SubmissionSearch = /*#__PURE__*/function () {
59
59
  return this.queryContext.pop();
60
60
  }
61
61
 
62
- /*
63
- * Execution Methods
62
+ /*
63
+ * Execution Methods
64
64
  */
65
65
  }, {
66
66
  key: "build",
@@ -81,8 +81,8 @@ var SubmissionSearch = exports.SubmissionSearch = /*#__PURE__*/function () {
81
81
  return this.query;
82
82
  }
83
83
 
84
- /*
85
- * Equality Methods
84
+ /*
85
+ * Equality Methods
86
86
  */
87
87
  }, {
88
88
  key: "eq",
@@ -172,8 +172,8 @@ var SubmissionSearch = exports.SubmissionSearch = /*#__PURE__*/function () {
172
172
  return this;
173
173
  }
174
174
 
175
- /*
176
- * Grouping Methods
175
+ /*
176
+ * Grouping Methods
177
177
  */
178
178
  }, {
179
179
  key: "or",
@@ -205,8 +205,8 @@ var SubmissionSearch = exports.SubmissionSearch = /*#__PURE__*/function () {
205
205
  return this;
206
206
  }
207
207
 
208
- /*
209
- * Sorting Methods
208
+ /*
209
+ * Sorting Methods
210
210
  */
211
211
  }, {
212
212
  key: "sortBy",
@@ -305,8 +305,8 @@ var SubmissionSearch = exports.SubmissionSearch = /*#__PURE__*/function () {
305
305
  return this;
306
306
  }
307
307
 
308
- /*
309
- * Privately used utilities.
308
+ /*
309
+ * Privately used utilities.
310
310
  */
311
311
  }, {
312
312
  key: "validateOuter",
@@ -436,6 +436,19 @@ var searchSubmissions = exports.searchSubmissions = function searchSubmissions(o
436
436
  promise = promise["catch"](_http.handleErrors);
437
437
  return promise;
438
438
  };
439
+
440
+ /**
441
+ * Fetches a submission by ID.
442
+ *
443
+ * @param {Object} options - Options for the fetch.
444
+ * @param {string} options.id - The ID of the submission to fetch.
445
+ * @param {boolean} [options.datastore] - Whether to fetch from the datastore API.
446
+ * @param {Object} [options.params] - Additional query parameters to include.
447
+ * @param {Object} [options.headers] - Additional headers to include.
448
+ *
449
+ * @returns {Promise<{submission: Object}>}
450
+ */
451
+
439
452
  var fetchSubmission = exports.fetchSubmission = function fetchSubmission(options) {
440
453
  var id = options.id;
441
454
  if (!id) {
@@ -456,6 +469,21 @@ var fetchSubmission = exports.fetchSubmission = function fetchSubmission(options
456
469
  // cleans up any errors.
457
470
  ["catch"](_http.handleErrors);
458
471
  };
472
+
473
+ /**
474
+ * Creates a new submission for the specified form in either a kapp or the datastore.
475
+ *
476
+ * @param {Object} options - Options for creating the submission.
477
+ * @param {string} [options.kappSlug] - The slug of the kapp. Defaults to bundle.kappSlug().
478
+ * @param {string} options.formSlug - The slug of the form to submit to.
479
+ * @param {Object} options.values - The values to submit.
480
+ * @param {boolean} [options.completed=true] - Whether the submission should be marked completed.
481
+ * @param {string} [options.coreState] - The core state of the submission.
482
+ * @param {string} [options.parent] - The ID of the parent submission, if applicable.
483
+ *
484
+ * @returns {Promise<{submission: Object}>}
485
+ */
486
+
459
487
  var createSubmission = exports.createSubmission = function createSubmission(options) {
460
488
  var _options$kappSlug = options.kappSlug,
461
489
  kappSlug = _options$kappSlug === void 0 ? _helpers.bundle.kappSlug() : _options$kappSlug,
@@ -492,6 +520,66 @@ var createSubmission = exports.createSubmission = function createSubmission(opti
492
520
  // cleans up any errors.
493
521
  ["catch"](_http.handleErrors);
494
522
  };
523
+
524
+ /**
525
+ * Clones an existing submission by ID.
526
+ *
527
+ * @param {Object} options - Options for cloning the submission.
528
+ * @param {string} options.id - The ID of the submission to clone.
529
+ * @param {boolean} [options.completed=false] - Whether the cloned submission should be marked as completed.
530
+ * @param {Object} [options.submission={}] - Optional values to override in the cloned submission.
531
+ * @returns {Promise<{submission: Object}>}
532
+ */
533
+
534
+ var cloneSubmission = exports.cloneSubmission = function cloneSubmission(options) {
535
+ var id = options.id,
536
+ _options$completed2 = options.completed,
537
+ completed = _options$completed2 === void 0 ? false : _options$completed2,
538
+ _options$submission = options.submission,
539
+ submission = _options$submission === void 0 ? {} : _options$submission,
540
+ _options$files = options.files,
541
+ files = _options$files === void 0 ? [] : _options$files;
542
+ if (!id) {
543
+ throw new Error('cloneSubmission failed! The option "id" is required.');
544
+ }
545
+ var path = "".concat(_helpers.bundle.apiLocation(), "/submissions/").concat(id, "/clone");
546
+ var params = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, (0, _http.paramBuilder)(options)), {}, {
547
+ completed: completed
548
+ });
549
+ var formData = new FormData();
550
+ formData.append('submission', JSON.stringify(submission));
551
+ files.forEach(function (_ref) {
552
+ var fieldName = _ref.fieldName,
553
+ file = _ref.file,
554
+ filename = _ref.filename;
555
+ formData.append(fieldName, file, filename);
556
+ });
557
+ return _axios["default"].post(path, formData, {
558
+ params: params,
559
+ headers: (0, _http.headerBuilder)(options)
560
+ })
561
+ // Remove the response envelop and leave us with the submission one.
562
+ .then(function (response) {
563
+ return {
564
+ submission: response.data.submission
565
+ };
566
+ })
567
+ // Clean up any errors we receive. Make sure this the last thing so that it
568
+ // cleans up any errors.
569
+ ["catch"](_http.handleErrors);
570
+ };
571
+
572
+ /**
573
+ * Updates an existing submission in either a kapp or the datastore.
574
+ *
575
+ * @param {Object} options - Options for updating the submission.
576
+ * @param {string} options.id - The ID of the submission to update.
577
+ * @param {Object} options.values - The values to update on the submission.
578
+ * @param {boolean} [options.datastore] - Whether the submission is in the datastore.
579
+ *
580
+ * @returns {Promise<{submission: Object}>}
581
+ */
582
+
495
583
  var updateSubmission = exports.updateSubmission = function updateSubmission(options) {
496
584
  var id = options.id,
497
585
  values = options.values;
@@ -521,8 +609,8 @@ var saveSubmissionMultipart = exports.saveSubmissionMultipart = function saveSub
521
609
  files = options.files,
522
610
  coreState = options.coreState,
523
611
  parent = options.parent,
524
- _options$completed2 = options.completed,
525
- completed = _options$completed2 === void 0 ? !id : _options$completed2;
612
+ _options$completed3 = options.completed,
613
+ completed = _options$completed3 === void 0 ? !id : _options$completed3;
526
614
 
527
615
  // Determine whether we should use the create or update endpoint based on the
528
616
  // options provided (the rest of the HTTP request behaves the same way
@@ -585,6 +673,17 @@ var submitSubmission = exports.submitSubmission = function submitSubmission(opti
585
673
  // cleans up any errors.
586
674
  ["catch"](_http.handleErrors);
587
675
  };
676
+
677
+ /**
678
+ * Deletes an existing submission from either a kapp or the datastore.
679
+ *
680
+ * @param {Object} options - Options for deleting the submission.
681
+ * @param {string} options.id - The ID of the submission to delete.
682
+ * @param {boolean} [options.datastore] - Whether the submission is in the datastore.
683
+ *
684
+ * @returns {Promise<{submission: Object}>}
685
+ */
686
+
588
687
  var deleteSubmission = exports.deleteSubmission = function deleteSubmission(options) {
589
688
  var id = options.id;
590
689
  if (!id) {
@@ -4,7 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/regeneratorRuntime"));
5
5
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
6
6
  var _axios = _interopRequireDefault(require("axios"));
7
- var _createError = _interopRequireDefault(require("axios/lib/core/createError"));
8
7
  var _translations = require("./translations");
9
8
  jest.mock('axios');
10
9
 
@@ -92,9 +91,13 @@ describe('translations api', function () {
92
91
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee3$(_context3) {
93
92
  while (1) switch (_context3.prev = _context3.next) {
94
93
  case 0:
95
- _axios["default"].get.mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
96
- status: 403,
97
- statusText: 'Forbidden'
94
+ _axios["default"].get.mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
95
+ name: 'AxiosError',
96
+ isAxiosError: true,
97
+ response: {
98
+ status: 403,
99
+ statusText: 'Forbidden'
100
+ }
98
101
  }));
99
102
  _context3.next = 3;
100
103
  return (0, _translations.fetchAvailableLocales)();
@@ -160,9 +163,13 @@ describe('translations api', function () {
160
163
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee5$(_context5) {
161
164
  while (1) switch (_context5.prev = _context5.next) {
162
165
  case 0:
163
- _axios["default"]["delete"].mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
164
- status: 403,
165
- statusText: 'Forbidden'
166
+ _axios["default"]["delete"].mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
167
+ name: 'AxiosError',
168
+ isAxiosError: true,
169
+ response: {
170
+ status: 403,
171
+ statusText: 'Forbidden'
172
+ }
166
173
  }));
167
174
  _context5.next = 3;
168
175
  return (0, _translations.clearTranslationsCache)();
@@ -262,9 +269,13 @@ describe('translations api', function () {
262
269
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee8$(_context8) {
263
270
  while (1) switch (_context8.prev = _context8.next) {
264
271
  case 0:
265
- _axios["default"].get.mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
266
- status: 403,
267
- statusText: 'Forbidden'
272
+ _axios["default"].get.mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
273
+ name: 'AxiosError',
274
+ isAxiosError: true,
275
+ response: {
276
+ status: 403,
277
+ statusText: 'Forbidden'
278
+ }
268
279
  }));
269
280
  _context8.next = 3;
270
281
  return (0, _translations.fetchStagedTranslations)();
@@ -334,9 +345,13 @@ describe('translations api', function () {
334
345
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee10$(_context10) {
335
346
  while (1) switch (_context10.prev = _context10.next) {
336
347
  case 0:
337
- _axios["default"].get.mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
338
- status: 403,
339
- statusText: 'Forbidden'
348
+ _axios["default"].get.mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
349
+ name: 'AxiosError',
350
+ isAxiosError: true,
351
+ response: {
352
+ status: 403,
353
+ statusText: 'Forbidden'
354
+ }
340
355
  }));
341
356
  _context10.next = 3;
342
357
  return (0, _translations.fetchDefaultLocale)();
@@ -415,9 +430,13 @@ describe('translations api', function () {
415
430
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee12$(_context12) {
416
431
  while (1) switch (_context12.prev = _context12.next) {
417
432
  case 0:
418
- _axios["default"].put.mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
419
- status: 403,
420
- statusText: 'Forbidden'
433
+ _axios["default"].put.mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
434
+ name: 'AxiosError',
435
+ isAxiosError: true,
436
+ response: {
437
+ status: 403,
438
+ statusText: 'Forbidden'
439
+ }
421
440
  }));
422
441
  _context12.next = 3;
423
442
  return (0, _translations.setDefaultLocale)({
@@ -487,9 +506,13 @@ describe('translations api', function () {
487
506
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee14$(_context14) {
488
507
  while (1) switch (_context14.prev = _context14.next) {
489
508
  case 0:
490
- _axios["default"].get.mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
491
- status: 403,
492
- statusText: 'Forbidden'
509
+ _axios["default"].get.mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
510
+ name: 'AxiosError',
511
+ isAxiosError: true,
512
+ response: {
513
+ status: 403,
514
+ statusText: 'Forbidden'
515
+ }
493
516
  }));
494
517
  _context14.next = 3;
495
518
  return (0, _translations.fetchEnabledLocales)();
@@ -568,9 +591,13 @@ describe('translations api', function () {
568
591
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee16$(_context16) {
569
592
  while (1) switch (_context16.prev = _context16.next) {
570
593
  case 0:
571
- _axios["default"].post.mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
572
- status: 403,
573
- statusText: 'Forbidden'
594
+ _axios["default"].post.mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
595
+ name: 'AxiosError',
596
+ isAxiosError: true,
597
+ response: {
598
+ status: 403,
599
+ statusText: 'Forbidden'
600
+ }
574
601
  }));
575
602
  _context16.next = 3;
576
603
  return (0, _translations.enableLocale)({
@@ -651,9 +678,13 @@ describe('translations api', function () {
651
678
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee18$(_context18) {
652
679
  while (1) switch (_context18.prev = _context18.next) {
653
680
  case 0:
654
- _axios["default"]["delete"].mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
655
- status: 403,
656
- statusText: 'Forbidden'
681
+ _axios["default"]["delete"].mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
682
+ name: 'AxiosError',
683
+ isAxiosError: true,
684
+ response: {
685
+ status: 403,
686
+ statusText: 'Forbidden'
687
+ }
657
688
  }));
658
689
  _context18.next = 3;
659
690
  return (0, _translations.disableLocale)({
@@ -823,9 +854,13 @@ describe('translations api', function () {
823
854
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee22$(_context22) {
824
855
  while (1) switch (_context22.prev = _context22.next) {
825
856
  case 0:
826
- _axios["default"].get.mockRejectedValue((0, _createError["default"])('Request failed with status code 400', null, 400, null, {
827
- status: 400,
828
- statusText: 'The custom, expected, and unexpected flags can only be specified independently.'
857
+ _axios["default"].get.mockRejectedValue(Object.assign(new Error('Request failed with status code 400'), {
858
+ name: 'AxiosError',
859
+ isAxiosError: true,
860
+ response: {
861
+ status: 400,
862
+ statusText: 'The custom, expected, and unexpected flags can only be specified independently.'
863
+ }
829
864
  }));
830
865
  _context22.next = 3;
831
866
  return (0, _translations.fetchContexts)({
@@ -861,9 +896,13 @@ describe('translations api', function () {
861
896
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee23$(_context23) {
862
897
  while (1) switch (_context23.prev = _context23.next) {
863
898
  case 0:
864
- _axios["default"].get.mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
865
- status: 403,
866
- statusText: 'Forbidden'
899
+ _axios["default"].get.mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
900
+ name: 'AxiosError',
901
+ isAxiosError: true,
902
+ response: {
903
+ status: 403,
904
+ statusText: 'Forbidden'
905
+ }
867
906
  }));
868
907
  _context23.next = 3;
869
908
  return (0, _translations.fetchContexts)();
@@ -940,9 +979,13 @@ describe('translations api', function () {
940
979
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee25$(_context25) {
941
980
  while (1) switch (_context25.prev = _context25.next) {
942
981
  case 0:
943
- _axios["default"].post.mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
944
- status: 403,
945
- statusText: 'Forbidden'
982
+ _axios["default"].post.mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
983
+ name: 'AxiosError',
984
+ isAxiosError: true,
985
+ response: {
986
+ status: 403,
987
+ statusText: 'Forbidden'
988
+ }
946
989
  }));
947
990
  _context25.next = 3;
948
991
  return (0, _translations.createContext)({
@@ -1031,9 +1074,13 @@ describe('translations api', function () {
1031
1074
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee27$(_context27) {
1032
1075
  while (1) switch (_context27.prev = _context27.next) {
1033
1076
  case 0:
1034
- _axios["default"].put.mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
1035
- status: 403,
1036
- statusText: 'Forbidden'
1077
+ _axios["default"].put.mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
1078
+ name: 'AxiosError',
1079
+ isAxiosError: true,
1080
+ response: {
1081
+ status: 403,
1082
+ statusText: 'Forbidden'
1083
+ }
1037
1084
  }));
1038
1085
  _context27.next = 3;
1039
1086
  return (0, _translations.updateContext)({
@@ -1109,9 +1156,13 @@ describe('translations api', function () {
1109
1156
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee29$(_context29) {
1110
1157
  while (1) switch (_context29.prev = _context29.next) {
1111
1158
  case 0:
1112
- _axios["default"]["delete"].mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
1113
- status: 403,
1114
- statusText: 'Forbidden'
1159
+ _axios["default"]["delete"].mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
1160
+ name: 'AxiosError',
1161
+ isAxiosError: true,
1162
+ response: {
1163
+ status: 403,
1164
+ statusText: 'Forbidden'
1165
+ }
1115
1166
  }));
1116
1167
  _context29.next = 3;
1117
1168
  return (0, _translations.deleteContext)({
@@ -1186,9 +1237,13 @@ describe('translations api', function () {
1186
1237
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee31$(_context31) {
1187
1238
  while (1) switch (_context31.prev = _context31.next) {
1188
1239
  case 0:
1189
- _axios["default"].get.mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
1190
- status: 403,
1191
- statusText: 'Forbidden'
1240
+ _axios["default"].get.mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
1241
+ name: 'AxiosError',
1242
+ isAxiosError: true,
1243
+ response: {
1244
+ status: 403,
1245
+ statusText: 'Forbidden'
1246
+ }
1192
1247
  }));
1193
1248
  _context31.next = 3;
1194
1249
  return (0, _translations.fetchContextKeys)({
@@ -1288,9 +1343,13 @@ describe('translations api', function () {
1288
1343
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee33$(_context33) {
1289
1344
  while (1) switch (_context33.prev = _context33.next) {
1290
1345
  case 0:
1291
- _axios["default"].put.mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
1292
- status: 403,
1293
- statusText: 'Forbidden'
1346
+ _axios["default"].put.mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
1347
+ name: 'AxiosError',
1348
+ isAxiosError: true,
1349
+ response: {
1350
+ status: 403,
1351
+ statusText: 'Forbidden'
1352
+ }
1294
1353
  }));
1295
1354
  _context33.next = 3;
1296
1355
  return (0, _translations.updateContextKey)({
@@ -1529,9 +1588,13 @@ describe('translations api', function () {
1529
1588
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee39$(_context39) {
1530
1589
  while (1) switch (_context39.prev = _context39.next) {
1531
1590
  case 0:
1532
- _axios["default"].get.mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
1533
- status: 403,
1534
- statusText: 'Forbidden'
1591
+ _axios["default"].get.mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
1592
+ name: 'AxiosError',
1593
+ isAxiosError: true,
1594
+ response: {
1595
+ status: 403,
1596
+ statusText: 'Forbidden'
1597
+ }
1535
1598
  }));
1536
1599
  _context39.next = 3;
1537
1600
  return (0, _translations.fetchTranslations)();
@@ -1690,9 +1753,13 @@ describe('translations api', function () {
1690
1753
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee43$(_context43) {
1691
1754
  while (1) switch (_context43.prev = _context43.next) {
1692
1755
  case 0:
1693
- _axios["default"].post.mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
1694
- status: 403,
1695
- statusText: 'Forbidden'
1756
+ _axios["default"].post.mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
1757
+ name: 'AxiosError',
1758
+ isAxiosError: true,
1759
+ response: {
1760
+ status: 403,
1761
+ statusText: 'Forbidden'
1762
+ }
1696
1763
  }));
1697
1764
  _context43.next = 3;
1698
1765
  return (0, _translations.upsertTranslations)({
@@ -1847,9 +1914,13 @@ describe('translations api', function () {
1847
1914
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee47$(_context47) {
1848
1915
  while (1) switch (_context47.prev = _context47.next) {
1849
1916
  case 0:
1850
- _axios["default"]["delete"].mockRejectedValue((0, _createError["default"])('Request failed with status code 403', null, 403, null, {
1851
- status: 403,
1852
- statusText: 'Forbidden'
1917
+ _axios["default"]["delete"].mockRejectedValue(Object.assign(new Error('Request failed with status code 403'), {
1918
+ name: 'AxiosError',
1919
+ isAxiosError: true,
1920
+ response: {
1921
+ status: 403,
1922
+ statusText: 'Forbidden'
1923
+ }
1853
1924
  }));
1854
1925
  _context47.next = 3;
1855
1926
  return (0, _translations.deleteTranslations)();