Skip to content

Commit 834b240

Browse files
authored
feat: add expiration to helper text when adding a relationship (#80)
1 parent 3c5f722 commit 834b240

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/spicedb-common/parsing.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,79 +49,79 @@ describe("parsing relationships", () => {
4949
const relationship = "";
5050
expect(parseRelationshipWithError(relationship)).toEqual({
5151
errorMessage:
52-
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
52+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]][expiration:2025-09-11T16:57:57Z]`',
5353
});
5454
});
5555

5656
it("returns an error for a relationship missing an object", () => {
5757
const relationship = "somenamespace#somerel@someuser:foo";
5858
expect(parseRelationshipWithError(relationship)).toEqual({
5959
errorMessage:
60-
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
60+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]][expiration:2025-09-11T16:57:57Z]`',
6161
});
6262
});
6363

6464
it("returns an error for a relationship missing a subject", () => {
6565
const relationship = "somenamespace:something#somerel";
6666
expect(parseRelationshipWithError(relationship)).toEqual({
6767
errorMessage:
68-
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
68+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]][expiration:2025-09-11T16:57:57Z]`',
6969
});
7070
});
7171

7272
it("returns an error for a relationship with an invalid namespace", () => {
7373
const relationship = "a:something#somerel@user:foo";
7474
expect(parseRelationshipWithError(relationship)).toEqual({
7575
errorMessage:
76-
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
76+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]][expiration:2025-09-11T16:57:57Z]`',
7777
});
7878
});
7979

8080
it("returns an error for a relationship with an invalid object id", () => {
8181
const relationship = "document:some.thing#somerel@user:foo";
8282
expect(parseRelationshipWithError(relationship)).toEqual({
8383
errorMessage:
84-
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
84+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]][expiration:2025-09-11T16:57:57Z]`',
8585
});
8686
});
8787

8888
it("returns an error for a relationship with a wildcard resource id", () => {
8989
const relationship = "document:*#somerel@user:foo";
9090
expect(parseRelationshipWithError(relationship)).toEqual({
9191
errorMessage:
92-
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
92+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]][expiration:2025-09-11T16:57:57Z]`',
9393
});
9494
});
9595

9696
it("returns an error for a relationship with an invalid relation", () => {
9797
const relationship = "document:something#a@user:foo";
9898
expect(parseRelationshipWithError(relationship)).toEqual({
9999
errorMessage:
100-
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
100+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]][expiration:2025-09-11T16:57:57Z]`',
101101
});
102102
});
103103

104104
it("returns an error for a relationship with an invalid subject namespace", () => {
105105
const relationship = "document:something#somerel@a:foo";
106106
expect(parseRelationshipWithError(relationship)).toEqual({
107107
errorMessage:
108-
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
108+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]][expiration:2025-09-11T16:57:57Z]`',
109109
});
110110
});
111111

112112
it("returns an error for a relationship with an invalid subject object id", () => {
113113
const relationship = "document:something#somerel@user:some.thing";
114114
expect(parseRelationshipWithError(relationship)).toEqual({
115115
errorMessage:
116-
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
116+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]][expiration:2025-09-11T16:57:57Z]`',
117117
});
118118
});
119119

120120
it("returns an error for a relationship with an invalid subject relation", () => {
121121
const relationship = "document:something#somerel@user:someuser#a";
122122
expect(parseRelationshipWithError(relationship)).toEqual({
123123
errorMessage:
124-
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
124+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]][expiration:2025-09-11T16:57:57Z]`',
125125
});
126126
});
127127

src/spicedb-common/parsing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export const parseRelationshipWithError = (
100100
if (!parsed || !parsed.groups) {
101101
return {
102102
errorMessage:
103-
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]]`',
103+
'Relationship must be of the form `resourcetype:resourceid#relation@subjecttype:subjectid[caveatname:[{"key":"value"}]][expiration:2025-09-11T16:57:57Z]`',
104104
};
105105
}
106106

0 commit comments

Comments
 (0)