@saltcorn/copilot 0.4.4 → 0.4.5

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.
@@ -17,7 +17,7 @@ class GenerateTables {
17
17
  const types = Object.values(getState().types);
18
18
  const fieldTypeCfg = types.map((ty) => {
19
19
  const properties = {
20
- data_type: { const: ty.name },
20
+ data_type: { type: "string", enum: [ty.name] },
21
21
  };
22
22
  const attrs = apply(ty.attributes, {}) || [];
23
23
  if (Array.isArray(attrs))
@@ -40,7 +40,7 @@ class GenerateTables {
40
40
  description:
41
41
  "A foreign key to a different table. This will reference the primary key on another table.",
42
42
  properties: {
43
- data_type: { const: "ForeignKey" },
43
+ data_type: { type: "string", enum: ["ForeignKey"] },
44
44
  reference_table: {
45
45
  type: "string",
46
46
  description: "Name of the table being referenced",
@@ -52,7 +52,7 @@ class GenerateTables {
52
52
  description:
53
53
  "A reference (file path) to a file on disk. This can be used for example to hold images or documents",
54
54
  properties: {
55
- data_type: { const: "File" },
55
+ data_type: { type: "string", enum: ["File"] },
56
56
  },
57
57
  });
58
58
  return {
@@ -16,7 +16,9 @@ const steps = async () => {
16
16
  );
17
17
 
18
18
  const stepTypeAndCfg = Object.keys(actionExplainers).map((actionName) => {
19
- const properties = { step_type: { const: actionName } };
19
+ const properties = {
20
+ step_type: { type: "string", enum: [actionName] }
21
+ };
20
22
  const myFields = actionFields.filter(
21
23
  (f) => f.showIf?.wf_action_name === actionName
22
24
  );
@@ -37,7 +39,9 @@ const steps = async () => {
37
39
  });
38
40
  for (const [actionName, action] of stateActionList) {
39
41
  try {
40
- const properties = { step_type: { const: actionName } };
42
+ const properties = {
43
+ step_type: { type: "string", enum: [actionName] }
44
+ };
41
45
  const cfgFields = await getActionConfigFields(action, null, {
42
46
  mode: "workflow",
43
47
  copilot: true,
@@ -69,7 +73,10 @@ const steps = async () => {
69
73
  //TODO workflows
70
74
  for (const trigger of triggers) {
71
75
  const properties = {
72
- step_type: { const: trigger.name },
76
+ step_type: {
77
+ type: "string",
78
+ enum: [trigger.name],
79
+ },
73
80
  };
74
81
  if (trigger.table_id) {
75
82
  const table = Table.findOne({ id: trigger.table_id });
package/common.js CHANGED
@@ -99,7 +99,19 @@ const fieldProperties = (field) => {
99
99
  if (field.options) props.enum = toArrayOfStrings(field.options);
100
100
  break;
101
101
  }
102
+ if (!props.type) {
103
+ switch (field.input_type) {
104
+ case "code":
105
+ props.type = "string";
106
+ break;
107
+ }
108
+ }
102
109
  return props;
103
110
  };
104
111
 
105
- module.exports = { getCompletion, getPromptFromTemplate, incompleteCfgMsg, fieldProperties };
112
+ module.exports = {
113
+ getCompletion,
114
+ getPromptFromTemplate,
115
+ incompleteCfgMsg,
116
+ fieldProperties,
117
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/copilot",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "AI assistant for building Saltcorn applications",
5
5
  "main": "index.js",
6
6
  "dependencies": {