@heroku/sdk 0.1.0-beta.0 → 0.2.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.
Files changed (35) hide show
  1. package/package.json +1 -1
  2. package/dist/compositions/add-on.d.ts +0 -7
  3. package/dist/compositions/add-on.js +0 -6
  4. package/dist/compositions/app.d.ts +0 -8
  5. package/dist/compositions/app.js +0 -11
  6. package/dist/compositions/dyno.d.ts +0 -17
  7. package/dist/compositions/dyno.js +0 -23
  8. package/dist/compositions/pg.d.ts +0 -15
  9. package/dist/compositions/pg.js +0 -56
  10. package/dist/compositions/pipeline.d.ts +0 -33
  11. package/dist/compositions/pipeline.js +0 -146
  12. package/dist/resources/data/backup.d.ts +0 -9
  13. package/dist/resources/data/backup.js +0 -10
  14. package/dist/resources/data/internal/resolve-addon-id.d.ts +0 -2
  15. package/dist/resources/data/internal/resolve-addon-id.js +0 -13
  16. package/dist/resources/data/postgres-credential.d.ts +0 -11
  17. package/dist/resources/data/postgres-credential.js +0 -16
  18. package/dist/resources/data/postgres.d.ts +0 -9
  19. package/dist/resources/data/postgres.js +0 -10
  20. package/dist/resources/data/transfer-schedule.d.ts +0 -9
  21. package/dist/resources/data/transfer-schedule.js +0 -10
  22. package/dist/resources/platform/add-on.d.ts +0 -211
  23. package/dist/resources/platform/add-on.js +0 -354
  24. package/dist/resources/platform/app.d.ts +0 -56
  25. package/dist/resources/platform/app.js +0 -50
  26. package/dist/resources/platform/dyno.d.ts +0 -45
  27. package/dist/resources/platform/dyno.js +0 -26
  28. package/dist/resources/platform/log-session.d.ts +0 -81
  29. package/dist/resources/platform/log-session.js +0 -167
  30. package/dist/resources/platform/pipeline-coupling.d.ts +0 -27
  31. package/dist/resources/platform/pipeline-coupling.js +0 -55
  32. package/dist/resources/platform/pipeline-promotion.d.ts +0 -21
  33. package/dist/resources/platform/pipeline-promotion.js +0 -128
  34. package/dist/resources/platform/pipeline.d.ts +0 -53
  35. 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
- }));