@ustriveneo/partner-sdk 1.0.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/README.md ADDED
@@ -0,0 +1,253 @@
1
+ # @ustriveneo/partner-sdk
2
+
3
+ TypeScript SDK for the UStrive Partner API. Enables partners to integrate UStrive's mentorship platform into their applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @ustriveneo/partner-sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { UStrivePartnerClient } from '@ustriveneo/partner-sdk';
15
+
16
+ const client = new UStrivePartnerClient({
17
+ apiKey: 'pk_live_xxx',
18
+ secret: 'sk_live_yyy',
19
+ });
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ### Create a Student
25
+
26
+ ```typescript
27
+ const user = await client.users.create({
28
+ firstName: 'Jane',
29
+ lastName: 'Doe',
30
+ email: 'jane@example.com',
31
+ userType: 'STUDENT',
32
+ });
33
+ ```
34
+
35
+ ### Search Mentors
36
+
37
+ ```typescript
38
+ const { mentors } = await client.mentors.search({
39
+ q: 'college applications',
40
+ limit: 10,
41
+ });
42
+ ```
43
+
44
+ ### Get Mentor Profile
45
+
46
+ ```typescript
47
+ const mentor = await client.mentors.get('mentor-id');
48
+ ```
49
+
50
+ ### Create a Match
51
+
52
+ ```typescript
53
+ const match = await client.matches.create({
54
+ studentId: 'student-id',
55
+ mentorId: 'mentor-id',
56
+ message: 'Looking forward to working together!',
57
+ });
58
+ ```
59
+
60
+ ### Schedule a Session
61
+
62
+ ```typescript
63
+ const session = await client.sessions.create({
64
+ matchId: 'match-id',
65
+ startTime: '2026-03-01T14:00:00Z',
66
+ endTime: '2026-03-01T15:00:00Z',
67
+ type: 'VIDEO',
68
+ timezone: { value: 'America/New_York', label: 'Eastern Time' },
69
+ });
70
+ ```
71
+
72
+ ### End a Match
73
+
74
+ ```typescript
75
+ await client.matches.end('match-id', {
76
+ satisfactionRating: 5,
77
+ feedback: 'Great experience!',
78
+ });
79
+ ```
80
+
81
+ ### List User's Matches
82
+
83
+ ```typescript
84
+ const { matches } = await client.matches.listByUser('user-id', {
85
+ status: 'ACTIVE',
86
+ });
87
+ ```
88
+
89
+ ### List User's Sessions
90
+
91
+ ```typescript
92
+ const { sessions } = await client.sessions.listByUser('user-id');
93
+ ```
94
+
95
+ ## External Identity & Cognito Integration
96
+
97
+ The SDK supports linking external user identities (e.g., Cognito `sub`) to UStrive users. This is useful when your application manages its own authentication via Cognito or another identity provider.
98
+
99
+ ### Sync User (Cognito Post Authentication Trigger)
100
+
101
+ The `sync` method is idempotent and designed to be called on every authentication event. It creates a new user if no match is found, or updates the existing linked user.
102
+
103
+ ```typescript
104
+ // In your Cognito Post Authentication Lambda trigger:
105
+ import { UStrivePartnerClient } from '@ustriveneo/partner-sdk';
106
+
107
+ const client = new UStrivePartnerClient({
108
+ apiKey: process.env.USTRIVE_API_KEY!,
109
+ secret: process.env.USTRIVE_SECRET!,
110
+ });
111
+
112
+ export const handler = async (event: any) => {
113
+ const { sub, email, given_name, family_name } = event.request.userAttributes;
114
+
115
+ const result = await client.users.sync({
116
+ externalId: sub,
117
+ firstName: given_name,
118
+ lastName: family_name,
119
+ email: email,
120
+ userType: 'STUDENT',
121
+ });
122
+
123
+ if (result.created) {
124
+ console.log('New UStrive user created:', result.id);
125
+ } else {
126
+ console.log('Existing UStrive user synced:', result.id);
127
+ }
128
+
129
+ return event;
130
+ };
131
+ ```
132
+
133
+ ### Look Up User by External ID
134
+
135
+ ```typescript
136
+ const user = await client.users.getByExternalId('cognito-sub-value');
137
+ console.log('UStrive user ID:', user.id);
138
+ ```
139
+
140
+ ### Create User with External ID
141
+
142
+ You can also provide an `externalId` when creating a user directly:
143
+
144
+ ```typescript
145
+ const user = await client.users.create({
146
+ firstName: 'Jane',
147
+ lastName: 'Doe',
148
+ email: 'jane@example.com',
149
+ userType: 'STUDENT',
150
+ externalId: 'cognito-sub-12345',
151
+ });
152
+ ```
153
+
154
+ ## Messaging
155
+
156
+ The SDK provides server-side messaging capabilities for match chat channels.
157
+
158
+ ### Get Stream Token
159
+
160
+ Generate a client-side token for a user to connect to real-time chat/video:
161
+
162
+ ```typescript
163
+ const { token, apiKey } = await client.messaging.getStreamToken('user-id');
164
+ // Pass token + apiKey to @ustriveneo/partner-realtime on the client
165
+ ```
166
+
167
+ ### Send a Message
168
+
169
+ ```typescript
170
+ const message = await client.messaging.sendMessage('match-id', {
171
+ userId: 'student-id',
172
+ text: 'Hello mentor!',
173
+ });
174
+ ```
175
+
176
+ ### Get Message History
177
+
178
+ ```typescript
179
+ const { messages } = await client.messaging.getMessages('match-id', {
180
+ limit: 50,
181
+ offset: 0,
182
+ });
183
+ ```
184
+
185
+ ## Calls (Video & Audio)
186
+
187
+ ### Create a Call
188
+
189
+ ```typescript
190
+ const call = await client.calls.create('match-id');
191
+ // Returns: { callId, type, createdAt }
192
+ ```
193
+
194
+ ### List Calls
195
+
196
+ ```typescript
197
+ const { calls } = await client.calls.list('match-id');
198
+ ```
199
+
200
+ ## Error Handling
201
+
202
+ ```typescript
203
+ import { UStriveError, RateLimitError, NotFoundError } from '@ustriveneo/partner-sdk';
204
+
205
+ try {
206
+ const user = await client.users.get('non-existent-id');
207
+ } catch (error) {
208
+ if (error instanceof NotFoundError) {
209
+ console.log('User not found');
210
+ } else if (error instanceof RateLimitError) {
211
+ console.log(`Rate limited. Retry after ${error.retryAfter} seconds`);
212
+ } else if (error instanceof UStriveError) {
213
+ console.log(`API error: ${error.message} (${error.statusCode})`);
214
+ }
215
+ }
216
+ ```
217
+
218
+ ## Configuration
219
+
220
+ ```typescript
221
+ const client = new UStrivePartnerClient({
222
+ apiKey: 'pk_test_xxx', // Your public API key
223
+ secret: 'sk_test_yyy', // Your secret key
224
+ baseUrl: 'https://partner-api-dev.ustriveneo.com', // Optional: override for dev/staging
225
+ });
226
+ ```
227
+
228
+ ## Authentication
229
+
230
+ The SDK handles authentication automatically. On the first request, it exchanges your API key and secret for a JWT token (valid for 1 hour). Tokens are refreshed automatically when they expire.
231
+
232
+ ## Webhooks
233
+
234
+ To receive real-time events (match created, session scheduled, etc.), configure a webhook URL when your partner account is created. Events are delivered as POST requests with an `X-UStrive-Signature` header for verification.
235
+
236
+ ### Verifying Webhook Signatures
237
+
238
+ ```typescript
239
+ import crypto from 'crypto';
240
+
241
+ function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean {
242
+ const [tsPart, sigPart] = signature.split(',');
243
+ const timestamp = tsPart.replace('t=', '');
244
+ const expectedSig = sigPart.replace('v1=', '');
245
+
246
+ const computed = crypto
247
+ .createHmac('sha256', secret)
248
+ .update(`${timestamp}.${payload}`)
249
+ .digest('hex');
250
+
251
+ return crypto.timingSafeEqual(Buffer.from(computed), Buffer.from(expectedSig));
252
+ }
253
+ ```
@@ -0,0 +1,31 @@
1
+ import { ClientConfig } from './types';
2
+ import { UsersResource } from './resources/users';
3
+ import { MentorsResource } from './resources/mentors';
4
+ import { MatchesResource } from './resources/matches';
5
+ import { SessionsResource } from './resources/sessions';
6
+ import { MessagingResource } from './resources/messaging';
7
+ import { CallsResource } from './resources/calls';
8
+ export declare class UStrivePartnerClient {
9
+ private apiKey;
10
+ private secret;
11
+ private baseUrl;
12
+ private authToken;
13
+ users: UsersResource;
14
+ mentors: MentorsResource;
15
+ matches: MatchesResource;
16
+ sessions: SessionsResource;
17
+ messaging: MessagingResource;
18
+ calls: CallsResource;
19
+ constructor(config: ClientConfig);
20
+ /**
21
+ * Makes an authenticated HTTP request to the Partner API.
22
+ * Automatically handles token exchange and refresh.
23
+ */
24
+ request<T = any>(method: string, path: string, options?: {
25
+ body?: any;
26
+ query?: Record<string, string | number | undefined>;
27
+ }): Promise<T>;
28
+ private ensureAuthenticated;
29
+ private buildUrl;
30
+ private handleResponse;
31
+ }
package/dist/client.js ADDED
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UStrivePartnerClient = void 0;
4
+ const errors_1 = require("./errors");
5
+ const users_1 = require("./resources/users");
6
+ const mentors_1 = require("./resources/mentors");
7
+ const matches_1 = require("./resources/matches");
8
+ const sessions_1 = require("./resources/sessions");
9
+ const messaging_1 = require("./resources/messaging");
10
+ const calls_1 = require("./resources/calls");
11
+ const DEFAULT_BASE_URL = 'https://partner-api-prod.myustrive.com';
12
+ class UStrivePartnerClient {
13
+ constructor(config) {
14
+ this.authToken = null;
15
+ if (!config.apiKey)
16
+ throw new Error('apiKey is required');
17
+ if (!config.secret)
18
+ throw new Error('secret is required');
19
+ this.apiKey = config.apiKey;
20
+ this.secret = config.secret;
21
+ this.baseUrl = (config.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, '');
22
+ this.users = new users_1.UsersResource(this);
23
+ this.mentors = new mentors_1.MentorsResource(this);
24
+ this.matches = new matches_1.MatchesResource(this);
25
+ this.sessions = new sessions_1.SessionsResource(this);
26
+ this.messaging = new messaging_1.MessagingResource(this);
27
+ this.calls = new calls_1.CallsResource(this);
28
+ }
29
+ /**
30
+ * Makes an authenticated HTTP request to the Partner API.
31
+ * Automatically handles token exchange and refresh.
32
+ */
33
+ async request(method, path, options) {
34
+ await this.ensureAuthenticated();
35
+ const url = this.buildUrl(path, options?.query);
36
+ const response = await fetch(url, {
37
+ method,
38
+ headers: {
39
+ 'Content-Type': 'application/json',
40
+ Authorization: `Bearer ${this.authToken.token}`,
41
+ },
42
+ body: options?.body ? JSON.stringify(options.body) : undefined,
43
+ });
44
+ // If token expired, refresh and retry once
45
+ if (response.status === 401) {
46
+ this.authToken = null;
47
+ await this.ensureAuthenticated();
48
+ const retryResponse = await fetch(url, {
49
+ method,
50
+ headers: {
51
+ 'Content-Type': 'application/json',
52
+ Authorization: `Bearer ${this.authToken.token}`,
53
+ },
54
+ body: options?.body ? JSON.stringify(options.body) : undefined,
55
+ });
56
+ return this.handleResponse(retryResponse);
57
+ }
58
+ return this.handleResponse(response);
59
+ }
60
+ async ensureAuthenticated() {
61
+ if (this.authToken && this.authToken.expiresAt > Date.now() + 60000) {
62
+ return; // Token still valid (with 1 minute buffer)
63
+ }
64
+ const response = await fetch(`${this.baseUrl}/partner/v1/auth/token`, {
65
+ method: 'POST',
66
+ headers: { 'Content-Type': 'application/json' },
67
+ body: JSON.stringify({ apiKey: this.apiKey, secret: this.secret }),
68
+ });
69
+ if (!response.ok) {
70
+ const body = await response.json().catch(() => ({}));
71
+ throw new errors_1.AuthenticationError(body.error || 'Failed to authenticate', body);
72
+ }
73
+ const data = await response.json();
74
+ this.authToken = {
75
+ token: data.token,
76
+ expiresIn: data.expiresIn,
77
+ partnerId: data.partnerId,
78
+ expiresAt: Date.now() + data.expiresIn * 1000,
79
+ };
80
+ }
81
+ buildUrl(path, query) {
82
+ const url = new URL(`${this.baseUrl}${path}`);
83
+ if (query) {
84
+ for (const [key, value] of Object.entries(query)) {
85
+ if (value !== undefined) {
86
+ url.searchParams.set(key, String(value));
87
+ }
88
+ }
89
+ }
90
+ return url.toString();
91
+ }
92
+ async handleResponse(response) {
93
+ const body = await response.json().catch(() => ({}));
94
+ if (response.ok) {
95
+ return body;
96
+ }
97
+ const message = body.error || `API error: ${response.status}`;
98
+ switch (response.status) {
99
+ case 401:
100
+ throw new errors_1.AuthenticationError(message, body);
101
+ case 403:
102
+ throw new errors_1.ForbiddenError(message, body);
103
+ case 404:
104
+ throw new errors_1.NotFoundError(message, body);
105
+ case 409:
106
+ throw new errors_1.ConflictError(message, body);
107
+ case 422:
108
+ throw new errors_1.ValidationError(message, body);
109
+ case 429:
110
+ throw new errors_1.RateLimitError(message, response.headers.get('Retry-After')
111
+ ? Number(response.headers.get('Retry-After'))
112
+ : undefined, body);
113
+ default:
114
+ throw new errors_1.UStriveError(message, response.status, body);
115
+ }
116
+ }
117
+ }
118
+ exports.UStrivePartnerClient = UStrivePartnerClient;
119
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names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+1,24 @@
1
+ export declare class UStriveError extends Error {
2
+ statusCode: number;
3
+ responseBody: any;
4
+ constructor(message: string, statusCode: number, responseBody?: any);
5
+ }
6
+ export declare class AuthenticationError extends UStriveError {
7
+ constructor(message?: string, responseBody?: any);
8
+ }
9
+ export declare class ForbiddenError extends UStriveError {
10
+ constructor(message?: string, responseBody?: any);
11
+ }
12
+ export declare class NotFoundError extends UStriveError {
13
+ constructor(message?: string, responseBody?: any);
14
+ }
15
+ export declare class ConflictError extends UStriveError {
16
+ constructor(message?: string, responseBody?: any);
17
+ }
18
+ export declare class ValidationError extends UStriveError {
19
+ constructor(message?: string, responseBody?: any);
20
+ }
21
+ export declare class RateLimitError extends UStriveError {
22
+ retryAfter?: number;
23
+ constructor(message?: string, retryAfter?: number, responseBody?: any);
24
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RateLimitError = exports.ValidationError = exports.ConflictError = exports.NotFoundError = exports.ForbiddenError = exports.AuthenticationError = exports.UStriveError = void 0;
4
+ class UStriveError extends Error {
5
+ constructor(message, statusCode, responseBody) {
6
+ super(message);
7
+ this.name = 'UStriveError';
8
+ this.statusCode = statusCode;
9
+ this.responseBody = responseBody;
10
+ }
11
+ }
12
+ exports.UStriveError = UStriveError;
13
+ class AuthenticationError extends UStriveError {
14
+ constructor(message = 'Authentication failed', responseBody) {
15
+ super(message, 401, responseBody);
16
+ this.name = 'AuthenticationError';
17
+ }
18
+ }
19
+ exports.AuthenticationError = AuthenticationError;
20
+ class ForbiddenError extends UStriveError {
21
+ constructor(message = 'Access denied', responseBody) {
22
+ super(message, 403, responseBody);
23
+ this.name = 'ForbiddenError';
24
+ }
25
+ }
26
+ exports.ForbiddenError = ForbiddenError;
27
+ class NotFoundError extends UStriveError {
28
+ constructor(message = 'Resource not found', responseBody) {
29
+ super(message, 404, responseBody);
30
+ this.name = 'NotFoundError';
31
+ }
32
+ }
33
+ exports.NotFoundError = NotFoundError;
34
+ class ConflictError extends UStriveError {
35
+ constructor(message = 'Resource conflict', responseBody) {
36
+ super(message, 409, responseBody);
37
+ this.name = 'ConflictError';
38
+ }
39
+ }
40
+ exports.ConflictError = ConflictError;
41
+ class ValidationError extends UStriveError {
42
+ constructor(message = 'Validation failed', responseBody) {
43
+ super(message, 422, responseBody);
44
+ this.name = 'ValidationError';
45
+ }
46
+ }
47
+ exports.ValidationError = ValidationError;
48
+ class RateLimitError extends UStriveError {
49
+ constructor(message = 'Rate limit exceeded', retryAfter, responseBody) {
50
+ super(message, 429, responseBody);
51
+ this.name = 'RateLimitError';
52
+ this.retryAfter = retryAfter;
53
+ }
54
+ }
55
+ exports.RateLimitError = RateLimitError;
56
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAa,SAAQ,KAAK;IAIrC,YAAY,OAAe,EAAE,UAAkB,EAAE,YAAkB;QACjE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF;AAVD,oCAUC;AAED,MAAa,mBAAoB,SAAQ,YAAY;IACnD,YAAY,UAAkB,uBAAuB,EAAE,YAAkB;QACvE,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AALD,kDAKC;AAED,MAAa,cAAe,SAAQ,YAAY;IAC9C,YAAY,UAAkB,eAAe,EAAE,YAAkB;QAC/D,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AALD,wCAKC;AAED,MAAa,aAAc,SAAQ,YAAY;IAC7C,YAAY,UAAkB,oBAAoB,EAAE,YAAkB;QACpE,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AALD,sCAKC;AAED,MAAa,aAAc,SAAQ,YAAY;IAC7C,YAAY,UAAkB,mBAAmB,EAAE,YAAkB;QACnE,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AALD,sCAKC;AAED,MAAa,eAAgB,SAAQ,YAAY;IAC/C,YAAY,UAAkB,mBAAmB,EAAE,YAAkB;QACnE,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AALD,0CAKC;AAED,MAAa,cAAe,SAAQ,YAAY;IAG9C,YAAY,UAAkB,qBAAqB,EAAE,UAAmB,EAAE,YAAkB;QAC1F,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AARD,wCAQC"}
@@ -0,0 +1,3 @@
1
+ export { UStrivePartnerClient } from './client';
2
+ export { UStriveError, AuthenticationError, ForbiddenError, NotFoundError, ConflictError, ValidationError, RateLimitError, } from './errors';
3
+ export type { ClientConfig, UserType, MatchStatus, SessionType, SessionStatus, Timezone, CreateUserInput, UpdateUserInput, User, CreateUserResponse, SyncUserInput, SyncUserResponse, ExternalUserResponse, MentorSearchParams, Mentor, MentorSearchResponse, CreateMatchInput, EndMatchInput, Match, MatchListResponse, EndMatchResponse, CreateSessionInput, Session, SessionListResponse, StreamTokenResponse, Message, MessageAttachment, SendMessageInput, MessageListParams, MessageListResponse, CreateCallInput, CallInfo, CallListResponse, } from './types';
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RateLimitError = exports.ValidationError = exports.ConflictError = exports.NotFoundError = exports.ForbiddenError = exports.AuthenticationError = exports.UStriveError = exports.UStrivePartnerClient = void 0;
4
+ var client_1 = require("./client");
5
+ Object.defineProperty(exports, "UStrivePartnerClient", { enumerable: true, get: function () { return client_1.UStrivePartnerClient; } });
6
+ var errors_1 = require("./errors");
7
+ Object.defineProperty(exports, "UStriveError", { enumerable: true, get: function () { return errors_1.UStriveError; } });
8
+ Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return errors_1.AuthenticationError; } });
9
+ Object.defineProperty(exports, "ForbiddenError", { enumerable: true, get: function () { return errors_1.ForbiddenError; } });
10
+ Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return errors_1.NotFoundError; } });
11
+ Object.defineProperty(exports, "ConflictError", { enumerable: true, get: function () { return errors_1.ConflictError; } });
12
+ Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return errors_1.ValidationError; } });
13
+ Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_1.RateLimitError; } });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAgD;AAAvC,8GAAA,oBAAoB,OAAA;AAC7B,mCAQkB;AAPhB,sGAAA,YAAY,OAAA;AACZ,6GAAA,mBAAmB,OAAA;AACnB,wGAAA,cAAc,OAAA;AACd,uGAAA,aAAa,OAAA;AACb,uGAAA,aAAa,OAAA;AACb,yGAAA,eAAe,OAAA;AACf,wGAAA,cAAc,OAAA"}
@@ -0,0 +1,16 @@
1
+ import type { UStrivePartnerClient } from '../client';
2
+ import type { CreateCallInput, CallInfo, CallListResponse } from '../types';
3
+ export declare class CallsResource {
4
+ private client;
5
+ constructor(client: UStrivePartnerClient);
6
+ /**
7
+ * Create a video/audio call for a match.
8
+ * Call type 'default' supports both video and audio — the user's device
9
+ * chooses camera on/off at join time.
10
+ */
11
+ create(matchId: string, _input?: CreateCallInput): Promise<CallInfo>;
12
+ /**
13
+ * List call sessions for a match.
14
+ */
15
+ list(matchId: string): Promise<CallListResponse>;
16
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CallsResource = void 0;
4
+ class CallsResource {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Create a video/audio call for a match.
10
+ * Call type 'default' supports both video and audio — the user's device
11
+ * chooses camera on/off at join time.
12
+ */
13
+ async create(matchId, _input) {
14
+ return this.client.request('POST', `/partner/v1/matches/${matchId}/calls`);
15
+ }
16
+ /**
17
+ * List call sessions for a match.
18
+ */
19
+ async list(matchId) {
20
+ return this.client.request('GET', `/partner/v1/matches/${matchId}/calls`);
21
+ }
22
+ }
23
+ exports.CallsResource = CallsResource;
24
+ //# sourceMappingURL=calls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calls.js","sourceRoot":"","sources":["../../src/resources/calls.ts"],"names":[],"mappings":";;;AAOA,MAAa,aAAa;IACxB,YAAoB,MAA4B;QAA5B,WAAM,GAAN,MAAM,CAAsB;IAAG,CAAC;IAEpD;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,MAAwB;QACpD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,MAAM,EACN,uBAAuB,OAAO,QAAQ,CACvC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,OAAe;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,KAAK,EACL,uBAAuB,OAAO,QAAQ,CACvC,CAAC;IACJ,CAAC;CACF;AAxBD,sCAwBC"}
@@ -0,0 +1,25 @@
1
+ import type { UStrivePartnerClient } from '../client';
2
+ import type { CreateMatchInput, Match, EndMatchInput, EndMatchResponse, MatchListResponse } from '../types';
3
+ export declare class MatchesResource {
4
+ private client;
5
+ constructor(client: UStrivePartnerClient);
6
+ /**
7
+ * Request a match between a student and mentor.
8
+ */
9
+ create(input: CreateMatchInput): Promise<Match>;
10
+ /**
11
+ * Get match details by ID.
12
+ */
13
+ get(matchId: string): Promise<Match>;
14
+ /**
15
+ * End a match (unmatch).
16
+ */
17
+ end(matchId: string, input?: EndMatchInput): Promise<EndMatchResponse>;
18
+ /**
19
+ * List all matches for a user.
20
+ */
21
+ listByUser(userId: string, params?: {
22
+ status?: string;
23
+ limit?: number;
24
+ }): Promise<MatchListResponse>;
25
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MatchesResource = void 0;
4
+ class MatchesResource {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Request a match between a student and mentor.
10
+ */
11
+ async create(input) {
12
+ return this.client.request('POST', '/partner/v1/matches', {
13
+ body: input,
14
+ });
15
+ }
16
+ /**
17
+ * Get match details by ID.
18
+ */
19
+ async get(matchId) {
20
+ return this.client.request('GET', `/partner/v1/matches/${matchId}`);
21
+ }
22
+ /**
23
+ * End a match (unmatch).
24
+ */
25
+ async end(matchId, input) {
26
+ return this.client.request('DELETE', `/partner/v1/matches/${matchId}`, {
27
+ body: input,
28
+ });
29
+ }
30
+ /**
31
+ * List all matches for a user.
32
+ */
33
+ async listByUser(userId, params) {
34
+ return this.client.request('GET', `/partner/v1/users/${userId}/matches`, { query: { status: params?.status, limit: params?.limit } });
35
+ }
36
+ }
37
+ exports.MatchesResource = MatchesResource;
38
+ //# sourceMappingURL=matches.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matches.js","sourceRoot":"","sources":["../../src/resources/matches.ts"],"names":[],"mappings":";;;AASA,MAAa,eAAe;IAC1B,YAAoB,MAA4B;QAA5B,WAAM,GAAN,MAAM,CAAsB;IAAG,CAAC;IAEpD;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,KAAuB;QAClC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAQ,MAAM,EAAE,qBAAqB,EAAE;YAC/D,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,OAAe;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAQ,KAAK,EAAE,uBAAuB,OAAO,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,OAAe,EAAE,KAAqB;QAC9C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAmB,QAAQ,EAAE,uBAAuB,OAAO,EAAE,EAAE;YACvF,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CACd,MAAc,EACd,MAA4C;QAE5C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,KAAK,EACL,qBAAqB,MAAM,UAAU,EACrC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAC5D,CAAC;IACJ,CAAC;CACF;AAzCD,0CAyCC"}
@@ -0,0 +1,14 @@
1
+ import type { UStrivePartnerClient } from '../client';
2
+ import type { Mentor, MentorSearchParams, MentorSearchResponse } from '../types';
3
+ export declare class MentorsResource {
4
+ private client;
5
+ constructor(client: UStrivePartnerClient);
6
+ /**
7
+ * Search mentors available in the partner's branch.
8
+ */
9
+ search(params?: MentorSearchParams): Promise<MentorSearchResponse>;
10
+ /**
11
+ * Get a mentor's profile by ID (sanitized).
12
+ */
13
+ get(mentorId: string): Promise<Mentor>;
14
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MentorsResource = void 0;
4
+ class MentorsResource {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Search mentors available in the partner's branch.
10
+ */
11
+ async search(params) {
12
+ return this.client.request('GET', '/partner/v1/mentors/search', {
13
+ query: {
14
+ q: params?.q,
15
+ limit: params?.limit,
16
+ offset: params?.offset,
17
+ },
18
+ });
19
+ }
20
+ /**
21
+ * Get a mentor's profile by ID (sanitized).
22
+ */
23
+ async get(mentorId) {
24
+ return this.client.request('GET', `/partner/v1/mentors/${mentorId}`);
25
+ }
26
+ }
27
+ exports.MentorsResource = MentorsResource;
28
+ //# sourceMappingURL=mentors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mentors.js","sourceRoot":"","sources":["../../src/resources/mentors.ts"],"names":[],"mappings":";;;AAGA,MAAa,eAAe;IAC1B,YAAoB,MAA4B;QAA5B,WAAM,GAAN,MAAM,CAAsB;IAAG,CAAC;IAEpD;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,MAA2B;QACtC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAuB,KAAK,EAAE,4BAA4B,EAAE;YACpF,KAAK,EAAE;gBACL,CAAC,EAAE,MAAM,EAAE,CAAC;gBACZ,KAAK,EAAE,MAAM,EAAE,KAAK;gBACpB,MAAM,EAAE,MAAM,EAAE,MAAM;aACvB;SACF,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,QAAgB;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAS,KAAK,EAAE,uBAAuB,QAAQ,EAAE,CAAC,CAAC;IAC/E,CAAC;CACF;AAtBD,0CAsBC"}
@@ -0,0 +1,20 @@
1
+ import type { UStrivePartnerClient } from '../client';
2
+ import type { StreamTokenResponse, Message, SendMessageInput, MessageListParams, MessageListResponse } from '../types';
3
+ export declare class MessagingResource {
4
+ private client;
5
+ constructor(client: UStrivePartnerClient);
6
+ /**
7
+ * Generate a Stream token for a user.
8
+ * Returns the token and the public API key needed to initialize Stream clients.
9
+ */
10
+ getStreamToken(userId: string): Promise<StreamTokenResponse>;
11
+ /**
12
+ * Get message history for a match's chat channel.
13
+ */
14
+ getMessages(matchId: string, params?: MessageListParams): Promise<MessageListResponse>;
15
+ /**
16
+ * Send a message to a match's chat channel on behalf of a user.
17
+ * The userId must be either the studentId or mentorId of the match.
18
+ */
19
+ sendMessage(matchId: string, input: SendMessageInput): Promise<Message>;
20
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessagingResource = void 0;
4
+ class MessagingResource {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Generate a Stream token for a user.
10
+ * Returns the token and the public API key needed to initialize Stream clients.
11
+ */
12
+ async getStreamToken(userId) {
13
+ return this.client.request('POST', `/partner/v1/users/${userId}/stream-token`);
14
+ }
15
+ /**
16
+ * Get message history for a match's chat channel.
17
+ */
18
+ async getMessages(matchId, params) {
19
+ return this.client.request('GET', `/partner/v1/matches/${matchId}/messages`, { query: { limit: params?.limit, offset: params?.offset } });
20
+ }
21
+ /**
22
+ * Send a message to a match's chat channel on behalf of a user.
23
+ * The userId must be either the studentId or mentorId of the match.
24
+ */
25
+ async sendMessage(matchId, input) {
26
+ return this.client.request('POST', `/partner/v1/matches/${matchId}/messages`, { body: input });
27
+ }
28
+ }
29
+ exports.MessagingResource = MessagingResource;
30
+ //# sourceMappingURL=messaging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messaging.js","sourceRoot":"","sources":["../../src/resources/messaging.ts"],"names":[],"mappings":";;;AASA,MAAa,iBAAiB;IAC5B,YAAoB,MAA4B;QAA5B,WAAM,GAAN,MAAM,CAAsB;IAAG,CAAC;IAEpD;;;OAGG;IACH,KAAK,CAAC,cAAc,CAAC,MAAc;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,MAAM,EACN,qBAAqB,MAAM,eAAe,CAC3C,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,OAAe,EAAE,MAA0B;QAC3D,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,KAAK,EACL,uBAAuB,OAAO,WAAW,EACzC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAC5D,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW,CAAC,OAAe,EAAE,KAAuB;QACxD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,MAAM,EACN,uBAAuB,OAAO,WAAW,EACzC,EAAE,IAAI,EAAE,KAAK,EAAE,CAChB,CAAC;IACJ,CAAC;CACF;AApCD,8CAoCC"}
@@ -0,0 +1,21 @@
1
+ import type { UStrivePartnerClient } from '../client';
2
+ import type { CreateSessionInput, Session, SessionListResponse } from '../types';
3
+ export declare class SessionsResource {
4
+ private client;
5
+ constructor(client: UStrivePartnerClient);
6
+ /**
7
+ * Schedule a new session for a match.
8
+ */
9
+ create(input: CreateSessionInput): Promise<Session>;
10
+ /**
11
+ * Get session details by ID.
12
+ */
13
+ get(sessionId: string): Promise<Session>;
14
+ /**
15
+ * List all sessions for a user.
16
+ */
17
+ listByUser(userId: string, params?: {
18
+ status?: string;
19
+ limit?: number;
20
+ }): Promise<SessionListResponse>;
21
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SessionsResource = void 0;
4
+ class SessionsResource {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Schedule a new session for a match.
10
+ */
11
+ async create(input) {
12
+ return this.client.request('POST', '/partner/v1/sessions', {
13
+ body: input,
14
+ });
15
+ }
16
+ /**
17
+ * Get session details by ID.
18
+ */
19
+ async get(sessionId) {
20
+ return this.client.request('GET', `/partner/v1/sessions/${sessionId}`);
21
+ }
22
+ /**
23
+ * List all sessions for a user.
24
+ */
25
+ async listByUser(userId, params) {
26
+ return this.client.request('GET', `/partner/v1/users/${userId}/sessions`, { query: { status: params?.status, limit: params?.limit } });
27
+ }
28
+ }
29
+ exports.SessionsResource = SessionsResource;
30
+ //# sourceMappingURL=sessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../src/resources/sessions.ts"],"names":[],"mappings":";;;AAGA,MAAa,gBAAgB;IAC3B,YAAoB,MAA4B;QAA5B,WAAM,GAAN,MAAM,CAAsB;IAAG,CAAC;IAEpD;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,KAAyB;QACpC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAU,MAAM,EAAE,sBAAsB,EAAE;YAClE,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,SAAiB;QACzB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAU,KAAK,EAAE,wBAAwB,SAAS,EAAE,CAAC,CAAC;IAClF,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CACd,MAAc,EACd,MAA4C;QAE5C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,KAAK,EACL,qBAAqB,MAAM,WAAW,EACtC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAC5D,CAAC;IACJ,CAAC;CACF;AAhCD,4CAgCC"}
@@ -0,0 +1,29 @@
1
+ import type { UStrivePartnerClient } from '../client';
2
+ import type { CreateUserInput, CreateUserResponse, User, UpdateUserInput, SyncUserInput, SyncUserResponse, ExternalUserResponse } from '../types';
3
+ export declare class UsersResource {
4
+ private client;
5
+ constructor(client: UStrivePartnerClient);
6
+ /**
7
+ * Create a new user in the partner's branch.
8
+ * Optionally provide an externalId to link the user to an external identity.
9
+ */
10
+ create(input: CreateUserInput): Promise<CreateUserResponse>;
11
+ /**
12
+ * Get a user by ID (sanitized - no PII).
13
+ */
14
+ get(userId: string): Promise<User>;
15
+ /**
16
+ * Update a user's profile.
17
+ */
18
+ update(userId: string, input: UpdateUserInput): Promise<User>;
19
+ /**
20
+ * Sync a user by external ID (idempotent).
21
+ * Designed for Cognito Post Authentication triggers - safe to call on every auth event.
22
+ * Creates a new user if no match is found, or updates the existing linked user.
23
+ */
24
+ sync(input: SyncUserInput): Promise<SyncUserResponse>;
25
+ /**
26
+ * Look up a user by their external ID (e.g., Cognito sub).
27
+ */
28
+ getByExternalId(externalId: string): Promise<ExternalUserResponse>;
29
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UsersResource = void 0;
4
+ class UsersResource {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Create a new user in the partner's branch.
10
+ * Optionally provide an externalId to link the user to an external identity.
11
+ */
12
+ async create(input) {
13
+ return this.client.request('POST', '/partner/v1/users', {
14
+ body: input,
15
+ });
16
+ }
17
+ /**
18
+ * Get a user by ID (sanitized - no PII).
19
+ */
20
+ async get(userId) {
21
+ return this.client.request('GET', `/partner/v1/users/${userId}`);
22
+ }
23
+ /**
24
+ * Update a user's profile.
25
+ */
26
+ async update(userId, input) {
27
+ return this.client.request('PUT', `/partner/v1/users/${userId}`, {
28
+ body: input,
29
+ });
30
+ }
31
+ /**
32
+ * Sync a user by external ID (idempotent).
33
+ * Designed for Cognito Post Authentication triggers - safe to call on every auth event.
34
+ * Creates a new user if no match is found, or updates the existing linked user.
35
+ */
36
+ async sync(input) {
37
+ return this.client.request('POST', '/partner/v1/users/sync', {
38
+ body: input,
39
+ });
40
+ }
41
+ /**
42
+ * Look up a user by their external ID (e.g., Cognito sub).
43
+ */
44
+ async getByExternalId(externalId) {
45
+ return this.client.request('GET', `/partner/v1/users/external/${encodeURIComponent(externalId)}`);
46
+ }
47
+ }
48
+ exports.UsersResource = UsersResource;
49
+ //# sourceMappingURL=users.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.js","sourceRoot":"","sources":["../../src/resources/users.ts"],"names":[],"mappings":";;;AAWA,MAAa,aAAa;IACxB,YAAoB,MAA4B;QAA5B,WAAM,GAAN,MAAM,CAAsB;IAAG,CAAC;IAEpD;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,KAAsB;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAqB,MAAM,EAAE,mBAAmB,EAAE;YAC1E,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,MAAc;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAO,KAAK,EAAE,qBAAqB,MAAM,EAAE,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,KAAsB;QACjD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAO,KAAK,EAAE,qBAAqB,MAAM,EAAE,EAAE;YACrE,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,KAAoB;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAmB,MAAM,EAAE,wBAAwB,EAAE;YAC7E,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe,CAAC,UAAkB;QACtC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,KAAK,EACL,8BAA8B,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAC/D,CAAC;IACJ,CAAC;CACF;AAjDD,sCAiDC"}
@@ -0,0 +1,231 @@
1
+ export interface ClientConfig {
2
+ apiKey: string;
3
+ secret: string;
4
+ baseUrl?: string;
5
+ }
6
+ export interface AuthToken {
7
+ token: string;
8
+ expiresIn: number;
9
+ partnerId: string;
10
+ expiresAt: number;
11
+ }
12
+ export interface PaginatedResponse<T> {
13
+ total: number;
14
+ limit?: number;
15
+ offset?: number;
16
+ }
17
+ export type UserType = 'STUDENT' | 'MENTOR';
18
+ export type MatchStatus = 'PENDING' | 'ACTIVE' | 'INACTIVE' | 'REJECTED' | 'REMOVED' | 'ENDED' | 'EXPIRED';
19
+ export type SessionType = 'CALL' | 'VIDEO' | 'CHAT';
20
+ export type SessionStatus = 'SCHEDULED' | 'IN_PROGRESS' | 'COMPLETED' | 'CANCELLED';
21
+ export interface Timezone {
22
+ value: string;
23
+ label?: string;
24
+ offset?: number;
25
+ abbrev?: string;
26
+ altName?: string;
27
+ }
28
+ export interface CreateUserInput {
29
+ firstName: string;
30
+ lastName: string;
31
+ email: string;
32
+ userType: UserType;
33
+ profileBio?: string;
34
+ city?: string;
35
+ state?: string;
36
+ externalId?: string;
37
+ }
38
+ export interface UpdateUserInput {
39
+ firstName?: string;
40
+ lastName?: string;
41
+ profileBio?: string;
42
+ profileTitle?: string;
43
+ profileCompany?: string;
44
+ profileLocation?: string;
45
+ profileWebsite?: string;
46
+ city?: string;
47
+ state?: string;
48
+ gender?: string;
49
+ profileEthnicity?: string;
50
+ onboardingCompleted?: boolean;
51
+ profileCompleted?: boolean;
52
+ }
53
+ export interface User {
54
+ id: string;
55
+ firstName: string;
56
+ lastName: string;
57
+ profilePictureUrl?: string | null;
58
+ profileCoverUrl?: string | null;
59
+ profileBio?: string | null;
60
+ profileTitle?: string | null;
61
+ profileCompany?: string | null;
62
+ profileLocation?: string | null;
63
+ profileWebsite?: string | null;
64
+ profileSkills?: string[] | null;
65
+ profileInterests?: string[] | null;
66
+ city?: string | null;
67
+ state?: string | null;
68
+ bgCheckStatus?: string | null;
69
+ profileCompleted?: boolean | null;
70
+ createdAt?: string | null;
71
+ updatedAt?: string | null;
72
+ }
73
+ export interface CreateUserResponse {
74
+ id: string;
75
+ firstName: string;
76
+ lastName: string;
77
+ email: string;
78
+ userType: UserType;
79
+ branchSlug: string;
80
+ externalId?: string;
81
+ createdAt: string;
82
+ }
83
+ export interface SyncUserInput {
84
+ externalId: string;
85
+ firstName: string;
86
+ lastName: string;
87
+ email: string;
88
+ userType: UserType;
89
+ profileBio?: string;
90
+ city?: string;
91
+ state?: string;
92
+ }
93
+ export interface SyncUserResponse {
94
+ id: string;
95
+ firstName: string;
96
+ lastName: string;
97
+ email?: string;
98
+ userType?: UserType;
99
+ externalId: string;
100
+ branchSlug: string;
101
+ created: boolean;
102
+ createdAt?: string;
103
+ updatedAt?: string;
104
+ }
105
+ export interface ExternalUserResponse extends User {
106
+ externalId: string;
107
+ }
108
+ export interface MentorSearchParams {
109
+ q?: string;
110
+ limit?: number;
111
+ offset?: number;
112
+ }
113
+ export interface Mentor extends User {
114
+ available?: boolean;
115
+ matchCount?: number;
116
+ }
117
+ export interface MentorSearchResponse extends PaginatedResponse<Mentor> {
118
+ mentors: Mentor[];
119
+ }
120
+ export interface CreateMatchInput {
121
+ studentId: string;
122
+ mentorId: string;
123
+ message?: string;
124
+ }
125
+ export interface EndMatchInput {
126
+ satisfactionRating?: number;
127
+ feedback?: string;
128
+ reason?: string;
129
+ }
130
+ export interface Match {
131
+ id: string;
132
+ studentId: string;
133
+ mentorId: string;
134
+ branchId: string;
135
+ status: MatchStatus;
136
+ streamChatId?: string;
137
+ matchRequestMessage?: string | null;
138
+ lastInteractionAt?: string | null;
139
+ startDate?: string | null;
140
+ endDate?: string | null;
141
+ endedAt?: string | null;
142
+ endReason?: string | null;
143
+ createdAt: string;
144
+ updatedAt?: string;
145
+ student?: User | null;
146
+ mentor?: User | null;
147
+ }
148
+ export interface MatchListResponse {
149
+ matches: Match[];
150
+ total: number;
151
+ }
152
+ export interface EndMatchResponse {
153
+ success: boolean;
154
+ matchId: string;
155
+ message: string;
156
+ }
157
+ export interface CreateSessionInput {
158
+ matchId: string;
159
+ startTime: string;
160
+ endTime: string;
161
+ type: SessionType;
162
+ timezone: Timezone;
163
+ notes?: string;
164
+ }
165
+ export interface Session {
166
+ id: string;
167
+ matchId: string;
168
+ mentorId: string;
169
+ studentId: string;
170
+ branchId?: string;
171
+ startTime: string;
172
+ endTime: string;
173
+ type: SessionType;
174
+ status: SessionStatus;
175
+ timezone: Timezone;
176
+ notes?: string | null;
177
+ meetingLink?: string | null;
178
+ cancellationReason?: string | null;
179
+ cancelledAt?: string | null;
180
+ createdAt: string;
181
+ updatedAt?: string;
182
+ }
183
+ export interface SessionListResponse {
184
+ sessions: Session[];
185
+ total: number;
186
+ }
187
+ export interface StreamTokenResponse {
188
+ token: string;
189
+ apiKey: string;
190
+ }
191
+ export interface Message {
192
+ id: string;
193
+ text: string;
194
+ userId: string;
195
+ attachments?: MessageAttachment[];
196
+ createdAt: string;
197
+ }
198
+ export interface MessageAttachment {
199
+ type: string;
200
+ url: string;
201
+ name?: string;
202
+ size?: number;
203
+ }
204
+ export interface SendMessageInput {
205
+ userId: string;
206
+ text: string;
207
+ }
208
+ export interface MessageListParams {
209
+ limit?: number;
210
+ offset?: number;
211
+ }
212
+ export interface MessageListResponse {
213
+ messages: Message[];
214
+ }
215
+ export interface CreateCallInput {
216
+ type?: 'video' | 'audio';
217
+ }
218
+ export interface CallInfo {
219
+ callId: string;
220
+ type: string;
221
+ createdAt: string;
222
+ endedAt?: string;
223
+ duration?: number;
224
+ }
225
+ export interface CallListResponse {
226
+ calls: CallInfo[];
227
+ }
228
+ export interface ApiErrorResponse {
229
+ error: string;
230
+ userId?: string;
231
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@ustriveneo/partner-sdk",
3
+ "version": "1.0.0",
4
+ "description": "TypeScript SDK for UStrive Partner API",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "tsc --watch",
13
+ "test": "vitest run",
14
+ "test:watch": "vitest",
15
+ "typecheck": "tsc --noEmit"
16
+ },
17
+ "keywords": [
18
+ "ustrive",
19
+ "partner",
20
+ "sdk",
21
+ "mentorship"
22
+ ],
23
+ "license": "MIT",
24
+ "devDependencies": {
25
+ "typescript": "^5.3.0",
26
+ "vitest": "^0.34.6"
27
+ }
28
+ }