@unito/integration-api 4.1.6 → 4.2.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.
@@ -218,18 +218,530 @@ function isFieldSchema(potentialFieldSchema) {
218
218
  (isUndefined(potentialFieldSchema['semantic']) || isSemantic(potentialFieldSchema['semantic'])));
219
219
  }
220
220
 
221
+ const dateToStringlikeConfiguration = {
222
+ locale: {
223
+ type: 'enum',
224
+ default: 'en-CA',
225
+ values: ['en-CA'],
226
+ description: 'The locale to use for formatting the date.',
227
+ },
228
+ timezone: {
229
+ type: 'enum',
230
+ default: 'UTC',
231
+ values: ['UTC'],
232
+ description: 'The timezone to use for formatting the date.',
233
+ },
234
+ };
235
+ const htmlToRichTextConfiguration = {
236
+ decorator: {
237
+ type: 'boolean',
238
+ description: 'Decorate the content with author information and optional date.',
239
+ default: false,
240
+ hidden: true,
241
+ },
242
+ decoratorTemplate: {
243
+ type: 'string',
244
+ description: 'Template for the decorator. Use {author} and {date} placeholders.',
245
+ default: 'On <strong>{semantic:createdAt}</strong>, <em>{semantic:user.semantic:displayName}</em> commented:',
246
+ hidden: true,
247
+ },
248
+ decoratorPrefix: {
249
+ type: 'string',
250
+ description: `Prefix for the decorator. Defaults to "➤".`,
251
+ default: '➤',
252
+ hidden: true,
253
+ },
254
+ };
255
+ const markdownToRichTextConfiguration = {
256
+ decorator: {
257
+ type: 'boolean',
258
+ description: 'Decorate the content with author information and optional date.',
259
+ default: false,
260
+ hidden: true,
261
+ },
262
+ decoratorTemplate: {
263
+ type: 'string',
264
+ description: 'Template for the decorator. Use {author} and {date} placeholders.',
265
+ default: 'On **{semantic:createdAt}**, __{semantic:user.semantic:displayName}__ commented:',
266
+ hidden: true,
267
+ },
268
+ decoratorPrefix: {
269
+ type: 'string',
270
+ description: `Prefix for the decorator. Defaults to "➤".`,
271
+ default: '➤',
272
+ hidden: true,
273
+ },
274
+ };
275
+ const fieldTypeCompatibilityMatrix = {
276
+ [FieldValueTypes.BLOB]: {
277
+ [FieldValueTypes.BLOB]: {},
278
+ [FieldValueTypes.BOOLEAN]: null,
279
+ [FieldValueTypes.DATE]: null,
280
+ [FieldValueTypes.DATE_RANGE]: null,
281
+ [FieldValueTypes.DATETIME]: null,
282
+ [FieldValueTypes.DATETIME_RANGE]: null,
283
+ [FieldValueTypes.DURATION]: null,
284
+ [FieldValueTypes.EMAIL]: null,
285
+ [FieldValueTypes.INTEGER]: null,
286
+ [FieldValueTypes.NUMBER]: null,
287
+ [FieldValueTypes.OBJECT]: null,
288
+ [FieldValueTypes.REFERENCE]: null,
289
+ [FieldValueTypes.RICH_TEXT_HTML]: null,
290
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: null,
291
+ [FieldValueTypes.STRING]: null,
292
+ [FieldValueTypes.URL]: null,
293
+ },
294
+ [FieldValueTypes.BOOLEAN]: {
295
+ [FieldValueTypes.BLOB]: null,
296
+ [FieldValueTypes.BOOLEAN]: {},
297
+ [FieldValueTypes.DATE]: null,
298
+ [FieldValueTypes.DATE_RANGE]: null,
299
+ [FieldValueTypes.DATETIME]: null,
300
+ [FieldValueTypes.DATETIME_RANGE]: null,
301
+ [FieldValueTypes.DURATION]: null,
302
+ [FieldValueTypes.EMAIL]: null,
303
+ [FieldValueTypes.INTEGER]: {},
304
+ [FieldValueTypes.NUMBER]: {},
305
+ [FieldValueTypes.OBJECT]: null,
306
+ [FieldValueTypes.REFERENCE]: null,
307
+ [FieldValueTypes.RICH_TEXT_HTML]: {},
308
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: {},
309
+ [FieldValueTypes.STRING]: {},
310
+ [FieldValueTypes.URL]: null,
311
+ },
312
+ [FieldValueTypes.DATE]: {
313
+ [FieldValueTypes.BLOB]: null,
314
+ [FieldValueTypes.BOOLEAN]: null,
315
+ [FieldValueTypes.DATE]: {},
316
+ [FieldValueTypes.DATE_RANGE]: null,
317
+ [FieldValueTypes.DATETIME]: {},
318
+ [FieldValueTypes.DATETIME_RANGE]: null,
319
+ [FieldValueTypes.DURATION]: null,
320
+ [FieldValueTypes.EMAIL]: null,
321
+ [FieldValueTypes.INTEGER]: {},
322
+ [FieldValueTypes.NUMBER]: {},
323
+ [FieldValueTypes.OBJECT]: null,
324
+ [FieldValueTypes.REFERENCE]: null,
325
+ [FieldValueTypes.RICH_TEXT_HTML]: dateToStringlikeConfiguration,
326
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: dateToStringlikeConfiguration,
327
+ [FieldValueTypes.STRING]: dateToStringlikeConfiguration,
328
+ [FieldValueTypes.URL]: null,
329
+ },
330
+ [FieldValueTypes.DATE_RANGE]: {
331
+ [FieldValueTypes.BLOB]: null,
332
+ [FieldValueTypes.BOOLEAN]: null,
333
+ [FieldValueTypes.DATE]: null,
334
+ [FieldValueTypes.DATE_RANGE]: null,
335
+ [FieldValueTypes.DATETIME]: null,
336
+ [FieldValueTypes.DATETIME_RANGE]: null,
337
+ [FieldValueTypes.DURATION]: null,
338
+ [FieldValueTypes.EMAIL]: null,
339
+ [FieldValueTypes.INTEGER]: null,
340
+ [FieldValueTypes.NUMBER]: null,
341
+ [FieldValueTypes.OBJECT]: null,
342
+ [FieldValueTypes.REFERENCE]: null,
343
+ [FieldValueTypes.RICH_TEXT_HTML]: null,
344
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: null,
345
+ [FieldValueTypes.STRING]: null,
346
+ [FieldValueTypes.URL]: null,
347
+ },
348
+ [FieldValueTypes.DATETIME]: {
349
+ [FieldValueTypes.BLOB]: null,
350
+ [FieldValueTypes.BOOLEAN]: null,
351
+ [FieldValueTypes.DATE]: {},
352
+ [FieldValueTypes.DATE_RANGE]: null,
353
+ [FieldValueTypes.DATETIME]: {},
354
+ [FieldValueTypes.DATETIME_RANGE]: null,
355
+ [FieldValueTypes.DURATION]: null,
356
+ [FieldValueTypes.EMAIL]: null,
357
+ [FieldValueTypes.INTEGER]: {},
358
+ [FieldValueTypes.NUMBER]: {},
359
+ [FieldValueTypes.OBJECT]: null,
360
+ [FieldValueTypes.REFERENCE]: null,
361
+ [FieldValueTypes.RICH_TEXT_HTML]: dateToStringlikeConfiguration,
362
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: dateToStringlikeConfiguration,
363
+ [FieldValueTypes.STRING]: dateToStringlikeConfiguration,
364
+ [FieldValueTypes.URL]: null,
365
+ },
366
+ [FieldValueTypes.DATETIME_RANGE]: {
367
+ [FieldValueTypes.BLOB]: null,
368
+ [FieldValueTypes.BOOLEAN]: null,
369
+ [FieldValueTypes.DATE]: null,
370
+ [FieldValueTypes.DATE_RANGE]: null,
371
+ [FieldValueTypes.DATETIME]: null,
372
+ [FieldValueTypes.DATETIME_RANGE]: null,
373
+ [FieldValueTypes.DURATION]: null,
374
+ [FieldValueTypes.EMAIL]: null,
375
+ [FieldValueTypes.INTEGER]: null,
376
+ [FieldValueTypes.NUMBER]: null,
377
+ [FieldValueTypes.OBJECT]: null,
378
+ [FieldValueTypes.REFERENCE]: null,
379
+ [FieldValueTypes.RICH_TEXT_HTML]: null,
380
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: null,
381
+ [FieldValueTypes.STRING]: null,
382
+ [FieldValueTypes.URL]: null,
383
+ },
384
+ [FieldValueTypes.DURATION]: {
385
+ [FieldValueTypes.BLOB]: null,
386
+ [FieldValueTypes.BOOLEAN]: null,
387
+ [FieldValueTypes.DATE]: null,
388
+ [FieldValueTypes.DATE_RANGE]: null,
389
+ [FieldValueTypes.DATETIME]: null,
390
+ [FieldValueTypes.DATETIME_RANGE]: null,
391
+ [FieldValueTypes.DURATION]: {},
392
+ [FieldValueTypes.EMAIL]: null,
393
+ [FieldValueTypes.INTEGER]: {},
394
+ [FieldValueTypes.NUMBER]: {},
395
+ [FieldValueTypes.OBJECT]: null,
396
+ [FieldValueTypes.REFERENCE]: null,
397
+ [FieldValueTypes.RICH_TEXT_HTML]: {},
398
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: {},
399
+ [FieldValueTypes.STRING]: {},
400
+ [FieldValueTypes.URL]: null,
401
+ },
402
+ [FieldValueTypes.EMAIL]: {
403
+ [FieldValueTypes.BLOB]: null,
404
+ [FieldValueTypes.BOOLEAN]: null,
405
+ [FieldValueTypes.DATE]: null,
406
+ [FieldValueTypes.DATE_RANGE]: null,
407
+ [FieldValueTypes.DATETIME]: null,
408
+ [FieldValueTypes.DATETIME_RANGE]: null,
409
+ [FieldValueTypes.DURATION]: null,
410
+ [FieldValueTypes.EMAIL]: {},
411
+ [FieldValueTypes.INTEGER]: null,
412
+ [FieldValueTypes.NUMBER]: null,
413
+ [FieldValueTypes.OBJECT]: null,
414
+ [FieldValueTypes.REFERENCE]: null,
415
+ [FieldValueTypes.RICH_TEXT_HTML]: {},
416
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: {},
417
+ [FieldValueTypes.STRING]: {},
418
+ [FieldValueTypes.URL]: null,
419
+ },
420
+ [FieldValueTypes.INTEGER]: {
421
+ [FieldValueTypes.BLOB]: null,
422
+ [FieldValueTypes.BOOLEAN]: {},
423
+ [FieldValueTypes.DATE]: {},
424
+ [FieldValueTypes.DATE_RANGE]: null,
425
+ [FieldValueTypes.DATETIME]: {},
426
+ [FieldValueTypes.DATETIME_RANGE]: null,
427
+ [FieldValueTypes.DURATION]: null,
428
+ [FieldValueTypes.EMAIL]: null,
429
+ [FieldValueTypes.INTEGER]: {},
430
+ [FieldValueTypes.NUMBER]: {},
431
+ [FieldValueTypes.OBJECT]: null,
432
+ [FieldValueTypes.REFERENCE]: null,
433
+ [FieldValueTypes.RICH_TEXT_HTML]: {},
434
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: {},
435
+ [FieldValueTypes.STRING]: {},
436
+ [FieldValueTypes.URL]: null,
437
+ },
438
+ [FieldValueTypes.NUMBER]: {
439
+ [FieldValueTypes.BLOB]: null,
440
+ [FieldValueTypes.BOOLEAN]: {},
441
+ [FieldValueTypes.DATE]: {},
442
+ [FieldValueTypes.DATE_RANGE]: null,
443
+ [FieldValueTypes.DATETIME]: {},
444
+ [FieldValueTypes.DATETIME_RANGE]: null,
445
+ [FieldValueTypes.DURATION]: null,
446
+ [FieldValueTypes.EMAIL]: null,
447
+ [FieldValueTypes.INTEGER]: {},
448
+ [FieldValueTypes.NUMBER]: {},
449
+ [FieldValueTypes.OBJECT]: null,
450
+ [FieldValueTypes.REFERENCE]: null,
451
+ [FieldValueTypes.RICH_TEXT_HTML]: {},
452
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: {},
453
+ [FieldValueTypes.STRING]: {},
454
+ [FieldValueTypes.URL]: null,
455
+ },
456
+ [FieldValueTypes.OBJECT]: {
457
+ [FieldValueTypes.BLOB]: null,
458
+ [FieldValueTypes.BOOLEAN]: null,
459
+ [FieldValueTypes.DATE]: null,
460
+ [FieldValueTypes.DATE_RANGE]: null,
461
+ [FieldValueTypes.DATETIME]: null,
462
+ [FieldValueTypes.DATETIME_RANGE]: null,
463
+ [FieldValueTypes.DURATION]: null,
464
+ [FieldValueTypes.EMAIL]: null,
465
+ [FieldValueTypes.INTEGER]: null,
466
+ [FieldValueTypes.NUMBER]: null,
467
+ [FieldValueTypes.OBJECT]: null,
468
+ [FieldValueTypes.REFERENCE]: null,
469
+ [FieldValueTypes.RICH_TEXT_HTML]: null,
470
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: null,
471
+ [FieldValueTypes.STRING]: null,
472
+ [FieldValueTypes.URL]: null,
473
+ },
474
+ [FieldValueTypes.REFERENCE]: {
475
+ [FieldValueTypes.BLOB]: null,
476
+ [FieldValueTypes.BOOLEAN]: null,
477
+ [FieldValueTypes.DATE]: null,
478
+ [FieldValueTypes.DATE_RANGE]: null,
479
+ [FieldValueTypes.DATETIME]: null,
480
+ [FieldValueTypes.DATETIME_RANGE]: null,
481
+ [FieldValueTypes.DURATION]: null,
482
+ [FieldValueTypes.EMAIL]: null,
483
+ [FieldValueTypes.INTEGER]: null,
484
+ [FieldValueTypes.NUMBER]: null,
485
+ [FieldValueTypes.OBJECT]: null,
486
+ [FieldValueTypes.REFERENCE]: {},
487
+ [FieldValueTypes.RICH_TEXT_HTML]: null,
488
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: null,
489
+ [FieldValueTypes.STRING]: null,
490
+ [FieldValueTypes.URL]: null,
491
+ },
492
+ [FieldValueTypes.RICH_TEXT_HTML]: {
493
+ [FieldValueTypes.BLOB]: null,
494
+ [FieldValueTypes.BOOLEAN]: null,
495
+ [FieldValueTypes.DATE]: null,
496
+ [FieldValueTypes.DATE_RANGE]: null,
497
+ [FieldValueTypes.DATETIME]: null,
498
+ [FieldValueTypes.DATETIME_RANGE]: null,
499
+ [FieldValueTypes.DURATION]: null,
500
+ [FieldValueTypes.EMAIL]: null,
501
+ [FieldValueTypes.INTEGER]: null,
502
+ [FieldValueTypes.NUMBER]: null,
503
+ [FieldValueTypes.OBJECT]: null,
504
+ [FieldValueTypes.REFERENCE]: null,
505
+ [FieldValueTypes.RICH_TEXT_HTML]: htmlToRichTextConfiguration,
506
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: htmlToRichTextConfiguration,
507
+ [FieldValueTypes.STRING]: {},
508
+ [FieldValueTypes.URL]: null,
509
+ },
510
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: {
511
+ [FieldValueTypes.BLOB]: null,
512
+ [FieldValueTypes.BOOLEAN]: null,
513
+ [FieldValueTypes.DATE]: null,
514
+ [FieldValueTypes.DATE_RANGE]: null,
515
+ [FieldValueTypes.DATETIME]: null,
516
+ [FieldValueTypes.DATETIME_RANGE]: null,
517
+ [FieldValueTypes.DURATION]: null,
518
+ [FieldValueTypes.EMAIL]: null,
519
+ [FieldValueTypes.INTEGER]: null,
520
+ [FieldValueTypes.NUMBER]: null,
521
+ [FieldValueTypes.OBJECT]: null,
522
+ [FieldValueTypes.REFERENCE]: null,
523
+ [FieldValueTypes.RICH_TEXT_HTML]: markdownToRichTextConfiguration,
524
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: markdownToRichTextConfiguration,
525
+ [FieldValueTypes.STRING]: {},
526
+ [FieldValueTypes.URL]: null,
527
+ },
528
+ [FieldValueTypes.STRING]: {
529
+ [FieldValueTypes.BLOB]: null,
530
+ [FieldValueTypes.BOOLEAN]: {},
531
+ [FieldValueTypes.DATE]: {},
532
+ [FieldValueTypes.DATE_RANGE]: null,
533
+ [FieldValueTypes.DATETIME]: {},
534
+ [FieldValueTypes.DATETIME_RANGE]: null,
535
+ [FieldValueTypes.DURATION]: null,
536
+ [FieldValueTypes.EMAIL]: null,
537
+ [FieldValueTypes.INTEGER]: {},
538
+ [FieldValueTypes.NUMBER]: {},
539
+ [FieldValueTypes.OBJECT]: null,
540
+ [FieldValueTypes.REFERENCE]: null,
541
+ [FieldValueTypes.RICH_TEXT_HTML]: {},
542
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: {},
543
+ [FieldValueTypes.STRING]: {},
544
+ [FieldValueTypes.URL]: null,
545
+ },
546
+ [FieldValueTypes.URL]: {
547
+ [FieldValueTypes.BLOB]: null,
548
+ [FieldValueTypes.BOOLEAN]: null,
549
+ [FieldValueTypes.DATE]: null,
550
+ [FieldValueTypes.DATE_RANGE]: null,
551
+ [FieldValueTypes.DATETIME]: null,
552
+ [FieldValueTypes.DATETIME_RANGE]: null,
553
+ [FieldValueTypes.DURATION]: null,
554
+ [FieldValueTypes.EMAIL]: null,
555
+ [FieldValueTypes.INTEGER]: null,
556
+ [FieldValueTypes.NUMBER]: null,
557
+ [FieldValueTypes.OBJECT]: null,
558
+ [FieldValueTypes.REFERENCE]: null,
559
+ [FieldValueTypes.RICH_TEXT_HTML]: {},
560
+ [FieldValueTypes.RICH_TEXT_MARKDOWN]: {},
561
+ [FieldValueTypes.STRING]: {},
562
+ [FieldValueTypes.URL]: {},
563
+ },
564
+ };
565
+
566
+ /**
567
+ * JSONPath parser that returns a relation that is guaranteed to have its schema populated.
568
+ */
569
+ function findRelationByJSONPath(item, query) {
570
+ const tokens = parseJSONPath(query);
571
+ const relations = [];
572
+ let current = item;
573
+ for (const token of tokens) {
574
+ if (current === '__self') {
575
+ const previousRelation = relations[relations.length - 1];
576
+ if (!previousRelation) {
577
+ throw new Error(`Invalid use of __self`);
578
+ }
579
+ current = previousRelation.schema;
580
+ }
581
+ const result = applyToken(current, token);
582
+ if (isReferenceRelation(result) && isRelationSchema(result.schema)) {
583
+ relations.push(result);
584
+ }
585
+ else if (isRelationSummary(result) && isRelationSchema(result.schema)) {
586
+ relations.push(result);
587
+ }
588
+ current = result;
589
+ }
590
+ if (isReferenceRelation(current) || isRelationSummary(current)) {
591
+ return relations[relations.length - 1];
592
+ }
593
+ return undefined;
594
+ }
595
+ /**
596
+ * Parse JSONPath expression into tokens
597
+ */
598
+ function parseJSONPath(query) {
599
+ const tokens = [];
600
+ let remaining = query;
601
+ // Remove root $ if present
602
+ if (remaining.startsWith('$')) {
603
+ remaining = remaining.substring(1);
604
+ }
605
+ while (remaining.length > 0) {
606
+ // Skip leading dots
607
+ if (remaining.startsWith('.')) {
608
+ remaining = remaining.substring(1);
609
+ continue;
610
+ }
611
+ // Parse bracket notation [...]
612
+ if (remaining.startsWith('[')) {
613
+ const bracketMatch = remaining.match(/^\[([^\]]*)\]/);
614
+ if (!bracketMatch) {
615
+ throw new Error(`Unclosed bracket in JSONPath: ${query}`);
616
+ }
617
+ remaining = remaining.substring(bracketMatch[0].length);
618
+ tokens.push(parseBracketExpression(String(bracketMatch[1])));
619
+ continue;
620
+ }
621
+ // Parse property name (until . or [ or end)
622
+ const propertyMatch = remaining.match(/^([^.[]+)/);
623
+ if (propertyMatch) {
624
+ const propertyName = String(propertyMatch[1]);
625
+ remaining = remaining.substring(propertyName.length);
626
+ tokens.push({ type: 'property', name: propertyName });
627
+ }
628
+ }
629
+ return tokens;
630
+ }
631
+ /**
632
+ * Parse bracket expression into a token
633
+ */
634
+ function parseBracketExpression(content) {
635
+ // Filter expression: ?(@.property == 'value')
636
+ if (content.startsWith('?(')) {
637
+ const filterExpr = content.substring(2, content.length - 1);
638
+ return { type: 'filter', expression: parseFilterExpression(filterExpr) };
639
+ }
640
+ // Array index: 0, 1, 2, etc.
641
+ const index = parseInt(content, 10);
642
+ if (!isNaN(index)) {
643
+ return { type: 'index', value: index };
644
+ }
645
+ throw new Error(`Unsupported bracket expression: ${content}`);
646
+ }
647
+ /**
648
+ * Parse filter expression like @.name == 'value'
649
+ */
650
+ function parseFilterExpression(expr) {
651
+ const opIndex = expr.indexOf('==');
652
+ if (opIndex === -1) {
653
+ throw new Error(`Filter expression must use == operator: ${expr}`);
654
+ }
655
+ const left = expr.substring(0, opIndex).trim();
656
+ const right = expr.substring(opIndex + 2).trim();
657
+ // Parse left side (should be @.property)
658
+ if (!left.startsWith('@.')) {
659
+ throw new Error(`Filter expression must start with @.: ${expr}`);
660
+ }
661
+ const property = left.substring(2);
662
+ // Parse right side (value) using regex to extract quoted strings
663
+ const quotedMatch = right.match(/^(?<quote>['"])(?<content>.*?)\k<quote>$/);
664
+ if (!quotedMatch) {
665
+ throw new Error(`Filter expression value must be a quoted string: ${expr}`);
666
+ }
667
+ return { property, value: quotedMatch.groups['content'] };
668
+ }
669
+ /**
670
+ * Apply a single token to the current value
671
+ */
672
+ function applyToken(current, token) {
673
+ switch (token.type) {
674
+ case 'property':
675
+ return applyProperty(current, token.name);
676
+ case 'index':
677
+ return applyIndex(current, token.value);
678
+ case 'filter':
679
+ return applyFilter(current, token.expression);
680
+ default:
681
+ throw new Error(`Unsupported token type: ${token.type}`);
682
+ }
683
+ }
684
+ /**
685
+ * Apply property access
686
+ */
687
+ function applyProperty(current, property) {
688
+ if (!isObject(current) || !(property in current)) {
689
+ return undefined;
690
+ }
691
+ return current[property];
692
+ }
693
+ /**
694
+ * Apply array index access
695
+ */
696
+ function applyIndex(current, index) {
697
+ if (!Array.isArray(current) || index < 0 || index >= current.length) {
698
+ return undefined;
699
+ }
700
+ return current[index];
701
+ }
702
+ /**
703
+ * Apply filter expression
704
+ *
705
+ * This function returns the first item that matches the filter expression.
706
+ */
707
+ function applyFilter(current, filter) {
708
+ if (!Array.isArray(current)) {
709
+ return undefined;
710
+ }
711
+ for (const item of current) {
712
+ if (isObject(item) && matchesFilter(item, filter)) {
713
+ return item;
714
+ }
715
+ }
716
+ return undefined;
717
+ }
718
+ /**
719
+ * Check if an item matches a filter expression
720
+ */
721
+ function matchesFilter(item, filter) {
722
+ if (!(filter.property in item)) {
723
+ return false;
724
+ }
725
+ return item[filter.property] === filter.value;
726
+ }
727
+
221
728
  exports.FieldValueTypes = FieldValueTypes;
222
729
  exports.OperatorTypes = OperatorTypes;
223
730
  exports.RelationSemantics = RelationSemantics;
224
731
  exports.Semantics = Semantics;
225
732
  exports.StatusCodes = StatusCodes;
733
+ exports.fieldTypeCompatibilityMatrix = fieldTypeCompatibilityMatrix;
734
+ exports.findRelationByJSONPath = findRelationByJSONPath;
226
735
  exports.isFieldSchema = isFieldSchema;
227
736
  exports.isFieldValueType = isFieldValueType;
228
737
  exports.isItem = isItem;
229
738
  exports.isItemSummary = isItemSummary;
739
+ exports.isObject = isObject;
230
740
  exports.isReferenceRelation = isReferenceRelation;
231
741
  exports.isRelation = isRelation;
232
742
  exports.isRelationSchema = isRelationSchema;
233
743
  exports.isRelationSchemaOrSelf = isRelationSchemaOrSelf;
234
744
  exports.isRelationSummary = isRelationSummary;
235
745
  exports.isSemantic = isSemantic;
746
+ exports.isString = isString;
747
+ exports.isUndefined = isUndefined;
@@ -1,2 +1,4 @@
1
1
  export * from './types.js';
2
2
  export * from './guards.js';
3
+ export * from './compatibilities.js';
4
+ export * from './jsonPathHelpers.js';
package/dist/src/index.js CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from './types.js';
2
2
  export * from './guards.js';
3
+ export * from './compatibilities.js';
4
+ export * from './jsonPathHelpers.js';
@@ -0,0 +1,5 @@
1
+ import * as Api from './index.js';
2
+ /**
3
+ * JSONPath parser that returns a relation that is guaranteed to have its schema populated.
4
+ */
5
+ export declare function findRelationByJSONPath(item: Api.Item, query: string): Api.Relation | Api.RelationWithPopulatedSchema<Api.RelationSummary> | Api.RelationWithPopulatedSchema<Api.ReferenceRelation> | undefined;