@openpeepshq/client 0.1.38 → 0.2.1

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.
Files changed (38) hide show
  1. package/dist/common/authenticated.js +2 -2
  2. package/dist/endpoints/admin.js +2 -2
  3. package/dist/endpoints/conversations.d.ts +13 -39942
  4. package/dist/endpoints/jams.d.ts +1064 -38
  5. package/dist/endpoints/jams.js +1 -1
  6. package/dist/endpoints/posts.js +10 -2
  7. package/dist/endpoints/profiles.d.ts +3153 -75
  8. package/dist/endpoints/search.d.ts +3155 -77
  9. package/dist/endpoints/server.d.ts +1 -0
  10. package/dist/index.js +8 -11
  11. package/package.json +30 -9
  12. package/src/common/authenticated.ts +28 -0
  13. package/src/common/base.ts +11 -0
  14. package/src/endpoints/accounts.ts +52 -0
  15. package/src/endpoints/admin.ts +616 -0
  16. package/src/endpoints/analytics.ts +13 -0
  17. package/src/endpoints/auth.ts +43 -0
  18. package/src/endpoints/conversations.ts +44 -0
  19. package/src/endpoints/groups.ts +69 -0
  20. package/src/endpoints/helpers.ts +91 -0
  21. package/src/endpoints/i18n.ts +14 -0
  22. package/src/endpoints/jams.ts +126 -0
  23. package/src/endpoints/location.ts +10 -0
  24. package/src/endpoints/media.ts +56 -0
  25. package/src/endpoints/payments.ts +34 -0
  26. package/src/endpoints/plugins.ts +25 -0
  27. package/src/endpoints/posts.ts +377 -0
  28. package/src/endpoints/previewLink.ts +10 -0
  29. package/src/endpoints/profiles.ts +167 -0
  30. package/src/endpoints/reports.ts +32 -0
  31. package/src/endpoints/search.ts +34 -0
  32. package/src/endpoints/server.ts +38 -0
  33. package/src/endpoints/sso.ts +35 -0
  34. package/src/endpoints/streaming.ts +29 -0
  35. package/src/endpoints/types.ts +66 -0
  36. package/src/index.ts +88 -0
  37. package/src/types/index.ts +20 -0
  38. package/src/webhooks/index.ts +50 -0
@@ -68,6 +68,7 @@ export declare const server: (rawClient: FetchClient) => {
68
68
  defaultLanguage?: string | undefined;
69
69
  defaultTimeZone?: string | undefined;
70
70
  defaultFeedFormat?: "threaded" | "linear" | undefined;
71
+ indexProfiles?: boolean | undefined;
71
72
  };
72
73
  roles: {
73
74
  onRegistration: {
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
- var _a;
25
- return ({
26
- baseUrl: ((_a = options === null || options === void 0 ? void 0 : options.baseUrl) !== null && _a !== void 0 ? _a : '') + '/api/openpeeps/core/v1',
27
- headers: (options === null || options === void 0 ? void 0 : options.token)
28
- ? {
29
- Authorization: `Bearer ${options.token}`,
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.1.38",
3
+ "version": "0.2.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
+ "sideEffects": false,
6
7
  "dependencies": {
7
8
  "validator": "^13.11.0",
8
- "zod": "^4.4.3",
9
- "@openpeepshq/common": "^0.1.46",
10
- "@openpeepshq/fetch-client": "^0.1.7"
9
+ "@openpeepshq/fetch-client": "^0.2.1",
10
+ "@openpeepshq/common": "^0.3.1"
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
- ".": "./dist/index.js",
16
- "./*": "./dist/*/index.js"
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
- "/dist"
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
+ });