bleam 0.0.10 → 0.0.12

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 (90) hide show
  1. package/dist/ai.cjs +1872 -1182
  2. package/dist/ai.d.cts +267 -234
  3. package/dist/ai.d.ts +267 -234
  4. package/dist/ai.js +1859 -1167
  5. package/dist/cli.cjs +3 -183
  6. package/dist/cli.d.cts +3 -47
  7. package/dist/cli.d.ts +3 -47
  8. package/dist/cli.js +3 -183
  9. package/dist/config.d.cts +1 -1
  10. package/dist/config.d.ts +1 -1
  11. package/dist/{files-Ds1wT8C2.js → files-BXVkPrPN.js} +6 -1
  12. package/dist/{files-Bo7h9fik.cjs → files-DxaQ-Nv0.cjs} +11 -0
  13. package/dist/files.cjs +1 -1
  14. package/dist/files.js +1 -1
  15. package/dist/index.d.cts +1 -1
  16. package/dist/index.d.ts +1 -1
  17. package/dist/platform.cjs +1 -13
  18. package/dist/platform.d.cts +1 -28
  19. package/dist/platform.d.ts +1 -28
  20. package/dist/platform.js +1 -10
  21. package/dist/schema-B5BfdswF.js +226 -0
  22. package/dist/schema-BnVZOXfu.cjs +286 -0
  23. package/dist/schema-D5eImHxu.d.cts +125 -0
  24. package/dist/schema-SSjokbtw.d.ts +125 -0
  25. package/dist/schema.cjs +10 -2
  26. package/dist/schema.d.cts +2 -2
  27. package/dist/schema.d.ts +2 -2
  28. package/dist/schema.js +2 -2
  29. package/dist/state-Dh3HLixb.js +874 -0
  30. package/dist/state-LssDgpff.cjs +973 -0
  31. package/dist/state.cjs +16 -12
  32. package/dist/state.d.cts +144 -140
  33. package/dist/state.d.ts +145 -140
  34. package/dist/state.js +3 -3
  35. package/dist/{ui-Bg11tvlc.d.ts → ui-1WepaMS4.d.cts} +1 -1
  36. package/dist/{ui-Dd7SXdbg.d.cts → ui-D7bRLYee.d.ts} +7 -7
  37. package/dist/ui.d.cts +1 -1
  38. package/dist/ui.d.ts +1 -1
  39. package/dist/window.d.cts +1 -1
  40. package/dist/window.d.ts +1 -1
  41. package/package.json +3 -1
  42. package/templates/foundation-models/app/index.tsx +77 -15
  43. package/templates/image-generation/app/index.tsx +4 -2
  44. package/templates/native/ios/Bleam/AI/Flux2/Configuration/ModelRegistry.swift +1 -1
  45. package/templates/native/ios/Bleam/AI/Flux2/Pipeline/FluxImageRunner.swift +7 -2
  46. package/templates/native/ios/Bleam/AI/TextGeneration/Bonsai/BonsaiTextGenerator.swift +46 -0
  47. package/templates/native/ios/Bleam/AI/TextGeneration/Bonsai/BonsaiTextModel.swift +107 -0
  48. package/templates/native/ios/Bleam/AI/TextGeneration/Bonsai/BonsaiTextSnapshotValidator.swift +201 -0
  49. package/templates/native/ios/Bleam/AI/TextGeneration/Core/GenerationTypes.swift +85 -0
  50. package/templates/native/ios/Bleam/AI/TextGeneration/Core/ModelCapabilities.swift +21 -0
  51. package/templates/native/ios/Bleam/AI/TextGeneration/Core/TextKVCache.swift +23 -0
  52. package/templates/native/ios/Bleam/AI/TextGeneration/Core/TokenSampler.swift +79 -0
  53. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3CheckpointLoader.swift +161 -0
  54. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3Configuration.swift +119 -0
  55. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3InferenceSession.swift +84 -0
  56. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3Layers.swift +197 -0
  57. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3Model.swift +130 -0
  58. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Checkpoint.swift +102 -0
  59. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Configuration.swift +140 -0
  60. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Model.swift +112 -0
  61. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Session.swift +121 -0
  62. package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridCache.swift +42 -0
  63. package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridFullAttention.swift +57 -0
  64. package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridLayers.swift +58 -0
  65. package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridLinearAttention.swift +111 -0
  66. package/templates/native/ios/Bleam/AppDelegate.swift +0 -206
  67. package/templates/native/ios/Bleam.xcodeproj/project.pbxproj +135 -129
  68. package/templates/native/ios/GenerationService/BonsaiTextGenerationRunner.swift +103 -0
  69. package/templates/native/ios/GenerationService/ImageGenerationRunner.swift +19 -7
  70. package/templates/native/ios/GenerationService/main.swift +174 -48
  71. package/templates/native/ios/Podfile.lock +173 -173
  72. package/templates/native/ios/Shared/Generation/GenerationServiceProtocol.swift +3 -0
  73. package/templates/native/ios/Shared/Generation/GenerationWorkerProtocol.swift +44 -0
  74. package/templates/native/modules/bleam-runtime/ios/AIModule.swift +239 -341
  75. package/templates/native/modules/bleam-runtime/ios/GenerationContracts.swift +47 -0
  76. package/templates/native/modules/bleam-runtime/ios/PlatformModule.swift +0 -191
  77. package/templates/text-generation/app/index.tsx +124 -0
  78. package/templates/text-generation/app.config.ts +5 -0
  79. package/templates/updates/README.md +43 -199
  80. package/templates/updates/src/index.ts +5 -98
  81. package/templates/updates/src/schema.ts +18 -173
  82. package/dist/schema-Bo5Jvqus.js +0 -90
  83. package/dist/schema-DOOjfXvs.d.ts +0 -58
  84. package/dist/schema-ENSMX_1t.d.cts +0 -58
  85. package/dist/schema-rQ13mrpD.cjs +0 -102
  86. package/dist/state-Bx0VlTlO.cjs +0 -852
  87. package/dist/state-CAwe-Vw1.js +0 -767
  88. package/templates/native/ios/PlatformHelper/main.swift +0 -726
  89. /package/dist/{config-Cms0rvqg.d.ts → config-COcRnn5a.d.cts} +0 -0
  90. /package/dist/{config-CufOVJV3.d.cts → config-Chi-flpJ.d.ts} +0 -0
package/dist/state.cjs CHANGED
@@ -1,19 +1,23 @@
1
1
  require('./native-runtime-CsXnXkQn.cjs');
2
2
  require('./crypto-CT3VZ7lF.cjs');
3
- const require_state = require('./state-Bx0VlTlO.cjs');
4
- require('./schema-rQ13mrpD.cjs');
3
+ const require_schema = require('./schema-BnVZOXfu.cjs');
4
+ const require_state = require('./state-LssDgpff.cjs');
5
5
 
6
- exports.Collection = require_state.Collection;
7
- exports.LiveStore = require_state.LiveStore;
6
+ exports.CollectionVersionConflictError = require_state.CollectionVersionConflictError;
7
+ exports.array = require_schema.array;
8
8
  exports.atom = require_state.atom;
9
- exports.collection = require_state.collection;
10
- exports.isLinked = require_state.isLinked;
11
- exports.link = require_state.link;
12
- exports.setting = require_state.setting;
13
- exports.unlink = require_state.unlink;
9
+ exports.atomCollection = require_state.atomCollection;
10
+ exports.boolean = require_schema.boolean;
11
+ exports.literal = require_schema.literal;
12
+ exports.mutateAtom = require_state.mutateAtom;
13
+ exports.number = require_schema.number;
14
+ exports.object = require_schema.object;
15
+ exports.queryAtom = require_state.queryAtom;
16
+ exports.string = require_schema.string;
17
+ exports.transactionAtom = require_state.transactionAtom;
14
18
  exports.useAtom = require_state.useAtom;
19
+ exports.useAtomValue = require_state.useAtomValue;
15
20
  exports.useField = require_state.useField;
16
21
  exports.useList = require_state.useList;
17
- exports.useSetting = require_state.useSetting;
18
- exports.useStore = require_state.useStore;
19
- exports.useView = require_state.useView;
22
+ exports.useRow = require_state.useRow;
23
+ exports.useSetAtom = require_state.useSetAtom;
package/dist/state.d.cts CHANGED
@@ -1,159 +1,163 @@
1
- import { a as FieldValue, f as SchemaOutput, l as SchemaInput, m as SchemaShape, t as BleamSchema } from "./schema-ENSMX_1t.cjs";
1
+ import { A as array, C as SchemaOutput, E as SchemaShape, F as number, I as object, P as literal, R as string, _ as ObjectField, b as SchemaInput, c as FieldPath, j as boolean, k as ValueAtFieldPath, s as FieldOutput, w as SchemaPatch } from "./schema-D5eImHxu.cjs";
2
2
 
3
3
  //#region src/state/atom.d.ts
4
- type Listener = () => void;
5
- interface Store<Value> {
6
- get(): Value;
7
- subscribe(listener: Listener): () => void;
4
+ declare const atomValue: unique symbol;
5
+ declare const atomWrite: unique symbol;
6
+ interface Atom<Value> {
7
+ readonly [atomValue]: Value;
8
8
  }
9
- interface WritableStore<Value> extends Store<Value> {
10
- set(value: Value): void;
11
- update(updater: (value: Value) => Value): void;
12
- }
13
- declare class LiveStore<Value> implements WritableStore<Value> {
14
- private value;
15
- private listeners;
16
- constructor(value: Value);
17
- get(): Value;
18
- set(value: Value): void;
19
- update(updater: (value: Value) => Value): void;
20
- subscribe(listener: Listener): () => void;
9
+ interface WritableAtom<Value, Args$1 extends unknown[], Result$1> extends Atom<Value> {
10
+ readonly [atomWrite]: {
11
+ args: Args$1;
12
+ result: Result$1;
13
+ };
21
14
  }
22
- type Atom<Value> = WritableStore<Value>;
23
- type SetStoreValue<Value> = (value: Value | ((current: Value) => Value)) => void;
24
- declare function atom<Value>(initialValue: Value): Atom<Value>;
25
- declare function useStore<Value>(store: Store<Value>): Value;
26
- declare function useAtom<Value>(value: Atom<Value>): readonly [Value, SetStoreValue<Value>];
15
+ type SetStateAction<Value> = Value | ((current: Value) => Value);
16
+ type PrimitiveAtom<Value> = WritableAtom<Value, [SetStateAction<Value>], void>;
17
+ type Getter = <Value>(value: Atom<Value>) => Value;
18
+ type Setter = <Value, Args$1 extends unknown[], Result$1>(value: WritableAtom<Value, Args$1, Result$1>, ...args: Args$1) => Result$1;
19
+ type AtomOptions = {
20
+ storage?: string;
21
+ };
22
+ declare function atom<Value, Args$1 extends unknown[], Result$1>(read: (get: Getter) => Value, write: (get: Getter, set: Setter, ...args: Args$1) => Result$1): WritableAtom<Value, Args$1, Result$1>;
23
+ declare function atom<Value>(read: (get: Getter) => Value): Atom<Value>;
24
+ declare function atom<Value>(initialValue: Value, options?: AtomOptions): PrimitiveAtom<Value>;
25
+ declare function useAtomValue<Value>(value: Atom<Value>): Awaited<Value>;
26
+ declare function useSetAtom<Value, Args$1 extends unknown[], Result$1>(value: WritableAtom<Value, Args$1, Result$1>): (...args: Args$1) => Result$1;
27
+ declare function useAtom<Value, Args$1 extends unknown[], Result$1>(value: WritableAtom<Value, Args$1, Result$1>): [Awaited<Value>, (...args: Args$1) => Result$1];
27
28
  //#endregion
28
29
  //#region src/state/collection.d.ts
29
- type FieldRecord = Record<string, FieldValue | undefined>;
30
- type CollectionFields<Shape extends SchemaShape> = SchemaOutput<Shape>;
31
- type CollectionInput<Shape extends SchemaShape> = SchemaInput<Shape>;
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;
53
- };
54
- type CollectionReference = {
55
- readonly name: string;
56
- get(id: string): Promise<unknown>;
30
+ declare const collectionBrand: unique symbol;
31
+ type AnyShape = SchemaShape;
32
+ type AnyCollection = CollectionAtom<AnyShape>;
33
+ type Scalar = string | number | boolean;
34
+ type MaybePromise<Value> = Value | Promise<Value>;
35
+ type Order = 'asc' | 'desc';
36
+ type Comparison = 'equals' | 'greater-than' | 'less-than' | 'contains';
37
+ type ComparisonFor<Value> = Value extends number ? Exclude<Comparison, 'contains'> : Value extends string ? 'equals' | 'contains' : 'equals';
38
+ type WhereClauseValue<Value> = Value | readonly [ComparisonFor<Value>, Value] | ReadonlyArray<readonly [ComparisonFor<Value>, Value]>;
39
+ type ScalarFieldPath<Shape extends SchemaShape> = { [Key in Extract<keyof Shape, string>]: Shape[Key] extends {
40
+ kind: 'object';
41
+ shape: infer Nested extends SchemaShape;
42
+ } ? `${Key}.${ScalarFieldPath<Nested>}` : Shape[Key] extends {
43
+ kind: 'array';
44
+ } ? never : Key }[Extract<keyof Shape, string>];
45
+ type ScalarAtPath<Shape extends SchemaShape, Path$1 extends ScalarFieldPath<Shape>> = Path$1 extends `${infer Key}.${infer Rest}` ? Key extends keyof Shape ? Shape[Key] extends ObjectField<infer Nested> ? Rest extends ScalarFieldPath<Nested> ? ScalarAtPath<Nested, Rest> : never : never : never : Path$1 extends keyof Shape ? Extract<FieldOutput<Shape[Path$1]>, Scalar> : never;
46
+ type CollectionRow<Shape extends SchemaShape> = {
47
+ readonly id: string;
48
+ readonly collection: string;
49
+ readonly version: number;
50
+ readonly createdAt: string;
51
+ readonly updatedAt: string;
52
+ readonly data: SchemaOutput<Shape>;
53
+ readonly links: Readonly<Record<string, readonly string[]>>;
57
54
  };
58
- type ViewOptions = {
59
- links?: CollectionReference[];
55
+ interface CollectionAtom<Shape extends SchemaShape> extends Atom<Promise<readonly string[]>> {
56
+ readonly [collectionBrand]: Shape;
57
+ }
58
+ declare class CollectionVersionConflictError extends Error {
59
+ readonly collection: string;
60
+ readonly id: string;
61
+ readonly expectedVersion: number;
62
+ readonly actualVersion: number;
63
+ readonly name = "CollectionVersionConflictError";
64
+ constructor(collection: string, id: string, expectedVersion: number, actualVersion: number);
65
+ }
66
+ type UpdateOptions = {
67
+ ifVersion?: number;
60
68
  };
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;
69
+ type RowOptions = {
70
+ links?: readonly AnyCollection[];
67
71
  };
68
- type NormalizedListOptions = {
69
- where?: Record<string, Array<[string, FieldValue]>>;
70
- sortBy?: string;
71
- order?: 'asc' | 'desc';
72
- take?: number;
72
+ type CollectionWhere<Shape extends SchemaShape> = Partial<{ [Path in ScalarFieldPath<Shape>]: WhereClauseValue<ScalarAtPath<Shape, Path>> }>;
73
+ type WhereClause = {
74
+ path: string;
75
+ comparison: Comparison;
76
+ operand: Scalar;
73
77
  };
74
- type RecordChange = {
75
- collection: string;
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: {
78
+ type QueryPlan = {
79
+ terminal: 'ids' | 'row' | 'field';
80
+ where: WhereClause[];
81
+ from?: {
84
82
  collection: string;
85
83
  id: string;
86
84
  };
87
- right: {
88
- collection: string;
89
- id: string;
85
+ sort?: {
86
+ path: string;
87
+ order: Order;
90
88
  };
89
+ take?: number;
90
+ id?: string;
91
+ path?: string;
92
+ links?: string[];
91
93
  };
92
- type ListDependencies = {
93
- collection: string;
94
- paths: Set<string>;
95
- options: NormalizedListOptions;
94
+ type QueryTerminal<Shape extends SchemaShape, Result$1> = {
95
+ readonly plan: QueryPlan;
96
+ readonly result?: Result$1;
97
+ readonly shape?: Shape;
96
98
  };
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[]>;
99
+ interface QueryBuilder<Shape extends SchemaShape> {
100
+ where(filters: CollectionWhere<Shape>): QueryBuilder<Shape>;
101
+ from<OtherShape extends SchemaShape>(other: CollectionAtom<OtherShape>, id: string): QueryBuilder<Shape>;
102
+ sortBy(path: ScalarFieldPath<Shape> | 'createdAt' | 'updatedAt', order?: Order): QueryBuilder<Shape>;
103
+ take(count: number): QueryBuilder<Shape>;
104
+ ids(): QueryTerminal<Shape, readonly string[]>;
105
+ row(id: string, options?: RowOptions): QueryTerminal<Shape, CollectionRow<Shape> | null>;
106
+ field<Path$1 extends FieldPath<Shape>>(id: string, path: Path$1): QueryTerminal<Shape, ValueAtFieldPath<Shape, Path$1> | undefined>;
107
+ }
108
+ type InsertTerminal<Shape extends SchemaShape> = {
109
+ kind: 'insert';
110
+ args: [SchemaInput<Shape>];
111
+ result: string;
104
112
  };
105
- declare class Collection<Shape extends SchemaShape> {
106
- readonly name: string;
107
- readonly shape: Shape;
108
- readonly validator: BleamSchema<SchemaInput<Shape>, SchemaOutput<Shape>>;
109
- private records;
110
- private lists;
111
- private fields;
112
- constructor(name: string, shape: Shape);
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[]>;
143
- private deleteLinksForRecord;
113
+ type UpdateTerminal<Shape extends SchemaShape> = {
114
+ kind: 'update';
115
+ id: string;
116
+ args: [SchemaPatch<Shape>, UpdateOptions?];
117
+ result: CollectionRow<Shape>;
118
+ };
119
+ type RemoveTerminal = {
120
+ kind: 'remove';
121
+ id: string;
122
+ args: [];
123
+ result: boolean;
124
+ };
125
+ type LinkTerminal = {
126
+ kind: 'link' | 'unlink';
127
+ id: string;
128
+ other: AnyCollection;
129
+ args: [string];
130
+ result: boolean;
131
+ };
132
+ type MutationTerminal<Shape extends SchemaShape> = InsertTerminal<Shape> | UpdateTerminal<Shape> | RemoveTerminal | LinkTerminal;
133
+ interface MutationBuilder<Shape extends SchemaShape> {
134
+ insert(): InsertTerminal<Shape>;
135
+ update(id: string): UpdateTerminal<Shape>;
136
+ remove(id: string): RemoveTerminal;
137
+ link<OtherShape extends SchemaShape>(id: string, other: CollectionAtom<OtherShape>): LinkTerminal;
138
+ unlink<OtherShape extends SchemaShape>(id: string, other: CollectionAtom<OtherShape>): LinkTerminal;
144
139
  }
145
- declare function collection<Shape extends SchemaShape>(name: string, shape: Shape): Collection<Shape>;
146
- declare function link<FirstShape extends SchemaShape, SecondShape extends SchemaShape>(firstCollection: Collection<FirstShape>, firstId: string, secondCollection: Collection<SecondShape>, secondId: string): Promise<void>;
147
- declare function unlink<FirstShape extends SchemaShape, SecondShape extends SchemaShape>(firstCollection: Collection<FirstShape>, firstId: string, secondCollection: Collection<SecondShape>, secondId: string): Promise<void>;
148
- declare function isLinked<FirstShape extends SchemaShape, SecondShape extends SchemaShape>(firstCollection: Collection<FirstShape>, firstId: string, secondCollection: Collection<SecondShape>, secondId: string): Promise<boolean>;
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;
152
- //#endregion
153
- //#region src/state/setting.d.ts
154
- type Setting<Value> = WritableStore<Value>;
155
- type SetSettingValue<Value> = SetStoreValue<Value>;
156
- declare function setting<Value extends string | number | boolean>(key: string, initialValue: Value): Setting<Value>;
157
- declare function useSetting<Value>(value: Setting<Value>): readonly [Value, SetStoreValue<Value>];
140
+ type TerminalArgs<Terminal> = Terminal extends {
141
+ args: infer Args extends unknown[];
142
+ } ? Args : never;
143
+ type TerminalResult<Terminal> = Terminal extends {
144
+ result: infer Result;
145
+ } ? Result : never;
146
+ declare function atomCollection<const Shape extends SchemaShape>(name: string, shape: Shape): CollectionAtom<Shape>;
147
+ declare function queryAtom<Shape extends SchemaShape, Result$1>(collection: CollectionAtom<Shape>, build: (builder: QueryBuilder<Shape>) => QueryTerminal<Shape, Result$1>): Atom<Promise<Result$1>>;
148
+ declare function mutateAtom<Shape extends SchemaShape, Terminal extends MutationTerminal<Shape>>(collection: CollectionAtom<Shape>, build: (builder: MutationBuilder<Shape>) => Terminal): WritableAtom<null, TerminalArgs<Terminal>, Promise<TerminalResult<Terminal>>>;
149
+ interface TransactionContext {
150
+ get<Shape extends SchemaShape>(collection: CollectionAtom<Shape>, id: string, options?: RowOptions): Promise<CollectionRow<Shape> | null>;
151
+ query<Shape extends SchemaShape, Result$1>(collection: CollectionAtom<Shape>, build: (builder: QueryBuilder<Shape>) => QueryTerminal<Shape, Result$1>): Promise<Result$1>;
152
+ insert<Shape extends SchemaShape>(collection: CollectionAtom<Shape>, value: SchemaInput<Shape>): Promise<string>;
153
+ update<Shape extends SchemaShape>(collection: CollectionAtom<Shape>, id: string, patch: SchemaPatch<Shape>, options?: UpdateOptions): Promise<CollectionRow<Shape>>;
154
+ remove<Shape extends SchemaShape>(collection: CollectionAtom<Shape>, id: string): Promise<boolean>;
155
+ link<LeftShape extends SchemaShape, RightShape extends SchemaShape>(collection: CollectionAtom<LeftShape>, id: string, other: CollectionAtom<RightShape>, otherId: string): Promise<boolean>;
156
+ unlink<LeftShape extends SchemaShape, RightShape extends SchemaShape>(collection: CollectionAtom<LeftShape>, id: string, other: CollectionAtom<RightShape>, otherId: string): Promise<boolean>;
157
+ }
158
+ declare function transactionAtom<Args$1 extends unknown[], Result$1>(action: (context: TransactionContext, ...args: Args$1) => MaybePromise<Result$1>): WritableAtom<null, Args$1, Promise<Result$1>>;
159
+ declare function useList<Shape extends SchemaShape>(collection: CollectionAtom<Shape>, build?: (builder: QueryBuilder<Shape>) => QueryTerminal<Shape, readonly string[]>): readonly string[];
160
+ declare function useRow<Shape extends SchemaShape>(collection: CollectionAtom<Shape>, id: string, options?: RowOptions): CollectionRow<Shape> | null;
161
+ declare function useField<Shape extends SchemaShape, Path$1 extends FieldPath<Shape>>(collection: CollectionAtom<Shape>, id: string, path: Path$1): ValueAtFieldPath<Shape, Path$1> | undefined;
158
162
  //#endregion
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 };
163
+ export { type Atom, type AtomOptions, CollectionAtom, CollectionRow, CollectionVersionConflictError, CollectionWhere, type Getter, MutationBuilder, type PrimitiveAtom, QueryBuilder, RowOptions, type SetStateAction, type Setter, TransactionContext, UpdateOptions, type WritableAtom, array, atom, atomCollection, boolean, literal, mutateAtom, number, object, queryAtom, string, transactionAtom, useAtom, useAtomValue, useField, useList, useRow, useSetAtom };