@oneblink/sdk 3.2.0-beta.1 → 3.2.0-beta.3
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/package.json +1 -1
- package/tenants/classes/FormElementLists.d.ts +111 -0
- package/tenants/classes/FormElementLists.js +149 -0
- package/tenants/classes/FormElementLists.js.map +1 -0
- package/tenants/classes/FormElementLookups.d.ts +120 -0
- package/tenants/classes/FormElementLookups.js +151 -0
- package/tenants/classes/FormElementLookups.js.map +1 -0
- package/tenants/classes/index.d.ts +3 -1
- package/tenants/classes/index.js +5 -1
- package/tenants/classes/index.js.map +1 -1
- package/tenants/lib/forms-validation/common.d.ts +11 -1
- package/tenants/lib/forms-validation/common.js +17 -5
- package/tenants/lib/forms-validation/common.js.map +1 -1
- package/tenants/lib/forms-validation/index.js +56 -34
- package/tenants/lib/forms-validation/index.js.map +1 -1
- package/tenants/types.d.ts +27 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneblink/sdk",
|
|
3
3
|
"description": "OneBlink SDK to serve as an entry point for all OneBlink Services in NodeJS",
|
|
4
|
-
"version": "3.2.0-beta.
|
|
4
|
+
"version": "3.2.0-beta.3",
|
|
5
5
|
"author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/oneblink/sdk-node-js/issues"
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { FormTypes } from '@oneblink/types';
|
|
2
|
+
import OneBlinkAPI from '../lib/one-blink-api';
|
|
3
|
+
import { ConstructorOptions, FormElementListSearchOptions, FormElementListSearchResult } from '../types';
|
|
4
|
+
export default class FormElementLists extends OneBlinkAPI {
|
|
5
|
+
/**
|
|
6
|
+
* #### Example
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { FormElementLists } from '@oneblink/sdk'
|
|
10
|
+
*
|
|
11
|
+
* const options = {
|
|
12
|
+
* accessKey: '123455678901ABCDEFGHIJKL',
|
|
13
|
+
* secretKey: '123455678901ABCDEFGHIJKL123455678901ABCDEFGHIJKL',
|
|
14
|
+
* }
|
|
15
|
+
* const formElementListsClient = new FormElementLists(options)
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
constructor(options: ConstructorOptions);
|
|
19
|
+
/**
|
|
20
|
+
* #### Example
|
|
21
|
+
*
|
|
22
|
+
* ```javascript
|
|
23
|
+
* const searchParams = {
|
|
24
|
+
* limit: 1,
|
|
25
|
+
* offset: 0,
|
|
26
|
+
* }
|
|
27
|
+
* const { formElementLists, meta } =
|
|
28
|
+
* await formElementListsClient.searchFormElementLists(searchParams)
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param searchParams Search options
|
|
32
|
+
*/
|
|
33
|
+
searchFormElementLists(searchParams: FormElementListSearchOptions): Promise<FormElementListSearchResult>;
|
|
34
|
+
/**
|
|
35
|
+
* #### Example
|
|
36
|
+
*
|
|
37
|
+
* ```javascript
|
|
38
|
+
* const data = {
|
|
39
|
+
* name: 'my list',
|
|
40
|
+
* organisationId: 'abc123',
|
|
41
|
+
* environments: [
|
|
42
|
+
* {
|
|
43
|
+
* options: [
|
|
44
|
+
* {
|
|
45
|
+
* label: 'One'
|
|
46
|
+
* value: '1'
|
|
47
|
+
* },
|
|
48
|
+
* {
|
|
49
|
+
* label: 'Two'
|
|
50
|
+
* value: '2'
|
|
51
|
+
* }
|
|
52
|
+
* ]
|
|
53
|
+
* formsAppEnvironmentId: 1,
|
|
54
|
+
* },
|
|
55
|
+
* ],
|
|
56
|
+
* type: 'STATIC',
|
|
57
|
+
* }
|
|
58
|
+
* const list = await formElementListsClient.createFormElementList(data)
|
|
59
|
+
* // Use list here...
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @param newFormElementList The data for the new list
|
|
63
|
+
*/
|
|
64
|
+
createFormElementList(newFormElementList: FormTypes.NewFormElementOptionSet): Promise<FormTypes.FormElementOptionSet>;
|
|
65
|
+
/**
|
|
66
|
+
* #### Example
|
|
67
|
+
*
|
|
68
|
+
* ```javascript
|
|
69
|
+
* const data = {
|
|
70
|
+
* id: 1,
|
|
71
|
+
* name: 'my list',
|
|
72
|
+
* organisationId: 'abc123',
|
|
73
|
+
* environments: [
|
|
74
|
+
* {
|
|
75
|
+
* options: [
|
|
76
|
+
* {
|
|
77
|
+
* label: 'One'
|
|
78
|
+
* value: '1'
|
|
79
|
+
* },
|
|
80
|
+
* {
|
|
81
|
+
* label: 'Two'
|
|
82
|
+
* value: '2'
|
|
83
|
+
* },
|
|
84
|
+
* {
|
|
85
|
+
* label: 'Three'
|
|
86
|
+
* value: '2'
|
|
87
|
+
* },
|
|
88
|
+
* ]
|
|
89
|
+
* formsAppEnvironmentId: 1,
|
|
90
|
+
* },
|
|
91
|
+
* ],
|
|
92
|
+
* type: 'STATIC',
|
|
93
|
+
* }
|
|
94
|
+
* const list = await formElementListsClient.updateFormElementList(data)
|
|
95
|
+
* // Use list here...
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @param list The data for the list to update
|
|
99
|
+
*/
|
|
100
|
+
updateFormElementList(list: FormTypes.FormElementOptionSet): Promise<FormTypes.FormElementOptionSet>;
|
|
101
|
+
/**
|
|
102
|
+
* #### Example
|
|
103
|
+
*
|
|
104
|
+
* ```javascript
|
|
105
|
+
* await formElementListsClient.deleteFormElementList(1)
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @param id The id of the list to delete
|
|
109
|
+
*/
|
|
110
|
+
deleteFormElementList(id: number): Promise<void>;
|
|
111
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const one_blink_api_1 = __importDefault(require("../lib/one-blink-api"));
|
|
7
|
+
const basePath = `/form-element-options/dynamic`;
|
|
8
|
+
class FormElementLists extends one_blink_api_1.default {
|
|
9
|
+
/**
|
|
10
|
+
* #### Example
|
|
11
|
+
*
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { FormElementLists } from '@oneblink/sdk'
|
|
14
|
+
*
|
|
15
|
+
* const options = {
|
|
16
|
+
* accessKey: '123455678901ABCDEFGHIJKL',
|
|
17
|
+
* secretKey: '123455678901ABCDEFGHIJKL123455678901ABCDEFGHIJKL',
|
|
18
|
+
* }
|
|
19
|
+
* const formElementListsClient = new FormElementLists(options)
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
constructor(options) {
|
|
23
|
+
options = options || {};
|
|
24
|
+
super(options.accessKey, options.secretKey);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* #### Example
|
|
28
|
+
*
|
|
29
|
+
* ```javascript
|
|
30
|
+
* const searchParams = {
|
|
31
|
+
* limit: 1,
|
|
32
|
+
* offset: 0,
|
|
33
|
+
* }
|
|
34
|
+
* const { formElementLists, meta } =
|
|
35
|
+
* await formElementListsClient.searchFormElementLists(searchParams)
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @param searchParams Search options
|
|
39
|
+
*/
|
|
40
|
+
async searchFormElementLists(searchParams) {
|
|
41
|
+
if (!searchParams ||
|
|
42
|
+
typeof searchParams !== 'object' ||
|
|
43
|
+
typeof searchParams.organisationId !== 'string') {
|
|
44
|
+
throw new TypeError('Must supply "options.organisationId" as a string');
|
|
45
|
+
}
|
|
46
|
+
const result = await super.searchRequest(basePath, searchParams);
|
|
47
|
+
return {
|
|
48
|
+
meta: result.meta,
|
|
49
|
+
formElementLists: result.formElementDynamicOptionSets,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* #### Example
|
|
54
|
+
*
|
|
55
|
+
* ```javascript
|
|
56
|
+
* const data = {
|
|
57
|
+
* name: 'my list',
|
|
58
|
+
* organisationId: 'abc123',
|
|
59
|
+
* environments: [
|
|
60
|
+
* {
|
|
61
|
+
* options: [
|
|
62
|
+
* {
|
|
63
|
+
* label: 'One'
|
|
64
|
+
* value: '1'
|
|
65
|
+
* },
|
|
66
|
+
* {
|
|
67
|
+
* label: 'Two'
|
|
68
|
+
* value: '2'
|
|
69
|
+
* }
|
|
70
|
+
* ]
|
|
71
|
+
* formsAppEnvironmentId: 1,
|
|
72
|
+
* },
|
|
73
|
+
* ],
|
|
74
|
+
* type: 'STATIC',
|
|
75
|
+
* }
|
|
76
|
+
* const list = await formElementListsClient.createFormElementList(data)
|
|
77
|
+
* // Use list here...
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @param newFormElementList The data for the new list
|
|
81
|
+
*/
|
|
82
|
+
async createFormElementList(newFormElementList) {
|
|
83
|
+
if (!newFormElementList || typeof newFormElementList !== 'object') {
|
|
84
|
+
throw new TypeError('Must supply "newList" as an object');
|
|
85
|
+
}
|
|
86
|
+
return super.postRequest(basePath, newFormElementList);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* #### Example
|
|
90
|
+
*
|
|
91
|
+
* ```javascript
|
|
92
|
+
* const data = {
|
|
93
|
+
* id: 1,
|
|
94
|
+
* name: 'my list',
|
|
95
|
+
* organisationId: 'abc123',
|
|
96
|
+
* environments: [
|
|
97
|
+
* {
|
|
98
|
+
* options: [
|
|
99
|
+
* {
|
|
100
|
+
* label: 'One'
|
|
101
|
+
* value: '1'
|
|
102
|
+
* },
|
|
103
|
+
* {
|
|
104
|
+
* label: 'Two'
|
|
105
|
+
* value: '2'
|
|
106
|
+
* },
|
|
107
|
+
* {
|
|
108
|
+
* label: 'Three'
|
|
109
|
+
* value: '2'
|
|
110
|
+
* },
|
|
111
|
+
* ]
|
|
112
|
+
* formsAppEnvironmentId: 1,
|
|
113
|
+
* },
|
|
114
|
+
* ],
|
|
115
|
+
* type: 'STATIC',
|
|
116
|
+
* }
|
|
117
|
+
* const list = await formElementListsClient.updateFormElementList(data)
|
|
118
|
+
* // Use list here...
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @param list The data for the list to update
|
|
122
|
+
*/
|
|
123
|
+
async updateFormElementList(list) {
|
|
124
|
+
if (!list || typeof list !== 'object') {
|
|
125
|
+
throw new TypeError('Must supply "list" as an object');
|
|
126
|
+
}
|
|
127
|
+
if (typeof list.id !== 'number') {
|
|
128
|
+
throw new TypeError('Must supply "list.id" as a number');
|
|
129
|
+
}
|
|
130
|
+
return super.putRequest(`${basePath}/${list.id}`, list);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* #### Example
|
|
134
|
+
*
|
|
135
|
+
* ```javascript
|
|
136
|
+
* await formElementListsClient.deleteFormElementList(1)
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* @param id The id of the list to delete
|
|
140
|
+
*/
|
|
141
|
+
async deleteFormElementList(id) {
|
|
142
|
+
if (typeof id !== 'number' || Number.isNaN(id)) {
|
|
143
|
+
throw new TypeError('Must supply "id" as a number');
|
|
144
|
+
}
|
|
145
|
+
return super.deleteRequest(`${basePath}/${id}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.default = FormElementLists;
|
|
149
|
+
//# sourceMappingURL=FormElementLists.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormElementLists.js","sourceRoot":"","sources":["../../src/classes/FormElementLists.ts"],"names":[],"mappings":";;;;;AACA,yEAA8C;AAO9C,MAAM,QAAQ,GAAG,+BAA+B,CAAA;AAEhD,MAAqB,gBAAiB,SAAQ,uBAAW;IACvD;;;;;;;;;;;;OAYG;IACH,YAAY,OAA2B;QACrC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAA;QACvB,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;IAC7C,C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,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;YAC9C,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAA;SACpD;QAED,OAAO,KAAK,CAAC,aAAa,CAAC,GAAG,QAAQ,IAAI,EAAE,EAAE,CAAC,CAAA;IACjD,CAAC;CACF;AApKD,mCAoKC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { FormTypes } from '@oneblink/types';
|
|
2
|
+
import OneBlinkAPI from '../lib/one-blink-api';
|
|
3
|
+
import { ConstructorOptions, FormElementLookupSearchResult } from '../types';
|
|
4
|
+
export default class FormElementLookups extends OneBlinkAPI {
|
|
5
|
+
/**
|
|
6
|
+
* #### Example
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { FormElementLookups } from '@oneblink/sdk'
|
|
10
|
+
*
|
|
11
|
+
* const options = {
|
|
12
|
+
* accessKey: '123455678901ABCDEFGHIJKL',
|
|
13
|
+
* secretKey: '123455678901ABCDEFGHIJKL123455678901ABCDEFGHIJKL',
|
|
14
|
+
* }
|
|
15
|
+
* const formElementLookups = new FormElementLookups(options)
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
constructor(options: ConstructorOptions);
|
|
19
|
+
/**
|
|
20
|
+
* #### Example
|
|
21
|
+
*
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const lookupId = 1
|
|
24
|
+
* const lookup = await formElementLookups.getFormElementLookup(lookupId)
|
|
25
|
+
* // Use lookup here
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param id The exact id of the lookup you wish to get
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
getFormElementLookup(id: number): Promise<FormTypes.FormElementLookup>;
|
|
32
|
+
/**
|
|
33
|
+
* #### Example
|
|
34
|
+
*
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const organisationId = '2i4321a7n2389a2700065425'
|
|
37
|
+
* const lookups = await formElementLookups.searchFormElementLookups({
|
|
38
|
+
* organisationId,
|
|
39
|
+
* limit: 50,
|
|
40
|
+
* offset: 0,
|
|
41
|
+
* })
|
|
42
|
+
* // Use lookups here
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @param options
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
searchFormElementLookups(options: {
|
|
49
|
+
/**
|
|
50
|
+
* The exact id of organisation associated with the lookups you wish to
|
|
51
|
+
* search
|
|
52
|
+
*/
|
|
53
|
+
organisationId: string;
|
|
54
|
+
limit?: number;
|
|
55
|
+
offset?: number;
|
|
56
|
+
}): Promise<FormElementLookupSearchResult>;
|
|
57
|
+
/**
|
|
58
|
+
* #### Example
|
|
59
|
+
*
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const newLookup = {
|
|
62
|
+
* name: 'My New Lookup',
|
|
63
|
+
* environments: [
|
|
64
|
+
* {
|
|
65
|
+
* formsAppEnvironmentId: 1,
|
|
66
|
+
* urL: 'https://my-url.com/lookup',
|
|
67
|
+
* },
|
|
68
|
+
* ],
|
|
69
|
+
* type: 'DATA',
|
|
70
|
+
* organisationId: '',
|
|
71
|
+
* }
|
|
72
|
+
* const createdLookup = await lookups.createFormElementLookup(newLookup)
|
|
73
|
+
* // Use lookup here
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @param newFormElementLookup
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
createFormElementLookup(newFormElementLookup: FormTypes.NewFormElementLookup): Promise<FormTypes.FormElementLookup>;
|
|
80
|
+
/**
|
|
81
|
+
* #### Example
|
|
82
|
+
*
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const lookup = {
|
|
85
|
+
* id: 1,
|
|
86
|
+
* createdAt: '2023-06-28T02:00:03.000Z',
|
|
87
|
+
* updatedAt: '2023-06-28T02:00:03.000Z',
|
|
88
|
+
* name: 'My New Lookup',
|
|
89
|
+
* environments: [
|
|
90
|
+
* {
|
|
91
|
+
* formsAppEnvironmentId: 1,
|
|
92
|
+
* url: 'https://my-url.com/lookup',
|
|
93
|
+
* },
|
|
94
|
+
* ],
|
|
95
|
+
* type: 'DATA',
|
|
96
|
+
* organisationId: '',
|
|
97
|
+
* }
|
|
98
|
+
* const updatedLookup = await formElementLookups.updateFormElementLookup(
|
|
99
|
+
* lookup,
|
|
100
|
+
* )
|
|
101
|
+
* // Use lookup here
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @param formElementLookup
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
updateFormElementLookup(formElementLookup: FormTypes.FormElementLookup): Promise<FormTypes.FormElementLookup>;
|
|
108
|
+
/**
|
|
109
|
+
* #### Example
|
|
110
|
+
*
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const lookupId = 7
|
|
113
|
+
* await formElementLookups.deleteFormElementLookup(lookupId)
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @param id The id of the lookup to delete
|
|
117
|
+
* @returns
|
|
118
|
+
*/
|
|
119
|
+
deleteFormElementLookup(id: number): Promise<void>;
|
|
120
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const one_blink_api_1 = __importDefault(require("../lib/one-blink-api"));
|
|
7
|
+
class FormElementLookups extends one_blink_api_1.default {
|
|
8
|
+
/**
|
|
9
|
+
* #### Example
|
|
10
|
+
*
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { FormElementLookups } from '@oneblink/sdk'
|
|
13
|
+
*
|
|
14
|
+
* const options = {
|
|
15
|
+
* accessKey: '123455678901ABCDEFGHIJKL',
|
|
16
|
+
* secretKey: '123455678901ABCDEFGHIJKL123455678901ABCDEFGHIJKL',
|
|
17
|
+
* }
|
|
18
|
+
* const formElementLookups = new FormElementLookups(options)
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
constructor(options) {
|
|
22
|
+
options = options || {};
|
|
23
|
+
super(options.accessKey, options.secretKey);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* #### Example
|
|
27
|
+
*
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const lookupId = 1
|
|
30
|
+
* const lookup = await formElementLookups.getFormElementLookup(lookupId)
|
|
31
|
+
* // Use lookup here
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @param id The exact id of the lookup you wish to get
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
async getFormElementLookup(id) {
|
|
38
|
+
if (typeof id !== 'number' || Number.isNaN(id)) {
|
|
39
|
+
throw new TypeError('Must supply "id" as a number');
|
|
40
|
+
}
|
|
41
|
+
return super.getRequest(`/form-element-lookups/${id}`);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* #### Example
|
|
45
|
+
*
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const organisationId = '2i4321a7n2389a2700065425'
|
|
48
|
+
* const lookups = await formElementLookups.searchFormElementLookups({
|
|
49
|
+
* organisationId,
|
|
50
|
+
* limit: 50,
|
|
51
|
+
* offset: 0,
|
|
52
|
+
* })
|
|
53
|
+
* // Use lookups here
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @param options
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
async searchFormElementLookups(options) {
|
|
60
|
+
if (!options ||
|
|
61
|
+
typeof options !== 'object' ||
|
|
62
|
+
typeof options.organisationId !== 'string') {
|
|
63
|
+
throw new TypeError('Must supply "options.organisationId" as a string');
|
|
64
|
+
}
|
|
65
|
+
return super.searchRequest(`/form-element-lookups`, {
|
|
66
|
+
limit: options.limit,
|
|
67
|
+
offset: options.offset,
|
|
68
|
+
organisationId: options.organisationId,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* #### Example
|
|
73
|
+
*
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const newLookup = {
|
|
76
|
+
* name: 'My New Lookup',
|
|
77
|
+
* environments: [
|
|
78
|
+
* {
|
|
79
|
+
* formsAppEnvironmentId: 1,
|
|
80
|
+
* urL: 'https://my-url.com/lookup',
|
|
81
|
+
* },
|
|
82
|
+
* ],
|
|
83
|
+
* type: 'DATA',
|
|
84
|
+
* organisationId: '',
|
|
85
|
+
* }
|
|
86
|
+
* const createdLookup = await lookups.createFormElementLookup(newLookup)
|
|
87
|
+
* // Use lookup here
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @param newFormElementLookup
|
|
91
|
+
* @returns
|
|
92
|
+
*/
|
|
93
|
+
async createFormElementLookup(newFormElementLookup) {
|
|
94
|
+
if (!newFormElementLookup || typeof newFormElementLookup !== 'object') {
|
|
95
|
+
throw new TypeError('Must supply "newLookup" as an object');
|
|
96
|
+
}
|
|
97
|
+
return super.postRequest(`/form-element-lookups`, newFormElementLookup);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* #### Example
|
|
101
|
+
*
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const lookup = {
|
|
104
|
+
* id: 1,
|
|
105
|
+
* createdAt: '2023-06-28T02:00:03.000Z',
|
|
106
|
+
* updatedAt: '2023-06-28T02:00:03.000Z',
|
|
107
|
+
* name: 'My New Lookup',
|
|
108
|
+
* environments: [
|
|
109
|
+
* {
|
|
110
|
+
* formsAppEnvironmentId: 1,
|
|
111
|
+
* url: 'https://my-url.com/lookup',
|
|
112
|
+
* },
|
|
113
|
+
* ],
|
|
114
|
+
* type: 'DATA',
|
|
115
|
+
* organisationId: '',
|
|
116
|
+
* }
|
|
117
|
+
* const updatedLookup = await formElementLookups.updateFormElementLookup(
|
|
118
|
+
* lookup,
|
|
119
|
+
* )
|
|
120
|
+
* // Use lookup here
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @param formElementLookup
|
|
124
|
+
* @returns
|
|
125
|
+
*/
|
|
126
|
+
async updateFormElementLookup(formElementLookup) {
|
|
127
|
+
if (!formElementLookup || typeof formElementLookup !== 'object') {
|
|
128
|
+
throw new TypeError('Must supply "updatedLookup" as an object');
|
|
129
|
+
}
|
|
130
|
+
return super.putRequest(`/form-element-lookups/${formElementLookup.id}`, formElementLookup);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* #### Example
|
|
134
|
+
*
|
|
135
|
+
* ```typescript
|
|
136
|
+
* const lookupId = 7
|
|
137
|
+
* await formElementLookups.deleteFormElementLookup(lookupId)
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* @param id The id of the lookup to delete
|
|
141
|
+
* @returns
|
|
142
|
+
*/
|
|
143
|
+
async deleteFormElementLookup(id) {
|
|
144
|
+
if (typeof id !== 'number' || Number.isNaN(id)) {
|
|
145
|
+
throw new TypeError('Must supply "id" as a number');
|
|
146
|
+
}
|
|
147
|
+
return super.deleteRequest(`/form-element-lookups/${id}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.default = FormElementLookups;
|
|
151
|
+
//# sourceMappingURL=FormElementLookups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormElementLookups.js","sourceRoot":"","sources":["../../src/classes/FormElementLookups.ts"],"names":[],"mappings":";;;;;AACA,yEAA8C;AAG9C,MAAqB,kBAAmB,SAAQ,uBAAW;IACzD;;;;;;;;;;;;OAYG;IACH,YAAY,OAA2B;QACrC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAA;QACvB,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;IAC7C,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,oBAAoB,CAAC,EAAU;QACnC,IAAI,OAAO,EAAE,K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;IACH,KAAK,CAAC,uBAAuB,CAAC,EAAU;QACtC,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;YAC9C,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAA;SACpD;QACD,OAAO,KAAK,CAAC,aAAa,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAA;IAC3D,CAAC;CACF;AAtKD,qCAsKC"}
|
|
@@ -9,5 +9,7 @@ import Approvals from './Approvals';
|
|
|
9
9
|
import FormsAppEnvironments from './FormsAppEnvironments';
|
|
10
10
|
import EmailTemplates from './EmailTemplates';
|
|
11
11
|
import DataManager from './DataManager';
|
|
12
|
+
import FormElementLookups from './FormElementLookups';
|
|
13
|
+
import FormElementLists from './FormElementLists';
|
|
12
14
|
import sendEmail from './sendEmail';
|
|
13
|
-
export { Forms, FormsApps, Jobs, Keys, Organisations, TeamMembers, PDF, Approvals, FormsAppEnvironments, EmailTemplates, DataManager, sendEmail, };
|
|
15
|
+
export { Forms, FormsApps, Jobs, Keys, Organisations, TeamMembers, PDF, Approvals, FormsAppEnvironments, EmailTemplates, DataManager, FormElementLookups, FormElementLists, sendEmail, };
|
package/tenants/classes/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.sendEmail = exports.DataManager = exports.EmailTemplates = exports.FormsAppEnvironments = exports.Approvals = exports.PDF = exports.TeamMembers = exports.Organisations = exports.Keys = exports.Jobs = exports.FormsApps = exports.Forms = void 0;
|
|
6
|
+
exports.sendEmail = exports.FormElementLists = exports.FormElementLookups = exports.DataManager = exports.EmailTemplates = exports.FormsAppEnvironments = exports.Approvals = exports.PDF = exports.TeamMembers = exports.Organisations = exports.Keys = exports.Jobs = exports.FormsApps = exports.Forms = void 0;
|
|
7
7
|
// Classes
|
|
8
8
|
const Forms_1 = __importDefault(require("./Forms"));
|
|
9
9
|
exports.Forms = Forms_1.default;
|
|
@@ -27,6 +27,10 @@ const EmailTemplates_1 = __importDefault(require("./EmailTemplates"));
|
|
|
27
27
|
exports.EmailTemplates = EmailTemplates_1.default;
|
|
28
28
|
const DataManager_1 = __importDefault(require("./DataManager"));
|
|
29
29
|
exports.DataManager = DataManager_1.default;
|
|
30
|
+
const FormElementLookups_1 = __importDefault(require("./FormElementLookups"));
|
|
31
|
+
exports.FormElementLookups = FormElementLookups_1.default;
|
|
32
|
+
const FormElementLists_1 = __importDefault(require("./FormElementLists"));
|
|
33
|
+
exports.FormElementLists = FormElementLists_1.default;
|
|
30
34
|
// Functions
|
|
31
35
|
const sendEmail_1 = __importDefault(require("./sendEmail"));
|
|
32
36
|
exports.sendEmail = sendEmail_1.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/classes/index.ts"],"names":[],"mappings":";;;;;;AAAA,UAAU;AACV,oDAA2B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/classes/index.ts"],"names":[],"mappings":";;;;;;AAAA,UAAU;AACV,oDAA2B;AAiBzB,gBAjBK,eAAK,CAiBL;AAhBP,4DAAmC;AAiBjC,oBAjBK,mBAAS,CAiBL;AAhBX,kDAAyB;AAiBvB,eAjBK,cAAI,CAiBL;AAhBN,kDAAyB;AAiBvB,eAjBK,cAAI,CAiBL;AAhBN,oEAA2C;AAiBzC,wBAjBK,uBAAa,CAiBL;AAhBf,gEAAuC;AAiBrC,sBAjBK,qBAAW,CAiBL;AAhBb,gDAAuB;AAiBrB,cAjBK,aAAG,CAiBL;AAhBL,4DAAmC;AAiBjC,oBAjBK,mBAAS,CAiBL;AAhBX,kFAAyD;AAiBvD,+BAjBK,8BAAoB,CAiBL;AAhBtB,sEAA6C;AAiB3C,yBAjBK,wBAAc,CAiBL;AAhBhB,gEAAuC;AAiBrC,sBAjBK,qBAAW,CAiBL;AAhBb,8EAAqD;AAiBnD,6BAjBK,4BAAkB,CAiBL;AAhBpB,0EAAiD;AAiB/C,2BAjBK,0BAAgB,CAiBL;AAhBlB,YAAY;AACZ,4DAAmC;AAgBjC,oBAhBK,mBAAS,CAgBL"}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { FormTypes } from '@oneblink/types';
|
|
2
2
|
import Joi from 'joi';
|
|
3
3
|
export declare function validateJoiSchema<T>(data: unknown, schema: Joi.Schema, options?: Joi.ValidationOptions): T;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Reduce an array of form elements down to the elements that are not purely to
|
|
6
|
+
* determine the layout of the form. I.e. Strips out "page" and "section" form
|
|
7
|
+
* elements as they only contribute to the layout of the form. "repeatableSet"
|
|
8
|
+
* form elements are not stripped out because they contribute to the submission
|
|
9
|
+
* data.
|
|
10
|
+
*
|
|
11
|
+
* @param elements
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare const stripLayoutFormElements: (elements: Array<FormTypes.FormElement>) => Array<FormTypes.FormElement>;
|
|
5
15
|
export declare function validateElementNamesAcrossNestedElements(elements: FormTypes.FormElement[]): string[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateElementNamesAcrossNestedElements = exports.
|
|
3
|
+
exports.validateElementNamesAcrossNestedElements = exports.stripLayoutFormElements = exports.validateJoiSchema = void 0;
|
|
4
|
+
const sdk_core_1 = require("@oneblink/sdk-core");
|
|
4
5
|
function validateJoiSchema(data, schema, options) {
|
|
5
6
|
const result = schema.validate(data, options);
|
|
6
7
|
if (result.error) {
|
|
@@ -9,11 +10,22 @@ function validateJoiSchema(data, schema, options) {
|
|
|
9
10
|
return result.value;
|
|
10
11
|
}
|
|
11
12
|
exports.validateJoiSchema = validateJoiSchema;
|
|
12
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Reduce an array of form elements down to the elements that are not purely to
|
|
15
|
+
* determine the layout of the form. I.e. Strips out "page" and "section" form
|
|
16
|
+
* elements as they only contribute to the layout of the form. "repeatableSet"
|
|
17
|
+
* form elements are not stripped out because they contribute to the submission
|
|
18
|
+
* data.
|
|
19
|
+
*
|
|
20
|
+
* @param elements
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
const stripLayoutFormElements = (elements) => {
|
|
13
24
|
const rootFormElements = [];
|
|
14
25
|
for (const element of elements) {
|
|
15
|
-
|
|
16
|
-
|
|
26
|
+
const namelessElement = sdk_core_1.typeCastService.formElements.toNamelessElement(element);
|
|
27
|
+
if (namelessElement) {
|
|
28
|
+
rootFormElements.push(...(0, exports.stripLayoutFormElements)(namelessElement.elements));
|
|
17
29
|
}
|
|
18
30
|
else {
|
|
19
31
|
rootFormElements.push(element);
|
|
@@ -21,7 +33,7 @@ const getRootFormElements = (elements) => {
|
|
|
21
33
|
}
|
|
22
34
|
return rootFormElements;
|
|
23
35
|
};
|
|
24
|
-
exports.
|
|
36
|
+
exports.stripLayoutFormElements = stripLayoutFormElements;
|
|
25
37
|
function checkElementNameUniqueness(elementNames, name) {
|
|
26
38
|
// check if name already exists
|
|
27
39
|
const existingName = elementNames.find((e) => e === name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/lib/forms-validation/common.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/lib/forms-validation/common.ts"],"names":[],"mappings":";;;AAAA,iDAAoD;AAIpD,SAAgB,iBAAiB,CAC/B,IAAa,EACb,MAAkB,EAClB,OAA+B;IAE/B,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAC7C,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,MAAM,MA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C,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aACxB;SACF;aAAM;YACL,0BAA0B,CAAC,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;YACtD,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;SAChC;KACF;IACD,OAAO,YAAY,CAAA;AACrB,CAAC;AAnBD,4FAmBC"}
|
|
@@ -41,7 +41,7 @@ function validateFormEventData(formElements, workflowEvent) {
|
|
|
41
41
|
formEvent,
|
|
42
42
|
propertyName: 'formEvent',
|
|
43
43
|
validatedFormElements: formElements,
|
|
44
|
-
rootFormElements: (0, common_1.
|
|
44
|
+
rootFormElements: (0, common_1.stripLayoutFormElements)(formElements),
|
|
45
45
|
});
|
|
46
46
|
return formEvent;
|
|
47
47
|
}
|
|
@@ -58,18 +58,63 @@ function validateReferenceDate({ element, referenceType, elements, }) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
function validateFormElementReferences(
|
|
61
|
+
function validateFormElementReferences(formElements) {
|
|
62
|
+
const availableFormElements = (0, common_1.stripLayoutFormElements)(formElements);
|
|
62
63
|
// Element References
|
|
63
|
-
for (const element of
|
|
64
|
+
for (const element of availableFormElements) {
|
|
64
65
|
switch (element.type) {
|
|
66
|
+
case 'date':
|
|
67
|
+
case 'datetime': {
|
|
68
|
+
if (element.toDateElementId) {
|
|
69
|
+
validateReferenceDate({
|
|
70
|
+
element,
|
|
71
|
+
referenceType: 'toDateElementId',
|
|
72
|
+
elements: availableFormElements,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (element.fromDateElementId) {
|
|
76
|
+
validateReferenceDate({
|
|
77
|
+
element,
|
|
78
|
+
referenceType: 'fromDateElementId',
|
|
79
|
+
elements: availableFormElements,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case 'repeatableSet': {
|
|
85
|
+
(0, common_1.validateElementNamesAcrossNestedElements)(element.elements);
|
|
86
|
+
validateFormElementReferences(element.elements);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Validate each summary form element's references to other form elements. A
|
|
94
|
+
* summary form element can reference form elements from anywhere in the form.
|
|
95
|
+
*
|
|
96
|
+
* @param form
|
|
97
|
+
* @param formElements
|
|
98
|
+
*/
|
|
99
|
+
function validateSummaryFormElements(form, formElements, propertyName) {
|
|
100
|
+
for (let formElementIndex = 0; formElementIndex < formElements.length; formElementIndex++) {
|
|
101
|
+
const element = formElements[formElementIndex];
|
|
102
|
+
switch (element.type) {
|
|
103
|
+
case 'section':
|
|
104
|
+
case 'page':
|
|
105
|
+
case 'repeatableSet': {
|
|
106
|
+
validateSummaryFormElements(form, element.elements, `${propertyName}[${formElementIndex}].elements`);
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
65
109
|
case 'summary': {
|
|
66
|
-
element.elementIds.
|
|
110
|
+
for (let elementIdIndex = 0; elementIdIndex < element.elementIds.length; elementIdIndex++) {
|
|
111
|
+
const elementId = element.elementIds[elementIdIndex];
|
|
67
112
|
if (elementId === element.id) {
|
|
68
|
-
throw new Error(
|
|
113
|
+
throw new Error(`"${propertyName}[${formElementIndex}].elementIds" cannot contain a reference to itself`);
|
|
69
114
|
}
|
|
70
|
-
const summarizedElement = sdk_core_1.formElementsService.findFormElement(
|
|
115
|
+
const summarizedElement = sdk_core_1.formElementsService.findFormElement(form.elements, (formElement) => formElement.id === elementId);
|
|
71
116
|
if (!summarizedElement) {
|
|
72
|
-
throw new Error(
|
|
117
|
+
throw new Error(`"${propertyName}[${formElementIndex}].elementIds[${elementIdIndex}]" (${elementId}) does not exist in "elements"`);
|
|
73
118
|
}
|
|
74
119
|
const validSummaryElementTypes = [
|
|
75
120
|
'text',
|
|
@@ -88,33 +133,9 @@ function validateFormElementReferences(rootElements, formElements) {
|
|
|
88
133
|
'calculation',
|
|
89
134
|
];
|
|
90
135
|
if (!validSummaryElementTypes.some((type) => type === summarizedElement.type)) {
|
|
91
|
-
throw new Error(
|
|
136
|
+
throw new Error(`"${propertyName}[${formElementIndex}].elementIds[${elementIdIndex}]" (${elementId}) references a form element type (${summarizedElement.type}) that cannot be summarised`);
|
|
92
137
|
}
|
|
93
|
-
});
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
case 'date':
|
|
97
|
-
case 'datetime': {
|
|
98
|
-
if (element.toDateElementId) {
|
|
99
|
-
validateReferenceDate({
|
|
100
|
-
element,
|
|
101
|
-
referenceType: 'toDateElementId',
|
|
102
|
-
elements: rootElements,
|
|
103
|
-
});
|
|
104
138
|
}
|
|
105
|
-
if (element.fromDateElementId) {
|
|
106
|
-
validateReferenceDate({
|
|
107
|
-
element,
|
|
108
|
-
referenceType: 'fromDateElementId',
|
|
109
|
-
elements: rootElements,
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
case 'repeatableSet': {
|
|
115
|
-
(0, common_1.validateElementNamesAcrossNestedElements)(element.elements);
|
|
116
|
-
const repSetRootElements = (0, common_1.getRootFormElements)(element.elements);
|
|
117
|
-
validateFormElementReferences(repSetRootElements, element.elements);
|
|
118
139
|
break;
|
|
119
140
|
}
|
|
120
141
|
}
|
|
@@ -136,8 +157,9 @@ function validateWithFormSchema(form) {
|
|
|
136
157
|
if (!validatedForm.submissionEvents) {
|
|
137
158
|
validatedForm.submissionEvents = [];
|
|
138
159
|
}
|
|
139
|
-
|
|
140
|
-
validateFormElementReferences(
|
|
160
|
+
validateSummaryFormElements(validatedForm, validatedForm.elements, 'elements');
|
|
161
|
+
validateFormElementReferences(validatedForm.elements);
|
|
162
|
+
const rootFormElements = (0, common_1.stripLayoutFormElements)(validatedForm.elements);
|
|
141
163
|
// Form Event References
|
|
142
164
|
const formEventPropsToValidate = [
|
|
143
165
|
'draftEvents',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/forms-validation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAqB;AACrB,iDAAwD;AAMxD,kDAMwB;AACxB,uEAAkF;AAClF,qCAIiB;AACjB,+EAA8E;AAE9E,SAAS,qBAAqB,CAC5B,YAAqC,EACrC,aAAsB;IAEtB,MAAM,SAAS,GAAG,IAAA,0BAAiB,EAAC,aAAa,EAAE,kCAAmB,EAAE;QACtE,YAAY,EAAE,IAAI;KACnB,CAAmC,CAAA;IACpC,IAAA,wCAAiB,EAAC;QAChB,SAAS;QACT,YAAY,EAAE,WAAW;QACzB,qBAAqB,EAAE,YAAY;QACnC,gBAAgB,EAAE,IAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/forms-validation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAqB;AACrB,iDAAwD;AAMxD,kDAMwB;AACxB,uEAAkF;AAClF,qCAIiB;AACjB,+EAA8E;AAE9E,SAAS,qBAAqB,CAC5B,YAAqC,EACrC,aAAsB;IAEtB,MAAM,SAAS,GAAG,IAAA,0BAAiB,EAAC,aAAa,EAAE,kCAAmB,EAAE;QACtE,YAAY,EAAE,IAAI;KACnB,CAAmC,CAAA;IACpC,IAAA,wCAAiB,EAAC;QAChB,SAAS;QACT,YAAY,EAAE,WAAW;QACzB,qBAAqB,EAAE,YAAY;QACnC,gBAAgB,EAAE,IAAA,gCAAuB,EAAC,YAAY,CAAC;KACxD,CAAC,CAAA;IACF,OAAO,SAAS,CAAA;AAClB,CAAC;AAiRC,sDAAqB;AA/QvB,SAAS,qBAAqB,CAAC,EAC7B,OAAO,EACP,aAAa,EACb,QAAQ,GAKT;IACC,IAAI,OAAO,CAAC,aAAa,CAAC,EAAE;QAC1B,4CAA4C;QAC5C,MAAM,iBAAiB,GAAG,QAAQ,CAAC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,GAAG,IAAA,0BAAiB,EAAI,OAAO,EAAE,4BAAa,EAAE;QACpE,YAAY,EAAE,IAAI;KACnB,CAAC,CAAA;IAEF,OAAO,gBAAgB,CAAA;AACzB,CAAC;AA+CC,8DAAyB;AA7C3B,SAAS,6BAA6B,CACpC,OAAgB;IAEhB,MAAM,gBAAgB,GAAG,IAAA,0BAAiB,EACxC,OAAO,EACP,gCAAiB,EACjB;QACE,YAAY,EAAE,IAAI;KACnB,CACF,CAAA;IACD,OAAO,gBAAgB,CAAA;AACzB,CAAC;AAmCC,sEAA6B;AAjC/B,SAAS,6BAA6B,CACpC,UAA0B;IAE1B,MAAM,MAAM,GAAG,aAAG,CAAC,KAAK,EAAE;SACvB,GAAG,CAAC,CAAC,CAAC;SACN,KAAK,CAAC,kDAA+B,CAAC;SACtC,QAAQ,EAAE,CAAA;IAEb,MAAM,mBAAmB,GAAG,IAAA,0BAAiB,EAE3C,UAAU,EAAE,MAAM,EAAE;QACpB,YAAY,EAAE,IAAI;KACnB,CAAC,CAAA;IACF,OAAO,mBAAmB,CAAA;AAC5B,CAAC;AAoBC,sEAA6B;AAlB/B,SAAS,kBAAkB,CACzB,UAAmB;IAEnB,MAAM,mBAAmB,GAAG,IAAA,0BAAiB,EAC3C,UAAU,EACV,+BAAgB,EAChB;QACE,YAAY,EAAE,IAAI;KACnB,CACF,CAAA;IACD,OAAO,mBAAmB,CAAA;AAC5B,CAAC;AAQC,gDAAkB"}
|
package/tenants/types.d.ts
CHANGED
|
@@ -15,7 +15,10 @@ export type PreFillMeta = AWSTypes.FormS3Credentials & {
|
|
|
15
15
|
export type BaseSearchOptions = {
|
|
16
16
|
/** Limit the number of results returned */
|
|
17
17
|
limit?: number;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Skip a specific number of results, used in conjunction with `limit` to
|
|
20
|
+
* enforce paging
|
|
21
|
+
*/
|
|
19
22
|
offset?: number;
|
|
20
23
|
};
|
|
21
24
|
export type TenantBase = {
|
|
@@ -64,7 +67,10 @@ export type FormsSearchOptions = BaseSearchOptions & {
|
|
|
64
67
|
* or `false` or not specified.
|
|
65
68
|
*/
|
|
66
69
|
isAuthenticated?: boolean;
|
|
67
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Search on the `name` property of a form. Can be a prefix, suffix or partial
|
|
72
|
+
* match
|
|
73
|
+
*/
|
|
68
74
|
name?: string;
|
|
69
75
|
/**
|
|
70
76
|
* Search on the `formsAppIds` property of a form. Must be the exact match of
|
|
@@ -141,7 +147,10 @@ export type JobsSearchResult = MiscTypes.BaseSearchResult & {
|
|
|
141
147
|
jobs: SubmissionTypes.FormsAppJob[];
|
|
142
148
|
};
|
|
143
149
|
export type DataManagerRegexFilter = {
|
|
144
|
-
/**
|
|
150
|
+
/**
|
|
151
|
+
* The Regular expression to search with. This can just be a simple string if
|
|
152
|
+
* desired.
|
|
153
|
+
*/
|
|
145
154
|
$regex: string;
|
|
146
155
|
/**
|
|
147
156
|
* Regex options. String with any combination of the following characters:
|
|
@@ -215,7 +224,10 @@ export type DataManagerFreshdeskDependentFieldFilter = {
|
|
|
215
224
|
* `select` element.
|
|
216
225
|
*/
|
|
217
226
|
subCategory?: DataManagerStringArrayFilter;
|
|
218
|
-
/**
|
|
227
|
+
/**
|
|
228
|
+
* The filter for the `item`. This property is treated as a non multi `select`
|
|
229
|
+
* element.
|
|
230
|
+
*/
|
|
219
231
|
item?: DataManagerStringArrayFilter;
|
|
220
232
|
};
|
|
221
233
|
export type DataManagerNestedFilterFilter = {
|
|
@@ -236,7 +248,8 @@ export type DataManagerNestedFilterFilter = {
|
|
|
236
248
|
* Element of type: checkboxes, select (multi): USE
|
|
237
249
|
* `DataManagerMultipleSelectionsArrayFilter`.
|
|
238
250
|
*
|
|
239
|
-
* Element of type: radio, autocomplete, select: USE
|
|
251
|
+
* Element of type: radio, autocomplete, select: USE
|
|
252
|
+
* `DataManagerStringArrayFilter`.
|
|
240
253
|
*
|
|
241
254
|
* Element of type: boolean: USE `DataManagerBooleanFilter`.
|
|
242
255
|
*
|
|
@@ -301,3 +314,12 @@ export type SearchDataManagerRecordsResponse = {
|
|
|
301
314
|
};
|
|
302
315
|
submissions: Array<FormStoreRecord>;
|
|
303
316
|
};
|
|
317
|
+
export type FormElementLookupSearchResult = {
|
|
318
|
+
formElementLookups: FormTypes.FormElementLookup[];
|
|
319
|
+
} & MiscTypes.BaseSearchResult;
|
|
320
|
+
export type FormElementListSearchResult = {
|
|
321
|
+
formElementLists: FormTypes.FormElementOptionSet[];
|
|
322
|
+
} & MiscTypes.BaseSearchResult;
|
|
323
|
+
export type FormElementListSearchOptions = BaseSearchOptions & {
|
|
324
|
+
organisationId: string;
|
|
325
|
+
};
|