@twin.org/auditable-item-graph-service 0.0.3-next.2 → 0.0.3-next.21
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 +609 -44
- package/dist/es/auditableItemGraphRoutes.js.map +1 -1
- package/dist/es/auditableItemGraphService.js +714 -159
- 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 +8 -0
- package/dist/es/entities/auditableItemGraphVertex.js.map +1 -1
- package/dist/es/models/IAuditableItemGraphServiceConstructorOptions.js.map +1 -1
- package/dist/types/auditableItemGraphRoutes.d.ts +42 -2
- package/dist/types/auditableItemGraphService.d.ts +81 -55
- 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 +4 -0
- package/dist/types/models/IAuditableItemGraphServiceConstructorOptions.d.ts +4 -0
- package/docs/changelog.md +370 -71
- package/docs/examples.md +241 -1
- package/docs/open-api/spec.json +1218 -220
- 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 +221 -59
- package/docs/reference/classes/AuditableItemGraphVertex.md +26 -18
- package/docs/reference/functions/auditableItemGraphChangesetGet.md +31 -0
- package/docs/reference/functions/auditableItemGraphChangesetList.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 +5 -0
- package/docs/reference/interfaces/IAuditableItemGraphServiceConstructorOptions.md +18 -10
- package/locales/en.json +7 -2
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ICreatedResponse, type IHttpRequestContext, type INoContentResponse, type IRestRoute, type ITag } from "@twin.org/api-models";
|
|
2
|
-
import { type IAuditableItemGraphCreateRequest, type IAuditableItemGraphGetRequest, type IAuditableItemGraphGetResponse, type IAuditableItemGraphListRequest, type IAuditableItemGraphListResponse, type IAuditableItemGraphUpdateRequest } from "@twin.org/auditable-item-graph-models";
|
|
2
|
+
import { type IAuditableItemGraphChangesetGetRequest, type IAuditableItemGraphChangesetGetResponse, type IAuditableItemGraphChangesetListRequest, type IAuditableItemGraphChangesetListResponse, type IAuditableItemGraphCreateRequest, type IAuditableItemGraphGetRequest, type IAuditableItemGraphGetResponse, type IAuditableItemGraphListRequest, type IAuditableItemGraphListResponse, type IAuditableItemGraphUpdateRequest, type IAuditableItemGraphUpdatePartialRequest, type IAuditableItemGraphVersionGetRequest, type IAuditableItemGraphVersionGetResponse, type IAuditableItemGraphVersionListRequest, type IAuditableItemGraphVersionListResponse } from "@twin.org/auditable-item-graph-models";
|
|
3
3
|
/**
|
|
4
4
|
* The tag to associate with the routes.
|
|
5
5
|
*/
|
|
@@ -28,13 +28,37 @@ export declare function auditableItemGraphCreate(httpRequestContext: IHttpReques
|
|
|
28
28
|
*/
|
|
29
29
|
export declare function auditableItemGraphGet(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemGraphGetRequest): Promise<IAuditableItemGraphGetResponse>;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Get the graph vertex changeset list.
|
|
32
|
+
* @param httpRequestContext The request context for the API.
|
|
33
|
+
* @param componentName The name of the component to use in the routes.
|
|
34
|
+
* @param request The request.
|
|
35
|
+
* @returns The response object with additional http response properties.
|
|
36
|
+
*/
|
|
37
|
+
export declare function auditableItemGraphChangesetList(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemGraphChangesetListRequest): Promise<IAuditableItemGraphChangesetListResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* Get the graph vertex changeset.
|
|
40
|
+
* @param httpRequestContext The request context for the API.
|
|
41
|
+
* @param componentName The name of the component to use in the routes.
|
|
42
|
+
* @param request The request.
|
|
43
|
+
* @returns The response object with additional http response properties.
|
|
44
|
+
*/
|
|
45
|
+
export declare function auditableItemGraphChangesetGet(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemGraphChangesetGetRequest): Promise<IAuditableItemGraphChangesetGetResponse>;
|
|
46
|
+
/**
|
|
47
|
+
* Update the graph vertex (PUT — full replacement of vertex state).
|
|
32
48
|
* @param httpRequestContext The request context for the API.
|
|
33
49
|
* @param componentName The name of the component to use in the routes.
|
|
34
50
|
* @param request The request.
|
|
35
51
|
* @returns The response object with additional http response properties.
|
|
36
52
|
*/
|
|
37
53
|
export declare function auditableItemGraphUpdate(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemGraphUpdateRequest): Promise<INoContentResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* Partially update the graph vertex (PATCH — optional scalars; list fields use `{ add, remove }`).
|
|
56
|
+
* @param httpRequestContext The request context for the API.
|
|
57
|
+
* @param componentName The name of the component to use in the routes.
|
|
58
|
+
* @param request The request.
|
|
59
|
+
* @returns The response object with additional http response properties.
|
|
60
|
+
*/
|
|
61
|
+
export declare function auditableItemGraphUpdatePartial(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemGraphUpdatePartialRequest): Promise<INoContentResponse>;
|
|
38
62
|
/**
|
|
39
63
|
* Query the graph vertices.
|
|
40
64
|
* @param httpRequestContext The request context for the API.
|
|
@@ -43,3 +67,19 @@ export declare function auditableItemGraphUpdate(httpRequestContext: IHttpReques
|
|
|
43
67
|
* @returns The response object with additional http response properties.
|
|
44
68
|
*/
|
|
45
69
|
export declare function auditableItemGraphList(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemGraphListRequest): Promise<IAuditableItemGraphListResponse>;
|
|
70
|
+
/**
|
|
71
|
+
* Get the graph vertex at a specific version.
|
|
72
|
+
* @param httpRequestContext The request context for the API.
|
|
73
|
+
* @param componentName The name of the component to use in the routes.
|
|
74
|
+
* @param request The request.
|
|
75
|
+
* @returns The response object with additional http response properties.
|
|
76
|
+
*/
|
|
77
|
+
export declare function auditableItemGraphVersionGet(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemGraphVersionGetRequest): Promise<IAuditableItemGraphVersionGetResponse>;
|
|
78
|
+
/**
|
|
79
|
+
* Get all versions of a graph vertex.
|
|
80
|
+
* @param httpRequestContext The request context for the API.
|
|
81
|
+
* @param componentName The name of the component to use in the routes.
|
|
82
|
+
* @param request The request.
|
|
83
|
+
* @returns The response object with additional http response properties.
|
|
84
|
+
*/
|
|
85
|
+
export declare function auditableItemGraphVersionList(httpRequestContext: IHttpRequestContext, componentName: string, request: IAuditableItemGraphVersionListRequest): Promise<IAuditableItemGraphVersionListResponse>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { VerifyDepth, type IAuditableItemGraphComponent, type IAuditableItemGraphVertex, type IAuditableItemGraphVertexList } from "@twin.org/auditable-item-graph-models";
|
|
2
|
-
import { type IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
1
|
+
import { VerifyDepth, type IAuditableItemGraphChangeset, type IAuditableItemGraphChangesetList, type IAuditableItemGraphComponent, type IAuditableItemGraphPartialVertex, type IAuditableItemGraphVertex, type IAuditableItemGraphVertexList, type IAuditableItemGraphVertexVersionList } from "@twin.org/auditable-item-graph-models";
|
|
3
2
|
import { SortDirection, type IComparator } from "@twin.org/entity";
|
|
4
3
|
import type { IAuditableItemGraphServiceConstructorOptions } from "./models/IAuditableItemGraphServiceConstructorOptions.js";
|
|
5
4
|
/**
|
|
@@ -28,6 +27,10 @@ export declare class AuditableItemGraphService implements IAuditableItemGraphCom
|
|
|
28
27
|
* @returns The class name of the component.
|
|
29
28
|
*/
|
|
30
29
|
className(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Register all AIG metrics with the telemetry component.
|
|
32
|
+
*/
|
|
33
|
+
start(): Promise<void>;
|
|
31
34
|
/**
|
|
32
35
|
* Create a new graph vertex.
|
|
33
36
|
* @param vertex The vertex to create.
|
|
@@ -37,82 +40,96 @@ export declare class AuditableItemGraphService implements IAuditableItemGraphCom
|
|
|
37
40
|
* @param vertex.edges The edges connected to the vertex.
|
|
38
41
|
* @returns The id of the new graph item.
|
|
39
42
|
*/
|
|
40
|
-
create(vertex:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
annotationObject?: IJsonLdNodeObject;
|
|
56
|
-
}[];
|
|
57
|
-
}): Promise<string>;
|
|
43
|
+
create(vertex: Omit<IAuditableItemGraphVertex, "id">): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Update a graph vertex (PUT — full replacement of vertex state).
|
|
46
|
+
* Concurrent updates for the same vertex are serialized via `Mutex` on the vertex id.
|
|
47
|
+
* @param vertex The vertex to update.
|
|
48
|
+
* @returns Nothing.
|
|
49
|
+
*/
|
|
50
|
+
update(vertex: IAuditableItemGraphVertex): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Partially update a graph vertex (PATCH — explicit list patches; only defined properties applied).
|
|
53
|
+
* Serialized with `update` via `Mutex` on the same vertex id within this instance.
|
|
54
|
+
* @param partial The partial vertex update.
|
|
55
|
+
* @returns Nothing.
|
|
56
|
+
*/
|
|
57
|
+
updatePartial(partial: IAuditableItemGraphPartialVertex): Promise<void>;
|
|
58
58
|
/**
|
|
59
59
|
* Get a graph vertex.
|
|
60
60
|
* @param id The id of the vertex to get.
|
|
61
61
|
* @param options Additional options for the get operation.
|
|
62
62
|
* @param options.includeDeleted Whether to include deleted/updated aliases, resource, edges, defaults to false.
|
|
63
|
-
* @param options.includeChangesets Whether to include the changesets of the vertex, defaults to false.
|
|
64
63
|
* @param options.verifySignatureDepth How many signatures to verify, defaults to "none".
|
|
65
64
|
* @returns The vertex if found.
|
|
66
65
|
* @throws NotFoundError if the vertex is not found.
|
|
67
66
|
*/
|
|
68
67
|
get(id: string, options?: {
|
|
69
68
|
includeDeleted?: boolean;
|
|
70
|
-
includeChangesets?: boolean;
|
|
71
69
|
verifySignatureDepth?: VerifyDepth;
|
|
72
70
|
}): Promise<IAuditableItemGraphVertex>;
|
|
73
71
|
/**
|
|
74
|
-
*
|
|
75
|
-
* @param
|
|
76
|
-
* @param
|
|
77
|
-
* @param
|
|
78
|
-
* @param
|
|
79
|
-
* @param
|
|
80
|
-
* @
|
|
81
|
-
* @
|
|
72
|
+
* Get a graph vertex changeset list.
|
|
73
|
+
* @param id The id of the vertex to get.
|
|
74
|
+
* @param cursor The optional cursor to get next chunk.
|
|
75
|
+
* @param limit Limit the number of entities to return.
|
|
76
|
+
* @param options Additional options for the get operation.
|
|
77
|
+
* @param options.verifySignatureDepth How many signatures to verify, defaults to "none".
|
|
78
|
+
* @returns The vertex if found.
|
|
79
|
+
* @throws NotFoundError if the vertex is not found.
|
|
82
80
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
resources?: {
|
|
92
|
-
id?: string;
|
|
93
|
-
resourceObject?: IJsonLdNodeObject;
|
|
94
|
-
}[];
|
|
95
|
-
edges?: {
|
|
96
|
-
id?: string;
|
|
97
|
-
targetId: string;
|
|
98
|
-
edgeRelationships: string[];
|
|
99
|
-
annotationObject?: IJsonLdNodeObject;
|
|
100
|
-
}[];
|
|
101
|
-
}): Promise<void>;
|
|
102
|
-
/**
|
|
103
|
-
* Remove the verifiable storage for an item.
|
|
81
|
+
getChangesets(id: string, cursor?: string, limit?: number, options?: {
|
|
82
|
+
verifySignatureDepth?: VerifyDepth;
|
|
83
|
+
}): Promise<{
|
|
84
|
+
changesets: IAuditableItemGraphChangesetList;
|
|
85
|
+
cursor?: string;
|
|
86
|
+
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Get a graph vertex changeset.
|
|
104
89
|
* @param id The id of the vertex to get.
|
|
90
|
+
* @param options Additional options for the get operation.
|
|
91
|
+
* @param options.verifySignatureDepth How many signatures to verify, defaults to "none".
|
|
92
|
+
* @returns The vertex if found.
|
|
93
|
+
* @throws NotFoundError if the vertex is not found.
|
|
94
|
+
*/
|
|
95
|
+
getChangeset(id: string, options?: {
|
|
96
|
+
verifySignatureDepth?: VerifyDepth;
|
|
97
|
+
}): Promise<IAuditableItemGraphChangeset>;
|
|
98
|
+
/**
|
|
99
|
+
* Get a graph vertex at a specific version.
|
|
100
|
+
* @param id The id of the vertex.
|
|
101
|
+
* @param version The version number to retrieve.
|
|
102
|
+
* @returns The vertex reconstructed at that version.
|
|
103
|
+
* @throws NotFoundError if the vertex or version is not found.
|
|
104
|
+
*/
|
|
105
|
+
getVersion(id: string, version: number): Promise<IAuditableItemGraphVertex>;
|
|
106
|
+
/**
|
|
107
|
+
* Get all versions of a graph vertex.
|
|
108
|
+
* @param id The id of the vertex.
|
|
109
|
+
* @param options Additional options for the operation.
|
|
110
|
+
* @param options.after Only return versions created after this ISO 8601 timestamp (exclusive).
|
|
111
|
+
* @param options.before Only return versions created before this ISO 8601 timestamp (exclusive).
|
|
112
|
+
* @returns The list of vertex versions.
|
|
113
|
+
* @throws NotFoundError if the vertex is not found.
|
|
114
|
+
*/
|
|
115
|
+
getVersions(id: string, options?: {
|
|
116
|
+
after?: string;
|
|
117
|
+
before?: string;
|
|
118
|
+
}): Promise<IAuditableItemGraphVertexVersionList>;
|
|
119
|
+
/**
|
|
120
|
+
* Remove the proof for an item.
|
|
121
|
+
* @param id The id of the vertex to remove the proof from.
|
|
105
122
|
* @returns Nothing.
|
|
106
123
|
* @throws NotFoundError if the vertex is not found.
|
|
107
124
|
*/
|
|
108
|
-
|
|
125
|
+
removeProof(id: string): Promise<void>;
|
|
109
126
|
/**
|
|
110
127
|
* Query the graph for vertices.
|
|
111
128
|
* @param options The query options.
|
|
112
129
|
* @param options.id The optional id to look for.
|
|
113
130
|
* @param options.idMode Look in id, alias or both, defaults to both.
|
|
114
131
|
* @param options.idExact Find only exact matches, default to false meaning partial matching.
|
|
115
|
-
* @param options.
|
|
132
|
+
* @param options.resourceTypes Include vertices with specific resource types.
|
|
116
133
|
* @param conditions Conditions to use in the query.
|
|
117
134
|
* @param orderBy The order for the results, defaults to created.
|
|
118
135
|
* @param orderByDirection The direction for the order, defaults to desc.
|
|
@@ -125,8 +142,17 @@ export declare class AuditableItemGraphService implements IAuditableItemGraphCom
|
|
|
125
142
|
id?: string;
|
|
126
143
|
idMode?: "id" | "alias" | "both";
|
|
127
144
|
idExact?: boolean;
|
|
128
|
-
|
|
129
|
-
}, conditions?: IComparator[], orderBy?: keyof Pick<IAuditableItemGraphVertex, "dateCreated" | "dateModified">, orderByDirection?: SortDirection, properties?: (keyof IAuditableItemGraphVertex)[], cursor?: string, limit?: number): Promise<
|
|
145
|
+
resourceTypes?: string[];
|
|
146
|
+
}, conditions?: IComparator[], orderBy?: keyof Pick<IAuditableItemGraphVertex, "dateCreated" | "dateModified">, orderByDirection?: SortDirection, properties?: (keyof IAuditableItemGraphVertex)[], cursor?: string, limit?: number): Promise<{
|
|
147
|
+
entries: IAuditableItemGraphVertexList;
|
|
148
|
+
cursor?: string;
|
|
149
|
+
}>;
|
|
150
|
+
/**
|
|
151
|
+
* Verify the signature of a changeset and add the verification result to the changeset JSON-LD.
|
|
152
|
+
* @param storedChangeset The changeset to verify.
|
|
153
|
+
* @returns Whether the changeset is verified.
|
|
154
|
+
*/
|
|
155
|
+
private verifyChangesetSignature;
|
|
130
156
|
/**
|
|
131
157
|
* Get the resource id from a resource object.
|
|
132
158
|
* @param resource The resource.
|
|
@@ -27,4 +27,8 @@ export declare class AuditableItemGraphAlias {
|
|
|
27
27
|
* Object to associate with the alias as JSON-LD.
|
|
28
28
|
*/
|
|
29
29
|
annotationObject?: IJsonLdNodeObject;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the alias should be unique across the graph, meaning that no other vertex can have the same alias. Defaults to false.
|
|
32
|
+
*/
|
|
33
|
+
unique?: boolean;
|
|
30
34
|
}
|
|
@@ -27,4 +27,8 @@ export declare class AuditableItemGraphChangeset {
|
|
|
27
27
|
* The immutable proof id which contains the signature for this changeset.
|
|
28
28
|
*/
|
|
29
29
|
proofId?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The version number of the vertex after this changeset was applied.
|
|
32
|
+
*/
|
|
33
|
+
version?: number;
|
|
30
34
|
}
|
|
@@ -22,6 +22,10 @@ export interface IAuditableItemGraphServiceConstructorOptions {
|
|
|
22
22
|
* The event bus component type, defaults to no event bus.
|
|
23
23
|
*/
|
|
24
24
|
eventBusComponentType?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The component type for the optional telemetry component used for event metrics, defaults to no telemetry.
|
|
27
|
+
*/
|
|
28
|
+
telemetryComponentType?: string;
|
|
25
29
|
/**
|
|
26
30
|
* The configuration for the service.
|
|
27
31
|
*/
|