basyx-typescript-sdk 2.3.1 → 2.4.0

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 (61) hide show
  1. package/README.md +68 -1
  2. package/bundle/index.cjs +1412 -89
  3. package/bundle/index.cjs.map +1 -1
  4. package/bundle/index.mjs +1344 -90
  5. package/bundle/index.mjs.map +1 -1
  6. package/dist/clients/AasRegistryClient.d.ts +20 -0
  7. package/dist/clients/AasRegistryClient.js +40 -0
  8. package/dist/clients/AasRepositoryClient.d.ts +20 -0
  9. package/dist/clients/AasRepositoryClient.js +40 -0
  10. package/dist/clients/ConceptDescriptionRepositoryClient.d.ts +20 -0
  11. package/dist/clients/ConceptDescriptionRepositoryClient.js +40 -0
  12. package/dist/clients/SubmodelRegistryClient.d.ts +20 -0
  13. package/dist/clients/SubmodelRegistryClient.js +40 -0
  14. package/dist/clients/SubmodelRepositoryClient.d.ts +20 -0
  15. package/dist/clients/SubmodelRepositoryClient.js +40 -0
  16. package/dist/generated/AasRegistryService/apis/AssetAdministrationShellRegistryAPIApi.d.ts +14 -1
  17. package/dist/generated/AasRegistryService/apis/AssetAdministrationShellRegistryAPIApi.js +29 -0
  18. package/dist/generated/AasRegistryService/models/index.d.ts +374 -0
  19. package/dist/generated/AasRegistryService/models/index.js +6 -0
  20. package/dist/generated/AasRepositoryService/apis/AssetAdministrationShellRepositoryAPIApi.d.ts +14 -1
  21. package/dist/generated/AasRepositoryService/apis/AssetAdministrationShellRepositoryAPIApi.js +29 -0
  22. package/dist/generated/AasRepositoryService/models/index.d.ts +381 -0
  23. package/dist/generated/AasRepositoryService/models/index.js +7 -0
  24. package/dist/generated/ConceptDescriptionRepositoryService/apis/ConceptDescriptionRepositoryAPIApi.d.ts +14 -1
  25. package/dist/generated/ConceptDescriptionRepositoryService/apis/ConceptDescriptionRepositoryAPIApi.js +29 -0
  26. package/dist/generated/ConceptDescriptionRepositoryService/models/index.d.ts +381 -0
  27. package/dist/generated/ConceptDescriptionRepositoryService/models/index.js +7 -0
  28. package/dist/generated/SubmodelRegistryService/apis/SubmodelRegistryAPIApi.d.ts +14 -1
  29. package/dist/generated/SubmodelRegistryService/apis/SubmodelRegistryAPIApi.js +29 -0
  30. package/dist/generated/SubmodelRegistryService/models/index.d.ts +381 -0
  31. package/dist/generated/SubmodelRegistryService/models/index.js +7 -0
  32. package/dist/generated/SubmodelRepositoryService/apis/SubmodelRepositoryAPIApi.d.ts +14 -1
  33. package/dist/generated/SubmodelRepositoryService/apis/SubmodelRepositoryAPIApi.js +29 -0
  34. package/dist/generated/SubmodelRepositoryService/models/index.d.ts +381 -0
  35. package/dist/generated/SubmodelRepositoryService/models/index.js +7 -0
  36. package/dist/lib/endpointConfiguration.d.ts +71 -0
  37. package/dist/lib/endpointConfiguration.js +101 -0
  38. package/dist/lib/index.d.ts +1 -0
  39. package/dist/lib/index.js +2 -0
  40. package/dist/lib/queryJsonization.d.ts +17 -0
  41. package/dist/lib/queryJsonization.js +309 -0
  42. package/dist/lib/queryRequests.d.ts +24 -0
  43. package/dist/lib/queryRequests.js +44 -0
  44. package/dist/models/Query.d.ts +378 -0
  45. package/dist/models/Query.js +430 -0
  46. package/dist/models/QueryResult.d.ts +22 -0
  47. package/dist/models/QueryResult.js +1 -0
  48. package/dist/models/index.d.ts +2 -0
  49. package/dist/models/index.js +2 -0
  50. package/dist/services/AasService.d.ts +15 -4
  51. package/dist/services/AasService.js +38 -40
  52. package/dist/services/SubmodelService.d.ts +9 -8
  53. package/dist/services/SubmodelService.js +17 -34
  54. package/dist/services/index.d.ts +1 -0
  55. package/dist/utils/DescriptorUtils.d.ts +27 -1
  56. package/dist/utils/DescriptorUtils.js +65 -27
  57. package/dist/utils/ServiceDescriptionUtils.d.ts +30 -0
  58. package/dist/utils/ServiceDescriptionUtils.js +43 -0
  59. package/dist/utils/index.d.ts +2 -0
  60. package/dist/utils/index.js +2 -0
  61. package/package.json +1 -1
@@ -0,0 +1,309 @@
1
+ import { common } from '@aas-core-works/aas-core3.1-typescript';
2
+ import { DeserializationError, IndexSegment, Path, PropertySegment, } from '@aas-core-works/aas-core3.1-typescript/jsonization';
3
+ import { AndExpression, AttributeOperand, BooleanCast, BooleanLiteral, ClaimAttribute, ContainsComparison, DateTimeAttributeItem, DateTimeAttributeOperand, DateTimeCast, DateTimeLiteral, DayOfMonth, DayOfWeek, EndsWithComparison, EqualComparison, FieldOperand, GlobalAttribute, GreaterThanComparison, GreaterThanOrEqualComparison, HexCast, HexLiteral, LessThanComparison, LessThanOrEqualComparison, MatchClause, Month, NotEqualComparison, NotExpression, NumberCast, NumberLiteral, OrExpression, Query, QueryFilter, ReferenceAttribute, RegexComparison, StartsWithComparison, StringCast, StringLiteral, TimeCast, TimeLiteral, Year, } from '../models/Query';
4
+ // The JSON names of the global attribute kinds, indexed by the enum values. DateTimeGlobalAttributeKind uses the first
5
+ // three of them.
6
+ const GLOBAL_ATTRIBUTE_KIND_JSON_NAMES = ['LOCALNOW', 'UTCNOW', 'CLIENTNOW', 'ANONYMOUS'];
7
+ const QUERY_SELECT_JSON_NAMES = ['id'];
8
+ // The JSON name of each property of the expression classes. Every expression class has exactly one property.
9
+ const PROPERTY_JSON_NAMES = [
10
+ ['claim', 'CLAIM'],
11
+ ['kind', 'GLOBAL'],
12
+ ['reference', 'REFERENCE'],
13
+ ['field', '$field'],
14
+ ['strVal', '$strVal'],
15
+ ['attribute', '$attribute'],
16
+ ['numVal', '$numVal'],
17
+ ['hexVal', '$hexVal'],
18
+ ['dateTimeVal', '$dateTimeVal'],
19
+ ['timeVal', '$timeVal'],
20
+ ['boolean', '$boolean'],
21
+ ['strCast', '$strCast'],
22
+ ['numCast', '$numCast'],
23
+ ['hexCast', '$hexCast'],
24
+ ['boolCast', '$boolCast'],
25
+ ['dateTimeCast', '$dateTimeCast'],
26
+ ['timeCast', '$timeCast'],
27
+ ['dayOfWeek', '$dayOfWeek'],
28
+ ['dayOfMonth', '$dayOfMonth'],
29
+ ['month', '$month'],
30
+ ['year', '$year'],
31
+ ['eq', '$eq'],
32
+ ['ne', '$ne'],
33
+ ['gt', '$gt'],
34
+ ['ge', '$ge'],
35
+ ['lt', '$lt'],
36
+ ['le', '$le'],
37
+ ['contains', '$contains'],
38
+ ['startsWith', '$starts-with'],
39
+ ['endsWith', '$ends-with'],
40
+ ['regex', '$regex'],
41
+ ['matchOperands', '$match'],
42
+ ['andOperands', '$and'],
43
+ ['orOperands', '$or'],
44
+ ['notOperand', '$not'],
45
+ ];
46
+ /**
47
+ * Serialize a query to the JSON of the AAS Query Language, as sent in the body of the `/query/*` endpoints.
48
+ *
49
+ * @param query The query to serialize
50
+ * @returns The JSON-able object, e.g. `{ "$condition": { "$eq": [{ "$field": "$aas#idShort" }, { "$strVal": "x" }] } }`
51
+ */
52
+ export function toJsonableQuery(query) {
53
+ const jsonable = {};
54
+ if (query.select !== null && query.select !== undefined) {
55
+ jsonable['$select'] = enumToJsonable(QUERY_SELECT_JSON_NAMES, query.select, 'QuerySelect');
56
+ }
57
+ jsonable['$condition'] = expressionToJsonable(query.condition);
58
+ if (query.filters !== null && query.filters !== undefined) {
59
+ jsonable['$filters'] = query.filters.map((filter) => ({
60
+ $fragment: filter.fragment,
61
+ $condition: expressionToJsonable(filter.condition),
62
+ }));
63
+ }
64
+ return jsonable;
65
+ }
66
+ function expressionToJsonable(expression) {
67
+ const properties = expression;
68
+ for (const [property, jsonName] of PROPERTY_JSON_NAMES) {
69
+ const value = properties?.[property];
70
+ if (value !== undefined) {
71
+ return { [jsonName]: propertyToJsonable(property, value) };
72
+ }
73
+ }
74
+ throw new Error(`Unexpected query expression: ${JSON.stringify(expression)}`);
75
+ }
76
+ function propertyToJsonable(property, value) {
77
+ if (property === 'kind') {
78
+ return enumToJsonable(GLOBAL_ATTRIBUTE_KIND_JSON_NAMES, value, 'GlobalAttributeKind');
79
+ }
80
+ if (Array.isArray(value)) {
81
+ return value.map((item) => expressionToJsonable(item));
82
+ }
83
+ if (typeof value === 'object' && value !== null) {
84
+ return expressionToJsonable(value);
85
+ }
86
+ return value;
87
+ }
88
+ function enumToJsonable(jsonNames, value, enumName) {
89
+ const jsonName = jsonNames[value];
90
+ if (jsonName === undefined) {
91
+ throw new Error(`Unexpected ${enumName} value: ${value}`);
92
+ }
93
+ return jsonName;
94
+ }
95
+ /**
96
+ * Parse the JSON of the AAS Query Language as a {@link Query}.
97
+ *
98
+ * @param jsonable The JSON-able value to parse, e.g. the result of `JSON.parse`
99
+ * @returns Either the parsed query, or the error with the path to the invalid value
100
+ */
101
+ export function queryFromJsonable(jsonable) {
102
+ try {
103
+ return new common.Either(parseQuery(jsonable), null);
104
+ }
105
+ catch (err) {
106
+ if (err instanceof ParseError) {
107
+ return new common.Either(null, new DeserializationError(err.message, err.path));
108
+ }
109
+ throw err;
110
+ }
111
+ }
112
+ class ParseError {
113
+ message;
114
+ path = new Path();
115
+ constructor(message) {
116
+ this.message = message;
117
+ }
118
+ }
119
+ function fail(message) {
120
+ throw new ParseError(message);
121
+ }
122
+ function describeJsonValue(jsonable) {
123
+ if (jsonable === null) {
124
+ return 'null';
125
+ }
126
+ if (Array.isArray(jsonable)) {
127
+ return 'an array';
128
+ }
129
+ return typeof jsonable;
130
+ }
131
+ function asObject(jsonable) {
132
+ if (typeof jsonable !== 'object' || jsonable === null || Array.isArray(jsonable)) {
133
+ fail(`Expected a JSON object, but got ${describeJsonValue(jsonable)}`);
134
+ }
135
+ return jsonable;
136
+ }
137
+ function asString(jsonable) {
138
+ if (typeof jsonable !== 'string') {
139
+ fail(`Expected a string, but got ${describeJsonValue(jsonable)}`);
140
+ }
141
+ return jsonable;
142
+ }
143
+ function asNumber(jsonable) {
144
+ if (typeof jsonable !== 'number') {
145
+ fail(`Expected a number, but got ${describeJsonValue(jsonable)}`);
146
+ }
147
+ return jsonable;
148
+ }
149
+ function asBoolean(jsonable) {
150
+ if (typeof jsonable !== 'boolean') {
151
+ fail(`Expected a boolean, but got ${describeJsonValue(jsonable)}`);
152
+ }
153
+ return jsonable;
154
+ }
155
+ function asArray(jsonable) {
156
+ if (!Array.isArray(jsonable)) {
157
+ fail(`Expected an array, but got ${describeJsonValue(jsonable)}`);
158
+ }
159
+ return jsonable;
160
+ }
161
+ function listOf(parse) {
162
+ return (jsonable) => {
163
+ const items = asArray(jsonable);
164
+ return items.map((item, index) => {
165
+ try {
166
+ return parse(item);
167
+ }
168
+ catch (err) {
169
+ if (err instanceof ParseError) {
170
+ err.path.prepend(new IndexSegment(items, index));
171
+ }
172
+ throw err;
173
+ }
174
+ });
175
+ };
176
+ }
177
+ function pairOf(parse) {
178
+ return (jsonable) => {
179
+ const items = asArray(jsonable);
180
+ if (items.length !== 2) {
181
+ fail(`Expected exactly two operands, but got ${items.length}`);
182
+ }
183
+ const [left, right] = listOf(parse)(items);
184
+ return [left, right];
185
+ };
186
+ }
187
+ function enumFromJsonable(jsonNames, enumName) {
188
+ return (jsonable) => {
189
+ const value = jsonNames.indexOf(asString(jsonable));
190
+ if (value === -1) {
191
+ fail(`Expected a ${enumName} (${jsonNames.join(', ')}), but got ${JSON.stringify(jsonable)}`);
192
+ }
193
+ return value;
194
+ };
195
+ }
196
+ function property(jsonObject, name, parse) {
197
+ try {
198
+ if (jsonObject[name] === undefined) {
199
+ fail(`The required property is missing`);
200
+ }
201
+ return parse(jsonObject[name]);
202
+ }
203
+ catch (err) {
204
+ if (err instanceof ParseError) {
205
+ err.path.prepend(new PropertySegment(jsonObject, name));
206
+ }
207
+ throw err;
208
+ }
209
+ }
210
+ function expectOnlyProperties(jsonObject, names, typeName) {
211
+ const unexpected = Object.keys(jsonObject).filter((key) => !names.includes(key));
212
+ if (unexpected.length > 0) {
213
+ fail(`Unexpected properties for ${typeName}: ${unexpected.join(', ')}`);
214
+ }
215
+ }
216
+ /**
217
+ * Parse an expression of a union by the one property that names its class, as the JSON of the query language has no
218
+ * `modelType`.
219
+ */
220
+ function oneOf(typeName, parsers) {
221
+ return (jsonable) => {
222
+ const jsonObject = asObject(jsonable);
223
+ const available = parsers();
224
+ const names = Object.keys(jsonObject);
225
+ // Only own properties name a parser, so that keys like `__proto__` or `constructor` are rejected
226
+ if (names.length !== 1 || !Object.hasOwn(available, names[0])) {
227
+ fail(`Expected exactly one of the properties ${Object.keys(available).join(', ')} for ${typeName}, ` +
228
+ `but got: ${names.join(', ') || 'none'}`);
229
+ }
230
+ return available[names[0]](jsonObject);
231
+ };
232
+ }
233
+ const parseGlobalAttributeKind = enumFromJsonable(GLOBAL_ATTRIBUTE_KIND_JSON_NAMES, 'GlobalAttributeKind');
234
+ const parseDateTimeGlobalAttributeKind = enumFromJsonable(GLOBAL_ATTRIBUTE_KIND_JSON_NAMES.slice(0, 3), 'DateTimeGlobalAttributeKind');
235
+ const parseQuerySelect = enumFromJsonable(QUERY_SELECT_JSON_NAMES, 'QuerySelect');
236
+ const parseAttributeItem = oneOf('AttributeItem', () => ({
237
+ CLAIM: (o) => new ClaimAttribute(property(o, 'CLAIM', asString)),
238
+ GLOBAL: (o) => new GlobalAttribute(property(o, 'GLOBAL', parseGlobalAttributeKind)),
239
+ REFERENCE: (o) => new ReferenceAttribute(property(o, 'REFERENCE', asString)),
240
+ }));
241
+ const parseDateTimeAttributeItem = oneOf('DateTimeAttributeItem', () => ({
242
+ GLOBAL: (o) => new DateTimeAttributeItem(property(o, 'GLOBAL', parseDateTimeGlobalAttributeKind)),
243
+ }));
244
+ const stringValueParsers = () => ({
245
+ $field: (o) => new FieldOperand(property(o, '$field', asString)),
246
+ $strVal: (o) => new StringLiteral(property(o, '$strVal', asString)),
247
+ $strCast: (o) => new StringCast(property(o, '$strCast', parseValue)),
248
+ $attribute: (o) => new AttributeOperand(property(o, '$attribute', parseAttributeItem)),
249
+ });
250
+ const dateTimeLiteralParsers = () => ({
251
+ $dateTimeVal: (o) => new DateTimeLiteral(property(o, '$dateTimeVal', asString)),
252
+ $dateTimeCast: (o) => new DateTimeCast(property(o, '$dateTimeCast', parseStringValue)),
253
+ });
254
+ const parseStringValue = oneOf('StringValue', stringValueParsers);
255
+ const parseDateTimeOperand = oneOf('DateTimeOperand', () => ({
256
+ ...dateTimeLiteralParsers(),
257
+ $attribute: (o) => new DateTimeAttributeOperand(property(o, '$attribute', parseDateTimeAttributeItem)),
258
+ }));
259
+ const parseTimeCastOperand = oneOf('TimeCastOperand', () => ({
260
+ ...stringValueParsers(),
261
+ ...dateTimeLiteralParsers(),
262
+ }));
263
+ const parseValue = oneOf('Value', () => ({
264
+ ...stringValueParsers(),
265
+ $numVal: (o) => new NumberLiteral(property(o, '$numVal', asNumber)),
266
+ $numCast: (o) => new NumberCast(property(o, '$numCast', parseValue)),
267
+ $dayOfWeek: (o) => new DayOfWeek(property(o, '$dayOfWeek', parseDateTimeOperand)),
268
+ $dayOfMonth: (o) => new DayOfMonth(property(o, '$dayOfMonth', parseDateTimeOperand)),
269
+ $month: (o) => new Month(property(o, '$month', parseDateTimeOperand)),
270
+ $year: (o) => new Year(property(o, '$year', parseDateTimeOperand)),
271
+ $hexVal: (o) => new HexLiteral(property(o, '$hexVal', asString)),
272
+ $hexCast: (o) => new HexCast(property(o, '$hexCast', parseValue)),
273
+ $boolean: (o) => new BooleanLiteral(property(o, '$boolean', asBoolean)),
274
+ $boolCast: (o) => new BooleanCast(property(o, '$boolCast', parseValue)),
275
+ ...dateTimeLiteralParsers(),
276
+ $timeVal: (o) => new TimeLiteral(property(o, '$timeVal', asString)),
277
+ $timeCast: (o) => new TimeCast(property(o, '$timeCast', parseTimeCastOperand)),
278
+ }));
279
+ const matchExpressionParsers = () => ({
280
+ $match: (o) => new MatchClause(property(o, '$match', listOf(parseMatchExpression))),
281
+ $eq: (o) => new EqualComparison(property(o, '$eq', pairOf(parseValue))),
282
+ $ne: (o) => new NotEqualComparison(property(o, '$ne', pairOf(parseValue))),
283
+ $gt: (o) => new GreaterThanComparison(property(o, '$gt', pairOf(parseValue))),
284
+ $ge: (o) => new GreaterThanOrEqualComparison(property(o, '$ge', pairOf(parseValue))),
285
+ $lt: (o) => new LessThanComparison(property(o, '$lt', pairOf(parseValue))),
286
+ $le: (o) => new LessThanOrEqualComparison(property(o, '$le', pairOf(parseValue))),
287
+ $contains: (o) => new ContainsComparison(property(o, '$contains', pairOf(parseStringValue))),
288
+ '$starts-with': (o) => new StartsWithComparison(property(o, '$starts-with', pairOf(parseStringValue))),
289
+ '$ends-with': (o) => new EndsWithComparison(property(o, '$ends-with', pairOf(parseStringValue))),
290
+ $regex: (o) => new RegexComparison(property(o, '$regex', pairOf(parseStringValue))),
291
+ });
292
+ const parseMatchExpression = oneOf('MatchExpression', matchExpressionParsers);
293
+ const parseLogicalExpression = oneOf('LogicalExpression', () => ({
294
+ $and: (o) => new AndExpression(property(o, '$and', listOf(parseLogicalExpression))),
295
+ $or: (o) => new OrExpression(property(o, '$or', listOf(parseLogicalExpression))),
296
+ $not: (o) => new NotExpression(property(o, '$not', parseLogicalExpression)),
297
+ $boolean: (o) => new BooleanLiteral(property(o, '$boolean', asBoolean)),
298
+ ...matchExpressionParsers(),
299
+ }));
300
+ function parseQueryFilter(jsonable) {
301
+ const jsonObject = asObject(jsonable);
302
+ expectOnlyProperties(jsonObject, ['$fragment', '$condition'], 'QueryFilter');
303
+ return new QueryFilter(property(jsonObject, '$fragment', asString), property(jsonObject, '$condition', parseLogicalExpression));
304
+ }
305
+ function parseQuery(jsonable) {
306
+ const jsonObject = asObject(jsonable);
307
+ expectOnlyProperties(jsonObject, ['$select', '$condition', '$filters'], 'Query');
308
+ return new Query(property(jsonObject, '$condition', parseLogicalExpression), jsonObject['$select'] === undefined ? null : property(jsonObject, '$select', parseQuerySelect), jsonObject['$filters'] === undefined ? null : property(jsonObject, '$filters', listOf(parseQueryFilter)));
309
+ }
@@ -0,0 +1,24 @@
1
+ import type { JsonObject } from '@aas-core-works/aas-core3.1-typescript/jsonization';
2
+ import type { QueryResult } from '../models/QueryResult';
3
+ import { Query } from '../models/Query';
4
+ /**
5
+ * Serialize the query for the body of a `/query/*` request.
6
+ *
7
+ * @throws RequiredError if no query is given
8
+ */
9
+ export declare function toQueryRequestBody(query: Query): JsonObject;
10
+ /**
11
+ * Convert the response of a `/query/*` request.
12
+ *
13
+ * The result holds identifiers if the server reports `resultType: 'Identifier'` or the query selected them. Servers
14
+ * that return objects for `select: QuerySelect.Id` anyway are tolerated: the `id` of each object is used.
15
+ *
16
+ * @param response The parsed response body
17
+ * @param query The query that was sent
18
+ * @param resultType The `resultType` of a result with objects
19
+ * @param convertItem Converts a returned object
20
+ */
21
+ export declare function convertQueryResult<ApiItem, T, ResultType extends string, PagingMetadata>(response: {
22
+ paging_metadata?: PagingMetadata;
23
+ result?: Array<ApiItem | string>;
24
+ }, query: Query, resultType: ResultType, convertItem: (item: ApiItem) => T): QueryResult<T, ResultType, PagingMetadata>;
@@ -0,0 +1,44 @@
1
+ import { RequiredError } from '../generated/runtime';
2
+ import { QuerySelect } from '../models/Query';
3
+ import { toJsonableQuery } from './queryJsonization';
4
+ /**
5
+ * Serialize the query for the body of a `/query/*` request.
6
+ *
7
+ * @throws RequiredError if no query is given
8
+ */
9
+ export function toQueryRequestBody(query) {
10
+ if (query === null || query === undefined) {
11
+ throw new RequiredError('query', 'Required parameter "query" was null or undefined.');
12
+ }
13
+ return toJsonableQuery(query);
14
+ }
15
+ /**
16
+ * Convert the response of a `/query/*` request.
17
+ *
18
+ * The result holds identifiers if the server reports `resultType: 'Identifier'` or the query selected them. Servers
19
+ * that return objects for `select: QuerySelect.Id` anyway are tolerated: the `id` of each object is used.
20
+ *
21
+ * @param response The parsed response body
22
+ * @param query The query that was sent
23
+ * @param resultType The `resultType` of a result with objects
24
+ * @param convertItem Converts a returned object
25
+ */
26
+ export function convertQueryResult(response, query, resultType, convertItem) {
27
+ const pagedResult = response.paging_metadata;
28
+ const items = response.result ?? [];
29
+ const reportedResultType = pagedResult?.resultType;
30
+ if (reportedResultType === 'Identifier' || query.select === QuerySelect.Id) {
31
+ return { pagedResult, resultType: 'Identifier', result: items.map(toIdentifier) };
32
+ }
33
+ return { pagedResult, resultType, result: items.map((item) => convertItem(item)) };
34
+ }
35
+ function toIdentifier(item) {
36
+ if (typeof item === 'string') {
37
+ return item;
38
+ }
39
+ const id = item?.id;
40
+ if (typeof id === 'string') {
41
+ return id;
42
+ }
43
+ throw new Error(`Expected an identifier in the query result, but got: ${JSON.stringify(item)}`);
44
+ }