@verdant-web/common 2.5.0 → 2.5.2

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.
@@ -36,5 +36,7 @@ export type UserInfoUpdate<Profile = any, Presence = any> = Omit<UserInfo<Profil
36
36
  };
37
37
  export interface VerdantInternalPresence {
38
38
  viewId?: string;
39
+ lastFieldId?: string;
40
+ lastFieldTimestamp?: number;
39
41
  }
40
42
  export declare const initialInternalPresence: VerdantInternalPresence;
@@ -1 +1 @@
1
- {"version":3,"file":"presence.js","sourceRoot":"","sources":["../../src/presence.ts"],"names":[],"mappings":"AAgDA,MAAM,CAAC,MAAM,uBAAuB,GAA4B,EAAE,CAAC"}
1
+ {"version":3,"file":"presence.js","sourceRoot":"","sources":["../../src/presence.ts"],"names":[],"mappings":"AAkDA,MAAM,CAAC,MAAM,uBAAuB,GAA4B,EAAE,CAAC"}
@@ -4,32 +4,49 @@ export declare const fields: {
4
4
  properties: Props;
5
5
  nullable?: boolean;
6
6
  default?: ShapeFromFieldsWithDefaults<Props> | (() => ShapeFromFieldsWithDefaults<Props>);
7
+ /** Add some docs to your field which will annotate the generated typing */
8
+ documentation?: string;
7
9
  }) => StorageObjectFieldSchema<Props>;
8
10
  array: <T extends StorageFieldSchema>(args: {
9
11
  items: T;
10
12
  nullable?: boolean;
13
+ /** Add some docs to your field which will annotate the generated typing */
14
+ documentation?: string;
11
15
  }) => StorageArrayFieldSchema<T>;
12
16
  string: (args?: {
13
17
  nullable?: boolean;
14
18
  default?: string | (() => string);
15
19
  options?: string[];
20
+ /** Add some docs to your field which will annotate the generated typing */
21
+ documentation?: string;
16
22
  }) => StorageStringFieldSchema;
17
23
  number: (args?: {
18
24
  nullable?: boolean;
19
25
  default?: number | (() => number);
26
+ /** Add some docs to your field which will annotate the generated typing */
27
+ documentation?: string;
20
28
  }) => StorageNumberFieldSchema;
21
29
  boolean: (args?: {
22
30
  nullable?: boolean;
23
31
  default?: boolean | (() => boolean);
32
+ /** Add some docs to your field which will annotate the generated typing */
33
+ documentation?: string;
24
34
  }) => StorageBooleanFieldSchema;
25
35
  any: <TShape>(args?: {
26
36
  default?: TShape;
37
+ /** Add some docs to your field which will annotate the generated typing */
38
+ documentation?: string;
27
39
  }) => StorageAnyFieldSchema<TShape>;
28
40
  map: <T_1 extends StorageFieldSchema>(args: {
29
41
  values: T_1;
42
+ /** Add some docs to your field which will annotate the generated typing */
43
+ documentation?: string | undefined;
30
44
  }) => StorageMapFieldSchema<T_1>;
31
45
  file: (args?: {
32
46
  nullable?: boolean;
33
47
  downloadRemote?: boolean;
48
+ /** Add some docs to your field which will annotate the generated typing */
49
+ documentation?: string;
34
50
  }) => StorageFileFieldSchema;
51
+ id: () => StorageStringFieldSchema;
35
52
  };
@@ -1,3 +1,4 @@
1
+ import cuid from 'cuid';
1
2
  const objectField = (args) => {
2
3
  return Object.assign({ type: 'object' }, args);
3
4
  };
@@ -22,6 +23,16 @@ const mapField = (args) => {
22
23
  const fileField = (args) => {
23
24
  return Object.assign({ type: 'file' }, args);
24
25
  };
26
+ /**
27
+ * Meant for use on primary key fields. Do not use this to refer
28
+ * to another document as a 'foreign key'
29
+ */
30
+ const idField = () => {
31
+ return {
32
+ type: 'string',
33
+ default: cuid,
34
+ };
35
+ };
25
36
  export const fields = {
26
37
  object: objectField,
27
38
  array: arrayField,
@@ -31,5 +42,6 @@ export const fields = {
31
42
  any: anyField,
32
43
  map: mapField,
33
44
  file: fileField,
45
+ id: idField,
34
46
  };
35
47
  //# sourceMappingURL=fieldHelpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fieldHelpers.js","sourceRoot":"","sources":["../../../src/schema/fieldHelpers.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,GAAG,CAAoC,IAMvD,EAAmC,EAAE;IACrC,uBACC,IAAI,EAAE,QAAQ,IACX,IAAI,EACN;AACH,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAA+B,IAGjD,EAA8B,EAAE;IAChC,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10
10
  properties: Props;
11
11
  nullable?: boolean | undefined;
12
12
  default?: import("./types.js").ShapeFromFieldsWithDefaults<Props> | (() => import("./types.js").ShapeFromFieldsWithDefaults<Props>) | undefined;
13
+ documentation?: string | undefined;
13
14
  }) => import("./types.js").StorageObjectFieldSchema<Props>;
14
15
  array: <T extends import("./types.js").StorageFieldSchema>(args: {
15
16
  items: T;
16
17
  nullable?: boolean | undefined;
18
+ documentation?: string | undefined;
17
19
  }) => import("./types.js").StorageArrayFieldSchema<T>;
18
20
  string: (args?: {
19
21
  nullable?: boolean | undefined;
20
22
  default?: string | (() => string) | undefined;
21
23
  options?: string[] | undefined;
24
+ documentation?: string | undefined;
22
25
  } | undefined) => import("./types.js").StorageStringFieldSchema;
23
26
  number: (args?: {
24
27
  nullable?: boolean | undefined;
25
28
  default?: number | (() => number) | undefined;
29
+ documentation?: string | undefined;
26
30
  } | undefined) => import("./types.js").StorageNumberFieldSchema;
27
31
  boolean: (args?: {
28
32
  nullable?: boolean | undefined;
29
33
  default?: boolean | (() => boolean) | undefined;
34
+ documentation?: string | undefined;
30
35
  } | undefined) => import("./types.js").StorageBooleanFieldSchema;
31
36
  any: <TShape>(args?: {
32
37
  default?: TShape | undefined;
38
+ documentation?: string | undefined;
33
39
  } | undefined) => import("./types.js").StorageAnyFieldSchema<TShape>;
34
40
  map: <T_1 extends import("./types.js").StorageFieldSchema>(args: {
35
41
  values: T_1;
42
+ documentation?: string | undefined;
36
43
  }) => import("./types.js").StorageMapFieldSchema<T_1>;
37
44
  file: (args?: {
38
45
  nullable?: boolean | undefined;
39
46
  downloadRemote?: boolean | undefined;
47
+ documentation?: string | undefined;
40
48
  } | undefined) => import("./types.js").StorageFileFieldSchema;
49
+ id: () => import("./types.js").StorageStringFieldSchema;
41
50
  };
42
51
  var generated: {
43
52
  id: (() => string) & {
@@ -4,35 +4,49 @@ export type StorageStringFieldSchema = {
4
4
  default?: string | (() => string);
5
5
  /** Limit the values to a certain set of options */
6
6
  options?: string[];
7
+ /** Add some docs to your field which will annotate the generated typing */
8
+ documentation?: string;
7
9
  };
8
10
  export type StorageNumberFieldSchema = {
9
11
  type: 'number';
10
12
  nullable?: boolean;
11
13
  default?: number | (() => number);
14
+ /** Add some docs to your field which will annotate the generated typing */
15
+ documentation?: string;
12
16
  };
13
17
  export type StorageBooleanFieldSchema = {
14
18
  type: 'boolean';
15
19
  nullable?: boolean;
16
20
  default?: boolean | (() => boolean);
21
+ /** Add some docs to your field which will annotate the generated typing */
22
+ documentation?: string;
17
23
  };
18
24
  export type StorageArrayFieldSchema<TItems extends StorageFieldSchema> = {
19
25
  type: 'array';
20
26
  items: TItems;
21
27
  nullable?: boolean;
28
+ /** Add some docs to your field which will annotate the generated typing */
29
+ documentation?: string;
22
30
  };
23
31
  export type StorageObjectFieldSchema<Props extends StorageFieldsSchema> = {
24
32
  type: 'object';
25
33
  properties: Props;
26
34
  nullable?: boolean;
27
35
  default?: Record<string, any> | (() => Record<string, any>);
36
+ /** Add some docs to your field which will annotate the generated typing */
37
+ documentation?: string;
28
38
  };
29
39
  export type StorageAnyFieldSchema<TShape = any> = {
30
40
  type: 'any';
31
41
  default?: TShape;
42
+ /** Add some docs to your field which will annotate the generated typing */
43
+ documentation?: string;
32
44
  };
33
45
  export type StorageMapFieldSchema<V extends StorageFieldSchema> = {
34
46
  type: 'map';
35
47
  values: V;
48
+ /** Add some docs to your field which will annotate the generated typing */
49
+ documentation?: string;
36
50
  };
37
51
  export type StorageFileFieldSchema = {
38
52
  type: 'file';
@@ -43,6 +57,8 @@ export type StorageFileFieldSchema = {
43
57
  * connection to use files created by other devices.
44
58
  */
45
59
  downloadRemote?: boolean;
60
+ /** Add some docs to your field which will annotate the generated typing */
61
+ documentation?: string;
46
62
  };
47
63
  export type StorageFieldSchema = StorageStringFieldSchema | StorageNumberFieldSchema | StorageBooleanFieldSchema | StorageArrayFieldSchema<any> | StorageObjectFieldSchema<any> | StorageAnyFieldSchema | StorageMapFieldSchema<any> | StorageFileFieldSchema;
48
64
  export type StorageFieldsSchema = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdant-web/common",
3
- "version": "2.5.0",
3
+ "version": "2.5.2",
4
4
  "access": "public",
5
5
  "type": "module",
6
6
  "exports": {
package/src/presence.ts CHANGED
@@ -44,6 +44,8 @@ export type UserInfoUpdate<Profile = any, Presence = any> = Omit<
44
44
 
45
45
  export interface VerdantInternalPresence {
46
46
  viewId?: string;
47
+ lastFieldId?: string;
48
+ lastFieldTimestamp?: number;
47
49
  }
48
50
 
49
51
  export const initialInternalPresence: VerdantInternalPresence = {};
@@ -1,3 +1,4 @@
1
+ import cuid from 'cuid';
1
2
  import {
2
3
  ShapeFromFieldsWithDefaults,
3
4
  StorageAnyFieldSchema,
@@ -18,6 +19,8 @@ const objectField = <Props extends StorageFieldsSchema>(args: {
18
19
  default?:
19
20
  | ShapeFromFieldsWithDefaults<Props>
20
21
  | (() => ShapeFromFieldsWithDefaults<Props>);
22
+ /** Add some docs to your field which will annotate the generated typing */
23
+ documentation?: string;
21
24
  }): StorageObjectFieldSchema<Props> => {
22
25
  return {
23
26
  type: 'object',
@@ -28,6 +31,8 @@ const objectField = <Props extends StorageFieldsSchema>(args: {
28
31
  const arrayField = <T extends StorageFieldSchema>(args: {
29
32
  items: T;
30
33
  nullable?: boolean;
34
+ /** Add some docs to your field which will annotate the generated typing */
35
+ documentation?: string;
31
36
  }): StorageArrayFieldSchema<T> => {
32
37
  return {
33
38
  type: 'array',
@@ -39,6 +44,8 @@ const stringField = (args?: {
39
44
  nullable?: boolean;
40
45
  default?: string | (() => string);
41
46
  options?: string[];
47
+ /** Add some docs to your field which will annotate the generated typing */
48
+ documentation?: string;
42
49
  }): StorageStringFieldSchema => {
43
50
  return {
44
51
  type: 'string',
@@ -49,6 +56,8 @@ const stringField = (args?: {
49
56
  const numberField = (args?: {
50
57
  nullable?: boolean;
51
58
  default?: number | (() => number);
59
+ /** Add some docs to your field which will annotate the generated typing */
60
+ documentation?: string;
52
61
  }): StorageNumberFieldSchema => {
53
62
  return {
54
63
  type: 'number',
@@ -59,6 +68,8 @@ const numberField = (args?: {
59
68
  const booleanField = (args?: {
60
69
  nullable?: boolean;
61
70
  default?: boolean | (() => boolean);
71
+ /** Add some docs to your field which will annotate the generated typing */
72
+ documentation?: string;
62
73
  }): StorageBooleanFieldSchema => {
63
74
  return {
64
75
  type: 'boolean',
@@ -68,6 +79,8 @@ const booleanField = (args?: {
68
79
 
69
80
  const anyField = <TShape>(args?: {
70
81
  default?: TShape;
82
+ /** Add some docs to your field which will annotate the generated typing */
83
+ documentation?: string;
71
84
  }): StorageAnyFieldSchema<TShape> => {
72
85
  return {
73
86
  type: 'any',
@@ -77,6 +90,8 @@ const anyField = <TShape>(args?: {
77
90
 
78
91
  const mapField = <T extends StorageFieldSchema>(args: {
79
92
  values: T;
93
+ /** Add some docs to your field which will annotate the generated typing */
94
+ documentation?: string;
80
95
  }): StorageMapFieldSchema<T> => {
81
96
  return {
82
97
  type: 'map',
@@ -87,6 +102,8 @@ const mapField = <T extends StorageFieldSchema>(args: {
87
102
  const fileField = (args?: {
88
103
  nullable?: boolean;
89
104
  downloadRemote?: boolean;
105
+ /** Add some docs to your field which will annotate the generated typing */
106
+ documentation?: string;
90
107
  }): StorageFileFieldSchema => {
91
108
  return {
92
109
  type: 'file',
@@ -94,6 +111,17 @@ const fileField = (args?: {
94
111
  };
95
112
  };
96
113
 
114
+ /**
115
+ * Meant for use on primary key fields. Do not use this to refer
116
+ * to another document as a 'foreign key'
117
+ */
118
+ const idField = (): StorageStringFieldSchema => {
119
+ return {
120
+ type: 'string',
121
+ default: cuid,
122
+ };
123
+ };
124
+
97
125
  export const fields = {
98
126
  object: objectField,
99
127
  array: arrayField,
@@ -103,4 +131,5 @@ export const fields = {
103
131
  any: anyField,
104
132
  map: mapField,
105
133
  file: fileField,
134
+ id: idField,
106
135
  };
@@ -4,35 +4,49 @@ export type StorageStringFieldSchema = {
4
4
  default?: string | (() => string);
5
5
  /** Limit the values to a certain set of options */
6
6
  options?: string[];
7
+ /** Add some docs to your field which will annotate the generated typing */
8
+ documentation?: string;
7
9
  };
8
10
  export type StorageNumberFieldSchema = {
9
11
  type: 'number';
10
12
  nullable?: boolean;
11
13
  default?: number | (() => number);
14
+ /** Add some docs to your field which will annotate the generated typing */
15
+ documentation?: string;
12
16
  };
13
17
  export type StorageBooleanFieldSchema = {
14
18
  type: 'boolean';
15
19
  nullable?: boolean;
16
20
  default?: boolean | (() => boolean);
21
+ /** Add some docs to your field which will annotate the generated typing */
22
+ documentation?: string;
17
23
  };
18
24
  export type StorageArrayFieldSchema<TItems extends StorageFieldSchema> = {
19
25
  type: 'array';
20
26
  items: TItems;
21
27
  nullable?: boolean;
28
+ /** Add some docs to your field which will annotate the generated typing */
29
+ documentation?: string;
22
30
  };
23
31
  export type StorageObjectFieldSchema<Props extends StorageFieldsSchema> = {
24
32
  type: 'object';
25
33
  properties: Props;
26
34
  nullable?: boolean;
27
35
  default?: Record<string, any> | (() => Record<string, any>);
36
+ /** Add some docs to your field which will annotate the generated typing */
37
+ documentation?: string;
28
38
  };
29
39
  export type StorageAnyFieldSchema<TShape = any> = {
30
40
  type: 'any';
31
41
  default?: TShape;
42
+ /** Add some docs to your field which will annotate the generated typing */
43
+ documentation?: string;
32
44
  };
33
45
  export type StorageMapFieldSchema<V extends StorageFieldSchema> = {
34
46
  type: 'map';
35
47
  values: V;
48
+ /** Add some docs to your field which will annotate the generated typing */
49
+ documentation?: string;
36
50
  };
37
51
  export type StorageFileFieldSchema = {
38
52
  type: 'file';
@@ -43,6 +57,8 @@ export type StorageFileFieldSchema = {
43
57
  * connection to use files created by other devices.
44
58
  */
45
59
  downloadRemote?: boolean;
60
+ /** Add some docs to your field which will annotate the generated typing */
61
+ documentation?: string;
46
62
  };
47
63
 
48
64
  export type StorageFieldSchema =