@cosmoner/sdk 1.20.1 → 1.22.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/README.md CHANGED
@@ -256,6 +256,7 @@ A method taking an id rejects an empty one before sending anything.
256
256
  | `registries` | `list()`, `get(registryId)` | `delete(registryId)` |
257
257
  | `iam` | `list()`, `get(iamUserName)` — the list holds `credentials` plus partial-failure `errors` | `delete(iamUserName)` |
258
258
  | `members` | `list()` — members and pending invitations | |
259
+ | `invoices` | `list({ status, createdGte, createdLte, limit, startingAfter })` — one page, newest first; `export({ status, createdGte, createdLte })` — every match, up to 1,000; `get(invoiceId)` — each with `invoicePdfUrl`. Needs `billing:read` | |
259
260
  | `email` | `listDomains()`, `getDomain(emailDomainId)`, `limits()`, alongside `send()` | `createDomain({ domainId })`, `createExternalDomain({ domainName })`, `verifyDomain(emailDomainId)`, `deleteDomain(emailDomainId)` |
260
261
 
261
262
  Two of these return a credential, and each needs only the namespace's read
package/dist/client.d.ts CHANGED
@@ -8,6 +8,7 @@ import { DomainsService } from "./services/domains";
8
8
  import { EmailService } from "./services/email";
9
9
  import { HostingService } from "./services/hosting";
10
10
  import { IamService } from "./services/iam";
11
+ import { InvoicesService } from "./services/invoices";
11
12
  import { MembersService } from "./services/members";
12
13
  import { ProjectsService } from "./services/projects";
13
14
  import { RedisService } from "./services/redis";
@@ -44,6 +45,7 @@ export declare class Cosmoner {
44
45
  readonly email: EmailService;
45
46
  readonly hosting: HostingService;
46
47
  readonly iam: IamService;
48
+ readonly invoices: InvoicesService;
47
49
  readonly members: MembersService;
48
50
  /** Account-level: never uses the client's default project. */
49
51
  readonly projects: ProjectsService;
@@ -49,7 +49,7 @@ export interface DeploymentPreviews {
49
49
  export interface DeploymentService {
50
50
  name: string;
51
51
  /** Defaulted to `service` when the file does not say. */
52
- type: "service" | "static";
52
+ type: "service" | "static" | "worker";
53
53
  source_dir?: string;
54
54
  build?: DeploymentBuild;
55
55
  run_command?: string;
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export { DomainsService, type CreateDomainResponse, type DeleteDomainResponse, t
13
13
  export { EmailService, type CreateEmailDomainParams, type CreateEmailDomainResponse, type CreateExternalEmailDomainParams, type CreateSmtpCredentialParams, type CreateSmtpCredentialResponse, type EmailDomain, type EmailDomainDetail, type EmailDomainVerification, type EmailLimits, type EmailTemplateRef, type GetEmailDomainResponse, type GetEmailLimitsResponse, type ListEmailDomainsResponse, type NewSmtpCredential, type SendEmailParams, type SendEmailResponse, type SendRawEmailParams, type SendTemplateEmailParams, type SentEmailTemplate, type VerifyEmailDomainResponse, } from "./services/email";
14
14
  export { HostingService, type CreateHostingSiteParams, type CreateHostingSiteResponse, type DeleteHostingSiteResponse, type AttachHostingDomainParams, type AttachHostingDomainResponse, type DetachHostingDomainResponse, type EnableHostingMailParams, type GetHostingAccessResponse, type GetHostingSiteParams, type GetHostingSiteResponse, type GetHostingSiteWithCredentialsResponse, type HostingAccess, type HostingDomain, type HostingDomainAttached, type HostingDomainBehaviour, type HostingDomainDnsInstructions, type HostingDomainKind, type HostingImageBuild, type HostingImageStatus, type HostingImageStatusResponse, type HostingImageUpdate, type HostingMailStatus, type HostingMailStatusResponse, type HostingPrice, type HostingSite, type HostingSiteStatus, type HostingSiteWithCredentials, type HostingTier, type ListHostingDomainsResponse, type ListHostingPricesResponse, type ListHostingSitesResponse, type PreviewHostingSiteParams, type PreviewHostingSiteResponse, type SetHostingPhpVersionParams, type UpdateHostingDomainParams, type UpdateHostingDomainResponse, } from "./services/hosting";
15
15
  export { IamService, type CreateIamCredentialParams, type CreateIamCredentialResponse, type GetIamCredentialResponse, type IamCredential, type IamCredentialList, type IamRegistryGrant, type IamStorageGrant, type ListIamCredentialsResponse, type NewIamCredential, } from "./services/iam";
16
+ export { InvoicesService, type ExportInvoicesResponse, type GetInvoiceResponse, type Invoice, type InvoiceFilterParams, type InvoicePage, type InvoiceStatus, type ListInvoicesParams, type ListInvoicesResponse, } from "./services/invoices";
16
17
  export { MembersService, type ListMembersResponse, type ProjectMember, type ProjectMembers } from "./services/members";
17
18
  export type { CheckoutPreview, PlanChangePreview } from "./services/preview";
18
19
  export { ProjectsService, type DeleteProjectResponse, type GetProjectResponse, type ListProjectsResponse, type Project, type UpdateProjectParams, type UpdateProjectResponse, } from "./services/projects";
package/dist/index.js CHANGED
@@ -46,6 +46,7 @@ __export(index_exports, {
46
46
  HostingService: () => HostingService,
47
47
  IamService: () => IamService,
48
48
  InsufficientScopeError: () => InsufficientScopeError,
49
+ InvoicesService: () => InvoicesService,
49
50
  MAX_DEPLOYMENT_BYTES: () => MAX_DEPLOYMENT_BYTES,
50
51
  MembersService: () => MembersService,
51
52
  NotFoundError: () => NotFoundError,
@@ -950,6 +951,49 @@ var IamService = class {
950
951
  }
951
952
  };
952
953
 
954
+ // src/services/invoices.ts
955
+ var InvoicesService = class {
956
+ constructor(transport, config) {
957
+ this.transport = transport;
958
+ this.config = config;
959
+ }
960
+ /** Lists one page of the project's invoices, newest first, at every stage. */
961
+ async list(params = {}) {
962
+ return this.transport.request("GET", this.basePath(params.projectId), {
963
+ query: { ...filterQuery(params), limit: params.limit, starting_after: params.startingAfter || void 0 }
964
+ });
965
+ }
966
+ /**
967
+ * Every invoice matching the filters in one response, newest first, for
968
+ * bookkeeping. At most 1,000: narrow the date range to reach further back.
969
+ * Rate-limited, unlike `list()`.
970
+ */
971
+ async export(params = {}) {
972
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/export`, {
973
+ query: filterQuery(params)
974
+ });
975
+ }
976
+ /** Reads one invoice by the id `list()` returns. */
977
+ async get(invoiceId, params = {}) {
978
+ if (!invoiceId) throw new Error("invoiceId is required");
979
+ return this.transport.request(
980
+ "GET",
981
+ `${this.basePath(params.projectId)}/${encodeURIComponent(invoiceId)}`
982
+ );
983
+ }
984
+ /** Builds the collection route for the resolved project. */
985
+ basePath(projectId) {
986
+ return `/v1/projects/${resolveProjectId(this.config, projectId)}/billing/invoices`;
987
+ }
988
+ };
989
+ function filterQuery(params) {
990
+ return {
991
+ status: params.status,
992
+ created_gte: params.createdGte || void 0,
993
+ created_lte: params.createdLte || void 0
994
+ };
995
+ }
996
+
953
997
  // src/services/members.ts
954
998
  var MembersService = class {
955
999
  constructor(transport, config) {
@@ -1784,7 +1828,7 @@ function sleep(ms) {
1784
1828
  }
1785
1829
 
1786
1830
  // src/version.ts
1787
- var VERSION = "1.20.1";
1831
+ var VERSION = "1.22.0";
1788
1832
  var USER_AGENT = `cosmoner-node/${VERSION}`;
1789
1833
 
1790
1834
  // src/transport.ts
@@ -1914,6 +1958,7 @@ var Cosmoner = class {
1914
1958
  this.email = new EmailService(this.transport, this.config);
1915
1959
  this.hosting = new HostingService(this.transport, this.config);
1916
1960
  this.iam = new IamService(this.transport, this.config);
1961
+ this.invoices = new InvoicesService(this.transport, this.config);
1917
1962
  this.members = new MembersService(this.transport, this.config);
1918
1963
  this.projects = new ProjectsService(this.transport);
1919
1964
  this.catalog = new CatalogService(this.transport);
@@ -1984,7 +2029,7 @@ var SERVICE_FIELDS = {
1984
2029
  pattern: /^[a-z0-9][a-z0-9-]*$/,
1985
2030
  patternMessage: "Service names must be lowercase letters, numbers, or hyphens, and start with a letter or number"
1986
2031
  },
1987
- type: { kind: "string", enum: ["service", "static"], default: "service" },
2032
+ type: { kind: "string", enum: ["service", "static", "worker"], default: "service" },
1988
2033
  source_dir: { kind: "string", maxLength: 512 },
1989
2034
  build: { kind: "object", fields: BUILD_FIELDS },
1990
2035
  run_command: { kind: "string", maxLength: 1024 },
@@ -2183,6 +2228,17 @@ function checkService(service, _raw, path, issues) {
2183
2228
  "port does not apply to a static site \u2014 the platform serves it"
2184
2229
  );
2185
2230
  }
2231
+ if (service.type === "worker") {
2232
+ for (const key of ["port", "http_port", "internal_port"]) {
2233
+ if (service[key] !== void 0) {
2234
+ issues.error([...path, key], `${key} does not apply to a worker \u2014 nothing connects to it`);
2235
+ }
2236
+ }
2237
+ const previews = isMapping(service.previews) ? service.previews : void 0;
2238
+ if (previews?.enabled === true) {
2239
+ issues.error([...path, "previews"], "Workers have no previews \u2014 a preview is a URL to open");
2240
+ }
2241
+ }
2186
2242
  const legacyPorts = ["http_port", "internal_port"].filter(
2187
2243
  (key) => service[key] !== void 0
2188
2244
  );
@@ -2292,6 +2348,7 @@ var index_default = Cosmoner;
2292
2348
  HostingService,
2293
2349
  IamService,
2294
2350
  InsufficientScopeError,
2351
+ InvoicesService,
2295
2352
  MAX_DEPLOYMENT_BYTES,
2296
2353
  MembersService,
2297
2354
  NotFoundError,
package/dist/index.mjs CHANGED
@@ -875,6 +875,49 @@ var IamService = class {
875
875
  }
876
876
  };
877
877
 
878
+ // src/services/invoices.ts
879
+ var InvoicesService = class {
880
+ constructor(transport, config) {
881
+ this.transport = transport;
882
+ this.config = config;
883
+ }
884
+ /** Lists one page of the project's invoices, newest first, at every stage. */
885
+ async list(params = {}) {
886
+ return this.transport.request("GET", this.basePath(params.projectId), {
887
+ query: { ...filterQuery(params), limit: params.limit, starting_after: params.startingAfter || void 0 }
888
+ });
889
+ }
890
+ /**
891
+ * Every invoice matching the filters in one response, newest first, for
892
+ * bookkeeping. At most 1,000: narrow the date range to reach further back.
893
+ * Rate-limited, unlike `list()`.
894
+ */
895
+ async export(params = {}) {
896
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/export`, {
897
+ query: filterQuery(params)
898
+ });
899
+ }
900
+ /** Reads one invoice by the id `list()` returns. */
901
+ async get(invoiceId, params = {}) {
902
+ if (!invoiceId) throw new Error("invoiceId is required");
903
+ return this.transport.request(
904
+ "GET",
905
+ `${this.basePath(params.projectId)}/${encodeURIComponent(invoiceId)}`
906
+ );
907
+ }
908
+ /** Builds the collection route for the resolved project. */
909
+ basePath(projectId) {
910
+ return `/v1/projects/${resolveProjectId(this.config, projectId)}/billing/invoices`;
911
+ }
912
+ };
913
+ function filterQuery(params) {
914
+ return {
915
+ status: params.status,
916
+ created_gte: params.createdGte || void 0,
917
+ created_lte: params.createdLte || void 0
918
+ };
919
+ }
920
+
878
921
  // src/services/members.ts
879
922
  var MembersService = class {
880
923
  constructor(transport, config) {
@@ -1709,7 +1752,7 @@ function sleep(ms) {
1709
1752
  }
1710
1753
 
1711
1754
  // src/version.ts
1712
- var VERSION = "1.20.1";
1755
+ var VERSION = "1.22.0";
1713
1756
  var USER_AGENT = `cosmoner-node/${VERSION}`;
1714
1757
 
1715
1758
  // src/transport.ts
@@ -1839,6 +1882,7 @@ var Cosmoner = class {
1839
1882
  this.email = new EmailService(this.transport, this.config);
1840
1883
  this.hosting = new HostingService(this.transport, this.config);
1841
1884
  this.iam = new IamService(this.transport, this.config);
1885
+ this.invoices = new InvoicesService(this.transport, this.config);
1842
1886
  this.members = new MembersService(this.transport, this.config);
1843
1887
  this.projects = new ProjectsService(this.transport);
1844
1888
  this.catalog = new CatalogService(this.transport);
@@ -1909,7 +1953,7 @@ var SERVICE_FIELDS = {
1909
1953
  pattern: /^[a-z0-9][a-z0-9-]*$/,
1910
1954
  patternMessage: "Service names must be lowercase letters, numbers, or hyphens, and start with a letter or number"
1911
1955
  },
1912
- type: { kind: "string", enum: ["service", "static"], default: "service" },
1956
+ type: { kind: "string", enum: ["service", "static", "worker"], default: "service" },
1913
1957
  source_dir: { kind: "string", maxLength: 512 },
1914
1958
  build: { kind: "object", fields: BUILD_FIELDS },
1915
1959
  run_command: { kind: "string", maxLength: 1024 },
@@ -2108,6 +2152,17 @@ function checkService(service, _raw, path, issues) {
2108
2152
  "port does not apply to a static site \u2014 the platform serves it"
2109
2153
  );
2110
2154
  }
2155
+ if (service.type === "worker") {
2156
+ for (const key of ["port", "http_port", "internal_port"]) {
2157
+ if (service[key] !== void 0) {
2158
+ issues.error([...path, key], `${key} does not apply to a worker \u2014 nothing connects to it`);
2159
+ }
2160
+ }
2161
+ const previews = isMapping(service.previews) ? service.previews : void 0;
2162
+ if (previews?.enabled === true) {
2163
+ issues.error([...path, "previews"], "Workers have no previews \u2014 a preview is a URL to open");
2164
+ }
2165
+ }
2111
2166
  const legacyPorts = ["http_port", "internal_port"].filter(
2112
2167
  (key) => service[key] !== void 0
2113
2168
  );
@@ -2216,6 +2271,7 @@ export {
2216
2271
  HostingService,
2217
2272
  IamService,
2218
2273
  InsufficientScopeError,
2274
+ InvoicesService,
2219
2275
  MAX_DEPLOYMENT_BYTES,
2220
2276
  MembersService,
2221
2277
  NotFoundError,
@@ -126,7 +126,7 @@ export interface CreateAppDraftParams extends ProjectScopedParams {
126
126
  size: string;
127
127
  /** A region slug from `client.catalog.appRegions()`. */
128
128
  region: string;
129
- appType?: "service" | "static";
129
+ appType?: "service" | "static" | "worker";
130
130
  gitProvider?: "github" | "gitlab" | "bitbucket";
131
131
  /** `owner/repo`. */
132
132
  gitRepo?: string;
@@ -0,0 +1,78 @@
1
+ /** Invoices service namespace — the invoices issued to a project. Read-only. */
2
+ import { type ResolvedConfig } from "../config";
3
+ import type { Transport } from "../transport";
4
+ /** Where an invoice is in its lifecycle. */
5
+ export type InvoiceStatus = "draft" | "open" | "paid" | "uncollectible" | "void";
6
+ /** An invoice issued to the project. */
7
+ export interface Invoice {
8
+ /** Opaque id. Also the cursor for the next page of `list()`. */
9
+ id: string;
10
+ /** The number printed on the invoice. Null while it is a draft. */
11
+ number: string | null;
12
+ /** ISO 8601 date-time. */
13
+ created: string;
14
+ /** Amount due, in minor units of `currency`: `4900` is USD 49.00. */
15
+ amountDue: number;
16
+ /** Upper-case ISO 4217 code, e.g. `USD`. */
17
+ currency: string;
18
+ status: InvoiceStatus | null;
19
+ /** A page showing the invoice, where an open one can be paid. Null while it is a draft. */
20
+ hostedInvoiceUrl: string | null;
21
+ /** A direct download of the invoice as a PDF. Null while it is a draft. */
22
+ invoicePdfUrl: string | null;
23
+ /** Always null: the project is the one the request named. */
24
+ project: null;
25
+ }
26
+ /** One page of invoices, newest first. */
27
+ export interface InvoicePage {
28
+ data: Invoice[];
29
+ hasMore: boolean;
30
+ /** Pass as `startingAfter` for the next page. Null on the last page. */
31
+ nextCursor: string | null;
32
+ }
33
+ /** Options accepted by every method, for working across projects. */
34
+ export interface ProjectScopedParams {
35
+ /** Overrides the client-level default project for this call. */
36
+ projectId?: string;
37
+ }
38
+ interface Envelope<T> {
39
+ success: true;
40
+ data: T;
41
+ }
42
+ /** Filters shared by `list()` and `export()`. */
43
+ export interface InvoiceFilterParams extends ProjectScopedParams {
44
+ status?: InvoiceStatus;
45
+ /** Inclusive lower bound on the invoice date: an ISO date (`2026-01-01`) or date-time. */
46
+ createdGte?: string;
47
+ /** Inclusive upper bound on the invoice date: an ISO date or date-time. */
48
+ createdLte?: string;
49
+ }
50
+ /** Arguments accepted by `client.invoices.list()`. */
51
+ export interface ListInvoicesParams extends InvoiceFilterParams {
52
+ /** Page size, 1 to 100. The API defaults to 10. */
53
+ limit?: number;
54
+ /** The previous page's `nextCursor`. */
55
+ startingAfter?: string;
56
+ }
57
+ export type ListInvoicesResponse = Envelope<InvoicePage>;
58
+ export type ExportInvoicesResponse = Envelope<Invoice[]>;
59
+ export type GetInvoiceResponse = Envelope<Invoice>;
60
+ /** A project's invoices. Needs a key with `billing:read`. */
61
+ export declare class InvoicesService {
62
+ private readonly transport;
63
+ private readonly config;
64
+ constructor(transport: Transport, config: ResolvedConfig);
65
+ /** Lists one page of the project's invoices, newest first, at every stage. */
66
+ list(params?: ListInvoicesParams): Promise<ListInvoicesResponse>;
67
+ /**
68
+ * Every invoice matching the filters in one response, newest first, for
69
+ * bookkeeping. At most 1,000: narrow the date range to reach further back.
70
+ * Rate-limited, unlike `list()`.
71
+ */
72
+ export(params?: InvoiceFilterParams): Promise<ExportInvoicesResponse>;
73
+ /** Reads one invoice by the id `list()` returns. */
74
+ get(invoiceId: string, params?: ProjectScopedParams): Promise<GetInvoiceResponse>;
75
+ /** Builds the collection route for the resolved project. */
76
+ private basePath;
77
+ }
78
+ export {};
package/dist/version.d.ts CHANGED
@@ -8,5 +8,5 @@
8
8
  * the release workflow runs that straight after `npm version`, and
9
9
  * `version.test.ts` fails the build if the two ever disagree.
10
10
  */
11
- export declare const VERSION = "1.20.1";
12
- export declare const USER_AGENT = "cosmoner-node/1.20.1";
11
+ export declare const VERSION = "1.22.0";
12
+ export declare const USER_AGENT = "cosmoner-node/1.22.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmoner/sdk",
3
- "version": "1.20.1",
3
+ "version": "1.22.0",
4
4
  "description": "Cosmoner SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",