@graffiti-garden/api 0.0.5 → 0.0.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graffiti-garden/api",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "The heart of Graffiti",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
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: Date;
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.getTime()).toEqual(
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.getTime()).toEqual(
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.getTime()).toBe(
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.getTime()).toEqual(
479
- putted.lastModified.getTime(),
480
- );
472
+ expect(gotten.lastModified).toEqual(putted.lastModified);
481
473
  });
482
474
  });
483
475
  };
@@ -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.getTime()).toEqual(
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.getTime()).toEqual(
95
- afterResult.value.lastModified.getTime(),
92
+ expect(beforeResult.value.lastModified).toEqual(
93
+ afterResult.value.lastModified,
96
94
  );
97
- expect(sharedResult.value.lastModified.getTime()).toEqual(
98
- afterResult.value.lastModified.getTime(),
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.getTime()).toEqual(
176
- afterResult.value.lastModified.getTime(),
173
+ expect(beforeResult.value.lastModified).toEqual(
174
+ afterResult.value.lastModified,
177
175
  );
178
- expect(sharedResult.value.lastModified.getTime()).toEqual(
179
- afterResult.value.lastModified.getTime(),
176
+ expect(sharedResult.value.lastModified).toEqual(
177
+ afterResult.value.lastModified,
180
178
  );
181
179
  });
182
180