@twin.org/auditable-item-graph-service 0.0.3-next.8 → 0.9.0-next.2
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/README.md +3 -1
- package/dist/es/auditableItemGraphRoutes.js +309 -8
- package/dist/es/auditableItemGraphRoutes.js.map +1 -1
- package/dist/es/auditableItemGraphService.js +576 -95
- package/dist/es/auditableItemGraphService.js.map +1 -1
- package/dist/es/entities/auditableItemGraphAlias.js +8 -0
- package/dist/es/entities/auditableItemGraphAlias.js.map +1 -1
- package/dist/es/entities/auditableItemGraphChangeset.js +8 -0
- package/dist/es/entities/auditableItemGraphChangeset.js.map +1 -1
- package/dist/es/entities/auditableItemGraphVertex.js +9 -1
- package/dist/es/entities/auditableItemGraphVertex.js.map +1 -1
- package/dist/es/models/IAuditableItemGraphServiceConfig.js.map +1 -1
- package/dist/es/models/IAuditableItemGraphServiceConstructorOptions.js.map +1 -1
- package/dist/es/models/IAuditableItemGraphServiceContext.js +2 -0
- package/dist/es/models/IAuditableItemGraphServiceContext.js.map +1 -1
- package/dist/es/restEntryPoints.js +3 -0
- package/dist/es/restEntryPoints.js.map +1 -1
- package/dist/types/auditableItemGraphRoutes.d.ts +34 -2
- package/dist/types/auditableItemGraphService.d.ts +50 -71
- package/dist/types/entities/auditableItemGraphAlias.d.ts +4 -0
- package/dist/types/entities/auditableItemGraphChangeset.d.ts +4 -0
- package/dist/types/entities/auditableItemGraphVertex.d.ts +5 -1
- package/dist/types/models/IAuditableItemGraphServiceConfig.d.ts +4 -0
- package/dist/types/models/IAuditableItemGraphServiceConstructorOptions.d.ts +4 -0
- package/dist/types/models/IAuditableItemGraphServiceContext.d.ts +6 -3
- package/dist/types/restEntryPoints.d.ts +3 -0
- package/docs/changelog.md +437 -84
- package/docs/examples.md +241 -1
- package/docs/open-api/spec.json +845 -268
- package/docs/reference/classes/AuditableItemGraphAlias.md +18 -10
- package/docs/reference/classes/AuditableItemGraphChangeset.md +16 -8
- package/docs/reference/classes/AuditableItemGraphEdge.md +10 -10
- package/docs/reference/classes/AuditableItemGraphPatch.md +6 -6
- package/docs/reference/classes/AuditableItemGraphResource.md +9 -9
- package/docs/reference/classes/AuditableItemGraphService.md +135 -57
- package/docs/reference/classes/AuditableItemGraphVertex.md +26 -18
- package/docs/reference/functions/auditableItemGraphRemoveProof.md +31 -0
- package/docs/reference/functions/auditableItemGraphUpdate.md +1 -1
- package/docs/reference/functions/auditableItemGraphUpdatePartial.md +31 -0
- package/docs/reference/functions/auditableItemGraphVersionGet.md +31 -0
- package/docs/reference/functions/auditableItemGraphVersionList.md +31 -0
- package/docs/reference/index.md +4 -0
- package/docs/reference/interfaces/IAuditableItemGraphServiceConfig.md +8 -0
- package/docs/reference/interfaces/IAuditableItemGraphServiceConstructorOptions.md +18 -10
- package/docs/reference/variables/restEntryPoints.md +2 -0
- package/locales/en.json +6 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# TWIN Auditable Item Graph Service
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package delivers the core graph operations, including create, update, query, and historical change retrieval with verifiable audit data.
|
|
4
|
+
|
|
5
|
+
It also exposes route definitions so applications can host the service over HTTP while keeping behaviour aligned with shared contracts.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Copyright 2024 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
-
import { HttpParameterHelper } from "@twin.org/api-models";
|
|
3
|
+
import { HttpContextIdKeys, HttpParameterHelper, HttpUrlHelper } from "@twin.org/api-models";
|
|
4
4
|
import { AuditableItemGraphContexts, AuditableItemGraphTypes } from "@twin.org/auditable-item-graph-models";
|
|
5
|
+
import { ContextIdStore } from "@twin.org/context";
|
|
5
6
|
import { Coerce, ComponentFactory, Guards, Is } from "@twin.org/core";
|
|
6
7
|
import { SchemaOrgContexts, SchemaOrgTypes } from "@twin.org/standards-schema-org";
|
|
7
8
|
import { HeaderHelper, HeaderTypes, HttpStatusCode, MimeTypes } from "@twin.org/web";
|
|
@@ -39,6 +40,11 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
39
40
|
id: "auditableItemGraphCreateRequestExample",
|
|
40
41
|
request: {
|
|
41
42
|
body: {
|
|
43
|
+
"@context": [
|
|
44
|
+
AuditableItemGraphContexts.Context,
|
|
45
|
+
AuditableItemGraphContexts.ContextCommon
|
|
46
|
+
],
|
|
47
|
+
type: AuditableItemGraphTypes.Vertex,
|
|
42
48
|
annotationObject: {
|
|
43
49
|
"@context": "https://schema.org",
|
|
44
50
|
"@type": "Note",
|
|
@@ -46,6 +52,7 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
46
52
|
},
|
|
47
53
|
aliases: [
|
|
48
54
|
{
|
|
55
|
+
type: AuditableItemGraphTypes.Alias,
|
|
49
56
|
id: "bar456",
|
|
50
57
|
annotationObject: {
|
|
51
58
|
"@context": "https://schema.org",
|
|
@@ -54,6 +61,7 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
54
61
|
}
|
|
55
62
|
},
|
|
56
63
|
{
|
|
64
|
+
type: AuditableItemGraphTypes.Alias,
|
|
57
65
|
id: "foo321",
|
|
58
66
|
annotationObject: {
|
|
59
67
|
"@context": "https://schema.org",
|
|
@@ -64,6 +72,7 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
64
72
|
],
|
|
65
73
|
resources: [
|
|
66
74
|
{
|
|
75
|
+
type: AuditableItemGraphTypes.Resource,
|
|
67
76
|
id: "resource1",
|
|
68
77
|
resourceObject: {
|
|
69
78
|
"@context": "https://schema.org",
|
|
@@ -72,6 +81,7 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
72
81
|
}
|
|
73
82
|
},
|
|
74
83
|
{
|
|
84
|
+
type: AuditableItemGraphTypes.Resource,
|
|
75
85
|
id: "resource2",
|
|
76
86
|
resourceObject: {
|
|
77
87
|
"@context": "https://schema.org",
|
|
@@ -82,6 +92,7 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
82
92
|
],
|
|
83
93
|
edges: [
|
|
84
94
|
{
|
|
95
|
+
type: AuditableItemGraphTypes.Edge,
|
|
85
96
|
targetId: "aig:1234567890",
|
|
86
97
|
edgeRelationships: ["frenemy"],
|
|
87
98
|
annotationObject: {
|
|
@@ -91,6 +102,7 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
91
102
|
}
|
|
92
103
|
},
|
|
93
104
|
{
|
|
105
|
+
type: AuditableItemGraphTypes.Edge,
|
|
94
106
|
targetId: "aig:45678901234",
|
|
95
107
|
edgeRelationships: ["end"],
|
|
96
108
|
annotationObject: {
|
|
@@ -492,6 +504,114 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
492
504
|
}
|
|
493
505
|
]
|
|
494
506
|
};
|
|
507
|
+
const getVersionRoute = {
|
|
508
|
+
operationId: "auditableItemGraphVersionGet",
|
|
509
|
+
summary: "Get a graph vertex at a specific version",
|
|
510
|
+
tag: tagsAuditableItemGraph[0].name,
|
|
511
|
+
method: "GET",
|
|
512
|
+
path: `${baseRouteName}/:id/versions/:version`,
|
|
513
|
+
handler: async (httpRequestContext, request) => auditableItemGraphVersionGet(httpRequestContext, componentName, request),
|
|
514
|
+
requestType: {
|
|
515
|
+
type: "IAuditableItemGraphVersionGetRequest",
|
|
516
|
+
examples: [
|
|
517
|
+
{
|
|
518
|
+
id: "auditableItemGraphVersionGetRequestExample",
|
|
519
|
+
request: {
|
|
520
|
+
headers: {
|
|
521
|
+
[HeaderTypes.Accept]: MimeTypes.Json
|
|
522
|
+
},
|
|
523
|
+
pathParams: {
|
|
524
|
+
id: "aig:1234567890",
|
|
525
|
+
version: "1"
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
]
|
|
530
|
+
},
|
|
531
|
+
responseType: [
|
|
532
|
+
{
|
|
533
|
+
type: "IAuditableItemGraphVersionGetResponse",
|
|
534
|
+
examples: [
|
|
535
|
+
{
|
|
536
|
+
id: "auditableItemGraphVersionGetResponseExample",
|
|
537
|
+
response: {
|
|
538
|
+
body: {
|
|
539
|
+
"@context": [
|
|
540
|
+
AuditableItemGraphContexts.Context,
|
|
541
|
+
AuditableItemGraphContexts.ContextCommon,
|
|
542
|
+
SchemaOrgContexts.Context
|
|
543
|
+
],
|
|
544
|
+
type: AuditableItemGraphTypes.Vertex,
|
|
545
|
+
id: "aig:1234567890",
|
|
546
|
+
dateCreated: "2024-08-22T11:55:16.271Z",
|
|
547
|
+
version: 1
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
]
|
|
552
|
+
}
|
|
553
|
+
]
|
|
554
|
+
};
|
|
555
|
+
const getVersionListRoute = {
|
|
556
|
+
operationId: "auditableItemGraphVersionList",
|
|
557
|
+
summary: "Get all versions of a graph vertex",
|
|
558
|
+
tag: tagsAuditableItemGraph[0].name,
|
|
559
|
+
method: "GET",
|
|
560
|
+
path: `${baseRouteName}/:id/versions`,
|
|
561
|
+
handler: async (httpRequestContext, request) => auditableItemGraphVersionList(httpRequestContext, componentName, request),
|
|
562
|
+
requestType: {
|
|
563
|
+
type: "IAuditableItemGraphVersionListRequest",
|
|
564
|
+
examples: [
|
|
565
|
+
{
|
|
566
|
+
id: "auditableItemGraphVersionListRequestExample",
|
|
567
|
+
request: {
|
|
568
|
+
headers: {
|
|
569
|
+
[HeaderTypes.Accept]: MimeTypes.Json
|
|
570
|
+
},
|
|
571
|
+
pathParams: {
|
|
572
|
+
id: "aig:1234567890"
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
id: "auditableItemGraphVersionListAfterRequestExample",
|
|
578
|
+
request: {
|
|
579
|
+
pathParams: {
|
|
580
|
+
id: "aig:1234567890"
|
|
581
|
+
},
|
|
582
|
+
query: {
|
|
583
|
+
after: "2026-04-03T12:00:00Z"
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
]
|
|
588
|
+
},
|
|
589
|
+
responseType: [
|
|
590
|
+
{
|
|
591
|
+
type: "IAuditableItemGraphVersionListResponse",
|
|
592
|
+
examples: [
|
|
593
|
+
{
|
|
594
|
+
id: "auditableItemGraphVersionListResponseExample",
|
|
595
|
+
response: {
|
|
596
|
+
body: {
|
|
597
|
+
"@context": [
|
|
598
|
+
SchemaOrgContexts.Context,
|
|
599
|
+
AuditableItemGraphContexts.Context,
|
|
600
|
+
AuditableItemGraphContexts.ContextCommon
|
|
601
|
+
],
|
|
602
|
+
type: [SchemaOrgTypes.ItemList, AuditableItemGraphTypes.VertexVersionList],
|
|
603
|
+
[SchemaOrgTypes.ItemListElement]: [
|
|
604
|
+
{ version: 0, dateCreated: "2024-08-22T11:55:16.271Z" },
|
|
605
|
+
{ version: 1, dateCreated: "2024-08-22T11:56:00.000Z" },
|
|
606
|
+
{ version: 2, dateCreated: "2024-08-22T11:57:00.000Z" }
|
|
607
|
+
]
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
]
|
|
612
|
+
}
|
|
613
|
+
]
|
|
614
|
+
};
|
|
495
615
|
const updateRoute = {
|
|
496
616
|
operationId: "auditableItemGraphUpdate",
|
|
497
617
|
summary: "Update a graph vertex",
|
|
@@ -509,6 +629,11 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
509
629
|
id: "aig:1234567890"
|
|
510
630
|
},
|
|
511
631
|
body: {
|
|
632
|
+
"@context": [
|
|
633
|
+
AuditableItemGraphContexts.Context,
|
|
634
|
+
AuditableItemGraphContexts.ContextCommon
|
|
635
|
+
],
|
|
636
|
+
type: AuditableItemGraphTypes.Vertex,
|
|
512
637
|
annotationObject: {
|
|
513
638
|
"@context": "https://schema.org",
|
|
514
639
|
"@type": "Note",
|
|
@@ -516,6 +641,7 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
516
641
|
},
|
|
517
642
|
aliases: [
|
|
518
643
|
{
|
|
644
|
+
type: AuditableItemGraphTypes.Alias,
|
|
519
645
|
id: "bar456",
|
|
520
646
|
annotationObject: {
|
|
521
647
|
"@context": "https://schema.org",
|
|
@@ -524,6 +650,7 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
524
650
|
}
|
|
525
651
|
},
|
|
526
652
|
{
|
|
653
|
+
type: AuditableItemGraphTypes.Alias,
|
|
527
654
|
id: "foo321",
|
|
528
655
|
annotationObject: {
|
|
529
656
|
"@context": "https://schema.org",
|
|
@@ -534,6 +661,7 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
534
661
|
],
|
|
535
662
|
resources: [
|
|
536
663
|
{
|
|
664
|
+
type: AuditableItemGraphTypes.Resource,
|
|
537
665
|
id: "resource1",
|
|
538
666
|
resourceObject: {
|
|
539
667
|
"@context": "https://schema.org",
|
|
@@ -542,6 +670,7 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
542
670
|
}
|
|
543
671
|
},
|
|
544
672
|
{
|
|
673
|
+
type: AuditableItemGraphTypes.Resource,
|
|
545
674
|
id: "resource2",
|
|
546
675
|
resourceObject: {
|
|
547
676
|
"@context": "https://schema.org",
|
|
@@ -552,6 +681,7 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
552
681
|
],
|
|
553
682
|
edges: [
|
|
554
683
|
{
|
|
684
|
+
type: AuditableItemGraphTypes.Edge,
|
|
555
685
|
id: "edge1",
|
|
556
686
|
targetId: "aig:1234567890",
|
|
557
687
|
edgeRelationships: ["frenemy"],
|
|
@@ -562,6 +692,7 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
562
692
|
}
|
|
563
693
|
},
|
|
564
694
|
{
|
|
695
|
+
type: AuditableItemGraphTypes.Edge,
|
|
565
696
|
id: "edge2",
|
|
566
697
|
targetId: "aig:45678901234",
|
|
567
698
|
edgeRelationships: ["end"],
|
|
@@ -583,6 +714,47 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
583
714
|
}
|
|
584
715
|
]
|
|
585
716
|
};
|
|
717
|
+
const updatePartialRoute = {
|
|
718
|
+
operationId: "auditableItemGraphUpdatePartial",
|
|
719
|
+
summary: "Partially update a graph vertex",
|
|
720
|
+
tag: tagsAuditableItemGraph[0].name,
|
|
721
|
+
method: "PATCH",
|
|
722
|
+
path: `${baseRouteName}/:id`,
|
|
723
|
+
handler: async (httpRequestContext, request) => auditableItemGraphUpdatePartial(httpRequestContext, componentName, request),
|
|
724
|
+
requestType: {
|
|
725
|
+
type: "IAuditableItemGraphUpdatePartialRequest",
|
|
726
|
+
examples: [
|
|
727
|
+
{
|
|
728
|
+
id: "auditableItemGraphUpdatePartialRequestExample",
|
|
729
|
+
request: {
|
|
730
|
+
pathParams: {
|
|
731
|
+
id: "aig:1234567890"
|
|
732
|
+
},
|
|
733
|
+
body: {
|
|
734
|
+
"@context": [
|
|
735
|
+
AuditableItemGraphContexts.Context,
|
|
736
|
+
AuditableItemGraphContexts.ContextCommon
|
|
737
|
+
],
|
|
738
|
+
edgePatches: {
|
|
739
|
+
add: [
|
|
740
|
+
{
|
|
741
|
+
type: AuditableItemGraphTypes.Edge,
|
|
742
|
+
targetId: "aig:45678901234",
|
|
743
|
+
edgeRelationships: ["document"]
|
|
744
|
+
}
|
|
745
|
+
]
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
]
|
|
751
|
+
},
|
|
752
|
+
responseType: [
|
|
753
|
+
{
|
|
754
|
+
type: "INoContentResponse"
|
|
755
|
+
}
|
|
756
|
+
]
|
|
757
|
+
};
|
|
586
758
|
const listRoute = {
|
|
587
759
|
operationId: "auditableItemGraphList",
|
|
588
760
|
summary: "Query graph vertices by id or alias",
|
|
@@ -698,7 +870,52 @@ export function generateRestRoutesAuditableItemGraph(baseRouteName, componentNam
|
|
|
698
870
|
}
|
|
699
871
|
]
|
|
700
872
|
};
|
|
701
|
-
|
|
873
|
+
const removeProofRoute = {
|
|
874
|
+
operationId: "auditableItemGraphRemoveProof",
|
|
875
|
+
summary: "Remove the notarization proof from all changesets of a graph vertex",
|
|
876
|
+
tag: tagsAuditableItemGraph[0].name,
|
|
877
|
+
method: "DELETE",
|
|
878
|
+
path: `${baseRouteName}/:id/proof`,
|
|
879
|
+
handler: async (httpRequestContext, request) => auditableItemGraphRemoveProof(httpRequestContext, componentName, request),
|
|
880
|
+
requestType: {
|
|
881
|
+
type: "IAuditableItemGraphRemoveProofRequest",
|
|
882
|
+
examples: [
|
|
883
|
+
{
|
|
884
|
+
id: "auditableItemGraphRemoveProofRequestExample",
|
|
885
|
+
request: {
|
|
886
|
+
pathParams: {
|
|
887
|
+
id: "0101010101010101010101010101010101010101010101010101010101010101"
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
]
|
|
892
|
+
},
|
|
893
|
+
responseType: [
|
|
894
|
+
{
|
|
895
|
+
type: "INoContentResponse",
|
|
896
|
+
examples: [
|
|
897
|
+
{
|
|
898
|
+
id: "auditableItemGraphRemoveProofResponseExample",
|
|
899
|
+
response: {
|
|
900
|
+
statusCode: HttpStatusCode.noContent
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
]
|
|
904
|
+
}
|
|
905
|
+
]
|
|
906
|
+
};
|
|
907
|
+
return [
|
|
908
|
+
createRoute,
|
|
909
|
+
getRoute,
|
|
910
|
+
getVersionRoute,
|
|
911
|
+
getVersionListRoute,
|
|
912
|
+
getChangesetRoute,
|
|
913
|
+
getChangesetListRoute,
|
|
914
|
+
updateRoute,
|
|
915
|
+
updatePartialRoute,
|
|
916
|
+
listRoute,
|
|
917
|
+
removeProofRoute
|
|
918
|
+
];
|
|
702
919
|
}
|
|
703
920
|
/**
|
|
704
921
|
* Create the graph vertex.
|
|
@@ -762,9 +979,9 @@ export async function auditableItemGraphChangesetList(httpRequestContext, compon
|
|
|
762
979
|
const headers = {
|
|
763
980
|
[HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
|
|
764
981
|
};
|
|
765
|
-
const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
|
|
766
982
|
if (Is.stringValue(result.cursor)) {
|
|
767
|
-
|
|
983
|
+
const contextIds = await ContextIdStore.getContextIds();
|
|
984
|
+
headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(HttpUrlHelper.replaceOrigin(httpRequestContext.serverRequest.url, contextIds?.[HttpContextIdKeys.PublicOrigin]), { cursor: result.cursor }, "next");
|
|
768
985
|
}
|
|
769
986
|
return {
|
|
770
987
|
headers,
|
|
@@ -783,7 +1000,7 @@ export async function auditableItemGraphChangesetGet(httpRequestContext, compone
|
|
|
783
1000
|
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
784
1001
|
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
785
1002
|
const component = ComponentFactory.get(componentName);
|
|
786
|
-
const changesetUrn =
|
|
1003
|
+
const changesetUrn = `${request.pathParams.id}:changeset:${request.pathParams.changesetId}`;
|
|
787
1004
|
const result = await component.getChangeset(changesetUrn, {
|
|
788
1005
|
verifySignatureDepth: request.query?.verifySignatureDepth
|
|
789
1006
|
});
|
|
@@ -797,7 +1014,7 @@ export async function auditableItemGraphChangesetGet(httpRequestContext, compone
|
|
|
797
1014
|
};
|
|
798
1015
|
}
|
|
799
1016
|
/**
|
|
800
|
-
* Update the graph vertex.
|
|
1017
|
+
* Update the graph vertex (PUT — full replacement of vertex state).
|
|
801
1018
|
* @param httpRequestContext The request context for the API.
|
|
802
1019
|
* @param componentName The name of the component to use in the routes.
|
|
803
1020
|
* @param request The request.
|
|
@@ -814,6 +1031,24 @@ export async function auditableItemGraphUpdate(httpRequestContext, componentName
|
|
|
814
1031
|
statusCode: HttpStatusCode.noContent
|
|
815
1032
|
};
|
|
816
1033
|
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Partially update the graph vertex (PATCH — optional scalars; list fields use `{ add, remove }`).
|
|
1036
|
+
* @param httpRequestContext The request context for the API.
|
|
1037
|
+
* @param componentName The name of the component to use in the routes.
|
|
1038
|
+
* @param request The request.
|
|
1039
|
+
* @returns The response object with additional http response properties.
|
|
1040
|
+
*/
|
|
1041
|
+
export async function auditableItemGraphUpdatePartial(httpRequestContext, componentName, request) {
|
|
1042
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
1043
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
1044
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
1045
|
+
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
1046
|
+
const component = ComponentFactory.get(componentName);
|
|
1047
|
+
await component.updatePartial({ ...request.body, id: request.pathParams.id });
|
|
1048
|
+
return {
|
|
1049
|
+
statusCode: HttpStatusCode.noContent
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
817
1052
|
/**
|
|
818
1053
|
* Query the graph vertices.
|
|
819
1054
|
* @param httpRequestContext The request context for the API.
|
|
@@ -824,7 +1059,6 @@ export async function auditableItemGraphUpdate(httpRequestContext, componentName
|
|
|
824
1059
|
export async function auditableItemGraphList(httpRequestContext, componentName, request) {
|
|
825
1060
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
826
1061
|
Guards.object(ROUTES_SOURCE, "request.query", request.query);
|
|
827
|
-
const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
|
|
828
1062
|
const component = ComponentFactory.get(componentName);
|
|
829
1063
|
const result = await component.query({
|
|
830
1064
|
id: request.query?.id,
|
|
@@ -836,11 +1070,78 @@ export async function auditableItemGraphList(httpRequestContext, componentName,
|
|
|
836
1070
|
[HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
|
|
837
1071
|
};
|
|
838
1072
|
if (Is.stringValue(result.cursor)) {
|
|
839
|
-
|
|
1073
|
+
const contextIds = await ContextIdStore.getContextIds();
|
|
1074
|
+
headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(HttpUrlHelper.replaceOrigin(httpRequestContext.serverRequest.url, contextIds?.[HttpContextIdKeys.PublicOrigin]), { cursor: result.cursor }, "next");
|
|
840
1075
|
}
|
|
841
1076
|
return {
|
|
842
1077
|
headers,
|
|
843
1078
|
body: result.entries
|
|
844
1079
|
};
|
|
845
1080
|
}
|
|
1081
|
+
/**
|
|
1082
|
+
* Get the graph vertex at a specific version.
|
|
1083
|
+
* @param httpRequestContext The request context for the API.
|
|
1084
|
+
* @param componentName The name of the component to use in the routes.
|
|
1085
|
+
* @param request The request.
|
|
1086
|
+
* @returns The response object with additional http response properties.
|
|
1087
|
+
*/
|
|
1088
|
+
export async function auditableItemGraphVersionGet(httpRequestContext, componentName, request) {
|
|
1089
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
1090
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
1091
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
1092
|
+
const version = Coerce.integer(request.pathParams.version);
|
|
1093
|
+
Guards.integer(ROUTES_SOURCE, "request.pathParams.version", version);
|
|
1094
|
+
const component = ComponentFactory.get(componentName);
|
|
1095
|
+
const result = await component.getVersion(request.pathParams.id, version);
|
|
1096
|
+
return {
|
|
1097
|
+
headers: {
|
|
1098
|
+
[HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd
|
|
1099
|
+
? MimeTypes.JsonLd
|
|
1100
|
+
: MimeTypes.Json
|
|
1101
|
+
},
|
|
1102
|
+
body: result
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
/**
|
|
1106
|
+
* Remove the notarization proof from all changesets of a graph vertex.
|
|
1107
|
+
* @param httpRequestContext The request context for the API.
|
|
1108
|
+
* @param componentName The name of the component to use in the routes.
|
|
1109
|
+
* @param request The request.
|
|
1110
|
+
* @returns The response object with additional http response properties.
|
|
1111
|
+
*/
|
|
1112
|
+
export async function auditableItemGraphRemoveProof(httpRequestContext, componentName, request) {
|
|
1113
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
1114
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
1115
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
1116
|
+
const component = ComponentFactory.get(componentName);
|
|
1117
|
+
await component.removeProof(request.pathParams.id);
|
|
1118
|
+
return {
|
|
1119
|
+
statusCode: HttpStatusCode.noContent
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Get all versions of a graph vertex.
|
|
1124
|
+
* @param httpRequestContext The request context for the API.
|
|
1125
|
+
* @param componentName The name of the component to use in the routes.
|
|
1126
|
+
* @param request The request.
|
|
1127
|
+
* @returns The response object with additional http response properties.
|
|
1128
|
+
*/
|
|
1129
|
+
export async function auditableItemGraphVersionList(httpRequestContext, componentName, request) {
|
|
1130
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
1131
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
1132
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
1133
|
+
const component = ComponentFactory.get(componentName);
|
|
1134
|
+
const result = await component.getVersions(request.pathParams.id, {
|
|
1135
|
+
after: request.query?.after,
|
|
1136
|
+
before: request.query?.before
|
|
1137
|
+
});
|
|
1138
|
+
return {
|
|
1139
|
+
headers: {
|
|
1140
|
+
[HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd
|
|
1141
|
+
? MimeTypes.JsonLd
|
|
1142
|
+
: MimeTypes.Json
|
|
1143
|
+
},
|
|
1144
|
+
body: result
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
846
1147
|
//# sourceMappingURL=auditableItemGraphRoutes.js.map
|