@openpkg-ts/sdk 0.41.0 → 0.42.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.d.ts +2 -2
- package/dist/index.js +16 -12
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ interface ExtractOptions {
|
|
|
33
33
|
includePrivate?: boolean;
|
|
34
34
|
/** Configuration for resolving external package re-exports */
|
|
35
35
|
externals?: ExternalsConfig;
|
|
36
|
-
/** Max properties to serialize per object type (default:
|
|
36
|
+
/** Max properties to serialize per object type (default: 500) */
|
|
37
37
|
maxProperties?: number;
|
|
38
38
|
/** Callback when properties are truncated */
|
|
39
39
|
onTruncation?: (typeName: string, actual: number, limit: number) => void;
|
|
@@ -1171,7 +1171,7 @@ interface SerializerContext {
|
|
|
1171
1171
|
inTupleElement?: boolean;
|
|
1172
1172
|
/** Include private/protected class members (default: false) */
|
|
1173
1173
|
includePrivate?: boolean;
|
|
1174
|
-
/** Max properties to serialize per object type (default:
|
|
1174
|
+
/** Max properties to serialize per object type (default: 500) */
|
|
1175
1175
|
maxProperties: number;
|
|
1176
1176
|
/** Callback when properties are truncated */
|
|
1177
1177
|
onTruncation?: (typeName: string, actual: number, limit: number) => void;
|
package/dist/index.js
CHANGED
|
@@ -2453,7 +2453,7 @@ function buildObjectSchema(properties, checker, ctx, originalType) {
|
|
|
2453
2453
|
const required = [];
|
|
2454
2454
|
for (const prop of properties) {
|
|
2455
2455
|
const propName = prop.getName();
|
|
2456
|
-
if (propName.startsWith("
|
|
2456
|
+
if (propName.startsWith("__@"))
|
|
2457
2457
|
continue;
|
|
2458
2458
|
if (isArrayLikeType && ARRAY_PROTOTYPE_METHODS.has(propName)) {
|
|
2459
2459
|
continue;
|
|
@@ -2995,23 +2995,27 @@ class TypeRegistry {
|
|
|
2995
2995
|
const props = {};
|
|
2996
2996
|
const required = [];
|
|
2997
2997
|
const limit = ctx.maxProperties;
|
|
2998
|
-
if (properties.length > limit && ctx.onTruncation) {
|
|
2999
|
-
const typeName = type.getSymbol()?.getName() ?? "anonymous";
|
|
3000
|
-
ctx.onTruncation(typeName, properties.length, limit);
|
|
3001
|
-
}
|
|
3002
2998
|
const isArrayLike = checker.isArrayType(type) || checker.isTupleType(type) || type.symbol?.getName() === "Array" && type.symbol?.getDeclarations()?.[0]?.getSourceFile()?.fileName?.includes("/typescript/lib/lib.");
|
|
3003
2999
|
const isStringLike = type.flags & ts5.TypeFlags.StringLike;
|
|
3004
3000
|
const isNumberLike = type.flags & ts5.TypeFlags.NumberLike;
|
|
3005
|
-
|
|
3001
|
+
const included = properties.filter((prop) => {
|
|
3006
3002
|
const propName = prop.getName();
|
|
3007
|
-
if (propName.startsWith("
|
|
3008
|
-
|
|
3003
|
+
if (propName.startsWith("__@"))
|
|
3004
|
+
return false;
|
|
3009
3005
|
if (isArrayLike && ARRAY_PROTOTYPE_METHODS.has(propName))
|
|
3010
|
-
|
|
3006
|
+
return false;
|
|
3011
3007
|
if (isStringLike && STRING_PROTOTYPE_METHODS.has(propName))
|
|
3012
|
-
|
|
3008
|
+
return false;
|
|
3013
3009
|
if (isNumberLike && NUMBER_PROTOTYPE_METHODS.has(propName))
|
|
3014
|
-
|
|
3010
|
+
return false;
|
|
3011
|
+
return true;
|
|
3012
|
+
});
|
|
3013
|
+
if (included.length > limit && ctx.onTruncation) {
|
|
3014
|
+
const typeName = type.getSymbol()?.getName() ?? "anonymous";
|
|
3015
|
+
ctx.onTruncation(typeName, included.length, limit);
|
|
3016
|
+
}
|
|
3017
|
+
for (const prop of included.slice(0, limit)) {
|
|
3018
|
+
const propName = prop.getName();
|
|
3015
3019
|
const propType = checker.getTypeOfSymbol(prop);
|
|
3016
3020
|
this.registerType(propType, ctx);
|
|
3017
3021
|
props[propName] = buildSchema(propType, checker, ctx);
|
|
@@ -3043,7 +3047,7 @@ function createContext(program, sourceFile, options = {}) {
|
|
|
3043
3047
|
visitedTypes: new Set,
|
|
3044
3048
|
registeredTypes: new Set,
|
|
3045
3049
|
includePrivate: options.includePrivate ?? false,
|
|
3046
|
-
maxProperties: options.maxProperties ??
|
|
3050
|
+
maxProperties: options.maxProperties ?? 500,
|
|
3047
3051
|
onTruncation: options.onTruncation
|
|
3048
3052
|
};
|
|
3049
3053
|
}
|