Skip to content

Commit 2f1c012

Browse files
authored
Deterministic output for doc types (#76890)
* disable incremental builds for public type generation. They generate non-deterministic types microsoft/rushstack#1958 * do not infer public types
1 parent 39f8fc6 commit 2f1c012

File tree

12 files changed

+77
-116
lines changed

12 files changed

+77
-116
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
<b>Signature:</b>
99

1010
```typescript
11-
export declare type AppenderConfigType = TypeOf<typeof appendersSchema>;
11+
export declare type AppenderConfigType = ConsoleAppenderConfig | FileAppenderConfig | LegacyAppenderConfig;
1212
```

src/core/server/index.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@
3939
* @packageDocumentation
4040
*/
4141

42+
import { Type } from '@kbn/config-schema';
4243
import {
4344
ElasticsearchServiceSetup,
4445
ILegacyScopedClusterClient,
4546
configSchema as elasticsearchConfigSchema,
4647
ElasticsearchServiceStart,
4748
IScopedClusterClient,
4849
} from './elasticsearch';
49-
5050
import { HttpServiceSetup, HttpServiceStart } from './http';
5151
import { HttpResources } from './http_resources';
5252

@@ -63,12 +63,7 @@ import { CapabilitiesSetup, CapabilitiesStart } from './capabilities';
6363
import { MetricsServiceStart } from './metrics';
6464
import { StatusServiceSetup } from './status';
6565
import { Auditor, AuditTrailSetup, AuditTrailStart } from './audit_trail';
66-
import {
67-
LoggingServiceSetup,
68-
appendersSchema,
69-
loggerContextConfigSchema,
70-
loggerSchema,
71-
} from './logging';
66+
import { AppenderConfigType, appendersSchema, LoggingServiceSetup } from './logging';
7267

7368
export { AuditableEvent, Auditor, AuditorFactory, AuditTrailSetup } from './audit_trail';
7469
export { bootstrap } from './bootstrap';
@@ -497,8 +492,6 @@ export const config = {
497492
schema: elasticsearchConfigSchema,
498493
},
499494
logging: {
500-
appenders: appendersSchema,
501-
loggers: loggerSchema,
502-
loggerContext: loggerContextConfigSchema,
495+
appenders: appendersSchema as Type<AppenderConfigType>,
503496
},
504497
};

src/core/server/legacy/logging/appenders/legacy_appender.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ import { LogRecord } from '../../../logging/log_record';
2323
import { LegacyLoggingServer } from '../legacy_logging_server';
2424
import { LegacyVars } from '../../types';
2525

26+
export interface LegacyAppenderConfig {
27+
kind: 'legacy-appender';
28+
legacyLoggingConfig?: any;
29+
}
30+
2631
/**
2732
* Simple appender that just forwards `LogRecord` to the legacy KbnServer log.
2833
* @internal

src/core/server/logging/appenders/appenders.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@
1717
* under the License.
1818
*/
1919

20-
import { schema, TypeOf } from '@kbn/config-schema';
20+
import { schema } from '@kbn/config-schema';
2121

2222
import { assertNever } from '../../../utils';
23-
import { LegacyAppender } from '../../legacy/logging/appenders/legacy_appender';
23+
import {
24+
LegacyAppender,
25+
LegacyAppenderConfig,
26+
} from '../../legacy/logging/appenders/legacy_appender';
2427
import { Layouts } from '../layouts/layouts';
2528
import { LogRecord } from '../log_record';
26-
import { ConsoleAppender } from './console/console_appender';
27-
import { FileAppender } from './file/file_appender';
29+
import { ConsoleAppender, ConsoleAppenderConfig } from './console/console_appender';
30+
import { FileAppender, FileAppenderConfig } from './file/file_appender';
2831

2932
/**
3033
* Config schema for validting the shape of the `appenders` key in in {@link LoggerContextConfigType} or
@@ -39,7 +42,7 @@ export const appendersSchema = schema.oneOf([
3942
]);
4043

4144
/** @public */
42-
export type AppenderConfigType = TypeOf<typeof appendersSchema>;
45+
export type AppenderConfigType = ConsoleAppenderConfig | FileAppenderConfig | LegacyAppenderConfig;
4346

4447
/**
4548
* Entity that can append `LogRecord` instances to file, stdout, memory or whatever

src/core/server/logging/appenders/console/console_appender.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@
1919

2020
import { schema } from '@kbn/config-schema';
2121

22-
import { Layout, Layouts } from '../../layouts/layouts';
22+
import { Layout, Layouts, LayoutConfigType } from '../../layouts/layouts';
2323
import { LogRecord } from '../../log_record';
2424
import { DisposableAppender } from '../appenders';
2525

2626
const { literal, object } = schema;
2727

28+
export interface ConsoleAppenderConfig {
29+
kind: 'console';
30+
layout: LayoutConfigType;
31+
}
32+
2833
/**
34+
*
2935
* Appender that formats all the `LogRecord` instances it receives and logs them via built-in `console`.
3036
* @internal
3137
*/

src/core/server/logging/appenders/file/file_appender.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@
2020
import { schema } from '@kbn/config-schema';
2121
import { createWriteStream, WriteStream } from 'fs';
2222

23-
import { Layout, Layouts } from '../../layouts/layouts';
23+
import { Layout, Layouts, LayoutConfigType } from '../../layouts/layouts';
2424
import { LogRecord } from '../../log_record';
2525
import { DisposableAppender } from '../appenders';
2626

27+
export interface FileAppenderConfig {
28+
kind: 'file';
29+
layout: LayoutConfigType;
30+
path: string;
31+
}
32+
2733
/**
2834
* Appender that formats all the `LogRecord` instances it receives and writes them to the specified file.
2935
* @internal

src/core/server/logging/layouts/json_layout.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import moment from 'moment-timezone';
2121
import { merge } from 'lodash';
22-
import { schema, TypeOf } from '@kbn/config-schema';
22+
import { schema } from '@kbn/config-schema';
2323

2424
import { LogRecord } from '../log_record';
2525
import { Layout } from './layouts';
@@ -31,7 +31,9 @@ const jsonLayoutSchema = object({
3131
});
3232

3333
/** @internal */
34-
export type JsonLayoutConfigType = TypeOf<typeof jsonLayoutSchema>;
34+
export interface JsonLayoutConfigType {
35+
kind: 'json';
36+
}
3537

3638
/**
3739
* Layout that just converts `LogRecord` into JSON string.

src/core/server/logging/layouts/layouts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { PatternLayout, PatternLayoutConfigType } from './pattern_layout';
2626

2727
const { oneOf } = schema;
2828

29-
type LayoutConfigType = PatternLayoutConfigType | JsonLayoutConfigType;
29+
export type LayoutConfigType = PatternLayoutConfigType | JsonLayoutConfigType;
3030

3131
/**
3232
* Entity that can format `LogRecord` instance into a string.

src/core/server/logging/layouts/pattern_layout.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
import { schema, TypeOf } from '@kbn/config-schema';
20+
import { schema } from '@kbn/config-schema';
2121

2222
import { LogRecord } from '../log_record';
2323
import { Layout } from './layouts';
@@ -58,7 +58,11 @@ const conversions: Conversion[] = [
5858
];
5959

6060
/** @internal */
61-
export type PatternLayoutConfigType = TypeOf<typeof patternLayoutSchema>;
61+
export interface PatternLayoutConfigType {
62+
kind: 'pattern';
63+
highlight?: boolean;
64+
pattern?: string;
65+
}
6266

6367
/**
6468
* Layout that formats `LogRecord` using the `pattern` string with optional

src/core/server/logging/logging_config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ export const config = {
9696
}),
9797
};
9898

99-
export type LoggingConfigType = TypeOf<typeof config.schema>;
99+
export type LoggingConfigType = Omit<TypeOf<typeof config.schema>, 'appenders'> & {
100+
appenders: Map<string, AppenderConfigType>;
101+
};
100102

101103
/**
102104
* Config schema for validating the inputs to the {@link LoggingServiceStart.configure} API.

0 commit comments

Comments
 (0)