@formio/uag 1.3.0 → 1.3.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/README.md CHANGED
@@ -60,7 +60,7 @@ try {
60
60
  There is also a way to extend the functionality of the UAG through the use of modules, which is documented in the [Modules Readme](./module/Readme.md)
61
61
 
62
62
  ### Docker
63
- In addition to running the UAG in node.js, you can also run the UAG within the Docker environment. This enables a wide range of deployment options into common hosting environments such as AWS and Azure as well as allow for the use in common orchestration runtimes such as Kubernetes and Docker Compose. The container that you will use for running the UAG is as follows.
63
+ In addition to running the UAG in Node.js, you can also run the UAG within the Docker environment. This enables a wide range of deployment options into common hosting environments such as AWS and Azure as well as allow for the use in common orchestration runtimes such as Kubernetes and Docker Compose. The container that you will use for running the UAG is as follows.
64
64
 
65
65
  ```
66
66
  formio/uag
@@ -1,9 +1,8 @@
1
- **All required fields have been collected for <%= parentLabel %>!**
1
+ **All required fields have been collected for <%= parentLabel %>.**
2
2
  <% if (parentDataPath) { %>
3
3
  This data was collected within the data path of **<%= parentDataPath %>**.
4
4
  <% } %>
5
5
  <%= dataSummary %>
6
-
7
6
  **Next Steps**:
8
7
  <% if (parent && parent.isTable) { %>
9
8
  1. Use the `get_form_fields` tool with the same `parent` parameter and `criteria` set to "optional" to check if there are optional fields. If so, ask the user if they wish to fill any of them out for this row.
@@ -2,7 +2,7 @@
2
2
  <% if (parent) { %>
3
3
  The following data is being collected for the nested component **<%= parent.label %> (<%= parent.type %>)**. The parent `data_path` is **parent.data_path**, and all of the child data is collected within the path of **<%= parentDataPath %>**.
4
4
  <% } %>
5
- ## Progress: <%= progress.collected %>/<%= progress.total %> required fields collected for <%= parentLabel %>.
5
+ ## Progress: <%= progress.collected %>/<%= progress.total %> all fields (required and optional) collected for <%= parentLabel %>.
6
6
 
7
7
  ## Remaining required fields for <%= parentLabel %>:
8
8
  <%= fields %>
@@ -11,4 +11,5 @@ Use the `collect_field_data` tool to provide values for the remaining required f
11
11
  <%= dataSummary %>
12
12
 
13
13
  **Next Steps**:
14
- 1. Ask the user for any remaining required fields for <%= parentLabel %>.
14
+ 1. Ask the user for any remaining required fields for <%= parentLabel %>.
15
+ 2. If all "required" fields have been collected, then use the `get_form_fields` with `criteria` set to "optional" to get any additional fields the user wishes to also provide.
@@ -1,16 +1,11 @@
1
- <%= message %>## <%= type %> fields for <%= parentLabel %>
1
+ ## <%= type %> fields for <%= parentLabel %>
2
2
  <% if (parent) { %>
3
3
  All values for these fields should be stored within the `data_path`="<%= parentDataPath %>" (e.g. "<%= parentDataPath %>.exampleField")
4
4
  <% } %>
5
- ### Summary
6
- - Total fields for <%= parentLabel %>: <%= totalFields %>
7
- - Total fields collected for <%= parentLabel %>: <% totalCollected %>
8
- - Number of <%= type %> fields for <%= parentLabel %>: <%= totalType %>
9
- - Number of <%= type %> fields collected for <%= parentLabel %>: <%= totalTypeCollected %>
10
-
11
- <%= rules %>
12
5
 
13
6
  ### <%= type %> fields for <%= parentLabel %>
14
7
  <%= fieldList %>
15
8
 
9
+ <%= rules %>
10
+
16
11
  Once the user provides provides some context, use the `get_field_info` tool to understand how to validate and process the data that was collected. Make sure to set the `field_paths` to only the paths of the fields that the user has provided values for.
@@ -3,4 +3,4 @@ Here is the field information for the fields requested.
3
3
  ### Field Information
4
4
  <%= fields %>
5
5
 
6
- Use the `collect_field_data` tool to collect field information that the user has provided.
6
+ Use the `collect_field_data` tool to collect field information that the user has provided, or use the `submission_update` tool to update existing records with new or modified values.
@@ -63,7 +63,7 @@ const collectData = async (project) => {
63
63
  }),
64
64
  progress: {
65
65
  collected: Object.keys(form_data).length,
66
- total: fields.required.components.length + Object.keys(form_data).length
66
+ total: fields.total
67
67
  }
68
68
  });
69
69
  }
@@ -13,10 +13,9 @@ const getFormFields = async (project) => {
13
13
  description: 'Get high level overview of the fields that are present in a form, and to understand the "rules" on how the data for each field type should be collected. The purpose of this tool is to determine what fields the user is requesting (and to understand how to format that values for that data), and use that to create a list of field data_path\'s that the user is providing context for. This list can then be provided to the `get_field_info` tool to determine the specific field level information for those fields (validation, required, collection rules, etc). PREREQUISITE: You must call the `get_forms` tool first to understand what forms are available to submit and the permissions associated with those forms.',
14
14
  inputSchema: (new SchemaBuilder_1.SchemaBuilder(project))
15
15
  .form_name()
16
- .form_data()
17
16
  .criteria()
18
17
  .parent().schema,
19
- execute: async ({ form_name, form_data, criteria, parent }, extra) => {
18
+ execute: async ({ form_name, criteria, parent }, extra) => {
20
19
  const form = await project.getForm(form_name);
21
20
  if (!form) {
22
21
  return project.mcpResponse(template_1.ResponseTemplate.formNotFound, { formName: form_name }, true);
@@ -26,17 +25,8 @@ const getFormFields = async (project) => {
26
25
  if (!parent?.data_path || !parent.type) {
27
26
  parent = undefined;
28
27
  }
29
- // Get the submission data.
30
- const submission = form.convertToSubmission(form_data);
31
28
  // Get the fields at the specified data path (or root if not provided).
32
- const fields = await form.getFields(submission, extra.authInfo, parent?.data_path);
33
- // If the agent requests optional fields, but there are still requird fields to fill out, then force required
34
- // and inform the agent of this change.
35
- let message = '';
36
- if (criteria == 'optional' && fields.required.components.length > 0) {
37
- criteria = 'required';
38
- message = 'You requested "optional" fields, but the user is not finished collecting required information. Please finish collecting the following required fields first.\n\n';
39
- }
29
+ const fields = await form.getFields({ data: {} }, extra.authInfo, parent?.data_path);
40
30
  // Determine which fields to show based on the criteria.
41
31
  const criteriaFields = criteria === 'all' ?
42
32
  [...fields.required.components, ...fields.optional.components] :
@@ -53,37 +43,14 @@ const getFormFields = async (project) => {
53
43
  const criteriaRules = criteria === 'all' ?
54
44
  { ...fields.required.rules, ...fields.optional.rules } :
55
45
  criteria === 'required' ? fields.required.rules : fields.optional.rules;
56
- let totalType = fields.total;
57
- if (criteria === 'required') {
58
- totalType = fields.totalRequired;
59
- }
60
- else if (criteria === 'optional') {
61
- totalType = fields.total - fields.totalRequired;
62
- }
63
- const totalCollected = Object.keys(form_data || {}).length;
64
- let totalTypeCollected = 0;
65
- if (criteria === 'required') {
66
- totalTypeCollected = fields.totalRequiredCollected;
67
- }
68
- else if (criteria === 'optional') {
69
- totalTypeCollected = totalCollected - fields.totalRequiredCollected;
70
- }
71
- else {
72
- totalTypeCollected = totalCollected;
73
- }
74
46
  // Show the form fields based on the criteria.
75
47
  return project.mcpResponse(template_1.ResponseTemplate.getFormFields, {
76
- message,
77
48
  parent,
78
49
  parentLabel: (0, utils_1.getParentLabel)(parent, form.form),
79
50
  parentDataPath: (0, utils_1.getParentDataPath)(parent, fields.rowIndex),
80
51
  type: (0, lodash_1.upperFirst)(criteria),
81
52
  rules: project.uagTemplate?.renderTemplate(template_1.ResponseTemplate.fieldRules, { rules: Object.entries(criteriaRules) }),
82
- fieldList: project.uagTemplate?.renderTemplate(template_1.ResponseTemplate.fieldList, { fields: criteriaFields }),
83
- totalFields: fields.total,
84
- totalType,
85
- totalCollected,
86
- totalTypeCollected
53
+ fieldList: project.uagTemplate?.renderTemplate(template_1.ResponseTemplate.fieldList, { fields: criteriaFields })
87
54
  });
88
55
  }
89
56
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/uag",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "The Form.io Universal Agent Gateway (UAG).",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",