@openpeepshq/client 0.1.38 → 0.2.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.
@@ -0,0 +1,69 @@
1
+ import type { FetchClient } from '@openpeepshq/fetch-client';
2
+ import type {
3
+ CreateGroupRequest,
4
+ GroupData,
5
+ GroupMember,
6
+ GroupRoleData,
7
+ GroupWithMeta,
8
+ PublicProfile,
9
+ SuccessResponse,
10
+ } from '@openpeepshq/common';
11
+ import { allpeepNoPayloadEndpoint, allpeepPayloadEndpoint } from './helpers';
12
+
13
+ export const groups = (rawClient: FetchClient) => ({
14
+ create: allpeepPayloadEndpoint<GroupWithMeta, CreateGroupRequest>(
15
+ rawClient,
16
+ '/groups',
17
+ 'post',
18
+ ),
19
+ list: allpeepNoPayloadEndpoint<GroupWithMeta[]>(
20
+ rawClient,
21
+ '/groups',
22
+ ),
23
+ findById: allpeepNoPayloadEndpoint<GroupWithMeta, { id: string }>(
24
+ rawClient,
25
+ '/groups/:id',
26
+ ),
27
+ findByHandle: allpeepNoPayloadEndpoint<GroupWithMeta, { handle: string }>(
28
+ rawClient,
29
+ '/groups/by-handle/:handle',
30
+ ),
31
+ update: allpeepPayloadEndpoint<GroupWithMeta, GroupData, { id: string }>(
32
+ rawClient,
33
+ '/groups/:id',
34
+ 'put',
35
+ ),
36
+ delete: allpeepNoPayloadEndpoint<GroupWithMeta, { id: string }>(
37
+ rawClient,
38
+ '/groups/:id',
39
+ 'delete',
40
+ ),
41
+ members: allpeepNoPayloadEndpoint<GroupMember[], { id: string }>(
42
+ rawClient,
43
+ '/groups/:id/members',
44
+ ),
45
+ join: allpeepNoPayloadEndpoint<SuccessResponse, { id: string }>(
46
+ rawClient,
47
+ '/groups/:id/join',
48
+ 'post',
49
+ ),
50
+ leave: allpeepNoPayloadEndpoint<SuccessResponse, { id: string }>(
51
+ rawClient,
52
+ '/groups/:id/leave',
53
+ 'delete',
54
+ ),
55
+ addMember: allpeepPayloadEndpoint<SuccessResponse, PublicProfile, { id: string }>(
56
+ rawClient,
57
+ '/groups/:id/members',
58
+ ),
59
+ removeMember: allpeepNoPayloadEndpoint<SuccessResponse, { id: string; memberId: string }>(
60
+ rawClient,
61
+ '/groups/:id/members/:memberId',
62
+ 'delete',
63
+ ),
64
+ setMemberRoles: allpeepPayloadEndpoint<SuccessResponse, GroupRoleData, { id: string; memberId: string }>(
65
+ rawClient,
66
+ '/groups/:id/members/:memberId',
67
+ 'put',
68
+ ),
69
+ });
@@ -0,0 +1,91 @@
1
+ import type { SuccessFailureResponse } from "@openpeepshq/common";
2
+ import {
3
+ type BodyType,
4
+ type EndpointDefinition,
5
+ type FetchClient,
6
+ type FormDataEndpointDefinition,
7
+ type FormDataSource,
8
+ type ParametersType,
9
+ typedNoPayloadEndpoint,
10
+ typedPayloadEndpoint,
11
+ typedPayloadProgressObserverEndpoint,
12
+ type Verb,
13
+ } from "@openpeepshq/fetch-client";
14
+
15
+ export const allpeepPayloadEndpoint = <
16
+ Output,
17
+ Input extends BodyType,
18
+ PathParameters extends ParametersType = undefined,
19
+ QueryParameters extends ParametersType = undefined,
20
+ >(
21
+ rawClient: FetchClient,
22
+ path: string,
23
+ method: Verb = "post",
24
+ convertToFormData?: Input extends FormDataSource ? true : false | undefined,
25
+ ) =>
26
+ typedPayloadEndpoint<
27
+ Output,
28
+ Input,
29
+ SuccessFailureResponse,
30
+ PathParameters,
31
+ QueryParameters
32
+ >(
33
+ {
34
+ path,
35
+ method,
36
+ convertToFormData,
37
+ } as Input extends FormDataSource
38
+ ? FormDataEndpointDefinition
39
+ : EndpointDefinition,
40
+ rawClient,
41
+ );
42
+
43
+ export const allpeepPayloadProgressObserverEndpoint = <
44
+ Output,
45
+ Input extends BodyType,
46
+ PathParameters extends ParametersType = undefined,
47
+ QueryParameters extends ParametersType = undefined,
48
+ >(
49
+ rawClient: FetchClient,
50
+ path: string,
51
+ method: Verb = "post",
52
+ convertToFormData?: Input extends FormDataSource ? true : false | undefined,
53
+ ) =>
54
+ typedPayloadProgressObserverEndpoint<
55
+ Output,
56
+ Input,
57
+ SuccessFailureResponse,
58
+ PathParameters,
59
+ QueryParameters
60
+ >(
61
+ {
62
+ path,
63
+ method,
64
+ convertToFormData,
65
+ } as Input extends FormDataSource
66
+ ? FormDataEndpointDefinition
67
+ : EndpointDefinition,
68
+ rawClient,
69
+ );
70
+
71
+ export const allpeepNoPayloadEndpoint = <
72
+ Output,
73
+ PathParameters extends ParametersType = undefined,
74
+ QueryParameters extends ParametersType = undefined,
75
+ >(
76
+ rawClient: FetchClient,
77
+ path: string,
78
+ method: Verb = "get",
79
+ ) =>
80
+ typedNoPayloadEndpoint<
81
+ Output,
82
+ SuccessFailureResponse,
83
+ PathParameters,
84
+ QueryParameters
85
+ >(
86
+ {
87
+ path,
88
+ method,
89
+ },
90
+ rawClient,
91
+ );
@@ -0,0 +1,14 @@
1
+ import type { FetchClient } from '@openpeepshq/fetch-client';
2
+ import type { ResourceLanguage } from 'i18next';
3
+ import { allpeepNoPayloadEndpoint } from './helpers';
4
+
5
+ export const i18n = (rawClient: FetchClient) => ({
6
+ translations: allpeepNoPayloadEndpoint<ResourceLanguage, { lang: string }>(
7
+ rawClient,
8
+ '/i18n/:lang',
9
+ ),
10
+ languages: allpeepNoPayloadEndpoint<string[]>(
11
+ rawClient,
12
+ '/i18n/languages',
13
+ ),
14
+ });
@@ -0,0 +1,126 @@
1
+ import type { FetchClient } from '@openpeepshq/fetch-client';
2
+ import type {
3
+ ChronologicalInfiniteQueryParams,
4
+ JamEvent,
5
+ JamState,
6
+ JamTokenResponse,
7
+ PublicPost,
8
+ MuteParticipantRequest,
9
+ PublicProfile,
10
+ SuccessResponse,
11
+ JamRecording,
12
+ JamObserverResponseData,
13
+ JamRtmpStreamRequest,
14
+ JamRtmpStreamResponse,
15
+ } from '@openpeepshq/common';
16
+ import { allpeepNoPayloadEndpoint, allpeepPayloadEndpoint } from './helpers';
17
+ import { noPayloadEventSource } from '@openpeepshq/fetch-client';
18
+
19
+ type OccurrenceQuery = { occurrence?: string };
20
+
21
+ export const jams = (
22
+ rawClient: FetchClient,
23
+ eventSource: ReturnType<typeof noPayloadEventSource>,
24
+ ) => {
25
+ return {
26
+ list: allpeepNoPayloadEndpoint<PublicPost[], undefined, { live?: 'true' }>(
27
+ rawClient,
28
+ '/jams',
29
+ ),
30
+ state: allpeepNoPayloadEndpoint<JamState, { id: string }, OccurrenceQuery>(
31
+ rawClient,
32
+ '/jams/:id/state',
33
+ ),
34
+ close: allpeepNoPayloadEndpoint<
35
+ SuccessResponse,
36
+ { id: string },
37
+ OccurrenceQuery
38
+ >(rawClient, '/jams/:id/close', 'put'),
39
+ token: allpeepNoPayloadEndpoint<
40
+ JamTokenResponse,
41
+ { id: string },
42
+ OccurrenceQuery & { reconnect?: 'true' }
43
+ >(rawClient, '/jams/:id/token'),
44
+ muteParticipant: allpeepPayloadEndpoint<
45
+ SuccessResponse,
46
+ MuteParticipantRequest,
47
+ { id: string },
48
+ OccurrenceQuery
49
+ >(rawClient, '/jams/:id/mute-participant'),
50
+ waitingRoom: {
51
+ listen: eventSource<
52
+ Record<string, PublicProfile>,
53
+ { id: string },
54
+ OccurrenceQuery
55
+ >('/jams/:id/waiting-room'),
56
+ join: eventSource<JamTokenResponse, { id: string }, OccurrenceQuery>(
57
+ '/jams/:id/waiting-room',
58
+ 'post',
59
+ ),
60
+ admit: allpeepNoPayloadEndpoint<
61
+ SuccessResponse,
62
+ { id: string; profileId: string },
63
+ OccurrenceQuery
64
+ >(rawClient, '/jams/:id/waiting-room/:profileId/admit', 'post'),
65
+ },
66
+ events: {
67
+ list: allpeepNoPayloadEndpoint<
68
+ JamEvent[],
69
+ { id: string },
70
+ ChronologicalInfiniteQueryParams
71
+ >(rawClient, '/jams/:id/events'),
72
+ create: allpeepPayloadEndpoint<JamEvent, JamEvent, { id: string }>(
73
+ rawClient,
74
+ '/jams/:id/events',
75
+ ),
76
+ attendance: allpeepNoPayloadEndpoint<JamEvent[], { id: string }>(
77
+ rawClient,
78
+ '/jams/:id/events/attendance',
79
+ ),
80
+ exportAttendance: async ({ id }: { id: string }) => {
81
+ const response = await rawClient.get(
82
+ `/jams/${id}/events/attendance/export`,
83
+ );
84
+
85
+ if (!response.ok) {
86
+ throw { ...(await response.json()), status: response.status };
87
+ }
88
+
89
+ return response.text();
90
+ },
91
+ },
92
+ recordings: {
93
+ start: allpeepNoPayloadEndpoint<
94
+ JamRecording,
95
+ { id: string },
96
+ OccurrenceQuery
97
+ >(rawClient, '/jams/:id/recordings', 'post'),
98
+ stop: allpeepNoPayloadEndpoint<
99
+ JamRecording,
100
+ { id: string },
101
+ OccurrenceQuery
102
+ >(rawClient, '/jams/:id/recordings/stop', 'put'),
103
+ observerLink: allpeepNoPayloadEndpoint<
104
+ JamObserverResponseData,
105
+ { id: string },
106
+ OccurrenceQuery
107
+ >(rawClient, '/jams/:id/recordings/observer-link', 'get'),
108
+ },
109
+ streams: {
110
+ get: allpeepNoPayloadEndpoint<JamRtmpStreamResponse, { id: string }>(
111
+ rawClient,
112
+ '/jams/:id/streams',
113
+ ),
114
+ start: allpeepPayloadEndpoint<
115
+ JamRtmpStreamResponse,
116
+ JamRtmpStreamRequest,
117
+ { id: string }
118
+ >(rawClient, '/jams/:id/streams', 'post'),
119
+ stop: allpeepNoPayloadEndpoint<JamRtmpStreamResponse, { id: string }>(
120
+ rawClient,
121
+ '/jams/:id/streams/stop',
122
+ 'put',
123
+ ),
124
+ },
125
+ };
126
+ };
@@ -0,0 +1,10 @@
1
+ import type { FetchClient } from '@openpeepshq/fetch-client';
2
+ import type { GeocodingResult } from '@openpeepshq/common';
3
+ import { allpeepNoPayloadEndpoint } from './helpers';
4
+
5
+ export const location = (rawClient: FetchClient) => ({
6
+ geocode: allpeepNoPayloadEndpoint<GeocodingResult[], undefined, { query: string }>(
7
+ rawClient,
8
+ '/location/geocode',
9
+ ),
10
+ });
@@ -0,0 +1,56 @@
1
+ import type {
2
+ FetchClient,
3
+ noPayloadEventSource,
4
+ } from '@openpeepshq/fetch-client';
5
+ import type {
6
+ MediaAttachment,
7
+ MediaProgressEvent,
8
+ MediaStorageRequestInput,
9
+ SuccessResponse,
10
+ } from '@openpeepshq/common';
11
+ import {
12
+ allpeepNoPayloadEndpoint,
13
+ allpeepPayloadEndpoint,
14
+ allpeepPayloadProgressObserverEndpoint,
15
+ } from './helpers';
16
+
17
+ export const media = (
18
+ rawClient: FetchClient,
19
+ eventSource: ReturnType<typeof noPayloadEventSource>,
20
+ ) => ({
21
+ list: allpeepNoPayloadEndpoint<MediaAttachment[]>(
22
+ rawClient,
23
+ '/media',
24
+ ),
25
+ findById: allpeepNoPayloadEndpoint<MediaAttachment, { id: string }>(
26
+ rawClient,
27
+ '/media/:id',
28
+ ),
29
+ create: allpeepPayloadEndpoint<MediaAttachment, MediaStorageRequestInput>(
30
+ rawClient,
31
+ '/media',
32
+ 'post',
33
+ true,
34
+ ),
35
+ /**
36
+ * Same as `create` but routes through XHR so callers can pass
37
+ * `onUploadProgress` to receive byte-level upload events. Returns either a
38
+ * fully-processed `MediaAttachment` (small files, sync path) or a partial
39
+ * one with `status: 'processing'` (large files, async path) — pair with
40
+ * `progress.listen` to track the background processing phase.
41
+ */
42
+ createWithProgress: allpeepPayloadProgressObserverEndpoint<
43
+ MediaAttachment,
44
+ MediaStorageRequestInput
45
+ >(rawClient, '/media', 'post', true),
46
+ delete: allpeepNoPayloadEndpoint<SuccessResponse, { id: string }>(
47
+ rawClient,
48
+ '/media/:id',
49
+ 'delete',
50
+ ),
51
+ progress: {
52
+ listen: eventSource<MediaProgressEvent, { id: string }>(
53
+ '/media/:id/progress',
54
+ ),
55
+ },
56
+ });
@@ -0,0 +1,34 @@
1
+ import type { FetchClient } from '@openpeepshq/fetch-client';
2
+ import type {
3
+ PaymentCheckoutResponse,
4
+ StripeCustomerPortalResponseSchema,
5
+ StripeSubscriptionData,
6
+ SuccessFailureResponse,
7
+ StripePaymentConfig,
8
+ } from '@openpeepshq/common';
9
+ import { allpeepNoPayloadEndpoint, allpeepPayloadEndpoint } from './helpers';
10
+
11
+ export const payments = (rawClient: FetchClient) => ({
12
+ createCheckout: allpeepNoPayloadEndpoint<PaymentCheckoutResponse>(
13
+ rawClient,
14
+ '/payments/create-checkout',
15
+ 'post',
16
+ ),
17
+ createPortal: allpeepNoPayloadEndpoint<StripeCustomerPortalResponseSchema>(
18
+ rawClient,
19
+ '/payments/create-portal',
20
+ 'post',
21
+ ),
22
+ success: allpeepNoPayloadEndpoint<SuccessFailureResponse>(
23
+ rawClient,
24
+ '/payments/success',
25
+ ),
26
+ status: allpeepNoPayloadEndpoint<StripeSubscriptionData>(
27
+ rawClient,
28
+ '/payments/status',
29
+ ),
30
+ test: allpeepPayloadEndpoint<SuccessFailureResponse, StripePaymentConfig>(
31
+ rawClient,
32
+ '/payments/test',
33
+ ),
34
+ });
@@ -0,0 +1,25 @@
1
+ import type { FetchClient } from '@openpeepshq/fetch-client';
2
+ import type {
3
+ PluginConfigResponse,
4
+ PluginEntry,
5
+ PluginManifest,
6
+ } from '@openpeepshq/common';
7
+ import { allpeepNoPayloadEndpoint } from './helpers';
8
+
9
+ type PluginManifestEntry = PluginManifest & {
10
+ key: string;
11
+ namespace: string;
12
+ name: string;
13
+ };
14
+
15
+ export const plugins = (rawClient: FetchClient) => ({
16
+ list: allpeepNoPayloadEndpoint<PluginEntry[]>(rawClient, '/plugins'),
17
+ config: allpeepNoPayloadEndpoint<PluginConfigResponse>(
18
+ rawClient,
19
+ '/plugins/config',
20
+ ),
21
+ manifest: allpeepNoPayloadEndpoint<PluginManifestEntry[]>(
22
+ rawClient,
23
+ '/plugins/manifest',
24
+ ),
25
+ });