@openupstream/cli 0.3.0 → 0.5.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.
@@ -0,0 +1,39 @@
1
+ /**
2
+ * `oup domain` and `oup route`: which Route an address names, what a Route
3
+ * goes to, and how Domains and Routes are printed. Pure, so it is tested
4
+ * without an API.
5
+ */
6
+ import { type Bucket, type Domain, type Route, type RouteInput, type Service } from '@openupstream/sdk';
7
+ import { type Result } from './result.js';
8
+ /** A hostname as typed, the way the API keeps it: lowercase, without a scheme, a path or a final dot. */
9
+ export declare const hostnameOf: (typed: string) => string;
10
+ /** What is wrong with a custom domain's hostname; undefined when nothing is. */
11
+ export declare const hostnameProblem: (hostname: string) => string | undefined;
12
+ /** The Domain `hostname` of the Project. */
13
+ export declare const domainNamed: (domains: readonly Domain[], hostname: string, project: string) => Result<Domain, string>;
14
+ /**
15
+ * The Domain and the path prefix an address names: `www.example.com/docs`,
16
+ * `www.example.com` (its `/`), or `/docs` alone for the Project's default
17
+ * Domain. A scheme in front is ignored.
18
+ */
19
+ export declare const parseAddress: (address: string, domains: readonly Domain[], project: string) => Result<{
20
+ readonly domain: Domain;
21
+ readonly pathPrefix: string;
22
+ }, string>;
23
+ /** What `oup route add` was told the Route goes to. */
24
+ export interface TargetFlags {
25
+ readonly bucket?: string | undefined;
26
+ readonly service?: string | undefined;
27
+ readonly spa?: boolean | undefined;
28
+ }
29
+ /** The Route for the API: to the Bucket or the Service of that name, one of the two. */
30
+ export declare const routeInput: (pathPrefix: string, flags: TargetFlags, buckets: readonly Pick<Bucket, "id" | "name">[], services: readonly Pick<Service, "id" | "name" | "port">[], project: string) => Result<RouteInput, string>;
31
+ /** What the API refused, with the flag to change where the API names a field instead. */
32
+ export declare const routeRefusal: (message: string, flags: TargetFlags) => string;
33
+ /** Where a custom domain's CNAME points: `ingress.<customer domain>`, the customer domain being what follows the default Domain's first label. */
34
+ export declare const ingressOf: (domains: readonly Domain[]) => string | undefined;
35
+ export declare const formatDomains: (domains: readonly Domain[]) => string[];
36
+ /** The DNS records a custom domain needs, for one that is not verified yet; nothing for the others. */
37
+ export declare const dnsRecords: (domain: Domain, ingress: string | undefined) => string[];
38
+ /** Every Route as `hostname/path -> target`, Domain after Domain; a Domain that is not verified says so, since nothing is served at it. */
39
+ export declare const formatRoutes: (domains: readonly Domain[], routes: Readonly<Record<string, readonly Route[]>>, buckets: readonly Pick<Bucket, "id" | "name">[], services: readonly Pick<Service, "id" | "name">[]) => string[];
package/dist/routes.js ADDED
@@ -0,0 +1,91 @@
1
+ /**
2
+ * `oup domain` and `oup route`: which Route an address names, what a Route
3
+ * goes to, and how Domains and Routes are printed. Pure, so it is tested
4
+ * without an API.
5
+ */
6
+ import { HOSTNAME, PATH_PREFIX } from '@openupstream/sdk';
7
+ import { err, ok } from './result.js';
8
+ /** A hostname as typed, the way the API keeps it: lowercase, without a scheme, a path or a final dot. */
9
+ export const hostnameOf = (typed) => typed
10
+ .trim()
11
+ .toLowerCase()
12
+ .replace(/^https?:\/\//, '')
13
+ .replace(/\/.*$/, '')
14
+ .replace(/\.$/, '');
15
+ /** What is wrong with a custom domain's hostname; undefined when nothing is. */
16
+ export const hostnameProblem = (hostname) => HOSTNAME.test(hostname) ? undefined : `${hostname === '' ? 'that' : hostname} is not a hostname; give one like www.example.com`;
17
+ /** The Domain `hostname` of the Project. */
18
+ export const domainNamed = (domains, hostname, project) => {
19
+ const found = domains.find((domain) => domain.hostname === hostname);
20
+ return found === undefined ? err(`no Domain ${hostname} in ${project}; oup domain list shows them`) : ok(found);
21
+ };
22
+ /**
23
+ * The Domain and the path prefix an address names: `www.example.com/docs`,
24
+ * `www.example.com` (its `/`), or `/docs` alone for the Project's default
25
+ * Domain. A scheme in front is ignored.
26
+ */
27
+ export const parseAddress = (address, domains, project) => {
28
+ const typed = address.trim().replace(/^https?:\/\//, '');
29
+ const slash = typed.indexOf('/');
30
+ const hostname = (slash === -1 ? typed : typed.slice(0, slash)).toLowerCase().replace(/\.$/, '');
31
+ const pathPrefix = slash === -1 ? '/' : typed.slice(slash);
32
+ if (!PATH_PREFIX.test(pathPrefix)) {
33
+ return err(`${pathPrefix} is not a path of a Route: / or /segment[/segment…], without a slash at its end`);
34
+ }
35
+ // A word without a dot is no hostname: most likely a path that lacks its slash.
36
+ if (hostname !== '' && !hostname.includes('.')) {
37
+ return err(`${typed} is not an address: give <hostname>/<path>, or a path that starts with a slash, as in /${typed}`);
38
+ }
39
+ if (hostname !== '') {
40
+ const domain = domainNamed(domains, hostname, project);
41
+ return domain.ok ? ok({ domain: domain.value, pathPrefix }) : domain;
42
+ }
43
+ const byDefault = domains.find((domain) => domain.kind === 'default');
44
+ return byDefault === undefined ? err(`${project} has no default Domain; name the hostname, as in www.example.com${pathPrefix}`) : ok({ domain: byDefault, pathPrefix });
45
+ };
46
+ /** The Route for the API: to the Bucket or the Service of that name, one of the two. */
47
+ export const routeInput = (pathPrefix, flags, buckets, services, project) => {
48
+ if ((flags.bucket === undefined) === (flags.service === undefined)) {
49
+ return err('a Route goes to one thing: give --bucket <name> or --service <name>');
50
+ }
51
+ if (flags.bucket !== undefined) {
52
+ const bucket = buckets.find((candidate) => candidate.name === flags.bucket);
53
+ return bucket === undefined ? err(`no Bucket ${flags.bucket} in ${project}`) : ok({ pathPrefix, bucketId: bucket.id, spaFallback: flags.spa ?? false });
54
+ }
55
+ if (flags.spa === true) {
56
+ return err('--spa is for a Bucket: a Service answers every path itself');
57
+ }
58
+ const service = services.find((candidate) => candidate.name === flags.service);
59
+ return service === undefined
60
+ ? err(`no Service ${flags.service} in ${project}`)
61
+ : service.port === null
62
+ ? err(`the Service ${service.name} has no port, so it serves no HTTP; give it one with oup service deploy ${service.name} --port <port>`)
63
+ : ok({ pathPrefix, serviceId: service.id });
64
+ };
65
+ /** What the API refused, with the flag to change where the API names a field instead. */
66
+ export const routeRefusal = (message, flags) => /spaFallback/.test(message) ? `${message}: ${flags.spa === true ? 'leave --spa out' : 'add --spa'}, as on its other Routes` : message;
67
+ /** Where a custom domain's CNAME points: `ingress.<customer domain>`, the customer domain being what follows the default Domain's first label. */
68
+ export const ingressOf = (domains) => {
69
+ const hostname = domains.find((domain) => domain.kind === 'default')?.hostname;
70
+ return hostname === undefined ? undefined : `ingress.${hostname.slice(hostname.indexOf('.') + 1)}`;
71
+ };
72
+ /** Whether a Domain is served: the default one always, a custom one once verified. */
73
+ const state = (domain) => (domain.kind === 'default' ? 'default' : domain.verification.state === 'verified' ? 'verified' : 'not verified');
74
+ export const formatDomains = (domains) => domains.map((domain) => `${domain.hostname.padEnd(48)} ${state(domain)}`);
75
+ /** The DNS records a custom domain needs, for one that is not verified yet; nothing for the others. */
76
+ export const dnsRecords = (domain, ingress) => domain.kind === 'custom' && domain.verification.state === 'pending'
77
+ ? [
78
+ `TXT ${domain.verification.txtRecord.name} ${domain.verification.txtRecord.value}`,
79
+ ...(ingress === undefined ? [] : [`CNAME ${domain.hostname} ${ingress}`]),
80
+ ]
81
+ : [];
82
+ /** What a Route goes to, in words; a Resource that is gone by its kind alone. */
83
+ const target = (route, buckets, services) => {
84
+ const to = route.target;
85
+ return to.kind === 'bucket'
86
+ ? `Bucket ${buckets.find((bucket) => bucket.id === to.bucketId)?.name ?? '(gone)'}${to.spaFallback ? ' (single-page app)' : ''}`
87
+ : `Service ${services.find((service) => service.id === to.serviceId)?.name ?? '(gone)'}`;
88
+ };
89
+ /** Every Route as `hostname/path -> target`, Domain after Domain; a Domain that is not verified says so, since nothing is served at it. */
90
+ export const formatRoutes = (domains, routes, buckets, services) => domains.flatMap((domain) => (routes[domain.id] ?? []).map((route) => `${`${domain.hostname}${route.pathPrefix}`.padEnd(56)} ${target(route, buckets, services)}${state(domain) === 'not verified' ? ' (Domain not verified)' : ''}`));
91
+ //# sourceMappingURL=routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAA4B,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;AAEF,6IAA6I;AAC7I,MAAM,CAAC,MAAM,YAAY,GAAG,CACxB,OAA0B,EAC1B,MAAkD,EAClD,OAA+C,EAC/C,QAAiD,EACzC,EAAE,CACV,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CACvB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CACzB,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,cAAc,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,EAAE,EAAE,CAC9K,CACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ /** `oup sites`: the compute Sites, as the installation's nodes say (ADR-0007). */
2
+ import type { SiteInfo } from '@openupstream/sdk';
3
+ /** One line per Site: its id, `default` for the default Site, and where it is. */
4
+ export declare const formatSites: (sites: readonly SiteInfo[]) => string[];
package/dist/sites.js ADDED
@@ -0,0 +1,6 @@
1
+ /** One line per Site: its id, `default` for the default Site, and where it is. */
2
+ export const formatSites = (sites) => {
3
+ const width = Math.max(4, ...sites.map((site) => site.id.length));
4
+ return sites.map((site) => `${site.id.padEnd(width)} ${(site.default ? 'default' : '').padEnd(7)} ${site.description ?? ''}`.trimEnd());
5
+ };
6
+ //# sourceMappingURL=sites.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sites.js","sourceRoot":"","sources":["../src/sites.ts"],"names":[],"mappings":"AAGA,kFAAkF;AAClF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAA0B,EAAY,EAAE;IAChE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAClE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,WAAW,IAAI,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;AAC9I,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * `oup token`: an Account's tokens (ARCHITECTURE.md, decision 144). Pure, so
3
+ * it is tested without an API.
4
+ */
5
+ import { type AccountToken, type AccountTokenRole } from '@openupstream/sdk';
6
+ import { type Result } from './result.js';
7
+ /**
8
+ * One line per token: name, role, until when, last use, and its grants as
9
+ * `project/database:level`.
10
+ */
11
+ export declare const formatTokens: (tokens: readonly AccountToken[], now: Date) => string[];
12
+ /** The token with this name. */
13
+ export declare const tokenByName: (tokens: readonly AccountToken[], name: string) => Result<AccountToken, string>;
14
+ /** A role, or `none`: only what the token's grants give (null). Never owner. */
15
+ export declare const parseTokenRole: (value: string | undefined) => Result<AccountTokenRole | null, string>;
16
+ /**
17
+ * `--expires`: a number of days (`90d`), a date (`2027-03-01`, its start in
18
+ * UTC) or an RFC 3339 time; in the future and at most
19
+ * ACCOUNT_TOKEN_MAX_DAYS away. The API checks that too.
20
+ */
21
+ export declare const parseExpiry: (value: string | undefined, now: Date) => Result<Date, string>;
package/dist/tokens.js ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * `oup token`: an Account's tokens (ARCHITECTURE.md, decision 144). Pure, so
3
+ * it is tested without an API.
4
+ */
5
+ import { ACCOUNT_TOKEN_MAX_DAYS, ACCOUNT_TOKEN_ROLES } from '@openupstream/sdk';
6
+ import { err, ok } from './result.js';
7
+ const DAY_MS = 86_400_000;
8
+ /**
9
+ * One line per token: name, role, until when, last use, and its grants as
10
+ * `project/database:level`.
11
+ */
12
+ export const formatTokens = (tokens, now) => tokens.map((token) => {
13
+ const until = token.expiresAt.slice(0, 10);
14
+ const expiry = new Date(token.expiresAt).getTime() <= now.getTime() ? `expired ${until}` : `until ${until}`;
15
+ const used = token.lastUsedAt === null ? 'never used' : `used ${token.lastUsedAt.slice(0, 10)}`;
16
+ const line = `${token.name.padEnd(24)} ${(token.role ?? '-').padEnd(10)} ${expiry.padEnd(18)} ${used}`;
17
+ const grants = token.grants.map((grant) => `${grant.projectName}/${grant.databaseName}:${grant.access}`);
18
+ return grants.length === 0 ? line : `${line} ${grants.join(', ')}`;
19
+ });
20
+ /** The token with this name. */
21
+ export const tokenByName = (tokens, name) => {
22
+ const found = tokens.find((token) => token.name === name);
23
+ return found === undefined ? err(`no Account token ${name} in this Account`) : ok(found);
24
+ };
25
+ /** A role, or `none`: only what the token's grants give (null). Never owner. */
26
+ export const parseTokenRole = (value) => value === 'none'
27
+ ? ok(null)
28
+ : ACCOUNT_TOKEN_ROLES.includes(value ?? '')
29
+ ? ok(value)
30
+ : err(`an Account token's role is ${[...ACCOUNT_TOKEN_ROLES, 'none'].join(' or ')}; never owner`);
31
+ /**
32
+ * `--expires`: a number of days (`90d`), a date (`2027-03-01`, its start in
33
+ * UTC) or an RFC 3339 time; in the future and at most
34
+ * ACCOUNT_TOKEN_MAX_DAYS away. The API checks that too.
35
+ */
36
+ export const parseExpiry = (value, now) => {
37
+ if (value === undefined) {
38
+ return err(`--expires is required: a number of days (90d) or a date, at most ${ACCOUNT_TOKEN_MAX_DAYS} days away`);
39
+ }
40
+ const days = /^(\d{1,4})d$/.exec(value)?.[1];
41
+ const date = days !== undefined
42
+ ? new Date(now.getTime() + Number(days) * DAY_MS)
43
+ : /^\d{4}-\d{2}-\d{2}$/.test(value)
44
+ ? new Date(`${value}T00:00:00Z`)
45
+ : /^\d{4}-\d{2}-\d{2}T/.test(value)
46
+ ? new Date(value)
47
+ : undefined;
48
+ if (date === undefined || Number.isNaN(date.getTime())) {
49
+ return err(`--expires ${value}: a number of days (90d), a date (2027-03-01) or an RFC 3339 time`);
50
+ }
51
+ if (date.getTime() <= now.getTime()) {
52
+ return err(`--expires ${value} is not in the future`);
53
+ }
54
+ return date.getTime() > now.getTime() + ACCOUNT_TOKEN_MAX_DAYS * DAY_MS
55
+ ? err(`--expires ${value} is more than ${ACCOUNT_TOKEN_MAX_DAYS} days away; an Account token lasts a year at most`)
56
+ : ok(date);
57
+ };
58
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAA4C,MAAM,mBAAmB,CAAC;AAC1H,OAAO,EAAe,GAAG,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,MAAM,GAAG,UAAU,CAAC;AAE1B;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAA+B,EAAE,GAAS,EAAY,EAAE,CACjF,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;IACjB,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC;IAC5G,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC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nE,CAAC,CAAC,GAAG,CAAC,aAAa,KAAK,iBAAiB,sBAAsB,mDAAmD,CAAC;QACnH,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AACnB,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * `oup usage`: what a Project's Resources use now, as a table. Pure, so it
3
+ * is tested without an API. The number formats are the dashboard's
4
+ * (`dashboard/src/lib/usage.ts`), which cannot be imported from here.
5
+ */
6
+ import type { Measured, ProjectUsage } from '@openupstream/sdk';
7
+ /** Bytes in the largest unit that keeps the number at 1 or more; 1 GB is 2^30 bytes, as the sizes are. */
8
+ export declare const formatBytes: (bytes: number) => string;
9
+ /** Millicores as CPUs: `0.13 CPU`. */
10
+ export declare const formatCpu: (millicores: number) => string;
11
+ /** `used of allocated`, whichever of the two is known; `-` when neither is. */
12
+ export declare const formatMeasured: (measured: Measured, format: (value: number) => string) => string;
13
+ /**
14
+ * The Project's Resources with what each uses now of what it was given,
15
+ * and with `instances` every running copy below its Resource. Says when
16
+ * nothing is measured, and that this is not what is billed.
17
+ */
18
+ export declare const formatUsage: (usage: ProjectUsage, project: string, options: {
19
+ readonly instances: boolean;
20
+ }) => string[];
package/dist/usage.js ADDED
@@ -0,0 +1,68 @@
1
+ const UNITS = ['B', 'KB', 'MB', 'GB', 'TB'];
2
+ /** Bytes in the largest unit that keeps the number at 1 or more; 1 GB is 2^30 bytes, as the sizes are. */
3
+ export const formatBytes = (bytes) => {
4
+ const power = bytes < 1 ? 0 : Math.min(UNITS.length - 1, Math.floor(Math.log2(bytes) / 10));
5
+ const value = bytes / 2 ** (10 * power);
6
+ return `${power === 0 || value >= 100 ? Math.round(value) : value.toFixed(1)} ${UNITS[power]}`;
7
+ };
8
+ /** Millicores as CPUs: `0.13 CPU`. */
9
+ export const formatCpu = (millicores) => `${(millicores / 1000).toFixed(2)} CPU`;
10
+ /** `used of allocated`, whichever of the two is known; `-` when neither is. */
11
+ export const formatMeasured = (measured, format) => measured.used !== null && measured.allocated !== null
12
+ ? `${format(measured.used)} of ${format(measured.allocated)}`
13
+ : measured.used !== null
14
+ ? format(measured.used)
15
+ : measured.allocated !== null
16
+ ? `${format(measured.allocated)} allocated`
17
+ : '-';
18
+ /** Rows as lines, every column as wide as its widest cell. */
19
+ const table = (rows, indent = '') => {
20
+ const widths = (rows[0] ?? []).map((_, column) => Math.max(...rows.map((row) => (row[column] ?? '').length)));
21
+ return rows.map((row) => `${indent}${row.map((cell, column) => cell.padEnd(widths[column] ?? 0)).join(' ')}`.trimEnd());
22
+ };
23
+ const KIND = { database: 'Database', service: 'Service', job: 'Job', bucket: 'Bucket' };
24
+ const resourceRow = (resource) => [
25
+ KIND[resource.kind],
26
+ resource.name,
27
+ formatMeasured(resource.cpuMillicores, formatCpu),
28
+ formatMeasured(resource.memoryBytes, formatBytes),
29
+ formatMeasured(resource.storageBytes, formatBytes),
30
+ ];
31
+ const orDash = (value, format) => (value === null ? '-' : format(value));
32
+ const instanceRow = (instance) => [
33
+ `${instance.role} ${instance.name}`,
34
+ instance.site ?? 'not placed',
35
+ `${instance.state}${instance.restarts === 0 ? '' : `, ${instance.restarts} ${instance.restarts === 1 ? 'restart' : 'restarts'}`}`,
36
+ orDash(instance.cpuMillicores, formatCpu),
37
+ orDash(instance.memoryBytes, formatBytes),
38
+ orDash(instance.storageBytes, formatBytes),
39
+ ];
40
+ /**
41
+ * The Project's Resources with what each uses now of what it was given,
42
+ * and with `instances` every running copy below its Resource. Says when
43
+ * nothing is measured, and that this is not what is billed.
44
+ */
45
+ export const formatUsage = (usage, project, options) => {
46
+ if (usage.resources.length === 0) {
47
+ return [`No Resources in ${project}.`];
48
+ }
49
+ const header = ['KIND', 'NAME', 'CPU', 'MEMORY', 'STORAGE'];
50
+ const rows = table([header, ...usage.resources.map(resourceRow)]);
51
+ // One table for the instances of all Resources, so their columns line up down the page.
52
+ const instanceLines = table(usage.resources.flatMap((resource) => resource.instances.map(instanceRow)), ' ');
53
+ const firstOf = usage.resources.map((_, index) => usage.resources.slice(0, index).reduce((sum, resource) => sum + resource.instances.length, 0));
54
+ const lines = options.instances
55
+ ? [
56
+ rows[0] ?? '',
57
+ ...usage.resources.flatMap((resource, index) => [rows[index + 1] ?? '', ...instanceLines.slice(firstOf[index] ?? 0, (firstOf[index] ?? 0) + resource.instances.length)]),
58
+ ]
59
+ : rows;
60
+ return [
61
+ ...lines,
62
+ '',
63
+ usage.measured
64
+ ? `Measured ${usage.measuredAt}: use now of what was given, not what is billed.`
65
+ : 'CPU, memory and disk are not measured right now: this installation has no Prometheus, or it did not answer.',
66
+ ];
67
+ };
68
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.js","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAOA,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAErD,0GAA0G;AAC1G,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAU,EAAE;IACjD,MAAM,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC5F,MAAM,KAAK,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC;IACxC,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;AACnG,CAAC,CAAC;AAEF,sCAAsC;AACtC,MAAM,CAA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AI,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;SAC3K;QACH,CAAC,CAAC,IAAI,CAAC;IACX,OAAO;QACH,GAAG,KAAK;QACR,EAAE;QACF,KAAK,CAAC,QAAQ;YACV,CAAC,CAAC,YAAY,KAAK,CAAC,UAAU,kDAAkD;YAChF,CAAC,CAAC,6GAA6G;KACtH,CAAC;AACN,CAAC,CAAC"}
package/dist/version.d.ts CHANGED
@@ -2,4 +2,4 @@
2
2
  * The CLI's own version, as in package.json; the release workflow checks
3
3
  * that the tag `cli-v<version>` names it (ARCHITECTURE.md, decision 80).
4
4
  */
5
- export declare const CLI_VERSION = "0.3.0";
5
+ export declare const CLI_VERSION = "0.5.0";
package/dist/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  * The CLI's own version, as in package.json; the release workflow checks
3
3
  * that the tag `cli-v<version>` names it (ARCHITECTURE.md, decision 80).
4
4
  */
5
- export const CLI_VERSION = '0.3.0';
5
+ export const CLI_VERSION = '0.5.0';
6
6
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openupstream/cli",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "oup, the openupstream command line tool",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -28,6 +28,8 @@
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "^24.0.0",
31
+ "@types/pg": "^8.23.1",
32
+ "@types/ws": "^8.18.2",
31
33
  "tsx": "^4.19.0",
32
34
  "typescript": "^5.7.0"
33
35
  },
@@ -36,6 +38,8 @@
36
38
  },
37
39
  "dependencies": {
38
40
  "@aws-sdk/client-s3": "^3.1161.0",
39
- "@openupstream/sdk": "^0.4.0"
41
+ "@openupstream/sdk": "^0.9.1",
42
+ "pg": "^8.23.1",
43
+ "ws": "^8.22.0"
40
44
  }
41
45
  }