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,355 +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 createZeroServerCore_exports = {};
|
|
26
|
-
__export(createZeroServerCore_exports, {
|
|
27
|
-
createZeroServerCore: () => createZeroServerCore
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(createZeroServerCore_exports);
|
|
30
|
-
var import_server = require("@rocicorp/zero/server");
|
|
31
|
-
var import_asyncTasks = require("./asyncTasks.native.js");
|
|
32
|
-
var import_createZeroDirectServer = require("./createZeroDirectServer.native.js");
|
|
33
|
-
var import_createMutators = require("./helpers/createMutators.native.js");
|
|
34
|
-
var import_mutatorContext = require("./helpers/mutatorContext.native.js");
|
|
35
|
-
var import_queryContext = require("./helpers/queryContext.native.js");
|
|
36
|
-
function _assert_this_initialized(self) {
|
|
37
|
-
if (self === void 0) {
|
|
38
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
39
|
-
}
|
|
40
|
-
return self;
|
|
41
|
-
}
|
|
42
|
-
function _call_super(_this, derived, args) {
|
|
43
|
-
derived = _get_prototype_of(derived);
|
|
44
|
-
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
45
|
-
}
|
|
46
|
-
function _class_call_check(instance, Constructor) {
|
|
47
|
-
if (!(instance instanceof Constructor)) {
|
|
48
|
-
throw new TypeError("Cannot call a class as a function");
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function _construct(Parent, args, Class) {
|
|
52
|
-
if (_is_native_reflect_construct()) {
|
|
53
|
-
_construct = Reflect.construct;
|
|
54
|
-
} else {
|
|
55
|
-
_construct = function construct(Parent2, args2, Class2) {
|
|
56
|
-
var a = [null];
|
|
57
|
-
a.push.apply(a, args2);
|
|
58
|
-
var Constructor = Function.bind.apply(Parent2, a);
|
|
59
|
-
var instance = new Constructor();
|
|
60
|
-
if (Class2) _set_prototype_of(instance, Class2.prototype);
|
|
61
|
-
return instance;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
return _construct.apply(null, arguments);
|
|
65
|
-
}
|
|
66
|
-
function _define_property(obj, key, value) {
|
|
67
|
-
if (key in obj) {
|
|
68
|
-
Object.defineProperty(obj, key, {
|
|
69
|
-
value,
|
|
70
|
-
enumerable: true,
|
|
71
|
-
configurable: true,
|
|
72
|
-
writable: true
|
|
73
|
-
});
|
|
74
|
-
} else {
|
|
75
|
-
obj[key] = value;
|
|
76
|
-
}
|
|
77
|
-
return obj;
|
|
78
|
-
}
|
|
79
|
-
function _get_prototype_of(o) {
|
|
80
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {
|
|
81
|
-
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
82
|
-
};
|
|
83
|
-
return _get_prototype_of(o);
|
|
84
|
-
}
|
|
85
|
-
function _inherits(subClass, superClass) {
|
|
86
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
87
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
88
|
-
}
|
|
89
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
90
|
-
constructor: {
|
|
91
|
-
value: subClass,
|
|
92
|
-
writable: true,
|
|
93
|
-
configurable: true
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
if (superClass) _set_prototype_of(subClass, superClass);
|
|
97
|
-
}
|
|
98
|
-
function _instanceof(left, right) {
|
|
99
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
100
|
-
return !!right[Symbol.hasInstance](left);
|
|
101
|
-
} else {
|
|
102
|
-
return left instanceof right;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function _is_native_function(fn) {
|
|
106
|
-
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
107
|
-
}
|
|
108
|
-
function _possible_constructor_return(self, call) {
|
|
109
|
-
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
110
|
-
return call;
|
|
111
|
-
}
|
|
112
|
-
return _assert_this_initialized(self);
|
|
113
|
-
}
|
|
114
|
-
function _set_prototype_of(o, p) {
|
|
115
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {
|
|
116
|
-
o2.__proto__ = p2;
|
|
117
|
-
return o2;
|
|
118
|
-
};
|
|
119
|
-
return _set_prototype_of(o, p);
|
|
120
|
-
}
|
|
121
|
-
function _type_of(obj) {
|
|
122
|
-
"@swc/helpers - typeof";
|
|
123
|
-
|
|
124
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
125
|
-
}
|
|
126
|
-
function _wrap_native_super(Class) {
|
|
127
|
-
var _cache = typeof Map === "function" ? /* @__PURE__ */new Map() : void 0;
|
|
128
|
-
_wrap_native_super = function wrapNativeSuper(Class2) {
|
|
129
|
-
if (Class2 === null || !_is_native_function(Class2)) return Class2;
|
|
130
|
-
if (typeof Class2 !== "function") {
|
|
131
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
132
|
-
}
|
|
133
|
-
if (typeof _cache !== "undefined") {
|
|
134
|
-
if (_cache.has(Class2)) return _cache.get(Class2);
|
|
135
|
-
_cache.set(Class2, Wrapper);
|
|
136
|
-
}
|
|
137
|
-
function Wrapper() {
|
|
138
|
-
return _construct(Class2, arguments, _get_prototype_of(this).constructor);
|
|
139
|
-
}
|
|
140
|
-
Wrapper.prototype = Object.create(Class2.prototype, {
|
|
141
|
-
constructor: {
|
|
142
|
-
value: Wrapper,
|
|
143
|
-
enumerable: false,
|
|
144
|
-
writable: true,
|
|
145
|
-
configurable: true
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
return _set_prototype_of(Wrapper, Class2);
|
|
149
|
-
};
|
|
150
|
-
return _wrap_native_super(Class);
|
|
151
|
-
}
|
|
152
|
-
function _is_native_reflect_construct() {
|
|
153
|
-
try {
|
|
154
|
-
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
155
|
-
} catch (_) {}
|
|
156
|
-
return (_is_native_reflect_construct = function () {
|
|
157
|
-
return !!result;
|
|
158
|
-
})();
|
|
159
|
-
}
|
|
160
|
-
function createZeroServerCore(param) {
|
|
161
|
-
var {
|
|
162
|
-
createDatabase,
|
|
163
|
-
createServerActions,
|
|
164
|
-
defaultAllowAdminRole = "all",
|
|
165
|
-
defaultMutateAuthData,
|
|
166
|
-
models,
|
|
167
|
-
mutations: mutationValidators,
|
|
168
|
-
persistAlreadyProcessed,
|
|
169
|
-
queries,
|
|
170
|
-
schema,
|
|
171
|
-
validateMutation,
|
|
172
|
-
validateQuery
|
|
173
|
-
} = param;
|
|
174
|
-
var {
|
|
175
|
-
permissions,
|
|
176
|
-
server
|
|
177
|
-
} = (0, import_createZeroDirectServer.createZeroDirectServerRuntime)({
|
|
178
|
-
createDatabase,
|
|
179
|
-
createServerActions,
|
|
180
|
-
defaultAllowAdminRole,
|
|
181
|
-
defaultMutateAuthData,
|
|
182
|
-
models,
|
|
183
|
-
mutations: mutationValidators,
|
|
184
|
-
queries,
|
|
185
|
-
schema,
|
|
186
|
-
validateMutation,
|
|
187
|
-
validateQuery
|
|
188
|
-
});
|
|
189
|
-
var handleMutationRequest = async function (param2) {
|
|
190
|
-
var {
|
|
191
|
-
authData,
|
|
192
|
-
request,
|
|
193
|
-
scheduleBackgroundTask,
|
|
194
|
-
skipAsyncTasks
|
|
195
|
-
} = param2;
|
|
196
|
-
var tasks = (0, import_createZeroDirectServer.createAsyncTaskCollector)();
|
|
197
|
-
var recoveryRequest = request.clone();
|
|
198
|
-
var mutators = (0, import_createMutators.createMutators)({
|
|
199
|
-
enqueueTask: tasks.enqueueTask,
|
|
200
|
-
can: permissions.can,
|
|
201
|
-
createServerActions,
|
|
202
|
-
environment: "server",
|
|
203
|
-
models,
|
|
204
|
-
authData,
|
|
205
|
-
validateMutation,
|
|
206
|
-
mutationValidators
|
|
207
|
-
});
|
|
208
|
-
var processor = new import_server.PushProcessor(withTransactionLifecycle(createDatabase(), tasks.lifecycle));
|
|
209
|
-
var response = await processor.process(mutators, request);
|
|
210
|
-
if (persistAlreadyProcessed) {
|
|
211
|
-
var parsed = await parseAlreadyProcessed(recoveryRequest, response);
|
|
212
|
-
if (parsed) await persistAlreadyProcessed(parsed);
|
|
213
|
-
}
|
|
214
|
-
if (!skipAsyncTasks && tasks.committed.length) {
|
|
215
|
-
var entries = tasks.committed.map(function (entry) {
|
|
216
|
-
return {
|
|
217
|
-
...entry,
|
|
218
|
-
task: function () {
|
|
219
|
-
return (0, import_mutatorContext.runWithAuthScope)(authData, entry.task);
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
});
|
|
223
|
-
await (0, import_asyncTasks.runAsyncTaskEntries)(entries, {
|
|
224
|
-
background: scheduleBackgroundTask
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
return {
|
|
228
|
-
response,
|
|
229
|
-
asyncTasks: tasks.committed
|
|
230
|
-
};
|
|
231
|
-
};
|
|
232
|
-
var handleQueryRequest = async function (param2) {
|
|
233
|
-
var {
|
|
234
|
-
authData,
|
|
235
|
-
request
|
|
236
|
-
} = param2;
|
|
237
|
-
if (!queries) {
|
|
238
|
-
throw new Error("No queries registered with createZeroServer. Pass the syncedQueries registry to createZeroServer via the queries option.");
|
|
239
|
-
}
|
|
240
|
-
var handler = function (name, args) {
|
|
241
|
-
return (0, import_createZeroDirectServer.resolveServerQuery)({
|
|
242
|
-
authData,
|
|
243
|
-
name,
|
|
244
|
-
args,
|
|
245
|
-
queries,
|
|
246
|
-
permissions,
|
|
247
|
-
validateQuery
|
|
248
|
-
});
|
|
249
|
-
};
|
|
250
|
-
var userID = typeof (authData === null || authData === void 0 ? void 0 : authData.id) === "string" ? authData.id : void 0;
|
|
251
|
-
var response = await (0, import_queryContext.runWithQueryContext)({
|
|
252
|
-
authData: authData || {}
|
|
253
|
-
}, function () {
|
|
254
|
-
return (
|
|
255
|
-
// the legacy overload omits userID when auth does not identify a user.
|
|
256
|
-
userID === void 0 ? (0, import_server.handleQueryRequest)(handler, schema, request) : (0, import_server.handleQueryRequest)({
|
|
257
|
-
handler,
|
|
258
|
-
schema,
|
|
259
|
-
request,
|
|
260
|
-
userID
|
|
261
|
-
})
|
|
262
|
-
);
|
|
263
|
-
});
|
|
264
|
-
return {
|
|
265
|
-
response
|
|
266
|
-
};
|
|
267
|
-
};
|
|
268
|
-
return {
|
|
269
|
-
handleMutationRequest,
|
|
270
|
-
handleQueryRequest,
|
|
271
|
-
...server
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
function withTransactionLifecycle(database, lifecycle) {
|
|
275
|
-
return {
|
|
276
|
-
async transaction(callback, input) {
|
|
277
|
-
try {
|
|
278
|
-
var value = await database.transaction(async function (tx, hooks) {
|
|
279
|
-
lifecycle.beginAttempt();
|
|
280
|
-
try {
|
|
281
|
-
var result = await callback(tx, {
|
|
282
|
-
...hooks,
|
|
283
|
-
async updateClientMutationID() {
|
|
284
|
-
var result2 = await hooks.updateClientMutationID();
|
|
285
|
-
if (input && input.mutationID < result2.lastMutationID) {
|
|
286
|
-
throw new ExpectedDuplicateMutation(input.clientID, input.mutationID, result2.lastMutationID);
|
|
287
|
-
}
|
|
288
|
-
return result2;
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
lifecycle.completeAttempt();
|
|
292
|
-
return result;
|
|
293
|
-
} catch (error) {
|
|
294
|
-
lifecycle.rollbackAttempt();
|
|
295
|
-
throw error;
|
|
296
|
-
}
|
|
297
|
-
}, input);
|
|
298
|
-
lifecycle.commitTransaction();
|
|
299
|
-
return value;
|
|
300
|
-
} catch (error) {
|
|
301
|
-
lifecycle.rollbackTransaction();
|
|
302
|
-
if (_instanceof(error, ExpectedDuplicateMutation)) {
|
|
303
|
-
return {
|
|
304
|
-
id: {
|
|
305
|
-
clientID: error.clientID,
|
|
306
|
-
id: error.mutationID
|
|
307
|
-
},
|
|
308
|
-
result: {
|
|
309
|
-
error: "alreadyProcessed",
|
|
310
|
-
details: error.message
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
throw error;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
var ExpectedDuplicateMutation = /* @__PURE__ */function (Error1) {
|
|
320
|
-
"use strict";
|
|
321
|
-
|
|
322
|
-
_inherits(ExpectedDuplicateMutation2, Error1);
|
|
323
|
-
function ExpectedDuplicateMutation2(clientID, mutationID, expectedMutationID) {
|
|
324
|
-
_class_call_check(this, ExpectedDuplicateMutation2);
|
|
325
|
-
var _this;
|
|
326
|
-
_this = _call_super(this, ExpectedDuplicateMutation2, [`Ignoring mutation from ${clientID} with ID ${mutationID} as it was already processed. Expected: ${expectedMutationID}`]), _define_property(_this, "clientID", void 0), _define_property(_this, "mutationID", void 0), _this.clientID = clientID, _this.mutationID = mutationID;
|
|
327
|
-
return _this;
|
|
328
|
-
}
|
|
329
|
-
return ExpectedDuplicateMutation2;
|
|
330
|
-
}(_wrap_native_super(Error));
|
|
331
|
-
async function parseAlreadyProcessed(request, response) {
|
|
332
|
-
var mutations = alreadyProcessedMutations(response);
|
|
333
|
-
if (mutations.length === 0) return;
|
|
334
|
-
var upstreamSchema = new URL(request.url).searchParams.get("schema");
|
|
335
|
-
if (!upstreamSchema) return;
|
|
336
|
-
var body = await request.json();
|
|
337
|
-
if (typeof body.clientGroupID !== "string") return;
|
|
338
|
-
return {
|
|
339
|
-
clientGroupID: body.clientGroupID,
|
|
340
|
-
mutations,
|
|
341
|
-
upstreamSchema
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
function alreadyProcessedMutations(response) {
|
|
345
|
-
if (!response || (typeof response === "undefined" ? "undefined" : _type_of(response)) !== "object") return [];
|
|
346
|
-
var mutations = response.mutations;
|
|
347
|
-
if (!Array.isArray(mutations)) return [];
|
|
348
|
-
return mutations.filter(function (mutation) {
|
|
349
|
-
if (!mutation || (typeof mutation === "undefined" ? "undefined" : _type_of(mutation)) !== "object") return false;
|
|
350
|
-
var id = mutation.id;
|
|
351
|
-
var result = mutation.result;
|
|
352
|
-
return !!id && (typeof id === "undefined" ? "undefined" : _type_of(id)) === "object" && typeof id.clientID === "string" && typeof id.id === "number" && !!result && (typeof result === "undefined" ? "undefined" : _type_of(result)) === "object" && result.error === "alreadyProcessed";
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
//# sourceMappingURL=createZeroServerCore.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","createZeroServerCore_exports","__export","createZeroServerCore","module","exports","import_server","require","import_asyncTasks","import_createZeroDirectServer","import_createMutators","import_mutatorContext","import_queryContext","_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","_","param","createDatabase","createServerActions","defaultAllowAdminRole","defaultMutateAuthData","models","mutations","mutationValidators","persistAlreadyProcessed","queries","schema","validateMutation","validateQuery","permissions","server","createZeroDirectServerRuntime","handleMutationRequest","param2","authData","request","scheduleBackgroundTask","skipAsyncTasks","tasks","createAsyncTaskCollector","recoveryRequest","clone","mutators","createMutators","enqueueTask","can","environment","processor","PushProcessor","withTransactionLifecycle","lifecycle","response","process","parsed","parseAlreadyProcessed","committed","length","entries","map","entry","task","runWithAuthScope","runAsyncTaskEntries","background","asyncTasks"],"sources":["../../src/createZeroServerCore.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,4BAAA;AAAAC,QAAA,CAAAD,4BAAA;EAAAE,oBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAGO,CAAAK,4BAAA;AAEP,IAAAK,aAAA,GAAAC,OAAoC;A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,MAAA;MAMXa,QAAA;MACFP,gBAAA;MAEAJ;IAIE;IACA,IAAIwB,SAAU,OAAA/G,aAAc,CAAAgH,aAAA,CAAAC,wBAAA,CAAAhC,cAAA,IAAAqB,KAAA,CAAAY,SAAA;IAE5B,IAAMC,QAAA,SAAiBJ,SAAQ,CAAAK,OAAQ,CAAAV,QAAK,EAAAP,OAAa;IACzD,IAAKX,uBAAgB;MAErB,IAAM6B,MAAQ,SAAMC,qBAAa,CAAAd,eAAA,EAAAW,QAAA;MAC7B,IAAAE,MAAO,EAAK,MAAA7B,uBAA4B,CAAA6B,MAAA;IAE5C;IACE,KAAAhB,cAAe,IAAKC,KAAA,CAAAiB,SAAA,CAAAC,MAAA;MACpB,IAAAC,OAAA,GAAAnB,KAAA,CAAAiB,SAAA,CAAAG,GAAA,WAAAC,KAAA;QACA;UACF,GAAAA,KAAA;UACFC,IAAA,WAAAA,CAAA;YAES,WAAAvH,qBAA0B,CAA+CwH,gBAAA,EAAA3B,QAAA,EAAAyB,KAAA,CAAAC,IAAA;UAC3E;QACC;MACF,CAAC;MAEL,MAAO,IAAA1H,iBAAkB,CAAA4H,mBAAmD,EAAAL,OAAA;QACtEM,UAAC,EAAA3B;MACL;IACA;IACA,OACE;MAQHe,QAAA;MACHa,UAAA,EAAA1B,KAAA,CAAAiB","ignoreList":[]}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
var import_vitest = require("vitest");
|
|
2
|
-
var import_testHarness = require("./testHarness.cjs");
|
|
3
|
-
let harness;
|
|
4
|
-
(0, import_vitest.afterEach)(async () => {
|
|
5
|
-
await harness?.close();
|
|
6
|
-
harness = void 0;
|
|
7
|
-
});
|
|
8
|
-
(0, import_vitest.describe)("zero-http auth parity", () => {
|
|
9
|
-
(0, import_vitest.test)("real clients only emit rows visible to their auth token", async () => {
|
|
10
|
-
harness = await (0, import_testHarness.startZeroHttpHarness)({
|
|
11
|
-
seed: {
|
|
12
|
-
user: [{
|
|
13
|
-
id: "u1",
|
|
14
|
-
name: "ada"
|
|
15
|
-
}, {
|
|
16
|
-
id: "u2",
|
|
17
|
-
name: "ben"
|
|
18
|
-
}],
|
|
19
|
-
project: [{
|
|
20
|
-
id: "p-u1",
|
|
21
|
-
ownerId: "u1",
|
|
22
|
-
name: "u1 private"
|
|
23
|
-
}, {
|
|
24
|
-
id: "p-u2",
|
|
25
|
-
ownerId: "u2",
|
|
26
|
-
name: "u2 private"
|
|
27
|
-
}, {
|
|
28
|
-
id: "p-shared",
|
|
29
|
-
ownerId: "u2",
|
|
30
|
-
name: "shared"
|
|
31
|
-
}],
|
|
32
|
-
member: [{
|
|
33
|
-
id: "m-u1-owner",
|
|
34
|
-
projectId: "p-u1",
|
|
35
|
-
userId: "u1"
|
|
36
|
-
}, {
|
|
37
|
-
id: "m-u2-owner",
|
|
38
|
-
projectId: "p-u2",
|
|
39
|
-
userId: "u2"
|
|
40
|
-
}, {
|
|
41
|
-
id: "m-shared-u1",
|
|
42
|
-
projectId: "p-shared",
|
|
43
|
-
userId: "u1"
|
|
44
|
-
}, {
|
|
45
|
-
id: "m-shared-u2",
|
|
46
|
-
projectId: "p-shared",
|
|
47
|
-
userId: "u2"
|
|
48
|
-
}]
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
const u1 = harness.createZero("u1");
|
|
52
|
-
const u2 = harness.createZero("u2");
|
|
53
|
-
const u1Users = u1.query.user.materialize();
|
|
54
|
-
const u1Projects = u1.query.project.related("members").materialize();
|
|
55
|
-
const u2Users = u2.query.user.materialize();
|
|
56
|
-
const u2Projects = u2.query.project.related("members").materialize();
|
|
57
|
-
const u1UserEmissions = [];
|
|
58
|
-
const u1ProjectEmissions = [];
|
|
59
|
-
const u2UserEmissions = [];
|
|
60
|
-
const u2ProjectEmissions = [];
|
|
61
|
-
const stops = [captureRows(u1Users, u1UserEmissions, normalizeUsers), captureRows(u1Projects, u1ProjectEmissions, normalizeProjects), captureRows(u2Users, u2UserEmissions, normalizeUsers), captureRows(u2Projects, u2ProjectEmissions, normalizeProjects)];
|
|
62
|
-
try {
|
|
63
|
-
const [u1UsersComplete, u1ProjectsComplete, u2UsersComplete, u2ProjectsComplete] = await Promise.all([(0, import_testHarness.waitForComplete)(u1Users), (0, import_testHarness.waitForComplete)(u1Projects), (0, import_testHarness.waitForComplete)(u2Users), (0, import_testHarness.waitForComplete)(u2Projects)]);
|
|
64
|
-
(0, import_vitest.expect)(normalizeUsers(u1UsersComplete)).toEqual([{
|
|
65
|
-
id: "u1",
|
|
66
|
-
name: "ada"
|
|
67
|
-
}]);
|
|
68
|
-
(0, import_vitest.expect)(normalizeProjects(u1ProjectsComplete)).toEqual([{
|
|
69
|
-
id: "p-shared",
|
|
70
|
-
ownerId: "u2",
|
|
71
|
-
name: "shared",
|
|
72
|
-
members: [{
|
|
73
|
-
id: "m-shared-u1",
|
|
74
|
-
projectId: "p-shared",
|
|
75
|
-
userId: "u1"
|
|
76
|
-
}, {
|
|
77
|
-
id: "m-shared-u2",
|
|
78
|
-
projectId: "p-shared",
|
|
79
|
-
userId: "u2"
|
|
80
|
-
}]
|
|
81
|
-
}, {
|
|
82
|
-
id: "p-u1",
|
|
83
|
-
ownerId: "u1",
|
|
84
|
-
name: "u1 private",
|
|
85
|
-
members: [{
|
|
86
|
-
id: "m-u1-owner",
|
|
87
|
-
projectId: "p-u1",
|
|
88
|
-
userId: "u1"
|
|
89
|
-
}]
|
|
90
|
-
}]);
|
|
91
|
-
(0, import_vitest.expect)(normalizeUsers(u2UsersComplete)).toEqual([{
|
|
92
|
-
id: "u2",
|
|
93
|
-
name: "ben"
|
|
94
|
-
}]);
|
|
95
|
-
(0, import_vitest.expect)(normalizeProjects(u2ProjectsComplete)).toEqual([{
|
|
96
|
-
id: "p-shared",
|
|
97
|
-
ownerId: "u2",
|
|
98
|
-
name: "shared",
|
|
99
|
-
members: [{
|
|
100
|
-
id: "m-shared-u1",
|
|
101
|
-
projectId: "p-shared",
|
|
102
|
-
userId: "u1"
|
|
103
|
-
}, {
|
|
104
|
-
id: "m-shared-u2",
|
|
105
|
-
projectId: "p-shared",
|
|
106
|
-
userId: "u2"
|
|
107
|
-
}]
|
|
108
|
-
}, {
|
|
109
|
-
id: "p-u2",
|
|
110
|
-
ownerId: "u2",
|
|
111
|
-
name: "u2 private",
|
|
112
|
-
members: [{
|
|
113
|
-
id: "m-u2-owner",
|
|
114
|
-
projectId: "p-u2",
|
|
115
|
-
userId: "u2"
|
|
116
|
-
}]
|
|
117
|
-
}]);
|
|
118
|
-
assertNoUserEmission(u1UserEmissions, "u2");
|
|
119
|
-
assertNoProjectEmission(u1ProjectEmissions, "p-u2", "m-u2-owner");
|
|
120
|
-
assertNoUserEmission(u2UserEmissions, "u1");
|
|
121
|
-
assertNoProjectEmission(u2ProjectEmissions, "p-u1", "m-u1-owner");
|
|
122
|
-
await harness.transport.pull();
|
|
123
|
-
await (0, import_testHarness.sleep)(50);
|
|
124
|
-
assertNoUserEmission(u1UserEmissions, "u2");
|
|
125
|
-
assertNoProjectEmission(u1ProjectEmissions, "p-u2", "m-u2-owner");
|
|
126
|
-
assertNoUserEmission(u2UserEmissions, "u1");
|
|
127
|
-
assertNoProjectEmission(u2ProjectEmissions, "p-u1", "m-u1-owner");
|
|
128
|
-
} finally {
|
|
129
|
-
for (const stop of stops) stop();
|
|
130
|
-
u1Users.destroy();
|
|
131
|
-
u1Projects.destroy();
|
|
132
|
-
u2Users.destroy();
|
|
133
|
-
u2Projects.destroy();
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
(0, import_vitest.test)("unknown token 401 reaches needs-auth without materializing data", async () => {
|
|
137
|
-
harness = await (0, import_testHarness.startZeroHttpHarness)({
|
|
138
|
-
seed: {
|
|
139
|
-
user: [{
|
|
140
|
-
id: "u1",
|
|
141
|
-
name: "ada"
|
|
142
|
-
}],
|
|
143
|
-
project: [{
|
|
144
|
-
id: "p-u1",
|
|
145
|
-
ownerId: "u1",
|
|
146
|
-
name: "u1 private"
|
|
147
|
-
}],
|
|
148
|
-
member: [{
|
|
149
|
-
id: "m-u1-owner",
|
|
150
|
-
projectId: "p-u1",
|
|
151
|
-
userId: "u1"
|
|
152
|
-
}]
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
const unknown = harness.createZero("missing");
|
|
156
|
-
const projects = unknown.query.project.related("members").materialize();
|
|
157
|
-
const emissions = [];
|
|
158
|
-
const stop = captureRows(projects, emissions, normalizeProjects);
|
|
159
|
-
try {
|
|
160
|
-
await (0, import_testHarness.eventually)(() => (0, import_vitest.expect)(unknown.connection.state.current.name).toBe("needs-auth"));
|
|
161
|
-
await (0, import_testHarness.sleep)(50);
|
|
162
|
-
(0, import_vitest.expect)(projects.data).toEqual([]);
|
|
163
|
-
(0, import_vitest.expect)(emissions.every(emission => emission.length === 0)).toBe(true);
|
|
164
|
-
} finally {
|
|
165
|
-
stop();
|
|
166
|
-
projects.destroy();
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
function captureRows(view, emissions, normalize) {
|
|
171
|
-
return view.addListener(data => {
|
|
172
|
-
emissions.push(normalize(data));
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
function assertNoUserEmission(emissions, privateUserID) {
|
|
176
|
-
for (const emission of emissions) {
|
|
177
|
-
(0, import_vitest.expect)(emission.map(row => row.id)).not.toContain(privateUserID);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
function assertNoProjectEmission(emissions, privateProjectID, privateMemberID) {
|
|
181
|
-
for (const emission of emissions) {
|
|
182
|
-
(0, import_vitest.expect)(emission.map(row => row.id)).not.toContain(privateProjectID);
|
|
183
|
-
(0, import_vitest.expect)(emission.flatMap(row => row.members.map(member => member.id))).not.toContain(privateMemberID);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
function normalizeUsers(users) {
|
|
187
|
-
return clone(users).sort((a, b) => a.id.localeCompare(b.id));
|
|
188
|
-
}
|
|
189
|
-
function normalizeProjects(projects) {
|
|
190
|
-
return clone(projects).map(project => ({
|
|
191
|
-
...project,
|
|
192
|
-
members: [...project.members].sort((a, b) => a.id.localeCompare(b.id))
|
|
193
|
-
})).sort((a, b) => a.id.localeCompare(b.id));
|
|
194
|
-
}
|
|
195
|
-
function clone(value) {
|
|
196
|
-
return JSON.parse(JSON.stringify(value));
|
|
197
|
-
}
|