@qoretechnologies/reqraft 0.10.46-pr.95.ge595a13 → 0.10.46

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.
Files changed (147) hide show
  1. package/.claude/CLAUDE.md +12 -0
  2. package/.tasks/INDEX.md +1 -0
  3. package/.tasks/TEMPLATE_TOKEN_GRAMMAR.md +72 -0
  4. package/dist/components/composer/Composer.d.ts.map +1 -1
  5. package/dist/components/composer/Composer.js +5 -1
  6. package/dist/components/composer/Composer.js.map +1 -1
  7. package/dist/components/form/engine/CompactRow.d.ts +14 -0
  8. package/dist/components/form/engine/CompactRow.d.ts.map +1 -1
  9. package/dist/components/form/engine/CompactRow.js +199 -41
  10. package/dist/components/form/engine/CompactRow.js.map +1 -1
  11. package/dist/components/form/engine/CompactToolbar.d.ts.map +1 -1
  12. package/dist/components/form/engine/CompactToolbar.js +72 -72
  13. package/dist/components/form/engine/CompactToolbar.js.map +1 -1
  14. package/dist/components/form/engine/FormEngine.d.ts +65 -1
  15. package/dist/components/form/engine/FormEngine.d.ts.map +1 -1
  16. package/dist/components/form/engine/FormEngine.js +276 -108
  17. package/dist/components/form/engine/FormEngine.js.map +1 -1
  18. package/dist/components/form/engine/_structuredData/SchemaDataView.d.ts.map +1 -1
  19. package/dist/components/form/engine/_structuredData/SchemaDataView.js +55 -13
  20. package/dist/components/form/engine/_structuredData/SchemaDataView.js.map +1 -1
  21. package/dist/components/form/engine/_structuredData/structuredData.d.ts +15 -0
  22. package/dist/components/form/engine/_structuredData/structuredData.d.ts.map +1 -1
  23. package/dist/components/form/engine/_structuredData/structuredData.js +22 -1
  24. package/dist/components/form/engine/_structuredData/structuredData.js.map +1 -1
  25. package/dist/components/form/engine/compactRowStyles.d.ts.map +1 -1
  26. package/dist/components/form/engine/compactRowStyles.js +15 -3
  27. package/dist/components/form/engine/compactRowStyles.js.map +1 -1
  28. package/dist/components/form/engine/compactToolbarContext.d.ts +8 -0
  29. package/dist/components/form/engine/compactToolbarContext.d.ts.map +1 -1
  30. package/dist/components/form/engine/compactToolbarContext.js.map +1 -1
  31. package/dist/components/form/engine/readFirst.d.ts +24 -0
  32. package/dist/components/form/engine/readFirst.d.ts.map +1 -1
  33. package/dist/components/form/engine/readFirst.js +84 -6
  34. package/dist/components/form/engine/readFirst.js.map +1 -1
  35. package/dist/components/form/fields/Field.d.ts.map +1 -1
  36. package/dist/components/form/fields/Field.js +1 -1
  37. package/dist/components/form/fields/Field.js.map +1 -1
  38. package/dist/components/form/fields/allowed-values/AllowedValues.d.ts +12 -2
  39. package/dist/components/form/fields/allowed-values/AllowedValues.d.ts.map +1 -1
  40. package/dist/components/form/fields/allowed-values/AllowedValues.js +16 -6
  41. package/dist/components/form/fields/allowed-values/AllowedValues.js.map +1 -1
  42. package/dist/components/form/fields/auto/AutoFormField.d.ts.map +1 -1
  43. package/dist/components/form/fields/auto/AutoFormField.js +64 -14
  44. package/dist/components/form/fields/auto/AutoFormField.js.map +1 -1
  45. package/dist/components/form/fields/long-string/LongString.d.ts +9 -1
  46. package/dist/components/form/fields/long-string/LongString.d.ts.map +1 -1
  47. package/dist/components/form/fields/long-string/LongString.js +25 -4
  48. package/dist/components/form/fields/long-string/LongString.js.map +1 -1
  49. package/dist/components/form/fields/template/ExampleValueModal.d.ts +29 -0
  50. package/dist/components/form/fields/template/ExampleValueModal.d.ts.map +1 -0
  51. package/dist/components/form/fields/template/ExampleValueModal.js +122 -0
  52. package/dist/components/form/fields/template/ExampleValueModal.js.map +1 -0
  53. package/dist/components/form/fields/template/ReadOnlyTemplateTag.d.ts.map +1 -1
  54. package/dist/components/form/fields/template/ReadOnlyTemplateTag.js +3 -3
  55. package/dist/components/form/fields/template/ReadOnlyTemplateTag.js.map +1 -1
  56. package/dist/components/form/fields/template/TemplateField.d.ts.map +1 -1
  57. package/dist/components/form/fields/template/TemplateField.js +81 -27
  58. package/dist/components/form/fields/template/TemplateField.js.map +1 -1
  59. package/dist/components/form/fields/template/__fixtures__/longExampleValue.d.ts +2 -0
  60. package/dist/components/form/fields/template/__fixtures__/longExampleValue.d.ts.map +1 -0
  61. package/dist/components/form/fields/template/__fixtures__/longExampleValue.js +9 -0
  62. package/dist/components/form/fields/template/__fixtures__/longExampleValue.js.map +1 -0
  63. package/dist/components/form/index.d.ts +1 -0
  64. package/dist/components/form/index.d.ts.map +1 -1
  65. package/dist/components/form/index.js +1 -0
  66. package/dist/components/form/index.js.map +1 -1
  67. package/dist/components/searchFilterBar/SearchFilterBar.d.ts +12 -1
  68. package/dist/components/searchFilterBar/SearchFilterBar.d.ts.map +1 -1
  69. package/dist/components/searchFilterBar/SearchFilterBar.js +2 -2
  70. package/dist/components/searchFilterBar/SearchFilterBar.js.map +1 -1
  71. package/dist/components/ticketThread/TicketThread.d.ts.map +1 -1
  72. package/dist/components/ticketThread/TicketThread.js +1 -1
  73. package/dist/components/ticketThread/TicketThread.js.map +1 -1
  74. package/dist/helpers/common.d.ts +8 -1
  75. package/dist/helpers/common.d.ts.map +1 -1
  76. package/dist/helpers/common.js +9 -1
  77. package/dist/helpers/common.js.map +1 -1
  78. package/dist/helpers/expressions.d.ts.map +1 -1
  79. package/dist/helpers/expressions.js +15 -2
  80. package/dist/helpers/expressions.js.map +1 -1
  81. package/dist/helpers/optionUiTypes.d.ts +30 -0
  82. package/dist/helpers/optionUiTypes.d.ts.map +1 -0
  83. package/dist/helpers/optionUiTypes.js +156 -0
  84. package/dist/helpers/optionUiTypes.js.map +1 -0
  85. package/dist/helpers/options.d.ts +19 -0
  86. package/dist/helpers/options.d.ts.map +1 -1
  87. package/dist/helpers/options.js +25 -1
  88. package/dist/helpers/options.js.map +1 -1
  89. package/dist/helpers/providerValue.d.ts +68 -0
  90. package/dist/helpers/providerValue.d.ts.map +1 -0
  91. package/dist/helpers/providerValue.js +50 -0
  92. package/dist/helpers/providerValue.js.map +1 -0
  93. package/dist/helpers/singleLineString.d.ts +37 -0
  94. package/dist/helpers/singleLineString.d.ts.map +1 -0
  95. package/dist/helpers/singleLineString.js +66 -0
  96. package/dist/helpers/singleLineString.js.map +1 -0
  97. package/dist/helpers/templates.d.ts +100 -0
  98. package/dist/helpers/templates.d.ts.map +1 -1
  99. package/dist/helpers/templates.js +237 -4
  100. package/dist/helpers/templates.js.map +1 -1
  101. package/dist/helpers/validations.d.ts +103 -2
  102. package/dist/helpers/validations.d.ts.map +1 -1
  103. package/dist/helpers/validations.js +858 -91
  104. package/dist/helpers/validations.js.map +1 -1
  105. package/dist/index.d.ts +1 -1
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +2 -1
  108. package/dist/index.js.map +1 -1
  109. package/package.json +1 -1
  110. package/src/components/composer/Composer.tsx +7 -3
  111. package/src/components/form/engine/CompactRow.tsx +279 -33
  112. package/src/components/form/engine/CompactToolbar.tsx +105 -98
  113. package/src/components/form/engine/FormEngine.stories.tsx +995 -12
  114. package/src/components/form/engine/FormEngine.tsx +377 -94
  115. package/src/components/form/engine/_structuredData/SchemaDataView.stories.tsx +104 -0
  116. package/src/components/form/engine/_structuredData/SchemaDataView.tsx +158 -101
  117. package/src/components/form/engine/_structuredData/structuredData.ts +20 -0
  118. package/src/components/form/engine/compactRowStyles.ts +55 -1
  119. package/src/components/form/engine/compactToolbarContext.ts +8 -0
  120. package/src/components/form/engine/readFirst.ts +125 -35
  121. package/src/components/form/fields/Field.tsx +3 -1
  122. package/src/components/form/fields/allowed-values/AllowedValues.tsx +24 -2
  123. package/src/components/form/fields/array/ArrayAutoField.stories.tsx +81 -0
  124. package/src/components/form/fields/auto/AutoFormField.stories.tsx +47 -1
  125. package/src/components/form/fields/auto/AutoFormField.tsx +73 -11
  126. package/src/components/form/fields/long-string/LongString.tsx +46 -5
  127. package/src/components/form/fields/schema-definition/SchemaDefinitionField.stories.tsx +5 -0
  128. package/src/components/form/fields/template/ExampleValueModal.stories.tsx +114 -0
  129. package/src/components/form/fields/template/ExampleValueModal.tsx +99 -0
  130. package/src/components/form/fields/template/ReadOnlyTemplateTag.tsx +8 -4
  131. package/src/components/form/fields/template/TemplateField.stories.tsx +389 -1
  132. package/src/components/form/fields/template/TemplateField.tsx +100 -35
  133. package/src/components/form/fields/template/__fixtures__/longExampleValue.ts +7 -0
  134. package/src/components/form/index.tsx +1 -0
  135. package/src/components/searchFilterBar/SearchFilterBar.stories.tsx +62 -0
  136. package/src/components/searchFilterBar/SearchFilterBar.tsx +13 -0
  137. package/src/components/ticketThread/TicketThread.tsx +7 -0
  138. package/src/helpers/common.ts +11 -1
  139. package/src/helpers/expressions.ts +16 -2
  140. package/src/helpers/optionUiTypes.ts +161 -0
  141. package/src/helpers/options.ts +23 -0
  142. package/src/helpers/providerValue.ts +125 -0
  143. package/src/helpers/singleLineString.ts +61 -0
  144. package/src/helpers/templates.ts +272 -3
  145. package/src/helpers/validations.ts +1177 -109
  146. package/src/hooks/useWebSocket/useWebsocket.stories.tsx +23 -2
  147. package/src/index.tsx +1 -0
@@ -0,0 +1,62 @@
1
+ import { StoryObj } from '@storybook/react-vite';
2
+ import { expect, fn, within } from 'storybook/test';
3
+
4
+ import { StoryMeta } from '../../types';
5
+ import { SearchFilterBar } from './SearchFilterBar';
6
+
7
+ /*
8
+ * The strip that sits above a list and narrows it: a search box plus the filter
9
+ * dropdowns that go with it.
10
+ */
11
+ const meta = {
12
+ component: SearchFilterBar,
13
+ title: 'Components/Search Filter Bar',
14
+ args: {
15
+ onChange: fn(),
16
+ placeholder: 'Search tickets…',
17
+ filters: [
18
+ {
19
+ icon: 'Filter3Line' as const,
20
+ label: 'Any status',
21
+ items: [
22
+ { label: 'Any status', value: 'any', selected: true },
23
+ { label: 'Open', value: 'open' },
24
+ { label: 'Resolved', value: 'resolved' },
25
+ ],
26
+ },
27
+ ],
28
+ },
29
+ } as StoryMeta<typeof SearchFilterBar>;
30
+
31
+ export default meta;
32
+ type Story = StoryObj<typeof meta>;
33
+
34
+ export const Idle: Story = {
35
+ args: { value: '' },
36
+ parameters: {
37
+ docs: {
38
+ description: {
39
+ story: 'Nothing typed — the bar is quiet, and the list below it is the whole list.',
40
+ },
41
+ },
42
+ },
43
+ play: async ({ canvasElement }) => {
44
+ expect(within(canvasElement).getByPlaceholderText('Search tickets…')).toBeVisible();
45
+ },
46
+ };
47
+
48
+ export const Filtering: Story = {
49
+ args: { value: 'deploy', intent: 'info' },
50
+ parameters: {
51
+ docs: {
52
+ description: {
53
+ story:
54
+ 'A query is active, so the box carries `intent="info"`. Without it a filtered list and a genuinely short list look identical, and a reader who lands on three rows cannot tell which they are looking at.',
55
+ },
56
+ },
57
+ },
58
+ play: async ({ canvasElement }) => {
59
+ const input = within(canvasElement).getByPlaceholderText('Search tickets…');
60
+ expect(input).toHaveValue('deploy');
61
+ },
62
+ };
@@ -1,4 +1,5 @@
1
1
  import { ReqoreControlGroup, ReqoreDropdown, ReqoreInput } from '@qoretechnologies/reqore';
2
+ import { TReqoreIntent } from '@qoretechnologies/reqore/dist/constants/theme';
2
3
  import { IReqoreIconName } from '@qoretechnologies/reqore/dist/types/icons';
3
4
  import styled, { css } from 'styled-components';
4
5
 
@@ -70,6 +71,16 @@ export interface ISearchFilterBarProps {
70
71
  * panel (the References tab); a bar above a page-level list does not need it.
71
72
  */
72
73
  sticky?: boolean;
74
+ /**
75
+ * Intent for the search box.
76
+ *
77
+ * A bar that is narrowing the list should look different from one that is
78
+ * not — otherwise a reader who arrives at a short list cannot tell whether it
79
+ * is short or filtered. Callers pass `'info'` while a query is active. Left
80
+ * to the caller rather than derived from `value`, because a caller may hold
81
+ * other filter state this component never sees.
82
+ */
83
+ intent?: TReqoreIntent;
73
84
  }
74
85
 
75
86
  export const SearchFilterBar = ({
@@ -79,6 +90,7 @@ export const SearchFilterBar = ({
79
90
  filters = [],
80
91
  stacked,
81
92
  sticky,
93
+ intent,
82
94
  }: ISearchFilterBarProps) => (
83
95
  <Container $sticky={sticky}>
84
96
  {/* `size='small'` on the GROUP, not per control: the bar filters the content, it
@@ -98,6 +110,7 @@ export const SearchFilterBar = ({
98
110
  value={value}
99
111
  onChange={(event) => onChange((event.currentTarget as HTMLInputElement).value)}
100
112
  onClearClick={value ? () => onChange('') : undefined}
113
+ intent={intent}
101
114
  minimal
102
115
  fluid
103
116
  />
@@ -198,6 +198,13 @@ const StyledSkeletonThread = styled.div`
198
198
  gap: 12px;
199
199
  width: 100%;
200
200
  min-height: 100%;
201
+ /* A real message carries its own bubble, so it never touches the host's edge.
202
+ The skeleton is bare bars, and without this its avatars and lines were
203
+ pressed flat against the border of whatever holds the thread — which reads
204
+ as a clipped render rather than as loading. border-box so the padding comes
205
+ out of the 100% rather than adding to it. */
206
+ box-sizing: border-box;
207
+ padding: 12px;
201
208
  `;
202
209
 
203
210
  const StyledSkeletonRow = styled.div<{ $self: boolean }>`
@@ -1,5 +1,5 @@
1
1
  import { IReqoreRichTextEditorProps } from '@qoretechnologies/reqore/dist/components/RichTextEditor';
2
- import { TQorusFormFieldSchema } from '@qoretechnologies/ts-toolkit';
2
+ import { TQorusFormFieldSchema, TQorusFormOperatorValue } from '@qoretechnologies/ts-toolkit';
3
3
  import yaml from 'js-yaml';
4
4
 
5
5
  // ─── Typed ↔ YAML helpers ──────────────────────────────────────────────────────
@@ -163,6 +163,16 @@ export const richtextToSegments = (
163
163
  return segments;
164
164
  };
165
165
 
166
+ /**
167
+ * An operator value as the list it logically is.
168
+ *
169
+ * An option's `op` holds either one operator or a chain of them, and both
170
+ * spellings are legitimate on the wire. Every reader wants the list.
171
+ */
172
+ export const fixOperatorValue = (
173
+ operator: TQorusFormOperatorValue
174
+ ): (string | null | undefined)[] => (Array.isArray(operator) ? operator : [operator]);
175
+
166
176
  export const insertAtIndex = (array: any[] = [], index = 0, value: any): any[] => {
167
177
  return [...array.slice(0, index), value, ...array.slice(index)];
168
178
  };
@@ -46,14 +46,28 @@ export const argumentMatchesType = (
46
46
  );
47
47
  };
48
48
 
49
+ /**
50
+ * `auto` is the codebase's other spelling of `any` — `Field.tsx` maps both to
51
+ * one renderer, and FormEngine tests `type === 'any' || type === 'auto'` in
52
+ * several places — but the TYPES LIST only carries `any`.
53
+ *
54
+ * That mattered here because an unknown main type falls into the "not found"
55
+ * branch below and answers FALSE for every check. So an `auto`-typed field was
56
+ * judged incompatible with everything: `filterTemplatesByType()` removed every
57
+ * template from it, and the picker offered a group header with nothing under
58
+ * it. The field was not "a field with no templates" — it was a field whose
59
+ * templates had all been filtered away by a name mismatch.
60
+ */
61
+ const normalizeAnyLikeTypeName = (name: string): string => (name === 'auto' ? 'any' : name);
62
+
49
63
  export const areQorusTypesCompatible = (
50
64
  mainType: string | string[],
51
65
  checkType: string | string[],
52
66
  fallbackTypes?: IQorusTypeObject[]
53
67
  ): boolean => {
54
68
  const types = getQorusTypes() || fallbackTypes || defaultQorusTypes;
55
- const mainTypes = isArray(mainType) ? mainType : [mainType];
56
- const checkTypes = isArray(checkType) ? checkType : [checkType];
69
+ const mainTypes = (isArray(mainType) ? mainType : [mainType]).map(normalizeAnyLikeTypeName);
70
+ const checkTypes = (isArray(checkType) ? checkType : [checkType]).map(normalizeAnyLikeTypeName);
57
71
  // Get each of the main types from the types list
58
72
  for (const main of mainTypes) {
59
73
  // Get the type object from the types
@@ -0,0 +1,161 @@
1
+ /**
2
+ * The Qorus option `ui_type` vocabulary.
3
+ *
4
+ * A `ui_type` names the widget an option is rendered with, and — because the
5
+ * widget decides what a complete value looks like — it is also what
6
+ * `validateField` switches on. Both readers have to agree about which strings
7
+ * are in the vocabulary, so the lists live here rather than beside either one.
8
+ *
9
+ * Grouped by what the group means to a reader, not by alphabet: the scalar
10
+ * types hold a single value, the collection types hold several, the choice
11
+ * types pick from a supplied set, and the interface types name another Qorus
12
+ * object by its name — which is why `isOptionInterfaceUiType` is enough for
13
+ * validation to treat the whole group as a non-empty string.
14
+ */
15
+
16
+ export const OPTION_SCALAR_UI_TYPES = [
17
+ 'string',
18
+ 'long-string',
19
+ 'data',
20
+ 'binary',
21
+ 'richtext',
22
+ 'bool',
23
+ 'boolean',
24
+ 'date',
25
+ 'int',
26
+ 'integer',
27
+ 'float',
28
+ 'number',
29
+ 'byte-size',
30
+ // an integer count of milliseconds rendered through the unit-aware timeout
31
+ // field; `validateField` has carried a dedicated `case 'timeout'` since the
32
+ // connection-options work, and a type the validator has a branch for must be
33
+ // in the vocabulary the same switch is keyed on — consumers ask
34
+ // `isOptionUiType` before they ever reach the validator, and an unlisted
35
+ // type reads as unknown (qorus-ide's timeout field regressed exactly this
36
+ // way when its local registry copy was consolidated onto this one).
37
+ 'timeout',
38
+ 'url',
39
+ 'code-editor',
40
+ 'rgbcolor',
41
+ 'any',
42
+ 'auto',
43
+ // semantic string formats (string-backed types that carry a UI-renderable identity; see the qore
44
+ // DataProvider QoreStringFormatDataType)
45
+ 'email',
46
+ 'uri',
47
+ 'uuid',
48
+ 'hostname',
49
+ 'ipv4',
50
+ 'ipv6',
51
+ 'phone',
52
+ ] as const;
53
+
54
+ export const OPTION_COLLECTION_UI_TYPES = [
55
+ 'hash',
56
+ 'free-hash',
57
+ 'list',
58
+ 'free-list',
59
+ 'option_hash',
60
+ 'file',
61
+ 'file-as-string',
62
+ 'collection-documents',
63
+ ] as const;
64
+
65
+ export const OPTION_CHOICE_UI_TYPES = [
66
+ 'enum',
67
+ 'select-string',
68
+ 'select-array',
69
+ 'multi-select',
70
+ ] as const;
71
+
72
+ export const OPTION_INTERFACE_UI_TYPES = [
73
+ 'workflow',
74
+ 'service',
75
+ 'job',
76
+ 'connection',
77
+ 'mapper',
78
+ 'class',
79
+ 'value-map',
80
+ 'fsm',
81
+ 'qog',
82
+ 'api-schema',
83
+ 'auth-profile',
84
+ 'ai-collection',
85
+ 'ai-endpoint',
86
+ 'ai-guardrail',
87
+ 'ml-model',
88
+ 'release-config',
89
+ 'alertrule',
90
+ 'alertsilence',
91
+ 'installed-release',
92
+ 'business-process',
93
+ 'schema',
94
+ 'test',
95
+ ] as const;
96
+
97
+ export const OPTION_CUSTOM_UI_TYPES = [
98
+ 'processor',
99
+ 'processor-mappings',
100
+ 'data-provider',
101
+ 'tool-catalog',
102
+ 'schema-definition',
103
+ 'test-cases',
104
+ 'test-value-contract',
105
+ 'dpql',
106
+ 'active-windows',
107
+ ] as const;
108
+
109
+ export const OPTION_UI_TYPES = [
110
+ ...OPTION_SCALAR_UI_TYPES,
111
+ ...OPTION_COLLECTION_UI_TYPES,
112
+ ...OPTION_CHOICE_UI_TYPES,
113
+ ...OPTION_INTERFACE_UI_TYPES,
114
+ ...OPTION_CUSTOM_UI_TYPES,
115
+ ] as const;
116
+
117
+ export type TOptionUiType = (typeof OPTION_UI_TYPES)[number];
118
+ export type TOptionInterfaceUiType = (typeof OPTION_INTERFACE_UI_TYPES)[number];
119
+
120
+ export const LEGACY_FIELD_UI_TYPES = [
121
+ 'api-manager',
122
+ 'array',
123
+ 'array-auto',
124
+ 'array-of-pairs',
125
+ 'class-array',
126
+ 'class-connectors',
127
+ 'constant-array',
128
+ 'context-selector',
129
+ 'cron',
130
+ 'data-provider-options',
131
+ 'file-array',
132
+ 'fsm-list',
133
+ 'function-array',
134
+ 'http-content',
135
+ 'method-name',
136
+ 'opcua-method-arguments',
137
+ 'opcua-write-values',
138
+ 'options',
139
+ 'select',
140
+ 'service-events',
141
+ 'service-webhooks',
142
+ 'type-selector',
143
+ ] as const;
144
+
145
+ export const KNOWN_QORUS_UI_TYPES = [...OPTION_UI_TYPES, ...LEGACY_FIELD_UI_TYPES] as const;
146
+
147
+ export type TLegacyFieldUiType = (typeof LEGACY_FIELD_UI_TYPES)[number];
148
+ export type TKnownQorusUiType = (typeof KNOWN_QORUS_UI_TYPES)[number];
149
+
150
+ const optionUiTypeSet = new Set<string>(OPTION_UI_TYPES);
151
+ const interfaceUiTypeSet = new Set<string>(OPTION_INTERFACE_UI_TYPES);
152
+ const knownQorusUiTypeSet = new Set<string>(KNOWN_QORUS_UI_TYPES);
153
+
154
+ export const isOptionUiType = (type: unknown): type is TOptionUiType =>
155
+ typeof type === 'string' && optionUiTypeSet.has(type);
156
+
157
+ export const isOptionInterfaceUiType = (type: unknown): type is TOptionInterfaceUiType =>
158
+ typeof type === 'string' && interfaceUiTypeSet.has(type);
159
+
160
+ export const isKnownQorusUiType = (type: unknown): type is TKnownQorusUiType =>
161
+ typeof type === 'string' && knownQorusUiTypeSet.has(type);
@@ -29,3 +29,26 @@ export const getRequiredOptionMessage = (
29
29
 
30
30
  return `This field or ${requiredOptions} is required`;
31
31
  };
32
+
33
+ /**
34
+ * The value of one element of a list field.
35
+ *
36
+ * A list element arrives in either of two shapes, and both are legitimate. The
37
+ * editor keeps each element in a `{value, type}` envelope while the form is
38
+ * being worked on — that is what `formatToServerValue` writes — while a value
39
+ * read back from storage holds what the server contract asks for, which for a
40
+ * list of strings is the bare strings.
41
+ *
42
+ * Reaching straight for `.value` answered `undefined` for every stored element.
43
+ * On a read that emptied the row; on a validation pass it failed the element as
44
+ * empty; and on an autosaving form the emptiness was then written back over the
45
+ * stored value. One helper so the readers cannot disagree about which shape
46
+ * they are looking at.
47
+ *
48
+ * An array is never an envelope — a rich-text document is itself an array, and
49
+ * `'value' in []` is false anyway, but saying so keeps the intent legible.
50
+ */
51
+ export const getListElementValue = (element: unknown): unknown =>
52
+ element && typeof element === 'object' && !Array.isArray(element) && 'value' in element ?
53
+ (element as { value: unknown }).value
54
+ : element;
@@ -0,0 +1,125 @@
1
+ import { TQorusForm } from '@qoretechnologies/ts-toolkit';
2
+
3
+ export type TRecordType = 'search' | 'search-single' | 'create' | 'update' | 'delete';
4
+ export type TRealRecordType = 'read' | 'create' | 'update' | 'delete';
5
+
6
+ export type TProviderTypeSupports = {
7
+ [key in `supports_${TRealRecordType}`]?: boolean;
8
+ };
9
+
10
+ export type TProviderTypeArgs = {
11
+ [key in `${TRecordType}_args`]?: TQorusForm | TQorusForm[];
12
+ };
13
+
14
+ /**
15
+ * A data-provider selection, in the shape the form holds it.
16
+ *
17
+ * The `supports_*` flags say which record operations the selected provider can
18
+ * perform; validation reads them to decide whether a provider is a legitimate
19
+ * target for the operation the field was configured for.
20
+ */
21
+ export interface IProviderType extends TProviderTypeSupports, TProviderTypeArgs {
22
+ type: string;
23
+ name: string;
24
+ path?: string;
25
+ options?: TQorusForm;
26
+ subtype?: 'request' | 'response';
27
+ hasApiContext?: boolean;
28
+ optionsChanged?: boolean;
29
+ searchOptionsChanged?: boolean;
30
+ desc?: string;
31
+ use_args?: boolean;
32
+ args?: any;
33
+ up?: boolean;
34
+ supports_request?: boolean;
35
+ supports_messages?: 'ASYNC' | 'SYNC' | 'NONE';
36
+ supports_observable?: boolean;
37
+ transaction_management?: boolean;
38
+ record_requires_search_options?: boolean;
39
+ create_args_freeform?: TQorusForm[];
40
+ is_api_call?: boolean;
41
+ search_options?: TQorusForm;
42
+ descriptions?: string[];
43
+ message_id?: string;
44
+ message?: {
45
+ type: string;
46
+ value: any;
47
+ };
48
+ }
49
+
50
+ /**
51
+ * A provider value as an object, from either representation a caller may hold.
52
+ *
53
+ * A provider reaches the form either already expanded into `IProviderType`, or
54
+ * as the flat path string the server stores — `"factory/db{driver=pgsql}/table"`
55
+ * or the plain `"type/name/path"`. Returns `null` for anything that is neither,
56
+ * so a caller reports an invalid value rather than reading fields off nothing.
57
+ */
58
+ export const maybeBuildOptionProvider = (provider: unknown): IProviderType | null => {
59
+ if (!provider) {
60
+ return null;
61
+ }
62
+ if (typeof provider === 'object') {
63
+ return provider as IProviderType;
64
+ }
65
+ if (typeof provider !== 'string') {
66
+ return null;
67
+ }
68
+
69
+ if (provider.startsWith('factory')) {
70
+ const fixedProvider = provider.endsWith('/') ? provider : `${provider}/`;
71
+ const [factoryType] = fixedProvider.split('/');
72
+ const factoryName = fixedProvider.substring(
73
+ fixedProvider.indexOf('/') + 1,
74
+ fixedProvider.lastIndexOf('{')
75
+ );
76
+ const options = fixedProvider.substring(
77
+ fixedProvider.indexOf('{') + 1,
78
+ fixedProvider.lastIndexOf('}')
79
+ );
80
+ const optionsObject = options
81
+ .split(',')
82
+ .filter(Boolean)
83
+ .reduce<Record<string, string>>((result, option) => {
84
+ const [key, value] = option.split('=');
85
+ result[key] = value;
86
+ return result;
87
+ }, {});
88
+ const result: IProviderType = {
89
+ type: factoryType,
90
+ name: factoryName,
91
+ path: fixedProvider.substring(fixedProvider.lastIndexOf('}/') + 2),
92
+ options: optionsObject as unknown as TQorusForm,
93
+ };
94
+ if (provider.includes('?options_changed')) {
95
+ result.optionsChanged = true;
96
+ }
97
+ return result;
98
+ }
99
+
100
+ const [type, name, ...path] = provider.split('/');
101
+ return { type, name, path: path.join('/') };
102
+ };
103
+
104
+ /**
105
+ * An FSM variable action — which variable, and what is done to it.
106
+ *
107
+ * The provider half is `Partial<IProviderType>` because the action's own
108
+ * `action_type` decides which provider fields have to be there; validation
109
+ * re-runs the matching provider validator over the merged value rather than
110
+ * duplicating those rules here.
111
+ */
112
+ export type TVariableActionValue = {
113
+ var_type: 'globalvar' | 'localvar' | 'autovar';
114
+ var_name: string;
115
+ transaction_action?: 'commit' | 'rollback' | 'begin-transaction';
116
+ action_type?:
117
+ | 'search'
118
+ | 'search-single'
119
+ | 'update'
120
+ | 'create'
121
+ | 'delete'
122
+ | 'transaction'
123
+ | 'send-message'
124
+ | 'apicall';
125
+ } & Partial<IProviderType>;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Which string field types hold one line, and how to keep them that way.
3
+ *
4
+ * The server already draws this distinction and the IDE was throwing it away:
5
+ * a service's `name` is declared `ui_type: "string"` while its `description` is
6
+ * `ui_type: "long-string"` with `markdown: True` (see `ServiceMetadata.qc`).
7
+ * Every one of them — plus `email`, `uuid`, `hostname`, `ipv4`, `ipv6` and
8
+ * `phone` — rendered through the same growing textarea, so a technical name, a
9
+ * version and an IP address all accepted Enter.
10
+ *
11
+ * That is not a cosmetic problem. These values become YAML keys, class names,
12
+ * URLs and identifiers; a newline in one of them is invalid input that the form
13
+ * happily accepted and passed on, and the operator had no way to see it.
14
+ *
15
+ * The rule is the server's own contract, stated once here rather than guessed
16
+ * per field, and it is enforced in `LongString.tsx`.
17
+ *
18
+ * It lives in reqraft rather than in a consumer because the consumer is not the
19
+ * only renderer: qorus-ide fixed this in its OWN long-string field, and every
20
+ * form that goes through FormEngine — which is where an alert rule's Internal
21
+ * Name, Name and Short Description are — reaches THIS one instead. The fix was
22
+ * real and the field in front of the operator still took Enter.
23
+ */
24
+
25
+ /**
26
+ * The string types that hold exactly one line — the ones routed to a textarea
27
+ * today.
28
+ *
29
+ * Listed explicitly rather than derived by excluding the document types,
30
+ * because the two directions fail very differently. Missing a single-line type
31
+ * here leaves it behaving as it does now — no worse. Wrongly treating a new
32
+ * DOCUMENT type as single-line would flatten a user's text as they typed it,
33
+ * which is data loss. So an unrecognised type stays multi-line.
34
+ */
35
+ const SINGLE_LINE_STRING_TYPES = new Set([
36
+ 'string',
37
+ 'email',
38
+ 'uuid',
39
+ 'hostname',
40
+ 'ipv4',
41
+ 'ipv6',
42
+ 'phone',
43
+ ]);
44
+
45
+ /** True when a string field of this type holds a single line. */
46
+ export const isSingleLineStringType = (type?: string): boolean =>
47
+ !!type && SINGLE_LINE_STRING_TYPES.has(type);
48
+
49
+ /**
50
+ * Flattens any line break to a single space.
51
+ *
52
+ * A space rather than nothing, because the newline is usually where a word
53
+ * boundary was — pasting two lines into a name should read as two words, not
54
+ * one run-together one. CR, LF and CRLF all collapse to one space, and the
55
+ * result is trimmed of leading/trailing whitespace the break introduced.
56
+ */
57
+ export const flattenToSingleLine = (value: string): string =>
58
+ value.replace(/\r\n|\r|\n/g, ' ').replace(/ {2,}/g, ' ');
59
+
60
+ /** True when the value carries a line break this field should not hold. */
61
+ export const hasLineBreak = (value: string): boolean => /\r|\n/.test(value);