@backstage/plugin-techdocs-node 1.12.11-next.2 → 1.12.12-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/CHANGELOG.md +34 -0
- package/dist/index.cjs.js +70 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +164 -165
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ 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
5
|
import { LoggerService, UrlReaderService, DiscoveryService } from '@backstage/backend-plugin-api';
|
|
6
|
-
import { Writable } from 'stream';
|
|
7
6
|
import express from 'express';
|
|
8
7
|
import { ScmIntegrationRegistry } from '@backstage/integration';
|
|
9
8
|
import { IndexableDocument } from '@backstage/plugin-search-common';
|
|
9
|
+
import { Writable } from 'stream';
|
|
10
10
|
import * as winston from 'winston';
|
|
11
11
|
import { Logger } from 'winston';
|
|
12
12
|
|
|
@@ -137,176 +137,12 @@ declare const getDocFilesFromRepository: (reader: UrlReaderService, entity: Enti
|
|
|
137
137
|
logger?: LoggerService;
|
|
138
138
|
}) => Promise<PreparerResponse>;
|
|
139
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
|
-
|
|
300
140
|
/**
|
|
301
141
|
* Options for building generators
|
|
302
142
|
* @public
|
|
303
143
|
*/
|
|
304
144
|
type GeneratorOptions = {
|
|
305
145
|
logger: LoggerService;
|
|
306
|
-
/**
|
|
307
|
-
* @deprecated containerRunner is now instantiated in
|
|
308
|
-
* the generator and this option will be removed in the future
|
|
309
|
-
*/
|
|
310
146
|
containerRunner?: TechDocsContainerRunner;
|
|
311
147
|
};
|
|
312
148
|
/**
|
|
@@ -357,6 +193,41 @@ type GeneratorBuilder = {
|
|
|
357
193
|
register(protocol: SupportedGeneratorKey, generator: GeneratorBase): void;
|
|
358
194
|
get(entity: Entity): GeneratorBase;
|
|
359
195
|
};
|
|
196
|
+
/**
|
|
197
|
+
* Handles the running of containers to generate TechDocs.
|
|
198
|
+
*
|
|
199
|
+
* Custom implementations, e.g. for Kubernetes or other execution environments, can be inspired by the internal default
|
|
200
|
+
* implementation `DockerContainerRunner`.
|
|
201
|
+
*
|
|
202
|
+
* @public
|
|
203
|
+
*/
|
|
204
|
+
interface TechDocsContainerRunner {
|
|
205
|
+
/**
|
|
206
|
+
* Runs a container image to completion.
|
|
207
|
+
*/
|
|
208
|
+
runContainer(opts: {
|
|
209
|
+
imageName: string;
|
|
210
|
+
command?: string | string[];
|
|
211
|
+
args: string[];
|
|
212
|
+
logStream?: Writable;
|
|
213
|
+
mountDirs?: Record<string, string>;
|
|
214
|
+
workingDir?: string;
|
|
215
|
+
envVars?: Record<string, string>;
|
|
216
|
+
pullImage?: boolean;
|
|
217
|
+
defaultUser?: boolean;
|
|
218
|
+
pullOptions?: {
|
|
219
|
+
authconfig?: {
|
|
220
|
+
username?: string;
|
|
221
|
+
password?: string;
|
|
222
|
+
auth?: string;
|
|
223
|
+
email?: string;
|
|
224
|
+
serveraddress?: string;
|
|
225
|
+
[key: string]: unknown;
|
|
226
|
+
};
|
|
227
|
+
[key: string]: unknown;
|
|
228
|
+
};
|
|
229
|
+
}): Promise<void>;
|
|
230
|
+
}
|
|
360
231
|
|
|
361
232
|
/**
|
|
362
233
|
* Generates documentation files
|
|
@@ -515,6 +386,134 @@ declare class Preparers implements PreparerBuilder {
|
|
|
515
386
|
get(entity: Entity): PreparerBase;
|
|
516
387
|
}
|
|
517
388
|
|
|
389
|
+
/**
|
|
390
|
+
* Options for building publishers
|
|
391
|
+
* @public
|
|
392
|
+
*/
|
|
393
|
+
type PublisherFactory = {
|
|
394
|
+
logger: LoggerService;
|
|
395
|
+
discovery: DiscoveryService;
|
|
396
|
+
customPublisher?: PublisherBase | undefined;
|
|
397
|
+
};
|
|
398
|
+
/**
|
|
399
|
+
* Key for all the different types of TechDocs publishers that are supported.
|
|
400
|
+
* @public
|
|
401
|
+
*/
|
|
402
|
+
type PublisherType = 'local' | 'googleGcs' | 'awsS3' | 'azureBlobStorage' | 'openStackSwift';
|
|
403
|
+
/**
|
|
404
|
+
* Request publish definition
|
|
405
|
+
* @public
|
|
406
|
+
*/
|
|
407
|
+
type PublishRequest = {
|
|
408
|
+
entity: Entity;
|
|
409
|
+
directory: string;
|
|
410
|
+
};
|
|
411
|
+
/**
|
|
412
|
+
* Response containing metadata about where files were published and what may
|
|
413
|
+
* have been published or updated.
|
|
414
|
+
* @public
|
|
415
|
+
*/
|
|
416
|
+
type PublishResponse = {
|
|
417
|
+
/**
|
|
418
|
+
* The URL which serves files from the local publisher's static directory.
|
|
419
|
+
*/
|
|
420
|
+
remoteUrl?: string;
|
|
421
|
+
/**
|
|
422
|
+
* The list of objects (specifically their paths) that were published.
|
|
423
|
+
* Objects do not have a preceding slash, and match how one would load the
|
|
424
|
+
* object over the `/static/docs/*` TechDocs Backend Plugin endpoint.
|
|
425
|
+
*/
|
|
426
|
+
objects?: string[];
|
|
427
|
+
} | void;
|
|
428
|
+
/**
|
|
429
|
+
* Result for the validation check.
|
|
430
|
+
* @public
|
|
431
|
+
*/
|
|
432
|
+
type ReadinessResponse = {
|
|
433
|
+
/** If true, the publisher is able to interact with the backing storage. */
|
|
434
|
+
isAvailable: boolean;
|
|
435
|
+
};
|
|
436
|
+
/**
|
|
437
|
+
* Type to hold metadata found in techdocs_metadata.json and associated with each site
|
|
438
|
+
* @param etag - ETag of the resource used to generate the site. Usually the latest commit sha of the source repository.
|
|
439
|
+
* @public
|
|
440
|
+
*/
|
|
441
|
+
type TechDocsMetadata = {
|
|
442
|
+
site_name: string;
|
|
443
|
+
site_description: string;
|
|
444
|
+
etag: string;
|
|
445
|
+
build_timestamp: number;
|
|
446
|
+
files?: string[];
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* TechDocs entity triplet migration request
|
|
450
|
+
* @public
|
|
451
|
+
*/
|
|
452
|
+
type MigrateRequest = {
|
|
453
|
+
/**
|
|
454
|
+
* Whether or not to remove the source file. Defaults to false (acting like a
|
|
455
|
+
* copy instead of a move).
|
|
456
|
+
*/
|
|
457
|
+
removeOriginal?: boolean;
|
|
458
|
+
/**
|
|
459
|
+
* Maximum number of files/objects to migrate at once. Defaults to 25.
|
|
460
|
+
*/
|
|
461
|
+
concurrency?: number;
|
|
462
|
+
};
|
|
463
|
+
/**
|
|
464
|
+
* Base class for a TechDocs publisher (e.g. Local, Google GCS Bucket, AWS S3, etc.)
|
|
465
|
+
* The publisher handles publishing of the generated static files after the prepare and generate steps of TechDocs.
|
|
466
|
+
* It also provides APIs to communicate with the storage service.
|
|
467
|
+
*
|
|
468
|
+
* @public
|
|
469
|
+
*/
|
|
470
|
+
interface PublisherBase {
|
|
471
|
+
/**
|
|
472
|
+
* Check if the publisher is ready. This check tries to perform certain checks to see if the
|
|
473
|
+
* publisher is configured correctly and can be used to publish or read documentations.
|
|
474
|
+
* The different implementations might e.g. use the provided service credentials to access the
|
|
475
|
+
* target or check if a folder/bucket is available.
|
|
476
|
+
*/
|
|
477
|
+
getReadiness(): Promise<ReadinessResponse>;
|
|
478
|
+
/**
|
|
479
|
+
* Store the generated static files onto a storage service (either local filesystem or external service).
|
|
480
|
+
*
|
|
481
|
+
* @param request - Object containing the entity from the service
|
|
482
|
+
* catalog, and the directory that contains the generated static files from TechDocs.
|
|
483
|
+
*/
|
|
484
|
+
publish(request: PublishRequest): Promise<PublishResponse>;
|
|
485
|
+
/**
|
|
486
|
+
* Retrieve TechDocs Metadata about a site e.g. name, contributors, last updated, etc.
|
|
487
|
+
* This API uses the techdocs_metadata.json file that co-exists along with the generated docs.
|
|
488
|
+
*/
|
|
489
|
+
fetchTechDocsMetadata(entityName: CompoundEntityRef): Promise<TechDocsMetadata>;
|
|
490
|
+
/**
|
|
491
|
+
* Route middleware to serve static documentation files for an entity.
|
|
492
|
+
*/
|
|
493
|
+
docsRouter(): express.Handler;
|
|
494
|
+
/**
|
|
495
|
+
* Check if the index.html is present for the Entity at the Storage location.
|
|
496
|
+
*/
|
|
497
|
+
hasDocsBeenGenerated(entityName: Entity): Promise<boolean>;
|
|
498
|
+
/**
|
|
499
|
+
* Migrates documentation objects with case sensitive entity triplets to
|
|
500
|
+
* lowercase entity triplets. This was (will be) a change introduced in
|
|
501
|
+
* `techdocs-cli` version `{0.x.y}` and `techdocs-backend` version `{0.x.y}`.
|
|
502
|
+
*
|
|
503
|
+
* Implementation of this method is unnecessary in publishers introduced
|
|
504
|
+
* after version `{0.x.y}` of `techdocs-node`.
|
|
505
|
+
*/
|
|
506
|
+
migrateDocsCase?(migrateRequest: MigrateRequest): Promise<void>;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Definition for a TechDocs publisher builder
|
|
510
|
+
* @public
|
|
511
|
+
*/
|
|
512
|
+
type PublisherBuilder = {
|
|
513
|
+
register(type: PublisherType, publisher: PublisherBase): void;
|
|
514
|
+
get(config: Config): PublisherBase;
|
|
515
|
+
};
|
|
516
|
+
|
|
518
517
|
/**
|
|
519
518
|
* Factory class to create a TechDocs publisher based on defined publisher type in app config.
|
|
520
519
|
* Uses `techdocs.publisher.type`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-techdocs-node",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.12-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,11 +53,11 @@
|
|
|
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-plugin-api": "^1.0.
|
|
57
|
-
"@backstage/catalog-model": "^1.
|
|
56
|
+
"@backstage/backend-plugin-api": "^1.0.1-next.0",
|
|
57
|
+
"@backstage/catalog-model": "^1.7.0",
|
|
58
58
|
"@backstage/config": "^1.2.0",
|
|
59
59
|
"@backstage/errors": "^1.2.4",
|
|
60
|
-
"@backstage/integration": "^1.15.0
|
|
60
|
+
"@backstage/integration": "^1.15.0",
|
|
61
61
|
"@backstage/integration-aws-node": "^0.1.12",
|
|
62
62
|
"@backstage/plugin-search-common": "^1.2.14",
|
|
63
63
|
"@backstage/plugin-techdocs-common": "^0.1.0",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"winston": "^3.2.1"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@backstage/backend-test-utils": "^1.0.
|
|
82
|
-
"@backstage/cli": "^0.
|
|
81
|
+
"@backstage/backend-test-utils": "^1.0.1-next.0",
|
|
82
|
+
"@backstage/cli": "^0.28.0-next.0",
|
|
83
83
|
"@types/fs-extra": "^11.0.0",
|
|
84
84
|
"@types/js-yaml": "^4.0.0",
|
|
85
85
|
"@types/mime-types": "^2.1.0",
|