powersync 0.0.0-dev-20260305101740 → 0.0.0-dev-20260316080136

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 (99) hide show
  1. package/README.md +33 -27
  2. package/bin/dev.js +7 -1
  3. package/dist/api/build-service-yaml.d.ts +29 -0
  4. package/dist/api/build-service-yaml.js +246 -0
  5. package/dist/api/build-service-yaml.js.map +1 -0
  6. package/dist/api/cloud/create-cloud-instance.js +1 -0
  7. package/dist/api/cloud/create-cloud-instance.js.map +1 -0
  8. package/dist/api/cloud/create-cloud-template.d.ts +15 -0
  9. package/dist/api/cloud/create-cloud-template.js +33 -0
  10. package/dist/api/cloud/create-cloud-template.js.map +1 -0
  11. package/dist/api/cloud/fetch-cloud-config.js +1 -0
  12. package/dist/api/cloud/fetch-cloud-config.js.map +1 -0
  13. package/dist/api/cloud/fetch-cloud-sync-rules-content.js +1 -0
  14. package/dist/api/cloud/fetch-cloud-sync-rules-content.js.map +1 -0
  15. package/dist/api/cloud/test-connection.js +1 -0
  16. package/dist/api/cloud/test-connection.js.map +1 -0
  17. package/dist/api/cloud/validate-cloud-link-config.js +1 -0
  18. package/dist/api/cloud/validate-cloud-link-config.js.map +1 -0
  19. package/dist/api/cloud/wait-for-operation.js +1 -0
  20. package/dist/api/cloud/wait-for-operation.js.map +1 -0
  21. package/dist/api/cloud/write-cloud-link.js +1 -0
  22. package/dist/api/cloud/write-cloud-link.js.map +1 -0
  23. package/dist/api/display-status.js +1 -0
  24. package/dist/api/display-status.js.map +1 -0
  25. package/dist/api/ide/configure-vscode-ide.js +1 -0
  26. package/dist/api/ide/configure-vscode-ide.js.map +1 -0
  27. package/dist/api/login-server.js +1 -0
  28. package/dist/api/login-server.js.map +1 -0
  29. package/dist/api/run-validation-tests.js +1 -0
  30. package/dist/api/run-validation-tests.js.map +1 -0
  31. package/dist/api/self-hosted/fetch-self-hosted-sync-rules-content.js +1 -0
  32. package/dist/api/self-hosted/fetch-self-hosted-sync-rules-content.js.map +1 -0
  33. package/dist/commands/configure/ide.js +1 -0
  34. package/dist/commands/configure/ide.js.map +1 -0
  35. package/dist/commands/configure/index.js +1 -0
  36. package/dist/commands/configure/index.js.map +1 -0
  37. package/dist/commands/deploy/index.js +2 -1
  38. package/dist/commands/deploy/index.js.map +1 -0
  39. package/dist/commands/deploy/service-config.js +1 -0
  40. package/dist/commands/deploy/service-config.js.map +1 -0
  41. package/dist/commands/deploy/sync-config.js +1 -0
  42. package/dist/commands/deploy/sync-config.js.map +1 -0
  43. package/dist/commands/destroy.js +1 -0
  44. package/dist/commands/destroy.js.map +1 -0
  45. package/dist/commands/fetch/config.js +1 -0
  46. package/dist/commands/fetch/config.js.map +1 -0
  47. package/dist/commands/fetch/index.js +1 -0
  48. package/dist/commands/fetch/index.js.map +1 -0
  49. package/dist/commands/fetch/instances.js +1 -0
  50. package/dist/commands/fetch/instances.js.map +1 -0
  51. package/dist/commands/fetch/status.js +1 -0
  52. package/dist/commands/fetch/status.js.map +1 -0
  53. package/dist/commands/generate/index.js +1 -0
  54. package/dist/commands/generate/index.js.map +1 -0
  55. package/dist/commands/generate/schema.js +2 -1
  56. package/dist/commands/generate/schema.js.map +1 -0
  57. package/dist/commands/generate/token.js +1 -0
  58. package/dist/commands/generate/token.js.map +1 -0
  59. package/dist/commands/init/cloud.js +21 -15
  60. package/dist/commands/init/cloud.js.map +1 -0
  61. package/dist/commands/init/index.js +1 -0
  62. package/dist/commands/init/index.js.map +1 -0
  63. package/dist/commands/init/self-hosted.js +29 -3
  64. package/dist/commands/init/self-hosted.js.map +1 -0
  65. package/dist/commands/link/cloud.js +1 -0
  66. package/dist/commands/link/cloud.js.map +1 -0
  67. package/dist/commands/link/index.js +1 -0
  68. package/dist/commands/link/index.js.map +1 -0
  69. package/dist/commands/link/self-hosted.js +1 -0
  70. package/dist/commands/link/self-hosted.js.map +1 -0
  71. package/dist/commands/login.js +1 -0
  72. package/dist/commands/login.js.map +1 -0
  73. package/dist/commands/logout.js +1 -0
  74. package/dist/commands/logout.js.map +1 -0
  75. package/dist/commands/migrate/index.js +1 -0
  76. package/dist/commands/migrate/index.js.map +1 -0
  77. package/dist/commands/migrate/sync-rules.js +1 -0
  78. package/dist/commands/migrate/sync-rules.js.map +1 -0
  79. package/dist/commands/pull/index.js +1 -0
  80. package/dist/commands/pull/index.js.map +1 -0
  81. package/dist/commands/pull/instance.d.ts +1 -0
  82. package/dist/commands/pull/instance.js +27 -12
  83. package/dist/commands/pull/instance.js.map +1 -0
  84. package/dist/commands/status.js +1 -0
  85. package/dist/commands/status.js.map +1 -0
  86. package/dist/commands/stop.js +1 -0
  87. package/dist/commands/stop.js.map +1 -0
  88. package/dist/commands/validate.js +1 -0
  89. package/dist/commands/validate.js.map +1 -0
  90. package/dist/help.js +1 -0
  91. package/dist/help.js.map +1 -0
  92. package/dist/index.js +1 -0
  93. package/dist/index.js.map +1 -0
  94. package/oclif.manifest.json +7 -1
  95. package/package.json +10 -10
  96. package/templates/cloud/powersync/service.template.yaml +164 -0
  97. package/templates/self-hosted/base/powersync/service.template.yaml +209 -0
  98. package/templates/cloud/powersync/service.yaml +0 -174
  99. package/templates/self-hosted/base/powersync/service.yaml +0 -243
package/README.md CHANGED
@@ -239,7 +239,7 @@ $ npm install -g powersync
239
239
  $ powersync COMMAND
240
240
  running command...
241
241
  $ powersync (--version)
242
- powersync/0.0.0-dev-20260305101740 linux-x64 node-v24.14.0
242
+ powersync/0.0.0-dev-20260316080136 linux-x64 node-v24.14.0
243
243
  $ powersync --help [COMMAND]
244
244
  USAGE
245
245
  $ powersync COMMAND
@@ -388,7 +388,7 @@ EXAMPLES
388
388
  $ powersync configure ide
389
389
  ```
390
390
 
391
- _See code: [src/commands/configure/ide.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/configure/ide.ts)_
391
+ _See code: [src/commands/configure/ide.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/configure/ide.ts)_
392
392
 
393
393
  ## `powersync deploy`
394
394
 
@@ -428,7 +428,7 @@ EXAMPLES
428
428
  $ powersync deploy --instance-id=<id> --project-id=<id>
429
429
  ```
430
430
 
431
- _See code: [src/commands/deploy/index.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/deploy/index.ts)_
431
+ _See code: [src/commands/deploy/index.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/deploy/index.ts)_
432
432
 
433
433
  ## `powersync deploy service-config`
434
434
 
@@ -465,7 +465,7 @@ EXAMPLES
465
465
  $ powersync deploy service-config --instance-id=<id> --project-id=<id>
466
466
  ```
467
467
 
468
- _See code: [src/commands/deploy/service-config.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/deploy/service-config.ts)_
468
+ _See code: [src/commands/deploy/service-config.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/deploy/service-config.ts)_
469
469
 
470
470
  ## `powersync deploy sync-config`
471
471
 
@@ -504,7 +504,7 @@ EXAMPLES
504
504
  $ powersync deploy sync-config --instance-id=<id> --project-id=<id>
505
505
  ```
506
506
 
507
- _See code: [src/commands/deploy/sync-config.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/deploy/sync-config.ts)_
507
+ _See code: [src/commands/deploy/sync-config.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/deploy/sync-config.ts)_
508
508
 
509
509
  ## `powersync destroy`
510
510
 
@@ -541,7 +541,7 @@ EXAMPLES
541
541
  $ powersync destroy --confirm=yes
542
542
  ```
543
543
 
544
- _See code: [src/commands/destroy.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/destroy.ts)_
544
+ _See code: [src/commands/destroy.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/destroy.ts)_
545
545
 
546
546
  ## `powersync docker configure`
547
547
 
@@ -579,7 +579,7 @@ EXAMPLES
579
579
  $ powersync docker configure --database=postgres --storage=postgres
580
580
  ```
581
581
 
582
- _See code: [@powersync/cli-plugin-docker](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/docker/configure.ts)_
582
+ _See code: [@powersync/cli-plugin-docker](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/docker/configure.ts)_
583
583
 
584
584
  ## `powersync docker reset`
585
585
 
@@ -608,7 +608,7 @@ EXAMPLES
608
608
  $ powersync docker reset
609
609
  ```
610
610
 
611
- _See code: [@powersync/cli-plugin-docker](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/docker/reset.ts)_
611
+ _See code: [@powersync/cli-plugin-docker](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/docker/reset.ts)_
612
612
 
613
613
  ## `powersync docker start`
614
614
 
@@ -636,7 +636,7 @@ EXAMPLES
636
636
  $ powersync docker start
637
637
  ```
638
638
 
639
- _See code: [@powersync/cli-plugin-docker](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/docker/start.ts)_
639
+ _See code: [@powersync/cli-plugin-docker](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/docker/start.ts)_
640
640
 
641
641
  ## `powersync docker stop`
642
642
 
@@ -678,7 +678,7 @@ EXAMPLES
678
678
  $ powersync docker stop --project-name=powersync_myapp --remove
679
679
  ```
680
680
 
681
- _See code: [@powersync/cli-plugin-docker](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/docker/stop.ts)_
681
+ _See code: [@powersync/cli-plugin-docker](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/docker/stop.ts)_
682
682
 
683
683
  ## `powersync edit config`
684
684
 
@@ -720,7 +720,7 @@ EXAMPLES
720
720
  $ powersync edit config --directory ./powersync
721
721
  ```
722
722
 
723
- _See code: [@powersync/cli-plugin-config-edit](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/edit/config.ts)_
723
+ _See code: [@powersync/cli-plugin-config-edit](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/edit/config.ts)_
724
724
 
725
725
  ## `powersync fetch config`
726
726
 
@@ -757,7 +757,7 @@ EXAMPLES
757
757
  $ powersync fetch config --output=json
758
758
  ```
759
759
 
760
- _See code: [src/commands/fetch/config.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/fetch/config.ts)_
760
+ _See code: [src/commands/fetch/config.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/fetch/config.ts)_
761
761
 
762
762
  ## `powersync fetch instances`
763
763
 
@@ -785,7 +785,7 @@ EXAMPLES
785
785
  $ powersync fetch instances --project-id=<id> --output=json
786
786
  ```
787
787
 
788
- _See code: [src/commands/fetch/instances.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/fetch/instances.ts)_
788
+ _See code: [src/commands/fetch/instances.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/fetch/instances.ts)_
789
789
 
790
790
  ## `powersync fetch status`
791
791
 
@@ -830,7 +830,7 @@ EXAMPLES
830
830
  $ powersync fetch status --instance-id=<id> --project-id=<id>
831
831
  ```
832
832
 
833
- _See code: [src/commands/fetch/status.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/fetch/status.ts)_
833
+ _See code: [src/commands/fetch/status.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/fetch/status.ts)_
834
834
 
835
835
  ## `powersync generate schema`
836
836
 
@@ -874,7 +874,7 @@ EXAMPLES
874
874
  $ powersync generate schema --output=dart --output-path=lib/schema.dart --instance-id=<id> --project-id=<id>
875
875
  ```
876
876
 
877
- _See code: [src/commands/generate/schema.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/generate/schema.ts)_
877
+ _See code: [src/commands/generate/schema.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/generate/schema.ts)_
878
878
 
879
879
  ## `powersync generate token`
880
880
 
@@ -920,7 +920,7 @@ EXAMPLES
920
920
  $ powersync generate token --subject=user-123 --expires-in-seconds=3600
921
921
  ```
922
922
 
923
- _See code: [src/commands/generate/token.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/generate/token.ts)_
923
+ _See code: [src/commands/generate/token.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/generate/token.ts)_
924
924
 
925
925
  ## `powersync help [COMMAND]`
926
926
 
@@ -966,7 +966,7 @@ EXAMPLES
966
966
  $ powersync init cloud --directory=powersync
967
967
  ```
968
968
 
969
- _See code: [src/commands/init/cloud.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/init/cloud.ts)_
969
+ _See code: [src/commands/init/cloud.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/init/cloud.ts)_
970
970
 
971
971
  ## `powersync init self-hosted`
972
972
 
@@ -993,7 +993,7 @@ EXAMPLES
993
993
  $ powersync init self-hosted --directory=powersync
994
994
  ```
995
995
 
996
- _See code: [src/commands/init/self-hosted.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/init/self-hosted.ts)_
996
+ _See code: [src/commands/init/self-hosted.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/init/self-hosted.ts)_
997
997
 
998
998
  ## `powersync link cloud`
999
999
 
@@ -1032,7 +1032,7 @@ EXAMPLES
1032
1032
  $ powersync link cloud --instance-id=<id> --project-id=<project-id> --org-id=<org-id>
1033
1033
  ```
1034
1034
 
1035
- _See code: [src/commands/link/cloud.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/link/cloud.ts)_
1035
+ _See code: [src/commands/link/cloud.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/link/cloud.ts)_
1036
1036
 
1037
1037
  ## `powersync link self-hosted`
1038
1038
 
@@ -1060,7 +1060,7 @@ EXAMPLES
1060
1060
  $ powersync link self-hosted --api-url=https://powersync.example.com
1061
1061
  ```
1062
1062
 
1063
- _See code: [src/commands/link/self-hosted.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/link/self-hosted.ts)_
1063
+ _See code: [src/commands/link/self-hosted.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/link/self-hosted.ts)_
1064
1064
 
1065
1065
  ## `powersync login`
1066
1066
 
@@ -1081,7 +1081,7 @@ EXAMPLES
1081
1081
  $ powersync login
1082
1082
  ```
1083
1083
 
1084
- _See code: [src/commands/login.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/login.ts)_
1084
+ _See code: [src/commands/login.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/login.ts)_
1085
1085
 
1086
1086
  ## `powersync logout`
1087
1087
 
@@ -1101,7 +1101,7 @@ EXAMPLES
1101
1101
  $ powersync logout
1102
1102
  ```
1103
1103
 
1104
- _See code: [src/commands/logout.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/logout.ts)_
1104
+ _See code: [src/commands/logout.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/logout.ts)_
1105
1105
 
1106
1106
  ## `powersync migrate sync-rules`
1107
1107
 
@@ -1138,7 +1138,7 @@ DESCRIPTION
1138
1138
  Migrates Sync Rules to Sync Streams
1139
1139
  ```
1140
1140
 
1141
- _See code: [src/commands/migrate/sync-rules.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/migrate/sync-rules.ts)_
1141
+ _See code: [src/commands/migrate/sync-rules.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/migrate/sync-rules.ts)_
1142
1142
 
1143
1143
  ## `powersync plugins`
1144
1144
 
@@ -1437,6 +1437,12 @@ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
1437
1437
  ```
1438
1438
  USAGE
1439
1439
  $ powersync pull instance [--directory <value>] [--instance-id <value> --project-id <value>] [--org-id <value>]
1440
+ [--overwrite]
1441
+
1442
+ FLAGS
1443
+ --overwrite Overwrite existing service.yaml and sync-config.yaml if they exist. By default, if these files already
1444
+ exist, the fetched configs will be written to service-fetched.yaml and sync-fetched.yaml to avoid
1445
+ overwriting local changes.
1440
1446
 
1441
1447
  PROJECT FLAGS
1442
1448
  --directory=<value> [default: powersync] Directory containing PowerSync config. Defaults to "powersync". This is
@@ -1464,7 +1470,7 @@ EXAMPLES
1464
1470
  $ powersync pull instance --instance-id=<id> --project-id=<id> --org-id=<org-id>
1465
1471
  ```
1466
1472
 
1467
- _See code: [src/commands/pull/instance.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/pull/instance.ts)_
1473
+ _See code: [src/commands/pull/instance.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/pull/instance.ts)_
1468
1474
 
1469
1475
  ## `powersync status`
1470
1476
 
@@ -1509,7 +1515,7 @@ EXAMPLES
1509
1515
  $ powersync status --instance-id=<id> --project-id=<id>
1510
1516
  ```
1511
1517
 
1512
- _See code: [src/commands/status.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/status.ts)_
1518
+ _See code: [src/commands/status.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/status.ts)_
1513
1519
 
1514
1520
  ## `powersync stop`
1515
1521
 
@@ -1546,7 +1552,7 @@ EXAMPLES
1546
1552
  $ powersync stop --confirm=yes
1547
1553
  ```
1548
1554
 
1549
- _See code: [src/commands/stop.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/stop.ts)_
1555
+ _See code: [src/commands/stop.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/stop.ts)_
1550
1556
 
1551
1557
  ## `powersync validate`
1552
1558
 
@@ -1591,6 +1597,6 @@ EXAMPLES
1591
1597
  $ powersync validate --api-url=https://powersync.example.com
1592
1598
  ```
1593
1599
 
1594
- _See code: [src/commands/validate.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260305101740/src/commands/validate.ts)_
1600
+ _See code: [src/commands/validate.ts](https://github.com/powersync-ja/powersync-cli/blob/v0.0.0-dev-20260316080136/src/commands/validate.ts)_
1595
1601
 
1596
1602
  <!-- commandsstop -->
package/bin/dev.js CHANGED
@@ -11,12 +11,18 @@ setCliClientHeaders({
11
11
  'user-agent': `POWERSYNC_CLI/${packageJSON.version}`
12
12
  });
13
13
 
14
+ // Ensure pnpm scripts run in the shell's original cwd (pnpm sets INIT_CWD for this).
15
+ if (process.env.INIT_CWD && process.env.INIT_CWD !== process.cwd()) {
16
+ process.chdir(process.env.INIT_CWD);
17
+ }
18
+
14
19
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
15
20
 
16
21
  await execute({
17
22
  development: true,
18
- dir: import.meta.url,
23
+ // Force oclif to ignore the baked manifest so it resolves commands from TS via tsx.
19
24
  loadOptions: {
25
+ ignoreManifest: true,
20
26
  root: path.resolve(__dirname, '..')
21
27
  }
22
28
  });
@@ -0,0 +1,29 @@
1
+ import { BaseServiceSelfHostedConfig, ServiceCloudConfig } from '@powersync/cli-schemas';
2
+ export type BuildServiceYamlOptions = {
3
+ /**
4
+ * The service configuration to render in the form of the provided template.
5
+ */
6
+ baseConfig: Partial<BaseServiceSelfHostedConfig | ServiceCloudConfig>;
7
+ /**
8
+ * A YAML comment block to attach to the top of the rendered YAML file, typically containing schema information and links to documentation.
9
+ */
10
+ schemaHeader: string;
11
+ /**
12
+ * The absolute path to the YAML template file to use for rendering. This file should contain all possible configuration options with comments.
13
+ */
14
+ templatePath: string;
15
+ /**
16
+ * For certain fields that are arrays of objects (e.g. replication->connections), if the provided config has an empty array, we want to replace it with a commented-out example from the template. This option allows specifying the paths to those fields in order to apply that replacement logic after the initial rendering of comments and missing fields.
17
+ */
18
+ templateReplacementPaths?: string[][];
19
+ };
20
+ /**
21
+ * Renders a service YAML file from a concrete base config and a parseable template.
22
+ * Given a service config, the rendering process involves:
23
+ * - Adding comments to fields from the template.
24
+ * - Adding commented-out snippets for missing fields from the template, placed at the end of their respective sections.
25
+ * - Preserving the order of fields as defined in the template.
26
+ *
27
+ * The output is a YAML string that can be written to a file, with comments and structure that guide users in filling out missing information.
28
+ */
29
+ export declare function buildServiceYaml({ baseConfig, schemaHeader, templatePath, templateReplacementPaths }: BuildServiceYamlOptions): string;
@@ -0,0 +1,246 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { Document, isMap, isNode, isPair, isScalar, isSeq, Pair, parseDocument, YAMLMap } from 'yaml';
3
+ /**
4
+ * Renders a service YAML file from a concrete base config and a parseable template.
5
+ * Given a service config, the rendering process involves:
6
+ * - Adding comments to fields from the template.
7
+ * - Adding commented-out snippets for missing fields from the template, placed at the end of their respective sections.
8
+ * - Preserving the order of fields as defined in the template.
9
+ *
10
+ * The output is a YAML string that can be written to a file, with comments and structure that guide users in filling out missing information.
11
+ */
12
+ export function buildServiceYaml({ baseConfig, schemaHeader, templatePath, templateReplacementPaths }) {
13
+ const templateContent = readFileSync(templatePath, 'utf8');
14
+ const templateDoc = parseDocument(templateContent);
15
+ const outputDoc = new Document(baseConfig);
16
+ // Both documents should be a YAML map at the root level.
17
+ if (!isMap(templateDoc.contents) || !isMap(outputDoc.contents)) {
18
+ throw new Error('Expected both template and base config to be YAML maps at the root level.');
19
+ }
20
+ // Recursively starts annotating the provided config given the template.
21
+ annotateLevelFromTemplate({ outputMap: outputDoc.contents, templateMap: templateDoc.contents });
22
+ /**
23
+ * For some values, such as the replication->connections array or the client_auth->jwks->keys array,
24
+ * we want to add a commented-out example from the template if the array (in the service config) is empty.
25
+ * This allows users to see example options, and gives a quick path for them to configure the config.
26
+ * This parsing is handled after the initial parsing of the template.
27
+ * We want to avoid rendering incomplete YAML sections such as
28
+ * ```yaml
29
+ * replication:
30
+ * connections: # No content here
31
+ * # No content here
32
+ * client_auth:
33
+ * # etc
34
+ * ```
35
+ * This typically causes a validation error.
36
+ * Instead, we want to render the section with a commented-out example from the template, such as:
37
+ * ```yaml
38
+ * #replication:
39
+ * # connections:
40
+ * # - name: example-connection
41
+ * # host: example.com
42
+ * # port: 1234
43
+ * client_auth:
44
+ * jwks:
45
+ * ```
46
+ * This implements a replacement for those empty arrays.
47
+ */
48
+ for (const { path, shouldReplace } of [
49
+ {
50
+ path: ['replication', 'connections'],
51
+ shouldReplace: baseConfig.replication?.connections?.length === 0
52
+ },
53
+ { path: ['client_auth', 'jwks', 'keys'], shouldReplace: baseConfig.client_auth?.jwks?.keys?.length === 0 },
54
+ ...(templateReplacementPaths?.map((path) => ({ path, shouldReplace: true })) ?? [])
55
+ ]) {
56
+ if (!shouldReplace)
57
+ continue;
58
+ replaceListWithComment({
59
+ outputRootDoc: outputDoc,
60
+ path,
61
+ templateDoc
62
+ });
63
+ }
64
+ const renderedYaml = outputDoc.toString();
65
+ return `${schemaHeader}\n\n${renderedYaml}`;
66
+ }
67
+ /**
68
+ * Adds a comment to the target YAML node. The comment can be either a comment on the same line (comment) or a comment on the line before (commentBefore).
69
+ */
70
+ function annotateComment(options) {
71
+ const { appendComments = true, comment, commentBefore, target } = options;
72
+ if (!comment && !commentBefore)
73
+ return;
74
+ if (isScalar(target)) {
75
+ if (comment)
76
+ target.comment = appendComments ? (target.comment ?? '') + '\n' + comment : comment;
77
+ if (commentBefore)
78
+ target.commentBefore = appendComments ? commentBefore + '\n\n' + (target.commentBefore ?? '') : commentBefore;
79
+ }
80
+ else if (isPair(target) && isScalar(target.key)) {
81
+ if (comment)
82
+ target.key.comment = appendComments ? (target.key.comment ?? '') + '\n' + comment : comment;
83
+ if (commentBefore)
84
+ target.key.commentBefore = appendComments
85
+ ? commentBefore + '\n\n' + (target.key.commentBefore ?? '')
86
+ : commentBefore;
87
+ }
88
+ }
89
+ function copyNodeComments(source, target) {
90
+ if (!isNode(source) || !isNode(target))
91
+ return;
92
+ target.comment = source.comment;
93
+ target.commentBefore = source.commentBefore;
94
+ }
95
+ /**
96
+ * Copies comments from the source YAML node to the target YAML node, including comments on the node itself, as well as comments on the key and value if the node is a pair. This ensures that all relevant comments from the template are preserved in the output YAML.
97
+ */
98
+ function copyComments(options) {
99
+ const { source, target } = options;
100
+ // Pair-level comments
101
+ copyNodeComments(source, target);
102
+ // Key comments
103
+ copyNodeComments(source.key, target.key);
104
+ if (isSeq(source.value) && isSeq(target.value) && target.value.items.length > 0) {
105
+ // Avoid copying template block comments for sequences when we already have data
106
+ // (e.g. replication->connections), otherwise example comments bleed into real configs.
107
+ return;
108
+ }
109
+ // Value comments (covers scalars and maps that carry block comments before the value)
110
+ copyNodeComments(source.value, target.value);
111
+ }
112
+ /**
113
+ * Copies comments from the template to the output YAML at all levels, and appends optional template snippets for any missing keys.
114
+ */
115
+ function annotateLevelFromTemplate(options) {
116
+ const { outputMap, templateMap } = options;
117
+ // For items not present in the currentConfig, we'll add commented out snippets from the template at the end of the section.
118
+ const missingPairs = [];
119
+ for (const templatePair of templateMap.items) {
120
+ const key = getPairKey(templatePair);
121
+ if (!key)
122
+ continue;
123
+ const outputPair = outputMap.items.find((pair) => getPairKey(pair) === key);
124
+ if (!outputMap.has(key) || !outputPair) {
125
+ // We need to add this pair as a commented-out snippet later.
126
+ missingPairs.push(templatePair);
127
+ continue;
128
+ }
129
+ copyComments({
130
+ source: templatePair,
131
+ target: outputPair
132
+ });
133
+ // Add spacing between pairs
134
+ if (isNode(outputPair.key) && isNode(templatePair.key)) {
135
+ outputPair.key.spaceBefore = templatePair.key.spaceBefore;
136
+ }
137
+ // Walk the tree recursively for maps and sequences
138
+ if (isMap(templatePair.value) && isMap(outputPair.value)) {
139
+ annotateLevelFromTemplate({ outputMap: outputPair.value, templateMap: templatePair.value });
140
+ }
141
+ else if (isSeq(templatePair.value) && isSeq(outputPair.value)) {
142
+ for (const outputItem of outputPair.value.items) {
143
+ // For sequences, we need a method to match the items.
144
+ // We currently only deeply traverse replication->connections and client_auth->jwks->keys, which both have a "type" or "kty" field we can use for matching.
145
+ const matchingTemplateItem = templatePair.value.items.find((templateItem) => {
146
+ if (isMap(templateItem) && isMap(outputItem)) {
147
+ return ((templateItem.has('type') &&
148
+ outputItem.has('type') &&
149
+ templateItem.get('type') === outputItem.get('type')) ||
150
+ (templateItem.has('kty') && outputItem.has('kty') && templateItem.get('kty') === outputItem.get('kty')));
151
+ }
152
+ return false;
153
+ });
154
+ if (!matchingTemplateItem)
155
+ continue;
156
+ annotateLevelFromTemplate({
157
+ outputMap: outputItem,
158
+ templateMap: matchingTemplateItem
159
+ });
160
+ }
161
+ }
162
+ }
163
+ if (missingPairs.length > 0) {
164
+ matchSorting({
165
+ orderedBy: templateMap.items,
166
+ toBeSorted: missingPairs
167
+ });
168
+ // The fact that we use a node comment means the indentation will be handled automatically.
169
+ const snippets = missingPairs.map((pair) => pairToYaml(pair)).join('\n');
170
+ outputMap.comment = (outputMap.comment ? outputMap.comment + '\n' : '') + snippets;
171
+ }
172
+ matchSorting({
173
+ orderedBy: templateMap.items,
174
+ toBeSorted: outputMap.items
175
+ });
176
+ }
177
+ function getPairKey(pair) {
178
+ if (!isScalar(pair.key))
179
+ return null;
180
+ const { value } = pair.key;
181
+ return typeof value === 'string' ? value : String(value);
182
+ }
183
+ function pairToYaml(pair) {
184
+ const map = new YAMLMap();
185
+ map.items = [pair];
186
+ return new Document(map).toString().trimEnd();
187
+ }
188
+ function replaceListWithComment(options) {
189
+ // This is only true if the array is present and empty.
190
+ // If the replication connections array is empty, add a commented-out example from the template.
191
+ const { outputRootDoc, path, templateDoc } = options;
192
+ const parentOutputContainer = outputRootDoc.getIn(path.slice(0, -1), true);
193
+ if (!isMap(parentOutputContainer)) {
194
+ throw new Error(`Expected parent of ${path.slice(0, -1).join('.')} to be a YAML map.`);
195
+ }
196
+ const finalOutputKey = path.at(-1);
197
+ const outputItemIndex = parentOutputContainer.items.findIndex((pair) => getPairKey(pair) === finalOutputKey);
198
+ if (outputItemIndex === -1) {
199
+ throw new Error(`Expected ${finalOutputKey} key to be present in the output YAML.`);
200
+ }
201
+ const outputItem = parentOutputContainer.items[outputItemIndex];
202
+ const templatePair = templateDoc.getIn(path, true);
203
+ const templateCommentString = pairToYaml(new Pair(finalOutputKey, templatePair));
204
+ /**
205
+ * We don't want any empty objects/maps in the output YAML.
206
+ * That causes validation errors and requires additional effort from users to input.
207
+ * Instead, if a map is empty, we traverse on level up and add the map item as a comment on
208
+ * that level.
209
+ */
210
+ const siblingPair = parentOutputContainer.items[outputItemIndex + 1];
211
+ if (siblingPair) {
212
+ // Add this example as a comment on the next sibling key.
213
+ // We also need to preserve the current comment on the current key.
214
+ const previousCommentBefore = (isScalar(outputItem.key) && outputItem.key.commentBefore && `${outputItem.key.commentBefore}\n`) || '';
215
+ annotateComment({ commentBefore: previousCommentBefore + templateCommentString, target: siblingPair });
216
+ }
217
+ else if (path.length === 1) {
218
+ // If there is no sibling and we are at the root, we just need to append it as a comment to the main doc
219
+ parentOutputContainer.comment = (parentOutputContainer.comment || '') + templateCommentString;
220
+ }
221
+ else {
222
+ // Move one level up and add the example as a comment on the parent key
223
+ return replaceListWithComment({
224
+ outputRootDoc,
225
+ path: path.slice(0, -1),
226
+ templateDoc
227
+ });
228
+ }
229
+ // Delete the original yaml node
230
+ parentOutputContainer.delete(outputItem.key);
231
+ }
232
+ /**
233
+ * Sorts on array of YAML items by the order of another array's keyed values.
234
+ */
235
+ function matchSorting(params) {
236
+ const { orderedBy, toBeSorted } = params;
237
+ const orderMap = new Map(orderedBy.map((item, index) => [getPairKey(item), index]));
238
+ toBeSorted.sort((a, b) => {
239
+ const aKey = getPairKey(a);
240
+ const bKey = getPairKey(b);
241
+ const aIndex = aKey ? (orderMap.get(aKey) ?? Number.POSITIVE_INFINITY) : Number.POSITIVE_INFINITY;
242
+ const bIndex = bKey ? (orderMap.get(bKey) ?? Number.POSITIVE_INFINITY) : Number.POSITIVE_INFINITY;
243
+ return aIndex - bIndex;
244
+ });
245
+ }
246
+ //# sourceMappingURL=build-service-yaml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-service-yaml.js","sourceRoot":"","sources":["../../src/api/build-service-yaml.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAsBtG;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,wBAAwB,EACA;IACxB,MAAM,eAAe,GAAG,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAC3D,MAAM,WAAW,GAAG,aAAa,CAAC,eAAe,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;IAE3C,yDAAyD;IACzD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/D,MAAM,IAAI,KAAK,CAAC,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,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC;QAClG,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC;QAClG,OAAO,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -17,3 +17,4 @@ export async function createCloudInstance(client, options) {
17
17
  });
18
18
  return { instanceId: result.id };
19
19
  }
20
+ //# sourceMappingURL=create-cloud-instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-cloud-instance.js","sourceRoot":"","sources":["../../../src/api/cloud/create-cloud-instance.ts"],"names":[],"mappings":"AAaA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAAiC,EACjC,OAAmC;IAEnC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEnD,8FAA8F;IAC9F,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;IAC3C,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACb,UAAU,MAAM,iFAAiF,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAClJ,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC;QACzC,MAAM,EAAE,SAAS;QACjB,IAAI;QACJ,MAAM,EAAE,KAAK;QACb,MAAM;KACP,CAAC,CAAC;IACH,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1,15 @@
1
+ export declare const CLOUD_TEMPLATES_DIR: string;
2
+ export declare const SERVICE_TEMPLATE_FILENAME = "service.template.yaml";
3
+ export declare const CLOUD_SERVICE_TEMPLATE_PATH: string;
4
+ export declare const CLOUD_SYNC_CONFIG_TEMPLATE_PATH: string;
5
+ export declare const CLOUD_CLI_TEMPLATE_PATH: string;
6
+ export type WriteCloudTemplateFilesParams = {
7
+ targetDir: string;
8
+ };
9
+ export declare function writeCloudSyncConfigFile(params: WriteCloudTemplateFilesParams): Promise<void>;
10
+ /**
11
+ * Copies the cloud template files to the provided destination.
12
+ * YAML schemas are applied to copied files.
13
+ * This copies the template Sync config and CLI config files.
14
+ */
15
+ export declare function writeCloudTemplateFiles(params: WriteCloudTemplateFilesParams): Promise<void>;
@@ -0,0 +1,33 @@
1
+ import { CLI_FILENAME, SYNC_FILENAME, YAML_CLI_SCHEMA, YAML_SYNC_RULES_SCHEMA } from '@powersync/cli-core';
2
+ import { copyFile, mkdir, readFile, writeFile } from 'node:fs/promises';
3
+ import { dirname, join } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+ export const CLOUD_TEMPLATES_DIR = join(__dirname, '..', '..', '..', 'templates', 'cloud', 'powersync');
7
+ export const SERVICE_TEMPLATE_FILENAME = 'service.template.yaml';
8
+ export const CLOUD_SERVICE_TEMPLATE_PATH = join(CLOUD_TEMPLATES_DIR, SERVICE_TEMPLATE_FILENAME);
9
+ export const CLOUD_SYNC_CONFIG_TEMPLATE_PATH = join(CLOUD_TEMPLATES_DIR, SYNC_FILENAME);
10
+ export const CLOUD_CLI_TEMPLATE_PATH = join(CLOUD_TEMPLATES_DIR, CLI_FILENAME);
11
+ export async function writeCloudSyncConfigFile(params) {
12
+ const { targetDir } = params;
13
+ const syncOutputPath = join(targetDir, SYNC_FILENAME);
14
+ await copyFile(CLOUD_SYNC_CONFIG_TEMPLATE_PATH, syncOutputPath);
15
+ await writeFile(syncOutputPath, `${YAML_SYNC_RULES_SCHEMA}\n\n${await readFile(syncOutputPath, 'utf8')}`);
16
+ }
17
+ /**
18
+ * Copies the cloud template files to the provided destination.
19
+ * YAML schemas are applied to copied files.
20
+ * This copies the template Sync config and CLI config files.
21
+ */
22
+ export async function writeCloudTemplateFiles(params) {
23
+ const { targetDir } = params;
24
+ // Create the target directory if it doesn't exist
25
+ await mkdir(targetDir, { recursive: true });
26
+ // Initial copy of template files
27
+ const cliOutputPath = join(targetDir, CLI_FILENAME);
28
+ await copyFile(CLOUD_CLI_TEMPLATE_PATH, cliOutputPath);
29
+ // Add schemas to templates
30
+ await writeFile(cliOutputPath, `${YAML_CLI_SCHEMA}\n\n${await readFile(cliOutputPath, 'utf8')}`);
31
+ await writeCloudSyncConfigFile(params);
32
+ }
33
+ //# sourceMappingURL=create-cloud-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-cloud-template.js","sourceRoot":"","sources":["../../../src/api/cloud/create-cloud-template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC3G,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAA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,CAAC,CAAC;AACzC,CAAC"}
@@ -16,3 +16,4 @@ export async function fetchCloudConfig(client, linked) {
16
16
  });
17
17
  return decodeFetchedCloudConfig(instanceConfig);
18
18
  }
19
+ //# sourceMappingURL=fetch-cloud-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-cloud-config.js","sourceRoot":"","sources":["../../../src/api/cloud/fetch-cloud-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,kBAAkB,EAA6B,MAAM,wBAAwB,CAAC;AAS/G,MAAM,UAAU,wBAAwB,CAAC,cAA6C;IACpF,MAAM,eAAe,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;IAChG,8DAA8D;IAC9D,MAAM,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAC,eAAsB,CAAC,CAAC;IACjE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,CAAC,UAAU,EAAE,CAAC;AAC1D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAiC,EACjC,MAA8B;IAE9B,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC;QACpD,MAAM,EAAE,MAAM,CAAC,UAAU;QACzB,EAAE,EAAE,MAAM,CAAC,WAAW;QACtB,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC,CAAC;IACH,OAAO,wBAAwB,CAAC,cAAc,CAAC,CAAC;AAClD,CAAC"}
@@ -24,3 +24,4 @@ export async function fetchCloudSyncRulesContent(project) {
24
24
  }
25
25
  return instanceConfig.sync_rules;
26
26
  }
27
+ //# sourceMappingURL=fetch-cloud-sync-rules-content.js.map