@graffiti-garden/api 0.0.7 → 0.0.9

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.7",
3
+ "version": "0.0.9",
4
4
  "description": "The heart of Graffiti",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/1-api.ts CHANGED
@@ -19,13 +19,17 @@ import type { JSONSchema4 } from "json-schema";
19
19
  * user interface tools to present and interact with the data.
20
20
  *
21
21
  * There are several different implementations of this Graffiti API available,
22
- * including a decentralized implementation and a local implementation
22
+ * including a [decentralized implementation](https://github.com/graffiti-garden/client-core),
23
+ * and a [local implementation](https://github.com/graffiti-garden/implementation-pouchdb)
23
24
  * that can be used for testing. In the design of Graffiti we prioritized
24
25
  * the design of this API first as it is the layer that shapes the experience
25
26
  * of developing applications. While different implementations provide tradeoffs between
26
27
  * other important properties (e.g. privacy, security, scalability), those properties
27
28
  * are useless if the system as a whole is unusable. Build APIs before protocols!
28
29
  *
30
+ * There is also a wrapper around this API that provides a [Vue plugin](https://github.com/graffiti-garden/wrapper-vue/)
31
+ * that enables reactivity. Other front-end frameworks can be supported in the future.
32
+ *
29
33
  * The first group of methods are like standard CRUD methods that
30
34
  * allow applications to {@link put}, {@link get}, {@link patch}, and {@link delete}
31
35
  * {@link GraffitiObjectBase} objects. The main difference between these
@@ -333,7 +337,7 @@ export abstract class Graffiti {
333
337
  ): GraffitiStream<{
334
338
  channel: string;
335
339
  source: string;
336
- lastModified: string;
340
+ lastModified: number;
337
341
  count: number;
338
342
  }>;
339
343
 
@@ -365,7 +369,7 @@ export abstract class Graffiti {
365
369
  /**
366
370
  * The age at which a query for a session will be considered expired.
367
371
  */
368
- abstract readonly maxAge: number;
372
+ // abstract readonly maxAge: number;
369
373
 
370
374
  /**
371
375
  * Begins the login process. Depending on the implementation, this may
package/src/2-types.ts CHANGED
@@ -95,12 +95,16 @@ export interface GraffitiObjectBase {
95
95
  source: string;
96
96
 
97
97
  /**
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
- * It can also be used to sort objects in a user interface but in many cases it would be better to
98
+ * The time the object was last modified, measured in milliseconds since January 1, 1970.
99
+ * This is used for caching and synchronization.
100
+ * A number, rather than an ISO string or Date object, is used for easy comparison, sorting,
101
+ * and JSON Schema [range queries](https://json-schema.org/understanding-json-schema/reference/numeric#range).
102
+ *
103
+ * It is possible to use this value to sort objects in a user's interface but in many cases it would be better to
100
104
  * use a `createdAt` property in the object's {@link value | `value`} to indicate when the object was created
101
105
  * rather than when it was modified.
102
106
  */
103
- lastModified: string;
107
+ lastModified: number;
104
108
 
105
109
  /**
106
110
  * A boolean indicating whether the object has been deleted.
package/tests/crud.ts CHANGED
@@ -56,9 +56,7 @@ export const graffitiCRUDTests = (
56
56
  expect(beforeReplaced.name).toEqual(previous.name);
57
57
  expect(beforeReplaced.actor).toEqual(previous.actor);
58
58
  expect(beforeReplaced.source).toEqual(previous.source);
59
- expect(new Date(beforeReplaced.lastModified).getTime()).toBeGreaterThan(
60
- new Date(gotten.lastModified).getTime(),
61
- );
59
+ expect(beforeReplaced.lastModified).toBeGreaterThan(gotten.lastModified);
62
60
 
63
61
  // Get it again
64
62
  const afterReplaced = await graffiti.get(previous, {});
@@ -70,8 +68,8 @@ export const graffitiCRUDTests = (
70
68
  const beforeDeleted = await graffiti.delete(afterReplaced, session);
71
69
  expect(beforeDeleted.tombstone).toEqual(true);
72
70
  expect(beforeDeleted.value).toEqual(newValue);
73
- expect(new Date(beforeDeleted.lastModified).getTime()).toBeGreaterThan(
74
- new Date(beforeReplaced.lastModified).getTime(),
71
+ expect(beforeDeleted.lastModified).toBeGreaterThan(
72
+ beforeReplaced.lastModified,
75
73
  );
76
74
 
77
75
  // Try to get it and fail