@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
package/src/store.ts
DELETED
|
@@ -1,1165 +0,0 @@
|
|
|
1
|
-
import { create } from 'mutative';
|
|
2
|
-
import { immutableDeepMerge } from './utils/object.js';
|
|
3
|
-
import { coerceToDate } from './utils/dates.ts';
|
|
4
|
-
import { BackendRelayDBAttr } from './attrTypes.ts';
|
|
5
|
-
import { LinkIndex } from './utils/linkIndex.ts';
|
|
6
|
-
|
|
7
|
-
type Triple = [string, string, any, number];
|
|
8
|
-
type Attrs = Record<string, BackendRelayDBAttr>;
|
|
9
|
-
type OrderedDataType = 'string' | 'number' | 'date';
|
|
10
|
-
|
|
11
|
-
type OrderedTriple = {
|
|
12
|
-
key: string | number;
|
|
13
|
-
order: number;
|
|
14
|
-
triple: Triple;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type OrderedAttrIndex = {
|
|
18
|
-
dataType: OrderedDataType;
|
|
19
|
-
entries: OrderedTriple[];
|
|
20
|
-
fallback: OrderedTriple[];
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type OrderedAttrQuery = {
|
|
24
|
-
dataType: OrderedDataType;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const MIN_ORDERED_INDEX_ENTRIES = 32;
|
|
28
|
-
|
|
29
|
-
interface AttrIndexes {
|
|
30
|
-
blobAttrs: Map<string, Map<string, BackendRelayDBAttr>>;
|
|
31
|
-
primaryKeys: Map<string, BackendRelayDBAttr>;
|
|
32
|
-
forwardIdents: Map<string, Map<string, BackendRelayDBAttr>>;
|
|
33
|
-
revIdents: Map<string, Map<string, BackendRelayDBAttr>>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export type Store = {
|
|
37
|
-
eav: Map<string, Map<string, Map<any, Triple>>>;
|
|
38
|
-
aev: Map<string, Map<string, Map<any, Triple>>>;
|
|
39
|
-
ave: Map<string, Map<any, Map<string, Triple>>>;
|
|
40
|
-
orderedAV: Map<string, OrderedAttrIndex>;
|
|
41
|
-
orderedAVQueries: Map<string, OrderedAttrQuery>;
|
|
42
|
-
vae: Map<any, Map<string, Map<string, Triple>>>;
|
|
43
|
-
useDateObjects: boolean | null | undefined;
|
|
44
|
-
cardinalityInference: boolean | null | undefined;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
type StoreJsonVersion0 = {
|
|
48
|
-
__type: 'store';
|
|
49
|
-
attrs: Attrs;
|
|
50
|
-
triples: Triple[];
|
|
51
|
-
cardinalityInference: boolean | null | undefined;
|
|
52
|
-
linkIndex: LinkIndex | null;
|
|
53
|
-
useDateObjects: boolean | null | undefined;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
type StoreJsonVersion1 = {
|
|
57
|
-
triples: Triple[];
|
|
58
|
-
cardinalityInference: boolean | null | undefined;
|
|
59
|
-
useDateObjects: boolean | null | undefined;
|
|
60
|
-
version: 1;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export type StoreJson = StoreJsonVersion0 | StoreJsonVersion1;
|
|
64
|
-
|
|
65
|
-
export type AttrsStoreJson = {
|
|
66
|
-
attrs: Attrs;
|
|
67
|
-
linkIndex: LinkIndex | null;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export interface AttrsStore {
|
|
71
|
-
attrs: Attrs;
|
|
72
|
-
linkIndex: LinkIndex | null;
|
|
73
|
-
resetAttrIndexes(): void;
|
|
74
|
-
addAttr(attr: BackendRelayDBAttr): void;
|
|
75
|
-
deleteAttr(attrId: string): void;
|
|
76
|
-
updateAttr(partialAttr: Partial<BackendRelayDBAttr> & { id: string }): void;
|
|
77
|
-
getAttr(id: string): BackendRelayDBAttr | undefined;
|
|
78
|
-
blobAttrs: Map<string, Map<string, BackendRelayDBAttr>>;
|
|
79
|
-
primaryKeys: Map<string, BackendRelayDBAttr>;
|
|
80
|
-
forwardIdents: Map<string, Map<string, BackendRelayDBAttr>>;
|
|
81
|
-
revIdents: Map<string, Map<string, BackendRelayDBAttr>>;
|
|
82
|
-
toJSON(): AttrsStoreJson;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export class AttrsStoreClass implements AttrsStore {
|
|
86
|
-
public attrs: Attrs;
|
|
87
|
-
public linkIndex: LinkIndex | null;
|
|
88
|
-
private _blobAttrs: Map<string, Map<string, BackendRelayDBAttr>> | null =
|
|
89
|
-
null;
|
|
90
|
-
private _primaryKeys: Map<string, BackendRelayDBAttr> | null = null;
|
|
91
|
-
private _forwardIdents: Map<string, Map<string, BackendRelayDBAttr>> | null =
|
|
92
|
-
null;
|
|
93
|
-
private _revIdents: Map<string, Map<string, BackendRelayDBAttr>> | null =
|
|
94
|
-
null;
|
|
95
|
-
constructor(attrs: Attrs, linkIndex: LinkIndex | null) {
|
|
96
|
-
this.attrs = attrs;
|
|
97
|
-
this.linkIndex = linkIndex;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
public resetAttrIndexes() {
|
|
101
|
-
this._blobAttrs = null;
|
|
102
|
-
this._primaryKeys = null;
|
|
103
|
-
this._forwardIdents = null;
|
|
104
|
-
this._revIdents = null;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
public addAttr(attr: BackendRelayDBAttr) {
|
|
108
|
-
this.attrs[attr.id] = attr;
|
|
109
|
-
this.resetAttrIndexes();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
public deleteAttr(attrId: string) {
|
|
113
|
-
delete this.attrs[attrId];
|
|
114
|
-
this.resetAttrIndexes();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
public updateAttr(partialAttr: Partial<BackendRelayDBAttr> & { id: string }) {
|
|
118
|
-
const attr = this.attrs[partialAttr.id];
|
|
119
|
-
if (!attr) return;
|
|
120
|
-
this.attrs[partialAttr.id] = { ...attr, ...partialAttr };
|
|
121
|
-
this.resetAttrIndexes();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
public getAttr(id: string): BackendRelayDBAttr | undefined {
|
|
125
|
-
return this.attrs[id];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
get blobAttrs(): Map<string, Map<string, BackendRelayDBAttr>> {
|
|
129
|
-
if (this._blobAttrs) {
|
|
130
|
-
return this._blobAttrs;
|
|
131
|
-
}
|
|
132
|
-
this._blobAttrs = new Map();
|
|
133
|
-
for (const attr of Object.values(this.attrs)) {
|
|
134
|
-
if (isBlob(attr)) {
|
|
135
|
-
const [_, fwdEtype, fwdLabel] = attr['forward-identity'];
|
|
136
|
-
setInMap(this.blobAttrs, [fwdEtype, fwdLabel], attr);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return this._blobAttrs;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
get primaryKeys(): Map<string, BackendRelayDBAttr> {
|
|
143
|
-
if (this._primaryKeys) {
|
|
144
|
-
return this._primaryKeys;
|
|
145
|
-
}
|
|
146
|
-
this._primaryKeys = new Map();
|
|
147
|
-
|
|
148
|
-
for (const attr of Object.values(this.attrs)) {
|
|
149
|
-
if (attr['primary?']) {
|
|
150
|
-
const [_, fwdEtype] = attr['forward-identity'];
|
|
151
|
-
setInMap(this._primaryKeys, [fwdEtype], attr);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return this._primaryKeys;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
get forwardIdents(): Map<string, Map<string, BackendRelayDBAttr>> {
|
|
158
|
-
if (this._forwardIdents) {
|
|
159
|
-
return this._forwardIdents;
|
|
160
|
-
}
|
|
161
|
-
this._forwardIdents = new Map();
|
|
162
|
-
|
|
163
|
-
for (const attr of Object.values(this.attrs)) {
|
|
164
|
-
const fwdIdent = attr['forward-identity'];
|
|
165
|
-
const [_, fwdEtype, fwdLabel] = fwdIdent;
|
|
166
|
-
setInMap(this._forwardIdents, [fwdEtype, fwdLabel], attr);
|
|
167
|
-
}
|
|
168
|
-
return this._forwardIdents;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
get revIdents(): Map<string, Map<string, BackendRelayDBAttr>> {
|
|
172
|
-
if (this._revIdents) {
|
|
173
|
-
return this._revIdents;
|
|
174
|
-
}
|
|
175
|
-
this._revIdents = new Map();
|
|
176
|
-
|
|
177
|
-
for (const attr of Object.values(this.attrs)) {
|
|
178
|
-
const revIdent = attr['reverse-identity'];
|
|
179
|
-
if (revIdent) {
|
|
180
|
-
const [_, revEtype, revLabel] = revIdent;
|
|
181
|
-
setInMap(this._revIdents, [revEtype, revLabel], attr);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return this._revIdents;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
public toJSON(): AttrsStoreJson {
|
|
188
|
-
return { attrs: this.attrs, linkIndex: this.linkIndex };
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function hasEA(attr: BackendRelayDBAttr) {
|
|
193
|
-
return attr['cardinality'] === 'one';
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function isRef(attr: BackendRelayDBAttr) {
|
|
197
|
-
return attr['value-type'] === 'ref';
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export function isBlob(attr: BackendRelayDBAttr) {
|
|
201
|
-
return attr['value-type'] === 'blob';
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function getAttr(attrs: Attrs, attrId: string): BackendRelayDBAttr | undefined {
|
|
205
|
-
return attrs[attrId];
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export function getInMap(obj, path) {
|
|
209
|
-
return path.reduce((acc, key) => acc && acc.get(key), obj);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function deleteInMap(m, path) {
|
|
213
|
-
if (path.length === 0) throw new Error('path must have at least one element');
|
|
214
|
-
if (path.length === 1) {
|
|
215
|
-
m.delete(path[0]);
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
const [head, ...tail] = path;
|
|
219
|
-
if (!m.has(head)) return;
|
|
220
|
-
deleteInMap(m.get(head), tail);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function setInMap(m: Map<any, any>, path: any[], value: any) {
|
|
224
|
-
let current = m;
|
|
225
|
-
const lastI = path.length - 1;
|
|
226
|
-
for (let i = 0; i < lastI; i++) {
|
|
227
|
-
const part = path[i];
|
|
228
|
-
|
|
229
|
-
let nextMap = current.get(part);
|
|
230
|
-
if (nextMap === undefined) {
|
|
231
|
-
nextMap = new Map();
|
|
232
|
-
current.set(part, nextMap);
|
|
233
|
-
}
|
|
234
|
-
current = nextMap;
|
|
235
|
-
}
|
|
236
|
-
if (lastI > -1) {
|
|
237
|
-
current.set(path[lastI], value);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
function deleteAVEEntriesForEntity(store: Store, aid: string, eid: string) {
|
|
242
|
-
const values = store.aev.get(aid)?.get(eid);
|
|
243
|
-
if (!values) return;
|
|
244
|
-
|
|
245
|
-
for (const value of values.keys()) {
|
|
246
|
-
deleteInMap(store.ave, [aid, value, eid]);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function isOrderedDataType(value: unknown): value is OrderedDataType {
|
|
251
|
-
return value === 'string' || value === 'number' || value === 'date';
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function orderedValue(
|
|
255
|
-
dataType: OrderedDataType,
|
|
256
|
-
value: unknown,
|
|
257
|
-
): string | number | undefined {
|
|
258
|
-
if (dataType === 'string') {
|
|
259
|
-
return typeof value === 'string' ? value : undefined;
|
|
260
|
-
}
|
|
261
|
-
if (dataType === 'number') {
|
|
262
|
-
return typeof value === 'number' && !Number.isNaN(value)
|
|
263
|
-
? value
|
|
264
|
-
: undefined;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const timestamp = coerceToDate(value)?.getTime();
|
|
268
|
-
return typeof timestamp === 'number' && !Number.isNaN(timestamp)
|
|
269
|
-
? timestamp
|
|
270
|
-
: undefined;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function createOrderedAttrIndex(
|
|
274
|
-
aev: Store['aev'],
|
|
275
|
-
aid: string,
|
|
276
|
-
dataType: OrderedDataType,
|
|
277
|
-
): OrderedAttrIndex | undefined {
|
|
278
|
-
const entityMap = aev.get(aid);
|
|
279
|
-
if (!entityMap) return;
|
|
280
|
-
|
|
281
|
-
const entries: OrderedTriple[] = [];
|
|
282
|
-
const fallback: OrderedTriple[] = [];
|
|
283
|
-
let order = 0;
|
|
284
|
-
for (const valueMap of entityMap.values()) {
|
|
285
|
-
for (const triple of valueMap.values()) {
|
|
286
|
-
const item = { key: orderedValue(dataType, triple[2]), order, triple };
|
|
287
|
-
order += 1;
|
|
288
|
-
if (item.key === undefined) {
|
|
289
|
-
fallback.push(item as OrderedTriple);
|
|
290
|
-
} else {
|
|
291
|
-
entries.push(item as OrderedTriple);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
entries.sort((a, b) => {
|
|
297
|
-
if (a.key < b.key) return -1;
|
|
298
|
-
if (a.key > b.key) return 1;
|
|
299
|
-
return a.order - b.order;
|
|
300
|
-
});
|
|
301
|
-
return { dataType, entries, fallback };
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
function invalidateOrderedAttrIndex(store: Store, aid: string) {
|
|
305
|
-
store.orderedAV.delete(aid);
|
|
306
|
-
store.orderedAVQueries.delete(aid);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
function isDateAttr(attr: BackendRelayDBAttr) {
|
|
310
|
-
return attr['checked-data-type'] === 'date';
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
function createTripleIndexes(
|
|
314
|
-
attrsStore: AttrsStore,
|
|
315
|
-
triples: Triple[],
|
|
316
|
-
useDateObjects: boolean | null | undefined,
|
|
317
|
-
): Pick<
|
|
318
|
-
Store,
|
|
319
|
-
'eav' | 'aev' | 'ave' | 'orderedAV' | 'orderedAVQueries' | 'vae'
|
|
320
|
-
> {
|
|
321
|
-
const eav = new Map();
|
|
322
|
-
const aev = new Map();
|
|
323
|
-
const ave = new Map();
|
|
324
|
-
const vae = new Map();
|
|
325
|
-
for (const triple of triples) {
|
|
326
|
-
let [eid, aid, v] = triple;
|
|
327
|
-
const attr = attrsStore.getAttr(aid);
|
|
328
|
-
if (!attr) {
|
|
329
|
-
console.warn('no such attr', aid, eid);
|
|
330
|
-
continue;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
if (attr['checked-data-type'] === 'date' && useDateObjects) {
|
|
334
|
-
v = coerceToDate(v);
|
|
335
|
-
triple[2] = v;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
if (isRef(attr)) {
|
|
339
|
-
setInMap(vae, [v, aid, eid], triple);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
setInMap(eav, [eid, aid, v], triple);
|
|
343
|
-
setInMap(aev, [aid, eid, v], triple);
|
|
344
|
-
setInMap(ave, [aid, v, eid], triple);
|
|
345
|
-
}
|
|
346
|
-
const orderedAV = new Map<string, OrderedAttrIndex>();
|
|
347
|
-
const orderedAVQueries = new Map<string, OrderedAttrQuery>();
|
|
348
|
-
return { eav, aev, ave, orderedAV, orderedAVQueries, vae };
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
function createAttrIndexes(
|
|
352
|
-
attrs: Record<string, BackendRelayDBAttr>,
|
|
353
|
-
): AttrIndexes {
|
|
354
|
-
const blobAttrs = new Map();
|
|
355
|
-
const primaryKeys = new Map();
|
|
356
|
-
const forwardIdents = new Map();
|
|
357
|
-
const revIdents = new Map();
|
|
358
|
-
for (const attr of Object.values(attrs)) {
|
|
359
|
-
const fwdIdent = attr['forward-identity'];
|
|
360
|
-
const [_, fwdEtype, fwdLabel] = fwdIdent;
|
|
361
|
-
const revIdent = attr['reverse-identity'];
|
|
362
|
-
|
|
363
|
-
setInMap(forwardIdents, [fwdEtype, fwdLabel], attr);
|
|
364
|
-
if (isBlob(attr)) {
|
|
365
|
-
setInMap(blobAttrs, [fwdEtype, fwdLabel], attr);
|
|
366
|
-
}
|
|
367
|
-
if (attr['primary?']) {
|
|
368
|
-
setInMap(primaryKeys, [fwdEtype], attr);
|
|
369
|
-
}
|
|
370
|
-
if (revIdent) {
|
|
371
|
-
const [_, revEtype, revLabel] = revIdent;
|
|
372
|
-
setInMap(revIdents, [revEtype, revLabel], attr);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
return { blobAttrs, primaryKeys, forwardIdents, revIdents };
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
export function toJSON(store: Store): StoreJsonVersion1 {
|
|
380
|
-
return {
|
|
381
|
-
triples: allMapValues(store.eav, 3),
|
|
382
|
-
cardinalityInference: store.cardinalityInference,
|
|
383
|
-
useDateObjects: store.useDateObjects,
|
|
384
|
-
version: 1,
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
export function fromJSON(attrsStore: AttrsStore, storeJSON: StoreJson): Store {
|
|
389
|
-
return createStore(
|
|
390
|
-
attrsStore,
|
|
391
|
-
storeJSON.triples,
|
|
392
|
-
storeJSON.cardinalityInference,
|
|
393
|
-
storeJSON.useDateObjects,
|
|
394
|
-
);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
export function attrsStoreFromJSON(
|
|
398
|
-
attrsStoreJSON: AttrsStoreJson | null,
|
|
399
|
-
storeJSON: StoreJson | null,
|
|
400
|
-
): AttrsStore | undefined {
|
|
401
|
-
if (attrsStoreJSON) {
|
|
402
|
-
return new AttrsStoreClass(attrsStoreJSON.attrs, attrsStoreJSON.linkIndex);
|
|
403
|
-
}
|
|
404
|
-
if (storeJSON && '__type' in storeJSON) {
|
|
405
|
-
return new AttrsStoreClass(storeJSON.attrs, storeJSON.linkIndex);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
export function hasTriple(store: Store, [e, a, v]: [string, string, any]) {
|
|
410
|
-
return getInMap(store.eav, [e, a, v]) !== undefined;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
export function hasEntity(store: Store, e: string) {
|
|
414
|
-
return getInMap(store.eav, [e]) !== undefined;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
export function createStore(
|
|
418
|
-
attrsStore: AttrsStore,
|
|
419
|
-
triples: Triple[],
|
|
420
|
-
enableCardinalityInference?: boolean | null,
|
|
421
|
-
useDateObjects?: boolean | null,
|
|
422
|
-
): Store {
|
|
423
|
-
const store = createTripleIndexes(
|
|
424
|
-
attrsStore,
|
|
425
|
-
triples,
|
|
426
|
-
useDateObjects,
|
|
427
|
-
) as unknown as Store;
|
|
428
|
-
store.cardinalityInference = enableCardinalityInference;
|
|
429
|
-
store.useDateObjects = useDateObjects;
|
|
430
|
-
return store;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
// We may have local triples with lookup refs in them,
|
|
434
|
-
// we need to convert those lookup refs to eids to insert them
|
|
435
|
-
// into the store. If we can't find the lookup ref locally,
|
|
436
|
-
// then we drop the triple and have to wait for the server response
|
|
437
|
-
// to see the optimistic updates.
|
|
438
|
-
function resolveLookupRefs(store: Store, triple: Triple): Triple | null {
|
|
439
|
-
let eid;
|
|
440
|
-
|
|
441
|
-
// Check if `e` is a lookup ref
|
|
442
|
-
if (Array.isArray(triple[0])) {
|
|
443
|
-
const [a, v] = triple[0];
|
|
444
|
-
const eMaps = store.aev.get(a);
|
|
445
|
-
if (!eMaps) {
|
|
446
|
-
// We don't have the attr, so don't try to add the
|
|
447
|
-
// triple to the store
|
|
448
|
-
return null;
|
|
449
|
-
}
|
|
450
|
-
// AVE preserves the entity insertion order used by the former scan.
|
|
451
|
-
eid = v === v ? store.ave.get(a)?.get(v)?.keys().next().value : undefined;
|
|
452
|
-
} else {
|
|
453
|
-
eid = triple[0];
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
if (!eid) {
|
|
457
|
-
// We don't know the eid that the ref refers to, so
|
|
458
|
-
// we can't add the triple to the store.
|
|
459
|
-
return null;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
// Check if v is a lookup ref
|
|
463
|
-
const lookupV = triple[2];
|
|
464
|
-
if (
|
|
465
|
-
Array.isArray(lookupV) &&
|
|
466
|
-
lookupV.length === 2 &&
|
|
467
|
-
store.aev.get(lookupV[0])
|
|
468
|
-
) {
|
|
469
|
-
const [a, v] = lookupV;
|
|
470
|
-
const eMaps = store.aev.get(a);
|
|
471
|
-
if (!eMaps) {
|
|
472
|
-
// We don't have the attr, so don't try to add the
|
|
473
|
-
// triple to the store
|
|
474
|
-
return null;
|
|
475
|
-
}
|
|
476
|
-
const value =
|
|
477
|
-
v === v ? store.ave.get(a)?.get(v)?.keys().next().value : undefined;
|
|
478
|
-
if (!value) {
|
|
479
|
-
return null;
|
|
480
|
-
}
|
|
481
|
-
const [_e, aid, _v, ...rest] = triple;
|
|
482
|
-
return [eid, aid, value, ...rest];
|
|
483
|
-
} else {
|
|
484
|
-
const [_, ...rest] = triple;
|
|
485
|
-
return [eid, ...rest];
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
export function retractTriple(
|
|
490
|
-
store: Store,
|
|
491
|
-
attrsStore: AttrsStore,
|
|
492
|
-
rawTriple: Triple,
|
|
493
|
-
): void {
|
|
494
|
-
const triple = resolveLookupRefs(store, rawTriple);
|
|
495
|
-
if (!triple) {
|
|
496
|
-
return;
|
|
497
|
-
}
|
|
498
|
-
const [eid, aid, v] = triple;
|
|
499
|
-
const attr = attrsStore.getAttr(aid);
|
|
500
|
-
if (!attr) {
|
|
501
|
-
return;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
deleteInMap(store.eav, [eid, aid, v]);
|
|
505
|
-
deleteInMap(store.aev, [aid, eid, v]);
|
|
506
|
-
deleteInMap(store.ave, [aid, v, eid]);
|
|
507
|
-
invalidateOrderedAttrIndex(store, aid);
|
|
508
|
-
if (isRef(attr)) {
|
|
509
|
-
deleteInMap(store.vae, [v, aid, eid]);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
let _seed = 0;
|
|
514
|
-
function getCreatedAt(
|
|
515
|
-
store: Store,
|
|
516
|
-
attr: BackendRelayDBAttr,
|
|
517
|
-
triple: Triple,
|
|
518
|
-
): Number {
|
|
519
|
-
const [eid, aid, v] = triple;
|
|
520
|
-
let createdAt;
|
|
521
|
-
|
|
522
|
-
const t = getInMap(store.eav, [eid, aid, v]);
|
|
523
|
-
if (t) {
|
|
524
|
-
createdAt = t[3];
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* (XXX)
|
|
529
|
-
* Two hacks here, for generating a `createdAt`
|
|
530
|
-
*
|
|
531
|
-
* 1. We multiply Date.now() by 10, to make sure that
|
|
532
|
-
* `createdAt` is always greater than anything the server
|
|
533
|
-
* could return
|
|
534
|
-
*
|
|
535
|
-
* We do this because right now we know we _only_ insert
|
|
536
|
-
* triples as optimistic updates.
|
|
537
|
-
*
|
|
538
|
-
* 2. We increment by `_seed`, to make sure there are no
|
|
539
|
-
* two triples with the same `createdAt`. This is
|
|
540
|
-
* done to make tests more predictable.
|
|
541
|
-
*
|
|
542
|
-
* We may need to rethink this. Because we * 10, we can't
|
|
543
|
-
* use this value as an _actual_ `createdAt` timestamp.
|
|
544
|
-
* Eventually we may want too though; For example, we could
|
|
545
|
-
* use `createdAt` for each triple, to infer a `createdAt` and
|
|
546
|
-
* `updatedAt` value for each object.
|
|
547
|
-
*/
|
|
548
|
-
return createdAt || Date.now() * 10 + _seed++;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
export function addTriple(
|
|
552
|
-
store: Store,
|
|
553
|
-
attrsStore: AttrsStore,
|
|
554
|
-
rawTriple: Triple,
|
|
555
|
-
) {
|
|
556
|
-
const triple = resolveLookupRefs(store, rawTriple);
|
|
557
|
-
if (!triple) {
|
|
558
|
-
return;
|
|
559
|
-
}
|
|
560
|
-
let [eid, aid, v] = triple;
|
|
561
|
-
const attr = attrsStore.getAttr(aid);
|
|
562
|
-
if (!attr) {
|
|
563
|
-
// (XXX): Due to the way we're handling attrs, it's
|
|
564
|
-
// possible to enter a state where we receive a triple without an attr.
|
|
565
|
-
// See: https://github.com/jsventures/instant-local/pull/132 for details.
|
|
566
|
-
// For now, if we receive a command without an attr, we no-op.
|
|
567
|
-
return;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
if (attr['checked-data-type'] === 'date' && store.useDateObjects) {
|
|
571
|
-
v = coerceToDate(v);
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
const existingTriple = getInMap(store.eav, [eid, aid, v]);
|
|
575
|
-
// Reuse the created_at for a triple if it's already in the store.
|
|
576
|
-
// Prevents updates from temporarily pushing an entity to the top
|
|
577
|
-
// while waiting for the server response.
|
|
578
|
-
const t = existingTriple?.[3] ?? getCreatedAt(store, attr, triple);
|
|
579
|
-
const enhancedTriple = [eid, aid, v, t];
|
|
580
|
-
|
|
581
|
-
if (hasEA(attr)) {
|
|
582
|
-
deleteAVEEntriesForEntity(store, aid, eid);
|
|
583
|
-
setInMap(store.eav, [eid, aid], new Map([[v, enhancedTriple]]));
|
|
584
|
-
setInMap(store.aev, [aid, eid], new Map([[v, enhancedTriple]]));
|
|
585
|
-
} else {
|
|
586
|
-
setInMap(store.eav, [eid, aid, v], enhancedTriple);
|
|
587
|
-
setInMap(store.aev, [aid, eid, v], enhancedTriple);
|
|
588
|
-
}
|
|
589
|
-
setInMap(store.ave, [aid, v, eid], enhancedTriple);
|
|
590
|
-
invalidateOrderedAttrIndex(store, aid);
|
|
591
|
-
|
|
592
|
-
if (isRef(attr)) {
|
|
593
|
-
setInMap(store.vae, [v, aid, eid], enhancedTriple);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
function mergeTriple(store: Store, attrsStore: AttrsStore, rawTriple: Triple) {
|
|
598
|
-
const triple = resolveLookupRefs(store, rawTriple);
|
|
599
|
-
if (!triple) {
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
const [eid, aid, update] = triple;
|
|
604
|
-
const attr = attrsStore.getAttr(aid);
|
|
605
|
-
|
|
606
|
-
if (!attr) return;
|
|
607
|
-
|
|
608
|
-
if (!isBlob(attr))
|
|
609
|
-
throw new Error('merge operation is not supported for links');
|
|
610
|
-
|
|
611
|
-
const eavValuesMap = getInMap(store.eav, [eid, aid]);
|
|
612
|
-
if (!eavValuesMap) return;
|
|
613
|
-
|
|
614
|
-
const currentTriple = eavValuesMap.values().next()?.value;
|
|
615
|
-
if (!currentTriple) return;
|
|
616
|
-
|
|
617
|
-
const currentValue = currentTriple[2];
|
|
618
|
-
|
|
619
|
-
const updatedValue = immutableDeepMerge(currentValue, update);
|
|
620
|
-
const enhancedTriple = [
|
|
621
|
-
eid,
|
|
622
|
-
aid,
|
|
623
|
-
updatedValue,
|
|
624
|
-
getCreatedAt(store, attr, currentTriple),
|
|
625
|
-
];
|
|
626
|
-
|
|
627
|
-
deleteAVEEntriesForEntity(store, aid, eid);
|
|
628
|
-
setInMap(store.eav, [eid, aid], new Map([[updatedValue, enhancedTriple]]));
|
|
629
|
-
setInMap(store.aev, [aid, eid], new Map([[updatedValue, enhancedTriple]]));
|
|
630
|
-
setInMap(store.ave, [aid, updatedValue, eid], enhancedTriple);
|
|
631
|
-
invalidateOrderedAttrIndex(store, aid);
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
function deleteEntity(store: Store, attrsStore: AttrsStore, args: any[]) {
|
|
635
|
-
const [lookup, etype] = args;
|
|
636
|
-
const triple = resolveLookupRefs(store, [lookup] as unknown as Triple);
|
|
637
|
-
|
|
638
|
-
if (!triple) {
|
|
639
|
-
return;
|
|
640
|
-
}
|
|
641
|
-
const [id] = triple;
|
|
642
|
-
|
|
643
|
-
// delete forward links and attributes + cardinality one links
|
|
644
|
-
const eMap = store.eav.get(id);
|
|
645
|
-
if (eMap) {
|
|
646
|
-
for (const a of eMap.keys()) {
|
|
647
|
-
const attr = attrsStore.getAttr(a);
|
|
648
|
-
|
|
649
|
-
// delete cascade refs
|
|
650
|
-
if (attr && attr['on-delete-reverse'] === 'cascade') {
|
|
651
|
-
allMapValues(eMap.get(a), 1).forEach(
|
|
652
|
-
([e, a, v]: [string, string, any]) =>
|
|
653
|
-
deleteEntity(store, attrsStore, [v, attr['reverse-identity']?.[1]]),
|
|
654
|
-
);
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
if (
|
|
658
|
-
// Fall back to deleting everything if we've rehydrated tx-steps from
|
|
659
|
-
// the store that didn't set `etype` in deleteEntity
|
|
660
|
-
!etype ||
|
|
661
|
-
// If we don't know about the attr, let's just get rid of it
|
|
662
|
-
!attr ||
|
|
663
|
-
// Make sure it matches the etype
|
|
664
|
-
attr['forward-identity']?.[1] === etype
|
|
665
|
-
) {
|
|
666
|
-
deleteAVEEntriesForEntity(store, a, id);
|
|
667
|
-
deleteInMap(store.aev, [a, id]);
|
|
668
|
-
deleteInMap(store.eav, [id, a]);
|
|
669
|
-
invalidateOrderedAttrIndex(store, a);
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
// Clear out the eav index for `id` if we deleted all of the attributes
|
|
673
|
-
if (eMap.size === 0) {
|
|
674
|
-
deleteInMap(store.eav, [id]);
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
// delete reverse links
|
|
679
|
-
const vaeTriples = store.vae.get(id) && allMapValues(store.vae.get(id), 2);
|
|
680
|
-
|
|
681
|
-
if (vaeTriples) {
|
|
682
|
-
vaeTriples.forEach((triple: Triple) => {
|
|
683
|
-
const [e, a, v] = triple;
|
|
684
|
-
const attr = attrsStore.getAttr(a);
|
|
685
|
-
if (!etype || !attr || attr['reverse-identity']?.[1] === etype) {
|
|
686
|
-
deleteInMap(store.eav, [e, a, v]);
|
|
687
|
-
deleteInMap(store.aev, [a, e, v]);
|
|
688
|
-
deleteInMap(store.ave, [a, v, e]);
|
|
689
|
-
deleteInMap(store.vae, [v, a, e]);
|
|
690
|
-
invalidateOrderedAttrIndex(store, a);
|
|
691
|
-
}
|
|
692
|
-
if (
|
|
693
|
-
attr &&
|
|
694
|
-
attr['on-delete'] === 'cascade' &&
|
|
695
|
-
attr['reverse-identity']?.[1] === etype
|
|
696
|
-
) {
|
|
697
|
-
deleteEntity(store, attrsStore, [e, attr['forward-identity']?.[1]]);
|
|
698
|
-
}
|
|
699
|
-
});
|
|
700
|
-
}
|
|
701
|
-
// Clear out vae index for `id` if we deleted all the reverse attributes
|
|
702
|
-
if (store.vae.get(id)?.size === 0) {
|
|
703
|
-
deleteInMap(store.vae, [id]);
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
// (XXX): Whenever we change/delete attrs,
|
|
708
|
-
// We indiscriminately reset the index map.
|
|
709
|
-
// There are lots of opportunities for optimization:
|
|
710
|
-
// * We _only_ need to run this indexes change. We could detect that
|
|
711
|
-
// * We could batch this reset at the end
|
|
712
|
-
// * We could add an ave index for all triples, so removing the
|
|
713
|
-
// right triples is easy and fast.
|
|
714
|
-
function resetIndexMap(store: Store, attrsStore, newTriples: Triple[]) {
|
|
715
|
-
const newIndexMap = createTripleIndexes(
|
|
716
|
-
attrsStore,
|
|
717
|
-
newTriples,
|
|
718
|
-
store.useDateObjects,
|
|
719
|
-
);
|
|
720
|
-
Object.keys(newIndexMap).forEach((key) => {
|
|
721
|
-
store[key] = newIndexMap[key];
|
|
722
|
-
});
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
function addAttr(attrsStore: AttrsStore, [attr]: [BackendRelayDBAttr]) {
|
|
726
|
-
attrsStore.addAttr(attr);
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
function getAllTriples(store: Store): Triple[] {
|
|
730
|
-
return allMapValues(store.eav, 3);
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
function deleteAttr(store: Store, attrsStore: AttrsStore, [id]: [string]) {
|
|
734
|
-
if (!attrsStore.getAttr(id)) return;
|
|
735
|
-
const newTriples = getAllTriples(store).filter(([_, aid]) => aid !== id);
|
|
736
|
-
attrsStore.deleteAttr(id);
|
|
737
|
-
resetIndexMap(store, attrsStore, newTriples);
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
function updateAttr(
|
|
741
|
-
store: Store,
|
|
742
|
-
attrsStore: AttrsStore,
|
|
743
|
-
[partialAttr]: [Partial<BackendRelayDBAttr> & { id: string }],
|
|
744
|
-
) {
|
|
745
|
-
const attr = attrsStore.getAttr(partialAttr.id);
|
|
746
|
-
if (!attr) return;
|
|
747
|
-
attrsStore.updateAttr(partialAttr);
|
|
748
|
-
resetIndexMap(store, attrsStore, getAllTriples(store));
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
function applyTxStep(store: Store, attrsStore: AttrsStore, txStep) {
|
|
752
|
-
const [action, ...args] = txStep;
|
|
753
|
-
switch (action) {
|
|
754
|
-
case 'add-triple':
|
|
755
|
-
addTriple(store, attrsStore, args);
|
|
756
|
-
break;
|
|
757
|
-
case 'deep-merge-triple':
|
|
758
|
-
mergeTriple(store, attrsStore, args);
|
|
759
|
-
break;
|
|
760
|
-
case 'retract-triple':
|
|
761
|
-
retractTriple(store, attrsStore, args);
|
|
762
|
-
break;
|
|
763
|
-
case 'delete-entity':
|
|
764
|
-
deleteEntity(store, attrsStore, args);
|
|
765
|
-
break;
|
|
766
|
-
case 'add-attr':
|
|
767
|
-
addAttr(attrsStore, args);
|
|
768
|
-
break;
|
|
769
|
-
case 'delete-attr':
|
|
770
|
-
deleteAttr(store, attrsStore, args);
|
|
771
|
-
break;
|
|
772
|
-
case 'update-attr':
|
|
773
|
-
updateAttr(store, attrsStore, args);
|
|
774
|
-
break;
|
|
775
|
-
case 'restore-attr':
|
|
776
|
-
break;
|
|
777
|
-
case 'rule-params':
|
|
778
|
-
break;
|
|
779
|
-
default:
|
|
780
|
-
throw new Error(`unhandled transaction action: ${action}`);
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
export function allMapValues(m, level, res: any[] = []) {
|
|
785
|
-
if (!m) {
|
|
786
|
-
return res;
|
|
787
|
-
}
|
|
788
|
-
if (level === 0) {
|
|
789
|
-
return res;
|
|
790
|
-
}
|
|
791
|
-
if (level === 1) {
|
|
792
|
-
for (const v of m.values()) {
|
|
793
|
-
res.push(v);
|
|
794
|
-
}
|
|
795
|
-
return res;
|
|
796
|
-
}
|
|
797
|
-
for (const v of m.values()) {
|
|
798
|
-
allMapValues(v, level - 1, res);
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
return res;
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
function triplesByValue(store: Store, m: Map<any, Triple>, v: any) {
|
|
805
|
-
const res: Triple[] = [];
|
|
806
|
-
if (v?.hasOwnProperty('$not')) {
|
|
807
|
-
for (const candidate of m.keys()) {
|
|
808
|
-
if (v.$not !== candidate) {
|
|
809
|
-
res.push(m.get(candidate) as Triple);
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
return res;
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
if (v?.hasOwnProperty('$isNull')) {
|
|
816
|
-
const { attrId, isNull, reverse } = v.$isNull;
|
|
817
|
-
|
|
818
|
-
if (reverse) {
|
|
819
|
-
for (const candidate of m.keys()) {
|
|
820
|
-
const vMap = store.vae.get(candidate);
|
|
821
|
-
const isValNull = !vMap || !vMap.get(attrId);
|
|
822
|
-
if (isNull ? isValNull : !isValNull) {
|
|
823
|
-
res.push(m.get(candidate) as Triple);
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
} else {
|
|
827
|
-
const aMap = store.aev.get(attrId);
|
|
828
|
-
for (const candidate of m.keys()) {
|
|
829
|
-
const isValNull =
|
|
830
|
-
!aMap || aMap.get(candidate)?.get(null) || !aMap.get(candidate);
|
|
831
|
-
if (isNull ? isValNull : !isValNull) {
|
|
832
|
-
res.push(m.get(candidate) as Triple);
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
return res;
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
if (v?.$comparator) {
|
|
840
|
-
return allMapValues(m, 1).filter(v.$op);
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
const values = v.in || v.$in || [v];
|
|
844
|
-
|
|
845
|
-
for (const value of values) {
|
|
846
|
-
const triple = m.get(value);
|
|
847
|
-
if (triple) {
|
|
848
|
-
res.push(triple);
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
return res;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
function binarySearch(
|
|
856
|
-
entries: OrderedTriple[],
|
|
857
|
-
value: string | number,
|
|
858
|
-
inclusive: boolean,
|
|
859
|
-
) {
|
|
860
|
-
let low = 0;
|
|
861
|
-
let high = entries.length;
|
|
862
|
-
while (low < high) {
|
|
863
|
-
const mid = Math.floor((low + high) / 2);
|
|
864
|
-
const entry = entries[mid];
|
|
865
|
-
if (entry.key < value || (!inclusive && entry.key === value)) {
|
|
866
|
-
low = mid + 1;
|
|
867
|
-
} else {
|
|
868
|
-
high = mid;
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
return low;
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
function scanOrderedTriples(aMap: Map<string, Map<any, Triple>>, v: any) {
|
|
875
|
-
const triples: Triple[] = [];
|
|
876
|
-
let total = 0;
|
|
877
|
-
|
|
878
|
-
for (const valueMap of aMap.values()) {
|
|
879
|
-
for (const triple of valueMap.values()) {
|
|
880
|
-
total += 1;
|
|
881
|
-
if (v.$op(triple)) {
|
|
882
|
-
triples.push(triple);
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
return { triples, total };
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
function indexedOrderedTriples(index: OrderedAttrIndex, v: any) {
|
|
890
|
-
const value = orderedValue(index.dataType, v.$value);
|
|
891
|
-
if (value === undefined) return;
|
|
892
|
-
|
|
893
|
-
let start = 0;
|
|
894
|
-
let end = index.entries.length;
|
|
895
|
-
switch (v.$order) {
|
|
896
|
-
case 'gt':
|
|
897
|
-
start = binarySearch(index.entries, value, false);
|
|
898
|
-
break;
|
|
899
|
-
case 'gte':
|
|
900
|
-
start = binarySearch(index.entries, value, true);
|
|
901
|
-
break;
|
|
902
|
-
case 'lt':
|
|
903
|
-
end = binarySearch(index.entries, value, true);
|
|
904
|
-
break;
|
|
905
|
-
case 'lte':
|
|
906
|
-
end = binarySearch(index.entries, value, false);
|
|
907
|
-
break;
|
|
908
|
-
default:
|
|
909
|
-
return;
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
const matches = index.entries
|
|
913
|
-
.slice(start, end)
|
|
914
|
-
.concat(index.fallback.filter((entry) => v.$op(entry.triple)));
|
|
915
|
-
if (matches.length > (index.entries.length + index.fallback.length) / 2) {
|
|
916
|
-
return;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
return matches.sort((a, b) => a.order - b.order).map((entry) => entry.triple);
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
function orderedTriplesByValue(
|
|
923
|
-
store: Store,
|
|
924
|
-
aid: string,
|
|
925
|
-
aMap: Map<string, Map<any, Triple>>,
|
|
926
|
-
v: any,
|
|
927
|
-
) {
|
|
928
|
-
if (!isOrderedDataType(v.$dataType)) return;
|
|
929
|
-
|
|
930
|
-
const value = orderedValue(v.$dataType, v.$value);
|
|
931
|
-
if (value === undefined) return;
|
|
932
|
-
|
|
933
|
-
const index = store.orderedAV.get(aid);
|
|
934
|
-
if (index && index.dataType === v.$dataType) {
|
|
935
|
-
return indexedOrderedTriples(index, v);
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
const scan = scanOrderedTriples(aMap, v);
|
|
939
|
-
const priorQuery = store.orderedAVQueries.get(aid);
|
|
940
|
-
if (
|
|
941
|
-
priorQuery?.dataType === v.$dataType &&
|
|
942
|
-
scan.total >= MIN_ORDERED_INDEX_ENTRIES &&
|
|
943
|
-
scan.triples.length <= scan.total / 2
|
|
944
|
-
) {
|
|
945
|
-
const newIndex = createOrderedAttrIndex(store.aev, aid, v.$dataType);
|
|
946
|
-
if (!newIndex) return scan.triples;
|
|
947
|
-
store.orderedAV.set(aid, newIndex);
|
|
948
|
-
return indexedOrderedTriples(newIndex, v) ?? scan.triples;
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
store.orderedAVQueries.set(aid, { dataType: v.$dataType });
|
|
952
|
-
return scan.triples;
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
// A poor man's pattern matching
|
|
956
|
-
// Returns either eav, ea, ev, av, v, or ''
|
|
957
|
-
function whichIdx(e, a, v): 'eav' | 'ea' | 'ev' | 'av' | 'e' | 'a' | 'v' | '' {
|
|
958
|
-
let res = '';
|
|
959
|
-
if (e !== undefined) {
|
|
960
|
-
res += 'e';
|
|
961
|
-
}
|
|
962
|
-
if (a !== undefined) {
|
|
963
|
-
res += 'a';
|
|
964
|
-
}
|
|
965
|
-
if (v !== undefined) {
|
|
966
|
-
res += 'v';
|
|
967
|
-
}
|
|
968
|
-
return res as 'eav' | 'ea' | 'ev' | 'av' | 'e' | 'a' | 'v' | '';
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
export function getTriples(store, [e, a, v]) {
|
|
972
|
-
const idx = whichIdx(e, a, v);
|
|
973
|
-
switch (idx) {
|
|
974
|
-
case 'e': {
|
|
975
|
-
const eMap = store.eav.get(e);
|
|
976
|
-
return allMapValues(eMap, 2);
|
|
977
|
-
}
|
|
978
|
-
case 'ea': {
|
|
979
|
-
const aMap = store.eav.get(e)?.get(a);
|
|
980
|
-
return allMapValues(aMap, 1);
|
|
981
|
-
}
|
|
982
|
-
case 'eav': {
|
|
983
|
-
const aMap = store.eav.get(e)?.get(a);
|
|
984
|
-
if (!aMap) {
|
|
985
|
-
return [];
|
|
986
|
-
}
|
|
987
|
-
return triplesByValue(store, aMap, v);
|
|
988
|
-
}
|
|
989
|
-
case 'ev': {
|
|
990
|
-
const eMap = store.eav.get(e);
|
|
991
|
-
if (!eMap) {
|
|
992
|
-
return [];
|
|
993
|
-
}
|
|
994
|
-
const res: Triple[] = [];
|
|
995
|
-
for (const aMap of eMap.values()) {
|
|
996
|
-
res.push(...triplesByValue(store, aMap, v));
|
|
997
|
-
}
|
|
998
|
-
return res;
|
|
999
|
-
}
|
|
1000
|
-
case 'a': {
|
|
1001
|
-
const aMap = store.aev.get(a);
|
|
1002
|
-
return allMapValues(aMap, 2);
|
|
1003
|
-
}
|
|
1004
|
-
case 'av': {
|
|
1005
|
-
const aMap = store.aev.get(a);
|
|
1006
|
-
if (!aMap) {
|
|
1007
|
-
return [];
|
|
1008
|
-
}
|
|
1009
|
-
if (v?.$comparator && v.$order) {
|
|
1010
|
-
const triples = orderedTriplesByValue(store, a, aMap, v);
|
|
1011
|
-
if (triples) return triples;
|
|
1012
|
-
}
|
|
1013
|
-
const res: Triple[] = [];
|
|
1014
|
-
for (const eMap of aMap.values()) {
|
|
1015
|
-
res.push(...triplesByValue(store, eMap, v));
|
|
1016
|
-
}
|
|
1017
|
-
return res;
|
|
1018
|
-
}
|
|
1019
|
-
case 'v': {
|
|
1020
|
-
const res: Triple[] = [];
|
|
1021
|
-
for (const eMap of store.eav.values()) {
|
|
1022
|
-
for (const aMap of eMap.values()) {
|
|
1023
|
-
res.push(...triplesByValue(store, aMap, v));
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
return res;
|
|
1027
|
-
}
|
|
1028
|
-
default: {
|
|
1029
|
-
return allMapValues(store.eav, 3);
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
export function getAsObject(
|
|
1035
|
-
store: Store,
|
|
1036
|
-
attrs: Map<string, BackendRelayDBAttr> | undefined,
|
|
1037
|
-
e: string,
|
|
1038
|
-
) {
|
|
1039
|
-
const obj = {};
|
|
1040
|
-
|
|
1041
|
-
if (!attrs) {
|
|
1042
|
-
return obj;
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
for (const [label, attr] of attrs.entries()) {
|
|
1046
|
-
const aMap = store.eav.get(e)?.get(attr.id);
|
|
1047
|
-
const triples = allMapValues(aMap, 1);
|
|
1048
|
-
for (const triple of triples) {
|
|
1049
|
-
obj[label] = triple[2];
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
return obj;
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
export function getAttrByFwdIdentName(
|
|
1057
|
-
attrsStore: AttrsStore,
|
|
1058
|
-
inputEtype: string,
|
|
1059
|
-
inputLabel: string,
|
|
1060
|
-
) {
|
|
1061
|
-
return attrsStore.forwardIdents.get(inputEtype)?.get(inputLabel);
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
export function getAttrByReverseIdentName(
|
|
1065
|
-
attrsStore: AttrsStore,
|
|
1066
|
-
inputEtype: string,
|
|
1067
|
-
inputLabel: string,
|
|
1068
|
-
) {
|
|
1069
|
-
return attrsStore.revIdents.get(inputEtype)?.get(inputLabel);
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
export function getBlobAttrs(attrsStore: AttrsStore, etype: string) {
|
|
1073
|
-
return attrsStore.blobAttrs.get(etype);
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
export function getPrimaryKeyAttr(attrsStore: AttrsStore, etype: string) {
|
|
1077
|
-
const fromPrimary = attrsStore.primaryKeys.get(etype);
|
|
1078
|
-
if (fromPrimary) {
|
|
1079
|
-
return fromPrimary;
|
|
1080
|
-
}
|
|
1081
|
-
return attrsStore.forwardIdents.get(etype)?.get('id');
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
function findTriple(
|
|
1085
|
-
store: Store,
|
|
1086
|
-
attrsStore: AttrsStore,
|
|
1087
|
-
rawTriple: [string, string, any] | Triple,
|
|
1088
|
-
): Triple | undefined {
|
|
1089
|
-
const triple = resolveLookupRefs(store, rawTriple as Triple);
|
|
1090
|
-
if (!triple) {
|
|
1091
|
-
return;
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
const [eid, aid, v] = triple;
|
|
1095
|
-
const attr = attrsStore.getAttr(aid);
|
|
1096
|
-
if (!attr) {
|
|
1097
|
-
// (XXX): Due to the way we're handling attrs, it's
|
|
1098
|
-
// possible to enter a state where we receive a triple without an attr.
|
|
1099
|
-
// See: https://github.com/jsventures/instant-local/pull/132 for details.
|
|
1100
|
-
// For now, if we receive a command without an attr, we no-op.
|
|
1101
|
-
return;
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
return getInMap(store.eav, [eid, aid]);
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
export function transact(
|
|
1108
|
-
store: Store,
|
|
1109
|
-
attrsStore: AttrsStore,
|
|
1110
|
-
txSteps,
|
|
1111
|
-
): { store: Store; attrsStore: AttrsStore } {
|
|
1112
|
-
const txStepsFiltered = txSteps.filter(
|
|
1113
|
-
([action, eid, attrId, value, opts]) => {
|
|
1114
|
-
if (action !== 'add-triple' && action !== 'deep-merge-triple') {
|
|
1115
|
-
return true;
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
const mode = opts?.mode;
|
|
1119
|
-
if (mode !== 'create' && mode !== 'update') {
|
|
1120
|
-
return true;
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
let exists = false;
|
|
1124
|
-
|
|
1125
|
-
const attr = attrsStore.getAttr(attrId);
|
|
1126
|
-
if (attr) {
|
|
1127
|
-
const idAttr = getPrimaryKeyAttr(
|
|
1128
|
-
attrsStore,
|
|
1129
|
-
attr['forward-identity'][1],
|
|
1130
|
-
);
|
|
1131
|
-
exists = !!findTriple(store, attrsStore, [
|
|
1132
|
-
eid as string,
|
|
1133
|
-
idAttr?.id as string,
|
|
1134
|
-
eid,
|
|
1135
|
-
]);
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
if (mode === 'create' && exists) {
|
|
1139
|
-
return false;
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
if (mode === 'update' && !exists) {
|
|
1143
|
-
return false;
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
return true;
|
|
1147
|
-
},
|
|
1148
|
-
);
|
|
1149
|
-
|
|
1150
|
-
return create(
|
|
1151
|
-
{ store, attrsStore },
|
|
1152
|
-
(draft) => {
|
|
1153
|
-
txStepsFiltered.forEach((txStep) => {
|
|
1154
|
-
applyTxStep(draft.store, draft.attrsStore, txStep);
|
|
1155
|
-
});
|
|
1156
|
-
},
|
|
1157
|
-
{
|
|
1158
|
-
mark: (target) => {
|
|
1159
|
-
if (target instanceof AttrsStoreClass) {
|
|
1160
|
-
return 'immutable';
|
|
1161
|
-
}
|
|
1162
|
-
},
|
|
1163
|
-
},
|
|
1164
|
-
);
|
|
1165
|
-
}
|