@antelopejs/cloud-sdk 0.1.3 → 0.1.4

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/api.d.ts CHANGED
@@ -39,6 +39,13 @@ export interface CreateProjectOptions {
39
39
  */
40
40
  idempotencyKey?: string;
41
41
  }
42
+ /** A value a service publishes to the other services of its environment. */
43
+ export interface PublishedValue {
44
+ /** The service that publishes the value. */
45
+ serviceId: string;
46
+ /** The key it publishes the value under. */
47
+ publishedKey: string;
48
+ }
42
49
  /** How a log read is shaped: one bounded page, or a tail from a cursor. */
43
50
  export interface LogRequest {
44
51
  follow: boolean;
@@ -172,6 +179,30 @@ export declare class CloudApi {
172
179
  removedRetentionDays: number;
173
180
  };
174
181
  }>;
182
+ /**
183
+ * Sets the port the service's container listens on, from 1024 to 65535, or
184
+ * clears it with null. A service created from a repository has none, and is
185
+ * refused its deployments until it has one. The running revision keeps its
186
+ * port; the next deployment takes the new one.
187
+ */
188
+ setServicePort(serviceId: string, port: number | null): Promise<void>;
189
+ /**
190
+ * Opens the service to the internet on its own address, or closes it. A
191
+ * service without a port is refused with
192
+ * `cloud.errors.settings.public_needs_port`.
193
+ */
194
+ setServiceExposure(serviceId: string, isPublic: boolean): Promise<void>;
195
+ /**
196
+ * Adds a variable to the service that follows a value another service of
197
+ * its environment publishes, such as the `MONGO_URL` of a MongoDB resource.
198
+ * The value never reaches the client; the variable is then listed with a
199
+ * `resource` origin.
200
+ *
201
+ * @param serviceId The service that gets the variable
202
+ * @param key The variable's name on that service
203
+ * @param published The publishing service and the key it publishes
204
+ */
205
+ followPublishedValue(serviceId: string, key: string, published: PublishedValue): Promise<void>;
175
206
  deploymentHistory(serviceId: string): Promise<{
176
207
  activeBuilds?: components["schemas"]["ActiveBuild"][];
177
208
  desiredRevisionId: string | null;
package/dist/api.js CHANGED
@@ -143,6 +143,43 @@ export class CloudApi {
143
143
  const result = await this.client.GET("/api/cloud/services/{serviceId}/settings", { params: { path: { serviceId } } });
144
144
  return dataOf(result);
145
145
  }
146
+ /**
147
+ * Sets the port the service's container listens on, from 1024 to 65535, or
148
+ * clears it with null. A service created from a repository has none, and is
149
+ * refused its deployments until it has one. The running revision keeps its
150
+ * port; the next deployment takes the new one.
151
+ */
152
+ async setServicePort(serviceId, port) {
153
+ const result = await this.client.PUT("/api/cloud/services/{serviceId}/port", { params: { path: { serviceId } }, body: { port }, parseAs: "text" });
154
+ acceptedOf(result);
155
+ }
156
+ /**
157
+ * Opens the service to the internet on its own address, or closes it. A
158
+ * service without a port is refused with
159
+ * `cloud.errors.settings.public_needs_port`.
160
+ */
161
+ async setServiceExposure(serviceId, isPublic) {
162
+ const result = await this.client.PUT("/api/cloud/services/{serviceId}/network", { params: { path: { serviceId } }, body: { isPublic }, parseAs: "text" });
163
+ acceptedOf(result);
164
+ }
165
+ /**
166
+ * Adds a variable to the service that follows a value another service of
167
+ * its environment publishes, such as the `MONGO_URL` of a MongoDB resource.
168
+ * The value never reaches the client; the variable is then listed with a
169
+ * `resource` origin.
170
+ *
171
+ * @param serviceId The service that gets the variable
172
+ * @param key The variable's name on that service
173
+ * @param published The publishing service and the key it publishes
174
+ */
175
+ async followPublishedValue(serviceId, key, published) {
176
+ const result = await this.client.POST("/api/cloud/services/{serviceId}/variables/references", {
177
+ params: { path: { serviceId } },
178
+ body: { key, ...published },
179
+ parseAs: "text",
180
+ });
181
+ acceptedOf(result);
182
+ }
146
183
  async deploymentHistory(serviceId) {
147
184
  const result = await this.client.GET("/api/cloud/services/{serviceId}/deployments", {
148
185
  params: { path: { serviceId } },
@@ -355,6 +355,72 @@ export interface paths {
355
355
  patch?: never;
356
356
  trace?: never;
357
357
  };
358
+ "/api/cloud/services/{serviceId}/port": {
359
+ parameters: {
360
+ query?: never;
361
+ header?: never;
362
+ path?: never;
363
+ cookie?: never;
364
+ };
365
+ get?: never;
366
+ /**
367
+ * @description Sets the port the service's container listens on, or clears it with null. A service a
368
+ * project creation builds from a repository starts without one, and cannot be deployed
369
+ * until it has one: a deployment asked before fails with `cloud.errors.builds.missing_port`.
370
+ *
371
+ * The running revision keeps the port it was deployed with; the next deployment takes the
372
+ * new one.
373
+ */
374
+ put: operations["setServicePort"];
375
+ post?: never;
376
+ delete?: never;
377
+ options?: never;
378
+ head?: never;
379
+ patch?: never;
380
+ trace?: never;
381
+ };
382
+ "/api/cloud/services/{serviceId}/network": {
383
+ parameters: {
384
+ query?: never;
385
+ header?: never;
386
+ path?: never;
387
+ cookie?: never;
388
+ };
389
+ get?: never;
390
+ /**
391
+ * @description Opens the service to the internet on its own address, or closes it. A service is created
392
+ * closed. Sending the exposure it already has changes nothing.
393
+ */
394
+ put: operations["setServiceExposure"];
395
+ post?: never;
396
+ delete?: never;
397
+ options?: never;
398
+ head?: never;
399
+ patch?: never;
400
+ trace?: never;
401
+ };
402
+ "/api/cloud/services/{serviceId}/variables/references": {
403
+ parameters: {
404
+ query?: never;
405
+ header?: never;
406
+ path?: never;
407
+ cookie?: never;
408
+ };
409
+ get?: never;
410
+ put?: never;
411
+ /**
412
+ * @description Adds a variable to the service that follows a value another service of the same
413
+ * environment publishes, such as the `MONGO_URL` of a MongoDB resource: the variable takes
414
+ * the published value, and takes the new one when it changes. Listed afterwards with a
415
+ * `resource` origin. The value itself is never sent to the client.
416
+ */
417
+ post: operations["followPublishedValue"];
418
+ delete?: never;
419
+ options?: never;
420
+ head?: never;
421
+ patch?: never;
422
+ trace?: never;
423
+ };
358
424
  "/api/cloud/services/{serviceId}/source-deployments": {
359
425
  parameters: {
360
426
  query?: never;
@@ -1619,6 +1685,148 @@ export interface operations {
1619
1685
  default: components["responses"]["Error"];
1620
1686
  };
1621
1687
  };
1688
+ setServicePort: {
1689
+ parameters: {
1690
+ query?: never;
1691
+ header?: never;
1692
+ path: {
1693
+ serviceId: string;
1694
+ };
1695
+ cookie?: never;
1696
+ };
1697
+ requestBody: {
1698
+ content: {
1699
+ "application/json": {
1700
+ /** @description The port the container listens on; null for a service that listens on none. */
1701
+ port: number | null;
1702
+ };
1703
+ };
1704
+ };
1705
+ responses: {
1706
+ /** @description Done */
1707
+ 200: {
1708
+ headers: {
1709
+ [name: string]: unknown;
1710
+ };
1711
+ content?: never;
1712
+ };
1713
+ /** @description `cloud.errors.settings.invalid_port`: the port is not an integer from 1024 to 65535. */
1714
+ 400: {
1715
+ headers: {
1716
+ [name: string]: unknown;
1717
+ };
1718
+ content: {
1719
+ "application/json": components["schemas"]["Error"];
1720
+ };
1721
+ };
1722
+ /** @description `cloud.errors.settings.public_needs_port`: a public service cannot lose its port. `cloud.errors.settings.preview_read_only`: a preview mirrors its environment and is not edited. */
1723
+ 409: {
1724
+ headers: {
1725
+ [name: string]: unknown;
1726
+ };
1727
+ content: {
1728
+ "application/json": components["schemas"]["Error"];
1729
+ };
1730
+ };
1731
+ default: components["responses"]["Error"];
1732
+ };
1733
+ };
1734
+ setServiceExposure: {
1735
+ parameters: {
1736
+ query?: never;
1737
+ header?: never;
1738
+ path: {
1739
+ serviceId: string;
1740
+ };
1741
+ cookie?: never;
1742
+ };
1743
+ requestBody: {
1744
+ content: {
1745
+ "application/json": {
1746
+ /** @description Whether the internet reaches the service on its own address. */
1747
+ isPublic: boolean;
1748
+ };
1749
+ };
1750
+ };
1751
+ responses: {
1752
+ /** @description Done */
1753
+ 200: {
1754
+ headers: {
1755
+ [name: string]: unknown;
1756
+ };
1757
+ content?: never;
1758
+ };
1759
+ /** @description `cloud.errors.settings.public_needs_port`: a service without a port cannot be opened. `cloud.errors.settings.subdomain_taken`: another service holds its address. `cloud.errors.settings.preview_read_only`: a preview mirrors its environment and is not edited. */
1760
+ 409: {
1761
+ headers: {
1762
+ [name: string]: unknown;
1763
+ };
1764
+ content: {
1765
+ "application/json": components["schemas"]["Error"];
1766
+ };
1767
+ };
1768
+ default: components["responses"]["Error"];
1769
+ };
1770
+ };
1771
+ followPublishedValue: {
1772
+ parameters: {
1773
+ query?: never;
1774
+ header?: never;
1775
+ path: {
1776
+ serviceId: string;
1777
+ };
1778
+ cookie?: never;
1779
+ };
1780
+ requestBody: {
1781
+ content: {
1782
+ "application/json": {
1783
+ /** @description The name of the variable on the service. */
1784
+ key: string;
1785
+ /** @description The service that publishes the value. */
1786
+ serviceId: string;
1787
+ /** @description The key the publisher publishes the value under. */
1788
+ publishedKey: string;
1789
+ };
1790
+ };
1791
+ };
1792
+ responses: {
1793
+ /** @description Done */
1794
+ 200: {
1795
+ headers: {
1796
+ [name: string]: unknown;
1797
+ };
1798
+ content?: never;
1799
+ };
1800
+ /** @description `cloud.errors.settings.invalid_key`: the name is not a valid variable name. `cloud.errors.settings.self_reference`: a service cannot follow its own value. */
1801
+ 400: {
1802
+ headers: {
1803
+ [name: string]: unknown;
1804
+ };
1805
+ content: {
1806
+ "application/json": components["schemas"]["Error"];
1807
+ };
1808
+ };
1809
+ /** @description `cloud.errors.settings.unknown_publisher`: the environment has no such service. `cloud.errors.settings.key_not_published`: the publisher publishes no such key. */
1810
+ 404: {
1811
+ headers: {
1812
+ [name: string]: unknown;
1813
+ };
1814
+ content: {
1815
+ "application/json": components["schemas"]["Error"];
1816
+ };
1817
+ };
1818
+ /** @description `cloud.errors.settings.duplicate_key`: the service already holds a variable of that name. `cloud.errors.settings.preview_read_only`: a preview mirrors its environment and is not edited. */
1819
+ 409: {
1820
+ headers: {
1821
+ [name: string]: unknown;
1822
+ };
1823
+ content: {
1824
+ "application/json": components["schemas"]["Error"];
1825
+ };
1826
+ };
1827
+ default: components["responses"]["Error"];
1828
+ };
1829
+ };
1622
1830
  deploySource: {
1623
1831
  parameters: {
1624
1832
  query?: never;
@@ -385,6 +385,9 @@ paths:
385
385
  application/json:
386
386
  schema: { $ref: '#/components/schemas/ServiceSettings' }
387
387
  default: { $ref: '#/components/responses/Error' }
388
+ /api/cloud/services/{serviceId}/port: { $ref: 'services.yaml#/paths/port' }
389
+ /api/cloud/services/{serviceId}/network: { $ref: 'services.yaml#/paths/network' }
390
+ /api/cloud/services/{serviceId}/variables/references: { $ref: 'services.yaml#/paths/variableReferences' }
388
391
  /api/cloud/services/{serviceId}/source-deployments:
389
392
  post:
390
393
  operationId: deploySource
@@ -0,0 +1,126 @@
1
+ paths:
2
+ port:
3
+ put:
4
+ operationId: setServicePort
5
+ description: |
6
+ Sets the port the service's container listens on, or clears it with null. A service a
7
+ project creation builds from a repository starts without one, and cannot be deployed
8
+ until it has one: a deployment asked before fails with `cloud.errors.builds.missing_port`.
9
+
10
+ The running revision keeps the port it was deployed with; the next deployment takes the
11
+ new one.
12
+ security: [{ bearerAuth: [] }]
13
+ parameters:
14
+ - in: path
15
+ name: serviceId
16
+ required: true
17
+ schema: { type: string }
18
+ requestBody:
19
+ required: true
20
+ content:
21
+ application/json:
22
+ schema:
23
+ type: object
24
+ required: [port]
25
+ properties:
26
+ port:
27
+ description: The port the container listens on; null for a service that listens on none.
28
+ type: [integer, "null"]
29
+ minimum: 1024
30
+ maximum: 65535
31
+ responses:
32
+ '200':
33
+ description: Done
34
+ '400':
35
+ description: '`cloud.errors.settings.invalid_port`: the port is not an integer from 1024 to 65535.'
36
+ content:
37
+ application/json:
38
+ schema: { $ref: './cloud.openapi.yaml#/components/schemas/Error' }
39
+ '409':
40
+ description: '`cloud.errors.settings.public_needs_port`: a public service cannot lose its port. `cloud.errors.settings.preview_read_only`: a preview mirrors its environment and is not edited.'
41
+ content:
42
+ application/json:
43
+ schema: { $ref: './cloud.openapi.yaml#/components/schemas/Error' }
44
+ default: { $ref: './cloud.openapi.yaml#/components/responses/Error' }
45
+ variableReferences:
46
+ post:
47
+ operationId: followPublishedValue
48
+ description: |
49
+ Adds a variable to the service that follows a value another service of the same
50
+ environment publishes, such as the `MONGO_URL` of a MongoDB resource: the variable takes
51
+ the published value, and takes the new one when it changes. Listed afterwards with a
52
+ `resource` origin. The value itself is never sent to the client.
53
+ security: [{ bearerAuth: [] }]
54
+ parameters:
55
+ - in: path
56
+ name: serviceId
57
+ required: true
58
+ schema: { type: string }
59
+ requestBody:
60
+ required: true
61
+ content:
62
+ application/json:
63
+ schema:
64
+ type: object
65
+ required: [key, serviceId, publishedKey]
66
+ properties:
67
+ key:
68
+ description: The name of the variable on the service.
69
+ type: string
70
+ serviceId:
71
+ description: The service that publishes the value.
72
+ type: string
73
+ publishedKey:
74
+ description: The key the publisher publishes the value under.
75
+ type: string
76
+ responses:
77
+ '200':
78
+ description: Done
79
+ '400':
80
+ description: '`cloud.errors.settings.invalid_key`: the name is not a valid variable name. `cloud.errors.settings.self_reference`: a service cannot follow its own value.'
81
+ content:
82
+ application/json:
83
+ schema: { $ref: './cloud.openapi.yaml#/components/schemas/Error' }
84
+ '404':
85
+ description: '`cloud.errors.settings.unknown_publisher`: the environment has no such service. `cloud.errors.settings.key_not_published`: the publisher publishes no such key.'
86
+ content:
87
+ application/json:
88
+ schema: { $ref: './cloud.openapi.yaml#/components/schemas/Error' }
89
+ '409':
90
+ description: '`cloud.errors.settings.duplicate_key`: the service already holds a variable of that name. `cloud.errors.settings.preview_read_only`: a preview mirrors its environment and is not edited.'
91
+ content:
92
+ application/json:
93
+ schema: { $ref: './cloud.openapi.yaml#/components/schemas/Error' }
94
+ default: { $ref: './cloud.openapi.yaml#/components/responses/Error' }
95
+ network:
96
+ put:
97
+ operationId: setServiceExposure
98
+ description: |
99
+ Opens the service to the internet on its own address, or closes it. A service is created
100
+ closed. Sending the exposure it already has changes nothing.
101
+ security: [{ bearerAuth: [] }]
102
+ parameters:
103
+ - in: path
104
+ name: serviceId
105
+ required: true
106
+ schema: { type: string }
107
+ requestBody:
108
+ required: true
109
+ content:
110
+ application/json:
111
+ schema:
112
+ type: object
113
+ required: [isPublic]
114
+ properties:
115
+ isPublic:
116
+ description: Whether the internet reaches the service on its own address.
117
+ type: boolean
118
+ responses:
119
+ '200':
120
+ description: Done
121
+ '409':
122
+ description: '`cloud.errors.settings.public_needs_port`: a service without a port cannot be opened. `cloud.errors.settings.subdomain_taken`: another service holds its address. `cloud.errors.settings.preview_read_only`: a preview mirrors its environment and is not edited.'
123
+ content:
124
+ application/json:
125
+ schema: { $ref: './cloud.openapi.yaml#/components/schemas/Error' }
126
+ default: { $ref: './cloud.openapi.yaml#/components/responses/Error' }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/cloud-sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Typed client for the AntelopeJS Cloud API",
5
5
  "keywords": [
6
6
  "antelopejs",