Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into ingest/epm-list
Browse files Browse the repository at this point in the history
  • Loading branch information
jen-huang committed Mar 16, 2020
2 parents fd29a13 + ef32611 commit f5aa8d0
Show file tree
Hide file tree
Showing 25 changed files with 786 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

## SavedObject interface


<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

## SavedObject interface


<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,8 @@ export type RecursiveReadonly<T> = T extends (...args: any[]) => any ? T : T ext
[K in keyof T]: RecursiveReadonly<T[K]>;
}> : T;

// Warning: (ae-missing-release-tag) "SavedObject" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface SavedObject<T = unknown> {
attributes: T;
Expand Down
13 changes: 8 additions & 5 deletions src/core/public/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ export {
export { SimpleSavedObject } from './simple_saved_object';
export { SavedObjectsStart, SavedObjectsService } from './saved_objects_service';
export {
SavedObject,
SavedObjectAttribute,
SavedObjectAttributes,
SavedObjectAttributeSingle,
SavedObjectReference,
SavedObjectsBaseOptions,
SavedObjectsFindOptions,
SavedObjectsMigrationVersion,
Expand All @@ -48,3 +43,11 @@ export {
SavedObjectsImportError,
SavedObjectsImportRetry,
} from '../../server/types';

export {
SavedObject,
SavedObjectAttribute,
SavedObjectAttributes,
SavedObjectAttributeSingle,
SavedObjectReference,
} from '../../types';
59 changes: 5 additions & 54 deletions src/core/server/saved_objects/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,66 +35,17 @@ export {
import { LegacyConfig } from '../legacy';
import { SavedObjectUnsanitizedDoc } from './serialization';
import { SavedObjectsMigrationLogger } from './migrations/core/migration_logger';
import { SavedObject } from '../../types';

export {
SavedObjectAttributes,
SavedObjectAttribute,
SavedObjectAttributeSingle,
SavedObject,
SavedObjectReference,
SavedObjectsMigrationVersion,
} from '../../types';

/**
* Information about the migrations that have been applied to this SavedObject.
* When Kibana starts up, KibanaMigrator detects outdated documents and
* migrates them based on this value. For each migration that has been applied,
* the plugin's name is used as a key and the latest migration version as the
* value.
*
* @example
* migrationVersion: {
* dashboard: '7.1.1',
* space: '6.6.6',
* }
*
* @public
*/
export interface SavedObjectsMigrationVersion {
[pluginName: string]: string;
}

/**
* @public
*/
export interface SavedObject<T = unknown> {
/** The ID of this Saved Object, guaranteed to be unique for all objects of the same `type` */
id: string;
/** The type of Saved Object. Each plugin can define it's own custom Saved Object types. */
type: string;
/** An opaque version number which changes on each successful write operation. Can be used for implementing optimistic concurrency control. */
version?: string;
/** Timestamp of the last time this document had been updated. */
updated_at?: string;
error?: {
message: string;
statusCode: number;
};
/** {@inheritdoc SavedObjectAttributes} */
attributes: T;
/** {@inheritdoc SavedObjectReference} */
references: SavedObjectReference[];
/** {@inheritdoc SavedObjectsMigrationVersion} */
migrationVersion?: SavedObjectsMigrationVersion;
}

/**
* A reference to another saved object.
*
* @public
*/
export interface SavedObjectReference {
name: string;
type: string;
id: string;
}

/**
*
* @public
Expand Down
2 changes: 2 additions & 0 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,8 @@ export interface RouteValidatorOptions {
// @public
export type SafeRouteMethod = 'get' | 'options';

// Warning: (ae-missing-release-tag) "SavedObject" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface SavedObject<T = unknown> {
attributes: T;
Expand Down
51 changes: 51 additions & 0 deletions src/core/types/saved_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,54 @@ export type SavedObjectAttribute = SavedObjectAttributeSingle | SavedObjectAttri
export interface SavedObjectAttributes {
[key: string]: SavedObjectAttribute;
}

/**
* A reference to another saved object.
*
* @public
*/
export interface SavedObjectReference {
name: string;
type: string;
id: string;
}

/**
* Information about the migrations that have been applied to this SavedObject.
* When Kibana starts up, KibanaMigrator detects outdated documents and
* migrates them based on this value. For each migration that has been applied,
* the plugin's name is used as a key and the latest migration version as the
* value.
*
* @example
* migrationVersion: {
* dashboard: '7.1.1',
* space: '6.6.6',
* }
*
* @public
*/
export interface SavedObjectsMigrationVersion {
[pluginName: string]: string;
}

export interface SavedObject<T = unknown> {
/** The ID of this Saved Object, guaranteed to be unique for all objects of the same `type` */
id: string;
/** The type of Saved Object. Each plugin can define it's own custom Saved Object types. */
type: string;
/** An opaque version number which changes on each successful write operation. Can be used for implementing optimistic concurrency control. */
version?: string;
/** Timestamp of the last time this document had been updated. */
updated_at?: string;
error?: {
message: string;
statusCode: number;
};
/** {@inheritdoc SavedObjectAttributes} */
attributes: T;
/** {@inheritdoc SavedObjectReference} */
references: SavedObjectReference[];
/** {@inheritdoc SavedObjectsMigrationVersion} */
migrationVersion?: SavedObjectsMigrationVersion;
}
32 changes: 3 additions & 29 deletions x-pack/legacy/plugins/maps/server/maps_telemetry/maps_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
// @ts-ignore
} from '../../common/constants';
import { LayerDescriptor } from '../../common/descriptor_types';
import { MapSavedObject } from '../../../../../plugins/maps/common/map_saved_object_type';

interface IStats {
[key: string]: {
Expand All @@ -32,33 +33,6 @@ interface ILayerTypeCount {
[key: string]: number;
}

interface IMapSavedObject {
[key: string]: any;
fields: IFieldType[];
title: string;
id?: string;
type?: string;
timeFieldName?: string;
fieldFormatMap?: Record<
string,
{
id: string;
params: unknown;
}
>;
attributes?: {
title?: string;
description?: string;
mapStateJSON?: string;
layerListJSON?: string;
uiStateJSON?: string;
bounds?: {
type?: string;
coordinates?: [];
};
};
}

function getUniqueLayerCounts(layerCountsList: ILayerTypeCount[], mapsCount: number) {
const uniqueLayerTypes = _.uniq(_.flatten(layerCountsList.map(lTypes => Object.keys(lTypes))));

Expand Down Expand Up @@ -102,7 +76,7 @@ export function buildMapsTelemetry({
indexPatternSavedObjects,
settings,
}: {
mapSavedObjects: IMapSavedObject[];
mapSavedObjects: MapSavedObject[];
indexPatternSavedObjects: IIndexPattern[];
settings: SavedObjectAttribute;
}): SavedObjectAttributes {
Expand Down Expand Up @@ -183,7 +157,7 @@ export async function getMapsTelemetry(
savedObjectsClient: SavedObjectsClientContract,
config: Function
) {
const mapSavedObjects: IMapSavedObject[] = await getMapSavedObjects(savedObjectsClient);
const mapSavedObjects: MapSavedObject[] = await getMapSavedObjects(savedObjectsClient);
const indexPatternSavedObjects: IIndexPattern[] = await getIndexPatternSavedObjects(
savedObjectsClient
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,21 @@ export function registerGenerateFromJobParams(
}

const { exportType } = request.params;
let jobParams;
let response;
try {
const jobParams = rison.decode(jobParamsRison) as object | null;
jobParams = rison.decode(jobParamsRison) as object | null;
if (!jobParams) {
throw new Error('missing jobParams!');
}
response = await handler(exportType, jobParams, legacyRequest, h);
} catch (err) {
throw boom.badRequest(`invalid rison: ${jobParamsRison}`);
}
try {
response = await handler(exportType, jobParams, legacyRequest, h);
} catch (err) {
throw handleError(exportType, err);
}
return response;
},
});
Expand Down
Loading

0 comments on commit f5aa8d0

Please sign in to comment.