orez 0.2.27 → 0.2.30

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 (157) hide show
  1. package/dist/cf-do/worker.d.ts +3 -0
  2. package/dist/cf-do/worker.d.ts.map +1 -1
  3. package/dist/cf-do/worker.js +37 -15
  4. package/dist/cf-do/worker.js.map +1 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +8 -0
  7. package/dist/index.js.map +1 -1
  8. package/package.json +3 -4
  9. package/src/admin/admin-data.test.ts +0 -348
  10. package/src/admin/http-proxy.ts +0 -252
  11. package/src/admin/log-store.ts +0 -192
  12. package/src/admin/server.ts +0 -471
  13. package/src/admin/ui.ts +0 -1322
  14. package/src/bench/proxy-throughput.bench.ts +0 -343
  15. package/src/bench/serial-mutations.bench.ts +0 -270
  16. package/src/browser.ts +0 -203
  17. package/src/cf-do/.wrangler/cache/cf.json +0 -1
  18. package/src/cf-do/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite +0 -0
  19. package/src/cf-do/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite-shm +0 -0
  20. package/src/cf-do/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite-wal +0 -0
  21. package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/0ffaabee41a60e04dd0eb7db3073f0a40139e6a97ccd26823967acb652b89a7b.sqlite +0 -0
  22. package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/metadata.sqlite +0 -0
  23. package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/metadata.sqlite-shm +0 -0
  24. package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/metadata.sqlite-wal +0 -0
  25. package/src/cf-do/.wrangler/tmp/bundle-0z4CpE/middleware-insertion-facade.js +0 -11
  26. package/src/cf-do/.wrangler/tmp/bundle-0z4CpE/middleware-loader.entry.ts +0 -134
  27. package/src/cf-do/.wrangler/tmp/bundle-vYmw0E/middleware-insertion-facade.js +0 -11
  28. package/src/cf-do/.wrangler/tmp/bundle-vYmw0E/middleware-loader.entry.ts +0 -134
  29. package/src/cf-do/.wrangler/tmp/dev-cbILNo/worker.js +0 -1059
  30. package/src/cf-do/.wrangler/tmp/dev-cbILNo/worker.js.map +0 -8
  31. package/src/cf-do/.wrangler/tmp/dev-qbho19/worker.js +0 -1059
  32. package/src/cf-do/.wrangler/tmp/dev-qbho19/worker.js.map +0 -8
  33. package/src/cf-do/ARCHITECTURE.md +0 -93
  34. package/src/cf-do/CHAT_E2E.md +0 -213
  35. package/src/cf-do/watermark.test.ts +0 -103
  36. package/src/cf-do/watermark.ts +0 -118
  37. package/src/cf-do/worker.ts +0 -1041
  38. package/src/cf-do/wrangler.toml +0 -11
  39. package/src/cf-pglite/README.md +0 -19
  40. package/src/change-tracking.ts +0 -25
  41. package/src/child-process.test.ts +0 -147
  42. package/src/child-process.ts +0 -90
  43. package/src/cli-entry.ts +0 -72
  44. package/src/cli.test.ts +0 -40
  45. package/src/cli.ts +0 -1214
  46. package/src/config.ts +0 -150
  47. package/src/do-sql-tracking.test.ts +0 -19
  48. package/src/do-sql-tracking.ts +0 -19
  49. package/src/index.ts +0 -1215
  50. package/src/integration/integration.test.ts +0 -517
  51. package/src/integration/native-binary.guard.test.ts +0 -13
  52. package/src/integration/native-startup.test.ts +0 -44
  53. package/src/integration/replication-latency.test.ts +0 -428
  54. package/src/integration/restore-live-stress.test.ts +0 -433
  55. package/src/integration/restore-reset.test.ts +0 -400
  56. package/src/integration/restore.test.ts +0 -274
  57. package/src/integration/test-permissions.ts +0 -147
  58. package/src/load-config.ts +0 -46
  59. package/src/log.ts +0 -96
  60. package/src/mutex.ts +0 -47
  61. package/src/pg-proxy-browser.singledb.test.ts +0 -233
  62. package/src/pg-proxy-browser.ts +0 -2022
  63. package/src/pg-proxy-do-backend.test.ts +0 -3890
  64. package/src/pg-proxy-do-backend.ts +0 -7191
  65. package/src/pg-proxy.ts +0 -1087
  66. package/src/pg-sqlite-compiler/README.md +0 -53
  67. package/src/pg-sqlite-compiler/catalog/seed.ts +0 -524
  68. package/src/pg-sqlite-compiler/fixtures/pgsqlite/arithmetic.json +0 -307
  69. package/src/pg-sqlite-compiler/fixtures/pgsqlite/array.json +0 -377
  70. package/src/pg-sqlite-compiler/fixtures/pgsqlite/cast.json +0 -12
  71. package/src/pg-sqlite-compiler/fixtures/pgsqlite/catalog.json +0 -447
  72. package/src/pg-sqlite-compiler/fixtures/pgsqlite/create-table.json +0 -32
  73. package/src/pg-sqlite-compiler/fixtures/pgsqlite/datetime.json +0 -397
  74. package/src/pg-sqlite-compiler/fixtures/pgsqlite/enum.json +0 -337
  75. package/src/pg-sqlite-compiler/fixtures/pgsqlite/insert.json +0 -337
  76. package/src/pg-sqlite-compiler/fixtures/pgsqlite/json.json +0 -537
  77. package/src/pg-sqlite-compiler/fixtures/pgsqlite/misc.json +0 -1837
  78. package/src/pg-sqlite-compiler/index.ts +0 -73
  79. package/src/pg-sqlite-compiler/integration.test.ts +0 -136
  80. package/src/pg-sqlite-compiler/passes/ast-utils.ts +0 -113
  81. package/src/pg-sqlite-compiler/passes/catalog.ts +0 -65
  82. package/src/pg-sqlite-compiler/passes/datetime.ts +0 -74
  83. package/src/pg-sqlite-compiler/passes/index.ts +0 -49
  84. package/src/pg-sqlite-compiler/passes/types.ts +0 -156
  85. package/src/pg-sqlite-compiler/smoke.test.ts +0 -69
  86. package/src/pg-sqlite-compiler/test/catalog.test.ts +0 -171
  87. package/src/pg-sqlite-compiler/test/corpus.test.ts +0 -161
  88. package/src/pg-sqlite-compiler/test/datetime.oracle.test.ts +0 -102
  89. package/src/pg-sqlite-compiler/test/oracle.ts +0 -237
  90. package/src/pg-sqlite-compiler/test/types.test.ts +0 -109
  91. package/src/pg-sqlite-compiler/types.ts +0 -63
  92. package/src/pglite-ipc.test.ts +0 -116
  93. package/src/pglite-ipc.ts +0 -266
  94. package/src/pglite-manager.ts +0 -557
  95. package/src/pglite-web-proxy.test.ts +0 -57
  96. package/src/pglite-web-proxy.ts +0 -221
  97. package/src/pglite-web-worker.ts +0 -152
  98. package/src/pglite-worker-thread.ts +0 -253
  99. package/src/port.ts +0 -25
  100. package/src/process-title.ts +0 -9
  101. package/src/recovery.ts +0 -155
  102. package/src/replication/change-tracker.test.ts +0 -357
  103. package/src/replication/change-tracker.ts +0 -279
  104. package/src/replication/handler.test.ts +0 -511
  105. package/src/replication/handler.ts +0 -1190
  106. package/src/replication/pgoutput-encoder.test.ts +0 -697
  107. package/src/replication/pgoutput-encoder.ts +0 -373
  108. package/src/replication/tcp-replication.test.ts +0 -876
  109. package/src/replication/zero-compat.test.ts +0 -1150
  110. package/src/restore-stress.test.ts +0 -188
  111. package/src/s3-local.ts +0 -203
  112. package/src/shim/hooks.mjs +0 -120
  113. package/src/shim/register.mjs +0 -4
  114. package/src/sqlite-mode/apply-mode.ts +0 -224
  115. package/src/sqlite-mode/index.ts +0 -15
  116. package/src/sqlite-mode/native-binary.ts +0 -89
  117. package/src/sqlite-mode/package-resolve.ts +0 -17
  118. package/src/sqlite-mode/resolve-mode.ts +0 -80
  119. package/src/sqlite-mode/shim-template.ts +0 -159
  120. package/src/sqlite-mode/sqlite-mode.test.ts +0 -427
  121. package/src/sqlite-mode/types.ts +0 -30
  122. package/src/vite-plugin.ts +0 -67
  123. package/src/wasm-sqlite.test.ts +0 -537
  124. package/src/worker/browser-admin.ts +0 -52
  125. package/src/worker/browser-build-config.test.ts +0 -71
  126. package/src/worker/browser-build-config.ts +0 -109
  127. package/src/worker/browser-embed-admin.test.ts +0 -75
  128. package/src/worker/browser-embed.ts +0 -345
  129. package/src/worker/cf-patches.ts +0 -384
  130. package/src/worker/embed-integration.test.ts +0 -321
  131. package/src/worker/index.ts +0 -138
  132. package/src/worker/shims/fastify.test.ts +0 -255
  133. package/src/worker/shims/fastify.ts +0 -306
  134. package/src/worker/shims/http-service.test.ts +0 -355
  135. package/src/worker/shims/http-service.ts +0 -293
  136. package/src/worker/shims/node-stub.ts +0 -290
  137. package/src/worker/shims/oxfmt.ts +0 -3
  138. package/src/worker/shims/postgres-browser.ts +0 -59
  139. package/src/worker/shims/postgres-socket.test.ts +0 -576
  140. package/src/worker/shims/postgres-socket.ts +0 -310
  141. package/src/worker/shims/postgres.test.ts +0 -364
  142. package/src/worker/shims/postgres.ts +0 -1454
  143. package/src/worker/shims/sqlite-browser.test.ts +0 -233
  144. package/src/worker/shims/sqlite-browser.ts +0 -175
  145. package/src/worker/shims/sqlite.test.ts +0 -786
  146. package/src/worker/shims/sqlite.ts +0 -978
  147. package/src/worker/shims/stream-browser.ts +0 -15
  148. package/src/worker/shims/ws-browser.test.ts +0 -205
  149. package/src/worker/shims/ws-browser.ts +0 -248
  150. package/src/worker/shims/ws.test.ts +0 -288
  151. package/src/worker/shims/ws.ts +0 -467
  152. package/src/worker/shims/zero-process-env.ts +0 -11
  153. package/src/worker/types.ts +0 -75
  154. package/src/worker/worker-integration.test.ts +0 -223
  155. package/src/worker/worker.test.ts +0 -136
  156. package/src/worker/zero-cache-embed-cf.ts +0 -463
  157. package/src/worker/zero-cache-embed.ts +0 -277
@@ -1,288 +0,0 @@
1
- import { describe, it, expect, beforeEach, vi } from 'vitest'
2
-
3
- import WebSocket, { WebSocketServer, createWebSocketStream } from './ws.js'
4
-
5
- /** mock CF WebSocket — mimics the server side of a WebSocketPair */
6
- function createMockCFWebSocket() {
7
- const listeners = new Map<string, Array<(event: any) => void>>()
8
-
9
- const ws = {
10
- readyState: 1, // OPEN
11
- send: vi.fn(),
12
- close: vi.fn(() => {
13
- ws.readyState = 3 // CLOSED
14
- }),
15
- accept: vi.fn(),
16
- addEventListener: vi.fn((type: string, handler: (event: any) => void) => {
17
- if (!listeners.has(type)) listeners.set(type, [])
18
- listeners.get(type)!.push(handler)
19
- }),
20
- removeEventListener: vi.fn((type: string, handler: (event: any) => void) => {
21
- const arr = listeners.get(type)
22
- if (arr) {
23
- const idx = arr.indexOf(handler)
24
- if (idx >= 0) arr.splice(idx, 1)
25
- }
26
- }),
27
-
28
- // helper to fire events in tests
29
- _fire(type: string, event: any) {
30
- for (const h of listeners.get(type) || []) h(event)
31
- },
32
- }
33
-
34
- return ws
35
- }
36
-
37
- describe('WebSocket shim', () => {
38
- let cfWs: ReturnType<typeof createMockCFWebSocket>
39
- let ws: InstanceType<typeof WebSocket>
40
-
41
- beforeEach(() => {
42
- cfWs = createMockCFWebSocket()
43
- ws = new WebSocket(cfWs as any)
44
- })
45
-
46
- describe('constructor', () => {
47
- it('wraps a CF WebSocket', () => {
48
- expect(ws).toBeInstanceOf(WebSocket)
49
- })
50
-
51
- it('handles string URL for localhost (in-process)', () => {
52
- // no longer throws — localhost URLs use the in-process path
53
- // without a fastify instance it emits close instead of throwing
54
- const ws = new WebSocket('ws://localhost')
55
- expect(ws).toBeInstanceOf(WebSocket)
56
- })
57
-
58
- it('sets up event listeners on CF WebSocket', () => {
59
- expect(cfWs.addEventListener).toHaveBeenCalledWith('message', expect.any(Function))
60
- expect(cfWs.addEventListener).toHaveBeenCalledWith('close', expect.any(Function))
61
- expect(cfWs.addEventListener).toHaveBeenCalledWith('error', expect.any(Function))
62
- expect(cfWs.addEventListener).toHaveBeenCalledWith('open', expect.any(Function))
63
- })
64
- })
65
-
66
- describe('static constants', () => {
67
- it('has readyState constants', () => {
68
- expect(WebSocket.CONNECTING).toBe(0)
69
- expect(WebSocket.OPEN).toBe(1)
70
- expect(WebSocket.CLOSING).toBe(2)
71
- expect(WebSocket.CLOSED).toBe(3)
72
- })
73
-
74
- it('has instance readyState constants', () => {
75
- expect(ws.CONNECTING).toBe(0)
76
- expect(ws.OPEN).toBe(1)
77
- expect(ws.CLOSING).toBe(2)
78
- expect(ws.CLOSED).toBe(3)
79
- })
80
- })
81
-
82
- describe('readyState', () => {
83
- it('reflects CF WebSocket readyState', () => {
84
- cfWs.readyState = 1
85
- expect(ws.readyState).toBe(1)
86
- cfWs.readyState = 3
87
- expect(ws.readyState).toBe(3)
88
- })
89
- })
90
-
91
- describe('send()', () => {
92
- it('sends string data', () => {
93
- ws.send('hello')
94
- expect(cfWs.send).toHaveBeenCalledWith('hello')
95
- })
96
-
97
- it('sends ArrayBuffer data', () => {
98
- const buf = new ArrayBuffer(4)
99
- ws.send(buf)
100
- expect(cfWs.send).toHaveBeenCalledWith(buf)
101
- })
102
-
103
- it('sends Uint8Array data', () => {
104
- const arr = new Uint8Array([1, 2, 3])
105
- ws.send(arr)
106
- expect(cfWs.send).toHaveBeenCalledWith(expect.any(Uint8Array))
107
- })
108
-
109
- it('sends Buffer data as Uint8Array', () => {
110
- const buf = Buffer.from('hello')
111
- ws.send(buf)
112
- expect(cfWs.send).toHaveBeenCalledWith(expect.any(Uint8Array))
113
- })
114
-
115
- it('calls callback on success', () => {
116
- const cb = vi.fn()
117
- ws.send('test', cb)
118
- expect(cb).toHaveBeenCalledWith()
119
- })
120
-
121
- it('calls callback with error on failure', () => {
122
- cfWs.send.mockImplementation(() => {
123
- throw new Error('send failed')
124
- })
125
- const cb = vi.fn()
126
- ws.send('test', cb)
127
- expect(cb).toHaveBeenCalledWith(expect.any(Error))
128
- })
129
- })
130
-
131
- describe('close()', () => {
132
- it('closes the CF WebSocket', () => {
133
- ws.close(1000, 'normal')
134
- expect(cfWs.close).toHaveBeenCalledWith(1000, 'normal')
135
- })
136
-
137
- it('does not throw if already closed', () => {
138
- cfWs.close.mockImplementation(() => {
139
- throw new Error('already closed')
140
- })
141
- expect(() => ws.close()).not.toThrow()
142
- })
143
- })
144
-
145
- describe('terminate()', () => {
146
- it('closes with code 1000', () => {
147
- ws.terminate()
148
- expect(cfWs.close).toHaveBeenCalled()
149
- expect(cfWs.close.mock.calls[0][0]).toBe(1000)
150
- })
151
- })
152
-
153
- describe('ping()', () => {
154
- it('emits pong (CF handles ping at platform level)', () => {
155
- const pongHandler = vi.fn()
156
- ws.on('pong', pongHandler)
157
- ws.ping()
158
- expect(pongHandler).toHaveBeenCalled()
159
- })
160
- })
161
-
162
- describe('event forwarding', () => {
163
- it('emits message events from CF WebSocket', () => {
164
- const handler = vi.fn()
165
- ws.on('message', handler)
166
- cfWs._fire('message', { data: 'hello' })
167
- // ws npm API: message handler gets (data, isBinary)
168
- expect(handler).toHaveBeenCalledWith('hello', false)
169
- })
170
-
171
- it('emits close events from CF WebSocket', () => {
172
- const handler = vi.fn()
173
- ws.on('close', handler)
174
- cfWs._fire('close', { code: 1000, reason: 'normal', wasClean: true })
175
- // ws npm API: close handler gets (code, reason)
176
- expect(handler).toHaveBeenCalledWith(1000, 'normal')
177
- })
178
-
179
- it('emits error events from CF WebSocket', () => {
180
- const handler = vi.fn()
181
- ws.on('error', handler)
182
- cfWs._fire('error', { message: 'oops', error: new Error('oops') })
183
- expect(handler).toHaveBeenCalledWith(expect.objectContaining({ message: 'oops' }))
184
- })
185
-
186
- it('supports addEventListener/removeEventListener', () => {
187
- const handler = vi.fn()
188
- ws.addEventListener('message', handler)
189
- cfWs._fire('message', { data: 'test' })
190
- expect(handler).toHaveBeenCalledTimes(1)
191
-
192
- ws.removeEventListener('message', handler)
193
- cfWs._fire('message', { data: 'test2' })
194
- expect(handler).toHaveBeenCalledTimes(1)
195
- })
196
- })
197
- })
198
-
199
- describe('WebSocketServer shim', () => {
200
- it('creates with noServer option', () => {
201
- const wss = new WebSocketServer({ noServer: true })
202
- expect(wss).toBeInstanceOf(WebSocketServer)
203
- })
204
-
205
- describe('handleUpgrade()', () => {
206
- it('wraps CF WebSocket and calls callback', () => {
207
- const wss = new WebSocketServer({ noServer: true })
208
- const cfWs = createMockCFWebSocket()
209
- const callback = vi.fn()
210
-
211
- wss.handleUpgrade({ url: '/test', headers: {} }, cfWs, Buffer.alloc(0), callback)
212
-
213
- expect(callback).toHaveBeenCalledTimes(1)
214
- const ws = callback.mock.calls[0][0]
215
- expect(ws).toBeInstanceOf(WebSocket)
216
- })
217
-
218
- it('wrapped WebSocket delegates send to CF WebSocket', () => {
219
- const wss = new WebSocketServer({ noServer: true })
220
- const cfWs = createMockCFWebSocket()
221
- let wrappedWs: InstanceType<typeof WebSocket>
222
-
223
- wss.handleUpgrade({}, cfWs, null, (ws) => {
224
- wrappedWs = ws
225
- })
226
-
227
- wrappedWs!.send('hello from server')
228
- expect(cfWs.send).toHaveBeenCalledWith('hello from server')
229
- })
230
- })
231
- })
232
-
233
- describe('createWebSocketStream', () => {
234
- it('creates a duplex stream from WebSocket', () => {
235
- const cfWs = createMockCFWebSocket()
236
- const ws = new WebSocket(cfWs as any)
237
- const stream = createWebSocketStream(ws)
238
-
239
- expect(stream).toBeDefined()
240
- expect(stream.readable).toBe(true)
241
- expect(stream.writable).toBe(true)
242
- })
243
-
244
- it('writes to WebSocket via stream', async () => {
245
- const cfWs = createMockCFWebSocket()
246
- const ws = new WebSocket(cfWs as any)
247
- const stream = createWebSocketStream(ws)
248
-
249
- await new Promise<void>((resolve) => {
250
- stream.write('hello', () => {
251
- expect(cfWs.send).toHaveBeenCalledWith('hello')
252
- stream.destroy()
253
- resolve()
254
- })
255
- })
256
- })
257
-
258
- it('reads from WebSocket messages', async () => {
259
- const cfWs = createMockCFWebSocket()
260
- const ws = new WebSocket(cfWs as any)
261
- const stream = createWebSocketStream(ws)
262
-
263
- const received = new Promise<string>((resolve) => {
264
- stream.on('data', (chunk) => {
265
- resolve(chunk.toString())
266
- })
267
- })
268
-
269
- cfWs._fire('message', { data: 'world' })
270
-
271
- const data = await received
272
- expect(data).toBe('world')
273
- stream.destroy()
274
- })
275
-
276
- it('ends stream on WebSocket close', async () => {
277
- const cfWs = createMockCFWebSocket()
278
- const ws = new WebSocket(cfWs as any)
279
- const stream = createWebSocketStream(ws)
280
-
281
- const closed = new Promise<void>((resolve) => {
282
- stream.on('close', () => resolve())
283
- })
284
-
285
- cfWs._fire('close', { code: 1000 })
286
- await closed
287
- })
288
- })