@appsemble/utils 0.20.45 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +3 -3
  2. package/api/components/schemas/ObjectRemapperDefinition.js +6 -504
  3. package/api/components/schemas/RequestActionDefinition.js +1 -1
  4. package/api/components/schemas/ScimPatchOp.d.ts +2 -0
  5. package/api/components/schemas/ScimPatchOp.js +47 -0
  6. package/api/components/schemas/ScimSecret.d.ts +2 -0
  7. package/api/components/schemas/ScimSecret.js +16 -0
  8. package/api/components/schemas/ScimUser.d.ts +2 -0
  9. package/api/components/schemas/ScimUser.js +60 -0
  10. package/api/components/schemas/index.d.ts +3 -0
  11. package/api/components/schemas/index.js +3 -0
  12. package/api/components/securitySchemes/index.d.ts +1 -0
  13. package/api/components/securitySchemes/index.js +1 -0
  14. package/api/components/securitySchemes/scim.d.ts +2 -0
  15. package/api/components/securitySchemes/scim.js +6 -0
  16. package/api/index.test.js +1 -1
  17. package/api/paths/appScimEndpoints.d.ts +2 -0
  18. package/api/paths/appScimEndpoints.js +260 -0
  19. package/api/paths/appScimSecrets.d.ts +2 -0
  20. package/api/paths/appScimSecrets.js +45 -0
  21. package/api/paths/index.js +4 -0
  22. package/appMessages.test.js +1 -1
  23. package/iterApp.test.js +44 -48
  24. package/jsonschema.test.js +8 -8
  25. package/package.json +3 -3
  26. package/reference-schemas/remappers/arrays.d.ts +2 -0
  27. package/reference-schemas/remappers/arrays.js +334 -0
  28. package/reference-schemas/remappers/conditionals.d.ts +2 -0
  29. package/reference-schemas/remappers/conditionals.js +93 -0
  30. package/reference-schemas/remappers/data.d.ts +2 -0
  31. package/reference-schemas/remappers/data.js +321 -0
  32. package/reference-schemas/remappers/dates.d.ts +2 -0
  33. package/reference-schemas/remappers/dates.js +38 -0
  34. package/reference-schemas/remappers/history.d.ts +2 -0
  35. package/reference-schemas/remappers/history.js +246 -0
  36. package/reference-schemas/remappers/index.d.ts +9 -0
  37. package/reference-schemas/remappers/index.js +10 -0
  38. package/reference-schemas/remappers/objects.d.ts +2 -0
  39. package/reference-schemas/remappers/objects.js +157 -0
  40. package/reference-schemas/remappers/randoms.d.ts +2 -0
  41. package/reference-schemas/remappers/randoms.js +35 -0
  42. package/reference-schemas/remappers/strings.d.ts +2 -0
  43. package/reference-schemas/remappers/strings.js +81 -0
  44. package/reference-schemas/remappers/unsorted.d.ts +2 -0
  45. package/reference-schemas/remappers/unsorted.js +71 -0
  46. package/remap.test.js +8 -9
  47. package/vitest.config.d.ts +2 -0
@@ -0,0 +1,321 @@
1
+ export const dataRemappers = {
2
+ array: {
3
+ enum: ['index', 'length'],
4
+ description: `Get the current array.map’s index or length.
5
+
6
+ Returns nothing when not in the context of \`array.map’s\`.
7
+ `,
8
+ },
9
+ app: {
10
+ enum: ['id', 'locale', 'url'],
11
+ description: `Gives actual information about the current app. Using this remapper you will have access to the
12
+ following information:
13
+
14
+ - \`id\`: App ID
15
+ - \`locale\`: Current locale (user selected language) of the app
16
+ - \`url\`: Base URL of the app
17
+
18
+ Example:
19
+
20
+ \`\`\`json
21
+ {
22
+ "id": 11,
23
+ "locale": "en",
24
+ "url": "https://example-app.examplecompany.appsemble.app"
25
+ }
26
+ \`\`\`
27
+ `,
28
+ },
29
+ context: {
30
+ type: 'string',
31
+ description: `Gets a property from custom context passed by blocks. This property is specific to each block. To
32
+ understand what the context of a certain block does, check the block’s description.
33
+
34
+ For this example, we will take the [\`table\`](/blocks/@appsemble/table/0.20.39) block. As of now,
35
+ this block provides two options for context: \`index\` and \`repeatedIndex\`. Whenever you click on an
36
+ item in the table, it gives the index of that table row in the associated action.
37
+
38
+ So with the following example:
39
+
40
+ \`\`\`yaml
41
+ type: table
42
+ version: 0.20.39
43
+ events:
44
+ listen:
45
+ data: contextData
46
+ parameters:
47
+ fields:
48
+ - label: Name
49
+ value: { prop: name }
50
+ onClick: clickName
51
+ - label: Age
52
+ value: { prop: age }
53
+ actions:
54
+ clickName:
55
+ remapBefore:
56
+ context: index
57
+ type: log
58
+ \`\`\`
59
+
60
+ Clicking on the first item would log \`0\`, the second item \`1\` and so on.
61
+ `,
62
+ },
63
+ history: {
64
+ type: 'integer',
65
+ description: `> **Note:** This remapper is explained more in depth in the [History](/docs/remapper/history) page
66
+
67
+ Gives the data at the history entry at the specified history index. The history at specified index
68
+ is the data that is passed to that action.
69
+
70
+ \`\`\`yaml
71
+ remapBefore:
72
+ object.from:
73
+ title: Most influential bands of all time
74
+ content: ...
75
+ type: noop # history 0
76
+ onSuccess:
77
+ type: resource.query # history 1
78
+ resource: people
79
+ onSuccess:
80
+ type: noop # history 2
81
+ onSuccess:
82
+ remapBefore:
83
+ history: 1
84
+ type: log # history 3
85
+ \`\`\`
86
+
87
+ Result:
88
+
89
+ \`\`\`json
90
+ {
91
+ "title": "Most influential bands of all time",
92
+ "content": ...
93
+ }
94
+ \`\`\`
95
+ `,
96
+ },
97
+ step: {
98
+ type: 'string',
99
+ description: `
100
+
101
+ While in a loop page, this remapper allows you to get properties from the data at the current index.
102
+
103
+ \`\`\`yaml
104
+ name: Survey
105
+ type: loop
106
+ actions:
107
+ onLoad:
108
+ type: resource.query
109
+ resource: questions
110
+ foreach:
111
+ blocks:
112
+ - type: detail-viewer
113
+ version: 0.20.39
114
+ parameters:
115
+ fields:
116
+ - label: { step: title }
117
+ \`\`\`
118
+
119
+ With this example, we load an array of questions that have the \`title\` property. What the \`step\`
120
+ remapper does in this case is show the title of the current question in the loop.
121
+
122
+ The result of this is a flow page where each page shows the question’s title.
123
+
124
+ `,
125
+ },
126
+ page: {
127
+ enum: ['data', 'url'],
128
+ description: `Gives actual information about the current page. This remapper gives access to the following
129
+ information:
130
+
131
+ - \`data\`: Current page data (FlowPage)
132
+ - \`url\`: Full URL of the current page
133
+
134
+ Example:
135
+
136
+ \`\`\`json
137
+ {
138
+ "data": {
139
+ "name": "Peter"
140
+ },
141
+ "url": "https://example-app.examplecompany.appsemble.app/en/example-page-a"
142
+ }
143
+ \`\`\`
144
+
145
+ The page data only works in the context of a flow page. Let’s say you have a
146
+ [“FlowPage”](/docs/reference/app#-flow-page-definition) type with multiple subpages. Whenever you
147
+ navigate to the next page it adds the data from that page to the flow page’s data. The page remapper
148
+ allows you to access this cumulative data.
149
+
150
+ The following page definition shows a page definition for a flow page where the user has to fill in
151
+ some user information. For each subpage the result of \`page: data\` is shown.
152
+
153
+
154
+ \`\`\`yaml
155
+ name: PageDataFlow
156
+ type: flow
157
+ steps:
158
+ # page: data = {}
159
+ - blocks:
160
+ - type: form
161
+ version: 0.20.39
162
+ parameters:
163
+ fields:
164
+ - name: name
165
+ type: string
166
+ actions:
167
+ onSubmit:
168
+ type: flow.next
169
+ # page: data = { name: "Peter" }
170
+ - blocks:
171
+ - type: form
172
+ version: 0.20.39
173
+ parameters:
174
+ fields:
175
+ - name: age
176
+ type: string
177
+ actions:
178
+ onSubmit:
179
+ type: flow.next
180
+ # page: data = { name: "Peter", age: "47" }
181
+ - blocks:
182
+ - type: data-loader
183
+ version: 0.20.39
184
+ actions:
185
+ onLoad:
186
+ remapBefore:
187
+ page: data
188
+ type: log
189
+ \`\`\`
190
+
191
+ The result of the final page’s log would then be:
192
+
193
+ \`\`\`json
194
+ {
195
+ "name": "Peter",
196
+ "age": "47"
197
+ }
198
+ \`\`\`
199
+
200
+ `,
201
+ },
202
+ prop: {
203
+ anyOf: [
204
+ { type: 'string' },
205
+ { type: 'integer' },
206
+ { type: 'array', minItems: 1, items: { anyOf: [{ type: 'string' }, { type: 'integer' }] } },
207
+ ],
208
+ description: `Gets the chosen property from an object.
209
+
210
+ \`\`\`json
211
+ {
212
+ "name": "John",
213
+ "age": 52
214
+ }
215
+ \`\`\`
216
+
217
+ \`\`\`yaml
218
+ prop: name
219
+ \`\`\`
220
+
221
+ Result:
222
+
223
+ \`\`\`json
224
+ "John"
225
+ \`\`\`
226
+ `,
227
+ },
228
+ root: {
229
+ enum: [null],
230
+ description: `Gets the input data as it was initially passed to the remapper function.
231
+
232
+ \`\`\`yaml
233
+ type: resource.query
234
+ resource: people
235
+ query:
236
+ object.from:
237
+ $filter: city eq 'Eindhoven'
238
+ onSuccess:
239
+ remapBefore:
240
+ object.from:
241
+ name: Residents of Eindhoven
242
+ people:
243
+ root: null
244
+ \`\`\`
245
+
246
+ Result:
247
+
248
+ \`\`\`json
249
+ {
250
+ "name": "Residents of Eindhoven",
251
+ "people": [
252
+ {
253
+ "name": ...,
254
+ "city": "Eindhoven"
255
+ },
256
+ ...
257
+ ]
258
+ }
259
+ \`\`\`
260
+ `,
261
+ },
262
+ static: {
263
+ description: 'Use a static value.',
264
+ },
265
+ translate: {
266
+ type: 'string',
267
+ description: `> **Note:** This is explained much more in depth at [Translating](/docs/03-guide/translating)
268
+
269
+ This remapper allows you to easily add translations to your app. To make this remapper work, replace
270
+ any static text with \`translate: {name}\`. Then, in your app’s Translations page pick the language
271
+ you want to translate. You will see a list of names with input text below. Translations you manually
272
+ put in the app using the \`translate\` remapper are found under “Custom messages”.
273
+
274
+ After putting the translation in, any user that logs in with that language selected will see the
275
+ translated message.
276
+
277
+ Example:
278
+
279
+ \`\`\`yaml
280
+ type: detail-viewer
281
+ version: 0.20.39
282
+ parameters:
283
+ fields:
284
+ - label: { translate: weatherTitle }
285
+ value: { translate: weatherBody }
286
+ \`\`\`
287
+
288
+ `,
289
+ },
290
+ user: {
291
+ enum: ['sub', 'name', 'email', 'email_verified', 'picture', 'profile', 'locale'],
292
+ description: `
293
+ > **Note:** For this remapper to work, the user that activated the remapper has to be logged in to
294
+ > the app
295
+
296
+ Provides some fields of user information taken from the OpenID user info. These fields are:
297
+
298
+ - \`email\`: User’s **primary** email address
299
+ - \`email_verified\`: Whether the user’s primary email address is verified or not (\`boolean\`)
300
+ - \`locale\`: The user’s default language [\`BCP47\`](https://en.wikipedia.org/wiki/IETF_language_tag)
301
+ language tag (ex. \`en\`) (Broken)
302
+ - \`name\`: The user’s name
303
+ - \`picture\`: Full URL to the user’s profile picture web address
304
+ - \`sub\`: The user’s identifier
305
+
306
+ Example:
307
+
308
+ \`\`\`json
309
+ {
310
+ "email": "example@hotmail.nl",
311
+ "email_verified": true,
312
+ "locale": "en",
313
+ "name": "Test User",
314
+ "picture": "https://www.gravatar.com/avatar/f46b82357ce29bcd1099915946cda468?s=128&d=mp",
315
+ "sub": "5c6270e2-ad31-414f-bcab-6752a2c4dcfd"
316
+ }
317
+ \`\`\`
318
+ `,
319
+ },
320
+ };
321
+ //# sourceMappingURL=data.js.map
@@ -0,0 +1,2 @@
1
+ import { type OpenAPIV3 } from 'openapi-types';
2
+ export declare const dateRemappers: Record<string, OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject>;
@@ -0,0 +1,38 @@
1
+ export const dateRemappers = {
2
+ 'date.add': {
3
+ type: 'string',
4
+ description: 'Add the specified value to a given date.',
5
+ },
6
+ 'date.format': {
7
+ enum: [null],
8
+ description: 'Format a date according to rfc3339.',
9
+ },
10
+ 'date.now': {
11
+ enum: [null],
12
+ description: 'Returns the current date.',
13
+ },
14
+ 'date.parse': {
15
+ type: 'string',
16
+ description: `Convert a string to a date using a given format.
17
+
18
+ For example:
19
+ \`\`\`yaml
20
+ - static: 02/11/2014 # The date string to parse
21
+ - date.parse: MM/dd/yyyy # The given format to parse the date with
22
+ # => Tue Feb 11 2014 00:00:00
23
+ \`\`\`
24
+
25
+ See [date-fns](https://date-fns.org/v2.29.3/docs/parse) for the supported formats.
26
+
27
+ Leaving the format empty will try to parse the date using the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
28
+ For example:
29
+ \`\`\`yaml
30
+ date.parse:
31
+ - static: 2014-02-11T11:30:30 # The date string to parse
32
+ - date.parse: '' # The given format to parse the date with
33
+ # => Tue Feb 11 2014 11:30:30
34
+ \`\`\`
35
+ `,
36
+ },
37
+ };
38
+ //# sourceMappingURL=dates.js.map
@@ -0,0 +1,2 @@
1
+ import { type OpenAPIV3 } from 'openapi-types';
2
+ export declare const historyRemappers: Record<string, OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject>;
@@ -0,0 +1,246 @@
1
+ export const historyRemappers = {
2
+ 'from.history': {
3
+ type: 'object',
4
+ required: ['index', 'props'],
5
+ description: `Creates a new object based on the specified properties in the given history index. This can be very
6
+ useful when you want to combine two sources of data together. It’s also cleaner than separately
7
+ using \`object.from\` together with \`history\`.
8
+
9
+ In the following example, you can see why this might be handy. Let’s say you get the details about a
10
+ concert from a source like an action or a block. You have this information and then you want to get
11
+ some additional data like the attendees of the concert. With \`from.history\` you can combine the
12
+ older data like the name and date, and add the new \`attendees\` data. The result will be an object
13
+ with this combined data.
14
+
15
+ History index 1:
16
+
17
+ \`\`\`json
18
+ {
19
+ "name": "Rolling stones at Amsterdam Arena",
20
+ "artist": "Rolling Stones",
21
+ "location": "Amsterdam Arena",
22
+ "date": "07-07-2022",
23
+ "price": 120
24
+ }
25
+ \`\`\`
26
+
27
+ Input:
28
+
29
+ \`\`\`json
30
+ [ .. ]
31
+ \`\`\`
32
+
33
+ \`\`\`yaml
34
+ object.from:
35
+ concertDetails:
36
+ from.history:
37
+ index: 1
38
+ props:
39
+ name: { prop: name }
40
+ date: { prop: date }
41
+ attendees: { root: null }
42
+ \`\`\`
43
+
44
+ Result:
45
+
46
+ \`\`\`json
47
+ {
48
+ "concertDetails": {
49
+ "attendees": [ .. ],
50
+ "date": "07-07-2022",
51
+ "name": "Rolling stones at Amsterdam Arena"
52
+ }
53
+ }
54
+ \`\`\`
55
+ `,
56
+ additionalProperties: false,
57
+ properties: {
58
+ index: {
59
+ type: 'integer',
60
+ description: `The index of the history stack item to assign.
61
+
62
+ 0 is the index of the first item in the history stack.
63
+ `,
64
+ },
65
+ props: {
66
+ description: 'Predefined mapper keys to choose what properties to apply.',
67
+ additionalProperties: {
68
+ $ref: '#/components/schemas/RemapperDefinition',
69
+ },
70
+ },
71
+ },
72
+ },
73
+ 'assign.history': {
74
+ type: 'object',
75
+ required: ['index', 'props'],
76
+ description: `Assigns properties from the specified history stack index to an existing object.
77
+ Similarly to the \`from.history\` remapper, this allows you to get a property from a place in the
78
+ history and give it to a new object. The only difference here is that you are not creating an
79
+ entirely new object, but you are taking an existing object and assigning new values to it.
80
+
81
+ So, we can take the example from \`from.history\` and flip it.
82
+
83
+ History index 1:
84
+
85
+ \`\`\`json
86
+ {
87
+ "peopleAmount": 3000
88
+ }
89
+ \`\`\`
90
+
91
+ Input:
92
+
93
+ \`\`\`json
94
+ {
95
+ "name": "Rolling stones at Amsterdam Arena",
96
+ "artist": "Rolling Stones",
97
+ "location": "Amsterdam Arena",
98
+ "date": "07-07-2022",
99
+ "price": 120
100
+ }
101
+ \`\`\`
102
+
103
+ \`\`\`yaml
104
+ object.from:
105
+ concertDetails:
106
+ assign.history:
107
+ index: 1
108
+ props:
109
+ attendees: { prop: peopleAmount }
110
+ \`\`\`
111
+
112
+ Result:
113
+
114
+ \`\`\`json
115
+ {
116
+ "concertDetails": {
117
+ "name": "Rolling stones at Amsterdam Arena",
118
+ "artist": "Rolling Stones",
119
+ "location": "Amsterdam Arena",
120
+ "date": "07-07-2022",
121
+ "price": 120,
122
+ "attendees": 3000
123
+ }
124
+ }
125
+ \`\`\`
126
+ `,
127
+ additionalProperties: false,
128
+ properties: {
129
+ index: {
130
+ type: 'integer',
131
+ description: `The index of the history stack item to assign.
132
+
133
+ 0 is the index of the first item in the history stack.
134
+ `,
135
+ },
136
+ props: {
137
+ description: 'Predefined mapper keys to choose what properties to assign.',
138
+ additionalProperties: {
139
+ $ref: '#/components/schemas/RemapperDefinition',
140
+ },
141
+ },
142
+ },
143
+ },
144
+ 'omit.history': {
145
+ type: 'object',
146
+ required: ['index', 'keys'],
147
+ description: `Assigns properties from the specified history stack index to the current value and excludes the
148
+ given properties.
149
+
150
+ Similarly to the other history remappers, this gives you the data from a certain point in the
151
+ history stack and allows you to modify it before adding to the current value. This one, however,
152
+ allows you to take the complete specified history data and omit certain values.
153
+
154
+ This remapper can be extremely helpful for re-using data you got before in the history stack while
155
+ filtering certain properties.
156
+
157
+ For example, let’s say you have the information for a concert but don’t want normal users to see
158
+ sensitive data about it. Using \`omit.history\` you can take this concert data but exclude the
159
+ sensitive parts.
160
+
161
+ History index 1:
162
+
163
+ \`\`\`json
164
+ {
165
+ "name": "Rolling stones at Amsterdam Arena",
166
+ "artist": "Rolling Stones",
167
+ "location": "Amsterdam Arena",
168
+ "date": "07-07-2022",
169
+ "bandPasswords": [ .. ],
170
+ "bankDetailsAttendees": [ .. ]
171
+ }
172
+ \`\`\`
173
+
174
+ Input:
175
+
176
+ \`\`\`json
177
+ [ .. ]
178
+ \`\`\`
179
+
180
+ \`\`\`yaml
181
+ object.from:
182
+ concertDetails:
183
+ omit.history:
184
+ index: 1
185
+ keys:
186
+ - bandPasswords
187
+ - bankDetailsAttendees
188
+ \`\`\`
189
+
190
+ Result:
191
+
192
+ \`\`\`json
193
+ {
194
+ "concertDetails": {
195
+ "name": "Rolling stones at Amsterdam Arena",
196
+ "artist": "Rolling Stones",
197
+ "location": "Amsterdam Arena",
198
+ "date": "07-07-2022",
199
+ "attendees": [ .. ]
200
+ }
201
+ }
202
+ \`\`\`
203
+ `,
204
+ additionalProperties: false,
205
+ properties: {
206
+ index: {
207
+ type: 'integer',
208
+ description: `The index of the history stack item to assign.
209
+
210
+ 0 is the index of the first item in the history stack.
211
+ `,
212
+ },
213
+ keys: {
214
+ description: `Exclude properties from the history stack item, based on the given object keys.
215
+
216
+ Nested properties can be excluded using arrays of keys.
217
+
218
+ For example:
219
+ \`\`\`yaml
220
+ omit.history:
221
+ index: 0
222
+ keys:
223
+ - foo # Excludes the property foo
224
+ - - bar # Excludes the property baz inside of bar
225
+ - baz
226
+ \`\`\`
227
+ `,
228
+ type: 'array',
229
+ items: {
230
+ minItems: 1,
231
+ anyOf: [
232
+ { type: 'string' },
233
+ {
234
+ type: 'array',
235
+ minItems: 2,
236
+ items: {
237
+ type: 'string',
238
+ },
239
+ },
240
+ ],
241
+ },
242
+ },
243
+ },
244
+ },
245
+ };
246
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1,9 @@
1
+ export * from './arrays.js';
2
+ export * from './conditionals.js';
3
+ export * from './data.js';
4
+ export * from './dates.js';
5
+ export * from './history.js';
6
+ export * from './objects.js';
7
+ export * from './randoms.js';
8
+ export * from './strings.js';
9
+ export * from './unsorted.js';
@@ -0,0 +1,10 @@
1
+ export * from './arrays.js';
2
+ export * from './conditionals.js';
3
+ export * from './data.js';
4
+ export * from './dates.js';
5
+ export * from './history.js';
6
+ export * from './objects.js';
7
+ export * from './randoms.js';
8
+ export * from './strings.js';
9
+ export * from './unsorted.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import { type OpenAPIV3 } from 'openapi-types';
2
+ export declare const objectRemappers: Record<string, OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject>;