Skip to content

Commit 3bf73d9

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

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

+1-1
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

+3-10
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

+5
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

+8-5
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

+7-1
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

+7-1
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

+4-2
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

+1-1
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

+6-2
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

+3-1
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.

src/core/server/server.api.md

+31-92
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,12 @@ import { UpdateDocumentByQueryParams } from 'elasticsearch';
153153
import { UpdateDocumentParams } from 'elasticsearch';
154154
import { Url } from 'url';
155155

156-
// Warning: (ae-forgotten-export) The symbol "appendersSchema" needs to be exported by the entry point index.d.ts
156+
// Warning: (ae-forgotten-export) The symbol "ConsoleAppenderConfig" needs to be exported by the entry point index.d.ts
157+
// Warning: (ae-forgotten-export) The symbol "FileAppenderConfig" needs to be exported by the entry point index.d.ts
158+
// Warning: (ae-forgotten-export) The symbol "LegacyAppenderConfig" needs to be exported by the entry point index.d.ts
157159
//
158160
// @public (undocumented)
159-
export type AppenderConfigType = TypeOf<typeof appendersSchema>;
161+
export type AppenderConfigType = ConsoleAppenderConfig | FileAppenderConfig | LegacyAppenderConfig;
160162

161163
// @public
162164
export function assertNever(x: never): never;
@@ -325,108 +327,45 @@ export type CapabilitiesSwitcher = (request: KibanaRequest, uiCapabilities: Capa
325327
export const config: {
326328
elasticsearch: {
327329
schema: import("@kbn/config-schema").ObjectType<{
328-
sniffOnStart: import("@kbn/config-schema").Type<boolean>;
329-
sniffInterval: import("@kbn/config-schema").Type<false | import("moment").Duration>;
330-
sniffOnConnectionFault: import("@kbn/config-schema").Type<boolean>;
331-
hosts: import("@kbn/config-schema").Type<string | string[]>;
332-
preserveHost: import("@kbn/config-schema").Type<boolean>;
333-
username: import("@kbn/config-schema").Type<string | undefined>;
334-
password: import("@kbn/config-schema").Type<string | undefined>;
335-
requestHeadersWhitelist: import("@kbn/config-schema").Type<string | string[]>;
336-
customHeaders: import("@kbn/config-schema").Type<Record<string, string>>;
337-
shardTimeout: import("@kbn/config-schema").Type<import("moment").Duration>;
338-
requestTimeout: import("@kbn/config-schema").Type<import("moment").Duration>;
339-
pingTimeout: import("@kbn/config-schema").Type<import("moment").Duration>;
340-
startupTimeout: import("@kbn/config-schema").Type<import("moment").Duration>;
341-
logQueries: import("@kbn/config-schema").Type<boolean>;
330+
sniffOnStart: Type<boolean>;
331+
sniffInterval: Type<false | import("moment").Duration>;
332+
sniffOnConnectionFault: Type<boolean>;
333+
hosts: Type<string | string[]>;
334+
preserveHost: Type<boolean>;
335+
username: Type<string | undefined>;
336+
password: Type<string | undefined>;
337+
requestHeadersWhitelist: Type<string | string[]>;
338+
customHeaders: Type<Record<string, string>>;
339+
shardTimeout: Type<import("moment").Duration>;
340+
requestTimeout: Type<import("moment").Duration>;
341+
pingTimeout: Type<import("moment").Duration>;
342+
startupTimeout: Type<import("moment").Duration>;
343+
logQueries: Type<boolean>;
342344
ssl: import("@kbn/config-schema").ObjectType<{
343-
verificationMode: import("@kbn/config-schema").Type<"none" | "certificate" | "full">;
344-
certificateAuthorities: import("@kbn/config-schema").Type<string | string[] | undefined>;
345-
certificate: import("@kbn/config-schema").Type<string | undefined>;
346-
key: import("@kbn/config-schema").Type<string | undefined>;
347-
keyPassphrase: import("@kbn/config-schema").Type<string | undefined>;
345+
verificationMode: Type<"none" | "certificate" | "full">;
346+
certificateAuthorities: Type<string | string[] | undefined>;
347+
certificate: Type<string | undefined>;
348+
key: Type<string | undefined>;
349+
keyPassphrase: Type<string | undefined>;
348350
keystore: import("@kbn/config-schema").ObjectType<{
349-
path: import("@kbn/config-schema").Type<string | undefined>;
350-
password: import("@kbn/config-schema").Type<string | undefined>;
351+
path: Type<string | undefined>;
352+
password: Type<string | undefined>;
351353
}>;
352354
truststore: import("@kbn/config-schema").ObjectType<{
353-
path: import("@kbn/config-schema").Type<string | undefined>;
354-
password: import("@kbn/config-schema").Type<string | undefined>;
355+
path: Type<string | undefined>;
356+
password: Type<string | undefined>;
355357
}>;
356-
alwaysPresentCertificate: import("@kbn/config-schema").Type<boolean>;
358+
alwaysPresentCertificate: Type<boolean>;
357359
}>;
358-
apiVersion: import("@kbn/config-schema").Type<string>;
360+
apiVersion: Type<string>;
359361
healthCheck: import("@kbn/config-schema").ObjectType<{
360-
delay: import("@kbn/config-schema").Type<import("moment").Duration>;
362+
delay: Type<import("moment").Duration>;
361363
}>;
362364
ignoreVersionMismatch: import("@kbn/config-schema/target/types/types").ConditionalType<false, boolean, boolean>;
363365
}>;
364366
};
365367
logging: {
366-
appenders: import("@kbn/config-schema").Type<Readonly<{} & {
367-
layout: Readonly<{} & {
368-
kind: "json";
369-
}> | Readonly<{
370-
pattern?: string | undefined;
371-
highlight?: boolean | undefined;
372-
} & {
373-
kind: "pattern";
374-
}>;
375-
kind: "console";
376-
}> | Readonly<{} & {
377-
path: string;
378-
layout: Readonly<{} & {
379-
kind: "json";
380-
}> | Readonly<{
381-
pattern?: string | undefined;
382-
highlight?: boolean | undefined;
383-
} & {
384-
kind: "pattern";
385-
}>;
386-
kind: "file";
387-
}> | Readonly<{
388-
legacyLoggingConfig?: any;
389-
} & {
390-
kind: "legacy-appender";
391-
}>>;
392-
loggers: import("@kbn/config-schema").ObjectType<{
393-
appenders: import("@kbn/config-schema").Type<string[]>;
394-
context: import("@kbn/config-schema").Type<string>;
395-
level: import("@kbn/config-schema").Type<import("./logging/log_level").LogLevelId>;
396-
}>;
397-
loggerContext: import("@kbn/config-schema").ObjectType<{
398-
appenders: import("@kbn/config-schema").Type<Map<string, Readonly<{} & {
399-
layout: Readonly<{} & {
400-
kind: "json";
401-
}> | Readonly<{
402-
pattern?: string | undefined;
403-
highlight?: boolean | undefined;
404-
} & {
405-
kind: "pattern";
406-
}>;
407-
kind: "console";
408-
}> | Readonly<{} & {
409-
path: string;
410-
layout: Readonly<{} & {
411-
kind: "json";
412-
}> | Readonly<{
413-
pattern?: string | undefined;
414-
highlight?: boolean | undefined;
415-
} & {
416-
kind: "pattern";
417-
}>;
418-
kind: "file";
419-
}> | Readonly<{
420-
legacyLoggingConfig?: any;
421-
} & {
422-
kind: "legacy-appender";
423-
}>>>;
424-
loggers: import("@kbn/config-schema").Type<Readonly<{} & {
425-
context: string;
426-
appenders: string[];
427-
level: import("./logging/log_level").LogLevelId;
428-
}>[]>;
429-
}>;
368+
appenders: Type<AppenderConfigType>;
430369
};
431370
};
432371

tsconfig.types.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"extends": "./tsconfig.base.json",
33
"compilerOptions": {
4+
"incremental": false,
45
"declaration": true,
56
"outDir": "./target/types",
67
"stripInternal": false,

0 commit comments

Comments
 (0)