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