-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Reporting/np-k8] Remove several oncePerServer usages #50997
[Reporting/np-k8] Remove several oncePerServer usages #50997
Conversation
Pinging @elastic/kibana-stack-services (Team:Stack Services) |
💔 Build Failed |
'xpack.reporting.exportTypes.csv_from_savedobject.executeJob.failedToAccessPanel', | ||
{ defaultMessage: 'Failed to access panel metadata for job execution' } | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This had to be added for types reasoning: panel
can be undefined per the TS fixes in this PR.
💔 Build Failed |
💚 Build Succeeded |
💚 Build Succeeded |
@@ -193,9 +198,10 @@ export interface JobParamPostPayload { | |||
|
|||
export interface JobDocPayload { | |||
headers?: Record<string, string>; | |||
jobParams: object; | |||
jobParams: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JobDocPayload's jobParams depends on what kind of job it is. It could be an object with savedObjectId (CSV export) or a URL (PDF). Getting to a point where there is a "base" JobDocPayload
type that is extended for more specific contexts, has been hard with the way I've tried: any minor change can cause seemingly random TS checking to fail, at any place in Reporting code.
For now, I'm switching this to any
but I think the correct way to do this is with TypeScript Generics. At some point in the future, I could see that the way to get the JobDocPayload
type in a specific context would be to use a generic:
let fooPayloadA: JobDocPayload<JobParamsSavedObject>;
let fooPayloadB: JobDocPayload<JobParamsUrl>;
) => Promise<object>; | ||
) => Promise<JobParamsSavedObject | JobParamsUrl>; | ||
|
||
export type ImmediateCreateJobFn = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
function createJobFn(server: ServerFacade) { | ||
export function createJobFactory(server: ServerFacade): ESQueueCreateJobFnDiscoverCsv { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, there is another PR that does these changes: https://github.com/elastic/kibana/pull/49426/files#diff-e6c74eb5d977f06c7f116aa268248b9cR11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go with this one and I'll close the other
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inspired by @joelgriffith's PR, I think it would be better to do this like:
export const createJobFactory: CreateJobFactory = function createJobFn(server: ServerFacade) {
That's what I was originally looking for in my changes, but couldn't get the JS right.
import { JobParamsPNG, ESQueueCreateJobFnPNG } from '../../types'; | ||
|
||
function createJobFn(server: ServerFacade) { | ||
export function createJobFn(server: ServerFacade): ESQueueCreateJobFnPNG { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, bug: should be createJobFactory
@@ -39,7 +38,7 @@ const getReportingHeaders = (output: JobDocOutputExecuted, exportType: ExportTyp | |||
return metaDataHeaders; | |||
}; | |||
|
|||
function getDocumentPayloadFn(server: ServerFacade) { | |||
export function getDocumentPayloadFactory(server: ServerFacade) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM, I didn't see any test changes though? Guess that this is more side-effect in nature anyways.
There potentially would have been changes need in some of the mock objects that are tests are using for job params, and job payload, but since those are typed as |
@timroes can I please trouble you to take a 2nd look at this PR, or delegate someone outside of Stack Services to do so? I'd like to start getting outside teams a little familiar with Reporting code, as well as gather feedback on our types and integration with the new platform. The Reporting code going through change for New Platform migration are what take in all the integrations that all apps have with Reporting (job generation, deriving export type from the job params, etc). |
@elasticmachine merge upstream |
💚 Build Succeeded |
💚 Build Succeeded |
Hi Joel, since this almost was merged with a bug in it. The |
💚 Build Succeeded |
* [Reporting/np-k8] Remove several oncePerServer usages * ts fixes 1 * ts fixes 2 * more ts fixes * more ts fixes * more ts fixes * ts simplification * improve ts * remove any type for jobParams and define JobParamsSavedObject and JobParamsUrl * ts simplification * Fix ts * ts simplification * fix ts * bug fix * align with joels pr
💔 Build Failed |
* [Reporting/np-k8] Remove several oncePerServer usages * ts fixes 1 * ts fixes 2 * more ts fixes * more ts fixes * more ts fixes * ts simplification * improve ts * remove any type for jobParams and define JobParamsSavedObject and JobParamsUrl * ts simplification * Fix ts * ts simplification * fix ts * bug fix * align with joels pr
Summary
Pulled from #50973
This is part of Reporting New Platform migration efforts: removing references of the Hapi
server
object.Working on New Platform changes to remove references to the Hapi server object caused a trickle of TS check failures. This PR handles mostly the fixes for the failures, as well as the low-fruit changes for removing references to the server object.
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.[ ] This was checked for cross-browser compatibility, including a check against IE11[ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support[ ] Documentation was added for features that require explanation or tutorials[ ] Unit or functional tests were updated or added to match the most common scenarios[ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers
[ ] This includes a feature addition or change that requires a release note and was labeled appropriately