@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
|
@@ -0,0 +1,1159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BackendRelayError = exports.setBackendRelayWarningsEnabled = exports.BackendRelayAPIError = exports.WebhooksManager = exports.Webhooks = exports.createBackendRelayRouteHandler = exports.i = exports.lookup = exports.tx = exports.id = exports.init_experimental = void 0;
|
|
7
|
+
exports.init = init;
|
|
8
|
+
const uuid_1 = require("uuid");
|
|
9
|
+
const core_1 = require("@backendrelay/core");
|
|
10
|
+
Object.defineProperty(exports, "tx", { enumerable: true, get: function () { return core_1.tx; } });
|
|
11
|
+
Object.defineProperty(exports, "lookup", { enumerable: true, get: function () { return core_1.lookup; } });
|
|
12
|
+
Object.defineProperty(exports, "i", { enumerable: true, get: function () { return core_1.i; } });
|
|
13
|
+
Object.defineProperty(exports, "id", { enumerable: true, get: function () { return core_1.id; } });
|
|
14
|
+
Object.defineProperty(exports, "BackendRelayAPIError", { enumerable: true, get: function () { return core_1.BackendRelayAPIError; } });
|
|
15
|
+
Object.defineProperty(exports, "setBackendRelayWarningsEnabled", { enumerable: true, get: function () { return core_1.setBackendRelayWarningsEnabled; } });
|
|
16
|
+
Object.defineProperty(exports, "BackendRelayError", { enumerable: true, get: function () { return core_1.BackendRelayError; } });
|
|
17
|
+
Object.defineProperty(exports, "createBackendRelayRouteHandler", { enumerable: true, get: function () { return core_1.createBackendRelayRouteHandler; } });
|
|
18
|
+
const version_ts_1 = __importDefault(require("./version.js"));
|
|
19
|
+
const subscribe_ts_1 = require("./subscribe.js");
|
|
20
|
+
const cookie_1 = require("cookie");
|
|
21
|
+
const eventsource_1 = require("@instantdb/eventsource");
|
|
22
|
+
const polyfill_ts_1 = require("./polyfill.js");
|
|
23
|
+
const webhooks_1 = require("@backendrelay/webhooks");
|
|
24
|
+
Object.defineProperty(exports, "Webhooks", { enumerable: true, get: function () { return webhooks_1.Webhooks; } });
|
|
25
|
+
Object.defineProperty(exports, "WebhooksManager", { enumerable: true, get: function () { return webhooks_1.WebhooksManager; } });
|
|
26
|
+
function configWithDefaults(config) {
|
|
27
|
+
return {
|
|
28
|
+
...config,
|
|
29
|
+
apiURI: (0, core_1.requireApiURI)(config.apiURI, 'BackendRelay admin SDK'),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function backendrelayConfigWithDefaults(config) {
|
|
33
|
+
return {
|
|
34
|
+
...config,
|
|
35
|
+
apiURI: (0, core_1.requireApiURI)(config.apiURI, 'BackendRelay admin SDK'),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function withImpersonation(headers, opts) {
|
|
39
|
+
if ('email' in opts) {
|
|
40
|
+
headers['as-email'] = opts.email;
|
|
41
|
+
}
|
|
42
|
+
else if ('token' in opts) {
|
|
43
|
+
headers['as-token'] = opts.token;
|
|
44
|
+
}
|
|
45
|
+
else if ('guest' in opts) {
|
|
46
|
+
headers['as-guest'] = 'true';
|
|
47
|
+
}
|
|
48
|
+
return headers;
|
|
49
|
+
}
|
|
50
|
+
function validateConfigAndImpersonation(config, impersonationOpts) {
|
|
51
|
+
if (impersonationOpts &&
|
|
52
|
+
('token' in impersonationOpts || 'guest' in impersonationOpts)) {
|
|
53
|
+
// adminToken is not required for `token` or `guest` impersonation
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (config.adminToken) {
|
|
57
|
+
// An adminToken is provided.
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (impersonationOpts && 'email' in impersonationOpts) {
|
|
61
|
+
throw new Error('Admin token required. To impersonate users with an email you must pass `adminToken` to `init`.');
|
|
62
|
+
}
|
|
63
|
+
throw new Error('Admin token required. To run this operation pass `adminToken` to `init`, or use `db.asUser`.');
|
|
64
|
+
}
|
|
65
|
+
function authorizedHeaders(config, impersonationOpts) {
|
|
66
|
+
validateConfigAndImpersonation(config, impersonationOpts);
|
|
67
|
+
const { adminToken, appId } = config;
|
|
68
|
+
const headers = {
|
|
69
|
+
'content-type': 'application/json',
|
|
70
|
+
'app-id': appId,
|
|
71
|
+
};
|
|
72
|
+
if (adminToken) {
|
|
73
|
+
headers.authorization = `Bearer ${adminToken}`;
|
|
74
|
+
}
|
|
75
|
+
if (config.requestId) {
|
|
76
|
+
headers['x-request-id'] = config.requestId;
|
|
77
|
+
}
|
|
78
|
+
return impersonationOpts
|
|
79
|
+
? withImpersonation(headers, impersonationOpts)
|
|
80
|
+
: headers;
|
|
81
|
+
}
|
|
82
|
+
// NextJS 13 and 14 cache fetch requests by default.
|
|
83
|
+
//
|
|
84
|
+
// Since adminDB.query uses fetch, this means that it would also cache by default.
|
|
85
|
+
//
|
|
86
|
+
// We don't want this behavior. `adminDB.query` should return the latest result by default.
|
|
87
|
+
//
|
|
88
|
+
// To get around this, we set an explicit `cache` header for NextJS 13 and 14.
|
|
89
|
+
// This is no longer needed in NextJS 15 onwards, as the default is `no-store` again.
|
|
90
|
+
// Once NextJS 13 and 14 are no longer common, we can remove this code.
|
|
91
|
+
function isNextJSVersionThatCachesFetchByDefault() {
|
|
92
|
+
return (
|
|
93
|
+
// NextJS 13 onwards added a `__nextPatched` property to the fetch function
|
|
94
|
+
fetch['__nextPatched'] &&
|
|
95
|
+
// NextJS 15 onwards _also_ added a global `next-patch` symbol.
|
|
96
|
+
!globalThis[Symbol.for('next-patch')]);
|
|
97
|
+
}
|
|
98
|
+
function getDefaultFetchOpts() {
|
|
99
|
+
return isNextJSVersionThatCachesFetchByDefault() ? { cache: 'no-store' } : {};
|
|
100
|
+
}
|
|
101
|
+
async function jsonReject(rejectFn, res) {
|
|
102
|
+
const body = await res.text();
|
|
103
|
+
try {
|
|
104
|
+
const json = JSON.parse(body);
|
|
105
|
+
return rejectFn(new core_1.BackendRelayAPIError({ status: res.status, body: json }));
|
|
106
|
+
}
|
|
107
|
+
catch (_e) {
|
|
108
|
+
return rejectFn(new core_1.BackendRelayAPIError({
|
|
109
|
+
status: res.status,
|
|
110
|
+
body: { type: undefined, message: body },
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function rawJsonFetch(input, init, onError) {
|
|
115
|
+
try {
|
|
116
|
+
const defaultFetchOpts = getDefaultFetchOpts();
|
|
117
|
+
const headers = {
|
|
118
|
+
...(init?.headers || {}),
|
|
119
|
+
'BackendRelay-Admin-Version': version_ts_1.default,
|
|
120
|
+
'BackendRelay-Core-Version': core_1.version,
|
|
121
|
+
};
|
|
122
|
+
const res = await fetch(input, { ...defaultFetchOpts, ...init, headers });
|
|
123
|
+
if (res.status === 200) {
|
|
124
|
+
const json = await res.json();
|
|
125
|
+
return Promise.resolve(json);
|
|
126
|
+
}
|
|
127
|
+
return await jsonReject((x) => Promise.reject(x), res);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
(0, core_1.notifyError)(onError, error);
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function makeEventSourceWrapper(opts) {
|
|
135
|
+
return class EventSourceWrapper {
|
|
136
|
+
source;
|
|
137
|
+
static OPEN = eventsource_1.EventSource.OPEN;
|
|
138
|
+
static CONNECTING = eventsource_1.EventSource.CONNECTING;
|
|
139
|
+
static CLOSED = eventsource_1.EventSource.CLOSED;
|
|
140
|
+
url;
|
|
141
|
+
constructor(url) {
|
|
142
|
+
this.url = url;
|
|
143
|
+
this.source = this.#createEventSource(url);
|
|
144
|
+
}
|
|
145
|
+
get onopen() {
|
|
146
|
+
return this.source.onopen;
|
|
147
|
+
}
|
|
148
|
+
set onopen(fn) {
|
|
149
|
+
this.source.onopen = fn;
|
|
150
|
+
}
|
|
151
|
+
get onmessage() {
|
|
152
|
+
return this.source.onmessage;
|
|
153
|
+
}
|
|
154
|
+
set onmessage(fn) {
|
|
155
|
+
this.source.onmessage = fn;
|
|
156
|
+
}
|
|
157
|
+
get onerror() {
|
|
158
|
+
return this.source.onerror;
|
|
159
|
+
}
|
|
160
|
+
set onerror(fn) {
|
|
161
|
+
this.source.onerror = fn;
|
|
162
|
+
}
|
|
163
|
+
get readyState() {
|
|
164
|
+
return this.source.readyState;
|
|
165
|
+
}
|
|
166
|
+
close() {
|
|
167
|
+
this.source.close();
|
|
168
|
+
}
|
|
169
|
+
#createEventSource(url) {
|
|
170
|
+
const es = new eventsource_1.EventSource(url, {
|
|
171
|
+
messageEvent: polyfill_ts_1.MessageEventPolyfill,
|
|
172
|
+
fetch(input, init) {
|
|
173
|
+
return fetch(input, {
|
|
174
|
+
...init,
|
|
175
|
+
method: 'POST',
|
|
176
|
+
headers: opts.headers,
|
|
177
|
+
body: JSON.stringify({
|
|
178
|
+
'inference?': opts.inference,
|
|
179
|
+
versions: {
|
|
180
|
+
'@backendrelay/admin': version_ts_1.default,
|
|
181
|
+
'@backendrelay/core': core_1.version,
|
|
182
|
+
},
|
|
183
|
+
}),
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
return es;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
*
|
|
193
|
+
* The first step: init your application!
|
|
194
|
+
*
|
|
195
|
+
* Visit your BackendRelay dashboard to get your `appId` and `adminToken`, and
|
|
196
|
+
* pass the API origin as `apiURI` :) The admin SDK no longer defaults to
|
|
197
|
+
* backendrelay.com.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* import { init } from "@backendrelay/admin"
|
|
201
|
+
*
|
|
202
|
+
* const db = init({
|
|
203
|
+
* appId: process.env.BACKENDRELAY_APP_ID!,
|
|
204
|
+
* adminToken: process.env.BACKENDRELAY_APP_ADMIN_TOKEN,
|
|
205
|
+
* apiURI: process.env.BACKENDRELAY_API_URI!,
|
|
206
|
+
* })
|
|
207
|
+
*
|
|
208
|
+
* // You can also provide a schema for type safety and editor autocomplete!
|
|
209
|
+
*
|
|
210
|
+
* import { init } from "@backendrelay/admin"
|
|
211
|
+
* import schema from ""../backendrelay.schema.ts";
|
|
212
|
+
*
|
|
213
|
+
* const db = init({
|
|
214
|
+
* appId: process.env.BACKENDRELAY_APP_ID!,
|
|
215
|
+
* adminToken: process.env.BACKENDRELAY_APP_ADMIN_TOKEN,
|
|
216
|
+
* apiURI: process.env.BACKENDRELAY_API_URI!,
|
|
217
|
+
* schema,
|
|
218
|
+
* })
|
|
219
|
+
*/
|
|
220
|
+
function init(
|
|
221
|
+
// Allows config with missing `useDateObjects`, but keeps `UseDates`
|
|
222
|
+
// as a non-nullable in the BackendRelayConfig type.
|
|
223
|
+
config) {
|
|
224
|
+
if (!config.appId || !(0, uuid_1.validate)(config.appId)) {
|
|
225
|
+
console.warn('warning: BackendRelay Admin DB must be initialized with a valid appId. Received: ' +
|
|
226
|
+
JSON.stringify(config.appId));
|
|
227
|
+
}
|
|
228
|
+
const configStrict = {
|
|
229
|
+
...config,
|
|
230
|
+
appId: config.appId?.trim(),
|
|
231
|
+
adminToken: config.adminToken?.trim(),
|
|
232
|
+
useDateObjects: (config.useDateObjects ?? false),
|
|
233
|
+
};
|
|
234
|
+
return new BackendRelayAdminDatabase(configStrict);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* @deprecated
|
|
238
|
+
* `init_experimental` is deprecated. You can replace it with `init`.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
*
|
|
242
|
+
* // Before
|
|
243
|
+
* import { init_experimental } from "@backendrelay/admin"
|
|
244
|
+
* const db = init_experimental({ ... });
|
|
245
|
+
*
|
|
246
|
+
* // After
|
|
247
|
+
* import { init } from "@backendrelay/admin"
|
|
248
|
+
* const db = init({ ... });
|
|
249
|
+
*/
|
|
250
|
+
const init_experimental = init;
|
|
251
|
+
exports.init_experimental = init_experimental;
|
|
252
|
+
function steps(inputChunks) {
|
|
253
|
+
const chunks = Array.isArray(inputChunks) ? inputChunks : [inputChunks];
|
|
254
|
+
return chunks.flatMap(core_1.getOps);
|
|
255
|
+
}
|
|
256
|
+
class Rooms {
|
|
257
|
+
config;
|
|
258
|
+
_fetch = (input, init) => rawJsonFetch(input, init, this.config.onError);
|
|
259
|
+
constructor(config) {
|
|
260
|
+
this.config = config;
|
|
261
|
+
}
|
|
262
|
+
async getPresence(roomType, roomId) {
|
|
263
|
+
const res = await this._fetch(`${this.config.apiURI}/admin/rooms/presence?app_id=${this.config.appId}&room-type=${String(roomType)}&room-id=${roomId}`, {
|
|
264
|
+
method: 'GET',
|
|
265
|
+
headers: authorizedHeaders(this.config),
|
|
266
|
+
});
|
|
267
|
+
return res.sessions || {};
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
class Auth {
|
|
271
|
+
config;
|
|
272
|
+
_fetch = (input, init) => rawJsonFetch(input, init, this.config.onError);
|
|
273
|
+
constructor(config) {
|
|
274
|
+
this.config = config;
|
|
275
|
+
this.createToken = this.createToken.bind(this);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Generates a magic code for the user with the given email.
|
|
279
|
+
* This is useful if you want to use your own email provider
|
|
280
|
+
* to send magic codes.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* // Generate a magic code
|
|
284
|
+
* const { code } = await db.auth.generateMagicCode({ email })
|
|
285
|
+
* // Send the magic code to the user with your own email provider
|
|
286
|
+
* await customEmailProvider.sendMagicCode(email, code)
|
|
287
|
+
*
|
|
288
|
+
* @see https://backendrelay.com/docs/backend#custom-magic-codes
|
|
289
|
+
*/
|
|
290
|
+
generateMagicCode = async (email) => {
|
|
291
|
+
return this._fetch(`${this.config.apiURI}/admin/magic_code?app_id=${this.config.appId}`, {
|
|
292
|
+
method: 'POST',
|
|
293
|
+
headers: authorizedHeaders(this.config),
|
|
294
|
+
body: JSON.stringify({ email }),
|
|
295
|
+
});
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* Sends a magic code to the user with the given email.
|
|
299
|
+
* This uses BackendRelay's built-in email provider.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* // Send an email to user with magic code
|
|
303
|
+
* await db.auth.sendMagicCode({ email })
|
|
304
|
+
*
|
|
305
|
+
* @see https://backendrelay.com/docs/backend#custom-magic-codes
|
|
306
|
+
*/
|
|
307
|
+
sendMagicCode = async (email) => {
|
|
308
|
+
return this._fetch(`${this.config.apiURI}/admin/send_magic_code?app_id=${this.config.appId}`, {
|
|
309
|
+
method: 'POST',
|
|
310
|
+
headers: authorizedHeaders(this.config),
|
|
311
|
+
body: JSON.stringify({ email }),
|
|
312
|
+
});
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* @deprecated Use {@link checkMagicCode} instead to get the `created` field
|
|
316
|
+
* and support `extraFields`.
|
|
317
|
+
*
|
|
318
|
+
* @see https://backendrelay.com/docs/backend#custom-magic-codes
|
|
319
|
+
*/
|
|
320
|
+
verifyMagicCode = async (email, code) => {
|
|
321
|
+
const { user } = await this._fetch(`${this.config.apiURI}/admin/verify_magic_code?app_id=${this.config.appId}`, {
|
|
322
|
+
method: 'POST',
|
|
323
|
+
headers: authorizedHeaders(this.config),
|
|
324
|
+
body: JSON.stringify({ email, code }),
|
|
325
|
+
});
|
|
326
|
+
return user;
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* Verifies a magic code and returns the user along with whether
|
|
330
|
+
* the user was newly created. Supports `extraFields` to set custom
|
|
331
|
+
* `$users` properties at signup.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* const { user, created } = await db.auth.checkMagicCode(
|
|
335
|
+
* email,
|
|
336
|
+
* code,
|
|
337
|
+
* { extraFields: { nickname: 'ari' } },
|
|
338
|
+
* );
|
|
339
|
+
*
|
|
340
|
+
* @see https://backendrelay.com/docs/backend#custom-magic-codes
|
|
341
|
+
*/
|
|
342
|
+
checkMagicCode = async (email, code, options) => {
|
|
343
|
+
const res = await this._fetch(`${this.config.apiURI}/admin/verify_magic_code?app_id=${this.config.appId}`, {
|
|
344
|
+
method: 'POST',
|
|
345
|
+
headers: authorizedHeaders(this.config),
|
|
346
|
+
body: JSON.stringify({
|
|
347
|
+
email,
|
|
348
|
+
code,
|
|
349
|
+
...(options?.extraFields
|
|
350
|
+
? { 'extra-fields': options.extraFields }
|
|
351
|
+
: {}),
|
|
352
|
+
}),
|
|
353
|
+
});
|
|
354
|
+
return { user: res.user, created: res.created };
|
|
355
|
+
};
|
|
356
|
+
async createToken(input) {
|
|
357
|
+
const body = typeof input === 'string' ? { email: input } : input;
|
|
358
|
+
const ret = await this._fetch(`${this.config.apiURI}/admin/refresh_tokens?app_id=${this.config.appId}`, {
|
|
359
|
+
method: 'POST',
|
|
360
|
+
headers: authorizedHeaders(this.config),
|
|
361
|
+
body: JSON.stringify(body),
|
|
362
|
+
});
|
|
363
|
+
return ret.user.refresh_token;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Verifies a given token and returns the associated user.
|
|
367
|
+
*
|
|
368
|
+
* This is often useful for writing custom endpoints, where you need
|
|
369
|
+
* to authenticate users.
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* app.post('/custom_endpoint', async (req, res) => {
|
|
373
|
+
* const user = await db.auth.verifyToken(req.headers['token'])
|
|
374
|
+
* if (!user) {
|
|
375
|
+
* return res.status(401).send('Uh oh, you are not authenticated')
|
|
376
|
+
* }
|
|
377
|
+
* // ...
|
|
378
|
+
* })
|
|
379
|
+
* @see https://backendrelay.com/docs/backend#custom-endpoints
|
|
380
|
+
*/
|
|
381
|
+
verifyToken = async (token) => {
|
|
382
|
+
const res = await this._fetch(`${this.config.apiURI}/runtime/auth/verify_refresh_token?app_id=${this.config.appId}`, {
|
|
383
|
+
method: 'POST',
|
|
384
|
+
headers: { 'content-type': 'application/json' },
|
|
385
|
+
body: JSON.stringify({
|
|
386
|
+
'app-id': this.config.appId,
|
|
387
|
+
'refresh-token': token,
|
|
388
|
+
}),
|
|
389
|
+
});
|
|
390
|
+
return res.user;
|
|
391
|
+
};
|
|
392
|
+
/**
|
|
393
|
+
* Retrieves an app user by id, email, or refresh token.
|
|
394
|
+
* Resolves to `null` when no user matches; throws on malformed
|
|
395
|
+
* input or auth errors.
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* const user = await db.auth.getUser({ email });
|
|
399
|
+
* if (!user) {
|
|
400
|
+
* console.log("No user found");
|
|
401
|
+
* return;
|
|
402
|
+
* }
|
|
403
|
+
* console.log("Found user:", user);
|
|
404
|
+
*
|
|
405
|
+
* @see https://backendrelay.com/docs/backend#retrieve-a-user
|
|
406
|
+
*/
|
|
407
|
+
getUser = async (params) => {
|
|
408
|
+
const qs = new URLSearchParams(Object.entries(params)).toString();
|
|
409
|
+
const response = await this._fetch(`${this.config.apiURI}/admin/users?app_id=${this.config.appId}&${qs}`, {
|
|
410
|
+
method: 'GET',
|
|
411
|
+
headers: authorizedHeaders(this.config),
|
|
412
|
+
});
|
|
413
|
+
return response.user;
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* Deletes an app user by id, email, or refresh token.
|
|
417
|
+
* Resolves to `null` when no user matches; throws on malformed
|
|
418
|
+
* input or auth errors.
|
|
419
|
+
*
|
|
420
|
+
* NB: This _only_ deletes the user; it does not delete all user data.
|
|
421
|
+
* You will need to handle this manually.
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* const deletedUser = await db.auth.deleteUser({ email });
|
|
425
|
+
* if (!deletedUser) {
|
|
426
|
+
* console.log("No user found to delete");
|
|
427
|
+
* return;
|
|
428
|
+
* }
|
|
429
|
+
* console.log("Deleted user:", deletedUser);
|
|
430
|
+
*
|
|
431
|
+
* @see https://backendrelay.com/docs/backend#delete-a-user
|
|
432
|
+
*/
|
|
433
|
+
deleteUser = async (params) => {
|
|
434
|
+
const qs = new URLSearchParams(Object.entries(params)).toString();
|
|
435
|
+
const response = await this._fetch(`${this.config.apiURI}/admin/users?app_id=${this.config.appId}&${qs}`, {
|
|
436
|
+
method: 'DELETE',
|
|
437
|
+
headers: authorizedHeaders(this.config),
|
|
438
|
+
});
|
|
439
|
+
return response.deleted;
|
|
440
|
+
};
|
|
441
|
+
async signOut(input) {
|
|
442
|
+
// If input is a string, we assume it's an email.
|
|
443
|
+
// This is because of backwards compatibility: we used to only
|
|
444
|
+
// accept email strings. Eventually we can remove this
|
|
445
|
+
const params = typeof input === 'string' ? { email: input } : input;
|
|
446
|
+
const config = this.config;
|
|
447
|
+
await this._fetch(`${config.apiURI}/admin/sign_out?app_id=${this.config.appId}`, {
|
|
448
|
+
method: 'POST',
|
|
449
|
+
headers: authorizedHeaders(config),
|
|
450
|
+
body: JSON.stringify(params),
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Get instant user from Request
|
|
455
|
+
*
|
|
456
|
+
* Reads cookies and gets a validated user
|
|
457
|
+
* @param req The request containing a cookie synced with createBackendRelayRouteHandler
|
|
458
|
+
* @param opts Allow disabling validation of refresh token
|
|
459
|
+
*/
|
|
460
|
+
getUserFromRequest = async (req, opts) => {
|
|
461
|
+
const cookieHeader = req.headers.get('cookie') || '';
|
|
462
|
+
const parsedCookie = (0, cookie_1.parseCookie)(cookieHeader);
|
|
463
|
+
const cookieName = 'backendrelay_user_' + this.config.appId;
|
|
464
|
+
if (!parsedCookie[cookieName]) {
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
const value = parsedCookie[cookieName];
|
|
468
|
+
const user = JSON.parse(value);
|
|
469
|
+
if (!user?.refresh_token) {
|
|
470
|
+
return null;
|
|
471
|
+
}
|
|
472
|
+
if (opts?.disableValidation) {
|
|
473
|
+
return user;
|
|
474
|
+
}
|
|
475
|
+
const verified = await this.verifyToken(user.refresh_token);
|
|
476
|
+
return verified;
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
const isNodeReadable = (v) => v &&
|
|
480
|
+
typeof v === 'object' &&
|
|
481
|
+
typeof v.pipe === 'function' &&
|
|
482
|
+
typeof v.read === 'function';
|
|
483
|
+
const isWebReadable = (v) => v && typeof v.getReader === 'function';
|
|
484
|
+
function isHeaderSafe(value) {
|
|
485
|
+
return /^[\x20-\x7e]*$/.test(value);
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Functions to manage file storage.
|
|
489
|
+
*/
|
|
490
|
+
class Storage {
|
|
491
|
+
config;
|
|
492
|
+
impersonationOpts;
|
|
493
|
+
_fetch = (input, init) => rawJsonFetch(input, init, this.config.onError);
|
|
494
|
+
constructor(config, impersonationOpts) {
|
|
495
|
+
this.config = config;
|
|
496
|
+
this.impersonationOpts = impersonationOpts;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Uploads file at the provided path. Accepts bytes (`Uint8Array`, including
|
|
500
|
+
* Node's `Buffer`), a Node `Readable`, or a web `ReadableStream`.
|
|
501
|
+
*
|
|
502
|
+
* @see https://backendrelay.com/docs/storage
|
|
503
|
+
* @example
|
|
504
|
+
* const buffer = fs.readFileSync('demo.png');
|
|
505
|
+
* const isSuccess = await db.storage.uploadFile('photos/demo.png', buffer);
|
|
506
|
+
*/
|
|
507
|
+
uploadFile = async (path, file, metadata = {}) => {
|
|
508
|
+
const headers = {
|
|
509
|
+
...authorizedHeaders(this.config, this.impersonationOpts),
|
|
510
|
+
};
|
|
511
|
+
if (isHeaderSafe(path)) {
|
|
512
|
+
headers['path'] = path;
|
|
513
|
+
}
|
|
514
|
+
if (metadata.contentDisposition) {
|
|
515
|
+
if (isHeaderSafe(metadata.contentDisposition)) {
|
|
516
|
+
headers['content-disposition'] = metadata.contentDisposition;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
// headers.content-type will become "undefined" (string)
|
|
520
|
+
// if not removed from the object
|
|
521
|
+
delete headers['content-type'];
|
|
522
|
+
if (metadata.contentType) {
|
|
523
|
+
headers['content-type'] = metadata.contentType;
|
|
524
|
+
}
|
|
525
|
+
let duplex;
|
|
526
|
+
if (isNodeReadable(file)) {
|
|
527
|
+
duplex = 'half'; // one-way stream
|
|
528
|
+
}
|
|
529
|
+
if (isNodeReadable(file) || isWebReadable(file)) {
|
|
530
|
+
if (!metadata.fileSize) {
|
|
531
|
+
throw new Error('fileSize is required in metadata when uploading streams');
|
|
532
|
+
}
|
|
533
|
+
headers['content-length'] = metadata.fileSize.toString();
|
|
534
|
+
}
|
|
535
|
+
let options = {
|
|
536
|
+
method: 'PUT',
|
|
537
|
+
headers,
|
|
538
|
+
body: file,
|
|
539
|
+
...(duplex && { duplex }),
|
|
540
|
+
};
|
|
541
|
+
let url = `${this.config.apiURI}/admin/storage/upload?app_id=${encodeURIComponent(this.config.appId)}&path=${encodeURIComponent(path)}`;
|
|
542
|
+
if (metadata.contentDisposition) {
|
|
543
|
+
url += `&content-disposition=${encodeURIComponent(metadata.contentDisposition)}`;
|
|
544
|
+
}
|
|
545
|
+
return this._fetch(url, options);
|
|
546
|
+
};
|
|
547
|
+
/**
|
|
548
|
+
* Deletes a file by its path name (e.g. "photos/demo.png").
|
|
549
|
+
*
|
|
550
|
+
* @deprecated Use `db.transact` to delete files instead:
|
|
551
|
+
* @example
|
|
552
|
+
* // Delete by id
|
|
553
|
+
* await db.transact(db.tx.$files[fileId].delete());
|
|
554
|
+
*
|
|
555
|
+
* // Delete by path
|
|
556
|
+
* await db.transact(db.tx.$files[lookup('path', 'photos/demo.png')].delete());
|
|
557
|
+
*
|
|
558
|
+
* @see https://backendrelay.com/docs/storage
|
|
559
|
+
*/
|
|
560
|
+
delete = async (pathname) => {
|
|
561
|
+
return this._fetch(`${this.config.apiURI}/admin/storage/files?app_id=${this.config.appId}&filename=${encodeURIComponent(pathname)}`, {
|
|
562
|
+
method: 'DELETE',
|
|
563
|
+
headers: authorizedHeaders(this.config, this.impersonationOpts),
|
|
564
|
+
});
|
|
565
|
+
};
|
|
566
|
+
/**
|
|
567
|
+
* Deletes multiple files by their path names.
|
|
568
|
+
*
|
|
569
|
+
* @deprecated Use `db.transact` to delete files instead:
|
|
570
|
+
* @example
|
|
571
|
+
* // Delete multiple files by path
|
|
572
|
+
* const paths = ['images/1.png', 'images/2.png', 'images/3.png'];
|
|
573
|
+
* await db.transact(paths.map(p => db.tx.$files[lookup('path', p)].delete()));
|
|
574
|
+
*
|
|
575
|
+
* @see https://backendrelay.com/docs/storage
|
|
576
|
+
*/
|
|
577
|
+
deleteMany = async (pathnames) => {
|
|
578
|
+
return this._fetch(`${this.config.apiURI}/admin/storage/files/delete?app_id=${this.config.appId}`, {
|
|
579
|
+
method: 'POST',
|
|
580
|
+
headers: authorizedHeaders(this.config, this.impersonationOpts),
|
|
581
|
+
body: JSON.stringify({ filenames: pathnames }),
|
|
582
|
+
});
|
|
583
|
+
};
|
|
584
|
+
/**
|
|
585
|
+
* @deprecated. This method will be removed in the future. Use `uploadFile`
|
|
586
|
+
* instead
|
|
587
|
+
*/
|
|
588
|
+
upload = async (pathname, file, metadata = {}) => {
|
|
589
|
+
const { data: presignedUrl } = await this._fetch(`${this.config.apiURI}/admin/storage/signed-upload-url?app_id=${this.config.appId}`, {
|
|
590
|
+
method: 'POST',
|
|
591
|
+
headers: authorizedHeaders(this.config),
|
|
592
|
+
body: JSON.stringify({
|
|
593
|
+
app_id: this.config.appId,
|
|
594
|
+
filename: pathname,
|
|
595
|
+
}),
|
|
596
|
+
});
|
|
597
|
+
const headers = {};
|
|
598
|
+
const contentType = metadata.contentType;
|
|
599
|
+
if (contentType) {
|
|
600
|
+
headers['Content-Type'] = contentType;
|
|
601
|
+
}
|
|
602
|
+
const { ok } = await fetch(presignedUrl, {
|
|
603
|
+
method: 'PUT',
|
|
604
|
+
body: file,
|
|
605
|
+
headers,
|
|
606
|
+
});
|
|
607
|
+
return ok;
|
|
608
|
+
};
|
|
609
|
+
/**
|
|
610
|
+
* @deprecated. This method will be removed in the future. Use `query` instead
|
|
611
|
+
* @example
|
|
612
|
+
* const files = await db.query({ $files: {}})
|
|
613
|
+
*/
|
|
614
|
+
list = async () => {
|
|
615
|
+
const { data } = await this._fetch(`${this.config.apiURI}/admin/storage/files?app_id=${this.config.appId}`, {
|
|
616
|
+
method: 'GET',
|
|
617
|
+
headers: authorizedHeaders(this.config),
|
|
618
|
+
});
|
|
619
|
+
return data;
|
|
620
|
+
};
|
|
621
|
+
/**
|
|
622
|
+
* @deprecated. getDownloadUrl will be removed in the future.
|
|
623
|
+
* Use `query` instead to query and fetch for valid urls
|
|
624
|
+
*
|
|
625
|
+
* db.useQuery({
|
|
626
|
+
* $files: {
|
|
627
|
+
* $: {
|
|
628
|
+
* where: {
|
|
629
|
+
* path: "moop.png"
|
|
630
|
+
* }
|
|
631
|
+
* }
|
|
632
|
+
* }
|
|
633
|
+
* })
|
|
634
|
+
*/
|
|
635
|
+
getDownloadUrl = async (pathname) => {
|
|
636
|
+
const { data } = await this._fetch(`${this.config.apiURI}/admin/storage/signed-download-url?app_id=${this.config.appId}&filename=${encodeURIComponent(pathname)}`, {
|
|
637
|
+
method: 'GET',
|
|
638
|
+
headers: authorizedHeaders(this.config),
|
|
639
|
+
});
|
|
640
|
+
return data;
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Functions to manage streams.
|
|
645
|
+
*/
|
|
646
|
+
class Streams {
|
|
647
|
+
#ensureBackendRelayStream;
|
|
648
|
+
constructor(ensureBackendRelayStream) {
|
|
649
|
+
this.#ensureBackendRelayStream = ensureBackendRelayStream;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Creates a new ReadableStream for the given clientId.
|
|
653
|
+
*
|
|
654
|
+
* @example
|
|
655
|
+
* const stream = db.streams.createReadStream({clientId: clientId})
|
|
656
|
+
* for await (const chunk of stream) {
|
|
657
|
+
* console.log(chunk);
|
|
658
|
+
* }
|
|
659
|
+
*/
|
|
660
|
+
createReadStream = (opts) => {
|
|
661
|
+
return this.#ensureBackendRelayStream().createReadStream(opts);
|
|
662
|
+
};
|
|
663
|
+
/**
|
|
664
|
+
* Creates a new WritableStream for the given clientId.
|
|
665
|
+
*
|
|
666
|
+
* @example
|
|
667
|
+
* const writeStream = db.streams.createWriteStream({clientId: clientId})
|
|
668
|
+
* const writer = writeStream.getWriter();
|
|
669
|
+
* writer.write('Hello world');
|
|
670
|
+
* writer.close();
|
|
671
|
+
*/
|
|
672
|
+
createWriteStream = (opts) => {
|
|
673
|
+
return this.#ensureBackendRelayStream().createWriteStream(opts);
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
function createLogger(isEnabled, baseLogger = console) {
|
|
677
|
+
return {
|
|
678
|
+
info: isEnabled ? (...args) => baseLogger.info(...args) : () => { },
|
|
679
|
+
debug: isEnabled ? (...args) => baseLogger.debug(...args) : () => { },
|
|
680
|
+
error: isEnabled ? (...args) => baseLogger.error(...args) : () => { },
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
*
|
|
685
|
+
* The first step: init your application!
|
|
686
|
+
*
|
|
687
|
+
* Visit your BackendRelay dashboard to get your `appId` and `adminToken`, and
|
|
688
|
+
* pass the API origin as `apiURI` :) The admin SDK no longer defaults to
|
|
689
|
+
* backendrelay.com.
|
|
690
|
+
*
|
|
691
|
+
* @example
|
|
692
|
+
* const db = init({ appId: "my-app-id", adminToken: "my-admin-token", apiURI: "https://api.example.com" })
|
|
693
|
+
*/
|
|
694
|
+
class BackendRelayAdminDatabase {
|
|
695
|
+
config;
|
|
696
|
+
auth;
|
|
697
|
+
storage;
|
|
698
|
+
streams;
|
|
699
|
+
rooms;
|
|
700
|
+
impersonationOpts;
|
|
701
|
+
webhooks;
|
|
702
|
+
hatchet;
|
|
703
|
+
#sseConnection = null;
|
|
704
|
+
#sseBackoff = 0;
|
|
705
|
+
#backendrelayStream = null;
|
|
706
|
+
#log;
|
|
707
|
+
_fetch = (input, init) => rawJsonFetch(input, init, this.config.onError);
|
|
708
|
+
tx = (0, core_1.txInit)();
|
|
709
|
+
constructor(_config) {
|
|
710
|
+
this.config = backendrelayConfigWithDefaults(_config);
|
|
711
|
+
this.auth = new Auth(this.config);
|
|
712
|
+
this.storage = new Storage(this.config, this.impersonationOpts);
|
|
713
|
+
this.streams = new Streams(this.#ensureBackendRelayStream.bind(this));
|
|
714
|
+
this.rooms = new Rooms(this.config);
|
|
715
|
+
this.webhooks = new webhooks_1.Webhooks(this.config, (input, init) => rawJsonFetch(input, init, this.config.onError));
|
|
716
|
+
this.hatchet = {
|
|
717
|
+
credentials: () => this._fetch(`${this.config.apiURI}/dash/apps/${this.config.appId}/hatchet`, { headers: authorizedHeaders(this.config, this.impersonationOpts) }),
|
|
718
|
+
};
|
|
719
|
+
this.#log = createLogger(!!this.config.verbose, this.config.logger);
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Sometimes you want to scope queries to a specific user.
|
|
723
|
+
*
|
|
724
|
+
* You can provide a user's auth token, email, or impersonate a guest.
|
|
725
|
+
*
|
|
726
|
+
* @see https://backendrelay.com/docs/backend#impersonating-users
|
|
727
|
+
* @example
|
|
728
|
+
* await db.asUser({email: "stopa@backendrelay.com"}).query({ goals: {} })
|
|
729
|
+
*/
|
|
730
|
+
asUser = (opts) => {
|
|
731
|
+
const newClient = new BackendRelayAdminDatabase({
|
|
732
|
+
...this.config,
|
|
733
|
+
});
|
|
734
|
+
newClient.impersonationOpts = opts;
|
|
735
|
+
newClient.storage = new Storage(this.config, opts);
|
|
736
|
+
return newClient;
|
|
737
|
+
};
|
|
738
|
+
/**
|
|
739
|
+
* Use this to query your data!
|
|
740
|
+
*
|
|
741
|
+
* @see https://backendrelay.com/docs/instaql
|
|
742
|
+
*
|
|
743
|
+
* @example
|
|
744
|
+
* // fetch all goals
|
|
745
|
+
* await db.query({ goals: {} })
|
|
746
|
+
*
|
|
747
|
+
* // goals where the title is "Get Fit"
|
|
748
|
+
* await db.query({ goals: { $: { where: { title: "Get Fit" } } } })
|
|
749
|
+
*
|
|
750
|
+
* // all goals, _alongside_ their todos
|
|
751
|
+
* await db.query({ goals: { todos: {} } })
|
|
752
|
+
*/
|
|
753
|
+
query = (query, opts = {}) => {
|
|
754
|
+
if (query && opts && 'ruleParams' in opts) {
|
|
755
|
+
query = { $$ruleParams: opts['ruleParams'], ...query };
|
|
756
|
+
}
|
|
757
|
+
if (!this.config.disableValidation) {
|
|
758
|
+
(0, core_1.validateQuery)(query, this.config.schema);
|
|
759
|
+
}
|
|
760
|
+
const fetchOpts = opts.fetchOpts || {};
|
|
761
|
+
const fetchOptsHeaders = fetchOpts['headers'] || {};
|
|
762
|
+
return this._fetch(`${this.config.apiURI}/admin/query?app_id=${this.config.appId}`, {
|
|
763
|
+
...fetchOpts,
|
|
764
|
+
method: 'POST',
|
|
765
|
+
headers: {
|
|
766
|
+
...fetchOptsHeaders,
|
|
767
|
+
...authorizedHeaders(this.config, this.impersonationOpts),
|
|
768
|
+
},
|
|
769
|
+
body: JSON.stringify({
|
|
770
|
+
query: query,
|
|
771
|
+
'inference?': !!this.config.schema,
|
|
772
|
+
}),
|
|
773
|
+
});
|
|
774
|
+
};
|
|
775
|
+
/**
|
|
776
|
+
* Returns the current version counter for each entity id, defaulting to 0.
|
|
777
|
+
*
|
|
778
|
+
* Pass the versions returned here as `conditions.assert` version checks when
|
|
779
|
+
* another request writes the same entities.
|
|
780
|
+
*/
|
|
781
|
+
versions = async (entityIds) => {
|
|
782
|
+
const res = await this._fetch(`${this.config.apiURI}/admin/versions?app_id=${this.config.appId}`, {
|
|
783
|
+
method: 'POST',
|
|
784
|
+
headers: authorizedHeaders(this.config, this.impersonationOpts),
|
|
785
|
+
body: JSON.stringify({ 'entity-ids': entityIds }),
|
|
786
|
+
});
|
|
787
|
+
return res.versions ?? {};
|
|
788
|
+
};
|
|
789
|
+
/**
|
|
790
|
+
* Writes function log lines for a request. The functions runtime calls this
|
|
791
|
+
* with `ctx.log` output and the inbound `x-request-id`.
|
|
792
|
+
*/
|
|
793
|
+
log = async (entries, requestId) => {
|
|
794
|
+
await this._fetch(`${this.config.apiURI}/admin/logs?app_id=${this.config.appId}`, {
|
|
795
|
+
method: 'POST',
|
|
796
|
+
headers: authorizedHeaders(this.config, this.impersonationOpts),
|
|
797
|
+
body: JSON.stringify({
|
|
798
|
+
'request-id': requestId ?? undefined,
|
|
799
|
+
entries,
|
|
800
|
+
}),
|
|
801
|
+
});
|
|
802
|
+
};
|
|
803
|
+
/** Returns the transactions, logs and webhook events for one request id. */
|
|
804
|
+
trace = (requestId) => {
|
|
805
|
+
return this._fetch(`${this.config.apiURI}/admin/traces/${encodeURIComponent(requestId)}?app_id=${this.config.appId}`, {
|
|
806
|
+
method: 'GET',
|
|
807
|
+
headers: authorizedHeaders(this.config, this.impersonationOpts),
|
|
808
|
+
});
|
|
809
|
+
};
|
|
810
|
+
/**
|
|
811
|
+
* Runs count/sum/avg/min/max over one entity type, optionally grouped by an
|
|
812
|
+
* attribute. Aggregates are admin-only because per-record rules are not
|
|
813
|
+
* evaluated inside SQL aggregates.
|
|
814
|
+
*/
|
|
815
|
+
aggregate = (params) => {
|
|
816
|
+
return this._fetch(`${this.config.apiURI}/admin/aggregate?app_id=${this.config.appId}`, {
|
|
817
|
+
method: 'POST',
|
|
818
|
+
headers: authorizedHeaders(this.config, this.impersonationOpts),
|
|
819
|
+
body: JSON.stringify({
|
|
820
|
+
etype: params.etype,
|
|
821
|
+
filters: params.filters ?? {},
|
|
822
|
+
'group-by': params.groupBy,
|
|
823
|
+
aggregate: {
|
|
824
|
+
field: params.field,
|
|
825
|
+
sum: params.sum,
|
|
826
|
+
avg: params.avg,
|
|
827
|
+
min: params.min,
|
|
828
|
+
max: params.max,
|
|
829
|
+
},
|
|
830
|
+
}),
|
|
831
|
+
});
|
|
832
|
+
};
|
|
833
|
+
/**
|
|
834
|
+
* Returns the nearest vectors for an attribute. Requires the pgvector
|
|
835
|
+
* extension on the database. Admin-only for the same reason as aggregate.
|
|
836
|
+
*/
|
|
837
|
+
nearest = (params) => {
|
|
838
|
+
return this._fetch(`${this.config.apiURI}/admin/nearest?app_id=${this.config.appId}`, {
|
|
839
|
+
method: 'POST',
|
|
840
|
+
headers: authorizedHeaders(this.config, this.impersonationOpts),
|
|
841
|
+
body: JSON.stringify({
|
|
842
|
+
etype: params.etype,
|
|
843
|
+
attr: params.attr,
|
|
844
|
+
vector: params.vector,
|
|
845
|
+
limit: params.limit ?? 10,
|
|
846
|
+
}),
|
|
847
|
+
});
|
|
848
|
+
};
|
|
849
|
+
/**
|
|
850
|
+
* Use this to to get a live view of your data!
|
|
851
|
+
*
|
|
852
|
+
* @see https://www.backendrelay.com/docs/backend
|
|
853
|
+
*
|
|
854
|
+
* @example
|
|
855
|
+
* // create a subscription to a query
|
|
856
|
+
* const query = { goals: { $: { where: { title: "Get Fit" } } } }
|
|
857
|
+
* const sub = db.subscribeQuery(query);
|
|
858
|
+
*
|
|
859
|
+
* // iterate through the results with an async iterator
|
|
860
|
+
* for await (const payload of sub) {
|
|
861
|
+
* if (payload.error) {
|
|
862
|
+
* console.log(payload.error);
|
|
863
|
+
* // Stop the subscription
|
|
864
|
+
* sub.close();
|
|
865
|
+
* } else {
|
|
866
|
+
* console.log(payload.data);
|
|
867
|
+
* }
|
|
868
|
+
* }
|
|
869
|
+
*
|
|
870
|
+
* // Stop the subscription
|
|
871
|
+
* sub.close();
|
|
872
|
+
*
|
|
873
|
+
* // Create a subscription with a callback
|
|
874
|
+
* const sub = db.subscribeQuery(query, (payload) => {
|
|
875
|
+
* if (payload.error) {
|
|
876
|
+
* console.log(payload.error);
|
|
877
|
+
* // Stop the subscription
|
|
878
|
+
* sub.close();
|
|
879
|
+
* } else {
|
|
880
|
+
* console.log(payload.data);
|
|
881
|
+
* }
|
|
882
|
+
* });
|
|
883
|
+
*/
|
|
884
|
+
subscribeQuery(query, cb, opts = {}) {
|
|
885
|
+
if (query && opts && 'ruleParams' in opts) {
|
|
886
|
+
query = { $$ruleParams: opts['ruleParams'], ...query };
|
|
887
|
+
}
|
|
888
|
+
if (!this.config.disableValidation) {
|
|
889
|
+
(0, core_1.validateQuery)(query, this.config.schema);
|
|
890
|
+
}
|
|
891
|
+
const fetchOpts = opts.fetchOpts || {};
|
|
892
|
+
const fetchOptsHeaders = fetchOpts['headers'] || {};
|
|
893
|
+
const headers = {
|
|
894
|
+
...fetchOptsHeaders,
|
|
895
|
+
...authorizedHeaders(this.config, this.impersonationOpts),
|
|
896
|
+
};
|
|
897
|
+
const inference = !!this.config.schema;
|
|
898
|
+
return (0, subscribe_ts_1.subscribe)(query, cb, {
|
|
899
|
+
headers,
|
|
900
|
+
inference,
|
|
901
|
+
apiURI: this.config.apiURI,
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Use this to write data! You can create, update, delete, and link objects
|
|
906
|
+
*
|
|
907
|
+
* @see https://backendrelay.com/docs/instaml
|
|
908
|
+
*
|
|
909
|
+
* @example
|
|
910
|
+
* // Create a new object in the `goals` namespace
|
|
911
|
+
* const goalId = id();
|
|
912
|
+
* db.transact(db.tx.goals[goalId].update({title: "Get fit"}))
|
|
913
|
+
*
|
|
914
|
+
* // Update the title
|
|
915
|
+
* db.transact(db.tx.goals[goalId].update({title: "Get super fit"}))
|
|
916
|
+
*
|
|
917
|
+
* // Delete it
|
|
918
|
+
* db.transact(db.tx.goals[goalId].delete())
|
|
919
|
+
*
|
|
920
|
+
* // Or create an association:
|
|
921
|
+
* todoId = id();
|
|
922
|
+
* db.transact([
|
|
923
|
+
* db.tx.todos[todoId].update({ title: 'Go on a run' }),
|
|
924
|
+
* db.tx.goals[goalId].link({todos: todoId}),
|
|
925
|
+
* ])
|
|
926
|
+
*/
|
|
927
|
+
transact = (inputChunks, options) => {
|
|
928
|
+
// JavaScript callers may still pass the former enqueue options. Fail before
|
|
929
|
+
// writing data instead of silently discarding their requested background work.
|
|
930
|
+
if (options && 'enqueue' in options) {
|
|
931
|
+
return Promise.reject(new Error('Transaction options are no longer supported. Use db.transact(chunks).'));
|
|
932
|
+
}
|
|
933
|
+
if (!this.config.disableValidation) {
|
|
934
|
+
(0, core_1.validateTransactions)(inputChunks, this.config.schema);
|
|
935
|
+
}
|
|
936
|
+
return this._fetch(`${this.config.apiURI}/admin/transact?app_id=${this.config.appId}`, {
|
|
937
|
+
method: 'POST',
|
|
938
|
+
headers: authorizedHeaders(this.config, this.impersonationOpts),
|
|
939
|
+
body: JSON.stringify({
|
|
940
|
+
steps: steps(inputChunks),
|
|
941
|
+
'throw-on-missing-attrs?': !!this.config.schema,
|
|
942
|
+
conditions: options?.conditions,
|
|
943
|
+
}),
|
|
944
|
+
});
|
|
945
|
+
};
|
|
946
|
+
/**
|
|
947
|
+
* Like `query`, but returns debugging information
|
|
948
|
+
* for permissions checks along with the result.
|
|
949
|
+
* Useful for inspecting the values returned by the permissions checks.
|
|
950
|
+
* Note, this will return debug information for *all* entities
|
|
951
|
+
* that match the query's `where` clauses.
|
|
952
|
+
*
|
|
953
|
+
* Requires a user/guest context to be set with `asUser`,
|
|
954
|
+
* since permissions checks are user-specific.
|
|
955
|
+
*
|
|
956
|
+
* Accepts an optional configuration object with a `rules` key.
|
|
957
|
+
* The provided rules will override the rules in the database for the query.
|
|
958
|
+
*
|
|
959
|
+
* @see https://backendrelay.com/docs/instaql
|
|
960
|
+
*
|
|
961
|
+
* @example
|
|
962
|
+
* await db.asUser({ guest: true }).debugQuery(
|
|
963
|
+
* { goals: {} },
|
|
964
|
+
* { rules: { goals: { allow: { read: "auth.id != null" } } }
|
|
965
|
+
* )
|
|
966
|
+
*/
|
|
967
|
+
debugQuery = async (query, opts) => {
|
|
968
|
+
if (query && opts && 'ruleParams' in opts) {
|
|
969
|
+
query = { $$ruleParams: opts['ruleParams'], ...query };
|
|
970
|
+
}
|
|
971
|
+
const body = {
|
|
972
|
+
query,
|
|
973
|
+
'rules-override': opts?.rules,
|
|
974
|
+
'inference?': opts?.cardinalityInference ?? !!this.config.schema,
|
|
975
|
+
};
|
|
976
|
+
if (opts?.ip) {
|
|
977
|
+
body['ip-override'] = opts.ip;
|
|
978
|
+
}
|
|
979
|
+
if (opts?.origin) {
|
|
980
|
+
body['origin-override'] = opts.origin;
|
|
981
|
+
}
|
|
982
|
+
const response = await this._fetch(`${this.config.apiURI}/admin/query_perms_check?app_id=${this.config.appId}`, {
|
|
983
|
+
method: 'POST',
|
|
984
|
+
headers: authorizedHeaders(this.config, this.impersonationOpts),
|
|
985
|
+
body: JSON.stringify(body),
|
|
986
|
+
});
|
|
987
|
+
return {
|
|
988
|
+
result: response.result,
|
|
989
|
+
checkResults: response['check-results'],
|
|
990
|
+
};
|
|
991
|
+
};
|
|
992
|
+
/**
|
|
993
|
+
* Like `transact`, but does not write to the database.
|
|
994
|
+
* Returns debugging information for permissions checks.
|
|
995
|
+
* Useful for inspecting the values returned by the permissions checks.
|
|
996
|
+
*
|
|
997
|
+
* Requires a user/guest context to be set with `asUser`,
|
|
998
|
+
* since permissions checks are user-specific.
|
|
999
|
+
*
|
|
1000
|
+
* Accepts an optional configuration object with a `rules` key.
|
|
1001
|
+
* The provided rules will override the rules in the database for the duration of the transaction.
|
|
1002
|
+
*
|
|
1003
|
+
* @example
|
|
1004
|
+
* const goalId = id();
|
|
1005
|
+
* db.asUser({ guest: true }).debugTransact(
|
|
1006
|
+
* [db.tx.goals[goalId].update({title: "Get fit"})],
|
|
1007
|
+
* { rules: { goals: { allow: { update: "auth.id != null" } } }
|
|
1008
|
+
* )
|
|
1009
|
+
*/
|
|
1010
|
+
debugTransact = (inputChunks, opts) => {
|
|
1011
|
+
const body = {
|
|
1012
|
+
steps: steps(inputChunks),
|
|
1013
|
+
'rules-override': opts?.rules,
|
|
1014
|
+
// @ts-expect-error because we're using a private API (for now)
|
|
1015
|
+
'dangerously-commit-tx': opts?.__dangerouslyCommit,
|
|
1016
|
+
};
|
|
1017
|
+
if (opts?.ip) {
|
|
1018
|
+
body['ip-override'] = opts.ip;
|
|
1019
|
+
}
|
|
1020
|
+
if (opts?.origin) {
|
|
1021
|
+
body['origin-override'] = opts.origin;
|
|
1022
|
+
}
|
|
1023
|
+
return this._fetch(`${this.config.apiURI}/admin/transact_perms_check?app_id=${this.config.appId}`, {
|
|
1024
|
+
method: 'POST',
|
|
1025
|
+
headers: authorizedHeaders(this.config, this.impersonationOpts),
|
|
1026
|
+
body: JSON.stringify(body),
|
|
1027
|
+
});
|
|
1028
|
+
};
|
|
1029
|
+
#setupSSEConnection() {
|
|
1030
|
+
if (this.#sseConnection) {
|
|
1031
|
+
this.#sseConnection.close();
|
|
1032
|
+
}
|
|
1033
|
+
const headers = {
|
|
1034
|
+
...authorizedHeaders(this.config, this.impersonationOpts),
|
|
1035
|
+
};
|
|
1036
|
+
const inference = !!this.config.schema;
|
|
1037
|
+
const ES = makeEventSourceWrapper({ headers, inference });
|
|
1038
|
+
const conn = new core_1.SSEConnection(ES, `${this.config.apiURI}/admin/sse?app_id=${this.config.appId}`, `${this.config.apiURI}/admin/sse/push?app_id=${this.config.appId}`);
|
|
1039
|
+
conn.onopen = this.#onopen;
|
|
1040
|
+
conn.onmessage = this.#onmessage;
|
|
1041
|
+
conn.onclose = this.#onclose;
|
|
1042
|
+
conn.onerror = this.#onerror;
|
|
1043
|
+
this.#sseConnection = conn;
|
|
1044
|
+
return conn;
|
|
1045
|
+
}
|
|
1046
|
+
#ensureSSEConnection() {
|
|
1047
|
+
return this.#sseConnection || this.#setupSSEConnection();
|
|
1048
|
+
}
|
|
1049
|
+
#trySend(eventId, msg) {
|
|
1050
|
+
const sseConnection = this.#ensureSSEConnection();
|
|
1051
|
+
this.#log.info('[send]', eventId, msg, {
|
|
1052
|
+
isOpen: sseConnection.isOpen(),
|
|
1053
|
+
});
|
|
1054
|
+
if (sseConnection.isOpen()) {
|
|
1055
|
+
sseConnection.send({ 'client-event-id': eventId, ...msg });
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
#setupBackendRelayStream() {
|
|
1059
|
+
this.#ensureSSEConnection();
|
|
1060
|
+
const backendrelayStream = new core_1.BackendRelayStream({
|
|
1061
|
+
WStream: this.config.WritableStream || WritableStream,
|
|
1062
|
+
RStream: this.config.ReadableStream || ReadableStream,
|
|
1063
|
+
trySend: (eventId, msg) => {
|
|
1064
|
+
this.#trySend(eventId, msg);
|
|
1065
|
+
},
|
|
1066
|
+
log: this.#log,
|
|
1067
|
+
});
|
|
1068
|
+
this.#backendrelayStream = backendrelayStream;
|
|
1069
|
+
return backendrelayStream;
|
|
1070
|
+
}
|
|
1071
|
+
#ensureBackendRelayStream() {
|
|
1072
|
+
return this.#backendrelayStream || this.#setupBackendRelayStream();
|
|
1073
|
+
}
|
|
1074
|
+
#onopen = (e) => {
|
|
1075
|
+
if (e.target !== this.#sseConnection) {
|
|
1076
|
+
this.#log.info('[socket][open]', e.target.id, 'skip; this is no longer the current transport');
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
this.#log.info('[socket][open]', e.target.id);
|
|
1080
|
+
this.#sseBackoff = 0;
|
|
1081
|
+
this.#backendrelayStream?.onConnectionStatusChange('authenticated');
|
|
1082
|
+
};
|
|
1083
|
+
#onclose = (e) => {
|
|
1084
|
+
if (e.target !== this.#sseConnection) {
|
|
1085
|
+
this.#log.info('[socket][close]', e.target.id, 'skip; this is no longer the current transport');
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
this.#log.info('[socket][close]', e.target.id);
|
|
1089
|
+
this.#backendrelayStream?.onConnectionStatusChange('closed');
|
|
1090
|
+
if (this.#sseConnection) {
|
|
1091
|
+
this.#sseConnection = null;
|
|
1092
|
+
if (!this.#connectionIsIdle()) {
|
|
1093
|
+
// We didn't remove the sse connection, and we have streams we care about, so let's try again
|
|
1094
|
+
setTimeout(() => this.#ensureSSEConnection(), this.#sseBackoff);
|
|
1095
|
+
this.#sseBackoff = Math.min(15000, Math.max(this.#sseBackoff, 500) * 2);
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
#onerror = (e) => {
|
|
1100
|
+
if (e.target !== this.#sseConnection) {
|
|
1101
|
+
this.#log.info('[socket][error]', e.target.id, 'skip; this is no longer the current transport');
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1104
|
+
this.#log.info('[socket][error]', e.target.id);
|
|
1105
|
+
this.#backendrelayStream?.onConnectionStatusChange('closed');
|
|
1106
|
+
};
|
|
1107
|
+
#connectionIsIdle() {
|
|
1108
|
+
return (!this.#backendrelayStream || !this.#backendrelayStream.hasActiveStreams());
|
|
1109
|
+
}
|
|
1110
|
+
#maybeShutdownConnection() {
|
|
1111
|
+
if (this.#sseConnection && this.#connectionIsIdle()) {
|
|
1112
|
+
const conn = this.#sseConnection;
|
|
1113
|
+
this.#log.info('cleaning up unused socket', conn.id);
|
|
1114
|
+
this.#sseConnection = null;
|
|
1115
|
+
conn.close();
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
#onmessage = (e) => {
|
|
1119
|
+
if (e.target !== this.#sseConnection) {
|
|
1120
|
+
this.#log.info('[socket][message]', e.target.id, 'skip; this is no longer the current transport');
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
const msg = e.message;
|
|
1124
|
+
this.#log.info('[receive]', msg);
|
|
1125
|
+
switch (msg.op) {
|
|
1126
|
+
case 'start-stream-ok': {
|
|
1127
|
+
this.#backendrelayStream?.onStartStreamOk(msg);
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1130
|
+
case 'stream-flushed': {
|
|
1131
|
+
this.#backendrelayStream?.onStreamFlushed(msg);
|
|
1132
|
+
break;
|
|
1133
|
+
}
|
|
1134
|
+
case 'append-failed': {
|
|
1135
|
+
this.#backendrelayStream?.onAppendFailed(msg);
|
|
1136
|
+
break;
|
|
1137
|
+
}
|
|
1138
|
+
case 'stream-append': {
|
|
1139
|
+
this.#backendrelayStream?.onStreamAppend(msg);
|
|
1140
|
+
break;
|
|
1141
|
+
}
|
|
1142
|
+
case 'error': {
|
|
1143
|
+
switch (msg['original-event']?.op) {
|
|
1144
|
+
case 'start-stream':
|
|
1145
|
+
case 'append-stream':
|
|
1146
|
+
case 'subscribe-stream':
|
|
1147
|
+
case 'unsubscribe-stream': {
|
|
1148
|
+
this.#backendrelayStream?.onRecieveError(msg);
|
|
1149
|
+
break;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
break;
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
// Closes the connection if we don't have any items pending
|
|
1156
|
+
this.#maybeShutdownConnection();
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
//# sourceMappingURL=index.js.map
|