@kineticdata/react 5.1.0 → 5.1.2

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 (35) hide show
  1. package/lib/apis/core/attributeDefinitions.js +11 -9
  2. package/lib/apis/core/attributeDefinitions.test.js +1 -1
  3. package/lib/apis/core/backgroundJobs.js +2 -1
  4. package/lib/apis/core/bridgeModelAttributeMappings.js +1 -1
  5. package/lib/apis/core/bridgeModelAttributes.js +15 -12
  6. package/lib/apis/core/bridgeModelMappings.js +1 -1
  7. package/lib/apis/core/bridgeModelQualificationMappings.js +2 -2
  8. package/lib/apis/core/bridgeModelQualifications.js +2 -2
  9. package/lib/apis/core/bridgeModels.js +20 -8
  10. package/lib/apis/core/bridgedresources.js +4 -2
  11. package/lib/apis/core/bridgedresources.test.js +1 -1
  12. package/lib/apis/core/formTypes.js +18 -21
  13. package/lib/apis/core/forms.js +2 -1
  14. package/lib/apis/core/oauthClients.js +11 -5
  15. package/lib/apis/core/platformItems.js +21 -0
  16. package/lib/apis/core/securityPolicyDefinitions.js +1 -1
  17. package/lib/apis/core/submissions.js +92 -3
  18. package/lib/apis/core/submissions.test.js +46 -19
  19. package/lib/apis/core/webhooks.js +1 -1
  20. package/lib/apis/core/webhooks.test.js +2 -2
  21. package/lib/apis/core/workflows.js +56 -0
  22. package/lib/apis/http.js +6 -0
  23. package/lib/apis/index.js +3 -1
  24. package/lib/apis/task/index.js +7 -3
  25. package/lib/components/index.js +2 -0
  26. package/lib/components/table/Table.js +14 -7
  27. package/lib/components/table/Table.redux.js +16 -8
  28. package/lib/components/task/builder/TaskDefinitionConfigForm.js +1 -1
  29. package/lib/components/task/builder/builder.redux.js +65 -28
  30. package/lib/components/task/builder/models.js +19 -0
  31. package/lib/components/task/workflows/LinkedWorkflowForm.js +255 -0
  32. package/lib/components/task/workflows/LinkedWorkflowTable.js +133 -0
  33. package/lib/components/task/workflows/WorkflowForm.js +12 -2
  34. package/package.json +3 -3
  35. package/proxyhelper.js +1 -2
@@ -32,11 +32,13 @@ var validateOptions = function validateOptions(functionName, requiredOptions, op
32
32
  };
33
33
 
34
34
  var buildEndpoint = function buildEndpoint(_ref) {
35
- var attributeType = _ref.attributeType,
36
- kappSlug = _ref.kappSlug,
37
- attributeName = _ref.attributeName;
35
+ var kappSlug = _ref.kappSlug,
36
+ at = _ref.attributeType,
37
+ an = _ref.attributeName;
38
+ var attributeType = encodeURIComponent(at);
39
+ var attributeName = encodeURIComponent(an);
38
40
  var basePath = kappSlug ? "".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/").concat(attributeType) : "".concat(bundle.apiLocation(), "/").concat(attributeType);
39
- return attributeName ? "".concat(basePath, "/").concat(attributeName) : basePath;
41
+ return an ? "".concat(basePath, "/").concat(attributeName) : basePath;
40
42
  };
41
43
 
42
44
  export var fetchAttributeDefinitions = function fetchAttributeDefinitions() {
@@ -70,12 +72,12 @@ export var createAttributeDefinition = function createAttributeDefinition() {
70
72
  var kappSlug = options.kappSlug,
71
73
  attributeType = options.attributeType,
72
74
  attributeDefinition = options.attributeDefinition;
73
- validateOptions('createAttributeDefinition', ['attributeType', 'attributeDefinition'], options); // For Creates, we don't append the name to the basePath (it goes in the body)
74
- // so not using the buildEndpoint function
75
+ validateOptions('createAttributeDefinition', ['attributeType', 'attributeDefinition'], options); // The API returns the singular name of the attribute type, so we remove the "s"
75
76
 
76
- var basePath = kappSlug ? "".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/").concat(attributeType) : "".concat(bundle.apiLocation(), "/").concat(attributeType); // The API returns the singular name of the attribute type, so we remove the "s"
77
-
78
- return axios.post(basePath, attributeDefinition, {
77
+ return axios.post(buildEndpoint({
78
+ kappSlug: kappSlug,
79
+ attributeType: attributeType
80
+ }), attributeDefinition, {
79
81
  params: paramBuilder(options),
80
82
  headers: headerBuilder(options)
81
83
  }).then(function (response) {
@@ -325,7 +325,7 @@ describe('attributeDefinitions api', function () {
325
325
 
326
326
  case 3:
327
327
  result = _context6.sent;
328
- expect(axios.put.mock.calls).toEqual([['space/app/api/v1/spaceAttributeDefinitions/Test Attribute', {
328
+ expect(axios.put.mock.calls).toEqual([['space/app/api/v1/spaceAttributeDefinitions/Test%20Attribute', {
329
329
  name: 'Test Attribute',
330
330
  description: 'Test Attr Desc',
331
331
  allowsMultiple: true
@@ -9,8 +9,9 @@ var backgroundJobPath = function backgroundJobPath() {
9
9
  kappSlug = _ref.kappSlug,
10
10
  job = _ref.job;
11
11
 
12
+ var j = encodeURIComponent(job);
12
13
  var basePath = !formSlug && !kappSlug ? "".concat(bundle.apiLocation(), "/backgroundJobs") : !formSlug && kappSlug ? "".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/backgroundJobs") : formSlug && !kappSlug ? "".concat(bundle.apiLocation(), "/forms/").concat(formSlug, "/backgroundJobs") : "".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/forms/").concat(formSlug, "/backgroundJobs");
13
- return basePath + (job ? "/".concat(job) : '');
14
+ return basePath + (job ? "/".concat(j) : '');
14
15
  };
15
16
 
16
17
  export var fetchBackgroundJobs = function fetchBackgroundJobs() {
@@ -22,7 +22,7 @@ var _apiGroup = apiGroup({
22
22
  var modelName = _ref2.modelName,
23
23
  mappingName = _ref2.mappingName,
24
24
  attributeName = _ref2.attributeName;
25
- return "/models/".concat(modelName, "/mappings/").concat(mappingName, "/attributes/").concat(attributeName);
25
+ return "/models/".concat(modelName, "/mappings/").concat(mappingName, "/attributes/").concat(encodeURIComponent(attributeName));
26
26
  },
27
27
  transform: function transform(response) {
28
28
  return {
@@ -1,10 +1,19 @@
1
1
  import axios from 'axios';
2
2
  import { bundle } from '../../helpers';
3
3
  import { handleErrors, headerBuilder, paramBuilder, validateOptions } from '../http';
4
+
5
+ var buildEndpoint = function buildEndpoint(_ref) {
6
+ var modelName = _ref.modelName,
7
+ attributeName = _ref.attributeName;
8
+ var an = encodeURIComponent(attributeName);
9
+ var mn = encodeURIComponent(modelName);
10
+ return attributeName ? "".concat(bundle.apiLocation(), "/models/").concat(mn, "/attributes/").concat(an) : "".concat(bundle.apiLocation(), "/models/").concat(mn, "/attributes");
11
+ };
12
+
4
13
  export var fetchBridgeModelAttributes = function fetchBridgeModelAttributes() {
5
14
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6
15
  validateOptions('fetchBridgeModelAttributes', ['modelName'], options);
7
- return axios.get("".concat(bundle.apiLocation(), "/models/").concat(options.modelName, "/attributes"), {
16
+ return axios.get(buildEndpoint(options), {
8
17
  params: paramBuilder(options),
9
18
  headers: headerBuilder(options)
10
19
  }).then(function (response) {
@@ -16,9 +25,7 @@ export var fetchBridgeModelAttributes = function fetchBridgeModelAttributes() {
16
25
  export var fetchBridgeModelAttribute = function fetchBridgeModelAttribute() {
17
26
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18
27
  validateOptions('fetchBridgeModelAttribute', ['modelName', 'attributeName'], options);
19
- var modelName = options.modelName,
20
- attributeName = options.attributeName;
21
- return axios.get("".concat(bundle.apiLocation(), "/models/").concat(modelName, "/attributes/").concat(attributeName), {
28
+ return axios.get(buildEndpoint(options), {
22
29
  params: paramBuilder(options),
23
30
  headers: headerBuilder(options)
24
31
  }).then(function (response) {
@@ -30,7 +37,7 @@ export var fetchBridgeModelAttribute = function fetchBridgeModelAttribute() {
30
37
  export var createBridgeModelAttribute = function createBridgeModelAttribute() {
31
38
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
32
39
  validateOptions('createBridgeModelAttribute', ['modelName', 'bridgeModelAttribute'], options);
33
- return axios.post("".concat(bundle.apiLocation(), "/models/").concat(options.modelName, "/attributes"), options.bridgeModelAttribute, {
40
+ return axios.post(buildEndpoint(options), options.bridgeModelAttribute, {
34
41
  params: paramBuilder(options),
35
42
  headers: headerBuilder(options)
36
43
  }).then(function (response) {
@@ -42,10 +49,8 @@ export var createBridgeModelAttribute = function createBridgeModelAttribute() {
42
49
  export var updateBridgeModelAttribute = function updateBridgeModelAttribute() {
43
50
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
44
51
  validateOptions('updateBridgeModelAttribute', ['modelName', 'attributeName', 'bridgeModelAttribute'], options);
45
- var modelName = options.modelName,
46
- attributeName = options.attributeName,
47
- bridgeModelAttribute = options.bridgeModelAttribute;
48
- return axios.put("".concat(bundle.apiLocation(), "/models/").concat(modelName, "/attributes/").concat(attributeName), bridgeModelAttribute, {
52
+ var bridgeModelAttribute = options.bridgeModelAttribute;
53
+ return axios.put(buildEndpoint(options), bridgeModelAttribute, {
49
54
  params: paramBuilder(options),
50
55
  headers: headerBuilder(options)
51
56
  }).then(function (response) {
@@ -57,9 +62,7 @@ export var updateBridgeModelAttribute = function updateBridgeModelAttribute() {
57
62
  export var deleteBridgeModelAttribute = function deleteBridgeModelAttribute() {
58
63
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
59
64
  validateOptions('deleteBridgeModelAttribute', ['modelName', 'attributeName'], options);
60
- var modelName = options.modelName,
61
- attributeName = options.attributeName;
62
- return axios["delete"]("".concat(bundle.apiLocation(), "/models/").concat(modelName, "/attributes/").concat(attributeName), {
65
+ return axios["delete"](buildEndpoint(options), {
63
66
  params: paramBuilder(options),
64
67
  headers: headerBuilder(options)
65
68
  }).then(function (response) {
@@ -20,7 +20,7 @@ var _apiGroup = apiGroup({
20
20
  url: function url(_ref2) {
21
21
  var modelName = _ref2.modelName,
22
22
  mappingName = _ref2.mappingName;
23
- return "/models/".concat(modelName, "/mappings/").concat(mappingName);
23
+ return "/models/".concat(encodeURIComponent(modelName), "/mappings/").concat(encodeURIComponent(mappingName));
24
24
  },
25
25
  transform: function transform(response) {
26
26
  return {
@@ -8,7 +8,7 @@ var _apiGroup = apiGroup({
8
8
  url: function url(_ref) {
9
9
  var modelName = _ref.modelName,
10
10
  mappingName = _ref.mappingName;
11
- return "/models/".concat(modelName, "/mappings/").concat(mappingName, "/qualifications");
11
+ return "/models/".concat(encodeURIComponent(modelName), "/mappings/").concat(encodeURIComponent(mappingName), "/qualifications");
12
12
  },
13
13
  transform: function transform(response) {
14
14
  return {
@@ -22,7 +22,7 @@ var _apiGroup = apiGroup({
22
22
  var modelName = _ref2.modelName,
23
23
  mappingName = _ref2.mappingName,
24
24
  qualificationName = _ref2.qualificationName;
25
- return "/models/".concat(modelName, "/mappings/").concat(mappingName, "/qualifications/").concat(qualificationName);
25
+ return "/models/".concat(encodeURIComponent(modelName), "/mappings/").concat(encodeURIComponent(mappingName), "/qualifications/").concat(encodeURIComponent(qualificationName));
26
26
  },
27
27
  transform: function transform(response) {
28
28
  return {
@@ -7,7 +7,7 @@ var _apiGroup = apiGroup({
7
7
  requiredOptions: ['modelName'],
8
8
  url: function url(_ref) {
9
9
  var modelName = _ref.modelName;
10
- return "/models/".concat(modelName, "/qualifications");
10
+ return "/models/".concat(encodeURIComponent(modelName), "/qualifications");
11
11
  },
12
12
  transform: function transform(response) {
13
13
  return {
@@ -20,7 +20,7 @@ var _apiGroup = apiGroup({
20
20
  url: function url(_ref2) {
21
21
  var modelName = _ref2.modelName,
22
22
  qualificationName = _ref2.qualificationName;
23
- return "/models/".concat(modelName, "/qualifications/").concat(qualificationName);
23
+ return "/models/".concat(encodeURIComponent(modelName), "/qualifications/").concat(encodeURIComponent(qualificationName));
24
24
  },
25
25
  transform: function transform(response) {
26
26
  return {
@@ -2,9 +2,22 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import axios from 'axios';
3
3
  import { bundle } from '../../helpers';
4
4
  import { handleErrors, headerBuilder, paramBuilder, validateOptions } from '../http';
5
+
6
+ var buildRuntimeEndpoint = function buildRuntimeEndpoint(_ref) {
7
+ var modelName = _ref.modelName;
8
+ var mn = encodeURIComponent(modelName);
9
+ return modelName ? "".concat(bundle.spaceLocation(), "/app/models/").concat(mn) : "".concat(bundle.spaceLocation(), "/app/models");
10
+ };
11
+
12
+ var buildEndpoint = function buildEndpoint(_ref2) {
13
+ var modelName = _ref2.modelName;
14
+ var mn = encodeURIComponent(modelName);
15
+ return modelName ? "".concat(bundle.apiLocation(), "/models/").concat(mn) : "".concat(bundle.apiLocation(), "/models");
16
+ };
17
+
5
18
  export var fetchBridgeModels = function fetchBridgeModels() {
6
19
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7
- return axios.get("".concat(bundle.apiLocation(), "/models"), {
20
+ return axios.get(buildEndpoint(options), {
8
21
  params: paramBuilder(options),
9
22
  headers: headerBuilder(options)
10
23
  }).then(function (response) {
@@ -16,7 +29,7 @@ export var fetchBridgeModels = function fetchBridgeModels() {
16
29
  export var fetchBridgeModel = function fetchBridgeModel() {
17
30
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18
31
  validateOptions('fetchBridgeModel', ['modelName'], options);
19
- return axios.get("".concat(bundle.apiLocation(), "/models/").concat(options.modelName), {
32
+ return axios.get(buildEndpoint(options), {
20
33
  params: paramBuilder(options),
21
34
  headers: headerBuilder(options)
22
35
  }).then(function (response) {
@@ -29,8 +42,7 @@ var TEST_METHODS = ['retrieve', 'search', 'count'];
29
42
  export var testBridgeModel = function testBridgeModel() {
30
43
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
31
44
  validateOptions('testBridgeModel', ['modelName', 'qualificationName', 'method'], options);
32
- var modelName = options.modelName,
33
- qualificationName = options.qualificationName,
45
+ var qualificationName = options.qualificationName,
34
46
  _options$attributes = options.attributes,
35
47
  attributes = _options$attributes === void 0 ? [] : _options$attributes;
36
48
  var method = TEST_METHODS.includes(options.method) ? options.method : 'retrieve';
@@ -38,7 +50,7 @@ export var testBridgeModel = function testBridgeModel() {
38
50
  params["parameters[".concat(parameter.name, "]")] = parameter.value;
39
51
  return params;
40
52
  }, {});
41
- return axios.post("".concat(bundle.spaceLocation(), "/app/models/").concat(modelName, "/qualifications/").concat(qualificationName, "/").concat(method), null, {
53
+ return axios.post("".concat(buildRuntimeEndpoint(options), "/qualifications/").concat(encodeURIComponent(qualificationName), "/").concat(encodeURIComponent(method)), null, {
42
54
  params: _objectSpread(_objectSpread({}, paramBuilder(options)), {}, {
43
55
  attributes: attributes.join(',')
44
56
  }, parameters),
@@ -48,7 +60,7 @@ export var testBridgeModel = function testBridgeModel() {
48
60
  export var createBridgeModel = function createBridgeModel() {
49
61
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
50
62
  validateOptions('createBridgeModel', ['bridgeModel'], options);
51
- return axios.post("".concat(bundle.apiLocation(), "/models"), options.bridgeModel, {
63
+ return axios.post(buildEndpoint(options), options.bridgeModel, {
52
64
  params: paramBuilder(options),
53
65
  headers: headerBuilder(options)
54
66
  }).then(function (response) {
@@ -60,7 +72,7 @@ export var createBridgeModel = function createBridgeModel() {
60
72
  export var updateBridgeModel = function updateBridgeModel() {
61
73
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
62
74
  validateOptions('updateBridgeModel', ['modelName', 'bridgeModel'], options);
63
- return axios.put("".concat(bundle.apiLocation(), "/models/").concat(options.modelName), options.bridgeModel, {
75
+ return axios.put(buildEndpoint(options), options.bridgeModel, {
64
76
  params: paramBuilder(options),
65
77
  headers: headerBuilder(options)
66
78
  }).then(function (response) {
@@ -72,7 +84,7 @@ export var updateBridgeModel = function updateBridgeModel() {
72
84
  export var deleteBridgeModel = function deleteBridgeModel() {
73
85
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
74
86
  validateOptions('deleteBridgeModel', ['modelName'], options);
75
- return axios["delete"]("".concat(bundle.apiLocation(), "/models/").concat(options.modelName), {
87
+ return axios["delete"](buildEndpoint(options), {
76
88
  params: paramBuilder(options),
77
89
  headers: headerBuilder(options)
78
90
  }).then(function (response) {
@@ -31,10 +31,12 @@ export var bridgedResourceUrl = function bridgedResourceUrl(options) {
31
31
 
32
32
  if (!bridgedResourceName) {
33
33
  throw new Error('Property "bridgedResourceName" is required.');
34
- } // build the url
34
+ }
35
35
 
36
+ var brn = encodeURIComponent(options.bridgedResourceName); // build the url
36
37
 
37
- var url = datastore ? "".concat(bundle.spaceLocation(), "/app/datastore/forms/").concat(options.formSlug, "/bridgedResources/").concat(encodeURIComponent(options.bridgedResourceName)) : "".concat(bundle.spaceLocation(), "/").concat(kappSlug, "/").concat(options.formSlug, "/bridgedResources/").concat(encodeURIComponent(options.bridgedResourceName)); // append any attributes if they were specified
38
+ var url = !datastore ? "".concat(bundle.spaceLocation(), "/").concat(kappSlug, "/").concat(formSlug, "/bridgedResources/").concat(brn) // Default kapp to 'datastore' if not provided to support deprecated datastore functionality
39
+ : "".concat(bundle.spaceLocation(), "/datastore/").concat(formSlug, "/bridgedResources/").concat(brn); // append any attributes if they were specified
38
40
 
39
41
  if (counting) {
40
42
  url += '/count';
@@ -55,7 +55,7 @@ describe('bridged resource api', function () {
55
55
  test('datastore form', function () {
56
56
  expect(bridgedResourceUrl(_objectSpread(_objectSpread({}, options), {}, {
57
57
  datastore: true
58
- }))).toBe('user/app/datastore/forms/formslug/bridgedResources/Collection');
58
+ }))).toBe('user/datastore/formslug/bridgedResources/Collection');
59
59
  });
60
60
  test('default the kapp option', function () {
61
61
  delete options.kappSlug;
@@ -1,12 +1,18 @@
1
1
  import axios from 'axios';
2
2
  import { bundle } from '../../helpers';
3
3
  import { handleErrors, headerBuilder, paramBuilder } from '../http';
4
+
5
+ var buildEndpoint = function buildEndpoint(_ref) {
6
+ var _ref$kappSlug = _ref.kappSlug,
7
+ kappSlug = _ref$kappSlug === void 0 ? bundle.kappSlug() : _ref$kappSlug,
8
+ name = _ref.name;
9
+ return name ? "".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/formTypes/").concat(encodeURIComponent(name)) : "".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/formTypes");
10
+ };
11
+
4
12
  export var fetchFormTypes = function fetchFormTypes() {
5
13
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6
- var _options$kappSlug = options.kappSlug,
7
- kappSlug = _options$kappSlug === void 0 ? bundle.kappSlug() : _options$kappSlug; // Build URL and fetch the form types.
8
-
9
- return axios.get("".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/formTypes"), {
14
+ // Build URL and fetch the form types.
15
+ return axios.get(buildEndpoint(options), {
10
16
  params: paramBuilder(options),
11
17
  headers: headerBuilder(options)
12
18
  }).then(function (response) {
@@ -17,16 +23,14 @@ export var fetchFormTypes = function fetchFormTypes() {
17
23
  };
18
24
  export var fetchFormType = function fetchFormType() {
19
25
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
20
- var _options$kappSlug2 = options.kappSlug,
21
- kappSlug = _options$kappSlug2 === void 0 ? bundle.kappSlug() : _options$kappSlug2,
22
- name = options.name;
26
+ var name = options.name;
23
27
 
24
28
  if (!name) {
25
29
  throw new Error('fetchFormType failed! The option "name" is required.');
26
30
  } // Build URL and fetch the form type.
27
31
 
28
32
 
29
- return axios.get("".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/formTypes/").concat(name), {
33
+ return axios.get(buildEndpoint(options), {
30
34
  params: paramBuilder(options),
31
35
  headers: headerBuilder(options)
32
36
  }).then(function (response) {
@@ -37,16 +41,14 @@ export var fetchFormType = function fetchFormType() {
37
41
  };
38
42
  export var createFormType = function createFormType() {
39
43
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
40
- var _options$kappSlug3 = options.kappSlug,
41
- kappSlug = _options$kappSlug3 === void 0 ? bundle.kappSlug() : _options$kappSlug3,
42
- formType = options.formType;
44
+ var formType = options.formType;
43
45
 
44
46
  if (!formType) {
45
47
  throw new Error('createFormType failed! The option "formType" is required.');
46
48
  } // Build URL and create the form type.
47
49
 
48
50
 
49
- return axios.post("".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/formTypes"), formType, {
51
+ return axios.post(buildEndpoint(options), formType, {
50
52
  params: paramBuilder(options),
51
53
  headers: headerBuilder(options)
52
54
  }).then(function (response) {
@@ -57,9 +59,7 @@ export var createFormType = function createFormType() {
57
59
  };
58
60
  export var updateFormType = function updateFormType() {
59
61
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
60
- var _options$kappSlug4 = options.kappSlug,
61
- kappSlug = _options$kappSlug4 === void 0 ? bundle.kappSlug() : _options$kappSlug4,
62
- formType = options.formType,
62
+ var formType = options.formType,
63
63
  name = options.name;
64
64
 
65
65
  if (!formType) {
@@ -71,7 +71,7 @@ export var updateFormType = function updateFormType() {
71
71
  } // Build URL and update the form type.
72
72
 
73
73
 
74
- return axios.put("".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/formTypes/").concat(name), formType, {
74
+ return axios.put(buildEndpoint(options), formType, {
75
75
  params: paramBuilder(options),
76
76
  headers: headerBuilder(options)
77
77
  }).then(function (response) {
@@ -82,11 +82,8 @@ export var updateFormType = function updateFormType() {
82
82
  };
83
83
  export var deleteFormType = function deleteFormType() {
84
84
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
85
- var _options$kappSlug5 = options.kappSlug,
86
- kappSlug = _options$kappSlug5 === void 0 ? bundle.kappSlug() : _options$kappSlug5,
87
- name = options.name; // Build URL and delete the form type.
88
-
89
- return axios["delete"]("".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/formTypes/").concat(name), {
85
+ // Build URL and delete the form type.
86
+ return axios["delete"](buildEndpoint(options), {
90
87
  params: paramBuilder(options),
91
88
  headers: headerBuilder(options)
92
89
  }).then(function (response) {
@@ -4,7 +4,8 @@ import { handleErrors, paramBuilder, headerBuilder } from '../http';
4
4
 
5
5
  var getPath = function getPath(kappSlug, formSlug) {
6
6
  var formSuffix = formSlug ? "/".concat(formSlug) : '';
7
- return kappSlug ? "".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/forms").concat(formSuffix) : "".concat(bundle.apiLocation(), "/datastore/forms").concat(formSuffix);
7
+ return kappSlug ? "".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/forms").concat(formSuffix) // Default kapp to 'datastore' if not provided to support deprecated datastore functionality
8
+ : "".concat(bundle.apiLocation(), "/kapps/datastore/forms").concat(formSuffix);
8
9
  }; // TODO: datastore is deprecated, remove datastore routes from paths.
9
10
 
10
11
 
@@ -2,9 +2,15 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import axios from 'axios';
3
3
  import { bundle } from '../../helpers';
4
4
  import { handleErrors, paramBuilder, headerBuilder } from '../http';
5
+
6
+ var buildEndpoint = function buildEndpoint(_ref) {
7
+ var clientId = _ref.clientId;
8
+ return clientId ? "".concat(bundle.apiLocation(), "/oauthClients/").concat(encodeURIComponent(clientId)) : "".concat(bundle.apiLocation(), "/oauthClients");
9
+ };
10
+
5
11
  export var fetchOAuthClients = function fetchOAuthClients() {
6
12
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7
- return axios.get("".concat(bundle.apiLocation(), "/oauthClients"), {
13
+ return axios.get(buildEndpoint(options), {
8
14
  params: _objectSpread({}, paramBuilder(options)),
9
15
  headers: headerBuilder(options)
10
16
  }).then(function (response) {
@@ -21,7 +27,7 @@ export var fetchOAuthClient = function fetchOAuthClient() {
21
27
  throw new Error('fetchOAuthClient failed! The option "clientId" is required.');
22
28
  }
23
29
 
24
- return axios.get("".concat(bundle.apiLocation(), "/oauthClients/").concat(clientId), {
30
+ return axios.get(buildEndpoint(options), {
25
31
  params: _objectSpread({}, paramBuilder(options)),
26
32
  headers: headerBuilder(options)
27
33
  }).then(function (response) {
@@ -44,7 +50,7 @@ export var updateOAuthClient = function updateOAuthClient() {
44
50
  } // Build URL and fetch the space.
45
51
 
46
52
 
47
- return axios.put("".concat(bundle.apiLocation(), "/oauthClients/").concat(clientId), client, {
53
+ return axios.put(buildEndpoint(options), client, {
48
54
  params: paramBuilder(options),
49
55
  headers: headerBuilder(options)
50
56
  }).then(function (response) {
@@ -62,7 +68,7 @@ export var createOAuthClient = function createOAuthClient() {
62
68
  } // Build URL and fetch the space.
63
69
 
64
70
 
65
- return axios.post("".concat(bundle.apiLocation(), "/oauthClients"), client, {
71
+ return axios.post(buildEndpoint(options), client, {
66
72
  params: paramBuilder(options),
67
73
  headers: headerBuilder(options)
68
74
  }).then(function (response) {
@@ -80,7 +86,7 @@ export var deleteOAuthClient = function deleteOAuthClient() {
80
86
  } // Build URL and fetch the space.
81
87
 
82
88
 
83
- return axios["delete"]("".concat(bundle.apiLocation(), "/oauthClients/").concat(clientId), {
89
+ return axios["delete"](buildEndpoint(options), {
84
90
  params: paramBuilder(options),
85
91
  headers: headerBuilder(options)
86
92
  }).then(function (response) {
@@ -0,0 +1,21 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import axios from 'axios';
3
+ import { bundle } from '../../helpers';
4
+ import { handleErrors, headerBuilder, paramBuilder, validateOptions } from '../http';
5
+ export var fetchPlatformItem = function fetchPlatformItem(options) {
6
+ validateOptions('fetchPlatformItem', ['type', 'id'], options);
7
+ var path = options.type === 'Space' ? "".concat(bundle.apiLocation(), "/space") : "".concat(bundle.apiLocation(), "/items/").concat(options.type, "/").concat(options.id);
8
+ var include = options.type === 'Form' ? 'kapp,kapp.space' : options.type === 'Kapp' ? 'space' : '';
9
+ return axios.get(path, {
10
+ params: paramBuilder(_objectSpread(_objectSpread({}, options), {}, {
11
+ include: include
12
+ })),
13
+ headers: headerBuilder(options)
14
+ }).then(function (response) {
15
+ return {
16
+ platformItem: response.data.space || response.data.kapp || response.data.form
17
+ };
18
+ }) // Clean up any errors we receive. Make sure this the last thing so that it
19
+ // cleans up any errors.
20
+ ["catch"](handleErrors);
21
+ };
@@ -25,7 +25,7 @@ var buildEndpoint = function buildEndpoint(_ref) {
25
25
  var kappSlug = _ref.kappSlug,
26
26
  securityPolicyName = _ref.securityPolicyName;
27
27
  var basePath = kappSlug ? "".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/securityPolicyDefinitions") : "".concat(bundle.apiLocation(), "/securityPolicyDefinitions");
28
- return securityPolicyName ? "".concat(basePath, "/").concat(securityPolicyName) : basePath;
28
+ return securityPolicyName ? "".concat(basePath, "/").concat(encodeURIComponent(securityPolicyName)) : basePath;
29
29
  };
30
30
 
31
31
  export var fetchSecurityPolicyDefinitions = function fetchSecurityPolicyDefinitions() {
@@ -412,8 +412,13 @@ export var SubmissionSearch = /*#__PURE__*/function () {
412
412
  export var searchSubmissions = function searchSubmissions(options) {
413
413
  var kapp = options.kapp,
414
414
  form = options.form,
415
- search = options.search;
416
- var path = kapp ? form ? "".concat(bundle.apiLocation(), "/kapps/").concat(kapp, "/forms/").concat(form, "/submissions") : "".concat(bundle.apiLocation(), "/kapps/").concat(kapp, "/submissions") : form ? "".concat(bundle.apiLocation(), "/datastore/forms/").concat(form, "/submissions") : "".concat(bundle.apiLocation(), "/submissions");
415
+ search = options.search,
416
+ _options$get = options.get,
417
+ get = _options$get === void 0 ? false : _options$get;
418
+ var endpoint = !get ? 'submissions-search' : 'submissions'; // Default kapp to 'datastore' if not provided to support deprecated datastore functionality
419
+
420
+ var kappSlug = kapp || 'datastore';
421
+ var path = form ? "".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/forms/").concat(form, "/").concat(endpoint) : "".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/").concat(endpoint);
417
422
 
418
423
  var meta = _objectSpread({}, search); // Format includes.
419
424
 
@@ -429,7 +434,9 @@ export var searchSubmissions = function searchSubmissions(options) {
429
434
  } // Fetch the submissions.
430
435
 
431
436
 
432
- var promise = axios.get(path, {
437
+ var promise = !get ? axios.post(path, _objectSpread(_objectSpread({}, meta), paramBuilder(options)), {
438
+ headers: headerBuilder(options)
439
+ }) : axios.get(path, {
433
440
  paramsSerializer: function paramsSerializer(params) {
434
441
  return qs.stringify(params);
435
442
  },
@@ -577,4 +584,86 @@ export var deleteSubmission = function deleteSubmission(options) {
577
584
  }) // Clean up any errors we receive. Make sure this the last thing so that it
578
585
  // cleans up any errors.
579
586
  ["catch"](handleErrors);
587
+ };
588
+ export var exportSubmissions = function exportSubmissions(options) {
589
+ var kappSlug = options.kappSlug,
590
+ formSlug = options.formSlug,
591
+ onDownloadProgress = options.onDownloadProgress;
592
+
593
+ if (!kappSlug) {
594
+ throw new Error('exportSubmissions failed! The option "kappSlug" is required.');
595
+ }
596
+
597
+ if (!formSlug) {
598
+ throw new Error('exportSubmissions failed! The option "formSlug" is required.');
599
+ }
600
+
601
+ var path = "".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/forms/").concat(formSlug, "/submissions-search?export");
602
+ return axios.post(path, {}, {
603
+ params: paramBuilder(options),
604
+ headers: headerBuilder(options),
605
+ onDownloadProgress: onDownloadProgress,
606
+ responseType: 'blob'
607
+ });
608
+ };
609
+ export var MODE_IMPORT = 'import';
610
+ export var MODE_BULK = 'bulk';
611
+
612
+ var modeToFn = function modeToFn(mode) {
613
+ return mode === MODE_BULK ? 'post' : 'patch';
614
+ };
615
+
616
+ export var importSubmissionStatus = function importSubmissionStatus(options) {
617
+ var kappSlug = options.kappSlug,
618
+ formSlug = options.formSlug,
619
+ jobId = options.jobId;
620
+ var path = "".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/forms/").concat(formSlug, "/submission-import/").concat(jobId);
621
+ return axios.get(path, {
622
+ params: paramBuilder(options),
623
+ headers: headerBuilder(options)
624
+ }).then(function (response) {
625
+ return {
626
+ backgroundJob: response.data.backgroundJob
627
+ };
628
+ })["catch"](handleErrors);
629
+ };
630
+ export var importSubmissions = function importSubmissions(options) {
631
+ var kappSlug = options.kappSlug,
632
+ formSlug = options.formSlug,
633
+ onUploadProgress = options.onUploadProgress,
634
+ file = options.file,
635
+ _options$mode = options.mode,
636
+ mode = _options$mode === void 0 ? MODE_IMPORT : _options$mode,
637
+ cancelToken = options.cancelToken;
638
+
639
+ if (!kappSlug) {
640
+ throw new Error('importSubmissions failed! The option "kappSlug" is required.');
641
+ }
642
+
643
+ if (!formSlug) {
644
+ throw new Error('importSubmissions failed! The option "formSlug" is required.');
645
+ }
646
+
647
+ if (!file) {
648
+ throw new Error('importSubmissions failed! The option "file" is required.');
649
+ }
650
+
651
+ var path = "".concat(bundle.apiLocation(), "/kapps/").concat(kappSlug, "/forms/").concat(formSlug, "/submissions?import");
652
+ return axios[modeToFn(mode)](path, file, {
653
+ cancelToken: cancelToken,
654
+ data: file,
655
+ params: paramBuilder(options),
656
+ headers: _objectSpread(_objectSpread({}, headerBuilder(options)), {}, {
657
+ 'Content-Type': 'application/csv'
658
+ }),
659
+ onUploadProgress: onUploadProgress
660
+ }).then(function (response) {
661
+ return response.data;
662
+ })["catch"](function (error) {
663
+ if (error.response && error.response.data && error.response.data.errors) {
664
+ return error.response.data;
665
+ } else {
666
+ return handleErrors(error);
667
+ }
668
+ });
580
669
  };