@openpeepshq/client 0.1.37 → 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.
- package/dist/common/authenticated.js +2 -2
- package/dist/endpoints/accounts.d.ts +69 -0
- package/dist/endpoints/accounts.js +1 -0
- package/dist/endpoints/admin.d.ts +115 -17328
- package/dist/endpoints/admin.js +11 -2
- package/dist/endpoints/auth.d.ts +2 -1
- package/dist/endpoints/conversations.d.ts +35481 -5352
- package/dist/endpoints/conversations.js +2 -0
- package/dist/endpoints/groups.d.ts +15 -3
- package/dist/endpoints/jams.d.ts +7500 -716
- package/dist/endpoints/jams.js +12 -0
- package/dist/endpoints/plugins.d.ts +1 -1
- package/dist/endpoints/posts.d.ts +72 -76801
- package/dist/endpoints/posts.js +12 -2
- package/dist/endpoints/profiles.d.ts +27308 -3781
- package/dist/endpoints/profiles.js +8 -0
- package/dist/endpoints/search.d.ts +24551 -4361
- package/dist/endpoints/server.d.ts +19 -1
- package/dist/index.js +8 -11
- package/package.json +30 -9
- package/src/common/authenticated.ts +28 -0
- package/src/common/base.ts +11 -0
- package/src/endpoints/accounts.ts +52 -0
- package/src/endpoints/admin.ts +616 -0
- package/src/endpoints/analytics.ts +13 -0
- package/src/endpoints/auth.ts +43 -0
- package/src/endpoints/conversations.ts +28 -0
- package/src/endpoints/groups.ts +69 -0
- package/src/endpoints/helpers.ts +91 -0
- package/src/endpoints/i18n.ts +14 -0
- package/src/endpoints/jams.ts +126 -0
- package/src/endpoints/location.ts +10 -0
- package/src/endpoints/media.ts +56 -0
- package/src/endpoints/payments.ts +34 -0
- package/src/endpoints/plugins.ts +25 -0
- package/src/endpoints/posts.ts +377 -0
- package/src/endpoints/previewLink.ts +10 -0
- package/src/endpoints/profiles.ts +167 -0
- package/src/endpoints/reports.ts +32 -0
- package/src/endpoints/search.ts +34 -0
- package/src/endpoints/server.ts +38 -0
- package/src/endpoints/sso.ts +35 -0
- package/src/endpoints/streaming.ts +29 -0
- package/src/endpoints/types.ts +66 -0
- package/src/index.ts +88 -0
- package/src/types/index.ts +20 -0
- package/src/webhooks/index.ts +50 -0
|
@@ -4,10 +4,17 @@ export declare const server: (rawClient: FetchClient) => {
|
|
|
4
4
|
version: string;
|
|
5
5
|
environment: string;
|
|
6
6
|
publicContent: boolean;
|
|
7
|
+
startedAt: string;
|
|
8
|
+
uptimeSeconds: number;
|
|
9
|
+
disk: {
|
|
10
|
+
folderBytes: number;
|
|
11
|
+
freeBytes: number;
|
|
12
|
+
totalBytes: number;
|
|
13
|
+
} | null;
|
|
14
|
+
lastAccessed: string | null;
|
|
7
15
|
communityConfig: {
|
|
8
16
|
theme: {
|
|
9
17
|
base: string;
|
|
10
|
-
primaryHex: string;
|
|
11
18
|
light: {
|
|
12
19
|
primaryHex: string;
|
|
13
20
|
secondaryHex?: string | undefined;
|
|
@@ -34,6 +41,7 @@ export declare const server: (rawClient: FetchClient) => {
|
|
|
34
41
|
};
|
|
35
42
|
icon?: string | undefined;
|
|
36
43
|
mobileIcon?: string | undefined;
|
|
44
|
+
primaryHex?: string | undefined;
|
|
37
45
|
logoFull?: string | undefined;
|
|
38
46
|
logoSmall?: string | undefined;
|
|
39
47
|
defaultProfileAvatar?: string | undefined;
|
|
@@ -58,6 +66,9 @@ export declare const server: (rawClient: FetchClient) => {
|
|
|
58
66
|
settings: {
|
|
59
67
|
openRegistrations: boolean;
|
|
60
68
|
defaultLanguage?: string | undefined;
|
|
69
|
+
defaultTimeZone?: string | undefined;
|
|
70
|
+
defaultFeedFormat?: "threaded" | "linear" | undefined;
|
|
71
|
+
indexProfiles?: boolean | undefined;
|
|
61
72
|
};
|
|
62
73
|
roles: {
|
|
63
74
|
onRegistration: {
|
|
@@ -100,12 +111,19 @@ export declare const server: (rawClient: FetchClient) => {
|
|
|
100
111
|
};
|
|
101
112
|
};
|
|
102
113
|
};
|
|
114
|
+
build?: string | undefined;
|
|
103
115
|
maxProfiles?: number | undefined;
|
|
104
116
|
sso?: {
|
|
117
|
+
generic: {
|
|
118
|
+
id: string;
|
|
119
|
+
name: string;
|
|
120
|
+
loginLink: string;
|
|
121
|
+
}[];
|
|
105
122
|
oidc: {
|
|
106
123
|
id: string;
|
|
107
124
|
name: string;
|
|
108
125
|
}[];
|
|
126
|
+
onlySSO?: boolean | undefined;
|
|
109
127
|
} | undefined;
|
|
110
128
|
}, {
|
|
111
129
|
success: boolean;
|
package/dist/index.js
CHANGED
|
@@ -20,17 +20,14 @@ import { previewLink } from './endpoints/previewLink.js';
|
|
|
20
20
|
import { payments } from './endpoints/payments.js';
|
|
21
21
|
import { streaming } from './endpoints/streaming.js';
|
|
22
22
|
import { webhookHandler } from './webhooks/index.js';
|
|
23
|
-
const allPeepClientOptionsToClientConfig = (options) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
: undefined,
|
|
32
|
-
});
|
|
33
|
-
};
|
|
23
|
+
const allPeepClientOptionsToClientConfig = (options) => ({
|
|
24
|
+
baseUrl: (options?.baseUrl ?? '') + '/api/openpeeps/core/v1',
|
|
25
|
+
headers: options?.token
|
|
26
|
+
? {
|
|
27
|
+
Authorization: `Bearer ${options.token}`,
|
|
28
|
+
}
|
|
29
|
+
: undefined,
|
|
30
|
+
});
|
|
34
31
|
export const openpeepsClient = (options) => {
|
|
35
32
|
const config = typeof options === 'function'
|
|
36
33
|
? async () => allPeepClientOptionsToClientConfig(await options())
|
package/package.json
CHANGED
|
@@ -1,24 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
6
7
|
"dependencies": {
|
|
7
8
|
"validator": "^13.11.0",
|
|
8
|
-
"
|
|
9
|
-
"@openpeepshq/
|
|
10
|
-
"@openpeepshq/fetch-client": "^0.1.7"
|
|
9
|
+
"@openpeepshq/common": "^0.2.0",
|
|
10
|
+
"@openpeepshq/fetch-client": "^0.2.0"
|
|
11
11
|
},
|
|
12
|
-
"main": "dist/index.js",
|
|
13
|
-
"types": "dist/index.d.ts",
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
14
|
"exports": {
|
|
15
|
-
".":
|
|
16
|
-
|
|
15
|
+
".": {
|
|
16
|
+
"react-native": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./src/index.ts"
|
|
19
|
+
},
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"node": "./dist/index.js",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./*": {
|
|
25
|
+
"react-native": {
|
|
26
|
+
"types": "./dist/*/index.d.ts",
|
|
27
|
+
"default": "./src/*/index.ts"
|
|
28
|
+
},
|
|
29
|
+
"types": "./dist/*/index.d.ts",
|
|
30
|
+
"node": "./dist/*/index.js",
|
|
31
|
+
"default": "./dist/*/index.js"
|
|
32
|
+
}
|
|
17
33
|
},
|
|
18
34
|
"files": [
|
|
19
|
-
"
|
|
35
|
+
"src",
|
|
36
|
+
"dist",
|
|
37
|
+
"!**/__tests__",
|
|
38
|
+
"!**/*.test.ts"
|
|
20
39
|
],
|
|
21
40
|
"devDependencies": {
|
|
41
|
+
"@types/node": "^22.14.1",
|
|
22
42
|
"@types/validator": "^13.11.9",
|
|
23
43
|
"@typescript-eslint/eslint-plugin": "^8.19.0",
|
|
24
44
|
"@typescript-eslint/parser": "^8.19.0",
|
|
@@ -34,6 +54,7 @@
|
|
|
34
54
|
"lint": "prettier --check . && ESLINT_USE_FLAT_CONFIG=false eslint .",
|
|
35
55
|
"format": "prettier --write .",
|
|
36
56
|
"clean": "rm -rf tsconfig.tsbuildinfo dist",
|
|
57
|
+
"typecheck": "tsc --noEmit",
|
|
37
58
|
"build": "tsc && tsc-alias",
|
|
38
59
|
"build:watch": "tsc && tsc-alias && (concurrently \"tsc -w\" \"tsc-alias -w\")"
|
|
39
60
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { fetchClient, type FetchClient } from '@openpeepshq/fetch-client';
|
|
2
|
+
import { apiClientConfig } from './base';
|
|
3
|
+
|
|
4
|
+
export const authHeaders = (token: string) => {
|
|
5
|
+
return token
|
|
6
|
+
? {
|
|
7
|
+
Authorization: `Bearer ${token}`,
|
|
8
|
+
}
|
|
9
|
+
: undefined;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const authenticatedCoreApiClient = (token: string): FetchClient =>
|
|
13
|
+
fetchClient({ ...apiClientConfig, headers: authHeaders(token) ?? {} });
|
|
14
|
+
|
|
15
|
+
export const handleError = async (r: Response) => {
|
|
16
|
+
if (r.ok) {
|
|
17
|
+
return r;
|
|
18
|
+
} else {
|
|
19
|
+
throw { ...(await r.json()), status: r.status };
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const transformResponse = (r: Response) => r.json();
|
|
24
|
+
|
|
25
|
+
export const handleFetchResult = async (r: Response) => {
|
|
26
|
+
await handleError(r);
|
|
27
|
+
return transformResponse(r);
|
|
28
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ClientConfig,
|
|
3
|
+
fetchClient,
|
|
4
|
+
type FetchClient,
|
|
5
|
+
} from '@openpeepshq/fetch-client';
|
|
6
|
+
|
|
7
|
+
export const apiClientConfig: ClientConfig = {
|
|
8
|
+
baseUrl: '/api/openpeeps/core/v1',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const coreApiClient = (): FetchClient => fetchClient(apiClientConfig);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { FetchClient } from '@openpeepshq/fetch-client';
|
|
2
|
+
import type {
|
|
3
|
+
AccountExport,
|
|
4
|
+
PublicAccount,
|
|
5
|
+
PushSubscription,
|
|
6
|
+
PushSubscriptionData,
|
|
7
|
+
SuccessResponse,
|
|
8
|
+
UpdateAccountPasswordRequest,
|
|
9
|
+
} from '@openpeepshq/common';
|
|
10
|
+
import { allpeepNoPayloadEndpoint, allpeepPayloadEndpoint } from './helpers';
|
|
11
|
+
|
|
12
|
+
export const accounts = (rawClient: FetchClient) => ({
|
|
13
|
+
current: {
|
|
14
|
+
update: allpeepPayloadEndpoint<
|
|
15
|
+
SuccessResponse,
|
|
16
|
+
UpdateAccountPasswordRequest
|
|
17
|
+
>(rawClient, '/accounts/current', 'patch'),
|
|
18
|
+
read: allpeepNoPayloadEndpoint<PublicAccount>(
|
|
19
|
+
rawClient,
|
|
20
|
+
'/accounts/current',
|
|
21
|
+
),
|
|
22
|
+
export: allpeepNoPayloadEndpoint<AccountExport>(
|
|
23
|
+
rawClient,
|
|
24
|
+
'/accounts/current/export',
|
|
25
|
+
),
|
|
26
|
+
createPushSubscription: allpeepPayloadEndpoint<
|
|
27
|
+
PushSubscription,
|
|
28
|
+
PushSubscriptionData
|
|
29
|
+
>(rawClient, '/accounts/current/push-subscriptions'),
|
|
30
|
+
listPushSubscriptions: allpeepNoPayloadEndpoint<PushSubscription[]>(
|
|
31
|
+
rawClient,
|
|
32
|
+
'/accounts/current/push-subscriptions',
|
|
33
|
+
),
|
|
34
|
+
testPushSubscription: allpeepPayloadEndpoint<
|
|
35
|
+
SuccessResponse,
|
|
36
|
+
{ subscriptionKey: string }
|
|
37
|
+
>(rawClient, '/accounts/current/push-subscriptions/test'),
|
|
38
|
+
validationEmail: allpeepNoPayloadEndpoint<SuccessResponse>(
|
|
39
|
+
rawClient,
|
|
40
|
+
'/accounts/current/validation-email',
|
|
41
|
+
'post',
|
|
42
|
+
),
|
|
43
|
+
deletePushSubcription: allpeepNoPayloadEndpoint<
|
|
44
|
+
SuccessResponse,
|
|
45
|
+
{ pushSubscriptionId: string }
|
|
46
|
+
>(
|
|
47
|
+
rawClient,
|
|
48
|
+
'/accounts/current/push-subscriptions/:pushSubscriptionId',
|
|
49
|
+
'delete',
|
|
50
|
+
),
|
|
51
|
+
},
|
|
52
|
+
});
|