Skip to content

Commit

Permalink
[lib] Make Blob service facts types more strict
Browse files Browse the repository at this point in the history
Summary:
Part of [[ https://linear.app/comm/issue/ENG-9422/clean-up-blob-service-client-code | ENG-9422 ]] about making types more strict.
Helps to avoid issues like [[ https://linear.app/comm/issue/ENG-9584/removeblobholders-errors-out-when-called-from-delete-accountjs-script#comment-9d0d5abc | ENG-9584 ]].

Test Plan: Flow

Reviewers: ashoat, kamil

Reviewed By: ashoat

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D13696
  • Loading branch information
barthap committed Oct 14, 2024
1 parent 113e6ed commit de679c3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/facts/blob-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@

import { isDev } from '../utils/dev-utils.js';

type BlobServicePath = '/blob/:blobHash' | '/blob' | '/holders';

export type BlobServiceHTTPEndpoint = {
+path: BlobServicePath,
+method: 'GET' | 'POST' | 'PUT' | 'DELETE',
type BlobHTTPEndpoints = {
+GET_BLOB: { +path: '/blob/:blobHash', +method: 'GET' },
+ASSIGN_HOLDER: { +path: '/blob', +method: 'POST' },
+ASSIGN_MULTIPLE_HOLDERS: { +path: '/holders', +method: 'POST' },
+UPLOAD_BLOB: { +path: '/blob', +method: 'PUT' },
+DELETE_BLOB: { +path: '/blob', +method: 'DELETE' },
+REMOVE_MULTIPLE_HOLDERS: { +path: '/holders', +method: 'DELETE' },
};

export type BlobServiceHTTPEndpoint =
BlobHTTPEndpoints[$Keys<BlobHTTPEndpoints>];

type BlobServiceConfig = {
+url: string,
+httpEndpoints: { +[endpoint: string]: BlobServiceHTTPEndpoint },
+httpEndpoints: BlobHTTPEndpoints,
};

const httpEndpoints = Object.freeze({
Expand Down

0 comments on commit de679c3

Please sign in to comment.