mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-12-05 19:25:00 +03:00
Move the legacy cloud codecs into a host adapter. Use typed account and document routes for remote operations. Match durable receipts to each local write sequence. Check the client dependency graphs and source boundaries in CI.
84 lines
2.5 KiB
JavaScript
84 lines
2.5 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { test } from 'node:test';
|
|
|
|
import { checkNormalDependencies, checkWireSources } from './client-compat.mjs';
|
|
|
|
void test('the source gate rejects protocol syntax and untracked or duplicate markers', () => {
|
|
for (const source of [
|
|
'"space:load-doc"',
|
|
'SocketIoPacket',
|
|
'EngineIoOutput',
|
|
'"/graphql"',
|
|
'"affine_session"',
|
|
'"x-affine-version"',
|
|
'"/api/auth/sign-in"',
|
|
'"/api/oauth/start"',
|
|
'"affine_csrf_token"',
|
|
'"x-affine-client-kind"',
|
|
'"x-affine-refresh-attempt"',
|
|
]) {
|
|
for (const [suffix, docs, errors] of [
|
|
['', '', 1],
|
|
[' // compat(client-0275): old-wire', '', 1],
|
|
[' // compat(client-0275): old-wire', '### old-wire', 0],
|
|
]) {
|
|
const result = checkWireSources([['core.rs', source + suffix]], docs);
|
|
assert.equal(result.errors.length, errors, source + suffix);
|
|
}
|
|
}
|
|
const source = '"space:x" // compat(client-0275): duplicate';
|
|
assert.equal(
|
|
checkWireSources([['core.rs', `${source}\n${source}`]], '### duplicate')
|
|
.errors.length,
|
|
1
|
|
);
|
|
});
|
|
|
|
void test('the graph gate follows transitive normal edges for each platform', () => {
|
|
const members = [
|
|
'affine-store',
|
|
'affine-client',
|
|
'affine-desktop',
|
|
'affine-mobile',
|
|
'blocksuite-playground-doc',
|
|
'blocksuite-editor',
|
|
'playground',
|
|
'blocksuite-preview',
|
|
'affine-compat-v027',
|
|
];
|
|
for (const [name, kind, wasm, errors] of [
|
|
['affine-compat-v027', null, false, 1],
|
|
['affine-compat-v027', null, true, 1],
|
|
['affine-compat-v027', 'dev', false, 0],
|
|
['affine-compat-v027', 'build', true, 0],
|
|
['tokio', null, false, 0],
|
|
['tokio', null, true, 1],
|
|
['reqwest', null, true, 1],
|
|
['hyper', null, true, 1],
|
|
['rustls', null, true, 1],
|
|
...['graphql_client', 'tokio-tungstenite', 'openssl', 'native-tls'].map(
|
|
name => [name, null, true, 1]
|
|
),
|
|
]) {
|
|
const edge = (pkg, kind) => ({ pkg, dep_kinds: [{ kind }] });
|
|
const packages = [...new Set([...members, 'indirect', name])].map(id => ({
|
|
id,
|
|
name: id,
|
|
}));
|
|
const nodes = packages.map(({ id }) => ({
|
|
id,
|
|
deps:
|
|
id === 'affine-store'
|
|
? [edge('indirect', null)]
|
|
: id === 'indirect'
|
|
? [edge(name, kind)]
|
|
: [],
|
|
}));
|
|
const actual = checkNormalDependencies(
|
|
{ packages, workspace_members: members, resolve: { nodes } },
|
|
wasm
|
|
);
|
|
assert.equal(actual.length, errors, [name, kind, wasm].join(','));
|
|
}
|
|
});
|