@syncular/transport-http 0.0.1 → 0.0.2-127

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/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # @syncular/transport-http
2
+
3
+ HTTP transport for Syncular using a typed OpenAPI client. Used by `@syncular/client` to push and pull commits, and to upload/download blobs.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @syncular/transport-http
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { createHttpTransport } from '@syncular/transport-http';
15
+
16
+ const transport = createHttpTransport({
17
+ baseUrl: 'https://api.example.com',
18
+ getHeaders: () => ({ Authorization: `Bearer ${token}` }),
19
+ });
20
+ ```
21
+
22
+ ## Documentation
23
+
24
+ - How sync works (push/pull): https://syncular.dev/docs/introduction/architecture
25
+ - API reference: https://syncular.dev/docs/api/postSync
26
+
27
+ ## Links
28
+
29
+ - GitHub: https://github.com/syncular/syncular
30
+ - Issues: https://github.com/syncular/syncular/issues
31
+
32
+ > Status: Alpha. APIs and storage layouts may change between releases.
@@ -3,7 +3,7 @@
3
3
  * Do not make direct changes to the file.
4
4
  */
5
5
  export interface paths {
6
- "/sync/pull": {
6
+ "/sync": {
7
7
  parameters: {
8
8
  query?: never;
9
9
  header?: never;
@@ -13,10 +13,10 @@ export interface paths {
13
13
  get?: never;
14
14
  put?: never;
15
15
  /**
16
- * Pull commits and snapshots
17
- * @description Pull commits and optional bootstrap snapshots for subscriptions
16
+ * Combined push and pull
17
+ * @description Perform push and/or pull in a single request to reduce round-trips
18
18
  */
19
- post: operations["postSyncPull"];
19
+ post: operations["postSync"];
20
20
  delete?: never;
21
21
  options?: never;
22
22
  head?: never;
@@ -43,26 +43,6 @@ export interface paths {
43
43
  patch?: never;
44
44
  trace?: never;
45
45
  };
46
- "/sync/push": {
47
- parameters: {
48
- query?: never;
49
- header?: never;
50
- path?: never;
51
- cookie?: never;
52
- };
53
- get?: never;
54
- put?: never;
55
- /**
56
- * Push a commit
57
- * @description Push a client commit with operations to the server
58
- */
59
- post: operations["postSyncPush"];
60
- delete?: never;
61
- options?: never;
62
- head?: never;
63
- patch?: never;
64
- trace?: never;
65
- };
66
46
  "/console/stats": {
67
47
  parameters: {
68
48
  query?: never;
@@ -233,6 +213,26 @@ export interface paths {
233
213
  patch?: never;
234
214
  trace?: never;
235
215
  };
216
+ "/console/notify-data-change": {
217
+ parameters: {
218
+ query?: never;
219
+ header?: never;
220
+ path?: never;
221
+ cookie?: never;
222
+ };
223
+ get?: never;
224
+ put?: never;
225
+ /**
226
+ * Notify external data change
227
+ * @description Creates a synthetic commit to force re-bootstrap for affected tables. Use after pipeline imports or direct DB writes to notify connected clients.
228
+ */
229
+ post: operations["postConsoleNotifyDataChange"];
230
+ delete?: never;
231
+ options?: never;
232
+ head?: never;
233
+ patch?: never;
234
+ trace?: never;
235
+ };
236
236
  "/console/clients/{id}": {
237
237
  parameters: {
238
238
  query?: never;
@@ -427,7 +427,7 @@ export interface components {
427
427
  }
428
428
  export type $defs = Record<string, never>;
429
429
  export interface operations {
430
- postSyncPull: {
430
+ postSync: {
431
431
  parameters: {
432
432
  query?: never;
433
433
  header?: never;
@@ -438,32 +438,48 @@ export interface operations {
438
438
  content: {
439
439
  "application/json": {
440
440
  clientId: string;
441
- limitCommits: number;
442
- limitSnapshotRows?: number;
443
- maxSnapshotPages?: number;
444
- dedupeRows?: boolean;
445
- subscriptions: {
446
- id: string;
447
- shape: string;
448
- scopes: {
449
- [key: string]: string | string[];
450
- };
451
- params?: {
452
- [key: string]: unknown;
453
- };
454
- cursor: number;
455
- bootstrapState?: {
456
- asOfCommitSeq: number;
457
- tables: string[];
458
- tableIndex: number;
459
- rowCursor: string | null;
460
- } | null;
461
- }[];
441
+ push?: {
442
+ clientCommitId: string;
443
+ operations: {
444
+ table: string;
445
+ row_id: string;
446
+ /** @enum {string} */
447
+ op: "upsert" | "delete";
448
+ payload: {
449
+ [key: string]: unknown;
450
+ } | null;
451
+ base_version?: number | null;
452
+ }[];
453
+ schemaVersion: number;
454
+ };
455
+ pull?: {
456
+ limitCommits: number;
457
+ limitSnapshotRows?: number;
458
+ maxSnapshotPages?: number;
459
+ dedupeRows?: boolean;
460
+ subscriptions: {
461
+ id: string;
462
+ table: string;
463
+ scopes: {
464
+ [key: string]: string | string[];
465
+ };
466
+ params?: {
467
+ [key: string]: unknown;
468
+ };
469
+ cursor: number;
470
+ bootstrapState?: {
471
+ asOfCommitSeq: number;
472
+ tables: string[];
473
+ tableIndex: number;
474
+ rowCursor: string | null;
475
+ } | null;
476
+ }[];
477
+ };
462
478
  };
463
479
  };
464
480
  };
465
481
  responses: {
466
- /** @description Successful pull response */
482
+ /** @description Combined sync response */
467
483
  200: {
468
484
  headers: {
469
485
  [name: string]: unknown;
@@ -472,53 +488,83 @@ export interface operations {
472
488
  "application/json": {
473
489
  /** @constant */
474
490
  ok: true;
475
- subscriptions: {
476
- id: string;
491
+ push?: {
492
+ /** @constant */
493
+ ok: true;
477
494
  /** @enum {string} */
478
- status: "active" | "revoked";
479
- scopes: {
480
- [key: string]: string | string[];
481
- };
482
- bootstrap: boolean;
483
- bootstrapState?: {
484
- asOfCommitSeq: number;
485
- tables: string[];
486
- tableIndex: number;
487
- rowCursor: string | null;
488
- } | null;
489
- nextCursor: number;
490
- commits: {
491
- commitSeq: number;
492
- createdAt: string;
493
- actorId: string;
494
- changes: {
495
- table: string;
496
- row_id: string;
497
- /** @enum {string} */
498
- op: "upsert" | "delete";
499
- row_json: unknown | null;
500
- row_version: number | null;
501
- scopes: {
502
- [key: string]: string;
503
- };
495
+ status: "applied" | "cached" | "rejected";
496
+ commitSeq?: number;
497
+ results: ({
498
+ opIndex: number;
499
+ /** @constant */
500
+ status: "applied";
501
+ } | {
502
+ opIndex: number;
503
+ /** @constant */
504
+ status: "conflict";
505
+ message: string;
506
+ server_version: number;
507
+ server_row: unknown;
508
+ } | {
509
+ opIndex: number;
510
+ /** @constant */
511
+ status: "error";
512
+ error: string;
513
+ code?: string;
514
+ retriable?: boolean;
515
+ })[];
516
+ };
517
+ pull?: {
518
+ /** @constant */
519
+ ok: true;
520
+ subscriptions: {
521
+ id: string;
522
+ /** @enum {string} */
523
+ status: "active" | "revoked";
524
+ scopes: {
525
+ [key: string]: string | string[];
526
+ };
527
+ bootstrap: boolean;
528
+ bootstrapState?: {
529
+ asOfCommitSeq: number;
530
+ tables: string[];
531
+ tableIndex: number;
532
+ rowCursor: string | null;
533
+ } | null;
534
+ nextCursor: number;
535
+ commits: {
536
+ commitSeq: number;
537
+ createdAt: string;
538
+ actorId: string;
539
+ changes: {
540
+ table: string;
541
+ row_id: string;
542
+ /** @enum {string} */
543
+ op: "upsert" | "delete";
544
+ row_json: unknown | null;
545
+ row_version: number | null;
546
+ scopes: {
547
+ [key: string]: string;
548
+ };
549
+ }[];
504
550
  }[];
505
- }[];
506
- snapshots?: {
507
- table: string;
508
- rows: unknown[];
509
- chunks?: {
510
- id: string;
511
- byteLength: number;
512
- sha256: string;
513
- /** @constant */
514
- encoding: "ndjson";
515
- /** @constant */
516
- compression: "gzip";
551
+ snapshots?: {
552
+ table: string;
553
+ rows: unknown[];
554
+ chunks?: {
555
+ id: string;
556
+ byteLength: number;
557
+ sha256: string;
558
+ /** @constant */
559
+ encoding: "json-row-frame-v1";
560
+ /** @constant */
561
+ compression: "gzip";
562
+ }[];
563
+ isFirstPage: boolean;
564
+ isLastPage: boolean;
517
565
  }[];
518
- isFirstPage: boolean;
519
- isLastPage: boolean;
520
566
  }[];
521
- }[];
567
+ };
522
568
  };
523
569
  };
524
570
  };
@@ -561,12 +607,14 @@ export interface operations {
561
607
  };
562
608
  requestBody?: never;
563
609
  responses: {
564
- /** @description Snapshot chunk data (gzip-compressed NDJSON) */
610
+ /** @description Snapshot chunk data (gzip-compressed framed JSON rows) */
565
611
  200: {
566
612
  headers: {
567
613
  [name: string]: unknown;
568
614
  };
569
- content?: never;
615
+ content: {
616
+ "application/octet-stream": string;
617
+ };
570
618
  };
571
619
  /** @description Not modified (cached) */
572
620
  304: {
@@ -616,95 +664,6 @@ export interface operations {
616
664
  };
617
665
  };
618
666
  };
619
- postSyncPush: {
620
- parameters: {
621
- query?: never;
622
- header?: never;
623
- path?: never;
624
- cookie?: never;
625
- };
626
- requestBody?: {
627
- content: {
628
- "application/json": {
629
- clientId: string;
630
- clientCommitId: string;
631
- operations: {
632
- table: string;
633
- row_id: string;
634
- /** @enum {string} */
635
- op: "upsert" | "delete";
636
- payload: {
637
- [key: string]: unknown;
638
- } | null;
639
- base_version?: number | null;
640
- }[];
641
- schemaVersion: number;
642
- };
643
- };
644
- };
645
- responses: {
646
- /** @description Successful push response */
647
- 200: {
648
- headers: {
649
- [name: string]: unknown;
650
- };
651
- content: {
652
- "application/json": {
653
- /** @constant */
654
- ok: true;
655
- /** @enum {string} */
656
- status: "applied" | "cached" | "rejected";
657
- commitSeq?: number;
658
- results: ({
659
- opIndex: number;
660
- /** @constant */
661
- status: "applied";
662
- } | {
663
- opIndex: number;
664
- /** @constant */
665
- status: "conflict";
666
- message: string;
667
- server_version: number;
668
- server_row: unknown;
669
- } | {
670
- opIndex: number;
671
- /** @constant */
672
- status: "error";
673
- error: string;
674
- code?: string;
675
- retriable?: boolean;
676
- })[];
677
- };
678
- };
679
- };
680
- /** @description Invalid request */
681
- 400: {
682
- headers: {
683
- [name: string]: unknown;
684
- };
685
- content: {
686
- "application/json": {
687
- error: string;
688
- message?: string;
689
- code?: string;
690
- };
691
- };
692
- };
693
- /** @description Unauthenticated */
694
- 401: {
695
- headers: {
696
- [name: string]: unknown;
697
- };
698
- content: {
699
- "application/json": {
700
- error: string;
701
- message?: string;
702
- code?: string;
703
- };
704
- };
705
- };
706
- };
707
- };
708
667
  getConsoleStats: {
709
668
  parameters: {
710
669
  query?: never;
@@ -919,7 +878,7 @@ export interface operations {
919
878
  rowId: string;
920
879
  /** @enum {string} */
921
880
  op: "upsert" | "delete";
922
- rowJson?: null;
881
+ rowJson: unknown | null;
923
882
  rowVersion: number | null;
924
883
  scopes: {
925
884
  [key: string]: unknown;
@@ -999,8 +958,7 @@ export interface operations {
999
958
  /** @enum {string} */
1000
959
  activityState: "active" | "idle" | "stale";
1001
960
  lastRequestAt: string | null;
1002
- /** @enum {string|null} */
1003
- lastRequestType: "push" | "pull" | null;
961
+ lastRequestType: ("push" | "pull") | null;
1004
962
  lastRequestOutcome: string | null;
1005
963
  effectiveScopes: {
1006
964
  [key: string]: unknown;
@@ -1168,6 +1126,61 @@ export interface operations {
1168
1126
  };
1169
1127
  };
1170
1128
  };
1129
+ postConsoleNotifyDataChange: {
1130
+ parameters: {
1131
+ query?: never;
1132
+ header?: never;
1133
+ path?: never;
1134
+ cookie?: never;
1135
+ };
1136
+ requestBody?: {
1137
+ content: {
1138
+ "application/json": {
1139
+ tables: string[];
1140
+ partitionId?: string;
1141
+ };
1142
+ };
1143
+ };
1144
+ responses: {
1145
+ /** @description Notification result */
1146
+ 200: {
1147
+ headers: {
1148
+ [name: string]: unknown;
1149
+ };
1150
+ content: {
1151
+ "application/json": {
1152
+ commitSeq: number;
1153
+ tables: string[];
1154
+ deletedChunks: number;
1155
+ };
1156
+ };
1157
+ };
1158
+ /** @description Invalid request */
1159
+ 400: {
1160
+ headers: {
1161
+ [name: string]: unknown;
1162
+ };
1163
+ content: {
1164
+ "application/json": {
1165
+ error: string;
1166
+ message?: string;
1167
+ };
1168
+ };
1169
+ };
1170
+ /** @description Unauthenticated */
1171
+ 401: {
1172
+ headers: {
1173
+ [name: string]: unknown;
1174
+ };
1175
+ content: {
1176
+ "application/json": {
1177
+ error: string;
1178
+ message?: string;
1179
+ };
1180
+ };
1181
+ };
1182
+ };
1183
+ };
1171
1184
  deleteConsoleClientsById: {
1172
1185
  parameters: {
1173
1186
  query?: never;
@@ -1724,6 +1737,7 @@ export interface operations {
1724
1737
  "application/json": {
1725
1738
  exists: boolean;
1726
1739
  uploadId?: string;
1740
+ /** Format: uri */
1727
1741
  uploadUrl?: string;
1728
1742
  /** @enum {string} */
1729
1743
  uploadMethod?: "PUT" | "POST";