@lambdaorm/lib 3.12.0 → 3.13.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/CHANGELOG.md +23 -0
- package/connection/infrastructure/adapters/Http.d.ts +77 -0
- package/connection/infrastructure/adapters/Http.d.ts.map +1 -0
- package/connection/infrastructure/adapters/Http.js +259 -0
- package/connection/infrastructure/adapters/Http.js.map +1 -0
- package/connection/infrastructure/facadeBuilder.d.ts.map +1 -1
- package/connection/infrastructure/facadeBuilder.js +3 -1
- package/connection/infrastructure/facadeBuilder.js.map +1 -1
- package/execution/application/services/queryExecutor/sourceConnections.d.ts +1 -0
- package/execution/application/services/queryExecutor/sourceConnections.d.ts.map +1 -1
- package/execution/application/services/queryExecutor/sourceConnections.js +5 -1
- package/execution/application/services/queryExecutor/sourceConnections.js.map +1 -1
- package/expressions/application/facade.d.ts +4 -0
- package/expressions/application/facade.d.ts.map +1 -1
- package/expressions/application/facade.js +12 -1
- package/expressions/application/facade.js.map +1 -1
- package/expressions/application/services/crossSourceQuery.d.ts +56 -0
- package/expressions/application/services/crossSourceQuery.d.ts.map +1 -0
- package/expressions/application/services/crossSourceQuery.js +230 -0
- package/expressions/application/services/crossSourceQuery.js.map +1 -0
- package/expressions/application/useCases/execute.d.ts +1 -0
- package/expressions/application/useCases/execute.d.ts.map +1 -1
- package/expressions/application/useCases/execute.js +10 -1
- package/expressions/application/useCases/execute.js.map +1 -1
- package/language/application/services/columnType.d.ts +5 -0
- package/language/application/services/columnType.d.ts.map +1 -1
- package/language/application/services/columnType.js +33 -0
- package/language/application/services/columnType.js.map +1 -1
- package/language/application/services/ddlBuilder.d.ts +10 -0
- package/language/application/services/ddlBuilder.d.ts.map +1 -1
- package/language/application/services/ddlBuilder.js +37 -2
- package/language/application/services/ddlBuilder.js.map +1 -1
- package/orm/infrastructure/orm.d.ts.map +1 -1
- package/orm/infrastructure/orm.js +1 -0
- package/orm/infrastructure/orm.js.map +1 -1
- package/package.json +2 -2
- package/query/domain/query.d.ts +2 -0
- package/query/domain/query.d.ts.map +1 -1
- package/query/domain/query.js.map +1 -1
- package/sentence/infrastructure/adapters/Http/HttpDmlBuilder.d.ts +54 -0
- package/sentence/infrastructure/adapters/Http/HttpDmlBuilder.d.ts.map +1 -0
- package/sentence/infrastructure/adapters/Http/HttpDmlBuilder.js +168 -0
- package/sentence/infrastructure/adapters/Http/HttpDmlBuilder.js.map +1 -0
- package/sentence/infrastructure/adapters/Http/config.json +90 -0
- package/sentence/infrastructure/adapters/Http/language.d.ts +13 -0
- package/sentence/infrastructure/adapters/Http/language.d.ts.map +1 -0
- package/sentence/infrastructure/adapters/Http/language.js +26 -0
- package/sentence/infrastructure/adapters/Http/language.js.map +1 -0
- package/sentence/infrastructure/languageServiceBuilder.d.ts.map +1 -1
- package/sentence/infrastructure/languageServiceBuilder.js +3 -1
- package/sentence/infrastructure/languageServiceBuilder.js.map +1 -1
- package/shared/application/inMemory.d.ts +32 -0
- package/shared/application/inMemory.d.ts.map +1 -0
- package/shared/application/inMemory.js +94 -0
- package/shared/application/inMemory.js.map +1 -0
- package/shared/infrastructure/helper.d.ts +3 -0
- package/shared/infrastructure/helper.d.ts.map +1 -1
- package/shared/infrastructure/helper.js.map +1 -1
- package/shared/infrastructure/observability/semconv.d.ts.map +1 -1
- package/shared/infrastructure/observability/semconv.js +3 -1
- package/shared/infrastructure/observability/semconv.js.map +1 -1
- package/stage/application/facade.d.ts +9 -0
- package/stage/application/facade.d.ts.map +1 -1
- package/stage/application/facade.js +18 -1
- package/stage/application/facade.js.map +1 -1
- package/stage/application/index.d.ts +1 -0
- package/stage/application/index.d.ts.map +1 -1
- package/stage/application/index.js +1 -0
- package/stage/application/index.js.map +1 -1
- package/stage/application/services/migrationService.d.ts +55 -0
- package/stage/application/services/migrationService.d.ts.map +1 -0
- package/stage/application/services/migrationService.js +97 -0
- package/stage/application/services/migrationService.js.map +1 -0
- package/stage/application/services/stateService.d.ts +9 -2
- package/stage/application/services/stateService.d.ts.map +1 -1
- package/stage/application/services/stateService.js +22 -7
- package/stage/application/services/stateService.js.map +1 -1
- package/stage/application/useCases/push.d.ts +10 -0
- package/stage/application/useCases/push.d.ts.map +1 -1
- package/stage/application/useCases/push.js +15 -4
- package/stage/application/useCases/push.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.13.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5f7ae4a: Queries across sources (docs/CROSS_SOURCE.md): a map, sort or having with fields of a relation in another source,
|
|
8
|
+
which sent a JOIN to a table that database doesn't have, runs as the root with an include of the other source and then
|
|
9
|
+
maps, groups, sorts and pages in memory; a sort of the root's fields goes to its database with the page; at most
|
|
10
|
+
`maxRows` rows to sort or group in memory (`CrossSourceError`). `orm.plan` shows what runs in memory.
|
|
11
|
+
- 55ab035: A REST API as a source (docs/HTTP_SOURCE.md): the dialect `Http` reads by key (`GET /x/{id}`), lists with the
|
|
12
|
+
parameters the API filters by and does the rest in memory (the engine of the queries across sources), writes with
|
|
13
|
+
`POST`/`PATCH`/`DELETE`, and in a transaction sends its writes at the commit, before the databases.
|
|
14
|
+
- 664671b: Migrations (docs/MIGRATIONS.md): push stops the changes that can lose data (a type that narrows, a shorter text)
|
|
15
|
+
unless `allowDestructive`, writes the undo of each push (`U<version>__push.sql`) and, with `infrastructure.migrations`,
|
|
16
|
+
records each push in the database; `orm.stage.migrations.list()` and `orm.stage.migrate(version)` go back. An absolute
|
|
17
|
+
`paths.state` is used as it is.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [5f7ae4a]
|
|
22
|
+
- Updated dependencies [55ab035]
|
|
23
|
+
- Updated dependencies [664671b]
|
|
24
|
+
- @lambdaorm/base@3.11.0
|
|
25
|
+
|
|
3
26
|
## 3.12.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Data, MappingConfigService } from '@lambdaorm/base';
|
|
2
|
+
import { Query } from '../../../query/domain';
|
|
3
|
+
import { DialectService } from '../../../language/domain';
|
|
4
|
+
import { ConnectionAdapter } from './base/connection';
|
|
5
|
+
import { ConnectionPoolAdapter } from './base/connectionPool';
|
|
6
|
+
import { Connection } from '../../domain';
|
|
7
|
+
import { OrmH3lp } from '../../../shared/infrastructure';
|
|
8
|
+
/** The connection of a source Http (docs/HTTP_SOURCE.md): the url of the API, its headers (secrets from ${VAR}), a timeout */
|
|
9
|
+
export interface HttpConnectionConfig {
|
|
10
|
+
url: string;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
timeout?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class HttpConnectionPoolAdapter extends ConnectionPoolAdapter {
|
|
15
|
+
constructor(config: any, helper: OrmH3lp);
|
|
16
|
+
/** nothing to open: each request is its own */
|
|
17
|
+
init(): Promise<void>;
|
|
18
|
+
protected create(id: string): Promise<Connection>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Runs the plans of HttpDmlBuilder on a REST API: a GET by key, a list with the parameters the API filters by, or the
|
|
22
|
+
* GET of each key of an include; then the rest in memory (filter, map, group, having, sort, page). In a transaction
|
|
23
|
+
* the writes wait until its commit (before the ones of the databases), except an insert whose answer is needed.
|
|
24
|
+
*/
|
|
25
|
+
export declare class HttpConnectionAdapter extends ConnectionAdapter {
|
|
26
|
+
/** the writes of the transaction in course, sent when it commits */
|
|
27
|
+
private pending;
|
|
28
|
+
private get settings();
|
|
29
|
+
private get exp();
|
|
30
|
+
end(): Promise<void>;
|
|
31
|
+
select(mapping: MappingConfigService, _dialect: DialectService, query: Query, data: Data): Promise<any>;
|
|
32
|
+
insert(mapping: MappingConfigService, _dialect: DialectService, query: Query, data: Data): Promise<any>;
|
|
33
|
+
bulkInsert(mapping: MappingConfigService, dialect: DialectService, query: Query, array: any[]): Promise<any[]>;
|
|
34
|
+
update(mapping: MappingConfigService, _dialect: DialectService, query: Query, data: Data): Promise<number>;
|
|
35
|
+
delete(mapping: MappingConfigService, _dialect: DialectService, query: Query, data: Data): Promise<number>;
|
|
36
|
+
upsert(mapping: MappingConfigService, dialect: DialectService, query: Query, data: Data): Promise<any>;
|
|
37
|
+
insertConditional(): Promise<any>;
|
|
38
|
+
merge(): Promise<any>;
|
|
39
|
+
bulkMerge(): Promise<any[]>;
|
|
40
|
+
execute(): Promise<any>;
|
|
41
|
+
/** an API has no tables: no DDL */
|
|
42
|
+
executeDDL(): Promise<any>;
|
|
43
|
+
executeSentence(): Promise<any>;
|
|
44
|
+
/** what fetch (and push) read of it: an API has no tables */
|
|
45
|
+
objects(): Promise<any[]>;
|
|
46
|
+
tables(): Promise<any[]>;
|
|
47
|
+
views(): Promise<any[]>;
|
|
48
|
+
partitions(): Promise<any[]>;
|
|
49
|
+
sequences(): Promise<any[]>;
|
|
50
|
+
primaryKeys(): Promise<any[]>;
|
|
51
|
+
uniqueKeys(): Promise<any[]>;
|
|
52
|
+
foreignKeys(): Promise<any[]>;
|
|
53
|
+
indexes(): Promise<any[]>;
|
|
54
|
+
beginTransaction(): Promise<void>;
|
|
55
|
+
/** the writes of the transaction, in order; the source Http commits before the databases */
|
|
56
|
+
commit(): Promise<void>;
|
|
57
|
+
rollback(): Promise<void>;
|
|
58
|
+
/** a write: now, or when the transaction commits */
|
|
59
|
+
private write;
|
|
60
|
+
/** a request to the API: its answer (JSON or text), undefined when it is 404 */
|
|
61
|
+
private request;
|
|
62
|
+
/** the route of an operation: the one declared ('PUT /invoices/{id}') or the convention, with its key */
|
|
63
|
+
private route;
|
|
64
|
+
private methodOf;
|
|
65
|
+
private keyOf;
|
|
66
|
+
/** the rows of the answer of a list: at items, or the answer itself, or its data or items */
|
|
67
|
+
private itemsOf;
|
|
68
|
+
/** an item of the API as a row of the domain: its fields by the mapping of each property */
|
|
69
|
+
private toRow;
|
|
70
|
+
/** the body of a write: each property by its name on the API */
|
|
71
|
+
private bodyOf;
|
|
72
|
+
private columnOf;
|
|
73
|
+
private entityOf;
|
|
74
|
+
/** the variables an expression of the plan reads: the data, its parents and the context */
|
|
75
|
+
private scope;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=Http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Http.d.ts","sourceRoot":"","sources":["../../../../../src/lib/connection/infrastructure/adapters/Http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAA8B,MAAM,iBAAiB,CAAA;AAExF,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAIxD,8HAA8H;AAC9H,MAAM,WAAW,oBAAoB;IACpC,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,qBAAa,yBAA0B,SAAQ,qBAAqB;gBAEtD,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO;IAIzC,+CAA+C;IAClC,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC;cAEnB,MAAM,CAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAGxD;AAED;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,iBAAiB;IAC3D,oEAAoE;IACpE,OAAO,CAAC,OAAO,CAA6B;IAE5C,OAAO,KAAK,QAAQ,G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7C,6DAA6D;IAChD,OAAO,IAAK,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,IAAK,OAAO,CAAC,GAAG,EAAE,CAAC;IACzB,KAAK,IAAK,OAAO,CAAC,GAAG,EAAE,CAAC;IACxB,UAAU,IAAK,OAAO,CAAC,GAAG,EAAE,CAAC;IAC7B,SAAS,IAAK,OAAO,CAAC,GAAG,EAAE,CAAC;IAC5B,WAAW,IAAK,OAAO,CAAC,GAAG,EAAE,CAAC;IAC9B,UAAU,IAAK,OAAO,CAAC,GAAG,EAAE,CAAC;IAC7B,WAAW,IAAK,OAAO,CAAC,GAAG,EAAE,CAAC;IAC9B,OAAO,IAAK,OAAO,CAAC,GAAG,EAAE,CAAC;IAE1B,gBAAgB,IAAK,OAAO,CAAC,IAAI,CAAC;IAK/C,4FAA4F;IAC/E,MAAM,IAAK,OAAO,CAAC,IAAI,CAAC;IAOxB,QAAQ,IAAK,OAAO,CAAC,IAAI,CAAC;IAKvC,oDAAoD;YACtC,KAAK;IASnB,gFAAgF;YAClE,OAAO;IAyBrB,yGAAyG;IACzG,OAAO,CAAC,KAAK;IAMb,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,KAAK;IAKb,6FAA6F;IAC7F,OAAO,CAAC,OAAO;IAWf,4FAA4F;IAC5F,OAAO,CAAC,KAAK;IASb,gEAAgE;IAChE,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,QAAQ;IAMhB,2FAA2F;IAC3F,OAAO,CAAC,KAAK;CASb"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpConnectionAdapter = exports.HttpConnectionPoolAdapter = void 0;
|
|
4
|
+
const base_1 = require("@lambdaorm/base");
|
|
5
|
+
const _3xpr_1 = require("3xpr");
|
|
6
|
+
const connection_1 = require("./base/connection");
|
|
7
|
+
const connectionPool_1 = require("./base/connectionPool");
|
|
8
|
+
const domain_1 = require("../../domain");
|
|
9
|
+
const inMemory_1 = require("../../../shared/application/inMemory");
|
|
10
|
+
const HttpDmlBuilder_1 = require("../../../sentence/infrastructure/adapters/Http/HttpDmlBuilder");
|
|
11
|
+
class HttpConnectionPoolAdapter extends connectionPool_1.ConnectionPoolAdapter {
|
|
12
|
+
// eslint-disable-next-line no-useless-constructor
|
|
13
|
+
constructor(config, helper) {
|
|
14
|
+
super(config, helper);
|
|
15
|
+
}
|
|
16
|
+
/** nothing to open: each request is its own */
|
|
17
|
+
async init() { }
|
|
18
|
+
async create(id) {
|
|
19
|
+
return new HttpConnectionAdapter(id, null, this, this.helper);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.HttpConnectionPoolAdapter = HttpConnectionPoolAdapter;
|
|
23
|
+
/**
|
|
24
|
+
* Runs the plans of HttpDmlBuilder on a REST API: a GET by key, a list with the parameters the API filters by, or the
|
|
25
|
+
* GET of each key of an include; then the rest in memory (filter, map, group, having, sort, page). In a transaction
|
|
26
|
+
* the writes wait until its commit (before the ones of the databases), except an insert whose answer is needed.
|
|
27
|
+
*/
|
|
28
|
+
class HttpConnectionAdapter extends connection_1.ConnectionAdapter {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
/** the writes of the transaction in course, sent when it commits */
|
|
32
|
+
this.pending = [];
|
|
33
|
+
}
|
|
34
|
+
get settings() {
|
|
35
|
+
const connection = this.config.connection;
|
|
36
|
+
const value = typeof connection === 'string' ? JSON.parse(connection) : connection;
|
|
37
|
+
if (!value?.url)
|
|
38
|
+
throw new base_1.SchemaError(`source ${this.config.name}: the connection of a source Http needs its url`);
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
get exp() {
|
|
42
|
+
return this.helper.expressions ?? _3xpr_1.expressions;
|
|
43
|
+
}
|
|
44
|
+
async end() { }
|
|
45
|
+
async select(mapping, _dialect, query, data) {
|
|
46
|
+
const plan = JSON.parse(query.sentence);
|
|
47
|
+
const entity = this.entityOf(mapping, plan);
|
|
48
|
+
const scope = this.scope(data);
|
|
49
|
+
let items;
|
|
50
|
+
if (plan.keys) {
|
|
51
|
+
const one = await this.request('GET', this.route(plan, 'get', entity, this.keyOf(plan, scope)));
|
|
52
|
+
items = one === undefined ? [] : [one];
|
|
53
|
+
}
|
|
54
|
+
else if (plan.keyList) {
|
|
55
|
+
const keys = (this.exp.eval(plan.keyList, scope) ?? []);
|
|
56
|
+
const found = await Promise.all([...new Set(keys)].map(key => this.request('GET', this.route(plan, 'get', entity, key))));
|
|
57
|
+
items = found.filter(p => p !== undefined);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const params = Object.entries(plan.params ?? {}).map(([property, text]) => [this.columnOf(entity, property), this.exp.eval(text, scope)]);
|
|
61
|
+
const answer = await this.request('GET', this.route(plan, 'list', entity), params);
|
|
62
|
+
items = this.itemsOf(answer, plan.http.items);
|
|
63
|
+
}
|
|
64
|
+
const rows = items.map(item => this.toRow(entity, item));
|
|
65
|
+
return (0, inMemory_1.runInMemory)(this.exp, rows, { variable: HttpDmlBuilder_1.HTTP_ROW, filter: plan.filter, map: plan.map, having: plan.having, sort: plan.sort, page: plan.page }, scope);
|
|
66
|
+
}
|
|
67
|
+
async insert(mapping, _dialect, query, data) {
|
|
68
|
+
const plan = JSON.parse(query.sentence);
|
|
69
|
+
const entity = this.entityOf(mapping, plan);
|
|
70
|
+
const body = this.bodyOf(entity, plan, this.scope(data));
|
|
71
|
+
const send = async () => {
|
|
72
|
+
const created = await this.request('POST', this.route(plan, 'insert', entity), [], body);
|
|
73
|
+
const key = entity.primaryKey?.[0];
|
|
74
|
+
return key && created && typeof created === 'object' ? created[this.columnOf(entity, key)] : undefined;
|
|
75
|
+
};
|
|
76
|
+
// the answer is needed now when the API generates the key: it isn't deferred
|
|
77
|
+
const key = entity.primaryKey?.[0];
|
|
78
|
+
if (this.inTransaction && key && body[this.columnOf(entity, key)] !== undefined) {
|
|
79
|
+
this.pending.push(send);
|
|
80
|
+
return body[this.columnOf(entity, key)];
|
|
81
|
+
}
|
|
82
|
+
return send();
|
|
83
|
+
}
|
|
84
|
+
async bulkInsert(mapping, dialect, query, array) {
|
|
85
|
+
const ids = [];
|
|
86
|
+
for (const item of array)
|
|
87
|
+
ids.push(await this.insert(mapping, dialect, query, new base_1.Data(item)));
|
|
88
|
+
return ids;
|
|
89
|
+
}
|
|
90
|
+
async update(mapping, _dialect, query, data) {
|
|
91
|
+
const plan = JSON.parse(query.sentence);
|
|
92
|
+
const entity = this.entityOf(mapping, plan);
|
|
93
|
+
const scope = this.scope(data);
|
|
94
|
+
const body = this.bodyOf(entity, plan, scope);
|
|
95
|
+
const route = this.route(plan, 'update', entity, this.keyOf(plan, scope));
|
|
96
|
+
return this.write(() => this.request(this.methodOf(plan.http.update, 'PATCH'), route, [], body));
|
|
97
|
+
}
|
|
98
|
+
async delete(mapping, _dialect, query, data) {
|
|
99
|
+
const plan = JSON.parse(query.sentence);
|
|
100
|
+
const entity = this.entityOf(mapping, plan);
|
|
101
|
+
const scope = this.scope(data);
|
|
102
|
+
const keys = plan.keys ? [this.keyOf(plan, scope)] : (this.exp.eval(plan.keyList, scope) ?? []);
|
|
103
|
+
let count = 0;
|
|
104
|
+
for (const key of keys)
|
|
105
|
+
count += await this.write(() => this.request(this.methodOf(plan.http.delete, 'DELETE'), this.route(plan, 'delete', entity, key)));
|
|
106
|
+
return count;
|
|
107
|
+
}
|
|
108
|
+
async upsert(mapping, dialect, query, data) {
|
|
109
|
+
return this.insert(mapping, dialect, query, data);
|
|
110
|
+
}
|
|
111
|
+
async insertConditional() { throw new base_1.SchemaError('insertConditional is not supported on a source Http'); }
|
|
112
|
+
async merge() { throw new base_1.SchemaError('merge is not supported on a source Http'); }
|
|
113
|
+
async bulkMerge() { throw new base_1.SchemaError('bulkMerge is not supported on a source Http'); }
|
|
114
|
+
async execute() { throw new base_1.SchemaError('a sentence is not supported on a source Http'); }
|
|
115
|
+
/** an API has no tables: no DDL */
|
|
116
|
+
async executeDDL() { return undefined; }
|
|
117
|
+
async executeSentence() { throw new base_1.SchemaError('a sentence is not supported on a source Http'); }
|
|
118
|
+
/** what fetch (and push) read of it: an API has no tables */
|
|
119
|
+
async objects() { return []; }
|
|
120
|
+
async tables() { return []; }
|
|
121
|
+
async views() { return []; }
|
|
122
|
+
async partitions() { return []; }
|
|
123
|
+
async sequences() { return []; }
|
|
124
|
+
async primaryKeys() { return []; }
|
|
125
|
+
async uniqueKeys() { return []; }
|
|
126
|
+
async foreignKeys() { return []; }
|
|
127
|
+
async indexes() { return []; }
|
|
128
|
+
async beginTransaction() {
|
|
129
|
+
this.inTransaction = true;
|
|
130
|
+
this.pending = [];
|
|
131
|
+
}
|
|
132
|
+
/** the writes of the transaction, in order; the source Http commits before the databases */
|
|
133
|
+
async commit() {
|
|
134
|
+
const pending = this.pending;
|
|
135
|
+
this.pending = [];
|
|
136
|
+
this.inTransaction = false;
|
|
137
|
+
for (const send of pending)
|
|
138
|
+
await send();
|
|
139
|
+
}
|
|
140
|
+
async rollback() {
|
|
141
|
+
this.pending = [];
|
|
142
|
+
this.inTransaction = false;
|
|
143
|
+
}
|
|
144
|
+
/** a write: now, or when the transaction commits */
|
|
145
|
+
async write(send) {
|
|
146
|
+
if (this.inTransaction) {
|
|
147
|
+
this.pending.push(send);
|
|
148
|
+
return 1;
|
|
149
|
+
}
|
|
150
|
+
await send();
|
|
151
|
+
return 1;
|
|
152
|
+
}
|
|
153
|
+
/** a request to the API: its answer (JSON or text), undefined when it is 404 */
|
|
154
|
+
async request(method, route, params = [], body) {
|
|
155
|
+
const { url, headers, timeout } = this.settings;
|
|
156
|
+
const target = new URL(url.replace(/\/$/, '') + route);
|
|
157
|
+
for (const [name, value] of params)
|
|
158
|
+
if (value !== undefined && value !== null)
|
|
159
|
+
target.searchParams.append(String(name), String(value));
|
|
160
|
+
const controller = new AbortController();
|
|
161
|
+
const timer = setTimeout(() => controller.abort(), timeout ?? 30000);
|
|
162
|
+
try {
|
|
163
|
+
const response = await fetch(target, {
|
|
164
|
+
method,
|
|
165
|
+
headers: { Accept: 'application/json', ...(body !== undefined ? { 'Content-Type': 'application/json' } : {}), ...(headers ?? {}) },
|
|
166
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
167
|
+
signal: controller.signal
|
|
168
|
+
});
|
|
169
|
+
if (response.status === 404 && method === 'GET')
|
|
170
|
+
return undefined;
|
|
171
|
+
const text = await response.text();
|
|
172
|
+
if (!response.ok) {
|
|
173
|
+
throw new domain_1.ExecutionError(this.config.name, '', `${method} ${target.pathname}`, `${response.status} ${response.statusText}: ${text.slice(0, 300)}`, body);
|
|
174
|
+
}
|
|
175
|
+
if (text === '')
|
|
176
|
+
return undefined;
|
|
177
|
+
try {
|
|
178
|
+
return JSON.parse(text);
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
return text;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
finally {
|
|
185
|
+
clearTimeout(timer);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/** the route of an operation: the one declared ('PUT /invoices/{id}') or the convention, with its key */
|
|
189
|
+
route(plan, operation, entity, key) {
|
|
190
|
+
const declared = plan.http[operation];
|
|
191
|
+
const path = declared ? declared.trim().split(/\s+/).pop() : (['list', 'insert'].includes(operation) ? plan.route : `${plan.route.replace(/\/$/, '')}/{${entity.primaryKey?.[0] ?? 'id'}}`);
|
|
192
|
+
return path.replace(/\{[^}]+\}/g, () => encodeURIComponent(String(key)));
|
|
193
|
+
}
|
|
194
|
+
methodOf(declared, fallback) {
|
|
195
|
+
const parts = declared?.trim().split(/\s+/) ?? [];
|
|
196
|
+
return parts.length > 1 ? parts[0].toUpperCase() : fallback;
|
|
197
|
+
}
|
|
198
|
+
keyOf(plan, scope) {
|
|
199
|
+
const [text] = Object.values(plan.keys ?? {});
|
|
200
|
+
return this.exp.eval(text, scope);
|
|
201
|
+
}
|
|
202
|
+
/** the rows of the answer of a list: at items, or the answer itself, or its data or items */
|
|
203
|
+
itemsOf(answer, items) {
|
|
204
|
+
if (items) {
|
|
205
|
+
const value = items.split('.').reduce((current, name) => current?.[name], answer);
|
|
206
|
+
return Array.isArray(value) ? value : [];
|
|
207
|
+
}
|
|
208
|
+
if (Array.isArray(answer))
|
|
209
|
+
return answer;
|
|
210
|
+
if (Array.isArray(answer?.data))
|
|
211
|
+
return answer.data;
|
|
212
|
+
if (Array.isArray(answer?.items))
|
|
213
|
+
return answer.items;
|
|
214
|
+
return answer === undefined || answer === null ? [] : [answer];
|
|
215
|
+
}
|
|
216
|
+
/** an item of the API as a row of the domain: its fields by the mapping of each property */
|
|
217
|
+
toRow(entity, item) {
|
|
218
|
+
const row = {};
|
|
219
|
+
for (const property of entity.properties ?? []) {
|
|
220
|
+
const value = item?.[property.mapping || property.name];
|
|
221
|
+
if (value !== undefined)
|
|
222
|
+
row[property.name] = value;
|
|
223
|
+
}
|
|
224
|
+
return row;
|
|
225
|
+
}
|
|
226
|
+
/** the body of a write: each property by its name on the API */
|
|
227
|
+
bodyOf(entity, plan, scope) {
|
|
228
|
+
const body = {};
|
|
229
|
+
for (const [property, text] of Object.entries(plan.body ?? {})) {
|
|
230
|
+
const value = this.exp.eval(text, scope);
|
|
231
|
+
if (value !== undefined)
|
|
232
|
+
body[this.columnOf(entity, property)] = value;
|
|
233
|
+
}
|
|
234
|
+
return body;
|
|
235
|
+
}
|
|
236
|
+
columnOf(entity, property) {
|
|
237
|
+
const found = entity.properties?.find(p => p.name === property);
|
|
238
|
+
return found?.mapping || property;
|
|
239
|
+
}
|
|
240
|
+
entityOf(mapping, plan) {
|
|
241
|
+
const entity = mapping.getEntity(plan.entity);
|
|
242
|
+
if (!entity)
|
|
243
|
+
throw new base_1.SchemaError(`mapping undefined on ${plan.entity} entity`);
|
|
244
|
+
return entity;
|
|
245
|
+
}
|
|
246
|
+
/** the variables an expression of the plan reads: the data, its parents and the context */
|
|
247
|
+
scope(data) {
|
|
248
|
+
const chain = [];
|
|
249
|
+
let current = data;
|
|
250
|
+
while (current) {
|
|
251
|
+
if (current.data && typeof current.data === 'object' && !Array.isArray(current.data))
|
|
252
|
+
chain.unshift(current.data);
|
|
253
|
+
current = current.parent;
|
|
254
|
+
}
|
|
255
|
+
return Object.assign({}, ...chain, { context: data.context ?? {} });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
exports.HttpConnectionAdapter = HttpConnectionAdapter;
|
|
259
|
+
//# sourceMappingURL=Http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Http.js","sourceRoot":"","sources":["../../../../../src/lib/connection/infrastructure/adapters/Http.ts"],"names":[],"mappings":";;;AAAA,0CAAwF;AACxF,gCAAoE;AAGpE,kDAAqD;AACrD,0DAA6D;AAC7D,yCAAyD;AAEzD,mEAAkE;AAClE,kGAAkG;AASlG,MAAa,yBAA0B,SAAQ,sCAAqB;IACnE,kDAAkD;IAClD,YAAa,MAAW,EAAE,MAAe;QACxC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtB,CAAC;IAED,+CAA+C;IACxC,KAAK,CAAC,IAAI,KAAmC,CAAC;IAE3C,KAAK,CAAC,MAAM,CAAE,EAAU;QACjC,OAAO,IAAI,qBAAqB,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAC9D,CAAC;CACD;AAZD,8DAYC;AAED;;;;GAIG;AACH,MAAa,qBAAsB,SAAQ,8BAAiB;IAA5D;;QACC,oEAAoE;QAC5D,YAAO,GAA2B,EAAE,CAAA;IAiO7C,CAAC;IA/NA,IAAY,QAAQ;QACnB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAA;QACzC,MAAM,KAAK,GAAG,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC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CAAC,OAAO,IAAI,EAAE,EAAE,CAAC,CAAA;IACpE,CAAC;CACD;AAnOD,sDAmOC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facadeBuilder.d.ts","sourceRoot":"","sources":["../../../../src/lib/connection/infrastructure/facadeBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"facadeBuilder.d.ts","sourceRoot":"","sources":["../../../../src/lib/connection/infrastructure/facadeBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAajD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAErD,qBAAa,uBAAuB;IAEtB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAC,OAAO;IACrC,KAAK,IAAI,gBAAgB;CAgBhC"}
|
|
@@ -14,6 +14,7 @@ const SQLjs_1 = require("./adapters/SQLjs");
|
|
|
14
14
|
const SqlServer_1 = require("./adapters/SqlServer");
|
|
15
15
|
const Oracle_1 = require("./adapters/Oracle");
|
|
16
16
|
const MongoDB_1 = require("./adapters/MongoDB");
|
|
17
|
+
const Http_1 = require("./adapters/Http");
|
|
17
18
|
class ConnectionFacadeBuilder {
|
|
18
19
|
// eslint-disable-next-line no-useless-constructor
|
|
19
20
|
constructor(helper) {
|
|
@@ -31,7 +32,8 @@ class ConnectionFacadeBuilder {
|
|
|
31
32
|
.addDialect(base_1.Dialect.SqlServer, SqlServer_1.SqlServerConnectionPoolAdapter)
|
|
32
33
|
.addDialect(base_1.Dialect.SQLjs, SQLjs_1.SQLjsConnectionPoolAdapter)
|
|
33
34
|
.addDialect(base_1.Dialect.Oracle, Oracle_1.OracleConnectionPoolAdapter)
|
|
34
|
-
.addDialect(base_1.Dialect.MongoDB, MongoDB_1.MongoDBConnectionPoolAdapter)
|
|
35
|
+
.addDialect(base_1.Dialect.MongoDB, MongoDB_1.MongoDBConnectionPoolAdapter)
|
|
36
|
+
.addDialect(base_1.Dialect.Http, Http_1.HttpConnectionPoolAdapter);
|
|
35
37
|
return connectionFacade;
|
|
36
38
|
}
|
|
37
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facadeBuilder.js","sourceRoot":"","sources":["../../../../src/lib/connection/infrastructure/facadeBuilder.ts"],"names":[],"mappings":";;;AAAA,0CAAyC;AACzC,gDAAiD;AACjD,yFAAqF;AACrF,mFAA+E;AAC/E,6DAAmE;AACnE,6DAAmE;AACnE,4CAA6D;AAC7D,gDAAiE;AACjE,sDAAuE;AACvE,4CAA6D;AAC7D,oDAAqE;AACrE,8CAA+D;AAC/D,gDAAiE;
|
|
1
|
+
{"version":3,"file":"facadeBuilder.js","sourceRoot":"","sources":["../../../../src/lib/connection/infrastructure/facadeBuilder.ts"],"names":[],"mappings":";;;AAAA,0CAAyC;AACzC,gDAAiD;AACjD,yFAAqF;AACrF,mFAA+E;AAC/E,6DAAmE;AACnE,6DAAmE;AACnE,4CAA6D;AAC7D,gDAAiE;AACjE,sDAAuE;AACvE,4CAA6D;AAC7D,oDAAqE;AACrE,8CAA+D;AAC/D,gDAAiE;AACjE,0CAA2D;AAG3D,MAAa,uBAAuB;IACnC,kDAAkD;IAClD,YAA8B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IACzC,KAAK;QACX,MAAM,cAAc,GAAG,IAAI,uCAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC1D,MAAM,WAAW,GAAG,IAAI,6CAAqB,CAAC,cAAc,CAAC,CAAA;QAC7D,MAAM,iBAAiB,GAAG,IAAI,2BAAiB,CAAC,WAAW,CAAC,CAAA;QAC5D,MAAM,iBAAiB,GAAG,IAAI,2BAAiB,CAAC,WAAW,CAAC,CAAA;QAC5D,MAAM,gBAAgB,GAAG,IAAI,8BAAgB,CAAC,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,CAAC;aAC9G,UAAU,CAAC,cAAO,CAAC,KAAK,EAAE,kCAA0B,CAAC;aACrD,UAAU,CAAC,cAAO,CAAC,OAAO,EAAE,sCAA4B,CAAC;aACzD,UAAU,CAAC,cAAO,CAAC,UAAU,EAAE,4CAA+B,CAAC;aAC/D,UAAU,CAAC,cAAO,CAAC,SAAS,EAAE,0CAA8B,CAAC;aAC7D,UAAU,CAAC,cAAO,CAAC,KAAK,EAAE,kCAA0B,CAAC;aACrD,UAAU,CAAC,cAAO,CAAC,MAAM,EAAE,oCAA2B,CAAC;aACvD,UAAU,CAAC,cAAO,CAAC,OAAO,EAAE,sCAA4B,CAAC;aACzD,UAAU,CAAC,cAAO,CAAC,IAAI,EAAE,gCAAyB,CAAC,CAAA;QACrD,OAAO,gBAAgB,CAAA;IACxB,CAAC;CACD;AAnBD,0DAmBC"}
|
|
@@ -10,6 +10,7 @@ export declare class SourceConnections {
|
|
|
10
10
|
private connections;
|
|
11
11
|
constructor(connectionFacade: ConnectionFacade, transactional: boolean);
|
|
12
12
|
get(source: string): Promise<Connection>;
|
|
13
|
+
/** a source Http commits first (docs/HTTP_SOURCE.md): if its API fails, the databases still roll back */
|
|
13
14
|
commit(): Promise<void>;
|
|
14
15
|
rollback(): Promise<void>;
|
|
15
16
|
release(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sourceConnections.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/execution/application/services/queryExecutor/sourceConnections.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sourceConnections.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/execution/application/services/queryExecutor/sourceConnections.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AAErE;;;GAGG;AACH,qBAAa,iBAAiB;IAGhB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAAoB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAFhG,OAAO,CAAC,WAAW,CAAuC;gBAE5B,gBAAgB,EAAE,gBAAgB,EAAmB,aAAa,EAAE,OAAO;IAE5F,GAAG,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAYtD,yGAAyG;IAC5F,MAAM,IAAK,OAAO,CAAC,IAAI,CAAC;IAQxB,QAAQ,IAAK,OAAO,CAAC,IAAI,CAAC;IAM1B,OAAO,IAAK,OAAO,CAAC,IAAI,CAAC;CAMtC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SourceConnections = void 0;
|
|
4
|
+
const base_1 = require("@lambdaorm/base");
|
|
4
5
|
/**
|
|
5
6
|
* The connections of an execution, one per source, acquired when first used. In a transaction every stage it touches
|
|
6
7
|
* shares them: a source used by two stages is one connection, so one database transaction.
|
|
@@ -23,8 +24,11 @@ class SourceConnections {
|
|
|
23
24
|
}
|
|
24
25
|
return connection;
|
|
25
26
|
}
|
|
27
|
+
/** a source Http commits first (docs/HTTP_SOURCE.md): if its API fails, the databases still roll back */
|
|
26
28
|
async commit() {
|
|
27
|
-
|
|
29
|
+
const sources = Object.keys(this.connections);
|
|
30
|
+
const first = sources.filter(p => this.connections[p].config?.dialect === base_1.Dialect.Http);
|
|
31
|
+
for (const source of [...first, ...sources.filter(p => !first.includes(p))]) {
|
|
28
32
|
await this.connections[source].commit();
|
|
29
33
|
}
|
|
30
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sourceConnections.js","sourceRoot":"","sources":["../../../../../../src/lib/execution/application/services/queryExecutor/sourceConnections.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"sourceConnections.js","sourceRoot":"","sources":["../../../../../../src/lib/execution/application/services/queryExecutor/sourceConnections.ts"],"names":[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,CAAC,QAAQ;QACpB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC1C,CAAC;IACF,CAAC;IAEM,KAAK,CAAC,OAAO;QACnB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAA;QAC9D,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,EAAE,CAAA;IACtB,CAAC;CACD;AAtCD,8CAsCC"}
|
|
@@ -7,6 +7,7 @@ import { ICache } from 'h3lp';
|
|
|
7
7
|
import { Expressions } from '3xpr';
|
|
8
8
|
import { Executor } from '../../execution/domain';
|
|
9
9
|
import { OrmH3lp } from '../../shared/infrastructure';
|
|
10
|
+
import { CrossSourcePlan } from './services/crossSourceQuery';
|
|
10
11
|
export declare class ExpressionFacade {
|
|
11
12
|
private readonly sentenceFacade;
|
|
12
13
|
private readonly schemaState;
|
|
@@ -17,6 +18,9 @@ export declare class ExpressionFacade {
|
|
|
17
18
|
private expressionExecute;
|
|
18
19
|
private readonly executor;
|
|
19
20
|
constructor(sentenceFacade: SentenceFacade, schemaState: SchemaState, languages: LanguagesService, executor: Executor, expressions: Expressions, cache: ICache<string, string>, helper: OrmH3lp);
|
|
21
|
+
private readonly crossQuery;
|
|
22
|
+
/** the plan of a query across sources (docs/CROSS_SOURCE.md), or undefined when it doesn't need it */
|
|
23
|
+
crossSourcePlan(query: string, options?: QueryOptions): CrossSourcePlan | undefined;
|
|
20
24
|
build(query: string, options?: QueryOptions): Query;
|
|
21
25
|
plan(query: string, options?: QueryOptions): QueryPlan;
|
|
22
26
|
solveQueryOptions(options?: QueryOptions): QueryOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["../../../../src/lib/expressions/application/facade.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAGrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAK7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAErD,qBAAa,gBAAgB;IAO3B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAR3B,OAAO,CAAC,WAAW,CAAY;IAC/B,OAAO,CAAC,YAAY,CAAY;IAChC,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,iBAAiB,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEhB,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,gBAAgB,EAC5C,QAAQ,EAAC,QAAQ,EACjB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,MAAM,EAAC,OAAO;
|
|
1
|
+
{"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["../../../../src/lib/expressions/application/facade.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,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AAK;IAIpD,IAAI,CAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,SAAS;IAQvD,iBAAiB,CAAE,OAAO,CAAC,EAAE,YAAY,GAAE,YAAY;IAiBjD,OAAO,CAAE,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;IAI7E,WAAW,CAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;IAIrE,WAAW,CAAE,OAAO,EAAE,YAAY,GAAC,SAAqB,EAAE,QAAQ,EAAE;QAAE,CAAC,EAAE,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7H,aAAa,CAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC;CAGlG"}
|
|
@@ -7,6 +7,7 @@ const plan_1 = require("./useCases/plan");
|
|
|
7
7
|
const queryBuilder_1 = require("./services/queryBuilder");
|
|
8
8
|
const queryBuilderCacheDecorator_1 = require("./services/queryBuilderCacheDecorator");
|
|
9
9
|
const execute_1 = require("./useCases/execute");
|
|
10
|
+
const crossSourceQuery_1 = require("./services/crossSourceQuery");
|
|
10
11
|
class ExpressionFacade {
|
|
11
12
|
constructor(sentenceFacade, schemaState, languages, executor, expressions, cache, helper) {
|
|
12
13
|
this.sentenceFacade = sentenceFacade;
|
|
@@ -17,12 +18,22 @@ class ExpressionFacade {
|
|
|
17
18
|
this.queryHelper = new queryHelper_1.QueryHelper(this.schemaState.stage, this.schemaState.view);
|
|
18
19
|
this.executor = executor;
|
|
19
20
|
this.expressionExecute = new execute_1.ExpressionExecute(this.builder, executor, expressions, helper, schemaState);
|
|
21
|
+
this.crossQuery = new crossSourceQuery_1.CrossSourceQuery(schemaState, expressions, helper);
|
|
22
|
+
}
|
|
23
|
+
/** the plan of a query across sources (docs/CROSS_SOURCE.md), or undefined when it doesn't need it */
|
|
24
|
+
crossSourcePlan(query, options) {
|
|
25
|
+
return this.crossQuery.plan(query, this.solveQueryOptions(options));
|
|
20
26
|
}
|
|
21
27
|
build(query, options) {
|
|
22
28
|
return this.builder.build(query, this.solveQueryOptions(options));
|
|
23
29
|
}
|
|
24
30
|
plan(query, options) {
|
|
25
|
-
|
|
31
|
+
const _options = this.solveQueryOptions(options);
|
|
32
|
+
// across sources: the sentences of what runs in the databases, and what runs in memory after them
|
|
33
|
+
const cross = this.crossQuery.plan(query, _options);
|
|
34
|
+
if (cross)
|
|
35
|
+
return { ...this.getQueryPlan.plan(cross.fetch, _options), inMemory: cross.inMemory };
|
|
36
|
+
return this.getQueryPlan.plan(query, _options);
|
|
26
37
|
}
|
|
27
38
|
solveQueryOptions(options) {
|
|
28
39
|
// inside a transaction (orm.transaction, a script) an execution without stage runs on the transaction's stage
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facade.js","sourceRoot":"","sources":["../../../../src/lib/expressions/application/facade.ts"],"names":[],"mappings":";AAAA,sDAAsD;;;AAKtD,wDAAoD;AACpD,0CAA6C;AAG7C,0DAAsD;AACtD,sFAAkF;AAClF,gDAAsD;AAOtD,MAAa,gBAAgB;IAM5B,YACkB,cAA8B,EAC9B,WAAwB,EACxB,SAA2B,EAC5C,QAAiB,EACjB,WAAwB,EACxB,KAA6B,EAC7B,MAAc;QANG,mBAAc,GAAd,cAAc,CAAgB;QAC9B,gBAAW,GAAX,WAAW,CAAa;QACxB,cAAS,GAAT,SAAS,CAAkB;QAK5C,IAAI,CAAC,OAAO,GAAG,IAAI,uDAA0B,CAAC,IAAI,2BAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,CA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EM,KAAK,CAAC,WAAW,CAAE,OAAiB,EAAE,OAAsB;QAClE,OAAO,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAA;IACpF,CAAC;IAEM,KAAK,CAAC,WAAW,CAAE,UAAkC,SAAS,EAAE,QAAmD;QACzH,OAAO,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAA;IACrF,CAAC;IAEM,KAAK,CAAC,aAAa,CAAE,MAAc,EAAE,OAAY,EAAE,EAAE,OAAuB;QAClF,OAAO,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAkB,CAAC,CAAA;IAC5G,CAAC;CACD;AAzED,4CAyEC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Expressions, Operand } from '3xpr';
|
|
2
|
+
import { QueryOptions, SchemaState } from '@lambdaorm/base';
|
|
3
|
+
import { OrmH3lp } from '../../../shared/infrastructure';
|
|
4
|
+
/** the rows a query across sources brings to sort or group in memory, by default */
|
|
5
|
+
export declare const CROSS_SOURCE_MAX_ROWS = 10000;
|
|
6
|
+
/** A query across sources, split (docs/CROSS_SOURCE.md): what runs in the databases and what in memory */
|
|
7
|
+
export interface CrossSourcePlan {
|
|
8
|
+
/** what runs in the databases: the root with its filters and the includes of the other sources */
|
|
9
|
+
fetch: string;
|
|
10
|
+
/** what runs in memory, in order: map, having, sort, page */
|
|
11
|
+
inMemory: string[];
|
|
12
|
+
/** the sort and the page went to the database of the root (they use only its fields) */
|
|
13
|
+
pushedDown: boolean;
|
|
14
|
+
/** the most rows the fetch can bring; undefined when it brings them all at once without a limit */
|
|
15
|
+
limit?: number;
|
|
16
|
+
steps: {
|
|
17
|
+
map?: Operand;
|
|
18
|
+
having?: Operand;
|
|
19
|
+
sort?: Operand;
|
|
20
|
+
page?: [number, number];
|
|
21
|
+
arrowVar: string;
|
|
22
|
+
relations: string[];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A map, a sort or a having with fields of a relation whose entity lives in another source can't be a JOIN (C6,
|
|
27
|
+
* docs/CROSS_SOURCE.md): `Orders.map(p => [p.id, p.customer.name]).sort(p => p.customer.name)` brings the orders with
|
|
28
|
+
* their filters and an include of their customer (each from its database), and then maps, groups, sorts and pages in
|
|
29
|
+
* memory with 3xpr. To sort or group in memory it brings at most maxRows rows (CrossSourceError when there are more).
|
|
30
|
+
*/
|
|
31
|
+
export declare class CrossSourceQuery {
|
|
32
|
+
private readonly schemaState;
|
|
33
|
+
private readonly expressions;
|
|
34
|
+
private readonly helper;
|
|
35
|
+
constructor(schemaState: SchemaState, expressions: Expressions, helper: OrmH3lp);
|
|
36
|
+
/** the plan of a query across sources, or undefined when the query doesn't need it */
|
|
37
|
+
plan(query: string, options: QueryOptions): CrossSourcePlan | undefined;
|
|
38
|
+
/** runs a query across sources: undefined when the query doesn't need it */
|
|
39
|
+
solve(query: string, data: any, options: QueryOptions, run: (query: string, data: any) => Promise<any[]>): Promise<{
|
|
40
|
+
result: any[];
|
|
41
|
+
} | undefined>;
|
|
42
|
+
private inMemory;
|
|
43
|
+
/** an expression with its arrow variable renamed */
|
|
44
|
+
private renamed;
|
|
45
|
+
/** the fields of a map: their name (as λORM names them), their text, and their aggregate */
|
|
46
|
+
private fields;
|
|
47
|
+
/** the name of a field of a map without a key: p.customer.name is customer_name, a function its name */
|
|
48
|
+
private nameOf;
|
|
49
|
+
private sortKeys;
|
|
50
|
+
private hasAggregates;
|
|
51
|
+
/** the clauses of the main chain */
|
|
52
|
+
private chain;
|
|
53
|
+
private vars;
|
|
54
|
+
private sourceOf;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=crossSourceQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
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