1 |
|
2 | import { Application, Binding, BindingFromClassOptions, BindingScope, Component, Constructor, MixinTarget } from '@loopback/core';
|
3 | import { Class } from '../common-types';
|
4 | import { SchemaMigrationOptions } from '../datasource';
|
5 | import { Model } from '../model';
|
6 | import { juggler, Repository } from '../repositories';
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | export declare function RepositoryMixin<T extends MixinTarget<Application>>(superClass: T): {
|
28 | new (...args: any[]): {
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | repository<R extends Repository<any>>(repoClass: Class<R>, nameOrOptions?: string | BindingFromClassOptions): Binding<R>;
|
59 | |
60 |
|
61 |
|
62 |
|
63 |
|
64 | getRepository<R_1 extends Repository<any>>(repo: Class<R_1>): Promise<R_1>;
|
65 | |
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 | dataSource<D extends juggler.DataSource>(dataSource: D | Class<D>, nameOrOptions?: string | BindingFromClassOptions): Binding<D>;
|
89 | |
90 |
|
91 |
|
92 |
|
93 | model<M extends Class<unknown>>(modelClass: M): Binding<M>;
|
94 | |
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 | component<C extends Component = Component>(componentCtor: Constructor<C>, nameOrOptions?: string | BindingFromClassOptions): Binding<C>;
|
117 | |
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 | mountComponentRepositories(componentInstanceOrClass: Class<unknown> | RepositoryComponent): void;
|
130 | |
131 |
|
132 |
|
133 |
|
134 |
|
135 | mountComponentModels(component: RepositoryComponent): void;
|
136 | |
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 | migrateSchema(options?: SchemaMigrationOptions): Promise<void>;
|
150 | readonly options: import("@loopback/core").ApplicationConfig;
|
151 | readonly state: string;
|
152 | controller: <T>(controllerCtor: import("@loopback/core").ControllerClass<T>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T>;
|
153 | server: <T_1 extends import("@loopback/core").Server>(ctor: Constructor<T_1>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T_1>;
|
154 | servers: <T_2 extends import("@loopback/core").Server>(ctors: Constructor<T_2>[]) => Binding<any>[];
|
155 | getServer: <T_3 extends import("@loopback/core").Server>(target: string | Constructor<T_3>) => Promise<T_3>;
|
156 | init: () => Promise<void>;
|
157 | onInit: (fn: () => import("@loopback/core").ValueOrPromise<void>) => Binding<import("@loopback/core").LifeCycleObserver>;
|
158 | start: () => Promise<void>;
|
159 | onStart: (fn: () => import("@loopback/core").ValueOrPromise<void>) => Binding<import("@loopback/core").LifeCycleObserver>;
|
160 | stop: () => Promise<void>;
|
161 | onStop: (fn: () => import("@loopback/core").ValueOrPromise<void>) => Binding<import("@loopback/core").LifeCycleObserver>;
|
162 | setMetadata: (metadata: import("@loopback/core").ApplicationMetadata) => void;
|
163 | lifeCycleObserver: <T_4 extends import("@loopback/core").LifeCycleObserver>(ctor: Constructor<T_4>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T_4>;
|
164 | service: <S>(cls: import("@loopback/core").ServiceOrProviderClass<S>, nameOrOptions?: string | import("@loopback/core").ServiceOptions | undefined) => Binding<S>;
|
165 | interceptor: (interceptor: import("@loopback/core").Interceptor | Constructor<import("@loopback/core").Provider<import("@loopback/core").Interceptor>>, nameOrOptions?: string | import("@loopback/core").InterceptorBindingOptions | undefined) => Binding<import("@loopback/core").Interceptor>;
|
166 | readonly name: string;
|
167 | readonly subscriptionManager: import("@loopback/core").ContextSubscriptionManager;
|
168 | scope: BindingScope;
|
169 | readonly parent: import("@loopback/core").Context | undefined;
|
170 | emitEvent: <T_5 extends import("@loopback/core").ContextEvent>(type: string, event: T_5) => void;
|
171 | emitError: (err: unknown) => void;
|
172 | bind: <ValueType = any>(key: import("@loopback/core").BindingAddress<ValueType>) => Binding<ValueType>;
|
173 | add: (binding: Binding<unknown>) => Application;
|
174 | configure: <ConfigValueType = any>(key?: import("@loopback/core").BindingAddress | undefined) => Binding<ConfigValueType>;
|
175 | getConfigAsValueOrPromise: <ConfigValueType_1>(key: import("@loopback/core").BindingAddress, propertyPath?: string | undefined, resolutionOptions?: import("@loopback/core").ResolutionOptions | undefined) => import("@loopback/core").ValueOrPromise<ConfigValueType_1 | undefined>;
|
176 | getConfig: <ConfigValueType_2>(key: import("@loopback/core").BindingAddress, propertyPath?: string | undefined, resolutionOptions?: import("@loopback/core").ResolutionOptions | undefined) => Promise<ConfigValueType_2 | undefined>;
|
177 | getConfigSync: <ConfigValueType_3>(key: import("@loopback/core").BindingAddress, propertyPath?: string | undefined, resolutionOptions?: import("@loopback/core").ResolutionOptions | undefined) => ConfigValueType_3 | undefined;
|
178 | unbind: (key: import("@loopback/core").BindingAddress) => boolean;
|
179 | subscribe: (observer: import("@loopback/core").ContextEventObserver) => import("@loopback/core").Subscription;
|
180 | unsubscribe: (observer: import("@loopback/core").ContextEventObserver) => boolean;
|
181 | close: () => void;
|
182 | isSubscribed: (observer: import("@loopback/core").ContextObserver) => boolean;
|
183 | createView: <T_6 = unknown>(filter: import("@loopback/core").BindingFilter, comparator?: import("@loopback/core").BindingComparator | undefined, options?: Omit<import("@loopback/core").ResolutionOptions, "session"> | undefined) => import("@loopback/core").ContextView<T_6>;
|
184 | contains: (key: import("@loopback/core").BindingAddress) => boolean;
|
185 | isBound: (key: import("@loopback/core").BindingAddress) => boolean;
|
186 | getOwnerContext: (keyOrBinding: import("@loopback/core").BindingAddress | Readonly<Binding<unknown>>) => import("@loopback/core").Context | undefined;
|
187 | getScopedContext: (scope: BindingScope.APPLICATION | BindingScope.SERVER | BindingScope.REQUEST) => import("@loopback/core").Context | undefined;
|
188 | getResolutionContext: (binding: Readonly<Binding<unknown>>) => import("@loopback/core").Context | undefined;
|
189 | isVisibleTo: (ctx: import("@loopback/core").Context) => boolean;
|
190 | find: <ValueType_1 = any>(pattern?: string | RegExp | import("@loopback/core").BindingFilter | undefined) => Readonly<Binding<ValueType_1>>[];
|
191 | findByTag: <ValueType_2 = any>(tagFilter: RegExp | import("@loopback/core").BindingTag) => Readonly<Binding<ValueType_2>>[];
|
192 | get: {
|
193 | <ValueType_3>(keyWithPath: import("@loopback/core").BindingAddress<ValueType_3>, session?: import("@loopback/core").ResolutionSession | undefined): Promise<ValueType_3>;
|
194 | <ValueType_4>(keyWithPath: import("@loopback/core").BindingAddress<ValueType_4>, options: import("@loopback/core").ResolutionOptions): Promise<ValueType_4 | undefined>;
|
195 | };
|
196 | getSync: {
|
197 | <ValueType_5>(keyWithPath: import("@loopback/core").BindingAddress<ValueType_5>, session?: import("@loopback/core").ResolutionSession | undefined): ValueType_5;
|
198 | <ValueType_6>(keyWithPath: import("@loopback/core").BindingAddress<ValueType_6>, options?: import("@loopback/core").ResolutionOptions | undefined): ValueType_6 | undefined;
|
199 | };
|
200 | getBinding: {
|
201 | <ValueType_7 = any>(key: import("@loopback/core").BindingAddress<ValueType_7>): Binding<ValueType_7>;
|
202 | <ValueType_8>(key: import("@loopback/core").BindingAddress<ValueType_8>, options?: {
|
203 | optional?: boolean | undefined;
|
204 | } | undefined): Binding<ValueType_8> | undefined;
|
205 | };
|
206 | findOrCreateBinding: <T_7>(key: import("@loopback/core").BindingAddress<T_7>, policy?: import("@loopback/core").BindingCreationPolicy | undefined) => Binding<T_7>;
|
207 | getValueOrPromise: <ValueType_9>(keyWithPath: import("@loopback/core").BindingAddress<ValueType_9>, optionsOrSession?: import("@loopback/core").ResolutionOptionsOrSession | undefined) => import("@loopback/core").ValueOrPromise<ValueType_9 | undefined>;
|
208 | toJSON: () => import("@loopback/core").JSONObject;
|
209 | inspect: (options?: import("@loopback/core").ContextInspectOptions | undefined) => import("@loopback/core").JSONObject;
|
210 | on: {
|
211 | (eventName: "bind" | "unbind", listener: import("@loopback/core").ContextEventListener): Application;
|
212 | (event: string | symbol, listener: (...args: any[]) => void): Application;
|
213 | };
|
214 | once: {
|
215 | (eventName: "bind" | "unbind", listener: import("@loopback/core").ContextEventListener): Application;
|
216 | (event: string | symbol, listener: (...args: any[]) => void): Application;
|
217 | };
|
218 | [EventEmitter.captureRejectionSymbol]?: (<K>(error: Error, event: string | symbol, ...args: any[]) => void) | undefined;
|
219 | addListener: <K_1>(eventName: string | symbol, listener: (...args: any[]) => void) => Application;
|
220 | removeListener: <K_2>(eventName: string | symbol, listener: (...args: any[]) => void) => Application;
|
221 | off: <K_3>(eventName: string | symbol, listener: (...args: any[]) => void) => Application;
|
222 | removeAllListeners: (event?: string | symbol | undefined) => Application;
|
223 | setMaxListeners: (n: number) => Application;
|
224 | getMaxListeners: () => number;
|
225 | listeners: <K_4>(eventName: string | symbol) => Function[];
|
226 | rawListeners: <K_5>(eventName: string | symbol) => Function[];
|
227 | emit: <K_6>(eventName: string | symbol, ...args: any[]) => boolean;
|
228 | listenerCount: <K_7>(eventName: string | symbol, listener?: Function | undefined) => number;
|
229 | prependListener: <K_8>(eventName: string | symbol, listener: (...args: any[]) => void) => Application;
|
230 | prependOnceListener: <K_9>(eventName: string | symbol, listener: (...args: any[]) => void) => Application;
|
231 | eventNames: () => (string | symbol)[];
|
232 | };
|
233 | } & T;
|
234 |
|
235 |
|
236 |
|
237 |
|
238 | export interface RepositoryComponent {
|
239 | |
240 |
|
241 |
|
242 |
|
243 | repositories?: Class<Repository<Model>>[];
|
244 | |
245 |
|
246 |
|
247 |
|
248 | models?: Class<Model>[];
|
249 | }
|
250 |
|
251 |
|
252 |
|
253 | export interface ApplicationWithRepositories extends Application {
|
254 | repository<R extends Repository<any>>(repo: Class<R>, name?: string): Binding<R>;
|
255 | getRepository<R extends Repository<any>>(repo: Class<R>): Promise<R>;
|
256 | dataSource<D extends juggler.DataSource>(dataSource: Class<D> | D, name?: string): Binding<D>;
|
257 | model<M extends Class<unknown>>(modelClass: M): Binding<M>;
|
258 | component(component: Class<unknown>, name?: string): Binding;
|
259 | mountComponentRepositories(component: Class<unknown>): void;
|
260 | migrateSchema(options?: SchemaMigrationOptions): Promise<void>;
|
261 | }
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 | export declare class RepositoryMixinDoc {
|
270 | constructor(...args: any[]);
|
271 | /**
|
272 | * Add a repository to this application.
|
273 | *
|
274 | * @param repo - The repository to add.
|
275 | *
|
276 | * @example
|
277 | * ```ts
|
278 | *
|
279 | * class NoteRepo {
|
280 | * model: any;
|
281 | *
|
282 | * constructor() {
|
283 | * const ds: juggler.DataSource = new juggler.DataSource({
|
284 | * name: 'db',
|
285 | * connector: 'memory',
|
286 | * });
|
287 | *
|
288 | * this.model = ds.createModel(
|
289 | * 'note',
|
290 | * {title: 'string', content: 'string'},
|
291 | * {}
|
292 | * );
|
293 | * }
|
294 | * };
|
295 | *
|
296 | * app.repository(NoteRepo);
|
297 | * ```
|
298 | */
|
299 | repository(repo: Class<Repository<any>>): Binding;
|
300 | /**
|
301 | * Retrieve the repository instance from the given Repository class
|
302 | *
|
303 | * @param repo - The repository class to retrieve the instance of
|
304 | */
|
305 | getRepository<R extends Repository<any>>(repo: Class<R>): Promise<R>;
|
306 | /**
|
307 | * Add the dataSource to this application.
|
308 | *
|
309 | * @param dataSource - The dataSource to add.
|
310 | * @param name - The binding name of the datasource; defaults to dataSource.name
|
311 | *
|
312 | * @example
|
313 | * ```ts
|
314 | *
|
315 | * const ds: juggler.DataSource = new juggler.DataSource({
|
316 | * name: 'db',
|
317 | * connector: 'memory',
|
318 | * });
|
319 | *
|
320 | * app.dataSource(ds);
|
321 | *
|
322 | *
|
323 | * constructor(@inject('datasources.db') dataSource: DataSourceType) {
|
324 | *
|
325 | * }
|
326 | * ```
|
327 | */
|
328 | dataSource(dataSource: Class<juggler.DataSource> | juggler.DataSource, name?: string): Binding;
|
329 | /**
|
330 | * Add a component to this application. Also mounts
|
331 | * all the components repositories.
|
332 | *
|
333 | * @param component - The component to add.
|
334 | *
|
335 | * @example
|
336 | * ```ts
|
337 | *
|
338 | * export class ProductComponent {
|
339 | * controllers = [ProductController];
|
340 | * repositories = [ProductRepo, UserRepo];
|
341 | * providers = {
|
342 | * [AUTHENTICATION_STRATEGY]: AuthStrategy,
|
343 | * [AUTHORIZATION_ROLE]: Role,
|
344 | * };
|
345 | * };
|
346 | *
|
347 | * app.component(ProductComponent);
|
348 | * ```
|
349 | */
|
350 | component(component: Class<{}>): Binding;
|
351 | /**
|
352 | * Get an instance of a component and mount all it's
|
353 | * repositories. This function is intended to be used internally
|
354 | * by component()
|
355 | *
|
356 | * @param component - The component to mount repositories of
|
357 | */
|
358 | mountComponentRepository(component: Class<{}>): void;
|
359 | /**
|
360 | * Update or recreate the database schema for all repositories.
|
361 | *
|
362 | * **WARNING**: By default, `migrateSchema()` will attempt to preserve data
|
363 | * while updating the schema in your target database, but this is not
|
364 | * guaranteed to be safe.
|
365 | *
|
366 | * Please check the documentation for your specific connector(s) for
|
367 | * a detailed breakdown of behaviors for automigrate!
|
368 | *
|
369 | * @param options - Migration options, e.g. whether to update tables
|
370 | * preserving data or rebuild everything from scratch.
|
371 | */
|
372 | migrateSchema(options?: SchemaMigrationOptions): Promise<void>;
|
373 | }
|
374 | /**
|
375 | * Create a binding for the given model class
|
376 | * @param modelClass - Model class
|
377 | */
|
378 | export declare function createModelClassBinding<M extends Class<unknown>>(modelClass: M): Binding<M>;
|
379 |
|
\ | No newline at end of file |