on-zero 0.6.21 → 0.6.22-1784492767691
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/dist/cjs/createPermissions.cjs +0 -2
- package/dist/cjs/createPermissions.native.js +0 -2
- package/dist/cjs/createPermissions.native.js.map +1 -1
- package/dist/cjs/createZeroSQLiteServer.test.cjs +97 -0
- package/dist/cjs/createZeroSQLiteServer.test.native.js +108 -0
- package/dist/cjs/createZeroSQLiteServer.test.native.js.map +1 -1
- package/dist/cjs/httpPull/transport.test.cjs +30 -9
- package/dist/cjs/httpPull/transport.test.native.js +43 -11
- package/dist/cjs/httpPull/transport.test.native.js.map +1 -1
- package/dist/cjs/httpPullTransport.cjs +63 -8
- package/dist/cjs/httpPullTransport.native.js +70 -10
- package/dist/cjs/httpPullTransport.native.js.map +1 -1
- package/dist/cjs/mutations.cjs +4 -11
- package/dist/cjs/mutations.native.js +4 -11
- package/dist/cjs/mutations.native.js.map +1 -1
- package/dist/esm/createPermissions.mjs +0 -2
- package/dist/esm/createPermissions.mjs.map +1 -1
- package/dist/esm/createPermissions.native.js +0 -2
- package/dist/esm/createPermissions.native.js.map +1 -1
- package/dist/esm/createZeroSQLiteServer.test.mjs +97 -0
- package/dist/esm/createZeroSQLiteServer.test.mjs.map +1 -1
- package/dist/esm/createZeroSQLiteServer.test.native.js +108 -0
- package/dist/esm/createZeroSQLiteServer.test.native.js.map +1 -1
- package/dist/esm/httpPull/transport.test.mjs +30 -9
- package/dist/esm/httpPull/transport.test.mjs.map +1 -1
- package/dist/esm/httpPull/transport.test.native.js +43 -11
- package/dist/esm/httpPull/transport.test.native.js.map +1 -1
- package/dist/esm/httpPullTransport.mjs +63 -8
- package/dist/esm/httpPullTransport.mjs.map +1 -1
- package/dist/esm/httpPullTransport.native.js +70 -10
- package/dist/esm/httpPullTransport.native.js.map +1 -1
- package/dist/esm/mutations.mjs +4 -11
- package/dist/esm/mutations.mjs.map +1 -1
- package/dist/esm/mutations.native.js +4 -11
- package/dist/esm/mutations.native.js.map +1 -1
- package/package.json +2 -2
- package/readme.md +27 -8
- package/src/createPermissions.ts +0 -2
- package/src/createZeroSQLiteServer.test.ts +94 -0
- package/src/httpPull/transport.test.ts +31 -10
- package/src/httpPullTransport.ts +97 -11
- package/src/mutations.ts +7 -21
- package/types/createPermissions.d.ts.map +1 -1
- package/types/httpPullTransport.d.ts +3 -1
- package/types/httpPullTransport.d.ts.map +1 -1
- package/types/mutations.d.ts +1 -1
- package/types/mutations.d.ts.map +1 -1
- package/dist/cjs/helpers/didRunPermissionCheck.cjs +0 -36
- package/dist/cjs/helpers/didRunPermissionCheck.native.js +0 -41
- package/dist/cjs/helpers/didRunPermissionCheck.native.js.map +0 -1
- package/dist/esm/helpers/didRunPermissionCheck.mjs +0 -10
- package/dist/esm/helpers/didRunPermissionCheck.mjs.map +0 -1
- package/dist/esm/helpers/didRunPermissionCheck.native.js +0 -12
- package/dist/esm/helpers/didRunPermissionCheck.native.js.map +0 -1
- package/src/helpers/didRunPermissionCheck.ts +0 -16
- package/types/helpers/didRunPermissionCheck.d.ts +0 -4
- package/types/helpers/didRunPermissionCheck.d.ts.map +0 -1
|
@@ -6,6 +6,8 @@ import { afterEach, beforeEach, describe, expect, test } from 'vitest'
|
|
|
6
6
|
|
|
7
7
|
import { createZeroSQLiteServer } from './createZeroSQLiteServer'
|
|
8
8
|
import { zeroHttpFixtureSchema } from './httpPull/fixtureSchema'
|
|
9
|
+
import { mutations } from './mutations'
|
|
10
|
+
import { serverWhere } from './serverWhere'
|
|
9
11
|
|
|
10
12
|
import type {
|
|
11
13
|
SqlStatementMetadata,
|
|
@@ -290,6 +292,98 @@ describe('createZeroSQLiteServer', () => {
|
|
|
290
292
|
})
|
|
291
293
|
})
|
|
292
294
|
|
|
295
|
+
test('allows a custom CRUD mutation to no-op without an automatic permission check', async () => {
|
|
296
|
+
const projectPermission = serverWhere('project', (q) => q.cmp('ownerId', 'u1'))
|
|
297
|
+
const projectMutations = mutations('project', projectPermission, {
|
|
298
|
+
insert: async () => {},
|
|
299
|
+
})
|
|
300
|
+
const server = createZeroSQLiteServer({
|
|
301
|
+
schema: zeroHttpFixtureSchema,
|
|
302
|
+
models: {
|
|
303
|
+
project: { mutate: projectMutations },
|
|
304
|
+
},
|
|
305
|
+
createServerActions: () => ({}),
|
|
306
|
+
transactionProvider,
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
const result = await server.handleMutationRequest({
|
|
310
|
+
authData: { id: 'u1', role: 'user' },
|
|
311
|
+
request: pushRequest(1, 'project.insert', {
|
|
312
|
+
id: 'p1',
|
|
313
|
+
ownerId: 'u1',
|
|
314
|
+
name: 'skip',
|
|
315
|
+
}),
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
expect((result.response as any).mutations[0].result).toEqual({})
|
|
319
|
+
expect(db.prepare('SELECT * FROM project').all()).toEqual([])
|
|
320
|
+
})
|
|
321
|
+
|
|
322
|
+
test('rolls back when a custom CRUD mutation throws', async () => {
|
|
323
|
+
const projectPermission = serverWhere('project', (q) => q.cmp('ownerId', 'u1'))
|
|
324
|
+
const projectMutations = mutations('project', projectPermission, {
|
|
325
|
+
insert: async ({ tx }, value: { id: string; ownerId: string; name: string }) => {
|
|
326
|
+
await tx.mutate.project.insert(value)
|
|
327
|
+
throw new Error('denied by custom validation')
|
|
328
|
+
},
|
|
329
|
+
})
|
|
330
|
+
const server = createZeroSQLiteServer({
|
|
331
|
+
schema: zeroHttpFixtureSchema,
|
|
332
|
+
models: {
|
|
333
|
+
project: { mutate: projectMutations },
|
|
334
|
+
},
|
|
335
|
+
createServerActions: () => ({}),
|
|
336
|
+
transactionProvider,
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
const result = await server.handleMutationRequest({
|
|
340
|
+
authData: { id: 'u2', role: 'user' },
|
|
341
|
+
request: pushRequest(1, 'project.insert', {
|
|
342
|
+
id: 'p2',
|
|
343
|
+
ownerId: 'u2',
|
|
344
|
+
name: 'unauthorized',
|
|
345
|
+
}),
|
|
346
|
+
})
|
|
347
|
+
|
|
348
|
+
expect((result.response as any).mutations[0].result).toMatchObject({
|
|
349
|
+
error: 'app',
|
|
350
|
+
message: 'denied by custom validation',
|
|
351
|
+
})
|
|
352
|
+
expect(db.prepare('SELECT * FROM project').all()).toEqual([])
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
test('permission-checks generated CRUD mutations', async () => {
|
|
356
|
+
let inserted: Record<string, unknown> | undefined
|
|
357
|
+
let permissionChecks = 0
|
|
358
|
+
const projectPermission = serverWhere('project', (q) => q.cmp('ownerId', 'u1'))
|
|
359
|
+
const projectMutations = mutations('project', projectPermission)
|
|
360
|
+
const value = { id: 'p3', ownerId: 'u2', name: 'unauthorized' }
|
|
361
|
+
|
|
362
|
+
await expect(
|
|
363
|
+
projectMutations.insert(
|
|
364
|
+
{
|
|
365
|
+
tx: {
|
|
366
|
+
mutate: {
|
|
367
|
+
project: {
|
|
368
|
+
insert: async (row: Record<string, unknown>) => {
|
|
369
|
+
inserted = row
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
can: async (_where, row) => {
|
|
375
|
+
permissionChecks++
|
|
376
|
+
expect(row).toEqual(value)
|
|
377
|
+
throw new Error('denied')
|
|
378
|
+
},
|
|
379
|
+
} as never,
|
|
380
|
+
value,
|
|
381
|
+
),
|
|
382
|
+
).rejects.toThrow('denied')
|
|
383
|
+
expect(inserted).toEqual(value)
|
|
384
|
+
expect(permissionChecks).toBe(1)
|
|
385
|
+
})
|
|
386
|
+
|
|
293
387
|
test('recovers duplicate results and deletes them through the cleanup mutation', async () => {
|
|
294
388
|
const server = createZeroSQLiteServer({
|
|
295
389
|
schema: zeroHttpFixtureSchema,
|
|
@@ -205,10 +205,11 @@ describe('zero-http transport', () => {
|
|
|
205
205
|
expect(requests.at(-1)?.headers.authorization).toBe('Bearer token-new')
|
|
206
206
|
})
|
|
207
207
|
|
|
208
|
-
test('push frames are serialized per socket', async () => {
|
|
208
|
+
test('push frames are serialized and queued bursts are batched per socket', async () => {
|
|
209
209
|
const firstPushStarted = defer<void>()
|
|
210
210
|
const releaseFirstPush = defer<void>()
|
|
211
|
-
const
|
|
211
|
+
const pushRequests: number[][] = []
|
|
212
|
+
const lifecycle: HttpPullLifecycleEvent[] = []
|
|
212
213
|
const fetch = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
|
|
213
214
|
const request = recordRequest(input, init)
|
|
214
215
|
if (request.path === '/pull') {
|
|
@@ -216,9 +217,9 @@ describe('zero-http transport', () => {
|
|
|
216
217
|
}
|
|
217
218
|
|
|
218
219
|
expect(request.path).toBe('/push')
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
if (
|
|
220
|
+
const mutationIDs = request.body.mutations.map((mutation: any) => mutation.id)
|
|
221
|
+
pushRequests.push(mutationIDs)
|
|
222
|
+
if (mutationIDs[0] === 1) {
|
|
222
223
|
firstPushStarted.resolve()
|
|
223
224
|
await releaseFirstPush.promise
|
|
224
225
|
}
|
|
@@ -231,7 +232,12 @@ describe('zero-http transport', () => {
|
|
|
231
232
|
},
|
|
232
233
|
})
|
|
233
234
|
})
|
|
234
|
-
|
|
235
|
+
const transport = installHttpPullTransport({
|
|
236
|
+
origin: ORIGIN,
|
|
237
|
+
fetch,
|
|
238
|
+
lifecycle: (event) => lifecycle.push(event),
|
|
239
|
+
})
|
|
240
|
+
transports.push(transport)
|
|
235
241
|
const { messages, socket } = openRawSocketWithMessages()
|
|
236
242
|
|
|
237
243
|
await eventually(() =>
|
|
@@ -240,19 +246,34 @@ describe('zero-http transport', () => {
|
|
|
240
246
|
socket.send(JSON.stringify(['push', pushBody(1)]))
|
|
241
247
|
await firstPushStarted.promise
|
|
242
248
|
socket.send(JSON.stringify(['push', pushBody(2)]))
|
|
249
|
+
socket.send(JSON.stringify(['push', pushBody(3)]))
|
|
250
|
+
socket.send(JSON.stringify(['push', pushBody(4)]))
|
|
243
251
|
await sleep(25)
|
|
244
252
|
|
|
245
|
-
expect(
|
|
253
|
+
expect(pushRequests).toEqual([[1]])
|
|
246
254
|
releaseFirstPush.resolve()
|
|
247
|
-
await eventually(() => expect(
|
|
255
|
+
await eventually(() => expect(pushRequests).toEqual([[1], [2, 3, 4]]))
|
|
248
256
|
await eventually(() =>
|
|
249
257
|
expect(messages.filter((message) => message[0] === 'pushResponse')).toHaveLength(2),
|
|
250
258
|
)
|
|
251
259
|
expect(
|
|
252
260
|
messages
|
|
253
261
|
.filter((message) => message[0] === 'pushResponse')
|
|
254
|
-
.
|
|
255
|
-
|
|
262
|
+
.flatMap((message) =>
|
|
263
|
+
message[1].mutations.map((mutation: any) => mutation.id.id),
|
|
264
|
+
),
|
|
265
|
+
).toEqual([1, 2, 3, 4])
|
|
266
|
+
expect(
|
|
267
|
+
lifecycle
|
|
268
|
+
.filter((event) => event.type === 'push')
|
|
269
|
+
.map(({ pushFrameCount, mutationCount }) => ({
|
|
270
|
+
pushFrameCount,
|
|
271
|
+
mutationCount,
|
|
272
|
+
})),
|
|
273
|
+
).toEqual([
|
|
274
|
+
{ pushFrameCount: 1, mutationCount: 1 },
|
|
275
|
+
{ pushFrameCount: 3, mutationCount: 3 },
|
|
276
|
+
])
|
|
256
277
|
})
|
|
257
278
|
|
|
258
279
|
test('cookie discipline skips unchanged pokes, chains changed pokes, and coalesces concurrent pulls', async () => {
|
package/src/httpPullTransport.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// by intercepting its /sync/v51/connect WebSocket with a shim that translates
|
|
3
3
|
// pull responses into v51 pokes. ported from the orez zero-http spike — the
|
|
4
4
|
// wire contract (lexicographic string cookies, gotQueriesPatch poke-part
|
|
5
|
-
// ordering, FIFO push
|
|
5
|
+
// ordering, bounded FIFO push batching, updateAuth, 401→Unauthorized frame,
|
|
6
6
|
// teardown drain) is pinned by the tests in ./httpPull/ and documented in
|
|
7
7
|
// ~/orez/plans/zero-http.md. do not "simplify" any of it without re-running
|
|
8
8
|
// those tests against a stock zero client.
|
|
@@ -57,6 +57,16 @@ type PullResponse =
|
|
|
57
57
|
gotQueries?: ServerGotQueries
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
type PushBody = Record<string, unknown> & {
|
|
61
|
+
mutations: unknown[]
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type PushBatch = {
|
|
65
|
+
body: unknown
|
|
66
|
+
frameCount: number
|
|
67
|
+
mutationCount: number
|
|
68
|
+
}
|
|
69
|
+
|
|
60
70
|
type TransportState = {
|
|
61
71
|
readonly pageID: string
|
|
62
72
|
readonly transportID: string
|
|
@@ -80,6 +90,11 @@ type TransportState = {
|
|
|
80
90
|
}
|
|
81
91
|
|
|
82
92
|
const COOKIE_WIDTH = 20
|
|
93
|
+
// the stock zero-cache pusher drains queued frames into a single request once
|
|
94
|
+
// its current request completes. keep the same backpressure relief here, but
|
|
95
|
+
// cap the number of mutations so one response cannot monopolize the HTTP
|
|
96
|
+
// transport indefinitely under a sustained producer.
|
|
97
|
+
const MAX_PUSH_BATCH_MUTATIONS = 64
|
|
83
98
|
// @rocicorp/zero 1.6 starts this deadline before its async createSocket work.
|
|
84
99
|
// the connect URL's `ts` is captured at the same attempt boundary.
|
|
85
100
|
const ZERO_CONNECT_TIMEOUT_MS = 10_000
|
|
@@ -122,7 +137,15 @@ export type HttpPullTransportOptions = {
|
|
|
122
137
|
}
|
|
123
138
|
|
|
124
139
|
export type HttpPullLifecycleEvent = {
|
|
125
|
-
type:
|
|
140
|
+
type:
|
|
141
|
+
| 'created'
|
|
142
|
+
| 'listener'
|
|
143
|
+
| 'open'
|
|
144
|
+
| 'close'
|
|
145
|
+
| 'failure'
|
|
146
|
+
| 'superseded'
|
|
147
|
+
| 'aborted'
|
|
148
|
+
| 'push'
|
|
126
149
|
pageID: string
|
|
127
150
|
transportID: string
|
|
128
151
|
zeroInstanceID: string
|
|
@@ -139,6 +162,8 @@ export type HttpPullLifecycleEvent = {
|
|
|
139
162
|
listener?: SocketEventType
|
|
140
163
|
code?: number
|
|
141
164
|
reason?: string
|
|
165
|
+
pushFrameCount?: number
|
|
166
|
+
mutationCount?: number
|
|
142
167
|
}
|
|
143
168
|
|
|
144
169
|
type HttpPullPageRegistry = {
|
|
@@ -307,7 +332,8 @@ class ZeroHttpSocket {
|
|
|
307
332
|
private sentQueryPatchLen = 0
|
|
308
333
|
private pullInFlight: Promise<void> | undefined
|
|
309
334
|
private pullAfterCurrent = false
|
|
310
|
-
private
|
|
335
|
+
private pendingPushes: unknown[] = []
|
|
336
|
+
private pushInFlight = false
|
|
311
337
|
private nextLocalCookieID: number
|
|
312
338
|
private openTimer: ReturnType<typeof setTimeout> | undefined
|
|
313
339
|
private pullTimer: ReturnType<typeof setInterval> | undefined
|
|
@@ -565,10 +591,14 @@ class ZeroHttpSocket {
|
|
|
565
591
|
this.queryVersion++
|
|
566
592
|
}
|
|
567
593
|
|
|
568
|
-
private async push(body:
|
|
594
|
+
private async push({ body, frameCount, mutationCount }: PushBatch) {
|
|
569
595
|
const response = (await this.postJSON('/push', body)) as {
|
|
570
596
|
pushResponse?: unknown
|
|
571
597
|
}
|
|
598
|
+
this.emitLifecycle('push', {
|
|
599
|
+
pushFrameCount: frameCount,
|
|
600
|
+
mutationCount,
|
|
601
|
+
})
|
|
572
602
|
// mutation RECOVERY pushes carry a PREVIOUS client's pending mutations,
|
|
573
603
|
// and the server response echoes that old clientID. zero-cache's pusher
|
|
574
604
|
// groups results by clientID and only delivers a client its OWN results
|
|
@@ -583,12 +613,50 @@ class ZeroHttpSocket {
|
|
|
583
613
|
}
|
|
584
614
|
|
|
585
615
|
private enqueuePush(body: unknown) {
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
616
|
+
this.pendingPushes.push(body)
|
|
617
|
+
if (this.pushInFlight) return
|
|
618
|
+
this.run(this.drainPushes())
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
private async drainPushes() {
|
|
622
|
+
this.pushInFlight = true
|
|
623
|
+
try {
|
|
624
|
+
while (this.readyState !== this.CLOSED && this.pendingPushes.length > 0) {
|
|
625
|
+
await this.push(this.takePushBatch())
|
|
626
|
+
}
|
|
627
|
+
} finally {
|
|
628
|
+
this.pushInFlight = false
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
private takePushBatch(): PushBatch {
|
|
633
|
+
const first = this.pendingPushes.shift()
|
|
634
|
+
const firstBody = parsePushBody(first)
|
|
635
|
+
if (!firstBody) {
|
|
636
|
+
return { body: first, frameCount: 1, mutationCount: 0 }
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
const mutations = [...firstBody.mutations]
|
|
640
|
+
let frameCount = 1
|
|
641
|
+
while (this.pendingPushes.length > 0) {
|
|
642
|
+
const nextBody = parsePushBody(this.pendingPushes[0])
|
|
643
|
+
if (
|
|
644
|
+
!nextBody ||
|
|
645
|
+
!areCompatiblePushBodies(firstBody, nextBody) ||
|
|
646
|
+
mutations.length + nextBody.mutations.length > MAX_PUSH_BATCH_MUTATIONS
|
|
647
|
+
) {
|
|
648
|
+
break
|
|
649
|
+
}
|
|
650
|
+
this.pendingPushes.shift()
|
|
651
|
+
mutations.push(...nextBody.mutations)
|
|
652
|
+
frameCount++
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
return {
|
|
656
|
+
body: frameCount === 1 ? firstBody : { ...firstBody, mutations },
|
|
657
|
+
frameCount,
|
|
658
|
+
mutationCount: mutations.length,
|
|
659
|
+
}
|
|
592
660
|
}
|
|
593
661
|
|
|
594
662
|
private requestPullAfterCurrent() {
|
|
@@ -849,7 +917,10 @@ class ZeroHttpSocket {
|
|
|
849
917
|
|
|
850
918
|
private emitLifecycle(
|
|
851
919
|
type: HttpPullLifecycleEvent['type'],
|
|
852
|
-
detail: Pick<
|
|
920
|
+
detail: Pick<
|
|
921
|
+
HttpPullLifecycleEvent,
|
|
922
|
+
'listener' | 'code' | 'reason' | 'pushFrameCount' | 'mutationCount'
|
|
923
|
+
> = {},
|
|
853
924
|
) {
|
|
854
925
|
this.state.lifecycle?.({
|
|
855
926
|
type,
|
|
@@ -872,6 +943,21 @@ class ZeroHttpSocket {
|
|
|
872
943
|
}
|
|
873
944
|
}
|
|
874
945
|
|
|
946
|
+
function parsePushBody(value: unknown): PushBody | undefined {
|
|
947
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) return
|
|
948
|
+
if (!('mutations' in value) || !Array.isArray(value.mutations)) return
|
|
949
|
+
// the runtime checks above establish the only fields batching reads.
|
|
950
|
+
return value as PushBody
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
function areCompatiblePushBodies(left: PushBody, right: PushBody) {
|
|
954
|
+
return (
|
|
955
|
+
left.clientGroupID === right.clientGroupID &&
|
|
956
|
+
left.pushVersion === right.pushVersion &&
|
|
957
|
+
left.schemaVersion === right.schemaVersion
|
|
958
|
+
)
|
|
959
|
+
}
|
|
960
|
+
|
|
875
961
|
function shouldIntercept(origin: URL, url: string | URL) {
|
|
876
962
|
const candidate = toHttpURL(url)
|
|
877
963
|
if (candidate.origin !== origin.origin) return false
|
package/src/mutations.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IS_SERVER_RUNTIME } from '@take-out/helpers'
|
|
2
|
-
import { getDidRunPermissionCheck } from './helpers/didRunPermissionCheck'
|
|
3
2
|
import { setMutationsPermissions } from './modelRegistry'
|
|
4
3
|
|
|
4
|
+
import type { TableBuilderWithColumns } from '@rocicorp/zero'
|
|
5
5
|
import type {
|
|
6
6
|
MutatorContext,
|
|
7
7
|
Schema,
|
|
@@ -10,7 +10,6 @@ import type {
|
|
|
10
10
|
TableUpdateRow,
|
|
11
11
|
Where,
|
|
12
12
|
} from './types'
|
|
13
|
-
import type { TableBuilderWithColumns } from '@rocicorp/zero'
|
|
14
13
|
|
|
15
14
|
// derive a TableBuilderWithColumns from the global schema by table name
|
|
16
15
|
type SchemaTableBuilder<TName extends TableName> = TableBuilderWithColumns<
|
|
@@ -74,10 +73,6 @@ function getOrCreateMutationProxy<T extends Record<string, Function>>(
|
|
|
74
73
|
return proxy
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
// two ways to use it:
|
|
78
|
-
// - mutations({}) which doesn't add the "allowed" helper or add CRUD
|
|
79
|
-
// - mutation('tableName', permissions) adds CRUD with permissions, adds allowed
|
|
80
|
-
|
|
81
76
|
type MutationBuilder<Obj = any> = (ctx: MutatorContext, obj?: Obj) => Promise<void>
|
|
82
77
|
type MutationBuilders = Record<string, MutationBuilder>
|
|
83
78
|
|
|
@@ -158,6 +153,9 @@ export function mutations<
|
|
|
158
153
|
: ((table as Table).schema.name as TableName)
|
|
159
154
|
|
|
160
155
|
const createCRUDMutation = (action: CRUDNames) => {
|
|
156
|
+
const customMutation = mutations?.[action]
|
|
157
|
+
if (customMutation) return customMutation
|
|
158
|
+
|
|
161
159
|
return async (ctx: MutatorContext, obj: any) => {
|
|
162
160
|
/**
|
|
163
161
|
* CRUD mutations have permissions handled automatically using `can`:
|
|
@@ -168,11 +166,6 @@ export function mutations<
|
|
|
168
166
|
* - for the rest: check runs before mutation
|
|
169
167
|
*/
|
|
170
168
|
const runServerPermissionCheck = async () => {
|
|
171
|
-
if (getDidRunPermissionCheck(ctx)) {
|
|
172
|
-
// if the user-defined CRUD mutation runs their own "can", we avoid running ours
|
|
173
|
-
return
|
|
174
|
-
}
|
|
175
|
-
|
|
176
169
|
// only validate on the server
|
|
177
170
|
if (IS_SERVER_RUNTIME) {
|
|
178
171
|
await ctx.can(permissions, obj)
|
|
@@ -183,15 +176,8 @@ export function mutations<
|
|
|
183
176
|
await runServerPermissionCheck()
|
|
184
177
|
}
|
|
185
178
|
|
|
186
|
-
//
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (existing) {
|
|
190
|
-
await existing(ctx, obj)
|
|
191
|
-
} else {
|
|
192
|
-
type TableName = keyof typeof ctx.tx.mutate // weird type foo because we declare this module and then type check
|
|
193
|
-
await ctx.tx.mutate[tableName as TableName]
|
|
194
|
-
}
|
|
179
|
+
type TableName = keyof typeof ctx.tx.mutate // weird type foo because we declare this module and then type check
|
|
180
|
+
await ctx.tx.mutate[tableName as TableName]
|
|
195
181
|
|
|
196
182
|
if (action === 'insert' || action === 'upsert') {
|
|
197
183
|
await runServerPermissionCheck()
|
|
@@ -208,7 +194,7 @@ export function mutations<
|
|
|
208
194
|
|
|
209
195
|
const finalMutations = {
|
|
210
196
|
...mutations,
|
|
211
|
-
//
|
|
197
|
+
// generated CRUD fills missing operations; custom CRUD runs as-is
|
|
212
198
|
...crudMutations,
|
|
213
199
|
} as any as Mutations
|
|
214
200
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPermissions.d.ts","sourceRoot":"","sources":["../src/createPermissions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createPermissions.d.ts","sourceRoot":"","sources":["../src/createPermissions.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAe,KAAK,EAAE,MAAM,SAAS,CAAA;AAC1F,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EAEjB,MAAM,IAAI,UAAU,EACrB,MAAM,gBAAgB,CAAA;AAEvB,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,iBAAiB,CAAC,MAAM,SAAS,UAAU,EAAE,EAC3D,WAAW,EACX,MAAM,EACN,aAAqB,GACtB,EAAE;IACD,WAAW,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B;;2BAG+B,eAAe,kCACjC,QAAQ,GAAG,IAAI,MACrB,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,mBACd,eAAe,WAEvB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,sBACjB,SAAS;EAmHhC"}
|
|
@@ -19,7 +19,7 @@ export type HttpPullTransportOptions = {
|
|
|
19
19
|
lifecycle?: (event: HttpPullLifecycleEvent) => void;
|
|
20
20
|
};
|
|
21
21
|
export type HttpPullLifecycleEvent = {
|
|
22
|
-
type: 'created' | 'listener' | 'open' | 'close' | 'failure' | 'superseded' | 'aborted';
|
|
22
|
+
type: 'created' | 'listener' | 'open' | 'close' | 'failure' | 'superseded' | 'aborted' | 'push';
|
|
23
23
|
pageID: string;
|
|
24
24
|
transportID: string;
|
|
25
25
|
zeroInstanceID: string;
|
|
@@ -36,6 +36,8 @@ export type HttpPullLifecycleEvent = {
|
|
|
36
36
|
listener?: SocketEventType;
|
|
37
37
|
code?: number;
|
|
38
38
|
reason?: string;
|
|
39
|
+
pushFrameCount?: number;
|
|
40
|
+
mutationCount?: number;
|
|
39
41
|
};
|
|
40
42
|
export declare function installHttpPullTransport(opts: HttpPullTransportOptions): HttpPullTransport;
|
|
41
43
|
export declare function ensureHttpPullTransport(opts: HttpPullTransportOptions): HttpPullTransport;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpPullTransport.d.ts","sourceRoot":"","sources":["../src/httpPullTransport.ts"],"names":[],"mappings":"AAUA,KAAK,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAA;AA+B7D,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,OAAO,EAAE,KAAK,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"httpPullTransport.d.ts","sourceRoot":"","sources":["../src/httpPullTransport.ts"],"names":[],"mappings":"AAUA,KAAK,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAA;AA+B7D,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,OAAO,EAAE,KAAK,OAAO,CAAA;AA4DhF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,SAAS,IAAI,IAAI,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAA;IAGd,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;IAGpB,cAAc,CAAC,EAAE,MAAM,CAAA;IAMvB,IAAI,CAAC,EAAE,OAAO,CAAA;IAId,cAAc,CAAC,EAAE,cAAc,CAAA;IAI/B,YAAY,CAAC,EAAE,OAAO,CAAA;IAGtB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAA;CACpD,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EACA,SAAS,GACT,UAAU,GACV,MAAM,GACN,OAAO,GACP,SAAS,GACT,YAAY,GACZ,SAAS,GACT,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAA;IACpC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,QAAQ,CAAC,EAAE,eAAe,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAwCD,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,wBAAwB,GAC7B,iBAAiB,CA6EnB;AAKD,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,wBAAwB,GAC7B,iBAAiB,CAQnB"}
|
package/types/mutations.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MutatorContext, Schema, TableInsertRow, TableName, TableUpdateRow, Where } from './types';
|
|
2
1
|
import type { TableBuilderWithColumns } from '@rocicorp/zero';
|
|
2
|
+
import type { MutatorContext, Schema, TableInsertRow, TableName, TableUpdateRow, Where } from './types';
|
|
3
3
|
type SchemaTableBuilder<TName extends TableName> = TableBuilderWithColumns<Schema['tables'][TName]>;
|
|
4
4
|
type MutationBuilder<Obj = any> = (ctx: MutatorContext, obj?: Obj) => Promise<void>;
|
|
5
5
|
type MutationBuilders = Record<string, MutationBuilder>;
|
package/types/mutations.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../src/mutations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../src/mutations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EACN,cAAc,EACd,SAAS,EACT,cAAc,EACd,KAAK,EACN,MAAM,SAAS,CAAA;AAGhB,KAAK,kBAAkB,CAAC,KAAK,SAAS,SAAS,IAAI,uBAAuB,CACxE,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CACxB,CAAA;AA2DD,KAAK,eAAe,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AACnF,KAAK,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;AAevD,KAAK,YAAY,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAA;AAEhD,KAAK,aAAa,CAAC,KAAK,SAAS,YAAY,IAAI;IAC/C,MAAM,EAAE,eAAe,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAA;IAC9C,MAAM,EAAE,eAAe,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAA;IAC9C,MAAM,EAAE,eAAe,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAA;IAC9C,MAAM,EAAE,eAAe,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAA;CAC/C,CAAA;AAED,KAAK,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAE1D,KAAK,iBAAiB,CAAC,KAAK,SAAS,YAAY,EAAE,SAAS,SAAS,gBAAgB,IAAI;KACtF,GAAG,IAAI,SAAS,GAAG,MAAM,SAAS,GAAG,GAAG,SAAS,MAAM,SAAS,GAC7D,SAAS,CAAC,GAAG,CAAC,GACd,GAAG,SAAS,MAAM,aAAa,CAAC,GAAG,CAAC,GAClC,aAAa,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GACzB,KAAK;CACZ,CAAA;AAED,wBAAgB,SAAS,CAAC,SAAS,SAAS,gBAAgB,EAC1D,SAAS,EAAE,SAAS,GACnB,SAAS,CAAA;AACZ,wBAAgB,SAAS,CAAC,KAAK,SAAS,YAAY,EAAE,WAAW,SAAS,KAAK,EAC7E,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,GACvB,iBAAiB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;AAC/B,wBAAgB,SAAS,CACvB,KAAK,SAAS,YAAY,EAC1B,WAAW,SAAS,KAAK,EACzB,SAAS,SAAS,gBAAgB,EAElC,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,GACnB,iBAAiB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;AAEtC,wBAAgB,SAAS,CAAC,KAAK,SAAS,SAAS,EAAE,WAAW,SAAS,KAAK,EAC1E,SAAS,EAAE,KAAK,EAChB,WAAW,EAAE,WAAW,GACvB,iBAAiB,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAA;AACnD,wBAAgB,SAAS,CACvB,KAAK,SAAS,SAAS,EACvB,WAAW,SAAS,KAAK,EACzB,SAAS,SAAS,gBAAgB,EAElC,SAAS,EAAE,KAAK,EAChB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,GACnB,iBAAiB,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,CAAA"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all) __defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: true
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
-
get: () => from[key],
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
}), mod);
|
|
23
|
-
var didRunPermissionCheck_exports = {};
|
|
24
|
-
__export(didRunPermissionCheck_exports, {
|
|
25
|
-
getDidRunPermissionCheck: () => getDidRunPermissionCheck,
|
|
26
|
-
setDidRunPermissionCheck: () => setDidRunPermissionCheck
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(didRunPermissionCheck_exports);
|
|
29
|
-
var import_helpers = require("@take-out/helpers");
|
|
30
|
-
const PermissionCheckRan = (0, import_helpers.globalValue)(`on-zero:permissions-check`, () => /* @__PURE__ */new WeakMap());
|
|
31
|
-
const getDidRunPermissionCheck = ctx => {
|
|
32
|
-
return PermissionCheckRan.get(ctx);
|
|
33
|
-
};
|
|
34
|
-
const setDidRunPermissionCheck = ctx => {
|
|
35
|
-
return PermissionCheckRan.set(ctx, true);
|
|
36
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: true
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
25
|
-
var didRunPermissionCheck_exports = {};
|
|
26
|
-
__export(didRunPermissionCheck_exports, {
|
|
27
|
-
getDidRunPermissionCheck: () => getDidRunPermissionCheck,
|
|
28
|
-
setDidRunPermissionCheck: () => setDidRunPermissionCheck
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(didRunPermissionCheck_exports);
|
|
31
|
-
var import_helpers = require("@take-out/helpers");
|
|
32
|
-
var PermissionCheckRan = (0, import_helpers.globalValue)(`on-zero:permissions-check`, function () {
|
|
33
|
-
return /* @__PURE__ */new WeakMap();
|
|
34
|
-
});
|
|
35
|
-
var getDidRunPermissionCheck = function (ctx) {
|
|
36
|
-
return PermissionCheckRan.get(ctx);
|
|
37
|
-
};
|
|
38
|
-
var setDidRunPermissionCheck = function (ctx) {
|
|
39
|
-
return PermissionCheckRan.set(ctx, true);
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=didRunPermissionCheck.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","didRunPermissionCheck_exports","__export","getDidRunPermissionCheck","setDidRunPermissionCheck","module","exports","import_helpers","require","PermissionCheckRan","globalValue","WeakMap","ctx","get","set"],"sources":["../../../src/helpers/didRunPermissionCheck.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,6BAAA;AAAAC,QAAA,CAAAD,6BAAA;EAAAE,wBAAA,EAAAA,CAAA,KAAAA,wBAAA;EAAAC,wBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAV,YAA4B,CAAAK,6BAAA;AAI5B,IAAAM,cAAM,GAAAC,OAAA,oBAAqB;AAAA,IACzBC,kBAAA,OAAAF,cAAA,CAAAG,WAAA;EACA,OAAM,mBAAIC,OAAiC;AAC7C;AAEO,IAAAR,wBAAM,YAAAA,CAA4BS,GAAwB;EAC/D,OAAOH,kBAAA,CAAmBI,GAAA,CAAID,GAAG;AACnC;AAEO,IAAAR,wBAAM,YAAAA,CAA4BQ,GAAwB;EAC/D,OAAOH,kBAAA,CAAmBK,GAAA,CAAIF,GAAA,EAAK,IAAI;AACzC","ignoreList":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { globalValue } from "@take-out/helpers";
|
|
2
|
-
const PermissionCheckRan = globalValue(`on-zero:permissions-check`, () => /* @__PURE__ */new WeakMap());
|
|
3
|
-
const getDidRunPermissionCheck = ctx => {
|
|
4
|
-
return PermissionCheckRan.get(ctx);
|
|
5
|
-
};
|
|
6
|
-
const setDidRunPermissionCheck = ctx => {
|
|
7
|
-
return PermissionCheckRan.set(ctx, true);
|
|
8
|
-
};
|
|
9
|
-
export { getDidRunPermissionCheck, setDidRunPermissionCheck };
|
|
10
|
-
//# sourceMappingURL=didRunPermissionCheck.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["globalValue","PermissionCheckRan","WeakMap","getDidRunPermissionCheck","ctx","get","setDidRunPermissionCheck","set"],"sources":["../../../src/helpers/didRunPermissionCheck.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAA,QAAmB;AAI5B,MAAMC,kBAAA,GAAqBD,WAAA,CACzB,6BACA,MAAM,mBAAIE,OAAA,CAAiC,CAC7C;AAEO,MAAMC,wBAAA,GAA4BC,GAAA,IAAwB;EAC/D,OAAOH,kBAAA,CAAmBI,GAAA,CAAID,GAAG;AACnC;AAEO,MAAME,wBAAA,GAA4BF,GAAA,IAAwB;EAC/D,OAAOH,kBAAA,CAAmBM,GAAA,CAAIH,GAAA,EAAK,IAAI;AACzC","ignoreList":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { globalValue } from "@take-out/helpers";
|
|
2
|
-
var PermissionCheckRan = globalValue(`on-zero:permissions-check`, function () {
|
|
3
|
-
return /* @__PURE__ */new WeakMap();
|
|
4
|
-
});
|
|
5
|
-
var getDidRunPermissionCheck = function (ctx) {
|
|
6
|
-
return PermissionCheckRan.get(ctx);
|
|
7
|
-
};
|
|
8
|
-
var setDidRunPermissionCheck = function (ctx) {
|
|
9
|
-
return PermissionCheckRan.set(ctx, true);
|
|
10
|
-
};
|
|
11
|
-
export { getDidRunPermissionCheck, setDidRunPermissionCheck };
|
|
12
|
-
//# sourceMappingURL=didRunPermissionCheck.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["globalValue","PermissionCheckRan","WeakMap","getDidRunPermissionCheck","ctx","get","setDidRunPermissionCheck","set"],"sources":["../../../src/helpers/didRunPermissionCheck.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAA,QAAmB;AAI5B,IAAAC,kBAAM,GAAAD,WAAqB;EACzB,0BAAAE,OAAA;AAAA,EACA;AACF,IAAAC,wBAAA,YAAAA,CAAAC,GAAA;EAEO,OAAMH,kBAAA,CAAAI,GAAA,CAAAD,GAA4B;AACvC;AACF,IAAAE,wBAAA,YAAAA,CAAAF,GAAA;EAEO,OAAMH,kBAAA,CAAAM,GAAA,CAAAH,GAA4B,OAAwB;AAC/D;AACF,S","ignoreList":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { globalValue } from '@take-out/helpers'
|
|
2
|
-
|
|
3
|
-
import type { MutatorContext } from '../types'
|
|
4
|
-
|
|
5
|
-
const PermissionCheckRan = globalValue(
|
|
6
|
-
`on-zero:permissions-check`,
|
|
7
|
-
() => new WeakMap<MutatorContext, boolean>(),
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
export const getDidRunPermissionCheck = (ctx: MutatorContext) => {
|
|
11
|
-
return PermissionCheckRan.get(ctx)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const setDidRunPermissionCheck = (ctx: MutatorContext) => {
|
|
15
|
-
return PermissionCheckRan.set(ctx, true)
|
|
16
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { MutatorContext } from '../types';
|
|
2
|
-
export declare const getDidRunPermissionCheck: (ctx: MutatorContext) => boolean | undefined;
|
|
3
|
-
export declare const setDidRunPermissionCheck: (ctx: MutatorContext) => WeakMap<MutatorContext, boolean>;
|
|
4
|
-
//# sourceMappingURL=didRunPermissionCheck.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"didRunPermissionCheck.d.ts","sourceRoot":"","sources":["../../src/helpers/didRunPermissionCheck.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAO9C,eAAO,MAAM,wBAAwB,GAAI,KAAK,cAAc,wBAE3D,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI,KAAK,cAAc,qCAE3D,CAAA"}
|