@saltcorn/copilot 0.1.0 → 0.1.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.
@@ -114,6 +114,7 @@ const runPost = async (
114
114
 
115
115
  const moreTypes = {
116
116
  decimal: "Float",
117
+ numeric: "Float",
117
118
  varchar: "String",
118
119
  };
119
120
 
@@ -137,14 +138,24 @@ const save_database = async (table_id, viewname, config, body, { req }) => {
137
138
  definition,
138
139
  primary_key,
139
140
  reference_definition,
141
+ resource,
140
142
  } of create_definitions) {
141
143
  if (primary_key) continue;
144
+ if (resource === "constraint") continue;
145
+
142
146
  let type =
143
147
  findType(definition.dataType.toLowerCase()) ||
144
148
  moreTypes[definition.dataType.toLowerCase()];
145
149
  if (reference_definition)
146
150
  type = `Key to ${reference_definition.table[0].table}`;
147
-
151
+ const constraint = create_definitions.find(
152
+ (cd) =>
153
+ cd.resource === "constraint" &&
154
+ cd.definition?.[0]?.column === column.column
155
+ );
156
+ if (constraint?.reference_definition) {
157
+ type = `Key to ${constraint.reference_definition.table[0].table}`;
158
+ }
148
159
  fields.push({
149
160
  name: column.column,
150
161
  type,
@@ -161,6 +172,7 @@ const save_database = async (table_id, viewname, config, body, { req }) => {
161
172
 
162
173
  for (const field of tbl.fields) {
163
174
  field.table = table;
175
+ console.log("field", field.name, "type", field.type);
164
176
  //pick summary field
165
177
  if (field.type === "Key to users") {
166
178
  field.attributes = { summary_field: "email" };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/copilot",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "AI assistant for building Saltcorn applications",
5
5
  "main": "index.js",
6
6
  "dependencies": {