@fonderie/client 1.1.0 → 1.3.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/brain/signatures.md +23 -0
- package/dist/index.cjs +52 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -1
- package/dist/index.d.ts +30 -1
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/brain/signatures.md
CHANGED
|
@@ -704,6 +704,7 @@ interface IRequestLocationDTO {
|
|
|
704
704
|
latitude?: number;
|
|
705
705
|
longitude?: number;
|
|
706
706
|
accuracyRadius?: number;
|
|
707
|
+
geonameId?: number;
|
|
707
708
|
isp?: string;
|
|
708
709
|
org?: string;
|
|
709
710
|
asn?: string;
|
|
@@ -1591,4 +1592,26 @@ type SubscriberType = 'user' | 'workspace';
|
|
|
1591
1592
|
function isMfaRequired(result: ILoginResult | IMfaRequiredResult): result is IMfaRequiredResult
|
|
1592
1593
|
|
|
1593
1594
|
function describeLocation(loc: IRequestLocationDTO | null | undefined, countryName?: ((code: string) => string | undefined) | undefined): string | null
|
|
1595
|
+
|
|
1596
|
+
const CONFIG_KEY_PATTERN: RegExp
|
|
1597
|
+
|
|
1598
|
+
const CONFIG_VALUE_TYPES: readonly ConfigValueType[]
|
|
1599
|
+
|
|
1600
|
+
function castConfigValue(type: ConfigValueType, raw: string): CastResult
|
|
1601
|
+
|
|
1602
|
+
function configKeyProblem(key: string): string | null
|
|
1603
|
+
|
|
1604
|
+
function configValueType(value: unknown): ConfigValueType
|
|
1605
|
+
|
|
1606
|
+
function formatConfigValue(value: unknown, type?: ConfigValueType): string
|
|
1607
|
+
|
|
1608
|
+
type CastResult = {
|
|
1609
|
+
ok: true;
|
|
1610
|
+
value: unknown;
|
|
1611
|
+
} | {
|
|
1612
|
+
ok: false;
|
|
1613
|
+
error: string;
|
|
1614
|
+
};
|
|
1615
|
+
|
|
1616
|
+
type ConfigValueType = 'string' | 'number' | 'boolean' | 'json';
|
|
1594
1617
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -27,6 +27,8 @@ __export(index_exports, {
|
|
|
27
27
|
AuthClient: () => AuthClient,
|
|
28
28
|
BillingAdminClient: () => BillingAdminClient,
|
|
29
29
|
BillingClient: () => BillingClient,
|
|
30
|
+
CONFIG_KEY_PATTERN: () => CONFIG_KEY_PATTERN,
|
|
31
|
+
CONFIG_VALUE_TYPES: () => CONFIG_VALUE_TYPES,
|
|
30
32
|
ConfigAdminClient: () => ConfigAdminClient,
|
|
31
33
|
CourierAdminClient: () => CourierAdminClient,
|
|
32
34
|
CustomersClient: () => CustomersClient,
|
|
@@ -35,8 +37,12 @@ __export(index_exports, {
|
|
|
35
37
|
MediaClient: () => MediaClient,
|
|
36
38
|
WebhooksClient: () => WebhooksClient,
|
|
37
39
|
WorkspacesClient: () => WorkspacesClient,
|
|
40
|
+
castConfigValue: () => castConfigValue,
|
|
41
|
+
configKeyProblem: () => configKeyProblem,
|
|
42
|
+
configValueType: () => configValueType,
|
|
38
43
|
createMemoryCache: () => createMemoryCache,
|
|
39
44
|
describeLocation: () => describeLocation,
|
|
45
|
+
formatConfigValue: () => formatConfigValue,
|
|
40
46
|
isMfaRequired: () => isMfaRequired
|
|
41
47
|
});
|
|
42
48
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -2124,6 +2130,46 @@ function describeLocation(loc, countryName) {
|
|
|
2124
2130
|
);
|
|
2125
2131
|
return parts.length > 0 ? parts.join(", ") : null;
|
|
2126
2132
|
}
|
|
2133
|
+
|
|
2134
|
+
// src/config-value.ts
|
|
2135
|
+
var CONFIG_VALUE_TYPES = ["string", "number", "boolean", "json"];
|
|
2136
|
+
function configValueType(value) {
|
|
2137
|
+
if (typeof value === "string") return "string";
|
|
2138
|
+
if (typeof value === "number") return "number";
|
|
2139
|
+
if (typeof value === "boolean") return "boolean";
|
|
2140
|
+
return "json";
|
|
2141
|
+
}
|
|
2142
|
+
function formatConfigValue(value, type = configValueType(value)) {
|
|
2143
|
+
if (type === "string") return typeof value === "string" ? value : String(value ?? "");
|
|
2144
|
+
if (type === "number") return typeof value === "number" ? String(value) : "";
|
|
2145
|
+
if (type === "boolean") return value === true ? "true" : "false";
|
|
2146
|
+
return JSON.stringify(value ?? null, null, 2);
|
|
2147
|
+
}
|
|
2148
|
+
function castConfigValue(type, raw) {
|
|
2149
|
+
if (type === "string") return { ok: true, value: raw };
|
|
2150
|
+
const t = raw.trim();
|
|
2151
|
+
if (type === "number") {
|
|
2152
|
+
if (t === "") return { ok: false, error: "Enter a number." };
|
|
2153
|
+
const n = Number(t);
|
|
2154
|
+
return Number.isFinite(n) ? { ok: true, value: n } : { ok: false, error: `"${raw}" is not a number.` };
|
|
2155
|
+
}
|
|
2156
|
+
if (type === "boolean") {
|
|
2157
|
+
const v = t.toLowerCase();
|
|
2158
|
+
if (["true", "1", "yes", "on"].includes(v)) return { ok: true, value: true };
|
|
2159
|
+
if (["false", "0", "no", "off"].includes(v)) return { ok: true, value: false };
|
|
2160
|
+
return { ok: false, error: "Use true or false." };
|
|
2161
|
+
}
|
|
2162
|
+
try {
|
|
2163
|
+
return { ok: true, value: JSON.parse(t) };
|
|
2164
|
+
} catch (err) {
|
|
2165
|
+
return { ok: false, error: `Not valid JSON: ${err.message}` };
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
var CONFIG_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9._-]{0,127}$/;
|
|
2169
|
+
function configKeyProblem(key) {
|
|
2170
|
+
if (!key) return "Enter a key.";
|
|
2171
|
+
return CONFIG_KEY_PATTERN.test(key) ? null : 'Start with a letter; use letters, digits, ".", "_" or "-" (max 128).';
|
|
2172
|
+
}
|
|
2127
2173
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2128
2174
|
0 && (module.exports = {
|
|
2129
2175
|
AdminClient,
|
|
@@ -2133,6 +2179,8 @@ function describeLocation(loc, countryName) {
|
|
|
2133
2179
|
AuthClient,
|
|
2134
2180
|
BillingAdminClient,
|
|
2135
2181
|
BillingClient,
|
|
2182
|
+
CONFIG_KEY_PATTERN,
|
|
2183
|
+
CONFIG_VALUE_TYPES,
|
|
2136
2184
|
ConfigAdminClient,
|
|
2137
2185
|
CourierAdminClient,
|
|
2138
2186
|
CustomersClient,
|
|
@@ -2141,8 +2189,12 @@ function describeLocation(loc, countryName) {
|
|
|
2141
2189
|
MediaClient,
|
|
2142
2190
|
WebhooksClient,
|
|
2143
2191
|
WorkspacesClient,
|
|
2192
|
+
castConfigValue,
|
|
2193
|
+
configKeyProblem,
|
|
2194
|
+
configValueType,
|
|
2144
2195
|
createMemoryCache,
|
|
2145
2196
|
describeLocation,
|
|
2197
|
+
formatConfigValue,
|
|
2146
2198
|
isMfaRequired
|
|
2147
2199
|
});
|
|
2148
2200
|
//# sourceMappingURL=index.cjs.map
|