UNPKG

1.94 kBPlain TextView Raw
1// Copyright IBM Corp. and LoopBack contributors 2018,2019. All Rights Reserved.
2// Node module: @loopback/repository
3// This file is licensed under the MIT License.
4// License text available at https://opensource.org/licenses/MIT
5
6import {
7 AnyObject,
8 Command,
9 NamedParameters,
10 Options,
11 PositionalParameters,
12} from '../common-types';
13import {Model} from '../model';
14
15/**
16 * Interfaces adopted by a {@link Connector}.
17 *
18 * @experimental
19 */
20export namespace ConnectorInterfaces {
21 /**
22 * Strong relation interfaces adopted by a {@link Connector}
23 *
24 * @experimental
25 */
26 export const enum StrongRelation {
27 BELONGS_TO = 'strongBelongsTo',
28 HAS_ONE = 'strongHasOne',
29 HAS_MANY = 'strongHasMany',
30 HAS_MANY_THROUGH = 'strongHasManyThrough',
31 HAS_AND_BELONGS_TO_MANY = 'strongHasAndBelongsToMany',
32 EMBEDS_ONE = 'strongEmbedsOne',
33 EMBEDS_MANY = 'strongEmbedsMany',
34 REFERNCES_MANY = 'strongReferencesMany',
35 }
36
37 /**
38 * Strong query join interfaces adopted by a {@link Connector}
39 *
40 * @experimental
41 */
42 export const enum StrongJoins {
43 INNER = 'strongInnerJoin',
44 LEFT = 'strongLeftJoin',
45 RIGHT = 'strongRightJoin',
46 FULL = 'strongFullJoin',
47 CARTESIAN = 'strongCartesianJoin',
48 }
49}
50
51/**
52 * Common properties/operations for connectors
53 */
54export interface Connector {
55 name: string; // Name/type of the connector
56 configModel?: Model; // The configuration model
57 interfaces?: (
58 | string
59 | ConnectorInterfaces.StrongRelation
60 | ConnectorInterfaces.StrongJoins
61 )[]; // A list of interfaces implemented by the connector
62 connect(): Promise<void>; // Connect to the underlying system
63 disconnect(): Promise<void>; // Disconnect from the underlying system
64 ping(): Promise<void>; // Ping the underlying system
65 execute?(
66 command: Command,
67 parameters: NamedParameters | PositionalParameters,
68 options?: Options,
69 ): Promise<AnyObject>;
70}