@heroku/sdk 0.1.0-beta.0 → 0.3.0-beta.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/resources/data/database.d.ts +1 -1
- package/dist/resources/data/maintenance.d.ts +1 -1
- package/dist/resources/data/postgres-database.d.ts +1 -1
- package/dist/resources/data/transfer.d.ts +1 -1
- package/dist/resources/platform/add-on/index.d.ts +1 -1
- package/dist/resources/platform/app/index.d.ts +1 -1
- package/dist/resources/platform/dyno/index.d.ts +1 -1
- package/dist/resources/platform/log-session/index.d.ts +1 -1
- package/dist/resources/platform/pipeline/coupling.d.ts +1 -1
- package/dist/resources/platform/pipeline/index.d.ts +1 -1
- package/dist/resources/platform/pipeline/promotion.d.ts +1 -1
- package/package.json +25 -7
- package/dist/compositions/add-on.d.ts +0 -7
- package/dist/compositions/add-on.js +0 -6
- package/dist/compositions/app.d.ts +0 -8
- package/dist/compositions/app.js +0 -11
- package/dist/compositions/dyno.d.ts +0 -17
- package/dist/compositions/dyno.js +0 -23
- package/dist/compositions/pg.d.ts +0 -15
- package/dist/compositions/pg.js +0 -56
- package/dist/compositions/pipeline.d.ts +0 -33
- package/dist/compositions/pipeline.js +0 -146
- package/dist/resources/data/backup.d.ts +0 -9
- package/dist/resources/data/backup.js +0 -10
- package/dist/resources/data/internal/resolve-addon-id.d.ts +0 -2
- package/dist/resources/data/internal/resolve-addon-id.js +0 -13
- package/dist/resources/data/postgres-credential.d.ts +0 -11
- package/dist/resources/data/postgres-credential.js +0 -16
- package/dist/resources/data/postgres.d.ts +0 -9
- package/dist/resources/data/postgres.js +0 -10
- package/dist/resources/data/transfer-schedule.d.ts +0 -9
- package/dist/resources/data/transfer-schedule.js +0 -10
- package/dist/resources/platform/add-on.d.ts +0 -211
- package/dist/resources/platform/add-on.js +0 -354
- package/dist/resources/platform/app.d.ts +0 -56
- package/dist/resources/platform/app.js +0 -50
- package/dist/resources/platform/dyno.d.ts +0 -45
- package/dist/resources/platform/dyno.js +0 -26
- package/dist/resources/platform/log-session.d.ts +0 -81
- package/dist/resources/platform/log-session.js +0 -167
- package/dist/resources/platform/pipeline-coupling.d.ts +0 -27
- package/dist/resources/platform/pipeline-coupling.js +0 -55
- package/dist/resources/platform/pipeline-promotion.d.ts +0 -21
- package/dist/resources/platform/pipeline-promotion.js +0 -128
- package/dist/resources/platform/pipeline.d.ts +0 -53
- package/dist/resources/platform/pipeline.js +0 -75
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { HerokuApiClient } from '@heroku/heroku-fetch';
|
|
2
|
-
import { extendResource } from '../../core/extend-resource.js';
|
|
3
|
-
export class PipelineNotFoundError extends Error {
|
|
4
|
-
identity;
|
|
5
|
-
id = 'not_found';
|
|
6
|
-
statusCode = 404;
|
|
7
|
-
constructor(identity) {
|
|
8
|
-
super(`Couldn't find a pipeline matching '${identity}'.`);
|
|
9
|
-
this.identity = identity;
|
|
10
|
-
this.name = 'PipelineNotFoundError';
|
|
11
|
-
}
|
|
12
|
-
get body() {
|
|
13
|
-
return { id: this.id, message: this.message, resource: 'pipeline' };
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export class PipelineAmbiguousError extends Error {
|
|
17
|
-
identity;
|
|
18
|
-
matches;
|
|
19
|
-
id = 'multiple_matches';
|
|
20
|
-
statusCode = 422;
|
|
21
|
-
constructor(identity, matches) {
|
|
22
|
-
super(`Ambiguous identifier; multiple pipelines named '${identity}' found (${matches.length} matches).`);
|
|
23
|
-
this.identity = identity;
|
|
24
|
-
this.matches = matches;
|
|
25
|
-
this.name = 'PipelineAmbiguousError';
|
|
26
|
-
}
|
|
27
|
-
get body() {
|
|
28
|
-
return { id: this.id, message: this.message };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const UUID_RE = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i;
|
|
32
|
-
/**
|
|
33
|
-
* Resolve a Pipeline by identity.
|
|
34
|
-
*
|
|
35
|
-
* The identity may be:
|
|
36
|
-
* - a UUID — fetched directly via `pipeline.info`.
|
|
37
|
-
* - a name — looked up via `GET /pipelines?eq[name]=<name>`. Pipeline
|
|
38
|
-
* names are not unique platform-wide, so a name lookup may return
|
|
39
|
-
* zero, one, or many matches.
|
|
40
|
-
*
|
|
41
|
-
* The name path uses a raw `HerokuApiClient` because the route
|
|
42
|
-
* registry's `pipeline.list` doesn't accept query params, and we don't
|
|
43
|
-
* want to bake those params into the routes-generated client (where
|
|
44
|
-
* they would leak across unrelated calls).
|
|
45
|
-
*
|
|
46
|
-
* Errors:
|
|
47
|
-
* - throws `PipelineNotFoundError` when no pipeline matches the name.
|
|
48
|
-
* - throws `PipelineAmbiguousError` when more than one does. Callers
|
|
49
|
-
* that want to prompt the user should catch this and inspect
|
|
50
|
-
* `error.matches`.
|
|
51
|
-
*/
|
|
52
|
-
export async function resolvePipeline(ctx, identity, options = {}) {
|
|
53
|
-
options.signal?.throwIfAborted();
|
|
54
|
-
if (UUID_RE.test(identity)) {
|
|
55
|
-
return ctx.platform.pipeline.info(identity);
|
|
56
|
-
}
|
|
57
|
-
const apiClient = new HerokuApiClient({
|
|
58
|
-
...options.clientOptions,
|
|
59
|
-
service: 'platform',
|
|
60
|
-
});
|
|
61
|
-
const response = await apiClient.get('/pipelines', {
|
|
62
|
-
searchParams: { 'eq[name]': identity },
|
|
63
|
-
});
|
|
64
|
-
const matches = (await response.json());
|
|
65
|
-
if (matches.length === 0) {
|
|
66
|
-
throw new PipelineNotFoundError(identity);
|
|
67
|
-
}
|
|
68
|
-
if (matches.length > 1) {
|
|
69
|
-
throw new PipelineAmbiguousError(identity, matches);
|
|
70
|
-
}
|
|
71
|
-
return matches[0];
|
|
72
|
-
}
|
|
73
|
-
export const pipelineExtensions = extendResource('platform', 'pipeline', ctx => ({
|
|
74
|
-
resolve: (identity, options) => resolvePipeline(ctx, identity, options),
|
|
75
|
-
}));
|