@nyaruka/temba-components 0.129.11 → 0.130.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -4
- package/demo/components/flow/example.html +5 -1
- package/demo/data/flows/sample-flow.json +144 -80
- package/dist/temba-components.js +290 -346
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/flow/CanvasNode.js +3 -35
- package/out-tsc/src/flow/CanvasNode.js.map +1 -1
- package/out-tsc/src/flow/NodeEditor.js +44 -11
- package/out-tsc/src/flow/NodeEditor.js.map +1 -1
- package/out-tsc/src/flow/actions/add_contact_groups.js +14 -2
- package/out-tsc/src/flow/actions/add_contact_groups.js.map +1 -1
- package/out-tsc/src/flow/actions/add_contact_urn.js +1 -1
- package/out-tsc/src/flow/actions/add_contact_urn.js.map +1 -1
- package/out-tsc/src/flow/actions/add_input_labels.js +2 -1
- package/out-tsc/src/flow/actions/add_input_labels.js.map +1 -1
- package/out-tsc/src/flow/actions/remove_contact_groups.js +1 -1
- package/out-tsc/src/flow/actions/remove_contact_groups.js.map +1 -1
- package/out-tsc/src/flow/actions/send_email.js +9 -0
- package/out-tsc/src/flow/actions/send_email.js.map +1 -1
- package/out-tsc/src/flow/actions/send_msg.js +7 -8
- package/out-tsc/src/flow/actions/send_msg.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_channel.js +25 -4
- package/out-tsc/src/flow/actions/set_contact_channel.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_field.js +51 -1
- package/out-tsc/src/flow/actions/set_contact_field.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_language.js +70 -2
- package/out-tsc/src/flow/actions/set_contact_language.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_name.js +27 -2
- package/out-tsc/src/flow/actions/set_contact_name.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_status.js +32 -2
- package/out-tsc/src/flow/actions/set_contact_status.js.map +1 -1
- package/out-tsc/src/flow/actions/set_run_result.js +13 -11
- package/out-tsc/src/flow/actions/set_run_result.js.map +1 -1
- package/out-tsc/src/flow/actions/split_by_expression_example.js +4 -4
- package/out-tsc/src/flow/actions/split_by_expression_example.js.map +1 -1
- package/out-tsc/src/flow/forms/index.js +2 -0
- package/out-tsc/src/flow/forms/index.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_random.js +117 -0
- package/out-tsc/src/flow/nodes/split_by_random.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_ticket.js +0 -1
- package/out-tsc/src/flow/nodes/split_by_ticket.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_webhook.js +1 -3
- package/out-tsc/src/flow/nodes/split_by_webhook.js.map +1 -1
- package/out-tsc/src/flow/types.js.map +1 -1
- package/out-tsc/src/form/ArrayEditor.js +9 -25
- package/out-tsc/src/form/ArrayEditor.js.map +1 -1
- package/out-tsc/src/form/FieldRenderer.js +6 -64
- package/out-tsc/src/form/FieldRenderer.js.map +1 -1
- package/out-tsc/src/form/select/Select.js +35 -58
- package/out-tsc/src/form/select/Select.js.map +1 -1
- package/out-tsc/src/utils.js +3 -0
- package/out-tsc/src/utils.js.map +1 -1
- package/out-tsc/test/nodes/split_by_random.test.js +0 -6
- package/out-tsc/test/nodes/split_by_random.test.js.map +1 -1
- package/out-tsc/test/temba-field-renderer.test.js +6 -3
- package/out-tsc/test/temba-field-renderer.test.js.map +1 -1
- package/out-tsc/test/utils.test.js +18 -0
- package/out-tsc/test/utils.test.js.map +1 -1
- package/package.json +1 -1
- package/screenshots/truth/actions/add_contact_groups/editor/descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/long-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/multiple-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/single-group.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/long-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/cleanup-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/long-descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/multiple-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/remove-from-all-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/single-group.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/cleanup-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/long-descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/remove-from-all-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/editor/set_contact_language.png +0 -0
- package/screenshots/truth/editor/set_contact_name.png +0 -0
- package/screenshots/truth/editor/set_run_result.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/ab-test-multiple-variants.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/sampling-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/three-way-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/two-bucket-split.png +0 -0
- package/src/flow/CanvasNode.ts +2 -39
- package/src/flow/NodeEditor.ts +54 -13
- package/src/flow/actions/add_contact_groups.ts +17 -2
- package/src/flow/actions/add_contact_urn.ts +1 -1
- package/src/flow/actions/add_input_labels.ts +2 -1
- package/src/flow/actions/remove_contact_groups.ts +1 -1
- package/src/flow/actions/send_email.ts +11 -1
- package/src/flow/actions/send_msg.ts +20 -11
- package/src/flow/actions/set_contact_channel.ts +28 -5
- package/src/flow/actions/set_contact_field.ts +56 -2
- package/src/flow/actions/set_contact_language.ts +74 -3
- package/src/flow/actions/set_contact_name.ts +31 -3
- package/src/flow/actions/set_contact_status.ts +36 -3
- package/src/flow/actions/set_run_result.ts +13 -15
- package/src/flow/actions/split_by_expression_example.ts +4 -4
- package/src/flow/forms/index.ts +1 -0
- package/src/flow/nodes/split_by_random.ts +148 -0
- package/src/flow/nodes/split_by_ticket.ts +0 -1
- package/src/flow/nodes/split_by_webhook.ts +1 -3
- package/src/flow/types.ts +2 -1
- package/src/form/ArrayEditor.ts +6 -20
- package/src/form/FieldRenderer.ts +6 -65
- package/src/form/select/Select.ts +38 -66
- package/src/store/flow-definition.d.ts +6 -1
- package/src/utils.ts +4 -0
- package/static/api/fields.json +93 -1208
- package/static/api/workspace.json +23 -0
- package/test/nodes/split_by_random.test.ts +0 -7
- package/test/temba-field-renderer.test.ts +26 -13
- package/test/utils.test.ts +20 -0
- package/web-dev-server.config.mjs +2 -0
- package/web-test-runner.config.mjs +37 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"uuid": "fe4e54e9-7d1c-4826-a450-4552fa47b2ef",
|
|
3
|
+
"name": "UNEP Mexico",
|
|
4
|
+
"country": "NG",
|
|
5
|
+
"languages": [
|
|
6
|
+
"eng",
|
|
7
|
+
"spa",
|
|
8
|
+
"fra",
|
|
9
|
+
"deu",
|
|
10
|
+
"por",
|
|
11
|
+
"ita",
|
|
12
|
+
"rus",
|
|
13
|
+
"zho",
|
|
14
|
+
"jpn",
|
|
15
|
+
"kor",
|
|
16
|
+
"ara",
|
|
17
|
+
"hin"
|
|
18
|
+
],
|
|
19
|
+
"timezone": "America/Los_Angeles",
|
|
20
|
+
"date_style": "day_first",
|
|
21
|
+
"anon": false,
|
|
22
|
+
"primary_language": "eng"
|
|
23
|
+
}
|
|
@@ -28,13 +28,6 @@ describe('split_by_random node config', () => {
|
|
|
28
28
|
expect(split_by_random.router).to.exist;
|
|
29
29
|
expect(split_by_random.router.type).to.equal('random');
|
|
30
30
|
});
|
|
31
|
-
|
|
32
|
-
it('is a simple node config without form or layout', () => {
|
|
33
|
-
expect(split_by_random.form).to.be.undefined;
|
|
34
|
-
expect(split_by_random.layout).to.be.undefined;
|
|
35
|
-
expect(split_by_random.toFormData).to.be.undefined;
|
|
36
|
-
expect(split_by_random.fromFormData).to.be.undefined;
|
|
37
|
-
});
|
|
38
31
|
});
|
|
39
32
|
|
|
40
33
|
describe('node scenarios', () => {
|
|
@@ -192,11 +192,16 @@ describe('FieldRenderer', () => {
|
|
|
192
192
|
searchable: true
|
|
193
193
|
};
|
|
194
194
|
|
|
195
|
-
const template = FieldRenderer.renderField(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
195
|
+
const template = FieldRenderer.renderField(
|
|
196
|
+
'country',
|
|
197
|
+
config,
|
|
198
|
+
[{ name: 'Canada', value: 'Canada' }],
|
|
199
|
+
{
|
|
200
|
+
errors: [],
|
|
201
|
+
showLabel: true,
|
|
202
|
+
onChange: () => {}
|
|
203
|
+
}
|
|
204
|
+
);
|
|
200
205
|
|
|
201
206
|
const container = await fixture(
|
|
202
207
|
html`<div style="width: 400px; padding: 20px;">${template}</div>`
|
|
@@ -219,7 +224,10 @@ describe('FieldRenderer', () => {
|
|
|
219
224
|
const template = FieldRenderer.renderField(
|
|
220
225
|
'skills',
|
|
221
226
|
config,
|
|
222
|
-
[
|
|
227
|
+
[
|
|
228
|
+
{ name: 'JavaScript', value: 'JavaScript' },
|
|
229
|
+
{ name: 'TypeScript', value: 'TypeScript' }
|
|
230
|
+
],
|
|
223
231
|
{
|
|
224
232
|
errors: [],
|
|
225
233
|
showLabel: true,
|
|
@@ -243,13 +251,18 @@ describe('FieldRenderer', () => {
|
|
|
243
251
|
options: ['Active', 'Inactive', 'Pending']
|
|
244
252
|
};
|
|
245
253
|
|
|
246
|
-
const template = FieldRenderer.renderField(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
254
|
+
const template = FieldRenderer.renderField(
|
|
255
|
+
'status',
|
|
256
|
+
config,
|
|
257
|
+
[{ name: 'Active', value: 'Active' }],
|
|
258
|
+
{
|
|
259
|
+
errors: [],
|
|
260
|
+
showLabel: false,
|
|
261
|
+
flavor: 'small',
|
|
262
|
+
extraClasses: 'form-control',
|
|
263
|
+
onChange: () => {}
|
|
264
|
+
}
|
|
265
|
+
);
|
|
253
266
|
|
|
254
267
|
const container = await fixture(
|
|
255
268
|
html`<div style="width: 200px; padding: 10px;">${template}</div>`
|
package/test/utils.test.ts
CHANGED
|
@@ -142,6 +142,26 @@ export const mockAPI = () => {
|
|
|
142
142
|
mockGET(url, key);
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
+
|
|
146
|
+
// Add mock data for contact form endpoints
|
|
147
|
+
mockGET(/\/api\/v2\/channels\.json/, {
|
|
148
|
+
results: [
|
|
149
|
+
{ uuid: 'chan-1', name: 'WhatsApp Channel' },
|
|
150
|
+
{ uuid: 'chan-2', name: 'Telegram Channel' },
|
|
151
|
+
{ uuid: 'chan-3', name: 'SMS Channel' },
|
|
152
|
+
{ uuid: 'chan-4', name: 'Facebook Messenger' }
|
|
153
|
+
]
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
mockGET(/\/api\/v2\/languages\.json/, {
|
|
157
|
+
results: [
|
|
158
|
+
{ iso: 'eng', name: 'English' },
|
|
159
|
+
{ iso: 'spa', name: 'Spanish' },
|
|
160
|
+
{ iso: 'fra', name: 'French' },
|
|
161
|
+
{ iso: 'por', name: 'Portuguese' },
|
|
162
|
+
{ iso: 'deu', name: 'German' }
|
|
163
|
+
]
|
|
164
|
+
});
|
|
145
165
|
};
|
|
146
166
|
|
|
147
167
|
export const mockGET = (
|
|
@@ -43,6 +43,8 @@ export default {
|
|
|
43
43
|
'/api/v2/contacts.json': './static/api/contacts.json',
|
|
44
44
|
'/api/v2/optins.json': './static/api/optins.json',
|
|
45
45
|
'/api/v2/topics.json': './static/api/topics.json',
|
|
46
|
+
'/api/v2/languages.json': './static/api/languages.json',
|
|
47
|
+
'/api/v2/workspace.json': './static/api/workspace.json',
|
|
46
48
|
'/api/internal/locations.json': './static/api/locations.json',
|
|
47
49
|
'/api/internal/orgs.json': './static/api/orgs.json'
|
|
48
50
|
};
|
|
@@ -322,6 +322,43 @@ export default {
|
|
|
322
322
|
preventAssignment: true,
|
|
323
323
|
'process.env.NODE_ENV': JSON.stringify('test'),
|
|
324
324
|
}),
|
|
325
|
+
{
|
|
326
|
+
name: 'api-mock-server',
|
|
327
|
+
serve(context) {
|
|
328
|
+
// Handle API endpoints by serving static files
|
|
329
|
+
if (context.request.method === 'GET' && context.path.startsWith('/api/')) {
|
|
330
|
+
// Map API endpoints to static files
|
|
331
|
+
const apiMappings = {
|
|
332
|
+
'/api/v2/groups.json': './static/api/groups.json',
|
|
333
|
+
'/api/v2/labels.json': './static/api/labels.json',
|
|
334
|
+
'/api/v2/fields.json': './static/api/fields.json',
|
|
335
|
+
'/api/v2/globals.json': './static/api/globals.json',
|
|
336
|
+
'/api/v2/completion.json': './static/mr/docs/en-us/editor.json',
|
|
337
|
+
'/api/v2/functions.json': './static/api/functions.json',
|
|
338
|
+
'/api/internal/templates.json': './static/api/templates.json',
|
|
339
|
+
'/api/v2/media.json': './static/api/media.json',
|
|
340
|
+
'/api/v2/users.json': './static/api/users.json',
|
|
341
|
+
'/api/v2/contacts.json': './static/api/contacts.json',
|
|
342
|
+
'/api/v2/optins.json': './static/api/optins.json',
|
|
343
|
+
'/api/v2/topics.json': './static/api/topics.json',
|
|
344
|
+
'/api/v2/languages.json': './static/api/languages.json',
|
|
345
|
+
'/api/v2/workspace.json': './static/api/workspace.json',
|
|
346
|
+
'/api/internal/locations.json': './static/api/locations.json',
|
|
347
|
+
'/api/internal/orgs.json': './static/api/orgs.json'
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
// Handle base path without query parameters
|
|
351
|
+
const basePath = context.path.split('?')[0];
|
|
352
|
+
const staticFile = apiMappings[basePath];
|
|
353
|
+
|
|
354
|
+
if (staticFile && fs.existsSync(path.resolve(staticFile))) {
|
|
355
|
+
context.contentType = 'application/json';
|
|
356
|
+
context.body = fs.readFileSync(path.resolve(staticFile), 'utf-8');
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
},
|
|
325
362
|
{
|
|
326
363
|
name: 'add-style',
|
|
327
364
|
transform(context) {
|