Skip to content

Commit

Permalink
Merge branch 'main' into fp/geospatial
Browse files Browse the repository at this point in the history
* main:
  Update main to core v13.13.0 (#5873)
  Only export a CJS bundle (using rollup) (#5882)
  Overhaul SDK metrics (#5830)

# Conflicts:
#	packages/realm/bindgen/vendor/realm-core
  • Loading branch information
papafe committed Jun 14, 2023
2 parents a1bfbce + 534602a commit 1564c2c
Show file tree
Hide file tree
Showing 48 changed files with 560 additions and 372 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## vNext (TBD)

### Breaking changes
* Now exporting only as CommonJS, to align with the way we exported from v11 in an attempt to keep breakage across the major version to an absolute minimum. This is a breaking change compared to the previous pre-releases of v12, since users have to update code which is doing named import of `Realm` to use default or `* as Realm` imports of the `Realm` constructor. ([#5882](https://github.com/realm/realm-js/pull/5882))
* `SyncSession` JS objects no longer keep their associated C++ objects, and therefore the sync network connection, alive. This was causing issues because JS garbage collection is lazy so the `SyncSession` may survive much longer than the last reference held to it. We now use the same technique as v11 to avoid keeping the C++ object alive (`std::weak_ptr`). ([#5815](https://github.com/realm/realm-js/pull/5815), since v12.0.0-alpha.0)
* Breaking change: On v11, if the C++ object had been destroyed already, we would often return `undefined` or some other default value when calling methods or accessing properties on the JS `SyncSession` object, even if that would violate our declared TS types. Now, in v12, we will throw from all methods and property accessors in this case.

Expand Down Expand Up @@ -131,6 +132,7 @@ result = pois.filtered("location geoWithin geoCircle([13.397255909303222, 52.511
* Upgraded React Native from 0.71.4 to 0.71.7. ([#5761](https://github.com/realm/realm-js/pull/5761))
* Upgraded Realm Core from v13.10.1 to v13.11.0. ([#5811](https://github.com/realm/realm-js/issues/5811))
* Bump sync protocol to v9 to indicate client has fix for client reset error during async open. ([realm/realm-core#6609](https://github.com/realm/realm-core/issues/6609))
* Aligning analytics with other Realm SDKs. You can still disable the submission by setting environment variable `REALM_DISABLE_ANALYTICS`, and you can print out what is submitted by setting the environment variable `REALM_PRINT_ANALYTICS`.
* Disabling sync session multiplexing by default in the SDK, since Core's default changed to enabled with v13.11.0. ([#5831](https://github.com/realm/realm-js/pull/5831))
* Upgraded Realm Core from v13.11.1 to v13.13.0. ([#5873](https://github.com/realm/realm-js/pull/5873))

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/hooks/import-app-before.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//
////////////////////////////////////////////////////////////////////////////

import { Realm, AppConfiguration } from "realm";
import Realm, { AppConfiguration } from "realm";

import { importApp } from "../utils/import-app";
import { AppConfig } from "@realm/app-importer";
Expand Down
61 changes: 45 additions & 16 deletions integration-tests/tests/src/node/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,66 @@
import * as os from "os";
import * as process from "process";
import * as path from "path";
import { fileURLToPath } from "url";

import { expect } from "chai";
import { collectPlatformData } from "realm/scripts/submit-analytics";
import { readFileSync } from "node:fs";

type Fixture = "node" | "react-native" | "electron";
import fse from "fs-extra";

// emulate old __dirname: https://flaviocopes.com/fix-dirname-not-defined-es-module-scope/
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

type Fixture = "node" | "react-native" | "electron" | "ts-node";

// TODO: Update this to use ESM friendly APIs
describe.skip("Analytics", () => {
describe("Analytics", () => {
function resolvePath(fixture: Fixture) {
return path.resolve(__dirname, "fixtures", fixture);
}

function getRealmVersion() {
const realmPath = path.resolve(__dirname, "../../../../package.json");
const realmPackageContent = readFileSync(realmPath, { encoding: "utf8" });
const realmPackageJson = JSON.parse(realmPackageContent);
return realmPackageJson["version"];
const packageJsonPath = path.resolve(__dirname, "../../../../packages/realm/package.json");
const packageJson = fse.readJsonSync(packageJsonPath);
return packageJson["version"];
}

function expectCommon(data: Record<string, unknown>) {
expect(data["JS Analytics Version"]).equals(2);
expect(data.Binding).equals("javascript");
expect(data.Language).equals("javascript");
expect(data["JS Analytics Version"]).equals(3);
expect(data.Binding).equals("Javascript");
expect(data["Host OS Type"]).equals(os.platform());
expect(data["Host OS Version"]).equals(os.release());
expect(data["Node.js version"]).equals(process.version);
expect(data["Node.js version"]).equals(process.version.slice(1)); // remove 'v'
expect(data["Realm Version"]).equals(getRealmVersion());
expect(data.token).equals("ce0fac19508f6c8f20066d345d360fd0");
expect(data["Anonymized Builder Id"]).is.not.undefined;
expect(data["Core Version"]).is.not.undefined;
expect((data["Core Version"] as string).match(/[0-9]+\.[0-9]+\.[0-9]+/)?.length).equal(1); // expect X.Y.Z
expect(data["Installation Method"]).equals("npm"); // we run our tests with NPM
}

it("parses node.js package.json", async () => {
const data = await collectPlatformData(resolvePath("node"));
expectCommon(data);
expect(data.Version).equals("1.2.3");
expect(data.Framework).equals("node.js");
expect(data["Framework Version"]).equals(process.version);
expect(data["JavaScript Engine"]).equals("v8");
expect(data["Framework Version"]).equals(process.version.slice(1)); // remove 'v'
expect(data["Runtime Engine"]).equals("v8");
expect(data["Anonymized Bundle Id"]).equals("TfvqclDWR/+6sIPfZc73MetEj0DLskCtWXjWXXXIg6k=");
expect(data.Language).equals("javascript");
expect(data["Language Version"]).equals("unknown");
});

it("parses typescript/node package.json", async () => {
const data = await collectPlatformData(resolvePath("ts-node"));
expectCommon(data);
expect(data.Version).equals("1.2.3");
expect(data.Framework).equals("node.js");
expect(data["Framework Version"]).equals(process.version.slice(1)); // remove 'v'
expect(data["Runtime Engine"]).equals("v8");
expect(data["Anonymized Bundle Id"]).equals("ajQjGK7Tztb3WeVhmPitQFDRV24loZVttnXWSlXUjEc=");
expect(data.Language).equals("typescript");
expect(data["Language Version"]).equals("3.2.1");
});

it("parses electron package.json", async () => {
Expand All @@ -64,7 +87,10 @@ describe.skip("Analytics", () => {
expect(data.Version).equals("1.2.3");
expect(data.Framework).equals("electron");
expect(data["Framework Version"]).equals("1.0.1");
expect(data["JavaScript Engine"]).equals("v8");
expect(data["Runtime Engine"]).equals("v8");
expect(data["Anonymized Bundle Id"]).equals("B4vmI2GL8s/WLRIvDt7ffHn1TeiJxNRzUPsgRfqhNOU=");
expect(data.Language).equals("javascript");
expect(data["Language Version"]).equals("unknown");
});

it("parses rn package.json", async () => {
Expand All @@ -73,6 +99,9 @@ describe.skip("Analytics", () => {
expect(data.Version).equals("1.2.3");
expect(data.Framework).equals("react-native");
expect(data["Framework Version"]).equals("1.0.1");
expect(data["JavaScript Engine"]).equals("unknown");
expect(data["Runtime Engine"]).equals("unknown");
expect(data["Anonymized Bundle Id"]).equals("1RmJBlqbKuzyRiPm4AsdIIxe8xlRUntGcGFEwUnUh6A=");
expect(data.Language).equals("javascript");
expect(data["Language Version"]).equals("unknown");
});
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "fake-ts-node-package",
"version": "1.2.3",
"devDependencies": {
"typescript": "3.2.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//
////////////////////////////////////////////////////////////////////////////

import { Realm } from "realm";
import Realm from "realm";

import { describePerformance } from "../utils/benchmark";

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/schemas/contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/* tslint:disable max-classes-per-file */

import { Realm } from "realm";
import Realm from "realm";

export interface IContact {
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/* tslint:disable max-classes-per-file */

import { Realm } from "realm";
import Realm from "realm";

export interface IPerson {
_id: Realm.BSON.ObjectId;
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/schemas/person-and-dogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/* tslint:disable max-classes-per-file */

import { Realm } from "realm";
import Realm from "realm";

export interface IPerson {
name: string;
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/setup-globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("Test Harness", function (this: Mocha.Suite) {
Context.prototype.longTimeout = longTimeout;
});

import { Realm } from "realm";
import Realm from "realm";

// Disable the logger to avoid console flooding
const { defaultLogLevel = "off" } = environment;
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/class-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////////////

import { expect } from "chai";
import { Realm } from "realm";
import Realm from "realm";

import { openRealmBeforeEach } from "../hooks";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////////////

import { expect } from "chai";
import { Realm } from "realm";
import Realm from "realm";
import { openRealmBeforeEach } from "../hooks";

import { PersonSchema, DogSchema } from "../schemas/person-and-dogs";
Expand Down
10 changes: 10 additions & 0 deletions integration-tests/tests/src/tests/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
OpenRealmBehaviorType,
OpenRealmTimeOutBehavior,
SessionStopPolicy,
WaitForSync,
} from "realm";

describe("Enums", function () {
Expand Down Expand Up @@ -84,4 +85,13 @@ describe("Enums", function () {
});
});
});
describe("WaitForSync", function () {
it("is accessible", function () {
expect(WaitForSync).deep.equals({
Always: "always",
FirstTime: "first-time",
Never: "never",
});
});
});
});
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//
////////////////////////////////////////////////////////////////////////////

import { Realm, BSON } from "realm";
import Realm, { BSON } from "realm";
import { expectArraysEqual, expectSimilar } from "../utils/comparisons";
import { expect } from "chai";
import { CanonicalObjectSchema } from "realm";
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////////////

import { expect } from "chai";
import { Realm } from "realm";
import Realm from "realm";
import { openRealmBeforeEach } from "../hooks";

import { PersonSchema, DogSchema } from "../schemas/person-and-dogs";
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//
////////////////////////////////////////////////////////////////////////////
import { expect } from "chai";
import { Realm } from "realm";
import Realm from "realm";

import { IPerson, Person, PersonSchema } from "../schemas/person-and-dogs";
import {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/realm-constructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////////////

import { expect } from "chai";
import { Realm } from "realm";
import Realm from "realm";

import { IPerson, PersonSchema, DogSchema } from "../schemas/person-and-dogs";

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import { expect } from "chai";
import { openRealmBefore } from "../hooks";
import { Realm } from "realm";
import Realm from "realm";

interface Test {
primary: number;
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////////////

import { expect } from "chai";
import { Realm } from "realm";
import Realm from "realm";

type DefaultObject = Record<string, unknown>;

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////////////

import { expect } from "chai";
import { Realm } from "realm";
import Realm from "realm";

import { openRealmBefore } from "../hooks";

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/shared-realms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////////////

import { expect } from "chai";
import { Realm, List } from "realm";
import Realm, { List } from "realm";

import { openRealmBefore, openRealmBeforeEach } from "../hooks";
import { createLocalConfig } from "../utils/open-realm";
Expand Down
3 changes: 1 addition & 2 deletions integration-tests/tests/src/tests/sync/flexible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
// fraction too long.

import { expect } from "chai";
import {
import Realm, {
BSON,
ClientResetMode,
ConfigurationWithSync,
ErrorCallback,
FlexibleSyncConfiguration,
Realm,
SessionStopPolicy,
SubscriptionSetState,
CompensatingWriteError,
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/sync/mixed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//
////////////////////////////////////////////////////////////////////////////
import { expect } from "chai";
import { Realm } from "realm";
import Realm from "realm";

import { importAppBefore, authenticateUserBefore, openRealmBefore } from "../../hooks";

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/sync/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////////////

import { expect } from "chai";
import { Realm } from "realm";
import Realm from "realm";

import { authenticateUserBefore, importAppBefore } from "../../hooks";
import { buildAppConfig } from "../../utils/build-app-config";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//
////////////////////////////////////////////////////////////////////////////

import { Realm, BSON } from "realm";
import Realm, { BSON } from "realm";
import { expect } from "chai";
import { importAppBefore } from "../../hooks";
import { getRegisteredEmailPassCredentials } from "../../utils/credentials";
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/sync/sync-as-local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////////////

import { expect } from "chai";
import { Realm } from "realm";
import Realm from "realm";

import { PersonSchema, IPerson } from "../../schemas/person-and-dog-with-object-ids";
import { authenticateUserBefore, importAppBefore, openRealmBefore } from "../../hooks";
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/sync/sync-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////////////

import { expect } from "chai";
import { Realm, ConnectionState, ObjectSchema, BSON, User, SyncConfiguration } from "realm";
import Realm, { ConnectionState, ObjectSchema, BSON, User, SyncConfiguration } from "realm";
import { importAppBefore } from "../../hooks";
import { DogSchema } from "../../schemas/person-and-dog-with-object-ids";
import { getRegisteredEmailPassCredentials } from "../../utils/credentials";
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/sync/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
randomVerifiableEmail,
} from "../../utils/generators";
import { KJUR } from "jsrsasign";
import { Realm, UserState } from "realm";
import Realm, { UserState } from "realm";

import { buildAppConfig } from "../../utils/build-app-config";

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/tests/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////////////

import { expect } from "chai";
import { Realm } from "realm";
import Realm from "realm";

describe("Realm.Types namespace", () => {
// We specify explicit types on the instance so TS will error if the type def is wrong
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/src/utils/open-realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//
////////////////////////////////////////////////////////////////////////////

import { Realm, Configuration, SyncConfiguration, User, BSON } from "realm";
import Realm, { Configuration, SyncConfiguration, User, BSON } from "realm";

// Either the sync property is left out (local Realm)
export type LocalConfiguration = Omit<Configuration, "sync"> & { sync?: never };
Expand Down
Loading

0 comments on commit 1564c2c

Please sign in to comment.