@overmap-ai/core 1.0.57 → 1.0.58-asset-description.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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @overmap-ai/core
2
-
3
- The `core` package contains core functionality for the Overmap platform. It is a peer dependency of all other overmap
4
- packages.
1
+ # @overmap-ai/core
2
+
3
+ The `core` package contains core functionality for the Overmap platform. It is a peer dependency of all other overmap
4
+ packages.
@@ -6,7 +6,7 @@ import { FieldOptions } from "./typings";
6
6
  import { FormikUserFormRevision } from "../../builder";
7
7
  export declare abstract class BaseFormElement<TIdentifier extends FieldTypeIdentifier = FieldTypeIdentifier> {
8
8
  readonly type: TIdentifier;
9
- protected readonly identifier: string;
9
+ readonly identifier: string;
10
10
  readonly description: string | null;
11
11
  protected constructor(options: BaseSerializedObject);
12
12
  getId(): string;
@@ -47,4 +47,6 @@ export declare abstract class BaseField<TValue extends FieldValue, TIdentifier e
47
47
  abstract serialize(): ISerializedOnlyField;
48
48
  getFieldValidators(): InputFieldLevelValidator<TValue>[];
49
49
  getFormValidators(): InputFormLevelValidator<TValue>[];
50
+ encodeValueToJson(value: TValue): string;
51
+ decodeJsonToValue(json: string): TValue;
50
52
  }
@@ -2,8 +2,8 @@ import { BaseField, ChildFieldOptions } from "../BaseField";
2
2
  import { GetInputProps, InputFieldLevelValidator } from "../typings";
3
3
  import { ChangeEvent, ReactNode } from "react";
4
4
  import { RiListCheck } from "react-icons/ri";
5
- import { ISerializedField, SelectFieldOption, SerializedMultiStringField } from "../../typings";
6
- type MultiStringFieldOptions = ChildFieldOptions<SelectFieldOption[]> & {
5
+ import { ISerializedField, SerializedMultiStringField } from "../../typings";
6
+ type MultiStringFieldOptions = ChildFieldOptions<string[]> & {
7
7
  minimum_length?: number;
8
8
  maximum_length?: number;
9
9
  placeholder?: string;
@@ -21,7 +21,7 @@ export declare const emptyMultiStringField: {
21
21
  * - Specifying the options of a SelectField (used in `SelectField.getFieldCreationSchema`
22
22
  * - Listing serial numbers and similar
23
23
  */
24
- export declare class MultiStringField extends BaseField<SelectFieldOption[], "multi-string"> {
24
+ export declare class MultiStringField extends BaseField<string[], "multi-string"> {
25
25
  static readonly fieldTypeName = "Multi-string";
26
26
  static readonly fieldTypeDescription = "Allows the user to provide multiple unique strings.";
27
27
  readonly minLength: number;
@@ -30,11 +30,11 @@ export declare class MultiStringField extends BaseField<SelectFieldOption[], "mu
30
30
  readonly placeholder: string;
31
31
  static Icon: typeof RiListCheck;
32
32
  constructor(options: MultiStringFieldOptions);
33
- getValueFromChangeEvent(event: ChangeEvent<HTMLInputElement> | SelectFieldOption[]): SelectFieldOption[];
33
+ getValueFromChangeEvent(event: ChangeEvent<HTMLInputElement> | string[]): string[];
34
34
  getInput(props: GetInputProps<this>): ReactNode;
35
35
  serialize(): SerializedMultiStringField;
36
- protected isBlank(value: SelectFieldOption[]): boolean;
37
- getFieldValidators(): InputFieldLevelValidator<SelectFieldOption[]>[];
36
+ protected isBlank(value: string[]): boolean;
37
+ getFieldValidators(): InputFieldLevelValidator<string[]>[];
38
38
  static deserialize(data: ISerializedField): MultiStringField;
39
39
  }
40
40
  export {};
@@ -23,5 +23,5 @@ export interface ComponentProps<TField extends BaseFormElement> extends Omit<HTM
23
23
  showInputOnly?: boolean;
24
24
  }
25
25
  export type GetInputProps<TField extends BaseFormElement> = Omit<ComponentProps<TField>, "field">;
26
- export type AnyField = BaseField<any>;
26
+ export type AnyField = BaseField<any, any>;
27
27
  export type ISerializedOnlyField = Exclude<ISerializedField, SerializedFieldSection>;
@@ -10,5 +10,6 @@ export declare const deserializeField: (serializedField: ISerializedOnlyField) =
10
10
  export declare const deserialize: (serialized: ISerializedField) => AnyField | FieldSection;
11
11
  export type PartialFormRevision = Pick<UserFormRevision, "title" | "fields" | "description"> & Partial<UserFormRevision>;
12
12
  export declare function formRevisionToSchema(formRevision: PartialFormRevision, meta?: Partial<SchemaMeta>): ISchema;
13
+ export declare function decodeFormValues(schema: ISchema, values: Record<string, string>): Record<string, FieldValue>;
13
14
  export declare function valueIsFile(v: FieldValue | Promise<File>[] | undefined): v is File[] | Promise<File>[];
14
15
  export declare function isConditionMet<TValue extends FieldValue | Promise<File>[]>(condition: TValue extends FieldValue ? SerializedCondition<TValue> | null : null, value: TValue): boolean;
@@ -4074,6 +4074,24 @@ const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
4074
4074
  }
4075
4075
  )
4076
4076
  );
4077
+ const selectFormSubmissionsByIssues = restructureCreateSelectorWithArgs(
4078
+ createSelector(
4079
+ [selectFormSubmissions, (_state, issueIds) => issueIds],
4080
+ (submissions, issueIds) => {
4081
+ var _a2;
4082
+ const issueSubmissions = {};
4083
+ for (const issueId of issueIds) {
4084
+ issueSubmissions[issueId] = [];
4085
+ }
4086
+ for (const submission of submissions) {
4087
+ if (submission.issue && issueIds.includes(submission.issue)) {
4088
+ (_a2 = issueSubmissions[submission.issue]) == null ? void 0 : _a2.push(submission);
4089
+ }
4090
+ }
4091
+ return issueSubmissions;
4092
+ }
4093
+ )
4094
+ );
4077
4095
  const selectFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
4078
4096
  createSelector(
4079
4097
  [selectFormSubmissions, (_state, assetId) => assetId],
@@ -8779,6 +8797,12 @@ class BaseField extends BaseFormElement {
8779
8797
  getFormValidators() {
8780
8798
  return [...this.formValidators];
8781
8799
  }
8800
+ encodeValueToJson(value) {
8801
+ return JSON.stringify(value);
8802
+ }
8803
+ decodeJsonToValue(json) {
8804
+ return JSON.parse(json);
8805
+ }
8782
8806
  }
8783
8807
  __publicField(BaseField, "fieldTypeName");
8784
8808
  __publicField(BaseField, "fieldTypeDescription");
@@ -13052,7 +13076,7 @@ const MultiStringInput = memo((props) => {
13052
13076
  );
13053
13077
  const handleChange = useCallback(
13054
13078
  (e) => {
13055
- if (value.findIndex((option) => option.value === e.target.value.trim()) >= 0) {
13079
+ if (value.findIndex((option) => option === e.target.value.trim()) >= 0) {
13056
13080
  setInternalError("All options must be unique");
13057
13081
  } else if (!e.target.value) {
13058
13082
  setInternalError("Option cannot be empty");
@@ -13071,7 +13095,7 @@ const MultiStringInput = memo((props) => {
13071
13095
  return;
13072
13096
  }
13073
13097
  const trimmedValue = intermediateValue.trim();
13074
- setValueAndTouched([...value, { value: trimmedValue, label: trimmedValue }]);
13098
+ setValueAndTouched([...value, trimmedValue]);
13075
13099
  setIntermediateValue("");
13076
13100
  }, [intermediateValue, internalError, setValueAndTouched, value]);
13077
13101
  const handleKeyDown = useCallback(
@@ -13141,7 +13165,7 @@ const MultiStringInput = memo((props) => {
13141
13165
  value.map((option, index2) => /* @__PURE__ */ jsx(
13142
13166
  Draggable,
13143
13167
  {
13144
- draggableId: `${option.value}-draggable`,
13168
+ draggableId: `${option}-draggable`,
13145
13169
  index: index2,
13146
13170
  isDragDisabled: disabled,
13147
13171
  children: ({ draggableProps, dragHandleProps, innerRef }) => /* @__PURE__ */ jsx(
@@ -13156,7 +13180,7 @@ const MultiStringInput = memo((props) => {
13156
13180
  mb: "1",
13157
13181
  asChild: true,
13158
13182
  children: /* @__PURE__ */ jsxs(Badge, { color: "gray", size: "2", children: [
13159
- /* @__PURE__ */ jsx("span", { children: option.label }),
13183
+ /* @__PURE__ */ jsx("span", { children: option }),
13160
13184
  /* @__PURE__ */ jsx(
13161
13185
  IconButton,
13162
13186
  {
@@ -13176,7 +13200,7 @@ const MultiStringInput = memo((props) => {
13176
13200
  }
13177
13201
  )
13178
13202
  },
13179
- option.value
13203
+ option
13180
13204
  )),
13181
13205
  droppableProvided.placeholder
13182
13206
  ] }) })
@@ -13433,7 +13457,7 @@ const QrInput = memo((props) => {
13433
13457
  severity,
13434
13458
  inputId,
13435
13459
  labelId,
13436
- label: showInputOnly ? label : "",
13460
+ label,
13437
13461
  image: showInputOnly ? void 0 : field.image,
13438
13462
  flexProps: { direction: "column", justify: "start", align: "start", gap: "1" },
13439
13463
  children: [
@@ -14851,6 +14875,27 @@ function formRevisionToSchema(formRevision, meta = {}) {
14851
14875
  meta: { readonly }
14852
14876
  };
14853
14877
  }
14878
+ function decodeFormValues(schema, values) {
14879
+ let allFields = [];
14880
+ for (const field of schema.fields) {
14881
+ if (field instanceof FieldSection) {
14882
+ allFields = allFields.concat(field.fields);
14883
+ } else {
14884
+ if (!(field instanceof BaseField)) {
14885
+ throw new Error("Invalid field type");
14886
+ }
14887
+ allFields.push(field);
14888
+ }
14889
+ }
14890
+ const result = {};
14891
+ for (const field of allFields) {
14892
+ if (!(field.identifier in values))
14893
+ ;
14894
+ const value = values[field.identifier];
14895
+ result[field.identifier] = field.decodeJsonToValue(value);
14896
+ }
14897
+ return result;
14898
+ }
14854
14899
  function valueIsFile(v) {
14855
14900
  return Array.isArray(v) && v.some((v2) => v2 instanceof File || v2 instanceof Promise);
14856
14901
  }
@@ -16632,6 +16677,7 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
16632
16677
  StringInput,
16633
16678
  TextField,
16634
16679
  TextInput,
16680
+ decodeFormValues,
16635
16681
  deserialize,
16636
16682
  deserializeField,
16637
16683
  emptyBaseField,
@@ -16840,6 +16886,7 @@ export {
16840
16886
  coordinatesToUrlText,
16841
16887
  createOfflineAction,
16842
16888
  createPointMarker,
16889
+ decodeFormValues,
16843
16890
  defaultBadgeColor,
16844
16891
  defaultStore,
16845
16892
  deleteAssetType,
@@ -17089,6 +17136,7 @@ export {
17089
17136
  selectFormSubmissions,
17090
17137
  selectFormSubmissionsByAssets,
17091
17138
  selectFormSubmissionsByFormRevisions,
17139
+ selectFormSubmissionsByIssues,
17092
17140
  selectFormSubmissionsMapping,
17093
17141
  selectFormSubmissionsOfAsset,
17094
17142
  selectFormSubmissionsOfForm,