Skip to content

Commit 1f9c182

Browse files
Merge branch '7.x' into backport/7.x/pr-64396
2 parents f3a1e37 + 50ff9ca commit 1f9c182

File tree

386 files changed

+10809
-6259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

386 files changed

+10809
-6259
lines changed

docs/development/core/server/kibana-plugin-core-server.savedobjectmigrationfn.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,36 @@ A migration function for a [saved object type](./kibana-plugin-core-server.saved
99
<b>Signature:</b>
1010

1111
```typescript
12-
export declare type SavedObjectMigrationFn = (doc: SavedObjectUnsanitizedDoc, context: SavedObjectMigrationContext) => SavedObjectUnsanitizedDoc;
12+
export declare type SavedObjectMigrationFn<InputAttributes = unknown, MigratedAttributes = unknown> = (doc: SavedObjectUnsanitizedDoc<InputAttributes>, context: SavedObjectMigrationContext) => SavedObjectUnsanitizedDoc<MigratedAttributes>;
1313
```
1414

1515
## Example
1616

1717

1818
```typescript
19-
const migrateProperty: SavedObjectMigrationFn = (doc, { log }) => {
20-
if(doc.attributes.someProp === null) {
21-
log.warn('Skipping migration');
22-
} else {
23-
doc.attributes.someProp = migrateProperty(doc.attributes.someProp);
24-
}
25-
26-
return doc;
19+
interface TypeV1Attributes {
20+
someKey: string;
21+
obsoleteProperty: number;
2722
}
2823

24+
interface TypeV2Attributes {
25+
someKey: string;
26+
newProperty: string;
27+
}
28+
29+
const migrateToV2: SavedObjectMigrationFn<TypeV1Attributes, TypeV2Attributes> = (doc, { log }) => {
30+
const { obsoleteProperty, ...otherAttributes } = doc.attributes;
31+
// instead of mutating `doc` we make a shallow copy so that we can use separate types for the input
32+
// and output attributes. We don't need to make a deep copy, we just need to ensure that obsolete
33+
// attributes are not present on the returned doc.
34+
return {
35+
...doc,
36+
attributes: {
37+
...otherAttributes,
38+
newProperty: migrate(obsoleteProperty),
39+
},
40+
};
41+
};
42+
2943
```
3044

docs/development/core/server/kibana-plugin-core-server.savedobjectsanitizeddoc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ Describes Saved Object documents that have passed through the migration framewor
99
<b>Signature:</b>
1010

1111
```typescript
12-
export declare type SavedObjectSanitizedDoc = SavedObjectDoc & Referencable;
12+
export declare type SavedObjectSanitizedDoc<T = unknown> = SavedObjectDoc<T> & Referencable;
1313
```

docs/development/core/server/kibana-plugin-core-server.savedobjectunsanitizeddoc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ Describes Saved Object documents from Kibana &lt; 7.0.0 which don't have a `refe
99
<b>Signature:</b>
1010

1111
```typescript
12-
export declare type SavedObjectUnsanitizedDoc = SavedObjectDoc & Partial<Referencable>;
12+
export declare type SavedObjectUnsanitizedDoc<T = unknown> = SavedObjectDoc<T> & Partial<Referencable>;
1313
```

docs/development/plugins/data/public/kibana-plugin-plugins-data-public.gettime.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
<b>Signature:</b>
88

99
```typescript
10-
export declare function getTime(indexPattern: IIndexPattern | undefined, timeRange: TimeRange, forceNow?: Date): import("../..").RangeFilter | undefined;
10+
export declare function getTime(indexPattern: IIndexPattern | undefined, timeRange: TimeRange, options?: {
11+
forceNow?: Date;
12+
fieldName?: string;
13+
}): import("../..").RangeFilter | undefined;
1114
```
1215

1316
## Parameters
@@ -16,7 +19,7 @@ export declare function getTime(indexPattern: IIndexPattern | undefined, timeRan
1619
| --- | --- | --- |
1720
| indexPattern | <code>IIndexPattern &#124; undefined</code> | |
1821
| timeRange | <code>TimeRange</code> | |
19-
| forceNow | <code>Date</code> | |
22+
| options | <code>{</code><br/><code> forceNow?: Date;</code><br/><code> fieldName?: string;</code><br/><code>}</code> | |
2023

2124
<b>Returns:</b>
2225

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [IIndexPattern](./kibana-plugin-plugins-data-public.iindexpattern.md) &gt; [getTimeField](./kibana-plugin-plugins-data-public.iindexpattern.gettimefield.md)
4+
5+
## IIndexPattern.getTimeField() method
6+
7+
<b>Signature:</b>
8+
9+
```typescript
10+
getTimeField?(): IFieldType | undefined;
11+
```
12+
<b>Returns:</b>
13+
14+
`IFieldType | undefined`
15+

docs/development/plugins/data/public/kibana-plugin-plugins-data-public.iindexpattern.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ export interface IIndexPattern
2222
| [title](./kibana-plugin-plugins-data-public.iindexpattern.title.md) | <code>string</code> | |
2323
| [type](./kibana-plugin-plugins-data-public.iindexpattern.type.md) | <code>string</code> | |
2424

25+
## Methods
26+
27+
| Method | Description |
28+
| --- | --- |
29+
| [getTimeField()](./kibana-plugin-plugins-data-public.iindexpattern.gettimefield.md) | |
30+

docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
| [getEsPreference(uiSettings, sessionId)](./kibana-plugin-plugins-data-public.getespreference.md) | |
4444
| [getQueryLog(uiSettings, storage, appName, language)](./kibana-plugin-plugins-data-public.getquerylog.md) | |
4545
| [getSearchErrorType({ message })](./kibana-plugin-plugins-data-public.getsearcherrortype.md) | |
46-
| [getTime(indexPattern, timeRange, forceNow)](./kibana-plugin-plugins-data-public.gettime.md) | |
46+
| [getTime(indexPattern, timeRange, options)](./kibana-plugin-plugins-data-public.gettime.md) | |
4747
| [plugin(initializerContext)](./kibana-plugin-plugins-data-public.plugin.md) | |
4848

4949
## Interfaces

src/cli/cluster/cluster_manager.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ export class ClusterManager {
259259

260260
const ignorePaths = [
261261
/[\\\/](\..*|node_modules|bower_components|target|public|__[a-z0-9_]+__|coverage)([\\\/]|$)/,
262-
/\.test\.(js|ts)$/,
262+
/\.test\.(js|tsx?)$/,
263+
/\.md$/,
264+
/debug\.log$/,
263265
...pluginInternalDirsIgnore,
264266
fromRoot('src/legacy/server/sass/__tmp__'),
265267
fromRoot('x-pack/legacy/plugins/reporting/.chromium'),

src/core/MIGRATION_EXAMPLES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ const migration = (doc, log) => {...}
957957
Would be converted to:
958958
959959
```typescript
960-
const migration: SavedObjectMigrationFn = (doc, { log }) => {...}
960+
const migration: SavedObjectMigrationFn<OldAttributes, MigratedAttributes> = (doc, { log }) => {...}
961961
```
962962
963963
### Remarks

src/core/server/http/http_server.test.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,14 @@ describe('setup contract', () => {
10681068
await create();
10691069
expect(create()).rejects.toThrowError('A cookieSessionStorageFactory was already created');
10701070
});
1071+
1072+
it('does not throw if called after stop', async () => {
1073+
const { createCookieSessionStorageFactory } = await server.setup(config);
1074+
await server.stop();
1075+
expect(() => {
1076+
createCookieSessionStorageFactory(cookieOptions);
1077+
}).not.toThrow();
1078+
});
10711079
});
10721080

10731081
describe('#isTlsEnabled', () => {
@@ -1113,4 +1121,54 @@ describe('setup contract', () => {
11131121
expect(getServerInfo().protocol).toEqual('https');
11141122
});
11151123
});
1124+
1125+
describe('#registerStaticDir', () => {
1126+
it('does not throw if called after stop', async () => {
1127+
const { registerStaticDir } = await server.setup(config);
1128+
await server.stop();
1129+
expect(() => {
1130+
registerStaticDir('/path1/{path*}', '/path/to/resource');
1131+
}).not.toThrow();
1132+
});
1133+
});
1134+
1135+
describe('#registerOnPreAuth', () => {
1136+
test('does not throw if called after stop', async () => {
1137+
const { registerOnPreAuth } = await server.setup(config);
1138+
await server.stop();
1139+
expect(() => {
1140+
registerOnPreAuth((req, res) => res.unauthorized());
1141+
}).not.toThrow();
1142+
});
1143+
});
1144+
1145+
describe('#registerOnPostAuth', () => {
1146+
test('does not throw if called after stop', async () => {
1147+
const { registerOnPostAuth } = await server.setup(config);
1148+
await server.stop();
1149+
expect(() => {
1150+
registerOnPostAuth((req, res) => res.unauthorized());
1151+
}).not.toThrow();
1152+
});
1153+
});
1154+
1155+
describe('#registerOnPreResponse', () => {
1156+
test('does not throw if called after stop', async () => {
1157+
const { registerOnPreResponse } = await server.setup(config);
1158+
await server.stop();
1159+
expect(() => {
1160+
registerOnPreResponse((req, res, t) => t.next());
1161+
}).not.toThrow();
1162+
});
1163+
});
1164+
1165+
describe('#registerAuth', () => {
1166+
test('does not throw if called after stop', async () => {
1167+
const { registerAuth } = await server.setup(config);
1168+
await server.stop();
1169+
expect(() => {
1170+
registerAuth((req, res) => res.unauthorized());
1171+
}).not.toThrow();
1172+
});
1173+
});
11161174
});

0 commit comments

Comments
 (0)