@fonderie/client 1.4.0 → 1.5.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.
@@ -240,6 +240,7 @@ interface ISetConfigInput {
240
240
  description?: string;
241
241
  active?: boolean;
242
242
  ifVersion?: number;
243
+ allowTypeChange?: boolean;
243
244
  }
244
245
 
245
246
  interface ISetSecretInput {
@@ -1602,10 +1603,14 @@ function castConfigValue(type: ConfigValueType, raw: string): CastResult
1602
1603
 
1603
1604
  function configKeyProblem(key: string): string | null
1604
1605
 
1606
+ function configValueLabel(value: unknown): string
1607
+
1605
1608
  function configValueType(value: unknown): ConfigValueType
1606
1609
 
1607
1610
  function formatConfigValue(value: unknown, type?: ConfigValueType): string
1608
1611
 
1612
+ function inferConfigValue(raw: string): IInferredConfigValue
1613
+
1609
1614
  type CastResult = {
1610
1615
  ok: true;
1611
1616
  value: unknown;
@@ -1616,6 +1621,13 @@ type CastResult = {
1616
1621
 
1617
1622
  type ConfigValueType = 'string' | 'number' | 'boolean' | 'json';
1618
1623
 
1624
+ interface IInferredConfigValue {
1625
+ type: ConfigValueType;
1626
+ value: unknown;
1627
+ label: string;
1628
+ ambiguous: boolean;
1629
+ }
1630
+
1619
1631
  new ConfigClient(http: HttpClient, tokens: TokenStore): ConfigClient
1620
1632
  .load(): Promise<IRemoteConfigState>
1621
1633
  .get<T>(key: string, fallback: T): T
package/dist/index.cjs CHANGED
@@ -40,10 +40,12 @@ __export(index_exports, {
40
40
  WorkspacesClient: () => WorkspacesClient,
41
41
  castConfigValue: () => castConfigValue,
42
42
  configKeyProblem: () => configKeyProblem,
43
+ configValueLabel: () => configValueLabel,
43
44
  configValueType: () => configValueType,
44
45
  createMemoryCache: () => createMemoryCache,
45
46
  describeLocation: () => describeLocation,
46
47
  formatConfigValue: () => formatConfigValue,
48
+ inferConfigValue: () => inferConfigValue,
47
49
  isMfaRequired: () => isMfaRequired
48
50
  });
49
51
  module.exports = __toCommonJS(index_exports);
@@ -2230,6 +2232,35 @@ function configKeyProblem(key) {
2230
2232
  if (!key) return "Enter a key.";
2231
2233
  return CONFIG_KEY_PATTERN.test(key) ? null : 'Start with a letter; use letters, digits, ".", "_" or "-" (max 128).';
2232
2234
  }
2235
+ var PLAIN_NUMBER = /^-?(0|[1-9]\d*)(\.\d+)?$/;
2236
+ function configValueLabel(value) {
2237
+ if (typeof value === "string") return "Text";
2238
+ if (typeof value === "number") return "Number";
2239
+ if (typeof value === "boolean") return "On/off";
2240
+ if (Array.isArray(value)) return "List";
2241
+ if (value === null) return "Empty";
2242
+ return "Object";
2243
+ }
2244
+ function inferConfigValue(raw) {
2245
+ const t = raw.trim();
2246
+ if (t === "true" || t === "false") {
2247
+ return { type: "boolean", value: t === "true", label: "On/off", ambiguous: true };
2248
+ }
2249
+ if (PLAIN_NUMBER.test(t)) {
2250
+ const n = Number(t);
2251
+ if (Number.isFinite(n) && String(n) === t) return { type: "number", value: n, label: "Number", ambiguous: true };
2252
+ }
2253
+ if (t.startsWith("{") || t.startsWith("[")) {
2254
+ try {
2255
+ const parsed = JSON.parse(t);
2256
+ if (parsed !== null && typeof parsed === "object") {
2257
+ return { type: "json", value: parsed, label: Array.isArray(parsed) ? "List" : "Object", ambiguous: false };
2258
+ }
2259
+ } catch {
2260
+ }
2261
+ }
2262
+ return { type: "string", value: raw, label: "Text", ambiguous: false };
2263
+ }
2233
2264
  // Annotate the CommonJS export names for ESM import in node:
2234
2265
  0 && (module.exports = {
2235
2266
  AdminClient,
@@ -2252,10 +2283,12 @@ function configKeyProblem(key) {
2252
2283
  WorkspacesClient,
2253
2284
  castConfigValue,
2254
2285
  configKeyProblem,
2286
+ configValueLabel,
2255
2287
  configValueType,
2256
2288
  createMemoryCache,
2257
2289
  describeLocation,
2258
2290
  formatConfigValue,
2291
+ inferConfigValue,
2259
2292
  isMfaRequired
2260
2293
  });
2261
2294
  //# sourceMappingURL=index.cjs.map