@livestore/common 0.0.53 → 0.0.54-dev.0
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/.tsbuildinfo +1 -1
- package/dist/derived-mutations.d.ts +8 -8
- package/dist/devtools/index.d.ts +137 -0
- package/dist/devtools/index.d.ts.map +1 -0
- package/dist/devtools/index.js +115 -0
- package/dist/devtools/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/schema/index.d.ts +48 -1
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +57 -5
- package/dist/schema/index.js.map +1 -1
- package/package.json +3 -3
- package/src/devtools/index.ts +146 -0
- package/src/index.ts +1 -0
- package/src/schema/index.ts +73 -5
|
@@ -18,19 +18,19 @@ export declare const makeDerivedMutationDefsForTable: <TTableDef extends DbSchem
|
|
|
18
18
|
readonly [x: string]: any;
|
|
19
19
|
}>;
|
|
20
20
|
update: import("./schema/mutations.js").MutationDef<`_Derived_Update_${string}`, {
|
|
21
|
-
readonly where: {
|
|
22
|
-
[x: string]: any;
|
|
23
|
-
};
|
|
24
21
|
readonly values: {
|
|
25
22
|
[x: string]: any;
|
|
26
23
|
};
|
|
27
|
-
}, {
|
|
28
24
|
readonly where: {
|
|
29
25
|
[x: string]: any;
|
|
30
26
|
};
|
|
27
|
+
}, {
|
|
31
28
|
readonly values: {
|
|
32
29
|
[x: string]: any;
|
|
33
30
|
};
|
|
31
|
+
readonly where: {
|
|
32
|
+
[x: string]: any;
|
|
33
|
+
};
|
|
34
34
|
}>;
|
|
35
35
|
delete: import("./schema/mutations.js").MutationDef<`_Derived_Delete_${string}`, {
|
|
36
36
|
readonly where: {
|
|
@@ -60,19 +60,19 @@ export declare const deriveUpdateMutationDef: <TTableDef extends DbSchema.TableD
|
|
|
60
60
|
enabled: true;
|
|
61
61
|
};
|
|
62
62
|
}, Schema.Schema<any, any, never>>>(table: TTableDef) => import("./schema/mutations.js").MutationDef<`_Derived_Update_${string}`, {
|
|
63
|
-
readonly where: {
|
|
64
|
-
[x: string]: any;
|
|
65
|
-
};
|
|
66
63
|
readonly values: {
|
|
67
64
|
[x: string]: any;
|
|
68
65
|
};
|
|
69
|
-
}, {
|
|
70
66
|
readonly where: {
|
|
71
67
|
[x: string]: any;
|
|
72
68
|
};
|
|
69
|
+
}, {
|
|
73
70
|
readonly values: {
|
|
74
71
|
[x: string]: any;
|
|
75
72
|
};
|
|
73
|
+
readonly where: {
|
|
74
|
+
[x: string]: any;
|
|
75
|
+
};
|
|
76
76
|
}>;
|
|
77
77
|
export declare const deriveDeleteMutationDef: <TTableDef extends DbSchema.TableDef<DbSchema.DefaultSqliteTableDefConstrained, boolean, DbSchema.TableOptions & {
|
|
78
78
|
deriveMutations: {
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Schema } from '@livestore/utils/effect';
|
|
2
|
+
import { type SqliteDsl as __SqliteDsl } from 'effect-db-schema';
|
|
3
|
+
declare const SnapshotReq_base: Schema.TaggedStruct<"LSD.SnapshotReq", {
|
|
4
|
+
requestId: typeof Schema.String;
|
|
5
|
+
}>;
|
|
6
|
+
export declare class SnapshotReq extends SnapshotReq_base {
|
|
7
|
+
}
|
|
8
|
+
declare const SnapshotRes_base: Schema.TaggedStruct<"LSD.SnapshotRes", {
|
|
9
|
+
requestId: typeof Schema.String;
|
|
10
|
+
snapshot: Schema.Schema<Uint8Array, readonly number[], never>;
|
|
11
|
+
}>;
|
|
12
|
+
export declare class SnapshotRes extends SnapshotRes_base {
|
|
13
|
+
}
|
|
14
|
+
declare const SerializedSchemaReq_base: Schema.TaggedStruct<"LSD.SerializedSchemaReq", {
|
|
15
|
+
requestId: typeof Schema.String;
|
|
16
|
+
}>;
|
|
17
|
+
export declare class SerializedSchemaReq extends SerializedSchemaReq_base {
|
|
18
|
+
}
|
|
19
|
+
declare const SerializedSchemaRes_base: Schema.TaggedStruct<"LSD.SerializedSchemaRes", {
|
|
20
|
+
requestId: typeof Schema.String;
|
|
21
|
+
schema: Schema.transform<Schema.Struct<{
|
|
22
|
+
tables: Schema.Record$<typeof Schema.String, Schema.Struct<{
|
|
23
|
+
sqliteDef: Schema.Struct<{
|
|
24
|
+
name: typeof Schema.String;
|
|
25
|
+
columns: Schema.Record$<typeof Schema.String, Schema.Struct<{
|
|
26
|
+
columnType: Schema.Literal<["blob", "integer", "text", "real"]>;
|
|
27
|
+
nullable: typeof Schema.Boolean;
|
|
28
|
+
primaryKey: typeof Schema.Boolean;
|
|
29
|
+
}>>;
|
|
30
|
+
ast: typeof Schema.Any;
|
|
31
|
+
}>;
|
|
32
|
+
isSingleColumn: typeof Schema.Boolean;
|
|
33
|
+
options: typeof Schema.Any;
|
|
34
|
+
}>>;
|
|
35
|
+
}>, Schema.Schema<import("../schema/index.js").LiveStoreSchema<__SqliteDsl.DbSchema, import("../schema/mutations.js").MutationDefRecord>, import("../schema/index.js").LiveStoreSchema<__SqliteDsl.DbSchema, import("../schema/mutations.js").MutationDefRecord>, never>>;
|
|
36
|
+
}>;
|
|
37
|
+
export declare class SerializedSchemaRes extends SerializedSchemaRes_base {
|
|
38
|
+
}
|
|
39
|
+
declare const MutationBroadcast_base: Schema.TaggedStruct<"LSD.MutationBroadcast", {
|
|
40
|
+
requestId: typeof Schema.String;
|
|
41
|
+
mutationEventEncoded: Schema.Struct<{
|
|
42
|
+
mutation: typeof Schema.String;
|
|
43
|
+
args: typeof Schema.Any;
|
|
44
|
+
id: typeof Schema.String;
|
|
45
|
+
}>;
|
|
46
|
+
persisted: typeof Schema.Boolean;
|
|
47
|
+
}>;
|
|
48
|
+
export declare class MutationBroadcast extends MutationBroadcast_base {
|
|
49
|
+
}
|
|
50
|
+
declare const MutationLogReq_base: Schema.TaggedStruct<"LSD.MutationLogReq", {
|
|
51
|
+
requestId: typeof Schema.String;
|
|
52
|
+
}>;
|
|
53
|
+
export declare class MutationLogReq extends MutationLogReq_base {
|
|
54
|
+
}
|
|
55
|
+
declare const MutationLogRes_base: Schema.TaggedStruct<"LSD.MutationLogRes", {
|
|
56
|
+
requestId: typeof Schema.String;
|
|
57
|
+
mutationLog: Schema.Schema<Uint8Array, readonly number[], never>;
|
|
58
|
+
}>;
|
|
59
|
+
export declare class MutationLogRes extends MutationLogRes_base {
|
|
60
|
+
}
|
|
61
|
+
declare const SubscribeSignalsReq_base: Schema.TaggedStruct<"LSD.SubscribeSignalsReq", {
|
|
62
|
+
requestId: typeof Schema.String;
|
|
63
|
+
includeResults: typeof Schema.Boolean;
|
|
64
|
+
}>;
|
|
65
|
+
export declare class SubscribeSignalsReq extends SubscribeSignalsReq_base {
|
|
66
|
+
}
|
|
67
|
+
declare const SubscribeSignalsRes_base: Schema.TaggedStruct<"LSD.SubscribeSignalsRes", {
|
|
68
|
+
requestId: typeof Schema.String;
|
|
69
|
+
signals: typeof Schema.Any;
|
|
70
|
+
}>;
|
|
71
|
+
export declare class SubscribeSignalsRes extends SubscribeSignalsRes_base {
|
|
72
|
+
}
|
|
73
|
+
declare const SubscribeLiveQueriesReq_base: Schema.TaggedStruct<"LSD.SubscribeLiveQueriesReq", {
|
|
74
|
+
requestId: typeof Schema.String;
|
|
75
|
+
}>;
|
|
76
|
+
export declare class SubscribeLiveQueriesReq extends SubscribeLiveQueriesReq_base {
|
|
77
|
+
}
|
|
78
|
+
declare const SerializedLiveQuery_base: Schema.Struct<{
|
|
79
|
+
_tag: Schema.Literal<["js", "sql", "graphql"]>;
|
|
80
|
+
id: typeof Schema.Number;
|
|
81
|
+
label: typeof Schema.String;
|
|
82
|
+
runs: typeof Schema.Number;
|
|
83
|
+
executionTimes: Schema.Array$<typeof Schema.Number>;
|
|
84
|
+
lastestResult: typeof Schema.Any;
|
|
85
|
+
activeSubscriptions: Schema.Array$<Schema.Struct<{
|
|
86
|
+
frames: Schema.Array$<Schema.Struct<{
|
|
87
|
+
name: typeof Schema.String;
|
|
88
|
+
filePath: typeof Schema.String;
|
|
89
|
+
}>>;
|
|
90
|
+
}>>;
|
|
91
|
+
}>;
|
|
92
|
+
export declare class SerializedLiveQuery extends SerializedLiveQuery_base {
|
|
93
|
+
}
|
|
94
|
+
declare const SubscribeLiveQueriesRes_base: Schema.TaggedStruct<"LSD.SubscribeLiveQueriesRes", {
|
|
95
|
+
requestId: typeof Schema.String;
|
|
96
|
+
liveQueries: Schema.Array$<typeof SerializedLiveQuery>;
|
|
97
|
+
}>;
|
|
98
|
+
export declare class SubscribeLiveQueriesRes extends SubscribeLiveQueriesRes_base {
|
|
99
|
+
}
|
|
100
|
+
declare const ResetAllDataReq_base: Schema.TaggedStruct<"LSD.ResetAllDataReq", {
|
|
101
|
+
requestId: typeof Schema.String;
|
|
102
|
+
mode: Schema.Literal<["all-data", "only-app-db"]>;
|
|
103
|
+
}>;
|
|
104
|
+
export declare class ResetAllDataReq extends ResetAllDataReq_base {
|
|
105
|
+
}
|
|
106
|
+
declare const ResetAllDataRes_base: Schema.TaggedStruct<"LSD.ResetAllDataRes", {
|
|
107
|
+
requestId: typeof Schema.String;
|
|
108
|
+
}>;
|
|
109
|
+
export declare class ResetAllDataRes extends ResetAllDataRes_base {
|
|
110
|
+
}
|
|
111
|
+
declare const AppHostReadyReq_base: Schema.TaggedStruct<"LSD.AppHostReadyReq", {
|
|
112
|
+
requestId: typeof Schema.String;
|
|
113
|
+
}>;
|
|
114
|
+
export declare class AppHostReadyReq extends AppHostReadyReq_base {
|
|
115
|
+
}
|
|
116
|
+
declare const AppHostReadyRes_base: Schema.TaggedStruct<"LSD.AppHostReadyRes", {
|
|
117
|
+
requestId: typeof Schema.String;
|
|
118
|
+
}>;
|
|
119
|
+
export declare class AppHostReadyRes extends AppHostReadyRes_base {
|
|
120
|
+
}
|
|
121
|
+
declare const Disconnect_base: Schema.TaggedStruct<"LSD.Disconnect", {
|
|
122
|
+
requestId: typeof Schema.String;
|
|
123
|
+
}>;
|
|
124
|
+
export declare class Disconnect extends Disconnect_base {
|
|
125
|
+
}
|
|
126
|
+
declare const SchemaChanged_base: Schema.TaggedStruct<"LSD.SchemaChanged", {
|
|
127
|
+
requestId: typeof Schema.String;
|
|
128
|
+
}>;
|
|
129
|
+
export declare class SchemaChanged extends SchemaChanged_base {
|
|
130
|
+
}
|
|
131
|
+
export declare const MessageToAppHost: Schema.Union<[typeof SnapshotReq, typeof SerializedSchemaReq, typeof MutationLogReq, typeof SubscribeSignalsReq, typeof SubscribeLiveQueriesReq, typeof ResetAllDataReq, typeof AppHostReadyReq]>;
|
|
132
|
+
export type MessageToAppHost = typeof MessageToAppHost.Type;
|
|
133
|
+
export declare const MessageFromAppHost: Schema.Union<[typeof SnapshotRes, typeof SerializedSchemaRes, typeof MutationLogRes, typeof SubscribeSignalsRes, typeof SubscribeLiveQueriesRes, typeof ResetAllDataRes, typeof AppHostReadyRes, typeof Disconnect, typeof SchemaChanged, typeof MutationBroadcast]>;
|
|
134
|
+
export type MessageFromAppHost = typeof MessageFromAppHost.Type;
|
|
135
|
+
export declare const makeBc: () => BroadcastChannel;
|
|
136
|
+
export {};
|
|
137
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/devtools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,KAAK,SAAS,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAA;;;;AAOhE,qBAAa,WAAY,SAAQ,gBAE/B;CAAG;;;;;AAEL,qBAAa,WAAY,SAAQ,gBAG/B;CAAG;;;;AAEL,qBAAa,mBAAoB,SAAQ,wBAEvC;CAAG;;;;;;;;;;;;;;;;;;;AAEL,qBAAa,mBAAoB,SAAQ,wBAGvC;CAAG;;;;;;;;;;AAEL,qBAAa,iBAAkB,SAAQ,sBAIrC;CAAG;;;;AAEL,qBAAa,cAAe,SAAQ,mBAElC;CAAG;;;;;AAEL,qBAAa,cAAe,SAAQ,mBAGlC;CAAG;;;;;AAEL,qBAAa,mBAAoB,SAAQ,wBAGvC;CAAG;;;;;AAEL,qBAAa,mBAAoB,SAAQ,wBAGvC;CAAG;;;;AAEL,qBAAa,uBAAwB,SAAQ,4BAE3C;CAAG;;;;;;;;;;;;;;;AAEL,qBAAa,mBAAoB,SAAQ,wBAUvC;CAAG;;;;;AAEL,qBAAa,uBAAwB,SAAQ,4BAG3C;CAAG;;;;;AAEL,qBAAa,eAAgB,SAAQ,oBAGnC;CAAG;;;;AAEL,qBAAa,eAAgB,SAAQ,oBAEnC;CAAG;;;;AAEL,qBAAa,eAAgB,SAAQ,oBAEnC;CAAG;;;;AACL,qBAAa,eAAgB,SAAQ,oBAEnC;CAAG;;;;AAEL,qBAAa,UAAW,SAAQ,eAE9B;CAAG;;;;AAEL,qBAAa,aAAc,SAAQ,kBAEjC;CAAG;AAwBL,eAAO,MAAM,gBAAgB,mMAQ5B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAA;AAE3D,eAAO,MAAM,kBAAkB,sQAW9B,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC,IAAI,CAAA;AAE/D,eAAO,MAAM,MAAM,wBAAmD,CAAA"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Schema } from '@livestore/utils/effect';
|
|
2
|
+
import { LiveStoreSchemaSchema } from '../schema/index.js';
|
|
3
|
+
import { mutationEventSchemaEncodedAny } from '../schema/mutations.js';
|
|
4
|
+
const requestId = Schema.String;
|
|
5
|
+
export class SnapshotReq extends Schema.TaggedStruct('LSD.SnapshotReq', {
|
|
6
|
+
requestId,
|
|
7
|
+
}) {
|
|
8
|
+
}
|
|
9
|
+
export class SnapshotRes extends Schema.TaggedStruct('LSD.SnapshotRes', {
|
|
10
|
+
requestId,
|
|
11
|
+
snapshot: Schema.Uint8Array,
|
|
12
|
+
}) {
|
|
13
|
+
}
|
|
14
|
+
export class SerializedSchemaReq extends Schema.TaggedStruct('LSD.SerializedSchemaReq', {
|
|
15
|
+
requestId,
|
|
16
|
+
}) {
|
|
17
|
+
}
|
|
18
|
+
export class SerializedSchemaRes extends Schema.TaggedStruct('LSD.SerializedSchemaRes', {
|
|
19
|
+
requestId,
|
|
20
|
+
schema: LiveStoreSchemaSchema,
|
|
21
|
+
}) {
|
|
22
|
+
}
|
|
23
|
+
export class MutationBroadcast extends Schema.TaggedStruct('LSD.MutationBroadcast', {
|
|
24
|
+
requestId,
|
|
25
|
+
mutationEventEncoded: mutationEventSchemaEncodedAny,
|
|
26
|
+
persisted: Schema.Boolean,
|
|
27
|
+
}) {
|
|
28
|
+
}
|
|
29
|
+
export class MutationLogReq extends Schema.TaggedStruct('LSD.MutationLogReq', {
|
|
30
|
+
requestId,
|
|
31
|
+
}) {
|
|
32
|
+
}
|
|
33
|
+
export class MutationLogRes extends Schema.TaggedStruct('LSD.MutationLogRes', {
|
|
34
|
+
requestId,
|
|
35
|
+
mutationLog: Schema.Uint8Array,
|
|
36
|
+
}) {
|
|
37
|
+
}
|
|
38
|
+
export class SubscribeSignalsReq extends Schema.TaggedStruct('LSD.SubscribeSignalsReq', {
|
|
39
|
+
requestId,
|
|
40
|
+
includeResults: Schema.Boolean,
|
|
41
|
+
}) {
|
|
42
|
+
}
|
|
43
|
+
export class SubscribeSignalsRes extends Schema.TaggedStruct('LSD.SubscribeSignalsRes', {
|
|
44
|
+
requestId,
|
|
45
|
+
signals: Schema.Any,
|
|
46
|
+
}) {
|
|
47
|
+
}
|
|
48
|
+
export class SubscribeLiveQueriesReq extends Schema.TaggedStruct('LSD.SubscribeLiveQueriesReq', {
|
|
49
|
+
requestId,
|
|
50
|
+
}) {
|
|
51
|
+
}
|
|
52
|
+
export class SerializedLiveQuery extends Schema.Struct({
|
|
53
|
+
_tag: Schema.Literal('js', 'sql', 'graphql'),
|
|
54
|
+
id: Schema.Number,
|
|
55
|
+
label: Schema.String,
|
|
56
|
+
runs: Schema.Number,
|
|
57
|
+
executionTimes: Schema.Array(Schema.Number),
|
|
58
|
+
lastestResult: Schema.Any,
|
|
59
|
+
activeSubscriptions: Schema.Array(Schema.Struct({ frames: Schema.Array(Schema.Struct({ name: Schema.String, filePath: Schema.String })) })),
|
|
60
|
+
}) {
|
|
61
|
+
}
|
|
62
|
+
export class SubscribeLiveQueriesRes extends Schema.TaggedStruct('LSD.SubscribeLiveQueriesRes', {
|
|
63
|
+
requestId,
|
|
64
|
+
liveQueries: Schema.Array(SerializedLiveQuery),
|
|
65
|
+
}) {
|
|
66
|
+
}
|
|
67
|
+
export class ResetAllDataReq extends Schema.TaggedStruct('LSD.ResetAllDataReq', {
|
|
68
|
+
requestId,
|
|
69
|
+
mode: Schema.Literal('all-data', 'only-app-db'),
|
|
70
|
+
}) {
|
|
71
|
+
}
|
|
72
|
+
export class ResetAllDataRes extends Schema.TaggedStruct('LSD.ResetAllDataRes', {
|
|
73
|
+
requestId,
|
|
74
|
+
}) {
|
|
75
|
+
}
|
|
76
|
+
export class AppHostReadyReq extends Schema.TaggedStruct('LSD.AppHostReadyReq', {
|
|
77
|
+
requestId,
|
|
78
|
+
}) {
|
|
79
|
+
}
|
|
80
|
+
export class AppHostReadyRes extends Schema.TaggedStruct('LSD.AppHostReadyRes', {
|
|
81
|
+
requestId,
|
|
82
|
+
}) {
|
|
83
|
+
}
|
|
84
|
+
export class Disconnect extends Schema.TaggedStruct('LSD.Disconnect', {
|
|
85
|
+
requestId,
|
|
86
|
+
}) {
|
|
87
|
+
}
|
|
88
|
+
export class SchemaChanged extends Schema.TaggedStruct('LSD.SchemaChanged', {
|
|
89
|
+
requestId,
|
|
90
|
+
}) {
|
|
91
|
+
}
|
|
92
|
+
// export const Message = Schema.Union(
|
|
93
|
+
// SnapshotReq,
|
|
94
|
+
// SnapshotRes,
|
|
95
|
+
// SerializedSchemaReq,
|
|
96
|
+
// SerializedSchemaRes,
|
|
97
|
+
// MutationBroadcast,
|
|
98
|
+
// MutationLogReq,
|
|
99
|
+
// MutationLogRes,
|
|
100
|
+
// SubscribeSignalsReq,
|
|
101
|
+
// SubscribeSignalsRes,
|
|
102
|
+
// SubscribeLiveQueriesReq,
|
|
103
|
+
// SubscribeLiveQueriesRes,
|
|
104
|
+
// ResetAllDataReq,
|
|
105
|
+
// ResetAllDataRes,
|
|
106
|
+
// Disconnect,
|
|
107
|
+
// SchemaChanged,
|
|
108
|
+
// AppHostReadyReq,
|
|
109
|
+
// AppHostReadyRes,
|
|
110
|
+
// )
|
|
111
|
+
// export type Message = typeof Message.Type
|
|
112
|
+
export const MessageToAppHost = Schema.Union(SnapshotReq, SerializedSchemaReq, MutationLogReq, SubscribeSignalsReq, SubscribeLiveQueriesReq, ResetAllDataReq, AppHostReadyReq);
|
|
113
|
+
export const MessageFromAppHost = Schema.Union(SnapshotRes, SerializedSchemaRes, MutationLogRes, SubscribeSignalsRes, SubscribeLiveQueriesRes, ResetAllDataRes, AppHostReadyRes, Disconnect, SchemaChanged, MutationBroadcast);
|
|
114
|
+
export const makeBc = () => new BroadcastChannel('livestore-devtools');
|
|
115
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/devtools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAGhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAA;AAEtE,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAA;AAE/B,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE;IACtE,SAAS;CACV,CAAC;CAAG;AAEL,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE;IACtE,SAAS;IACT,QAAQ,EA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C1E,SAAS;CACV,CAAC;CAAG;AAEL,uCAAuC;AACvC,iBAAiB;AACjB,iBAAiB;AACjB,yBAAyB;AACzB,yBAAyB;AACzB,uBAAuB;AACvB,oBAAoB;AACpB,oBAAoB;AACpB,yBAAyB;AACzB,yBAAyB;AACzB,6BAA6B;AAC7B,6BAA6B;AAC7B,qBAAqB;AACrB,qBAAqB;AACrB,gBAAgB;AAChB,mBAAmB;AACnB,qBAAqB;AACrB,qBAAqB;AACrB,IAAI;AAEJ,4CAA4C;AAE5C,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,KAAK,CAC1C,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,eAAe,EACf,eAAe,CAChB,CAAA;AAID,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,KAAK,CAC5C,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,eAAe,EACf,eAAe,EACf,UAAU,EACV,aAAa,EACb,iBAAiB,CAClB,CAAA;AAID,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,oBAAoB,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,mCAAmC,CAAA;AACjD,cAAc,eAAe,CAAA;AAC7B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,mCAAmC,CAAA;AACjD,cAAc,eAAe,CAAA;AAC7B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,mCAAmC,CAAA;AACjD,cAAc,eAAe,CAAA;AAC7B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,mCAAmC,CAAA;AACjD,cAAc,eAAe,CAAA;AAC7B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA"}
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Schema } from '@livestore/utils/effect';
|
|
2
|
+
import { SqliteDsl } from 'effect-db-schema';
|
|
2
3
|
import type { MigrationOptions } from '../adapter-types.js';
|
|
3
4
|
import { type MutationDef, type MutationDefMap, type MutationDefRecord, type RawSqlMutation } from './mutations.js';
|
|
4
5
|
import { type TableDef } from './table-def.js';
|
|
@@ -7,7 +8,10 @@ export * as DbSchema from './table-def.js';
|
|
|
7
8
|
export * as ParseUtils from './parse-utils.js';
|
|
8
9
|
export * from './mutations.js';
|
|
9
10
|
export * from './schema-helpers.js';
|
|
11
|
+
export declare const LiveStoreSchemaSymbol: unique symbol;
|
|
12
|
+
export type LiveStoreSchemaSymbol = typeof LiveStoreSchemaSymbol;
|
|
10
13
|
export type LiveStoreSchema<TDbSchema extends SqliteDsl.DbSchema = SqliteDsl.DbSchema, TMutationsDefRecord extends MutationDefRecord = MutationDefRecord> = {
|
|
14
|
+
readonly _Type: LiveStoreSchemaSymbol;
|
|
11
15
|
/** Only used on type-level */
|
|
12
16
|
readonly _DbSchemaType: TDbSchema;
|
|
13
17
|
/** Only used on type-level */
|
|
@@ -51,4 +55,47 @@ declare namespace FromInputSchema {
|
|
|
51
55
|
} : never;
|
|
52
56
|
export {};
|
|
53
57
|
}
|
|
58
|
+
export declare const LiveStoreSchemaFromSelf: Schema.Schema<LiveStoreSchema>;
|
|
59
|
+
export declare const TableDefColumnSchema: Schema.Struct<{
|
|
60
|
+
columnType: Schema.Literal<["blob", "integer", "text", "real"]>;
|
|
61
|
+
nullable: typeof Schema.Boolean;
|
|
62
|
+
primaryKey: typeof Schema.Boolean;
|
|
63
|
+
}>;
|
|
64
|
+
export declare const TableDefSqliteSchema: Schema.Struct<{
|
|
65
|
+
name: typeof Schema.String;
|
|
66
|
+
columns: Schema.Record$<typeof Schema.String, Schema.Struct<{
|
|
67
|
+
columnType: Schema.Literal<["blob", "integer", "text", "real"]>;
|
|
68
|
+
nullable: typeof Schema.Boolean;
|
|
69
|
+
primaryKey: typeof Schema.Boolean;
|
|
70
|
+
}>>;
|
|
71
|
+
ast: typeof Schema.Any;
|
|
72
|
+
}>;
|
|
73
|
+
export declare const TableDefSchema: Schema.Struct<{
|
|
74
|
+
sqliteDef: Schema.Struct<{
|
|
75
|
+
name: typeof Schema.String;
|
|
76
|
+
columns: Schema.Record$<typeof Schema.String, Schema.Struct<{
|
|
77
|
+
columnType: Schema.Literal<["blob", "integer", "text", "real"]>;
|
|
78
|
+
nullable: typeof Schema.Boolean;
|
|
79
|
+
primaryKey: typeof Schema.Boolean;
|
|
80
|
+
}>>;
|
|
81
|
+
ast: typeof Schema.Any;
|
|
82
|
+
}>;
|
|
83
|
+
isSingleColumn: typeof Schema.Boolean;
|
|
84
|
+
options: typeof Schema.Any;
|
|
85
|
+
}>;
|
|
86
|
+
export declare const LiveStoreSchemaSchema: Schema.transform<Schema.Struct<{
|
|
87
|
+
tables: Schema.Record$<typeof Schema.String, Schema.Struct<{
|
|
88
|
+
sqliteDef: Schema.Struct<{
|
|
89
|
+
name: typeof Schema.String;
|
|
90
|
+
columns: Schema.Record$<typeof Schema.String, Schema.Struct<{
|
|
91
|
+
columnType: Schema.Literal<["blob", "integer", "text", "real"]>;
|
|
92
|
+
nullable: typeof Schema.Boolean;
|
|
93
|
+
primaryKey: typeof Schema.Boolean;
|
|
94
|
+
}>>;
|
|
95
|
+
ast: typeof Schema.Any;
|
|
96
|
+
}>;
|
|
97
|
+
isSingleColumn: typeof Schema.Boolean;
|
|
98
|
+
options: typeof Schema.Any;
|
|
99
|
+
}>>;
|
|
100
|
+
}>, Schema.Schema<LiveStoreSchema<SqliteDsl.DbSchema, MutationDefRecord>, LiveStoreSchema<SqliteDsl.DbSchema, MutationDefRecord>, never>>;
|
|
54
101
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[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I,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;KAAE,GAAG;QAAE,kBAAkB,EAAE,cAAc,CAAA;KAAE,GACtF,UAAU,SAAS;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,GAAG,CAAA;KAAE,GACpD;SAAG,CAAC,IAAI,MAAM,UAAU,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;KAAE,GAAG;QAAE,kBAAkB,EAAE,cAAc,CAAA;KAAE,GAC5G,KAAK,CAAA;;CACd;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAUlE,CAAA;AAED,eAAO,MAAM,oBAAoB;;;;EAI/B,CAAA;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;EAI/B,CAAA;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;EAIzB,CAAA;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;yIA8BjC,CAAA"}
|
package/dist/schema/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { isReadonlyArray, shouldNeverHappen } from '@livestore/utils';
|
|
2
|
-
import {
|
|
1
|
+
import { isReadonlyArray, pick, shouldNeverHappen } from '@livestore/utils';
|
|
2
|
+
import { ReadonlyRecord, Schema } from '@livestore/utils/effect';
|
|
3
|
+
import { SqliteAst, SqliteDsl } from 'effect-db-schema';
|
|
3
4
|
import { makeDerivedMutationDefsForTable } from '../derived-mutations.js';
|
|
4
5
|
import { rawSqlMutation, } from './mutations.js';
|
|
5
6
|
import { systemTables } from './system-tables.js';
|
|
6
|
-
import { tableHasDerivedMutations } from './table-def.js';
|
|
7
|
+
import { table, tableHasDerivedMutations } from './table-def.js';
|
|
7
8
|
export * from './system-tables.js';
|
|
8
9
|
export * as DbSchema from './table-def.js';
|
|
9
10
|
export * as ParseUtils from './parse-utils.js';
|
|
10
11
|
export * from './mutations.js';
|
|
11
12
|
export * from './schema-helpers.js';
|
|
13
|
+
export const LiveStoreSchemaSymbol = Symbol.for('livestore.LiveStoreSchema');
|
|
12
14
|
export const makeSchema = (
|
|
13
15
|
/** Note when using the object-notation for tables/mutations, the object keys are ignored and not used as table/mutation names */
|
|
14
16
|
inputSchema) => {
|
|
@@ -54,12 +56,62 @@ inputSchema) => {
|
|
|
54
56
|
tables: [...tables.values()].map((_) => _.sqliteDef.ast),
|
|
55
57
|
});
|
|
56
58
|
return {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
_Type: LiveStoreSchemaSymbol,
|
|
60
|
+
_DbSchemaType: Symbol.for('livestore.DbSchemaType'),
|
|
61
|
+
_MutationDefMapType: Symbol.for('livestore.MutationDefMapType'),
|
|
59
62
|
tables,
|
|
60
63
|
mutations,
|
|
61
64
|
migrationOptions: inputSchema.migrations ?? { strategy: 'hard-reset' },
|
|
62
65
|
hash,
|
|
63
66
|
};
|
|
64
67
|
};
|
|
68
|
+
export const LiveStoreSchemaFromSelf = Schema.declare((_) => _._DbSchemaType === Symbol.for('livestore.DbSchemaType') &&
|
|
69
|
+
_._MutationDefMapType === Symbol.for('livestore.MutationDefMapType'), {
|
|
70
|
+
identifier: 'LiveStoreSchemaFromSelf',
|
|
71
|
+
pretty: () => (_) => `LiveStoreSchema(hash: ${_.hash})`,
|
|
72
|
+
arbitrary: () => (fc) => fc.anything,
|
|
73
|
+
equivalence: () => (a, b) => a.hash === b.hash,
|
|
74
|
+
});
|
|
75
|
+
export const TableDefColumnSchema = Schema.Struct({
|
|
76
|
+
columnType: Schema.Literal('blob', 'integer', 'text', 'real'),
|
|
77
|
+
nullable: Schema.Boolean,
|
|
78
|
+
primaryKey: Schema.Boolean,
|
|
79
|
+
});
|
|
80
|
+
export const TableDefSqliteSchema = Schema.Struct({
|
|
81
|
+
name: Schema.String,
|
|
82
|
+
columns: Schema.Record(Schema.String, TableDefColumnSchema),
|
|
83
|
+
ast: Schema.Any,
|
|
84
|
+
});
|
|
85
|
+
export const TableDefSchema = Schema.Struct({
|
|
86
|
+
sqliteDef: TableDefSqliteSchema,
|
|
87
|
+
isSingleColumn: Schema.Boolean,
|
|
88
|
+
options: Schema.Any,
|
|
89
|
+
});
|
|
90
|
+
export const LiveStoreSchemaSchema = Schema.transform(Schema.Struct({
|
|
91
|
+
tables: Schema.Record(Schema.String, TableDefSchema),
|
|
92
|
+
// mutations: Schema.Record(Schema.String, MutationDef.AnySchema),
|
|
93
|
+
// migrationOptions: Schema.Struct({ strategy: Schema.Literal('hard-reset') }),
|
|
94
|
+
}), LiveStoreSchemaFromSelf, {
|
|
95
|
+
encode: (schema) => ({
|
|
96
|
+
tables: ReadonlyRecord.map(Object.fromEntries(schema.tables.entries()), (t) => ({
|
|
97
|
+
sqliteDef: {
|
|
98
|
+
name: t.sqliteDef.name,
|
|
99
|
+
columns: ReadonlyRecord.map(t.sqliteDef.columns, (c) => pick(c, ['columnType', 'nullable', 'primaryKey'])),
|
|
100
|
+
ast: JSON.parse(JSON.stringify(t.sqliteDef.ast)),
|
|
101
|
+
},
|
|
102
|
+
isSingleColumn: t.isSingleColumn,
|
|
103
|
+
options: t.options,
|
|
104
|
+
})),
|
|
105
|
+
}),
|
|
106
|
+
decode: (schema) => {
|
|
107
|
+
const tables = ReadonlyRecord.map(schema.tables, (t) => {
|
|
108
|
+
const columns = ReadonlyRecord.map(t.sqliteDef.columns, (c) => {
|
|
109
|
+
const makeCol = SqliteDsl[c.columnType];
|
|
110
|
+
return makeCol({ nullable: c.nullable, primaryKey: c.primaryKey });
|
|
111
|
+
});
|
|
112
|
+
return table(t.sqliteDef.name, columns, t.options);
|
|
113
|
+
});
|
|
114
|
+
return makeSchema({ tables });
|
|
115
|
+
},
|
|
116
|
+
});
|
|
65
117
|
//# sourceMappingURL=index.js.map
|
package/dist/schema/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA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E,MAAM,EAAE,CAAC,CAAA;IAC/B,CAAC;CACF,CACF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livestore/common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.54-dev.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@opentelemetry/api": "^1.9.0",
|
|
32
|
-
"@livestore/utils": "0.0.
|
|
33
|
-
"effect-db-schema": "0.0.
|
|
32
|
+
"@livestore/utils": "0.0.54-dev.0",
|
|
33
|
+
"effect-db-schema": "0.0.54-dev.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"vitest": "^1.6.0"
|