@qm-hub/sync-client-types 0.2.1 → 0.2.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/index.d.mts CHANGED
@@ -207,6 +207,7 @@ interface SyncClientConfig {
207
207
  apiKey: string;
208
208
  defaultBatchSize: number;
209
209
  timeoutMs: number;
210
+ apiBasePath: string;
210
211
  }
211
212
  interface SyncResult {
212
213
  pushed: number;
@@ -220,7 +221,7 @@ declare function createAuthHeaders(apiKey: string, appId: string): AuthHeaders;
220
221
  /** Create AuthHeaders with bearer token */
221
222
  declare function withBearer(headers: AuthHeaders, token: string): AuthHeaders;
222
223
  /** Create default SyncClientConfig */
223
- declare function createSyncClientConfig(serverUrl: string, appId: string, apiKey: string, options?: Partial<Pick<SyncClientConfig, 'defaultBatchSize' | 'timeoutMs'>>): SyncClientConfig;
224
+ declare function createSyncClientConfig(serverUrl: string, appId: string, apiKey: string, options?: Partial<Pick<SyncClientConfig, 'defaultBatchSize' | 'timeoutMs' | 'apiBasePath'>>): SyncClientConfig;
224
225
  /** Create an initial checkpoint */
225
226
  declare function initialCheckpoint(): Checkpoint;
226
227
 
package/dist/index.d.ts CHANGED
@@ -207,6 +207,7 @@ interface SyncClientConfig {
207
207
  apiKey: string;
208
208
  defaultBatchSize: number;
209
209
  timeoutMs: number;
210
+ apiBasePath: string;
210
211
  }
211
212
  interface SyncResult {
212
213
  pushed: number;
@@ -220,7 +221,7 @@ declare function createAuthHeaders(apiKey: string, appId: string): AuthHeaders;
220
221
  /** Create AuthHeaders with bearer token */
221
222
  declare function withBearer(headers: AuthHeaders, token: string): AuthHeaders;
222
223
  /** Create default SyncClientConfig */
223
- declare function createSyncClientConfig(serverUrl: string, appId: string, apiKey: string, options?: Partial<Pick<SyncClientConfig, 'defaultBatchSize' | 'timeoutMs'>>): SyncClientConfig;
224
+ declare function createSyncClientConfig(serverUrl: string, appId: string, apiKey: string, options?: Partial<Pick<SyncClientConfig, 'defaultBatchSize' | 'timeoutMs' | 'apiBasePath'>>): SyncClientConfig;
224
225
  /** Create an initial checkpoint */
225
226
  declare function initialCheckpoint(): Checkpoint;
226
227
 
package/dist/index.js CHANGED
@@ -70,7 +70,7 @@ var QmSyncClient = class {
70
70
  * Register a new user.
71
71
  */
72
72
  async register(username, email, password) {
73
- const url = `${this.config.serverUrl}/api/v1/auth/register`;
73
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/auth/register`;
74
74
  const headers = this.buildHeaders();
75
75
  const body = JSON.stringify({ username, email, password });
76
76
  const response = await this.http({ method: "POST", url, headers, body });
@@ -88,7 +88,7 @@ var QmSyncClient = class {
88
88
  * Login with email and password.
89
89
  */
90
90
  async login(email, password) {
91
- const url = `${this.config.serverUrl}/api/v1/auth/login`;
91
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/auth/login`;
92
92
  const headers = this.buildHeaders();
93
93
  const body = JSON.stringify({ email, password });
94
94
  const response = await this.http({ method: "POST", url, headers, body });
@@ -108,7 +108,7 @@ var QmSyncClient = class {
108
108
  if (!this._refreshToken) {
109
109
  throw new Error("Not authenticated - please login first");
110
110
  }
111
- const url = `${this.config.serverUrl}/api/v1/auth/refresh`;
111
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/auth/refresh`;
112
112
  const headers = this.buildHeaders();
113
113
  const body = JSON.stringify({ refreshToken: this._refreshToken });
114
114
  const response = await this.http({ method: "POST", url, headers, body });
@@ -168,7 +168,7 @@ var QmSyncClient = class {
168
168
  records: records.map(this.syncToPushRecord),
169
169
  clientTimestamp: (/* @__PURE__ */ new Date()).toISOString()
170
170
  };
171
- const url = `${this.config.serverUrl}/api/v1/sync/${this.config.appId}/push`;
171
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/sync/${this.config.appId}/push`;
172
172
  return this.authenticatedPost(url, request);
173
173
  }
174
174
  /**
@@ -179,7 +179,7 @@ var QmSyncClient = class {
179
179
  checkpoint,
180
180
  batchSize: batchSize ?? this.config.defaultBatchSize
181
181
  };
182
- const url = `${this.config.serverUrl}/api/v1/sync/${this.config.appId}/pull`;
182
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/sync/${this.config.appId}/pull`;
183
183
  return this.authenticatedPost(url, request);
184
184
  }
185
185
  /**
@@ -196,7 +196,7 @@ var QmSyncClient = class {
196
196
  batchSize: this.config.defaultBatchSize
197
197
  }
198
198
  };
199
- const url = `${this.config.serverUrl}/api/v1/sync/${this.config.appId}/delta`;
199
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/sync/${this.config.appId}/delta`;
200
200
  return this.authenticatedPost(url, request);
201
201
  }
202
202
  // =========================================================================
@@ -297,7 +297,8 @@ function createSyncClientConfig(serverUrl, appId, apiKey, options) {
297
297
  appId,
298
298
  apiKey,
299
299
  defaultBatchSize: options?.defaultBatchSize ?? 100,
300
- timeoutMs: options?.timeoutMs ?? 3e4
300
+ timeoutMs: options?.timeoutMs ?? 3e4,
301
+ apiBasePath: options?.apiBasePath ?? "/api/v1"
301
302
  };
302
303
  }
303
304
  function initialCheckpoint() {
package/dist/index.mjs CHANGED
@@ -39,7 +39,7 @@ var QmSyncClient = class {
39
39
  * Register a new user.
40
40
  */
41
41
  async register(username, email, password) {
42
- const url = `${this.config.serverUrl}/api/v1/auth/register`;
42
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/auth/register`;
43
43
  const headers = this.buildHeaders();
44
44
  const body = JSON.stringify({ username, email, password });
45
45
  const response = await this.http({ method: "POST", url, headers, body });
@@ -57,7 +57,7 @@ var QmSyncClient = class {
57
57
  * Login with email and password.
58
58
  */
59
59
  async login(email, password) {
60
- const url = `${this.config.serverUrl}/api/v1/auth/login`;
60
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/auth/login`;
61
61
  const headers = this.buildHeaders();
62
62
  const body = JSON.stringify({ email, password });
63
63
  const response = await this.http({ method: "POST", url, headers, body });
@@ -77,7 +77,7 @@ var QmSyncClient = class {
77
77
  if (!this._refreshToken) {
78
78
  throw new Error("Not authenticated - please login first");
79
79
  }
80
- const url = `${this.config.serverUrl}/api/v1/auth/refresh`;
80
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/auth/refresh`;
81
81
  const headers = this.buildHeaders();
82
82
  const body = JSON.stringify({ refreshToken: this._refreshToken });
83
83
  const response = await this.http({ method: "POST", url, headers, body });
@@ -137,7 +137,7 @@ var QmSyncClient = class {
137
137
  records: records.map(this.syncToPushRecord),
138
138
  clientTimestamp: (/* @__PURE__ */ new Date()).toISOString()
139
139
  };
140
- const url = `${this.config.serverUrl}/api/v1/sync/${this.config.appId}/push`;
140
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/sync/${this.config.appId}/push`;
141
141
  return this.authenticatedPost(url, request);
142
142
  }
143
143
  /**
@@ -148,7 +148,7 @@ var QmSyncClient = class {
148
148
  checkpoint,
149
149
  batchSize: batchSize ?? this.config.defaultBatchSize
150
150
  };
151
- const url = `${this.config.serverUrl}/api/v1/sync/${this.config.appId}/pull`;
151
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/sync/${this.config.appId}/pull`;
152
152
  return this.authenticatedPost(url, request);
153
153
  }
154
154
  /**
@@ -165,7 +165,7 @@ var QmSyncClient = class {
165
165
  batchSize: this.config.defaultBatchSize
166
166
  }
167
167
  };
168
- const url = `${this.config.serverUrl}/api/v1/sync/${this.config.appId}/delta`;
168
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/sync/${this.config.appId}/delta`;
169
169
  return this.authenticatedPost(url, request);
170
170
  }
171
171
  // =========================================================================
@@ -266,7 +266,8 @@ function createSyncClientConfig(serverUrl, appId, apiKey, options) {
266
266
  appId,
267
267
  apiKey,
268
268
  defaultBatchSize: options?.defaultBatchSize ?? 100,
269
- timeoutMs: options?.timeoutMs ?? 3e4
269
+ timeoutMs: options?.timeoutMs ?? 3e4,
270
+ apiBasePath: options?.apiBasePath ?? "/api/v1"
270
271
  };
271
272
  }
272
273
  function initialCheckpoint() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qm-hub/sync-client-types",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "TypeScript types for qm-sync-client - generated from Rust with Specta",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
package/src/client.ts CHANGED
@@ -91,7 +91,7 @@ export class QmSyncClient {
91
91
  email: string,
92
92
  password: string
93
93
  ): Promise<AuthResponse> {
94
- const url = `${this.config.serverUrl}/api/v1/auth/register`;
94
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/auth/register`;
95
95
  const headers = this.buildHeaders();
96
96
  const body = JSON.stringify({ username, email, password });
97
97
 
@@ -113,7 +113,7 @@ export class QmSyncClient {
113
113
  * Login with email and password.
114
114
  */
115
115
  async login(email: string, password: string): Promise<AuthResponse> {
116
- const url = `${this.config.serverUrl}/api/v1/auth/login`;
116
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/auth/login`;
117
117
  const headers = this.buildHeaders();
118
118
  const body = JSON.stringify({ email, password });
119
119
 
@@ -138,7 +138,7 @@ export class QmSyncClient {
138
138
  throw new Error("Not authenticated - please login first");
139
139
  }
140
140
 
141
- const url = `${this.config.serverUrl}/api/v1/auth/refresh`;
141
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/auth/refresh`;
142
142
  const headers = this.buildHeaders();
143
143
  const body = JSON.stringify({ refreshToken: this._refreshToken });
144
144
 
@@ -209,7 +209,7 @@ export class QmSyncClient {
209
209
  clientTimestamp: new Date().toISOString(),
210
210
  };
211
211
 
212
- const url = `${this.config.serverUrl}/api/v1/sync/${this.config.appId}/push`;
212
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/sync/${this.config.appId}/push`;
213
213
  return this.authenticatedPost<PushRequest, PushResponse>(url, request);
214
214
  }
215
215
 
@@ -225,7 +225,7 @@ export class QmSyncClient {
225
225
  batchSize: batchSize ?? this.config.defaultBatchSize,
226
226
  };
227
227
 
228
- const url = `${this.config.serverUrl}/api/v1/sync/${this.config.appId}/pull`;
228
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/sync/${this.config.appId}/pull`;
229
229
  return this.authenticatedPost<PullRequest, PullResponse>(url, request);
230
230
  }
231
231
 
@@ -250,7 +250,7 @@ export class QmSyncClient {
250
250
  },
251
251
  };
252
252
 
253
- const url = `${this.config.serverUrl}/api/v1/sync/${this.config.appId}/delta`;
253
+ const url = `${this.config.serverUrl}${this.config.apiBasePath}/sync/${this.config.appId}/delta`;
254
254
  return this.authenticatedPost<DeltaRequest, DeltaResponse>(url, request);
255
255
  }
256
256
 
package/src/index.ts CHANGED
@@ -177,6 +177,7 @@ export interface SyncClientConfig {
177
177
  apiKey: string;
178
178
  defaultBatchSize: number;
179
179
  timeoutMs: number;
180
+ apiBasePath: string;
180
181
  }
181
182
 
182
183
  // =============================================================================
@@ -217,7 +218,7 @@ export function createSyncClientConfig(
217
218
  serverUrl: string,
218
219
  appId: string,
219
220
  apiKey: string,
220
- options?: Partial<Pick<SyncClientConfig, 'defaultBatchSize' | 'timeoutMs'>>
221
+ options?: Partial<Pick<SyncClientConfig, 'defaultBatchSize' | 'timeoutMs' | 'apiBasePath'>>
221
222
  ): SyncClientConfig {
222
223
  return {
223
224
  serverUrl,
@@ -225,6 +226,7 @@ export function createSyncClientConfig(
225
226
  apiKey,
226
227
  defaultBatchSize: options?.defaultBatchSize ?? 100,
227
228
  timeoutMs: options?.timeoutMs ?? 30000,
229
+ apiBasePath: options?.apiBasePath ?? '/api/v1',
228
230
  };
229
231
  }
230
232