orez 0.4.10 → 0.4.11
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/zero-http/fixture-schema.d.ts +111 -0
- package/dist/zero-http/fixture-schema.d.ts.map +1 -0
- package/dist/zero-http/fixture-schema.js +53 -0
- package/dist/zero-http/fixture-schema.js.map +1 -0
- package/dist/zero-http/server.d.ts +14 -0
- package/dist/zero-http/server.d.ts.map +1 -0
- package/dist/zero-http/server.js +284 -0
- package/dist/zero-http/server.js.map +1 -0
- package/dist/zero-http/test-harness.d.ts +36 -0
- package/dist/zero-http/test-harness.d.ts.map +1 -0
- package/dist/zero-http/test-harness.js +72 -0
- package/dist/zero-http/test-harness.js.map +1 -0
- package/dist/zero-http/transport.d.ts +9 -0
- package/dist/zero-http/transport.d.ts.map +1 -0
- package/dist/zero-http/transport.js +425 -0
- package/dist/zero-http/transport.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Transaction } from '@rocicorp/zero';
|
|
2
|
+
export declare const zeroHttpFixtureSchema: {
|
|
3
|
+
tables: {
|
|
4
|
+
readonly user: {
|
|
5
|
+
name: "user";
|
|
6
|
+
columns: {
|
|
7
|
+
readonly id: {
|
|
8
|
+
type: "string";
|
|
9
|
+
optional: false;
|
|
10
|
+
customType: string;
|
|
11
|
+
};
|
|
12
|
+
readonly name: {
|
|
13
|
+
type: "string";
|
|
14
|
+
optional: false;
|
|
15
|
+
customType: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
primaryKey: readonly [string, ...string[]];
|
|
19
|
+
} & {
|
|
20
|
+
primaryKey: ["id"];
|
|
21
|
+
};
|
|
22
|
+
readonly project: {
|
|
23
|
+
name: "project";
|
|
24
|
+
columns: {
|
|
25
|
+
readonly id: {
|
|
26
|
+
type: "string";
|
|
27
|
+
optional: false;
|
|
28
|
+
customType: string;
|
|
29
|
+
};
|
|
30
|
+
readonly ownerId: {
|
|
31
|
+
type: "string";
|
|
32
|
+
optional: false;
|
|
33
|
+
customType: string;
|
|
34
|
+
};
|
|
35
|
+
readonly name: {
|
|
36
|
+
type: "string";
|
|
37
|
+
optional: false;
|
|
38
|
+
customType: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
primaryKey: readonly [string, ...string[]];
|
|
42
|
+
} & {
|
|
43
|
+
primaryKey: ["id"];
|
|
44
|
+
};
|
|
45
|
+
readonly member: {
|
|
46
|
+
name: "member";
|
|
47
|
+
columns: {
|
|
48
|
+
readonly id: {
|
|
49
|
+
type: "string";
|
|
50
|
+
optional: false;
|
|
51
|
+
customType: string;
|
|
52
|
+
};
|
|
53
|
+
readonly projectId: {
|
|
54
|
+
type: "string";
|
|
55
|
+
optional: false;
|
|
56
|
+
customType: string;
|
|
57
|
+
};
|
|
58
|
+
readonly userId: {
|
|
59
|
+
type: "string";
|
|
60
|
+
optional: false;
|
|
61
|
+
customType: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
primaryKey: readonly [string, ...string[]];
|
|
65
|
+
} & {
|
|
66
|
+
primaryKey: ["id"];
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
relationships: {
|
|
70
|
+
readonly project: {
|
|
71
|
+
members: [{
|
|
72
|
+
readonly sourceField: readonly ("id" | "name" | "ownerId")[];
|
|
73
|
+
readonly destField: readonly ("id" | "projectId" | "userId")[];
|
|
74
|
+
readonly destSchema: "member";
|
|
75
|
+
readonly cardinality: "many";
|
|
76
|
+
}];
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
enableLegacyQueries: true;
|
|
80
|
+
enableLegacyMutators: boolean | undefined;
|
|
81
|
+
};
|
|
82
|
+
type FixtureTransaction = Transaction<typeof zeroHttpFixtureSchema>;
|
|
83
|
+
export type ProjectCreateArgs = {
|
|
84
|
+
id: string;
|
|
85
|
+
ownerId: string;
|
|
86
|
+
name: string;
|
|
87
|
+
};
|
|
88
|
+
export type ProjectRenameArgs = {
|
|
89
|
+
id: string;
|
|
90
|
+
name: string;
|
|
91
|
+
};
|
|
92
|
+
export type MemberAddArgs = {
|
|
93
|
+
id: string;
|
|
94
|
+
projectId: string;
|
|
95
|
+
userId: string;
|
|
96
|
+
};
|
|
97
|
+
export type MemberRemoveArgs = {
|
|
98
|
+
id: string;
|
|
99
|
+
};
|
|
100
|
+
export declare const zeroHttpFixtureMutators: {
|
|
101
|
+
project: {
|
|
102
|
+
create: (tx: FixtureTransaction, args: ProjectCreateArgs) => Promise<void>;
|
|
103
|
+
rename: (tx: FixtureTransaction, args: ProjectRenameArgs) => Promise<void>;
|
|
104
|
+
};
|
|
105
|
+
member: {
|
|
106
|
+
add: (tx: FixtureTransaction, args: MemberAddArgs) => Promise<void>;
|
|
107
|
+
remove: (tx: FixtureTransaction, args: MemberRemoveArgs) => Promise<void>;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
export {};
|
|
111
|
+
//# sourceMappingURL=fixture-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixture-schema.d.ts","sourceRoot":"","sources":["../../src/zero-http/fixture-schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAyBjD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYhC,CAAA;AAEF,KAAK,kBAAkB,GAAG,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEnE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAA;CACX,CAAA;AAED,eAAO,MAAM,uBAAuB;;qBAEb,kBAAkB,QAAQ,iBAAiB;qBAG3C,kBAAkB,QAAQ,iBAAiB;;;kBAK9C,kBAAkB,QAAQ,aAAa;qBAGpC,kBAAkB,QAAQ,gBAAgB;;CAIhE,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createSchema, relationships, string, table } from '@rocicorp/zero';
|
|
2
|
+
const user = table('user')
|
|
3
|
+
.columns({
|
|
4
|
+
id: string(),
|
|
5
|
+
name: string(),
|
|
6
|
+
})
|
|
7
|
+
.primaryKey('id');
|
|
8
|
+
const project = table('project')
|
|
9
|
+
.columns({
|
|
10
|
+
id: string(),
|
|
11
|
+
ownerId: string(),
|
|
12
|
+
name: string(),
|
|
13
|
+
})
|
|
14
|
+
.primaryKey('id');
|
|
15
|
+
const member = table('member')
|
|
16
|
+
.columns({
|
|
17
|
+
id: string(),
|
|
18
|
+
projectId: string(),
|
|
19
|
+
userId: string(),
|
|
20
|
+
})
|
|
21
|
+
.primaryKey('id');
|
|
22
|
+
export const zeroHttpFixtureSchema = createSchema({
|
|
23
|
+
tables: [user, project, member],
|
|
24
|
+
relationships: [
|
|
25
|
+
relationships(project, ({ many }) => ({
|
|
26
|
+
members: many({
|
|
27
|
+
sourceField: ['id'],
|
|
28
|
+
destField: ['projectId'],
|
|
29
|
+
destSchema: member,
|
|
30
|
+
}),
|
|
31
|
+
})),
|
|
32
|
+
],
|
|
33
|
+
enableLegacyQueries: true,
|
|
34
|
+
});
|
|
35
|
+
export const zeroHttpFixtureMutators = {
|
|
36
|
+
project: {
|
|
37
|
+
create: async (tx, args) => {
|
|
38
|
+
await tx.mutate.project.insert(args);
|
|
39
|
+
},
|
|
40
|
+
rename: async (tx, args) => {
|
|
41
|
+
await tx.mutate.project.update(args);
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
member: {
|
|
45
|
+
add: async (tx, args) => {
|
|
46
|
+
await tx.mutate.member.insert(args);
|
|
47
|
+
},
|
|
48
|
+
remove: async (tx, args) => {
|
|
49
|
+
await tx.mutate.member.delete({ id: args.id });
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=fixture-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixture-schema.js","sourceRoot":"","sources":["../../src/zero-http/fixture-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAI3E,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC;KACvB,OAAO,CAAC;IACP,EAAE,EAAE,MAAM,EAAE;IACZ,IAAI,EAAE,MAAM,EAAE;CACf,CAAC;KACD,UAAU,CAAC,IAAI,CAAC,CAAA;AAEnB,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC;KAC7B,OAAO,CAAC;IACP,EAAE,EAAE,MAAM,EAAE;IACZ,OAAO,EAAE,MAAM,EAAE;IACjB,IAAI,EAAE,MAAM,EAAE;CACf,CAAC;KACD,UAAU,CAAC,IAAI,CAAC,CAAA;AAEnB,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC;KAC3B,OAAO,CAAC;IACP,EAAE,EAAE,MAAM,EAAE;IACZ,SAAS,EAAE,MAAM,EAAE;IACnB,MAAM,EAAE,MAAM,EAAE;CACjB,CAAC;KACD,UAAU,CAAC,IAAI,CAAC,CAAA;AAEnB,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAAC;IAChD,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;IAC/B,aAAa,EAAE;QACb,aAAa,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YACpC,OAAO,EAAE,IAAI,CAAC;gBACZ,WAAW,EAAE,CAAC,IAAI,CAAC;gBACnB,SAAS,EAAE,CAAC,WAAW,CAAC;gBACxB,UAAU,EAAE,MAAM;aACnB,CAAC;SACH,CAAC,CAAC;KACJ;IACD,mBAAmB,EAAE,IAAI;CAC1B,CAAC,CAAA;AAyBF,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,OAAO,EAAE;QACP,MAAM,EAAE,KAAK,EAAE,EAAsB,EAAE,IAAuB,EAAE,EAAE;YAChE,MAAM,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACtC,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,EAAsB,EAAE,IAAuB,EAAE,EAAE;YAChE,MAAM,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACtC,CAAC;KACF;IACD,MAAM,EAAE;QACN,GAAG,EAAE,KAAK,EAAE,EAAsB,EAAE,IAAmB,EAAE,EAAE;YACzD,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACrC,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,EAAsB,EAAE,IAAsB,EAAE,EAAE;YAC/D,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;QAChD,CAAC;KACF;CACF,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Row = Record<string, string>;
|
|
2
|
+
export declare function startZeroHttpServer(opts?: {
|
|
3
|
+
seed?: {
|
|
4
|
+
user?: Row[];
|
|
5
|
+
project?: Row[];
|
|
6
|
+
member?: Row[];
|
|
7
|
+
};
|
|
8
|
+
}): Promise<{
|
|
9
|
+
url: string;
|
|
10
|
+
version(): number;
|
|
11
|
+
rows(table: string): Row[];
|
|
12
|
+
close(): Promise<void>;
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/zero-http/server.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AA6BxC,wBAAsB,mBAAmB,CAAC,IAAI,CAAC,EAAE;IAC/C,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE,CAAA;CACzD,GAAG,OAAO,CAAC;IACV,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,IAAI,MAAM,CAAA;IACjB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE,CAAA;IAC1B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB,CAAC,CA8HD"}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { createServer } from 'node:http';
|
|
2
|
+
const tableNames = ['user', 'project', 'member'];
|
|
3
|
+
export async function startZeroHttpServer(opts) {
|
|
4
|
+
const tables = seedTables(opts?.seed);
|
|
5
|
+
const lmids = new Map();
|
|
6
|
+
const mutationResults = new Map();
|
|
7
|
+
const clientGroupUsers = new Map();
|
|
8
|
+
let cookie = 1;
|
|
9
|
+
const server = createServer(async (req, res) => {
|
|
10
|
+
try {
|
|
11
|
+
if (req.method !== 'POST') {
|
|
12
|
+
sendJSON(res, 404, { error: 'not found' });
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const path = new URL(req.url || '/', 'http://127.0.0.1').pathname;
|
|
16
|
+
const userID = authenticate(req, tables);
|
|
17
|
+
if (!userID) {
|
|
18
|
+
sendJSON(res, 401, { error: 'unauthorized' });
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (path === '/pull') {
|
|
22
|
+
const body = (await readJSON(req));
|
|
23
|
+
if (!bindClientGroup(clientGroupUsers, body.clientGroupID, userID)) {
|
|
24
|
+
sendJSON(res, 403, { error: 'client group belongs to a different user' });
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (body.cookie === cookie) {
|
|
28
|
+
sendJSON(res, 200, { cookie, unchanged: true });
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (typeof body.cookie === 'number' && body.cookie > cookie) {
|
|
32
|
+
sendJSON(res, 409, {
|
|
33
|
+
error: `future cookie ${body.cookie} is ahead of server cookie ${cookie}`,
|
|
34
|
+
});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
sendJSON(res, 200, {
|
|
38
|
+
cookie,
|
|
39
|
+
lastMutationIDChanges: lastMutationIDChanges(lmids, body.clientGroupID),
|
|
40
|
+
rowsPatch: [{ op: 'clear' }, ...visibleRowsPatch(tables, userID)],
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (path === '/push') {
|
|
45
|
+
const body = (await readJSON(req));
|
|
46
|
+
if (!bindClientGroup(clientGroupUsers, body.clientGroupID, userID)) {
|
|
47
|
+
sendJSON(res, 403, { error: 'client group belongs to a different user' });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const mutations = Array.isArray(body.mutations) ? body.mutations : [];
|
|
51
|
+
const gap = findMutationGap(lmids, body.clientGroupID, mutations);
|
|
52
|
+
if (gap) {
|
|
53
|
+
sendJSON(res, 500, { error: gap });
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const pushResults = [];
|
|
57
|
+
let processedNewMutation = false;
|
|
58
|
+
for (const mutation of mutations) {
|
|
59
|
+
const current = lmidFor(lmids, body.clientGroupID, mutation.clientID);
|
|
60
|
+
if (mutation.id <= current) {
|
|
61
|
+
pushResults.push({
|
|
62
|
+
id: { clientID: mutation.clientID, id: mutation.id },
|
|
63
|
+
result: resultForMutation(mutationResults, body.clientGroupID, mutation.clientID, mutation.id) || {},
|
|
64
|
+
});
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const result = applyMutation(tables, userID, mutation);
|
|
68
|
+
setLMID(lmids, body.clientGroupID, mutation.clientID, mutation.id);
|
|
69
|
+
setMutationResult(mutationResults, body.clientGroupID, mutation.clientID, mutation.id, result);
|
|
70
|
+
processedNewMutation = true;
|
|
71
|
+
pushResults.push({
|
|
72
|
+
id: { clientID: mutation.clientID, id: mutation.id },
|
|
73
|
+
result,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (processedNewMutation)
|
|
77
|
+
cookie += 1;
|
|
78
|
+
sendJSON(res, 200, { pushResponse: { mutations: pushResults } });
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
sendJSON(res, 404, { error: 'not found' });
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
sendJSON(res, 500, { error: err instanceof Error ? err.message : String(err) });
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
await new Promise((resolve, reject) => {
|
|
88
|
+
server.once('error', reject);
|
|
89
|
+
server.listen(0, '127.0.0.1', () => {
|
|
90
|
+
server.off('error', reject);
|
|
91
|
+
resolve();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
const address = server.address();
|
|
95
|
+
return {
|
|
96
|
+
url: `http://127.0.0.1:${address.port}`,
|
|
97
|
+
version: () => cookie,
|
|
98
|
+
rows: (table) => rowsForTable(tables, table),
|
|
99
|
+
close: () => new Promise((resolve, reject) => {
|
|
100
|
+
server.close((err) => (err ? reject(err) : resolve()));
|
|
101
|
+
}),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function seedTables(seed) {
|
|
105
|
+
const tables = {
|
|
106
|
+
user: new Map(),
|
|
107
|
+
project: new Map(),
|
|
108
|
+
member: new Map(),
|
|
109
|
+
};
|
|
110
|
+
for (const table of tableNames) {
|
|
111
|
+
for (const row of seed?.[table] || []) {
|
|
112
|
+
if (typeof row.id === 'string')
|
|
113
|
+
tables[table].set(row.id, cloneRow(row));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return tables;
|
|
117
|
+
}
|
|
118
|
+
function authenticate(req, tables) {
|
|
119
|
+
const header = req.headers.authorization;
|
|
120
|
+
if (!header?.startsWith('Bearer token-'))
|
|
121
|
+
return null;
|
|
122
|
+
const userID = header.slice('Bearer token-'.length);
|
|
123
|
+
return tables.user.has(userID) ? userID : null;
|
|
124
|
+
}
|
|
125
|
+
function bindClientGroup(clientGroupUsers, clientGroupID, userID) {
|
|
126
|
+
const owner = clientGroupUsers.get(clientGroupID);
|
|
127
|
+
if (owner)
|
|
128
|
+
return owner === userID;
|
|
129
|
+
clientGroupUsers.set(clientGroupID, userID);
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
function visibleRowsPatch(tables, userID) {
|
|
133
|
+
const visibleProjectIDs = visibleProjectIDSet(tables, userID);
|
|
134
|
+
const rows = [];
|
|
135
|
+
const user = tables.user.get(userID);
|
|
136
|
+
if (user)
|
|
137
|
+
rows.push({ op: 'put', tableName: 'user', value: cloneRow(user) });
|
|
138
|
+
for (const project of tables.project.values()) {
|
|
139
|
+
if (visibleProjectIDs.has(project.id)) {
|
|
140
|
+
rows.push({ op: 'put', tableName: 'project', value: cloneRow(project) });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
for (const member of tables.member.values()) {
|
|
144
|
+
if (visibleProjectIDs.has(member.projectId)) {
|
|
145
|
+
rows.push({ op: 'put', tableName: 'member', value: cloneRow(member) });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return rows;
|
|
149
|
+
}
|
|
150
|
+
function visibleProjectIDSet(tables, userID) {
|
|
151
|
+
const projectIDs = new Set();
|
|
152
|
+
for (const project of tables.project.values()) {
|
|
153
|
+
if (project.ownerId === userID)
|
|
154
|
+
projectIDs.add(project.id);
|
|
155
|
+
}
|
|
156
|
+
for (const member of tables.member.values()) {
|
|
157
|
+
if (member.userId === userID && tables.project.has(member.projectId)) {
|
|
158
|
+
projectIDs.add(member.projectId);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return projectIDs;
|
|
162
|
+
}
|
|
163
|
+
function findMutationGap(lmids, clientGroupID, mutations) {
|
|
164
|
+
const nextLMIDs = new Map();
|
|
165
|
+
for (const mutation of mutations) {
|
|
166
|
+
const current = nextLMIDs.get(mutation.clientID) ?? lmidFor(lmids, clientGroupID, mutation.clientID);
|
|
167
|
+
if (mutation.id <= current)
|
|
168
|
+
continue;
|
|
169
|
+
if (mutation.id !== current + 1) {
|
|
170
|
+
return `mutation id gap for ${mutation.clientID}: got ${mutation.id}, expected ${current + 1}`;
|
|
171
|
+
}
|
|
172
|
+
nextLMIDs.set(mutation.clientID, mutation.id);
|
|
173
|
+
}
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
function applyMutation(tables, userID, mutation) {
|
|
177
|
+
if (mutation.type !== 'custom')
|
|
178
|
+
return appError('unsupported');
|
|
179
|
+
const args = mutation.args[0] || {};
|
|
180
|
+
if (mutation.name === 'project|create') {
|
|
181
|
+
if (tables.project.has(args.id))
|
|
182
|
+
return appError('exists');
|
|
183
|
+
if (args.ownerId !== userID)
|
|
184
|
+
return appError('forbidden');
|
|
185
|
+
tables.project.set(args.id, {
|
|
186
|
+
id: args.id,
|
|
187
|
+
ownerId: args.ownerId,
|
|
188
|
+
name: args.name,
|
|
189
|
+
});
|
|
190
|
+
return {};
|
|
191
|
+
}
|
|
192
|
+
if (mutation.name === 'project|rename') {
|
|
193
|
+
const project = tables.project.get(args.id);
|
|
194
|
+
if (!project)
|
|
195
|
+
return appError('not-found');
|
|
196
|
+
if (project.ownerId !== userID)
|
|
197
|
+
return appError('forbidden');
|
|
198
|
+
tables.project.set(args.id, { ...project, name: args.name });
|
|
199
|
+
return {};
|
|
200
|
+
}
|
|
201
|
+
if (mutation.name === 'member|add') {
|
|
202
|
+
const project = tables.project.get(args.projectId);
|
|
203
|
+
if (!project)
|
|
204
|
+
return appError('not-found');
|
|
205
|
+
if (project.ownerId !== userID)
|
|
206
|
+
return appError('forbidden');
|
|
207
|
+
if (tables.member.has(args.id))
|
|
208
|
+
return appError('exists');
|
|
209
|
+
tables.member.set(args.id, {
|
|
210
|
+
id: args.id,
|
|
211
|
+
projectId: args.projectId,
|
|
212
|
+
userId: args.userId,
|
|
213
|
+
});
|
|
214
|
+
return {};
|
|
215
|
+
}
|
|
216
|
+
if (mutation.name === 'member|remove') {
|
|
217
|
+
const member = tables.member.get(args.id);
|
|
218
|
+
if (!member)
|
|
219
|
+
return appError('not-found');
|
|
220
|
+
const project = tables.project.get(member.projectId);
|
|
221
|
+
if (!project)
|
|
222
|
+
return appError('not-found');
|
|
223
|
+
if (project.ownerId !== userID)
|
|
224
|
+
return appError('forbidden');
|
|
225
|
+
tables.member.delete(args.id);
|
|
226
|
+
return {};
|
|
227
|
+
}
|
|
228
|
+
return appError('unsupported');
|
|
229
|
+
}
|
|
230
|
+
function appError(details) {
|
|
231
|
+
return { error: 'app', details };
|
|
232
|
+
}
|
|
233
|
+
function lastMutationIDChanges(lmids, clientGroupID) {
|
|
234
|
+
return Object.fromEntries(lmids.get(clientGroupID) || []);
|
|
235
|
+
}
|
|
236
|
+
function lmidFor(lmids, clientGroupID, clientID) {
|
|
237
|
+
return lmids.get(clientGroupID)?.get(clientID) || 0;
|
|
238
|
+
}
|
|
239
|
+
function setLMID(lmids, clientGroupID, clientID, id) {
|
|
240
|
+
let group = lmids.get(clientGroupID);
|
|
241
|
+
if (!group) {
|
|
242
|
+
group = new Map();
|
|
243
|
+
lmids.set(clientGroupID, group);
|
|
244
|
+
}
|
|
245
|
+
group.set(clientID, id);
|
|
246
|
+
}
|
|
247
|
+
function resultForMutation(results, clientGroupID, clientID, id) {
|
|
248
|
+
return results.get(clientGroupID)?.get(clientID)?.get(id);
|
|
249
|
+
}
|
|
250
|
+
function setMutationResult(results, clientGroupID, clientID, id, result) {
|
|
251
|
+
let group = results.get(clientGroupID);
|
|
252
|
+
if (!group) {
|
|
253
|
+
group = new Map();
|
|
254
|
+
results.set(clientGroupID, group);
|
|
255
|
+
}
|
|
256
|
+
let client = group.get(clientID);
|
|
257
|
+
if (!client) {
|
|
258
|
+
client = new Map();
|
|
259
|
+
group.set(clientID, client);
|
|
260
|
+
}
|
|
261
|
+
client.set(id, result);
|
|
262
|
+
}
|
|
263
|
+
function rowsForTable(tables, table) {
|
|
264
|
+
if (!isTableName(table))
|
|
265
|
+
return [];
|
|
266
|
+
return [...tables[table].values()].map(cloneRow);
|
|
267
|
+
}
|
|
268
|
+
function isTableName(table) {
|
|
269
|
+
return tableNames.includes(table);
|
|
270
|
+
}
|
|
271
|
+
function cloneRow(row) {
|
|
272
|
+
return { ...row };
|
|
273
|
+
}
|
|
274
|
+
async function readJSON(req) {
|
|
275
|
+
let body = '';
|
|
276
|
+
for await (const chunk of req)
|
|
277
|
+
body += chunk;
|
|
278
|
+
return body ? JSON.parse(body) : {};
|
|
279
|
+
}
|
|
280
|
+
function sendJSON(res, status, body) {
|
|
281
|
+
res.writeHead(status, { 'content-type': 'application/json' });
|
|
282
|
+
res.end(JSON.stringify(body));
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/zero-http/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAA;AA+BnF,MAAM,UAAU,GAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;AAE7D,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,IAEzC;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}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Zero } from '@rocicorp/zero';
|
|
2
|
+
import { zeroHttpFixtureMutators, zeroHttpFixtureSchema } from './fixture-schema.js';
|
|
3
|
+
import { type Row } from './server.js';
|
|
4
|
+
export type FixtureZero = Zero<typeof zeroHttpFixtureSchema, typeof zeroHttpFixtureMutators>;
|
|
5
|
+
export type ZeroHttpHarness = Awaited<ReturnType<typeof startZeroHttpHarness>>;
|
|
6
|
+
export declare function startZeroHttpHarness(opts?: {
|
|
7
|
+
seed?: {
|
|
8
|
+
user?: Row[];
|
|
9
|
+
project?: Row[];
|
|
10
|
+
member?: Row[];
|
|
11
|
+
};
|
|
12
|
+
interceptFetch?: (next: typeof fetch) => typeof fetch;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
server: {
|
|
15
|
+
url: string;
|
|
16
|
+
version(): number;
|
|
17
|
+
rows(table: string): Row[];
|
|
18
|
+
close(): Promise<void>;
|
|
19
|
+
};
|
|
20
|
+
transport: {
|
|
21
|
+
pull(): Promise<void>;
|
|
22
|
+
readonly connections: number;
|
|
23
|
+
uninstall(): void;
|
|
24
|
+
};
|
|
25
|
+
createZero(userID: string, createOpts?: {
|
|
26
|
+
storageKey?: string;
|
|
27
|
+
pingTimeoutMs?: number;
|
|
28
|
+
}): FixtureZero;
|
|
29
|
+
close(): Promise<void>;
|
|
30
|
+
}>;
|
|
31
|
+
export declare function waitForComplete<T>(view: {
|
|
32
|
+
addListener(listener: (data: T, resultType: string) => void): () => void;
|
|
33
|
+
}): Promise<T>;
|
|
34
|
+
export declare function eventually(assertion: () => void | Promise<void>, timeout?: number): Promise<void>;
|
|
35
|
+
export declare function sleep(ms: number): Promise<unknown>;
|
|
36
|
+
//# sourceMappingURL=test-harness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-harness.d.ts","sourceRoot":"","sources":["../../src/zero-http/test-harness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,I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chema } from './fixture-schema.js';
|
|
3
|
+
import { startZeroHttpServer } from './server.js';
|
|
4
|
+
import { installZeroHttpTransport } from './transport.js';
|
|
5
|
+
let storageID = 0;
|
|
6
|
+
export async function startZeroHttpHarness(opts) {
|
|
7
|
+
const server = await startZeroHttpServer({ seed: opts?.seed });
|
|
8
|
+
const baseFetch = (input, init) => globalThis.fetch(input, init);
|
|
9
|
+
const transportFetch = opts?.interceptFetch ? opts.interceptFetch(baseFetch) : baseFetch;
|
|
10
|
+
const transport = installZeroHttpTransport({
|
|
11
|
+
origin: server.url,
|
|
12
|
+
fetch: transportFetch,
|
|
13
|
+
});
|
|
14
|
+
const clients = [];
|
|
15
|
+
return {
|
|
16
|
+
server,
|
|
17
|
+
transport,
|
|
18
|
+
createZero(userID, createOpts) {
|
|
19
|
+
const zero = new Zero({
|
|
20
|
+
server: server.url,
|
|
21
|
+
userID,
|
|
22
|
+
auth: `token-${userID}`,
|
|
23
|
+
schema: zeroHttpFixtureSchema,
|
|
24
|
+
kvStore: 'mem',
|
|
25
|
+
storageKey: createOpts?.storageKey ?? `zero-http-harness-${++storageID}`,
|
|
26
|
+
mutators: zeroHttpFixtureMutators,
|
|
27
|
+
pingTimeoutMs: createOpts?.pingTimeoutMs,
|
|
28
|
+
});
|
|
29
|
+
clients.push(zero);
|
|
30
|
+
return zero;
|
|
31
|
+
},
|
|
32
|
+
async close() {
|
|
33
|
+
await transport.pull().catch(() => { });
|
|
34
|
+
while (clients.length)
|
|
35
|
+
await clients.pop()?.close();
|
|
36
|
+
transport.uninstall();
|
|
37
|
+
await server.close();
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function waitForComplete(view) {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
const timeout = setTimeout(() => reject(new Error('timed out waiting for complete query')), 5_000);
|
|
44
|
+
let cleanup = () => { };
|
|
45
|
+
cleanup = view.addListener((data, resultType) => {
|
|
46
|
+
if (resultType !== 'complete')
|
|
47
|
+
return;
|
|
48
|
+
clearTimeout(timeout);
|
|
49
|
+
cleanup();
|
|
50
|
+
resolve(JSON.parse(JSON.stringify(data)));
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export async function eventually(assertion, timeout = 3_000) {
|
|
55
|
+
const started = Date.now();
|
|
56
|
+
let lastError;
|
|
57
|
+
while (Date.now() - started < timeout) {
|
|
58
|
+
try {
|
|
59
|
+
await assertion();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
lastError = error;
|
|
64
|
+
await sleep(10);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
throw lastError;
|
|
68
|
+
}
|
|
69
|
+
export function sleep(ms) {
|
|
70
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=test-harness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-harness.js","sourceRoot":"","sources":["../../src/zero-http/test-harness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAErC,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AACpF,OAAO,EAAE,mBAAmB,EAAY,MAAM,aAAa,CAAA;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AAEzD,IAAI,SAAS,GAAG,CAAC,CAAA;AASjB,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAG1C;IACC,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAC9D,MAAM,SAAS,GAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC9E,MAAM,cAAc,GAAG,IAAI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;IACd,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CACrB,GAAG;IACF,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,SAAS,IAAI,IAAI,CAAA;CAClB,CAgDA"}
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
const COOKIE_WIDTH = 20;
|
|
2
|
+
export function installZeroHttpTransport(opts) {
|
|
3
|
+
const previousWebSocket = globalThis.WebSocket;
|
|
4
|
+
const fetchImpl = opts.fetch ?? globalThis.fetch;
|
|
5
|
+
if (!fetchImpl) {
|
|
6
|
+
throw new Error('installZeroHttpTransport requires a fetch implementation');
|
|
7
|
+
}
|
|
8
|
+
const state = {
|
|
9
|
+
origin: new URL(opts.origin),
|
|
10
|
+
originString: trimTrailingSlash(new URL(opts.origin).toString()),
|
|
11
|
+
fetch: fetchImpl,
|
|
12
|
+
nativeWebSocket: previousWebSocket,
|
|
13
|
+
sockets: new Set(),
|
|
14
|
+
nextPokeID: 0,
|
|
15
|
+
};
|
|
16
|
+
const Shim = class {
|
|
17
|
+
static CONNECTING = 0;
|
|
18
|
+
static OPEN = 1;
|
|
19
|
+
static CLOSING = 2;
|
|
20
|
+
static CLOSED = 3;
|
|
21
|
+
constructor(url, protocols) {
|
|
22
|
+
if (shouldIntercept(state.origin, url)) {
|
|
23
|
+
return new ZeroHttpSocket(state, url, protocols);
|
|
24
|
+
}
|
|
25
|
+
if (!state.nativeWebSocket) {
|
|
26
|
+
throw new Error(`No native WebSocket available for ${String(url)}`);
|
|
27
|
+
}
|
|
28
|
+
return new state.nativeWebSocket(url, protocols);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
globalThis.WebSocket = Shim;
|
|
32
|
+
return {
|
|
33
|
+
pull: async () => {
|
|
34
|
+
await Promise.all([...state.sockets].map((socket) => socket.pull()));
|
|
35
|
+
},
|
|
36
|
+
get connections() {
|
|
37
|
+
return state.sockets.size;
|
|
38
|
+
},
|
|
39
|
+
uninstall: () => {
|
|
40
|
+
if (globalThis.WebSocket === Shim) {
|
|
41
|
+
globalThis.WebSocket = previousWebSocket;
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
class ZeroHttpSocket {
|
|
47
|
+
state;
|
|
48
|
+
CONNECTING = 0;
|
|
49
|
+
OPEN = 1;
|
|
50
|
+
CLOSING = 2;
|
|
51
|
+
CLOSED = 3;
|
|
52
|
+
url;
|
|
53
|
+
readyState = this.CONNECTING;
|
|
54
|
+
connectURL;
|
|
55
|
+
authToken;
|
|
56
|
+
listeners = {
|
|
57
|
+
open: new Set(),
|
|
58
|
+
message: new Set(),
|
|
59
|
+
close: new Set(),
|
|
60
|
+
error: new Set(),
|
|
61
|
+
};
|
|
62
|
+
clientID;
|
|
63
|
+
clientGroupID;
|
|
64
|
+
wsid;
|
|
65
|
+
cookie;
|
|
66
|
+
pendingGotQueriesPatch = [];
|
|
67
|
+
pullInFlight;
|
|
68
|
+
pullAfterCurrent = false;
|
|
69
|
+
pushChain = Promise.resolve();
|
|
70
|
+
nextLocalCookieID = 0;
|
|
71
|
+
openTimer;
|
|
72
|
+
constructor(state, url, protocols) {
|
|
73
|
+
this.state = state;
|
|
74
|
+
this.connectURL = toHttpURL(url);
|
|
75
|
+
this.url = String(url);
|
|
76
|
+
this.clientID = this.connectURL.searchParams.get('clientID') ?? '';
|
|
77
|
+
this.clientGroupID = this.connectURL.searchParams.get('clientGroupID') ?? '';
|
|
78
|
+
this.wsid = this.connectURL.searchParams.get('wsid') ?? `zero-http-${Date.now()}`;
|
|
79
|
+
const baseCookie = this.connectURL.searchParams.get('baseCookie');
|
|
80
|
+
this.cookie = baseCookie ? baseCookie : null;
|
|
81
|
+
const decoded = decodeSecProtocol(protocols);
|
|
82
|
+
this.authToken = decoded.authToken;
|
|
83
|
+
this.queueDesiredQueries(decoded.initConnectionMessage?.[1]);
|
|
84
|
+
this.state.sockets.add(this);
|
|
85
|
+
this.openTimer = setTimeout(() => this.open(), 0);
|
|
86
|
+
}
|
|
87
|
+
addEventListener(type, listener) {
|
|
88
|
+
if (listener)
|
|
89
|
+
this.listeners[type]?.add(listener);
|
|
90
|
+
}
|
|
91
|
+
removeEventListener(type, listener) {
|
|
92
|
+
if (listener)
|
|
93
|
+
this.listeners[type]?.delete(listener);
|
|
94
|
+
}
|
|
95
|
+
dispatchEvent(event) {
|
|
96
|
+
this.emit(event.type, event);
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
send(data) {
|
|
100
|
+
if (this.readyState !== this.OPEN) {
|
|
101
|
+
throw new Error('cannot send on a socket that is not open');
|
|
102
|
+
}
|
|
103
|
+
const message = JSON.parse(data);
|
|
104
|
+
switch (message[0]) {
|
|
105
|
+
case 'initConnection':
|
|
106
|
+
case 'changeDesiredQueries':
|
|
107
|
+
this.queueDesiredQueries(message[1]);
|
|
108
|
+
this.requestPullAfterCurrent();
|
|
109
|
+
return;
|
|
110
|
+
case 'updateAuth':
|
|
111
|
+
this.authToken = message[1].auth;
|
|
112
|
+
return;
|
|
113
|
+
case 'push':
|
|
114
|
+
this.enqueuePush(message[1]);
|
|
115
|
+
return;
|
|
116
|
+
case 'ping':
|
|
117
|
+
this.emitMessage(['pong', {}]);
|
|
118
|
+
return;
|
|
119
|
+
case 'pull':
|
|
120
|
+
this.run(this.answerMutationRecoveryPull(message[1]));
|
|
121
|
+
return;
|
|
122
|
+
case 'deleteClients':
|
|
123
|
+
case 'ackMutationResponses':
|
|
124
|
+
return;
|
|
125
|
+
default:
|
|
126
|
+
throw new Error(`unsupported zero-http upstream message ${message[0]}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
close(code = 1000, reason = '') {
|
|
130
|
+
if (this.readyState === this.CLOSED)
|
|
131
|
+
return;
|
|
132
|
+
if (this.openTimer)
|
|
133
|
+
clearTimeout(this.openTimer);
|
|
134
|
+
this.readyState = this.CLOSED;
|
|
135
|
+
this.state.sockets.delete(this);
|
|
136
|
+
this.emit('close', { code, reason, wasClean: code <= 1001 });
|
|
137
|
+
}
|
|
138
|
+
pull() {
|
|
139
|
+
if (this.readyState === this.CLOSED)
|
|
140
|
+
return Promise.resolve();
|
|
141
|
+
if (this.pullInFlight)
|
|
142
|
+
return this.pullInFlight;
|
|
143
|
+
this.pullInFlight = this.fetchPull(this.clientGroupID, this.cookie)
|
|
144
|
+
.then((response) => {
|
|
145
|
+
if (response.unchanged) {
|
|
146
|
+
this.emitGotQueriesPatch(response.cookie);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
this.emitPoke(response);
|
|
150
|
+
})
|
|
151
|
+
.catch((error) => {
|
|
152
|
+
this.fail(error);
|
|
153
|
+
throw error;
|
|
154
|
+
})
|
|
155
|
+
.finally(async () => {
|
|
156
|
+
const pullAgain = this.pullAfterCurrent;
|
|
157
|
+
this.pullAfterCurrent = false;
|
|
158
|
+
this.pullInFlight = undefined;
|
|
159
|
+
if (pullAgain && this.readyState !== this.CLOSED)
|
|
160
|
+
await this.pull();
|
|
161
|
+
});
|
|
162
|
+
return this.pullInFlight;
|
|
163
|
+
}
|
|
164
|
+
open() {
|
|
165
|
+
if (this.readyState !== this.CONNECTING)
|
|
166
|
+
return;
|
|
167
|
+
this.readyState = this.OPEN;
|
|
168
|
+
this.emit('open', {});
|
|
169
|
+
this.emitMessage(['connected', { wsid: this.wsid, timestamp: Date.now() }]);
|
|
170
|
+
setTimeout(() => this.run(this.pull()), 0);
|
|
171
|
+
}
|
|
172
|
+
queueDesiredQueries(body) {
|
|
173
|
+
const desiredQueriesPatch = body
|
|
174
|
+
?.desiredQueriesPatch;
|
|
175
|
+
if (!Array.isArray(desiredQueriesPatch))
|
|
176
|
+
return;
|
|
177
|
+
this.pendingGotQueriesPatch.push(...gotQueriesPatch(desiredQueriesPatch));
|
|
178
|
+
}
|
|
179
|
+
async push(body) {
|
|
180
|
+
const response = (await this.postJSON('/push', body));
|
|
181
|
+
this.emitMessage(['pushResponse', response.pushResponse]);
|
|
182
|
+
this.requestPullAfterCurrent();
|
|
183
|
+
}
|
|
184
|
+
enqueuePush(body) {
|
|
185
|
+
const nextPush = this.pushChain.then(async () => {
|
|
186
|
+
if (this.readyState === this.CLOSED)
|
|
187
|
+
return;
|
|
188
|
+
await this.push(body);
|
|
189
|
+
});
|
|
190
|
+
this.pushChain = nextPush.catch(() => { });
|
|
191
|
+
this.run(nextPush);
|
|
192
|
+
}
|
|
193
|
+
requestPullAfterCurrent() {
|
|
194
|
+
if (this.pullInFlight) {
|
|
195
|
+
this.pullAfterCurrent = true;
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
this.run(this.pull());
|
|
199
|
+
}
|
|
200
|
+
async answerMutationRecoveryPull(body) {
|
|
201
|
+
const response = await this.fetchPull(body.clientGroupID, body.cookie);
|
|
202
|
+
const cookie = toWebSocketCookie(response.cookie);
|
|
203
|
+
this.emitMessage([
|
|
204
|
+
'pull',
|
|
205
|
+
{
|
|
206
|
+
requestID: body.requestID,
|
|
207
|
+
cookie: cookie ?? this.cookie ?? '0',
|
|
208
|
+
lastMutationIDChanges: response.unchanged ? {} : response.lastMutationIDChanges,
|
|
209
|
+
},
|
|
210
|
+
]);
|
|
211
|
+
}
|
|
212
|
+
async fetchPull(clientGroupID, cookie) {
|
|
213
|
+
return (await this.postJSON('/pull', {
|
|
214
|
+
clientID: this.clientID,
|
|
215
|
+
clientGroupID,
|
|
216
|
+
cookie: toHttpCookie(cookie),
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
async postJSON(path, body) {
|
|
220
|
+
const response = await this.state.fetch(`${this.state.originString}${path}`, {
|
|
221
|
+
method: 'POST',
|
|
222
|
+
headers: {
|
|
223
|
+
authorization: this.authToken ? `Bearer ${this.authToken}` : '',
|
|
224
|
+
'content-type': 'application/json',
|
|
225
|
+
},
|
|
226
|
+
body: JSON.stringify(body),
|
|
227
|
+
});
|
|
228
|
+
if (!response.ok) {
|
|
229
|
+
throw new ZeroHttpResponseError(path, response.status);
|
|
230
|
+
}
|
|
231
|
+
return response.json();
|
|
232
|
+
}
|
|
233
|
+
run(promise) {
|
|
234
|
+
void promise.catch((error) => this.fail(error));
|
|
235
|
+
}
|
|
236
|
+
fail(error) {
|
|
237
|
+
if (this.readyState === this.CLOSED)
|
|
238
|
+
return;
|
|
239
|
+
if (isAuthHTTPError(error)) {
|
|
240
|
+
this.emitMessage([
|
|
241
|
+
'error',
|
|
242
|
+
{
|
|
243
|
+
kind: 'Unauthorized',
|
|
244
|
+
message: error.message,
|
|
245
|
+
origin: 'server',
|
|
246
|
+
},
|
|
247
|
+
]);
|
|
248
|
+
if (this.readyState !== this.CLOSED)
|
|
249
|
+
this.close(1000, error.message);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
this.emit('error', { error });
|
|
253
|
+
this.close(1011, errorMessage(error));
|
|
254
|
+
}
|
|
255
|
+
emitPoke(response) {
|
|
256
|
+
const nextCookie = toWebSocketCookie(response.cookie);
|
|
257
|
+
if (isStaleCookie(this.cookie, response.cookie)) {
|
|
258
|
+
throw new Error(`zero-http pull returned stale cookie ${response.cookie} for ${this.cookie}`);
|
|
259
|
+
}
|
|
260
|
+
const pokeID = `zero-http-${++this.state.nextPokeID}`;
|
|
261
|
+
const gotQueries = this.pendingGotQueriesPatch;
|
|
262
|
+
this.pendingGotQueriesPatch = [];
|
|
263
|
+
this.emitMessage([
|
|
264
|
+
'pokeStart',
|
|
265
|
+
{
|
|
266
|
+
pokeID,
|
|
267
|
+
baseCookie: this.cookie,
|
|
268
|
+
schemaVersions: {
|
|
269
|
+
minSupportedVersion: 1,
|
|
270
|
+
maxSupportedVersion: 1,
|
|
271
|
+
},
|
|
272
|
+
timestamp: Date.now(),
|
|
273
|
+
},
|
|
274
|
+
]);
|
|
275
|
+
this.emitMessage([
|
|
276
|
+
'pokePart',
|
|
277
|
+
{
|
|
278
|
+
pokeID,
|
|
279
|
+
lastMutationIDChanges: response.lastMutationIDChanges,
|
|
280
|
+
rowsPatch: response.rowsPatch,
|
|
281
|
+
},
|
|
282
|
+
]);
|
|
283
|
+
if (gotQueries.length > 0) {
|
|
284
|
+
this.emitMessage([
|
|
285
|
+
'pokePart',
|
|
286
|
+
{
|
|
287
|
+
pokeID,
|
|
288
|
+
gotQueriesPatch: gotQueries,
|
|
289
|
+
},
|
|
290
|
+
]);
|
|
291
|
+
}
|
|
292
|
+
this.emitMessage(['pokeEnd', { pokeID, cookie: nextCookie }]);
|
|
293
|
+
this.cookie = nextCookie;
|
|
294
|
+
}
|
|
295
|
+
emitGotQueriesPatch(cookie) {
|
|
296
|
+
if (this.pendingGotQueriesPatch.length === 0)
|
|
297
|
+
return;
|
|
298
|
+
const serverCookie = cookie ?? toHttpCookie(this.cookie);
|
|
299
|
+
if (serverCookie === null)
|
|
300
|
+
return;
|
|
301
|
+
const nextCookie = toLocalWebSocketCookie(serverCookie, ++this.nextLocalCookieID);
|
|
302
|
+
const pokeID = `zero-http-${++this.state.nextPokeID}`;
|
|
303
|
+
const gotQueries = this.pendingGotQueriesPatch;
|
|
304
|
+
this.pendingGotQueriesPatch = [];
|
|
305
|
+
this.emitMessage([
|
|
306
|
+
'pokeStart',
|
|
307
|
+
{
|
|
308
|
+
pokeID,
|
|
309
|
+
baseCookie: this.cookie,
|
|
310
|
+
schemaVersions: {
|
|
311
|
+
minSupportedVersion: 1,
|
|
312
|
+
maxSupportedVersion: 1,
|
|
313
|
+
},
|
|
314
|
+
timestamp: Date.now(),
|
|
315
|
+
},
|
|
316
|
+
]);
|
|
317
|
+
this.emitMessage([
|
|
318
|
+
'pokePart',
|
|
319
|
+
{
|
|
320
|
+
pokeID,
|
|
321
|
+
gotQueriesPatch: gotQueries,
|
|
322
|
+
},
|
|
323
|
+
]);
|
|
324
|
+
this.emitMessage(['pokeEnd', { pokeID, cookie: nextCookie }]);
|
|
325
|
+
this.cookie = nextCookie;
|
|
326
|
+
}
|
|
327
|
+
emitMessage(message) {
|
|
328
|
+
if (this.readyState !== this.OPEN)
|
|
329
|
+
return;
|
|
330
|
+
this.emit('message', { data: JSON.stringify(message) });
|
|
331
|
+
}
|
|
332
|
+
emit(type, event) {
|
|
333
|
+
const handler = this[`on${type}`];
|
|
334
|
+
if (typeof handler === 'function')
|
|
335
|
+
handler.call(this, event);
|
|
336
|
+
for (const listener of this.listeners[type]) {
|
|
337
|
+
if (typeof listener === 'function')
|
|
338
|
+
listener(event);
|
|
339
|
+
else
|
|
340
|
+
listener.handleEvent(event);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
function shouldIntercept(origin, url) {
|
|
345
|
+
const candidate = toHttpURL(url);
|
|
346
|
+
if (candidate.origin !== origin.origin)
|
|
347
|
+
return false;
|
|
348
|
+
return candidate.pathname === `${trimTrailingSlash(origin.pathname)}/sync/v51/connect`;
|
|
349
|
+
}
|
|
350
|
+
function toHttpURL(url) {
|
|
351
|
+
const parsed = new URL(url);
|
|
352
|
+
if (parsed.protocol === 'ws:')
|
|
353
|
+
parsed.protocol = 'http:';
|
|
354
|
+
if (parsed.protocol === 'wss:')
|
|
355
|
+
parsed.protocol = 'https:';
|
|
356
|
+
return parsed;
|
|
357
|
+
}
|
|
358
|
+
function trimTrailingSlash(value) {
|
|
359
|
+
return value.endsWith('/') ? value.slice(0, -1) : value;
|
|
360
|
+
}
|
|
361
|
+
function decodeSecProtocol(protocols) {
|
|
362
|
+
const protocol = Array.isArray(protocols) ? protocols[0] : protocols;
|
|
363
|
+
if (!protocol)
|
|
364
|
+
return {};
|
|
365
|
+
try {
|
|
366
|
+
const decoded = decodeURIComponent(protocol);
|
|
367
|
+
const json = new TextDecoder().decode(Uint8Array.from(globalThis.atob(decoded), (char) => char.charCodeAt(0)));
|
|
368
|
+
const parsed = JSON.parse(json);
|
|
369
|
+
return {
|
|
370
|
+
authToken: parsed.authToken,
|
|
371
|
+
initConnectionMessage: Array.isArray(parsed.initConnectionMessage)
|
|
372
|
+
? parsed.initConnectionMessage
|
|
373
|
+
: undefined,
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
catch {
|
|
377
|
+
return {};
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function gotQueriesPatch(patch) {
|
|
381
|
+
const got = [];
|
|
382
|
+
for (const op of patch) {
|
|
383
|
+
if (op.op === 'clear')
|
|
384
|
+
got.push({ op: 'clear' });
|
|
385
|
+
else if (op.hash)
|
|
386
|
+
got.push({ op: op.op, hash: op.hash });
|
|
387
|
+
}
|
|
388
|
+
return got;
|
|
389
|
+
}
|
|
390
|
+
function toHttpCookie(cookie) {
|
|
391
|
+
if (cookie === null || cookie === '')
|
|
392
|
+
return null;
|
|
393
|
+
const parsed = Number(cookie.slice(0, COOKIE_WIDTH));
|
|
394
|
+
if (!Number.isFinite(parsed)) {
|
|
395
|
+
throw new Error(`zero-http cookie is not numeric: ${cookie}`);
|
|
396
|
+
}
|
|
397
|
+
return parsed;
|
|
398
|
+
}
|
|
399
|
+
function toWebSocketCookie(cookie) {
|
|
400
|
+
return cookie === null ? null : String(cookie).padStart(COOKIE_WIDTH, '0');
|
|
401
|
+
}
|
|
402
|
+
function toLocalWebSocketCookie(cookie, localID) {
|
|
403
|
+
return `${String(cookie).padStart(COOKIE_WIDTH, '0')}#${String(localID).padStart(6, '0')}`;
|
|
404
|
+
}
|
|
405
|
+
function isStaleCookie(current, next) {
|
|
406
|
+
const currentNumber = toHttpCookie(current);
|
|
407
|
+
return currentNumber !== null && next <= currentNumber;
|
|
408
|
+
}
|
|
409
|
+
function errorMessage(error) {
|
|
410
|
+
return error instanceof Error ? error.message : String(error);
|
|
411
|
+
}
|
|
412
|
+
class ZeroHttpResponseError extends Error {
|
|
413
|
+
path;
|
|
414
|
+
status;
|
|
415
|
+
constructor(path, status) {
|
|
416
|
+
super(`zero-http ${path} failed with ${status}`);
|
|
417
|
+
this.path = path;
|
|
418
|
+
this.status = status;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
function isAuthHTTPError(error) {
|
|
422
|
+
return (error instanceof ZeroHttpResponseError &&
|
|
423
|
+
(error.status === 401 || error.status === 403));
|
|
424
|
+
}
|
|
425
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/zero-http/transport.ts"],"names":[],"mappings":"AAuCA,MAAM,YAAY,GAAG,EAAE,CAAA;AAEvB,MAAM,UAAU,wBAAwB,CAAC,IAGxC;IAKC,MAAM,iBAAiB,GAAG,UAAU,CAAC,SAA6C,CAAA;IAClF,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAA;IAChD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAA;IAC7E,CAAC;IAED,MAAM,KAAK,GAAmB;QAC5B,MAAM,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;QAC5B,YAAY,EAAE,iBAAiB,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;QAChE,KAAK,EAAE,SAAS;QAChB,eAAe,EAAE,iBAAiB;QAClC,OAAO,EAAE,IAAI,GAAG,EAAE;QAClB,UAAU,EAAE,CAAC;KACd,CAAA;IAED,MAAM,IAAI,GAAG;QACX,MAAM,CAAC,UAAU,GAAG,CAAC,CAAA;QACrB,MAAM,CAAC,IAAI,GAAG,CAAC,CAAA;QACf,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;QAClB,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;QAEjB,YAAY,GAAiB,EAAE,SAA8B;YAC3D,IAAI,eAAe,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;gBACvC,OAAO,IAAI,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,CAAA;YAClD,CAAC;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,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAC9E,CAAC,EACD,GAAG,CACJ,EAAE,CAAA;AACL,CAAC;AAED,SAAS,aAAa,CAAC,OAAsB,EAAE,IAAY;IACzD,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;IAC3C,OAAO,aAAa,KAAK,IAAI,IAAI,IAAI,IAAI,aAAa,CAAA;AACxD,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC/D,CAAC;AAED,MAAM,qBAAsB,SAAQ,KAAK;IAE5B;IACA;IAFX,YACW,IAAuB,EACvB,MAAc;QAEvB,KAAK,CAAC,aAAa,IAAI,gBAAgB,MAAM,EAAE,CAAC,CAAA;QAHvC,SAAI,GAAJ,IAAI,CAAmB;QACvB,WAAM,GAAN,MAAM,CAAQ;IAGzB,CAAC;CACF;AAED,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,CACL,KAAK,YAAY,qBAAqB;QACtC,CAAC,KAAK,CAAC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,CAAC,CAC/C,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orez",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.11",
|
|
4
4
|
"description": "PGlite-powered zero-sync development backend. No Docker required.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"@electric-sql/pglite": "0.4.1",
|
|
88
88
|
"@electric-sql/pglite-tools": "^0.3.1",
|
|
89
89
|
"@pgsql/traverse": "17.2.6",
|
|
90
|
-
"bedrock-sqlite": "0.4.
|
|
90
|
+
"bedrock-sqlite": "0.4.11",
|
|
91
91
|
"citty": "^0.2.0",
|
|
92
92
|
"pg-gateway": "0.3.0-beta.4",
|
|
93
93
|
"pgsql-parser": "^17.9.11",
|