@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,230 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { BackendRelaySchemaDef, InstaQLEntity } from '@backendrelay/core';
|
|
4
|
+
/** The signed-in user exposed to a function. */
|
|
5
|
+
export type FunctionUser = {
|
|
6
|
+
id: string;
|
|
7
|
+
email?: string | null;
|
|
8
|
+
};
|
|
9
|
+
export type FunctionLogEntry = {
|
|
10
|
+
function: string;
|
|
11
|
+
level: string;
|
|
12
|
+
message: string;
|
|
13
|
+
data?: unknown;
|
|
14
|
+
};
|
|
15
|
+
/** Typed run metadata passed to a job handler. */
|
|
16
|
+
export type JobMeta = {
|
|
17
|
+
jobId: string;
|
|
18
|
+
requestId?: string | null;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The narrow admin surface the runtime needs. A normal
|
|
22
|
+
* `BackendRelayAdminDatabase` is structurally compatible.
|
|
23
|
+
*/
|
|
24
|
+
export type FunctionsAdmin = {
|
|
25
|
+
auth: {
|
|
26
|
+
verifyToken(token: string): Promise<FunctionUser>;
|
|
27
|
+
};
|
|
28
|
+
query(query: unknown, opts?: unknown): Promise<any>;
|
|
29
|
+
versions(entityIds: string[]): Promise<Record<string, number>>;
|
|
30
|
+
transact(chunks: unknown, options?: {
|
|
31
|
+
conditions?: unknown;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
'tx-id': number;
|
|
34
|
+
}>;
|
|
35
|
+
asUser(actor: {
|
|
36
|
+
email: string;
|
|
37
|
+
} | {
|
|
38
|
+
token: string;
|
|
39
|
+
} | {
|
|
40
|
+
guest: boolean;
|
|
41
|
+
}): FunctionsAdmin;
|
|
42
|
+
log?(entries: FunctionLogEntry[], requestId?: string | null): Promise<void>;
|
|
43
|
+
aggregate?(params: {
|
|
44
|
+
etype: string;
|
|
45
|
+
filters?: Record<string, unknown>;
|
|
46
|
+
groupBy?: string;
|
|
47
|
+
field?: string;
|
|
48
|
+
sum?: boolean;
|
|
49
|
+
avg?: boolean;
|
|
50
|
+
min?: boolean;
|
|
51
|
+
max?: boolean;
|
|
52
|
+
}): Promise<{
|
|
53
|
+
rows: any[];
|
|
54
|
+
}>;
|
|
55
|
+
nearest?(params: {
|
|
56
|
+
etype: string;
|
|
57
|
+
attr: string;
|
|
58
|
+
vector: number[];
|
|
59
|
+
limit?: number;
|
|
60
|
+
}): Promise<{
|
|
61
|
+
rows: any[];
|
|
62
|
+
}>;
|
|
63
|
+
tx: any;
|
|
64
|
+
};
|
|
65
|
+
export type FunctionKind = 'query' | 'mutation';
|
|
66
|
+
export type FunctionDef<Args, Result> = {
|
|
67
|
+
kind: FunctionKind;
|
|
68
|
+
args: z.ZodType<Args, any, any>;
|
|
69
|
+
handler: (ctx: FunctionContext<any, any>, args: Args) => Promise<Result> | Result;
|
|
70
|
+
/** Public functions run as a guest when no bearer token is present. */
|
|
71
|
+
public?: boolean;
|
|
72
|
+
};
|
|
73
|
+
export type AnyFunctionDef = FunctionDef<any, any>;
|
|
74
|
+
export type FunctionDefinitions = Record<string, AnyFunctionDef>;
|
|
75
|
+
export type JobDefinition<Args, Result> = {
|
|
76
|
+
args: z.ZodType<Args, any, any>;
|
|
77
|
+
handler: (args: Args, meta: JobMeta) => Promise<Result> | Result;
|
|
78
|
+
/** Optional duplicate-protection key; defaults to the job record id. */
|
|
79
|
+
idempotencyKey?: (args: Args) => string;
|
|
80
|
+
};
|
|
81
|
+
export type AnyJobDefinition = JobDefinition<any, any>;
|
|
82
|
+
export type JobDefinitions = Record<string, AnyJobDefinition>;
|
|
83
|
+
type EntityName<S extends BackendRelaySchemaDef<any, any, any>> = keyof S['entities'] & string;
|
|
84
|
+
type EntityOf<S extends BackendRelaySchemaDef<any, any, any>, N extends EntityName<S>> = InstaQLEntity<S, N> & {
|
|
85
|
+
id: string;
|
|
86
|
+
};
|
|
87
|
+
/** Database helpers available inside a function. */
|
|
88
|
+
export type FunctionDb<S extends BackendRelaySchemaDef<any, any, any>> = {
|
|
89
|
+
get<N extends EntityName<S>>(etype: N, id: string): Promise<(EntityOf<S, N> & {
|
|
90
|
+
$version: number;
|
|
91
|
+
}) | null>;
|
|
92
|
+
query<Q = any>(query: Q): Promise<{
|
|
93
|
+
data: any;
|
|
94
|
+
versions: Record<string, number>;
|
|
95
|
+
}>;
|
|
96
|
+
insert<N extends EntityName<S>>(etype: N, data: Partial<EntityOf<S, N>>): string;
|
|
97
|
+
update<N extends EntityName<S>>(etype: N, id: string, data: Partial<EntityOf<S, N>>): void;
|
|
98
|
+
delete<N extends EntityName<S>>(etype: N, id: string): void;
|
|
99
|
+
link<N extends EntityName<S>>(etype: N, id: string, label: string, targetId: string): void;
|
|
100
|
+
increment<N extends EntityName<S>>(etype: N, id: string, attr: string, delta: number): void;
|
|
101
|
+
/** Admin-only aggregate over one entity type. */
|
|
102
|
+
aggregate<N extends EntityName<S>>(params: {
|
|
103
|
+
etype: N;
|
|
104
|
+
filters?: Record<string, unknown>;
|
|
105
|
+
groupBy?: string;
|
|
106
|
+
field?: string;
|
|
107
|
+
sum?: boolean;
|
|
108
|
+
avg?: boolean;
|
|
109
|
+
min?: boolean;
|
|
110
|
+
max?: boolean;
|
|
111
|
+
}): Promise<{
|
|
112
|
+
rows: any[];
|
|
113
|
+
}>;
|
|
114
|
+
/** Admin-only nearest vectors; requires pgvector on the database. */
|
|
115
|
+
nearest<N extends EntityName<S>>(params: {
|
|
116
|
+
etype: N;
|
|
117
|
+
attr: string;
|
|
118
|
+
vector: number[];
|
|
119
|
+
limit?: number;
|
|
120
|
+
}): Promise<{
|
|
121
|
+
rows: any[];
|
|
122
|
+
}>;
|
|
123
|
+
};
|
|
124
|
+
export type FunctionJobs<Jobs extends JobDefinitions = JobDefinitions> = {
|
|
125
|
+
enqueue<K extends keyof Jobs & string>(kind: K, args: z.infer<Jobs[K]['args']>): string;
|
|
126
|
+
};
|
|
127
|
+
export type FunctionContext<S extends BackendRelaySchemaDef<any, any, any> = BackendRelaySchemaDef<any, any, any>, Jobs extends JobDefinitions = JobDefinitions> = {
|
|
128
|
+
user: FunctionUser | null;
|
|
129
|
+
requestId: string | null;
|
|
130
|
+
db: FunctionDb<S>;
|
|
131
|
+
jobs: FunctionJobs<Jobs>;
|
|
132
|
+
/** Prefixed with the function name and request id. */
|
|
133
|
+
log: (...args: unknown[]) => void;
|
|
134
|
+
};
|
|
135
|
+
export type FunctionsOptions<S extends BackendRelaySchemaDef<any, any, any>, Jobs extends JobDefinitions> = {
|
|
136
|
+
admin: FunctionsAdmin;
|
|
137
|
+
/** Build a per-request admin client so the transaction gets `requestId`. */
|
|
138
|
+
adminFor?: (requestId: string | null) => FunctionsAdmin;
|
|
139
|
+
jobs?: Jobs;
|
|
140
|
+
/** Entity that stores outbox records. Defaults to `jobs`. */
|
|
141
|
+
jobsEntity?: string;
|
|
142
|
+
/** Retries after a stale version. Defaults to 3. */
|
|
143
|
+
retries?: number;
|
|
144
|
+
verifyToken?: (token: string) => Promise<FunctionUser>;
|
|
145
|
+
};
|
|
146
|
+
export declare function query<Args, Result>(def: Omit<FunctionDef<Args, Result>, 'kind'>): FunctionDef<Args, Result>;
|
|
147
|
+
export declare function mutation<Args, Result>(def: Omit<FunctionDef<Args, Result>, 'kind'>): FunctionDef<Args, Result>;
|
|
148
|
+
export declare function job<Args, Result>(def: JobDefinition<Args, Result>): JobDefinition<Args, Result>;
|
|
149
|
+
/**
|
|
150
|
+
* Creates schema-aware `query`/`mutation` helpers:
|
|
151
|
+
*
|
|
152
|
+
* ```ts
|
|
153
|
+
* const f = defineFunctions<typeof schema, typeof jobs>();
|
|
154
|
+
* export const addTodo = f.mutation({
|
|
155
|
+
* args: z.object({ title: z.string() }),
|
|
156
|
+
* handler: async (ctx, args) => {
|
|
157
|
+
* const project = await ctx.db.get('projects', args.projectId);
|
|
158
|
+
* ...
|
|
159
|
+
* },
|
|
160
|
+
* });
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export declare function defineFunctions<S extends BackendRelaySchemaDef<any, any, any>, Jobs extends JobDefinitions = {}>(): {
|
|
164
|
+
query<Args, Result>(def: Omit<FunctionDef<Args, Result>, "kind" | "handler"> & {
|
|
165
|
+
handler: (ctx: FunctionContext<S, Jobs>, args: Args) => Promise<Result> | Result;
|
|
166
|
+
}): FunctionDef<Args, Result>;
|
|
167
|
+
mutation<Args, Result>(def: Omit<FunctionDef<Args, Result>, "kind" | "handler"> & {
|
|
168
|
+
handler: (ctx: FunctionContext<S, Jobs>, args: Args) => Promise<Result> | Result;
|
|
169
|
+
}): FunctionDef<Args, Result>;
|
|
170
|
+
};
|
|
171
|
+
/** Throw this from a function to return a specific status. */
|
|
172
|
+
export declare class FunctionError extends Error {
|
|
173
|
+
readonly status: number;
|
|
174
|
+
constructor(message: string, status?: number);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Builds the Hono router for a set of function definitions. The client talks to
|
|
178
|
+
* `POST /:name`; `createFunctionsClient` uses the same shape.
|
|
179
|
+
*/
|
|
180
|
+
export declare function createFunctionsRouter<S extends BackendRelaySchemaDef<any, any, any> = BackendRelaySchemaDef<any, any, any>, Defs extends FunctionDefinitions = FunctionDefinitions, Jobs extends JobDefinitions = {}>(functions: Defs, options: FunctionsOptions<S, Jobs>): Hono;
|
|
181
|
+
export type FunctionArgs<D> = D extends FunctionDef<infer Args, any> ? Args : never;
|
|
182
|
+
export type FunctionResult<D> = D extends FunctionDef<any, infer Result> ? Result : never;
|
|
183
|
+
export type FunctionCallOptions = {
|
|
184
|
+
/**
|
|
185
|
+
* Builds a transaction applied locally before the call and rolled back when
|
|
186
|
+
* it returns or fails. Requires `createFunctionsClient({ db })`.
|
|
187
|
+
*/
|
|
188
|
+
optimistic?: (tx: any) => unknown;
|
|
189
|
+
};
|
|
190
|
+
export type FunctionsClient<Defs extends FunctionDefinitions> = {
|
|
191
|
+
[K in keyof Defs]: Defs[K] extends FunctionDef<infer Args, infer Result> ? (args: Args, options?: FunctionCallOptions) => Promise<Result> : never;
|
|
192
|
+
};
|
|
193
|
+
export type OptimisticDb = {
|
|
194
|
+
applyOptimistic(chunks: unknown): {
|
|
195
|
+
eventId: string;
|
|
196
|
+
rollback: () => void;
|
|
197
|
+
};
|
|
198
|
+
tx: any;
|
|
199
|
+
};
|
|
200
|
+
export type FunctionsClientOptions = {
|
|
201
|
+
/** Base URL of the mounted functions router, without a trailing slash. */
|
|
202
|
+
url: string;
|
|
203
|
+
/** Bearer token, or a function returning one per request. */
|
|
204
|
+
token?: string | (() => string | Promise<string>);
|
|
205
|
+
headers?: Record<string, string>;
|
|
206
|
+
requestId?: string | (() => string);
|
|
207
|
+
/** Enables `optimistic` callbacks through the core client. */
|
|
208
|
+
db?: OptimisticDb;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Typed client for `createFunctionsRouter`. Every call is a `POST /<name>`.
|
|
212
|
+
*
|
|
213
|
+
* ```ts
|
|
214
|
+
* const fn = createFunctionsClient<typeof functions>({
|
|
215
|
+
* url: 'http://localhost:3001/functions',
|
|
216
|
+
* token: () => sessionToken,
|
|
217
|
+
* });
|
|
218
|
+
* await fn.addTodo({ title: 'Ship it' });
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
export declare function createFunctionsClient<Defs extends FunctionDefinitions>(options: FunctionsClientOptions): FunctionsClient<Defs>;
|
|
222
|
+
/** Runs one typed job definition after validating its payload. */
|
|
223
|
+
export declare function runJob<Jobs extends JobDefinitions>(jobs: Jobs, kind: string, payload: unknown, meta: JobMeta): Promise<unknown>;
|
|
224
|
+
/**
|
|
225
|
+
* Turns job definitions into the dispatcher map used by the webhook handler:
|
|
226
|
+
* `{ [kind]: (payload, meta) => result }`.
|
|
227
|
+
*/
|
|
228
|
+
export declare function createJobHandlers<Jobs extends JobDefinitions>(jobs: Jobs): Record<string, (payload: unknown, meta: JobMeta) => Promise<unknown>>;
|
|
229
|
+
export {};
|
|
230
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE/E,gDAAgD;AAChD,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IA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AiB,CAAC,IAAI,SAAS,cAAc,EAC3D,IAAI,EAAE,IAAI,GACT,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAUvE"}
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FunctionError = void 0;
|
|
4
|
+
exports.query = query;
|
|
5
|
+
exports.mutation = mutation;
|
|
6
|
+
exports.job = job;
|
|
7
|
+
exports.defineFunctions = defineFunctions;
|
|
8
|
+
exports.createFunctionsRouter = createFunctionsRouter;
|
|
9
|
+
exports.createFunctionsClient = createFunctionsClient;
|
|
10
|
+
exports.runJob = runJob;
|
|
11
|
+
exports.createJobHandlers = createJobHandlers;
|
|
12
|
+
const hono_1 = require("hono");
|
|
13
|
+
const admin_1 = require("@backendrelay/admin");
|
|
14
|
+
function query(def) {
|
|
15
|
+
return { ...def, kind: 'query' };
|
|
16
|
+
}
|
|
17
|
+
function mutation(def) {
|
|
18
|
+
return { ...def, kind: 'mutation' };
|
|
19
|
+
}
|
|
20
|
+
function job(def) {
|
|
21
|
+
return def;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates schema-aware `query`/`mutation` helpers:
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* const f = defineFunctions<typeof schema, typeof jobs>();
|
|
28
|
+
* export const addTodo = f.mutation({
|
|
29
|
+
* args: z.object({ title: z.string() }),
|
|
30
|
+
* handler: async (ctx, args) => {
|
|
31
|
+
* const project = await ctx.db.get('projects', args.projectId);
|
|
32
|
+
* ...
|
|
33
|
+
* },
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
function defineFunctions() {
|
|
38
|
+
return {
|
|
39
|
+
query(def) {
|
|
40
|
+
return query(def);
|
|
41
|
+
},
|
|
42
|
+
mutation(def) {
|
|
43
|
+
return mutation(def);
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function newRunState() {
|
|
48
|
+
return {
|
|
49
|
+
chunks: [],
|
|
50
|
+
versions: new Map(),
|
|
51
|
+
increments: [],
|
|
52
|
+
overlay: new Map(),
|
|
53
|
+
deleted: new Set(),
|
|
54
|
+
logs: [],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function collectIds(value, out) {
|
|
58
|
+
if (Array.isArray(value)) {
|
|
59
|
+
for (const item of value)
|
|
60
|
+
collectIds(item, out);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (!value || typeof value !== 'object')
|
|
64
|
+
return;
|
|
65
|
+
const object = value;
|
|
66
|
+
if (typeof object.id === 'string')
|
|
67
|
+
out.add(object.id);
|
|
68
|
+
for (const item of Object.values(object))
|
|
69
|
+
collectIds(item, out);
|
|
70
|
+
}
|
|
71
|
+
function isPreconditionFailed(error) {
|
|
72
|
+
const body = error?.body;
|
|
73
|
+
return body?.hint?.type === 'precondition-failed';
|
|
74
|
+
}
|
|
75
|
+
/** Throw this from a function to return a specific status. */
|
|
76
|
+
class FunctionError extends Error {
|
|
77
|
+
status;
|
|
78
|
+
constructor(message, status = 400) {
|
|
79
|
+
super(message);
|
|
80
|
+
this.name = 'FunctionError';
|
|
81
|
+
this.status = status;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.FunctionError = FunctionError;
|
|
85
|
+
function errorResponse(error) {
|
|
86
|
+
const body = error?.body;
|
|
87
|
+
const status = typeof error?.status === 'number'
|
|
88
|
+
? error.status
|
|
89
|
+
: error instanceof FunctionError
|
|
90
|
+
? error.status
|
|
91
|
+
: 500;
|
|
92
|
+
return new Response(JSON.stringify(body ?? {
|
|
93
|
+
error: {
|
|
94
|
+
message: error instanceof Error ? error.message : 'Function failed',
|
|
95
|
+
},
|
|
96
|
+
}), { status, headers: { 'content-type': 'application/json' } });
|
|
97
|
+
}
|
|
98
|
+
function bearer(header) {
|
|
99
|
+
return header?.replace(/^Bearer\s+/i, '') || null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Builds the Hono router for a set of function definitions. The client talks to
|
|
103
|
+
* `POST /:name`; `createFunctionsClient` uses the same shape.
|
|
104
|
+
*/
|
|
105
|
+
function createFunctionsRouter(functions, options) {
|
|
106
|
+
const app = new hono_1.Hono();
|
|
107
|
+
const jobsEntity = options.jobsEntity ?? 'jobs';
|
|
108
|
+
const retries = options.retries ?? 3;
|
|
109
|
+
app.post('/:name', async (c) => {
|
|
110
|
+
const name = c.req.param('name');
|
|
111
|
+
const def = functions[name];
|
|
112
|
+
if (!def) {
|
|
113
|
+
return c.json({ error: { message: `Unknown function ${name}` } }, 404);
|
|
114
|
+
}
|
|
115
|
+
const requestId = c.req.header('x-request-id') ?? null;
|
|
116
|
+
const admin = options.adminFor
|
|
117
|
+
? options.adminFor(requestId)
|
|
118
|
+
: options.admin;
|
|
119
|
+
const token = bearer(c.req.header('authorization'));
|
|
120
|
+
let user = null;
|
|
121
|
+
if (token) {
|
|
122
|
+
try {
|
|
123
|
+
const verify = options.verifyToken ??
|
|
124
|
+
((value) => admin.auth.verifyToken(value));
|
|
125
|
+
user = await verify(token);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return c.json({ error: { message: 'Invalid bearer token' } }, 401);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else if (!def.public) {
|
|
132
|
+
return c.json({ error: { message: 'Missing bearer token' } }, 401);
|
|
133
|
+
}
|
|
134
|
+
const actor = user
|
|
135
|
+
? user.email
|
|
136
|
+
? admin.asUser({ email: user.email })
|
|
137
|
+
: token
|
|
138
|
+
? admin.asUser({ token })
|
|
139
|
+
: admin.asUser({ guest: true })
|
|
140
|
+
: admin.asUser({ guest: true });
|
|
141
|
+
const parsedBody = await c.req.json().catch(() => ({}));
|
|
142
|
+
const parsed = def.args.safeParse(parsedBody ?? {});
|
|
143
|
+
if (!parsed.success) {
|
|
144
|
+
return c.json({
|
|
145
|
+
error: {
|
|
146
|
+
type: 'validation-failed',
|
|
147
|
+
message: 'Invalid function arguments',
|
|
148
|
+
issues: parsed.error.issues,
|
|
149
|
+
},
|
|
150
|
+
}, 400);
|
|
151
|
+
}
|
|
152
|
+
const handler = async (state) => {
|
|
153
|
+
const db = createDb({ actor, state });
|
|
154
|
+
const jobs = createJobs({
|
|
155
|
+
actor,
|
|
156
|
+
state,
|
|
157
|
+
user,
|
|
158
|
+
jobs: options.jobs,
|
|
159
|
+
jobsEntity,
|
|
160
|
+
});
|
|
161
|
+
const ctx = {
|
|
162
|
+
user,
|
|
163
|
+
requestId,
|
|
164
|
+
db,
|
|
165
|
+
jobs,
|
|
166
|
+
log: (...args) => {
|
|
167
|
+
state.logs.push({
|
|
168
|
+
function: name,
|
|
169
|
+
level: 'info',
|
|
170
|
+
message: args.map(formatLogArg).join(' '),
|
|
171
|
+
data: args.length > 0 ? args : undefined,
|
|
172
|
+
});
|
|
173
|
+
console.log(`[fn ${name} ${requestId ?? '-'}]`, ...args);
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
return def.handler(ctx, parsed.data);
|
|
177
|
+
};
|
|
178
|
+
if (def.kind === 'query') {
|
|
179
|
+
const state = newRunState();
|
|
180
|
+
try {
|
|
181
|
+
const result = await handler(state);
|
|
182
|
+
await flushLogs(actor, state, requestId);
|
|
183
|
+
return c.json(result);
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
await flushLogs(actor, state, requestId);
|
|
187
|
+
return errorResponse(error);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
let lastError;
|
|
191
|
+
for (let attempt = 0; attempt <= retries; attempt += 1) {
|
|
192
|
+
const state = newRunState();
|
|
193
|
+
try {
|
|
194
|
+
const result = await handler(state);
|
|
195
|
+
if (state.chunks.length > 0 || state.increments.length > 0) {
|
|
196
|
+
await actor.transact(state.chunks, {
|
|
197
|
+
conditions: {
|
|
198
|
+
assert: [...state.versions.entries()].map(([id, version]) => [
|
|
199
|
+
'version',
|
|
200
|
+
id,
|
|
201
|
+
version,
|
|
202
|
+
]),
|
|
203
|
+
increment: state.increments,
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
await flushLogs(actor, state, requestId);
|
|
208
|
+
return c.json(result);
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
lastError = error;
|
|
212
|
+
if (!isPreconditionFailed(error) || attempt === retries) {
|
|
213
|
+
await flushLogs(actor, state, requestId);
|
|
214
|
+
return errorResponse(error);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return errorResponse(lastError);
|
|
219
|
+
});
|
|
220
|
+
app.get('/health', (c) => c.json({ ok: true }));
|
|
221
|
+
return app;
|
|
222
|
+
}
|
|
223
|
+
function formatLogArg(value) {
|
|
224
|
+
if (typeof value === 'string')
|
|
225
|
+
return value;
|
|
226
|
+
try {
|
|
227
|
+
return JSON.stringify(value);
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
return String(value);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
async function flushLogs(actor, state, requestId) {
|
|
234
|
+
if (state.logs.length === 0 || !actor.log)
|
|
235
|
+
return;
|
|
236
|
+
try {
|
|
237
|
+
await actor.log(state.logs, requestId);
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
// Logging must never turn a successful function into a failure.
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function createDb(options) {
|
|
244
|
+
const { actor, state } = options;
|
|
245
|
+
return {
|
|
246
|
+
async get(etype, id) {
|
|
247
|
+
const key = `${etype}:${id}`;
|
|
248
|
+
if (state.deleted.has(key))
|
|
249
|
+
return null;
|
|
250
|
+
const pending = state.overlay.get(key);
|
|
251
|
+
if (pending) {
|
|
252
|
+
const versions = await actor.versions([id]);
|
|
253
|
+
state.versions.set(id, versions[id] ?? 0);
|
|
254
|
+
return { ...pending, id, $version: versions[id] ?? 0 };
|
|
255
|
+
}
|
|
256
|
+
const result = await actor.query({
|
|
257
|
+
[etype]: { $: { where: { id } } },
|
|
258
|
+
});
|
|
259
|
+
const rows = result?.[etype];
|
|
260
|
+
const row = Array.isArray(rows) ? rows[0] : null;
|
|
261
|
+
const versions = await actor.versions([id]);
|
|
262
|
+
state.versions.set(id, versions[id] ?? 0);
|
|
263
|
+
return row ? { ...row, $version: versions[id] ?? 0 } : null;
|
|
264
|
+
},
|
|
265
|
+
async query(queryValue) {
|
|
266
|
+
const data = await actor.query(queryValue);
|
|
267
|
+
const ids = new Set();
|
|
268
|
+
collectIds(data, ids);
|
|
269
|
+
const versions = ids.size > 0 ? await actor.versions([...ids]) : {};
|
|
270
|
+
for (const id of ids) {
|
|
271
|
+
state.versions.set(id, versions[id] ?? 0);
|
|
272
|
+
}
|
|
273
|
+
return { data, versions };
|
|
274
|
+
},
|
|
275
|
+
insert(etype, data) {
|
|
276
|
+
const id = crypto.randomUUID();
|
|
277
|
+
state.overlay.set(`${etype}:${id}`, { ...data, id });
|
|
278
|
+
state.chunks.push(actor.tx[etype][id].update(data));
|
|
279
|
+
return id;
|
|
280
|
+
},
|
|
281
|
+
update(etype, id, data) {
|
|
282
|
+
const key = `${etype}:${id}`;
|
|
283
|
+
state.overlay.set(key, {
|
|
284
|
+
...(state.overlay.get(key) ?? {}),
|
|
285
|
+
...data,
|
|
286
|
+
id,
|
|
287
|
+
});
|
|
288
|
+
state.chunks.push(actor.tx[etype][id].update(data));
|
|
289
|
+
},
|
|
290
|
+
delete(etype, id) {
|
|
291
|
+
state.deleted.add(`${etype}:${id}`);
|
|
292
|
+
state.chunks.push(actor.tx[etype][id].delete());
|
|
293
|
+
},
|
|
294
|
+
link(etype, id, label, targetId) {
|
|
295
|
+
state.chunks.push(actor.tx[etype][id].link({ [label]: targetId }));
|
|
296
|
+
},
|
|
297
|
+
increment(etype, id, attr, delta) {
|
|
298
|
+
state.increments.push([etype, id, attr, delta]);
|
|
299
|
+
},
|
|
300
|
+
async aggregate(params) {
|
|
301
|
+
if (!actor.aggregate)
|
|
302
|
+
throw new Error('Aggregates are not supported');
|
|
303
|
+
return actor.aggregate(params);
|
|
304
|
+
},
|
|
305
|
+
async nearest(params) {
|
|
306
|
+
if (!actor.nearest)
|
|
307
|
+
throw new Error('Vector search is not supported');
|
|
308
|
+
return actor.nearest(params);
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
function createJobs(options) {
|
|
313
|
+
const { actor, state, user, jobs, jobsEntity } = options;
|
|
314
|
+
return {
|
|
315
|
+
enqueue(kind, args) {
|
|
316
|
+
if (!jobs || !(kind in jobs)) {
|
|
317
|
+
throw new Error(`Unknown job ${kind}`);
|
|
318
|
+
}
|
|
319
|
+
if (!user) {
|
|
320
|
+
throw new Error('Jobs can only be enqueued by a signed-in user');
|
|
321
|
+
}
|
|
322
|
+
const jobId = crypto.randomUUID();
|
|
323
|
+
state.chunks.push(actor.tx[jobsEntity][jobId].update({
|
|
324
|
+
kind,
|
|
325
|
+
payload: args,
|
|
326
|
+
status: 'queued',
|
|
327
|
+
ownerId: user.id,
|
|
328
|
+
}));
|
|
329
|
+
return jobId;
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Typed client for `createFunctionsRouter`. Every call is a `POST /<name>`.
|
|
335
|
+
*
|
|
336
|
+
* ```ts
|
|
337
|
+
* const fn = createFunctionsClient<typeof functions>({
|
|
338
|
+
* url: 'http://localhost:3001/functions',
|
|
339
|
+
* token: () => sessionToken,
|
|
340
|
+
* });
|
|
341
|
+
* await fn.addTodo({ title: 'Ship it' });
|
|
342
|
+
* ```
|
|
343
|
+
*/
|
|
344
|
+
function createFunctionsClient(options) {
|
|
345
|
+
const client = {};
|
|
346
|
+
return new Proxy(client, {
|
|
347
|
+
get(_target, property) {
|
|
348
|
+
if (typeof property !== 'string')
|
|
349
|
+
return undefined;
|
|
350
|
+
if (property === 'then' || property === 'toJSON')
|
|
351
|
+
return undefined;
|
|
352
|
+
return async (args, callOptions) => {
|
|
353
|
+
const optimisticDb = options.db;
|
|
354
|
+
let optimistic;
|
|
355
|
+
if (callOptions?.optimistic && optimisticDb) {
|
|
356
|
+
optimistic = optimisticDb.applyOptimistic(callOptions.optimistic(optimisticDb.tx));
|
|
357
|
+
}
|
|
358
|
+
try {
|
|
359
|
+
const token = typeof options.token === 'function'
|
|
360
|
+
? await options.token()
|
|
361
|
+
: options.token;
|
|
362
|
+
const requestId = typeof options.requestId === 'function'
|
|
363
|
+
? options.requestId()
|
|
364
|
+
: options.requestId;
|
|
365
|
+
const response = await fetch(`${options.url.replace(/\/$/, '')}/${property}`, {
|
|
366
|
+
method: 'POST',
|
|
367
|
+
headers: {
|
|
368
|
+
'content-type': 'application/json',
|
|
369
|
+
...(token ? { authorization: `Bearer ${token}` } : {}),
|
|
370
|
+
...(requestId ? { 'x-request-id': requestId } : {}),
|
|
371
|
+
...options.headers,
|
|
372
|
+
},
|
|
373
|
+
body: JSON.stringify(args ?? {}),
|
|
374
|
+
});
|
|
375
|
+
const body = await response.json().catch(() => ({}));
|
|
376
|
+
if (!response.ok) {
|
|
377
|
+
throw new admin_1.BackendRelayAPIError({
|
|
378
|
+
status: response.status,
|
|
379
|
+
body,
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
return body;
|
|
383
|
+
}
|
|
384
|
+
finally {
|
|
385
|
+
optimistic?.rollback();
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
},
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
/* -------------------------------------------------------------------------- */
|
|
392
|
+
/* Jobs */
|
|
393
|
+
/* -------------------------------------------------------------------------- */
|
|
394
|
+
/** Runs one typed job definition after validating its payload. */
|
|
395
|
+
async function runJob(jobs, kind, payload, meta) {
|
|
396
|
+
const def = jobs[kind];
|
|
397
|
+
if (!def)
|
|
398
|
+
throw new Error(`Unknown job ${kind}`);
|
|
399
|
+
const args = def.args.parse(payload);
|
|
400
|
+
return def.handler(args, meta);
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Turns job definitions into the dispatcher map used by the webhook handler:
|
|
404
|
+
* `{ [kind]: (payload, meta) => result }`.
|
|
405
|
+
*/
|
|
406
|
+
function createJobHandlers(jobs) {
|
|
407
|
+
return Object.fromEntries(Object.entries(jobs).map(([kind, def]) => [
|
|
408
|
+
kind,
|
|
409
|
+
async (payload, meta) => {
|
|
410
|
+
const args = def.args.parse(payload);
|
|
411
|
+
return def.handler(args, meta);
|
|
412
|
+
},
|
|
413
|
+
]));
|
|
414
|
+
}
|
|
415
|
+
//# sourceMappingURL=index.js.map
|