@valerypopoff/rivet2-core 2.1.3 → 2.1.4
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/dist/cjs/bundle.cjs +2707 -1012
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/cjs/webAppRuntime.cjs +625 -0
- package/dist/cjs/webAppRuntime.cjs.map +7 -0
- package/dist/esm/api/createProcessor.js +3 -0
- package/dist/esm/api/streaming.js +6 -0
- package/dist/esm/exports.js +5 -0
- package/dist/esm/integrations/mcp/MCPBase.js +92 -34
- package/dist/esm/model/GraphProcessor.js +11 -4
- package/dist/esm/model/GraphProgress.js +15 -0
- package/dist/esm/model/Nodes.js +3 -0
- package/dist/esm/model/ProcessContextBuilder.js +2 -1
- package/dist/esm/model/RecordingPlayer.js +10 -0
- package/dist/esm/model/SubprocessorBridge.js +1 -0
- package/dist/esm/model/UiGraph.js +127 -4
- package/dist/esm/model/UiGraphActionProtocol.js +122 -0
- package/dist/esm/model/UiGraphBindings.js +530 -0
- package/dist/esm/model/UiGraphBrowserRuntime.js +40 -0
- package/dist/esm/model/UiGraphNormalization.js +298 -0
- package/dist/esm/model/UiGraphRendererStyles.js +374 -6
- package/dist/esm/model/UiGraphRuntimeModel.js +300 -0
- package/dist/esm/model/UiGraphWebAppStatus.js +19 -0
- package/dist/esm/model/nodes/ArrayNode.js +2 -13
- package/dist/esm/model/nodes/AssembleMessageNode.js +2 -13
- package/dist/esm/model/nodes/AssemblePromptNode.js +2 -13
- package/dist/esm/model/nodes/CoalesceNode.js +2 -15
- package/dist/esm/model/nodes/DelayNode.js +3 -14
- package/dist/esm/model/nodes/DidRunNode.js +2 -13
- package/dist/esm/model/nodes/JoinNode.js +2 -13
- package/dist/esm/model/nodes/LoopControllerNode.js +3 -14
- package/dist/esm/model/nodes/MCPDiscoveryNode.js +19 -90
- package/dist/esm/model/nodes/MCPGetPromptNode.js +11 -97
- package/dist/esm/model/nodes/MCPToolCallNode.js +11 -97
- package/dist/esm/model/nodes/PassthroughNode.js +3 -14
- package/dist/esm/model/nodes/RaceInputsNode.js +2 -13
- package/dist/esm/model/nodes/ReportProgressNode.js +57 -0
- package/dist/esm/model/nodes/variadicPortIndex.js +32 -0
- package/dist/esm/plugins/anthropic/anthropic.js +1 -1
- package/dist/esm/recording/ExecutionRecorder.js +5 -0
- package/dist/esm/utils/fetchEventSource.js +16 -17
- package/dist/esm/utils/serialization/serialization.js +4 -0
- package/dist/esm/utils/serialization/serializationUtils.js +8 -27
- package/dist/esm/utils/serialization/serialization_v4.js +3 -3
- package/dist/esm/webAppRuntime.js +4 -2
- package/dist/types/api/streaming.d.ts +6 -0
- package/dist/types/exports.d.ts +5 -0
- package/dist/types/integrations/mcp/MCPBase.d.ts +26 -3
- package/dist/types/model/ExecutorProtocol.d.ts +7 -0
- package/dist/types/model/GraphProcessor.d.ts +7 -0
- package/dist/types/model/GraphProgress.d.ts +6 -0
- package/dist/types/model/Nodes.d.ts +3 -2
- package/dist/types/model/ProcessContext.d.ts +3 -0
- package/dist/types/model/ProcessContextBuilder.d.ts +2 -1
- package/dist/types/model/UiGraph.d.ts +42 -9
- package/dist/types/model/UiGraphActionProtocol.d.ts +69 -0
- package/dist/types/model/UiGraphBindings.d.ts +45 -0
- package/dist/types/model/UiGraphBrowserRuntime.d.ts +4 -0
- package/dist/types/model/UiGraphNormalization.d.ts +24 -0
- package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
- package/dist/types/model/UiGraphRuntimeModel.d.ts +77 -5
- package/dist/types/model/UiGraphWebAppStatus.d.ts +5 -0
- package/dist/types/model/nodes/ArrayNode.d.ts +0 -1
- package/dist/types/model/nodes/AssembleMessageNode.d.ts +0 -1
- package/dist/types/model/nodes/AssemblePromptNode.d.ts +0 -1
- package/dist/types/model/nodes/DelayNode.d.ts +0 -1
- package/dist/types/model/nodes/DidRunNode.d.ts +0 -1
- package/dist/types/model/nodes/JoinNode.d.ts +0 -1
- package/dist/types/model/nodes/LoopControllerNode.d.ts +0 -1
- package/dist/types/model/nodes/PassthroughNode.d.ts +0 -1
- package/dist/types/model/nodes/RaceInputsNode.d.ts +0 -1
- package/dist/types/model/nodes/ReportProgressNode.d.ts +23 -0
- package/dist/types/model/nodes/variadicPortIndex.d.ts +4 -0
- package/dist/types/recording/RecordedEvents.d.ts +5 -0
- package/dist/types/webAppRuntime.d.ts +8 -3
- package/package.json +2 -2
- package/dist/esm/plugins/anthropic/fetchEventSource.js +0 -107
- package/dist/types/plugins/anthropic/fetchEventSource.d.ts +0 -11
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getUiGraphJsonOutputFilename } from './UiGraphRuntimeModel.js';
|
|
2
|
+
/** Copies rendered web-app output without requiring the modern Clipboard API. */
|
|
3
|
+
export async function copyUiGraphText(value) {
|
|
4
|
+
try {
|
|
5
|
+
await navigator.clipboard.writeText(value);
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
// Preview hosts and non-secure origins may not expose the Clipboard API.
|
|
10
|
+
}
|
|
11
|
+
const textArea = document.createElement('textarea');
|
|
12
|
+
textArea.className = 'rivet-web-app-clipboard-fallback';
|
|
13
|
+
textArea.value = value;
|
|
14
|
+
try {
|
|
15
|
+
document.body.append(textArea);
|
|
16
|
+
textArea.select();
|
|
17
|
+
return document.execCommand?.('copy') ?? false;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
textArea.remove();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Downloads the exact JSON string rendered by a web-app output component. */
|
|
27
|
+
export function downloadUiGraphJsonOutput(value, appName) {
|
|
28
|
+
const url = URL.createObjectURL(new Blob([value], { type: 'application/json' }));
|
|
29
|
+
try {
|
|
30
|
+
const link = document.createElement('a');
|
|
31
|
+
link.href = url;
|
|
32
|
+
link.download = getUiGraphJsonOutputFilename(appName);
|
|
33
|
+
document.body.append(link);
|
|
34
|
+
link.click();
|
|
35
|
+
link.remove();
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
globalThis.setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { UI_GRAPH_GAP_SIZES, UI_GRAPH_OUTPUT_RENDER_MODES, normalizeUiGraphComponentIds, } from './UiGraph.js';
|
|
2
|
+
export class UiGraphNormalizationError extends Error {
|
|
3
|
+
issues;
|
|
4
|
+
constructor(issues) {
|
|
5
|
+
super(`Invalid UI graph configuration: ${issues.map(formatUiGraphNormalizationIssue).join('; ')}`);
|
|
6
|
+
this.issues = issues;
|
|
7
|
+
this.name = 'UiGraphNormalizationError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function formatUiGraphNormalizationIssue(issue) {
|
|
11
|
+
return `${issue.path}: ${issue.message}`;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Validates every UI graph and component discriminator while applying only the
|
|
15
|
+
* deterministic component-ID repair supported for legacy project snapshots.
|
|
16
|
+
*/
|
|
17
|
+
export function normalizeUiGraph(value, options = {}) {
|
|
18
|
+
const result = parseUiGraph(value, { ...options, expectedId: undefined });
|
|
19
|
+
if (result.issues.length > 0) {
|
|
20
|
+
throw new UiGraphNormalizationError(result.issues);
|
|
21
|
+
}
|
|
22
|
+
return result.uiGraph;
|
|
23
|
+
}
|
|
24
|
+
export function normalizeUiGraphRecord(value, options = {}) {
|
|
25
|
+
if (!isRecord(value)) {
|
|
26
|
+
throw new UiGraphNormalizationError([{ message: 'must be an object', path: 'Project uiGraphs' }]);
|
|
27
|
+
}
|
|
28
|
+
const issues = [];
|
|
29
|
+
const replacements = new Map();
|
|
30
|
+
const uiGraphEntries = Object.entries(value);
|
|
31
|
+
for (const [uiGraphId, uiGraph] of uiGraphEntries) {
|
|
32
|
+
const result = parseUiGraph(uiGraph, { ...options, expectedId: uiGraphId });
|
|
33
|
+
issues.push(...result.issues);
|
|
34
|
+
if (result.uiGraph && result.uiGraph !== uiGraph) {
|
|
35
|
+
replacements.set(uiGraphId, result.uiGraph);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (issues.length > 0) {
|
|
39
|
+
throw new UiGraphNormalizationError(issues);
|
|
40
|
+
}
|
|
41
|
+
if (replacements.size === 0) {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
return Object.fromEntries(uiGraphEntries.map(([uiGraphId, uiGraph]) => [uiGraphId, replacements.get(uiGraphId) ?? uiGraph]));
|
|
45
|
+
}
|
|
46
|
+
export function normalizeProjectUiGraphs(project) {
|
|
47
|
+
if (project.uiGraphs === undefined) {
|
|
48
|
+
return project;
|
|
49
|
+
}
|
|
50
|
+
const uiGraphs = normalizeUiGraphRecord(project.uiGraphs);
|
|
51
|
+
return uiGraphs === project.uiGraphs ? project : { ...project, uiGraphs };
|
|
52
|
+
}
|
|
53
|
+
function parseUiGraph(value, options) {
|
|
54
|
+
const issues = [];
|
|
55
|
+
const graphLabel = getUiGraphLabel(value, options.expectedId);
|
|
56
|
+
const graphPath = `UI graph "${graphLabel}"`;
|
|
57
|
+
if (!isRecord(value)) {
|
|
58
|
+
return { issues: [{ message: 'must be an object', path: graphPath }] };
|
|
59
|
+
}
|
|
60
|
+
requireNonEmptyString(value, 'id', graphPath, issues);
|
|
61
|
+
requireString(value, 'name', graphPath, issues);
|
|
62
|
+
optionalString(value, 'description', graphPath, issues);
|
|
63
|
+
if (options.expectedId !== undefined && typeof value.id === 'string' && value.id !== options.expectedId) {
|
|
64
|
+
issues.push({
|
|
65
|
+
message: `must match its project key "${options.expectedId}"`,
|
|
66
|
+
path: `${graphPath}.id`,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (!Array.isArray(value.components)) {
|
|
70
|
+
issues.push({ message: 'must be an array', path: `${graphPath}.components` });
|
|
71
|
+
return { issues };
|
|
72
|
+
}
|
|
73
|
+
validateComponents(value.components, graphPath, options, issues);
|
|
74
|
+
if (issues.length > 0) {
|
|
75
|
+
return { issues };
|
|
76
|
+
}
|
|
77
|
+
const uiGraph = value;
|
|
78
|
+
return {
|
|
79
|
+
issues,
|
|
80
|
+
uiGraph: options.repairComponentIds === false ? uiGraph : normalizeUiGraphComponentIds(uiGraph),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function validateComponents(components, graphPath, options, issues) {
|
|
84
|
+
const repairComponentIds = options.repairComponentIds !== false;
|
|
85
|
+
const usedIds = new Set();
|
|
86
|
+
for (const [index, component] of components.entries()) {
|
|
87
|
+
const componentPath = `${graphPath} component at index ${index}`;
|
|
88
|
+
if (!isRecord(component)) {
|
|
89
|
+
issues.push({ message: 'must be an object', path: componentPath });
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
validateComponent(component, componentPath, issues);
|
|
93
|
+
const rawComponentId = component.id;
|
|
94
|
+
if (rawComponentId !== undefined && typeof rawComponentId !== 'string') {
|
|
95
|
+
issues.push({ message: 'must be a string', path: `${componentPath}.id` });
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const componentId = rawComponentId ?? '';
|
|
99
|
+
if (!componentId.trim()) {
|
|
100
|
+
if (!repairComponentIds) {
|
|
101
|
+
issues.push({ message: 'must be a non-empty string', path: `${componentPath}.id` });
|
|
102
|
+
}
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (usedIds.has(componentId)) {
|
|
106
|
+
if (repairComponentIds) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
issues.push({
|
|
110
|
+
message: `duplicates component id "${componentId}"`,
|
|
111
|
+
path: `${componentPath}.id`,
|
|
112
|
+
});
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
usedIds.add(componentId);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function validateComponent(component, path, issues) {
|
|
119
|
+
const componentType = component.type;
|
|
120
|
+
if (typeof componentType !== 'string' || !hasOwn(UI_GRAPH_COMPONENT_VALIDATORS, componentType)) {
|
|
121
|
+
issues.push({
|
|
122
|
+
message: typeof componentType === 'string'
|
|
123
|
+
? `has unsupported type "${componentType}"`
|
|
124
|
+
: 'must have a supported string type',
|
|
125
|
+
path: `${path}.type`,
|
|
126
|
+
});
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
UI_GRAPH_COMPONENT_VALIDATORS[componentType](component, path, issues);
|
|
130
|
+
}
|
|
131
|
+
const UI_GRAPH_COMPONENT_VALIDATORS = {
|
|
132
|
+
text(component, path, issues) {
|
|
133
|
+
requireString(component, 'text', path, issues);
|
|
134
|
+
},
|
|
135
|
+
markdown(component, path, issues) {
|
|
136
|
+
requireString(component, 'markdown', path, issues);
|
|
137
|
+
},
|
|
138
|
+
gap(component, path, issues) {
|
|
139
|
+
requireEnum(component, 'size', UI_GRAPH_GAP_SIZES, path, issues);
|
|
140
|
+
},
|
|
141
|
+
input: validateInputComponent,
|
|
142
|
+
textarea: validateInputComponent,
|
|
143
|
+
button(component, path, issues) {
|
|
144
|
+
requireString(component, 'label', path, issues);
|
|
145
|
+
validateAction(component.action, `${path}.action`, issues);
|
|
146
|
+
},
|
|
147
|
+
chat(component, path, issues) {
|
|
148
|
+
optionalString(component, 'placeholder', path, issues);
|
|
149
|
+
validateChatAction(component.action, `${path}.action`, issues);
|
|
150
|
+
},
|
|
151
|
+
output(component, path, issues) {
|
|
152
|
+
optionalString(component, 'label', path, issues);
|
|
153
|
+
requireString(component, 'stateKey', path, issues);
|
|
154
|
+
optionalEnum(component, 'renderAs', UI_GRAPH_OUTPUT_RENDER_MODES, path, issues);
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
function validateInputComponent(component, path, issues) {
|
|
158
|
+
requireString(component, 'label', path, issues);
|
|
159
|
+
requireString(component, 'stateKey', path, issues);
|
|
160
|
+
optionalString(component, 'placeholder', path, issues);
|
|
161
|
+
optionalString(component, 'defaultValue', path, issues);
|
|
162
|
+
}
|
|
163
|
+
function validateAction(value, path, issues) {
|
|
164
|
+
if (!isRecord(value)) {
|
|
165
|
+
issues.push({ message: 'must be an object', path });
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const actionType = value.type;
|
|
169
|
+
if (typeof actionType !== 'string' || !hasOwn(UI_GRAPH_ACTION_VALIDATORS, actionType)) {
|
|
170
|
+
issues.push({ message: 'must be "runGraph"', path: `${path}.type` });
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
UI_GRAPH_ACTION_VALIDATORS[actionType](value, path, issues);
|
|
174
|
+
}
|
|
175
|
+
function validateChatAction(value, path, issues) {
|
|
176
|
+
if (!isRecord(value)) {
|
|
177
|
+
issues.push({ message: 'must be an object', path });
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (value.type !== 'runGraph') {
|
|
181
|
+
issues.push({ message: 'must be "runGraph"', path: `${path}.type` });
|
|
182
|
+
}
|
|
183
|
+
optionalString(value, 'graphId', path, issues);
|
|
184
|
+
optionalString(value, 'userInputId', path, issues);
|
|
185
|
+
optionalString(value, 'historyInputId', path, issues);
|
|
186
|
+
optionalString(value, 'responseOutputId', path, issues);
|
|
187
|
+
validateInputMappings(value.inputMappings, `${path}.inputMappings`, issues);
|
|
188
|
+
}
|
|
189
|
+
const UI_GRAPH_ACTION_VALIDATORS = {
|
|
190
|
+
runGraph(value, path, issues) {
|
|
191
|
+
optionalString(value, 'graphId', path, issues);
|
|
192
|
+
optionalString(value, 'outputKey', path, issues);
|
|
193
|
+
optionalString(value, 'outputStateKey', path, issues);
|
|
194
|
+
validateInputMappings(value.inputMappings, `${path}.inputMappings`, issues);
|
|
195
|
+
validateLegacyInputs(value.inputs, `${path}.inputs`, issues);
|
|
196
|
+
validateOutputMappings(value.outputs, `${path}.outputs`, issues);
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
function validateInputMappings(value, path, issues) {
|
|
200
|
+
if (value === undefined) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (!Array.isArray(value)) {
|
|
204
|
+
issues.push({ message: 'must be an array', path });
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
for (const [index, binding] of value.entries()) {
|
|
208
|
+
const bindingPath = `${path} at index ${index}`;
|
|
209
|
+
if (!isRecord(binding)) {
|
|
210
|
+
issues.push({ message: 'must be an object', path: bindingPath });
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
requireString(binding, 'inputKey', bindingPath, issues);
|
|
214
|
+
requireString(binding, 'stateKey', bindingPath, issues);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function validateLegacyInputs(value, path, issues) {
|
|
218
|
+
if (value === undefined) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (!isRecord(value)) {
|
|
222
|
+
issues.push({ message: 'must be an object', path });
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
for (const [inputId, binding] of Object.entries(value)) {
|
|
226
|
+
const bindingPath = `${path}[${JSON.stringify(inputId)}]`;
|
|
227
|
+
if (!isRecord(binding)) {
|
|
228
|
+
issues.push({ message: 'must be an object', path: bindingPath });
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (binding.type === 'state') {
|
|
232
|
+
requireString(binding, 'key', bindingPath, issues);
|
|
233
|
+
}
|
|
234
|
+
else if (binding.type === 'literal') {
|
|
235
|
+
if (!Object.prototype.hasOwnProperty.call(binding, 'value')) {
|
|
236
|
+
issues.push({ message: 'is required', path: `${bindingPath}.value` });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
issues.push({ message: 'must be "state" or "literal"', path: `${bindingPath}.type` });
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function validateOutputMappings(value, path, issues) {
|
|
245
|
+
if (value === undefined) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (!Array.isArray(value)) {
|
|
249
|
+
issues.push({ message: 'must be an array', path });
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
for (const [index, binding] of value.entries()) {
|
|
253
|
+
const bindingPath = `${path} at index ${index}`;
|
|
254
|
+
if (!isRecord(binding)) {
|
|
255
|
+
issues.push({ message: 'must be an object', path: bindingPath });
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
optionalString(binding, 'outputKey', bindingPath, issues);
|
|
259
|
+
requireString(binding, 'stateKey', bindingPath, issues);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function requireString(value, key, path, issues) {
|
|
263
|
+
if (typeof value[key] !== 'string') {
|
|
264
|
+
issues.push({ message: 'must be a string', path: `${path}.${key}` });
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function requireNonEmptyString(value, key, path, issues) {
|
|
268
|
+
if (typeof value[key] !== 'string' || !value[key].trim()) {
|
|
269
|
+
issues.push({ message: 'must be a non-empty string', path: `${path}.${key}` });
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function optionalString(value, key, path, issues) {
|
|
273
|
+
if (value[key] !== undefined && typeof value[key] !== 'string') {
|
|
274
|
+
issues.push({ message: 'must be a string when provided', path: `${path}.${key}` });
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function requireEnum(value, key, allowed, path, issues) {
|
|
278
|
+
if (typeof value[key] !== 'string' || !allowed.includes(value[key])) {
|
|
279
|
+
issues.push({ message: `must be one of: ${allowed.join(', ')}`, path: `${path}.${key}` });
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function optionalEnum(value, key, allowed, path, issues) {
|
|
283
|
+
if (value[key] !== undefined && (typeof value[key] !== 'string' || !allowed.includes(value[key]))) {
|
|
284
|
+
issues.push({ message: `must be one of: ${allowed.join(', ')}`, path: `${path}.${key}` });
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function getUiGraphLabel(value, expectedId) {
|
|
288
|
+
if (expectedId !== undefined) {
|
|
289
|
+
return expectedId;
|
|
290
|
+
}
|
|
291
|
+
return isRecord(value) && typeof value.id === 'string' && value.id.trim() ? value.id : '<unknown>';
|
|
292
|
+
}
|
|
293
|
+
function isRecord(value) {
|
|
294
|
+
return value != null && typeof value === 'object' && !Array.isArray(value);
|
|
295
|
+
}
|
|
296
|
+
function hasOwn(value, key) {
|
|
297
|
+
return Object.prototype.hasOwnProperty.call(value, key);
|
|
298
|
+
}
|