bleam 0.0.6 → 0.0.8

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.
Files changed (86) hide show
  1. package/dist/ai.cjs +3984 -25
  2. package/dist/ai.d.cts +503 -20
  3. package/dist/ai.d.ts +503 -20
  4. package/dist/ai.js +3946 -26
  5. package/dist/animated.cjs +1 -1
  6. package/dist/animated.js +1 -1
  7. package/dist/app.cjs +92 -0
  8. package/dist/app.js +92 -0
  9. package/dist/cli.cjs +653 -86
  10. package/dist/cli.d.cts +89 -1
  11. package/dist/cli.d.ts +89 -1
  12. package/dist/cli.js +654 -88
  13. package/dist/{config-ClDGHNb3.d.ts → config-Cms0rvqg.d.ts} +1 -0
  14. package/dist/{config-D3gPaVMb.d.cts → config-CufOVJV3.d.cts} +1 -0
  15. package/dist/config.d.cts +1 -1
  16. package/dist/config.d.ts +1 -1
  17. package/dist/crypto.d.cts +0 -2
  18. package/dist/crypto.d.ts +1 -1
  19. package/dist/dev-protocol.d.cts +14 -1
  20. package/dist/dev-protocol.d.ts +14 -1
  21. package/dist/files-Bo7h9fik.cjs +468 -0
  22. package/dist/files-Ds1wT8C2.js +445 -0
  23. package/dist/files-DwA7pzr3.d.cts +99 -0
  24. package/dist/files-VrkQlKIT.d.ts +99 -0
  25. package/dist/files.cjs +7 -0
  26. package/dist/files.d.cts +2 -0
  27. package/dist/files.d.ts +2 -0
  28. package/dist/files.js +4 -0
  29. package/dist/index.d.cts +1 -1
  30. package/dist/index.d.ts +1 -1
  31. package/dist/native-sqlite-xcGdamRD.js +64 -0
  32. package/dist/native-sqlite-yQLD5s9i.cjs +66 -0
  33. package/dist/platform.cjs +27 -0
  34. package/dist/platform.d.cts +39 -0
  35. package/dist/platform.d.ts +39 -0
  36. package/dist/platform.js +21 -0
  37. package/dist/runtime.d.cts +1 -6
  38. package/dist/runtime.d.ts +1 -6
  39. package/dist/{schema-ipsECAso.d.ts → schema-DOOjfXvs.d.ts} +1 -1
  40. package/dist/{schema-BOuUHcqo.d.cts → schema-ENSMX_1t.d.cts} +1 -1
  41. package/dist/schema.cjs +1 -1
  42. package/dist/schema.d.cts +1 -1
  43. package/dist/schema.d.ts +1 -1
  44. package/dist/schema.js +1 -1
  45. package/dist/state-Bx0VlTlO.cjs +852 -0
  46. package/dist/state-CAwe-Vw1.js +767 -0
  47. package/dist/state.cjs +17 -763
  48. package/dist/state.d.cts +107 -77
  49. package/dist/state.d.ts +107 -77
  50. package/dist/state.js +4 -745
  51. package/dist/ui-1WepaMS4.d.cts +92 -0
  52. package/dist/ui-Ce-pnUUA.d.ts +92 -0
  53. package/dist/ui.cjs +286 -35
  54. package/dist/ui.d.cts +2 -30
  55. package/dist/ui.d.ts +2 -30
  56. package/dist/ui.js +283 -36
  57. package/dist/window.cjs +596 -0
  58. package/dist/window.d.cts +63 -0
  59. package/dist/window.d.ts +63 -0
  60. package/dist/window.js +589 -0
  61. package/package.json +16 -14
  62. package/templates/basic/app/index.tsx +8 -5
  63. package/templates/foundation-models/app/index.tsx +32 -0
  64. package/templates/foundation-models/app.config.ts +5 -0
  65. package/templates/image-generation/app/index.tsx +39 -0
  66. package/templates/image-generation/app.config.ts +5 -0
  67. package/templates/state/app/index.tsx +30 -0
  68. package/templates/state/app.config.ts +5 -0
  69. package/dist/chrome.cjs +0 -265
  70. package/dist/chrome.d.cts +0 -19
  71. package/dist/chrome.d.ts +0 -19
  72. package/dist/chrome.js +0 -262
  73. package/dist/fs.cjs +0 -13
  74. package/dist/fs.d.cts +0 -8
  75. package/dist/fs.d.ts +0 -8
  76. package/dist/fs.js +0 -12
  77. package/dist/native-macos-D6p2SmUj.js +0 -20
  78. package/dist/native-macos-DLwo_ii9.cjs +0 -31
  79. package/dist/native-runtime-CbPzrs8j.d.cts +0 -33
  80. package/dist/native-runtime-DxHSrsTX.d.ts +0 -33
  81. package/dist/native.cjs +0 -135
  82. package/dist/native.d.cts +0 -34
  83. package/dist/native.d.ts +0 -34
  84. package/dist/native.js +0 -135
  85. /package/dist/{schema-DVmoD9JL.js → schema-Bo5Jvqus.js} +0 -0
  86. /package/dist/{schema-bxeeCyLn.cjs → schema-rQ13mrpD.cjs} +0 -0
package/dist/state.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { f as SchemaOutput, l as SchemaInput, m as SchemaShape, t as BleamSchema } from "./schema-BOuUHcqo.cjs";
1
+ import { a as FieldValue, f as SchemaOutput, l as SchemaInput, m as SchemaShape, t as BleamSchema } from "./schema-ENSMX_1t.cjs";
2
2
 
3
3
  //#region src/state/atom.d.ts
4
4
  type Listener = () => void;
@@ -20,110 +20,140 @@ declare class LiveStore<Value> implements WritableStore<Value> {
20
20
  subscribe(listener: Listener): () => void;
21
21
  }
22
22
  type Atom<Value> = WritableStore<Value>;
23
+ type SetStoreValue<Value> = (value: Value | ((current: Value) => Value)) => void;
23
24
  declare function atom<Value>(initialValue: Value): Atom<Value>;
24
25
  declare function useStore<Value>(store: Store<Value>): Value;
25
- declare function useAtom<Value>(value: Atom<Value>): Value;
26
+ declare function useAtom<Value>(value: Atom<Value>): readonly [Value, SetStoreValue<Value>];
26
27
  //#endregion
27
28
  //#region src/state/collection.d.ts
29
+ type FieldRecord = Record<string, FieldValue | undefined>;
28
30
  type CollectionFields<Shape extends SchemaShape> = SchemaOutput<Shape>;
29
31
  type CollectionInput<Shape extends SchemaShape> = SchemaInput<Shape>;
30
- type CollectionData<Shape extends SchemaShape> = CollectionFields<Shape> | undefined;
31
- type CollectionRecord<Shape extends SchemaShape> = CollectionFields<Shape> & {
32
- readonly id: string;
33
- data(): CollectionData<Shape>;
34
- delete(): Promise<void>;
35
- readonly set: (patch: Partial<CollectionInput<Shape>>) => Promise<void>;
36
- with(name: string): unknown | undefined;
37
- with<OtherShape extends SchemaShape>(collection: Collection<OtherShape>): CollectionRecord<OtherShape>[];
32
+ type CollectionData<Shape extends SchemaShape> = CollectionFields<Shape>;
33
+ type CollectionFieldKey<Shape extends SchemaShape> = Extract<keyof Shape, string>;
34
+ type CollectionFieldValue<Shape extends SchemaShape, Key extends CollectionFieldKey<Shape>> = Key extends keyof CollectionData<Shape> ? CollectionData<Shape>[Key] : undefined;
35
+ type Entry<Value> = {
36
+ value: Value | undefined;
37
+ error: unknown;
38
+ promise: Promise<unknown> | null;
39
+ version: number;
40
+ listeners: Set<Listener>;
41
+ };
42
+ type RawCollectionView = {
43
+ id: string;
44
+ collection: string;
45
+ createdAt: string;
46
+ updatedAt: string;
47
+ data: FieldRecord;
48
+ links: Record<string, string[]>;
49
+ };
50
+ type RecordEntry = Entry<RawCollectionView | null>;
51
+ type ListEntry = Entry<string[]> & {
52
+ dependencies: ListDependencies;
38
53
  };
39
54
  type CollectionReference = {
40
55
  readonly name: string;
41
56
  get(id: string): Promise<unknown>;
42
- refreshQueries(): Promise<void>;
43
- pin(record: object | string, name: string, target: object | CollectionReference, targetId?: string): Promise<void>;
44
- unpin(record: object | string, name: string): Promise<void>;
45
57
  };
46
- type AnyRecord = object;
47
- type JoinFilter = {
48
- kind: 'record';
49
- record: AnyRecord;
50
- } | {
51
- kind: 'id';
52
- collection: CollectionReference;
58
+ type ViewOptions = {
59
+ links?: CollectionReference[];
60
+ };
61
+ type ListWhereValue = FieldValue | ['equals' | 'greater-than' | 'less-than' | 'contains', FieldValue] | Array<['equals' | 'greater-than' | 'less-than' | 'contains', FieldValue]>;
62
+ type ListOptions<Shape extends SchemaShape> = {
63
+ where?: Partial<Record<CollectionFieldKey<Shape>, ListWhereValue>>;
64
+ sortBy?: CollectionFieldKey<Shape> | 'createdAt' | 'updatedAt';
65
+ order?: 'asc' | 'desc';
66
+ take?: number;
67
+ };
68
+ type NormalizedListOptions = {
69
+ where?: Record<string, Array<[string, FieldValue]>>;
70
+ sortBy?: string;
71
+ order?: 'asc' | 'desc';
72
+ take?: number;
73
+ };
74
+ type RecordChange = {
75
+ collection: string;
53
76
  id: string;
77
+ previous: RawCollectionView | null;
78
+ next: RawCollectionView | null;
79
+ changedPaths: Set<string>;
80
+ };
81
+ type EdgeChange = {
82
+ type: 'link' | 'unlink';
83
+ left: {
84
+ collection: string;
85
+ id: string;
86
+ };
87
+ right: {
88
+ collection: string;
89
+ id: string;
90
+ };
54
91
  };
55
- type JoinInclude = {
56
- collection: CollectionReference;
92
+ type ListDependencies = {
93
+ collection: string;
94
+ paths: Set<string>;
95
+ options: NormalizedListOptions;
57
96
  };
58
- type PinInclude = {
59
- name: string;
60
- target: CollectionReference;
97
+ type CollectionView<Shape extends SchemaShape> = {
98
+ readonly id: string;
99
+ readonly collection: string;
100
+ readonly createdAt: string;
101
+ readonly updatedAt: string;
102
+ readonly data: CollectionData<Shape>;
103
+ readonly links: Record<string, string[]>;
61
104
  };
62
105
  declare class Collection<Shape extends SchemaShape> {
63
106
  readonly name: string;
64
107
  readonly shape: Shape;
65
108
  readonly validator: BleamSchema<SchemaInput<Shape>, SchemaOutput<Shape>>;
66
- private queries;
67
- private store;
109
+ private records;
110
+ private lists;
111
+ private fields;
68
112
  constructor(name: string, shape: Shape);
69
- private initialize;
70
- private load;
71
- private notifyRecordListeners;
72
- private currentRecords;
73
- refreshQueries(): Promise<void>;
74
- insert(value: CollectionInput<Shape>): Promise<CollectionRecord<Shape>>;
75
- update(record: CollectionFields<Shape> | string, value: Partial<CollectionInput<Shape>>): Promise<void>;
76
- delete(record: CollectionFields<Shape> | string): Promise<void>;
77
- all(): Promise<CollectionRecord<Shape>[]>;
78
- get(id: string): Promise<CollectionRecord<Shape> | undefined>;
79
- pin(record: CollectionFields<Shape> | string, name: string, target: object | CollectionReference, targetId?: string): Promise<void>;
80
- unpin(record: CollectionFields<Shape> | string, name: string): Promise<void>;
81
- subscribeRecord(record: CollectionFields<Shape>, listener: Listener): () => void;
82
- queryStore(query?: {
83
- joins: JoinFilter[];
84
- joinIncludes: JoinInclude[];
85
- pinIncludes: PinInclude[];
86
- }): Store<CollectionRecord<Shape>[]>;
87
- private executeQuery;
113
+ validateListOptions(options?: ListOptions<Shape>): void;
114
+ getRecordEntry(id: string): RecordEntry;
115
+ getListEntry(options?: ListOptions<Shape>): ListEntry;
116
+ private getFieldEntry;
117
+ private notifyFields;
118
+ private setRecordValue;
119
+ private rawRecord;
120
+ private loadRecord;
121
+ private loadListRows;
122
+ private selectListRows;
123
+ private applyListOptions;
124
+ private refreshListEntry;
125
+ invalidateChanges(recordChanges: RecordChange[], edgeChanges?: EdgeChange[]): Promise<void>;
126
+ private refreshLoadedLinks;
127
+ private peekRecord;
128
+ insert(value: CollectionInput<Shape>): Promise<string>;
129
+ update(id: string, value: Partial<CollectionInput<Shape>>): Promise<void>;
130
+ delete(id: string): Promise<void>;
131
+ all(): Promise<CollectionView<Shape>[]>;
132
+ get(id: string): Promise<CollectionView<Shape> | null>;
133
+ subscribeRecord(id: string, listener: Listener): () => void;
134
+ subscribeList(options: ListOptions<Shape> | undefined, listener: Listener): () => void;
135
+ subscribeField(id: string, path: string, listener: Listener): () => void;
136
+ getRecordVersion(id: string): number;
137
+ getListVersion(options?: ListOptions<Shape>): number;
138
+ getFieldVersion(id: string, path: string): number;
139
+ getRecordSnapshot(id: string, options?: ViewOptions): CollectionView<Shape> | null | undefined;
140
+ getListSnapshot(options?: ListOptions<Shape>): string[] | undefined;
141
+ ensureRecord(id: string, options?: ViewOptions): Promise<RawCollectionView | null>;
142
+ ensureList(options?: ListOptions<Shape>): Promise<string[]>;
88
143
  private deleteLinksForRecord;
89
- private deletePinsForRecord;
90
144
  }
91
145
  declare function collection<Shape extends SchemaShape>(name: string, shape: Shape): Collection<Shape>;
92
- declare function link(first: object, second: object): Promise<void>;
93
146
  declare function link<FirstShape extends SchemaShape, SecondShape extends SchemaShape>(firstCollection: Collection<FirstShape>, firstId: string, secondCollection: Collection<SecondShape>, secondId: string): Promise<void>;
94
- declare function unlink(first: object, second: object): Promise<void>;
95
147
  declare function unlink<FirstShape extends SchemaShape, SecondShape extends SchemaShape>(firstCollection: Collection<FirstShape>, firstId: string, secondCollection: Collection<SecondShape>, secondId: string): Promise<void>;
96
- declare function isLinked(first: object, second: object): Promise<boolean>;
97
148
  declare function isLinked<FirstShape extends SchemaShape, SecondShape extends SchemaShape>(firstCollection: Collection<FirstShape>, firstId: string, secondCollection: Collection<SecondShape>, secondId: string): Promise<boolean>;
98
- declare function pin(source: object, name: string, target: object): Promise<void>;
99
- declare function pin<SourceShape extends SchemaShape, TargetShape extends SchemaShape>(sourceCollection: Collection<SourceShape>, sourceId: string, name: string, targetCollection: Collection<TargetShape>, targetId: string): Promise<void>;
100
- declare function unpin(source: object, name: string): Promise<void>;
101
- declare function unpin<SourceShape extends SchemaShape>(sourceCollection: Collection<SourceShape>, sourceId: string, name: string): Promise<void>;
102
- declare function isPinned(source: object, name: string, target: object): Promise<boolean>;
103
- declare function isPinned<SourceShape extends SchemaShape, TargetShape extends SchemaShape>(sourceCollection: Collection<SourceShape>, sourceId: string, name: string, targetCollection: Collection<TargetShape>, targetId: string): Promise<boolean>;
104
- declare class CollectionQuery<Shape extends SchemaShape> implements Store<CollectionRecord<Shape>[]> {
105
- private readonly collection;
106
- private joins;
107
- private joinIncludes;
108
- private pinIncludes;
109
- private cachedStore?;
110
- constructor(collection: Collection<Shape>);
111
- join(record: object): this;
112
- join<OtherShape extends SchemaShape>(collection: Collection<OtherShape>): this;
113
- join<OtherShape extends SchemaShape>(collection: Collection<OtherShape>, id: string): this;
114
- with<OtherShape extends SchemaShape>(name: string, target: Collection<OtherShape>): this;
115
- get(): CollectionRecord<Shape>[];
116
- subscribe(listener: Listener): () => void;
117
- store(): Store<CollectionRecord<Shape>[]>;
118
- }
119
- declare class QueryBuilder {
120
- from<Shape extends SchemaShape>(collection: Collection<Shape>): CollectionQuery<Shape>;
121
- }
122
- declare function useQuery<Output>(query: (builder: QueryBuilder) => Store<Output>): Output;
149
+ declare function useList<Shape extends SchemaShape>(collection: Collection<Shape>, options?: ListOptions<Shape>): string[];
150
+ declare function useView<Shape extends SchemaShape>(collection: Collection<Shape>, id: string, options?: ViewOptions): CollectionView<Shape> | null | undefined;
151
+ declare function useField<Shape extends SchemaShape, Key extends CollectionFieldKey<Shape>>(collection: Collection<Shape>, id: string, key: Key): CollectionFieldValue<Shape, Key> | undefined;
123
152
  //#endregion
124
153
  //#region src/state/setting.d.ts
125
154
  type Setting<Value> = WritableStore<Value>;
155
+ type SetSettingValue<Value> = SetStoreValue<Value>;
126
156
  declare function setting<Value extends string | number | boolean>(key: string, initialValue: Value): Setting<Value>;
127
- declare function useSetting<Value>(value: Setting<Value>): Value;
157
+ declare function useSetting<Value>(value: Setting<Value>): readonly [Value, SetStoreValue<Value>];
128
158
  //#endregion
129
- export { Atom, Collection, CollectionRecord, Listener, LiveStore, QueryBuilder, Setting, Store, WritableStore, atom, collection, isLinked, isPinned, link, pin, setting, unlink, unpin, useAtom, useQuery, useSetting, useStore };
159
+ export { Atom, Collection, CollectionView, ListOptions, Listener, LiveStore, SetSettingValue, SetStoreValue, Setting, Store, WritableStore, atom, collection, isLinked, link, setting, unlink, useAtom, useField, useList, useSetting, useStore, useView };
package/dist/state.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { f as SchemaOutput, l as SchemaInput, m as SchemaShape, t as BleamSchema } from "./schema-ipsECAso.js";
1
+ import { a as FieldValue, f as SchemaOutput, l as SchemaInput, m as SchemaShape, t as BleamSchema } from "./schema-DOOjfXvs.js";
2
2
 
3
3
  //#region src/state/atom.d.ts
4
4
  type Listener = () => void;
@@ -20,110 +20,140 @@ declare class LiveStore<Value> implements WritableStore<Value> {
20
20
  subscribe(listener: Listener): () => void;
21
21
  }
22
22
  type Atom<Value> = WritableStore<Value>;
23
+ type SetStoreValue<Value> = (value: Value | ((current: Value) => Value)) => void;
23
24
  declare function atom<Value>(initialValue: Value): Atom<Value>;
24
25
  declare function useStore<Value>(store: Store<Value>): Value;
25
- declare function useAtom<Value>(value: Atom<Value>): Value;
26
+ declare function useAtom<Value>(value: Atom<Value>): readonly [Value, SetStoreValue<Value>];
26
27
  //#endregion
27
28
  //#region src/state/collection.d.ts
29
+ type FieldRecord = Record<string, FieldValue | undefined>;
28
30
  type CollectionFields<Shape extends SchemaShape> = SchemaOutput<Shape>;
29
31
  type CollectionInput<Shape extends SchemaShape> = SchemaInput<Shape>;
30
- type CollectionData<Shape extends SchemaShape> = CollectionFields<Shape> | undefined;
31
- type CollectionRecord<Shape extends SchemaShape> = CollectionFields<Shape> & {
32
- readonly id: string;
33
- data(): CollectionData<Shape>;
34
- delete(): Promise<void>;
35
- readonly set: (patch: Partial<CollectionInput<Shape>>) => Promise<void>;
36
- with(name: string): unknown | undefined;
37
- with<OtherShape extends SchemaShape>(collection: Collection<OtherShape>): CollectionRecord<OtherShape>[];
32
+ type CollectionData<Shape extends SchemaShape> = CollectionFields<Shape>;
33
+ type CollectionFieldKey<Shape extends SchemaShape> = Extract<keyof Shape, string>;
34
+ type CollectionFieldValue<Shape extends SchemaShape, Key extends CollectionFieldKey<Shape>> = Key extends keyof CollectionData<Shape> ? CollectionData<Shape>[Key] : undefined;
35
+ type Entry<Value> = {
36
+ value: Value | undefined;
37
+ error: unknown;
38
+ promise: Promise<unknown> | null;
39
+ version: number;
40
+ listeners: Set<Listener>;
41
+ };
42
+ type RawCollectionView = {
43
+ id: string;
44
+ collection: string;
45
+ createdAt: string;
46
+ updatedAt: string;
47
+ data: FieldRecord;
48
+ links: Record<string, string[]>;
49
+ };
50
+ type RecordEntry = Entry<RawCollectionView | null>;
51
+ type ListEntry = Entry<string[]> & {
52
+ dependencies: ListDependencies;
38
53
  };
39
54
  type CollectionReference = {
40
55
  readonly name: string;
41
56
  get(id: string): Promise<unknown>;
42
- refreshQueries(): Promise<void>;
43
- pin(record: object | string, name: string, target: object | CollectionReference, targetId?: string): Promise<void>;
44
- unpin(record: object | string, name: string): Promise<void>;
45
57
  };
46
- type AnyRecord = object;
47
- type JoinFilter = {
48
- kind: 'record';
49
- record: AnyRecord;
50
- } | {
51
- kind: 'id';
52
- collection: CollectionReference;
58
+ type ViewOptions = {
59
+ links?: CollectionReference[];
60
+ };
61
+ type ListWhereValue = FieldValue | ['equals' | 'greater-than' | 'less-than' | 'contains', FieldValue] | Array<['equals' | 'greater-than' | 'less-than' | 'contains', FieldValue]>;
62
+ type ListOptions<Shape extends SchemaShape> = {
63
+ where?: Partial<Record<CollectionFieldKey<Shape>, ListWhereValue>>;
64
+ sortBy?: CollectionFieldKey<Shape> | 'createdAt' | 'updatedAt';
65
+ order?: 'asc' | 'desc';
66
+ take?: number;
67
+ };
68
+ type NormalizedListOptions = {
69
+ where?: Record<string, Array<[string, FieldValue]>>;
70
+ sortBy?: string;
71
+ order?: 'asc' | 'desc';
72
+ take?: number;
73
+ };
74
+ type RecordChange = {
75
+ collection: string;
53
76
  id: string;
77
+ previous: RawCollectionView | null;
78
+ next: RawCollectionView | null;
79
+ changedPaths: Set<string>;
80
+ };
81
+ type EdgeChange = {
82
+ type: 'link' | 'unlink';
83
+ left: {
84
+ collection: string;
85
+ id: string;
86
+ };
87
+ right: {
88
+ collection: string;
89
+ id: string;
90
+ };
54
91
  };
55
- type JoinInclude = {
56
- collection: CollectionReference;
92
+ type ListDependencies = {
93
+ collection: string;
94
+ paths: Set<string>;
95
+ options: NormalizedListOptions;
57
96
  };
58
- type PinInclude = {
59
- name: string;
60
- target: CollectionReference;
97
+ type CollectionView<Shape extends SchemaShape> = {
98
+ readonly id: string;
99
+ readonly collection: string;
100
+ readonly createdAt: string;
101
+ readonly updatedAt: string;
102
+ readonly data: CollectionData<Shape>;
103
+ readonly links: Record<string, string[]>;
61
104
  };
62
105
  declare class Collection<Shape extends SchemaShape> {
63
106
  readonly name: string;
64
107
  readonly shape: Shape;
65
108
  readonly validator: BleamSchema<SchemaInput<Shape>, SchemaOutput<Shape>>;
66
- private queries;
67
- private store;
109
+ private records;
110
+ private lists;
111
+ private fields;
68
112
  constructor(name: string, shape: Shape);
69
- private initialize;
70
- private load;
71
- private notifyRecordListeners;
72
- private currentRecords;
73
- refreshQueries(): Promise<void>;
74
- insert(value: CollectionInput<Shape>): Promise<CollectionRecord<Shape>>;
75
- update(record: CollectionFields<Shape> | string, value: Partial<CollectionInput<Shape>>): Promise<void>;
76
- delete(record: CollectionFields<Shape> | string): Promise<void>;
77
- all(): Promise<CollectionRecord<Shape>[]>;
78
- get(id: string): Promise<CollectionRecord<Shape> | undefined>;
79
- pin(record: CollectionFields<Shape> | string, name: string, target: object | CollectionReference, targetId?: string): Promise<void>;
80
- unpin(record: CollectionFields<Shape> | string, name: string): Promise<void>;
81
- subscribeRecord(record: CollectionFields<Shape>, listener: Listener): () => void;
82
- queryStore(query?: {
83
- joins: JoinFilter[];
84
- joinIncludes: JoinInclude[];
85
- pinIncludes: PinInclude[];
86
- }): Store<CollectionRecord<Shape>[]>;
87
- private executeQuery;
113
+ validateListOptions(options?: ListOptions<Shape>): void;
114
+ getRecordEntry(id: string): RecordEntry;
115
+ getListEntry(options?: ListOptions<Shape>): ListEntry;
116
+ private getFieldEntry;
117
+ private notifyFields;
118
+ private setRecordValue;
119
+ private rawRecord;
120
+ private loadRecord;
121
+ private loadListRows;
122
+ private selectListRows;
123
+ private applyListOptions;
124
+ private refreshListEntry;
125
+ invalidateChanges(recordChanges: RecordChange[], edgeChanges?: EdgeChange[]): Promise<void>;
126
+ private refreshLoadedLinks;
127
+ private peekRecord;
128
+ insert(value: CollectionInput<Shape>): Promise<string>;
129
+ update(id: string, value: Partial<CollectionInput<Shape>>): Promise<void>;
130
+ delete(id: string): Promise<void>;
131
+ all(): Promise<CollectionView<Shape>[]>;
132
+ get(id: string): Promise<CollectionView<Shape> | null>;
133
+ subscribeRecord(id: string, listener: Listener): () => void;
134
+ subscribeList(options: ListOptions<Shape> | undefined, listener: Listener): () => void;
135
+ subscribeField(id: string, path: string, listener: Listener): () => void;
136
+ getRecordVersion(id: string): number;
137
+ getListVersion(options?: ListOptions<Shape>): number;
138
+ getFieldVersion(id: string, path: string): number;
139
+ getRecordSnapshot(id: string, options?: ViewOptions): CollectionView<Shape> | null | undefined;
140
+ getListSnapshot(options?: ListOptions<Shape>): string[] | undefined;
141
+ ensureRecord(id: string, options?: ViewOptions): Promise<RawCollectionView | null>;
142
+ ensureList(options?: ListOptions<Shape>): Promise<string[]>;
88
143
  private deleteLinksForRecord;
89
- private deletePinsForRecord;
90
144
  }
91
145
  declare function collection<Shape extends SchemaShape>(name: string, shape: Shape): Collection<Shape>;
92
- declare function link(first: object, second: object): Promise<void>;
93
146
  declare function link<FirstShape extends SchemaShape, SecondShape extends SchemaShape>(firstCollection: Collection<FirstShape>, firstId: string, secondCollection: Collection<SecondShape>, secondId: string): Promise<void>;
94
- declare function unlink(first: object, second: object): Promise<void>;
95
147
  declare function unlink<FirstShape extends SchemaShape, SecondShape extends SchemaShape>(firstCollection: Collection<FirstShape>, firstId: string, secondCollection: Collection<SecondShape>, secondId: string): Promise<void>;
96
- declare function isLinked(first: object, second: object): Promise<boolean>;
97
148
  declare function isLinked<FirstShape extends SchemaShape, SecondShape extends SchemaShape>(firstCollection: Collection<FirstShape>, firstId: string, secondCollection: Collection<SecondShape>, secondId: string): Promise<boolean>;
98
- declare function pin(source: object, name: string, target: object): Promise<void>;
99
- declare function pin<SourceShape extends SchemaShape, TargetShape extends SchemaShape>(sourceCollection: Collection<SourceShape>, sourceId: string, name: string, targetCollection: Collection<TargetShape>, targetId: string): Promise<void>;
100
- declare function unpin(source: object, name: string): Promise<void>;
101
- declare function unpin<SourceShape extends SchemaShape>(sourceCollection: Collection<SourceShape>, sourceId: string, name: string): Promise<void>;
102
- declare function isPinned(source: object, name: string, target: object): Promise<boolean>;
103
- declare function isPinned<SourceShape extends SchemaShape, TargetShape extends SchemaShape>(sourceCollection: Collection<SourceShape>, sourceId: string, name: string, targetCollection: Collection<TargetShape>, targetId: string): Promise<boolean>;
104
- declare class CollectionQuery<Shape extends SchemaShape> implements Store<CollectionRecord<Shape>[]> {
105
- private readonly collection;
106
- private joins;
107
- private joinIncludes;
108
- private pinIncludes;
109
- private cachedStore?;
110
- constructor(collection: Collection<Shape>);
111
- join(record: object): this;
112
- join<OtherShape extends SchemaShape>(collection: Collection<OtherShape>): this;
113
- join<OtherShape extends SchemaShape>(collection: Collection<OtherShape>, id: string): this;
114
- with<OtherShape extends SchemaShape>(name: string, target: Collection<OtherShape>): this;
115
- get(): CollectionRecord<Shape>[];
116
- subscribe(listener: Listener): () => void;
117
- store(): Store<CollectionRecord<Shape>[]>;
118
- }
119
- declare class QueryBuilder {
120
- from<Shape extends SchemaShape>(collection: Collection<Shape>): CollectionQuery<Shape>;
121
- }
122
- declare function useQuery<Output>(query: (builder: QueryBuilder) => Store<Output>): Output;
149
+ declare function useList<Shape extends SchemaShape>(collection: Collection<Shape>, options?: ListOptions<Shape>): string[];
150
+ declare function useView<Shape extends SchemaShape>(collection: Collection<Shape>, id: string, options?: ViewOptions): CollectionView<Shape> | null | undefined;
151
+ declare function useField<Shape extends SchemaShape, Key extends CollectionFieldKey<Shape>>(collection: Collection<Shape>, id: string, key: Key): CollectionFieldValue<Shape, Key> | undefined;
123
152
  //#endregion
124
153
  //#region src/state/setting.d.ts
125
154
  type Setting<Value> = WritableStore<Value>;
155
+ type SetSettingValue<Value> = SetStoreValue<Value>;
126
156
  declare function setting<Value extends string | number | boolean>(key: string, initialValue: Value): Setting<Value>;
127
- declare function useSetting<Value>(value: Setting<Value>): Value;
157
+ declare function useSetting<Value>(value: Setting<Value>): readonly [Value, SetStoreValue<Value>];
128
158
  //#endregion
129
- export { Atom, Collection, CollectionRecord, Listener, LiveStore, QueryBuilder, Setting, Store, WritableStore, atom, collection, isLinked, isPinned, link, pin, setting, unlink, unpin, useAtom, useQuery, useSetting, useStore };
159
+ export { Atom, Collection, CollectionView, ListOptions, Listener, LiveStore, SetSettingValue, SetStoreValue, Setting, Store, WritableStore, atom, collection, isLinked, link, setting, unlink, useAtom, useField, useList, useSetting, useStore, useView };