orez 0.0.7 → 0.0.8

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 CHANGED
@@ -1,28 +1,22 @@
1
1
  # orez
2
2
 
3
- [Zero](https://zero.rocicorp.dev) development backend powered by [PGlite](https://pglite.dev). Bundles PostgreSQL and zero-cache into a single process with no system dependencies.
3
+ [Zero](https://zero.rocicorp.dev) development backend powered by [PGlite](https://pglite.dev). Bundles PostgreSQL and zero-cache into a single process no Docker, no Postgres install.
4
4
 
5
- `bun install && bun dev` — that's it.
6
-
7
- ## How it works
8
-
9
- orez starts three things in one process:
10
-
11
- 1. A PGlite instance (full PostgreSQL 16 running in-process via WASM)
12
- 2. A TCP proxy that speaks the PostgreSQL wire protocol, including logical replication
13
- 3. A zero-cache child process that connects to the proxy thinking it's a real Postgres server
5
+ ```
6
+ npx orez
7
+ ```
14
8
 
15
- The trick is in the TCP proxy. zero-cache needs logical replication to stay in sync with the upstream database. PGlite doesn't support logical replication natively, so orez fakes it. Every mutation is captured by triggers into a changes table, then encoded into the pgoutput binary protocol and streamed to zero-cache through the replication connection. zero-cache can't tell the difference.
9
+ Starts PGlite, the TCP proxy, and zero-cache. Ports auto-increment if already in use.
16
10
 
17
- The proxy also handles multi-database routing. zero-cache expects three separate databases (upstream, CVR, change), but PGlite is a single database. orez maps database names to schemas, so `zero_cvr` becomes the `zero_cvr` schema and `zero_cdb` becomes `zero_cdb`.
11
+ Exports a CLI, programmatic API, and Vite plugin.
18
12
 
19
13
  ## Install
20
14
 
21
15
  ```
22
- npm install orez @rocicorp/zero
16
+ npm install orez
23
17
  ```
24
18
 
25
- `@rocicorp/zero` is a peer dependency that provides the zero-cache binary. You can skip it if you only need PGlite + the proxy (`--skip-zero-cache`).
19
+ `@rocicorp/zero` is included as a dependency and provides the zero-cache binary.
26
20
 
27
21
  ## CLI
28
22
 
@@ -30,8 +24,6 @@ npm install orez @rocicorp/zero
30
24
  npx orez
31
25
  ```
32
26
 
33
- Starts PGlite, the TCP proxy, and zero-cache. Ports auto-increment if already in use.
34
-
35
27
  ```
36
28
  --pg-port postgresql proxy port (default: 6434)
37
29
  --zero-port zero-cache port (default: 5849)
@@ -42,9 +34,11 @@ Starts PGlite, the TCP proxy, and zero-cache. Ports auto-increment if already in
42
34
  --pg-password postgresql password (default: password)
43
35
  --skip-zero-cache run pglite + proxy only, skip zero-cache
44
36
  --log-level error, warn, info, debug (default: info)
37
+ --s3 also start a local s3-compatible server
38
+ --s3-port s3 server port (default: 9200)
45
39
  ```
46
40
 
47
- S3 subcommand:
41
+ S3 can also run standalone:
48
42
 
49
43
  ```
50
44
  npx orez s3
@@ -83,12 +77,25 @@ export default {
83
77
  pgPort: 6434,
84
78
  zeroPort: 5849,
85
79
  migrationsDir: 'src/database/migrations',
80
+ s3: true,
86
81
  }),
87
82
  ],
88
83
  }
89
84
  ```
90
85
 
91
- Starts orez when vite dev server starts, stops on close.
86
+ Starts orez when vite dev server starts, stops on close. Pass `s3: true` to also start a local s3 server.
87
+
88
+ ## How it works
89
+
90
+ orez starts three things in one process:
91
+
92
+ 1. A PGlite instance (full PostgreSQL 16 running in-process via WASM)
93
+ 2. A TCP proxy that speaks the PostgreSQL wire protocol, including logical replication
94
+ 3. A zero-cache child process that connects to the proxy thinking it's a real Postgres server
95
+
96
+ The trick is in the TCP proxy. zero-cache needs logical replication to stay in sync with the upstream database. PGlite doesn't support logical replication natively, so orez fakes it. Every mutation is captured by triggers into a changes table, then encoded into the pgoutput binary protocol and streamed to zero-cache through the replication connection. zero-cache can't tell the difference.
97
+
98
+ The proxy also handles multi-database routing. zero-cache expects three separate databases (upstream, CVR, change), but PGlite is a single database. orez maps database names to schemas, so `zero_cvr` becomes the `zero_cvr` schema and `zero_cdb` becomes `zero_cdb`.
92
99
 
93
100
  ## Environment variables
94
101
 
@@ -96,16 +103,16 @@ Your entire environment is forwarded to the zero-cache child process. This means
96
103
 
97
104
  orez provides sensible defaults for a few variables:
98
105
 
99
- | Variable | Default | Overridable |
100
- |----------|---------|-------------|
101
- | `NODE_ENV` | `development` | yes |
102
- | `ZERO_LOG_LEVEL` | from `--log-level` | yes |
103
- | `ZERO_NUM_SYNC_WORKERS` | `1` | yes |
104
- | `ZERO_UPSTREAM_DB` | *(managed by orez)* | no |
105
- | `ZERO_CVR_DB` | *(managed by orez)* | no |
106
- | `ZERO_CHANGE_DB` | *(managed by orez)* | no |
107
- | `ZERO_REPLICA_FILE` | *(managed by orez)* | no |
108
- | `ZERO_PORT` | *(managed by orez)* | no |
106
+ | Variable | Default | Overridable |
107
+ | ----------------------- | ------------------- | ----------- |
108
+ | `NODE_ENV` | `development` | yes |
109
+ | `ZERO_LOG_LEVEL` | from `--log-level` | yes |
110
+ | `ZERO_NUM_SYNC_WORKERS` | `1` | yes |
111
+ | `ZERO_UPSTREAM_DB` | _(managed by orez)_ | no |
112
+ | `ZERO_CVR_DB` | _(managed by orez)_ | no |
113
+ | `ZERO_CHANGE_DB` | _(managed by orez)_ | no |
114
+ | `ZERO_REPLICA_FILE` | _(managed by orez)_ | no |
115
+ | `ZERO_PORT` | _(managed by orez)_ | no |
109
116
 
110
117
  The `--log-level` flag controls both zero-cache (`ZERO_LOG_LEVEL`) and PGlite's debug output. Setting it to `debug` enables verbose logging from both.
111
118
 
@@ -134,6 +141,23 @@ The proxy intercepts several things to convince zero-cache it's talking to a rea
134
141
 
135
142
  The pgoutput encoder produces spec-compliant binary messages: Begin, Relation, Insert, Update, Delete, Commit, and Keepalive. All column values are encoded as text (typeOid 25), which zero-cache handles fine since it re-maps types downstream anyway.
136
143
 
144
+ ## Extra: orez/s3
145
+
146
+ Local s3-compatible server for dev. Avoids needing Docker or MinIO.
147
+
148
+ ```typescript
149
+ import { startS3Local } from 'orez/s3'
150
+
151
+ const server = await startS3Local({
152
+ port: 9200,
153
+ dataDir: '.orez',
154
+ })
155
+ ```
156
+
157
+ Or via CLI: `npx orez --s3` or standalone `npx orez s3`.
158
+
159
+ Handles GET, PUT, DELETE, HEAD with CORS. Files stored on disk. No multipart, no ACLs, no versioning.
160
+
137
161
  ## Tests
138
162
 
139
163
  82 tests across 6 test files covering the full stack from binary encoding to TCP-level integration:
@@ -172,21 +196,6 @@ src/
172
196
  change-tracker.ts trigger installation and change reader
173
197
  ```
174
198
 
175
- ## Extra: orez/s3
176
-
177
- The other annoying dep we found ourselves needing often was s3, so we're exporting `orez/s3`. Its likewise a tiny, dev-only helper for avoiding heavy docker deps like minio.
178
-
179
- ```typescript
180
- import { startS3Local } from 'orez/s3'
181
-
182
- const server = await startS3Local({
183
- port: 9200,
184
- dataDir: '.orez',
185
- })
186
- ```
187
-
188
- Handles GET, PUT, DELETE, HEAD with CORS. Files stored on disk. No multipart, no ACLs, no versioning.
189
-
190
199
  ## License
191
200
 
192
201
  MIT
package/dist/cli.js CHANGED
@@ -86,6 +86,16 @@ const main = defineCommand({
86
86
  description: 'log level: error, warn, info, debug',
87
87
  default: 'info',
88
88
  },
89
+ s3: {
90
+ type: 'boolean',
91
+ description: 'also start a local s3-compatible server',
92
+ default: false,
93
+ },
94
+ 's3-port': {
95
+ type: 'string',
96
+ description: 's3 server port',
97
+ default: '9200',
98
+ },
89
99
  },
90
100
  subCommands: {
91
101
  s3: s3Command,
@@ -102,16 +112,25 @@ const main = defineCommand({
102
112
  skipZeroCache: args['skip-zero-cache'],
103
113
  logLevel: args['log-level'],
104
114
  });
115
+ let s3Server = null;
116
+ if (args.s3) {
117
+ s3Server = await startS3Local({
118
+ port: Number(args['s3-port']),
119
+ dataDir: args['data-dir'],
120
+ });
121
+ }
105
122
  log.orez('ready');
106
123
  log.orez(`pg: postgresql://${config.pgUser}:${config.pgPassword}@127.0.0.1:${config.pgPort}/postgres`);
107
124
  if (!config.skipZeroCache) {
108
125
  log.zero(`http://localhost:${config.zeroPort}`);
109
126
  }
110
127
  process.on('SIGINT', async () => {
128
+ s3Server?.close();
111
129
  await stop();
112
130
  process.exit(0);
113
131
  });
114
132
  process.on('SIGTERM', async () => {
133
+ s3Server?.close();
115
134
  await stop();
116
135
  process.exit(0);
117
136
  });
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C,MAAM,SAAS,GAAG,aAAa,CAAC;IAC9B,IAAI,EAAE;QACJ,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,oCAAoC;KAClD;IACD,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,mBAAmB;YAChC,OAAO,EAAE,MAAM;SAChB;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,iCAAiC;YAC9C,OAAO,EAAE,OAAO;SACjB;KACF;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QAChB,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC;YAChC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YACvB,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;SAC1B,CAAC,CAAA;QAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACxB,MAAM,CAAC,KAAK,EAAE,CAAA;YACd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC,CAAC,CAAA;QACF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YACzB,MAAM,CAAC,KAAK,EAAE,CAAA;YACd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC,CAAC,CAAA;IACJ,CAAC;C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,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC,CAAC,CAAA;IACJ,CAAC;CACF,CAAC,CAAA;AAEF,OAAO,CAAC,IAAI,CAAC,CAAA"}
@@ -1,6 +1,8 @@
1
1
  import type { ZeroLiteConfig } from './config.js';
2
2
  import type { Plugin } from 'vite';
3
3
  export interface OrezPluginOptions extends Partial<ZeroLiteConfig> {
4
+ s3?: boolean;
5
+ s3Port?: number;
4
6
  }
5
7
  export default function orez(options?: OrezPluginOptions): Plugin;
6
8
  //# sourceMappingURL=vite-plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC,MAAM,WAAW,iBAAkB,SAAQ,OAAO,CAAC,cAAc,CAAC;CAAG;AAErE,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAkBhE"}
1
+ {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC,MAAM,WAAW,iBAAkB,SAAQ,OAAO,CAAC,cAAc,CAAC;IAChE,EAAE,CAAC,EAAE,OAAO,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,CA2BhE"}
@@ -1,12 +1,21 @@
1
1
  import { startZeroLite } from './index.js';
2
+ import { startS3Local } from './s3-local.js';
2
3
  export default function orez(options) {
3
4
  let stop = null;
5
+ let s3Server = null;
4
6
  return {
5
7
  name: 'orez',
6
8
  async configureServer(server) {
7
9
  const result = await startZeroLite(options);
8
10
  stop = result.stop;
11
+ if (options?.s3) {
12
+ s3Server = await startS3Local({
13
+ port: options.s3Port || 9200,
14
+ dataDir: result.config.dataDir,
15
+ });
16
+ }
9
17
  server.httpServer?.on('close', async () => {
18
+ s3Server?.close();
10
19
  if (stop) {
11
20
  await stop();
12
21
  stop = null;
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin.js","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAO1C,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,OAA2B;IACtD,IAAI,IAAI,GAAiC,IAAI,CAAA;IAE7C,OAAO;QACL,IAAI,EAAE,MAAM;QAEZ,KAAK,CAAC,eAAe,CAAC,MAAM;YAC1B,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,CAAA;YAC3C,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;YAElB,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;gBACxC,IAAI,IAAI,EAAE,CAAC;oBACT,MAAM,IAAI,EAAE,CAAA;oBACZ,IAAI,GAAG,IAAI,CAAA;gBACb,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"vite-plugin.js","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAW5C,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,OAA2B;IACtD,IAAI,IAAI,GAAiC,IAAI,CAAA;IAC7C,IAAI,QAAQ,GAAkB,IAAI,CAAA;IAElC,OAAO;QACL,IAAI,EAAE,MAAM;QAEZ,KAAK,CAAC,eAAe,CAAC,MAAM;YAC1B,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,CAAA;YAC3C,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;YAElB,IAAI,OAAO,EAAE,EAAE,EAAE,CAAC;gBAChB,QAAQ,GAAG,MAAM,YAAY,CAAC;oBAC5B,IAAI,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI;oBAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO;iBAC/B,CAAC,CAAA;YACJ,CAAC;YAED,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;gBACxC,QAAQ,EAAE,KAAK,EAAE,CAAA;gBACjB,IAAI,IAAI,EAAE,CAAC;oBACT,MAAM,IAAI,EAAE,CAAA;oBACZ,IAAI,GAAG,IAAI,CAAA;gBACb,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orez",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "PGlite-powered zero-sync development backend. No Docker required.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -42,11 +42,11 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@electric-sql/pglite": "^0.2.17",
45
+ "@rocicorp/zero": ">=0.1.0",
45
46
  "citty": "^0.2.0",
46
47
  "pg-gateway": "^0.3.0-beta.4"
47
48
  },
48
49
  "peerDependencies": {
49
- "@rocicorp/zero": "*",
50
50
  "vite": ">=5"
51
51
  },
52
52
  "peerDependenciesMeta": {
package/src/cli.ts CHANGED
@@ -90,6 +90,16 @@ const main = defineCommand({
90
90
  description: 'log level: error, warn, info, debug',
91
91
  default: 'info',
92
92
  },
93
+ s3: {
94
+ type: 'boolean',
95
+ description: 'also start a local s3-compatible server',
96
+ default: false,
97
+ },
98
+ 's3-port': {
99
+ type: 'string',
100
+ description: 's3 server port',
101
+ default: '9200',
102
+ },
93
103
  },
94
104
  subCommands: {
95
105
  s3: s3Command,
@@ -107,6 +117,14 @@ const main = defineCommand({
107
117
  logLevel: args['log-level'] as 'error' | 'warn' | 'info' | 'debug',
108
118
  })
109
119
 
120
+ let s3Server: import('node:http').Server | null = null
121
+ if (args.s3) {
122
+ s3Server = await startS3Local({
123
+ port: Number(args['s3-port']),
124
+ dataDir: args['data-dir'],
125
+ })
126
+ }
127
+
110
128
  log.orez('ready')
111
129
  log.orez(
112
130
  `pg: postgresql://${config.pgUser}:${config.pgPassword}@127.0.0.1:${config.pgPort}/postgres`
@@ -116,10 +134,12 @@ const main = defineCommand({
116
134
  }
117
135
 
118
136
  process.on('SIGINT', async () => {
137
+ s3Server?.close()
119
138
  await stop()
120
139
  process.exit(0)
121
140
  })
122
141
  process.on('SIGTERM', async () => {
142
+ s3Server?.close()
123
143
  await stop()
124
144
  process.exit(0)
125
145
  })
@@ -1,12 +1,18 @@
1
1
  import { startZeroLite } from './index.js'
2
+ import { startS3Local } from './s3-local.js'
2
3
 
3
4
  import type { ZeroLiteConfig } from './config.js'
5
+ import type { Server } from 'node:http'
4
6
  import type { Plugin } from 'vite'
5
7
 
6
- export interface OrezPluginOptions extends Partial<ZeroLiteConfig> {}
8
+ export interface OrezPluginOptions extends Partial<ZeroLiteConfig> {
9
+ s3?: boolean
10
+ s3Port?: number
11
+ }
7
12
 
8
13
  export default function orez(options?: OrezPluginOptions): Plugin {
9
14
  let stop: (() => Promise<void>) | null = null
15
+ let s3Server: Server | null = null
10
16
 
11
17
  return {
12
18
  name: 'orez',
@@ -15,7 +21,15 @@ export default function orez(options?: OrezPluginOptions): Plugin {
15
21
  const result = await startZeroLite(options)
16
22
  stop = result.stop
17
23
 
24
+ if (options?.s3) {
25
+ s3Server = await startS3Local({
26
+ port: options.s3Port || 9200,
27
+ dataDir: result.config.dataDir,
28
+ })
29
+ }
30
+
18
31
  server.httpServer?.on('close', async () => {
32
+ s3Server?.close()
19
33
  if (stop) {
20
34
  await stop()
21
35
  stop = null