@formio/uag 1.3.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.
- package/LICENSE.txt +19 -0
- package/README.md +336 -0
- package/lib/UAGFormInterface.d.ts +113 -0
- package/lib/UAGFormInterface.js +371 -0
- package/lib/UAGProjectInterface.d.ts +26 -0
- package/lib/UAGProjectInterface.js +96 -0
- package/lib/config.d.ts +54 -0
- package/lib/config.js +2 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +43 -0
- package/lib/router.d.ts +3 -0
- package/lib/router.js +74 -0
- package/lib/template.d.ts +54 -0
- package/lib/template.js +120 -0
- package/lib/templates/allFieldsCollected.md +17 -0
- package/lib/templates/collectedData.md +5 -0
- package/lib/templates/confirmFormSubmission.md +18 -0
- package/lib/templates/fieldCollectedNext.md +14 -0
- package/lib/templates/fieldList.md +5 -0
- package/lib/templates/fieldRules.md +4 -0
- package/lib/templates/fieldValidationErrors.md +7 -0
- package/lib/templates/fields.md +19 -0
- package/lib/templates/formNotFound.md +1 -0
- package/lib/templates/formSubmitted.md +7 -0
- package/lib/templates/getAvailableForms.md +18 -0
- package/lib/templates/getFormFields.md +16 -0
- package/lib/templates/getFormFieldsEmpty.md +4 -0
- package/lib/templates/getFormFieldsError.md +7 -0
- package/lib/templates/getFormFieldsInfo.md +6 -0
- package/lib/templates/getOptionalFields.md +19 -0
- package/lib/templates/noFormsAvailable.md +3 -0
- package/lib/templates/noSubmissionsFound.md +11 -0
- package/lib/templates/submissionNotFound.md +6 -0
- package/lib/templates/submissionPartialIdAmbiguous.md +12 -0
- package/lib/templates/submissionPartialIdNotFound.md +12 -0
- package/lib/templates/submissionSearchError.md +8 -0
- package/lib/templates/submissionUpdateError.md +6 -0
- package/lib/templates/submissionUpdated.md +15 -0
- package/lib/templates/submissionsFound.md +25 -0
- package/lib/templates/submitValidationError.md +7 -0
- package/lib/templates/submittedData.md +4 -0
- package/lib/tools/SchemaBuilder.d.ts +136 -0
- package/lib/tools/SchemaBuilder.js +192 -0
- package/lib/tools/collectData.d.ts +3 -0
- package/lib/tools/collectData.js +72 -0
- package/lib/tools/confirmSubmission.d.ts +3 -0
- package/lib/tools/confirmSubmission.js +56 -0
- package/lib/tools/findSubmission.d.ts +3 -0
- package/lib/tools/findSubmission.js +165 -0
- package/lib/tools/getFieldInfo.d.ts +3 -0
- package/lib/tools/getFieldInfo.js +41 -0
- package/lib/tools/getFormFields.d.ts +3 -0
- package/lib/tools/getFormFields.js +99 -0
- package/lib/tools/getForms.d.ts +3 -0
- package/lib/tools/getForms.js +38 -0
- package/lib/tools/index.d.ts +13 -0
- package/lib/tools/index.js +47 -0
- package/lib/tools/submissionUpdate.d.ts +3 -0
- package/lib/tools/submissionUpdate.js +79 -0
- package/lib/tools/submitForm.d.ts +3 -0
- package/lib/tools/submitForm.js +62 -0
- package/lib/tools/utils.d.ts +28 -0
- package/lib/tools/utils.js +27 -0
- package/package.json +57 -0
package/lib/router.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UAGRouter = UAGRouter;
|
|
4
|
+
const express_1 = require("express");
|
|
5
|
+
const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
6
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
7
|
+
// Helper function to create JSON RPC error responses
|
|
8
|
+
const createJsonRpcErrorResponse = (code, message) => {
|
|
9
|
+
return JSON.stringify({
|
|
10
|
+
error: { code, message },
|
|
11
|
+
id: null,
|
|
12
|
+
jsonrpc: "2.0",
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Handle errors that occur during response processing.
|
|
17
|
+
* @param error The error that occurred.
|
|
18
|
+
* @param res The response object.
|
|
19
|
+
* @returns True if the error was handled, false otherwise.
|
|
20
|
+
*/
|
|
21
|
+
const handleResponseError = (error, res) => {
|
|
22
|
+
if (error instanceof Response) {
|
|
23
|
+
const fixedHeaders = {};
|
|
24
|
+
error.headers.forEach((value, key) => {
|
|
25
|
+
fixedHeaders[key] = value;
|
|
26
|
+
});
|
|
27
|
+
res.status(error.status).set(fixedHeaders).send(error.statusText);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
console.error("[formio-uag] error handling request", error);
|
|
31
|
+
res.status(500).json(JSON.parse(createJsonRpcErrorResponse(-32603, "Internal Server Error")));
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
function UAGRouter(project) {
|
|
35
|
+
const router = (0, express_1.Router)();
|
|
36
|
+
// Handles the MCP post requests.
|
|
37
|
+
router.post('/', async (req, res) => {
|
|
38
|
+
try {
|
|
39
|
+
const transport = new streamableHttp_js_1.StreamableHTTPServerTransport({
|
|
40
|
+
sessionIdGenerator: undefined, // Use "undefined" to trigger stateless mode.
|
|
41
|
+
});
|
|
42
|
+
project.mcpServer.connect(transport);
|
|
43
|
+
if (!transport) {
|
|
44
|
+
res.status(500).json(JSON.parse(createJsonRpcErrorResponse(-32603, "Unable to create MCP transport.")));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
(0, types_js_1.isInitializeRequest)(req.body);
|
|
48
|
+
await transport.handleRequest(req, res, req.body);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
handleResponseError(error, res);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
// Handles the MCP get requests (for health checks, etc).
|
|
55
|
+
router.get('/', async (req, res) => {
|
|
56
|
+
try {
|
|
57
|
+
const transport = new streamableHttp_js_1.StreamableHTTPServerTransport({
|
|
58
|
+
sessionIdGenerator: undefined, // Use "undefined" to trigger stateless mode.
|
|
59
|
+
});
|
|
60
|
+
project.mcpServer.connect(transport);
|
|
61
|
+
if (!transport) {
|
|
62
|
+
res.status(500).json(JSON.parse(createJsonRpcErrorResponse(-32603, "Unable to create MCP transport.")));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
await transport.handleRequest(req, res);
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
handleResponseError(err, res);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
// Return the router
|
|
72
|
+
return router;
|
|
73
|
+
}
|
|
74
|
+
;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { TemplateExecutor } from 'lodash';
|
|
2
|
+
import { UAGTemplateConfig } from './config';
|
|
3
|
+
/**
|
|
4
|
+
* Template names enum for type safety
|
|
5
|
+
*/
|
|
6
|
+
export declare enum ResponseTemplate {
|
|
7
|
+
collectedData = "collectedData",
|
|
8
|
+
submittedData = "submittedData",
|
|
9
|
+
fieldRules = "fieldRules",
|
|
10
|
+
allFieldsCollected = "allFieldsCollected",
|
|
11
|
+
getFormFieldsEmpty = "getFormFieldsEmpty",
|
|
12
|
+
getFormFieldsInfo = "getFormFieldsInfo",
|
|
13
|
+
fieldCollectedNext = "fieldCollectedNext",
|
|
14
|
+
submitValidationError = "submitValidationError",
|
|
15
|
+
formSubmitted = "formSubmitted",
|
|
16
|
+
listAvailableForms = "listAvailableForms",
|
|
17
|
+
confirmFormSubmission = "confirmFormSubmission",
|
|
18
|
+
getOptionalFields = "getOptionalFields",
|
|
19
|
+
formNotFound = "formNotFound",
|
|
20
|
+
noSubmissionsFound = "noSubmissionsFound",
|
|
21
|
+
submissionsFound = "submissionsFound",
|
|
22
|
+
submissionSearchError = "submissionSearchError",
|
|
23
|
+
submissionNotFound = "submissionNotFound",
|
|
24
|
+
updateNotConfirmed = "updateNotConfirmed",
|
|
25
|
+
submissionUpdateError = "submissionUpdateError",
|
|
26
|
+
submissionUpdated = "submissionUpdated",
|
|
27
|
+
submissionPartialIdAmbiguous = "submissionPartialIdAmbiguous",
|
|
28
|
+
submissionPartialIdNotFound = "submissionPartialIdNotFound",
|
|
29
|
+
getFormFields = "getFormFields",
|
|
30
|
+
getFormFieldsError = "getFormFieldsError",
|
|
31
|
+
fieldValidationErrors = "fieldValidationErrors",
|
|
32
|
+
fields = "fields",
|
|
33
|
+
fieldList = "fieldList",
|
|
34
|
+
getAvailableForms = "getAvailableForms",
|
|
35
|
+
noFormsAvailable = "noFormsAvailable"
|
|
36
|
+
}
|
|
37
|
+
export declare class UAGTemplate {
|
|
38
|
+
config: UAGTemplateConfig;
|
|
39
|
+
templateCache: Map<string, TemplateExecutor>;
|
|
40
|
+
constructor(config?: UAGTemplateConfig);
|
|
41
|
+
/**
|
|
42
|
+
* Get a template by name
|
|
43
|
+
* @param templateName The name of the template
|
|
44
|
+
* @returns The compiled template function
|
|
45
|
+
*/
|
|
46
|
+
getTemplate(templateName: ResponseTemplate): TemplateExecutor;
|
|
47
|
+
/**
|
|
48
|
+
* Render a template with data
|
|
49
|
+
* @param templateName The name of the template
|
|
50
|
+
* @param data The data to render the template with
|
|
51
|
+
* @returns The rendered template
|
|
52
|
+
*/
|
|
53
|
+
renderTemplate(templateName: ResponseTemplate, data?: object): string;
|
|
54
|
+
}
|
package/lib/template.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.UAGTemplate = exports.ResponseTemplate = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const lodash_1 = require("lodash");
|
|
40
|
+
/**
|
|
41
|
+
* Template names enum for type safety
|
|
42
|
+
*/
|
|
43
|
+
var ResponseTemplate;
|
|
44
|
+
(function (ResponseTemplate) {
|
|
45
|
+
ResponseTemplate["collectedData"] = "collectedData";
|
|
46
|
+
ResponseTemplate["submittedData"] = "submittedData";
|
|
47
|
+
ResponseTemplate["fieldRules"] = "fieldRules";
|
|
48
|
+
ResponseTemplate["allFieldsCollected"] = "allFieldsCollected";
|
|
49
|
+
ResponseTemplate["getFormFieldsEmpty"] = "getFormFieldsEmpty";
|
|
50
|
+
ResponseTemplate["getFormFieldsInfo"] = "getFormFieldsInfo";
|
|
51
|
+
ResponseTemplate["fieldCollectedNext"] = "fieldCollectedNext";
|
|
52
|
+
ResponseTemplate["submitValidationError"] = "submitValidationError";
|
|
53
|
+
ResponseTemplate["formSubmitted"] = "formSubmitted";
|
|
54
|
+
ResponseTemplate["listAvailableForms"] = "listAvailableForms";
|
|
55
|
+
ResponseTemplate["confirmFormSubmission"] = "confirmFormSubmission";
|
|
56
|
+
ResponseTemplate["getOptionalFields"] = "getOptionalFields";
|
|
57
|
+
ResponseTemplate["formNotFound"] = "formNotFound";
|
|
58
|
+
ResponseTemplate["noSubmissionsFound"] = "noSubmissionsFound";
|
|
59
|
+
ResponseTemplate["submissionsFound"] = "submissionsFound";
|
|
60
|
+
ResponseTemplate["submissionSearchError"] = "submissionSearchError";
|
|
61
|
+
ResponseTemplate["submissionNotFound"] = "submissionNotFound";
|
|
62
|
+
ResponseTemplate["updateNotConfirmed"] = "updateNotConfirmed";
|
|
63
|
+
ResponseTemplate["submissionUpdateError"] = "submissionUpdateError";
|
|
64
|
+
ResponseTemplate["submissionUpdated"] = "submissionUpdated";
|
|
65
|
+
ResponseTemplate["submissionPartialIdAmbiguous"] = "submissionPartialIdAmbiguous";
|
|
66
|
+
ResponseTemplate["submissionPartialIdNotFound"] = "submissionPartialIdNotFound";
|
|
67
|
+
ResponseTemplate["getFormFields"] = "getFormFields";
|
|
68
|
+
ResponseTemplate["getFormFieldsError"] = "getFormFieldsError";
|
|
69
|
+
ResponseTemplate["fieldValidationErrors"] = "fieldValidationErrors";
|
|
70
|
+
ResponseTemplate["fields"] = "fields";
|
|
71
|
+
ResponseTemplate["fieldList"] = "fieldList";
|
|
72
|
+
ResponseTemplate["getAvailableForms"] = "getAvailableForms";
|
|
73
|
+
ResponseTemplate["noFormsAvailable"] = "noFormsAvailable";
|
|
74
|
+
})(ResponseTemplate || (exports.ResponseTemplate = ResponseTemplate = {}));
|
|
75
|
+
class UAGTemplate {
|
|
76
|
+
constructor(config = {}) {
|
|
77
|
+
this.config = config;
|
|
78
|
+
this.templateCache = new Map();
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get a template by name
|
|
82
|
+
* @param templateName The name of the template
|
|
83
|
+
* @returns The compiled template function
|
|
84
|
+
*/
|
|
85
|
+
getTemplate(templateName) {
|
|
86
|
+
if (this.templateCache.has(templateName)) {
|
|
87
|
+
return this.templateCache.get(templateName);
|
|
88
|
+
}
|
|
89
|
+
let templateContent = '';
|
|
90
|
+
if (this.config[templateName]) {
|
|
91
|
+
templateContent = this.config[templateName];
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
const templatePath = path.join(path.join(__dirname, 'templates') || '', `${templateName}.md`);
|
|
95
|
+
if (!fs.existsSync(templatePath))
|
|
96
|
+
throw new Error(`Template '${templateName}' not found at ${templatePath}`);
|
|
97
|
+
templateContent = this.config[templateName] || fs.readFileSync(templatePath, 'utf-8');
|
|
98
|
+
}
|
|
99
|
+
const compiled = (0, lodash_1.template)(templateContent);
|
|
100
|
+
this.templateCache.set(templateName, compiled);
|
|
101
|
+
return compiled;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Render a template with data
|
|
105
|
+
* @param templateName The name of the template
|
|
106
|
+
* @param data The data to render the template with
|
|
107
|
+
* @returns The rendered template
|
|
108
|
+
*/
|
|
109
|
+
renderTemplate(templateName, data = {}) {
|
|
110
|
+
try {
|
|
111
|
+
const template = this.getTemplate(templateName);
|
|
112
|
+
return template(data);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
116
|
+
throw new Error(`Failed to render template '${templateName}': ${errorMessage}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.UAGTemplate = UAGTemplate;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
**All required fields have been collected for <%= parentLabel %>!**
|
|
2
|
+
<% if (parentDataPath) { %>
|
|
3
|
+
This data was collected within the data path of **<%= parentDataPath %>**.
|
|
4
|
+
<% } %>
|
|
5
|
+
<%= dataSummary %>
|
|
6
|
+
|
|
7
|
+
**Next Steps**:
|
|
8
|
+
<% if (parent && parent.isTable) { %>
|
|
9
|
+
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.
|
|
10
|
+
2. If there are no optional fields, or the user declines, then ask the user if they wish to "Add Another" (add another row to the table). If they affirm, then use the `collect_field_data` tool to collect the next row's data. Make sure to increment the row index for the fields within this parent component (e.g. <%= parent.data_path %>[<%= rowIndex %>] => <%= parent.data_path %>[<%= (rowIndex + 1) %>]) when collecting data for the next row.
|
|
11
|
+
3. If they do not wish to "Add Another", then use the `get_form_fields` tool to determine if there are any more fields that need to be collected outside of the <%= parent.label %> component. If so, use the `collect_field_data` tool to collect that information (make sure to change the `parent` parameter to the level above the <%= parent.label %> field, or to `null` if we are at the root of the form).
|
|
12
|
+
<% } else if (parent && (parent.isForm || parent.isContainer)) { %>
|
|
13
|
+
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.
|
|
14
|
+
2. If there are no optional fields, or the user declines, then use the `get_form_fields` tool to determine if there are any more fields that need to be collected outside of the <%= parent.label %> component. If so, use the `collect_field_data` tool to collect that information (make sure to change the parent parameter to the level above the <%= parent.label %> field, or to `null` if we are at the root of the form).
|
|
15
|
+
<% } else { %>
|
|
16
|
+
1. Use the `get_form_fields` tool with the `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.
|
|
17
|
+
2. If there are no optional fields, or the user declines, then use the `confirm_form_submission` tool to show summary and get confirmation to submit the form.<% } %>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Confirm Form Submission
|
|
2
|
+
|
|
3
|
+
All the required information for your **<%= form.title %>** form has been collected.
|
|
4
|
+
|
|
5
|
+
Please review the following data before submission:
|
|
6
|
+
|
|
7
|
+
<%= dataSummary %>
|
|
8
|
+
|
|
9
|
+
**Please confirm:** Does this information look correct?
|
|
10
|
+
|
|
11
|
+
- Say or type "yes" or "confirm" to submit this form
|
|
12
|
+
- Say or type "no" or "cancel" to make changes
|
|
13
|
+
- Tell me which field you'd like to modify if you need to make changes
|
|
14
|
+
|
|
15
|
+
Only use `submit_completed_form` if the user explicitly confirms (says "yes", "confirm", "submit", etc.).
|
|
16
|
+
|
|
17
|
+
**Current Data**:
|
|
18
|
+
<%= JSON.stringify(currentData, null, 2) %>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<%= message %>
|
|
2
|
+
<% if (parent) { %>
|
|
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
|
+
<% } %>
|
|
5
|
+
## Progress: <%= progress.collected %>/<%= progress.total %> required fields collected for <%= parentLabel %>.
|
|
6
|
+
|
|
7
|
+
## Remaining required fields for <%= parentLabel %>:
|
|
8
|
+
<%= fields %>
|
|
9
|
+
Use the `collect_field_data` tool to provide values for the remaining required fields for <%= parentLabel %>. You can collect multiple fields at once by providing an array of field updates.
|
|
10
|
+
|
|
11
|
+
<%= dataSummary %>
|
|
12
|
+
|
|
13
|
+
**Next Steps**:
|
|
14
|
+
1. Ask the user for any remaining required fields for <%= parentLabel %>.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
## ❌ Field Validation Errors
|
|
2
|
+
|
|
3
|
+
The following fields have validation errors that need to be corrected:
|
|
4
|
+
<% invalidFields.forEach(function(field) { %>
|
|
5
|
+
- **<%= field.label %> (<%= field.path %>)**: <%= field.error %><% }); %>
|
|
6
|
+
|
|
7
|
+
Please provide valid values for these fields and try again.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<% fields.forEach(function(field, index) { %>
|
|
2
|
+
<%= index + 1 %>. **<%= field.label %>**
|
|
3
|
+
- **Data Path (data_path)**: "<%= field.path %>"
|
|
4
|
+
- **Label**: <%= field.label %>
|
|
5
|
+
- **Type**: <%= field.type %>
|
|
6
|
+
- **Required**: <% if (field.validation.required) { %>✅ Yes<% } else { %>❌ No<% } %>
|
|
7
|
+
- **Has Nested Components**: <% if (field.nested) { %>✅ Yes<% } else { %>❌ No<% } %><% if (field.description) { %>
|
|
8
|
+
- **Description**: <%= field.description %><% } %><% if (field.prompt) { %>
|
|
9
|
+
- **Prompt**: <%= field.prompt %><% } %><% if (field.format) { %>
|
|
10
|
+
- **Format**: <%= field.format %><% } %><% if (field.options) { %>
|
|
11
|
+
- **Options**: <% field.options.forEach(function(option) { %>
|
|
12
|
+
- <%= option.label %> (<%= option.value %>)<% }) %><% } %><% if (field.validation && Object.keys(field.validation).length > 0) { %>
|
|
13
|
+
- **Validation**:<% if (field.validation.minLength) { %>
|
|
14
|
+
- Min Length: <%= field.validation.minLength %><% } %><% if (field.validation.maxLength) { %>
|
|
15
|
+
- Max Length: <%= field.validation.maxLength %><% } %><% if (field.validation.pattern) { %>
|
|
16
|
+
- Pattern: <%= field.validation.pattern %><% } %><% if (field.validation.min) { %>
|
|
17
|
+
- Min Value: <%= field.validation.min %><% } %><% if (field.validation.max) { %>
|
|
18
|
+
- Max Value: <%= field.validation.max %><% } %><% } %>
|
|
19
|
+
<% }); %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
❌ Form "<%= formName %>" is not found.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Total forms (<%= totalForms %> total):
|
|
2
|
+
|
|
3
|
+
<% _.forEach(forms, function(form) { %>
|
|
4
|
+
- <%= form.title %> (**<%= form.name %>**):<% if (form.description) { %>
|
|
5
|
+
- **Description**: <%= form.description %><% } %><% if (!form.hasAccess) { %>
|
|
6
|
+
- **Permissions**: You do not have access to this form.<% } else { %>
|
|
7
|
+
- **Permissions**: <% if (form.permissions.create) { %>Create<% } %><% if (form.permissions.read) { %><% if (form.permissions.create) { %>, <% } %>Read<% } %><% if (form.permissions.update) { %><% if (form.permissions.create || form.permissions.read) { %>, <% } %>Update<% } %> submissions (records)
|
|
8
|
+
<% } %><% }); %>
|
|
9
|
+
|
|
10
|
+
If the user wishes to submit a form they do not have the "Create" permission, then let them know that they do not have the permission to submit that form.
|
|
11
|
+
|
|
12
|
+
If the user wishes to search for a record and they do not have the "Read" permission, then let them know that they do not have the permission to search for records.
|
|
13
|
+
|
|
14
|
+
If the user wishes to update an existing record and they do not have the "Update" permission, then let them know that they do not have permission to update records.
|
|
15
|
+
|
|
16
|
+
If they are simply asking about what forms are available, then you can use this list to provide them simple explaination about the forms available without the need for any permissions.
|
|
17
|
+
|
|
18
|
+
If the user has permission to perform the operation, and it is clear which form they wish to engage with, then immediately use the `get_form_fields` tool to understand how the data is structured within this form.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<%= message %>## <%= type %> fields for <%= parentLabel %>
|
|
2
|
+
<% if (parent) { %>
|
|
3
|
+
All values for these fields should be stored within the `data_path`="<%= parentDataPath %>" (e.g. "<%= parentDataPath %>.exampleField")
|
|
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
|
+
|
|
13
|
+
### <%= type %> fields for <%= parentLabel %>
|
|
14
|
+
<%= fieldList %>
|
|
15
|
+
|
|
16
|
+
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.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Optional Fields Available
|
|
2
|
+
|
|
3
|
+
All required fields have been collected for your **<%= form.title %>** form.
|
|
4
|
+
|
|
5
|
+
**Would you like to fill out any optional fields?**
|
|
6
|
+
|
|
7
|
+
There are <%= totalOptionalFields %> optional fields available:
|
|
8
|
+
<%= optionalFields %>
|
|
9
|
+
|
|
10
|
+
If values for any of these fields are already provided, then skip to the `collect_field_data` tool to add those additional fields. Otherwise, use the following options.
|
|
11
|
+
|
|
12
|
+
**Options:**
|
|
13
|
+
- Say "yes" or "I'd like to fill optional fields" to add optional information
|
|
14
|
+
- Say "no" or "skip optional fields" to proceed with just the required information
|
|
15
|
+
- Say the name of a specific field you'd like to fill (e.g., "email")
|
|
16
|
+
|
|
17
|
+
Use the `collect_field_data` tool to collect any optional fields the user wants to fill.
|
|
18
|
+
|
|
19
|
+
If they wish to skip the collection of optional fields, then use the `submit_completed_form` to submit the required data to the form.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
No submissions found for the <%= form.title %> form matching "<%= searchQuery %>".
|
|
2
|
+
|
|
3
|
+
The search didn't return any results. This could mean:
|
|
4
|
+
- No submissions exist with the specified criteria
|
|
5
|
+
- The search terms might need to be more specific
|
|
6
|
+
- The data might be stored in different fields than expected
|
|
7
|
+
|
|
8
|
+
You can try:
|
|
9
|
+
- Using different search terms
|
|
10
|
+
- Being more specific with names or identifiers
|
|
11
|
+
- Checking if the form name is correct
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Multiple submissions found ending with "<%= partialId %>" - the partial ID is not unique enough.
|
|
2
|
+
|
|
3
|
+
**Matching submissions:**
|
|
4
|
+
<% matchingSubmissions.forEach(function(submission, index) { %>
|
|
5
|
+
**Submission <%= index + 1 %>** (Full ID: <%= submission.fullId %>)
|
|
6
|
+
<% submission.data.forEach(function(item) { %>
|
|
7
|
+
- **<%= item.label %>:** <%= item.value %>
|
|
8
|
+
<% }); %>
|
|
9
|
+
---
|
|
10
|
+
<% }); %>
|
|
11
|
+
|
|
12
|
+
Please use a longer portion of the submission ID to uniquely identify which record you want to update.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
No submission found ending with "<%= partialId %>" for search "<%= searchQuery %>" in <%= form.title %>.
|
|
2
|
+
|
|
3
|
+
**Available submissions:**
|
|
4
|
+
<% availableSubmissions.forEach(function(submission, index) { %>
|
|
5
|
+
**Submission <%= index + 1 %>** (ID ends with: **<%= submission.partialId %>**)
|
|
6
|
+
<% submission.data.forEach(function(item) { %>
|
|
7
|
+
- **<%= item.label %>:** <%= item.value %>
|
|
8
|
+
<% }); %>
|
|
9
|
+
---
|
|
10
|
+
<% }); %>
|
|
11
|
+
|
|
12
|
+
Please try again with one of the partial IDs shown above, or be more specific in your search query.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Error searching submissions for <%= form.title %>: <%= error %>
|
|
2
|
+
|
|
3
|
+
The search for "<%= searchQuery %>" encountered an error. Please check:
|
|
4
|
+
- The form name is correct
|
|
5
|
+
- The search criteria is valid
|
|
6
|
+
- The API connection is working
|
|
7
|
+
|
|
8
|
+
Try rephrasing your search or contact support if the issue persists.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Successfully updated the record in <%= form.title %>!
|
|
2
|
+
- id: <%= submissionId %>
|
|
3
|
+
- created: <%= created %>
|
|
4
|
+
- modified: <%= modified %>
|
|
5
|
+
|
|
6
|
+
**Updated Fields (<%= totalFieldsUpdated %> total):** (It is VERY important to show the values to the user exactly as they were submitted/posted)
|
|
7
|
+
<% updateSummary.forEach(function(update) { %>
|
|
8
|
+
- **<%= update.data_path %>:**
|
|
9
|
+
- Previous: "<%= update.previous_value %>"
|
|
10
|
+
- New: "<%= update.new_value %>"
|
|
11
|
+
<% }); %>
|
|
12
|
+
|
|
13
|
+
<%= dataSummary %>
|
|
14
|
+
|
|
15
|
+
All <%= totalFieldsUpdated %> field(s) have been successfully updated.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Found <%= resultCount %> submissions for <%= form.title %> matching "<%= searchQuery %>":
|
|
2
|
+
|
|
3
|
+
<% submissions.forEach(function(submission, index) { %>
|
|
4
|
+
**Submission <%= index + 1 %>**
|
|
5
|
+
- **ID:** <%= submission._id %>
|
|
6
|
+
- **Requested Data:**
|
|
7
|
+
<% submission.data.forEach(function(field) { %>
|
|
8
|
+
- <%= field.path %>: <%= field.value %>
|
|
9
|
+
<% }); %>
|
|
10
|
+
- **Partial ID (submission_id_partial):** <%= submission.partialId %>
|
|
11
|
+
- **Created:** <%= submission.created %>
|
|
12
|
+
- **Updated:** <%= submission.modified %>
|
|
13
|
+
<% }); %>
|
|
14
|
+
<% if (submissions.length > 1) { %>
|
|
15
|
+
**Multiple submissions found. To proceed:**
|
|
16
|
+
1. **Be more specific** in your search query to find just one record, OR
|
|
17
|
+
2. **Provide the last 4 characters** of the submission ID you want to update (shown above as "ID ends with")
|
|
18
|
+
|
|
19
|
+
Example: "Update the submission ending in **abc1**" or use `find_submissions` with `submission_id_partial: "abc1"`
|
|
20
|
+
|
|
21
|
+
**Note:** All <%= fieldUpdates.length %> field update(s) will be applied to whichever submission you select.
|
|
22
|
+
<% } else { %>
|
|
23
|
+
|
|
24
|
+
Use the `confirm_submission_update` tool with the submission_id set to the full submission ID to submit the data.
|
|
25
|
+
<% } %>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Cannot submit the form due to the following reasons:
|
|
2
|
+
<% validationErrors.forEach(function(error) { %>
|
|
3
|
+
- <% if (error.label && error.path) { %>**<%= error.label %> (<%= error.path %>)**: <% } %><%= error.message %><% }); %>
|
|
4
|
+
|
|
5
|
+
These validation errors are in one of the following format:
|
|
6
|
+
- **Field Label (data_path)** - Error message: If the error is attributed to a specific field value.
|
|
7
|
+
- Error message: If the error is a general error that is not specific to a field value.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
**Submission Data Summary:** (IMPORTANT NOTE: When presenting the values to the user, it must appear exactly as they are in the submission; e.g "user@example.com", "(555) 123-4560")
|
|
2
|
+
<% data.forEach(function(item) { %>
|
|
3
|
+
- **<%= item.label %>**: <%= item.value %>
|
|
4
|
+
<% }); %>
|