Skip to content

Commit

Permalink
Create schema
Browse files Browse the repository at this point in the history
  • Loading branch information
chekrd authored and matus12 committed Nov 29, 2024
1 parent 7b9435c commit ad44f43
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/customAppSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { ErrorMessage } from './iframeSchema';
import { matchesSchema } from './matchesSchema';

export enum ErrorCode {
Nnn = 'Nnn',
UnknownMessage = 'unknown-message',
}

export type InitReturn =
export type InitResponse =
| {
readonly isError: false;
readonly context: {
Expand All @@ -26,7 +26,7 @@ export type InitReturn =
readonly description: string;
};

export const initCustomApp = (): Promise<InitReturn> => {
export const initCustomApp = (): Promise<InitResponse> => {
const stopListening = startListening();

return new Promise((resolve, reject) => {
Expand All @@ -38,6 +38,7 @@ export const initCustomApp = (): Promise<InitReturn> => {
payload: null,
},
(response) => {

if (matchesSchema(ErrorMessage, response)) {
resolve({ isError: true, code: response.code, description: response.description });
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/iframeSchema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from 'zod';

enum ErrorCode {
Nnn = 'Nnn',
UnknownMessage = 'unknown-message',
}

export const ErrorMessage = z
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { initCustomApp } from './customAppSdk';
export { InitReturn } from './customAppSdk';
export { InitResponse } from './customAppSdk';

0 comments on commit ad44f43

Please sign in to comment.