@peterhauge/apiops-cli 0.1.3-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/LICENSE.md +21 -0
- package/README.md +135 -0
- package/dist/cli/extract-command.d.ts +12 -0
- package/dist/cli/extract-command.d.ts.map +1 -0
- package/dist/cli/extract-command.js +157 -0
- package/dist/cli/extract-command.js.map +1 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +74 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init-command.d.ts +11 -0
- package/dist/cli/init-command.d.ts.map +1 -0
- package/dist/cli/init-command.js +87 -0
- package/dist/cli/init-command.js.map +1 -0
- package/dist/cli/publish-command.d.ts +12 -0
- package/dist/cli/publish-command.d.ts.map +1 -0
- package/dist/cli/publish-command.js +159 -0
- package/dist/cli/publish-command.js.map +1 -0
- package/dist/clients/apim-client.d.ts +110 -0
- package/dist/clients/apim-client.d.ts.map +1 -0
- package/dist/clients/apim-client.js +586 -0
- package/dist/clients/apim-client.js.map +1 -0
- package/dist/clients/artifact-store.d.ts +23 -0
- package/dist/clients/artifact-store.d.ts.map +1 -0
- package/dist/clients/artifact-store.js +188 -0
- package/dist/clients/artifact-store.js.map +1 -0
- package/dist/clients/iapim-client.d.ts +52 -0
- package/dist/clients/iapim-client.d.ts.map +1 -0
- package/dist/clients/iapim-client.js +6 -0
- package/dist/clients/iapim-client.js.map +1 -0
- package/dist/clients/iartifact-store.d.ts +50 -0
- package/dist/clients/iartifact-store.d.ts.map +1 -0
- package/dist/clients/iartifact-store.js +6 -0
- package/dist/clients/iartifact-store.js.map +1 -0
- package/dist/lib/auto-generated.d.ts +27 -0
- package/dist/lib/auto-generated.d.ts.map +1 -0
- package/dist/lib/auto-generated.js +34 -0
- package/dist/lib/auto-generated.js.map +1 -0
- package/dist/lib/cloud-config.d.ts +29 -0
- package/dist/lib/cloud-config.d.ts.map +1 -0
- package/dist/lib/cloud-config.js +60 -0
- package/dist/lib/cloud-config.js.map +1 -0
- package/dist/lib/config-loader.d.ts +21 -0
- package/dist/lib/config-loader.d.ts.map +1 -0
- package/dist/lib/config-loader.js +131 -0
- package/dist/lib/config-loader.js.map +1 -0
- package/dist/lib/dependency-graph.d.ts +43 -0
- package/dist/lib/dependency-graph.d.ts.map +1 -0
- package/dist/lib/dependency-graph.js +163 -0
- package/dist/lib/dependency-graph.js.map +1 -0
- package/dist/lib/exit-codes.d.ts +27 -0
- package/dist/lib/exit-codes.d.ts.map +1 -0
- package/dist/lib/exit-codes.js +33 -0
- package/dist/lib/exit-codes.js.map +1 -0
- package/dist/lib/logger.d.ts +39 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +128 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/parallel-runner.d.ts +38 -0
- package/dist/lib/parallel-runner.d.ts.map +1 -0
- package/dist/lib/parallel-runner.js +70 -0
- package/dist/lib/parallel-runner.js.map +1 -0
- package/dist/lib/resource-path.d.ts +205 -0
- package/dist/lib/resource-path.d.ts.map +1 -0
- package/dist/lib/resource-path.js +401 -0
- package/dist/lib/resource-path.js.map +1 -0
- package/dist/lib/resource-uri.d.ts +40 -0
- package/dist/lib/resource-uri.d.ts.map +1 -0
- package/dist/lib/resource-uri.js +86 -0
- package/dist/lib/resource-uri.js.map +1 -0
- package/dist/lib/user-agent.d.ts +2 -0
- package/dist/lib/user-agent.d.ts.map +1 -0
- package/dist/lib/user-agent.js +5 -0
- package/dist/lib/user-agent.js.map +1 -0
- package/dist/models/config.d.ts +83 -0
- package/dist/models/config.d.ts.map +1 -0
- package/dist/models/config.js +6 -0
- package/dist/models/config.js.map +1 -0
- package/dist/models/resource-types.d.ts +66 -0
- package/dist/models/resource-types.d.ts.map +1 -0
- package/dist/models/resource-types.js +243 -0
- package/dist/models/resource-types.js.map +1 -0
- package/dist/models/types.d.ts +47 -0
- package/dist/models/types.d.ts.map +1 -0
- package/dist/models/types.js +6 -0
- package/dist/models/types.js.map +1 -0
- package/dist/services/api-extractor.d.ts +36 -0
- package/dist/services/api-extractor.d.ts.map +1 -0
- package/dist/services/api-extractor.js +319 -0
- package/dist/services/api-extractor.js.map +1 -0
- package/dist/services/api-publisher.d.ts +18 -0
- package/dist/services/api-publisher.d.ts.map +1 -0
- package/dist/services/api-publisher.js +290 -0
- package/dist/services/api-publisher.js.map +1 -0
- package/dist/services/delete-unmatched-service.d.ts +17 -0
- package/dist/services/delete-unmatched-service.d.ts.map +1 -0
- package/dist/services/delete-unmatched-service.js +143 -0
- package/dist/services/delete-unmatched-service.js.map +1 -0
- package/dist/services/dry-run-reporter.d.ts +30 -0
- package/dist/services/dry-run-reporter.d.ts.map +1 -0
- package/dist/services/dry-run-reporter.js +111 -0
- package/dist/services/dry-run-reporter.js.map +1 -0
- package/dist/services/extract-service.d.ts +47 -0
- package/dist/services/extract-service.d.ts.map +1 -0
- package/dist/services/extract-service.js +374 -0
- package/dist/services/extract-service.js.map +1 -0
- package/dist/services/filter-service.d.ts +29 -0
- package/dist/services/filter-service.d.ts.map +1 -0
- package/dist/services/filter-service.js +143 -0
- package/dist/services/filter-service.js.map +1 -0
- package/dist/services/git-diff-service.d.ts +23 -0
- package/dist/services/git-diff-service.d.ts.map +1 -0
- package/dist/services/git-diff-service.js +135 -0
- package/dist/services/git-diff-service.js.map +1 -0
- package/dist/services/identity-guide-service.d.ts +11 -0
- package/dist/services/identity-guide-service.d.ts.map +1 -0
- package/dist/services/identity-guide-service.js +227 -0
- package/dist/services/identity-guide-service.js.map +1 -0
- package/dist/services/init-service.d.ts +16 -0
- package/dist/services/init-service.d.ts.map +1 -0
- package/dist/services/init-service.js +304 -0
- package/dist/services/init-service.js.map +1 -0
- package/dist/services/keyvault-checker.d.ts +58 -0
- package/dist/services/keyvault-checker.d.ts.map +1 -0
- package/dist/services/keyvault-checker.js +390 -0
- package/dist/services/keyvault-checker.js.map +1 -0
- package/dist/services/override-merger.d.ts +20 -0
- package/dist/services/override-merger.d.ts.map +1 -0
- package/dist/services/override-merger.js +102 -0
- package/dist/services/override-merger.js.map +1 -0
- package/dist/services/product-extractor.d.ts +26 -0
- package/dist/services/product-extractor.d.ts.map +1 -0
- package/dist/services/product-extractor.js +141 -0
- package/dist/services/product-extractor.js.map +1 -0
- package/dist/services/product-publisher.d.ts +15 -0
- package/dist/services/product-publisher.d.ts.map +1 -0
- package/dist/services/product-publisher.js +113 -0
- package/dist/services/product-publisher.js.map +1 -0
- package/dist/services/prompt-service.d.ts +13 -0
- package/dist/services/prompt-service.d.ts.map +1 -0
- package/dist/services/prompt-service.js +69 -0
- package/dist/services/prompt-service.js.map +1 -0
- package/dist/services/publish-service.d.ts +31 -0
- package/dist/services/publish-service.d.ts.map +1 -0
- package/dist/services/publish-service.js +445 -0
- package/dist/services/publish-service.js.map +1 -0
- package/dist/services/resource-extractor.d.ts +52 -0
- package/dist/services/resource-extractor.d.ts.map +1 -0
- package/dist/services/resource-extractor.js +168 -0
- package/dist/services/resource-extractor.js.map +1 -0
- package/dist/services/resource-publisher.d.ts +23 -0
- package/dist/services/resource-publisher.d.ts.map +1 -0
- package/dist/services/resource-publisher.js +349 -0
- package/dist/services/resource-publisher.js.map +1 -0
- package/dist/services/secret-redactor.d.ts +20 -0
- package/dist/services/secret-redactor.d.ts.map +1 -0
- package/dist/services/secret-redactor.js +45 -0
- package/dist/services/secret-redactor.js.map +1 -0
- package/dist/services/transitive-resolver.d.ts +45 -0
- package/dist/services/transitive-resolver.d.ts.map +1 -0
- package/dist/services/transitive-resolver.js +177 -0
- package/dist/services/transitive-resolver.js.map +1 -0
- package/dist/services/workspace-extractor.d.ts +34 -0
- package/dist/services/workspace-extractor.d.ts.map +1 -0
- package/dist/services/workspace-extractor.js +120 -0
- package/dist/services/workspace-extractor.js.map +1 -0
- package/dist/templates/azure-devops/extract-pipeline.d.ts +9 -0
- package/dist/templates/azure-devops/extract-pipeline.d.ts.map +1 -0
- package/dist/templates/azure-devops/extract-pipeline.js +95 -0
- package/dist/templates/azure-devops/extract-pipeline.js.map +1 -0
- package/dist/templates/azure-devops/publish-pipeline.d.ts +10 -0
- package/dist/templates/azure-devops/publish-pipeline.d.ts.map +1 -0
- package/dist/templates/azure-devops/publish-pipeline.js +100 -0
- package/dist/templates/azure-devops/publish-pipeline.js.map +1 -0
- package/dist/templates/configs/filter-config.d.ts +6 -0
- package/dist/templates/configs/filter-config.d.ts.map +1 -0
- package/dist/templates/configs/filter-config.js +51 -0
- package/dist/templates/configs/filter-config.js.map +1 -0
- package/dist/templates/configs/override-config.d.ts +6 -0
- package/dist/templates/configs/override-config.d.ts.map +1 -0
- package/dist/templates/configs/override-config.js +45 -0
- package/dist/templates/configs/override-config.js.map +1 -0
- package/dist/templates/configs/package-json.d.ts +10 -0
- package/dist/templates/configs/package-json.d.ts.map +1 -0
- package/dist/templates/configs/package-json.js +19 -0
- package/dist/templates/configs/package-json.js.map +1 -0
- package/dist/templates/copilot/identity-setup-prompt.d.ts +13 -0
- package/dist/templates/copilot/identity-setup-prompt.d.ts.map +1 -0
- package/dist/templates/copilot/identity-setup-prompt.js +279 -0
- package/dist/templates/copilot/identity-setup-prompt.js.map +1 -0
- package/dist/templates/github-actions/extract-workflow.d.ts +9 -0
- package/dist/templates/github-actions/extract-workflow.d.ts.map +1 -0
- package/dist/templates/github-actions/extract-workflow.js +126 -0
- package/dist/templates/github-actions/extract-workflow.js.map +1 -0
- package/dist/templates/github-actions/publish-workflow.d.ts +10 -0
- package/dist/templates/github-actions/publish-workflow.d.ts.map +1 -0
- package/dist/templates/github-actions/publish-workflow.js +105 -0
- package/dist/templates/github-actions/publish-workflow.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T018: Parallel execution runner with concurrency control.
|
|
3
|
+
*
|
|
4
|
+
* Custom implementation (no external dependencies such as p-limit) to limit
|
|
5
|
+
* concurrent APIM REST API calls and avoid 429 rate limiting. Azure APIM has
|
|
6
|
+
* strict per-second request limits, so unbounded Promise.all() would fire all
|
|
7
|
+
* requests simultaneously, triggering throttling. Bounded concurrency is a
|
|
8
|
+
* requirement from research.md R8 and justified in tasks.md T018.
|
|
9
|
+
*
|
|
10
|
+
* Built-in implementation without external dependencies (no p-limit).
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Executes tasks in parallel with bounded concurrency.
|
|
14
|
+
* Uses Promise.allSettled for fault tolerance.
|
|
15
|
+
*/
|
|
16
|
+
export class ParallelRunner {
|
|
17
|
+
concurrency;
|
|
18
|
+
constructor(options) {
|
|
19
|
+
this.concurrency = options.concurrency;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Run tasks in parallel with bounded concurrency.
|
|
23
|
+
* Returns results for all tasks, including failures.
|
|
24
|
+
*/
|
|
25
|
+
async runAll(tasks) {
|
|
26
|
+
const results = [];
|
|
27
|
+
const executing = new Map();
|
|
28
|
+
const completed = new Set();
|
|
29
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
30
|
+
const task = tasks[i];
|
|
31
|
+
if (!task)
|
|
32
|
+
continue;
|
|
33
|
+
const promise = this.executeTask(task, i, results).then(() => {
|
|
34
|
+
completed.add(i);
|
|
35
|
+
});
|
|
36
|
+
executing.set(i, promise);
|
|
37
|
+
// When we hit concurrency limit, wait for one to finish
|
|
38
|
+
if (executing.size >= this.concurrency) {
|
|
39
|
+
await Promise.race(executing.values());
|
|
40
|
+
// Remove completed promises
|
|
41
|
+
for (const idx of completed) {
|
|
42
|
+
executing.delete(idx);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Wait for remaining tasks to complete
|
|
47
|
+
await Promise.allSettled(executing.values());
|
|
48
|
+
return results;
|
|
49
|
+
}
|
|
50
|
+
async executeTask(task, index, results) {
|
|
51
|
+
try {
|
|
52
|
+
const value = await task();
|
|
53
|
+
results[index] = { status: 'fulfilled', value };
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
results[index] = {
|
|
57
|
+
status: 'rejected',
|
|
58
|
+
reason: error instanceof Error ? error : new Error(String(error))
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Helper function to run tasks with default concurrency.
|
|
65
|
+
*/
|
|
66
|
+
export async function runParallel(tasks, concurrency = 5) {
|
|
67
|
+
const runner = new ParallelRunner({ concurrency });
|
|
68
|
+
return runner.runAll(tasks);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=parallel-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallel-runner.js","sourceRoot":"","sources":["../../src/lib/parallel-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAYH;;;GAGG;AACH,MAAM,OAAO,cAAc;IACjB,WAAW,CAAS;IAE5B,YAAY,OAA8B;QACxC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACzC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAI,KAA2B;QACzC,MAAM,OAAO,GAAoB,EAAE,CAAC;QACpC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;QACnD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;QAEpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACtB,IAAI,CAAC,IAAI;gBAAE,SAAS;YAEpB,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;gBAC3D,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACnB,CAAC,CAAC,CAAC;YAEH,SAAS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|
2
|
+
* T013: Resource descriptor ↔ artifact file path mapping
|
|
3
|
+
* Map descriptor to directory/file paths per data-model.md artifact conventions
|
|
4
|
+
*/
|
|
5
|
+
import { ResourceDescriptor } from '../models/types.js';
|
|
6
|
+
import { ResourceType } from '../models/resource-types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Fills all positional `{i}` tokens in a template string with `nameParts[i]`.
|
|
9
|
+
* Throws if a placeholder index has no corresponding entry in `nameParts`.
|
|
10
|
+
*
|
|
11
|
+
* Examples:
|
|
12
|
+
* formatTemplatePath('apis/{0}/operations/{1}', ['petstore', 'get-user'])
|
|
13
|
+
* → 'apis/petstore/operations/get-user'
|
|
14
|
+
* formatTemplatePath('', []) → ''
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatTemplatePath(template: string, nameParts: string[]): string;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the number of positional `{i}` placeholders in a template string.
|
|
19
|
+
*
|
|
20
|
+
* Used by callers that need to validate that enough name-parts have been
|
|
21
|
+
* supplied before filling a template — without performing regex matching
|
|
22
|
+
* themselves.
|
|
23
|
+
*
|
|
24
|
+
* Example:
|
|
25
|
+
* countTemplatePlaceholders('apis/{0}/operations/{1}') → 2
|
|
26
|
+
* countTemplatePlaceholders('policies/policy') → 0
|
|
27
|
+
*/
|
|
28
|
+
export declare function countTemplatePlaceholders(template: string): number;
|
|
29
|
+
/**
|
|
30
|
+
* Ensures a path starts with a single leading slash.
|
|
31
|
+
*
|
|
32
|
+
* Example:
|
|
33
|
+
* makeFullPath('namedValues/my-nv') → '/namedValues/my-nv'
|
|
34
|
+
* makeFullPath('/namedValues/my-nv') → '/namedValues/my-nv'
|
|
35
|
+
*/
|
|
36
|
+
export declare function makeFullPath(relativePath: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Strips a single leading slash from a path, if present.
|
|
39
|
+
*
|
|
40
|
+
* Example:
|
|
41
|
+
* makeRelativePath('/namedValues/my-nv') → 'namedValues/my-nv'
|
|
42
|
+
* makeRelativePath('namedValues/my-nv') → 'namedValues/my-nv'
|
|
43
|
+
*/
|
|
44
|
+
export declare function makeRelativePath(absolutePath: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the resource's own name — the last element of `nameParts`.
|
|
47
|
+
*
|
|
48
|
+
* For 1-part types (e.g. Api, Product) `nameParts` contains only the own
|
|
49
|
+
* name, so this is equivalent to `nameParts[0]`. For 2-part types (e.g.
|
|
50
|
+
* ApiOperation, ProductTag) the own name is always the final element, with
|
|
51
|
+
* the parent name preceding it. Using this helper instead of a hard-coded
|
|
52
|
+
* index guards against future arity changes and avoids accidentally
|
|
53
|
+
* returning the parent name.
|
|
54
|
+
*
|
|
55
|
+
* Throws a `RangeError` if `nameParts` is empty.
|
|
56
|
+
*
|
|
57
|
+
* Examples:
|
|
58
|
+
* getNameFromNameParts(['petstore']) → 'petstore'
|
|
59
|
+
* getNameFromNameParts(['petstore', 'get-user']) → 'get-user'
|
|
60
|
+
* getNameFromNameParts([]) → throws RangeError
|
|
61
|
+
*/
|
|
62
|
+
export declare function getNameFromNameParts(nameParts: string[]): string;
|
|
63
|
+
/**
|
|
64
|
+
* Returns `nameParts[index]`, throwing a descriptive `RangeError` if the
|
|
65
|
+
* index is out of range.
|
|
66
|
+
*
|
|
67
|
+
* Prefer this over direct bracket access (`nameParts[0]`) so that missing
|
|
68
|
+
* name-parts surface as an explicit error rather than a silent `undefined`.
|
|
69
|
+
*
|
|
70
|
+
* Examples:
|
|
71
|
+
* getNamePart(['petstore', 'get-user'], 0) → 'petstore'
|
|
72
|
+
* getNamePart(['petstore', 'get-user'], 1) → 'get-user'
|
|
73
|
+
* getNamePart([], 0) → throws RangeError
|
|
74
|
+
*/
|
|
75
|
+
export declare function getNamePart(nameParts: string[], index: number): string;
|
|
76
|
+
/**
|
|
77
|
+
* Matches a positional template against a slash-delimited path string and
|
|
78
|
+
* returns the captured name-part values in positional order, or `undefined`
|
|
79
|
+
* if the path does not match the template.
|
|
80
|
+
*
|
|
81
|
+
* Both artifact-directory paths and ARM path suffixes use the same
|
|
82
|
+
* `{0}`, `{1}` placeholder syntax, so this single function handles both.
|
|
83
|
+
* Callers are not required to know anything about regexes.
|
|
84
|
+
*
|
|
85
|
+
* Examples:
|
|
86
|
+
* parseTemplatePath('apis/{0}/operations/{1}', 'apis/petstore/operations/get')
|
|
87
|
+
* → ['petstore', 'get']
|
|
88
|
+
* parseTemplatePath('policies/policy', 'policies/policy')
|
|
89
|
+
* → []
|
|
90
|
+
* parseTemplatePath('apis/{0}', 'backends/b1')
|
|
91
|
+
* → undefined
|
|
92
|
+
*/
|
|
93
|
+
export declare function parseTemplatePath(template: string, path: string): string[] | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Builds the artifact directory path for a given descriptor.
|
|
96
|
+
* Returns the directory where this resource's files should be stored.
|
|
97
|
+
*
|
|
98
|
+
* @param baseDir - Root artifact directory
|
|
99
|
+
* @param descriptor - Resource descriptor
|
|
100
|
+
* @returns Full directory path (OS-normalized)
|
|
101
|
+
*/
|
|
102
|
+
export declare function buildArtifactDirectory(baseDir: string, descriptor: ResourceDescriptor): string;
|
|
103
|
+
/**
|
|
104
|
+
* Builds the full artifact file path for a given descriptor.
|
|
105
|
+
* Returns the path to the info file (JSON/XML/MD).
|
|
106
|
+
*
|
|
107
|
+
* @param baseDir - Root artifact directory
|
|
108
|
+
* @param descriptor - Resource descriptor
|
|
109
|
+
* @returns Full file path (OS-normalized), or undefined if resource has no info file
|
|
110
|
+
*/
|
|
111
|
+
export declare function buildArtifactFilePath(baseDir: string, descriptor: ResourceDescriptor): string | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Builds the policy file path for a resource that supports policies.
|
|
114
|
+
*
|
|
115
|
+
* @param baseDir - Root artifact directory
|
|
116
|
+
* @param descriptor - Resource descriptor
|
|
117
|
+
* @returns Full path to policy.xml file
|
|
118
|
+
*/
|
|
119
|
+
export declare function buildPolicyFilePath(baseDir: string, descriptor: ResourceDescriptor): string;
|
|
120
|
+
/**
|
|
121
|
+
* Builds the API specification file path.
|
|
122
|
+
*
|
|
123
|
+
* @param baseDir - Root artifact directory
|
|
124
|
+
* @param descriptor - API descriptor
|
|
125
|
+
* @param format - Specification format (yaml, json, graphql, wsdl, wadl)
|
|
126
|
+
* @returns Full path to specification file
|
|
127
|
+
*/
|
|
128
|
+
export declare function buildSpecificationFilePath(baseDir: string, descriptor: ResourceDescriptor, format: 'yaml' | 'json' | 'graphql' | 'wsdl' | 'wadl'): string;
|
|
129
|
+
/**
|
|
130
|
+
* Builds the association file path (apis.json or groups.json).
|
|
131
|
+
*
|
|
132
|
+
* @param baseDir - Root artifact directory
|
|
133
|
+
* @param descriptor - Product or Gateway descriptor
|
|
134
|
+
* @param associationType - Type of association (apis, groups, or tags)
|
|
135
|
+
* @returns Full path to association file
|
|
136
|
+
*/
|
|
137
|
+
export declare function buildAssociationFilePath(baseDir: string, descriptor: ResourceDescriptor, associationType: 'apis' | 'groups' | 'tags'): string;
|
|
138
|
+
/**
|
|
139
|
+
* Derives the list URL path segment(s) from an ARM path suffix template.
|
|
140
|
+
*
|
|
141
|
+
* The list path is structurally derivable from `armPathSuffix`:
|
|
142
|
+
* - Last segment is a fixed word (no placeholder) → singleton; neither path is present.
|
|
143
|
+
* - Exactly one `{N}` placeholder and it is the last segment → top-level resource;
|
|
144
|
+
* `listPath` = the path before the placeholder (with a leading '/').
|
|
145
|
+
* - Two or more `{N}` placeholders and the last segment is the highest-index one →
|
|
146
|
+
* child resource; `childListPath` = the collection segment immediately before the
|
|
147
|
+
* last placeholder (with a leading '/').
|
|
148
|
+
*
|
|
149
|
+
* Examples:
|
|
150
|
+
* deriveListPaths('namedValues/{0}') → { listPath: '/namedValues' }
|
|
151
|
+
* deriveListPaths('apis/{0}/operations/{1}') → { childListPath: '/operations' }
|
|
152
|
+
* deriveListPaths('policies/policy') → {} (singleton)
|
|
153
|
+
* deriveListPaths('apis/{0}/policies/policy') → {} (singleton)
|
|
154
|
+
*/
|
|
155
|
+
export declare function deriveListPaths(template: string): {
|
|
156
|
+
listPath?: string;
|
|
157
|
+
childListPath?: string;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Parses an artifact file path back into a ResourceDescriptor.
|
|
161
|
+
* Inverse of buildArtifactFilePath.
|
|
162
|
+
*
|
|
163
|
+
* @param baseDir - Root artifact directory
|
|
164
|
+
* @param filePath - Full path to artifact file
|
|
165
|
+
* @returns ResourceDescriptor or undefined if path doesn't match known patterns
|
|
166
|
+
*/
|
|
167
|
+
export declare function parseArtifactPath(baseDir: string, filePath: string): ResourceDescriptor | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* Check if a resource type is a singleton (no list, only get).
|
|
170
|
+
* Singletons have armPathSuffix ending with a fixed segment (no `{n}` placeholder).
|
|
171
|
+
* E.g., ServicePolicy (`policies/policy`), ApiWiki (`apis/{0}/wikis/default`).
|
|
172
|
+
*/
|
|
173
|
+
export declare function isSingletonType(type: ResourceType): boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Check if a resource type is a child type requiring a parent.
|
|
176
|
+
* Child types have armPathSuffix with more path segments after the first placeholder.
|
|
177
|
+
* E.g., `apis/{0}/tags/{1}` or `apis/{0}/policies/policy`.
|
|
178
|
+
*/
|
|
179
|
+
export declare function isChildType(type: ResourceType): boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Compute the publish tier for a resource type based on ARM path structure.
|
|
182
|
+
* Resources are published from lowest tier to highest; same tier runs in parallel.
|
|
183
|
+
*
|
|
184
|
+
* Tier formula: `placeholderCount * 2 + (hasSegmentsAfterLastPlaceholder ? 1 : 0)`
|
|
185
|
+
*
|
|
186
|
+
* This ensures:
|
|
187
|
+
* - Fewer placeholders = earlier tier (parents before children)
|
|
188
|
+
* - Within same placeholder count, resources ending at a placeholder come
|
|
189
|
+
* before those with fixed segments after (e.g., operations before operation policies)
|
|
190
|
+
*
|
|
191
|
+
* Examples:
|
|
192
|
+
* `apis/{0}` → tier 2 (1 placeholder, ends at placeholder)
|
|
193
|
+
* `apis/{0}/policies/policy` → tier 3 (1 placeholder, has suffix)
|
|
194
|
+
* `apis/{0}/operations/{1}` → tier 4 (2 placeholders, ends at placeholder)
|
|
195
|
+
* `apis/{0}/operations/{1}/policies/policy` → tier 5 (2 placeholders, has suffix)
|
|
196
|
+
*/
|
|
197
|
+
export declare function getPublishTier(type: ResourceType): number;
|
|
198
|
+
/**
|
|
199
|
+
* Check if a resource type is a "grandchild" - has path segments after the last placeholder.
|
|
200
|
+
* These types depend on an intermediate parent that must exist first.
|
|
201
|
+
*
|
|
202
|
+
* @deprecated Use getPublishTier() for N-tier ordering instead
|
|
203
|
+
*/
|
|
204
|
+
export declare function hasNestedParent(type: ResourceType): boolean;
|
|
205
|
+
//# sourceMappingURL=resource-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-path.d.ts","sourceRoot":"","sources":["../../src/lib/resource-path.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAA0B,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAenF;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,CAYhF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,CAMhE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE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