@scalemule/nextjs 0.0.1 → 0.0.2

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/testing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { U as User, K as StorageFile, j as ApiResponse, A as ApiError } from './index-BkacIKdu.js';
3
+ import { U as User, N as StorageFile, A as ApiError } from './index-9v0SaLgg.js';
4
4
 
5
5
  interface MockUserOptions {
6
6
  id?: string;
@@ -27,8 +27,8 @@ interface MockFileOptions {
27
27
  }
28
28
  declare function createMockFile(options?: MockFileOptions): StorageFile;
29
29
  interface MockClientConfig {
30
- /** Simulated responses for specific paths */
31
- responses?: Record<string, ApiResponse<unknown>>;
30
+ /** Simulated responses for specific paths (return value, not wrapped) */
31
+ responses?: Record<string, unknown>;
32
32
  /** Default delay in ms (simulates network latency) */
33
33
  delay?: number;
34
34
  /** Whether to simulate errors */
@@ -46,13 +46,13 @@ declare class MockScaleMuleClient {
46
46
  getSessionToken(): string | null;
47
47
  getUserId(): string | null;
48
48
  isAuthenticated(): boolean;
49
- request<T>(path: string): Promise<ApiResponse<T>>;
50
- get<T>(path: string): Promise<ApiResponse<T>>;
51
- post<T>(path: string): Promise<ApiResponse<T>>;
52
- patch<T>(path: string): Promise<ApiResponse<T>>;
53
- put<T>(path: string): Promise<ApiResponse<T>>;
54
- delete<T>(path: string): Promise<ApiResponse<T>>;
55
- upload<T>(): Promise<ApiResponse<T>>;
49
+ request<T>(path: string): Promise<T>;
50
+ get<T>(path: string): Promise<T>;
51
+ post<T>(path: string): Promise<T>;
52
+ patch<T>(path: string): Promise<T>;
53
+ put<T>(path: string): Promise<T>;
54
+ delete<T>(path: string): Promise<T>;
55
+ upload<T>(): Promise<T>;
56
56
  }
57
57
  interface MockScaleMuleContextValue {
58
58
  client: MockScaleMuleClient;
package/dist/testing.js CHANGED
@@ -3,6 +3,15 @@
3
3
  var react = require('react');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
 
6
+ // src/types/index.ts
7
+ var ScaleMuleApiError = class extends Error {
8
+ constructor(error) {
9
+ super(error.message);
10
+ this.name = "ScaleMuleApiError";
11
+ this.code = error.code;
12
+ this.field = error.field;
13
+ }
14
+ };
6
15
  function createMockUser(options = {}) {
7
16
  return {
8
17
  id: options.id ?? "mock-user-id-123",
@@ -62,15 +71,12 @@ var MockScaleMuleClient = class {
62
71
  async request(path) {
63
72
  await this.simulateDelay();
64
73
  if (this.simulateErrors) {
65
- return {
66
- success: false,
67
- error: { code: "MOCK_ERROR", message: "Simulated error" }
68
- };
74
+ throw new ScaleMuleApiError({ code: "MOCK_ERROR", message: "Simulated error" });
69
75
  }
70
- if (this.responses[path]) {
76
+ if (this.responses[path] !== void 0) {
71
77
  return this.responses[path];
72
78
  }
73
- return { success: true, data: {} };
79
+ return {};
74
80
  }
75
81
  async get(path) {
76
82
  return this.request(path);
@@ -89,7 +95,7 @@ var MockScaleMuleClient = class {
89
95
  }
90
96
  async upload() {
91
97
  await this.simulateDelay();
92
- return { success: true, data: {} };
98
+ return {};
93
99
  }
94
100
  };
95
101
  var MockScaleMuleContext = react.createContext(null);
package/dist/testing.mjs CHANGED
@@ -1,6 +1,15 @@
1
1
  import { createContext, useState, useMemo, useContext } from 'react';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
 
4
+ // src/types/index.ts
5
+ var ScaleMuleApiError = class extends Error {
6
+ constructor(error) {
7
+ super(error.message);
8
+ this.name = "ScaleMuleApiError";
9
+ this.code = error.code;
10
+ this.field = error.field;
11
+ }
12
+ };
4
13
  function createMockUser(options = {}) {
5
14
  return {
6
15
  id: options.id ?? "mock-user-id-123",
@@ -60,15 +69,12 @@ var MockScaleMuleClient = class {
60
69
  async request(path) {
61
70
  await this.simulateDelay();
62
71
  if (this.simulateErrors) {
63
- return {
64
- success: false,
65
- error: { code: "MOCK_ERROR", message: "Simulated error" }
66
- };
72
+ throw new ScaleMuleApiError({ code: "MOCK_ERROR", message: "Simulated error" });
67
73
  }
68
- if (this.responses[path]) {
74
+ if (this.responses[path] !== void 0) {
69
75
  return this.responses[path];
70
76
  }
71
- return { success: true, data: {} };
77
+ return {};
72
78
  }
73
79
  async get(path) {
74
80
  return this.request(path);
@@ -87,7 +93,7 @@ var MockScaleMuleClient = class {
87
93
  }
88
94
  async upload() {
89
95
  await this.simulateDelay();
90
- return { success: true, data: {} };
96
+ return {};
91
97
  }
92
98
  };
93
99
  var MockScaleMuleContext = createContext(null);
@@ -1,4 +1,4 @@
1
- import { R as RegisterRequest, j as ApiResponse, U as User, k as LoginRequest, L as LoginResponse, c as ListFilesParams, Q as ListFilesResponse, K as StorageFile, _ as ClientContext, T as UploadResponse } from './index-BkacIKdu.js';
1
+ import { R as RegisterRequest, U as User, l as LoginRequest, L as LoginResponse, c as ListFilesParams, T as ListFilesResponse, N as StorageFile, $ as ClientContext, W as UploadResponse } from './index-9v0SaLgg.mjs';
2
2
 
3
3
  /**
4
4
  * Server-Side ScaleMule Client
@@ -39,53 +39,53 @@ declare class ScaleMuleServer {
39
39
  /**
40
40
  * Register a new user
41
41
  */
42
- register: (data: RegisterRequest) => Promise<ApiResponse<User>>;
42
+ register: (data: RegisterRequest) => Promise<User>;
43
43
  /**
44
44
  * Login user - returns session token (store in HTTP-only cookie)
45
45
  */
46
- login: (data: LoginRequest) => Promise<ApiResponse<LoginResponse>>;
46
+ login: (data: LoginRequest) => Promise<LoginResponse>;
47
47
  /**
48
48
  * Logout user
49
49
  */
50
- logout: (sessionToken: string) => Promise<ApiResponse<void>>;
50
+ logout: (sessionToken: string) => Promise<void>;
51
51
  /**
52
52
  * Get current user from session token
53
53
  */
54
- me: (sessionToken: string) => Promise<ApiResponse<User>>;
54
+ me: (sessionToken: string) => Promise<User>;
55
55
  /**
56
56
  * Refresh session token
57
57
  */
58
- refresh: (sessionToken: string) => Promise<ApiResponse<{
58
+ refresh: (sessionToken: string) => Promise<{
59
59
  session_token: string;
60
60
  expires_at: string;
61
- }>>;
61
+ }>;
62
62
  /**
63
63
  * Request password reset email
64
64
  */
65
- forgotPassword: (email: string) => Promise<ApiResponse<{
65
+ forgotPassword: (email: string) => Promise<{
66
66
  message: string;
67
- }>>;
67
+ }>;
68
68
  /**
69
69
  * Reset password with token
70
70
  */
71
- resetPassword: (token: string, newPassword: string) => Promise<ApiResponse<{
71
+ resetPassword: (token: string, newPassword: string) => Promise<{
72
72
  message: string;
73
- }>>;
73
+ }>;
74
74
  /**
75
75
  * Verify email with token
76
76
  */
77
- verifyEmail: (token: string) => Promise<ApiResponse<{
77
+ verifyEmail: (token: string) => Promise<{
78
78
  message: string;
79
- }>>;
79
+ }>;
80
80
  /**
81
81
  * Resend verification email.
82
82
  * Can be called with a session token (authenticated) or email (unauthenticated).
83
83
  */
84
84
  resendVerification: (sessionTokenOrEmail: string, options?: {
85
85
  email?: string;
86
- }) => Promise<ApiResponse<{
86
+ }) => Promise<{
87
87
  message: string;
88
- }>>;
88
+ }>;
89
89
  };
90
90
  user: {
91
91
  /**
@@ -94,25 +94,25 @@ declare class ScaleMuleServer {
94
94
  update: (sessionToken: string, data: {
95
95
  full_name?: string;
96
96
  avatar_url?: string;
97
- }) => Promise<ApiResponse<User>>;
97
+ }) => Promise<User>;
98
98
  /**
99
99
  * Change password
100
100
  */
101
- changePassword: (sessionToken: string, currentPassword: string, newPassword: string) => Promise<ApiResponse<{
101
+ changePassword: (sessionToken: string, currentPassword: string, newPassword: string) => Promise<{
102
102
  message: string;
103
- }>>;
103
+ }>;
104
104
  /**
105
105
  * Change email
106
106
  */
107
- changeEmail: (sessionToken: string, newEmail: string, password: string) => Promise<ApiResponse<{
107
+ changeEmail: (sessionToken: string, newEmail: string, password: string) => Promise<{
108
108
  message: string;
109
- }>>;
109
+ }>;
110
110
  /**
111
111
  * Delete account
112
112
  */
113
- deleteAccount: (sessionToken: string, password: string) => Promise<ApiResponse<{
113
+ deleteAccount: (sessionToken: string, password: string) => Promise<{
114
114
  message: string;
115
- }>>;
115
+ }>;
116
116
  };
117
117
  secrets: {
118
118
  /**
@@ -126,10 +126,10 @@ declare class ScaleMuleServer {
126
126
  * }
127
127
  * ```
128
128
  */
129
- get: (key: string) => Promise<ApiResponse<{
129
+ get: (key: string) => Promise<{
130
130
  value: string;
131
131
  version: number;
132
- }>>;
132
+ }>;
133
133
  /**
134
134
  * Set a secret in the tenant vault
135
135
  *
@@ -138,46 +138,46 @@ declare class ScaleMuleServer {
138
138
  * await scalemule.secrets.set('ANONYMOUS_USER_SALT', 'my-secret-salt')
139
139
  * ```
140
140
  */
141
- set: (key: string, value: string) => Promise<ApiResponse<{
141
+ set: (key: string, value: string) => Promise<{
142
142
  value: string;
143
143
  version: number;
144
- }>>;
144
+ }>;
145
145
  /**
146
146
  * Delete a secret from the tenant vault
147
147
  */
148
- delete: (key: string) => Promise<ApiResponse<void>>;
148
+ delete: (key: string) => Promise<void>;
149
149
  /**
150
150
  * List all secrets in the tenant vault
151
151
  */
152
- list: () => Promise<ApiResponse<{
152
+ list: () => Promise<{
153
153
  secrets: Array<{
154
154
  path: string;
155
155
  version: number;
156
156
  }>;
157
- }>>;
157
+ }>;
158
158
  /**
159
159
  * Get secret version history
160
160
  */
161
- versions: (key: string) => Promise<ApiResponse<{
161
+ versions: (key: string) => Promise<{
162
162
  versions: Array<{
163
163
  version: number;
164
164
  created_at: string;
165
165
  }>;
166
- }>>;
166
+ }>;
167
167
  /**
168
168
  * Rollback to a specific version
169
169
  */
170
- rollback: (key: string, version: number) => Promise<ApiResponse<{
170
+ rollback: (key: string, version: number) => Promise<{
171
171
  value: string;
172
172
  version: number;
173
- }>>;
173
+ }>;
174
174
  /**
175
175
  * Rotate a secret (copy current version as new version)
176
176
  */
177
- rotate: (key: string, newValue: string) => Promise<ApiResponse<{
177
+ rotate: (key: string, newValue: string) => Promise<{
178
178
  value: string;
179
179
  version: number;
180
- }>>;
180
+ }>;
181
181
  };
182
182
  bundles: {
183
183
  /**
@@ -194,12 +194,12 @@ declare class ScaleMuleServer {
194
194
  * }
195
195
  * ```
196
196
  */
197
- get: <T = Record<string, unknown>>(key: string, resolve?: boolean) => Promise<ApiResponse<{
197
+ get: <T = Record<string, unknown>>(key: string, resolve?: boolean) => Promise<{
198
198
  type: string;
199
199
  data: T;
200
200
  version: number;
201
201
  inherits_from?: string;
202
- }>>;
202
+ }>;
203
203
  /**
204
204
  * Set a bundle (structured secret)
205
205
  *
@@ -225,26 +225,26 @@ declare class ScaleMuleServer {
225
225
  * }, 'database/prod')
226
226
  * ```
227
227
  */
228
- set: <T = Record<string, unknown>>(key: string, type: string, data: T, inheritsFrom?: string) => Promise<ApiResponse<{
228
+ set: <T = Record<string, unknown>>(key: string, type: string, data: T, inheritsFrom?: string) => Promise<{
229
229
  type: string;
230
230
  data: T;
231
231
  version: number;
232
- }>>;
232
+ }>;
233
233
  /**
234
234
  * Delete a bundle
235
235
  */
236
- delete: (key: string) => Promise<ApiResponse<void>>;
236
+ delete: (key: string) => Promise<void>;
237
237
  /**
238
238
  * List all bundles
239
239
  */
240
- list: () => Promise<ApiResponse<{
240
+ list: () => Promise<{
241
241
  bundles: Array<{
242
242
  path: string;
243
243
  type: string;
244
244
  version: number;
245
245
  inherits_from?: string;
246
246
  }>;
247
- }>>;
247
+ }>;
248
248
  /**
249
249
  * Get connection URL for a database bundle
250
250
  *
@@ -256,9 +256,9 @@ declare class ScaleMuleServer {
256
256
  * }
257
257
  * ```
258
258
  */
259
- connectionUrl: (key: string) => Promise<ApiResponse<{
259
+ connectionUrl: (key: string) => Promise<{
260
260
  url: string;
261
- }>>;
261
+ }>;
262
262
  };
263
263
  vaultAudit: {
264
264
  /**
@@ -279,7 +279,7 @@ declare class ScaleMuleServer {
279
279
  since?: string;
280
280
  until?: string;
281
281
  limit?: number;
282
- }) => Promise<ApiResponse<{
282
+ }) => Promise<{
283
283
  logs: Array<{
284
284
  timestamp: string;
285
285
  action: string;
@@ -287,21 +287,21 @@ declare class ScaleMuleServer {
287
287
  success: boolean;
288
288
  error_message?: string;
289
289
  }>;
290
- }>>;
290
+ }>;
291
291
  };
292
292
  storage: {
293
293
  /**
294
294
  * List user's files
295
295
  */
296
- list: (userId: string, params?: ListFilesParams) => Promise<ApiResponse<ListFilesResponse>>;
296
+ list: (userId: string, params?: ListFilesParams) => Promise<ListFilesResponse>;
297
297
  /**
298
298
  * Get file info
299
299
  */
300
- get: (fileId: string) => Promise<ApiResponse<StorageFile>>;
300
+ get: (fileId: string) => Promise<StorageFile>;
301
301
  /**
302
302
  * Delete file
303
303
  */
304
- delete: (userId: string, fileId: string) => Promise<ApiResponse<void>>;
304
+ delete: (userId: string, fileId: string) => Promise<void>;
305
305
  /**
306
306
  * Upload file (from server - use FormData)
307
307
  *
@@ -326,7 +326,7 @@ declare class ScaleMuleServer {
326
326
  contentType: string;
327
327
  }, options?: {
328
328
  clientContext?: ClientContext;
329
- }) => Promise<ApiResponse<UploadResponse>>;
329
+ }) => Promise<UploadResponse>;
330
330
  };
331
331
  webhooks: {
332
332
  /**
@@ -341,23 +341,23 @@ declare class ScaleMuleServer {
341
341
  * })
342
342
  *
343
343
  * // Store the secret for signature verification
344
- * console.log('Webhook secret:', result.data.secret)
344
+ * console.log('Webhook secret:', result.secret)
345
345
  * ```
346
346
  */
347
347
  create: (data: {
348
348
  webhook_name: string;
349
349
  url: string;
350
350
  events: string[];
351
- }) => Promise<ApiResponse<{
351
+ }) => Promise<{
352
352
  id: string;
353
353
  secret: string;
354
354
  url: string;
355
355
  events: string[];
356
- }>>;
356
+ }>;
357
357
  /**
358
358
  * List all webhook subscriptions
359
359
  */
360
- list: () => Promise<ApiResponse<{
360
+ list: () => Promise<{
361
361
  webhooks: Array<{
362
362
  id: string;
363
363
  webhook_name: string;
@@ -365,11 +365,11 @@ declare class ScaleMuleServer {
365
365
  events: string[];
366
366
  is_enabled: boolean;
367
367
  }>;
368
- }>>;
368
+ }>;
369
369
  /**
370
370
  * Delete a webhook subscription
371
371
  */
372
- delete: (id: string) => Promise<ApiResponse<void>>;
372
+ delete: (id: string) => Promise<void>;
373
373
  /**
374
374
  * Update a webhook subscription
375
375
  */
@@ -377,21 +377,21 @@ declare class ScaleMuleServer {
377
377
  url?: string;
378
378
  events?: string[];
379
379
  is_enabled?: boolean;
380
- }) => Promise<ApiResponse<{
380
+ }) => Promise<{
381
381
  id: string;
382
382
  url: string;
383
383
  events: string[];
384
- }>>;
384
+ }>;
385
385
  /**
386
386
  * Get available webhook event types
387
387
  */
388
- eventTypes: () => Promise<ApiResponse<{
388
+ eventTypes: () => Promise<{
389
389
  events: Array<{
390
390
  event_name: string;
391
391
  event_description: string;
392
392
  payload_schema: Record<string, unknown>;
393
393
  }>;
394
- }>>;
394
+ }>;
395
395
  };
396
396
  analytics: {
397
397
  /**
@@ -446,10 +446,10 @@ declare class ScaleMuleServer {
446
446
  timestamp?: string;
447
447
  }, options?: {
448
448
  clientContext?: ClientContext;
449
- }) => Promise<ApiResponse<{
449
+ }) => Promise<{
450
450
  tracked: number;
451
451
  session_id?: string;
452
- }>>;
452
+ }>;
453
453
  /**
454
454
  * Track a page view
455
455
  *
@@ -470,10 +470,10 @@ declare class ScaleMuleServer {
470
470
  user_id?: string;
471
471
  }, options?: {
472
472
  clientContext?: ClientContext;
473
- }) => Promise<ApiResponse<{
473
+ }) => Promise<{
474
474
  tracked: number;
475
475
  session_id?: string;
476
- }>>;
476
+ }>;
477
477
  /**
478
478
  * Track multiple events in a batch (max 100)
479
479
  *
@@ -511,9 +511,9 @@ declare class ScaleMuleServer {
511
511
  timestamp?: string;
512
512
  }>, options?: {
513
513
  clientContext?: ClientContext;
514
- }) => Promise<ApiResponse<{
514
+ }) => Promise<{
515
515
  tracked: number;
516
- }>>;
516
+ }>;
517
517
  };
518
518
  }
519
519
  /**