Skip to content

Commit

Permalink
Properly pass plugins to routes
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar committed Nov 24, 2024
1 parent 95440e2 commit c46d94c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,18 @@ export class ObservabilityAIAssistantPlugin
];
}),
};
}) as ObservabilityAIAssistantRouteHandlerResources['plugins'];
}) as Pick<
ObservabilityAIAssistantRouteHandlerResources['plugins'],
keyof ObservabilityAIAssistantPluginStartDependencies
>;

const withCore = {
...routeHandlerPlugins,
core: {
setup: core,
start: () => core.getStartServices().then(([coreStart]) => coreStart),
},
};

const service = (this.service = new ObservabilityAIAssistantService({
logger: this.logger.get('service'),
Expand All @@ -133,7 +144,7 @@ export class ObservabilityAIAssistantPlugin
core,
logger: this.logger,
dependencies: {
plugins: routeHandlerPlugins,
plugins: withCore,
service: this.service,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export type ObservabilityAIAssistantRequestHandlerContext = Omit<
savedObjects: {
client: SavedObjectsClientContract;
};
coreStart: CoreStart;
}>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ export class ObservabilityAIAssistantAppPlugin
};
}),
core: Promise.resolve({
coreStart,
elasticsearch: {
client: coreStart.elasticsearch.client.asScoped(request),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ describe('observabilityAIAssistant rule_connector', () => {
getAdhocInstructions: () => [],
}),
},
context: {
core: Promise.resolve({
coreStart: { http: { basePath: { publicBaseUrl: 'http://kibana.com' } } },
}),
},
context: {},
plugins: {
core: {
start: () =>
Promise.resolve({
http: { basePath: { publicBaseUrl: 'http://kibana.com' } },
}),
},
actions: {
start: async () => {
return {
Expand Down

0 comments on commit c46d94c

Please sign in to comment.