skikrumb-api 2.0.1 → 2.1.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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { apiKeys, Device, Gateways, QueryDevice, RateRequest, Rates, ExternalUserRequest, ExternalUserResponse } from './models';
1
+ import { apiKeys, Device, Gateways, QueryDevice, RateRequest, Rates, ExternalUserRequest, ExternalUserResponse, ShareLinkRequest, ShareLinkResponse, SharePreviewResponse, ShareAcceptRequest, ShareAcceptResponse } from './models';
2
2
  declare class SkiKrumbRealtimeClient {
3
3
  private websocket;
4
4
  private sessionToken;
@@ -41,6 +41,9 @@ export declare const skiKrumb: (options?: {
41
41
  }) => Promise<unknown>;
42
42
  authenticateExternalUser: (userData: ExternalUserRequest) => Promise<ExternalUserResponse>;
43
43
  refreshSessionToken: (currentToken: string) => Promise<ExternalUserResponse>;
44
+ createSharingLink: (shareRequest: ShareLinkRequest) => Promise<ShareLinkResponse>;
45
+ previewSharingLink: (token: string) => Promise<SharePreviewResponse>;
46
+ acceptSharingLink: (token: string, acceptRequest: ShareAcceptRequest) => Promise<ShareAcceptResponse>;
44
47
  createRealtimeClient: (userId: string, sessionToken?: string, supabaseToken?: string) => SkiKrumbRealtimeClient;
45
48
  };
46
- export type { Device, Gateways, QueryDevice, RateRequest, Rates, apiKeys, ExternalUserRequest, ExternalUserResponse };
49
+ export type { Device, Gateways, QueryDevice, RateRequest, Rates, apiKeys, ExternalUserRequest, ExternalUserResponse, ShareLinkRequest, ShareLinkResponse, SharePreviewResponse, ShareAcceptRequest, ShareAcceptResponse, };
package/dist/index.js CHANGED
@@ -355,6 +355,69 @@ export const skiKrumb = (options = {
355
355
  throw error;
356
356
  }
357
357
  };
358
+ // Sharing API endpoints
359
+ const createSharingLink = async (shareRequest) => {
360
+ try {
361
+ const requestWithAuth = ky.create({
362
+ prefixUrl: options.url,
363
+ headers: {
364
+ 'Content-Type': 'application/json',
365
+ Authorization: `Bearer ${options.apiKey}`,
366
+ 'supabase-auth-token': options.supabaseToken || '',
367
+ 'x-client': options.requestedWith,
368
+ },
369
+ });
370
+ const response = await requestWithAuth
371
+ .post('sharing/create', { json: shareRequest })
372
+ .json();
373
+ return response;
374
+ }
375
+ catch (error) {
376
+ console.error('❌ Create Sharing Link Error:', error);
377
+ throw error;
378
+ }
379
+ };
380
+ const previewSharingLink = async (token) => {
381
+ try {
382
+ const requestWithAuth = ky.create({
383
+ prefixUrl: options.url,
384
+ headers: {
385
+ Authorization: `Bearer ${options.apiKey}`,
386
+ 'supabase-auth-token': options.supabaseToken || '',
387
+ 'x-client': options.requestedWith,
388
+ },
389
+ });
390
+ const response = await requestWithAuth
391
+ .get(`sharing/accept/${token}`)
392
+ .json();
393
+ return response;
394
+ }
395
+ catch (error) {
396
+ console.error('❌ Preview Sharing Link Error:', error);
397
+ throw error;
398
+ }
399
+ };
400
+ const acceptSharingLink = async (token, acceptRequest) => {
401
+ try {
402
+ const requestWithAuth = ky.create({
403
+ prefixUrl: options.url,
404
+ headers: {
405
+ 'Content-Type': 'application/json',
406
+ Authorization: `Bearer ${options.apiKey}`,
407
+ 'supabase-auth-token': options.supabaseToken || '',
408
+ 'x-client': options.requestedWith,
409
+ },
410
+ });
411
+ const response = await requestWithAuth
412
+ .post(`sharing/accept/${token}`, { json: acceptRequest })
413
+ .json();
414
+ return response;
415
+ }
416
+ catch (error) {
417
+ console.error('❌ Accept Sharing Link Error:', error);
418
+ throw error;
419
+ }
420
+ };
358
421
  return {
359
422
  createDevice,
360
423
  readDevices,
@@ -366,6 +429,9 @@ export const skiKrumb = (options = {
366
429
  sendMobileLocation,
367
430
  authenticateExternalUser,
368
431
  refreshSessionToken,
432
+ createSharingLink,
433
+ previewSharingLink,
434
+ acceptSharingLink,
369
435
  createRealtimeClient: (userId, sessionToken, supabaseToken) => {
370
436
  if (!sessionToken && !options.apiKey) {
371
437
  throw new Error('Session token or API key required for realtime client');
package/dist/models.d.ts CHANGED
@@ -114,3 +114,95 @@ export interface ExternalUserResponse {
114
114
  serialsCount?: number;
115
115
  timestamp?: string;
116
116
  }
117
+ export interface ShareLinkRequest {
118
+ invited_by: string;
119
+ profiles?: string[];
120
+ share_all: boolean;
121
+ duration_days?: number;
122
+ invited_email?: string;
123
+ }
124
+ export interface ShareLinkResponse {
125
+ success: boolean;
126
+ data?: {
127
+ sharing_link: {
128
+ id: string;
129
+ token: string;
130
+ status: string;
131
+ invited_by: string;
132
+ profiles: string[];
133
+ share_all: boolean;
134
+ link_expiry_date: string | null;
135
+ share_expiry_date: string | null;
136
+ };
137
+ family: {
138
+ id: string;
139
+ account: string;
140
+ invited_account: string | null;
141
+ sharing_link: string;
142
+ share_all: boolean;
143
+ accepted: boolean;
144
+ };
145
+ token: string;
146
+ share_url: string;
147
+ share_type: 'admin' | 'specific_profiles';
148
+ profiles_count: number | 'all';
149
+ expires_at: string | null;
150
+ };
151
+ error?: {
152
+ status: number;
153
+ message: string;
154
+ };
155
+ }
156
+ export interface SharePreviewResponse {
157
+ success: boolean;
158
+ data?: {
159
+ token: string;
160
+ sharing_link: {
161
+ id: string;
162
+ status: string;
163
+ share_all: boolean;
164
+ link_expiry_date: string | null;
165
+ share_expiry_date: string | null;
166
+ };
167
+ inviter: {
168
+ account_id: string;
169
+ name: string;
170
+ email: string;
171
+ };
172
+ share_type: 'admin' | 'specific_profiles';
173
+ profiles: Array<{
174
+ id: string;
175
+ first_name: string;
176
+ last_name: string;
177
+ avatar: string | null;
178
+ }>;
179
+ profiles_count: number | 'all';
180
+ is_expired: boolean;
181
+ can_accept: boolean;
182
+ };
183
+ error?: {
184
+ status: number;
185
+ message: string;
186
+ };
187
+ }
188
+ export interface ShareAcceptRequest {
189
+ accept: boolean;
190
+ invitee_account: string;
191
+ invitee_name?: string;
192
+ invitee_email?: string;
193
+ }
194
+ export interface ShareAcceptResponse {
195
+ success: boolean;
196
+ data?: {
197
+ operation: 'accepted' | 'declined';
198
+ bidirectional: boolean;
199
+ family: any;
200
+ reciprocal_family: any | null;
201
+ accessible_profiles: any[];
202
+ accessible_registrations: any[];
203
+ };
204
+ error?: {
205
+ status: number;
206
+ message: string;
207
+ };
208
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skikrumb-api",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "Wrapper for the skiKrumb API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",