@topolo/sdk 0.10.1 → 0.10.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.cjs +11 -9
- package/dist/index.js +11 -9
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4313,6 +4313,16 @@ function localReference(rootSchema, reference) {
|
|
|
4313
4313
|
return isRecord4(value) ? value[key] : void 0;
|
|
4314
4314
|
}, rootSchema);
|
|
4315
4315
|
}
|
|
4316
|
+
function representativeNumber(schema, hint) {
|
|
4317
|
+
const integer = schema.type === "integer";
|
|
4318
|
+
const words = String(hint || "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").toLowerCase();
|
|
4319
|
+
const preferred = /\b(?:percent|percentage|ratio|rate)\b/.test(words) ? 0.5 : /\b(?:amount|balance|cent|cents|minor)\b/.test(words) ? 1e3 : words.includes("year") ? 2026 : 1;
|
|
4320
|
+
const exclusiveOffset = (value2) => Math.max(Number.EPSILON * Math.max(1, Math.abs(value2)) * 2, Number.MIN_VALUE);
|
|
4321
|
+
const lower = typeof schema.exclusiveMinimum === "number" ? integer ? Math.floor(schema.exclusiveMinimum) + 1 : schema.exclusiveMinimum + exclusiveOffset(schema.exclusiveMinimum) : typeof schema.minimum === "number" ? integer ? Math.ceil(schema.minimum) : schema.minimum : -Infinity;
|
|
4322
|
+
const upper = typeof schema.exclusiveMaximum === "number" ? integer ? Math.ceil(schema.exclusiveMaximum) - 1 : schema.exclusiveMaximum - exclusiveOffset(schema.exclusiveMaximum) : typeof schema.maximum === "number" ? integer ? Math.floor(schema.maximum) : schema.maximum : Infinity;
|
|
4323
|
+
const value = Math.min(Math.max(preferred, lower), upper);
|
|
4324
|
+
return integer ? Math.round(value) : value;
|
|
4325
|
+
}
|
|
4316
4326
|
function sampleForSchema(schema, depth = 0, hint = "value", rootSchema = schema) {
|
|
4317
4327
|
if (!isRecord4(schema) || depth > 20) return null;
|
|
4318
4328
|
const referenced = localReference(rootSchema, schema.$ref);
|
|
@@ -4332,15 +4342,7 @@ function sampleForSchema(schema, depth = 0, hint = "value", rootSchema = schema)
|
|
|
4332
4342
|
}
|
|
4333
4343
|
if (schema.type === "boolean") return false;
|
|
4334
4344
|
if (schema.type === "integer" || schema.type === "number") {
|
|
4335
|
-
|
|
4336
|
-
if (typeof schema.exclusiveMinimum === "number" && value <= schema.exclusiveMinimum) {
|
|
4337
|
-
value = schema.type === "integer" ? Math.floor(schema.exclusiveMinimum) + 1 : schema.exclusiveMinimum + 0.1;
|
|
4338
|
-
}
|
|
4339
|
-
if (typeof schema.maximum === "number") value = Math.min(value, schema.maximum);
|
|
4340
|
-
if (typeof schema.exclusiveMaximum === "number" && value >= schema.exclusiveMaximum) {
|
|
4341
|
-
value = schema.type === "integer" ? Math.ceil(schema.exclusiveMaximum) - 1 : schema.exclusiveMaximum - 0.1;
|
|
4342
|
-
}
|
|
4343
|
-
return value;
|
|
4345
|
+
return representativeNumber(schema, hint);
|
|
4344
4346
|
}
|
|
4345
4347
|
if (schema.type === "string") return sampleString(schema, hint);
|
|
4346
4348
|
if (schema.type === "null") return null;
|
package/dist/index.js
CHANGED
|
@@ -4237,6 +4237,16 @@ function localReference(rootSchema, reference) {
|
|
|
4237
4237
|
return isRecord4(value) ? value[key] : void 0;
|
|
4238
4238
|
}, rootSchema);
|
|
4239
4239
|
}
|
|
4240
|
+
function representativeNumber(schema, hint) {
|
|
4241
|
+
const integer = schema.type === "integer";
|
|
4242
|
+
const words = String(hint || "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").toLowerCase();
|
|
4243
|
+
const preferred = /\b(?:percent|percentage|ratio|rate)\b/.test(words) ? 0.5 : /\b(?:amount|balance|cent|cents|minor)\b/.test(words) ? 1e3 : words.includes("year") ? 2026 : 1;
|
|
4244
|
+
const exclusiveOffset = (value2) => Math.max(Number.EPSILON * Math.max(1, Math.abs(value2)) * 2, Number.MIN_VALUE);
|
|
4245
|
+
const lower = typeof schema.exclusiveMinimum === "number" ? integer ? Math.floor(schema.exclusiveMinimum) + 1 : schema.exclusiveMinimum + exclusiveOffset(schema.exclusiveMinimum) : typeof schema.minimum === "number" ? integer ? Math.ceil(schema.minimum) : schema.minimum : -Infinity;
|
|
4246
|
+
const upper = typeof schema.exclusiveMaximum === "number" ? integer ? Math.ceil(schema.exclusiveMaximum) - 1 : schema.exclusiveMaximum - exclusiveOffset(schema.exclusiveMaximum) : typeof schema.maximum === "number" ? integer ? Math.floor(schema.maximum) : schema.maximum : Infinity;
|
|
4247
|
+
const value = Math.min(Math.max(preferred, lower), upper);
|
|
4248
|
+
return integer ? Math.round(value) : value;
|
|
4249
|
+
}
|
|
4240
4250
|
function sampleForSchema(schema, depth = 0, hint = "value", rootSchema = schema) {
|
|
4241
4251
|
if (!isRecord4(schema) || depth > 20) return null;
|
|
4242
4252
|
const referenced = localReference(rootSchema, schema.$ref);
|
|
@@ -4256,15 +4266,7 @@ function sampleForSchema(schema, depth = 0, hint = "value", rootSchema = schema)
|
|
|
4256
4266
|
}
|
|
4257
4267
|
if (schema.type === "boolean") return false;
|
|
4258
4268
|
if (schema.type === "integer" || schema.type === "number") {
|
|
4259
|
-
|
|
4260
|
-
if (typeof schema.exclusiveMinimum === "number" && value <= schema.exclusiveMinimum) {
|
|
4261
|
-
value = schema.type === "integer" ? Math.floor(schema.exclusiveMinimum) + 1 : schema.exclusiveMinimum + 0.1;
|
|
4262
|
-
}
|
|
4263
|
-
if (typeof schema.maximum === "number") value = Math.min(value, schema.maximum);
|
|
4264
|
-
if (typeof schema.exclusiveMaximum === "number" && value >= schema.exclusiveMaximum) {
|
|
4265
|
-
value = schema.type === "integer" ? Math.ceil(schema.exclusiveMaximum) - 1 : schema.exclusiveMaximum - 0.1;
|
|
4266
|
-
}
|
|
4267
|
-
return value;
|
|
4269
|
+
return representativeNumber(schema, hint);
|
|
4268
4270
|
}
|
|
4269
4271
|
if (schema.type === "string") return sampleString(schema, hint);
|
|
4270
4272
|
if (schema.type === "null") return null;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topolo/sdk",
|
|
3
|
-
"version": "0.10.
|
|
4
|
-
"topoloPublishedVersion": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
|
+
"topoloPublishedVersion": "0.10.2",
|
|
5
5
|
"description": "Typed client SDK for the Topolo platform. Used by TopoloCli, TopoloMCP, and third-party agents.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|