Skip to content

Commit

Permalink
Merge pull request #58 from hopinc/feat/domain-routes
Browse files Browse the repository at this point in the history
  • Loading branch information
alii authored Nov 14, 2022
2 parents ea27c3f + 72816cf commit 6eeaee1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-garlics-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@onehop/js': patch
---

Added missing domain routes
4 changes: 3 additions & 1 deletion src/rest/types/ignite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -823,4 +823,6 @@ export type IgniteEndpoints =
'/v1/ignite/deployments/:deployment_id/health-check',
{health_check: HealthCheck},
Partial<Omit<HealthCheck, 'id'>>
>;
>
| Endpoint<'DELETE', '/v1/ignite/domains/:domain_id', Empty>
| Endpoint<'GET', '/v1/ignite/domains/:domain_id', {domain: Domain}>;
10 changes: 4 additions & 6 deletions src/sdks/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import {create} from '@onehop/json-methods';
import {API, Id} from '../rest/index.js';
import {sdk} from './create.js';

type Token = Id<'leap_token'>;

/**
* New state to set to a channel, or a callback function that will produce the new state
*/
Expand All @@ -21,11 +19,11 @@ export const channels = sdk(client => {
await updateState(this.id, state, 'patch');
},

async subscribeToken(token: Token) {
async subscribeToken(token: Id<'leap_token'>) {
await channelsSDK.subscribeToken(this.id, token);
},

async subscribeTokens(tokens: Token[] | Set<Token>) {
async subscribeTokens(tokens: Id<'leap_token'>[] | Set<Id<'leap_token'>>) {
await channelsSDK.subscribeTokens(this.id, tokens);
},

Expand Down Expand Up @@ -118,7 +116,7 @@ export const channels = sdk(client => {

async subscribeToken(
channel: API.Channels.Channel | API.Channels.Channel['id'],
token: Token,
token: Id<'leap_token'>,
) {
const id = typeof channel === 'object' ? channel.id : channel;

Expand All @@ -131,7 +129,7 @@ export const channels = sdk(client => {

async subscribeTokens(
channel: API.Channels.Channel | API.Channels.Channel['id'],
tokens: Token[] | Set<Token>,
tokens: Id<'leap_token'>[] | Set<Id<'leap_token'>>,
) {
const promises: Array<Promise<void>> = [];

Expand Down
26 changes: 23 additions & 3 deletions src/sdks/ignite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export const ignite = sdk(client => {
{gateway_id: this.id},
);
},

async deleteDomain(domainId: Id<'domain'>) {
await client.delete('/v1/ignite/domains/:domain_id', undefined, {
domain_id: domainId,
});
},
});

const Deployments = create<API.Ignite.Deployment>().methods({
Expand Down Expand Up @@ -234,6 +240,22 @@ export const ignite = sdk(client => {
};

const igniteSDK = {
domains: {
delete: async (id: Id<'domain'>) => {
await client.delete('/v1/ignite/domains/:domain_id', undefined, {
domain_id: id,
});
},

get: async (id: Id<'domain'>) => {
const {domain} = await client.get('/v1/ignite/domains/:domain_id', {
domain_id: id,
});

return domain;
},
},

gateways: {
...deploymentGateways,

Expand Down Expand Up @@ -315,9 +337,7 @@ export const ignite = sdk(client => {
const {deployment} = await client.patch(
'/v1/ignite/deployments/:deployment_id',
config,
{
deployment_id: deploymentId,
},
{deployment_id: deploymentId},
);

return deployment;
Expand Down

1 comment on commit 6eeaee1

@vercel
Copy link

@vercel vercel bot commented on 6eeaee1 Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

hop-js – ./

hop-js-git-master-onehop.vercel.app
hop-js.vercel.app
hop-js-onehop.vercel.app
js.hop.io

Please sign in to comment.