Skip to content

Commit

Permalink
Adjust some types
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Jan 11, 2024
1 parent 6416ffb commit 344161c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
3 changes: 1 addition & 2 deletions apps/meteor/client/views/marketplace/hooks/useInstallApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ export const useInstallApp = (file: File, url: string): { install: () => void; i
/** @deprecated */
const getAppFile = async (): Promise<File | undefined> => {
try {
// @ts-ignore-next-line
const { buff } = await downloadPrivateAppFromUrl({ url, downloadOnly: true });
const { buff } = (await downloadPrivateAppFromUrl({ url, downloadOnly: true })) as { buff: { data: ArrayLike<number> } };

return new File([Uint8Array.from(buff.data)], 'app.zip', { type: 'application/zip' });
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/ee/client/apps/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ class AppClientOrchestrator {
}

public async installApp(appId: string, version: string, permissionsGranted?: IPermission[]): Promise<App> {
const { app } = await sdk.rest.post<'/apps'>('/apps', {
const { app } = (await sdk.rest.post<'/apps'>('/apps', {
appId,
marketplace: true,
version,
permissionsGranted,
});
})) as { app: App };
return app;
}

Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/ee/server/apps/communication/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class AppsRestApi {

// WE NEED TO MOVE EACH ENDPOINT HANDLER TO IT'S OWN FILE
this.api.addRoute(
'' as '/apps', // this is the default route, but an empty path was confusing the type
'',
{ authRequired: true, permissionsRequired: ['manage-apps'] },
{
async get() {
Expand Down Expand Up @@ -332,7 +332,7 @@ export class AppsRestApi {

return API.v1.success({ buff });
}
} else if (this.bodyParams.appId && this.bodyParams.marketplace && this.bodyParams.version) {
} else if ('appId' in this.bodyParams && this.bodyParams.appId && this.bodyParams.marketplace && this.bodyParams.version) {
const baseUrl = orchestrator.getMarketplaceUrl();

const headers = getDefaultHeaders();
Expand Down
30 changes: 21 additions & 9 deletions packages/rest-typings/src/apps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,27 @@ export type AppsEndpoints = {
}[])
| (() => { apps: App[] });

POST: (params: {
appId: string;
marketplace: boolean;
version: string;
permissionsGranted?: IPermission[];
url?: string;
downloadOnly?: boolean;
}) => {
app: App;
POST: {
(
params:
| {
appId: string;
marketplace: boolean;
version: string;
permissionsGranted?: IPermission[];
url?: string;
downloadOnly?: boolean;
}
| { url: string; downloadOnly?: boolean },
):
| {
app: App;
}
| {
buff: {
data: ArrayLike<number>;
};
};
};
};

Expand Down
2 changes: 1 addition & 1 deletion packages/rest-typings/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export type MatchPathPattern<TPath extends Path> = TPath extends any ? Extract<O

export type JoinPathPattern<TBasePath extends string, TSubPathPattern extends string> = Extract<
PathPattern,
`${TBasePath}/${TSubPathPattern}` | TSubPathPattern
`${TBasePath}${TSubPathPattern extends '' ? TSubPathPattern : `/${TSubPathPattern}`}` | TSubPathPattern
>;

type GetParams<TOperation> = TOperation extends (...args: any) => any ? Parameters<TOperation>[0] : never;
Expand Down

0 comments on commit 344161c

Please sign in to comment.