Skip to content

Commit

Permalink
add ws for ws between kernel <> cli
Browse files Browse the repository at this point in the history
  • Loading branch information
gonpombo8 committed Nov 23, 2021
1 parent 6479aa8 commit ff14b04
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as sdk from './sdk'

// export the utils
export * from './validation'

Expand Down Expand Up @@ -34,3 +36,4 @@ export {

export * from './platform'
export * from './misc'
export { sdk }
1 change: 1 addition & 0 deletions src/sdk/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ws'
12 changes: 12 additions & 0 deletions src/sdk/ws/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { SCENE_UPDATE, SceneUpdate } from "./scene-update";
import { UPDATE, Update } from "./update";

export * from './scene-update'
export * from './update'

/** @public */
export type Actions = typeof SCENE_UPDATE
| typeof UPDATE

/** @public */
export type WsMessages = SceneUpdate | Update
42 changes: 42 additions & 0 deletions src/sdk/ws/scene-update.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { generateValidator, JSONSchema, ValidateFunction } from "../../validation";

/** @public */
export const SCENE_UPDATE = 'SCENE_UPDATE'

/** @public */
export type SceneUpdate = {
type: typeof SCENE_UPDATE;
payload: {
sceneId: string;
sceneType: string;
}
};

/** @public */
export namespace SceneUpdate {
export const schema: JSONSchema<SceneUpdate> = {
type: "object",
properties: {
type: {
type: "string",
enum: [SCENE_UPDATE]
},
payload: {
type: "object",
properties: {
sceneId: {
type: "string"
},
sceneType: {
type: "string"
},
},
additionalProperties: false,
required: ["sceneId", "sceneType"],
},
},
required: ['payload', 'type']
};

export const validate: ValidateFunction<SceneUpdate> = generateValidator(schema);
}
25 changes: 25 additions & 0 deletions src/sdk/ws/update.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { generateValidator, JSONSchema, ValidateFunction } from "../../validation";

/** @public @deprecated */
export const UPDATE = 'update'

/** @public @deprecated */
export type Update = {
type: typeof UPDATE;
};

/** @public @deprecated */
export namespace Update {
export const schema: JSONSchema<Update> = {
type: "object",
properties: {
type: {
type: "string",
enum: [UPDATE]
},
},
required: ['type']
};

export const validate: ValidateFunction<Update> = generateValidator(schema);
}

0 comments on commit ff14b04

Please sign in to comment.