-
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
[File upload][Maps] NP migration for server & client #51045
Changes from all commits
c5ff754
ba8ac43
2169a73
dcd9444
340e611
4cfbe91
7593926
afcfe02
42d1f97
562850a
65e517b
a5d4f1e
359fc5f
deeacd0
8c64c06
9bfc86d
c202aa8
06b59eb
8bdb72b
baaa1b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export const mappings = { | ||
'file-upload-telemetry': { | ||
properties: { | ||
filesUploadedTotalCount: { | ||
type: 'long', | ||
}, | ||
}, | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { npStart } from 'ui/new_platform'; | ||
import { plugin } from '.'; | ||
|
||
const pluginInstance = plugin(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this module hopping? Is this something from the platform?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again just sticking with the expected shape for consistency with other plugins at this stage. Ultimately this file will go away when moved though. |
||
|
||
export const start = pluginInstance.start(npStart.core); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the rename when it is being renamed yet again when it is imported? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related to the previous comment on naming it "start". Here's the relevant section in the migration guide. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { Plugin, CoreStart } from 'src/core/public'; | ||
// @ts-ignore | ||
import { initResources } from './util/indexing_service'; | ||
// @ts-ignore | ||
import { JsonUploadAndParse } from './components/json_upload_and_parse'; | ||
// @ts-ignore | ||
import { initServicesAndConstants } from './kibana_services'; | ||
|
||
/** | ||
* These are the interfaces with your public contracts. You should export these | ||
* for other plugins to use in _their_ `SetupDeps`/`StartDeps` interfaces. | ||
* @public | ||
*/ | ||
export type FileUploadPluginSetup = ReturnType<FileUploadPlugin['setup']>; | ||
export type FileUploadPluginStart = ReturnType<FileUploadPlugin['start']>; | ||
|
||
/** @internal */ | ||
export class FileUploadPlugin implements Plugin<FileUploadPluginSetup, FileUploadPluginStart> { | ||
public setup() {} | ||
|
||
public start(core: CoreStart) { | ||
initServicesAndConstants(core); | ||
return { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any reason this is wrapped in an object? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just another convention they used in the guide and I saw used around. |
||
JsonUploadAndParse, | ||
}; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,22 +4,23 @@ | |
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { http } from './http_service'; | ||
import chrome from 'ui/chrome'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { indexPatternService } from '../kibana_services'; | ||
import { http as httpService } from './http_service'; | ||
import { | ||
indexPatternService, | ||
apiBasePath, | ||
savedObjectsClient | ||
} from '../kibana_services'; | ||
import { getGeoJsonIndexingDetails } from './geo_processing'; | ||
import { sizeLimitedChunking } from './size_limited_chunking'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
const basePath = chrome.addBasePath('/api/fileupload'); | ||
const fileType = 'json'; | ||
|
||
export async function indexData(parsedFile, transformDetails, indexName, dataType, appName) { | ||
if (!parsedFile) { | ||
throw(i18n.translate('xpack.fileUpload.indexingService.noFileImported', { | ||
defaultMessage: 'No file imported.' | ||
})); | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
} | ||
|
||
// Perform any processing required on file prior to indexing | ||
|
@@ -129,8 +130,8 @@ async function writeToIndex(indexingDetails) { | |
ingestPipeline | ||
} = indexingDetails; | ||
|
||
return await http({ | ||
url: `${basePath}/import${paramString}`, | ||
return await httpService({ | ||
url: `${apiBasePath}/fileupload/import${paramString}`, | ||
method: 'POST', | ||
data: { | ||
index, | ||
|
@@ -223,7 +224,6 @@ export async function createIndexPattern(indexPatternName) { | |
} | ||
|
||
async function getIndexPatternId(name) { | ||
const savedObjectsClient = chrome.getSavedObjectsClient(); | ||
const savedObjectSearch = | ||
await savedObjectsClient.find({ type: 'index-pattern', perPage: 1000 }); | ||
const indexPatternSavedObjects = savedObjectSearch.savedObjects; | ||
|
@@ -237,9 +237,8 @@ async function getIndexPatternId(name) { | |
} | ||
|
||
export const getExistingIndexNames = async () => { | ||
const basePath = chrome.addBasePath('/api'); | ||
const indexes = await http({ | ||
url: `${basePath}/index_management/indices`, | ||
const indexes = await httpService({ | ||
url: `${apiBasePath}/index_management/indices`, | ||
method: 'GET', | ||
}); | ||
return indexes | ||
|
@@ -248,7 +247,6 @@ export const getExistingIndexNames = async () => { | |
}; | ||
|
||
export const getExistingIndexPatternNames = async () => { | ||
const savedObjectsClient = chrome.getSavedObjectsClient(); | ||
const indexPatterns = await savedObjectsClient.find({ | ||
type: 'index-pattern', | ||
fields: ['id', 'title', 'type', 'fields'], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { getImportRouteHandler } from './routes/file_upload'; | ||
import { getTelemetry, initTelemetry } from './telemetry/telemetry'; | ||
import { MAX_BYTES } from '../common/constants/file_import'; | ||
|
||
const TELEMETRY_TYPE = 'fileUploadTelemetry'; | ||
|
||
export class FileUploadPlugin { | ||
setup(core, plugins, __LEGACY) { | ||
const elasticsearchPlugin = __LEGACY.plugins.elasticsearch; | ||
const getSavedObjectsRepository = __LEGACY.savedObjects.getSavedObjectsRepository; | ||
const makeUsageCollector = __LEGACY.usage.collectorSet.makeUsageCollector; | ||
|
||
// Set up route | ||
__LEGACY.route({ | ||
method: 'POST', | ||
path: '/api/fileupload/import', | ||
handler: getImportRouteHandler(elasticsearchPlugin, getSavedObjectsRepository), | ||
config: { | ||
payload: { maxBytes: MAX_BYTES }, | ||
} | ||
}); | ||
|
||
// Make usage collector | ||
makeUsageCollector({ | ||
type: TELEMETRY_TYPE, | ||
isReady: () => true, | ||
fetch: async () => (await getTelemetry(elasticsearchPlugin, getSavedObjectsRepository)) || initTelemetry() | ||
}); | ||
} | ||
} |
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.
that looks weird
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.
Pulled from the example on that one and found a few others who used the same syntax. No strong feelings either way personally so I just stuck with the example syntax