@openpeepshq/client 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/endpoints/admin.d.ts +11 -1
- package/dist/endpoints/admin.js +6 -0
- package/dist/endpoints/conversations.d.ts +18 -39941
- package/dist/endpoints/conversations.js +1 -0
- package/dist/endpoints/helpers.d.ts +1 -1
- package/dist/endpoints/helpers.js +4 -4
- package/dist/endpoints/jams.d.ts +1124 -49
- package/dist/endpoints/posts.d.ts +4 -0
- package/dist/endpoints/posts.js +10 -0
- package/dist/endpoints/profiles.d.ts +3334 -108
- package/dist/endpoints/search.d.ts +3337 -112
- package/dist/endpoints/search.js +1 -1
- package/dist/endpoints/server.d.ts +1 -0
- package/dist/endpoints/streaming.js +1 -1
- package/dist/webhooks/index.d.ts +1 -1
- package/dist/webhooks/index.js +3 -3
- package/package.json +11 -9
- package/src/endpoints/admin.ts +29 -0
- package/src/endpoints/auth.ts +37 -37
- package/src/endpoints/conversations.ts +37 -5
- package/src/endpoints/groups.ts +60 -63
- package/src/endpoints/helpers.ts +78 -78
- package/src/endpoints/i18n.ts +6 -9
- package/src/endpoints/location.ts +6 -5
- package/src/endpoints/media.ts +42 -45
- package/src/endpoints/posts.ts +13 -0
- package/src/endpoints/previewLink.ts +4 -5
- package/src/endpoints/reports.ts +23 -26
- package/src/endpoints/search.ts +43 -30
- package/src/endpoints/server.ts +23 -30
- package/src/endpoints/sso.ts +18 -30
- package/src/endpoints/streaming.ts +19 -25
- package/src/webhooks/index.ts +4 -10
package/src/endpoints/media.ts
CHANGED
|
@@ -1,56 +1,53 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
FetchClient,
|
|
3
|
+
noPayloadEventSource,
|
|
4
4
|
} from '@openpeepshq/fetch-client';
|
|
5
5
|
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
MediaAttachment,
|
|
7
|
+
MediaProgressEvent,
|
|
8
|
+
MediaStorageRequestInput,
|
|
9
|
+
SuccessResponse,
|
|
10
10
|
} from '@openpeepshq/common';
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
allpeepNoPayloadEndpoint,
|
|
13
|
+
allpeepPayloadEndpoint,
|
|
14
|
+
allpeepPayloadProgressObserverEndpoint,
|
|
15
15
|
} from './helpers';
|
|
16
16
|
|
|
17
17
|
export const media = (
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
rawClient: FetchClient,
|
|
19
|
+
eventSource: ReturnType<typeof noPayloadEventSource>,
|
|
20
20
|
) => ({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
delete
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
21
|
+
list: allpeepNoPayloadEndpoint<MediaAttachment[]>(rawClient, '/media'),
|
|
22
|
+
findById: allpeepNoPayloadEndpoint<MediaAttachment, { id: string }>(
|
|
23
|
+
rawClient,
|
|
24
|
+
'/media/:id',
|
|
25
|
+
),
|
|
26
|
+
create: allpeepPayloadEndpoint<MediaAttachment, MediaStorageRequestInput>(
|
|
27
|
+
rawClient,
|
|
28
|
+
'/media',
|
|
29
|
+
'post',
|
|
30
|
+
true,
|
|
31
|
+
),
|
|
32
|
+
/**
|
|
33
|
+
* Same as `create` but routes through XHR so callers can pass
|
|
34
|
+
* `onUploadProgress` to receive byte-level upload events. Returns either a
|
|
35
|
+
* fully-processed `MediaAttachment` (small files, sync path) or a partial
|
|
36
|
+
* one with `status: 'processing'` (large files, async path) — pair with
|
|
37
|
+
* `progress.listen` to track the background processing phase.
|
|
38
|
+
*/
|
|
39
|
+
createWithProgress: allpeepPayloadProgressObserverEndpoint<
|
|
40
|
+
MediaAttachment,
|
|
41
|
+
MediaStorageRequestInput
|
|
42
|
+
>(rawClient, '/media', 'post', true),
|
|
43
|
+
delete: allpeepNoPayloadEndpoint<SuccessResponse, { id: string }>(
|
|
44
|
+
rawClient,
|
|
45
|
+
'/media/:id',
|
|
46
|
+
'delete',
|
|
47
|
+
),
|
|
48
|
+
progress: {
|
|
49
|
+
listen: eventSource<MediaProgressEvent, { id: string }>(
|
|
50
|
+
'/media/:id/progress',
|
|
50
51
|
),
|
|
51
|
-
|
|
52
|
-
listen: eventSource<MediaProgressEvent, { id: string }>(
|
|
53
|
-
'/media/:id/progress',
|
|
54
|
-
),
|
|
55
|
-
},
|
|
52
|
+
},
|
|
56
53
|
});
|
package/src/endpoints/posts.ts
CHANGED
|
@@ -77,6 +77,7 @@ type Finders = {
|
|
|
77
77
|
{ id: string; recordingId: string }
|
|
78
78
|
>;
|
|
79
79
|
unseenCounts: OpenpeepsNoPayloadEndpoint<UnseenPostCounts>;
|
|
80
|
+
exportRsvps: (args: { id: string; occurrence?: string }) => Promise<string>;
|
|
80
81
|
};
|
|
81
82
|
|
|
82
83
|
// Explicit return types keep `tsc` from serializing the expanded PublicPost
|
|
@@ -140,6 +141,18 @@ const finders = (rawClient: FetchClient): Finders => ({
|
|
|
140
141
|
rawClient,
|
|
141
142
|
'/posts/unseen/counts',
|
|
142
143
|
),
|
|
144
|
+
exportRsvps: async ({ id, occurrence }) => {
|
|
145
|
+
const query = occurrence
|
|
146
|
+
? `?occurrence=${encodeURIComponent(occurrence)}`
|
|
147
|
+
: '';
|
|
148
|
+
const response = await rawClient.get(`/posts/${id}/rsvp/export${query}`);
|
|
149
|
+
|
|
150
|
+
if (!response.ok) {
|
|
151
|
+
throw { ...(await response.json()), status: response.status };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return response.text();
|
|
155
|
+
},
|
|
143
156
|
});
|
|
144
157
|
|
|
145
158
|
const eventFeeds = (rawClient: FetchClient): EventFeeds => ({
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { FetchClient } from '@openpeepshq/fetch-client';
|
|
2
|
-
import type {
|
|
3
|
-
FetchUrlResponse,
|
|
4
|
-
} from '@openpeepshq/common';
|
|
2
|
+
import type { FetchUrlResponse } from '@openpeepshq/common';
|
|
5
3
|
import { allpeepNoPayloadEndpoint } from './helpers';
|
|
6
4
|
|
|
7
|
-
export const previewLink = (rawClient: FetchClient) =>
|
|
5
|
+
export const previewLink = (rawClient: FetchClient) =>
|
|
6
|
+
allpeepNoPayloadEndpoint<FetchUrlResponse, { url: string }>(
|
|
8
7
|
rawClient,
|
|
9
8
|
'/fetch-url/:url',
|
|
10
|
-
);
|
|
9
|
+
);
|
package/src/endpoints/reports.ts
CHANGED
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
import type { FetchClient } from '@openpeepshq/fetch-client';
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
ReportCreationData,
|
|
4
|
+
PublicReport,
|
|
5
|
+
SuccessResponse,
|
|
6
6
|
} from '@openpeepshq/common';
|
|
7
7
|
import { allpeepNoPayloadEndpoint, allpeepPayloadEndpoint } from './helpers';
|
|
8
8
|
|
|
9
9
|
export const reports = (rawClient: FetchClient) => ({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
delete
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
'delete',
|
|
31
|
-
),
|
|
32
|
-
});
|
|
10
|
+
list: allpeepNoPayloadEndpoint<PublicReport[]>(rawClient, '/reports'),
|
|
11
|
+
findById: allpeepNoPayloadEndpoint<PublicReport, { reportId: string }>(
|
|
12
|
+
rawClient,
|
|
13
|
+
'/reports/:reportId',
|
|
14
|
+
),
|
|
15
|
+
create: allpeepPayloadEndpoint<PublicReport, ReportCreationData>(
|
|
16
|
+
rawClient,
|
|
17
|
+
'/reports',
|
|
18
|
+
),
|
|
19
|
+
update: allpeepPayloadEndpoint<
|
|
20
|
+
PublicReport,
|
|
21
|
+
Partial<ReportCreationData>,
|
|
22
|
+
{ id: string }
|
|
23
|
+
>(rawClient, '/reports/:id', 'patch'),
|
|
24
|
+
delete: allpeepNoPayloadEndpoint<SuccessResponse, { id: string }>(
|
|
25
|
+
rawClient,
|
|
26
|
+
'/reports/:id',
|
|
27
|
+
'delete',
|
|
28
|
+
),
|
|
29
|
+
});
|
package/src/endpoints/search.ts
CHANGED
|
@@ -1,34 +1,47 @@
|
|
|
1
|
-
import { FetchClient } from
|
|
2
|
-
import { allpeepNoPayloadEndpoint } from
|
|
3
|
-
import {
|
|
1
|
+
import { FetchClient } from '@openpeepshq/fetch-client';
|
|
2
|
+
import { allpeepNoPayloadEndpoint } from './helpers';
|
|
3
|
+
import {
|
|
4
|
+
GroupWithMeta,
|
|
5
|
+
PublicPost,
|
|
6
|
+
OffsetInfiniteQueryParams,
|
|
7
|
+
PublicProfile,
|
|
8
|
+
SearchResult,
|
|
9
|
+
SearchResultCounts,
|
|
10
|
+
} from '@openpeepshq/common';
|
|
4
11
|
|
|
5
12
|
type SearchQueryParams = OffsetInfiniteQueryParams & {
|
|
6
|
-
|
|
7
|
-
}
|
|
13
|
+
q: string;
|
|
14
|
+
};
|
|
8
15
|
|
|
9
16
|
export const search = (rawClient: FetchClient) => ({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
posts: allpeepNoPayloadEndpoint<
|
|
18
|
+
SearchResult<PublicPost>,
|
|
19
|
+
undefined,
|
|
20
|
+
SearchQueryParams
|
|
21
|
+
>(rawClient, '/search/posts'),
|
|
22
|
+
profiles: allpeepNoPayloadEndpoint<
|
|
23
|
+
SearchResult<PublicProfile>,
|
|
24
|
+
undefined,
|
|
25
|
+
SearchQueryParams
|
|
26
|
+
>(rawClient, '/search/profiles'),
|
|
27
|
+
events: allpeepNoPayloadEndpoint<
|
|
28
|
+
SearchResult<PublicPost>,
|
|
29
|
+
undefined,
|
|
30
|
+
SearchQueryParams
|
|
31
|
+
>(rawClient, '/search/events'),
|
|
32
|
+
jams: allpeepNoPayloadEndpoint<
|
|
33
|
+
SearchResult<PublicPost>,
|
|
34
|
+
undefined,
|
|
35
|
+
SearchQueryParams
|
|
36
|
+
>(rawClient, '/search/jams'),
|
|
37
|
+
groups: allpeepNoPayloadEndpoint<
|
|
38
|
+
SearchResult<GroupWithMeta>,
|
|
39
|
+
undefined,
|
|
40
|
+
SearchQueryParams
|
|
41
|
+
>(rawClient, '/search/groups'),
|
|
42
|
+
counts: allpeepNoPayloadEndpoint<
|
|
43
|
+
SearchResultCounts,
|
|
44
|
+
undefined,
|
|
45
|
+
SearchQueryParams
|
|
46
|
+
>(rawClient, '/search/counts'),
|
|
47
|
+
});
|
package/src/endpoints/server.ts
CHANGED
|
@@ -1,38 +1,31 @@
|
|
|
1
1
|
import type { FetchClient } from '@openpeepshq/fetch-client';
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
CapabilitiesConfig,
|
|
4
|
+
ServerInfo,
|
|
5
|
+
WebhookKeyResponse,
|
|
6
|
+
WebhookVerifyRequest,
|
|
7
|
+
WebhookVerifyResponse,
|
|
8
8
|
} from '@openpeepshq/common';
|
|
9
9
|
import { allpeepNoPayloadEndpoint, allpeepPayloadEndpoint } from './helpers';
|
|
10
10
|
|
|
11
11
|
export const server = (rawClient: FetchClient) => ({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
info: allpeepNoPayloadEndpoint<ServerInfo>(rawClient, '/server/info'),
|
|
13
|
+
config: {
|
|
14
|
+
capabilities: allpeepNoPayloadEndpoint<CapabilitiesConfig>(
|
|
15
|
+
rawClient,
|
|
16
|
+
'/server/config/capabilities',
|
|
15
17
|
),
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
),
|
|
28
|
-
verify: allpeepPayloadEndpoint<
|
|
29
|
-
WebhookVerifyResponse,
|
|
30
|
-
WebhookVerifyRequest
|
|
31
|
-
>(
|
|
32
|
-
rawClient,
|
|
33
|
-
'/server/keys/webhooks/verify',
|
|
34
|
-
'post',
|
|
35
|
-
),
|
|
36
|
-
},
|
|
18
|
+
},
|
|
19
|
+
keys: {
|
|
20
|
+
webhooks: {
|
|
21
|
+
public: allpeepNoPayloadEndpoint<WebhookKeyResponse>(
|
|
22
|
+
rawClient,
|
|
23
|
+
'/server/keys/webhooks',
|
|
24
|
+
),
|
|
25
|
+
verify: allpeepPayloadEndpoint<
|
|
26
|
+
WebhookVerifyResponse,
|
|
27
|
+
WebhookVerifyRequest
|
|
28
|
+
>(rawClient, '/server/keys/webhooks/verify', 'post'),
|
|
37
29
|
},
|
|
38
|
-
}
|
|
30
|
+
},
|
|
31
|
+
});
|
package/src/endpoints/sso.ts
CHANGED
|
@@ -3,33 +3,21 @@ import type { TokenResponse } from '@openpeepshq/common';
|
|
|
3
3
|
import { allpeepPayloadEndpoint, allpeepNoPayloadEndpoint } from './helpers';
|
|
4
4
|
|
|
5
5
|
export const sso = (rawClient: FetchClient) => ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
callback: allpeepNoPayloadEndpoint<
|
|
25
|
-
TokenResponse,
|
|
26
|
-
{ id: string },
|
|
27
|
-
Record<string, string>
|
|
28
|
-
>(
|
|
29
|
-
rawClient,
|
|
30
|
-
'/sso/oidc/{id}/callback',
|
|
31
|
-
'get',
|
|
32
|
-
),
|
|
33
|
-
},
|
|
34
|
-
}
|
|
35
|
-
);
|
|
6
|
+
generic: {
|
|
7
|
+
authenticate: allpeepPayloadEndpoint<
|
|
8
|
+
TokenResponse,
|
|
9
|
+
{ data: Record<string, string> }
|
|
10
|
+
>(rawClient, '/sso/generic'),
|
|
11
|
+
},
|
|
12
|
+
oidc: {
|
|
13
|
+
authorize: allpeepNoPayloadEndpoint<
|
|
14
|
+
{ data: { redirectUrl: string } },
|
|
15
|
+
{ id: string }
|
|
16
|
+
>(rawClient, '/sso/oidc/{id}/authorize', 'get'),
|
|
17
|
+
callback: allpeepNoPayloadEndpoint<
|
|
18
|
+
TokenResponse,
|
|
19
|
+
{ id: string },
|
|
20
|
+
Record<string, string>
|
|
21
|
+
>(rawClient, '/sso/oidc/{id}/callback', 'get'),
|
|
22
|
+
},
|
|
23
|
+
});
|
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
import type { FetchClient } from '@openpeepshq/fetch-client';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
MediaStreamRequest,
|
|
5
|
-
} from '@openpeepshq/common';
|
|
6
|
-
import {
|
|
7
|
-
allpeepNoPayloadEndpoint,
|
|
8
|
-
allpeepPayloadEndpoint,
|
|
9
|
-
} from './helpers';
|
|
2
|
+
import type { MediaStream, MediaStreamRequest } from '@openpeepshq/common';
|
|
3
|
+
import { allpeepNoPayloadEndpoint, allpeepPayloadEndpoint } from './helpers';
|
|
10
4
|
|
|
11
5
|
export const streaming = (rawClient: FetchClient) => ({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
6
|
+
vod: {
|
|
7
|
+
/**
|
|
8
|
+
* Request that an HLS VOD stream be produced for a media URL hosted on
|
|
9
|
+
* this server. Idempotent: returns the existing stream's status when
|
|
10
|
+
* called again with the same source URL.
|
|
11
|
+
*/
|
|
12
|
+
create: allpeepPayloadEndpoint<MediaStream, MediaStreamRequest>(
|
|
13
|
+
rawClient,
|
|
14
|
+
'/streaming/vod',
|
|
15
|
+
'post',
|
|
16
|
+
),
|
|
17
|
+
/** Polls the current status of a previously-created VOD stream. */
|
|
18
|
+
status: allpeepNoPayloadEndpoint<MediaStream, { storageId: string }>(
|
|
19
|
+
rawClient,
|
|
20
|
+
'/streaming/vod/:storageId/status',
|
|
21
|
+
),
|
|
22
|
+
},
|
|
29
23
|
});
|
package/src/webhooks/index.ts
CHANGED
|
@@ -7,18 +7,14 @@ import {
|
|
|
7
7
|
import { parseJwtKeyId, verifyJwt } from '@openpeepshq/common/lib';
|
|
8
8
|
import type { OpenpeepsNoPayloadEndpoint } from '../types';
|
|
9
9
|
|
|
10
|
-
export type WebhookHandler = (
|
|
11
|
-
input: string,
|
|
12
|
-
) => Promise<WebhookData>);
|
|
10
|
+
export type WebhookHandler = (input: string) => Promise<WebhookData>;
|
|
13
11
|
|
|
14
12
|
export const webhookHandler = (
|
|
15
13
|
publicKeyEndpoint: OpenpeepsNoPayloadEndpoint<WebhookKeyResponse>,
|
|
16
14
|
): WebhookHandler => {
|
|
17
|
-
|
|
18
|
-
let publicKey: string | undefined = undefined;
|
|
15
|
+
const publicKey: string | undefined = undefined;
|
|
19
16
|
|
|
20
17
|
const getPublicKey = async (kid?: string) => {
|
|
21
|
-
|
|
22
18
|
if (!kid) {
|
|
23
19
|
throw new Error('Kid is required');
|
|
24
20
|
}
|
|
@@ -34,8 +30,7 @@ export const webhookHandler = (
|
|
|
34
30
|
return result.data.publicKey;
|
|
35
31
|
};
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
return (async (input: string | WebhookVerifyRequest) => {
|
|
33
|
+
return async (input: string | WebhookVerifyRequest) => {
|
|
39
34
|
const token = typeof input === 'string' ? input : input.token;
|
|
40
35
|
const tokenKeyId = parseJwtKeyId(token);
|
|
41
36
|
|
|
@@ -45,6 +40,5 @@ export const webhookHandler = (
|
|
|
45
40
|
}
|
|
46
41
|
|
|
47
42
|
return webhookDataSchema.parse(verification.payload);
|
|
48
|
-
|
|
49
|
-
});
|
|
43
|
+
};
|
|
50
44
|
};
|