@backstage/plugin-techdocs-node 1.12.10 → 1.12.11-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -2,14 +2,13 @@
2
2
  import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
3
3
  import { Config } from '@backstage/config';
4
4
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
5
- import { UrlReaderService } from '@backstage/backend-plugin-api';
6
- import * as winston from 'winston';
7
- import { Logger } from 'winston';
8
- import { ContainerRunner, PluginEndpointDiscovery } from '@backstage/backend-common';
5
+ import { LoggerService, UrlReaderService, DiscoveryService } from '@backstage/backend-plugin-api';
6
+ import { Writable } from 'stream';
9
7
  import express from 'express';
10
8
  import { ScmIntegrationRegistry } from '@backstage/integration';
11
9
  import { IndexableDocument } from '@backstage/plugin-search-common';
12
- import { Writable } from 'stream';
10
+ import * as winston from 'winston';
11
+ import { Logger } from 'winston';
13
12
 
14
13
  /**
15
14
  * A unique identifier of the tree blob, usually the commit SHA or etag from the target.
@@ -21,7 +20,7 @@ type ETag = string;
21
20
  * @public
22
21
  */
23
22
  type PreparerConfig = {
24
- logger: Logger;
23
+ logger: LoggerService;
25
24
  reader: UrlReaderService;
26
25
  };
27
26
  /**
@@ -32,7 +31,7 @@ type PreparerOptions = {
32
31
  /**
33
32
  * An instance of the logger
34
33
  */
35
- logger?: Logger;
34
+ logger?: LoggerService;
36
35
  /**
37
36
  * see {@link ETag}
38
37
  */
@@ -95,7 +94,7 @@ type ParsedLocationAnnotation = {
95
94
  target: string;
96
95
  };
97
96
  /**
98
- * Returns a parset locations annotation
97
+ * Returns a parsed locations annotation
99
98
  * @public
100
99
  * @param annotationName - The name of the annotation in the entity metadata
101
100
  * @param entity - A TechDocs entity instance
@@ -120,7 +119,7 @@ declare const transformDirLocation: (entity: Entity, dirAnnotation: ParsedLocati
120
119
  target: string;
121
120
  };
122
121
  /**
123
- * Returns a entity reference based on the TechDocs annotation type
122
+ * Returns an entity reference based on the TechDocs annotation type
124
123
  * @public
125
124
  * @param entity - A TechDocs instance
126
125
  * @param scmIntegration - An implementation for SCM integration API
@@ -135,20 +134,180 @@ declare const getLocationForEntity: (entity: Entity, scmIntegration: ScmIntegrat
135
134
  */
136
135
  declare const getDocFilesFromRepository: (reader: UrlReaderService, entity: Entity, opts?: {
137
136
  etag?: string;
138
- logger?: Logger;
137
+ logger?: LoggerService;
139
138
  }) => Promise<PreparerResponse>;
140
139
 
140
+ /**
141
+ * Options for building publishers
142
+ * @public
143
+ */
144
+ type PublisherFactory = {
145
+ logger: LoggerService;
146
+ discovery: DiscoveryService;
147
+ customPublisher?: PublisherBase | undefined;
148
+ };
149
+ /**
150
+ * Key for all the different types of TechDocs publishers that are supported.
151
+ * @public
152
+ */
153
+ type PublisherType = 'local' | 'googleGcs' | 'awsS3' | 'azureBlobStorage' | 'openStackSwift';
154
+ /**
155
+ * Request publish definition
156
+ * @public
157
+ */
158
+ type PublishRequest = {
159
+ entity: Entity;
160
+ directory: string;
161
+ };
162
+ /**
163
+ * Response containing metadata about where files were published and what may
164
+ * have been published or updated.
165
+ * @public
166
+ */
167
+ type PublishResponse = {
168
+ /**
169
+ * The URL which serves files from the local publisher's static directory.
170
+ */
171
+ remoteUrl?: string;
172
+ /**
173
+ * The list of objects (specifically their paths) that were published.
174
+ * Objects do not have a preceding slash, and match how one would load the
175
+ * object over the `/static/docs/*` TechDocs Backend Plugin endpoint.
176
+ */
177
+ objects?: string[];
178
+ } | void;
179
+ /**
180
+ * Result for the validation check.
181
+ * @public
182
+ */
183
+ type ReadinessResponse = {
184
+ /** If true, the publisher is able to interact with the backing storage. */
185
+ isAvailable: boolean;
186
+ };
187
+ /**
188
+ * Type to hold metadata found in techdocs_metadata.json and associated with each site
189
+ * @param etag - ETag of the resource used to generate the site. Usually the latest commit sha of the source repository.
190
+ * @public
191
+ */
192
+ type TechDocsMetadata = {
193
+ site_name: string;
194
+ site_description: string;
195
+ etag: string;
196
+ build_timestamp: number;
197
+ files?: string[];
198
+ };
199
+ /**
200
+ * TechDocs entity triplet migration request
201
+ * @public
202
+ */
203
+ type MigrateRequest = {
204
+ /**
205
+ * Whether or not to remove the source file. Defaults to false (acting like a
206
+ * copy instead of a move).
207
+ */
208
+ removeOriginal?: boolean;
209
+ /**
210
+ * Maximum number of files/objects to migrate at once. Defaults to 25.
211
+ */
212
+ concurrency?: number;
213
+ };
214
+ /**
215
+ * Base class for a TechDocs publisher (e.g. Local, Google GCS Bucket, AWS S3, etc.)
216
+ * The publisher handles publishing of the generated static files after the prepare and generate steps of TechDocs.
217
+ * It also provides APIs to communicate with the storage service.
218
+ *
219
+ * @public
220
+ */
221
+ interface PublisherBase {
222
+ /**
223
+ * Check if the publisher is ready. This check tries to perform certain checks to see if the
224
+ * publisher is configured correctly and can be used to publish or read documentations.
225
+ * The different implementations might e.g. use the provided service credentials to access the
226
+ * target or check if a folder/bucket is available.
227
+ */
228
+ getReadiness(): Promise<ReadinessResponse>;
229
+ /**
230
+ * Store the generated static files onto a storage service (either local filesystem or external service).
231
+ *
232
+ * @param request - Object containing the entity from the service
233
+ * catalog, and the directory that contains the generated static files from TechDocs.
234
+ */
235
+ publish(request: PublishRequest): Promise<PublishResponse>;
236
+ /**
237
+ * Retrieve TechDocs Metadata about a site e.g. name, contributors, last updated, etc.
238
+ * This API uses the techdocs_metadata.json file that co-exists along with the generated docs.
239
+ */
240
+ fetchTechDocsMetadata(entityName: CompoundEntityRef): Promise<TechDocsMetadata>;
241
+ /**
242
+ * Route middleware to serve static documentation files for an entity.
243
+ */
244
+ docsRouter(): express.Handler;
245
+ /**
246
+ * Check if the index.html is present for the Entity at the Storage location.
247
+ */
248
+ hasDocsBeenGenerated(entityName: Entity): Promise<boolean>;
249
+ /**
250
+ * Migrates documentation objects with case sensitive entity triplets to
251
+ * lowercase entity triplets. This was (will be) a change introduced in
252
+ * `techdocs-cli` version `{0.x.y}` and `techdocs-backend` version `{0.x.y}`.
253
+ *
254
+ * Implementation of this method is unnecessary in publishers introduced
255
+ * after version `{0.x.y}` of `techdocs-node`.
256
+ */
257
+ migrateDocsCase?(migrateRequest: MigrateRequest): Promise<void>;
258
+ }
259
+ /**
260
+ * Definition for a TechDocs publisher builder
261
+ * @public
262
+ */
263
+ type PublisherBuilder = {
264
+ register(type: PublisherType, publisher: PublisherBase): void;
265
+ get(config: Config): PublisherBase;
266
+ };
267
+ /**
268
+ * Handles the running of containers, on behalf of others.
269
+ *
270
+ * @public
271
+ */
272
+ interface TechDocsContainerRunner {
273
+ /**
274
+ * Runs a container image to completion.
275
+ */
276
+ runContainer(opts: {
277
+ imageName: string;
278
+ command?: string | string[];
279
+ args: string[];
280
+ logStream?: Writable;
281
+ mountDirs?: Record<string, string>;
282
+ workingDir?: string;
283
+ envVars?: Record<string, string>;
284
+ pullImage?: boolean;
285
+ defaultUser?: boolean;
286
+ pullOptions?: {
287
+ authconfig?: {
288
+ username?: string;
289
+ password?: string;
290
+ auth?: string;
291
+ email?: string;
292
+ serveraddress?: string;
293
+ [key: string]: unknown;
294
+ };
295
+ [key: string]: unknown;
296
+ };
297
+ }): Promise<void>;
298
+ }
299
+
141
300
  /**
142
301
  * Options for building generators
143
302
  * @public
144
303
  */
145
304
  type GeneratorOptions = {
146
- logger: Logger;
305
+ logger: LoggerService;
147
306
  /**
148
307
  * @deprecated containerRunner is now instantiated in
149
308
  * the generator and this option will be removed in the future
150
309
  */
151
- containerRunner?: ContainerRunner;
310
+ containerRunner?: TechDocsContainerRunner;
152
311
  };
153
312
  /**
154
313
  * The values that the generator will receive.
@@ -220,8 +379,8 @@ declare class TechdocsGenerator implements GeneratorBase {
220
379
  */
221
380
  static fromConfig(config: Config, options: GeneratorOptions): TechdocsGenerator;
222
381
  constructor(options: {
223
- logger: Logger;
224
- containerRunner?: ContainerRunner;
382
+ logger: LoggerService;
383
+ containerRunner?: TechDocsContainerRunner;
225
384
  config: Config;
226
385
  scmIntegrations: ScmIntegrationRegistry;
227
386
  });
@@ -241,8 +400,8 @@ declare class Generators implements GeneratorBuilder {
241
400
  * @param options - Options to configure the TechDocs generator
242
401
  */
243
402
  static fromConfig(config: Config, options: {
244
- logger: Logger;
245
- containerRunner?: ContainerRunner;
403
+ logger: LoggerService;
404
+ containerRunner?: TechDocsContainerRunner;
246
405
  customGenerator?: TechdocsGenerator;
247
406
  }): Promise<GeneratorBuilder>;
248
407
  /**
@@ -356,134 +515,6 @@ declare class Preparers implements PreparerBuilder {
356
515
  get(entity: Entity): PreparerBase;
357
516
  }
358
517
 
359
- /**
360
- * Options for building publishers
361
- * @public
362
- */
363
- type PublisherFactory = {
364
- logger: Logger;
365
- discovery: PluginEndpointDiscovery;
366
- customPublisher?: PublisherBase | undefined;
367
- };
368
- /**
369
- * Key for all the different types of TechDocs publishers that are supported.
370
- * @public
371
- */
372
- type PublisherType = 'local' | 'googleGcs' | 'awsS3' | 'azureBlobStorage' | 'openStackSwift';
373
- /**
374
- * Request publish definition
375
- * @public
376
- */
377
- type PublishRequest = {
378
- entity: Entity;
379
- directory: string;
380
- };
381
- /**
382
- * Response containing metadata about where files were published and what may
383
- * have been published or updated.
384
- * @public
385
- */
386
- type PublishResponse = {
387
- /**
388
- * The URL which serves files from the local publisher's static directory.
389
- */
390
- remoteUrl?: string;
391
- /**
392
- * The list of objects (specifically their paths) that were published.
393
- * Objects do not have a preceding slash, and match how one would load the
394
- * object over the `/static/docs/*` TechDocs Backend Plugin endpoint.
395
- */
396
- objects?: string[];
397
- } | void;
398
- /**
399
- * Result for the validation check.
400
- * @public
401
- */
402
- type ReadinessResponse = {
403
- /** If true, the publisher is able to interact with the backing storage. */
404
- isAvailable: boolean;
405
- };
406
- /**
407
- * Type to hold metadata found in techdocs_metadata.json and associated with each site
408
- * @param etag - ETag of the resource used to generate the site. Usually the latest commit sha of the source repository.
409
- * @public
410
- */
411
- type TechDocsMetadata = {
412
- site_name: string;
413
- site_description: string;
414
- etag: string;
415
- build_timestamp: number;
416
- files?: string[];
417
- };
418
- /**
419
- * TechDocs entity triplet migration request
420
- * @public
421
- */
422
- type MigrateRequest = {
423
- /**
424
- * Whether or not to remove the source file. Defaults to false (acting like a
425
- * copy instead of a move).
426
- */
427
- removeOriginal?: boolean;
428
- /**
429
- * Maximum number of files/objects to migrate at once. Defaults to 25.
430
- */
431
- concurrency?: number;
432
- };
433
- /**
434
- * Base class for a TechDocs publisher (e.g. Local, Google GCS Bucket, AWS S3, etc.)
435
- * The publisher handles publishing of the generated static files after the prepare and generate steps of TechDocs.
436
- * It also provides APIs to communicate with the storage service.
437
- *
438
- * @public
439
- */
440
- interface PublisherBase {
441
- /**
442
- * Check if the publisher is ready. This check tries to perform certain checks to see if the
443
- * publisher is configured correctly and can be used to publish or read documentations.
444
- * The different implementations might e.g. use the provided service credentials to access the
445
- * target or check if a folder/bucket is available.
446
- */
447
- getReadiness(): Promise<ReadinessResponse>;
448
- /**
449
- * Store the generated static files onto a storage service (either local filesystem or external service).
450
- *
451
- * @param request - Object containing the entity from the service
452
- * catalog, and the directory that contains the generated static files from TechDocs.
453
- */
454
- publish(request: PublishRequest): Promise<PublishResponse>;
455
- /**
456
- * Retrieve TechDocs Metadata about a site e.g. name, contributors, last updated, etc.
457
- * This API uses the techdocs_metadata.json file that co-exists along with the generated docs.
458
- */
459
- fetchTechDocsMetadata(entityName: CompoundEntityRef): Promise<TechDocsMetadata>;
460
- /**
461
- * Route middleware to serve static documentation files for an entity.
462
- */
463
- docsRouter(): express.Handler;
464
- /**
465
- * Check if the index.html is present for the Entity at the Storage location.
466
- */
467
- hasDocsBeenGenerated(entityName: Entity): Promise<boolean>;
468
- /**
469
- * Migrates documentation objects with case sensitive entity triplets to
470
- * lowercase entity triplets. This was (will be) a change introduced in
471
- * `techdocs-cli` version `{0.x.y}` and `techdocs-backend` version `{0.x.y}`.
472
- *
473
- * Implementation of this method is unnecessary in publishers introduced
474
- * after version `{0.x.y}` of `techdocs-node`.
475
- */
476
- migrateDocsCase?(migrateRequest: MigrateRequest): Promise<void>;
477
- }
478
- /**
479
- * Definition for a TechDocs publisher builder
480
- * @public
481
- */
482
- type PublisherBuilder = {
483
- register(type: PublisherType, publisher: PublisherBase): void;
484
- get(config: Config): PublisherBase;
485
- };
486
-
487
518
  /**
488
519
  * Factory class to create a TechDocs publisher based on defined publisher type in app config.
489
520
  * Uses `techdocs.publisher.type`.
@@ -543,7 +574,7 @@ interface DocsBuildStrategy {
543
574
  }
544
575
 
545
576
  /**
546
- * Extension point type for configuring Techdocs builds.
577
+ * Extension point type for configuring TechDocs builds.
547
578
  *
548
579
  * @public
549
580
  */
@@ -552,13 +583,13 @@ interface TechdocsBuildsExtensionPoint {
552
583
  setBuildLogTransport(transport: winston.transport): void;
553
584
  }
554
585
  /**
555
- * Extension point for configuring Techdocs builds.
586
+ * Extension point for configuring TechDocs builds.
556
587
  *
557
588
  * @public
558
589
  */
559
590
  declare const techdocsBuildsExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<TechdocsBuildsExtensionPoint>;
560
591
  /**
561
- * Extension point type for configuring a custom Techdocs generator
592
+ * Extension point type for configuring a custom TechDocs generator
562
593
  *
563
594
  * @public
564
595
  */
@@ -566,13 +597,13 @@ interface TechdocsGeneratorExtensionPoint {
566
597
  setTechdocsGenerator(generator: TechdocsGenerator): void;
567
598
  }
568
599
  /**
569
- * Extension point for configuring a custom Techdocs generator
600
+ * Extension point for configuring a custom TechDocs generator
570
601
  *
571
602
  * @public
572
603
  */
573
604
  declare const techdocsGeneratorExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<TechdocsGeneratorExtensionPoint>;
574
605
  /**
575
- * Extension point type for configuring a custom Techdocs preparer
606
+ * Extension point type for configuring a custom TechDocs preparer
576
607
  *
577
608
  * @public
578
609
  */
@@ -580,13 +611,13 @@ interface TechdocsPreparerExtensionPoint {
580
611
  registerPreparer(protocol: RemoteProtocol, preparer: PreparerBase): void;
581
612
  }
582
613
  /**
583
- * Extension point for configuring a custom Techdocs preparer
614
+ * Extension point for configuring a custom TechDocs preparer
584
615
  *
585
616
  * @public
586
617
  */
587
618
  declare const techdocsPreparerExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<TechdocsPreparerExtensionPoint>;
588
619
  /**
589
- * Extension point type for configuring a custom Techdocs publisher
620
+ * Extension point type for configuring a custom TechDocs publisher
590
621
  *
591
622
  * @public
592
623
  */
@@ -594,10 +625,10 @@ interface TechdocsPublisherExtensionPoint {
594
625
  registerPublisher(type: PublisherType, publisher: PublisherBase): void;
595
626
  }
596
627
  /**
597
- * Extension point for configuring a custom Techdocs publisher
628
+ * Extension point for configuring a custom TechDocs publisher
598
629
  *
599
630
  * @public
600
631
  */
601
632
  declare const techdocsPublisherExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<TechdocsPublisherExtensionPoint>;
602
633
 
603
- export { DirectoryPreparer, type DocsBuildStrategy, type ETag, type GeneratorBase, type GeneratorBuilder, type GeneratorOptions, type GeneratorRunOptions, Generators, type MigrateRequest, type ParsedLocationAnnotation, type PreparerBase, type PreparerBuilder, type PreparerConfig, type PreparerOptions, type PreparerResponse, Preparers, type PublishRequest, type PublishResponse, Publisher, type PublisherBase, type PublisherBuilder, type PublisherFactory, type PublisherType, type ReadinessResponse, type RemoteProtocol, type SupportedGeneratorKey, type TechDocsDocument, type TechDocsMetadata, type TechdocsBuildsExtensionPoint, TechdocsGenerator, type TechdocsGeneratorExtensionPoint, type TechdocsPreparerExtensionPoint, type TechdocsPublisherExtensionPoint, UrlPreparer, getDocFilesFromRepository, getLocationForEntity, getMkDocsYml, getMkdocsYml, parseReferenceAnnotation, techdocsBuildsExtensionPoint, techdocsGeneratorExtensionPoint, techdocsPreparerExtensionPoint, techdocsPublisherExtensionPoint, transformDirLocation };
634
+ export { DirectoryPreparer, type DocsBuildStrategy, type ETag, type GeneratorBase, type GeneratorBuilder, type GeneratorOptions, type GeneratorRunOptions, Generators, type MigrateRequest, type ParsedLocationAnnotation, type PreparerBase, type PreparerBuilder, type PreparerConfig, type PreparerOptions, type PreparerResponse, Preparers, type PublishRequest, type PublishResponse, Publisher, type PublisherBase, type PublisherBuilder, type PublisherFactory, type PublisherType, type ReadinessResponse, type RemoteProtocol, type SupportedGeneratorKey, type TechDocsContainerRunner, type TechDocsDocument, type TechDocsMetadata, type TechdocsBuildsExtensionPoint, TechdocsGenerator, type TechdocsGeneratorExtensionPoint, type TechdocsPreparerExtensionPoint, type TechdocsPublisherExtensionPoint, UrlPreparer, getDocFilesFromRepository, getLocationForEntity, getMkDocsYml, getMkdocsYml, parseReferenceAnnotation, techdocsBuildsExtensionPoint, techdocsGeneratorExtensionPoint, techdocsPreparerExtensionPoint, techdocsPublisherExtensionPoint, transformDirLocation };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-techdocs-node",
3
- "version": "1.12.10",
3
+ "version": "1.12.11-next.0",
4
4
  "description": "Common node.js functionalities for TechDocs, to be shared between techdocs-backend plugin and techdocs-cli",
5
5
  "backstage": {
6
6
  "role": "node-library",
@@ -53,8 +53,7 @@
53
53
  "@aws-sdk/types": "^3.347.0",
54
54
  "@azure/identity": "^4.0.0",
55
55
  "@azure/storage-blob": "^12.5.0",
56
- "@backstage/backend-common": "^0.24.1",
57
- "@backstage/backend-plugin-api": "^0.8.1",
56
+ "@backstage/backend-plugin-api": "^0.9.0-next.0",
58
57
  "@backstage/catalog-model": "^1.6.0",
59
58
  "@backstage/config": "^1.2.0",
60
59
  "@backstage/errors": "^1.2.4",
@@ -79,8 +78,8 @@
79
78
  "winston": "^3.2.1"
80
79
  },
81
80
  "devDependencies": {
82
- "@backstage/backend-test-utils": "^0.5.1",
83
- "@backstage/cli": "^0.27.0",
81
+ "@backstage/backend-test-utils": "^0.6.0-next.0",
82
+ "@backstage/cli": "^0.27.1-next.0",
84
83
  "@types/fs-extra": "^11.0.0",
85
84
  "@types/js-yaml": "^4.0.0",
86
85
  "@types/mime-types": "^2.1.0",