Skip to content

Commit

Permalink
Remove node-fetch dependency from SDK, introduce @realm/fetch and…
Browse files Browse the repository at this point in the history
… allow passing `fetch` through `AppConfiguration` (#6401)

* Removed node-fetch and abort-controller from dependencies

* Hoisted dependencies on typescript and @types/node

* Started implementing a truely isometric fetch package

* Removed the path alias for types

* WIP

* Fixed Headers types

* Adding AbortSignal

* Removing types project as reference in root tsconfig.json

* assserting AbortSignal types and patching timeout static

* Adding AbortController

* Exporting Headers and returning Response

* ReadableStream WIP

* WIP

* Deleted @realm/network-transport

* Adding textStreaming config to React Native fetch requests.

* Adding engines and type param to @realm/fetch

* Removing network-transport from mono repo

* Using @realm/fetch from "realm"

* Using @realm/fetch from "app-importer"

* Using @realm/fetch from "realm-web"

* WIP

* Ensure @realm/fetch is in the bundle of realm-web

* Ensure @realm/fetch is in the bundle of realm

* Use a utility to wrap response.body in an async iterator

* Adding a version to @realm/fetch

* Adding engines to realm-web package.json

* Fixing react-native fetch implementation

* Adding comments to explain the weird emits

* Adding a "type-check" script to app-importer

* Adding a top-level "react-native" in @realm/fetch's package.json

* Prodiving a CJS + ESM node bundle

* Renamed fetch script to "build" (since it doesn't bundle)

* Bind fetch on node too (as this is loaded on Realm

* Debugging url and init separately

* Simplified types for ReactNative request init

* Implemented RN polyfill for AbortSignal.timeout

* Fixed setting statusText instead of status

* Using AbortSignal.timeout only if timeout is positive

* Adding an AnyFetch type

* Enable passing "fetch" through app configuration

* Passing baseUrl in the node-fetch test

* Providing a fallback for Symbol.asyncIterator if transpiled using Babel

* Apply suggestions from code review

Co-authored-by: LJ <[email protected]>
Co-authored-by: Andrew Meyer <[email protected]>

* Inlining configuration.storage

* Making cancel() return Promise<void>

* Adding ArrayBuffer | TypedArray to RequestBody

* Bumping lib of realm-web to es2022

---------

Co-authored-by: LJ <[email protected]>
Co-authored-by: Andrew Meyer <[email protected]>
  • Loading branch information
3 people authored Jan 25, 2024
1 parent 7908557 commit e7e8d9f
Show file tree
Hide file tree
Showing 94 changed files with 1,127 additions and 1,772 deletions.
1 change: 0 additions & 1 deletion .github/workflows/package-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
matrix:
workspace:
- realm
- '@realm/network-transport'
- '@realm/babel-plugin'
- '@realm/react'
include:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/pr-realm-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
# Only run when the PR makes changes to the packages
- "packages/realm-web/**"
- "packages/realm-web-integration-tests/**"
- "packages/realm-network-transport/**"
- "packages/realm-common/**"
- "packages/realm-app-importer/**"
# Changing types might also affect Realm Web
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/prepare-package-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ on:
options:
- '@realm/babel-plugin'
- '@realm/common'
- '@realm/network-transport'
- '@realm/react'
- '@realm/tools'
- '@realm/web'
Expand All @@ -41,11 +40,6 @@ jobs:
"PACKAGE_NAME": "@realm/common",
"VERSION_PREFIX": "realm-common-"
},
"@realm/network-transport": {
"PACKAGE_PATH": "packages/realm-network-transport",
"PACKAGE_NAME": "@realm/network-transport",
"VERSION_PREFIX": "realm-network-transport-"
},
"@realm/react": {
"PACKAGE_PATH": "packages/realm-react",
"PACKAGE_NAME": "@realm/react",
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/publish-package-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ on:
options:
- '@realm/babel-plugin'
- '@realm/common'
- '@realm/network-transport'
- '@realm/react'
- '@realm/tools'
- '@realm/web'
Expand Down Expand Up @@ -50,13 +49,6 @@ jobs:
"RELEASE_TITLE": "Realm Common",
"SDK_NAME": "Common"
},
"@realm/network-transport": {
"PACKAGE_PATH": "packages/realm-network-transport",
"PACKAGE_NAME": "@realm/network-transport",
"VERSION_PREFIX": "realm-network-transport-",
"RELEASE_TITLE": "Realm Network Transport",
"SDK_NAME": "Network Transport"
},
"@realm/react": {
"PACKAGE_PATH": "packages/realm-react",
"PACKAGE_NAME": "@realm/react",
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* None

### Enhancements
* None
* Added an optional `fetch` parameter to the `AppConfiguration`. Use this to specify a custom implementation of the `fetch` function used by the app to perform network requests.

### Fixed
* <How to hit and notice issue? what was the impact?> ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?)
Expand Down
6 changes: 2 additions & 4 deletions integration-tests/environments/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@
"dependencies": [
"../../../packages/realm:bundle",
"../../../packages/realm:build:node",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
"../../../packages/mocha-reporter:bundle"
]
},
"test:renderer": {
"command": "mocha-remote --reporter @realm/mocha-reporter --id renderer tsx runner.ts renderer",
"dependencies": [
"../../../packages/realm:bundle",
"../../../packages/realm:build:node",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
"../../../packages/mocha-reporter:bundle"
]
}
},
Expand Down
6 changes: 2 additions & 4 deletions integration-tests/environments/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@
"dependencies": [
"../../../packages/realm:bundle",
"../../../packages/realm:build:node",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
"../../../packages/mocha-reporter:bundle"
]
},
"test:commonjs": {
"command": "mocha-remote --reporter @realm/mocha-reporter tsx index.cjs",
"dependencies": [
"../../../packages/realm:bundle",
"../../../packages/realm:build:node",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
"../../../packages/mocha-reporter:bundle"
]
}
},
Expand Down
18 changes: 6 additions & 12 deletions integration-tests/environments/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@
"dependencies": [
"../../../packages/realm:build:android",
"../../../packages/realm:bundle",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
"../../../packages/mocha-reporter:bundle"
],
"env": {
"PLATFORM": "android",
Expand All @@ -118,8 +117,7 @@
"dependencies": [
"pod-install:simulator",
"../../../packages/realm:bundle",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
"../../../packages/mocha-reporter:bundle"
],
"env": {
"PLATFORM": "ios",
Expand All @@ -131,8 +129,7 @@
"dependencies": [
"pod-install:catalyst",
"../../../packages/realm:bundle",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
"../../../packages/mocha-reporter:bundle"
],
"env": {
"PLATFORM": "catalyst",
Expand All @@ -159,8 +156,7 @@
"dependencies": [
"../../../packages/realm:build:android",
"../../../packages/realm:bundle",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
"../../../packages/mocha-reporter:bundle"
],
"env": {
"PLATFORM": "android",
Expand All @@ -173,8 +169,7 @@
"pod-install:simulator",
"../../../packages/realm:build:ios:debug:simulator",
"../../../packages/realm:bundle",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
"../../../packages/mocha-reporter:bundle"
],
"env": {
"PLATFORM": "ios",
Expand All @@ -187,8 +182,7 @@
"pod-install:catalyst",
"../../../packages/realm:build:ios:debug:catalyst",
"../../../packages/realm:bundle",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
"../../../packages/mocha-reporter:bundle"
],
"env": {
"PLATFORM": "catalyst",
Expand Down
196 changes: 96 additions & 100 deletions integration-tests/tests/package.json
Original file line number Diff line number Diff line change
@@ -1,101 +1,97 @@
{
"name": "@realm/integration-tests",
"version": "0.1.0",
"description": "A set of tests that can run in different environments",
"main": "src/index.ts",
"exports": {
".": "./src/index.ts",
"./node": "./src/node/index.ts"
},
"private": true,
"scripts": {
"build": "wireit",
"start": "wireit",
"test": "wireit",
"lint": "wireit",
"coverage": "wireit",
"ci:coverage": "wireit"
},
"wireit": {
"lint": {
"command": "eslint --ext .js,.ts . && tsc --noEmit",
"dependencies": [
"../../packages/realm-network-transport:bundle",
"../../packages/realm:bundle"
]
},
"build": {
"command": "tsc",
"dependencies": [
"../../packages/realm:bundle",
"build-dependencies"
]
},
"start": {
"command": "mocha --watch",
"dependencies": [
"../../packages/realm:bundle",
"build-dependencies"
]
},
"test": {
"command": "mocha --exit",
"dependencies": [
"../../packages/realm:bundle",
"build-dependencies"
]
},
"coverage": {
"command": "nyc mocha --exit",
"dependencies": [
"../../packages/realm:bundle:coverage",
"build-dependencies"
]
},
"ci:coverage": {
"command": "nyc --reporter=lcov -- mocha --exit",
"dependencies": [
"../../packages/realm:bundle:coverage",
"build-dependencies"
]
},
"build-dependencies": {
"dependencies": [
"../../packages/realm:build:node",
"../../packages/mocha-reporter:bundle",
"../../packages/realm-network-transport:bundle"
]
}
},
"peerDependencies": {
"realm": "*"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@realm/app-importer": "*",
"@realm/mocha-reporter": "*",
"@thi.ng/bench": "^3.1.16",
"@types/chai": "^4.3.3",
"@types/chai-as-promised": "^7.1.5",
"@types/jsrsasign": "^10.5.4",
"@types/mocha": "^10.0.0",
"@types/node": "^18.15.10",
"concurrently": "^6.5.1",
"mocha": "^10.1.0",
"node-fetch": "^2.6.9",
"nyc": "^15.1.0",
"platform": "^1.3.6",
"realm": "*"
},
"dependencies": {
"@realm/network-transport": "^0.7.2",
"@thi.ng/bench": "^3.1.16",
"chai": "4.3.6",
"chai-as-promised": "^7.1.1",
"concurrently": "^6.0.2",
"jsrsasign": "^11.0.0"
},
"files": [
"/src"
]
}
"name": "@realm/integration-tests",
"version": "0.1.0",
"description": "A set of tests that can run in different environments",
"main": "src/index.ts",
"exports": {
".": "./src/index.ts",
"./node": "./src/node/index.ts"
},
"private": true,
"scripts": {
"build": "wireit",
"start": "wireit",
"test": "wireit",
"lint": "wireit",
"coverage": "wireit",
"ci:coverage": "wireit"
},
"wireit": {
"lint": {
"command": "eslint --ext .js,.ts . && tsc --noEmit",
"dependencies": [
"../../packages/realm:bundle"
]
},
"build": {
"command": "tsc",
"dependencies": [
"../../packages/realm:bundle",
"build-dependencies"
]
},
"start": {
"command": "mocha --watch",
"dependencies": [
"../../packages/realm:bundle",
"build-dependencies"
]
},
"test": {
"command": "mocha --exit",
"dependencies": [
"../../packages/realm:bundle",
"build-dependencies"
]
},
"coverage": {
"command": "nyc mocha --exit",
"dependencies": [
"../../packages/realm:bundle:coverage",
"build-dependencies"
]
},
"ci:coverage": {
"command": "nyc --reporter=lcov -- mocha --exit",
"dependencies": [
"../../packages/realm:bundle:coverage",
"build-dependencies"
]
},
"build-dependencies": {
"dependencies": [
"../../packages/realm:build:node",
"../../packages/mocha-reporter:bundle"
]
}
},
"peerDependencies": {
"realm": "*"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@realm/app-importer": "*",
"@realm/mocha-reporter": "*",
"@thi.ng/bench": "^3.1.16",
"@types/chai": "^4.3.3",
"@types/chai-as-promised": "^7.1.5",
"@types/jsrsasign": "^10.5.4",
"@types/mocha": "^10.0.0",
"concurrently": "^6.5.1",
"mocha": "^10.1.0",
"nyc": "^15.1.0",
"platform": "^1.3.6",
"realm": "*"
},
"dependencies": {
"@thi.ng/bench": "^3.1.16",
"chai": "4.3.6",
"chai-as-promised": "^7.1.1",
"concurrently": "^6.0.2",
"jsrsasign": "^11.0.0",
"node-fetch": "^3.3.2"
},
"files": [
"/src"
]
}
1 change: 1 addition & 0 deletions integration-tests/tests/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ import "./path";
import "./sync-proxy";
import "./custom-inspect";
import "./ssl";
import "./node-fetch";
Loading

0 comments on commit e7e8d9f

Please sign in to comment.