@peterhauge/apiops-cli 0.1.6-alpha.0 → 0.1.7-alpha.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/cli/extract-command.js +3 -3
- package/dist/cli/extract-command.js.map +1 -1
- package/dist/cli/publish-command.js +3 -3
- package/dist/cli/publish-command.js.map +1 -1
- package/dist/lib/dependency-graph.d.ts.map +1 -1
- package/dist/lib/dependency-graph.js +4 -1
- package/dist/lib/dependency-graph.js.map +1 -1
- package/dist/lib/resource-path.d.ts.map +1 -1
- package/dist/lib/resource-path.js +29 -8
- package/dist/lib/resource-path.js.map +1 -1
- package/dist/models/resource-types.d.ts +9 -1
- package/dist/models/resource-types.d.ts.map +1 -1
- package/dist/models/resource-types.js +20 -0
- package/dist/models/resource-types.js.map +1 -1
- package/dist/services/api-publisher.d.ts.map +1 -1
- package/dist/services/api-publisher.js +28 -3
- package/dist/services/api-publisher.js.map +1 -1
- package/dist/services/extract-service.js +5 -10
- package/dist/services/extract-service.js.map +1 -1
- package/dist/services/product-publisher.d.ts.map +1 -1
- package/dist/services/product-publisher.js +39 -0
- package/dist/services/product-publisher.js.map +1 -1
- package/dist/services/publish-service.js +44 -1
- package/dist/services/publish-service.js.map +1 -1
- package/dist/services/resource-extractor.d.ts.map +1 -1
- package/dist/services/resource-extractor.js +52 -1
- package/dist/services/resource-extractor.js.map +1 -1
- package/dist/services/resource-publisher.d.ts.map +1 -1
- package/dist/services/resource-publisher.js +63 -0
- package/dist/services/resource-publisher.js.map +1 -1
- package/dist/services/workspace-extractor.d.ts +1 -9
- package/dist/services/workspace-extractor.d.ts.map +1 -1
- package/dist/services/workspace-extractor.js +32 -39
- package/dist/services/workspace-extractor.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,41 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
/**
|
|
4
|
-
* T027: Workspace-scoped extraction
|
|
5
|
-
* List workspaces, extract workspace-scoped resources under workspaces/{name}/
|
|
6
|
-
* using same resource-extractor with workspace context prefix.
|
|
7
|
-
*/
|
|
8
|
-
import { ResourceType } from '../models/resource-types.js';
|
|
1
|
+
import { ResourceType, RESOURCE_TYPE_METADATA } from '../models/resource-types.js';
|
|
9
2
|
import { extractResourceType } from './resource-extractor.js';
|
|
10
3
|
import { extractApiResources } from './api-extractor.js';
|
|
11
4
|
import { extractProductResources } from './product-extractor.js';
|
|
12
5
|
import { logger } from '../lib/logger.js';
|
|
13
6
|
/**
|
|
14
|
-
* Types that can exist at the workspace level.
|
|
15
|
-
*
|
|
7
|
+
* Types that can exist at the workspace level, derived from RESOURCE_TYPE_METADATA.
|
|
8
|
+
* Enumerated in declaration order for deterministic iteration.
|
|
9
|
+
* A type is workspace-capable when its metadata has `workspaceSupported: true`.
|
|
16
10
|
*/
|
|
17
|
-
const WORKSPACE_SUPPORTED_TYPES = [
|
|
18
|
-
ResourceType.NamedValue,
|
|
19
|
-
ResourceType.Tag,
|
|
20
|
-
ResourceType.Backend,
|
|
21
|
-
ResourceType.Logger,
|
|
22
|
-
ResourceType.Diagnostic,
|
|
23
|
-
ResourceType.PolicyFragment,
|
|
24
|
-
ResourceType.Product,
|
|
25
|
-
ResourceType.Api,
|
|
26
|
-
ResourceType.Subscription,
|
|
27
|
-
ResourceType.GlobalSchema,
|
|
28
|
-
ResourceType.Documentation,
|
|
29
|
-
ResourceType.Group,
|
|
30
|
-
];
|
|
11
|
+
const WORKSPACE_SUPPORTED_TYPES = Object.values(ResourceType).filter((type) => RESOURCE_TYPE_METADATA[type].workspaceSupported === true);
|
|
31
12
|
/**
|
|
32
13
|
* Extract resources from all workspaces.
|
|
33
|
-
|
|
34
|
-
* Note: Workspace listing is not supported through the current IApimClient
|
|
35
|
-
* interface (ResourceType doesn't include Workspace). This function accepts
|
|
36
|
-
* workspace names from the filter config. If workspaceNames is not specified
|
|
37
|
-
* in the filter, workspace extraction is skipped.
|
|
38
|
-
*
|
|
14
|
+
|
|
39
15
|
* @param client - APIM REST client
|
|
40
16
|
* @param store - Artifact file store
|
|
41
17
|
* @param context - APIM service context
|
|
@@ -45,23 +21,41 @@ const WORKSPACE_SUPPORTED_TYPES = [
|
|
|
45
21
|
*/
|
|
46
22
|
export async function extractWorkspaces(client, store, context, outputDir, filter) {
|
|
47
23
|
const results = [];
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
24
|
+
let workspaceNames;
|
|
25
|
+
if (filter?.workspaceNames && filter.workspaceNames.length > 0) {
|
|
26
|
+
workspaceNames = filter.workspaceNames;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const discovered = [];
|
|
30
|
+
for await (const item of client.listResources(context, ResourceType.Workspace)) {
|
|
31
|
+
const name = item['name'];
|
|
32
|
+
if (typeof name === 'string') {
|
|
33
|
+
discovered.push(name);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
workspaceNames = discovered;
|
|
37
|
+
}
|
|
38
|
+
if (workspaceNames.length === 0) {
|
|
39
|
+
logger.debug('No workspaces found — skipping workspace extraction');
|
|
53
40
|
return results;
|
|
54
41
|
}
|
|
55
42
|
logger.info(`Extracting ${workspaceNames.length} workspace(s)...`);
|
|
56
43
|
for (const wsName of workspaceNames) {
|
|
44
|
+
// Persist the workspace container itself so publish can recreate it
|
|
45
|
+
// before workspace-scoped children (named values, APIs, products, etc.).
|
|
46
|
+
const wsDescriptor = { type: ResourceType.Workspace, nameParts: [wsName] };
|
|
47
|
+
const wsJson = await client.getResource(context, wsDescriptor);
|
|
48
|
+
if (!wsJson) {
|
|
49
|
+
logger.error(`Workspace container "${wsName}" was discovered but could not be read. Continuing with workspace child extraction.`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
await store.writeResource(outputDir, wsDescriptor, wsJson);
|
|
53
|
+
}
|
|
57
54
|
const wsResult = await extractWorkspace(client, store, context, wsName, outputDir, filter);
|
|
58
55
|
results.push(wsResult);
|
|
59
56
|
}
|
|
60
57
|
return results;
|
|
61
58
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Extract all resources from a single workspace.
|
|
64
|
-
*/
|
|
65
59
|
async function extractWorkspace(client, store, context, workspaceName, outputDir, filter) {
|
|
66
60
|
logger.info(`Extracting workspace "${workspaceName}"...`);
|
|
67
61
|
let resourceCount = 0;
|
|
@@ -72,7 +66,6 @@ async function extractWorkspace(client, store, context, workspaceName, outputDir
|
|
|
72
66
|
...context,
|
|
73
67
|
baseUrl: `${context.baseUrl}/workspaces/${encodeURIComponent(workspaceName)}`,
|
|
74
68
|
};
|
|
75
|
-
// Extract each supported resource type within the workspace
|
|
76
69
|
for (const type of WORKSPACE_SUPPORTED_TYPES) {
|
|
77
70
|
try {
|
|
78
71
|
const result = await extractResourceType(client, store, wsContext, type, outputDir, filter, undefined, workspaceName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-extractor.js","sourceRoot":"","sources":["../../src/services/workspace-extractor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"workspace-extractor.js","sourceRoot":"","sources":["../../src/services/workspace-extractor.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAEnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C;;;;GAIG;AACH,MAAM,yBAAyB,GAAmB,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAClF,CAAC,IAAI,EAAE,EAAE,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,kBAAkB,KAAK,IAAI,CACnE,CAAC;AAQF;;;;;;;;;GASG;AACH,MAA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