jazz-run 0.8.38 → 0.8.40

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # jazz-run
2
2
 
3
+ ## 0.8.40
4
+
5
+ ### Patch Changes
6
+
7
+ - cojson-storage-sqlite@0.8.40
8
+
9
+ ## 0.8.39
10
+
11
+ ### Patch Changes
12
+
13
+ - 96f844a: Make possible to use startSyncServer and createWorkerAccount via code
14
+ - 249eecb: Refactored to use the new waitForAllCoValuesSync API
15
+ - Updated dependencies [249eecb]
16
+ - Updated dependencies [3121551]
17
+ - Updated dependencies [ecc7c96]
18
+ - jazz-tools@0.8.39
19
+ - cojson@0.8.39
20
+ - cojson-storage-sqlite@0.8.39
21
+ - cojson-transport-ws@0.8.39
22
+
3
23
  ## 0.8.38
4
24
 
5
25
  ### Patch Changes
@@ -1,6 +1,5 @@
1
1
  import { createWebSocketPeer } from "cojson-transport-ws";
2
- import { Account, WasmCrypto, createJazzContext, isControlledAccount, } from "jazz-tools";
3
- import { fixedCredentialsAuth, randomSessionProvider } from "jazz-tools";
2
+ import { Account, WasmCrypto, isControlledAccount } from "jazz-tools";
4
3
  import { WebSocket } from "ws";
5
4
  export const createWorkerAccount = async ({ name, peer: peerAddr, }) => {
6
5
  const crypto = await WasmCrypto.create();
@@ -24,39 +23,10 @@ export const createWorkerAccount = async ({ name, peer: peerAddr, }) => {
24
23
  syncManager.syncCoValue(accountCoValue),
25
24
  syncManager.syncCoValue(accountProfileCoValue),
26
25
  ]);
27
- await Promise.race([
28
- Promise.all([
29
- syncManager.waitForUploadIntoPeer(peer.id, accountCoValue.id),
30
- syncManager.waitForUploadIntoPeer(peer.id, accountProfileCoValue.id),
31
- ]),
32
- failAfter(4000, "Timeout: Didn't manage to upload the account and profile"),
33
- ]);
34
- // Spawn a second peer to double check that the account is fully synced
35
- const peer2 = createWebSocketPeer({
36
- id: "verifyingPeer",
37
- websocket: new WebSocket(peerAddr),
38
- role: "server",
39
- });
40
- await Promise.race([
41
- createJazzContext({
42
- auth: fixedCredentialsAuth({
43
- accountID: account.id,
44
- secret: account._raw.agentSecret,
45
- }),
46
- sessionProvider: randomSessionProvider,
47
- peersToLoadFrom: [peer2],
48
- crypto,
49
- }),
50
- failAfter(10000, "Timeout: Account loading check failed"),
51
- ]);
26
+ await account.waitForAllCoValuesSync({ timeout: 4000 });
52
27
  return {
53
28
  accountId: account.id,
54
29
  agentSecret: account._raw.agentSecret,
55
30
  };
56
31
  };
57
- function failAfter(ms, errorMessage) {
58
- return new Promise((_, reject) => {
59
- setTimeout(() => reject(new Error(errorMessage)), ms);
60
- });
61
- }
62
32
  //# sourceMappingURL=createWorkerAccount.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createWorkerAccount.js","sourceRoot":"","sources":["../src/createWorkerAccount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACL,OAAO,EAGP,UAAU,EACV,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAE/B,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,IAAI,EACJ,IAAI,EAAE,QAAQ,GAIf,EAAE,EAAE;IACH,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE,CAAC;IAEzC,MAAM,IAAI,GAAG,mBAAmB,CAAC;QAC/B,EAAE,EAAE,UAAU;QACd,SAAS,EAAE,IAAI,SAAS,CAAC,QAAQ,CAAC;QAClC,IAAI,EAAE,QAAQ;KACf,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC;QACnC,aAAa,EAAE,EAAE,IAAI,EAAE;QACvB,eAAe,EAAE,CAAC,IAAI,CAAC;QACvB,MAAM;KACP,CAAC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ClC,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;IACzC,MAAM,qBAAqB,GAAG,OAAO,CAAC,OAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;IACzD,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;IAEvD,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,WAAW,CAAC,WAAW,CAAC,cAAc,CAAC;QACvC,WAAW,CAAC,WAAW,CAAC,qBAAqB,CAAC;KAC/C,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,sBAAsB,CAAC,EAAE,OAAO,EAAE,IAAK,EAAE,CAAC,CAAC;IAEzD,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,EAAE;QACrB,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW;KACtC,CAAC;AACJ,CAAC,CAAC"}
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ const inMemoryOption = Options.boolean("in-memory").pipe(Options.withDescription
34
34
  const dbOption = Options.file("db")
35
35
  .pipe(Options.withDescription("The path to the file where to store the data. Default is 'sync-db/storage.db'"))
36
36
  .pipe(Options.withDefault("sync-db/storage.db"));
37
- export const startSyncServerCommand = Command.make("sync", { port: portOption, inMemory: inMemoryOption, db: dbOption }, ({ port, inMemory, db }) => {
37
+ const startSyncServerCommand = Command.make("sync", { port: portOption, inMemory: inMemoryOption, db: dbOption }, ({ port, inMemory, db }) => {
38
38
  return Effect.gen(function* () {
39
39
  yield* Effect.promise(() => startSyncServer({ port, inMemory, db }));
40
40
  yield* Console.log(`COJSON sync server listening on ws://127.0.0.1:${port}`);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,uCAAuC;AACvC,OAAO,EAAE,OAAO,EA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C,cAAc,EAAE,sBAAsB,CAAC,CAAC,CAClE,CAAC;AAEF,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE;IAC/B,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,SAAS;CACnB,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAC1C,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,EACjC,WAAW,CAAC,OAAO,CACpB,CAAC"}
@@ -1,4 +1,8 @@
1
+ import { LocalNode } from "cojson";
2
+ import { createWebSocketPeer } from "cojson-transport-ws";
3
+ import { WasmCrypto } from "jazz-tools";
1
4
  import { describe, expect, it, onTestFinished } from "vitest";
5
+ import { WebSocket } from "ws";
2
6
  import { createWorkerAccount } from "../createWorkerAccount.js";
3
7
  import { startSyncServer } from "../startSyncServer.js";
4
8
  describe("createWorkerAccount - integration tests", () => {
@@ -22,6 +26,18 @@ describe("createWorkerAccount - integration tests", () => {
22
26
  });
23
27
  expect(accountId).toBeDefined();
24
28
  expect(agentSecret).toBeDefined();
29
+ const peer = createWebSocketPeer({
30
+ id: "upstream",
31
+ websocket: new WebSocket(`ws://localhost:${address.port}`),
32
+ role: "server",
33
+ });
34
+ const crypto = await WasmCrypto.create();
35
+ const { node } = await LocalNode.withNewlyCreatedAccount({
36
+ creationProps: { name: "test" },
37
+ peersToLoadFrom: [peer],
38
+ crypto,
39
+ });
40
+ expect(await node.load(accountId)).not.toBe("unavailable");
25
41
  });
26
42
  it("should create a worker account using the Jazz cloud", async () => {
27
43
  const { accountId, agentSecret } = await createWorkerAccount({
@@ -30,6 +46,18 @@ describe("createWorkerAccount - integration tests", () => {
30
46
  });
31
47
  expect(accountId).toBeDefined();
32
48
  expect(agentSecret).toBeDefined();
49
+ const peer = createWebSocketPeer({
50
+ id: "upstream",
51
+ websocket: new WebSocket(`wss://cloud.jazz.tools`),
52
+ role: "server",
53
+ });
54
+ const crypto = await WasmCrypto.create();
55
+ const { node } = await LocalNode.withNewlyCreatedAccount({
56
+ creationProps: { name: "test" },
57
+ peersToLoadFrom: [peer],
58
+ crypto,
59
+ });
60
+ expect(await node.load(accountId)).not.toBe("unavailable");
33
61
  });
34
62
  });
35
63
  //# sourceMappingURL=createWorkerAccount.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createWorkerAccount.test.js","sourceRoot":"","sources":["../../src/test/createWorkerAccount.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,QAAQ,CAAC,yCAAyC,EAAE,GAAG,EAAE;IACvD,EAAE,CAAC,4DAA4D,EAAE,KAAK,IAAI,EAAE;QAC1E,8DAA8D;QAC9D,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC;YACnC,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,IAAI;YACd,EAAE,EAAE,EAAE;SACP,CAAC,CAAC;QAEH,cAAc,CAAC,GAAG,EAAE;YAClB,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;QAEjC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,MAAM,mBAAmB,CAAC;YAC3D,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,kBAAkB,OAAO,CAAC,IAAI,EAAE;SACvC,CAAC,CAAC;QAEH,MA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EAAE,wBAAwB;SAC/B,CAAC,CAAC;QAEH,MAAM,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;QAChC,MAAM,CAAC,WAAW,CAAC,CAAC,WAAW,EAAE,CAAC;QAElC,MAAM,IAAI,GAAG,mBAAmB,CAAC;YAC/B,EAAE,EAAE,UAAU;YACd,SAAS,EAAE,IAAI,SAAS,CAAC,wBAAwB,CAAC;YAClD,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE,CAAC;QACzC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,SAAS,CAAC,uBAAuB,CAAC;YACvD,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;YAC/B,eAAe,EAAE,CAAC,IAAI,CAAC;YACvB,MAAM;SACP,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,SAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -3,7 +3,17 @@
3
3
  "bin": "./dist/index.js",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
- "version": "0.8.38",
6
+ "version": "0.8.40",
7
+ "exports": {
8
+ "./startSyncServer": {
9
+ "import": "./dist/startSyncServer.js",
10
+ "types": "./src/startSyncServer.ts"
11
+ },
12
+ "./createWorkerAccount": {
13
+ "import": "./dist/createWorkerAccount.js",
14
+ "types": "./src/createWorkerAccount.ts"
15
+ }
16
+ },
7
17
  "dependencies": {
8
18
  "@effect/cli": "^0.41.2",
9
19
  "@effect/platform-node": "^0.57.2",
@@ -11,16 +21,16 @@
11
21
  "@effect/printer-ansi": "^0.34.5",
12
22
  "@effect/schema": "^0.71.1",
13
23
  "@effect/typeclass": "^0.25.5",
14
- "cojson": "0.8.38",
15
- "cojson-storage-sqlite": "0.8.38",
16
- "cojson-transport-ws": "0.8.38",
24
+ "cojson": "0.8.39",
25
+ "cojson-storage-sqlite": "0.8.40",
26
+ "cojson-transport-ws": "0.8.39",
17
27
  "effect": "^3.6.5",
18
- "jazz-tools": "0.8.38",
28
+ "jazz-tools": "0.8.39",
19
29
  "ws": "^8.14.2"
20
30
  },
21
31
  "devDependencies": {
22
32
  "@types/ws": "8.5.10",
23
- "typescript": "^5.3.3"
33
+ "typescript": "~5.6.2"
24
34
  },
25
35
  "scripts": {
26
36
  "format-and-lint": "biome check .",
@@ -1,14 +1,5 @@
1
- import { CoValueCore, Profile } from "cojson";
2
1
  import { createWebSocketPeer } from "cojson-transport-ws";
3
- import {
4
- Account,
5
- CoMap,
6
- Peer,
7
- WasmCrypto,
8
- createJazzContext,
9
- isControlledAccount,
10
- } from "jazz-tools";
11
- import { fixedCredentialsAuth, randomSessionProvider } from "jazz-tools";
2
+ import { Account, WasmCrypto, isControlledAccount } from "jazz-tools";
12
3
  import { WebSocket } from "ws";
13
4
 
14
5
  export const createWorkerAccount = async ({
@@ -45,45 +36,10 @@ export const createWorkerAccount = async ({
45
36
  syncManager.syncCoValue(accountProfileCoValue),
46
37
  ]);
47
38
 
48
- await Promise.race([
49
- Promise.all([
50
- syncManager.waitForUploadIntoPeer(peer.id, accountCoValue.id),
51
- syncManager.waitForUploadIntoPeer(peer.id, accountProfileCoValue.id),
52
- ]),
53
- failAfter(
54
- 4_000,
55
- "Timeout: Didn't manage to upload the account and profile",
56
- ),
57
- ]);
58
-
59
- // Spawn a second peer to double check that the account is fully synced
60
- const peer2 = createWebSocketPeer({
61
- id: "verifyingPeer",
62
- websocket: new WebSocket(peerAddr),
63
- role: "server",
64
- });
65
-
66
- await Promise.race([
67
- createJazzContext({
68
- auth: fixedCredentialsAuth({
69
- accountID: account.id,
70
- secret: account._raw.agentSecret,
71
- }),
72
- sessionProvider: randomSessionProvider,
73
- peersToLoadFrom: [peer2],
74
- crypto,
75
- }),
76
- failAfter(10_000, "Timeout: Account loading check failed"),
77
- ]);
39
+ await account.waitForAllCoValuesSync({ timeout: 4_000 });
78
40
 
79
41
  return {
80
42
  accountId: account.id,
81
43
  agentSecret: account._raw.agentSecret,
82
44
  };
83
45
  };
84
-
85
- function failAfter(ms: number, errorMessage: string) {
86
- return new Promise((_, reject) => {
87
- setTimeout(() => reject(new Error(errorMessage)), ms);
88
- });
89
- }
package/src/index.ts CHANGED
@@ -60,7 +60,7 @@ const dbOption = Options.file("db")
60
60
  )
61
61
  .pipe(Options.withDefault("sync-db/storage.db"));
62
62
 
63
- export const startSyncServerCommand = Command.make(
63
+ const startSyncServerCommand = Command.make(
64
64
  "sync",
65
65
  { port: portOption, inMemory: inMemoryOption, db: dbOption },
66
66
  ({ port, inMemory, db }) => {
@@ -1,4 +1,8 @@
1
+ import { LocalNode } from "cojson";
2
+ import { createWebSocketPeer } from "cojson-transport-ws";
3
+ import { WasmCrypto } from "jazz-tools";
1
4
  import { describe, expect, it, onTestFinished } from "vitest";
5
+ import { WebSocket } from "ws";
2
6
  import { createWorkerAccount } from "../createWorkerAccount.js";
3
7
  import { startSyncServer } from "../startSyncServer.js";
4
8
 
@@ -28,6 +32,21 @@ describe("createWorkerAccount - integration tests", () => {
28
32
 
29
33
  expect(accountId).toBeDefined();
30
34
  expect(agentSecret).toBeDefined();
35
+
36
+ const peer = createWebSocketPeer({
37
+ id: "upstream",
38
+ websocket: new WebSocket(`ws://localhost:${address.port}`),
39
+ role: "server",
40
+ });
41
+
42
+ const crypto = await WasmCrypto.create();
43
+ const { node } = await LocalNode.withNewlyCreatedAccount({
44
+ creationProps: { name: "test" },
45
+ peersToLoadFrom: [peer],
46
+ crypto,
47
+ });
48
+
49
+ expect(await node.load(accountId as any)).not.toBe("unavailable");
31
50
  });
32
51
 
33
52
  it("should create a worker account using the Jazz cloud", async () => {
@@ -38,5 +57,20 @@ describe("createWorkerAccount - integration tests", () => {
38
57
 
39
58
  expect(accountId).toBeDefined();
40
59
  expect(agentSecret).toBeDefined();
60
+
61
+ const peer = createWebSocketPeer({
62
+ id: "upstream",
63
+ websocket: new WebSocket(`wss://cloud.jazz.tools`),
64
+ role: "server",
65
+ });
66
+
67
+ const crypto = await WasmCrypto.create();
68
+ const { node } = await LocalNode.withNewlyCreatedAccount({
69
+ creationProps: { name: "test" },
70
+ peersToLoadFrom: [peer],
71
+ crypto,
72
+ });
73
+
74
+ expect(await node.load(accountId as any)).not.toBe("unavailable");
41
75
  });
42
76
  });