@antelopejs/rethinkdb 1.4.1 → 1.6.0
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/README.md +34 -14
- package/dist/config.d.ts +25 -0
- package/dist/config.js +106 -0
- package/dist/config.js.map +1 -0
- package/dist/connection.d.ts +16 -1
- package/dist/connection.js +95 -6
- package/dist/connection.js.map +1 -1
- package/dist/implementations/catalog/discovery.d.ts +11 -0
- package/dist/implementations/catalog/discovery.js +209 -0
- package/dist/implementations/catalog/discovery.js.map +1 -0
- package/dist/implementations/catalog/index.d.ts +7 -0
- package/dist/implementations/catalog/index.js +65 -0
- package/dist/implementations/catalog/index.js.map +1 -0
- package/dist/implementations/catalog/locate.d.ts +10 -0
- package/dist/implementations/catalog/locate.js +36 -0
- package/dist/implementations/catalog/locate.js.map +1 -0
- package/dist/implementations/catalog/measures.d.ts +21 -0
- package/dist/implementations/catalog/measures.js +126 -0
- package/dist/implementations/catalog/measures.js.map +1 -0
- package/dist/implementations/catalog/profile.d.ts +2 -0
- package/dist/implementations/catalog/profile.js +218 -0
- package/dist/implementations/catalog/profile.js.map +1 -0
- package/dist/implementations/catalog/reference.d.ts +2 -0
- package/dist/implementations/catalog/reference.js +63 -0
- package/dist/implementations/catalog/reference.js.map +1 -0
- package/dist/implementations/catalog/rows.d.ts +2 -0
- package/dist/implementations/catalog/rows.js +44 -0
- package/dist/implementations/catalog/rows.js.map +1 -0
- package/dist/implementations/catalog/text.d.ts +4 -0
- package/dist/implementations/catalog/text.js +13 -0
- package/dist/implementations/catalog/text.js.map +1 -0
- package/dist/implementations/database/atomic.d.ts +1 -1
- package/dist/implementations/database/atomic.js +17 -10
- package/dist/implementations/database/atomic.js.map +1 -1
- package/dist/implementations/database/expression.js +1 -1
- package/dist/implementations/database/expression.js.map +1 -1
- package/dist/implementations/database/external-descriptor.d.ts +36 -0
- package/dist/implementations/database/external-descriptor.js +154 -0
- package/dist/implementations/database/external-descriptor.js.map +1 -0
- package/dist/implementations/database/external-probe.d.ts +26 -0
- package/dist/implementations/database/external-probe.js +89 -0
- package/dist/implementations/database/external-probe.js.map +1 -0
- package/dist/implementations/database/external-read.d.ts +11 -0
- package/dist/implementations/database/external-read.js +123 -0
- package/dist/implementations/database/external-read.js.map +1 -0
- package/dist/implementations/database/external-registration.d.ts +4 -0
- package/dist/implementations/database/external-registration.js +18 -0
- package/dist/implementations/database/external-registration.js.map +1 -0
- package/dist/implementations/database/external-selection.d.ts +25 -0
- package/dist/implementations/database/external-selection.js +230 -0
- package/dist/implementations/database/external-selection.js.map +1 -0
- package/dist/implementations/database/external-writes.d.ts +14 -0
- package/dist/implementations/database/external-writes.js +355 -0
- package/dist/implementations/database/external-writes.js.map +1 -0
- package/dist/implementations/database/indexes.d.ts +1 -0
- package/dist/implementations/database/indexes.js +9 -0
- package/dist/implementations/database/indexes.js.map +1 -1
- package/dist/implementations/database/initialize.js.map +1 -1
- package/dist/implementations/database/query.js +67 -15
- package/dist/implementations/database/query.js.map +1 -1
- package/dist/implementations/database/schema.d.ts +2 -0
- package/dist/implementations/database/schema.js +22 -0
- package/dist/implementations/database/schema.js.map +1 -1
- package/dist/implementations/database/selection-stages.d.ts +5 -0
- package/dist/implementations/database/selection-stages.js +110 -0
- package/dist/implementations/database/selection-stages.js.map +1 -0
- package/dist/implementations/database/selection.d.ts +10 -3
- package/dist/implementations/database/selection.js +67 -91
- package/dist/implementations/database/selection.js.map +1 -1
- package/dist/implementations/database/stream.d.ts +4 -1
- package/dist/implementations/database/stream.js +30 -16
- package/dist/implementations/database/stream.js.map +1 -1
- package/dist/implementations/database/utils.d.ts +3 -0
- package/dist/implementations/database/utils.js +12 -0
- package/dist/implementations/database/utils.js.map +1 -1
- package/dist/implementations/rethinkdb/index.d.ts +1 -1
- package/dist/implementations/rethinkdb/index.js.map +1 -1
- package/dist/index.d.ts +3 -7
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/test/antelope.test.js +28 -12
- package/dist/test/antelope.test.js.map +1 -1
- package/dist/test/atomic-mutation.test.js.map +1 -1
- package/dist/test/instance-indexes.test.js +8 -0
- package/dist/test/instance-indexes.test.js.map +1 -1
- package/dist/test/primitive-guards.test.d.ts +1 -0
- package/dist/test/primitive-guards.test.js +49 -0
- package/dist/test/primitive-guards.test.js.map +1 -0
- package/dist/test/write-results.test.js +9 -3
- package/dist/test/write-results.test.js.map +1 -1
- package/dist/test-external/catalog.test.d.ts +1 -0
- package/dist/test-external/catalog.test.js +136 -0
- package/dist/test-external/catalog.test.js.map +1 -0
- package/dist/test-external/erp.d.ts +18 -0
- package/dist/test-external/erp.js +74 -0
- package/dist/test-external/erp.js.map +1 -0
- package/dist/test-external/fixture.d.ts +12 -0
- package/dist/test-external/fixture.js +182 -0
- package/dist/test-external/fixture.js.map +1 -0
- package/dist/test-external/reads.test.d.ts +1 -0
- package/dist/test-external/reads.test.js +220 -0
- package/dist/test-external/reads.test.js.map +1 -0
- package/dist/test-external/refusals.test.d.ts +1 -0
- package/dist/test-external/refusals.test.js +53 -0
- package/dist/test-external/refusals.test.js.map +1 -0
- package/dist/test-external/startup.test.d.ts +1 -0
- package/dist/test-external/startup.test.js +41 -0
- package/dist/test-external/startup.test.js.map +1 -0
- package/dist/test-external/writes.test.d.ts +1 -0
- package/dist/test-external/writes.test.js +179 -0
- package/dist/test-external/writes.test.js.map +1 -0
- package/dist/write-result.js +10 -1
- package/dist/write-result.js.map +1 -1
- package/package.json +23 -7
package/README.md
CHANGED
|
@@ -11,10 +11,11 @@ The RethinkDB backend of AntelopeJS: it runs the database interface's queries on
|
|
|
11
11
|
|
|
12
12
|
## Interfaces
|
|
13
13
|
|
|
14
|
-
| Interface
|
|
15
|
-
|
|
|
16
|
-
| [`@antelopejs/interface-database`](https://github.com/AntelopeJS/interface-database)
|
|
17
|
-
| [`@antelopejs/interface-rethinkdb`](https://github.com/AntelopeJS/interface-rethinkdb)
|
|
14
|
+
| Interface | Documentation |
|
|
15
|
+
| ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
|
|
16
|
+
| [`@antelopejs/interface-database`](https://github.com/AntelopeJS/interface-database) | [Database](https://interfaces.antelopejs.com/docs/database) |
|
|
17
|
+
| [`@antelopejs/interface-rethinkdb`](https://github.com/AntelopeJS/interface-rethinkdb) | [RethinkDB](https://interfaces.antelopejs.com/docs/rethinkdb/introduction) |
|
|
18
|
+
| [`@antelopejs/interface-database-catalog`](https://github.com/AntelopeJS/interface-database-catalog) | [External mode](docs/external-mode.md#the-catalog) |
|
|
18
19
|
|
|
19
20
|
Schemas, tables, queries, change feeds and atomic mutations are documented on the database interface pages.
|
|
20
21
|
|
|
@@ -67,12 +68,16 @@ config: {
|
|
|
67
68
|
},
|
|
68
69
|
```
|
|
69
70
|
|
|
70
|
-
| Key
|
|
71
|
-
|
|
|
72
|
-
| `pool`
|
|
73
|
-
| `connection`
|
|
71
|
+
| Key | Description |
|
|
72
|
+
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
73
|
+
| `pool` | `rethinkdb-ts` pool options (`RPoolConnectionOptions`), passed to `r.connectPool()`. |
|
|
74
|
+
| `connection` | `rethinkdb-ts` connection options (`RConnectionOptions`), passed to `r.connect()`. Used when `pool` is unset. |
|
|
75
|
+
| `url` | `rethinkdb://user:password@host:port/database`, parsed into pool options. Required in external mode. |
|
|
76
|
+
| `mode` | `owned` (default): the module creates a database per schema and scopes rows to instances. `external`: it serves a database it did not create, see [External mode](docs/external-mode.md). |
|
|
77
|
+
| `statementTimeoutMs` | Time limit of each read of an external instance, enforced by closing that read's connection. |
|
|
78
|
+
| `catalog` | `{ enabled?: boolean }`: whether an external instance answers the catalog outside development. |
|
|
74
79
|
|
|
75
|
-
The module refuses to start when
|
|
80
|
+
The module refuses to start when none of `url`, `pool` and `connection` is set. The option types come from [`rethinkdb-ts`](https://github.com/rethinkdb/rethinkdb-ts).
|
|
76
81
|
|
|
77
82
|
## Quick start
|
|
78
83
|
|
|
@@ -90,6 +95,8 @@ To use the driver directly instead, add `@antelopejs/interface-rethinkdb` and re
|
|
|
90
95
|
|
|
91
96
|
- Each schema is a RethinkDB database, and each schema table is a table in it. Every table has a `tenant_id` index that scopes it to one instance.
|
|
92
97
|
- Each declared index `<name>` becomes a `<name>__i` index led by the instance. An index declared with `crossInstance: true` also gets an unprefixed `<name>` index for `CROSS_INSTANCE` queries; without it, those queries scan the table and log a one-time warning. Index names ending in `__i` are reserved.
|
|
98
|
+
- The primary key is the `_id` field, shared by all instances of a table: inserting an `_id` that any instance already uses throws a `DuplicateKeyError` on `_id`.
|
|
99
|
+
- RethinkDB cannot enforce unique secondary indexes, so schema initialization refuses a table that declares an index with `unique: true` and names the schema, table and index.
|
|
93
100
|
- Schema initialization creates missing databases, tables and indexes, retries up to five times, and waits for the indexes before the schema accepts queries.
|
|
94
101
|
|
|
95
102
|
Version 1.4 added the `<name>__i` indexes. The first boot after an upgrade builds them, which takes longer on large tables. The module never drops an index: drop the old ones you no longer need by hand, for example `r.db("<schema>").table("<table>").indexDrop("<name>")`.
|
|
@@ -98,15 +105,28 @@ Version 1.4 added the `<name>__i` indexes. The first boot after an upgrade build
|
|
|
98
105
|
|
|
99
106
|
- [Database](https://interfaces.antelopejs.com/docs/database): the `@antelopejs/interface-database` contract this module implements
|
|
100
107
|
- [RethinkDB](https://interfaces.antelopejs.com/docs/rethinkdb/introduction): the `@antelopejs/interface-rethinkdb` contract this module implements
|
|
108
|
+
- [External mode](docs/external-mode.md): serving a database the module did not create, and its catalog
|
|
101
109
|
- [Configuration](https://framework.antelopejs.com/docs/concepts/configuration): module sources, `config` blocks and config variables in `antelope.config.ts`
|
|
102
110
|
|
|
103
111
|
## Compatibility
|
|
104
112
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
|
108
|
-
|
|
|
109
|
-
| `@antelopejs/interface-core`
|
|
113
|
+
<!-- antelopejs-docs-compat:start -->
|
|
114
|
+
|
|
115
|
+
| Package | Supported | Tested with |
|
|
116
|
+
| ---------------------------------------- | ---------------- | ----------- |
|
|
117
|
+
| `@antelopejs/interface-core` | `>=0.2.4 <1.0.0` | `0.2.4` |
|
|
118
|
+
| `@antelopejs/interface-database` | `>=0.2.0 <0.3.0` | `0.2.0` |
|
|
119
|
+
| `@antelopejs/interface-database-catalog` | `>=0.0.3 <0.1.0` | `0.0.3` |
|
|
120
|
+
| `@antelopejs/interface-rethinkdb` | `>=0.1.0 <0.2.0` | `0.1.0` |
|
|
121
|
+
|
|
122
|
+
<!-- antelopejs-docs-compat:end -->
|
|
123
|
+
|
|
124
|
+
| Package | Supported range |
|
|
125
|
+
| ---------------------------------------- | ---------------- |
|
|
126
|
+
| `@antelopejs/interface-database` | `>=0.2.0 <0.3.0` |
|
|
127
|
+
| `@antelopejs/interface-rethinkdb` | `>=0.1.0 <0.2.0` |
|
|
128
|
+
| `@antelopejs/interface-database-catalog` | `>=0.0.3 <0.1.0` |
|
|
129
|
+
| `@antelopejs/interface-core` | `>=0.2.4 <1.0.0` |
|
|
110
130
|
|
|
111
131
|
The module is developed and tested against `@antelopejs/core` `^1.13.4` on Node.js 24, with `rethinkdb-ts` `^2.7.0` and RethinkDB 2.4.
|
|
112
132
|
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RConnectionOptions, RPoolConnectionOptions } from "rethinkdb-ts";
|
|
2
|
+
export type Mode = "owned" | "external";
|
|
3
|
+
export interface CatalogOptions {
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface Options {
|
|
7
|
+
mode?: Mode;
|
|
8
|
+
url?: string;
|
|
9
|
+
connection?: RConnectionOptions;
|
|
10
|
+
pool?: RPoolConnectionOptions;
|
|
11
|
+
statementTimeoutMs?: number;
|
|
12
|
+
catalog?: CatalogOptions;
|
|
13
|
+
}
|
|
14
|
+
export interface ResolvedOptions {
|
|
15
|
+
mode: Mode;
|
|
16
|
+
pool?: RPoolConnectionOptions;
|
|
17
|
+
connection?: RConnectionOptions;
|
|
18
|
+
database?: string;
|
|
19
|
+
statementTimeoutMs?: number;
|
|
20
|
+
catalog: CatalogOptions;
|
|
21
|
+
}
|
|
22
|
+
export declare function SetOptions(options?: Options): ResolvedOptions;
|
|
23
|
+
export declare function GetOptions(): ResolvedOptions;
|
|
24
|
+
export declare function IsExternal(): boolean;
|
|
25
|
+
export declare function ExternalDatabaseName(): string;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SetOptions = SetOptions;
|
|
4
|
+
exports.GetOptions = GetOptions;
|
|
5
|
+
exports.IsExternal = IsExternal;
|
|
6
|
+
exports.ExternalDatabaseName = ExternalDatabaseName;
|
|
7
|
+
const DEFAULT_MODE = "owned";
|
|
8
|
+
const MODES = ["owned", "external"];
|
|
9
|
+
const URL_PROTOCOL = "rethinkdb:";
|
|
10
|
+
const DEFAULT_PORT = 28015;
|
|
11
|
+
const SMALLEST_POSITIVE_INTEGER = 1;
|
|
12
|
+
const POOL_DEFAULTS = {
|
|
13
|
+
pool: true,
|
|
14
|
+
cursor: false,
|
|
15
|
+
silent: true,
|
|
16
|
+
discovery: false,
|
|
17
|
+
};
|
|
18
|
+
const NOT_CONFIGURED = "RethinkDB adapter is not configured: construct() has not run yet";
|
|
19
|
+
let resolved;
|
|
20
|
+
function ResolveMode(options) {
|
|
21
|
+
const mode = options?.mode ?? DEFAULT_MODE;
|
|
22
|
+
if (!MODES.includes(mode)) {
|
|
23
|
+
throw new Error(`mode must be one of ${MODES.join(", ")}, received ${String(mode)}`);
|
|
24
|
+
}
|
|
25
|
+
return mode;
|
|
26
|
+
}
|
|
27
|
+
function ParseUrl(url) {
|
|
28
|
+
const parsed = new URL(url);
|
|
29
|
+
if (parsed.protocol !== URL_PROTOCOL) {
|
|
30
|
+
throw new Error(`url must start with rethinkdb://, received ${parsed.protocol}//`);
|
|
31
|
+
}
|
|
32
|
+
const database = decodeURIComponent(parsed.pathname.replace(/^\//, ""));
|
|
33
|
+
return {
|
|
34
|
+
connection: {
|
|
35
|
+
host: parsed.hostname,
|
|
36
|
+
port: parsed.port ? Number(parsed.port) : DEFAULT_PORT,
|
|
37
|
+
user: decodeURIComponent(parsed.username) || "admin",
|
|
38
|
+
password: decodeURIComponent(parsed.password),
|
|
39
|
+
},
|
|
40
|
+
database: database === "" ? undefined : database,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function ExternalDatabase(options, parsed) {
|
|
44
|
+
if (!parsed) {
|
|
45
|
+
throw new Error(`mode "external" needs a non-empty config.url; set it through the project's envOverrides`);
|
|
46
|
+
}
|
|
47
|
+
if (!parsed.database) {
|
|
48
|
+
throw new Error(`mode "external" needs the database as the path of config.url`);
|
|
49
|
+
}
|
|
50
|
+
const poolDatabase = options?.pool?.db;
|
|
51
|
+
if (poolDatabase !== undefined && poolDatabase !== parsed.database) {
|
|
52
|
+
throw new Error(`pool.db (${poolDatabase}) disagrees with the database of config.url (${parsed.database})`);
|
|
53
|
+
}
|
|
54
|
+
return parsed.database;
|
|
55
|
+
}
|
|
56
|
+
function PositiveSafeInteger(option, supplied) {
|
|
57
|
+
if (supplied === undefined) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
if (!Number.isSafeInteger(supplied) || supplied < SMALLEST_POSITIVE_INTEGER) {
|
|
61
|
+
throw new Error(`${option} must be a positive safe integer, received ${supplied}`);
|
|
62
|
+
}
|
|
63
|
+
return supplied;
|
|
64
|
+
}
|
|
65
|
+
function UrlOf(options) {
|
|
66
|
+
return options?.url !== undefined && options.url.trim() !== ""
|
|
67
|
+
? ParseUrl(options.url)
|
|
68
|
+
: undefined;
|
|
69
|
+
}
|
|
70
|
+
function SetOptions(options) {
|
|
71
|
+
const mode = ResolveMode(options);
|
|
72
|
+
const parsed = UrlOf(options);
|
|
73
|
+
const database = mode === "external" ? ExternalDatabase(options, parsed) : undefined;
|
|
74
|
+
const pool = parsed
|
|
75
|
+
? { ...POOL_DEFAULTS, ...options?.pool, ...parsed.connection }
|
|
76
|
+
: options?.pool;
|
|
77
|
+
if (!pool && !options?.connection) {
|
|
78
|
+
throw new Error("Invalid RethinkDB options: set url, pool or connection");
|
|
79
|
+
}
|
|
80
|
+
resolved = {
|
|
81
|
+
mode,
|
|
82
|
+
pool,
|
|
83
|
+
connection: pool ? undefined : options?.connection,
|
|
84
|
+
database,
|
|
85
|
+
statementTimeoutMs: PositiveSafeInteger("statementTimeoutMs", options?.statementTimeoutMs),
|
|
86
|
+
catalog: options?.catalog ?? {},
|
|
87
|
+
};
|
|
88
|
+
return resolved;
|
|
89
|
+
}
|
|
90
|
+
function GetOptions() {
|
|
91
|
+
if (!resolved) {
|
|
92
|
+
throw new Error(NOT_CONFIGURED);
|
|
93
|
+
}
|
|
94
|
+
return resolved;
|
|
95
|
+
}
|
|
96
|
+
function IsExternal() {
|
|
97
|
+
return GetOptions().mode === "external";
|
|
98
|
+
}
|
|
99
|
+
function ExternalDatabaseName() {
|
|
100
|
+
const database = GetOptions().database;
|
|
101
|
+
if (!database) {
|
|
102
|
+
throw new Error("ExternalDatabaseName() is only defined on an external instance");
|
|
103
|
+
}
|
|
104
|
+
return database;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;AA0JA,gCAuBC;AAED,gCAKC;AAGD,gCAEC;AAGD,oDAQC;AA7ID,MAAM,YAAY,GAAS,OAAO,CAAC;AACnC,MAAM,KAAK,GAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AACrD,MAAM,YAAY,GAAG,YAAY,CAAC;AAClC,MAAM,YAAY,GAAG,KAAK,CAAC;AAC3B,MAAM,yBAAyB,GAAG,CAAC,CAAC;AACpC,MAAM,aAAa,GAA2B;IAC5C,IAA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AC;AAClB,CAAC"}
|
package/dist/connection.d.ts
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
|
+
import { type Connection, type RConnectionOptions, type RPoolConnectionOptions, type RunOptions } from "rethinkdb-ts";
|
|
1
2
|
import type { Cursor } from "rethinkdb-ts/lib/response/cursor";
|
|
2
3
|
import type { TermJson } from "rethinkdb-ts/lib/internal-types";
|
|
3
|
-
import { type RConnectionOptions, type RPoolConnectionOptions, type RunOptions } from "rethinkdb-ts";
|
|
4
4
|
export declare function ConnectDirect(options: RConnectionOptions): Promise<void>;
|
|
5
5
|
export declare function ConnectPool(options: RPoolConnectionOptions): Promise<void>;
|
|
6
6
|
export declare function Disconnect(): void;
|
|
7
7
|
export declare function SendQuery(query: TermJson, opts?: RunOptions): Promise<Cursor | undefined>;
|
|
8
8
|
export declare function executeTermJson(term: TermJson): Promise<any>;
|
|
9
|
+
export declare class QueryTimeoutError extends Error {
|
|
10
|
+
readonly status = "timeout";
|
|
11
|
+
constructor(timeoutMs: number);
|
|
12
|
+
}
|
|
13
|
+
export declare function SetDirectOptions(options: RConnectionOptions): void;
|
|
14
|
+
export interface BoundedCursor {
|
|
15
|
+
cursor: Cursor;
|
|
16
|
+
arm: () => void;
|
|
17
|
+
disarm: () => void;
|
|
18
|
+
release: () => void;
|
|
19
|
+
expired: () => boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function OpenBoundedCursor(term: TermJson, timeoutMs: number): Promise<BoundedCursor>;
|
|
22
|
+
export declare function DirectConnection(): Promise<Connection>;
|
|
23
|
+
export declare function executeBounded(term: TermJson, timeoutMs: number): Promise<any>;
|
package/dist/connection.js
CHANGED
|
@@ -3,23 +3,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.QueryTimeoutError = void 0;
|
|
6
7
|
exports.ConnectDirect = ConnectDirect;
|
|
7
8
|
exports.ConnectPool = ConnectPool;
|
|
8
9
|
exports.Disconnect = Disconnect;
|
|
9
10
|
exports.SendQuery = SendQuery;
|
|
10
11
|
exports.executeTermJson = executeTermJson;
|
|
12
|
+
exports.SetDirectOptions = SetDirectOptions;
|
|
13
|
+
exports.OpenBoundedCursor = OpenBoundedCursor;
|
|
14
|
+
exports.DirectConnection = DirectConnection;
|
|
15
|
+
exports.executeBounded = executeBounded;
|
|
11
16
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
12
|
-
const term_backtrace_1 = require("rethinkdb-ts/lib/error/term-backtrace");
|
|
13
17
|
const rethinkdb_ts_1 = require("rethinkdb-ts");
|
|
18
|
+
const term_backtrace_1 = require("rethinkdb-ts/lib/error/term-backtrace");
|
|
19
|
+
const connection_1 = require("rethinkdb-ts/lib/connection/connection");
|
|
20
|
+
const master_pool_1 = require("rethinkdb-ts/lib/connection/master-pool");
|
|
14
21
|
const logger_1 = require("./utils/logger");
|
|
15
22
|
const write_result_1 = require("./write-result");
|
|
16
23
|
let connection;
|
|
24
|
+
async function OpenConnection(options) {
|
|
25
|
+
const opened = await rethinkdb_ts_1.r.connect(options);
|
|
26
|
+
(0, node_assert_1.default)(opened instanceof connection_1.RethinkDBConnection, "r.connect answered no RethinkDBConnection");
|
|
27
|
+
return opened;
|
|
28
|
+
}
|
|
29
|
+
async function OpenPool(options) {
|
|
30
|
+
const opened = await rethinkdb_ts_1.r.connectPool(options);
|
|
31
|
+
(0, node_assert_1.default)(opened instanceof master_pool_1.MasterConnectionPool, "r.connectPool answered no MasterConnectionPool");
|
|
32
|
+
return opened;
|
|
33
|
+
}
|
|
17
34
|
async function ConnectDirect(options) {
|
|
18
35
|
logger_1.Logger.Debug("Connecting directly to RethinkDB", options.host ?? "localhost");
|
|
19
36
|
Disconnect();
|
|
20
37
|
connection = {
|
|
21
38
|
type: "direct",
|
|
22
|
-
connection: await
|
|
39
|
+
connection: await OpenConnection(options),
|
|
23
40
|
};
|
|
24
41
|
logger_1.Logger.Debug("Connected directly to RethinkDB");
|
|
25
42
|
}
|
|
@@ -28,7 +45,7 @@ async function ConnectPool(options) {
|
|
|
28
45
|
Disconnect();
|
|
29
46
|
connection = {
|
|
30
47
|
type: "pool",
|
|
31
|
-
connection: await
|
|
48
|
+
connection: await OpenPool(options),
|
|
32
49
|
};
|
|
33
50
|
logger_1.Logger.Debug("Connected to RethinkDB pool");
|
|
34
51
|
}
|
|
@@ -55,9 +72,7 @@ function SendQuery(query, opts) {
|
|
|
55
72
|
return connection.connection.queue(query, opts);
|
|
56
73
|
}
|
|
57
74
|
}
|
|
58
|
-
async function
|
|
59
|
-
logger_1.Logger.Debug("Executing query:", (0, term_backtrace_1.backtraceTerm)(term)[0]);
|
|
60
|
-
const cursor = await SendQuery(term);
|
|
75
|
+
async function Resolve(term, cursor) {
|
|
61
76
|
if (!cursor) {
|
|
62
77
|
return undefined;
|
|
63
78
|
}
|
|
@@ -75,4 +90,78 @@ async function executeTermJson(term) {
|
|
|
75
90
|
}
|
|
76
91
|
return results;
|
|
77
92
|
}
|
|
93
|
+
async function executeTermJson(term) {
|
|
94
|
+
logger_1.Logger.Debug("Executing query:", (0, term_backtrace_1.backtraceTerm)(term)[0]);
|
|
95
|
+
return Resolve(term, await SendQuery(term));
|
|
96
|
+
}
|
|
97
|
+
class QueryTimeoutError extends Error {
|
|
98
|
+
status = "timeout";
|
|
99
|
+
constructor(timeoutMs) {
|
|
100
|
+
super(`The query did not finish within ${timeoutMs} ms, and was stopped`);
|
|
101
|
+
this.name = "QueryTimeoutError";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.QueryTimeoutError = QueryTimeoutError;
|
|
105
|
+
let directOptions;
|
|
106
|
+
function SetDirectOptions(options) {
|
|
107
|
+
directOptions = options;
|
|
108
|
+
}
|
|
109
|
+
async function OpenBoundedCursor(term, timeoutMs) {
|
|
110
|
+
(0, node_assert_1.default)(directOptions, "No connection established");
|
|
111
|
+
const direct = await OpenConnection(directOptions);
|
|
112
|
+
let expired = false;
|
|
113
|
+
let timer;
|
|
114
|
+
let expire = () => undefined;
|
|
115
|
+
const deadline = new Promise((_, reject) => {
|
|
116
|
+
expire = reject;
|
|
117
|
+
});
|
|
118
|
+
const disarm = () => clearTimeout(timer);
|
|
119
|
+
const arm = () => {
|
|
120
|
+
disarm();
|
|
121
|
+
timer = setTimeout(() => {
|
|
122
|
+
expired = true;
|
|
123
|
+
expire(new QueryTimeoutError(timeoutMs));
|
|
124
|
+
void direct.close().catch(() => undefined);
|
|
125
|
+
}, timeoutMs);
|
|
126
|
+
};
|
|
127
|
+
const release = () => {
|
|
128
|
+
disarm();
|
|
129
|
+
void direct.close().catch(() => undefined);
|
|
130
|
+
};
|
|
131
|
+
arm();
|
|
132
|
+
try {
|
|
133
|
+
const opening = direct.query(term);
|
|
134
|
+
const cursor = await Promise.race([opening, deadline]);
|
|
135
|
+
(0, node_assert_1.default)(cursor, "Query returned no cursor.");
|
|
136
|
+
disarm();
|
|
137
|
+
return { cursor, arm, disarm, release, expired: () => expired };
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
release();
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function DirectConnection() {
|
|
145
|
+
(0, node_assert_1.default)(directOptions, "No connection established");
|
|
146
|
+
return rethinkdb_ts_1.r.connect(directOptions);
|
|
147
|
+
}
|
|
148
|
+
async function executeBounded(term, timeoutMs) {
|
|
149
|
+
(0, node_assert_1.default)(directOptions, "No connection established");
|
|
150
|
+
const direct = await OpenConnection(directOptions);
|
|
151
|
+
let timer;
|
|
152
|
+
const expired = new Promise((_, reject) => {
|
|
153
|
+
timer = setTimeout(() => {
|
|
154
|
+
reject(new QueryTimeoutError(timeoutMs));
|
|
155
|
+
void direct.close();
|
|
156
|
+
}, timeoutMs);
|
|
157
|
+
});
|
|
158
|
+
try {
|
|
159
|
+
const running = direct.query(term).then((cursor) => Resolve(term, cursor));
|
|
160
|
+
return await Promise.race([running, expired]);
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
clearTimeout(timer);
|
|
164
|
+
void direct.close().catch(() => undefined);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
78
167
|
//# sourceMappingURL=connection.js.map
|
package/dist/connection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";;;;;;AAkDA,sCAQC;AAED,kCAQC;AAED,gCAYC;AAED,8BAYC;AAwBD,0CAGC;AAeD,4CAEC;AAkBD,8CAoCC;AAGD,4CAGC;AAMD,wCAoBC;AAlOD,8DAAiC;AACjC,+CAMsB;AAGtB,0EAAsE;AACtE,uEAA6E;AAC7E,yEAA+E;AAE/E,2CAAwC;AACxC,iDAAqD;AAErD,IAAI,UASS,CAAC;AAEd,KAAK,UAAU,cAAc,CAC3B,OAA2B;IAE3B,MAAM,MAAM,GAAG,MAAM,gBAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,IAAA,qBAAM,EACJ,MAAM,YAAY,gCAAmB,EACrC,2CAA2C,CAC5C,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,KAAK,UAAU,QAAQ,CACrB,OAA+B;IAE/B,MAAM,MAAM,GAAG,MAAM,gBAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAA,qBAAM,EACJ,MAAM,YAAY,kCAAoB,EACtC,gDAAgD,CACjD,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAEM,KAAK,UAAU,aAAa,CAAC,OAA2B;IAC7D,eAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,OAAO,CAAC,IAAI,IAAI,WAAW,CAAC,CAAC;IAC9E,UAAU,EAAE,CAAC;IACb,UAAU,GAAG;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AAC;IAC7C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CatalogInfo, RelationDescription, RelationSummary } from "@antelopejs/interface-database-catalog";
|
|
2
|
+
export interface ListedTable {
|
|
3
|
+
name: string;
|
|
4
|
+
primaryKey: string;
|
|
5
|
+
estimatedRows: number;
|
|
6
|
+
uuidKeys: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function ReadInfo(): Promise<CatalogInfo>;
|
|
9
|
+
export declare function ListTable(name: string): Promise<ListedTable>;
|
|
10
|
+
export declare function Summarize(table: ListedTable): Promise<RelationSummary>;
|
|
11
|
+
export declare function DescribeTable(table: ListedTable): Promise<RelationDescription>;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReadInfo = ReadInfo;
|
|
4
|
+
exports.ListTable = ListTable;
|
|
5
|
+
exports.Summarize = Summarize;
|
|
6
|
+
exports.DescribeTable = DescribeTable;
|
|
7
|
+
const rethinkdb_ts_1 = require("rethinkdb-ts");
|
|
8
|
+
const config_1 = require("../../config");
|
|
9
|
+
const external_descriptor_1 = require("../database/external-descriptor");
|
|
10
|
+
const external_probe_1 = require("../database/external-probe");
|
|
11
|
+
const measures_1 = require("./measures");
|
|
12
|
+
const DEFAULT_PRIMARY_KEY = "id";
|
|
13
|
+
const KEY_SAMPLE = 1000;
|
|
14
|
+
const FALLBACK_ROWS = 1000;
|
|
15
|
+
const UNREACHABLE_KEY = "__antelopejs_write_probe__ no row has this key";
|
|
16
|
+
const DOMINANT_SHARE = 0.8;
|
|
17
|
+
const PERCENT = 100;
|
|
18
|
+
const NULL_TYPE = "NULL";
|
|
19
|
+
const READ_ONLY = "an embedded value comes back altered by a read, so it is never written";
|
|
20
|
+
const READINGS = new Map([
|
|
21
|
+
["STRING", "string"],
|
|
22
|
+
["NUMBER", "number"],
|
|
23
|
+
["BOOL", "boolean"],
|
|
24
|
+
["PTYPE<TIME>", "date"],
|
|
25
|
+
["OBJECT", "object"],
|
|
26
|
+
["ARRAY", "array"],
|
|
27
|
+
]);
|
|
28
|
+
async function ReadInfo() {
|
|
29
|
+
const version = await rethinkdb_ts_1.r
|
|
30
|
+
.db("rethinkdb")
|
|
31
|
+
.table("server_status")
|
|
32
|
+
.nth(0)("process")("version")
|
|
33
|
+
.run()
|
|
34
|
+
.catch(() => "unknown");
|
|
35
|
+
return {
|
|
36
|
+
engine: "rethinkdb",
|
|
37
|
+
version,
|
|
38
|
+
database: (0, config_1.ExternalDatabaseName)(),
|
|
39
|
+
role: (0, config_1.GetOptions)().pool?.user ?? "admin",
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async function ListTable(name) {
|
|
43
|
+
const info = await (0, external_probe_1.Table)(name).info().run();
|
|
44
|
+
const primaryKey = info.primary_key ?? DEFAULT_PRIMARY_KEY;
|
|
45
|
+
const keys = await (0, external_probe_1.Table)(name).limit(KEY_SAMPLE)(primaryKey).run();
|
|
46
|
+
return {
|
|
47
|
+
name,
|
|
48
|
+
primaryKey,
|
|
49
|
+
estimatedRows: (info.doc_count_estimates ?? []).reduce((sum, count) => sum + count, 0),
|
|
50
|
+
uuidKeys: keys.length > 0 &&
|
|
51
|
+
keys.every((key) => external_probe_1.UUID_TEXT_PATTERN.test(String(key))),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function Writes(name) {
|
|
55
|
+
const allowed = await (0, external_probe_1.Table)(name)
|
|
56
|
+
.get(UNREACHABLE_KEY)
|
|
57
|
+
.delete()
|
|
58
|
+
.run()
|
|
59
|
+
.then(() => true, () => false);
|
|
60
|
+
return { insert: allowed, update: allowed, delete: allowed };
|
|
61
|
+
}
|
|
62
|
+
async function Summarize(table) {
|
|
63
|
+
const finding = (0, external_descriptor_1.KeyOf)({ ends: await (0, external_probe_1.Ends)(table.name, table.primaryKey) });
|
|
64
|
+
return {
|
|
65
|
+
schema: (0, config_1.ExternalDatabaseName)(),
|
|
66
|
+
name: table.name,
|
|
67
|
+
kind: "table",
|
|
68
|
+
estimatedRows: table.estimatedRows,
|
|
69
|
+
estimate: "statistics",
|
|
70
|
+
key: finding.key
|
|
71
|
+
? { columns: [table.primaryKey], source: "primary" }
|
|
72
|
+
: null,
|
|
73
|
+
writes: await Writes(table.name),
|
|
74
|
+
comment: null,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
async function Indexes(name) {
|
|
78
|
+
const statuses = await (0, external_probe_1.Table)(name)
|
|
79
|
+
.indexStatus()
|
|
80
|
+
.map((status) => ({
|
|
81
|
+
index: status("index"),
|
|
82
|
+
multi: status("multi"),
|
|
83
|
+
query: status("query"),
|
|
84
|
+
}))
|
|
85
|
+
.run();
|
|
86
|
+
return statuses.map((status) => ({
|
|
87
|
+
name: status.index,
|
|
88
|
+
fields: (0, external_probe_1.IndexFields)(status.query),
|
|
89
|
+
multi: status.multi,
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
function FieldTypes(rows) {
|
|
93
|
+
return (0, measures_1.Described)(rows
|
|
94
|
+
.concatMap((row) => row.keys().map((key) => ({ f: key, t: row(key).typeOf() })))
|
|
95
|
+
.group("f", "t")
|
|
96
|
+
.count()
|
|
97
|
+
.ungroup()
|
|
98
|
+
.map((group) => group("group").append(group("reduction"))));
|
|
99
|
+
}
|
|
100
|
+
async function SampledFields(source) {
|
|
101
|
+
const measured = await FieldTypes(source.rows());
|
|
102
|
+
const groups = (0, measures_1.ValueOf)(measured.status === "timeout"
|
|
103
|
+
? await FieldTypes(source.head(FALLBACK_ROWS))
|
|
104
|
+
: measured) ?? [];
|
|
105
|
+
const fields = new Map();
|
|
106
|
+
for (const [field, type, count] of groups) {
|
|
107
|
+
fields.set(field, [...(fields.get(field) ?? []), { type, count }]);
|
|
108
|
+
}
|
|
109
|
+
return fields;
|
|
110
|
+
}
|
|
111
|
+
function Values(types) {
|
|
112
|
+
return types
|
|
113
|
+
.filter((entry) => entry.type !== NULL_TYPE)
|
|
114
|
+
.sort((left, right) => right.count - left.count);
|
|
115
|
+
}
|
|
116
|
+
function Total(types) {
|
|
117
|
+
return types.reduce((sum, entry) => sum + entry.count, 0);
|
|
118
|
+
}
|
|
119
|
+
function Shares(types) {
|
|
120
|
+
const values = Values(types);
|
|
121
|
+
return values
|
|
122
|
+
.map((entry) => `${entry.type} ${Math.round((entry.count / Total(values)) * PERCENT)}%`)
|
|
123
|
+
.join(" | ");
|
|
124
|
+
}
|
|
125
|
+
function Accepts(types, elements) {
|
|
126
|
+
const values = Values(types);
|
|
127
|
+
const [first] = values;
|
|
128
|
+
const kind = first && first.count >= DOMINANT_SHARE * Total(values)
|
|
129
|
+
? READINGS.get(first.type)
|
|
130
|
+
: undefined;
|
|
131
|
+
if (!kind) {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
const unread = values.filter((entry) => entry !== first);
|
|
135
|
+
const lossy = unread.map((entry) => `${entry.count} of ${Total(values)} values are ${entry.type} and read as null`);
|
|
136
|
+
const declared = kind === "array" ? ArrayDeclaration(elements) : kind;
|
|
137
|
+
if (!declared) {
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
return [
|
|
141
|
+
lossy.length > 0 ? { declared, lossy: lossy.join("; ") } : { declared },
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
function ArrayDeclaration(elements) {
|
|
145
|
+
const values = Values(elements);
|
|
146
|
+
const kind = values.length === 1 ? READINGS.get(values[0].type) : undefined;
|
|
147
|
+
return kind && kind !== "array" ? `${kind}[]` : undefined;
|
|
148
|
+
}
|
|
149
|
+
async function ElementTypes(source, field) {
|
|
150
|
+
const groups = (0, measures_1.ValueOf)(await (0, measures_1.Described)(source
|
|
151
|
+
.rows()
|
|
152
|
+
.concatMap((row) => row(field).default([]))
|
|
153
|
+
.group((element) => element.typeOf())
|
|
154
|
+
.count()
|
|
155
|
+
.ungroup()
|
|
156
|
+
.map((group) => [group("group"), group("reduction")]))) ?? [];
|
|
157
|
+
return groups.map(([type, count]) => ({ type, count }));
|
|
158
|
+
}
|
|
159
|
+
async function Column(source, table, name, types, rows) {
|
|
160
|
+
const elements = Values(types)[0]?.type === "ARRAY" ? await ElementTypes(source, name) : [];
|
|
161
|
+
const accepts = Accepts(types, elements);
|
|
162
|
+
const kind = READINGS.get(Values(types)[0]?.type ?? "");
|
|
163
|
+
const column = {
|
|
164
|
+
name,
|
|
165
|
+
native: Shares(types) || "NULL",
|
|
166
|
+
nullable: Total(Values(types)) < rows,
|
|
167
|
+
hasDefault: name === table.primaryKey && table.uuidKeys,
|
|
168
|
+
generated: false,
|
|
169
|
+
identity: null,
|
|
170
|
+
accepts,
|
|
171
|
+
comment: null,
|
|
172
|
+
};
|
|
173
|
+
if (accepts.length === 0) {
|
|
174
|
+
column.unsupported =
|
|
175
|
+
Values(types).length === 0
|
|
176
|
+
? "the sample holds only null for it"
|
|
177
|
+
: `no type covers 80% of the sampled values: ${Shares(types)}`;
|
|
178
|
+
}
|
|
179
|
+
if (kind === "object" || kind === "array") {
|
|
180
|
+
column.readOnly = READ_ONLY;
|
|
181
|
+
}
|
|
182
|
+
return column;
|
|
183
|
+
}
|
|
184
|
+
async function DescribeTable(table) {
|
|
185
|
+
const summary = await Summarize(table);
|
|
186
|
+
const source = (0, measures_1.SourceFor)(table.name, table.estimatedRows, table.uuidKeys);
|
|
187
|
+
const fields = await SampledFields(source);
|
|
188
|
+
const rows = Math.max(0, ...[...fields.values()].map((types) => Total(types)));
|
|
189
|
+
const names = [
|
|
190
|
+
table.primaryKey,
|
|
191
|
+
...[...fields.keys()].filter((name) => name !== table.primaryKey),
|
|
192
|
+
];
|
|
193
|
+
const columns = [];
|
|
194
|
+
for (const name of names.filter((field) => fields.has(field))) {
|
|
195
|
+
columns.push(await Column(source, table, name, fields.get(name) ?? [], rows));
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
...summary,
|
|
199
|
+
columns,
|
|
200
|
+
indexes: (await Indexes(table.name)).map((index) => ({
|
|
201
|
+
name: index.name,
|
|
202
|
+
columns: index.fields,
|
|
203
|
+
unique: false,
|
|
204
|
+
})),
|
|
205
|
+
references: [],
|
|
206
|
+
referencedBy: [],
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../../src/implementations/catalog/discovery.ts"],"names":[],"mappings":";;AAiEA,4BAaC;AAED,8BAeC;AAkBD,8BAcC;AA6JD,sCA+BC;AAlTD,+CAA+C;AAE/C,yCAAgE;AAChE,yEAAwD;AACxD,+DAMoC;AACpC,yCAAwE;AA0BxE,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,eAAe,GAAG,gDAAgD,CAAC;AACzE,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,OAAO,GAAG,GAAG,CAAC;AACpB,MAAM,SAAS,GAAG,MAAM,CAAC;AACzB,MAAM,SAAS,GACb,wEAAwE,CAAC;AAE3E,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAiB;IACvC,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACpB,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACpB,CAAC,MAAM,EAAE,SAAS,CAAC;IACnB,CAAC,aAAa,EAAE,MAAM,CAAC;IACvB,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACpB,CAAC,OAAO,EAAE,OAAO,CAAC;CACnB,CAAC,CAAC;AAEI,KAAK,UAAU,QAAQ;IAC5B,MAAM,OAAO,GAAW,MAAM,gBAAC;SAC5B,EAAE,CAAC,WAAW,CAAC;SACf,KAAK,CAAC,eAAe,CAAC;SACtB,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC;SAC5B,GAAG,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