@saltcorn/sql 0.6.0 → 0.6.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/index.js CHANGED
@@ -186,6 +186,29 @@ module.exports = {
186
186
  name: "SQLView",
187
187
  display_state_form: false,
188
188
  tableless: true,
189
+ copilot_generate_view_prompt: async ({ table }) => {
190
+ const tableLines = [];
191
+ const tables = await Table.find({});
192
+ tables.forEach((table) => {
193
+ const fieldLines = table.fields.map(
194
+ (f) =>
195
+ ` * ${f.name} with type: ${f.pretty_type.replace(
196
+ "Key to",
197
+ "ForeignKey referencing",
198
+ )}.${f.description ? ` ${f.description}` : ""}`,
199
+ );
200
+ tableLines.push(
201
+ `${table.name}${
202
+ table.description ? `: ${table.description}.` : "."
203
+ } Contains the following fields:\n${fieldLines.join("\n")}`,
204
+ );
205
+ });
206
+ return `The database already contains the following tables:
207
+
208
+ ${tableLines.join("\n\n")}
209
+
210
+ You can reference these tables when generating SQL`;
211
+ },
189
212
  get_state_fields,
190
213
  configuration_workflow,
191
214
  run,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/sql",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Actions and views based on SQL",
5
5
  "main": "index.js",
6
6
  "dependencies": {
package/table-provider.js CHANGED
@@ -70,6 +70,7 @@ const configuration_workflow = (req) =>
70
70
  label: "Create SQL VIEW",
71
71
  type: "Bool",
72
72
  name: "sql_view",
73
+ default: true
73
74
  },
74
75
  ]
75
76
  : []),
@@ -547,6 +548,9 @@ module.exports = {
547
548
  getJoinedRows: async (opts) => {
548
549
  return await syntheticTable.getJoinedRows(opts);
549
550
  },
551
+ aggregationQuery: async (aggs, opts) => {
552
+ return await syntheticTable.aggregationQuery(aggs, opts);
553
+ },
550
554
  }
551
555
  : {}),
552
556
  };