@openpeepshq/client 0.9.0 → 0.11.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.
@@ -8,7 +8,7 @@ export declare const streaming: (rawClient: FetchClient) => {
8
8
  */
9
9
  create: import("@openpeepshq/fetch-client").TypedPayloadEndpoint<{
10
10
  storageId: string;
11
- status: "error" | "processing" | "ready";
11
+ status: "error" | "ready" | "processing";
12
12
  error?: string | undefined;
13
13
  }, {
14
14
  url: string;
@@ -20,7 +20,7 @@ export declare const streaming: (rawClient: FetchClient) => {
20
20
  /** Polls the current status of a previously-created VOD stream. */
21
21
  status: import("@openpeepshq/fetch-client").TypedNoPayloadEndpoint<{
22
22
  storageId: string;
23
- status: "error" | "processing" | "ready";
23
+ status: "error" | "ready" | "processing";
24
24
  error?: string | undefined;
25
25
  }, {
26
26
  success: boolean;
package/dist/index.js CHANGED
@@ -21,7 +21,10 @@ import { payments } from './endpoints/payments.js';
21
21
  import { streaming } from './endpoints/streaming.js';
22
22
  import { webhookHandler } from './webhooks/index.js';
23
23
  const allPeepClientOptionsToClientConfig = (options) => ({
24
- baseUrl: (options?.baseUrl ?? '') + '/api/openpeeps/core/v1',
24
+ // Strip trailing slash(es) from the configured base so composing the API
25
+ // prefix cannot produce a doubled slash (`https://host//api/...`) that
26
+ // 404s against the server's single-slash routes.
27
+ baseUrl: (options?.baseUrl ?? '').replace(/\/+$/, '') + '/api/openpeeps/core/v1',
25
28
  headers: options?.token
26
29
  ? {
27
30
  Authorization: `Bearer ${options.token}`,
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@openpeepshq/client",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "dependencies": {
8
- "@openpeepshq/common": "^0.14.0",
8
+ "@openpeepshq/common": "^0.16.0",
9
9
  "@openpeepshq/fetch-client": "^0.2.1"
10
10
  },
11
11
  "main": "./dist/index.js",
@@ -47,10 +47,12 @@
47
47
  "tsc-alias": "^1.8.10",
48
48
  "typescript": "^6.0.2",
49
49
  "eslint-config-prettier": "^9.1.0",
50
- "@eslint/js": "^9.17.0"
50
+ "@eslint/js": "^9.17.0",
51
+ "vitest": "^4.1.12"
51
52
  },
52
53
  "scripts": {
53
54
  "lint": "eslint .",
55
+ "test": "vitest run",
54
56
  "format": "prettier --write --ignore-path ../../.prettierignore .",
55
57
  "clean": "rm -rf tsconfig.tsbuildinfo dist",
56
58
  "typecheck": "tsc --noEmit",
@@ -1,6 +1,7 @@
1
1
  import type { FetchClient } from '@openpeepshq/fetch-client';
2
2
  import type {
3
- AccountExport,
3
+ AccountExportJob,
4
+ AccountExportStatus,
4
5
  PublicAccount,
5
6
  PushSubscription,
6
7
  PushSubscriptionData,
@@ -19,10 +20,39 @@ export const accounts = (rawClient: FetchClient) => ({
19
20
  rawClient,
20
21
  '/accounts/current',
21
22
  ),
22
- export: allpeepNoPayloadEndpoint<AccountExport>(
23
- rawClient,
24
- '/accounts/current/export',
25
- ),
23
+ /**
24
+ * Personal-data export (GDPR-style). The archive is assembled
25
+ * asynchronously: `start()` enqueues the job and returns the `jobId`,
26
+ * `status(jobId)` is polled until `ready`, and `downloadUrl(token)`
27
+ * yields the one-time URL that streams the zip (auth is the token).
28
+ */
29
+ export: {
30
+ start: allpeepPayloadEndpoint<AccountExportJob, Record<string, never>>(
31
+ rawClient,
32
+ '/accounts/current/export/request',
33
+ 'post',
34
+ ),
35
+ status: allpeepNoPayloadEndpoint<
36
+ AccountExportStatus,
37
+ undefined,
38
+ { jobId: string }
39
+ >(rawClient, '/accounts/current/export/status'),
40
+ /**
41
+ * One-time URL that streams the assembled archive. The token is the
42
+ * credential (single-use, 7-day TTL); no auth header is required.
43
+ * Resolves the client's base URL so it works in web and RN alike.
44
+ *
45
+ * The path is relative to the client base: `rawClient.getConfig()`
46
+ * already returns `<options.baseUrl>/api/openpeeps/core/v1` (set in
47
+ * `index.ts`), so appending the prefix again would double it and 404
48
+ * against the server route `/api/openpeeps/core/v1/.../download`.
49
+ */
50
+ downloadUrl: async (downloadToken: string): Promise<string> => {
51
+ const config = await rawClient.getConfig();
52
+ const base = (config.baseUrl ?? '').replace(/\/$/, '');
53
+ return `${base}/accounts/current/export/download?token=${encodeURIComponent(downloadToken)}`;
54
+ },
55
+ },
26
56
  createPushSubscription: allpeepPayloadEndpoint<
27
57
  PushSubscription,
28
58
  PushSubscriptionData
@@ -22,6 +22,7 @@ import type {
22
22
  ProfileSettings,
23
23
  ProfileSettingsData,
24
24
  PublicAccessToken,
25
+ CalendarFeedTokenResponse,
25
26
  SessionEvent,
26
27
  SessionPlatform,
27
28
  Hashtag,
@@ -93,6 +94,19 @@ export const profiles = (
93
94
  SuccessResponse,
94
95
  { accessTokenId: string }
95
96
  >(rawClient, '/profiles/current/access-tokens/:accessTokenId', 'delete'),
97
+ // `calendarFeed` is a bare resource: POST mints (and revokes the old)
98
+ // token, DELETE revokes all — neither takes or returns a body beyond the
99
+ // typed response.
100
+ calendarFeed: allpeepNoPayloadEndpoint<CalendarFeedTokenResponse>(
101
+ rawClient,
102
+ '/profiles/current/calendar-feed',
103
+ 'post',
104
+ ),
105
+ revokeCalendarFeed: allpeepNoPayloadEndpoint<SuccessResponse>(
106
+ rawClient,
107
+ '/profiles/current/calendar-feed',
108
+ 'delete',
109
+ ),
96
110
  sessionEvents: {
97
111
  listen: eventSource<
98
112
  SessionEvent,
package/src/index.ts CHANGED
@@ -34,7 +34,11 @@ export interface OpenpeepsClientOptions {
34
34
  const allPeepClientOptionsToClientConfig = (
35
35
  options?: OpenpeepsClientOptions,
36
36
  ): ClientConfig => ({
37
- baseUrl: (options?.baseUrl ?? '') + '/api/openpeeps/core/v1',
37
+ // Strip trailing slash(es) from the configured base so composing the API
38
+ // prefix cannot produce a doubled slash (`https://host//api/...`) that
39
+ // 404s against the server's single-slash routes.
40
+ baseUrl:
41
+ (options?.baseUrl ?? '').replace(/\/+$/, '') + '/api/openpeeps/core/v1',
38
42
  headers: options?.token
39
43
  ? {
40
44
  Authorization: `Bearer ${options.token}`,