swoop-common 2.2.204 → 2.2.206

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.
@@ -7,6 +7,7 @@ export declare enum Stage {
7
7
  export interface MasterFieldDefinition {
8
8
  fieldType: string;
9
9
  name: string;
10
+ fieldId?: string;
10
11
  description?: string;
11
12
  required?: boolean;
12
13
  [key: `${string}Options`]: Record<string, any> | undefined;
@@ -17,9 +17,9 @@ export const generateJsonSchema = (formSchema, stage, onlyEditableFields) => {
17
17
  .includes(stage))
18
18
  return;
19
19
  const fieldSchema = defaultConverter(s, stage);
20
- built.properties[generateFieldId(s.name)] = fieldSchema;
20
+ built.properties[generateFieldId(s.name, s.fieldId)] = fieldSchema;
21
21
  if (s.required && s.fieldType !== "boolean")
22
- built.required.push(generateFieldId(s.name));
22
+ built.required.push(generateFieldId(s.name, s.fieldId));
23
23
  });
24
24
  return built;
25
25
  }
@@ -43,7 +43,7 @@ const defaultConverter = (field, stage, omitTitle, isChild) => {
43
43
  : undefined;
44
44
  const properties = {};
45
45
  for (const child of (_d = (_c = field.objectOptions) === null || _c === void 0 ? void 0 : _c.properties) !== null && _d !== void 0 ? _d : []) {
46
- const fieldId = generateFieldId(child.name);
46
+ const fieldId = generateFieldId(child.name, child.fieldId);
47
47
  properties[fieldId] = defaultConverter(child, stage, false, true);
48
48
  if (child.required && child.fieldType != "boolean")
49
49
  requiredFields.push(fieldId);
@@ -94,6 +94,9 @@ const defaultConverter = (field, stage, omitTitle, isChild) => {
94
94
  : {};
95
95
  let title = omitTitle ? undefined : field.name;
96
96
  let isReadonly = !isChild && !field.editableIn.map(Number).includes(stage);
97
+ if (field.fieldType === "operator") {
98
+ return Object.assign(Object.assign({}, (isReadonly && { readOnly: true })), { title, type: "array", "x-type": "operator", items: { type: "string" }, uniqueItems: true });
99
+ }
97
100
  if (field.fieldType === "enum" && ((_e = field.enumOptions) === null || _e === void 0 ? void 0 : _e.multiSelect)) {
98
101
  return Object.assign(Object.assign(Object.assign({}, (isReadonly && { readOnly: true })), { title, type: "array", "x-type": schema.schema["x-type"], items: {
99
102
  type: "string",
@@ -13,7 +13,7 @@ export const generateUiSchema = (formSchema, stage, onlyEditableFields) => {
13
13
  };
14
14
  const uiFieldSchemaFromFieldDefinition = (field, path = []) => {
15
15
  var _a;
16
- const scope = ["#", ...path, "properties", generateFieldId(field.name)].join("/");
16
+ const scope = ["#", ...path, "properties", generateFieldId(field.name, field.fieldId)].join("/");
17
17
  if (field.fieldType !== "object" || getAllTypes().find((t => t.name === field.fieldType))) {
18
18
  const uiElem = Object.assign({ type: "Control", scope }, (field.fieldType === "radio" && { options: { format: "radio" } }));
19
19
  return uiElem;
@@ -25,7 +25,7 @@ const uiFieldSchemaFromFieldDefinition = (field, path = []) => {
25
25
  elements: children.map((child) => uiFieldSchemaFromFieldDefinition(child, [
26
26
  ...path,
27
27
  "properties",
28
- generateFieldId(field.name),
28
+ generateFieldId(field.name, field.fieldId),
29
29
  ])),
30
30
  };
31
31
  return group;
@@ -1 +1 @@
1
- export declare function generateFieldId(name: string): string;
1
+ export declare function generateFieldId(name: string, fieldId?: string): string;
@@ -1,5 +1,7 @@
1
1
  // Helper function to generate field ID from name
2
- export function generateFieldId(name) {
2
+ export function generateFieldId(name, fieldId) {
3
+ if (fieldId)
4
+ return fieldId;
3
5
  if (!name)
4
6
  return `field_${Date.now()}_${Math.floor(Math.random() * 1000)}`;
5
7
  return toCamelCase(name);
@@ -161,6 +161,7 @@ registerType("person", "Person (Swooper)", { type: "string" }, {
161
161
  },
162
162
  },
163
163
  }, false);
164
+ registerType("operator", "Operator", { type: "array", items: { type: "string" }, uniqueItems: true }, {}, false);
164
165
  registerType("multiline", "Multiline", { type: "string" }, {}, false);
165
166
  registerType("wysiwyg-editor", "WYSIWYG Editor", { type: "string" }, {}, false);
166
167
  registerType("inspection", "Inspections", { type: "array" }, {}, false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swoop-common",
3
- "version": "2.2.204",
3
+ "version": "2.2.206",
4
4
  "main": "dist/api/index.js",
5
5
  "types": "dist/api/index.d.ts",
6
6
  "exports": {