@@ -5,12 +5,46 @@ import { ApiItem, ApiItemKind, IApiItemJson } from './ApiItem';
55import { ApiItemContainerMixin , IApiItemContainerMixinOptions } from '../mixins/ApiItemContainerMixin' ;
66import { JsonFile } from '@microsoft/node-core-library' ;
77import { ApiDocumentedItem , IApiDocumentedItemOptions } from './ApiDocumentedItem' ;
8+ import { Extractor } from '../Extractor' ;
89
910export interface IApiPackageOptions extends
1011 IApiItemContainerMixinOptions ,
1112 IApiDocumentedItemOptions {
1213}
1314
15+ export enum ApiJsonSchemaVersion {
16+ /**
17+ * The initial release.
18+ */
19+ V_1000 = 1000
20+ }
21+
22+ export interface IApiPackageMetadataJson {
23+ /**
24+ * The NPM package name for the tool that wrote the *.api.json file.
25+ * For informational purposes only.
26+ */
27+ toolPackage : string ;
28+ /**
29+ * The NPM package version for the tool that wrote the *.api.json file.
30+ * For informational purposes only.
31+ */
32+ toolVersion : string ;
33+
34+ /**
35+ * The *.api.json schema version. Used for determining whether the file format is
36+ * supported, and for backwards compatibility.
37+ */
38+ schemaVersion : ApiJsonSchemaVersion ;
39+ }
40+
41+ export interface IApiPackageJson extends IApiItemJson {
42+ /**
43+ * A file header that stores metadata about the tool that wrote the *.api.json file.
44+ */
45+ metadata : IApiPackageMetadataJson ;
46+ }
47+
1448export class ApiPackage extends ApiItemContainerMixin ( ApiDocumentedItem ) {
1549 public static loadFromJsonFile ( apiJsonFilename : string ) : ApiPackage {
1650 const jsonObject : { } = JsonFile . load ( apiJsonFilename ) ;
@@ -32,7 +66,13 @@ export class ApiPackage extends ApiItemContainerMixin(ApiDocumentedItem) {
3266 }
3367
3468 public saveToJsonFile ( apiJsonFilename : string ) : void {
35- const jsonObject : { } = { } ;
69+ const jsonObject : IApiPackageJson = {
70+ metadata : {
71+ toolPackage : Extractor . packageName ,
72+ toolVersion : Extractor . version ,
73+ schemaVersion : ApiJsonSchemaVersion . V_1000
74+ }
75+ } as IApiPackageJson ;
3676 this . serializeInto ( jsonObject ) ;
3777 JsonFile . save ( jsonObject , apiJsonFilename ) ;
3878 }
0 commit comments