@sylphx/sdk 0.21.1 → 0.23.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/dist/index.mjs CHANGED
@@ -839,13 +839,13 @@ function createConfigFromComponents(input) {
839
839
  const env = match[2];
840
840
  const slug = resolvedSlug.trim().toLowerCase();
841
841
  const domain = input.domain?.trim() || DEFAULT_SDK_API_HOST;
842
- const baseUrl = `https://${slug}.${domain}/v1`;
842
+ const baseUrl2 = `https://${slug}.${domain}/v1`;
843
843
  return freezeConfig({
844
844
  credential: trimmedCred,
845
845
  credentialType,
846
846
  env,
847
847
  slug,
848
- baseUrl,
848
+ baseUrl: baseUrl2,
849
849
  accessToken: input.accessToken
850
850
  });
851
851
  }
@@ -856,20 +856,20 @@ function createConfigFromComponents(input) {
856
856
  const validEnvs = ["dev", "stg", "prod", "prev"];
857
857
  const env = validEnvs.includes(envSegment) ? envSegment : "prod";
858
858
  const slug = resolvedSlug.trim().toLowerCase();
859
- let baseUrl;
859
+ let baseUrl2;
860
860
  if (input.platformUrl) {
861
861
  const platform = input.platformUrl.trim().replace(/\/$/, "");
862
- baseUrl = platform.includes("/v1") ? platform : `${platform}/v1`;
862
+ baseUrl2 = platform.includes("/v1") ? platform : `${platform}/v1`;
863
863
  } else {
864
864
  const domain = input.domain?.trim() || DEFAULT_SDK_API_HOST;
865
- baseUrl = `https://${slug}.${domain}/v1`;
865
+ baseUrl2 = `https://${slug}.${domain}/v1`;
866
866
  }
867
867
  return freezeConfig({
868
868
  credential: trimmedCred,
869
869
  credentialType: prefix,
870
870
  env,
871
871
  slug,
872
- baseUrl,
872
+ baseUrl: baseUrl2,
873
873
  accessToken: input.accessToken
874
874
  });
875
875
  }
@@ -1924,7 +1924,8 @@ var PLATFORM_PLANS = {
1924
1924
  maxProjects: 1,
1925
1925
  maxMembers: 1,
1926
1926
  maxCustomDomains: 0,
1927
- maxConcurrentRunners: 1,
1927
+ // Industry peer: GitHub Free concurrent jobs = 20 (was 1 — sub-peer).
1928
+ maxConcurrentRunners: 20,
1928
1929
  maxMacosRunners: 0,
1929
1930
  maxDatabases: 1,
1930
1931
  ciMaxJobDurationSeconds: 30 * 60,
@@ -1976,7 +1977,8 @@ var PLATFORM_PLANS = {
1976
1977
  maxProjects: 10,
1977
1978
  maxMembers: 10,
1978
1979
  maxCustomDomains: 5,
1979
- maxConcurrentRunners: 5,
1980
+ // Not worse than free floor / GitHub Free peer (was 5).
1981
+ maxConcurrentRunners: 20,
1980
1982
  maxMacosRunners: 1,
1981
1983
  maxDatabases: 10,
1982
1984
  ciMaxJobDurationSeconds: 60 * 60,
@@ -2019,7 +2021,8 @@ var PLATFORM_PLANS = {
2019
2021
  maxMembers: 25,
2020
2022
  maxCustomDomains: null,
2021
2023
  // unlimited
2022
- maxConcurrentRunners: 20,
2024
+ // Industry peer: GitHub Pro concurrent jobs = 40 (was 20 — sub-peer).
2025
+ maxConcurrentRunners: 40,
2023
2026
  maxMacosRunners: 5,
2024
2027
  maxDatabases: null,
2025
2028
  // unlimited
@@ -2414,8 +2417,8 @@ async function runPipeline(middlewares, initial) {
2414
2417
  }
2415
2418
  return response;
2416
2419
  }
2417
- function buildUrl(baseUrl, path, params) {
2418
- const url = `${baseUrl}${path}`;
2420
+ function buildUrl(baseUrl2, path, params) {
2421
+ const url = `${baseUrl2}${path}`;
2419
2422
  if (!params) return url;
2420
2423
  const entries = Object.entries(params).filter(([, v]) => v !== void 0);
2421
2424
  if (entries.length === 0) return url;
@@ -2437,9 +2440,9 @@ function interpolatePath(path, pathParams) {
2437
2440
  return encodeURIComponent(value);
2438
2441
  });
2439
2442
  }
2440
- async function executeRequest(method, baseUrl, path, options, baseHeaders, middlewares) {
2443
+ async function executeRequest(method, baseUrl2, path, options, baseHeaders, middlewares) {
2441
2444
  const finalPath = interpolatePath(path, options?.params?.path);
2442
- const url = buildUrl(baseUrl, finalPath, options?.params?.query);
2445
+ const url = buildUrl(baseUrl2, finalPath, options?.params?.query);
2443
2446
  const headers = { ...baseHeaders, ...options?.headers };
2444
2447
  const init = { method, headers };
2445
2448
  if (options?.body !== void 0) {
@@ -2471,9 +2474,9 @@ async function executeRequest(method, baseUrl, path, options, baseHeaders, middl
2471
2474
  }
2472
2475
  return { error: parsed, response };
2473
2476
  }
2474
- function buildClient(baseUrl, baseHeaders) {
2477
+ function buildClient(baseUrl2, baseHeaders) {
2475
2478
  const middlewares = [];
2476
- const dispatch = (method) => (path, options) => executeRequest(method, baseUrl, path, options, baseHeaders, middlewares);
2479
+ const dispatch = (method) => (path, options) => executeRequest(method, baseUrl2, path, options, baseHeaders, middlewares);
2477
2480
  const client = {
2478
2481
  GET: dispatch("GET"),
2479
2482
  POST: dispatch("POST"),
@@ -2816,8 +2819,8 @@ function validateClientConfig(config) {
2816
2819
  };
2817
2820
  }
2818
2821
  function createRestClient(config) {
2819
- const { secretKey, baseUrl } = validateClientConfig(config);
2820
- const { client, middlewares } = buildClient(`${baseUrl}${SDK_API_PATH}`, {
2822
+ const { secretKey, baseUrl: baseUrl2 } = validateClientConfig(config);
2823
+ const { client, middlewares } = buildClient(`${baseUrl2}${SDK_API_PATH}`, {
2821
2824
  "Content-Type": "application/json",
2822
2825
  "x-app-secret": secretKey
2823
2826
  });
@@ -2834,13 +2837,13 @@ function createRestClient(config) {
2834
2837
  return client;
2835
2838
  }
2836
2839
  function createDynamicRestClient(config) {
2837
- const { secretKey, baseUrl } = validateClientConfig(config);
2840
+ const { secretKey, baseUrl: baseUrl2 } = validateClientConfig(config);
2838
2841
  const validatedConfig = {
2839
2842
  ...config,
2840
2843
  secretKey,
2841
- platformUrl: baseUrl
2844
+ platformUrl: baseUrl2
2842
2845
  };
2843
- const { client, middlewares } = buildClient(`${baseUrl}${SDK_API_PATH}`, {
2846
+ const { client, middlewares } = buildClient(`${baseUrl2}${SDK_API_PATH}`, {
2844
2847
  "Content-Type": "application/json"
2845
2848
  });
2846
2849
  if (config.deduplication !== false) {
@@ -2874,7 +2877,7 @@ function getRestErrorMessage(error) {
2874
2877
  init_errors();
2875
2878
 
2876
2879
  // src/auth.ts
2877
- import { authEndpoints } from "@sylphx/contract";
2880
+ import { authEndpoints as authEndpoints4 } from "@sylphx/contract";
2878
2881
 
2879
2882
  // src/dpop.ts
2880
2883
  var dpop = {
@@ -2964,15 +2967,37 @@ function randomJti() {
2964
2967
  return base64UrlEncode(bytes);
2965
2968
  }
2966
2969
 
2970
+ // src/platform-auth.ts
2971
+ import { authEndpoints, refreshEndpoints } from "@sylphx/contract";
2972
+
2973
+ // src/contract-http.ts
2974
+ function baseUrl(url) {
2975
+ return url.replace(/\/$/, "");
2976
+ }
2977
+ function interpolatePath2(template, params) {
2978
+ let path = template;
2979
+ for (const [key, value] of Object.entries(params)) {
2980
+ path = path.replace(`:${key}`, encodeURIComponent(value));
2981
+ }
2982
+ return path;
2983
+ }
2984
+ function buildEndpointUrl(base, path, query) {
2985
+ const url = new URL(`${baseUrl(base)}${path}`);
2986
+ for (const [key, value] of Object.entries(query ?? {})) {
2987
+ if (value !== void 0) url.searchParams.set(key, value);
2988
+ }
2989
+ return url.toString();
2990
+ }
2991
+
2967
2992
  // src/platform-auth.ts
2968
2993
  init_errors();
2969
2994
  var platformAuth = {
2970
2995
  async refresh(opts) {
2971
2996
  const headers = { "Content-Type": "application/json" };
2972
2997
  if (opts.userAgent) headers["User-Agent"] = opts.userAgent;
2973
- const prefix = opts.urlPrefix ?? "/api/v1";
2974
- const res = await fetch(`${opts.baseUrl.replace(/\/$/, "")}${prefix}/auth/refresh`, {
2975
- method: "POST",
2998
+ const endpoint = refreshEndpoints.refresh;
2999
+ const res = await fetch(platformAuthEndpointUrl(opts, endpoint.path), {
3000
+ method: endpoint.method,
2976
3001
  headers,
2977
3002
  body: JSON.stringify({ refresh_token: opts.refreshToken })
2978
3003
  });
@@ -2982,15 +3007,19 @@ var platformAuth = {
2982
3007
  async logout(opts) {
2983
3008
  const headers = { "Content-Type": "application/json" };
2984
3009
  if (opts.userAgent) headers["User-Agent"] = opts.userAgent;
2985
- const prefix = opts.urlPrefix ?? "/api/v1";
2986
- const res = await fetch(`${opts.baseUrl.replace(/\/$/, "")}${prefix}/auth/logout`, {
2987
- method: "POST",
3010
+ const endpoint = authEndpoints.signOut;
3011
+ const res = await fetch(platformAuthEndpointUrl(opts, endpoint.path), {
3012
+ method: endpoint.method,
2988
3013
  headers,
2989
3014
  body: JSON.stringify({ refresh_token: opts.refreshToken })
2990
3015
  });
2991
3016
  if (!res.ok) throw await platformAuthError(res, "platformAuth.logout");
2992
3017
  }
2993
3018
  };
3019
+ function platformAuthEndpointUrl(opts, path) {
3020
+ const prefix = opts.urlPrefix ?? "/api/v1";
3021
+ return buildEndpointUrl(`${opts.baseUrl.replace(/\/$/, "")}${prefix}`, path);
3022
+ }
2994
3023
  async function platformAuthError(res, operation) {
2995
3024
  const body = await res.text().catch(() => "");
2996
3025
  let code = "platform_auth_error";
@@ -3183,10 +3212,10 @@ function resetPlatformJwksCache() {
3183
3212
  jwtJwksCache = null;
3184
3213
  }
3185
3214
  var PLATFORM_JWKS_TTL_MS = 60 * 60 * 1e3;
3186
- async function fetchPlatformJwks(baseUrl) {
3215
+ async function fetchPlatformJwks(baseUrl2) {
3187
3216
  const now = Date.now();
3188
3217
  if (jwtJwksCache && jwtJwksCache.expiresAt > now) return jwtJwksCache.keys;
3189
- const root = baseUrl.replace(/\/$/, "").replace(/\/v1$/, "");
3218
+ const root = baseUrl2.replace(/\/$/, "").replace(/\/v1$/, "");
3190
3219
  const res = await fetch(`${root}/.well-known/jwks.json`);
3191
3220
  if (!res.ok) throw new Error(`JWKS fetch failed: HTTP ${res.status}`);
3192
3221
  const data = await res.json();
@@ -3596,19 +3625,22 @@ async function platformJwtError(res, operation) {
3596
3625
  }
3597
3626
 
3598
3627
  // src/platform-password.ts
3628
+ import { authEndpoints as authEndpoints2 } from "@sylphx/contract";
3599
3629
  init_errors();
3600
3630
  var password = {
3601
3631
  async status(opts) {
3602
- const res = await fetch(`${opts.baseUrl.replace(/\/$/, "")}/auth/platform-password/status`, {
3603
- method: "GET",
3632
+ const endpoint = authEndpoints2.platformPasswordStatus;
3633
+ const res = await fetch(buildEndpointUrl(opts.baseUrl, endpoint.path), {
3634
+ method: endpoint.method,
3604
3635
  headers: buildPlatformPasswordHeaders(opts.accessToken, opts.userAgent)
3605
3636
  });
3606
3637
  if (!res.ok) throw await platformPasswordError(res, "password.status");
3607
3638
  return await res.json();
3608
3639
  },
3609
3640
  async set(opts) {
3610
- const res = await fetch(`${opts.baseUrl.replace(/\/$/, "")}/auth/platform-password/set`, {
3611
- method: "POST",
3641
+ const endpoint = authEndpoints2.platformPasswordSet;
3642
+ const res = await fetch(buildEndpointUrl(opts.baseUrl, endpoint.path), {
3643
+ method: endpoint.method,
3612
3644
  headers: buildPlatformPasswordHeaders(opts.accessToken, opts.userAgent),
3613
3645
  body: JSON.stringify({
3614
3646
  password: opts.password
@@ -3618,8 +3650,9 @@ var password = {
3618
3650
  return await res.json();
3619
3651
  },
3620
3652
  async change(opts) {
3621
- const res = await fetch(`${opts.baseUrl.replace(/\/$/, "")}/auth/platform-password/change`, {
3622
- method: "POST",
3653
+ const endpoint = authEndpoints2.platformPasswordChange;
3654
+ const res = await fetch(buildEndpointUrl(opts.baseUrl, endpoint.path), {
3655
+ method: endpoint.method,
3623
3656
  headers: buildPlatformPasswordHeaders(opts.accessToken, opts.userAgent),
3624
3657
  body: JSON.stringify({
3625
3658
  currentPassword: opts.currentPassword,
@@ -3663,19 +3696,22 @@ async function platformPasswordError(res, operation) {
3663
3696
  }
3664
3697
 
3665
3698
  // src/platform-sessions.ts
3699
+ import { authEndpoints as authEndpoints3 } from "@sylphx/contract";
3666
3700
  init_errors();
3667
3701
  var sessions = {
3668
3702
  async list(opts) {
3669
- const res = await fetch(`${opts.baseUrl.replace(/\/$/, "")}/auth/platform-sessions`, {
3670
- method: "GET",
3703
+ const endpoint = authEndpoints3.platformSessionsList;
3704
+ const res = await fetch(buildEndpointUrl(opts.baseUrl, endpoint.path), {
3705
+ method: endpoint.method,
3671
3706
  headers: buildPlatformSessionsHeaders(opts.accessToken, opts.userAgent)
3672
3707
  });
3673
3708
  if (!res.ok) throw await platformSessionError(res, "sessions.list");
3674
3709
  return await res.json();
3675
3710
  },
3676
3711
  async revoke(opts) {
3677
- const res = await fetch(`${opts.baseUrl.replace(/\/$/, "")}/auth/platform-sessions/revoke`, {
3678
- method: "POST",
3712
+ const endpoint = authEndpoints3.platformSessionsRevoke;
3713
+ const res = await fetch(buildEndpointUrl(opts.baseUrl, endpoint.path), {
3714
+ method: endpoint.method,
3679
3715
  headers: buildPlatformSessionsHeaders(opts.accessToken, opts.userAgent),
3680
3716
  body: JSON.stringify({ sessionId: opts.sessionId })
3681
3717
  });
@@ -3683,30 +3719,27 @@ var sessions = {
3683
3719
  return await res.json();
3684
3720
  },
3685
3721
  async revokeOther(opts) {
3686
- const res = await fetch(
3687
- `${opts.baseUrl.replace(/\/$/, "")}/auth/platform-sessions/revoke-other`,
3688
- {
3689
- method: "POST",
3690
- headers: buildPlatformSessionsHeaders(opts.accessToken, opts.userAgent)
3691
- }
3692
- );
3722
+ const endpoint = authEndpoints3.platformSessionsRevokeOther;
3723
+ const res = await fetch(buildEndpointUrl(opts.baseUrl, endpoint.path), {
3724
+ method: endpoint.method,
3725
+ headers: buildPlatformSessionsHeaders(opts.accessToken, opts.userAgent)
3726
+ });
3693
3727
  if (!res.ok) throw await platformSessionError(res, "sessions.revokeOther");
3694
3728
  return await res.json();
3695
3729
  },
3696
3730
  async revokeAll(opts) {
3697
- const res = await fetch(
3698
- `${opts.baseUrl.replace(/\/$/, "")}/auth/platform-sessions/revoke-all`,
3699
- {
3700
- method: "POST",
3701
- headers: buildPlatformSessionsHeaders(opts.accessToken, opts.userAgent)
3702
- }
3703
- );
3731
+ const endpoint = authEndpoints3.platformSessionsRevokeAll;
3732
+ const res = await fetch(buildEndpointUrl(opts.baseUrl, endpoint.path), {
3733
+ method: endpoint.method,
3734
+ headers: buildPlatformSessionsHeaders(opts.accessToken, opts.userAgent)
3735
+ });
3704
3736
  if (!res.ok) throw await platformSessionError(res, "sessions.revokeAll");
3705
3737
  return await res.json();
3706
3738
  },
3707
3739
  async rename(opts) {
3708
- const res = await fetch(`${opts.baseUrl.replace(/\/$/, "")}/auth/platform-sessions/rename`, {
3709
- method: "POST",
3740
+ const endpoint = authEndpoints3.platformSessionsRename;
3741
+ const res = await fetch(buildEndpointUrl(opts.baseUrl, endpoint.path), {
3742
+ method: endpoint.method,
3710
3743
  headers: buildPlatformSessionsHeaders(opts.accessToken, opts.userAgent),
3711
3744
  body: JSON.stringify({
3712
3745
  sessionId: opts.sessionId,
@@ -3904,21 +3937,21 @@ async function signInAsService(config, credentials) {
3904
3937
  // src/auth.ts
3905
3938
  async function signIn(config, input) {
3906
3939
  const body = input;
3907
- const endpoint = authEndpoints.signIn;
3940
+ const endpoint = authEndpoints4.signIn;
3908
3941
  return callApi(config, endpoint.path, {
3909
3942
  method: endpoint.method,
3910
3943
  body
3911
3944
  });
3912
3945
  }
3913
3946
  async function signUp(config, input) {
3914
- const endpoint = authEndpoints.signUp;
3947
+ const endpoint = authEndpoints4.signUp;
3915
3948
  return callApi(config, endpoint.path, {
3916
3949
  method: endpoint.method,
3917
3950
  body: input
3918
3951
  });
3919
3952
  }
3920
3953
  async function signOut(config) {
3921
- const endpoint = authEndpoints.signOut;
3954
+ const endpoint = authEndpoints4.signOut;
3922
3955
  await callApi(config, endpoint.path, { method: endpoint.method });
3923
3956
  }
3924
3957
  async function refreshToken(config, token) {
@@ -3947,7 +3980,7 @@ async function forgotPassword(config, email, options = {}) {
3947
3980
  });
3948
3981
  }
3949
3982
  async function resendVerificationEmail(config, email) {
3950
- const endpoint = authEndpoints.resendEmailVerification;
3983
+ const endpoint = authEndpoints4.resendEmailVerification;
3951
3984
  const body = { email };
3952
3985
  await callApi(config, endpoint.path, {
3953
3986
  method: endpoint.method,
@@ -3964,7 +3997,7 @@ async function getSession(config) {
3964
3997
  if (!config.accessToken) {
3965
3998
  return { user: null };
3966
3999
  }
3967
- const endpoint = authEndpoints.getSession;
4000
+ const endpoint = authEndpoints4.getSession;
3968
4001
  try {
3969
4002
  const user2 = await callApi(config, endpoint.path, {
3970
4003
  method: endpoint.method
@@ -4159,6 +4192,7 @@ async function deviceError(res, operation) {
4159
4192
  }
4160
4193
 
4161
4194
  // src/audit.ts
4195
+ import { auditEndpoints } from "@sylphx/contract";
4162
4196
  function buildHeaders2(accessToken, userAgent) {
4163
4197
  const headers = {
4164
4198
  Accept: "application/json",
@@ -4193,19 +4227,21 @@ async function auditError(res, operation) {
4193
4227
  }
4194
4228
  var audit = {
4195
4229
  async query(opts) {
4196
- const url = new URL(`${opts.baseUrl.replace(/\/$/, "")}/audit/query`);
4230
+ const endpoint = auditEndpoints.query;
4197
4231
  const f = opts.filter ?? {};
4198
- if (f.scope) url.searchParams.set("scope", f.scope);
4199
- if (f.actor) url.searchParams.set("actor", f.actor);
4200
- if (f.resourceType) url.searchParams.set("resource_type", f.resourceType);
4201
- if (f.resourceId) url.searchParams.set("resource_id", f.resourceId);
4202
- if (f.action) url.searchParams.set("action", f.action);
4203
- if (f.from) url.searchParams.set("from", f.from);
4204
- if (f.to) url.searchParams.set("to", f.to);
4205
- if (f.cursor) url.searchParams.set("cursor", f.cursor);
4206
- if (f.limit !== void 0) url.searchParams.set("limit", String(f.limit));
4207
- const res = await fetch(url.toString(), {
4208
- method: "GET",
4232
+ const url = buildEndpointUrl(opts.baseUrl, endpoint.path, {
4233
+ scope: f.scope,
4234
+ actor: f.actor,
4235
+ resource_type: f.resourceType,
4236
+ resource_id: f.resourceId,
4237
+ action: f.action,
4238
+ from: f.from,
4239
+ to: f.to,
4240
+ cursor: f.cursor,
4241
+ limit: f.limit === void 0 ? void 0 : String(f.limit)
4242
+ });
4243
+ const res = await fetch(url, {
4244
+ method: endpoint.method,
4209
4245
  headers: buildHeaders2(opts.accessToken, opts.userAgent)
4210
4246
  });
4211
4247
  if (!res.ok) throw await auditError(res, "audit.query");
@@ -4214,6 +4250,7 @@ var audit = {
4214
4250
  };
4215
4251
 
4216
4252
  // src/rate-limits.ts
4253
+ import { rateLimitsEndpoints } from "@sylphx/contract";
4217
4254
  function buildHeaders3(accessToken, userAgent) {
4218
4255
  const headers = {
4219
4256
  Accept: "application/json",
@@ -4249,54 +4286,74 @@ async function rateLimitError(res, operation) {
4249
4286
  }
4250
4287
  var rateLimits = {
4251
4288
  async status(opts) {
4252
- const url = new URL(`${opts.baseUrl.replace(/\/$/, "")}/rate-limits/status`);
4289
+ const endpoint = rateLimitsEndpoints.status;
4253
4290
  const f = opts.filter ?? {};
4254
- if (f.scope) url.searchParams.set("scope", f.scope);
4255
- if (f.scope_id) url.searchParams.set("scope_id", f.scope_id);
4256
- if (f.namespace) url.searchParams.set("namespace", f.namespace);
4257
- const res = await fetch(url.toString(), {
4258
- method: "GET",
4259
- headers: buildHeaders3(opts.accessToken, opts.userAgent)
4260
- });
4291
+ const res = await fetch(
4292
+ buildEndpointUrl(opts.baseUrl, endpoint.path, {
4293
+ scope: f.scope,
4294
+ scope_id: f.scope_id,
4295
+ namespace: f.namespace
4296
+ }),
4297
+ {
4298
+ method: endpoint.method,
4299
+ headers: buildHeaders3(opts.accessToken, opts.userAgent)
4300
+ }
4301
+ );
4261
4302
  if (!res.ok) throw await rateLimitError(res, "rateLimits.status");
4262
4303
  return await res.json();
4263
4304
  },
4264
4305
  strategies: {
4265
4306
  async list(opts) {
4266
- const url = new URL(`${opts.baseUrl.replace(/\/$/, "")}/rate-limits/strategies`);
4307
+ const endpoint = rateLimitsEndpoints.strategiesList;
4267
4308
  const f = opts.filter ?? {};
4268
- if (f.scope) url.searchParams.set("scope", f.scope);
4269
- if (f.scope_id) url.searchParams.set("scope_id", f.scope_id);
4270
- const res = await fetch(url.toString(), {
4271
- method: "GET",
4272
- headers: buildHeaders3(opts.accessToken, opts.userAgent)
4273
- });
4309
+ const res = await fetch(
4310
+ buildEndpointUrl(opts.baseUrl, endpoint.path, {
4311
+ scope: f.scope,
4312
+ scope_id: f.scope_id
4313
+ }),
4314
+ {
4315
+ method: endpoint.method,
4316
+ headers: buildHeaders3(opts.accessToken, opts.userAgent)
4317
+ }
4318
+ );
4274
4319
  if (!res.ok) throw await rateLimitError(res, "rateLimits.strategies.list");
4275
4320
  return await res.json();
4276
4321
  },
4277
4322
  async set(opts) {
4278
- const url = `${opts.baseUrl.replace(/\/$/, "")}/rate-limits/strategies/${encodeURIComponent(opts.namespace)}`;
4279
- const res = await fetch(url, {
4280
- method: "PUT",
4281
- headers: {
4282
- ...buildHeaders3(opts.accessToken, opts.userAgent),
4283
- "content-type": "application/json"
4284
- },
4285
- body: JSON.stringify(opts.body)
4286
- });
4323
+ const endpoint = rateLimitsEndpoints.strategyUpsert;
4324
+ const res = await fetch(
4325
+ buildEndpointUrl(
4326
+ opts.baseUrl,
4327
+ interpolatePath2(endpoint.path, { namespace: opts.namespace })
4328
+ ),
4329
+ {
4330
+ method: endpoint.method,
4331
+ headers: {
4332
+ ...buildHeaders3(opts.accessToken, opts.userAgent),
4333
+ "content-type": "application/json"
4334
+ },
4335
+ body: JSON.stringify(opts.body)
4336
+ }
4337
+ );
4287
4338
  if (!res.ok) throw await rateLimitError(res, "rateLimits.strategies.set");
4288
4339
  return await res.json();
4289
4340
  },
4290
4341
  async delete(opts) {
4291
- const url = `${opts.baseUrl.replace(/\/$/, "")}/rate-limits/strategies/${encodeURIComponent(opts.namespace)}`;
4292
- const res = await fetch(url, {
4293
- method: "DELETE",
4294
- headers: {
4295
- ...buildHeaders3(opts.accessToken, opts.userAgent),
4296
- "content-type": "application/json"
4297
- },
4298
- body: JSON.stringify(opts.body)
4299
- });
4342
+ const endpoint = rateLimitsEndpoints.strategyDelete;
4343
+ const res = await fetch(
4344
+ buildEndpointUrl(
4345
+ opts.baseUrl,
4346
+ interpolatePath2(endpoint.path, { namespace: opts.namespace })
4347
+ ),
4348
+ {
4349
+ method: endpoint.method,
4350
+ headers: {
4351
+ ...buildHeaders3(opts.accessToken, opts.userAgent),
4352
+ "content-type": "application/json"
4353
+ },
4354
+ body: JSON.stringify(opts.body)
4355
+ }
4356
+ );
4300
4357
  if (!res.ok) throw await rateLimitError(res, "rateLimits.strategies.delete");
4301
4358
  return await res.json();
4302
4359
  }
@@ -4813,6 +4870,7 @@ async function getBillingUsage(config, options) {
4813
4870
  }
4814
4871
 
4815
4872
  // src/storage.ts
4873
+ import { storageEndpoints } from "@sylphx/contract";
4816
4874
  init_errors();
4817
4875
 
4818
4876
  // src/lib/retry.ts
@@ -4925,18 +4983,24 @@ function randomBytes(n) {
4925
4983
 
4926
4984
  // src/storage.ts
4927
4985
  var PATHS = {
4928
- uploads: "/storage/uploads",
4929
- upload: (id) => `/storage/uploads/${encodeURIComponent(String(id))}`,
4930
- uploadComplete: (id) => `/storage/uploads/${encodeURIComponent(String(id))}:complete`,
4931
- uploadPart: (id, n) => `/storage/uploads/${encodeURIComponent(String(id))}/parts/${n}`,
4932
- files: "/storage/files",
4933
- file: (id) => `/storage/files/${encodeURIComponent(String(id))}`,
4934
- fileTakedown: (id) => `/storage/files/${encodeURIComponent(String(id))}:takedown`,
4935
- fileRestore: (id) => `/storage/files/${encodeURIComponent(String(id))}:restore`,
4936
- fileSignedUrl: (id) => `/storage/files/${encodeURIComponent(String(id))}:signedUrl`,
4937
- fileCopy: (id) => `/storage/files/${encodeURIComponent(String(id))}:copy`,
4938
- versions: (id) => `/storage/files/${encodeURIComponent(String(id))}/versions`,
4939
- versionRestore: (id, vid) => `/storage/files/${encodeURIComponent(String(id))}/versions/${encodeURIComponent(String(vid))}:restore`
4986
+ uploads: storageEndpoints.createUpload.path,
4987
+ upload: (id) => interpolatePath2(storageEndpoints.abortUpload.path, { uploadId: String(id) }),
4988
+ uploadComplete: (id) => interpolatePath2(storageEndpoints.completeUpload.path, { uploadId: String(id) }),
4989
+ uploadPart: (id, n) => interpolatePath2(storageEndpoints.presignUploadPart.path, {
4990
+ uploadId: String(id),
4991
+ partNumber: String(n)
4992
+ }),
4993
+ files: storageEndpoints.listFiles.path,
4994
+ file: (id) => interpolatePath2(storageEndpoints.getFile.path, { fileId: String(id) }),
4995
+ fileTakedown: (id) => interpolatePath2(storageEndpoints.takedownFile.path, { fileId: String(id) }),
4996
+ fileRestore: (id) => interpolatePath2(storageEndpoints.restoreFile.path, { fileId: String(id) }),
4997
+ fileSignedUrl: (id) => interpolatePath2(storageEndpoints.signFileUrl.path, { fileId: String(id) }),
4998
+ fileCopy: (id) => interpolatePath2(storageEndpoints.copyFile.path, { fileId: String(id) }),
4999
+ versions: (id) => interpolatePath2(storageEndpoints.listFileVersions.path, { fileId: String(id) }),
5000
+ versionRestore: (id, vid) => interpolatePath2(storageEndpoints.restoreFileVersion.path, {
5001
+ fileId: String(id),
5002
+ versionId: String(vid)
5003
+ })
4940
5004
  };
4941
5005
  var hasXhr = () => typeof globalThis.XMLHttpRequest !== "undefined";
4942
5006
  var hasLocalStorage = () => {
@@ -5134,7 +5198,7 @@ async function uploadsCreate(config, blob, options) {
5134
5198
  ifNoneMatch: options.ifNoneMatch
5135
5199
  };
5136
5200
  const session = await callApi(config, PATHS.uploads, {
5137
- method: "POST",
5201
+ method: storageEndpoints.createUpload.method,
5138
5202
  body: createBody,
5139
5203
  idempotencyKey,
5140
5204
  signal
@@ -5142,7 +5206,7 @@ async function uploadsCreate(config, blob, options) {
5142
5206
  const uploadId = session.uploadId;
5143
5207
  const onAborted = async () => {
5144
5208
  try {
5145
- await callApi(config, PATHS.upload(uploadId), { method: "DELETE" });
5209
+ await callApi(config, PATHS.upload(uploadId), { method: storageEndpoints.abortUpload.method });
5146
5210
  } catch {
5147
5211
  }
5148
5212
  clearResume(String(uploadId));
@@ -5174,7 +5238,7 @@ async function runSinglePart(config, blob, session, options, idempotencyKey) {
5174
5238
  config,
5175
5239
  PATHS.uploadComplete(session.uploadId),
5176
5240
  {
5177
- method: "POST",
5241
+ method: storageEndpoints.completeUpload.method,
5178
5242
  body: { parts: [{ partNumber: 1, etag: put.etag }] },
5179
5243
  idempotencyKey: `${idempotencyKey}:complete`,
5180
5244
  signal
@@ -5219,7 +5283,7 @@ async function runMultipart(config, blob, session, options, idempotencyKey) {
5219
5283
  config,
5220
5284
  PATHS.uploadComplete(session.uploadId),
5221
5285
  {
5222
- method: "POST",
5286
+ method: storageEndpoints.completeUpload.method,
5223
5287
  body: { parts: completedParts },
5224
5288
  idempotencyKey: `${idempotencyKey}:complete`,
5225
5289
  signal
@@ -5229,9 +5293,12 @@ async function runMultipart(config, blob, session, options, idempotencyKey) {
5229
5293
  return fileFromCompletion(completion, options, blob);
5230
5294
  }
5231
5295
  async function uploadsAbort(config, uploadId) {
5232
- await withRetry(() => callApi(config, PATHS.upload(uploadId), { method: "DELETE" }), {
5233
- maxRetries: 3
5234
- });
5296
+ await withRetry(
5297
+ () => callApi(config, PATHS.upload(uploadId), { method: storageEndpoints.abortUpload.method }),
5298
+ {
5299
+ maxRetries: 3
5300
+ }
5301
+ );
5235
5302
  clearResume(String(uploadId));
5236
5303
  }
5237
5304
  function filesListPage(config, options, cursor) {
@@ -5242,7 +5309,7 @@ function filesListPage(config, options, cursor) {
5242
5309
  includeDeleted: options.includeDeleted
5243
5310
  };
5244
5311
  return callApi(config, PATHS.files, {
5245
- method: "GET",
5312
+ method: storageEndpoints.listFiles.method,
5246
5313
  query: {
5247
5314
  folder: query.folder,
5248
5315
  cursor: query.cursor,
@@ -5266,19 +5333,23 @@ function filesList(config, options = {}) {
5266
5333
  return Object.assign(iter, { fetchPage });
5267
5334
  }
5268
5335
  async function filesGet(config, fileId) {
5269
- return callApi(config, PATHS.file(fileId), { method: "GET" });
5336
+ return callApi(config, PATHS.file(fileId), {
5337
+ method: storageEndpoints.getFile.method
5338
+ });
5270
5339
  }
5271
5340
  async function filesDelete(config, fileId) {
5272
- return callApi(config, PATHS.file(fileId), { method: "DELETE" });
5341
+ return callApi(config, PATHS.file(fileId), { method: storageEndpoints.deleteFile.method });
5273
5342
  }
5274
5343
  async function filesTakedown(config, fileId, options) {
5275
5344
  return callApi(config, PATHS.fileTakedown(fileId), {
5276
- method: "POST",
5345
+ method: storageEndpoints.takedownFile.method,
5277
5346
  body: options
5278
5347
  });
5279
5348
  }
5280
5349
  async function filesRestore(config, fileId) {
5281
- return callApi(config, PATHS.fileRestore(fileId), { method: "POST" });
5350
+ return callApi(config, PATHS.fileRestore(fileId), {
5351
+ method: storageEndpoints.restoreFile.method
5352
+ });
5282
5353
  }
5283
5354
  async function filesSignedUrl(config, fileId, options = {}) {
5284
5355
  const body = {
@@ -5287,7 +5358,7 @@ async function filesSignedUrl(config, fileId, options = {}) {
5287
5358
  userId: options.userId
5288
5359
  };
5289
5360
  return callApi(config, PATHS.fileSignedUrl(fileId), {
5290
- method: "POST",
5361
+ method: storageEndpoints.signFileUrl.method,
5291
5362
  body
5292
5363
  });
5293
5364
  }
@@ -5299,18 +5370,20 @@ async function filesCopy(config, fileId, options) {
5299
5370
  metadata: options.metadata
5300
5371
  };
5301
5372
  return callApi(config, PATHS.fileCopy(fileId), {
5302
- method: "POST",
5373
+ method: storageEndpoints.copyFile.method,
5303
5374
  body
5304
5375
  });
5305
5376
  }
5306
5377
  async function filesVersionsList(config, fileId) {
5307
5378
  const data = await callApi(config, PATHS.versions(fileId), {
5308
- method: "GET"
5379
+ method: storageEndpoints.listFileVersions.method
5309
5380
  });
5310
5381
  return data.versions;
5311
5382
  }
5312
5383
  async function filesVersionsRestore(config, fileId, versionId) {
5313
- return callApi(config, PATHS.versionRestore(fileId, versionId), { method: "POST" });
5384
+ return callApi(config, PATHS.versionRestore(fileId, versionId), {
5385
+ method: storageEndpoints.restoreFileVersion.method
5386
+ });
5314
5387
  }
5315
5388
  var storage = {
5316
5389
  uploads: {
@@ -5484,6 +5557,7 @@ async function registerPushServiceWorker(swPath = "/sw.js") {
5484
5557
  }
5485
5558
 
5486
5559
  // src/notifications.ts
5560
+ import { notificationsEndpoints } from "@sylphx/contract";
5487
5561
  function resolveSentCount(result) {
5488
5562
  if (result.sent !== void 0) return result.sent;
5489
5563
  if (result.sentTo !== void 0) return result.sentTo;
@@ -5495,14 +5569,16 @@ function resolveFailedCount(result) {
5495
5569
  return result.status === "failed" ? 1 : 0;
5496
5570
  }
5497
5571
  async function registerPush(config, subscription) {
5498
- await callApi(config, "/notifications/register", {
5499
- method: "POST",
5572
+ const endpoint = notificationsEndpoints.registerPush;
5573
+ await callApi(config, endpoint.path, {
5574
+ method: endpoint.method,
5500
5575
  body: { subscription }
5501
5576
  });
5502
5577
  }
5503
5578
  async function unregisterPush(config, endpoint) {
5504
- await callApi(config, "/notifications/unregister", {
5505
- method: "POST",
5579
+ const route = notificationsEndpoints.unregisterPush;
5580
+ await callApi(config, route.path, {
5581
+ method: route.method,
5506
5582
  body: { endpoint }
5507
5583
  });
5508
5584
  }
@@ -5514,8 +5590,9 @@ async function sendPush(config, userId, notification) {
5514
5590
  ...notification.icon !== void 0 && { icon: notification.icon },
5515
5591
  ...notification.url !== void 0 && { url: notification.url }
5516
5592
  };
5517
- const result = await callApi(config, "/notifications/send", {
5518
- method: "POST",
5593
+ const endpoint = notificationsEndpoints.sendPush;
5594
+ const result = await callApi(config, endpoint.path, {
5595
+ method: endpoint.method,
5519
5596
  body
5520
5597
  });
5521
5598
  const sent = resolveSentCount(result);
@@ -5529,49 +5606,61 @@ async function sendPush(config, userId, notification) {
5529
5606
  };
5530
5607
  }
5531
5608
  async function getPushPreferences(config) {
5532
- return callApi(config, "/notifications/preferences", { method: "GET" });
5609
+ const endpoint = notificationsEndpoints.getPreferences;
5610
+ return callApi(config, endpoint.path, { method: endpoint.method });
5533
5611
  }
5534
5612
  async function updatePushPreferences(config, preferences) {
5535
- await callApi(config, "/notifications/preferences", {
5536
- method: "PUT",
5613
+ const endpoint = notificationsEndpoints.updatePreferences;
5614
+ await callApi(config, endpoint.path, {
5615
+ method: endpoint.method,
5537
5616
  body: preferences
5538
5617
  });
5539
5618
  }
5540
5619
  var segments = {
5541
5620
  async create(config, input) {
5542
- return callApi(config, "/notifications/segments", { method: "POST", body: input });
5621
+ const endpoint = notificationsEndpoints.createSegment;
5622
+ return callApi(config, endpoint.path, { method: endpoint.method, body: input });
5543
5623
  },
5544
5624
  async list(config) {
5545
- return callApi(config, "/notifications/segments", { method: "GET" });
5625
+ const endpoint = notificationsEndpoints.listSegments;
5626
+ return callApi(config, endpoint.path, { method: endpoint.method });
5546
5627
  },
5547
5628
  async get(config, id) {
5548
- return callApi(config, `/notifications/segments/${id}`, { method: "GET" });
5629
+ const endpoint = notificationsEndpoints.getSegment;
5630
+ return callApi(config, interpolatePath2(endpoint.path, { id }), { method: endpoint.method });
5549
5631
  },
5550
5632
  async delete(config, id) {
5551
- await callApi(config, `/notifications/segments/${id}`, { method: "DELETE" });
5633
+ const endpoint = notificationsEndpoints.deleteSegment;
5634
+ await callApi(config, interpolatePath2(endpoint.path, { id }), { method: endpoint.method });
5552
5635
  }
5553
5636
  };
5554
5637
  var campaigns = {
5555
5638
  async create(config, input) {
5556
- return callApi(config, "/notifications/campaigns", { method: "POST", body: input });
5639
+ const endpoint = notificationsEndpoints.createCampaign;
5640
+ return callApi(config, endpoint.path, { method: endpoint.method, body: input });
5557
5641
  },
5558
5642
  async get(config, id) {
5559
- return callApi(config, `/notifications/campaigns/${id}`, { method: "GET" });
5643
+ const endpoint = notificationsEndpoints.getCampaign;
5644
+ return callApi(config, interpolatePath2(endpoint.path, { id }), { method: endpoint.method });
5560
5645
  },
5561
5646
  async schedule(config, id, scheduledAt) {
5562
- return callApi(config, `/notifications/campaigns/${id}/schedule`, {
5563
- method: "POST",
5647
+ const endpoint = notificationsEndpoints.scheduleCampaign;
5648
+ return callApi(config, interpolatePath2(endpoint.path, { id }), {
5649
+ method: endpoint.method,
5564
5650
  body: { scheduledAt }
5565
5651
  });
5566
5652
  },
5567
5653
  async send(config, id) {
5568
- return callApi(config, `/notifications/campaigns/${id}/send`, { method: "POST" });
5654
+ const endpoint = notificationsEndpoints.sendCampaign;
5655
+ return callApi(config, interpolatePath2(endpoint.path, { id }), { method: endpoint.method });
5569
5656
  },
5570
5657
  async cancel(config, id) {
5571
- return callApi(config, `/notifications/campaigns/${id}/cancel`, { method: "POST" });
5658
+ const endpoint = notificationsEndpoints.cancelCampaign;
5659
+ return callApi(config, interpolatePath2(endpoint.path, { id }), { method: endpoint.method });
5572
5660
  },
5573
5661
  async stats(config, id) {
5574
- return callApi(config, `/notifications/campaigns/${id}/stats`, { method: "GET" });
5662
+ const endpoint = notificationsEndpoints.getCampaignStats;
5663
+ return callApi(config, interpolatePath2(endpoint.path, { id }), { method: endpoint.method });
5575
5664
  }
5576
5665
  };
5577
5666
 
@@ -6220,31 +6309,38 @@ async function getFlagPayload(config, flagKey, context) {
6220
6309
  }
6221
6310
 
6222
6311
  // src/webhooks.ts
6312
+ import { webhooksRuntimeEndpoints } from "@sylphx/contract";
6223
6313
  async function getWebhookConfig(config) {
6224
- return callApi(config, "/webhooks/config", { method: "GET" });
6314
+ const endpoint = webhooksRuntimeEndpoints.getConfig;
6315
+ return callApi(config, endpoint.path, { method: endpoint.method });
6225
6316
  }
6226
6317
  async function updateWebhookConfig(config, data) {
6227
- return callApi(config, "/webhooks/config", { method: "PUT", body: data });
6318
+ const endpoint = webhooksRuntimeEndpoints.updateConfig;
6319
+ return callApi(config, endpoint.path, { method: endpoint.method, body: data });
6228
6320
  }
6229
6321
  async function getWebhookDeliveries(config, options) {
6230
- return callApi(config, "/webhooks/deliveries", {
6231
- method: "GET",
6322
+ const endpoint = webhooksRuntimeEndpoints.listDeliveries;
6323
+ return callApi(config, endpoint.path, {
6324
+ method: endpoint.method,
6232
6325
  query: options
6233
6326
  });
6234
6327
  }
6235
6328
  async function getWebhookDelivery(config, deliveryId) {
6236
- return callApi(config, `/webhooks/deliveries/${deliveryId}`, {
6237
- method: "GET"
6329
+ const endpoint = webhooksRuntimeEndpoints.getDelivery;
6330
+ return callApi(config, interpolatePath2(endpoint.path, { deliveryId }), {
6331
+ method: endpoint.method
6238
6332
  });
6239
6333
  }
6240
6334
  async function replayWebhookDelivery(config, deliveryId) {
6241
- return callApi(config, `/webhooks/deliveries/${deliveryId}/replay`, {
6242
- method: "POST"
6335
+ const endpoint = webhooksRuntimeEndpoints.replayDelivery;
6336
+ return callApi(config, interpolatePath2(endpoint.path, { deliveryId }), {
6337
+ method: endpoint.method
6243
6338
  });
6244
6339
  }
6245
6340
  async function getWebhookStats(config, environmentId) {
6246
- return callApi(config, "/webhooks/stats", {
6247
- method: "GET",
6341
+ const endpoint = webhooksRuntimeEndpoints.getStats;
6342
+ return callApi(config, endpoint.path, {
6343
+ method: endpoint.method,
6248
6344
  query: environmentId ? { environmentId } : void 0
6249
6345
  });
6250
6346
  }
@@ -6310,84 +6406,108 @@ async function getScheduledEmailStats(config) {
6310
6406
  }
6311
6407
 
6312
6408
  // src/consent.ts
6409
+ import { consentEndpoints } from "@sylphx/contract";
6410
+ function consentItemsFromRecord(consents) {
6411
+ return Object.entries(consents).map(([slug, granted]) => ({ slug, granted }));
6412
+ }
6313
6413
  async function getConsentTypes(config) {
6314
- return callApi(config, "/consent/types", { method: "GET" });
6414
+ const endpoint = consentEndpoints.listTypes;
6415
+ return callApi(config, endpoint.path, { method: endpoint.method });
6315
6416
  }
6316
6417
  async function hasConsent(config, purposeSlug, input, defaults) {
6317
- return callApi(config, "/consent/check", {
6318
- method: "POST",
6319
- body: { purposeSlug, ...input, defaults }
6320
- });
6418
+ const consents = await getUserConsents(config, input);
6419
+ const consent = consents.find((entry) => entry.slug === purposeSlug);
6420
+ if (consent) return consent.granted;
6421
+ if (defaults?.required) return true;
6422
+ return defaults?.defaultEnabled ?? false;
6321
6423
  }
6322
6424
  async function getUserConsents(config, input) {
6323
- return callApi(config, "/consent/user", {
6324
- method: "GET",
6325
- query: input
6425
+ const endpoint = consentEndpoints.listUser;
6426
+ return callApi(config, endpoint.path, {
6427
+ method: endpoint.method,
6428
+ query: {
6429
+ userId: input.userId,
6430
+ anonymousId: input.anonymousId
6431
+ }
6326
6432
  });
6327
6433
  }
6328
6434
  async function setConsents(config, input) {
6329
- return callApi(config, "/consent/set", { method: "POST", body: input });
6435
+ const endpoint = consentEndpoints.set;
6436
+ await callApi(config, endpoint.path, {
6437
+ method: endpoint.method,
6438
+ body: {
6439
+ userId: input.userId,
6440
+ anonymousId: input.anonymousId,
6441
+ consents: consentItemsFromRecord(input.consents),
6442
+ source: input.source,
6443
+ userAgent: input.userAgent
6444
+ }
6445
+ });
6330
6446
  }
6331
6447
  async function acceptAllConsents(config, input) {
6332
- return callApi(config, "/consent/accept-all", {
6333
- method: "POST",
6448
+ const endpoint = consentEndpoints.acceptAll;
6449
+ await callApi(config, endpoint.path, {
6450
+ method: endpoint.method,
6334
6451
  body: input
6335
6452
  });
6336
6453
  }
6337
6454
  async function declineOptionalConsents(config, input) {
6338
- return callApi(config, "/consent/decline-optional", {
6339
- method: "POST",
6455
+ const endpoint = consentEndpoints.declineOptional;
6456
+ await callApi(config, endpoint.path, {
6457
+ method: endpoint.method,
6340
6458
  body: input
6341
6459
  });
6342
6460
  }
6343
6461
  async function linkAnonymousConsents(config, input) {
6344
- return callApi(config, "/consent/link-anonymous", {
6345
- method: "POST",
6462
+ const endpoint = consentEndpoints.linkAnonymous;
6463
+ await callApi(config, endpoint.path, {
6464
+ method: endpoint.method,
6346
6465
  body: input
6347
6466
  });
6348
6467
  }
6349
6468
  async function getConsentHistory(config, input) {
6350
- return callApi(config, "/consent/history", {
6351
- method: "GET",
6469
+ const endpoint = consentEndpoints.history;
6470
+ return callApi(config, endpoint.path, {
6471
+ method: endpoint.method,
6352
6472
  query: {
6353
6473
  userId: input.userId,
6354
6474
  anonymousId: input.anonymousId,
6355
- limit: input.limit?.toString(),
6475
+ limit: input.limit,
6356
6476
  cursor: input.cursor
6357
6477
  }
6358
6478
  });
6359
6479
  }
6360
6480
 
6361
6481
  // src/referrals.ts
6362
- async function getMyReferralCode(config, userId) {
6363
- return callApi(config, "/referrals/code", {
6364
- method: "GET",
6365
- query: { userId }
6366
- });
6482
+ import { referralsEndpoints } from "@sylphx/contract";
6483
+ async function getMyReferralCode(config, _userId) {
6484
+ const endpoint = referralsEndpoints.getCode;
6485
+ return callApi(config, endpoint.path, { method: endpoint.method });
6367
6486
  }
6368
- async function getReferralStats(config, userId) {
6369
- return callApi(config, "/referrals/stats", {
6370
- method: "GET",
6371
- query: { userId }
6372
- });
6487
+ async function getReferralStats(config, _userId) {
6488
+ const endpoint = referralsEndpoints.stats;
6489
+ return callApi(config, endpoint.path, { method: endpoint.method });
6373
6490
  }
6374
6491
  async function redeemReferralCode(config, input, defaults) {
6375
- return callApi(config, "/referrals/redeem", {
6376
- method: "POST",
6377
- body: { ...input, defaults }
6492
+ const endpoint = referralsEndpoints.redeem;
6493
+ return callApi(config, endpoint.path, {
6494
+ method: endpoint.method,
6495
+ body: { code: input.code, defaults }
6378
6496
  });
6379
6497
  }
6380
- async function getReferralLeaderboard(config, userId, options) {
6381
- return callApi(config, "/referrals/leaderboard", {
6382
- method: "GET",
6383
- query: { userId, ...options }
6498
+ async function getReferralLeaderboard(config, _userId, options) {
6499
+ const endpoint = referralsEndpoints.leaderboard;
6500
+ return callApi(config, endpoint.path, {
6501
+ method: endpoint.method,
6502
+ query: {
6503
+ limit: options?.limit,
6504
+ period: options?.period
6505
+ }
6384
6506
  });
6385
6507
  }
6386
- async function regenerateReferralCode(config, userId) {
6387
- return callApi(config, "/referrals/code/regenerate", {
6388
- method: "POST",
6389
- body: { userId }
6390
- });
6508
+ async function regenerateReferralCode(config, _userId) {
6509
+ const endpoint = referralsEndpoints.regenerateCode;
6510
+ return callApi(config, endpoint.path, { method: endpoint.method });
6391
6511
  }
6392
6512
 
6393
6513
  // src/lib/engagement/types.ts
@@ -6828,7 +6948,7 @@ async function getDatabaseStatus(config) {
6828
6948
 
6829
6949
  // src/kv.ts
6830
6950
  import { kvEndpoints } from "@sylphx/contract";
6831
- function interpolatePath2(template, params) {
6951
+ function interpolatePath3(template, params) {
6832
6952
  let path = template;
6833
6953
  for (const [key, value] of Object.entries(params)) {
6834
6954
  path = path.replace(`:${key}`, encodeURIComponent(value));
@@ -6873,20 +6993,20 @@ async function kvGet(config, key) {
6873
6993
  const endpoint = kvEndpoints.get;
6874
6994
  const result = await callApi(
6875
6995
  config,
6876
- interpolatePath2(endpoint.path, { key }),
6996
+ interpolatePath3(endpoint.path, { key }),
6877
6997
  { method: endpoint.method }
6878
6998
  );
6879
6999
  return result.value;
6880
7000
  }
6881
7001
  async function kvDelete(config, key) {
6882
7002
  const endpoint = kvEndpoints.delete;
6883
- return callApi(config, interpolatePath2(endpoint.path, { key }), {
7003
+ return callApi(config, interpolatePath3(endpoint.path, { key }), {
6884
7004
  method: endpoint.method
6885
7005
  });
6886
7006
  }
6887
7007
  async function kvExists(config, key) {
6888
7008
  const endpoint = kvEndpoints.exists;
6889
- return callApi(config, interpolatePath2(endpoint.path, { key }), {
7009
+ return callApi(config, interpolatePath3(endpoint.path, { key }), {
6890
7010
  method: endpoint.method
6891
7011
  });
6892
7012
  }
@@ -7592,7 +7712,8 @@ var SandboxClient = class _SandboxClient {
7592
7712
  env: options?.env,
7593
7713
  storage: options?.storageGi !== void 0 ? { enabled: true, sizeGi: options.storageGi } : void 0,
7594
7714
  volumeMounts: options?.volumeMounts,
7595
- workspaceMounts: options?.workspaceMounts
7715
+ workspaceMounts: options?.workspaceMounts,
7716
+ egress: options?.egress
7596
7717
  },
7597
7718
  timeout: options?.createTimeoutMs ?? SANDBOX_CREATE_TIMEOUT_MS
7598
7719
  });