@palbase/web 2.0.0 → 2.0.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.
@@ -1,10 +1,10 @@
1
- import { P as PalbeConfig, d as PalbeRuntime } from './analytics-facade-ovP0pF2P.cjs';
2
- export { e as buildRuntime } from './analytics-facade-ovP0pF2P.cjs';
1
+ import { P as PalbeConfig, d as PalbeRuntime } from './analytics-facade-ChlBRcLZ.cjs';
2
+ export { e as buildRuntime } from './analytics-facade-ChlBRcLZ.cjs';
3
3
  import { B as BackendError } from './errors-fDoNdTrJ.cjs';
4
- export { P as PB, c as createBoundClient } from './pb-DDM_mCQB.cjs';
4
+ export { P as PB, c as createBoundClient } from './pb-B_6o5p79.cjs';
5
5
  import 'livekit-client';
6
6
  import './storage-BPaeSG8K.cjs';
7
- import './pooled-flags-Bwq4usn0.js';
7
+ import './pooled-flags-4GtDtsiu.js';
8
8
 
9
9
  interface EndpointDescriptor {
10
10
  method: string;
@@ -1,10 +1,10 @@
1
- import { P as PalbeConfig, d as PalbeRuntime } from './analytics-facade-DMtGDGfd.js';
2
- export { e as buildRuntime } from './analytics-facade-DMtGDGfd.js';
1
+ import { P as PalbeConfig, d as PalbeRuntime } from './analytics-facade-G0il4NrT.js';
2
+ export { e as buildRuntime } from './analytics-facade-G0il4NrT.js';
3
3
  import { B as BackendError } from './errors-fDoNdTrJ.js';
4
- export { P as PB, c as createBoundClient } from './pb-CvpcQero.js';
4
+ export { P as PB, c as createBoundClient } from './pb-nPBhqhJr.js';
5
5
  import 'livekit-client';
6
6
  import './storage-BPaeSG8K.js';
7
- import './pooled-flags-Bwq4usn0.js';
7
+ import './pooled-flags-4GtDtsiu.js';
8
8
 
9
9
  interface EndpointDescriptor {
10
10
  method: string;
package/dist/internal.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  createBoundClient,
7
7
  getRuntime,
8
8
  onConfigured
9
- } from "./chunk-V6VTX65P.js";
9
+ } from "./chunk-AIPUO4QX.js";
10
10
  import "./chunk-PZ5AY32C.js";
11
11
  export {
12
12
  __configure,
@@ -1792,6 +1792,19 @@ var PalbeCalls = class {
1792
1792
 
1793
1793
  // ../modules/flags/dist/index.js
1794
1794
  var FLAG_NAME_RE = /^[a-zA-Z0-9_-]+$/;
1795
+ function flagEnabled(value) {
1796
+ if (typeof value === "boolean") return value;
1797
+ return value != null && value !== 0 && value !== "";
1798
+ }
1799
+ function flagVariant(value) {
1800
+ return typeof value === "string" ? { name: value } : null;
1801
+ }
1802
+ function mapResponse(res, fn) {
1803
+ if (res.error || res.data == null) {
1804
+ return { ...res, data: null };
1805
+ }
1806
+ return { ...res, data: fn(res.data) };
1807
+ }
1795
1808
  var FlagsClient = class {
1796
1809
  httpClient;
1797
1810
  getCurrentUserId;
@@ -1811,10 +1824,11 @@ var FlagsClient = class {
1811
1824
  `Invalid flag name: "${flagName}". Flag names must match ${FLAG_NAME_RE.source}`
1812
1825
  );
1813
1826
  }
1814
- const params = this.buildContextParams(context);
1815
- const query = params.toString();
1816
- const path = `/v1/flags/${flagName}/enabled${query ? `?${query}` : ""}`;
1817
- return this.httpClient.request("GET", path);
1827
+ const res = await this.httpClient.request(
1828
+ "GET",
1829
+ this.mergedPath(context)
1830
+ );
1831
+ return mapResponse(res, (snap) => flagEnabled(snap.values?.[flagName]));
1818
1832
  }
1819
1833
  async getVariant(flagName, context) {
1820
1834
  if (!FLAG_NAME_RE.test(flagName)) {
@@ -1822,16 +1836,29 @@ var FlagsClient = class {
1822
1836
  `Invalid flag name: "${flagName}". Flag names must match ${FLAG_NAME_RE.source}`
1823
1837
  );
1824
1838
  }
1825
- const params = this.buildContextParams(context);
1826
- const query = params.toString();
1827
- const path = `/v1/flags/${flagName}/variant${query ? `?${query}` : ""}`;
1828
- return this.httpClient.request("GET", path);
1839
+ const res = await this.httpClient.request(
1840
+ "GET",
1841
+ this.mergedPath(context)
1842
+ );
1843
+ if (res.error || res.data == null) {
1844
+ return { ...res, data: null };
1845
+ }
1846
+ return { ...res, data: flagVariant(res.data.values?.[flagName]) };
1829
1847
  }
1830
1848
  async getAll(context) {
1831
- const params = this.buildContextParams(context);
1832
- const query = params.toString();
1833
- const path = `/v1/flags${query ? `?${query}` : ""}`;
1834
- return this.httpClient.request("GET", path);
1849
+ const res = await this.httpClient.request(
1850
+ "GET",
1851
+ this.mergedPath(context)
1852
+ );
1853
+ return mapResponse(res, (snap) => {
1854
+ const values = snap.values ?? {};
1855
+ return Object.keys(values).map((name) => {
1856
+ const value = values[name];
1857
+ const flag = { name, enabled: flagEnabled(value) };
1858
+ if (typeof value === "string") flag.variant = { name: value };
1859
+ return flag;
1860
+ });
1861
+ });
1835
1862
  }
1836
1863
  /**
1837
1864
  * Cold-start read: the full merged flag set for the current auth identity.
@@ -1930,15 +1957,16 @@ var FlagsClient = class {
1930
1957
  }
1931
1958
  };
1932
1959
  }
1933
- buildContextParams(context) {
1934
- const params = new URLSearchParams();
1935
- if (context?.userId) {
1936
- params.set("userId", context.userId);
1937
- }
1938
- if (context?.properties) {
1939
- params.set("properties", JSON.stringify(context.properties));
1940
- }
1941
- return params;
1960
+ /**
1961
+ * Resolve the merged-read path for a context. With `context.userId` present the
1962
+ * read targets that specific user's merged view (`/v1/user-flags/users/{id}`, a
1963
+ * privileged cross-user read); otherwise the current auth user's view
1964
+ * (`/v1/user-flags`). `context.properties` has no server-side targeting support
1965
+ * in the user-flags module and is ignored.
1966
+ */
1967
+ mergedPath(context) {
1968
+ const uid = context?.userId;
1969
+ return uid ? `/v1/user-flags/users/${encodeURIComponent(uid)}` : "/v1/user-flags";
1942
1970
  }
1943
1971
  };
1944
1972
  var DEFAULT_POLL_MS = 3e4;
@@ -2400,7 +2428,7 @@ var PalbeFlags = class {
2400
2428
  *
2401
2429
  * DEVIATION from iOS sync-cache parity: the platform does not propagate
2402
2430
  * variant metadata into the user-flags snapshot/delta cache, so this is an
2403
- * ASYNC transport read (`GET /v1/flags/{key}/variant`), not a cache lookup.
2431
+ * ASYNC transport read (derived from `GET /v1/user-flags`), not a cache lookup.
2404
2432
  */
2405
2433
  async getVariant(key) {
2406
2434
  let res;
@@ -8740,7 +8768,7 @@ function defaultSessionStorage(key) {
8740
8768
  }
8741
8769
 
8742
8770
  // src/version.ts
8743
- var VERSION = "2.0.0";
8771
+ var VERSION = "2.0.1";
8744
8772
 
8745
8773
  // src/runtime.ts
8746
8774
  function buildRuntime(config) {