@squiz/dx-json-schema-lib 1.16.0 → 1.21.1-alpha.10

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 (39) hide show
  1. package/.npm/_logs/{2023-02-27T22_59_15_807Z-debug-0.log → 2023-03-09T00_01_12_827Z-debug-0.log} +14 -14
  2. package/lib/JsonValidationService.js +8 -0
  3. package/lib/JsonValidationService.js.map +1 -1
  4. package/lib/JsonValidationService.spec.js +44 -0
  5. package/lib/JsonValidationService.spec.js.map +1 -1
  6. package/lib/index.d.ts +1 -0
  7. package/lib/index.js +1 -0
  8. package/lib/index.js.map +1 -1
  9. package/lib/manifest/v1/DxContentMetaSchema.json +116 -1
  10. package/lib/manifest/v1/MatrixAssetSchema.json +370 -0
  11. package/lib/manifest/v1/__test__/schemas/inputStringWithFormat.json +29 -0
  12. package/lib/manifest/v1/subSchemas.d.ts +2 -1
  13. package/lib/manifest/v1/subSchemas.js +3 -1
  14. package/lib/manifest/v1/subSchemas.js.map +1 -1
  15. package/lib/manifest/v1/v1.d.ts +400 -2
  16. package/lib/manifest/v1/v1.json +48 -0
  17. package/lib/validators/customFormatValidators.d.ts +2 -0
  18. package/lib/validators/customFormatValidators.js +14 -0
  19. package/lib/validators/customFormatValidators.js.map +1 -0
  20. package/lib/validators/utils/matrixAssetValidator.d.ts +2 -0
  21. package/lib/validators/utils/matrixAssetValidator.js +11 -0
  22. package/lib/validators/utils/matrixAssetValidator.js.map +1 -0
  23. package/lib/validators/utils/matrixAssetValidator.spec.d.ts +1 -0
  24. package/lib/validators/utils/matrixAssetValidator.spec.js +43 -0
  25. package/lib/validators/utils/matrixAssetValidator.spec.js.map +1 -0
  26. package/package.json +2 -2
  27. package/src/JsonValidationService.spec.ts +62 -0
  28. package/src/JsonValidationService.ts +9 -1
  29. package/src/index.ts +2 -0
  30. package/src/manifest/v1/DxContentMetaSchema.json +116 -1
  31. package/src/manifest/v1/MatrixAssetSchema.json +371 -0
  32. package/src/manifest/v1/__test__/schemas/inputStringWithFormat.json +29 -0
  33. package/src/manifest/v1/subSchemas.ts +2 -1
  34. package/src/manifest/v1/v1.json +48 -0
  35. package/src/manifest/v1/v1.ts +640 -2
  36. package/src/validators/customFormatValidators.ts +15 -0
  37. package/src/validators/utils/matrixAssetValidator.spec.ts +49 -0
  38. package/src/validators/utils/matrixAssetValidator.ts +8 -0
  39. package/tsconfig.tsbuildinfo +1 -1
@@ -60,7 +60,8 @@ export type CoreSchemaMetaSchema2 = {
60
60
  */
61
61
  enum?: true[];
62
62
  type?: ('array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string' | 'FormattedText') | ('array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string' | 'FormattedText')[];
63
- format?: string;
63
+ format?: 'date-time' | 'email' | 'hostname' | 'ipv4' | 'ipv6' | 'json-pointer' | 'matrix-asset-uri' | 'multi-line' | 'password' | 'phone' | 'regex' | 'relative-json-pointer' | 'uri-reference' | 'uri-template' | 'uri' | 'uuid';
64
+ matrixAssetTypes?: ('audioFile' | 'bodycopyContainer' | 'bodycopyDiv' | 'calendarEventsSearchPage' | 'contentContainerTemplate' | 'contentTypeMarkdown' | 'contentTypeNestContent' | 'contentTypeRawHtml' | 'contentTypeSnippet' | 'contentTypeWysiwyg' | 'cssFileFolder' | 'cssFile' | 'customForm' | 'dataRecord' | 'designAreaAssetLineage' | 'designAreaBody' | 'designAreaMenuNormal' | 'designAreaNestContent' | 'designCssCustomisation' | 'designCss' | 'designCustomisation' | 'designScss' | 'design' | 'docx' | 'excelDoc' | 'file' | 'folder' | 'gitBridge' | 'googleAnalyticsConnector' | 'googleAnalyticsView' | 'image' | 'jsFileFolder' | 'jsFile' | 'jsonWebToken' | 'layoutManager' | 'layout' | 'link' | 'metadataFieldDate' | 'metadataFieldRelatedAsset' | 'metadataFieldSelect' | 'metadataFieldText' | 'metadataFieldWysiwyg' | 'metadataSchema' | 'metadataSection' | 'newsItem' | 'oauthAccountManager' | 'pageAccountManager' | 'pageAssetListing' | 'pageCalendarEventsSearch' | 'pageCalendar' | 'pagePasswordReset' | 'pageRemoteContent' | 'pageRestResourceJs' | 'pageRestResourceOauthSession' | 'pageRestResourceOauthTwoLegged' | 'pageRestResource' | 'pageSiteMap' | 'pageStandard' | 'paintLayoutBodycopy' | 'paintLayoutPage' | 'pdfFile' | 'pdf' | 'persona' | 'powerpointDoc' | 'pptx' | 'redirectPage' | 'regex' | 'regularExpression' | 'rtfFile' | 'samlAccountManager' | 'saml2Acs' | 'saml2Sls' | 'searchPage' | 'site' | 'textFile' | 'TriggerTypes?' | 'userGroup' | 'wordDoc' | 'workflowSchema' | 'workflowStepCondition' | 'workflowStep' | 'workflowStream' | 'xlsx' | 'xmlFile')[];
64
65
  contentMediaType?: string;
65
66
  contentEncoding?: string;
66
67
  if?: CoreSchemaMetaSchema2;
@@ -142,6 +143,7 @@ export type CoreSchemaMetaSchema5 = {
142
143
  */
143
144
  export type SchemaArray1 = CoreSchemaMetaSchema5[];
144
145
  export type StringArray1 = string[];
146
+ export type ImageAdditionalInfo = FileAdditionalInfo;
145
147
  export interface ComponentManifest {
146
148
  /**
147
149
  * the manifest schema version
@@ -200,6 +202,26 @@ export interface ComponentManifest {
200
202
  previews?: {
201
203
  [k: string]: PreviewDefinition;
202
204
  };
205
+ /**
206
+ * Mocked uri objects used in the preview
207
+ */
208
+ mockedUris?: {
209
+ /**
210
+ * Property for defining the mock URI object
211
+ */
212
+ [k: string]: {
213
+ type: 'file';
214
+ /**
215
+ * Path to uri object
216
+ */
217
+ path: string;
218
+ [k: string]: unknown;
219
+ } | {
220
+ type: 'inline';
221
+ value: MatrixAssetSchema;
222
+ [k: string]: unknown;
223
+ };
224
+ };
203
225
  }
204
226
  /**
205
227
  * Icon for the component in Matrix and the DXP
@@ -280,7 +302,8 @@ export interface CoreSchemaMetaSchema1 {
280
302
  */
281
303
  enum?: true[];
282
304
  type?: ('array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string' | 'FormattedText') | ('array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string' | 'FormattedText')[];
283
- format?: string;
305
+ format?: 'date-time' | 'email' | 'hostname' | 'ipv4' | 'ipv6' | 'json-pointer' | 'matrix-asset-uri' | 'multi-line' | 'password' | 'phone' | 'regex' | 'relative-json-pointer' | 'uri-reference' | 'uri-template' | 'uri' | 'uuid';
306
+ matrixAssetTypes?: ('audioFile' | 'bodycopyContainer' | 'bodycopyDiv' | 'calendarEventsSearchPage' | 'contentContainerTemplate' | 'contentTypeMarkdown' | 'contentTypeNestContent' | 'contentTypeRawHtml' | 'contentTypeSnippet' | 'contentTypeWysiwyg' | 'cssFileFolder' | 'cssFile' | 'customForm' | 'dataRecord' | 'designAreaAssetLineage' | 'designAreaBody' | 'designAreaMenuNormal' | 'designAreaNestContent' | 'designCssCustomisation' | 'designCss' | 'designCustomisation' | 'designScss' | 'design' | 'docx' | 'excelDoc' | 'file' | 'folder' | 'gitBridge' | 'googleAnalyticsConnector' | 'googleAnalyticsView' | 'image' | 'jsFileFolder' | 'jsFile' | 'jsonWebToken' | 'layoutManager' | 'layout' | 'link' | 'metadataFieldDate' | 'metadataFieldRelatedAsset' | 'metadataFieldSelect' | 'metadataFieldText' | 'metadataFieldWysiwyg' | 'metadataSchema' | 'metadataSection' | 'newsItem' | 'oauthAccountManager' | 'pageAccountManager' | 'pageAssetListing' | 'pageCalendarEventsSearch' | 'pageCalendar' | 'pagePasswordReset' | 'pageRemoteContent' | 'pageRestResourceJs' | 'pageRestResourceOauthSession' | 'pageRestResourceOauthTwoLegged' | 'pageRestResource' | 'pageSiteMap' | 'pageStandard' | 'paintLayoutBodycopy' | 'paintLayoutPage' | 'pdfFile' | 'pdf' | 'persona' | 'powerpointDoc' | 'pptx' | 'redirectPage' | 'regex' | 'regularExpression' | 'rtfFile' | 'samlAccountManager' | 'saml2Acs' | 'saml2Sls' | 'searchPage' | 'site' | 'textFile' | 'TriggerTypes?' | 'userGroup' | 'wordDoc' | 'workflowSchema' | 'workflowStepCondition' | 'workflowStep' | 'workflowStream' | 'xlsx' | 'xmlFile')[];
284
307
  contentMediaType?: string;
285
308
  contentEncoding?: string;
286
309
  if?: CoreSchemaMetaSchema2;
@@ -457,3 +480,378 @@ export interface FunctionPreviewConfiguration {
457
480
  export interface ResponseHeaders2 {
458
481
  [k: string]: string;
459
482
  }
483
+ /**
484
+ * Inline URI object
485
+ */
486
+ export interface MatrixAssetSchema {
487
+ /**
488
+ * The asset ID.
489
+ */
490
+ id: string;
491
+ /**
492
+ * The asset type code.
493
+ */
494
+ type: string;
495
+ /**
496
+ * The asset type friendly name.
497
+ */
498
+ type_name: string;
499
+ /**
500
+ * The asset semantic version.
501
+ */
502
+ version: string;
503
+ /**
504
+ * The asset standard field name.
505
+ */
506
+ name: string;
507
+ /**
508
+ * The asset standard field short name.
509
+ */
510
+ short_name: string;
511
+ /**
512
+ * A object representing the asset status of the asset resource.
513
+ */
514
+ status: {
515
+ /**
516
+ * The bitwise id of the asset status
517
+ */
518
+ id: 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 256;
519
+ /**
520
+ * The type code of the asset status
521
+ */
522
+ code: 'archived' | 'under_construction' | 'pending_approval' | 'approved' | 'live' | 'live_approval' | 'editing' | 'editing_approval' | 'editing_approved';
523
+ /**
524
+ * The description of the asset status
525
+ */
526
+ name?: 'Archived' | 'Under Construction' | 'Pending Approval' | 'Approved To Go Live' | 'Live' | 'Up For Review' | 'Safe Editing' | 'Safe Editing Pending Approval' | 'Safe Edit Approved To Go Live';
527
+ };
528
+ /**
529
+ * A object representing when the asset status was created.
530
+ */
531
+ created: {
532
+ /**
533
+ * The creation date of the asset in ISO 8601 format.
534
+ */
535
+ date: string | null;
536
+ /**
537
+ * The asset ID of the User that created the asset.
538
+ */
539
+ user_id: string | null;
540
+ };
541
+ /**
542
+ * A object representing when the asset status was last updated.
543
+ */
544
+ updated: {
545
+ /**
546
+ * The last updated date of the asset in ISO 8601 format.
547
+ */
548
+ date: string | null;
549
+ /**
550
+ * The asset ID of the User that last updated the asset.
551
+ */
552
+ user_id: string | null;
553
+ };
554
+ /**
555
+ * A object representing when the asset status was last published.
556
+ */
557
+ published: {
558
+ /**
559
+ * The last published date of the asset in ISO 8601 format.
560
+ */
561
+ date: string | null;
562
+ /**
563
+ * The asset ID of the User that last published the asset.
564
+ */
565
+ user_id: string | null;
566
+ };
567
+ /**
568
+ * A object representing when the asset status was last changed.
569
+ */
570
+ status_changed?: {
571
+ /**
572
+ * The last date the state of the asset was changed in ISO 8601 format.
573
+ */
574
+ date: string | null;
575
+ /**
576
+ * The asset ID of the User that last changed the asset status.
577
+ */
578
+ user_id: string | null;
579
+ };
580
+ /**
581
+ * The primary URL for the asset.
582
+ */
583
+ url: string;
584
+ /**
585
+ * All URLs for the asset including the primary URL.
586
+ */
587
+ urls: string[];
588
+ /**
589
+ * List of attributes for the asset in key-value form.
590
+ */
591
+ attributes: {
592
+ [k: string]: unknown;
593
+ };
594
+ /**
595
+ * List of metadata values in key-value form.
596
+ */
597
+ metadata?: {
598
+ [k: string]: string[];
599
+ };
600
+ /**
601
+ * The contents for the asset (excluding file assets).
602
+ */
603
+ contents?: string;
604
+ /**
605
+ * The thumbnail image associated with the asset, shows a subset data of an image or image variety.
606
+ */
607
+ thumbnail?: {
608
+ /**
609
+ * The asset ID of the Image asset of the file.
610
+ */
611
+ asset_id?: string;
612
+ /**
613
+ * The accessible URL of the thumbnail image file.
614
+ */
615
+ url?: string;
616
+ /**
617
+ * The file name of the thumbnail image.
618
+ */
619
+ file_name?: string;
620
+ /**
621
+ * The image file width in pixels.
622
+ */
623
+ width?: number;
624
+ /**
625
+ * The image file height in pixels.
626
+ */
627
+ height?: number;
628
+ /**
629
+ * The file type of the image file, generally its extension.
630
+ */
631
+ file_type?: string;
632
+ /**
633
+ * The file size in bytes
634
+ */
635
+ file_size?: number;
636
+ /**
637
+ * The file size in human readable format
638
+ */
639
+ file_size_readable?: number;
640
+ /**
641
+ * The friendly name of the file asset
642
+ */
643
+ title?: string;
644
+ /**
645
+ * The alt attribute of the Image asset
646
+ */
647
+ alt?: string;
648
+ [k: string]: unknown;
649
+ };
650
+ /**
651
+ * All direct dependent child assets of the asset in normalized asset format.
652
+ */
653
+ include_dependents?: MatrixAssetSchema1[];
654
+ /**
655
+ * Additional data of an arbitrary nature related to the requested asset, which may include derived information or special child asset information.
656
+ */
657
+ additional?: AssetAdditionalInfo | FileAdditionalInfo | ImageAdditionalInfo | CalendarEventAdditionalInfo;
658
+ [k: string]: unknown;
659
+ }
660
+ export interface MatrixAssetSchema1 {
661
+ /**
662
+ * The asset ID.
663
+ */
664
+ id: string;
665
+ /**
666
+ * The asset type code.
667
+ */
668
+ type: string;
669
+ /**
670
+ * The asset type friendly name.
671
+ */
672
+ type_name: string;
673
+ /**
674
+ * The asset semantic version.
675
+ */
676
+ version: string;
677
+ /**
678
+ * The asset standard field name.
679
+ */
680
+ name: string;
681
+ /**
682
+ * The asset standard field short name.
683
+ */
684
+ short_name: string;
685
+ /**
686
+ * A object representing the asset status of the asset resource.
687
+ */
688
+ status: {
689
+ /**
690
+ * The bitwise id of the asset status
691
+ */
692
+ id: 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 256;
693
+ /**
694
+ * The type code of the asset status
695
+ */
696
+ code: 'archived' | 'under_construction' | 'pending_approval' | 'approved' | 'live' | 'live_approval' | 'editing' | 'editing_approval' | 'editing_approved';
697
+ /**
698
+ * The description of the asset status
699
+ */
700
+ name?: 'Archived' | 'Under Construction' | 'Pending Approval' | 'Approved To Go Live' | 'Live' | 'Up For Review' | 'Safe Editing' | 'Safe Editing Pending Approval' | 'Safe Edit Approved To Go Live';
701
+ };
702
+ /**
703
+ * A object representing when the asset status was created.
704
+ */
705
+ created: {
706
+ /**
707
+ * The creation date of the asset in ISO 8601 format.
708
+ */
709
+ date: string | null;
710
+ /**
711
+ * The asset ID of the User that created the asset.
712
+ */
713
+ user_id: string | null;
714
+ };
715
+ /**
716
+ * A object representing when the asset status was last updated.
717
+ */
718
+ updated: {
719
+ /**
720
+ * The last updated date of the asset in ISO 8601 format.
721
+ */
722
+ date: string | null;
723
+ /**
724
+ * The asset ID of the User that last updated the asset.
725
+ */
726
+ user_id: string | null;
727
+ };
728
+ /**
729
+ * A object representing when the asset status was last published.
730
+ */
731
+ published: {
732
+ /**
733
+ * The last published date of the asset in ISO 8601 format.
734
+ */
735
+ date: string | null;
736
+ /**
737
+ * The asset ID of the User that last published the asset.
738
+ */
739
+ user_id: string | null;
740
+ };
741
+ /**
742
+ * A object representing when the asset status was last changed.
743
+ */
744
+ status_changed?: {
745
+ /**
746
+ * The last date the state of the asset was changed in ISO 8601 format.
747
+ */
748
+ date: string | null;
749
+ /**
750
+ * The asset ID of the User that last changed the asset status.
751
+ */
752
+ user_id: string | null;
753
+ };
754
+ /**
755
+ * The primary URL for the asset.
756
+ */
757
+ url: string;
758
+ /**
759
+ * All URLs for the asset including the primary URL.
760
+ */
761
+ urls: string[];
762
+ /**
763
+ * List of attributes for the asset in key-value form.
764
+ */
765
+ attributes: {
766
+ [k: string]: unknown;
767
+ };
768
+ /**
769
+ * List of metadata values in key-value form.
770
+ */
771
+ metadata?: {
772
+ [k: string]: string[];
773
+ };
774
+ /**
775
+ * The contents for the asset (excluding file assets).
776
+ */
777
+ contents?: string;
778
+ /**
779
+ * The thumbnail image associated with the asset, shows a subset data of an image or image variety.
780
+ */
781
+ thumbnail?: {
782
+ /**
783
+ * The asset ID of the Image asset of the file.
784
+ */
785
+ asset_id?: string;
786
+ /**
787
+ * The accessible URL of the thumbnail image file.
788
+ */
789
+ url?: string;
790
+ /**
791
+ * The file name of the thumbnail image.
792
+ */
793
+ file_name?: string;
794
+ /**
795
+ * The image file width in pixels.
796
+ */
797
+ width?: number;
798
+ /**
799
+ * The image file height in pixels.
800
+ */
801
+ height?: number;
802
+ /**
803
+ * The file type of the image file, generally its extension.
804
+ */
805
+ file_type?: string;
806
+ /**
807
+ * The file size in bytes
808
+ */
809
+ file_size?: number;
810
+ /**
811
+ * The file size in human readable format
812
+ */
813
+ file_size_readable?: number;
814
+ /**
815
+ * The friendly name of the file asset
816
+ */
817
+ title?: string;
818
+ /**
819
+ * The alt attribute of the Image asset
820
+ */
821
+ alt?: string;
822
+ [k: string]: unknown;
823
+ };
824
+ /**
825
+ * All direct dependent child assets of the asset in normalized asset format.
826
+ */
827
+ include_dependents?: MatrixAssetSchema1[];
828
+ /**
829
+ * Additional data of an arbitrary nature related to the requested asset, which may include derived information or special child asset information.
830
+ */
831
+ additional?: AssetAdditionalInfo | FileAdditionalInfo | ImageAdditionalInfo | CalendarEventAdditionalInfo;
832
+ [k: string]: unknown;
833
+ }
834
+ export interface AssetAdditionalInfo {
835
+ [k: string]: unknown;
836
+ }
837
+ export interface FileAdditionalInfo {
838
+ file_info?: {
839
+ file_name?: string;
840
+ size_readable?: string;
841
+ size_bytes?: number;
842
+ width?: number;
843
+ height?: number;
844
+ modified_readable?: string;
845
+ modified_unix?: number;
846
+ [k: string]: unknown;
847
+ };
848
+ [k: string]: unknown;
849
+ }
850
+ export interface CalendarEventAdditionalInfo {
851
+ event_info?: {
852
+ duration?: number;
853
+ frequency?: string;
854
+ [k: string]: unknown;
855
+ };
856
+ [k: string]: unknown;
857
+ }
@@ -361,6 +361,54 @@
361
361
  }
362
362
  }
363
363
  }
364
+ },
365
+ "mockedUris": {
366
+ "type": "object",
367
+ "description": "Mocked uri objects used in the preview",
368
+ "propertyNames": {
369
+ "type": "string",
370
+ "pattern": "^[a-z0-9_\\-]+:\\/\\/"
371
+ },
372
+ "additionalProperties": {
373
+ "type": "object",
374
+ "description": "Property for defining the mock URI object",
375
+ "properties": {
376
+ "type": {
377
+ "description": "An enum of 'file' or 'inline' for how the uri object is defined",
378
+ "enum": ["file", "inline"]
379
+ }
380
+ },
381
+ "required": ["type"],
382
+ "oneOf": [
383
+ {
384
+ "type": "object",
385
+ "properties": {
386
+ "type": {
387
+ "enum": ["file"]
388
+ },
389
+ "path": {
390
+ "type": "string",
391
+ "format": "uri-reference",
392
+ "description": "Path to uri object"
393
+ }
394
+ },
395
+ "required": ["type", "path"]
396
+ },
397
+ {
398
+ "type": "object",
399
+ "properties": {
400
+ "type": {
401
+ "enum": ["inline"]
402
+ },
403
+ "value": {
404
+ "$ref": "MatrixAssetSchema.json",
405
+ "description": "Inline URI object"
406
+ }
407
+ },
408
+ "required": ["type", "value"]
409
+ }
410
+ ]
411
+ }
364
412
  }
365
413
  },
366
414
  "required": ["name", "namespace", "displayName", "description", "version", "functions", "$schema", "mainFunction"],
@@ -0,0 +1,2 @@
1
+ import { Draft, JSONError, JSONSchema } from 'json-schema-library';
2
+ export declare const customFormatValidators: Record<string, (draft: Draft, schema: JSONSchema, value: unknown, pointer: string) => undefined | JSONError | JSONError[]>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.customFormatValidators = void 0;
4
+ const SchemaValidationError_1 = require("../errors/SchemaValidationError");
5
+ const matrixAssetValidator_1 = require("./utils/matrixAssetValidator");
6
+ exports.customFormatValidators = {
7
+ 'matrix-asset-uri': (core, schema, value) => {
8
+ if ((0, matrixAssetValidator_1.isMatrixAssetUri)(value) === false) {
9
+ throw new SchemaValidationError_1.SchemaValidationError(`value "${value}" isn't a valid matrix asset uri`);
10
+ }
11
+ return;
12
+ },
13
+ };
14
+ //# sourceMappingURL=customFormatValidators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customFormatValidators.js","sourceRoot":"","sources":["../../src/validators/customFormatValidators.ts"],"names":[],"mappings":";;;AACA,2EAAwE;AACxE,uEAAgE;AAEnD,QAAA,sBAAsB,GAG/B;IACF,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAa,EAAE;QACrD,IAAI,IAAA,uCAAgB,EAAC,KAAK,CAAC,KAAK,KAAK,EAAE;YACrC,MAAM,IAAI,6CAAqB,CAAC,UAAU,KAAK,kCAAkC,CAAC,CAAC;SACpF;QACD,OAAO;IACT,CAAC;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type MatrixAssetUri = `matrix-asset://${string}`;
2
+ export declare function isMatrixAssetUri(url: unknown): url is MatrixAssetUri;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMatrixAssetUri = void 0;
4
+ function isMatrixAssetUri(url) {
5
+ if (typeof url !== 'string')
6
+ return false;
7
+ /*eslint-disable no-useless-escape*/
8
+ return /^matrix-asset:\/\/[a-zA-Z0-9.-]+\/[a-zA-Z0-9\/._-]+\/?([0-9]+(?:\:[0-9a-z\-\._/]+\$?)?)?$/.test(url);
9
+ }
10
+ exports.isMatrixAssetUri = isMatrixAssetUri;
11
+ //# sourceMappingURL=matrixAssetValidator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrixAssetValidator.js","sourceRoot":"","sources":["../../../src/validators/utils/matrixAssetValidator.ts"],"names":[],"mappings":";;;AAEA,SAAgB,gBAAgB,CAAC,GAAY;IAC3C,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE1C,oCAAoC;IACpC,OAAO,2FAA2F,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/G,CAAC;AALD,4CAKC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const matrixAssetValidator_1 = require("./matrixAssetValidator");
4
+ describe('matrixAssetValidator', () => {
5
+ describe('should return true for valid matrix asset uri', () => {
6
+ it('with basic uri structure', () => {
7
+ expect((0, matrixAssetValidator_1.isMatrixAssetUri)('matrix-asset://matrix.org/123')).toBe(true);
8
+ expect((0, matrixAssetValidator_1.isMatrixAssetUri)('matrix-asset://dx.dev.matrix/123')).toBe(true);
9
+ expect((0, matrixAssetValidator_1.isMatrixAssetUri)('matrix-asset://instance-identifier/123')).toBe(true);
10
+ });
11
+ it('different matrix identifiers', () => {
12
+ expect((0, matrixAssetValidator_1.isMatrixAssetUri)('matrix-asset://MATRIX-IDENTIFIER.STRANGE-NAME.org/123')).toBe(true);
13
+ expect((0, matrixAssetValidator_1.isMatrixAssetUri)('matrix-asset://matrix-identifier.STRANGE-NAME.org/123')).toBe(true);
14
+ });
15
+ it(' with different asset ids', () => {
16
+ expect((0, matrixAssetValidator_1.isMatrixAssetUri)('matrix-asset://matrix.org/123/')).toBe(true);
17
+ expect((0, matrixAssetValidator_1.isMatrixAssetUri)('matrix-asset://matrix.org/ASDFG1473189')).toBe(true);
18
+ expect((0, matrixAssetValidator_1.isMatrixAssetUri)('matrix-asset://matrix.org/1-2-3-a-3/456/')).toBe(true);
19
+ expect((0, matrixAssetValidator_1.isMatrixAssetUri)('matrix-asset://matrix.org/123/456/789')).toBe(true);
20
+ });
21
+ });
22
+ describe('should return false for invalid matrix asset uri', () => {
23
+ it('given incorrect type number', () => {
24
+ expect((0, matrixAssetValidator_1.isMatrixAssetUri)(123)).toBe(false);
25
+ });
26
+ it('given incorrect type object', () => {
27
+ expect((0, matrixAssetValidator_1.isMatrixAssetUri)({ test: 'invalid' })).toBe(false);
28
+ });
29
+ it('given incorrect value undefined', () => {
30
+ expect((0, matrixAssetValidator_1.isMatrixAssetUri)(undefined)).toBe(false);
31
+ });
32
+ it('when the scheme is incorrect', () => {
33
+ expect((0, matrixAssetValidator_1.isMatrixAssetUri)('invalid://matrix.org')).toBe(false);
34
+ });
35
+ it('when missing the asset id', () => {
36
+ expect((0, matrixAssetValidator_1.isMatrixAssetUri)('matrix-asset://matrix.org/')).toBe(false);
37
+ });
38
+ it('when missing the asset path', () => {
39
+ expect((0, matrixAssetValidator_1.isMatrixAssetUri)('matrix-asset:///123')).toBe(false);
40
+ });
41
+ });
42
+ });
43
+ //# sourceMappingURL=matrixAssetValidator.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrixAssetValidator.spec.js","sourceRoot":"","sources":["../../../src/validators/utils/matrixAss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/index.js",
6
6
  "scripts": {
@@ -30,5 +30,5 @@
30
30
  "json-schema-library": "7.4.5",
31
31
  "ts-brand": "0.0.2"
32
32
  },
33
- "gitHead": "6fbf11b4507a80f8ef6dd09b489bbebf2bcfbac1"
33
+ "gitHead": "e4aaed9499051ca99e7f3e3bab76b3ffc1fd0f4b"
34
34
  }