@graffiti-garden/api 0.0.5 → 0.0.7
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/package.json +6 -5
- package/src/1-api.ts +7 -2
- package/src/2-types.ts +2 -2
- package/tests/crud.ts +8 -16
- package/tests/synchronize.ts +9 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graffiti-garden/api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "The heart of Graffiti",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -29,12 +29,13 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://api.graffiti.garden/classes/Graffiti.html",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/json-schema": "^7.0.15",
|
|
33
|
-
"@types/node": "^22.10.5",
|
|
34
|
-
"ajv": "^8.17.1",
|
|
35
|
-
"fast-json-patch": "^3.1.1",
|
|
36
32
|
"tslib": "^2.8.1",
|
|
37
33
|
"typedoc": "^0.26.11",
|
|
38
34
|
"vitest": "^2.1.8"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@types/json-schema": "^7.0.15",
|
|
38
|
+
"ajv": "^8.17.1",
|
|
39
|
+
"fast-json-patch": "^3.1.1"
|
|
39
40
|
}
|
|
40
41
|
}
|
package/src/1-api.ts
CHANGED
|
@@ -333,7 +333,7 @@ export abstract class Graffiti {
|
|
|
333
333
|
): GraffitiStream<{
|
|
334
334
|
channel: string;
|
|
335
335
|
source: string;
|
|
336
|
-
lastModified:
|
|
336
|
+
lastModified: string;
|
|
337
337
|
count: number;
|
|
338
338
|
}>;
|
|
339
339
|
|
|
@@ -358,10 +358,15 @@ export abstract class Graffiti {
|
|
|
358
358
|
abstract listOrphans(session: GraffitiSession): GraffitiStream<{
|
|
359
359
|
name: string;
|
|
360
360
|
source: string;
|
|
361
|
-
lastModified:
|
|
361
|
+
lastModified: string;
|
|
362
362
|
tombstone: boolean;
|
|
363
363
|
}>;
|
|
364
364
|
|
|
365
|
+
/**
|
|
366
|
+
* The age at which a query for a session will be considered expired.
|
|
367
|
+
*/
|
|
368
|
+
abstract readonly maxAge: number;
|
|
369
|
+
|
|
365
370
|
/**
|
|
366
371
|
* Begins the login process. Depending on the implementation, this may
|
|
367
372
|
* involve redirecting the user to a login page or opening a popup,
|
package/src/2-types.ts
CHANGED
|
@@ -95,12 +95,12 @@ export interface GraffitiObjectBase {
|
|
|
95
95
|
source: string;
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
* The time the object was last modified. This is used for caching and synchronization.
|
|
98
|
+
* The time the object was last modified in [ISO format](https://fits.gsfc.nasa.gov/iso-time.html). This is used for caching and synchronization.
|
|
99
99
|
* It can also be used to sort objects in a user interface but in many cases it would be better to
|
|
100
100
|
* use a `createdAt` property in the object's {@link value | `value`} to indicate when the object was created
|
|
101
101
|
* rather than when it was modified.
|
|
102
102
|
*/
|
|
103
|
-
lastModified:
|
|
103
|
+
lastModified: string;
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* A boolean indicating whether the object has been deleted.
|
package/tests/crud.ts
CHANGED
|
@@ -41,9 +41,7 @@ export const graffitiCRUDTests = (
|
|
|
41
41
|
expect(gotten.name).toEqual(previous.name);
|
|
42
42
|
expect(gotten.actor).toEqual(previous.actor);
|
|
43
43
|
expect(gotten.source).toEqual(previous.source);
|
|
44
|
-
expect(gotten.lastModified
|
|
45
|
-
previous.lastModified.getTime(),
|
|
46
|
-
);
|
|
44
|
+
expect(gotten.lastModified).toEqual(previous.lastModified);
|
|
47
45
|
|
|
48
46
|
// Replace it
|
|
49
47
|
const newValue = {
|
|
@@ -58,24 +56,22 @@ export const graffitiCRUDTests = (
|
|
|
58
56
|
expect(beforeReplaced.name).toEqual(previous.name);
|
|
59
57
|
expect(beforeReplaced.actor).toEqual(previous.actor);
|
|
60
58
|
expect(beforeReplaced.source).toEqual(previous.source);
|
|
61
|
-
expect(beforeReplaced.lastModified.getTime()).toBeGreaterThan(
|
|
62
|
-
gotten.lastModified.getTime(),
|
|
59
|
+
expect(new Date(beforeReplaced.lastModified).getTime()).toBeGreaterThan(
|
|
60
|
+
new Date(gotten.lastModified).getTime(),
|
|
63
61
|
);
|
|
64
62
|
|
|
65
63
|
// Get it again
|
|
66
64
|
const afterReplaced = await graffiti.get(previous, {});
|
|
67
65
|
expect(afterReplaced.value).toEqual(newValue);
|
|
68
|
-
expect(afterReplaced.lastModified
|
|
69
|
-
beforeReplaced.lastModified.getTime(),
|
|
70
|
-
);
|
|
66
|
+
expect(afterReplaced.lastModified).toEqual(beforeReplaced.lastModified);
|
|
71
67
|
expect(afterReplaced.tombstone).toEqual(false);
|
|
72
68
|
|
|
73
69
|
// Delete it
|
|
74
70
|
const beforeDeleted = await graffiti.delete(afterReplaced, session);
|
|
75
71
|
expect(beforeDeleted.tombstone).toEqual(true);
|
|
76
72
|
expect(beforeDeleted.value).toEqual(newValue);
|
|
77
|
-
expect(beforeDeleted.lastModified.getTime()).toBeGreaterThan(
|
|
78
|
-
beforeReplaced.lastModified.getTime(),
|
|
73
|
+
expect(new Date(beforeDeleted.lastModified).getTime()).toBeGreaterThan(
|
|
74
|
+
new Date(beforeReplaced.lastModified).getTime(),
|
|
79
75
|
);
|
|
80
76
|
|
|
81
77
|
// Try to get it and fail
|
|
@@ -286,9 +282,7 @@ export const graffitiCRUDTests = (
|
|
|
286
282
|
expect(gotten.value).toEqual({
|
|
287
283
|
something: "goodbye, world~ :c",
|
|
288
284
|
});
|
|
289
|
-
expect(beforePatched.lastModified
|
|
290
|
-
gotten.lastModified.getTime(),
|
|
291
|
-
);
|
|
285
|
+
expect(beforePatched.lastModified).toBe(gotten.lastModified);
|
|
292
286
|
|
|
293
287
|
await graffiti.delete(putted, session);
|
|
294
288
|
});
|
|
@@ -475,9 +469,7 @@ export const graffitiCRUDTests = (
|
|
|
475
469
|
expect(gotten.value).toEqual(object.value);
|
|
476
470
|
expect(gotten.channels).toEqual(object.channels);
|
|
477
471
|
expect(gotten.allowed).toEqual(object.allowed);
|
|
478
|
-
expect(gotten.lastModified
|
|
479
|
-
putted.lastModified.getTime(),
|
|
480
|
-
);
|
|
472
|
+
expect(gotten.lastModified).toEqual(putted.lastModified);
|
|
481
473
|
});
|
|
482
474
|
});
|
|
483
475
|
};
|
package/tests/synchronize.ts
CHANGED
|
@@ -28,9 +28,7 @@ export const graffitiSynchronizeTests = (
|
|
|
28
28
|
expect(result.value.value).toEqual(object.value);
|
|
29
29
|
expect(result.value.channels).toEqual(channels);
|
|
30
30
|
expect(result.value.tombstone).toBe(false);
|
|
31
|
-
expect(result.value.lastModified
|
|
32
|
-
gotten.lastModified.getTime(),
|
|
33
|
-
);
|
|
31
|
+
expect(result.value.lastModified).toEqual(gotten.lastModified);
|
|
34
32
|
});
|
|
35
33
|
|
|
36
34
|
it("put", async () => {
|
|
@@ -91,11 +89,11 @@ export const graffitiSynchronizeTests = (
|
|
|
91
89
|
expect(sharedResult.value.value).toEqual(newValue);
|
|
92
90
|
expect(sharedResult.value.channels).toEqual([sharedChannel]);
|
|
93
91
|
expect(sharedResult.value.tombstone).toBe(false);
|
|
94
|
-
expect(beforeResult.value.lastModified
|
|
95
|
-
afterResult.value.lastModified
|
|
92
|
+
expect(beforeResult.value.lastModified).toEqual(
|
|
93
|
+
afterResult.value.lastModified,
|
|
96
94
|
);
|
|
97
|
-
expect(sharedResult.value.lastModified
|
|
98
|
-
afterResult.value.lastModified
|
|
95
|
+
expect(sharedResult.value.lastModified).toEqual(
|
|
96
|
+
afterResult.value.lastModified,
|
|
99
97
|
);
|
|
100
98
|
});
|
|
101
99
|
|
|
@@ -172,11 +170,11 @@ export const graffitiSynchronizeTests = (
|
|
|
172
170
|
expect(sharedResult.value.value).toEqual(newValue);
|
|
173
171
|
expect(sharedResult.value.channels).toEqual([sharedChannel]);
|
|
174
172
|
expect(sharedResult.value.tombstone).toBe(false);
|
|
175
|
-
expect(beforeResult.value.lastModified
|
|
176
|
-
afterResult.value.lastModified
|
|
173
|
+
expect(beforeResult.value.lastModified).toEqual(
|
|
174
|
+
afterResult.value.lastModified,
|
|
177
175
|
);
|
|
178
|
-
expect(sharedResult.value.lastModified
|
|
179
|
-
afterResult.value.lastModified
|
|
176
|
+
expect(sharedResult.value.lastModified).toEqual(
|
|
177
|
+
afterResult.value.lastModified,
|
|
180
178
|
);
|
|
181
179
|
});
|
|
182
180
|
|