on-zero 0.7.2 → 0.7.3-1784533014336
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/helpers/createMutators.cjs +4 -3
- package/dist/cjs/helpers/createMutators.native.js +6 -3
- package/dist/cjs/helpers/createMutators.native.js.map +1 -1
- package/dist/cjs/index.cjs +0 -1
- package/dist/cjs/index.native.js +0 -1
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/orez.cjs +231 -0
- package/dist/cjs/orez.native.js +324 -0
- package/dist/cjs/orez.native.js.map +1 -0
- package/dist/cjs/orez.test.cjs +268 -0
- package/dist/cjs/orez.test.native.js +288 -0
- package/dist/cjs/orez.test.native.js.map +1 -0
- package/dist/cjs/run.cjs +1 -1
- package/dist/cjs/run.native.js +1 -1
- package/dist/cjs/state.cjs +1 -1
- package/dist/cjs/state.native.js +1 -1
- package/dist/cjs/zeroRunner.cjs +1 -1
- package/dist/cjs/zeroRunner.native.js +1 -1
- package/dist/esm/cli.native.js +1 -1
- package/dist/esm/cli.native.js.map +1 -1
- package/dist/esm/combineZeroClients.native.js +2 -2
- package/dist/esm/combineZeroClients.native.js.map +1 -1
- package/dist/esm/createPermissions.native.js +4 -4
- package/dist/esm/createPermissions.native.js.map +1 -1
- package/dist/esm/createSchemaFromDrizzle.native.js +1 -1
- package/dist/esm/createSchemaFromDrizzle.native.js.map +1 -1
- package/dist/esm/createUseQuery.native.js +2 -2
- package/dist/esm/createUseQuery.native.js.map +1 -1
- package/dist/esm/createUseQueryDirect.native.js +2 -2
- package/dist/esm/createUseQueryDirect.native.js.map +1 -1
- package/dist/esm/createZeroClient.authData.test.native.js +2 -2
- package/dist/esm/createZeroClient.authData.test.native.js.map +1 -1
- package/dist/esm/createZeroClient.connection.test.native.js +1 -1
- package/dist/esm/createZeroClient.connection.test.native.js.map +1 -1
- package/dist/esm/createZeroClient.native.js +15 -15
- package/dist/esm/createZeroClient.native.js.map +1 -1
- package/dist/esm/createZeroClient.recovery.test.native.js +1 -1
- package/dist/esm/createZeroClient.recovery.test.native.js.map +1 -1
- package/dist/esm/generate-helpers.native.js.map +1 -1
- package/dist/esm/generate-lite.native.js +1 -1
- package/dist/esm/generate-lite.native.js.map +1 -1
- package/dist/esm/generate-lite.test.native.js +1 -1
- package/dist/esm/generate-lite.test.native.js.map +1 -1
- package/dist/esm/generate.native.js +1 -1
- package/dist/esm/generate.native.js.map +1 -1
- package/dist/esm/generate.test.native.js +1 -1
- package/dist/esm/generate.test.native.js.map +1 -1
- package/dist/esm/helpers/batchQuery.native.js.map +1 -1
- package/dist/esm/helpers/clearZeroClientData.native.js.map +1 -1
- package/dist/esm/helpers/createMutators.mjs +4 -3
- package/dist/esm/helpers/createMutators.mjs.map +1 -1
- package/dist/esm/helpers/createMutators.native.js +8 -5
- package/dist/esm/helpers/createMutators.native.js.map +1 -1
- package/dist/esm/helpers/createMutators.test.native.js +1 -1
- package/dist/esm/helpers/createMutators.test.native.js.map +1 -1
- package/dist/esm/helpers/ensureLoggedIn.native.js +1 -1
- package/dist/esm/helpers/ensureLoggedIn.native.js.map +1 -1
- package/dist/esm/helpers/getAuth.native.js +3 -3
- package/dist/esm/helpers/getAuth.native.js.map +1 -1
- package/dist/esm/helpers/mutatorContext.native.js.map +1 -1
- package/dist/esm/helpers/prettyFormatZeroQuery.native.js.map +1 -1
- package/dist/esm/helpers/queryContext.native.js.map +1 -1
- package/dist/esm/helpers/recoverZeroClient.native.js.map +1 -1
- package/dist/esm/helpers/recoverZeroClient.test.native.js +1 -1
- package/dist/esm/helpers/recoverZeroClient.test.native.js.map +1 -1
- package/dist/esm/helpers/showZeroClientError.native.js +1 -1
- package/dist/esm/helpers/showZeroClientError.native.js.map +1 -1
- 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.native.js +1 -1
- package/dist/esm/helpers/useZeroDebug.native.js.map +1 -1
- package/dist/esm/httpPull/fixtureSchema.native.js.map +1 -1
- package/dist/esm/httpPull/transport.test.native.js +3 -3
- package/dist/esm/httpPull/transport.test.native.js.map +1 -1
- package/dist/esm/httpPullTransport.native.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +0 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +22 -23
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/instanceRegistry.native.js +1 -1
- package/dist/esm/instanceRegistry.native.js.map +1 -1
- package/dist/esm/modelRegistry.native.js.map +1 -1
- package/dist/esm/multi.native.js +3 -3
- package/dist/esm/multi.native.js.map +1 -1
- package/dist/esm/multiInstance.test.native.js +8 -8
- package/dist/esm/multiInstance.test.native.js.map +1 -1
- package/dist/esm/multiInstanceNested.test.native.js +3 -3
- package/dist/esm/multiInstanceNested.test.native.js.map +1 -1
- package/dist/esm/multiPartition.test.native.js +1 -1
- package/dist/esm/multiPartition.test.native.js.map +1 -1
- package/dist/esm/mutations.native.js +1 -1
- package/dist/esm/mutations.native.js.map +1 -1
- package/dist/esm/mutations.test.native.js +2 -2
- package/dist/esm/mutations.test.native.js.map +1 -1
- package/dist/esm/orez.mjs +205 -0
- package/dist/esm/orez.mjs.map +1 -0
- package/dist/esm/orez.native.js +295 -0
- package/dist/esm/orez.native.js.map +1 -0
- package/dist/esm/orez.test.mjs +245 -0
- package/dist/esm/orez.test.mjs.map +1 -0
- package/dist/esm/orez.test.native.js +262 -0
- package/dist/esm/orez.test.native.js.map +1 -0
- package/dist/esm/provideZero.hydration.test.native.js +1 -1
- package/dist/esm/provideZero.hydration.test.native.js.map +1 -1
- package/dist/esm/queryRegistry.native.js.map +1 -1
- package/dist/esm/resolveQuery.native.js +1 -1
- package/dist/esm/resolveQuery.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 +5 -5
- package/dist/esm/run.native.js.map +1 -1
- package/dist/esm/serverWhere.native.js +1 -1
- package/dist/esm/serverWhere.native.js.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.native.js +1 -1
- package/dist/esm/state.native.js.map +1 -1
- package/dist/esm/testSetup.native.js.map +1 -1
- package/dist/esm/types.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.native.js +2 -2
- 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.native.js +1 -1
- package/dist/esm/vite-plugin.native.js.map +1 -1
- package/dist/esm/where.native.js +2 -2
- package/dist/esm/where.native.js.map +1 -1
- package/dist/esm/zeroRunner.mjs +1 -1
- package/dist/esm/zeroRunner.mjs.map +1 -1
- package/dist/esm/zeroRunner.native.js +2 -2
- package/dist/esm/zeroRunner.native.js.map +1 -1
- package/dist/esm/zql.native.js +1 -1
- package/dist/esm/zql.native.js.map +1 -1
- package/package.json +7 -23
- package/readme.md +40 -65
- package/src/createZeroClient.tsx +1 -1
- package/src/helpers/createMutators.ts +6 -2
- package/src/index.ts +0 -1
- package/src/orez.test.ts +266 -0
- package/src/orez.ts +344 -0
- package/src/run.ts +1 -1
- package/src/state.ts +1 -1
- package/src/types.ts +0 -5
- package/src/zeroRunner.ts +1 -1
- package/test-fixtures/server-return-types.ts +21 -58
- package/types/helpers/createMutators.d.ts +2 -1
- package/types/helpers/createMutators.d.ts.map +1 -1
- package/types/httpPull/fixtureSchema.d.ts +1 -1
- package/types/index.d.ts +0 -1
- package/types/index.d.ts.map +1 -1
- package/types/orez.d.ts +54 -0
- package/types/orez.d.ts.map +1 -0
- package/types/orez.test.d.ts +2 -0
- package/types/orez.test.d.ts.map +1 -0
- package/types/types.d.ts +0 -4
- package/types/types.d.ts.map +1 -1
- package/dist/cjs/asyncTasks.cjs +0 -51
- package/dist/cjs/asyncTasks.native.js +0 -84
- package/dist/cjs/asyncTasks.native.js.map +0 -1
- package/dist/cjs/createZeroDirectServer.cjs +0 -269
- package/dist/cjs/createZeroDirectServer.native.js +0 -287
- package/dist/cjs/createZeroDirectServer.native.js.map +0 -1
- package/dist/cjs/createZeroSQLiteServer.cjs +0 -50
- package/dist/cjs/createZeroSQLiteServer.native.js +0 -58
- package/dist/cjs/createZeroSQLiteServer.native.js.map +0 -1
- package/dist/cjs/createZeroSQLiteServer.test.cjs +0 -595
- package/dist/cjs/createZeroSQLiteServer.test.native.js +0 -647
- package/dist/cjs/createZeroSQLiteServer.test.native.js.map +0 -1
- package/dist/cjs/createZeroServer.cjs +0 -82
- package/dist/cjs/createZeroServer.native.js +0 -93
- package/dist/cjs/createZeroServer.native.js.map +0 -1
- package/dist/cjs/createZeroServer.test.cjs +0 -378
- package/dist/cjs/createZeroServer.test.native.js +0 -448
- package/dist/cjs/createZeroServer.test.native.js.map +0 -1
- package/dist/cjs/createZeroServerCore.cjs +0 -211
- package/dist/cjs/createZeroServerCore.native.js +0 -355
- package/dist/cjs/createZeroServerCore.native.js.map +0 -1
- package/dist/cjs/httpPull/auth.test.cjs +0 -197
- package/dist/cjs/httpPull/auth.test.native.js +0 -279
- package/dist/cjs/httpPull/auth.test.native.js.map +0 -1
- package/dist/cjs/httpPull/churn.test.cjs +0 -132
- package/dist/cjs/httpPull/churn.test.native.js +0 -155
- package/dist/cjs/httpPull/churn.test.native.js.map +0 -1
- package/dist/cjs/httpPull/completeAck.test.cjs +0 -69
- package/dist/cjs/httpPull/completeAck.test.native.js +0 -76
- package/dist/cjs/httpPull/completeAck.test.native.js.map +0 -1
- package/dist/cjs/httpPull/fixtureServer.cjs +0 -340
- package/dist/cjs/httpPull/fixtureServer.native.js +0 -534
- package/dist/cjs/httpPull/fixtureServer.native.js.map +0 -1
- package/dist/cjs/httpPull/integration.test.cjs +0 -53
- package/dist/cjs/httpPull/integration.test.native.js +0 -60
- package/dist/cjs/httpPull/integration.test.native.js.map +0 -1
- package/dist/cjs/httpPull/rebase.test.cjs +0 -360
- package/dist/cjs/httpPull/rebase.test.native.js +0 -420
- package/dist/cjs/httpPull/rebase.test.native.js.map +0 -1
- package/dist/cjs/httpPull/relations.test.cjs +0 -107
- package/dist/cjs/httpPull/relations.test.native.js +0 -119
- package/dist/cjs/httpPull/relations.test.native.js.map +0 -1
- package/dist/cjs/httpPull/testHarness.cjs +0 -100
- package/dist/cjs/httpPull/testHarness.native.js +0 -112
- package/dist/cjs/httpPull/testHarness.native.js.map +0 -1
- package/dist/cjs/server.cjs +0 -22
- package/dist/cjs/server.native.js +0 -4
- package/dist/cjs/server.native.js.map +0 -1
- package/dist/cjs/sqliteRuntime.cjs +0 -318
- package/dist/cjs/sqliteRuntime.native.js +0 -438
- package/dist/cjs/sqliteRuntime.native.js.map +0 -1
- package/dist/cjs/syncHost.cjs +0 -179
- package/dist/cjs/syncHost.native.js +0 -388
- package/dist/cjs/syncHost.native.js.map +0 -1
- package/dist/cjs/syncHost.test.cjs +0 -240
- package/dist/cjs/syncHost.test.native.js +0 -290
- package/dist/cjs/syncHost.test.native.js.map +0 -1
- package/dist/esm/asyncTasks.mjs +0 -26
- package/dist/esm/asyncTasks.mjs.map +0 -1
- package/dist/esm/asyncTasks.native.js +0 -56
- package/dist/esm/asyncTasks.native.js.map +0 -1
- package/dist/esm/createZeroDirectServer.mjs +0 -241
- package/dist/esm/createZeroDirectServer.mjs.map +0 -1
- package/dist/esm/createZeroDirectServer.native.js +0 -256
- package/dist/esm/createZeroDirectServer.native.js.map +0 -1
- package/dist/esm/createZeroSQLiteServer.mjs +0 -24
- package/dist/esm/createZeroSQLiteServer.mjs.map +0 -1
- package/dist/esm/createZeroSQLiteServer.native.js +0 -29
- package/dist/esm/createZeroSQLiteServer.native.js.map +0 -1
- package/dist/esm/createZeroSQLiteServer.test.mjs +0 -596
- package/dist/esm/createZeroSQLiteServer.test.mjs.map +0 -1
- package/dist/esm/createZeroSQLiteServer.test.native.js +0 -645
- package/dist/esm/createZeroSQLiteServer.test.native.js.map +0 -1
- package/dist/esm/createZeroServer.mjs +0 -57
- package/dist/esm/createZeroServer.mjs.map +0 -1
- package/dist/esm/createZeroServer.native.js +0 -65
- package/dist/esm/createZeroServer.native.js.map +0 -1
- package/dist/esm/createZeroServer.test.mjs +0 -379
- package/dist/esm/createZeroServer.test.mjs.map +0 -1
- package/dist/esm/createZeroServer.test.native.js +0 -446
- package/dist/esm/createZeroServer.test.native.js.map +0 -1
- package/dist/esm/createZeroServerCore.mjs +0 -186
- package/dist/esm/createZeroServerCore.mjs.map +0 -1
- package/dist/esm/createZeroServerCore.native.js +0 -327
- package/dist/esm/createZeroServerCore.native.js.map +0 -1
- package/dist/esm/httpPull/auth.test.mjs +0 -198
- package/dist/esm/httpPull/auth.test.mjs.map +0 -1
- package/dist/esm/httpPull/auth.test.native.js +0 -277
- package/dist/esm/httpPull/auth.test.native.js.map +0 -1
- package/dist/esm/httpPull/churn.test.mjs +0 -133
- package/dist/esm/httpPull/churn.test.mjs.map +0 -1
- package/dist/esm/httpPull/churn.test.native.js +0 -153
- package/dist/esm/httpPull/churn.test.native.js.map +0 -1
- package/dist/esm/httpPull/completeAck.test.mjs +0 -70
- package/dist/esm/httpPull/completeAck.test.mjs.map +0 -1
- package/dist/esm/httpPull/completeAck.test.native.js +0 -74
- package/dist/esm/httpPull/completeAck.test.native.js.map +0 -1
- package/dist/esm/httpPull/fixtureServer.mjs +0 -315
- package/dist/esm/httpPull/fixtureServer.mjs.map +0 -1
- package/dist/esm/httpPull/fixtureServer.native.js +0 -506
- package/dist/esm/httpPull/fixtureServer.native.js.map +0 -1
- package/dist/esm/httpPull/integration.test.mjs +0 -54
- package/dist/esm/httpPull/integration.test.mjs.map +0 -1
- package/dist/esm/httpPull/integration.test.native.js +0 -58
- package/dist/esm/httpPull/integration.test.native.js.map +0 -1
- package/dist/esm/httpPull/rebase.test.mjs +0 -361
- package/dist/esm/httpPull/rebase.test.mjs.map +0 -1
- package/dist/esm/httpPull/rebase.test.native.js +0 -418
- package/dist/esm/httpPull/rebase.test.native.js.map +0 -1
- package/dist/esm/httpPull/relations.test.mjs +0 -108
- package/dist/esm/httpPull/relations.test.mjs.map +0 -1
- package/dist/esm/httpPull/relations.test.native.js +0 -117
- package/dist/esm/httpPull/relations.test.native.js.map +0 -1
- package/dist/esm/httpPull/testHarness.mjs +0 -72
- package/dist/esm/httpPull/testHarness.mjs.map +0 -1
- package/dist/esm/httpPull/testHarness.native.js +0 -81
- package/dist/esm/httpPull/testHarness.native.js.map +0 -1
- package/dist/esm/server.mjs +0 -4
- package/dist/esm/server.mjs.map +0 -1
- package/dist/esm/server.native.js +0 -2
- package/dist/esm/server.native.js.map +0 -1
- package/dist/esm/sqliteRuntime.mjs +0 -289
- package/dist/esm/sqliteRuntime.mjs.map +0 -1
- package/dist/esm/sqliteRuntime.native.js +0 -406
- package/dist/esm/sqliteRuntime.native.js.map +0 -1
- package/dist/esm/syncHost.mjs +0 -153
- package/dist/esm/syncHost.mjs.map +0 -1
- package/dist/esm/syncHost.native.js +0 -359
- package/dist/esm/syncHost.native.js.map +0 -1
- package/dist/esm/syncHost.test.mjs +0 -217
- package/dist/esm/syncHost.test.mjs.map +0 -1
- package/dist/esm/syncHost.test.native.js +0 -264
- package/dist/esm/syncHost.test.native.js.map +0 -1
- package/src/asyncTasks.ts +0 -36
- package/src/createZeroDirectServer.ts +0 -411
- package/src/createZeroSQLiteServer.test.ts +0 -614
- package/src/createZeroSQLiteServer.ts +0 -56
- package/src/createZeroServer.test.ts +0 -421
- package/src/createZeroServer.ts +0 -105
- package/src/createZeroServerCore.ts +0 -296
- package/src/httpPull/auth.test.ts +0 -208
- package/src/httpPull/churn.test.ts +0 -147
- package/src/httpPull/completeAck.test.ts +0 -80
- package/src/httpPull/fixtureServer.ts +0 -391
- package/src/httpPull/integration.test.ts +0 -57
- package/src/httpPull/rebase.test.ts +0 -368
- package/src/httpPull/relations.test.ts +0 -135
- package/src/httpPull/testHarness.ts +0 -95
- package/src/server.native.ts +0 -3
- package/src/server.ts +0 -4
- package/src/sqliteRuntime.ts +0 -512
- package/src/syncHost.test.ts +0 -223
- package/src/syncHost.ts +0 -294
- package/types/asyncTasks.d.ts +0 -11
- package/types/asyncTasks.d.ts.map +0 -1
- package/types/createZeroDirectServer.d.ts +0 -80
- package/types/createZeroDirectServer.d.ts.map +0 -1
- package/types/createZeroSQLiteServer.d.ts +0 -12
- package/types/createZeroSQLiteServer.d.ts.map +0 -1
- package/types/createZeroSQLiteServer.test.d.ts +0 -2
- package/types/createZeroSQLiteServer.test.d.ts.map +0 -1
- package/types/createZeroServer.d.ts +0 -18
- package/types/createZeroServer.d.ts.map +0 -1
- package/types/createZeroServer.test.d.ts +0 -2
- package/types/createZeroServer.test.d.ts.map +0 -1
- package/types/createZeroServerCore.d.ts +0 -256
- package/types/createZeroServerCore.d.ts.map +0 -1
- package/types/httpPull/auth.test.d.ts +0 -2
- package/types/httpPull/auth.test.d.ts.map +0 -1
- package/types/httpPull/churn.test.d.ts +0 -2
- package/types/httpPull/churn.test.d.ts.map +0 -1
- package/types/httpPull/completeAck.test.d.ts +0 -2
- package/types/httpPull/completeAck.test.d.ts.map +0 -1
- package/types/httpPull/fixtureServer.d.ts +0 -14
- package/types/httpPull/fixtureServer.d.ts.map +0 -1
- package/types/httpPull/integration.test.d.ts +0 -2
- package/types/httpPull/integration.test.d.ts.map +0 -1
- package/types/httpPull/rebase.test.d.ts +0 -2
- package/types/httpPull/rebase.test.d.ts.map +0 -1
- package/types/httpPull/relations.test.d.ts +0 -2
- package/types/httpPull/relations.test.d.ts.map +0 -1
- package/types/httpPull/testHarness.d.ts +0 -32
- package/types/httpPull/testHarness.d.ts.map +0 -1
- package/types/server.d.ts +0 -5
- package/types/server.d.ts.map +0 -1
- package/types/server.native.d.ts +0 -1
- package/types/server.native.d.ts.map +0 -1
- package/types/sqliteRuntime.d.ts +0 -71
- package/types/sqliteRuntime.d.ts.map +0 -1
- package/types/syncHost.d.ts +0 -42
- package/types/syncHost.d.ts.map +0 -1
- package/types/syncHost.test.d.ts +0 -2
- package/types/syncHost.test.d.ts.map +0 -1
|
@@ -1,388 +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 syncHost_exports = {};
|
|
26
|
-
__export(syncHost_exports, {
|
|
27
|
-
MutationApplicationError: () => MutationApplicationError,
|
|
28
|
-
createZeroSyncHostAdapter: () => createZeroSyncHostAdapter
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(syncHost_exports);
|
|
31
|
-
var import_bindings = require("@rocicorp/zero/bindings");
|
|
32
|
-
var import_zero = require("@rocicorp/zero");
|
|
33
|
-
var import_createPermissions = require("./createPermissions.native.js");
|
|
34
|
-
var import_createZeroDirectServer = require("./createZeroDirectServer.native.js");
|
|
35
|
-
var import_sqliteRuntime = require("./sqliteRuntime.native.js");
|
|
36
|
-
var import_createMutators = require("./helpers/createMutators.native.js");
|
|
37
|
-
var import_mutatorContext = require("./helpers/mutatorContext.native.js");
|
|
38
|
-
var import_queryContext = require("./helpers/queryContext.native.js");
|
|
39
|
-
var import_state = require("./state.native.js");
|
|
40
|
-
function _assert_this_initialized(self) {
|
|
41
|
-
if (self === void 0) {
|
|
42
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
43
|
-
}
|
|
44
|
-
return self;
|
|
45
|
-
}
|
|
46
|
-
function _call_super(_this, derived, args) {
|
|
47
|
-
derived = _get_prototype_of(derived);
|
|
48
|
-
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
49
|
-
}
|
|
50
|
-
function _class_call_check(instance, Constructor) {
|
|
51
|
-
if (!(instance instanceof Constructor)) {
|
|
52
|
-
throw new TypeError("Cannot call a class as a function");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function _construct(Parent, args, Class) {
|
|
56
|
-
if (_is_native_reflect_construct()) {
|
|
57
|
-
_construct = Reflect.construct;
|
|
58
|
-
} else {
|
|
59
|
-
_construct = function construct(Parent2, args2, Class2) {
|
|
60
|
-
var a = [null];
|
|
61
|
-
a.push.apply(a, args2);
|
|
62
|
-
var Constructor = Function.bind.apply(Parent2, a);
|
|
63
|
-
var instance = new Constructor();
|
|
64
|
-
if (Class2) _set_prototype_of(instance, Class2.prototype);
|
|
65
|
-
return instance;
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
return _construct.apply(null, arguments);
|
|
69
|
-
}
|
|
70
|
-
function _define_property(obj, key, value) {
|
|
71
|
-
if (key in obj) {
|
|
72
|
-
Object.defineProperty(obj, key, {
|
|
73
|
-
value,
|
|
74
|
-
enumerable: true,
|
|
75
|
-
configurable: true,
|
|
76
|
-
writable: true
|
|
77
|
-
});
|
|
78
|
-
} else {
|
|
79
|
-
obj[key] = value;
|
|
80
|
-
}
|
|
81
|
-
return obj;
|
|
82
|
-
}
|
|
83
|
-
function _get_prototype_of(o) {
|
|
84
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {
|
|
85
|
-
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
86
|
-
};
|
|
87
|
-
return _get_prototype_of(o);
|
|
88
|
-
}
|
|
89
|
-
function _inherits(subClass, superClass) {
|
|
90
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
91
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
92
|
-
}
|
|
93
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
94
|
-
constructor: {
|
|
95
|
-
value: subClass,
|
|
96
|
-
writable: true,
|
|
97
|
-
configurable: true
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
if (superClass) _set_prototype_of(subClass, superClass);
|
|
101
|
-
}
|
|
102
|
-
function _instanceof(left, right) {
|
|
103
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
104
|
-
return !!right[Symbol.hasInstance](left);
|
|
105
|
-
} else {
|
|
106
|
-
return left instanceof right;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function _is_native_function(fn) {
|
|
110
|
-
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
111
|
-
}
|
|
112
|
-
function _possible_constructor_return(self, call) {
|
|
113
|
-
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
114
|
-
return call;
|
|
115
|
-
}
|
|
116
|
-
return _assert_this_initialized(self);
|
|
117
|
-
}
|
|
118
|
-
function _set_prototype_of(o, p) {
|
|
119
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {
|
|
120
|
-
o2.__proto__ = p2;
|
|
121
|
-
return o2;
|
|
122
|
-
};
|
|
123
|
-
return _set_prototype_of(o, p);
|
|
124
|
-
}
|
|
125
|
-
function _type_of(obj) {
|
|
126
|
-
"@swc/helpers - typeof";
|
|
127
|
-
|
|
128
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
129
|
-
}
|
|
130
|
-
function _wrap_native_super(Class) {
|
|
131
|
-
var _cache = typeof Map === "function" ? /* @__PURE__ */new Map() : void 0;
|
|
132
|
-
_wrap_native_super = function wrapNativeSuper(Class2) {
|
|
133
|
-
if (Class2 === null || !_is_native_function(Class2)) return Class2;
|
|
134
|
-
if (typeof Class2 !== "function") {
|
|
135
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
136
|
-
}
|
|
137
|
-
if (typeof _cache !== "undefined") {
|
|
138
|
-
if (_cache.has(Class2)) return _cache.get(Class2);
|
|
139
|
-
_cache.set(Class2, Wrapper);
|
|
140
|
-
}
|
|
141
|
-
function Wrapper() {
|
|
142
|
-
return _construct(Class2, arguments, _get_prototype_of(this).constructor);
|
|
143
|
-
}
|
|
144
|
-
Wrapper.prototype = Object.create(Class2.prototype, {
|
|
145
|
-
constructor: {
|
|
146
|
-
value: Wrapper,
|
|
147
|
-
enumerable: false,
|
|
148
|
-
writable: true,
|
|
149
|
-
configurable: true
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
return _set_prototype_of(Wrapper, Class2);
|
|
153
|
-
};
|
|
154
|
-
return _wrap_native_super(Class);
|
|
155
|
-
}
|
|
156
|
-
function _is_native_reflect_construct() {
|
|
157
|
-
try {
|
|
158
|
-
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
159
|
-
} catch (_) {}
|
|
160
|
-
return (_is_native_reflect_construct = function () {
|
|
161
|
-
return !!result;
|
|
162
|
-
})();
|
|
163
|
-
}
|
|
164
|
-
var MutationApplicationError = /* @__PURE__ */function (Error1) {
|
|
165
|
-
"use strict";
|
|
166
|
-
|
|
167
|
-
_inherits(MutationApplicationError2, Error1);
|
|
168
|
-
function MutationApplicationError2(details) {
|
|
169
|
-
var message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : details;
|
|
170
|
-
_class_call_check(this, MutationApplicationError2);
|
|
171
|
-
var _this;
|
|
172
|
-
_this = _call_super(this, MutationApplicationError2, [message]), _define_property(_this, "details", void 0), _this.details = details;
|
|
173
|
-
_this.name = "MutationApplicationError";
|
|
174
|
-
return _this;
|
|
175
|
-
}
|
|
176
|
-
return MutationApplicationError2;
|
|
177
|
-
}(_wrap_native_super(Error));
|
|
178
|
-
function createZeroSyncHostAdapter(param) {
|
|
179
|
-
var {
|
|
180
|
-
encodeValue,
|
|
181
|
-
mapAuthData = defaultMapAuthData,
|
|
182
|
-
transaction,
|
|
183
|
-
...options
|
|
184
|
-
} = param;
|
|
185
|
-
(0, import_state.setSchema)(options.schema, (0, import_zero.createBuilder)(options.schema));
|
|
186
|
-
(0, import_state.setEnvironment)("server");
|
|
187
|
-
var _options_defaultAllowAdminRole;
|
|
188
|
-
var permissions = (0, import_createPermissions.createPermissions)({
|
|
189
|
-
environment: "server",
|
|
190
|
-
schema: options.schema,
|
|
191
|
-
adminRoleMode: (_options_defaultAllowAdminRole = options.defaultAllowAdminRole) !== null && _options_defaultAllowAdminRole !== void 0 ? _options_defaultAllowAdminRole : "all"
|
|
192
|
-
});
|
|
193
|
-
var transactionOptions = {
|
|
194
|
-
encodeValue,
|
|
195
|
-
schema: options.schema
|
|
196
|
-
};
|
|
197
|
-
var mutators = {};
|
|
198
|
-
var _iteratorNormalCompletion = true,
|
|
199
|
-
_didIteratorError = false,
|
|
200
|
-
_iteratorError = void 0;
|
|
201
|
-
try {
|
|
202
|
-
var _loop = function () {
|
|
203
|
-
var [modelName, model] = _step.value;
|
|
204
|
-
var _model_mutate;
|
|
205
|
-
var _iteratorNormalCompletion2 = true,
|
|
206
|
-
_didIteratorError2 = false,
|
|
207
|
-
_iteratorError2 = void 0;
|
|
208
|
-
try {
|
|
209
|
-
var _loop2 = function () {
|
|
210
|
-
var mutatorName = _step1.value;
|
|
211
|
-
mutators[`${modelName}|${mutatorName}`] = async function (executor, args, context) {
|
|
212
|
-
var _modelMutators_modelName;
|
|
213
|
-
var authData = mapAuthData(context.claims);
|
|
214
|
-
var asyncTaskEntries = [];
|
|
215
|
-
var modelMutators = (0, import_createMutators.createMutators)({
|
|
216
|
-
enqueueTask(task, opts) {
|
|
217
|
-
asyncTaskEntries.push({
|
|
218
|
-
task,
|
|
219
|
-
barrier: (opts === null || opts === void 0 ? void 0 : opts.barrier) === true
|
|
220
|
-
});
|
|
221
|
-
},
|
|
222
|
-
authData,
|
|
223
|
-
can: permissions.can,
|
|
224
|
-
createServerActions: options.createServerActions,
|
|
225
|
-
environment: "server",
|
|
226
|
-
models: options.models,
|
|
227
|
-
mutationValidators: options.mutations,
|
|
228
|
-
validateMutation: options.validateMutation
|
|
229
|
-
});
|
|
230
|
-
var mutation = (_modelMutators_modelName = modelMutators[modelName]) === null || _modelMutators_modelName === void 0 ? void 0 : _modelMutators_modelName[mutatorName];
|
|
231
|
-
if (!mutation) throw new Error(`unknown on-zero mutator: ${modelName}|${mutatorName}`);
|
|
232
|
-
var mutationID = numericMutationID(context.mutationID);
|
|
233
|
-
var _context_clientID;
|
|
234
|
-
var onZeroTransaction = (0, import_sqliteRuntime.createZeroSQLiteTransaction)(transactionOptions, toSQLiteExecutor(executor), {
|
|
235
|
-
clientGroupID: "orez-sync-host",
|
|
236
|
-
clientID: (_context_clientID = context.clientID) !== null && _context_clientID !== void 0 ? _context_clientID : "",
|
|
237
|
-
mutationID,
|
|
238
|
-
upstreamSchema: "orez-sync-host"
|
|
239
|
-
});
|
|
240
|
-
try {
|
|
241
|
-
await mutation(onZeroTransaction, args);
|
|
242
|
-
} catch (error) {
|
|
243
|
-
throw asMutationApplicationError(error);
|
|
244
|
-
}
|
|
245
|
-
var _iteratorNormalCompletion3 = true,
|
|
246
|
-
_didIteratorError3 = false,
|
|
247
|
-
_iteratorError3 = void 0;
|
|
248
|
-
try {
|
|
249
|
-
var _loop3 = function () {
|
|
250
|
-
var {
|
|
251
|
-
task
|
|
252
|
-
} = _step2.value;
|
|
253
|
-
context.defer(function () {
|
|
254
|
-
return (0, import_mutatorContext.runWithAuthScope)(authData, task);
|
|
255
|
-
});
|
|
256
|
-
};
|
|
257
|
-
for (var _iterator3 = asyncTaskEntries[Symbol.iterator](), _step2; !(_iteratorNormalCompletion3 = (_step2 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) _loop3();
|
|
258
|
-
} catch (err) {
|
|
259
|
-
_didIteratorError3 = true;
|
|
260
|
-
_iteratorError3 = err;
|
|
261
|
-
} finally {
|
|
262
|
-
try {
|
|
263
|
-
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
264
|
-
_iterator3.return();
|
|
265
|
-
}
|
|
266
|
-
} finally {
|
|
267
|
-
if (_didIteratorError3) {
|
|
268
|
-
throw _iteratorError3;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
};
|
|
274
|
-
for (var _iterator2 = Object.keys((_model_mutate = model.mutate) !== null && _model_mutate !== void 0 ? _model_mutate : {})[Symbol.iterator](), _step1; !(_iteratorNormalCompletion2 = (_step1 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) _loop2();
|
|
275
|
-
} catch (err) {
|
|
276
|
-
_didIteratorError2 = true;
|
|
277
|
-
_iteratorError2 = err;
|
|
278
|
-
} finally {
|
|
279
|
-
try {
|
|
280
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
281
|
-
_iterator2.return();
|
|
282
|
-
}
|
|
283
|
-
} finally {
|
|
284
|
-
if (_didIteratorError2) {
|
|
285
|
-
throw _iteratorError2;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
for (var _iterator = Object.entries(options.models)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();
|
|
291
|
-
} catch (err) {
|
|
292
|
-
_didIteratorError = true;
|
|
293
|
-
_iteratorError = err;
|
|
294
|
-
} finally {
|
|
295
|
-
try {
|
|
296
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
297
|
-
_iterator.return();
|
|
298
|
-
}
|
|
299
|
-
} finally {
|
|
300
|
-
if (_didIteratorError) {
|
|
301
|
-
throw _iteratorError;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
mutators._zero_cleanupResults = async function () {};
|
|
306
|
-
var transactionProvider = function (work) {
|
|
307
|
-
return transaction(function (executor) {
|
|
308
|
-
return work(toSQLiteExecutor(executor));
|
|
309
|
-
});
|
|
310
|
-
};
|
|
311
|
-
var directDatabaseOptions = {
|
|
312
|
-
encodeValue: encodeValue !== null && encodeValue !== void 0 ? encodeValue : import_sqliteRuntime.encodeSQLiteValue,
|
|
313
|
-
initializedLedgers: /* @__PURE__ */new Set(),
|
|
314
|
-
ledgerTables: import_sqliteRuntime.defaultLedgerTables,
|
|
315
|
-
schema: options.schema,
|
|
316
|
-
transactionProvider
|
|
317
|
-
};
|
|
318
|
-
var direct = (0, import_createZeroDirectServer.createZeroDirectServer)({
|
|
319
|
-
...options,
|
|
320
|
-
createDatabase: function () {
|
|
321
|
-
return (0, import_sqliteRuntime.createSQLiteDatabase)(directDatabaseOptions);
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
return {
|
|
325
|
-
mutators: Object.freeze(mutators),
|
|
326
|
-
async resolveQuery(name, args, claims) {
|
|
327
|
-
if (!options.queries) {
|
|
328
|
-
throw new Error("No queries registered with createZeroSyncHostAdapter. Pass the syncedQueries registry via the queries option.");
|
|
329
|
-
}
|
|
330
|
-
var authData = mapAuthData(claims);
|
|
331
|
-
var query = await (0, import_queryContext.runWithQueryContext)({
|
|
332
|
-
authData
|
|
333
|
-
}, function () {
|
|
334
|
-
return (0, import_createZeroDirectServer.resolveServerQuery)({
|
|
335
|
-
authData,
|
|
336
|
-
args: args[0],
|
|
337
|
-
name,
|
|
338
|
-
permissions,
|
|
339
|
-
queries: options.queries,
|
|
340
|
-
validateQuery: options.validateQuery
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
return (0, import_bindings.asQueryInternals)(query).ast;
|
|
344
|
-
},
|
|
345
|
-
server: {
|
|
346
|
-
mutate: direct.mutate,
|
|
347
|
-
query: direct.query,
|
|
348
|
-
transaction: direct.transaction
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
function defaultMapAuthData(claims) {
|
|
353
|
-
return {
|
|
354
|
-
...claims,
|
|
355
|
-
id: typeof claims.id === "string" ? claims.id : claims.userID
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
function toSQLiteExecutor(executor) {
|
|
359
|
-
return {
|
|
360
|
-
exec(sql, params, metadata) {
|
|
361
|
-
return executor.exec(sql, params, metadata);
|
|
362
|
-
},
|
|
363
|
-
query(sql, params) {
|
|
364
|
-
return executor.query(sql, params);
|
|
365
|
-
},
|
|
366
|
-
queryAst(ast, format, queryName) {
|
|
367
|
-
return executor.queryAst(ast, format, queryName);
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
function numericMutationID(value) {
|
|
372
|
-
if (value === void 0) return 0;
|
|
373
|
-
var numeric = typeof value === "number" ? value : Number(value);
|
|
374
|
-
if (!Number.isSafeInteger(numeric) || numeric < 0) {
|
|
375
|
-
throw new TypeError(`invalid Zero mutation ID: ${value}`);
|
|
376
|
-
}
|
|
377
|
-
return numeric;
|
|
378
|
-
}
|
|
379
|
-
function asMutationApplicationError(error) {
|
|
380
|
-
if ((typeof error === "undefined" ? "undefined" : _type_of(error)) === "object" && error !== null && error.name === "MutationApplicationError" && typeof error.details === "string") {
|
|
381
|
-
return error;
|
|
382
|
-
}
|
|
383
|
-
var message = _instanceof(error, Error) ? error.message : String(error);
|
|
384
|
-
var applicationError = new MutationApplicationError(message);
|
|
385
|
-
if (_instanceof(error, Error) && error.stack) applicationError.stack = error.stack;
|
|
386
|
-
return applicationError;
|
|
387
|
-
}
|
|
388
|
-
//# sourceMappingURL=syncHost.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","syncHost_exports","__export","MutationApplicationError","createZeroSyncHostAdapter","module","exports","import_bindings","require","import_zero","import_createPermissions","import_createZeroDirectServer","import_sqliteRuntime","import_createMutators","import_mutatorContext","import_queryContext","import_state","_assert_this_initialized","self","ReferenceError","_call_super","_this","derived","args","_get_prototype_of","_possible_constructor_return","_is_native_reflect_construct","Reflect","construct","constructor","apply","_class_call_check","instance","Constructor","TypeError","_construct","Parent","Class","Parent2","args2","Class2","a","push","Function","bind","_set_prototype_of","prototype","arguments","_define_property","obj","key","Object","defineProperty","enumerable","configurable","writable","o","setPrototypeOf","getPrototypeOf","o2","__proto__","_inherits","subClass","superClass","create","_instanceof","left","right","Symbol","hasInstance","_is_native_function","fn","toString","call","indexOf","_type_of","p","p2","_wrap_native_super","_cache","Map","wrapNativeSuper","has","get","set","Wrapper","result","Boolean","valueOf","_","Error1","MutationApplicationError2","details","message","length","name","Error","param","encodeValue","mapAuthData","defaultMapAuthData","transaction","options","setSchema","schema","createBuilder","setEnvironment","_options_defaultAllowAdminRole","permissions","createPermissions","environment"],"sources":["../../src/syncHost.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,gBAAA;AAAAC,QAAA,CAAAD,gBAAA;EAAAE,wBAAA,EAAAA,CAAA,KAAAA,wBAAA;EAAAC,yBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAA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AAAC,kBAAA;IAAAC,WAAA;IAAA,GAAAC;EAAA,IAAAL,KAAA;EACA,IAAAjF,YAAgB,CAAAuF,SAAA,EAAAD,OAAiB,CAAAE,MAAQ,MAAM/F,WAAU,CAAAgG,aAAY,EAAAH,OAAA,CAAAE,MAAA;EACrE,IAAAxF,YAAM,CAAA0F,cAAuB;EAC7B,IAAIC,8BAA0B;EAC9B,IAAAC,WAAO,OAAAlG,wBAAA,CAAAmG,iBAAA;IACTC,WAAA","ignoreList":[]}
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
-
get: () => from[key],
|
|
11
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
-
value: mod,
|
|
23
|
-
enumerable: true
|
|
24
|
-
}) : target, mod));
|
|
25
|
-
var import_node_sqlite = require("node:sqlite");
|
|
26
|
-
var import_zero = require("@rocicorp/zero");
|
|
27
|
-
var v = __toESM(require("valibot"), 1);
|
|
28
|
-
var import_vitest = require("vitest");
|
|
29
|
-
var import_mutatorContext = require("./helpers/mutatorContext.cjs");
|
|
30
|
-
var import_fixtureSchema = require("./httpPull/fixtureSchema.cjs");
|
|
31
|
-
var import_syncHost = require("./syncHost.cjs");
|
|
32
|
-
var import_zql = require("./zql.cjs");
|
|
33
|
-
const queries = (0, import_zero.defineQueries)({
|
|
34
|
-
project: {
|
|
35
|
-
byOwner: (0, import_zero.defineQuery)(v.object({
|
|
36
|
-
ownerId: v.string()
|
|
37
|
-
}), ({
|
|
38
|
-
args
|
|
39
|
-
}) => import_zql.zql.project.where("ownerId", args.ownerId))
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
(0, import_vitest.describe)("createZeroSyncHostAdapter", () => {
|
|
43
|
-
let db;
|
|
44
|
-
let executor;
|
|
45
|
-
let transaction;
|
|
46
|
-
let lastQueryFormat;
|
|
47
|
-
let statements;
|
|
48
|
-
(0, import_vitest.beforeEach)(() => {
|
|
49
|
-
db = new import_node_sqlite.DatabaseSync(":memory:");
|
|
50
|
-
db.exec("CREATE TABLE project (id TEXT PRIMARY KEY, ownerId TEXT NOT NULL, name TEXT NOT NULL)");
|
|
51
|
-
statements = [];
|
|
52
|
-
executor = {
|
|
53
|
-
exec(sql, params = [], metadata) {
|
|
54
|
-
if (metadata) statements.push(metadata);
|
|
55
|
-
const result = db.prepare(sql).run(...params);
|
|
56
|
-
return {
|
|
57
|
-
changes: Number(result.changes)
|
|
58
|
-
};
|
|
59
|
-
},
|
|
60
|
-
query(sql, params = []) {
|
|
61
|
-
return db.prepare(sql).all(...params);
|
|
62
|
-
},
|
|
63
|
-
queryAst(_ast, format) {
|
|
64
|
-
lastQueryFormat = format;
|
|
65
|
-
const rows = db.prepare("SELECT * FROM project ORDER BY id").all();
|
|
66
|
-
return format.singular ? rows[0] : rows;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
transaction = async work => {
|
|
70
|
-
const effects = [];
|
|
71
|
-
db.exec("BEGIN");
|
|
72
|
-
try {
|
|
73
|
-
const value = await work(executor, {
|
|
74
|
-
defer(effect) {
|
|
75
|
-
effects.push(effect);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
db.exec("COMMIT");
|
|
79
|
-
for (const effect of effects) await effect();
|
|
80
|
-
return value;
|
|
81
|
-
} catch (error) {
|
|
82
|
-
db.exec("ROLLBACK");
|
|
83
|
-
throw error;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
});
|
|
87
|
-
(0, import_vitest.afterEach)(() => {
|
|
88
|
-
db.close();
|
|
89
|
-
});
|
|
90
|
-
(0, import_vitest.test)("adapts pipe-named mutators, auth, validation, and deferred effects", async () => {
|
|
91
|
-
let effectAuthID;
|
|
92
|
-
let validatedAuthID;
|
|
93
|
-
const adapter = (0, import_syncHost.createZeroSyncHostAdapter)({
|
|
94
|
-
schema: import_fixtureSchema.zeroHttpFixtureSchema,
|
|
95
|
-
models: {
|
|
96
|
-
project: {
|
|
97
|
-
mutate: {
|
|
98
|
-
create: async ({
|
|
99
|
-
authData,
|
|
100
|
-
server,
|
|
101
|
-
tx
|
|
102
|
-
}, value) => {
|
|
103
|
-
(0, import_vitest.expect)(authData?.id).toBe("u1");
|
|
104
|
-
await tx.mutate.project.insert(value);
|
|
105
|
-
server?.enqueueTask(async () => {
|
|
106
|
-
effectAuthID = (0, import_mutatorContext.getScopedAuthData)()?.id;
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
createServerActions: () => ({}),
|
|
113
|
-
queries,
|
|
114
|
-
transaction,
|
|
115
|
-
validateMutation({
|
|
116
|
-
authData
|
|
117
|
-
}) {
|
|
118
|
-
validatedAuthID = authData?.id;
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
(0, import_vitest.expect)(Object.keys(adapter.mutators)).toEqual(["project|create", "_zero_cleanupResults"]);
|
|
122
|
-
await transaction((tx, context) => adapter.mutators["project|create"](tx, {
|
|
123
|
-
id: "p1",
|
|
124
|
-
ownerId: "u1",
|
|
125
|
-
name: "first"
|
|
126
|
-
}, mutationContext(context)));
|
|
127
|
-
(0, import_vitest.expect)(db.prepare("SELECT * FROM project").all()).toEqual([{
|
|
128
|
-
id: "p1",
|
|
129
|
-
ownerId: "u1",
|
|
130
|
-
name: "first"
|
|
131
|
-
}]);
|
|
132
|
-
(0, import_vitest.expect)(validatedAuthID).toBe("u1");
|
|
133
|
-
(0, import_vitest.expect)(effectAuthID).toBe("u1");
|
|
134
|
-
(0, import_vitest.expect)(statements).toEqual([{
|
|
135
|
-
table: "project",
|
|
136
|
-
publicTable: "project",
|
|
137
|
-
kind: "insert"
|
|
138
|
-
}]);
|
|
139
|
-
});
|
|
140
|
-
(0, import_vitest.test)("returns a structural application error and drops rolled-back effects", async () => {
|
|
141
|
-
let effectRuns = 0;
|
|
142
|
-
const adapter = (0, import_syncHost.createZeroSyncHostAdapter)({
|
|
143
|
-
schema: import_fixtureSchema.zeroHttpFixtureSchema,
|
|
144
|
-
models: {
|
|
145
|
-
project: {
|
|
146
|
-
mutate: {
|
|
147
|
-
reject: async ({
|
|
148
|
-
server,
|
|
149
|
-
tx
|
|
150
|
-
}, value) => {
|
|
151
|
-
await tx.mutate.project.insert(value);
|
|
152
|
-
server?.enqueueTask(async () => {
|
|
153
|
-
effectRuns++;
|
|
154
|
-
});
|
|
155
|
-
throw new Error("denied");
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
createServerActions: () => ({}),
|
|
161
|
-
transaction
|
|
162
|
-
});
|
|
163
|
-
const error = await transaction((tx, context) => adapter.mutators["project|reject"](tx, {
|
|
164
|
-
id: "p1",
|
|
165
|
-
ownerId: "u1",
|
|
166
|
-
name: "must roll back"
|
|
167
|
-
}, mutationContext(context))).catch(caught => caught);
|
|
168
|
-
(0, import_vitest.expect)(error).toMatchObject({
|
|
169
|
-
name: "MutationApplicationError",
|
|
170
|
-
message: "denied",
|
|
171
|
-
details: "denied"
|
|
172
|
-
});
|
|
173
|
-
(0, import_vitest.expect)(db.prepare("SELECT * FROM project").all()).toEqual([]);
|
|
174
|
-
(0, import_vitest.expect)(effectRuns).toBe(0);
|
|
175
|
-
});
|
|
176
|
-
(0, import_vitest.test)("uses the host queryAst compiler surface for direct server queries", async () => {
|
|
177
|
-
db.prepare("INSERT INTO project (id, ownerId, name) VALUES (?, ?, ?)").run("p1", "u1", "first");
|
|
178
|
-
const adapter = (0, import_syncHost.createZeroSyncHostAdapter)({
|
|
179
|
-
schema: import_fixtureSchema.zeroHttpFixtureSchema,
|
|
180
|
-
models: {},
|
|
181
|
-
createServerActions: () => ({}),
|
|
182
|
-
transaction
|
|
183
|
-
});
|
|
184
|
-
await (0, import_vitest.expect)(adapter.server.query(q => q.project.one())).resolves.toEqual({
|
|
185
|
-
id: "p1",
|
|
186
|
-
ownerId: "u1",
|
|
187
|
-
name: "first"
|
|
188
|
-
});
|
|
189
|
-
(0, import_vitest.expect)(lastQueryFormat).toEqual({
|
|
190
|
-
relationships: {},
|
|
191
|
-
singular: true
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
(0, import_vitest.test)("resolves auth-sensitive named queries and runs query validation", async () => {
|
|
195
|
-
let validation;
|
|
196
|
-
const adapter = (0, import_syncHost.createZeroSyncHostAdapter)({
|
|
197
|
-
schema: import_fixtureSchema.zeroHttpFixtureSchema,
|
|
198
|
-
models: {},
|
|
199
|
-
createServerActions: () => ({}),
|
|
200
|
-
queries,
|
|
201
|
-
transaction,
|
|
202
|
-
validateQuery(args) {
|
|
203
|
-
validation = args;
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
const ast = await adapter.resolveQuery("project|byOwner", [{
|
|
207
|
-
ownerId: "u1"
|
|
208
|
-
}], {
|
|
209
|
-
userID: "u1",
|
|
210
|
-
role: "member"
|
|
211
|
-
});
|
|
212
|
-
(0, import_vitest.expect)(ast).toMatchObject({
|
|
213
|
-
table: "project"
|
|
214
|
-
});
|
|
215
|
-
(0, import_vitest.expect)(JSON.stringify(ast)).toContain("ownerId");
|
|
216
|
-
(0, import_vitest.expect)(JSON.stringify(ast)).toContain("u1");
|
|
217
|
-
(0, import_vitest.expect)(validation).toEqual({
|
|
218
|
-
authData: {
|
|
219
|
-
id: "u1",
|
|
220
|
-
role: "member",
|
|
221
|
-
userID: "u1"
|
|
222
|
-
},
|
|
223
|
-
queryName: "project|byOwner",
|
|
224
|
-
params: {
|
|
225
|
-
ownerId: "u1"
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
function mutationContext(context) {
|
|
231
|
-
return {
|
|
232
|
-
...context,
|
|
233
|
-
claims: {
|
|
234
|
-
userID: "u1",
|
|
235
|
-
role: "member"
|
|
236
|
-
},
|
|
237
|
-
clientID: "client-a",
|
|
238
|
-
mutationID: "1"
|
|
239
|
-
};
|
|
240
|
-
}
|