orez-sync-cf-host 0.4.67 → 0.4.71

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orez-sync-cf-host",
3
- "version": "0.4.67",
3
+ "version": "0.4.71",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts"
Binary file
@@ -29,6 +29,7 @@ interface Env extends SyncHostEnv {
29
29
 
30
30
  const runawayNamespaces = new Set<string>()
31
31
  const numericTextNamespaces = new Set<string>()
32
+ const jsonValueNamespaces = new Set<string>()
32
33
  const hydratedNamespaces = new Set<string>()
33
34
  let delegatedFailuresRemaining = 0
34
35
  let delegatedAttempts = 0
@@ -111,6 +112,40 @@ export class DataService extends WorkerEntrypoint<Env> {
111
112
  )
112
113
  }
113
114
  const namespace = pathname.split('/')[1] ?? ''
115
+ if (pathname.endsWith('/changes') && jsonValueNamespaces.has(namespace)) {
116
+ const cursor = Number(new URL(request.url).searchParams.get('watermark') ?? 0)
117
+ const values = [
118
+ { nested: { tags: ['a', 2, true] } },
119
+ [1, 'two', null],
120
+ '42',
121
+ 'true',
122
+ 'null',
123
+ '{"looks":"encoded"}',
124
+ 42.5,
125
+ true,
126
+ ]
127
+ return Promise.resolve(
128
+ Response.json({
129
+ watermark: values.length,
130
+ changes: values
131
+ .map((meta, index) => ({
132
+ watermark: index + 1,
133
+ tableName: 'item',
134
+ op: 'INSERT',
135
+ rowData: {
136
+ id: `json-${index}`,
137
+ label: 'json round trip',
138
+ rank: index,
139
+ done: false,
140
+ meta,
141
+ },
142
+ oldData: null,
143
+ }))
144
+ .filter((change) => change.watermark > cursor)
145
+ .slice(0, 2),
146
+ })
147
+ )
148
+ }
114
149
  if (pathname.endsWith('/changes') && numericTextNamespaces.has(namespace)) {
115
150
  const watermark = Number(new URL(request.url).searchParams.get('watermark') ?? 0)
116
151
  return Promise.resolve(
@@ -218,6 +253,18 @@ const syncWorker = createSyncWorker(config)
218
253
  export default {
219
254
  fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
220
255
  const url = new URL(request.url)
256
+ if (url.pathname.startsWith('/json-values-control/')) {
257
+ const namespace = url.pathname.slice('/json-values-control/'.length)
258
+ return request
259
+ .json()
260
+ .catch(() => ({}))
261
+ .then((body) => {
262
+ if ((body as { enabled?: unknown }).enabled === true)
263
+ jsonValueNamespaces.add(namespace)
264
+ else jsonValueNamespaces.delete(namespace)
265
+ return Response.json({ ok: true, namespace })
266
+ })
267
+ }
221
268
  if (url.pathname.startsWith('/numeric-text-control/')) {
222
269
  const namespace = url.pathname.slice('/numeric-text-control/'.length)
223
270
  return request