@backendrelay/core 1.1.0 → 2.0.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/dist/standalone/index.js +1 -1
- package/dist/standalone/index.umd.cjs +1 -1
- package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typeUtils.d.ts +20 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typeUtils.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typeUtils.js +5 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typeUtils.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typesTests.d.ts +2 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typesTests.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typesTests.js +88 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/__types__/typesTests.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/byop.live.e2e.test.d.ts +2 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/byop.live.e2e.test.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/byop.live.e2e.test.js +131 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/byop.live.e2e.test.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/config.test.d.ts +2 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/config.test.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/config.test.js +65 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/config.test.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/index.d.ts +725 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/index.js +1159 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/index.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/live.e2e.test.d.ts +2 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/live.e2e.test.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/live.e2e.test.js +91 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/live.e2e.test.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/package.json +3 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/polyfill.d.ts +17 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/polyfill.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/polyfill.js +26 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/polyfill.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/removed-features.test.d.ts +2 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/removed-features.test.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/removed-features.test.js +50 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/removed-features.test.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/storage-upload.test.d.ts +2 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/storage-upload.test.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/storage-upload.test.js +33 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/storage-upload.test.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/subscribe.d.ts +39 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/subscribe.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/subscribe.js +306 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/subscribe.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/version.d.ts +3 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/version.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/version.js +5 -0
- package/node_modules/@backendrelay/admin/dist/commonjs/version.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/__types__/typeUtils.d.ts +20 -0
- package/node_modules/@backendrelay/admin/dist/esm/__types__/typeUtils.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/__types__/typeUtils.js +4 -0
- package/node_modules/@backendrelay/admin/dist/esm/__types__/typeUtils.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/__types__/typesTests.d.ts +2 -0
- package/node_modules/@backendrelay/admin/dist/esm/__types__/typesTests.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/__types__/typesTests.js +86 -0
- package/node_modules/@backendrelay/admin/dist/esm/__types__/typesTests.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/byop.live.e2e.test.d.ts +2 -0
- package/node_modules/@backendrelay/admin/dist/esm/byop.live.e2e.test.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/byop.live.e2e.test.js +129 -0
- package/node_modules/@backendrelay/admin/dist/esm/byop.live.e2e.test.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/config.test.d.ts +2 -0
- package/node_modules/@backendrelay/admin/dist/esm/config.test.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/config.test.js +63 -0
- package/node_modules/@backendrelay/admin/dist/esm/config.test.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/index.d.ts +725 -0
- package/node_modules/@backendrelay/admin/dist/esm/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/index.js +1146 -0
- package/node_modules/@backendrelay/admin/dist/esm/index.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/live.e2e.test.d.ts +2 -0
- package/node_modules/@backendrelay/admin/dist/esm/live.e2e.test.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/live.e2e.test.js +89 -0
- package/node_modules/@backendrelay/admin/dist/esm/live.e2e.test.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/package.json +3 -0
- package/node_modules/@backendrelay/admin/dist/esm/polyfill.d.ts +17 -0
- package/node_modules/@backendrelay/admin/dist/esm/polyfill.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/polyfill.js +22 -0
- package/node_modules/@backendrelay/admin/dist/esm/polyfill.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/removed-features.test.d.ts +2 -0
- package/node_modules/@backendrelay/admin/dist/esm/removed-features.test.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/removed-features.test.js +48 -0
- package/node_modules/@backendrelay/admin/dist/esm/removed-features.test.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/storage-upload.test.d.ts +2 -0
- package/node_modules/@backendrelay/admin/dist/esm/storage-upload.test.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/storage-upload.test.js +31 -0
- package/node_modules/@backendrelay/admin/dist/esm/storage-upload.test.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/subscribe.d.ts +39 -0
- package/node_modules/@backendrelay/admin/dist/esm/subscribe.d.ts.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/subscribe.js +300 -0
- package/node_modules/@backendrelay/admin/dist/esm/subscribe.js.map +1 -0
- package/node_modules/@backendrelay/admin/dist/esm/version.d.ts +3 -0
- package/node_modules/@backendrelay/admin/dist/esm/version.d.ts.map +1 -0
- package/{src/version.ts → node_modules/@backendrelay/admin/dist/esm/version.js} +1 -1
- package/node_modules/@backendrelay/admin/dist/esm/version.js.map +1 -0
- package/node_modules/@backendrelay/admin/package.json +52 -0
- package/node_modules/@backendrelay/functions/README.md +131 -0
- package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typeUtils.d.ts +3 -0
- package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typeUtils.d.ts.map +1 -0
- package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typeUtils.js +3 -0
- package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typeUtils.js.map +1 -0
- package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typesTests.d.ts +2 -0
- package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typesTests.d.ts.map +1 -0
- package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typesTests.js +51 -0
- package/node_modules/@backendrelay/functions/dist/commonjs/__types__/typesTests.js.map +1 -0
- package/node_modules/@backendrelay/functions/dist/commonjs/index.d.ts +230 -0
- package/node_modules/@backendrelay/functions/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/functions/dist/commonjs/index.js +415 -0
- package/node_modules/@backendrelay/functions/dist/commonjs/index.js.map +1 -0
- package/node_modules/@backendrelay/functions/dist/commonjs/package.json +3 -0
- package/node_modules/@backendrelay/functions/dist/esm/__types__/typeUtils.d.ts +3 -0
- package/node_modules/@backendrelay/functions/dist/esm/__types__/typeUtils.d.ts.map +1 -0
- package/node_modules/@backendrelay/functions/dist/esm/__types__/typeUtils.js +2 -0
- package/node_modules/@backendrelay/functions/dist/esm/__types__/typeUtils.js.map +1 -0
- package/node_modules/@backendrelay/functions/dist/esm/__types__/typesTests.d.ts +2 -0
- package/node_modules/@backendrelay/functions/dist/esm/__types__/typesTests.d.ts.map +1 -0
- package/node_modules/@backendrelay/functions/dist/esm/__types__/typesTests.js +49 -0
- package/node_modules/@backendrelay/functions/dist/esm/__types__/typesTests.js.map +1 -0
- package/node_modules/@backendrelay/functions/dist/esm/index.d.ts +230 -0
- package/node_modules/@backendrelay/functions/dist/esm/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/functions/dist/esm/index.js +403 -0
- package/node_modules/@backendrelay/functions/dist/esm/index.js.map +1 -0
- package/node_modules/@backendrelay/functions/dist/esm/package.json +3 -0
- package/node_modules/@backendrelay/functions/package.json +49 -0
- package/node_modules/@backendrelay/hatchet/dist/commonjs/index.d.ts +43 -0
- package/node_modules/@backendrelay/hatchet/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/hatchet/dist/commonjs/index.js +63 -0
- package/node_modules/@backendrelay/hatchet/dist/commonjs/index.js.map +1 -0
- package/node_modules/@backendrelay/hatchet/dist/commonjs/package.json +3 -0
- package/node_modules/@backendrelay/hatchet/dist/esm/index.d.ts +43 -0
- package/node_modules/@backendrelay/hatchet/dist/esm/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/hatchet/dist/esm/index.js +59 -0
- package/node_modules/@backendrelay/hatchet/dist/esm/index.js.map +1 -0
- package/node_modules/@backendrelay/hatchet/dist/esm/package.json +3 -0
- package/node_modules/@backendrelay/hatchet/package.json +46 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/ProgressPromise.d.ts +18 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/ProgressPromise.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/ProgressPromise.js +77 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/ProgressPromise.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/apps.d.ts +99 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/apps.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/apps.js +177 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/apps.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/auth.d.ts +7 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/auth.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/auth.js +15 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/auth.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/http.d.ts +3 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/http.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/http.js +46 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/http.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/perms.d.ts +13 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/perms.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/perms.js +25 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/perms.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/platform-api.d.ts +285 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/platform-api.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/platform-api.js +426 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/platform-api.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/schema-coerce.d.ts +24 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/schema-coerce.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/schema-coerce.js +108 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/schema-coerce.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/schema.d.ts +188 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/schema.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/schema.js +412 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api/schema.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api.d.ts +9 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api.js +12 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/api.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/backupDownload.d.ts +89 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/backupDownload.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/backupDownload.js +357 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/backupDownload.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/backups.d.ts +146 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/backups.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/backups.js +251 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/backups.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/clerk.d.ts +2 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/clerk.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/clerk.js +29 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/clerk.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/consts.d.ts +11 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/consts.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/consts.js +17 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/consts.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/crypto.d.ts +4 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/crypto.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/crypto.js +26 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/crypto.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/index.d.ts +19 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/index.js +76 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/index.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/migrationUtils.d.ts +4 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/migrationUtils.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/migrationUtils.js +52 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/migrationUtils.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/migrations.d.ts +99 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/migrations.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/migrations.js +597 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/migrations.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/oauth.d.ts +98 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/oauth.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/oauth.js +275 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/oauth.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/oauthCommon.d.ts +12 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/oauthCommon.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/oauthCommon.js +26 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/oauthCommon.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/package.json +3 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/perms.d.ts +3 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/perms.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/perms.js +66 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/perms.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/privateFields.d.ts +13 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/privateFields.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/privateFields.js +31 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/privateFields.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/relationships.d.ts +7 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/relationships.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/relationships.js +46 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/relationships.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/schema.d.ts +161 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/schema.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/schema.js +174 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/schema.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/serverOAuth.d.ts +25 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/serverOAuth.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/serverOAuth.js +68 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/serverOAuth.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/typescript-schema.d.ts +17 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/typescript-schema.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/typescript-schema.js +314 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/typescript-schema.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/util.d.ts +13 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/util.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/util.js +55 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/util.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/version.d.ts +3 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/version.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/version.js +5 -0
- package/node_modules/@backendrelay/platform/dist/commonjs/version.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/ProgressPromise.d.ts +18 -0
- package/node_modules/@backendrelay/platform/dist/esm/ProgressPromise.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/ProgressPromise.js +73 -0
- package/node_modules/@backendrelay/platform/dist/esm/ProgressPromise.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/apps.d.ts +99 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/apps.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/apps.js +165 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/apps.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/auth.d.ts +7 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/auth.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/auth.js +12 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/auth.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/http.d.ts +3 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/http.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/http.js +39 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/http.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/perms.d.ts +13 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/perms.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/perms.js +21 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/perms.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/platform-api.d.ts +285 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/platform-api.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/platform-api.js +421 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/platform-api.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/schema-coerce.d.ts +24 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/schema-coerce.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/schema-coerce.js +99 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/schema-coerce.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/schema.d.ts +188 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/schema.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/schema.js +393 -0
- package/node_modules/@backendrelay/platform/dist/esm/api/schema.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api.d.ts +9 -0
- package/node_modules/@backendrelay/platform/dist/esm/api.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/api.js +4 -0
- package/node_modules/@backendrelay/platform/dist/esm/api.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/backupDownload.d.ts +89 -0
- package/node_modules/@backendrelay/platform/dist/esm/backupDownload.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/backupDownload.js +354 -0
- package/node_modules/@backendrelay/platform/dist/esm/backupDownload.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/backups.d.ts +146 -0
- package/node_modules/@backendrelay/platform/dist/esm/backups.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/backups.js +240 -0
- package/node_modules/@backendrelay/platform/dist/esm/backups.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/clerk.d.ts +2 -0
- package/node_modules/@backendrelay/platform/dist/esm/clerk.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/clerk.js +26 -0
- package/node_modules/@backendrelay/platform/dist/esm/clerk.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/consts.d.ts +11 -0
- package/node_modules/@backendrelay/platform/dist/esm/consts.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/consts.js +13 -0
- package/node_modules/@backendrelay/platform/dist/esm/consts.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/crypto.d.ts +4 -0
- package/node_modules/@backendrelay/platform/dist/esm/crypto.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/crypto.js +21 -0
- package/node_modules/@backendrelay/platform/dist/esm/crypto.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/index.d.ts +19 -0
- package/node_modules/@backendrelay/platform/dist/esm/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/index.js +18 -0
- package/node_modules/@backendrelay/platform/dist/esm/index.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/migrationUtils.d.ts +4 -0
- package/node_modules/@backendrelay/platform/dist/esm/migrationUtils.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/migrationUtils.js +47 -0
- package/node_modules/@backendrelay/platform/dist/esm/migrationUtils.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/migrations.d.ts +99 -0
- package/node_modules/@backendrelay/platform/dist/esm/migrations.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/migrations.js +588 -0
- package/node_modules/@backendrelay/platform/dist/esm/migrations.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/oauth.d.ts +98 -0
- package/node_modules/@backendrelay/platform/dist/esm/oauth.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/oauth.js +266 -0
- package/node_modules/@backendrelay/platform/dist/esm/oauth.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/oauthCommon.d.ts +12 -0
- package/node_modules/@backendrelay/platform/dist/esm/oauthCommon.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/oauthCommon.js +22 -0
- package/node_modules/@backendrelay/platform/dist/esm/oauthCommon.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/package.json +3 -0
- package/node_modules/@backendrelay/platform/dist/esm/perms.d.ts +3 -0
- package/node_modules/@backendrelay/platform/dist/esm/perms.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/perms.js +62 -0
- package/node_modules/@backendrelay/platform/dist/esm/perms.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/privateFields.d.ts +13 -0
- package/node_modules/@backendrelay/platform/dist/esm/privateFields.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/privateFields.js +28 -0
- package/node_modules/@backendrelay/platform/dist/esm/privateFields.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/relationships.d.ts +7 -0
- package/node_modules/@backendrelay/platform/dist/esm/relationships.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/relationships.js +43 -0
- package/node_modules/@backendrelay/platform/dist/esm/relationships.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/schema.d.ts +161 -0
- package/node_modules/@backendrelay/platform/dist/esm/schema.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/schema.js +158 -0
- package/node_modules/@backendrelay/platform/dist/esm/schema.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/serverOAuth.d.ts +25 -0
- package/node_modules/@backendrelay/platform/dist/esm/serverOAuth.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/serverOAuth.js +64 -0
- package/node_modules/@backendrelay/platform/dist/esm/serverOAuth.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/typescript-schema.d.ts +17 -0
- package/node_modules/@backendrelay/platform/dist/esm/typescript-schema.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/typescript-schema.js +310 -0
- package/node_modules/@backendrelay/platform/dist/esm/typescript-schema.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/util.d.ts +13 -0
- package/node_modules/@backendrelay/platform/dist/esm/util.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/util.js +46 -0
- package/node_modules/@backendrelay/platform/dist/esm/util.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/version.d.ts +3 -0
- package/node_modules/@backendrelay/platform/dist/esm/version.d.ts.map +1 -0
- package/node_modules/@backendrelay/platform/dist/esm/version.js +3 -0
- package/node_modules/@backendrelay/platform/dist/esm/version.js.map +1 -0
- package/node_modules/@backendrelay/platform/dist/standalone/index.js +13738 -0
- package/node_modules/@backendrelay/platform/dist/standalone/index.umd.cjs +72 -0
- package/node_modules/@backendrelay/platform/package.json +51 -0
- package/node_modules/@backendrelay/resumable-stream/dist/commonjs/index.d.ts +67 -0
- package/node_modules/@backendrelay/resumable-stream/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/resumable-stream/dist/commonjs/index.js +129 -0
- package/node_modules/@backendrelay/resumable-stream/dist/commonjs/index.js.map +1 -0
- package/node_modules/@backendrelay/resumable-stream/dist/commonjs/package.json +3 -0
- package/node_modules/@backendrelay/resumable-stream/dist/esm/index.d.ts +67 -0
- package/node_modules/@backendrelay/resumable-stream/dist/esm/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/resumable-stream/dist/esm/index.js +126 -0
- package/node_modules/@backendrelay/resumable-stream/dist/esm/index.js.map +1 -0
- package/node_modules/@backendrelay/resumable-stream/dist/esm/package.json +3 -0
- package/node_modules/@backendrelay/resumable-stream/dist/standalone/index.js +4354 -0
- package/node_modules/@backendrelay/resumable-stream/dist/standalone/index.umd.cjs +6 -0
- package/node_modules/@backendrelay/resumable-stream/package.json +47 -0
- package/node_modules/@backendrelay/rules/README.md +34 -0
- package/node_modules/@backendrelay/rules/dist/commonjs/index.d.ts +117 -0
- package/node_modules/@backendrelay/rules/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/rules/dist/commonjs/index.js +68 -0
- package/node_modules/@backendrelay/rules/dist/commonjs/index.js.map +1 -0
- package/node_modules/@backendrelay/rules/dist/commonjs/package.json +3 -0
- package/node_modules/@backendrelay/rules/dist/esm/index.d.ts +117 -0
- package/node_modules/@backendrelay/rules/dist/esm/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/rules/dist/esm/index.js +64 -0
- package/node_modules/@backendrelay/rules/dist/esm/index.js.map +1 -0
- package/node_modules/@backendrelay/rules/dist/esm/package.json +3 -0
- package/node_modules/@backendrelay/rules/package.json +46 -0
- package/node_modules/@backendrelay/test/README.md +75 -0
- package/node_modules/@backendrelay/test/dist/commonjs/index.d.ts +74 -0
- package/node_modules/@backendrelay/test/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/test/dist/commonjs/index.js +197 -0
- package/node_modules/@backendrelay/test/dist/commonjs/index.js.map +1 -0
- package/node_modules/@backendrelay/test/dist/commonjs/live.e2e.test.d.ts +2 -0
- package/node_modules/@backendrelay/test/dist/commonjs/live.e2e.test.d.ts.map +1 -0
- package/node_modules/@backendrelay/test/dist/commonjs/live.e2e.test.js +45 -0
- package/node_modules/@backendrelay/test/dist/commonjs/live.e2e.test.js.map +1 -0
- package/node_modules/@backendrelay/test/dist/commonjs/package.json +3 -0
- package/node_modules/@backendrelay/test/dist/esm/index.d.ts +74 -0
- package/node_modules/@backendrelay/test/dist/esm/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/test/dist/esm/index.js +192 -0
- package/node_modules/@backendrelay/test/dist/esm/index.js.map +1 -0
- package/node_modules/@backendrelay/test/dist/esm/live.e2e.test.d.ts +2 -0
- package/node_modules/@backendrelay/test/dist/esm/live.e2e.test.d.ts.map +1 -0
- package/node_modules/@backendrelay/test/dist/esm/live.e2e.test.js +43 -0
- package/node_modules/@backendrelay/test/dist/esm/live.e2e.test.js.map +1 -0
- package/node_modules/@backendrelay/test/dist/esm/package.json +3 -0
- package/node_modules/@backendrelay/test/package.json +49 -0
- package/node_modules/@backendrelay/version/dist/commonjs/index.d.ts +3 -0
- package/node_modules/@backendrelay/version/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/version/dist/commonjs/index.js +6 -0
- package/node_modules/@backendrelay/version/dist/commonjs/index.js.map +1 -0
- package/node_modules/@backendrelay/version/dist/commonjs/package.json +3 -0
- package/node_modules/@backendrelay/version/dist/commonjs/version.d.ts +3 -0
- package/node_modules/@backendrelay/version/dist/commonjs/version.d.ts.map +1 -0
- package/node_modules/@backendrelay/version/dist/commonjs/version.js +10 -0
- package/node_modules/@backendrelay/version/dist/commonjs/version.js.map +1 -0
- package/node_modules/@backendrelay/version/dist/esm/index.d.ts +3 -0
- package/node_modules/@backendrelay/version/dist/esm/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/version/dist/esm/index.js +3 -0
- package/node_modules/@backendrelay/version/dist/esm/index.js.map +1 -0
- package/node_modules/@backendrelay/version/dist/esm/package.json +3 -0
- package/node_modules/@backendrelay/version/dist/esm/version.d.ts +3 -0
- package/node_modules/@backendrelay/version/dist/esm/version.d.ts.map +1 -0
- package/node_modules/@backendrelay/version/dist/esm/version.js +7 -0
- package/node_modules/@backendrelay/version/dist/esm/version.js.map +1 -0
- package/node_modules/@backendrelay/version/dist/standalone/index.js +4 -0
- package/node_modules/@backendrelay/version/dist/standalone/index.umd.cjs +1 -0
- package/node_modules/@backendrelay/version/package.json +44 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typeUtils.d.ts +12 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typeUtils.d.ts.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typeUtils.js +5 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typeUtils.js.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typesTests.d.ts +2 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typesTests.d.ts.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typesTests.js +82 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/__types__/typesTests.js.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/index.d.ts +607 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/index.js +830 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/index.js.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/live.e2e.test.d.ts +2 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/live.e2e.test.d.ts.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/live.e2e.test.js +139 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/live.e2e.test.js.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/commonjs/package.json +3 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typeUtils.d.ts +12 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typeUtils.d.ts.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typeUtils.js +4 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typeUtils.js.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typesTests.d.ts +2 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typesTests.d.ts.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typesTests.js +80 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/__types__/typesTests.js.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/index.d.ts +607 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/index.d.ts.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/index.js +825 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/index.js.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/live.e2e.test.d.ts +2 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/live.e2e.test.d.ts.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/live.e2e.test.js +137 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/live.e2e.test.js.map +1 -0
- package/node_modules/@backendrelay/webhooks/dist/esm/package.json +3 -0
- package/node_modules/@backendrelay/webhooks/package.json +46 -0
- package/package.json +129 -56
- package/subpaths/admin/index.cjs +1 -0
- package/subpaths/admin/index.d.ts +1 -0
- package/subpaths/admin/index.mjs +3 -0
- package/subpaths/functions/index.cjs +1 -0
- package/subpaths/functions/index.d.ts +1 -0
- package/subpaths/functions/index.mjs +3 -0
- package/subpaths/hatchet/index.cjs +1 -0
- package/subpaths/hatchet/index.d.ts +1 -0
- package/subpaths/hatchet/index.mjs +3 -0
- package/subpaths/platform/index.cjs +1 -0
- package/subpaths/platform/index.d.ts +1 -0
- package/subpaths/platform/index.mjs +3 -0
- package/subpaths/resumable-stream/index.cjs +1 -0
- package/subpaths/resumable-stream/index.d.ts +1 -0
- package/subpaths/resumable-stream/index.mjs +3 -0
- package/subpaths/rules/index.cjs +1 -0
- package/subpaths/rules/index.d.ts +1 -0
- package/subpaths/rules/index.mjs +3 -0
- package/subpaths/test/index.cjs +1 -0
- package/subpaths/test/index.d.ts +1 -0
- package/subpaths/test/index.mjs +3 -0
- package/subpaths/version/index.cjs +1 -0
- package/subpaths/version/index.d.ts +1 -0
- package/subpaths/version/index.mjs +3 -0
- package/subpaths/webhooks/index.cjs +1 -0
- package/subpaths/webhooks/index.d.ts +1 -0
- package/subpaths/webhooks/index.mjs +3 -0
- package/.tshy/build.json +0 -8
- package/.tshy/commonjs.json +0 -16
- package/.tshy/esm.json +0 -15
- package/__example__/standalone.esm.html +0 -23
- package/__example__/standalone.umd.html +0 -21
- package/__tests__/src/Connection.test.ts +0 -292
- package/__tests__/src/IndexedDBStorage.test.ts +0 -96
- package/__tests__/src/Reactor.test.ts +0 -1179
- package/__tests__/src/auth-extra-fields.e2e.test.ts +0 -160
- package/__tests__/src/byop.e2e.test.ts +0 -762
- package/__tests__/src/config.test.ts +0 -85
- package/__tests__/src/cookieSync.e2e.test.ts +0 -163
- package/__tests__/src/data/movies/attrs.json +0 -145
- package/__tests__/src/data/movies/triples.json +0 -1507
- package/__tests__/src/data/zeneca/attrs.json +0 -251
- package/__tests__/src/data/zeneca/triples.json +0 -15854
- package/__tests__/src/datalog.test.ts +0 -175
- package/__tests__/src/devtool.test.ts +0 -23
- package/__tests__/src/framework.test.ts +0 -173
- package/__tests__/src/infiniteQuery.e2e.test.ts +0 -467
- package/__tests__/src/instaml.test.ts +0 -1593
- package/__tests__/src/instaql.bench.ts +0 -34
- package/__tests__/src/instaql.test.ts +0 -1497
- package/__tests__/src/instaqlInference.test.ts +0 -243
- package/__tests__/src/presence.test.ts +0 -49
- package/__tests__/src/queryValidation.test.ts +0 -1101
- package/__tests__/src/schema.test.ts +0 -653
- package/__tests__/src/serializeSchema.test.ts +0 -123
- package/__tests__/src/simple.e2e.test.ts +0 -133
- package/__tests__/src/storage-upload.test.ts +0 -37
- package/__tests__/src/store.test.ts +0 -960
- package/__tests__/src/syncTable.e2e.test.ts +0 -245
- package/__tests__/src/syncTable.test.ts +0 -235
- package/__tests__/src/transactionValidation.test.ts +0 -450
- package/__tests__/src/typeUtils.ts +0 -39
- package/__tests__/src/upstream-improvements.e2e.test.ts +0 -54
- package/__tests__/src/utils/MutationStorage.test.ts +0 -77
- package/__tests__/src/utils/PersistedObject.test.ts +0 -569
- package/__tests__/src/utils/dates.test.ts +0 -111
- package/__tests__/src/utils/e2e.ts +0 -100
- package/__tests__/src/utils/msw.ts +0 -3
- package/__tests__/src/utils/object.test.ts +0 -78
- package/__tests__/src/utils/weakHash.test.ts +0 -68
- package/__tests__/src/utils/weakHashLegacy.test.ts +0 -22
- package/__tests__/src/vite.env.d.ts +0 -1
- package/src/BackendRelayError.ts +0 -50
- package/src/Connection.ts +0 -361
- package/src/InMemoryStorage.ts +0 -34
- package/src/IndexedDBStorage.ts +0 -398
- package/src/Reactor.js +0 -1541
- package/src/StorageAPI.ts +0 -147
- package/src/Stream.ts +0 -1252
- package/src/SyncTable.ts +0 -750
- package/src/WindowNetworkListener.js +0 -19
- package/src/__types__/fieldsTypeTest.ts +0 -111
- package/src/__types__/typeUtils.ts +0 -39
- package/src/__types__/useDatesTypeTest.ts +0 -66
- package/src/attrTypes.ts +0 -37
- package/src/authAPI.ts +0 -205
- package/src/clientTypes.ts +0 -28
- package/src/coreTypes.ts +0 -58
- package/src/createRouteHandler.ts +0 -68
- package/src/datalog.js +0 -116
- package/src/devtool.ts +0 -179
- package/src/framework.ts +0 -450
- package/src/helperTypes.ts +0 -117
- package/src/index.ts +0 -1293
- package/src/infiniteQuery.ts +0 -599
- package/src/instaml.ts +0 -676
- package/src/instaql.ts +0 -999
- package/src/instatx.ts +0 -265
- package/src/model/instaqlResult.js +0 -25
- package/src/parseSchemaFromJSON.ts +0 -176
- package/src/presence.ts +0 -123
- package/src/presenceTypes.ts +0 -19
- package/src/queryTypes.ts +0 -749
- package/src/queryValidation.ts +0 -598
- package/src/reactorAuth.js +0 -236
- package/src/reactorEvents.js +0 -414
- package/src/reactorMutations.js +0 -354
- package/src/reactorRooms.js +0 -297
- package/src/reactorStorage.js +0 -180
- package/src/reactorSubs.js +0 -275
- package/src/reactorTransport.js +0 -391
- package/src/reactorTypes.ts +0 -41
- package/src/routeHandlerProtocol.ts +0 -25
- package/src/rulesTypes.ts +0 -132
- package/src/sanityCheckQueries.ts +0 -191
- package/src/schema.ts +0 -206
- package/src/schemaTypes.ts +0 -664
- package/src/store.ts +0 -1165
- package/src/transactionValidation.ts +0 -204
- package/src/urls.ts +0 -50
- package/src/utils/Deferred.ts +0 -20
- package/src/utils/MutationStorage.ts +0 -89
- package/src/utils/PersistedObject.ts +0 -612
- package/src/utils/dates.ts +0 -269
- package/src/utils/error.ts +0 -9
- package/src/utils/fetch.ts +0 -131
- package/src/utils/flags.ts +0 -14
- package/src/utils/id.ts +0 -28
- package/src/utils/linkIndex.ts +0 -33
- package/src/utils/log.ts +0 -23
- package/src/utils/object.js +0 -180
- package/src/utils/pgtime.ts +0 -199
- package/src/utils/pick.js +0 -9
- package/src/utils/strings.ts +0 -19
- package/src/utils/weakHash.ts +0 -77
- package/src/utils/weakHashLegacy.ts +0 -75
- package/src/warningToggle.ts +0 -5
- package/tsconfig.cjs.dev.json +0 -15
- package/tsconfig.dev.json +0 -14
- package/tsconfig.json +0 -13
- package/tsconfig.test.json +0 -5
- package/vite.config.ts +0 -19
- package/vitest.config.ts +0 -54
|
@@ -1,1179 +0,0 @@
|
|
|
1
|
-
// https://www.npmjs.com/package/fake-indexeddb
|
|
2
|
-
import 'fake-indexeddb/auto';
|
|
3
|
-
import { test, expect, vi } from 'vitest';
|
|
4
|
-
import { IDBObjectStore } from 'fake-indexeddb';
|
|
5
|
-
import { setTimeout as sleep } from 'timers/promises';
|
|
6
|
-
|
|
7
|
-
import IndexedDBStorage from '../../src/IndexedDBStorage';
|
|
8
|
-
|
|
9
|
-
import Reactor, { STATUS } from '../../src/Reactor';
|
|
10
|
-
import InMemoryStorage from '../../src/InMemoryStorage';
|
|
11
|
-
import * as instaml from '../../src/instaml';
|
|
12
|
-
import * as instatx from '../../src/instatx';
|
|
13
|
-
import zenecaAttrs from './data/zeneca/attrs.json';
|
|
14
|
-
import zenecaTriples from './data/zeneca/triples.json';
|
|
15
|
-
import uuid from '../../src/utils/id';
|
|
16
|
-
import { weakHash } from '../../src';
|
|
17
|
-
import { AttrsStoreClass } from '../../src/store';
|
|
18
|
-
|
|
19
|
-
const zenecaAttrsStore = new AttrsStoreClass(
|
|
20
|
-
zenecaAttrs.reduce((res, x) => {
|
|
21
|
-
res[x.id] = x;
|
|
22
|
-
return res;
|
|
23
|
-
}, {}),
|
|
24
|
-
null,
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
async function waitForLoaded(reactor) {
|
|
28
|
-
await reactor.querySubs.waitForMetaToLoad();
|
|
29
|
-
await reactor.kv.waitForMetaToLoad();
|
|
30
|
-
await reactor._pendingMutationsLoaded;
|
|
31
|
-
await reactor.querySubs.flush();
|
|
32
|
-
await reactor.kv.flush();
|
|
33
|
-
await reactor.mutations.flush();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function createReloadableInMemoryStorage() {
|
|
37
|
-
const stores = new Map<string, Map<string, unknown>>();
|
|
38
|
-
|
|
39
|
-
return class ReloadableInMemoryStorage {
|
|
40
|
-
private store: Map<string, unknown>;
|
|
41
|
-
|
|
42
|
-
constructor(appId: string, storeName: string) {
|
|
43
|
-
const key = `${appId}:${storeName}`;
|
|
44
|
-
this.store = stores.get(key) ?? new Map();
|
|
45
|
-
stores.set(key, this.store);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async getItem(key: string) {
|
|
49
|
-
return this.store.get(key) ?? null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async removeItem(key: string) {
|
|
53
|
-
this.store.delete(key);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async multiSet(values: Array<[string, unknown]>) {
|
|
57
|
-
for (const [key, value] of values) {
|
|
58
|
-
this.store.set(key, value);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async getAllKeys() {
|
|
63
|
-
return [...this.store.keys()];
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async function waitForStreamStart(messages) {
|
|
69
|
-
for (let i = 0; i < 10; i++) {
|
|
70
|
-
const message = messages.find((message) => message.op === 'start-stream');
|
|
71
|
-
if (message) {
|
|
72
|
-
return message;
|
|
73
|
-
}
|
|
74
|
-
await sleep(1);
|
|
75
|
-
}
|
|
76
|
-
throw new Error('Timed out waiting for write stream start');
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function captureStreamMessages(reactor) {
|
|
80
|
-
const messages = [];
|
|
81
|
-
reactor._backendrelayStream.trySend = (eventId, message) => {
|
|
82
|
-
messages.push({ 'client-event-id': eventId, ...message });
|
|
83
|
-
};
|
|
84
|
-
return messages;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function createStreamReactor(appId, Storage) {
|
|
88
|
-
const global = globalThis as { window?: unknown; BroadcastChannel?: unknown };
|
|
89
|
-
const window = global.window;
|
|
90
|
-
const broadcastChannel = global.BroadcastChannel;
|
|
91
|
-
global.window = {};
|
|
92
|
-
global.BroadcastChannel = undefined;
|
|
93
|
-
try {
|
|
94
|
-
return new Reactor(
|
|
95
|
-
{
|
|
96
|
-
appId,
|
|
97
|
-
apiURI: 'https://api.example.com',
|
|
98
|
-
websocketURI: 'wss://api.example.com/runtime/session',
|
|
99
|
-
},
|
|
100
|
-
Storage,
|
|
101
|
-
{
|
|
102
|
-
getIsOnline: () => new Promise(() => {}),
|
|
103
|
-
listen: () => {},
|
|
104
|
-
},
|
|
105
|
-
);
|
|
106
|
-
} finally {
|
|
107
|
-
global.window = window;
|
|
108
|
-
global.BroadcastChannel = broadcastChannel;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
test('write streams resume persisted chunks after reload', async () => {
|
|
113
|
-
const appId = uuid();
|
|
114
|
-
const clientId = 'write-stream-client';
|
|
115
|
-
const Storage = createReloadableInMemoryStorage();
|
|
116
|
-
const reactor = createStreamReactor(appId, Storage);
|
|
117
|
-
const messages = captureStreamMessages(reactor);
|
|
118
|
-
const writer = reactor.createWriteStream({ clientId }).getWriter();
|
|
119
|
-
const start = await waitForStreamStart(messages);
|
|
120
|
-
|
|
121
|
-
reactor._handleReceive(0, {
|
|
122
|
-
op: 'start-stream-ok',
|
|
123
|
-
'client-event-id': start['client-event-id'],
|
|
124
|
-
'stream-id': 'stream-1',
|
|
125
|
-
offset: 0,
|
|
126
|
-
});
|
|
127
|
-
await writer.write('hello');
|
|
128
|
-
await writer.write('world');
|
|
129
|
-
reactor._handleReceive(0, {
|
|
130
|
-
op: 'stream-flushed',
|
|
131
|
-
'stream-id': 'stream-1',
|
|
132
|
-
offset: 5,
|
|
133
|
-
done: false,
|
|
134
|
-
});
|
|
135
|
-
await writer.close();
|
|
136
|
-
await reactor.kv.flush();
|
|
137
|
-
await reactor.mutations.flush();
|
|
138
|
-
|
|
139
|
-
const reloadedReactor = createStreamReactor(appId, Storage);
|
|
140
|
-
const reloadedMessages = captureStreamMessages(reloadedReactor);
|
|
141
|
-
reloadedReactor.createWriteStream({ clientId }).getWriter();
|
|
142
|
-
const reloadedStart = await waitForStreamStart(reloadedMessages);
|
|
143
|
-
|
|
144
|
-
expect(reloadedStart['reconnect-token']).toBe(start['reconnect-token']);
|
|
145
|
-
reloadedReactor._handleReceive(0, {
|
|
146
|
-
op: 'start-stream-ok',
|
|
147
|
-
'client-event-id': reloadedStart['client-event-id'],
|
|
148
|
-
'stream-id': 'stream-1',
|
|
149
|
-
offset: 5,
|
|
150
|
-
});
|
|
151
|
-
await sleep(1);
|
|
152
|
-
|
|
153
|
-
expect(reloadedMessages).toContainEqual({
|
|
154
|
-
op: 'append-stream',
|
|
155
|
-
'client-event-id': expect.any(String),
|
|
156
|
-
'stream-id': 'stream-1',
|
|
157
|
-
chunks: ['world'],
|
|
158
|
-
offset: 5,
|
|
159
|
-
done: true,
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
reloadedReactor._handleReceive(0, {
|
|
163
|
-
op: 'stream-flushed',
|
|
164
|
-
'stream-id': 'stream-1',
|
|
165
|
-
offset: 10,
|
|
166
|
-
done: true,
|
|
167
|
-
});
|
|
168
|
-
await reloadedReactor.kv.flush();
|
|
169
|
-
|
|
170
|
-
expect(
|
|
171
|
-
reloadedReactor.kv.currentValue.writeStreams?.[clientId],
|
|
172
|
-
).toBeUndefined();
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
test('aborting a write stream removes its persisted state', async () => {
|
|
176
|
-
const appId = uuid();
|
|
177
|
-
const clientId = 'aborted-write-stream-client';
|
|
178
|
-
const Storage = createReloadableInMemoryStorage();
|
|
179
|
-
const reactor = createStreamReactor(appId, Storage);
|
|
180
|
-
const messages = captureStreamMessages(reactor);
|
|
181
|
-
const writer = reactor.createWriteStream({ clientId }).getWriter();
|
|
182
|
-
const start = await waitForStreamStart(messages);
|
|
183
|
-
|
|
184
|
-
reactor._handleReceive(0, {
|
|
185
|
-
op: 'start-stream-ok',
|
|
186
|
-
'client-event-id': start['client-event-id'],
|
|
187
|
-
'stream-id': 'stream-1',
|
|
188
|
-
offset: 0,
|
|
189
|
-
});
|
|
190
|
-
await writer.abort('cancelled');
|
|
191
|
-
await reactor.kv.flush();
|
|
192
|
-
await reactor.mutations.flush();
|
|
193
|
-
|
|
194
|
-
expect(reactor.kv.currentValue.writeStreams?.[clientId]).toBeUndefined();
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
test('queryOnce runs a fresh one-shot read when the query is already subscribed', async () => {
|
|
198
|
-
const appId = uuid();
|
|
199
|
-
const reactor = new Reactor({ appId });
|
|
200
|
-
reactor._initStorage(IndexedDBStorage);
|
|
201
|
-
reactor._setAttrs(zenecaAttrs);
|
|
202
|
-
await waitForLoaded(reactor);
|
|
203
|
-
|
|
204
|
-
const messages: any[] = [];
|
|
205
|
-
reactor._trySendAuthed = ((eventId: string, msg: any) => {
|
|
206
|
-
messages.push({ eventId, ...msg });
|
|
207
|
-
}) as any;
|
|
208
|
-
|
|
209
|
-
const q = { users: {} };
|
|
210
|
-
let subscribedData: any;
|
|
211
|
-
const subscriber = new Promise((resolve) => {
|
|
212
|
-
reactor.subscribeQuery(q, (result) => {
|
|
213
|
-
subscribedData = result;
|
|
214
|
-
resolve(result);
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
reactor._handleReceive(0, {
|
|
218
|
-
op: 'add-query-ok',
|
|
219
|
-
q,
|
|
220
|
-
'processed-tx-id': 0,
|
|
221
|
-
result: [
|
|
222
|
-
{
|
|
223
|
-
data: { 'datalog-result': { 'join-rows': [zenecaTriples] } },
|
|
224
|
-
'child-nodes': [],
|
|
225
|
-
},
|
|
226
|
-
],
|
|
227
|
-
});
|
|
228
|
-
await subscriber;
|
|
229
|
-
expect(subscribedData.data.users).toHaveLength(4);
|
|
230
|
-
|
|
231
|
-
messages.length = 0;
|
|
232
|
-
const once = reactor.queryOnce(q);
|
|
233
|
-
expect(messages).toHaveLength(1);
|
|
234
|
-
expect(messages[0].op).toBe('query-once');
|
|
235
|
-
|
|
236
|
-
reactor._handleReceive(0, {
|
|
237
|
-
op: 'query-once-ok',
|
|
238
|
-
q,
|
|
239
|
-
'client-event-id': messages[0].eventId,
|
|
240
|
-
'processed-tx-id': 1,
|
|
241
|
-
result: [
|
|
242
|
-
{
|
|
243
|
-
data: { 'datalog-result': { 'join-rows': [] } },
|
|
244
|
-
'child-nodes': [],
|
|
245
|
-
},
|
|
246
|
-
],
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
const fresh = await once;
|
|
250
|
-
expect(fresh.data.users).toEqual([]);
|
|
251
|
-
// The subscription keeps its own result; queryOnce did not replace it.
|
|
252
|
-
expect(subscribedData.data.users).toHaveLength(4);
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
test('querySubs round-trips', async () => {
|
|
256
|
-
const appId = uuid();
|
|
257
|
-
const reactor = new Reactor({ appId });
|
|
258
|
-
reactor._initStorage(IndexedDBStorage);
|
|
259
|
-
reactor._setAttrs(zenecaAttrs);
|
|
260
|
-
const q = { users: {} };
|
|
261
|
-
|
|
262
|
-
await waitForLoaded(reactor);
|
|
263
|
-
|
|
264
|
-
const resultOne = new Promise((resolve, reject) => {
|
|
265
|
-
reactor.subscribeQuery(q, (res) => {
|
|
266
|
-
if (res.error) {
|
|
267
|
-
reject(res.error);
|
|
268
|
-
}
|
|
269
|
-
resolve(res);
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
// Initialize the store
|
|
274
|
-
reactor._handleReceive(0, {
|
|
275
|
-
op: 'add-query-ok',
|
|
276
|
-
q,
|
|
277
|
-
'processed-tx-id': 0,
|
|
278
|
-
result: [
|
|
279
|
-
{
|
|
280
|
-
data: {
|
|
281
|
-
'datalog-result': {
|
|
282
|
-
'join-rows': [zenecaTriples],
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
'child-nodes': [],
|
|
286
|
-
},
|
|
287
|
-
],
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
const data1 = await resultOne;
|
|
291
|
-
|
|
292
|
-
// Make sure the store has the data we expect
|
|
293
|
-
expect(data1.data.users.map((x) => x.handle)).toEqual([
|
|
294
|
-
'joe',
|
|
295
|
-
'alex',
|
|
296
|
-
'stopa',
|
|
297
|
-
'nicolegf',
|
|
298
|
-
]);
|
|
299
|
-
|
|
300
|
-
await waitForLoaded(reactor);
|
|
301
|
-
|
|
302
|
-
// Create a new reactor
|
|
303
|
-
const reactor2 = new Reactor({ appId });
|
|
304
|
-
reactor2._initStorage(IndexedDBStorage);
|
|
305
|
-
reactor2._setAttrs(zenecaAttrs);
|
|
306
|
-
|
|
307
|
-
await waitForLoaded(reactor2);
|
|
308
|
-
await reactor2.querySubs.waitForKeyToLoad(weakHash(q));
|
|
309
|
-
|
|
310
|
-
// Check that it pull the data from indexedDB
|
|
311
|
-
const res = await new Promise((resolve, reject) => {
|
|
312
|
-
reactor2.subscribeQuery(q, (res) => {
|
|
313
|
-
if (res.error) {
|
|
314
|
-
reject(res.error);
|
|
315
|
-
}
|
|
316
|
-
resolve(res);
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
expect(res.data.users.map((x) => x.handle)).toEqual([
|
|
321
|
-
'joe',
|
|
322
|
-
'alex',
|
|
323
|
-
'stopa',
|
|
324
|
-
'nicolegf',
|
|
325
|
-
]);
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
test('rewrite mutations', () => {
|
|
329
|
-
const appId = uuid();
|
|
330
|
-
const reactor = new Reactor({ appId });
|
|
331
|
-
|
|
332
|
-
const bookId = 'bookId';
|
|
333
|
-
const bookshelfId = 'bookshelfId';
|
|
334
|
-
const ops = [
|
|
335
|
-
instatx.tx.books[bookId].update({ title: 'title' }),
|
|
336
|
-
instatx.tx.users[instatx.lookup('handle', 'stopa')].update({
|
|
337
|
-
email: 's@example.com',
|
|
338
|
-
}),
|
|
339
|
-
instatx.tx.bookshelves[bookshelfId].link({
|
|
340
|
-
users: { handle: 'stopa' },
|
|
341
|
-
}),
|
|
342
|
-
instatx.tx.bookshelves[bookshelfId].unlink({
|
|
343
|
-
users: ['handle', 'joe'],
|
|
344
|
-
}),
|
|
345
|
-
instatx.tx.bookshelves[bookshelfId].unlink({
|
|
346
|
-
users: instatx.lookup('handle', 'joe'),
|
|
347
|
-
}),
|
|
348
|
-
];
|
|
349
|
-
|
|
350
|
-
// create transactions without any attributes
|
|
351
|
-
const optimisticSteps = instaml.transform(
|
|
352
|
-
{ attrsStore: new AttrsStoreClass({}, null) },
|
|
353
|
-
ops,
|
|
354
|
-
);
|
|
355
|
-
|
|
356
|
-
const mutations = new Map([['k', { 'tx-steps': optimisticSteps }]]);
|
|
357
|
-
|
|
358
|
-
const rewrittenWithoutAttrs = reactor
|
|
359
|
-
._rewriteMutations(new AttrsStoreClass({}, null), mutations)
|
|
360
|
-
.get('k')['tx-steps'];
|
|
361
|
-
|
|
362
|
-
// Check that we didn't clobber anything in our rewrite
|
|
363
|
-
expect(rewrittenWithoutAttrs).toEqual(optimisticSteps);
|
|
364
|
-
|
|
365
|
-
// rewrite them with the new server attributes
|
|
366
|
-
const rewrittenSteps = reactor
|
|
367
|
-
._rewriteMutations(zenecaAttrsStore, mutations)
|
|
368
|
-
.get('k')['tx-steps'];
|
|
369
|
-
|
|
370
|
-
const serverSteps = instaml.transform({ attrsStore: zenecaAttrsStore }, ops);
|
|
371
|
-
expect(rewrittenSteps).toEqual(serverSteps);
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
test('rewrite mutations works with multiple transactions', () => {
|
|
375
|
-
const appId = uuid();
|
|
376
|
-
const reactor = new Reactor({ appId });
|
|
377
|
-
reactor._initStorage(InMemoryStorage);
|
|
378
|
-
|
|
379
|
-
const bookId = 'bookId';
|
|
380
|
-
const bookshelfId = 'bookshelfId';
|
|
381
|
-
const ops = [
|
|
382
|
-
instatx.tx.books[bookId].update({ title: 'title' }),
|
|
383
|
-
instatx.tx.users[instatx.lookup('handle', 'stopa')].update({
|
|
384
|
-
email: 's@example.com',
|
|
385
|
-
}),
|
|
386
|
-
instatx.tx.bookshelves[bookshelfId].link({
|
|
387
|
-
users: { handle: 'stopa' },
|
|
388
|
-
}),
|
|
389
|
-
instatx.tx.bookshelves[bookshelfId].unlink({
|
|
390
|
-
users: ['handle', 'joe'],
|
|
391
|
-
}),
|
|
392
|
-
instatx.tx.bookshelves[bookshelfId].unlink({
|
|
393
|
-
users: instatx.lookup('handle', 'joe'),
|
|
394
|
-
}),
|
|
395
|
-
];
|
|
396
|
-
|
|
397
|
-
const keys = ['a', 'b', 'c', 'd'];
|
|
398
|
-
|
|
399
|
-
for (const k of keys) {
|
|
400
|
-
const attrs = reactor.optimisticAttrs();
|
|
401
|
-
const steps = instaml.transform({ attrsStore: attrs }, ops);
|
|
402
|
-
const mut = {
|
|
403
|
-
op: 'transact',
|
|
404
|
-
'tx-steps': steps,
|
|
405
|
-
};
|
|
406
|
-
reactor._updatePendingMutations((prev) => {
|
|
407
|
-
prev[k] = mut;
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// rewrite them with the new server attributes
|
|
412
|
-
const rewrittenMutations = reactor._rewriteMutations(
|
|
413
|
-
zenecaAttrsStore,
|
|
414
|
-
reactor._pendingMutations(),
|
|
415
|
-
);
|
|
416
|
-
|
|
417
|
-
const serverSteps = instaml.transform({ attrsStore: zenecaAttrsStore }, ops);
|
|
418
|
-
for (const k of keys) {
|
|
419
|
-
expect(rewrittenMutations.get(k)['tx-steps']).toEqual(serverSteps);
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
test('optimisticTx is not overwritten by refresh-ok', async () => {
|
|
424
|
-
const appId = uuid();
|
|
425
|
-
const reactor = new Reactor({ appId });
|
|
426
|
-
reactor._initStorage(IndexedDBStorage);
|
|
427
|
-
reactor._setAttrs(zenecaAttrs);
|
|
428
|
-
const q = { users: {} };
|
|
429
|
-
const joe_id = 'ce942051-2d74-404a-9c7d-4aa3f2d54ae4';
|
|
430
|
-
|
|
431
|
-
await waitForLoaded(reactor);
|
|
432
|
-
|
|
433
|
-
let data = null;
|
|
434
|
-
|
|
435
|
-
reactor.subscribeQuery(q, (res) => {
|
|
436
|
-
data = res;
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
// Initialize the store
|
|
440
|
-
reactor._handleReceive(0, {
|
|
441
|
-
op: 'add-query-ok',
|
|
442
|
-
q,
|
|
443
|
-
'processed-tx-id': 0,
|
|
444
|
-
result: [
|
|
445
|
-
{
|
|
446
|
-
data: {
|
|
447
|
-
'datalog-result': {
|
|
448
|
-
'join-rows': [zenecaTriples],
|
|
449
|
-
},
|
|
450
|
-
},
|
|
451
|
-
'child-nodes': [],
|
|
452
|
-
},
|
|
453
|
-
],
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
await reactor.querySubs.flush();
|
|
457
|
-
|
|
458
|
-
expect(data.data.users.map((x) => x.handle)).toEqual([
|
|
459
|
-
'joe',
|
|
460
|
-
'alex',
|
|
461
|
-
'stopa',
|
|
462
|
-
'nicolegf',
|
|
463
|
-
]);
|
|
464
|
-
|
|
465
|
-
// first optimistic
|
|
466
|
-
const ops2 = [
|
|
467
|
-
instatx.tx.users[joe_id].update({
|
|
468
|
-
handle: 'joe2',
|
|
469
|
-
}),
|
|
470
|
-
];
|
|
471
|
-
|
|
472
|
-
reactor.pushTx(ops2);
|
|
473
|
-
|
|
474
|
-
await reactor.querySubs.flush();
|
|
475
|
-
|
|
476
|
-
expect(data.data.users.map((x) => x.handle)).toEqual([
|
|
477
|
-
'joe2',
|
|
478
|
-
'alex',
|
|
479
|
-
'stopa',
|
|
480
|
-
'nicolegf',
|
|
481
|
-
]);
|
|
482
|
-
|
|
483
|
-
const [eventId2] = reactor._pendingMutations().keys();
|
|
484
|
-
|
|
485
|
-
// second optimistic
|
|
486
|
-
const ops3 = [
|
|
487
|
-
instatx.tx.users[joe_id].update({
|
|
488
|
-
handle: 'joe3',
|
|
489
|
-
}),
|
|
490
|
-
];
|
|
491
|
-
|
|
492
|
-
reactor.pushTx(ops3);
|
|
493
|
-
|
|
494
|
-
await reactor.querySubs.flush();
|
|
495
|
-
|
|
496
|
-
expect(data.data.users.map((x) => x.handle)).toEqual([
|
|
497
|
-
'joe3',
|
|
498
|
-
'alex',
|
|
499
|
-
'stopa',
|
|
500
|
-
'nicolegf',
|
|
501
|
-
]);
|
|
502
|
-
|
|
503
|
-
const [_, eventId3] = reactor._pendingMutations().keys();
|
|
504
|
-
|
|
505
|
-
// confirmation from server for first optimistic
|
|
506
|
-
reactor._handleReceive(1, {
|
|
507
|
-
op: 'transact-ok',
|
|
508
|
-
'client-event-id': eventId2,
|
|
509
|
-
'tx-id': 100,
|
|
510
|
-
});
|
|
511
|
-
|
|
512
|
-
await waitForLoaded(reactor);
|
|
513
|
-
|
|
514
|
-
expect(data.data.users.map((x) => x.handle)).toEqual([
|
|
515
|
-
'joe3',
|
|
516
|
-
'alex',
|
|
517
|
-
'stopa',
|
|
518
|
-
'nicolegf',
|
|
519
|
-
]);
|
|
520
|
-
|
|
521
|
-
// query refresh after first tx
|
|
522
|
-
reactor._handleReceive(3, {
|
|
523
|
-
op: 'refresh-ok',
|
|
524
|
-
'processed-tx-id': 100,
|
|
525
|
-
attrs: zenecaAttrs,
|
|
526
|
-
computations: [
|
|
527
|
-
{
|
|
528
|
-
'instaql-query': q,
|
|
529
|
-
'instaql-result': [
|
|
530
|
-
{
|
|
531
|
-
data: {
|
|
532
|
-
'datalog-result': {
|
|
533
|
-
'join-rows': [zenecaTriples],
|
|
534
|
-
},
|
|
535
|
-
},
|
|
536
|
-
'child-nodes': [],
|
|
537
|
-
},
|
|
538
|
-
],
|
|
539
|
-
},
|
|
540
|
-
],
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
// make sure it doesn’t override local results
|
|
544
|
-
await waitForLoaded(reactor);
|
|
545
|
-
|
|
546
|
-
expect(data.data.users.map((x) => x.handle)).toEqual([
|
|
547
|
-
'joe3',
|
|
548
|
-
'alex',
|
|
549
|
-
'stopa',
|
|
550
|
-
'nicolegf',
|
|
551
|
-
]);
|
|
552
|
-
|
|
553
|
-
// confirmation from server for second optimistic
|
|
554
|
-
reactor._handleReceive(2, {
|
|
555
|
-
op: 'transact-ok',
|
|
556
|
-
'client-event-id': eventId3,
|
|
557
|
-
'tx-id': 101,
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
await waitForLoaded(reactor);
|
|
561
|
-
|
|
562
|
-
expect(data.data.users.map((x) => x.handle)).toEqual([
|
|
563
|
-
'joe3',
|
|
564
|
-
'alex',
|
|
565
|
-
'stopa',
|
|
566
|
-
'nicolegf',
|
|
567
|
-
]);
|
|
568
|
-
|
|
569
|
-
// make sure it still doesn’t override local results
|
|
570
|
-
await waitForLoaded(reactor);
|
|
571
|
-
|
|
572
|
-
expect(data.data.users.map((x) => x.handle)).toEqual([
|
|
573
|
-
'joe3',
|
|
574
|
-
'alex',
|
|
575
|
-
'stopa',
|
|
576
|
-
'nicolegf',
|
|
577
|
-
]);
|
|
578
|
-
});
|
|
579
|
-
|
|
580
|
-
test("we don't cleanup mutations we're still waiting on", async () => {
|
|
581
|
-
const appId = uuid();
|
|
582
|
-
const reactor = new Reactor({
|
|
583
|
-
appId,
|
|
584
|
-
pendingTxCleanupTimeout: 1,
|
|
585
|
-
pendingMutationCleanupThreshold: 0,
|
|
586
|
-
});
|
|
587
|
-
|
|
588
|
-
reactor._initStorage(IndexedDBStorage);
|
|
589
|
-
reactor._setAttrs(zenecaAttrs);
|
|
590
|
-
const q = { users: {} };
|
|
591
|
-
const joe_id = 'ce942051-2d74-404a-9c7d-4aa3f2d54ae4';
|
|
592
|
-
|
|
593
|
-
await waitForLoaded(reactor);
|
|
594
|
-
|
|
595
|
-
// Add two transactions
|
|
596
|
-
const ops1 = [
|
|
597
|
-
instatx.tx.users[joe_id].update({
|
|
598
|
-
handle: 'joe2',
|
|
599
|
-
}),
|
|
600
|
-
];
|
|
601
|
-
|
|
602
|
-
reactor.pushTx(ops1);
|
|
603
|
-
|
|
604
|
-
const ops2 = [
|
|
605
|
-
instatx.tx.users[joe_id].update({
|
|
606
|
-
handle: 'joe2',
|
|
607
|
-
}),
|
|
608
|
-
];
|
|
609
|
-
|
|
610
|
-
reactor.pushTx(ops2);
|
|
611
|
-
|
|
612
|
-
await reactor.kv.flush();
|
|
613
|
-
await reactor.mutations.flush();
|
|
614
|
-
|
|
615
|
-
const [ev1, ev2] = reactor._pendingMutations().keys();
|
|
616
|
-
|
|
617
|
-
// Mark one as received
|
|
618
|
-
reactor._handleReceive(1, {
|
|
619
|
-
op: 'transact-ok',
|
|
620
|
-
'client-event-id': ev1,
|
|
621
|
-
'tx-id': 100,
|
|
622
|
-
});
|
|
623
|
-
|
|
624
|
-
// Wait for the pendingTxCleanupTimeout to expire
|
|
625
|
-
await sleep(10);
|
|
626
|
-
|
|
627
|
-
// Cleanup shouldn't remove the mutation we're still waiting on
|
|
628
|
-
await reactor._cleanupPendingMutationsTimeout();
|
|
629
|
-
|
|
630
|
-
const remainingKeys = new Array(...reactor._pendingMutations().keys());
|
|
631
|
-
|
|
632
|
-
expect(remainingKeys).toStrictEqual([ev2]);
|
|
633
|
-
|
|
634
|
-
// Optimistic-only transactions apply locally and roll back without ever
|
|
635
|
-
// entering the send/replay path.
|
|
636
|
-
const optimistic = reactor.pushOptimisticTx([
|
|
637
|
-
instatx.tx.users[joe_id].update({ handle: 'optimistic' }),
|
|
638
|
-
]);
|
|
639
|
-
await reactor.querySubs.flush();
|
|
640
|
-
expect(
|
|
641
|
-
[...reactor._pendingMutations().values()].some((mut) => mut.optimistic),
|
|
642
|
-
).toBe(true);
|
|
643
|
-
|
|
644
|
-
optimistic.rollback();
|
|
645
|
-
await reactor.querySubs.flush();
|
|
646
|
-
expect(
|
|
647
|
-
[...reactor._pendingMutations().values()].some((mut) => mut.optimistic),
|
|
648
|
-
).toBe(false);
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
test('getLocalId always returns the same id', async () => {
|
|
652
|
-
const appId = uuid();
|
|
653
|
-
|
|
654
|
-
const idbs = new Map();
|
|
655
|
-
|
|
656
|
-
// Class that reuses the same underlying storage for indexeddb.
|
|
657
|
-
// This will make fake-indexeddb act more like the browser, otherwise
|
|
658
|
-
// we get a fresh in-memory store each time we call indexedDB.open
|
|
659
|
-
class IDBStorage {
|
|
660
|
-
constructor(appId, dbName) {
|
|
661
|
-
if (idbs.get(dbName)) {
|
|
662
|
-
return idbs.get(dbName);
|
|
663
|
-
}
|
|
664
|
-
const idb = new IndexedDBStorage(appId, dbName);
|
|
665
|
-
idbs.set(dbName, idb);
|
|
666
|
-
return idb;
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
const reactor = new Reactor({
|
|
671
|
-
appId,
|
|
672
|
-
pendingTxCleanupTimeout: 1,
|
|
673
|
-
pendingMutationCleanupThreshold: 0,
|
|
674
|
-
});
|
|
675
|
-
|
|
676
|
-
reactor._initStorage(IDBStorage);
|
|
677
|
-
|
|
678
|
-
const promises = [];
|
|
679
|
-
|
|
680
|
-
const ids = new Set();
|
|
681
|
-
|
|
682
|
-
for (const _ of [...new Array(1000)]) {
|
|
683
|
-
const p = reactor.getLocalId('id').then((id) => ids.add(id));
|
|
684
|
-
promises.push(p);
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
await Promise.all(promises);
|
|
688
|
-
|
|
689
|
-
expect(ids.size).toBe(1);
|
|
690
|
-
await reactor.querySubs.flush();
|
|
691
|
-
|
|
692
|
-
await reactor.kv.flush();
|
|
693
|
-
await reactor.mutations.flush();
|
|
694
|
-
|
|
695
|
-
const reactor2 = new Reactor({
|
|
696
|
-
appId,
|
|
697
|
-
pendingTxCleanupTimeout: 1,
|
|
698
|
-
pendingMutationCleanupThreshold: 0,
|
|
699
|
-
});
|
|
700
|
-
|
|
701
|
-
async function idbSnapshot(idb, { includeMeta }) {
|
|
702
|
-
const keys = await idb.getAllKeys();
|
|
703
|
-
const res = {};
|
|
704
|
-
for (const key of keys) {
|
|
705
|
-
if (key === '__meta' && !includeMeta) {
|
|
706
|
-
continue;
|
|
707
|
-
}
|
|
708
|
-
res[key] = await idb.getItem(key);
|
|
709
|
-
}
|
|
710
|
-
return res;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
reactor2._initStorage(IDBStorage);
|
|
714
|
-
|
|
715
|
-
const id = await reactor2.getLocalId('id');
|
|
716
|
-
|
|
717
|
-
expect(id).toStrictEqual([...ids][0]);
|
|
718
|
-
});
|
|
719
|
-
|
|
720
|
-
async function makeLegacyDb(name, stores, fill) {
|
|
721
|
-
const db = await new Promise((resolve, reject) => {
|
|
722
|
-
const req = indexedDB.open(name, 1);
|
|
723
|
-
req.onupgradeneeded = () => {
|
|
724
|
-
for (const storeName of stores) {
|
|
725
|
-
req.result.createObjectStore(storeName);
|
|
726
|
-
}
|
|
727
|
-
};
|
|
728
|
-
req.onsuccess = () => resolve(req.result);
|
|
729
|
-
req.onerror = () => reject(req.error);
|
|
730
|
-
});
|
|
731
|
-
await new Promise((resolve, reject) => {
|
|
732
|
-
const tx = db.transaction(stores, 'readwrite');
|
|
733
|
-
fill(tx);
|
|
734
|
-
tx.oncomplete = () => resolve();
|
|
735
|
-
tx.onerror = () => reject(tx.error);
|
|
736
|
-
});
|
|
737
|
-
db.close();
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
test('pending mutations persist as one row per mutation', async () => {
|
|
741
|
-
const appId = uuid();
|
|
742
|
-
const reactor = new Reactor({ appId });
|
|
743
|
-
reactor._initStorage(IndexedDBStorage);
|
|
744
|
-
reactor._setAttrs(zenecaAttrs);
|
|
745
|
-
await waitForLoaded(reactor);
|
|
746
|
-
|
|
747
|
-
reactor.pushTx([instatx.tx.books[uuid()].update({ title: 'one' })]);
|
|
748
|
-
reactor
|
|
749
|
-
.pushTx([instatx.tx.books[uuid()].update({ title: 'two' })])
|
|
750
|
-
.catch(() => {});
|
|
751
|
-
const [ev1, ev2] = [...reactor._pendingMutations().keys()];
|
|
752
|
-
await reactor.mutations.flush();
|
|
753
|
-
|
|
754
|
-
const mutationStore = new IndexedDBStorage(appId, 'mutations');
|
|
755
|
-
const keys = await mutationStore.getAllKeys();
|
|
756
|
-
expect(keys).toContain(ev1);
|
|
757
|
-
expect(keys).toContain(ev2);
|
|
758
|
-
expect(await mutationStore.getItem(ev1)).toMatchObject({ op: 'transact' });
|
|
759
|
-
|
|
760
|
-
// The kv store no longer holds the old blob
|
|
761
|
-
const kvStore = new IndexedDBStorage(appId, 'kv');
|
|
762
|
-
expect(await kvStore.getItem('pendingMutations')).toBeNull();
|
|
763
|
-
|
|
764
|
-
// Deleting a mutation removes just its row
|
|
765
|
-
reactor._handleMutationError('error', ev2, { message: 'test' });
|
|
766
|
-
await reactor.mutations.flush();
|
|
767
|
-
const keysAfter = await mutationStore.getAllKeys();
|
|
768
|
-
expect(keysAfter).toContain(ev1);
|
|
769
|
-
expect(keysAfter).not.toContain(ev2);
|
|
770
|
-
});
|
|
771
|
-
|
|
772
|
-
test('pending mutations round-trip across reloads and unconfirmed ones are re-sent', async () => {
|
|
773
|
-
const appId = uuid();
|
|
774
|
-
const reactor = new Reactor({ appId });
|
|
775
|
-
reactor._initStorage(IndexedDBStorage);
|
|
776
|
-
reactor._setAttrs(zenecaAttrs);
|
|
777
|
-
await waitForLoaded(reactor);
|
|
778
|
-
|
|
779
|
-
reactor.pushTx([instatx.tx.books[uuid()].update({ title: 'offline' })]);
|
|
780
|
-
const [eventId] = [...reactor._pendingMutations().keys()];
|
|
781
|
-
await reactor.mutations.flush();
|
|
782
|
-
|
|
783
|
-
const reactor2 = new Reactor({ appId });
|
|
784
|
-
const sent = [];
|
|
785
|
-
reactor2._sendMutation = (evId, _mut) => {
|
|
786
|
-
sent.push(evId);
|
|
787
|
-
};
|
|
788
|
-
reactor2._initStorage(IndexedDBStorage);
|
|
789
|
-
await waitForLoaded(reactor2);
|
|
790
|
-
|
|
791
|
-
expect([...reactor2._pendingMutations().keys()]).toEqual([eventId]);
|
|
792
|
-
expect(sent).toEqual([eventId]);
|
|
793
|
-
});
|
|
794
|
-
|
|
795
|
-
test('upgrades v6 databases, splitting pending mutations into rows', async () => {
|
|
796
|
-
const appId = uuid();
|
|
797
|
-
const mutA = { op: 'transact', 'tx-steps': [], created: 1, order: 1 };
|
|
798
|
-
const mutB = {
|
|
799
|
-
op: 'transact',
|
|
800
|
-
'tx-steps': [],
|
|
801
|
-
created: 2,
|
|
802
|
-
order: 2,
|
|
803
|
-
'tx-id': 5,
|
|
804
|
-
};
|
|
805
|
-
await makeLegacyDb(
|
|
806
|
-
`instant_${appId}_6`,
|
|
807
|
-
['kv', 'querySubs', 'syncSubs'],
|
|
808
|
-
(tx) => {
|
|
809
|
-
const kv = tx.objectStore('kv');
|
|
810
|
-
kv.put(
|
|
811
|
-
[
|
|
812
|
-
['evA', mutA],
|
|
813
|
-
['evB', mutB],
|
|
814
|
-
],
|
|
815
|
-
'pendingMutations',
|
|
816
|
-
);
|
|
817
|
-
kv.put({ id: 'u1' }, 'currentUser');
|
|
818
|
-
kv.put(
|
|
819
|
-
{
|
|
820
|
-
objects: {
|
|
821
|
-
pendingMutations: { createdAt: 1, updatedAt: 1, size: 0 },
|
|
822
|
-
currentUser: { createdAt: 1, updatedAt: 1, size: 0 },
|
|
823
|
-
},
|
|
824
|
-
},
|
|
825
|
-
'__meta',
|
|
826
|
-
);
|
|
827
|
-
tx.objectStore('querySubs').put({ some: 'sub' }, 'hash1');
|
|
828
|
-
},
|
|
829
|
-
);
|
|
830
|
-
|
|
831
|
-
const mutationStore = new IndexedDBStorage(appId, 'mutations');
|
|
832
|
-
expect(await mutationStore.getItem('evA')).toEqual(mutA);
|
|
833
|
-
expect(await mutationStore.getItem('evB')).toEqual(mutB);
|
|
834
|
-
// The migration writes a meta row so boot can enumerate the mutations
|
|
835
|
-
expect((await mutationStore.getItem('__meta')).objects).toHaveProperty('evA');
|
|
836
|
-
|
|
837
|
-
const kvStore = new IndexedDBStorage(appId, 'kv');
|
|
838
|
-
expect(await kvStore.getItem('pendingMutations')).toBeNull();
|
|
839
|
-
expect(await kvStore.getItem('currentUser')).toEqual({ id: 'u1' });
|
|
840
|
-
expect(
|
|
841
|
-
(await kvStore.getItem('__meta')).objects.pendingMutations,
|
|
842
|
-
).toBeUndefined();
|
|
843
|
-
|
|
844
|
-
const querySubStore = new IndexedDBStorage(appId, 'querySubs');
|
|
845
|
-
expect(await querySubStore.getItem('hash1')).toEqual({ some: 'sub' });
|
|
846
|
-
});
|
|
847
|
-
|
|
848
|
-
test('a reactor booting on migrated v6 data adopts and re-sends unconfirmed mutations', async () => {
|
|
849
|
-
const appId = uuid();
|
|
850
|
-
const mutA = { op: 'transact', 'tx-steps': [], created: 1, order: 1 };
|
|
851
|
-
const mutB = {
|
|
852
|
-
op: 'transact',
|
|
853
|
-
'tx-steps': [],
|
|
854
|
-
created: 2,
|
|
855
|
-
order: 2,
|
|
856
|
-
'tx-id': 5,
|
|
857
|
-
};
|
|
858
|
-
await makeLegacyDb(
|
|
859
|
-
`instant_${appId}_6`,
|
|
860
|
-
['kv', 'querySubs', 'syncSubs'],
|
|
861
|
-
(tx) => {
|
|
862
|
-
tx.objectStore('kv').put(
|
|
863
|
-
[
|
|
864
|
-
['evA', mutA],
|
|
865
|
-
['evB', mutB],
|
|
866
|
-
],
|
|
867
|
-
'pendingMutations',
|
|
868
|
-
);
|
|
869
|
-
},
|
|
870
|
-
);
|
|
871
|
-
|
|
872
|
-
const reactor = new Reactor({ appId });
|
|
873
|
-
const sent = [];
|
|
874
|
-
reactor._sendMutation = (evId, _mut) => {
|
|
875
|
-
sent.push(evId);
|
|
876
|
-
};
|
|
877
|
-
reactor._initStorage(IndexedDBStorage);
|
|
878
|
-
await waitForLoaded(reactor);
|
|
879
|
-
|
|
880
|
-
expect([...reactor._pendingMutations().keys()].sort()).toEqual([
|
|
881
|
-
'evA',
|
|
882
|
-
'evB',
|
|
883
|
-
]);
|
|
884
|
-
// evA was never confirmed by the server, so it gets re-sent; evB has a
|
|
885
|
-
// tx-id and does not
|
|
886
|
-
expect(sent).toEqual(['evA']);
|
|
887
|
-
});
|
|
888
|
-
|
|
889
|
-
test('upgrades v5 databases through to per-mutation rows', async () => {
|
|
890
|
-
const appId = uuid();
|
|
891
|
-
const mutOld = { op: 'transact', 'tx-steps': [], created: 1, order: 1 };
|
|
892
|
-
await makeLegacyDb(`instant_${appId}_5`, ['kv'], (tx) => {
|
|
893
|
-
const kv = tx.objectStore('kv');
|
|
894
|
-
// v5 JSON.stringified values before storing
|
|
895
|
-
kv.put(JSON.stringify([['evOld', mutOld]]), 'pendingMutations');
|
|
896
|
-
kv.put({ id: 'u5' }, 'currentUser');
|
|
897
|
-
});
|
|
898
|
-
|
|
899
|
-
const mutationStore = new IndexedDBStorage(appId, 'mutations');
|
|
900
|
-
expect(await mutationStore.getItem('evOld')).toEqual(mutOld);
|
|
901
|
-
|
|
902
|
-
const kvStore = new IndexedDBStorage(appId, 'kv');
|
|
903
|
-
expect(await kvStore.getItem('pendingMutations')).toBeNull();
|
|
904
|
-
expect(await kvStore.getItem('currentUser')).toEqual({ id: 'u5' });
|
|
905
|
-
});
|
|
906
|
-
|
|
907
|
-
test('migration retries after an aborted atomic copy and preserves the old database', async () => {
|
|
908
|
-
const appId = uuid();
|
|
909
|
-
const mutation = { op: 'transact', 'tx-steps': [], created: 1, order: 1 };
|
|
910
|
-
await makeLegacyDb(
|
|
911
|
-
`instant_${appId}_6`,
|
|
912
|
-
['kv', 'querySubs', 'syncSubs'],
|
|
913
|
-
(tx) => {
|
|
914
|
-
tx.objectStore('kv').put([['retry-me', mutation]], 'pendingMutations');
|
|
915
|
-
},
|
|
916
|
-
);
|
|
917
|
-
const originalCommit = IDBTransaction.prototype.commit;
|
|
918
|
-
IDBTransaction.prototype.commit = function () {
|
|
919
|
-
if (this.objectStoreNames.contains('_migrations')) this.abort();
|
|
920
|
-
else originalCommit.call(this);
|
|
921
|
-
};
|
|
922
|
-
try {
|
|
923
|
-
const failed = new IndexedDBStorage(appId, 'mutations');
|
|
924
|
-
expect(await failed._dbPromise).toBeNull();
|
|
925
|
-
} finally {
|
|
926
|
-
IDBTransaction.prototype.commit = originalCommit;
|
|
927
|
-
}
|
|
928
|
-
const retried = new IndexedDBStorage(appId, 'mutations');
|
|
929
|
-
expect(await retried.getItem('retry-me')).toEqual(mutation);
|
|
930
|
-
await retried.removeItem('retry-me');
|
|
931
|
-
const reopened = new IndexedDBStorage(appId, 'mutations');
|
|
932
|
-
expect(await reopened.getItem('retry-me')).toBeNull();
|
|
933
|
-
const old = await new Promise<IDBDatabase>((resolve, reject) => {
|
|
934
|
-
const request = indexedDB.open(`instant_${appId}_6`);
|
|
935
|
-
request.onsuccess = () => resolve(request.result);
|
|
936
|
-
request.onerror = () => reject(request.error);
|
|
937
|
-
});
|
|
938
|
-
const saved = await new Promise((resolve) => {
|
|
939
|
-
const request = old
|
|
940
|
-
.transaction('kv')
|
|
941
|
-
.objectStore('kv')
|
|
942
|
-
.get('pendingMutations');
|
|
943
|
-
request.onsuccess = () => resolve(request.result);
|
|
944
|
-
});
|
|
945
|
-
expect(saved).toEqual([['retry-me', mutation]]);
|
|
946
|
-
old.close();
|
|
947
|
-
});
|
|
948
|
-
|
|
949
|
-
test('an auth change cannot replay a mutation from a delayed persistence read', async () => {
|
|
950
|
-
const appId = uuid();
|
|
951
|
-
await makeLegacyDb(
|
|
952
|
-
`instant_${appId}_6`,
|
|
953
|
-
['kv', 'querySubs', 'syncSubs'],
|
|
954
|
-
(tx) => {
|
|
955
|
-
tx.objectStore('kv').put(
|
|
956
|
-
[
|
|
957
|
-
[
|
|
958
|
-
'old-user',
|
|
959
|
-
{ op: 'transact', 'tx-steps': [], created: 1, order: 1 },
|
|
960
|
-
],
|
|
961
|
-
],
|
|
962
|
-
'pendingMutations',
|
|
963
|
-
);
|
|
964
|
-
},
|
|
965
|
-
);
|
|
966
|
-
let release!: () => void;
|
|
967
|
-
let readStarted!: () => void;
|
|
968
|
-
const gate = new Promise<void>((resolve) => {
|
|
969
|
-
release = resolve;
|
|
970
|
-
});
|
|
971
|
-
const started = new Promise<void>((resolve) => {
|
|
972
|
-
readStarted = resolve;
|
|
973
|
-
});
|
|
974
|
-
class DelayedStorage extends IndexedDBStorage {
|
|
975
|
-
async getItem(key: string) {
|
|
976
|
-
const result = await super.getItem(key);
|
|
977
|
-
if (key === 'old-user') {
|
|
978
|
-
readStarted();
|
|
979
|
-
await gate;
|
|
980
|
-
}
|
|
981
|
-
return result;
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
const reactor = new Reactor({ appId });
|
|
985
|
-
const sent: string[] = [];
|
|
986
|
-
reactor._sendMutation = (id) => sent.push(id);
|
|
987
|
-
reactor._transport = { close() {} } as any;
|
|
988
|
-
reactor._initStorage(DelayedStorage);
|
|
989
|
-
await started;
|
|
990
|
-
await reactor.updateUser(null);
|
|
991
|
-
release();
|
|
992
|
-
await reactor._pendingMutationsLoaded;
|
|
993
|
-
await reactor.mutations.flush();
|
|
994
|
-
expect(sent).toEqual([]);
|
|
995
|
-
expect([...reactor._pendingMutations()]).toEqual([]);
|
|
996
|
-
expect(
|
|
997
|
-
await new IndexedDBStorage(appId, 'mutations').getItem('old-user'),
|
|
998
|
-
).toBeNull();
|
|
999
|
-
});
|
|
1000
|
-
|
|
1001
|
-
test('independent browser contexts publish the legacy migration only once', async () => {
|
|
1002
|
-
const appId = uuid();
|
|
1003
|
-
await makeLegacyDb(
|
|
1004
|
-
`instant_${appId}_6`,
|
|
1005
|
-
['kv', 'querySubs', 'syncSubs'],
|
|
1006
|
-
(tx) => {
|
|
1007
|
-
tx.objectStore('kv').put([['event', { order: 1 }]], 'pendingMutations');
|
|
1008
|
-
},
|
|
1009
|
-
);
|
|
1010
|
-
vi.resetModules();
|
|
1011
|
-
const First = (await import('../../src/IndexedDBStorage')).default;
|
|
1012
|
-
vi.resetModules();
|
|
1013
|
-
const Second = (await import('../../src/IndexedDBStorage')).default;
|
|
1014
|
-
const writes = vi.spyOn(IDBObjectStore.prototype, 'put');
|
|
1015
|
-
try {
|
|
1016
|
-
const a = new First(appId, 'mutations');
|
|
1017
|
-
const b = new Second(appId, 'mutations');
|
|
1018
|
-
await Promise.all([a._dbPromise, b._dbPromise]);
|
|
1019
|
-
const copies = writes.mock.calls.filter(
|
|
1020
|
-
(args, i) =>
|
|
1021
|
-
args[1] === 'event' && writes.mock.contexts[i].name === 'mutations',
|
|
1022
|
-
);
|
|
1023
|
-
expect(copies).toHaveLength(1);
|
|
1024
|
-
await a.removeItem('event');
|
|
1025
|
-
expect(await b.getItem('event')).toBeNull();
|
|
1026
|
-
} finally {
|
|
1027
|
-
writes.mockRestore();
|
|
1028
|
-
}
|
|
1029
|
-
});
|
|
1030
|
-
|
|
1031
|
-
test('auth changes clear the durable queue before persisting the new identity', async () => {
|
|
1032
|
-
const Storage = createReloadableInMemoryStorage();
|
|
1033
|
-
const appId = uuid();
|
|
1034
|
-
const kv = new Storage(appId, 'kv');
|
|
1035
|
-
await kv.multiSet([
|
|
1036
|
-
['currentUser', { id: 'old-user' }],
|
|
1037
|
-
['pendingMutations', [['old-event', { order: 1 }]]],
|
|
1038
|
-
]);
|
|
1039
|
-
const reactor = createStreamReactor(appId, Storage);
|
|
1040
|
-
reactor._transport = { close() {} } as any;
|
|
1041
|
-
await waitForLoaded(reactor);
|
|
1042
|
-
const setUser = reactor.setCurrentUser.bind(reactor);
|
|
1043
|
-
let changed = false;
|
|
1044
|
-
reactor.setCurrentUser = async (user) => {
|
|
1045
|
-
expect(
|
|
1046
|
-
await new Storage(appId, 'mutations').getItem('old-event'),
|
|
1047
|
-
).toBeNull();
|
|
1048
|
-
expect(await kv.getItem('currentUser')).toEqual({ id: 'old-user' });
|
|
1049
|
-
changed = true;
|
|
1050
|
-
await setUser(user);
|
|
1051
|
-
};
|
|
1052
|
-
await reactor.changeCurrentUser({ id: 'new-user' } as any);
|
|
1053
|
-
expect(changed).toBe(true);
|
|
1054
|
-
reactor.shutdown();
|
|
1055
|
-
});
|
|
1056
|
-
|
|
1057
|
-
test('reconnect backoff is full-jitter exponential and restarts on 1012', () => {
|
|
1058
|
-
const reactor = createStreamReactor(uuid(), InMemoryStorage);
|
|
1059
|
-
const transport = { id: 'ws_0', close() {} } as any;
|
|
1060
|
-
reactor._transport = transport;
|
|
1061
|
-
reactor._wsOk = true;
|
|
1062
|
-
const delays: number[] = [];
|
|
1063
|
-
const setTimeoutSpy = vi.spyOn(globalThis, 'setTimeout').mockImplementation(((
|
|
1064
|
-
fn: () => void,
|
|
1065
|
-
ms?: number,
|
|
1066
|
-
) => {
|
|
1067
|
-
delays.push(ms ?? 0);
|
|
1068
|
-
return 0 as any;
|
|
1069
|
-
}) as any);
|
|
1070
|
-
const randomSpy = vi.spyOn(Math, 'random').mockReturnValue(0.5);
|
|
1071
|
-
try {
|
|
1072
|
-
for (let attempt = 0; attempt < 8; attempt++) {
|
|
1073
|
-
reactor._transportOnClose({ target: transport, code: 1006 });
|
|
1074
|
-
}
|
|
1075
|
-
// Ceiling is min(10s, 250ms * 2^attempt); half of it at random() = 0.5.
|
|
1076
|
-
expect(delays).toEqual([125, 250, 500, 1000, 2000, 4000, 5000, 5000]);
|
|
1077
|
-
|
|
1078
|
-
reactor._transportOnClose({ target: transport, code: 1012 });
|
|
1079
|
-
expect(delays.at(-1)).toBe(125);
|
|
1080
|
-
expect(reactor._reconnectAttempt).toBe(1);
|
|
1081
|
-
} finally {
|
|
1082
|
-
setTimeoutSpy.mockRestore();
|
|
1083
|
-
randomSpy.mockRestore();
|
|
1084
|
-
}
|
|
1085
|
-
});
|
|
1086
|
-
|
|
1087
|
-
test('transient add-query errors are retried instead of surfaced', async () => {
|
|
1088
|
-
const reactor = createStreamReactor(uuid(), InMemoryStorage);
|
|
1089
|
-
await waitForLoaded(reactor);
|
|
1090
|
-
reactor.status = STATUS.AUTHENTICATED;
|
|
1091
|
-
const retries: any[] = [];
|
|
1092
|
-
const surfaced: any[] = [];
|
|
1093
|
-
reactor._trySendAuthed = ((_eventId: string, msg: any) => {
|
|
1094
|
-
retries.push(msg);
|
|
1095
|
-
}) as any;
|
|
1096
|
-
reactor.notifyQueryError = ((_hash: string, error: any) => {
|
|
1097
|
-
surfaced.push(error);
|
|
1098
|
-
}) as any;
|
|
1099
|
-
reactor.notifyQueryOnceError = (() => {}) as any;
|
|
1100
|
-
const q = { goals: {} };
|
|
1101
|
-
const transientError = {
|
|
1102
|
-
op: 'error',
|
|
1103
|
-
status: 429,
|
|
1104
|
-
type: 'rate-limited',
|
|
1105
|
-
message: 'slow down',
|
|
1106
|
-
'client-event-id': 'event-1',
|
|
1107
|
-
'original-event': { op: 'add-query', q },
|
|
1108
|
-
};
|
|
1109
|
-
|
|
1110
|
-
vi.useFakeTimers();
|
|
1111
|
-
try {
|
|
1112
|
-
reactor._handleReceiveError(transientError);
|
|
1113
|
-
expect(surfaced).toEqual([]);
|
|
1114
|
-
expect(retries).toEqual([]);
|
|
1115
|
-
await vi.advanceTimersByTimeAsync(20_000);
|
|
1116
|
-
expect(retries).toEqual([{ op: 'add-query', q }]);
|
|
1117
|
-
|
|
1118
|
-
for (let attempt = 0; attempt < 5; attempt++) {
|
|
1119
|
-
reactor._handleReceiveError(transientError);
|
|
1120
|
-
await vi.advanceTimersByTimeAsync(20_000);
|
|
1121
|
-
}
|
|
1122
|
-
// Five retries were scheduled; the next transient failure surfaces.
|
|
1123
|
-
expect(retries).toHaveLength(5);
|
|
1124
|
-
expect(surfaced).toHaveLength(1);
|
|
1125
|
-
|
|
1126
|
-
reactor._addQueryRetryAttempts.clear();
|
|
1127
|
-
reactor._handleReceiveError({
|
|
1128
|
-
...transientError,
|
|
1129
|
-
status: 400,
|
|
1130
|
-
type: 'validation-failed',
|
|
1131
|
-
});
|
|
1132
|
-
expect(surfaced).toHaveLength(2);
|
|
1133
|
-
expect(retries).toHaveLength(5);
|
|
1134
|
-
} finally {
|
|
1135
|
-
vi.useRealTimers();
|
|
1136
|
-
}
|
|
1137
|
-
});
|
|
1138
|
-
|
|
1139
|
-
test('a throwing message handler does not drop the rest of a batch', () => {
|
|
1140
|
-
const appId = uuid();
|
|
1141
|
-
const reactor = new Reactor({ appId });
|
|
1142
|
-
reactor._initStorage(IndexedDBStorage);
|
|
1143
|
-
|
|
1144
|
-
// Topic cbs run synchronously inside _handleReceive, so the first
|
|
1145
|
-
// message's throw escapes its dispatch.
|
|
1146
|
-
const seen: any[] = [];
|
|
1147
|
-
reactor.subscribeTopic('room', 'room-1', 'topic', (data) => {
|
|
1148
|
-
seen.push(data);
|
|
1149
|
-
if (data === 'boom') throw new Error('subscriber exploded');
|
|
1150
|
-
});
|
|
1151
|
-
|
|
1152
|
-
const transport = { id: 'ws_0', type: 'ws', close() {} } as any;
|
|
1153
|
-
reactor._transport = transport;
|
|
1154
|
-
const logged = vi.spyOn(reactor._log, 'error');
|
|
1155
|
-
try {
|
|
1156
|
-
reactor._transportOnMessage({
|
|
1157
|
-
target: transport,
|
|
1158
|
-
message: [
|
|
1159
|
-
{
|
|
1160
|
-
op: 'server-broadcast',
|
|
1161
|
-
'room-id': 'room-1',
|
|
1162
|
-
topic: 'topic',
|
|
1163
|
-
data: { data: 'boom', 'peer-id': 'peer-1' },
|
|
1164
|
-
},
|
|
1165
|
-
{
|
|
1166
|
-
op: 'server-broadcast',
|
|
1167
|
-
'room-id': 'room-1',
|
|
1168
|
-
topic: 'topic',
|
|
1169
|
-
data: { data: 'after', 'peer-id': 'peer-1' },
|
|
1170
|
-
},
|
|
1171
|
-
],
|
|
1172
|
-
});
|
|
1173
|
-
|
|
1174
|
-
expect(seen).toEqual(['boom', 'after']);
|
|
1175
|
-
expect(logged).toHaveBeenCalled();
|
|
1176
|
-
} finally {
|
|
1177
|
-
logged.mockRestore();
|
|
1178
|
-
}
|
|
1179
|
-
});
|