@api-client/core 0.19.27 → 0.19.28

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@api-client/core",
3
3
  "description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
4
- "version": "0.19.27",
4
+ "version": "0.19.28",
5
5
  "license": "UNLICENSED",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -120,4 +120,37 @@ export class DeploymentsSdk extends SdkBase {
120
120
  throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)
121
121
  }
122
122
  }
123
+
124
+ apis = {
125
+ /**
126
+ * Lists deployments for a given API, with one entry per environment.
127
+ * This is used to display the list of environments for a given API.
128
+ *
129
+ * @param oid The organization ID
130
+ * @param apiId The API ID
131
+ * @param request Optional SDK options
132
+ */
133
+ listAllForApi: async (
134
+ oid: string,
135
+ apiId: string,
136
+ request: SdkOptions = {}
137
+ ): Promise<ContextListResult<DeploymentSchema>> => {
138
+ const url = this.sdk.getUrl(RouteBuilder.deploymentsApisByEnv(oid, apiId))
139
+ const { token = this.sdk.token } = request
140
+ const result = await this.sdk.http.get(url.toString(), { token })
141
+ return this.processListResponse<DeploymentSchema>(result, 'Unable to list environment deployments for an API. ')
142
+ },
143
+
144
+ listAllForEnvironment: async (
145
+ oid: string,
146
+ apiId: string,
147
+ env: DeploymentEnvironment,
148
+ request: SdkOptions = {}
149
+ ): Promise<ContextListResult<DeploymentSchema>> => {
150
+ const url = this.sdk.getUrl(RouteBuilder.deploymentsApisForEnv(oid, apiId, env))
151
+ const { token = this.sdk.token } = request
152
+ const result = await this.sdk.http.get(url.toString(), { token })
153
+ return this.processListResponse<DeploymentSchema>(result, 'Unable to list environment deployments for an API. ')
154
+ },
155
+ }
123
156
  }
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-extraneous-class */
2
2
 
3
3
  import type { AiSessionApp } from '../models/AiSession.js'
4
+ import type { DeploymentEnvironment } from '../models/store/Deployment.js'
4
5
 
5
6
  /**
6
7
  * A helper class to make sure routes user and reported by this service are consistent.
@@ -339,6 +340,18 @@ export class RouteBuilder {
339
340
  return `/v1/orgs/${oid}/deployments`
340
341
  }
341
342
 
343
+ static deploymentsApis(oid: string, apiId: string): string {
344
+ return `${RouteBuilder.deployments(oid)}/apis/${apiId}`
345
+ }
346
+
347
+ static deploymentsApisByEnv(oid: string, apiId: string): string {
348
+ return `${RouteBuilder.deploymentsApis(oid, apiId)}/envs`
349
+ }
350
+
351
+ static deploymentsApisForEnv(oid: string, apiId: string, env: DeploymentEnvironment): string {
352
+ return `${RouteBuilder.deploymentsApis(oid, apiId)}/envs/${env}`
353
+ }
354
+
342
355
  static deployment(oid: string, deploymentId: string): string {
343
356
  return `${RouteBuilder.deployments(oid)}/${deploymentId}`
344
357
  }
@@ -1715,6 +1715,58 @@ export class SdkMock {
1715
1715
  options
1716
1716
  )
1717
1717
  },
1718
+ apis: {
1719
+ listAllForApi: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
1720
+ const { mock } = this
1721
+ const respond = this.createDefaultResponse(
1722
+ 200,
1723
+ { 'content-type': 'application/json' },
1724
+ () => {
1725
+ const obj: ContextListResult<DeploymentSchema> = {
1726
+ items: this.gen.deployments.deployments(init?.size ?? 5),
1727
+ cursor: this.createCursorOption(init),
1728
+ }
1729
+ return JSON.stringify(obj)
1730
+ },
1731
+ init
1732
+ )
1733
+ await mock.add(
1734
+ {
1735
+ match: {
1736
+ uri: RouteBuilder.deploymentsApisByEnv(':oid', ':apiId'),
1737
+ methods: ['GET'],
1738
+ },
1739
+ respond,
1740
+ },
1741
+ options
1742
+ )
1743
+ },
1744
+ listAllForEnv: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
1745
+ const { mock } = this
1746
+ const respond = this.createDefaultResponse(
1747
+ 200,
1748
+ { 'content-type': 'application/json' },
1749
+ () => {
1750
+ const obj: ContextListResult<DeploymentSchema> = {
1751
+ items: this.gen.deployments.deployments(init?.size ?? 5),
1752
+ cursor: this.createCursorOption(init),
1753
+ }
1754
+ return JSON.stringify(obj)
1755
+ },
1756
+ init
1757
+ )
1758
+ await mock.add(
1759
+ {
1760
+ match: {
1761
+ uri: RouteBuilder.deploymentsApisForEnv(':oid', ':apiId', ':env' as unknown as DeploymentEnvironment),
1762
+ methods: ['GET'],
1763
+ },
1764
+ respond,
1765
+ },
1766
+ options
1767
+ )
1768
+ },
1769
+ },
1718
1770
  }
1719
1771
 
1720
1772
  /**