@powersync/service-core 0.0.0-dev-20261005112123 → 0.0.0-dev-20261007110800
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/CHANGELOG.md +22 -11
- package/dist/api/RouteAPI.d.ts +8 -1
- package/dist/api/api-index.d.ts +1 -0
- package/dist/api/api-index.js +1 -0
- package/dist/api/api-index.js.map +1 -1
- package/dist/api/diagnostics.js +28 -14
- package/dist/api/diagnostics.js.map +1 -1
- package/dist/api/source-capabilities.d.ts +12 -0
- package/dist/api/source-capabilities.js +27 -0
- package/dist/api/source-capabilities.js.map +1 -0
- package/dist/replication/AbstractReplicator.d.ts +10 -0
- package/dist/replication/AbstractReplicator.js +19 -3
- package/dist/replication/AbstractReplicator.js.map +1 -1
- package/dist/replication/ReplicationModule.js +10 -2
- package/dist/replication/ReplicationModule.js.map +1 -1
- package/dist/routes/configure-fastify.d.ts +24 -24
- package/dist/routes/endpoints/admin.d.ts +48 -48
- package/dist/routes/endpoints/admin.js +8 -8
- package/dist/routes/endpoints/admin.js.map +1 -1
- package/dist/routes/endpoints/sync-rules.js +51 -14
- package/dist/routes/endpoints/sync-rules.js.map +1 -1
- package/dist/storage/BucketStorageFactory.d.ts +11 -13
- package/dist/storage/BucketStorageFactory.js +21 -11
- package/dist/storage/BucketStorageFactory.js.map +1 -1
- package/dist/storage/PersistedReplicationStream.d.ts +1 -2
- package/dist/storage/PersistedReplicationStream.js.map +1 -1
- package/dist/storage/PersistedSyncConfigContent.d.ts +4 -4
- package/dist/storage/PersistedSyncConfigContent.js +5 -12
- package/dist/storage/PersistedSyncConfigContent.js.map +1 -1
- package/dist/storage/StorageEngine.d.ts +0 -4
- package/dist/storage/StorageEngine.js +1 -7
- package/dist/storage/StorageEngine.js.map +1 -1
- package/dist/storage/StorageProvider.d.ts +1 -6
- package/dist/storage/SyncRulesBucketStorage.d.ts +1 -1
- package/dist/storage/storage-index.d.ts +0 -1
- package/dist/storage/storage-index.js +0 -1
- package/dist/storage/storage-index.js.map +1 -1
- package/dist/system/ServiceContext.d.ts +0 -20
- package/dist/system/ServiceContext.js +1 -29
- package/dist/system/ServiceContext.js.map +1 -1
- package/package.json +11 -11
- package/src/api/RouteAPI.ts +9 -1
- package/src/api/api-index.ts +1 -0
- package/src/api/diagnostics.ts +24 -12
- package/src/api/source-capabilities.ts +31 -0
- package/src/replication/AbstractReplicator.ts +22 -3
- package/src/replication/ReplicationModule.ts +9 -2
- package/src/routes/endpoints/admin.ts +14 -6
- package/src/routes/endpoints/sync-rules.ts +52 -16
- package/src/storage/BucketStorageFactory.ts +21 -19
- package/src/storage/PersistedReplicationStream.ts +1 -2
- package/src/storage/PersistedSyncConfigContent.ts +9 -16
- package/src/storage/StorageEngine.ts +1 -10
- package/src/storage/StorageProvider.ts +1 -6
- package/src/storage/SyncRulesBucketStorage.ts +1 -1
- package/src/storage/storage-index.ts +0 -1
- package/src/system/ServiceContext.ts +1 -47
- package/test/src/AbstractReplicator.test.ts +94 -23
- package/test/src/PersistedSyncConfigContent.test.ts +1 -3
- package/test/src/diagnostics.test.ts +71 -0
- package/test/src/routes/admin.test.ts +205 -11
- package/test/src/routes/mocks.ts +0 -2
- package/test/src/routes/sync-rules.test.ts +76 -0
- package/test/src/source-capabilities.test.ts +42 -0
- package/test/src/source_table_config.test.ts +55 -0
- package/test/src/storage/BucketStorageFactory.test.ts +46 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/storage/SyncConfigParser.d.ts +0 -44
- package/dist/storage/SyncConfigParser.js +0 -73
- package/dist/storage/SyncConfigParser.js.map +0 -1
- package/src/storage/SyncConfigParser.ts +0 -124
- package/test/src/SyncConfigParser.test.ts +0 -309
|
@@ -70,16 +70,16 @@ export declare const diagnostics: router.Endpoint<{
|
|
|
70
70
|
sync_rules_content?: boolean | undefined;
|
|
71
71
|
}, {
|
|
72
72
|
connections: {
|
|
73
|
+
id: string;
|
|
73
74
|
errors: {
|
|
74
|
-
level: "warning" | "fatal";
|
|
75
75
|
message: string;
|
|
76
|
+
level: "warning" | "fatal";
|
|
76
77
|
location?: {
|
|
77
78
|
start_offset: number;
|
|
78
79
|
end_offset: number;
|
|
79
80
|
} | undefined;
|
|
80
81
|
ts?: string | undefined;
|
|
81
82
|
}[];
|
|
82
|
-
id: string;
|
|
83
83
|
connected: boolean;
|
|
84
84
|
postgres_uri: string;
|
|
85
85
|
}[];
|
|
@@ -175,16 +175,16 @@ export declare const diagnostics: router.Endpoint<{
|
|
|
175
175
|
sync_rules_content?: boolean | undefined;
|
|
176
176
|
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, {
|
|
177
177
|
connections: {
|
|
178
|
+
id: string;
|
|
178
179
|
errors: {
|
|
179
|
-
level: "warning" | "fatal";
|
|
180
180
|
message: string;
|
|
181
|
+
level: "warning" | "fatal";
|
|
181
182
|
location?: {
|
|
182
183
|
start_offset: number;
|
|
183
184
|
end_offset: number;
|
|
184
185
|
} | undefined;
|
|
185
186
|
ts?: string | undefined;
|
|
186
187
|
}[];
|
|
187
|
-
id: string;
|
|
188
188
|
connected: boolean;
|
|
189
189
|
postgres_uri: string;
|
|
190
190
|
}[];
|
|
@@ -291,16 +291,16 @@ export declare const diagnostics: router.Endpoint<{
|
|
|
291
291
|
sync_rules_content?: boolean | undefined;
|
|
292
292
|
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>) => Promise<{
|
|
293
293
|
connections: {
|
|
294
|
+
id: string;
|
|
294
295
|
errors: {
|
|
295
|
-
level: "warning" | "fatal";
|
|
296
296
|
message: string;
|
|
297
|
+
level: "warning" | "fatal";
|
|
297
298
|
location?: {
|
|
298
299
|
start_offset: number;
|
|
299
300
|
end_offset: number;
|
|
300
301
|
} | undefined;
|
|
301
302
|
ts?: string | undefined;
|
|
302
303
|
}[];
|
|
303
|
-
id: string;
|
|
304
304
|
connected: boolean;
|
|
305
305
|
postgres_uri: string;
|
|
306
306
|
}[];
|
|
@@ -402,9 +402,9 @@ export declare const getSchema: router.Endpoint<{}, {
|
|
|
402
402
|
name: string;
|
|
403
403
|
columns: {
|
|
404
404
|
name: string;
|
|
405
|
+
type: string;
|
|
405
406
|
sqlite_type: number | import("@powersync/service-types").SqliteSchemaTypeText;
|
|
406
407
|
internal_type: string;
|
|
407
|
-
type: string;
|
|
408
408
|
pg_type: string;
|
|
409
409
|
description?: string | undefined;
|
|
410
410
|
}[];
|
|
@@ -423,9 +423,9 @@ export declare const getSchema: router.Endpoint<{}, {
|
|
|
423
423
|
name: string;
|
|
424
424
|
columns: {
|
|
425
425
|
name: string;
|
|
426
|
+
type: string;
|
|
426
427
|
sqlite_type: number | import("@powersync/service-types").SqliteSchemaTypeText;
|
|
427
428
|
internal_type: string;
|
|
428
|
-
type: string;
|
|
429
429
|
pg_type: string;
|
|
430
430
|
description?: string | undefined;
|
|
431
431
|
}[];
|
|
@@ -455,9 +455,9 @@ export declare const getSchema: router.Endpoint<{}, {
|
|
|
455
455
|
name: string;
|
|
456
456
|
columns: {
|
|
457
457
|
name: string;
|
|
458
|
+
type: string;
|
|
458
459
|
sqlite_type: number | import("@powersync/service-types").SqliteSchemaTypeText;
|
|
459
460
|
internal_type: string;
|
|
460
|
-
type: string;
|
|
461
461
|
pg_type: string;
|
|
462
462
|
description?: string | undefined;
|
|
463
463
|
}[];
|
|
@@ -503,8 +503,8 @@ export declare const validate: router.Endpoint<{
|
|
|
503
503
|
sync_rules: string;
|
|
504
504
|
}, {
|
|
505
505
|
errors: {
|
|
506
|
-
level: "warning" | "fatal";
|
|
507
506
|
message: string;
|
|
507
|
+
level: "warning" | "fatal";
|
|
508
508
|
location?: {
|
|
509
509
|
start_offset: number;
|
|
510
510
|
end_offset: number;
|
|
@@ -517,18 +517,18 @@ export declare const validate: router.Endpoint<{
|
|
|
517
517
|
tables: {
|
|
518
518
|
name: string;
|
|
519
519
|
schema: string;
|
|
520
|
-
replication_id: string[];
|
|
521
|
-
data_queries: boolean;
|
|
522
|
-
parameter_queries: boolean;
|
|
523
520
|
errors: {
|
|
524
|
-
level: "warning" | "fatal";
|
|
525
521
|
message: string;
|
|
522
|
+
level: "warning" | "fatal";
|
|
526
523
|
location?: {
|
|
527
524
|
start_offset: number;
|
|
528
525
|
end_offset: number;
|
|
529
526
|
} | undefined;
|
|
530
527
|
ts?: string | undefined;
|
|
531
528
|
}[];
|
|
529
|
+
replication_id: string[];
|
|
530
|
+
data_queries: boolean;
|
|
531
|
+
parameter_queries: boolean;
|
|
532
532
|
pattern?: string | undefined;
|
|
533
533
|
}[];
|
|
534
534
|
slot_name: string;
|
|
@@ -549,8 +549,8 @@ export declare const validate: router.Endpoint<{
|
|
|
549
549
|
sync_rules: string;
|
|
550
550
|
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, {
|
|
551
551
|
errors: {
|
|
552
|
-
level: "warning" | "fatal";
|
|
553
552
|
message: string;
|
|
553
|
+
level: "warning" | "fatal";
|
|
554
554
|
location?: {
|
|
555
555
|
start_offset: number;
|
|
556
556
|
end_offset: number;
|
|
@@ -563,18 +563,18 @@ export declare const validate: router.Endpoint<{
|
|
|
563
563
|
tables: {
|
|
564
564
|
name: string;
|
|
565
565
|
schema: string;
|
|
566
|
-
replication_id: string[];
|
|
567
|
-
data_queries: boolean;
|
|
568
|
-
parameter_queries: boolean;
|
|
569
566
|
errors: {
|
|
570
|
-
level: "warning" | "fatal";
|
|
571
567
|
message: string;
|
|
568
|
+
level: "warning" | "fatal";
|
|
572
569
|
location?: {
|
|
573
570
|
start_offset: number;
|
|
574
571
|
end_offset: number;
|
|
575
572
|
} | undefined;
|
|
576
573
|
ts?: string | undefined;
|
|
577
574
|
}[];
|
|
575
|
+
replication_id: string[];
|
|
576
|
+
data_queries: boolean;
|
|
577
|
+
parameter_queries: boolean;
|
|
578
578
|
pattern?: string | undefined;
|
|
579
579
|
}[];
|
|
580
580
|
slot_name: string;
|
|
@@ -606,8 +606,8 @@ export declare const validate: router.Endpoint<{
|
|
|
606
606
|
sync_rules: string;
|
|
607
607
|
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>) => Promise<{
|
|
608
608
|
errors: {
|
|
609
|
-
level: "warning" | "fatal";
|
|
610
609
|
message: string;
|
|
610
|
+
level: "warning" | "fatal";
|
|
611
611
|
location?: {
|
|
612
612
|
start_offset: number;
|
|
613
613
|
end_offset: number;
|
|
@@ -620,18 +620,18 @@ export declare const validate: router.Endpoint<{
|
|
|
620
620
|
tables: {
|
|
621
621
|
name: string;
|
|
622
622
|
schema: string;
|
|
623
|
-
replication_id: string[];
|
|
624
|
-
data_queries: boolean;
|
|
625
|
-
parameter_queries: boolean;
|
|
626
623
|
errors: {
|
|
627
|
-
level: "warning" | "fatal";
|
|
628
624
|
message: string;
|
|
625
|
+
level: "warning" | "fatal";
|
|
629
626
|
location?: {
|
|
630
627
|
start_offset: number;
|
|
631
628
|
end_offset: number;
|
|
632
629
|
} | undefined;
|
|
633
630
|
ts?: string | undefined;
|
|
634
631
|
}[];
|
|
632
|
+
replication_id: string[];
|
|
633
|
+
data_queries: boolean;
|
|
634
|
+
parameter_queries: boolean;
|
|
635
635
|
pattern?: string | undefined;
|
|
636
636
|
}[];
|
|
637
637
|
slot_name: string;
|
|
@@ -715,16 +715,16 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
|
|
|
715
715
|
sync_rules_content?: boolean | undefined;
|
|
716
716
|
}, {
|
|
717
717
|
connections: {
|
|
718
|
+
id: string;
|
|
718
719
|
errors: {
|
|
719
|
-
level: "warning" | "fatal";
|
|
720
720
|
message: string;
|
|
721
|
+
level: "warning" | "fatal";
|
|
721
722
|
location?: {
|
|
722
723
|
start_offset: number;
|
|
723
724
|
end_offset: number;
|
|
724
725
|
} | undefined;
|
|
725
726
|
ts?: string | undefined;
|
|
726
727
|
}[];
|
|
727
|
-
id: string;
|
|
728
728
|
connected: boolean;
|
|
729
729
|
postgres_uri: string;
|
|
730
730
|
}[];
|
|
@@ -820,16 +820,16 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
|
|
|
820
820
|
sync_rules_content?: boolean | undefined;
|
|
821
821
|
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, {
|
|
822
822
|
connections: {
|
|
823
|
+
id: string;
|
|
823
824
|
errors: {
|
|
824
|
-
level: "warning" | "fatal";
|
|
825
825
|
message: string;
|
|
826
|
+
level: "warning" | "fatal";
|
|
826
827
|
location?: {
|
|
827
828
|
start_offset: number;
|
|
828
829
|
end_offset: number;
|
|
829
830
|
} | undefined;
|
|
830
831
|
ts?: string | undefined;
|
|
831
832
|
}[];
|
|
832
|
-
id: string;
|
|
833
833
|
connected: boolean;
|
|
834
834
|
postgres_uri: string;
|
|
835
835
|
}[];
|
|
@@ -936,16 +936,16 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
|
|
|
936
936
|
sync_rules_content?: boolean | undefined;
|
|
937
937
|
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>) => Promise<{
|
|
938
938
|
connections: {
|
|
939
|
+
id: string;
|
|
939
940
|
errors: {
|
|
940
|
-
level: "warning" | "fatal";
|
|
941
941
|
message: string;
|
|
942
|
+
level: "warning" | "fatal";
|
|
942
943
|
location?: {
|
|
943
944
|
start_offset: number;
|
|
944
945
|
end_offset: number;
|
|
945
946
|
} | undefined;
|
|
946
947
|
ts?: string | undefined;
|
|
947
948
|
}[];
|
|
948
|
-
id: string;
|
|
949
949
|
connected: boolean;
|
|
950
950
|
postgres_uri: string;
|
|
951
951
|
}[];
|
|
@@ -1046,9 +1046,9 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
|
|
|
1046
1046
|
name: string;
|
|
1047
1047
|
columns: {
|
|
1048
1048
|
name: string;
|
|
1049
|
+
type: string;
|
|
1049
1050
|
sqlite_type: number | import("@powersync/service-types").SqliteSchemaTypeText;
|
|
1050
1051
|
internal_type: string;
|
|
1051
|
-
type: string;
|
|
1052
1052
|
pg_type: string;
|
|
1053
1053
|
description?: string | undefined;
|
|
1054
1054
|
}[];
|
|
@@ -1067,9 +1067,9 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
|
|
|
1067
1067
|
name: string;
|
|
1068
1068
|
columns: {
|
|
1069
1069
|
name: string;
|
|
1070
|
+
type: string;
|
|
1070
1071
|
sqlite_type: number | import("@powersync/service-types").SqliteSchemaTypeText;
|
|
1071
1072
|
internal_type: string;
|
|
1072
|
-
type: string;
|
|
1073
1073
|
pg_type: string;
|
|
1074
1074
|
description?: string | undefined;
|
|
1075
1075
|
}[];
|
|
@@ -1099,9 +1099,9 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
|
|
|
1099
1099
|
name: string;
|
|
1100
1100
|
columns: {
|
|
1101
1101
|
name: string;
|
|
1102
|
+
type: string;
|
|
1102
1103
|
sqlite_type: number | import("@powersync/service-types").SqliteSchemaTypeText;
|
|
1103
1104
|
internal_type: string;
|
|
1104
|
-
type: string;
|
|
1105
1105
|
pg_type: string;
|
|
1106
1106
|
description?: string | undefined;
|
|
1107
1107
|
}[];
|
|
@@ -1145,8 +1145,8 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
|
|
|
1145
1145
|
sync_rules: string;
|
|
1146
1146
|
}, {
|
|
1147
1147
|
errors: {
|
|
1148
|
-
level: "warning" | "fatal";
|
|
1149
1148
|
message: string;
|
|
1149
|
+
level: "warning" | "fatal";
|
|
1150
1150
|
location?: {
|
|
1151
1151
|
start_offset: number;
|
|
1152
1152
|
end_offset: number;
|
|
@@ -1159,18 +1159,18 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
|
|
|
1159
1159
|
tables: {
|
|
1160
1160
|
name: string;
|
|
1161
1161
|
schema: string;
|
|
1162
|
-
replication_id: string[];
|
|
1163
|
-
data_queries: boolean;
|
|
1164
|
-
parameter_queries: boolean;
|
|
1165
1162
|
errors: {
|
|
1166
|
-
level: "warning" | "fatal";
|
|
1167
1163
|
message: string;
|
|
1164
|
+
level: "warning" | "fatal";
|
|
1168
1165
|
location?: {
|
|
1169
1166
|
start_offset: number;
|
|
1170
1167
|
end_offset: number;
|
|
1171
1168
|
} | undefined;
|
|
1172
1169
|
ts?: string | undefined;
|
|
1173
1170
|
}[];
|
|
1171
|
+
replication_id: string[];
|
|
1172
|
+
data_queries: boolean;
|
|
1173
|
+
parameter_queries: boolean;
|
|
1174
1174
|
pattern?: string | undefined;
|
|
1175
1175
|
}[];
|
|
1176
1176
|
slot_name: string;
|
|
@@ -1191,8 +1191,8 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
|
|
|
1191
1191
|
sync_rules: string;
|
|
1192
1192
|
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>, {
|
|
1193
1193
|
errors: {
|
|
1194
|
-
level: "warning" | "fatal";
|
|
1195
1194
|
message: string;
|
|
1195
|
+
level: "warning" | "fatal";
|
|
1196
1196
|
location?: {
|
|
1197
1197
|
start_offset: number;
|
|
1198
1198
|
end_offset: number;
|
|
@@ -1205,18 +1205,18 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
|
|
|
1205
1205
|
tables: {
|
|
1206
1206
|
name: string;
|
|
1207
1207
|
schema: string;
|
|
1208
|
-
replication_id: string[];
|
|
1209
|
-
data_queries: boolean;
|
|
1210
|
-
parameter_queries: boolean;
|
|
1211
1208
|
errors: {
|
|
1212
|
-
level: "warning" | "fatal";
|
|
1213
1209
|
message: string;
|
|
1210
|
+
level: "warning" | "fatal";
|
|
1214
1211
|
location?: {
|
|
1215
1212
|
start_offset: number;
|
|
1216
1213
|
end_offset: number;
|
|
1217
1214
|
} | undefined;
|
|
1218
1215
|
ts?: string | undefined;
|
|
1219
1216
|
}[];
|
|
1217
|
+
replication_id: string[];
|
|
1218
|
+
data_queries: boolean;
|
|
1219
|
+
parameter_queries: boolean;
|
|
1220
1220
|
pattern?: string | undefined;
|
|
1221
1221
|
}[];
|
|
1222
1222
|
slot_name: string;
|
|
@@ -1248,8 +1248,8 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
|
|
|
1248
1248
|
sync_rules: string;
|
|
1249
1249
|
}, import("../router.js").Context, import("../router.js").BasicRouterRequest>) => Promise<{
|
|
1250
1250
|
errors: {
|
|
1251
|
-
level: "warning" | "fatal";
|
|
1252
1251
|
message: string;
|
|
1252
|
+
level: "warning" | "fatal";
|
|
1253
1253
|
location?: {
|
|
1254
1254
|
start_offset: number;
|
|
1255
1255
|
end_offset: number;
|
|
@@ -1262,18 +1262,18 @@ export declare const ADMIN_ROUTES: ((router.Endpoint<{
|
|
|
1262
1262
|
tables: {
|
|
1263
1263
|
name: string;
|
|
1264
1264
|
schema: string;
|
|
1265
|
-
replication_id: string[];
|
|
1266
|
-
data_queries: boolean;
|
|
1267
|
-
parameter_queries: boolean;
|
|
1268
1265
|
errors: {
|
|
1269
|
-
level: "warning" | "fatal";
|
|
1270
1266
|
message: string;
|
|
1267
|
+
level: "warning" | "fatal";
|
|
1271
1268
|
location?: {
|
|
1272
1269
|
start_offset: number;
|
|
1273
1270
|
end_offset: number;
|
|
1274
1271
|
} | undefined;
|
|
1275
1272
|
ts?: string | undefined;
|
|
1276
1273
|
}[];
|
|
1274
|
+
replication_id: string[];
|
|
1275
|
+
data_queries: boolean;
|
|
1276
|
+
parameter_queries: boolean;
|
|
1277
1277
|
pattern?: string | undefined;
|
|
1278
1278
|
}[];
|
|
1279
1279
|
slot_name: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as sqlite from 'node:sqlite';
|
|
2
2
|
import { ErrorCode, errors, router, schema } from '@powersync/lib-services-framework';
|
|
3
|
-
import { nodeSqlite, StaticSchema } from '@powersync/service-sync-rules';
|
|
3
|
+
import { nodeSqlite, SqlSyncRules, StaticSchema } from '@powersync/service-sync-rules';
|
|
4
4
|
import { internal_routes } from '@powersync/service-types';
|
|
5
5
|
import { DEFAULT_HYDRATION_STATE } from '@powersync/service-sync-rules';
|
|
6
6
|
import * as api from '../../api/api-index.js';
|
|
@@ -117,13 +117,15 @@ export const reprocess = routeDefinition({
|
|
|
117
117
|
// 1. This always re-parses the source YAML. If there are changes to the Sync Streams compiler, that can affect the sync plan.
|
|
118
118
|
// 2. If the source does not set the storage version, this will update it do the current version.
|
|
119
119
|
// We can consider tweaking this behavior in the future.
|
|
120
|
-
const parsed =
|
|
120
|
+
const parsed = SqlSyncRules.fromYaml(active.content.sync_rules_content, {
|
|
121
121
|
...apiHandler.getParseSyncRulesOptions(),
|
|
122
122
|
schema: undefined,
|
|
123
123
|
// This sync config already passed validation. But if the config is not valid anymore due
|
|
124
124
|
// to a service change, we do want to report the error here.
|
|
125
125
|
throwOnError: true
|
|
126
126
|
});
|
|
127
|
+
storage.logSyncConfigErrors(parsed);
|
|
128
|
+
await api.assertSourceCapabilities(apiHandler, parsed.config);
|
|
127
129
|
const new_rules = await activeBucketStorage.updateSyncRules(storage.updateSyncRulesFromConfig(parsed, {
|
|
128
130
|
version_label: active.content.version_label,
|
|
129
131
|
forceNewReplicationStream: true
|
|
@@ -142,15 +144,13 @@ export const reprocess = routeDefinition({
|
|
|
142
144
|
}
|
|
143
145
|
});
|
|
144
146
|
class FakeSyncRulesContentForValidation extends storage.PersistedSyncConfigContent {
|
|
145
|
-
validationParser;
|
|
146
147
|
schema;
|
|
147
|
-
constructor(
|
|
148
|
-
super(data
|
|
149
|
-
this.validationParser = validationParser;
|
|
148
|
+
constructor(schema, data) {
|
|
149
|
+
super(data);
|
|
150
150
|
this.schema = schema;
|
|
151
151
|
}
|
|
152
152
|
parsed(options) {
|
|
153
|
-
const syncConfig =
|
|
153
|
+
const syncConfig = SqlSyncRules.fromYaml(this.sync_rules_content, {
|
|
154
154
|
...options,
|
|
155
155
|
schema: this.schema
|
|
156
156
|
});
|
|
@@ -184,7 +184,7 @@ export const validate = routeDefinition({
|
|
|
184
184
|
const apiHandler = service_context.routerEngine.getAPI();
|
|
185
185
|
const schemaData = await api.getConnectionsSchema(apiHandler);
|
|
186
186
|
const schema = new StaticSchema(schemaData.connections);
|
|
187
|
-
const sync_rules = new FakeSyncRulesContentForValidation(
|
|
187
|
+
const sync_rules = new FakeSyncRulesContentForValidation(schema, {
|
|
188
188
|
// Dummy values
|
|
189
189
|
replicationStreamId: 0,
|
|
190
190
|
replicationStreamName: '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../../src/routes/endpoints/admin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AACtF,OAAO,
|
|
1
|
+
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../../src/routes/endpoints/admin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AACtF,OAAO,EAEL,UAAU,EAEV,YAAY,EACZ,YAAY,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,GAAG,MAAM,wBAAwB,CAAC;AAC9C,OAAO,KAAK,OAAO,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC;IACxC,IAAI,EAAE,2BAA2B;IACjC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI;IAC9B,SAAS,EAAE,OAAO;IAClB,SAAS,EAAE,MAAM,CAAC,sBAAsB,CAAC,eAAe,CAAC,iBAAiB,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;IACtG,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACzB,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,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAC5G,CAAC;QAED,OAAO,eAAe,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ErrorCode, errors, router, schema } from '@powersync/lib-services-framework';
|
|
2
|
-
import { SyncRulesErrors } from '@powersync/service-sync-rules';
|
|
2
|
+
import { SqlSyncRules, SyncRulesErrors } from '@powersync/service-sync-rules';
|
|
3
3
|
import * as t from 'ts-codec';
|
|
4
|
-
import {
|
|
4
|
+
import { assertSourceCapabilities } from '../../api/source-capabilities.js';
|
|
5
|
+
import { logSyncConfigErrors, updateSyncRulesFromConfig } from '../../storage/BucketStorageFactory.js';
|
|
5
6
|
import { authApi } from '../auth.js';
|
|
6
7
|
import { routeDefinition } from '../router.js';
|
|
7
8
|
const DeploySyncRulesRequest = t.object({
|
|
@@ -45,8 +46,9 @@ export const deploySyncRules = routeDefinition({
|
|
|
45
46
|
const content = payload.params.content;
|
|
46
47
|
let syncConfig;
|
|
47
48
|
try {
|
|
49
|
+
// First ensure the SyncConfig parses correctly
|
|
48
50
|
const apiHandler = service_context.routerEngine.getAPI();
|
|
49
|
-
syncConfig =
|
|
51
|
+
syncConfig = SqlSyncRules.fromYaml(content, {
|
|
50
52
|
...apiHandler.getParseSyncRulesOptions(),
|
|
51
53
|
// We don't do any schema-level validation at this point
|
|
52
54
|
schema: undefined
|
|
@@ -60,6 +62,19 @@ export const deploySyncRules = routeDefinition({
|
|
|
60
62
|
details: e.message
|
|
61
63
|
});
|
|
62
64
|
}
|
|
65
|
+
logSyncConfigErrors(syncConfig);
|
|
66
|
+
try {
|
|
67
|
+
// Validate if the current sources support the configuration specified in the Sync Config
|
|
68
|
+
await assertSourceCapabilities(service_context.routerEngine.getAPI(), syncConfig.config);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
throw new errors.ServiceError({
|
|
72
|
+
status: 422,
|
|
73
|
+
code: ErrorCode.PSYNC_R0001,
|
|
74
|
+
description: 'Source capability validation failed',
|
|
75
|
+
details: error.message
|
|
76
|
+
});
|
|
77
|
+
}
|
|
63
78
|
const sync_rules = await storageEngine.activeBucketStorage.updateSyncRules(updateSyncRulesFromConfig(syncConfig));
|
|
64
79
|
return {
|
|
65
80
|
slot_name: sync_rules.replicationStreamName
|
|
@@ -80,7 +95,7 @@ export const validateSyncRules = routeDefinition({
|
|
|
80
95
|
const content = payload.params.content;
|
|
81
96
|
const { service_context } = payload.context;
|
|
82
97
|
const apiHandler = service_context.routerEngine.getAPI();
|
|
83
|
-
const info = await debugSyncRules(apiHandler, content
|
|
98
|
+
const info = await debugSyncRules(apiHandler, content);
|
|
84
99
|
return replyPrettyJson(info);
|
|
85
100
|
}
|
|
86
101
|
});
|
|
@@ -101,11 +116,9 @@ export const currentSyncRules = routeDefinition({
|
|
|
101
116
|
}
|
|
102
117
|
const sync_rules = active.content;
|
|
103
118
|
const apiHandler = service_context.routerEngine.getAPI();
|
|
104
|
-
const info = await debugSyncRules(apiHandler, sync_rules.sync_rules_content
|
|
119
|
+
const info = await debugSyncRules(apiHandler, sync_rules.sync_rules_content);
|
|
105
120
|
const next = await activeBucketStorage.getDeployingSyncConfig();
|
|
106
|
-
const next_info = next
|
|
107
|
-
? await debugSyncRules(apiHandler, next.content.sync_rules_content, service_context.syncConfigParser)
|
|
108
|
-
: null;
|
|
121
|
+
const next_info = next ? await debugSyncRules(apiHandler, next.content.sync_rules_content) : null;
|
|
109
122
|
const response = {
|
|
110
123
|
current: {
|
|
111
124
|
slot_name: sync_rules.replicationStreamName,
|
|
@@ -148,13 +161,15 @@ export const reprocessSyncRules = routeDefinition({
|
|
|
148
161
|
});
|
|
149
162
|
}
|
|
150
163
|
const sync_rules = active.content;
|
|
151
|
-
const parsed =
|
|
164
|
+
const parsed = SqlSyncRules.fromYaml(sync_rules.sync_rules_content, {
|
|
152
165
|
...payload.context.service_context.routerEngine.getAPI().getParseSyncRulesOptions(),
|
|
153
166
|
schema: undefined,
|
|
154
167
|
// This sync config already passed validation. But if the rules are not valid anymore due
|
|
155
168
|
// to a service change, we do want to report the error here.
|
|
156
169
|
throwOnError: true
|
|
157
170
|
});
|
|
171
|
+
logSyncConfigErrors(parsed);
|
|
172
|
+
await assertSourceCapabilities(payload.context.service_context.routerEngine.getAPI(), parsed.config);
|
|
158
173
|
const new_rules = await activeBucketStorage.updateSyncRules(updateSyncRulesFromConfig(parsed, {
|
|
159
174
|
version_label: sync_rules.version_label,
|
|
160
175
|
forceNewReplicationStream: true
|
|
@@ -172,17 +187,39 @@ function replyPrettyJson(payload) {
|
|
|
172
187
|
headers: { 'Content-Type': 'application/json' }
|
|
173
188
|
});
|
|
174
189
|
}
|
|
175
|
-
async function debugSyncRules(apiHandler, sync_rules
|
|
190
|
+
async function debugSyncRules(apiHandler, sync_rules) {
|
|
176
191
|
try {
|
|
177
|
-
const rules =
|
|
192
|
+
const rules = SqlSyncRules.fromYaml(sync_rules, {
|
|
178
193
|
...apiHandler.getParseSyncRulesOptions(),
|
|
179
194
|
// No schema-based validation at this point
|
|
180
195
|
schema: undefined
|
|
181
196
|
});
|
|
182
|
-
const
|
|
183
|
-
const
|
|
197
|
+
const errors = [];
|
|
198
|
+
const warnings = [];
|
|
199
|
+
const recordError = (error) => {
|
|
200
|
+
errors.push(...(error instanceof SyncRulesErrors ? error.errors.map((e) => e.message) : [error.message]));
|
|
201
|
+
};
|
|
202
|
+
try {
|
|
203
|
+
const diagnostics = (await apiHandler.validateSourceCapabilities?.(rules.config)) ?? [];
|
|
204
|
+
for (const diagnostic of diagnostics) {
|
|
205
|
+
(diagnostic.level === 'fatal' ? errors : warnings).push(diagnostic.message);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
catch (e) {
|
|
209
|
+
recordError(e);
|
|
210
|
+
}
|
|
211
|
+
let resolved_tables = [];
|
|
212
|
+
try {
|
|
213
|
+
const source_table_patterns = rules.config.getSourceTables();
|
|
214
|
+
resolved_tables = await apiHandler.getDebugTablesInfo(source_table_patterns, rules.config);
|
|
215
|
+
}
|
|
216
|
+
catch (e) {
|
|
217
|
+
recordError(e);
|
|
218
|
+
}
|
|
184
219
|
return {
|
|
185
|
-
valid:
|
|
220
|
+
valid: errors.length == 0,
|
|
221
|
+
...(warnings.length > 0 ? { warnings } : {}),
|
|
222
|
+
...(errors.length > 0 ? { errors } : {}),
|
|
186
223
|
bucket_definitions: rules.config.debugRepresentation(),
|
|
187
224
|
source_tables: resolved_tables,
|
|
188
225
|
data_tables: rules.config.debugGetOutputTables()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-rules.js","sourceRoot":"","sources":["../../../src/routes/endpoints/sync-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AACtF,OAAO,EAAwB,eAAe,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"sync-rules.js","sourceRoot":"","sources":["../../../src/routes/endpoints/sync-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AACtF,OAAO,EAAE,YAAY,EAAwB,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEpG,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAG5E,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AACvG,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,E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