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.
- package/dist/ai.cjs +3984 -25
- package/dist/ai.d.cts +503 -20
- package/dist/ai.d.ts +503 -20
- package/dist/ai.js +3946 -26
- package/dist/animated.cjs +1 -1
- package/dist/animated.js +1 -1
- package/dist/app.cjs +92 -0
- package/dist/app.js +92 -0
- package/dist/cli.cjs +653 -86
- package/dist/cli.d.cts +89 -1
- package/dist/cli.d.ts +89 -1
- package/dist/cli.js +654 -88
- package/dist/{config-ClDGHNb3.d.ts → config-Cms0rvqg.d.ts} +1 -0
- package/dist/{config-D3gPaVMb.d.cts → config-CufOVJV3.d.cts} +1 -0
- package/dist/config.d.cts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/crypto.d.cts +0 -2
- package/dist/crypto.d.ts +1 -1
- package/dist/dev-protocol.d.cts +14 -1
- package/dist/dev-protocol.d.ts +14 -1
- package/dist/files-Bo7h9fik.cjs +468 -0
- package/dist/files-Ds1wT8C2.js +445 -0
- package/dist/files-DwA7pzr3.d.cts +99 -0
- package/dist/files-VrkQlKIT.d.ts +99 -0
- package/dist/files.cjs +7 -0
- package/dist/files.d.cts +2 -0
- package/dist/files.d.ts +2 -0
- package/dist/files.js +4 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/native-sqlite-xcGdamRD.js +64 -0
- package/dist/native-sqlite-yQLD5s9i.cjs +66 -0
- package/dist/platform.cjs +27 -0
- package/dist/platform.d.cts +39 -0
- package/dist/platform.d.ts +39 -0
- package/dist/platform.js +21 -0
- package/dist/runtime.d.cts +1 -6
- package/dist/runtime.d.ts +1 -6
- package/dist/{schema-ipsECAso.d.ts → schema-DOOjfXvs.d.ts} +1 -1
- package/dist/{schema-BOuUHcqo.d.cts → schema-ENSMX_1t.d.cts} +1 -1
- package/dist/schema.cjs +1 -1
- package/dist/schema.d.cts +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +1 -1
- package/dist/state-Bx0VlTlO.cjs +852 -0
- package/dist/state-CAwe-Vw1.js +767 -0
- package/dist/state.cjs +17 -763
- package/dist/state.d.cts +107 -77
- package/dist/state.d.ts +107 -77
- package/dist/state.js +4 -745
- package/dist/ui-1WepaMS4.d.cts +92 -0
- package/dist/ui-Ce-pnUUA.d.ts +92 -0
- package/dist/ui.cjs +286 -35
- package/dist/ui.d.cts +2 -30
- package/dist/ui.d.ts +2 -30
- package/dist/ui.js +283 -36
- package/dist/window.cjs +596 -0
- package/dist/window.d.cts +63 -0
- package/dist/window.d.ts +63 -0
- package/dist/window.js +589 -0
- package/package.json +16 -14
- package/templates/basic/app/index.tsx +8 -5
- package/templates/foundation-models/app/index.tsx +32 -0
- package/templates/foundation-models/app.config.ts +5 -0
- package/templates/image-generation/app/index.tsx +39 -0
- package/templates/image-generation/app.config.ts +5 -0
- package/templates/state/app/index.tsx +30 -0
- package/templates/state/app.config.ts +5 -0
- package/dist/chrome.cjs +0 -265
- package/dist/chrome.d.cts +0 -19
- package/dist/chrome.d.ts +0 -19
- package/dist/chrome.js +0 -262
- package/dist/fs.cjs +0 -13
- package/dist/fs.d.cts +0 -8
- package/dist/fs.d.ts +0 -8
- package/dist/fs.js +0 -12
- package/dist/native-macos-D6p2SmUj.js +0 -20
- package/dist/native-macos-DLwo_ii9.cjs +0 -31
- package/dist/native-runtime-CbPzrs8j.d.cts +0 -33
- package/dist/native-runtime-DxHSrsTX.d.ts +0 -33
- package/dist/native.cjs +0 -135
- package/dist/native.d.cts +0 -34
- package/dist/native.d.ts +0 -34
- package/dist/native.js +0 -135
- /package/dist/{schema-DVmoD9JL.js → schema-Bo5Jvqus.js} +0 -0
- /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-
|
|
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
|
|
31
|
-
type
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
56
|
-
collection:
|
|
92
|
+
type ListDependencies = {
|
|
93
|
+
collection: string;
|
|
94
|
+
paths: Set<string>;
|
|
95
|
+
options: NormalizedListOptions;
|
|
57
96
|
};
|
|
58
|
-
type
|
|
59
|
-
|
|
60
|
-
|
|
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
|
|
67
|
-
private
|
|
109
|
+
private records;
|
|
110
|
+
private lists;
|
|
111
|
+
private fields;
|
|
68
112
|
constructor(name: string, shape: Shape);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
private
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
|
99
|
-
declare function
|
|
100
|
-
declare function
|
|
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,
|
|
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-
|
|
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
|
|
31
|
-
type
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
56
|
-
collection:
|
|
92
|
+
type ListDependencies = {
|
|
93
|
+
collection: string;
|
|
94
|
+
paths: Set<string>;
|
|
95
|
+
options: NormalizedListOptions;
|
|
57
96
|
};
|
|
58
|
-
type
|
|
59
|
-
|
|
60
|
-
|
|
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
|
|
67
|
-
private
|
|
109
|
+
private records;
|
|
110
|
+
private lists;
|
|
111
|
+
private fields;
|
|
68
112
|
constructor(name: string, shape: Shape);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
private
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
|
99
|
-
declare function
|
|
100
|
-
declare function
|
|
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,
|
|
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 };
|