on-zero 0.7.10 → 0.8.0
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 → README.md} +172 -231
- package/dist/cjs/cli.cjs +5 -2
- package/dist/cjs/cli.native.js +5 -2
- package/dist/cjs/cli.native.js.map +1 -1
- package/dist/cjs/combineZeroClients.cjs +2 -2
- package/dist/cjs/combineZeroClients.native.js +6 -6
- package/dist/cjs/combineZeroClients.native.js.map +1 -1
- package/dist/cjs/config.cjs +30 -0
- package/dist/cjs/config.native.js +33 -0
- package/dist/cjs/config.native.js.map +1 -0
- package/dist/cjs/createPermissions.cjs +2 -2
- package/dist/cjs/createPermissions.native.js +17 -27
- package/dist/cjs/createPermissions.native.js.map +1 -1
- package/dist/cjs/createUseQuery.cjs +3 -3
- package/dist/cjs/createUseQuery.native.js +4 -4
- package/dist/cjs/createUseQuery.native.js.map +1 -1
- package/dist/cjs/createUseQueryDirect.cjs +4 -3
- package/dist/cjs/createUseQueryDirect.native.js +14 -18
- package/dist/cjs/createUseQueryDirect.native.js.map +1 -1
- package/dist/cjs/createZeroClient.cjs +29 -9
- package/dist/cjs/createZeroClient.connection.test.cjs +11 -0
- package/dist/cjs/createZeroClient.connection.test.native.js +14 -7
- package/dist/cjs/createZeroClient.connection.test.native.js.map +1 -1
- package/dist/cjs/createZeroClient.native.js +58 -32
- package/dist/cjs/createZeroClient.native.js.map +1 -1
- package/dist/cjs/createZeroClient.recovery.test.cjs +90 -3
- package/dist/cjs/createZeroClient.recovery.test.native.js +109 -19
- package/dist/cjs/createZeroClient.recovery.test.native.js.map +1 -1
- package/dist/cjs/generate-helpers.cjs +70 -17
- package/dist/cjs/generate-helpers.native.js +110 -23
- package/dist/cjs/generate-helpers.native.js.map +1 -1
- package/dist/cjs/generate-layout.cjs +586 -0
- package/dist/cjs/generate-layout.native.js +1275 -0
- package/dist/cjs/generate-layout.native.js.map +1 -0
- package/dist/cjs/generate-lite.cjs +295 -27
- package/dist/cjs/generate-lite.native.js +854 -102
- package/dist/cjs/generate-lite.native.js.map +1 -1
- package/dist/cjs/generate-lite.test.cjs +433 -41
- package/dist/cjs/generate-lite.test.native.js +446 -41
- package/dist/cjs/generate-lite.test.native.js.map +1 -1
- package/dist/cjs/generate.cjs +172 -94
- package/dist/cjs/generate.native.js +324 -148
- package/dist/cjs/generate.native.js.map +1 -1
- package/dist/cjs/generate.test.cjs +362 -45
- package/dist/cjs/generate.test.native.js +374 -45
- package/dist/cjs/generate.test.native.js.map +1 -1
- package/dist/cjs/helpers/NullToOptional.cjs +18 -0
- package/dist/cjs/helpers/NullToOptional.native.js +21 -0
- package/dist/cjs/helpers/NullToOptional.native.js.map +1 -0
- package/dist/cjs/helpers/asyncContext.cjs +128 -0
- package/dist/cjs/helpers/asyncContext.native.js +87 -0
- package/dist/cjs/helpers/asyncContext.native.js.map +1 -0
- package/dist/cjs/helpers/batchQuery.cjs +2 -2
- package/dist/cjs/helpers/batchQuery.native.js +2 -2
- package/dist/cjs/helpers/batchQuery.native.js.map +1 -1
- package/dist/cjs/helpers/createMutators.cjs +7 -4
- package/dist/cjs/helpers/createMutators.native.js +12 -9
- package/dist/cjs/helpers/createMutators.native.js.map +1 -1
- package/dist/cjs/helpers/createMutators.test.native.js +2 -2
- package/dist/cjs/helpers/createMutators.test.native.js.map +1 -1
- package/dist/cjs/helpers/ellipsis.cjs +35 -0
- package/dist/cjs/helpers/ellipsis.native.js +38 -0
- package/dist/cjs/helpers/ellipsis.native.js.map +1 -0
- package/dist/cjs/helpers/emitter.cjs +99 -0
- package/dist/cjs/helpers/emitter.native.js +125 -0
- package/dist/cjs/helpers/emitter.native.js.map +1 -0
- package/dist/cjs/helpers/ensure.cjs +33 -0
- package/dist/cjs/helpers/ensure.native.js +37 -0
- package/dist/cjs/helpers/ensure.native.js.map +1 -0
- package/dist/cjs/helpers/ensureLoggedIn.cjs +2 -2
- package/dist/cjs/helpers/ensureLoggedIn.native.js +3 -3
- package/dist/cjs/helpers/ensureLoggedIn.native.js.map +1 -1
- package/dist/cjs/helpers/errors.cjs +40 -0
- package/dist/cjs/helpers/errors.native.js +152 -0
- package/dist/cjs/helpers/errors.native.js.map +1 -0
- package/dist/cjs/helpers/getCurrentComponentStack.cjs +71 -0
- package/dist/cjs/helpers/getCurrentComponentStack.native.js +93 -0
- package/dist/cjs/helpers/getCurrentComponentStack.native.js.map +1 -0
- package/dist/cjs/helpers/globalValue.cjs +39 -0
- package/dist/cjs/helpers/globalValue.native.js +42 -0
- package/dist/cjs/helpers/globalValue.native.js.map +1 -0
- package/dist/cjs/helpers/mapObject.cjs +36 -0
- package/dist/cjs/helpers/mapObject.native.js +39 -0
- package/dist/cjs/helpers/mapObject.native.js.map +1 -0
- package/dist/cjs/helpers/mutationLifecycle.cjs +251 -0
- package/dist/cjs/helpers/mutationLifecycle.native.js +392 -0
- package/dist/cjs/helpers/mutationLifecycle.native.js.map +1 -0
- package/dist/cjs/helpers/mutationLifecycle.test.cjs +174 -0
- package/dist/cjs/helpers/mutationLifecycle.test.native.js +182 -0
- package/dist/cjs/helpers/mutationLifecycle.test.native.js.map +1 -0
- package/dist/cjs/helpers/mutatorContext.cjs +3 -3
- package/dist/cjs/helpers/mutatorContext.native.js +5 -5
- package/dist/cjs/helpers/mutatorContext.native.js.map +1 -1
- package/dist/cjs/helpers/platform.cjs +31 -0
- package/dist/cjs/helpers/platform.native.js +33 -0
- package/dist/cjs/helpers/platform.native.js.map +1 -0
- package/dist/cjs/helpers/prettyFormatZeroQuery.cjs +2 -2
- package/dist/cjs/helpers/prettyFormatZeroQuery.native.js +7 -7
- package/dist/cjs/helpers/prettyFormatZeroQuery.native.js.map +1 -1
- package/dist/cjs/helpers/queryContext.cjs +2 -2
- package/dist/cjs/helpers/queryContext.native.js +4 -4
- package/dist/cjs/helpers/queryContext.native.js.map +1 -1
- package/dist/cjs/helpers/recoverZeroClient.cjs +14 -15
- package/dist/cjs/helpers/recoverZeroClient.native.js +26 -23
- package/dist/cjs/helpers/recoverZeroClient.native.js.map +1 -1
- package/dist/cjs/helpers/recoverZeroClient.test.cjs +10 -8
- package/dist/cjs/helpers/recoverZeroClient.test.native.js +17 -21
- package/dist/cjs/helpers/recoverZeroClient.test.native.js.map +1 -1
- package/dist/cjs/helpers/sleep.cjs +34 -0
- package/dist/cjs/helpers/sleep.native.js +39 -0
- package/dist/cjs/helpers/sleep.native.js.map +1 -0
- package/dist/cjs/helpers/time.cjs +47 -0
- package/dist/cjs/helpers/time.native.js +80 -0
- package/dist/cjs/helpers/time.native.js.map +1 -0
- package/dist/cjs/helpers/tuple.cjs +18 -0
- package/dist/cjs/helpers/tuple.native.js +21 -0
- package/dist/cjs/helpers/tuple.native.js.map +1 -0
- package/dist/cjs/helpers/useMutation.native.js +5 -5
- package/dist/cjs/helpers/useMutation.native.js.map +1 -1
- package/dist/cjs/helpers/useMutation.test.native.js +1 -1
- package/dist/cjs/helpers/useMutation.test.native.js.map +1 -1
- package/dist/cjs/helpers/useZeroDebug.cjs +2 -2
- package/dist/cjs/helpers/useZeroDebug.native.js +7 -8
- package/dist/cjs/helpers/useZeroDebug.native.js.map +1 -1
- package/dist/cjs/index.cjs +9 -1
- package/dist/cjs/index.native.js +8 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/instanceRegistry.cjs +16 -4
- package/dist/cjs/instanceRegistry.native.js +56 -6
- package/dist/cjs/instanceRegistry.native.js.map +1 -1
- package/dist/cjs/multi.cjs +34 -13
- package/dist/cjs/multi.native.js +39 -17
- package/dist/cjs/multi.native.js.map +1 -1
- package/dist/cjs/multiInstance.test.cjs +6 -2
- package/dist/cjs/multiInstance.test.native.js +13 -9
- package/dist/cjs/multiInstance.test.native.js.map +1 -1
- package/dist/cjs/multiInstanceNested.test.native.js +10 -10
- package/dist/cjs/multiInstanceNested.test.native.js.map +1 -1
- package/dist/cjs/multiPartition.test.cjs +85 -36
- package/dist/cjs/multiPartition.test.native.js +102 -39
- package/dist/cjs/multiPartition.test.native.js.map +1 -1
- package/dist/cjs/mutations.cjs +2 -2
- package/dist/cjs/mutations.native.js +4 -4
- package/dist/cjs/mutations.native.js.map +1 -1
- package/dist/cjs/mutations.test.native.js +3 -3
- package/dist/cjs/mutations.test.native.js.map +1 -1
- package/dist/cjs/provideZero.hydration.test.cjs +3 -3
- package/dist/cjs/provideZero.hydration.test.native.js +4 -4
- package/dist/cjs/provideZero.hydration.test.native.js.map +1 -1
- package/dist/cjs/run.cjs +1 -1
- package/dist/cjs/run.native.js +3 -3
- package/dist/cjs/run.native.js.map +1 -1
- package/dist/cjs/server.cjs +20 -16
- package/dist/cjs/server.native.js +50 -57
- package/dist/cjs/server.native.js.map +1 -1
- package/dist/cjs/server.test.cjs +129 -6
- package/dist/cjs/server.test.native.js +141 -10
- package/dist/cjs/server.test.native.js.map +1 -1
- package/dist/cjs/serverWhere.test.native.js +3 -3
- package/dist/cjs/serverWhere.test.native.js.map +1 -1
- package/dist/cjs/state.cjs +2 -2
- package/dist/cjs/state.native.js +10 -10
- package/dist/cjs/state.native.js.map +1 -1
- package/dist/cjs/usePermission.test.native.js +3 -3
- package/dist/cjs/usePermission.test.native.js.map +1 -1
- package/dist/cjs/useQuery.empty.test.cjs +3 -3
- package/dist/cjs/useQuery.empty.test.native.js +6 -6
- package/dist/cjs/useQuery.empty.test.native.js.map +1 -1
- package/dist/cjs/useQuery.ssr.test.native.js +2 -2
- package/dist/cjs/useQuery.ssr.test.native.js.map +1 -1
- package/dist/cjs/vite-plugin.cjs +7 -8
- package/dist/cjs/vite-plugin.native.js +11 -11
- package/dist/cjs/vite-plugin.native.js.map +1 -1
- package/dist/cjs/where.cjs +3 -3
- package/dist/cjs/where.native.js +4 -4
- package/dist/cjs/where.native.js.map +1 -1
- package/dist/esm/cli.mjs +6 -3
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/cli.native.js +6 -3
- package/dist/esm/cli.native.js.map +1 -1
- package/dist/esm/combineZeroClients.mjs +1 -1
- package/dist/esm/combineZeroClients.mjs.map +1 -1
- package/dist/esm/combineZeroClients.native.js +5 -5
- package/dist/esm/combineZeroClients.native.js.map +1 -1
- package/dist/esm/config.mjs +5 -0
- package/dist/esm/config.mjs.map +1 -0
- package/dist/esm/config.native.js +5 -0
- package/dist/esm/config.native.js.map +1 -0
- package/dist/esm/createPermissions.mjs +1 -1
- package/dist/esm/createPermissions.mjs.map +1 -1
- package/dist/esm/createPermissions.native.js +16 -26
- package/dist/esm/createPermissions.native.js.map +1 -1
- package/dist/esm/createUseQuery.mjs +2 -2
- package/dist/esm/createUseQuery.mjs.map +1 -1
- package/dist/esm/createUseQuery.native.js +3 -3
- package/dist/esm/createUseQuery.native.js.map +1 -1
- package/dist/esm/createUseQueryDirect.mjs +2 -1
- package/dist/esm/createUseQueryDirect.mjs.map +1 -1
- package/dist/esm/createUseQueryDirect.native.js +12 -16
- package/dist/esm/createUseQueryDirect.native.js.map +1 -1
- package/dist/esm/createZeroClient.connection.test.mjs +11 -0
- package/dist/esm/createZeroClient.connection.test.mjs.map +1 -1
- package/dist/esm/createZeroClient.connection.test.native.js +14 -7
- package/dist/esm/createZeroClient.connection.test.native.js.map +1 -1
- package/dist/esm/createZeroClient.mjs +25 -5
- package/dist/esm/createZeroClient.mjs.map +1 -1
- package/dist/esm/createZeroClient.native.js +54 -28
- package/dist/esm/createZeroClient.native.js.map +1 -1
- package/dist/esm/createZeroClient.recovery.test.mjs +90 -3
- package/dist/esm/createZeroClient.recovery.test.mjs.map +1 -1
- package/dist/esm/createZeroClient.recovery.test.native.js +109 -19
- package/dist/esm/createZeroClient.recovery.test.native.js.map +1 -1
- package/dist/esm/generate-helpers.mjs +70 -18
- package/dist/esm/generate-helpers.mjs.map +1 -1
- package/dist/esm/generate-helpers.native.js +110 -24
- package/dist/esm/generate-helpers.native.js.map +1 -1
- package/dist/esm/generate-layout.mjs +560 -0
- package/dist/esm/generate-layout.mjs.map +1 -0
- package/dist/esm/generate-layout.native.js +1246 -0
- package/dist/esm/generate-layout.native.js.map +1 -0
- package/dist/esm/generate-lite.mjs +296 -28
- package/dist/esm/generate-lite.mjs.map +1 -1
- package/dist/esm/generate-lite.native.js +855 -103
- package/dist/esm/generate-lite.native.js.map +1 -1
- package/dist/esm/generate-lite.test.mjs +434 -42
- package/dist/esm/generate-lite.test.mjs.map +1 -1
- package/dist/esm/generate-lite.test.native.js +447 -42
- package/dist/esm/generate-lite.test.native.js.map +1 -1
- package/dist/esm/generate.mjs +172 -96
- package/dist/esm/generate.mjs.map +1 -1
- package/dist/esm/generate.native.js +324 -150
- package/dist/esm/generate.native.js.map +1 -1
- package/dist/esm/generate.test.mjs +366 -49
- package/dist/esm/generate.test.mjs.map +1 -1
- package/dist/esm/generate.test.native.js +378 -49
- package/dist/esm/generate.test.native.js.map +1 -1
- package/dist/esm/helpers/NullToOptional.mjs +2 -0
- package/dist/esm/helpers/NullToOptional.mjs.map +1 -0
- package/dist/esm/helpers/NullToOptional.native.js +2 -0
- package/dist/esm/helpers/NullToOptional.native.js.map +1 -0
- package/dist/esm/helpers/asyncContext.mjs +102 -0
- package/dist/esm/helpers/asyncContext.mjs.map +1 -0
- package/dist/esm/helpers/asyncContext.native.js +58 -0
- package/dist/esm/helpers/asyncContext.native.js.map +1 -0
- package/dist/esm/helpers/batchQuery.mjs +1 -1
- package/dist/esm/helpers/batchQuery.native.js +1 -1
- package/dist/esm/helpers/createMutators.mjs +5 -2
- package/dist/esm/helpers/createMutators.mjs.map +1 -1
- package/dist/esm/helpers/createMutators.native.js +10 -7
- package/dist/esm/helpers/createMutators.native.js.map +1 -1
- package/dist/esm/helpers/createMutators.test.native.js +2 -2
- package/dist/esm/helpers/createMutators.test.native.js.map +1 -1
- package/dist/esm/helpers/ellipsis.mjs +10 -0
- package/dist/esm/helpers/ellipsis.mjs.map +1 -0
- package/dist/esm/helpers/ellipsis.native.js +10 -0
- package/dist/esm/helpers/ellipsis.native.js.map +1 -0
- package/dist/esm/helpers/emitter.mjs +72 -0
- package/dist/esm/helpers/emitter.mjs.map +1 -0
- package/dist/esm/helpers/emitter.native.js +95 -0
- package/dist/esm/helpers/emitter.native.js.map +1 -0
- package/dist/esm/helpers/ensure.mjs +8 -0
- package/dist/esm/helpers/ensure.mjs.map +1 -0
- package/dist/esm/helpers/ensure.native.js +9 -0
- package/dist/esm/helpers/ensure.native.js.map +1 -0
- package/dist/esm/helpers/ensureLoggedIn.mjs +1 -1
- package/dist/esm/helpers/ensureLoggedIn.mjs.map +1 -1
- package/dist/esm/helpers/ensureLoggedIn.native.js +2 -2
- package/dist/esm/helpers/ensureLoggedIn.native.js.map +1 -1
- package/dist/esm/helpers/errors.mjs +14 -0
- package/dist/esm/helpers/errors.mjs.map +1 -0
- package/dist/esm/helpers/errors.native.js +123 -0
- package/dist/esm/helpers/errors.native.js.map +1 -0
- package/dist/esm/helpers/getCurrentComponentStack.mjs +35 -0
- package/dist/esm/helpers/getCurrentComponentStack.mjs.map +1 -0
- package/dist/esm/helpers/getCurrentComponentStack.native.js +54 -0
- package/dist/esm/helpers/getCurrentComponentStack.native.js.map +1 -0
- package/dist/esm/helpers/globalValue.mjs +14 -0
- package/dist/esm/helpers/globalValue.mjs.map +1 -0
- package/dist/esm/helpers/globalValue.native.js +14 -0
- package/dist/esm/helpers/globalValue.native.js.map +1 -0
- package/dist/esm/helpers/mapObject.mjs +11 -0
- package/dist/esm/helpers/mapObject.mjs.map +1 -0
- package/dist/esm/helpers/mapObject.native.js +11 -0
- package/dist/esm/helpers/mapObject.native.js.map +1 -0
- package/dist/esm/helpers/mutationLifecycle.mjs +221 -0
- package/dist/esm/helpers/mutationLifecycle.mjs.map +1 -0
- package/dist/esm/helpers/mutationLifecycle.native.js +359 -0
- package/dist/esm/helpers/mutationLifecycle.native.js.map +1 -0
- package/dist/esm/helpers/mutationLifecycle.test.mjs +175 -0
- package/dist/esm/helpers/mutationLifecycle.test.mjs.map +1 -0
- package/dist/esm/helpers/mutationLifecycle.test.native.js +180 -0
- package/dist/esm/helpers/mutationLifecycle.test.native.js.map +1 -0
- package/dist/esm/helpers/mutatorContext.mjs +1 -1
- package/dist/esm/helpers/mutatorContext.native.js +4 -4
- package/dist/esm/helpers/mutatorContext.native.js.map +1 -1
- package/dist/esm/helpers/platform.mjs +5 -0
- package/dist/esm/helpers/platform.mjs.map +1 -0
- package/dist/esm/helpers/platform.native.js +4 -0
- package/dist/esm/helpers/platform.native.js.map +1 -0
- package/dist/esm/helpers/prettyFormatZeroQuery.mjs +1 -1
- package/dist/esm/helpers/prettyFormatZeroQuery.native.js +6 -6
- package/dist/esm/helpers/prettyFormatZeroQuery.native.js.map +1 -1
- package/dist/esm/helpers/queryContext.mjs +1 -1
- package/dist/esm/helpers/queryContext.native.js +3 -3
- package/dist/esm/helpers/queryContext.native.js.map +1 -1
- package/dist/esm/helpers/recoverZeroClient.mjs +14 -15
- package/dist/esm/helpers/recoverZeroClient.mjs.map +1 -1
- package/dist/esm/helpers/recoverZeroClient.native.js +26 -23
- package/dist/esm/helpers/recoverZeroClient.native.js.map +1 -1
- package/dist/esm/helpers/recoverZeroClient.test.mjs +8 -6
- package/dist/esm/helpers/recoverZeroClient.test.mjs.map +1 -1
- package/dist/esm/helpers/recoverZeroClient.test.native.js +15 -19
- package/dist/esm/helpers/recoverZeroClient.test.native.js.map +1 -1
- package/dist/esm/helpers/sleep.mjs +9 -0
- package/dist/esm/helpers/sleep.mjs.map +1 -0
- package/dist/esm/helpers/sleep.native.js +11 -0
- package/dist/esm/helpers/sleep.native.js.map +1 -0
- package/dist/esm/helpers/time.mjs +22 -0
- package/dist/esm/helpers/time.mjs.map +1 -0
- package/dist/esm/helpers/time.native.js +52 -0
- package/dist/esm/helpers/time.native.js.map +1 -0
- package/dist/esm/helpers/tuple.mjs +2 -0
- package/dist/esm/helpers/tuple.mjs.map +1 -0
- package/dist/esm/helpers/tuple.native.js +2 -0
- package/dist/esm/helpers/tuple.native.js.map +1 -0
- package/dist/esm/helpers/useMutation.native.js +5 -5
- package/dist/esm/helpers/useMutation.native.js.map +1 -1
- package/dist/esm/helpers/useMutation.test.native.js +1 -1
- package/dist/esm/helpers/useMutation.test.native.js.map +1 -1
- package/dist/esm/helpers/useZeroDebug.mjs +1 -1
- package/dist/esm/helpers/useZeroDebug.mjs.map +1 -1
- package/dist/esm/helpers/useZeroDebug.native.js +6 -7
- package/dist/esm/helpers/useZeroDebug.native.js.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +3 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +3 -1
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/instanceRegistry.mjs +13 -2
- package/dist/esm/instanceRegistry.mjs.map +1 -1
- package/dist/esm/instanceRegistry.native.js +53 -4
- package/dist/esm/instanceRegistry.native.js.map +1 -1
- package/dist/esm/multi.mjs +33 -12
- package/dist/esm/multi.mjs.map +1 -1
- package/dist/esm/multi.native.js +38 -16
- package/dist/esm/multi.native.js.map +1 -1
- package/dist/esm/multiInstance.test.mjs +5 -1
- package/dist/esm/multiInstance.test.mjs.map +1 -1
- package/dist/esm/multiInstance.test.native.js +12 -8
- package/dist/esm/multiInstance.test.native.js.map +1 -1
- package/dist/esm/multiInstanceNested.test.native.js +10 -10
- package/dist/esm/multiInstanceNested.test.native.js.map +1 -1
- package/dist/esm/multiPartition.test.mjs +86 -37
- package/dist/esm/multiPartition.test.mjs.map +1 -1
- package/dist/esm/multiPartition.test.native.js +103 -40
- package/dist/esm/multiPartition.test.native.js.map +1 -1
- package/dist/esm/mutations.mjs +1 -1
- package/dist/esm/mutations.mjs.map +1 -1
- package/dist/esm/mutations.native.js +3 -3
- package/dist/esm/mutations.native.js.map +1 -1
- package/dist/esm/mutations.test.native.js +3 -3
- package/dist/esm/mutations.test.native.js.map +1 -1
- package/dist/esm/provideZero.hydration.test.mjs +1 -1
- package/dist/esm/provideZero.hydration.test.mjs.map +1 -1
- package/dist/esm/provideZero.hydration.test.native.js +2 -2
- package/dist/esm/provideZero.hydration.test.native.js.map +1 -1
- package/dist/esm/run.mjs +1 -1
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/run.native.js +3 -3
- package/dist/esm/run.native.js.map +1 -1
- package/dist/esm/server.mjs +20 -15
- package/dist/esm/server.mjs.map +1 -1
- package/dist/esm/server.native.js +50 -56
- package/dist/esm/server.native.js.map +1 -1
- package/dist/esm/server.test.mjs +130 -7
- package/dist/esm/server.test.mjs.map +1 -1
- package/dist/esm/server.test.native.js +142 -11
- package/dist/esm/server.test.native.js.map +1 -1
- package/dist/esm/serverWhere.test.mjs.map +1 -1
- package/dist/esm/serverWhere.test.native.js +3 -3
- package/dist/esm/serverWhere.test.native.js.map +1 -1
- package/dist/esm/state.mjs +1 -1
- package/dist/esm/state.mjs.map +1 -1
- package/dist/esm/state.native.js +9 -9
- package/dist/esm/state.native.js.map +1 -1
- package/dist/esm/usePermission.test.native.js +3 -3
- package/dist/esm/usePermission.test.native.js.map +1 -1
- package/dist/esm/useQuery.empty.test.mjs +1 -1
- package/dist/esm/useQuery.empty.test.mjs.map +1 -1
- package/dist/esm/useQuery.empty.test.native.js +4 -4
- package/dist/esm/useQuery.empty.test.native.js.map +1 -1
- package/dist/esm/useQuery.ssr.test.native.js +2 -2
- package/dist/esm/useQuery.ssr.test.native.js.map +1 -1
- package/dist/esm/vite-plugin.mjs +7 -8
- package/dist/esm/vite-plugin.mjs.map +1 -1
- package/dist/esm/vite-plugin.native.js +11 -11
- package/dist/esm/vite-plugin.native.js.map +1 -1
- package/dist/esm/where.mjs +1 -1
- package/dist/esm/where.mjs.map +1 -1
- package/dist/esm/where.native.js +2 -2
- package/dist/esm/where.native.js.map +1 -1
- package/package.json +18 -6
- package/src/cli.ts +11 -3
- package/src/combineZeroClients.tsx +18 -10
- package/src/config.ts +72 -0
- package/src/createPermissions.ts +3 -4
- package/src/createUseQuery.tsx +8 -8
- package/src/createUseQueryDirect.tsx +11 -10
- package/src/createZeroClient.authData.test.tsx +1 -1
- package/src/createZeroClient.connection.test.tsx +13 -2
- package/src/createZeroClient.recovery.test.tsx +100 -4
- package/src/createZeroClient.tsx +87 -30
- package/src/generate-helpers.ts +108 -31
- package/src/generate-layout.ts +841 -0
- package/src/generate-lite.test.ts +421 -42
- package/src/generate-lite.ts +479 -43
- package/src/generate.test.ts +552 -90
- package/src/generate.ts +360 -163
- package/src/helpers/NullToOptional.ts +5 -0
- package/src/helpers/asyncContext.native.ts +90 -0
- package/src/helpers/asyncContext.ts +159 -0
- package/src/helpers/batchQuery.ts +2 -2
- package/src/helpers/createMutators.ts +11 -8
- package/src/helpers/ellipsis.ts +9 -0
- package/src/helpers/emitter.tsx +106 -0
- package/src/helpers/ensure.ts +10 -0
- package/src/helpers/ensureLoggedIn.ts +1 -2
- package/src/helpers/errors.ts +13 -0
- package/src/helpers/getCurrentComponentStack.ts +56 -0
- package/src/helpers/globalValue.ts +40 -0
- package/src/helpers/mapObject.ts +14 -0
- package/src/helpers/mutationLifecycle.test.ts +180 -0
- package/src/helpers/mutationLifecycle.ts +313 -0
- package/src/helpers/mutatorContext.ts +3 -3
- package/src/helpers/platform.native.ts +2 -0
- package/src/helpers/platform.ts +16 -0
- package/src/helpers/prettyFormatZeroQuery.ts +2 -2
- package/src/helpers/queryContext.ts +2 -2
- package/src/helpers/recoverZeroClient.test.ts +23 -21
- package/src/helpers/recoverZeroClient.ts +56 -49
- package/src/helpers/sleep.ts +8 -0
- package/src/helpers/time.ts +51 -0
- package/src/helpers/tuple.ts +1 -0
- package/src/helpers/useMutation.tsx +3 -3
- package/src/helpers/useZeroDebug.ts +3 -3
- package/src/index.ts +13 -1
- package/src/instanceRegistry.ts +19 -6
- package/src/multi.ts +75 -31
- package/src/multiInstance.test.tsx +31 -13
- package/src/multiInstanceNested.test.tsx +2 -2
- package/src/multiPartition.test.ts +62 -27
- package/src/mutations.ts +10 -10
- package/src/provideZero.hydration.test.tsx +1 -1
- package/src/resolveQuery.ts +2 -2
- package/src/run.ts +7 -7
- package/src/server.test.ts +117 -18
- package/src/server.ts +70 -43
- package/src/serverWhere.ts +2 -2
- package/src/state.ts +2 -2
- package/src/types.ts +47 -6
- package/src/useQuery.empty.test.tsx +3 -3
- package/src/useQuery.ssr.test.ts +1 -1
- package/src/vite-plugin.ts +12 -9
- package/src/where.ts +6 -7
- package/src/zeroRunner.ts +2 -2
- package/types/combineZeroClients.d.ts +11 -5
- package/types/combineZeroClients.d.ts.map +1 -1
- package/types/config.d.ts +62 -0
- package/types/config.d.ts.map +1 -0
- package/types/createPermissions.d.ts.map +1 -1
- package/types/createUseQuery.d.ts.map +1 -1
- package/types/createUseQueryDirect.d.ts +1 -1
- package/types/createUseQueryDirect.d.ts.map +1 -1
- package/types/createZeroClient.d.ts +22 -12
- package/types/createZeroClient.d.ts.map +1 -1
- package/types/createZeroClient.recovery.test.d.ts.map +1 -1
- package/types/generate-helpers.d.ts +17 -2
- package/types/generate-helpers.d.ts.map +1 -1
- package/types/generate-layout.d.ts +26 -0
- package/types/generate-layout.d.ts.map +1 -0
- package/types/generate-lite.d.ts +29 -1
- package/types/generate-lite.d.ts.map +1 -1
- package/types/generate.d.ts +20 -0
- package/types/generate.d.ts.map +1 -1
- package/types/helpers/NullToOptional.d.ts +6 -0
- package/types/helpers/NullToOptional.d.ts.map +1 -0
- package/types/helpers/asyncContext.d.ts +15 -0
- package/types/helpers/asyncContext.d.ts.map +1 -0
- package/types/helpers/asyncContext.native.d.ts +8 -0
- package/types/helpers/asyncContext.native.d.ts.map +1 -0
- package/types/helpers/createMutators.d.ts +2 -1
- package/types/helpers/createMutators.d.ts.map +1 -1
- package/types/helpers/ellipsis.d.ts +2 -0
- package/types/helpers/ellipsis.d.ts.map +1 -0
- package/types/helpers/emitter.d.ts +21 -0
- package/types/helpers/emitter.d.ts.map +1 -0
- package/types/helpers/ensure.d.ts +2 -0
- package/types/helpers/ensure.d.ts.map +1 -0
- package/types/helpers/ensureLoggedIn.d.ts.map +1 -1
- package/types/helpers/errors.d.ts +7 -0
- package/types/helpers/errors.d.ts.map +1 -0
- package/types/helpers/getCurrentComponentStack.d.ts +2 -0
- package/types/helpers/getCurrentComponentStack.d.ts.map +1 -0
- package/types/helpers/globalValue.d.ts +23 -0
- package/types/helpers/globalValue.d.ts.map +1 -0
- package/types/helpers/mapObject.d.ts +4 -0
- package/types/helpers/mapObject.d.ts.map +1 -0
- package/types/helpers/mutationLifecycle.d.ts +44 -0
- package/types/helpers/mutationLifecycle.d.ts.map +1 -0
- package/types/helpers/mutationLifecycle.test.d.ts +2 -0
- package/types/helpers/mutationLifecycle.test.d.ts.map +1 -0
- package/types/helpers/platform.d.ts +3 -0
- package/types/helpers/platform.d.ts.map +1 -0
- package/types/helpers/platform.native.d.ts +3 -0
- package/types/helpers/platform.native.d.ts.map +1 -0
- package/types/helpers/recoverZeroClient.d.ts +13 -9
- package/types/helpers/recoverZeroClient.d.ts.map +1 -1
- package/types/helpers/sleep.d.ts +2 -0
- package/types/helpers/sleep.d.ts.map +1 -0
- package/types/helpers/time.d.ts +28 -0
- package/types/helpers/time.d.ts.map +1 -0
- package/types/helpers/tuple.d.ts +2 -0
- package/types/helpers/tuple.d.ts.map +1 -0
- package/types/index.d.ts +3 -1
- package/types/index.d.ts.map +1 -1
- package/types/instanceRegistry.d.ts +1 -0
- package/types/instanceRegistry.d.ts.map +1 -1
- package/types/multi.d.ts +23 -1
- package/types/multi.d.ts.map +1 -1
- package/types/mutations.d.ts +1 -1
- package/types/mutations.d.ts.map +1 -1
- package/types/run.d.ts.map +1 -1
- package/types/server.d.ts +12 -8
- package/types/server.d.ts.map +1 -1
- package/types/state.d.ts +1 -1
- package/types/state.d.ts.map +1 -1
- package/types/types.d.ts +23 -1
- package/types/types.d.ts.map +1 -1
- package/types/vite-plugin.d.ts.map +1 -1
- package/types/where.d.ts.map +1 -1
- package/lint/ssr-guards.js +0 -165
- package/test-fixtures/server-return-types.ts +0 -58
- package/test-fixtures/tsconfig.json +0 -13
- package/tsconfig.json +0 -26
- package/vitest.config.ts +0 -8
|
@@ -31,15 +31,19 @@ var import_vitest = require("vitest");
|
|
|
31
31
|
var import_generate = require("./generate.cjs");
|
|
32
32
|
const import_meta = {};
|
|
33
33
|
const testDir = (0, import_node_path.join)((0, import_node_os.tmpdir)(), "on-zero-test-" + Date.now());
|
|
34
|
-
(
|
|
35
|
-
(0, import_node_fs.mkdirSync)((0, import_node_path.
|
|
34
|
+
function writeFileSync(path, content) {
|
|
35
|
+
(0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(path), {
|
|
36
36
|
recursive: true
|
|
37
37
|
});
|
|
38
|
-
(0, import_node_fs.
|
|
38
|
+
(0, import_node_fs.writeFileSync)(path, content);
|
|
39
|
+
}
|
|
40
|
+
(0, import_vitest.beforeEach)(() => {
|
|
41
|
+
(0, import_node_fs.mkdirSync)(testDir, {
|
|
39
42
|
recursive: true
|
|
40
43
|
});
|
|
41
44
|
});
|
|
42
45
|
(0, import_vitest.afterEach)(() => {
|
|
46
|
+
import_vitest.vi.restoreAllMocks();
|
|
43
47
|
(0, import_node_fs.rmSync)(testDir, {
|
|
44
48
|
recursive: true,
|
|
45
49
|
force: true
|
|
@@ -47,7 +51,7 @@ const testDir = (0, import_node_path.join)((0, import_node_os.tmpdir)(), "on-zer
|
|
|
47
51
|
});
|
|
48
52
|
(0, import_vitest.describe)("generate", () => {
|
|
49
53
|
(0, import_vitest.test)("generates models.ts, types.ts, tables.ts from model files", async () => {
|
|
50
|
-
|
|
54
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/mutations.ts"), `
|
|
51
55
|
import { table, string, boolean } from 'on-zero'
|
|
52
56
|
|
|
53
57
|
export const schema = table('post', {
|
|
@@ -56,7 +60,7 @@ export const schema = table('post', {
|
|
|
56
60
|
published: boolean(),
|
|
57
61
|
})
|
|
58
62
|
`);
|
|
59
|
-
|
|
63
|
+
writeFileSync((0, import_node_path.join)(testDir, "comment/mutations.ts"), `
|
|
60
64
|
import { table, string } from 'on-zero'
|
|
61
65
|
|
|
62
66
|
export const schema = table('comment', {
|
|
@@ -65,8 +69,8 @@ export const schema = table('comment', {
|
|
|
65
69
|
body: string(),
|
|
66
70
|
})
|
|
67
71
|
`);
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/post.test.ts"), `throw new Error('test files must not be generated as models')`);
|
|
73
|
+
writeFileSync((0, import_node_path.join)(testDir, "comment/comment.spec.ts"), `throw new Error('spec files must not be generated as queries')`);
|
|
70
74
|
const result = await (0, import_generate.generate)({
|
|
71
75
|
dir: testDir,
|
|
72
76
|
silent: true
|
|
@@ -78,20 +82,20 @@ export const schema = table('comment', {
|
|
|
78
82
|
(0, import_vitest.expect)((0, import_node_fs.existsSync)((0, import_node_path.join)(testDir, "generated/types.ts"))).toBe(true);
|
|
79
83
|
(0, import_vitest.expect)((0, import_node_fs.existsSync)((0, import_node_path.join)(testDir, "generated/tables.ts"))).toBe(true);
|
|
80
84
|
const modelsContent = (0, import_node_fs.readFileSync)((0, import_node_path.join)(testDir, "generated/models.ts"), "utf-8");
|
|
81
|
-
(0, import_vitest.expect)(modelsContent).toContain("import * as comment from '../
|
|
82
|
-
(0, import_vitest.expect)(modelsContent).toContain("import * as post from '../
|
|
85
|
+
(0, import_vitest.expect)(modelsContent).toContain("import * as comment from '../comment/mutations'");
|
|
86
|
+
(0, import_vitest.expect)(modelsContent).toContain("import * as post from '../post/mutations'");
|
|
83
87
|
(0, import_vitest.expect)(modelsContent).not.toContain("post.test");
|
|
84
88
|
(0, import_vitest.expect)(modelsContent).toContain("export const models = {");
|
|
85
89
|
const typesContent = (0, import_node_fs.readFileSync)((0, import_node_path.join)(testDir, "generated/types.ts"), "utf-8");
|
|
86
90
|
(0, import_vitest.expect)(typesContent).toContain("export type Post = TableInsertRow<typeof schema.post>");
|
|
87
91
|
(0, import_vitest.expect)(typesContent).toContain("export type Comment = TableInsertRow<typeof schema.comment>");
|
|
88
92
|
const tablesContent = (0, import_node_fs.readFileSync)((0, import_node_path.join)(testDir, "generated/tables.ts"), "utf-8");
|
|
89
|
-
(0, import_vitest.expect)(tablesContent).toContain("export { schema as post } from '../
|
|
90
|
-
(0, import_vitest.expect)(tablesContent).toContain("export { schema as comment } from '../
|
|
93
|
+
(0, import_vitest.expect)(tablesContent).toContain("export { schema as post } from '../post/mutations'");
|
|
94
|
+
(0, import_vitest.expect)(tablesContent).toContain("export { schema as comment } from '../comment/mutations'");
|
|
91
95
|
});
|
|
92
96
|
(0, import_vitest.test)("generates query validators from query files", async () => {
|
|
93
|
-
|
|
94
|
-
|
|
97
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/mutations.ts"), `export const schema = table('post', { id: string() })`);
|
|
98
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/queries.ts"), `
|
|
95
99
|
import { zero } from '../zero'
|
|
96
100
|
|
|
97
101
|
export const allPosts = () => zero.query.post
|
|
@@ -109,7 +113,8 @@ export const postsByAuthor = ({ authorId, limit }: { authorId: string; limit?: n
|
|
|
109
113
|
(0, import_vitest.expect)((0, import_node_fs.existsSync)((0, import_node_path.join)(testDir, "generated/groupedQueries.ts"))).toBe(true);
|
|
110
114
|
(0, import_vitest.expect)((0, import_node_fs.existsSync)((0, import_node_path.join)(testDir, "generated/syncedQueries.ts"))).toBe(true);
|
|
111
115
|
const groupedContent = (0, import_node_fs.readFileSync)((0, import_node_path.join)(testDir, "generated/groupedQueries.ts"), "utf-8");
|
|
112
|
-
(0, import_vitest.expect)(groupedContent).toContain("
|
|
116
|
+
(0, import_vitest.expect)(groupedContent).toContain("import * as postSource from '../post/queries'");
|
|
117
|
+
(0, import_vitest.expect)(groupedContent).toContain("postById: postSource.postById");
|
|
113
118
|
const syncedContent = (0, import_node_fs.readFileSync)((0, import_node_path.join)(testDir, "generated/syncedQueries.ts"), "utf-8");
|
|
114
119
|
(0, import_vitest.expect)(syncedContent).toContain("allPosts: defineQuery");
|
|
115
120
|
(0, import_vitest.expect)(syncedContent).toContain("postById: defineQuery");
|
|
@@ -117,8 +122,8 @@ export const postsByAuthor = ({ authorId, limit }: { authorId: string; limit?: n
|
|
|
117
122
|
(0, import_vitest.expect)(syncedContent).toContain("v.object");
|
|
118
123
|
});
|
|
119
124
|
(0, import_vitest.test)("skips permission exports in queries", async () => {
|
|
120
|
-
|
|
121
|
-
|
|
125
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/mutations.ts"), `export const schema = table('post', { id: string() })`);
|
|
126
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/queries.ts"), `
|
|
122
127
|
export const permission = () => ({ canRead: true })
|
|
123
128
|
export const allPosts = () => zero.query.post
|
|
124
129
|
`);
|
|
@@ -132,20 +137,20 @@ export const allPosts = () => zero.query.post
|
|
|
132
137
|
(0, import_vitest.expect)(syncedContent).not.toContain("permission:");
|
|
133
138
|
});
|
|
134
139
|
(0, import_vitest.test)("aliases user import without changing the model key", async () => {
|
|
135
|
-
|
|
140
|
+
writeFileSync((0, import_node_path.join)(testDir, "user/mutations.ts"), `export const schema = table('user', { id: string(), name: string() })`);
|
|
136
141
|
await (0, import_generate.generate)({
|
|
137
142
|
dir: testDir,
|
|
138
143
|
silent: true
|
|
139
144
|
});
|
|
140
145
|
const modelsContent = (0, import_node_fs.readFileSync)((0, import_node_path.join)(testDir, "generated/models.ts"), "utf-8");
|
|
141
|
-
(0, import_vitest.expect)(modelsContent).toContain("import * as userPublic from '../
|
|
146
|
+
(0, import_vitest.expect)(modelsContent).toContain("import * as userPublic from '../user/mutations'");
|
|
142
147
|
(0, import_vitest.expect)(modelsContent).toContain("user: userPublic,");
|
|
143
148
|
(0, import_vitest.expect)(modelsContent).not.toContain("\n userPublic,");
|
|
144
149
|
const typesContent = (0, import_node_fs.readFileSync)((0, import_node_path.join)(testDir, "generated/types.ts"), "utf-8");
|
|
145
150
|
(0, import_vitest.expect)(typesContent).toContain("typeof schema.userPublic");
|
|
146
151
|
});
|
|
147
152
|
(0, import_vitest.test)("runs after command when files change", async () => {
|
|
148
|
-
|
|
153
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/mutations.ts"), `export const schema = table('post', { id: string() })`);
|
|
149
154
|
const markerFile = (0, import_node_path.join)(testDir, "after-ran");
|
|
150
155
|
const result = await (0, import_generate.generate)({
|
|
151
156
|
dir: testDir,
|
|
@@ -156,7 +161,7 @@ export const allPosts = () => zero.query.post
|
|
|
156
161
|
(0, import_vitest.expect)((0, import_node_fs.existsSync)(markerFile)).toBe(true);
|
|
157
162
|
});
|
|
158
163
|
(0, import_vitest.test)("does not regenerate when nothing changed", async () => {
|
|
159
|
-
|
|
164
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/mutations.ts"), `export const schema = table('post', { id: string() })`);
|
|
160
165
|
const first = await (0, import_generate.generate)({
|
|
161
166
|
dir: testDir,
|
|
162
167
|
silent: true
|
|
@@ -169,8 +174,8 @@ export const allPosts = () => zero.query.post
|
|
|
169
174
|
(0, import_vitest.expect)(second.filesChanged).toBe(0);
|
|
170
175
|
});
|
|
171
176
|
(0, import_vitest.test)("force regenerates without source changes", async () => {
|
|
172
|
-
|
|
173
|
-
|
|
177
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/mutations.ts"), `export const schema = table('post', { id: string() })`);
|
|
178
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/queries.ts"), `export const allPosts = () => zero.query.post`);
|
|
174
179
|
await (0, import_generate.generate)({
|
|
175
180
|
dir: testDir,
|
|
176
181
|
silent: true
|
|
@@ -185,9 +190,321 @@ export const allPosts = () => zero.query.post
|
|
|
185
190
|
(0, import_vitest.expect)((0, import_node_fs.existsSync)(syncedQueriesPath)).toBe(true);
|
|
186
191
|
});
|
|
187
192
|
});
|
|
193
|
+
(0, import_vitest.describe)("instance layout", () => {
|
|
194
|
+
const dataDir = () => (0, import_node_path.join)(testDir, "src/data");
|
|
195
|
+
(0, import_vitest.test)("discovers file and folder namespaces and emits related sync closure", async () => {
|
|
196
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "control/reaction.ts"), `export const allReactions = () => zql.reaction`);
|
|
197
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "on-zero.config.ts"), `export default defineConfig({ instances: { control: {}, project: { scope: 'projectId' } } })`);
|
|
198
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "project/message/queries.ts"), `
|
|
199
|
+
const unused = () => zql.message.related('notARealRelation')
|
|
200
|
+
const withComments = () => zql.message.related('comments', (q) => q.related('author'))
|
|
201
|
+
export const messages = () => withComments()
|
|
202
|
+
`);
|
|
203
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "project/message/mutations.ts"), `export const schema = table('message').columns({ id: string(), projectId: string() })`);
|
|
204
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "project/message/helpers.ts"), `export const privateHelper = () => 'ignored'`);
|
|
205
|
+
writeFileSync((0, import_node_path.join)(testDir, "src/database/relations.ts"), `
|
|
206
|
+
export const relations = defineRelations(schema, (r) => ({
|
|
207
|
+
message: { comments: r.many.comment({}) },
|
|
208
|
+
comment: { author: r.one.userPublic({}) },
|
|
209
|
+
}))
|
|
210
|
+
`);
|
|
211
|
+
writeFileSync((0, import_node_path.join)(testDir, "src/database/schema.ts"), `
|
|
212
|
+
export const comment = sqliteTable('comment', { id: text(), projectId: text() })
|
|
213
|
+
export const userPublic = sqliteTable('user_public', { id: text(), projectId: text() })
|
|
214
|
+
`);
|
|
215
|
+
const membership = await (0, import_generate.deriveDataMembership)({
|
|
216
|
+
dir: dataDir()
|
|
217
|
+
});
|
|
218
|
+
(0, import_vitest.expect)(membership.allTables).toEqual(["comment", "message", "reaction", "userPublic"]);
|
|
219
|
+
(0, import_vitest.expect)(membership.instances.project).toEqual({
|
|
220
|
+
tables: ["message"],
|
|
221
|
+
syncTables: ["comment", "message", "userPublic"],
|
|
222
|
+
supportTables: [],
|
|
223
|
+
scope: "projectId"
|
|
224
|
+
});
|
|
225
|
+
await (0, import_generate.generate)({
|
|
226
|
+
dir: dataDir(),
|
|
227
|
+
silent: true
|
|
228
|
+
});
|
|
229
|
+
const grouped = (0, import_node_fs.readFileSync)((0, import_node_path.join)(dataDir(), "generated/groupedQueries.ts"), "utf8");
|
|
230
|
+
(0, import_vitest.expect)(grouped).toContain("from '../control/reaction'");
|
|
231
|
+
(0, import_vitest.expect)(grouped).toContain("from '../project/message/queries'");
|
|
232
|
+
(0, import_vitest.expect)(grouped).not.toContain("privateHelper");
|
|
233
|
+
const manifest = (0, import_node_fs.readFileSync)((0, import_node_path.join)(dataDir(), "generated/instances.ts"), "utf8");
|
|
234
|
+
(0, import_vitest.expect)(manifest).toContain("control: {");
|
|
235
|
+
(0, import_vitest.expect)(manifest).toContain("project: {");
|
|
236
|
+
(0, import_vitest.expect)(manifest).toContain('tables: ["message"]');
|
|
237
|
+
(0, import_vitest.expect)(manifest).toContain('syncTables: ["comment","message","userPublic"]');
|
|
238
|
+
(0, import_vitest.expect)(manifest).toContain(`defaultVisibility: (value: string) => ({ column: "projectId", value })`);
|
|
239
|
+
});
|
|
240
|
+
(0, import_vitest.test)("derives single-file namespaces from data exports", async () => {
|
|
241
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "server.ts"), `export const serverRows = () => zql.server`);
|
|
242
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "types.ts"), `export const formatRow = (value: string) => value`);
|
|
243
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "auth.ts"), `export function authId(auth: { id: string }) { return auth.id }`);
|
|
244
|
+
await (0, import_vitest.expect)((0, import_generate.deriveDataMembership)({
|
|
245
|
+
dir: dataDir()
|
|
246
|
+
})).resolves.toEqual({
|
|
247
|
+
instances: {
|
|
248
|
+
default: {
|
|
249
|
+
tables: ["server"],
|
|
250
|
+
syncTables: ["server"],
|
|
251
|
+
supportTables: [],
|
|
252
|
+
scope: null
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
allTables: ["server"]
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
(0, import_vitest.test)("warns once and ignores an unparseable non-data file", async () => {
|
|
259
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "post.ts"), `export const posts = () => zql.post`);
|
|
260
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "types.ts"), `export type Broken = {`);
|
|
261
|
+
const warn = import_vitest.vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
262
|
+
await (0, import_vitest.expect)((0, import_generate.deriveDataMembership)({
|
|
263
|
+
dir: dataDir()
|
|
264
|
+
})).resolves.toMatchObject({
|
|
265
|
+
allTables: ["post"]
|
|
266
|
+
});
|
|
267
|
+
(0, import_vitest.expect)(warn).toHaveBeenCalledOnce();
|
|
268
|
+
(0, import_vitest.expect)(warn).toHaveBeenCalledWith("[on-zero] ignoring data/types.ts: no recognized data exports");
|
|
269
|
+
warn.mockRestore();
|
|
270
|
+
});
|
|
271
|
+
(0, import_vitest.test)("derives fileless support tables through mutation helpers", async () => {
|
|
272
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "post.ts"), `
|
|
273
|
+
import { writeAudit } from './helpers/writeAudit'
|
|
274
|
+
export const posts = () => zql.post
|
|
275
|
+
export const mutate = mutations('post', { save: async (ctx) => writeAudit(ctx.tx) })
|
|
276
|
+
`);
|
|
277
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "helpers/writeAudit.ts"), `
|
|
278
|
+
import { readSettings } from './readSettings'
|
|
279
|
+
export async function writeAudit(tx: Transaction) {
|
|
280
|
+
await tx.mutate.audit.insert({ id: 'audit' })
|
|
281
|
+
await tx.mutate.post.update({ id: 'post' })
|
|
282
|
+
await tx.mutate[tableName].insert({ id: 'dynamic' })
|
|
283
|
+
return readSettings(tx)
|
|
284
|
+
}
|
|
285
|
+
`);
|
|
286
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "helpers/readSettings.ts"), `export const readSettings = (tx: Transaction) => tx.query.settings`);
|
|
287
|
+
await (0, import_vitest.expect)((0, import_generate.deriveDataMembership)({
|
|
288
|
+
dir: dataDir()
|
|
289
|
+
})).resolves.toEqual({
|
|
290
|
+
instances: {
|
|
291
|
+
default: {
|
|
292
|
+
tables: ["post"],
|
|
293
|
+
syncTables: ["post"],
|
|
294
|
+
supportTables: ["audit", "settings"],
|
|
295
|
+
scope: null
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
allTables: ["audit", "post", "settings"]
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
(0, import_vitest.test)("includes a fileless support table in every instance that uses it", async () => {
|
|
302
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "control/account.ts"), `export const mutate = mutations('account', { save: async (ctx) => ctx.tx.mutate.audit.insert({}) })`);
|
|
303
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "on-zero.config.ts"), `export default defineConfig({ instances: { control: {}, project: { scope: 'projectId' } } })`);
|
|
304
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "project/message.ts"), `
|
|
305
|
+
export const schema = table('message').columns({ id: string(), projectId: string() })
|
|
306
|
+
export const mutate = mutations(schema, permission, {
|
|
307
|
+
save: async (ctx) => ctx.tx.mutate.audit.insert({}),
|
|
308
|
+
})
|
|
309
|
+
`);
|
|
310
|
+
await (0, import_vitest.expect)((0, import_generate.deriveDataMembership)({
|
|
311
|
+
dir: dataDir()
|
|
312
|
+
})).resolves.toMatchObject({
|
|
313
|
+
instances: {
|
|
314
|
+
control: {
|
|
315
|
+
supportTables: ["audit"]
|
|
316
|
+
},
|
|
317
|
+
project: {
|
|
318
|
+
supportTables: ["audit"]
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
allTables: ["account", "audit", "message"]
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
(0, import_vitest.test)("keeps a configured default instance at the data root", async () => {
|
|
325
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "on-zero.config.ts"), `export default defineConfig({ instances: { default: { dir: '.', supportTables: ['accountGithubOrgLink', 'accountRepo', 'usageLedger'] }, project: { scope: 'projectId' } } })`);
|
|
326
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "account.ts"), `export const accounts = () => zql.account`);
|
|
327
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "project/message.ts"), `export const schema = table('message').columns({ id: string(), projectId: string() })`);
|
|
328
|
+
await (0, import_vitest.expect)((0, import_generate.deriveDataMembership)({
|
|
329
|
+
dir: dataDir()
|
|
330
|
+
})).resolves.toEqual({
|
|
331
|
+
instances: {
|
|
332
|
+
default: {
|
|
333
|
+
tables: ["account"],
|
|
334
|
+
syncTables: ["account"],
|
|
335
|
+
supportTables: ["accountGithubOrgLink", "accountRepo", "usageLedger"],
|
|
336
|
+
scope: null
|
|
337
|
+
},
|
|
338
|
+
project: {
|
|
339
|
+
tables: ["message"],
|
|
340
|
+
syncTables: ["message"],
|
|
341
|
+
supportTables: [],
|
|
342
|
+
scope: "projectId"
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
allTables: ["account", "accountGithubOrgLink", "accountRepo", "message", "usageLedger"]
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
(0, import_vitest.test)("emits only relations whose source and target are derived members", async () => {
|
|
349
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "post.ts"), `export const posts = () => zql.post`);
|
|
350
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "comment.ts"), `export const comments = () => zql.comment`);
|
|
351
|
+
writeFileSync((0, import_node_path.join)(testDir, "src/database/relations.ts"), `
|
|
352
|
+
export const relations = defineRelations(schema, (r) => ({
|
|
353
|
+
post: {
|
|
354
|
+
comments: r.many.comment({}),
|
|
355
|
+
privateNotes: r.many.privateNote({}),
|
|
356
|
+
},
|
|
357
|
+
comment: { post: r.one.post({}), author: r.one.privateUser({}) },
|
|
358
|
+
privateNote: { post: r.one.post({}) },
|
|
359
|
+
}))
|
|
360
|
+
`);
|
|
361
|
+
const generated = await (0, import_generate.generateDrizzleSchemaInputFile)({
|
|
362
|
+
dir: dataDir(),
|
|
363
|
+
schemaImportPath: "../../database/schema"
|
|
364
|
+
});
|
|
365
|
+
const runnable = generated.replace(`import { defineRelations } from 'drizzle-orm'`, "").replace(`import * as schema from "../../database/schema"`, "").replace(/export \{[^\n]+\} from [^\n]+/, "").replace("export const relations =", "globalThis.relations =");
|
|
366
|
+
const context = {
|
|
367
|
+
schema: {
|
|
368
|
+
comment: {},
|
|
369
|
+
post: {}
|
|
370
|
+
},
|
|
371
|
+
defineRelations: (_schema, factory) => factory({
|
|
372
|
+
one: new Proxy({}, {
|
|
373
|
+
get: (_target, table) => () => ({
|
|
374
|
+
table
|
|
375
|
+
})
|
|
376
|
+
}),
|
|
377
|
+
many: new Proxy({}, {
|
|
378
|
+
get: (_target, table) => () => ({
|
|
379
|
+
table
|
|
380
|
+
})
|
|
381
|
+
})
|
|
382
|
+
})
|
|
383
|
+
};
|
|
384
|
+
(0, import_node_vm.runInNewContext)(runnable, context);
|
|
385
|
+
(0, import_vitest.expect)(context.relations).toEqual({
|
|
386
|
+
comment: {
|
|
387
|
+
post: {
|
|
388
|
+
table: "post"
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
post: {
|
|
392
|
+
comments: {
|
|
393
|
+
table: "comment"
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
(0, import_vitest.test)("rejects a relation that crosses instance ownership", async () => {
|
|
399
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "control/userPublic.ts"), `export const users = () => zql.userPublic`);
|
|
400
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "on-zero.config.ts"), `export default defineConfig({ instances: { control: {}, project: { scope: 'projectId' } } })`);
|
|
401
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "project/message.ts"), `
|
|
402
|
+
export const schema = table('message').columns({ id: string(), projectId: string() })
|
|
403
|
+
export const messages = () => zql.message.related('author')
|
|
404
|
+
`);
|
|
405
|
+
writeFileSync((0, import_node_path.join)(testDir, "src/database/relations.ts"), `export const relations = defineRelations(schema, (r) => ({ message: { author: r.one.userPublic({}) } }))`);
|
|
406
|
+
await (0, import_vitest.expect)((0, import_generate.generate)({
|
|
407
|
+
dir: dataDir(),
|
|
408
|
+
silent: true
|
|
409
|
+
})).rejects.toThrow(/message\.messages.*instance 'project'.*userPublic.*instance 'control'/);
|
|
410
|
+
});
|
|
411
|
+
(0, import_vitest.test)("rejects a scoped sync table without the scope column", async () => {
|
|
412
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "on-zero.config.ts"), `export default defineConfig({ instances: { project: { scope: 'projectId' } } })`);
|
|
413
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "project/message.ts"), `export const schema = table('message').columns({ id: string() })`);
|
|
414
|
+
await (0, import_vitest.expect)((0, import_generate.generate)({
|
|
415
|
+
dir: dataDir(),
|
|
416
|
+
silent: true
|
|
417
|
+
})).rejects.toThrow(/table 'message'.*instance 'project'.*scope column 'projectId'/);
|
|
418
|
+
});
|
|
419
|
+
(0, import_vitest.test)("rejects duplicate namespaces across instances", async () => {
|
|
420
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "control/message.ts"), `export const messages = () => zql.message`);
|
|
421
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "on-zero.config.ts"), `export default defineConfig({ instances: { control: {}, project: { scope: 'projectId' } } })`);
|
|
422
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "project/message.ts"), `export const schema = table('message').columns({ projectId: string() })`);
|
|
423
|
+
await (0, import_vitest.expect)((0, import_generate.generate)({
|
|
424
|
+
dir: dataDir(),
|
|
425
|
+
silent: true
|
|
426
|
+
})).rejects.toThrow(/namespace 'message'.*instances 'control' and 'project'/);
|
|
427
|
+
});
|
|
428
|
+
(0, import_vitest.test)("resolves configured instance directories relative to the config file", async () => {
|
|
429
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "on-zero.config.ts"), `export default defineConfig({ instances: { control: { dir: './planes/control-data', supportTables: ['audit'] }, project: { dir: '../project-data', scope: 'projectId' } } })`);
|
|
430
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "planes/control-data/account.ts"), `export const accounts = () => zql.account`);
|
|
431
|
+
writeFileSync((0, import_node_path.join)(testDir, "src/project-data/message.ts"), `export const schema = table('message').columns({ id: string(), projectId: string() })`);
|
|
432
|
+
await (0, import_vitest.expect)((0, import_generate.deriveDataMembership)({
|
|
433
|
+
dir: dataDir(),
|
|
434
|
+
config: (0, import_node_path.join)(dataDir(), "on-zero.config.ts")
|
|
435
|
+
})).resolves.toEqual({
|
|
436
|
+
instances: {
|
|
437
|
+
control: {
|
|
438
|
+
tables: ["account"],
|
|
439
|
+
syncTables: ["account"],
|
|
440
|
+
supportTables: ["audit"],
|
|
441
|
+
scope: null
|
|
442
|
+
},
|
|
443
|
+
project: {
|
|
444
|
+
tables: ["message"],
|
|
445
|
+
syncTables: ["message"],
|
|
446
|
+
supportTables: [],
|
|
447
|
+
scope: "projectId"
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
allTables: ["account", "audit", "message"]
|
|
451
|
+
});
|
|
452
|
+
await (0, import_vitest.expect)((0, import_generate.generate)({
|
|
453
|
+
dir: dataDir(),
|
|
454
|
+
config: (0, import_node_path.join)(dataDir(), "on-zero.config.ts"),
|
|
455
|
+
silent: true
|
|
456
|
+
})).resolves.toMatchObject({
|
|
457
|
+
modelCount: 2,
|
|
458
|
+
schemaCount: 1
|
|
459
|
+
});
|
|
460
|
+
(0, import_vitest.expect)((0, import_node_fs.readFileSync)((0, import_node_path.join)(dataDir(), "generated/models.ts"), "utf8")).toContain("from '../../project-data/message'");
|
|
461
|
+
});
|
|
462
|
+
(0, import_vitest.test)("rejects missing configured instance directories", async () => {
|
|
463
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "on-zero.config.ts"), `export default defineConfig({ instances: { project: { dir: './missing' } } })`);
|
|
464
|
+
await (0, import_vitest.expect)((0, import_generate.deriveDataMembership)({
|
|
465
|
+
dir: dataDir()
|
|
466
|
+
})).rejects.toThrow(/instance 'project' directory does not exist.*missing/);
|
|
467
|
+
});
|
|
468
|
+
(0, import_vitest.test)("rejects two instances that resolve to the same directory", async () => {
|
|
469
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "on-zero.config.ts"), `export default defineConfig({ instances: { control: { dir: './shared' }, project: { dir: './shared' } } })`);
|
|
470
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "shared/account.ts"), `export const accounts = () => zql.account`);
|
|
471
|
+
await (0, import_vitest.expect)((0, import_generate.deriveDataMembership)({
|
|
472
|
+
dir: dataDir()
|
|
473
|
+
})).rejects.toThrow(/instances 'control' and 'project' resolve to the same directory/);
|
|
474
|
+
});
|
|
475
|
+
(0, import_vitest.test)("rejects root namespaces when instances are configured", async () => {
|
|
476
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "on-zero.config.ts"), `export default defineConfig({ instances: { project: {} } })`);
|
|
477
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "project/message.ts"), `export const rows = () => zql.message`);
|
|
478
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "account.ts"), `export const rows = () => zql.account`);
|
|
479
|
+
await (0, import_vitest.expect)((0, import_generate.deriveDataMembership)({
|
|
480
|
+
dir: dataDir()
|
|
481
|
+
})).rejects.toThrow(/data namespace .*account\.ts.*outside every instance directory/);
|
|
482
|
+
});
|
|
483
|
+
(0, import_vitest.test)("rejects removed instance.ts configuration", async () => {
|
|
484
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "post.ts"), `export const posts = () => zql.post`);
|
|
485
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "project/instance.ts"), `export default defineInstance({ scope: 'projectId' })`);
|
|
486
|
+
await (0, import_vitest.expect)((0, import_generate.deriveDataMembership)({
|
|
487
|
+
dir: dataDir()
|
|
488
|
+
})).rejects.toThrow(/uses removed instance\.ts configuration/);
|
|
489
|
+
});
|
|
490
|
+
(0, import_vitest.test)("rejects the removed top-level layout", async () => {
|
|
491
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "queries/message.ts"), `export const messages = () => zql.message`);
|
|
492
|
+
await (0, import_vitest.expect)((0, import_generate.generate)({
|
|
493
|
+
dir: dataDir(),
|
|
494
|
+
silent: true
|
|
495
|
+
})).rejects.toThrow(/removed top-level queries\/ layout/);
|
|
496
|
+
});
|
|
497
|
+
(0, import_vitest.test)("rejects dynamically named relations", async () => {
|
|
498
|
+
writeFileSync((0, import_node_path.join)(dataDir(), "message.ts"), `export const messages = (relation: string) => zql.message.related(relation)`);
|
|
499
|
+
await (0, import_vitest.expect)((0, import_generate.generate)({
|
|
500
|
+
dir: dataDir(),
|
|
501
|
+
silent: true
|
|
502
|
+
})).rejects.toThrow(/related\(\) without a string literal.*statically derivable/);
|
|
503
|
+
});
|
|
504
|
+
});
|
|
188
505
|
(0, import_vitest.describe)("mutations", () => {
|
|
189
506
|
(0, import_vitest.test)("generates validators for inline mutation param types", async () => {
|
|
190
|
-
|
|
507
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/mutations.ts"), `
|
|
191
508
|
import { table, string } from 'on-zero'
|
|
192
509
|
import { mutations, serverWhere } from 'on-zero'
|
|
193
510
|
|
|
@@ -216,7 +533,7 @@ export const mutate = mutations(schema, perm, {
|
|
|
216
533
|
(0, import_vitest.expect)(content).toContain("v.string()");
|
|
217
534
|
});
|
|
218
535
|
(0, import_vitest.test)("generates CRUD validators from schema columns", async () => {
|
|
219
|
-
|
|
536
|
+
writeFileSync((0, import_node_path.join)(testDir, "task/mutations.ts"), `
|
|
220
537
|
import { table, string, number, boolean } from 'on-zero'
|
|
221
538
|
import { mutations, serverWhere } from 'on-zero'
|
|
222
539
|
|
|
@@ -243,7 +560,7 @@ export const mutate = mutations(schema, perm)
|
|
|
243
560
|
(0, import_vitest.expect)(content).toContain("delete:");
|
|
244
561
|
});
|
|
245
562
|
(0, import_vitest.test)("treats models without export const mutate as empty mutations", async () => {
|
|
246
|
-
|
|
563
|
+
writeFileSync((0, import_node_path.join)(testDir, "readonly/mutations.ts"), `
|
|
247
564
|
import { table, string } from 'on-zero'
|
|
248
565
|
|
|
249
566
|
export const schema = table('readonly').columns({
|
|
@@ -260,7 +577,7 @@ export const schema = table('readonly').columns({
|
|
|
260
577
|
(0, import_vitest.expect)(content).toContain("readonly: {");
|
|
261
578
|
});
|
|
262
579
|
(0, import_vitest.test)("extracts custom mutations from bare mutations({})", async () => {
|
|
263
|
-
|
|
580
|
+
writeFileSync((0, import_node_path.join)(testDir, "admin/mutations.ts"), `
|
|
264
581
|
import { mutations } from 'on-zero'
|
|
265
582
|
|
|
266
583
|
export const mutate = mutations({
|
|
@@ -278,7 +595,7 @@ export const mutate = mutations({
|
|
|
278
595
|
(0, import_vitest.expect)(content).toContain("v.string()");
|
|
279
596
|
});
|
|
280
597
|
(0, import_vitest.test)("generates validators for string-model multiline mutation params", async () => {
|
|
281
|
-
|
|
598
|
+
writeFileSync((0, import_node_path.join)(testDir, "agentEvent/mutations.ts"), `
|
|
282
599
|
import { mutations, serverWhere } from 'on-zero'
|
|
283
600
|
|
|
284
601
|
const perm = serverWhere('agentEvent', () => true)
|
|
@@ -312,7 +629,7 @@ export const mutate = mutations('agentEvent', perm, {
|
|
|
312
629
|
(0, import_vitest.expect)(content).not.toContain("claimReviewLease: v.object({})");
|
|
313
630
|
});
|
|
314
631
|
(0, import_vitest.test)("generates validators for object intersections", async () => {
|
|
315
|
-
|
|
632
|
+
writeFileSync((0, import_node_path.join)(testDir, "agent/mutations.ts"), `
|
|
316
633
|
import { mutations, serverWhere } from 'on-zero'
|
|
317
634
|
|
|
318
635
|
const perm = serverWhere('agent', () => true)
|
|
@@ -345,7 +662,7 @@ export const mutate = mutations('agent', perm, {
|
|
|
345
662
|
(0, import_vitest.expect)(content).not.toContain("[key");
|
|
346
663
|
});
|
|
347
664
|
(0, import_vitest.test)("uses v.unknown for untyped mutation payloads", async () => {
|
|
348
|
-
|
|
665
|
+
writeFileSync((0, import_node_path.join)(testDir, "project/mutations.ts"), `
|
|
349
666
|
import { mutations, serverWhere } from 'on-zero'
|
|
350
667
|
|
|
351
668
|
const perm = serverWhere('project', () => true)
|
|
@@ -365,7 +682,7 @@ export const mutate = mutations('project', perm, {
|
|
|
365
682
|
(0, import_vitest.expect)(content).not.toContain("insert: v.void_()");
|
|
366
683
|
});
|
|
367
684
|
(0, import_vitest.test)("handles mutations with only context param (void)", async () => {
|
|
368
|
-
|
|
685
|
+
writeFileSync((0, import_node_path.join)(testDir, "user/mutations.ts"), `
|
|
369
686
|
import { table, string } from 'on-zero'
|
|
370
687
|
import { mutations, serverWhere } from 'on-zero'
|
|
371
688
|
|
|
@@ -390,7 +707,7 @@ export const mutate = mutations(schema, perm, {
|
|
|
390
707
|
(0, import_vitest.expect)(content).toContain("finishOnboarding");
|
|
391
708
|
});
|
|
392
709
|
(0, import_vitest.test)("handles primitive param type", async () => {
|
|
393
|
-
|
|
710
|
+
writeFileSync((0, import_node_path.join)(testDir, "user/mutations.ts"), `
|
|
394
711
|
import { table, string } from 'on-zero'
|
|
395
712
|
import { mutations, serverWhere } from 'on-zero'
|
|
396
713
|
|
|
@@ -416,7 +733,7 @@ export const mutate = mutations(schema, perm, {
|
|
|
416
733
|
(0, import_vitest.expect)(content).toContain("v.string()");
|
|
417
734
|
});
|
|
418
735
|
(0, import_vitest.test)("handles array param type", async () => {
|
|
419
|
-
|
|
736
|
+
writeFileSync((0, import_node_path.join)(testDir, "batch/mutations.ts"), `
|
|
420
737
|
import { mutations } from 'on-zero'
|
|
421
738
|
|
|
422
739
|
export const mutate = mutations({
|
|
@@ -434,7 +751,7 @@ export const mutate = mutations({
|
|
|
434
751
|
(0, import_vitest.expect)(content).toContain("v.array");
|
|
435
752
|
});
|
|
436
753
|
(0, import_vitest.test)("populates mutationCount and caching works", async () => {
|
|
437
|
-
|
|
754
|
+
writeFileSync((0, import_node_path.join)(testDir, "item/mutations.ts"), `
|
|
438
755
|
import { table, string } from 'on-zero'
|
|
439
756
|
import { mutations, serverWhere } from 'on-zero'
|
|
440
757
|
|
|
@@ -466,14 +783,14 @@ export const mutate = mutations(schema, perm, {
|
|
|
466
783
|
});
|
|
467
784
|
(0, import_vitest.describe)("type resolution", () => {
|
|
468
785
|
(0, import_vitest.test)("resolves imported type references for mutations", async () => {
|
|
469
|
-
|
|
786
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/types.ts"), `
|
|
470
787
|
export type ArchiveParams = {
|
|
471
788
|
id: string
|
|
472
789
|
reason: string
|
|
473
790
|
archived: boolean
|
|
474
791
|
}
|
|
475
792
|
`);
|
|
476
|
-
|
|
793
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/mutations.ts"), `
|
|
477
794
|
import { table, string, boolean } from 'on-zero'
|
|
478
795
|
import { mutations } from 'on-zero'
|
|
479
796
|
import type { ArchiveParams } from './types'
|
|
@@ -495,7 +812,7 @@ export const mutate = mutations({
|
|
|
495
812
|
(0, import_vitest.expect)(content).toContain("archived");
|
|
496
813
|
});
|
|
497
814
|
(0, import_vitest.test)("resolves utility types like Pick", async () => {
|
|
498
|
-
|
|
815
|
+
writeFileSync((0, import_node_path.join)(testDir, "item/types.ts"), `
|
|
499
816
|
export type Item = {
|
|
500
817
|
id: string
|
|
501
818
|
name: string
|
|
@@ -503,7 +820,7 @@ export type Item = {
|
|
|
503
820
|
count: number
|
|
504
821
|
}
|
|
505
822
|
`);
|
|
506
|
-
|
|
823
|
+
writeFileSync((0, import_node_path.join)(testDir, "item/mutations.ts"), `
|
|
507
824
|
import { table, string, number } from 'on-zero'
|
|
508
825
|
import { mutations, serverWhere } from 'on-zero'
|
|
509
826
|
import type { Item } from './types'
|
|
@@ -534,8 +851,8 @@ export const mutate = mutations(schema, perm, {
|
|
|
534
851
|
(0, import_vitest.expect)(content).not.toMatch(/rename:[\s\S]*count/);
|
|
535
852
|
});
|
|
536
853
|
(0, import_vitest.test)("resolves instantiated Zero row fields through Partial and Omit", async () => {
|
|
537
|
-
(0, import_node_fs.symlinkSync)((0, import_node_path.join)(import_meta.dirname, "
|
|
538
|
-
|
|
854
|
+
(0, import_node_fs.symlinkSync)((0, import_node_path.join)(import_meta.dirname, "../node_modules"), (0, import_node_path.join)(testDir, "node_modules"), "dir");
|
|
855
|
+
writeFileSync((0, import_node_path.join)(testDir, "item/types.ts"), `
|
|
539
856
|
import type { Row } from '@rocicorp/zero'
|
|
540
857
|
import { drizzleZeroConfig } from 'drizzle-zero-sqlite'
|
|
541
858
|
import { sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
@@ -549,7 +866,7 @@ const schema = drizzleZeroConfig({ item })
|
|
|
549
866
|
|
|
550
867
|
export type Item = Row<(typeof schema)['tables']['item']>
|
|
551
868
|
`);
|
|
552
|
-
|
|
869
|
+
writeFileSync((0, import_node_path.join)(testDir, "item/mutations.ts"), `
|
|
553
870
|
import { mutations } from 'on-zero'
|
|
554
871
|
import type { Item } from './types'
|
|
555
872
|
|
|
@@ -572,13 +889,13 @@ export const mutate = mutations('item', {
|
|
|
572
889
|
(0, import_vitest.expect)(content).not.toContain("description: v.optional(v.unknown())");
|
|
573
890
|
});
|
|
574
891
|
(0, import_vitest.test)("skips symbol-keyed properties when resolving imported mutation param types", async () => {
|
|
575
|
-
|
|
892
|
+
writeFileSync((0, import_node_path.join)(testDir, "item/types.ts"), `
|
|
576
893
|
export type WeirdParams = {
|
|
577
894
|
id: string
|
|
578
895
|
[Symbol.iterator]?: () => Iterator<string>
|
|
579
896
|
}
|
|
580
897
|
`);
|
|
581
|
-
|
|
898
|
+
writeFileSync((0, import_node_path.join)(testDir, "item/mutations.ts"), `
|
|
582
899
|
import { mutations } from 'on-zero'
|
|
583
900
|
import type { WeirdParams } from './types'
|
|
584
901
|
|
|
@@ -598,14 +915,14 @@ export const mutate = mutations({
|
|
|
598
915
|
(0, import_vitest.expect)(content).not.toContain("__@iterator");
|
|
599
916
|
});
|
|
600
917
|
(0, import_vitest.test)("resolves imported types in query params", async () => {
|
|
601
|
-
|
|
602
|
-
|
|
918
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/mutations.ts"), `export const schema = table('post', { id: string() })`);
|
|
919
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/types.ts"), `
|
|
603
920
|
export type PostFilter = {
|
|
604
921
|
authorId: string
|
|
605
922
|
published: boolean
|
|
606
923
|
}
|
|
607
924
|
`);
|
|
608
|
-
|
|
925
|
+
writeFileSync((0, import_node_path.join)(testDir, "post/queries.ts"), `
|
|
609
926
|
import type { PostFilter } from './types'
|
|
610
927
|
|
|
611
928
|
export const filteredPosts = (filter: PostFilter) => zero.query.post
|