@postman-cse/onboarding-bootstrap 2.1.0 → 2.1.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.
- package/dist/action.cjs +254 -46
- package/dist/cli.cjs +254 -46
- package/dist/index.cjs +254 -46
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -298375,9 +298375,19 @@ function collectParameterChecks(root, pathItem, operation, version2, operationId
|
|
|
298375
298375
|
if (defaultSerialization) warnings.push(`CONTRACT_SCHEMA_NOT_COMPILED: parameter ${location2}:${name} schema on ${operationId} skipped (${packed.unsupported})`);
|
|
298376
298376
|
continue;
|
|
298377
298377
|
}
|
|
298378
|
-
if (location2 === "path"
|
|
298379
|
-
|
|
298380
|
-
|
|
298378
|
+
if (location2 === "path") {
|
|
298379
|
+
const containingSegment = pathTemplate.split("/").find((segment) => segment.includes(`{${name}}`));
|
|
298380
|
+
if (containingSegment !== void 0 && containingSegment !== `{${name}}`) {
|
|
298381
|
+
const segmentParts = containingSegment.split(/(\{[^}]+\})/).filter(Boolean);
|
|
298382
|
+
let extractable = true;
|
|
298383
|
+
for (let partIndex = 0; partIndex < segmentParts.length - 1; partIndex += 1) {
|
|
298384
|
+
if (/^\{[^}]+\}$/.test(segmentParts[partIndex]) && /^\{[^}]+\}$/.test(segmentParts[partIndex + 1])) extractable = false;
|
|
298385
|
+
}
|
|
298386
|
+
if (!extractable) {
|
|
298387
|
+
warnings.push(`CONTRACT_PATH_PARAM_COMPOUND_SEGMENT_NOT_VALIDATED: path parameter ${name} of ${operationId} is in an ambiguous adjacent-parameter path segment and is not schema-validated`);
|
|
298388
|
+
continue;
|
|
298389
|
+
}
|
|
298390
|
+
}
|
|
298381
298391
|
}
|
|
298382
298392
|
const scalarSchema = packedScalarSchema(packed);
|
|
298383
298393
|
if (scalarSchema !== void 0) {
|
|
@@ -299097,7 +299107,7 @@ function createContractScript(operation, warnings = []) {
|
|
|
299097
299107
|
' function requestPathSegments() { var raw = ""; try { raw = typeof pm.request.url.getPath === "function" ? String(pm.request.url.getPath() || "") : ""; } catch (ignored) {} if (!raw) { var path = pm.request.url.path; raw = Array.isArray(path) ? "/" + path.join("/") : String(path || ""); } return raw.split("?")[0].split("#")[0].split("/").filter(function (segment) { return segment.length > 0; }); }',
|
|
299098
299108
|
// Server path prefixes sit ahead of the template segments, so the
|
|
299099
299109
|
// template aligns against the trailing request segments.
|
|
299100
|
-
' function pathParamValue(name) { var template = String(contract.path).split("/").filter(function (segment) { return segment.length > 0; }); var actual = requestPathSegments(); var offset = actual.length - template.length; if (offset < 0) return undefined; for (var i = 0; i < template.length; i += 1) {
|
|
299110
|
+
' function pathParamValue(name) { var template = String(contract.path).split("/").filter(function (segment) { return segment.length > 0; }); var actual = requestPathSegments(); var offset = actual.length - template.length; if (offset < 0) return undefined; var token = "{" + name + "}"; for (var i = 0; i < template.length; i += 1) { var seg = template[i]; var actualSeg = actual[offset + i]; if (actualSeg === undefined) continue; if (seg === token) { try { return decodeURIComponent(actualSeg); } catch (ignored) { return actualSeg; } } if (seg.indexOf(token) === -1) continue; var chunks = [], j = 0, bad = false; while (j < seg.length) { if (seg.charAt(j) === "{") { var close = seg.indexOf("}", j); if (close === -1) { bad = true; break; } chunks.push({ p: seg.slice(j + 1, close) }); j = close + 1; } else { var nb = seg.indexOf("{", j); var lit = nb === -1 ? seg.slice(j) : seg.slice(j, nb); chunks.push({ l: lit }); j = nb === -1 ? seg.length : nb; } } if (bad) return undefined; var pos = 0, found, ok = true; for (var c = 0; c < chunks.length; c += 1) { var ch = chunks[c]; if (ch.l !== undefined) { if (actualSeg.indexOf(ch.l, pos) === pos) pos += ch.l.length; else { ok = false; break; } } else { var nextLit = (chunks[c + 1] && chunks[c + 1].l !== undefined) ? chunks[c + 1].l : undefined; var isLast = c === chunks.length - 1; var end; if (isLast) { end = actualSeg.length; } else if (nextLit === undefined) { ok = false; break; } else { var idx = actualSeg.indexOf(nextLit, pos + 1); if (idx === -1) { ok = false; break; } end = idx; } if (end <= pos) { ok = false; break; } if (ch.p === name) found = actualSeg.slice(pos, end); pos = end; } } if (ok && pos === actualSeg.length && found !== undefined) { try { return decodeURIComponent(found); } catch (ignored) { return found; } } } return undefined; }',
|
|
299101
299111
|
' function isPlaceholder(value) { var text = String(value).trim(); return /^<[^<>]*>$/.test(text) || text.indexOf("{{") !== -1; }',
|
|
299102
299112
|
' function splitDelimited(value, decode) { if (decode === "csv") return value.split(","); if (decode === "ssv") return value.split(/%20| /); return value.split(/%7C|\\|/i); }',
|
|
299103
299113
|
" function decodeComponent(value) { try { return decodeURIComponent(value); } catch (ignored) { return value; } }",
|
|
@@ -301054,7 +301064,7 @@ function resolveActionVersion(explicit) {
|
|
|
301054
301064
|
if (explicit) {
|
|
301055
301065
|
return explicit;
|
|
301056
301066
|
}
|
|
301057
|
-
return "2.1.
|
|
301067
|
+
return "2.1.1" ? "2.1.1" : "unknown";
|
|
301058
301068
|
}
|
|
301059
301069
|
function telemetryDisabled(env) {
|
|
301060
301070
|
const flag = String(env.POSTMAN_ACTIONS_TELEMETRY ?? "").trim().toLowerCase();
|
|
@@ -313638,27 +313648,28 @@ function classifyNamedType(named) {
|
|
|
313638
313648
|
function describeType(type) {
|
|
313639
313649
|
let current = type;
|
|
313640
313650
|
let nonNull = false;
|
|
313641
|
-
let list = false;
|
|
313642
|
-
let listItemNonNull = false;
|
|
313643
313651
|
if ((0, import_graphql.isNonNullType)(current)) {
|
|
313644
313652
|
nonNull = true;
|
|
313645
313653
|
current = current.ofType;
|
|
313646
313654
|
}
|
|
313647
|
-
|
|
313648
|
-
|
|
313655
|
+
const lists = [];
|
|
313656
|
+
while ((0, import_graphql.isListType)(current)) {
|
|
313649
313657
|
current = current.ofType;
|
|
313658
|
+
let itemNonNull = false;
|
|
313650
313659
|
if ((0, import_graphql.isNonNullType)(current)) {
|
|
313651
|
-
|
|
313660
|
+
itemNonNull = true;
|
|
313652
313661
|
current = current.ofType;
|
|
313653
313662
|
}
|
|
313663
|
+
lists.push({ itemNonNull });
|
|
313654
313664
|
}
|
|
313655
313665
|
const named = (0, import_graphql.getNamedType)(current);
|
|
313656
313666
|
return {
|
|
313657
313667
|
name: named.name,
|
|
313658
313668
|
kind: classifyNamedType(named),
|
|
313659
313669
|
nonNull,
|
|
313660
|
-
list,
|
|
313661
|
-
listItemNonNull
|
|
313670
|
+
list: lists.length > 0,
|
|
313671
|
+
listItemNonNull: lists.length > 0 ? lists[0].itemNonNull : false,
|
|
313672
|
+
lists
|
|
313662
313673
|
};
|
|
313663
313674
|
}
|
|
313664
313675
|
function describeArgument(arg) {
|
|
@@ -313695,7 +313706,7 @@ function collectRootOperations(rootType, kind, schema, shapes) {
|
|
|
313695
313706
|
}
|
|
313696
313707
|
if (returns.kind === "union") {
|
|
313697
313708
|
opWarnings.push(
|
|
313698
|
-
`
|
|
313709
|
+
`GQL_UNION_MEMBER_FIELDS_NOT_EXPANDED: ${kind}.${fieldName} returns union ${returns.name}; its __typename is validated (object + declared member name) but member-specific fields are not expanded or asserted`
|
|
313699
313710
|
);
|
|
313700
313711
|
}
|
|
313701
313712
|
if (returns.kind === "unknown") {
|
|
@@ -313759,9 +313770,12 @@ function parseGraphQLSchema(content, opts = {}) {
|
|
|
313759
313770
|
}
|
|
313760
313771
|
for (const operation of operations) warnings.push(...operation.warnings);
|
|
313761
313772
|
const enumValues = {};
|
|
313773
|
+
const unionMembers = {};
|
|
313762
313774
|
for (const namedType of Object.values(schema.getTypeMap())) {
|
|
313763
313775
|
if ((0, import_graphql.isEnumType)(namedType)) {
|
|
313764
313776
|
enumValues[namedType.name] = namedType.getValues().map((value) => value.name);
|
|
313777
|
+
} else if ((0, import_graphql.isUnionType)(namedType)) {
|
|
313778
|
+
unionMembers[namedType.name] = namedType.getTypes().map((member) => member.name).sort((x, y) => x.localeCompare(y));
|
|
313765
313779
|
}
|
|
313766
313780
|
}
|
|
313767
313781
|
return {
|
|
@@ -313769,6 +313783,7 @@ function parseGraphQLSchema(content, opts = {}) {
|
|
|
313769
313783
|
operations,
|
|
313770
313784
|
objectShapes,
|
|
313771
313785
|
enumValues,
|
|
313786
|
+
unionMembers,
|
|
313772
313787
|
warnings
|
|
313773
313788
|
};
|
|
313774
313789
|
}
|
|
@@ -313776,6 +313791,7 @@ function parseGraphQLSchema(content, opts = {}) {
|
|
|
313776
313791
|
// src/lib/protocols/graphql/selection.ts
|
|
313777
313792
|
var SELECTION_DEPTH = 1;
|
|
313778
313793
|
function selectFields(typeRef, index, depth) {
|
|
313794
|
+
if (typeRef.kind === "union") return [];
|
|
313779
313795
|
if (typeRef.kind !== "object" && typeRef.kind !== "interface") return null;
|
|
313780
313796
|
const shape = index.objectShapes[typeRef.name];
|
|
313781
313797
|
if (!shape) return [];
|
|
@@ -313809,8 +313825,8 @@ var DEFAULT_URL = "{{baseUrl}}/graphql";
|
|
|
313809
313825
|
function argTypeSdl(arg) {
|
|
313810
313826
|
const ref = arg.type;
|
|
313811
313827
|
let inner = ref.name;
|
|
313812
|
-
|
|
313813
|
-
inner = ref.
|
|
313828
|
+
for (let i = ref.lists.length - 1; i >= 0; i -= 1) {
|
|
313829
|
+
inner = ref.lists[i].itemNonNull ? `[${inner}!]` : `[${inner}]`;
|
|
313814
313830
|
}
|
|
313815
313831
|
return ref.nonNull ? `${inner}!` : inner;
|
|
313816
313832
|
}
|
|
@@ -313979,12 +313995,25 @@ function buildShapeAssertions(operation, index, warnings) {
|
|
|
313979
313995
|
return emitValueAssertions("value", operation.returns, selection, operation.id, index, warnings);
|
|
313980
313996
|
}
|
|
313981
313997
|
function emitValueAssertions(accessor, ref, selection, ctx, index, warnings) {
|
|
313982
|
-
if (ref.
|
|
313983
|
-
const
|
|
313984
|
-
const
|
|
313998
|
+
if (ref.lists.length > 0) {
|
|
313999
|
+
const [outer, ...rest] = ref.lists;
|
|
314000
|
+
const innerRef = {
|
|
314001
|
+
...ref,
|
|
314002
|
+
lists: rest,
|
|
314003
|
+
list: rest.length > 0,
|
|
314004
|
+
listItemNonNull: rest.length > 0 ? rest[0].itemNonNull : false
|
|
314005
|
+
};
|
|
314006
|
+
const elementLines = emitValueAssertions("__el", innerRef, selection, `${ctx} (list element)`, index, warnings);
|
|
313985
314007
|
const lines = [`pm.expect(${accessor}, ${JSON.stringify(`${ctx}: expected a list`)}).to.be.an("array");`];
|
|
313986
|
-
|
|
313987
|
-
|
|
314008
|
+
const body = [];
|
|
314009
|
+
if (outer.itemNonNull) {
|
|
314010
|
+
body.push(`pm.expect(__el, ${JSON.stringify(`${ctx} (list element): a non-null list item ([T!]) was null`)}).to.not.be.null;`);
|
|
314011
|
+
body.push(...elementLines);
|
|
314012
|
+
} else if (elementLines.length > 0) {
|
|
314013
|
+
body.push("if (__el === null || __el === undefined) return;", ...elementLines);
|
|
314014
|
+
}
|
|
314015
|
+
if (body.length > 0) {
|
|
314016
|
+
lines.push(`${accessor}.forEach(function (__el) {`, ...body.map((line) => ` ${line}`), "});");
|
|
313988
314017
|
}
|
|
313989
314018
|
return lines;
|
|
313990
314019
|
}
|
|
@@ -314002,8 +314031,22 @@ function emitValueAssertions(accessor, ref, selection, ctx, index, warnings) {
|
|
|
314002
314031
|
return lines;
|
|
314003
314032
|
}
|
|
314004
314033
|
if (ref.kind === "union") {
|
|
314005
|
-
|
|
314006
|
-
|
|
314034
|
+
const members = index.unionMembers[ref.name];
|
|
314035
|
+
const objMsg = JSON.stringify(ctx + ": expected union " + ref.name + " value as an object");
|
|
314036
|
+
const presentMsg = JSON.stringify(ctx + ": union " + ref.name + " value must carry __typename");
|
|
314037
|
+
const stringMsg = JSON.stringify(ctx + ": union " + ref.name + " __typename must be a string");
|
|
314038
|
+
const lines = [
|
|
314039
|
+
"pm.expect(" + accessor + ", " + objMsg + ').to.be.an("object");',
|
|
314040
|
+
"pm.expect(" + accessor + ", " + presentMsg + ').to.have.property("__typename");',
|
|
314041
|
+
"pm.expect(" + accessor + " && " + accessor + ".__typename, " + stringMsg + ').to.be.a("string");'
|
|
314042
|
+
];
|
|
314043
|
+
if (members && members.length > 0) {
|
|
314044
|
+
const memberMsg = JSON.stringify(ctx + ": __typename is not a declared member of union " + ref.name);
|
|
314045
|
+
lines.push("pm.expect(" + accessor + " && " + accessor + ".__typename, " + memberMsg + ").to.be.oneOf(" + JSON.stringify(members) + ");");
|
|
314046
|
+
} else {
|
|
314047
|
+
warnings.push("GQL_UNION_MEMBERS_UNKNOWN: " + ctx + " union " + ref.name + " member set was not resolved; only object + string __typename is asserted");
|
|
314048
|
+
}
|
|
314049
|
+
return lines;
|
|
314007
314050
|
}
|
|
314008
314051
|
warnings.push(`GQL_UNKNOWN_RETURN_TYPE: ${ctx} return type ${ref.name} could not be classified; only presence is asserted`);
|
|
314009
314052
|
return [];
|
|
@@ -314014,6 +314057,7 @@ function emitFieldAssertions(objectAccessor, parentTypeName, field, ctx, index,
|
|
|
314014
314057
|
const lines = [];
|
|
314015
314058
|
if (field.type.nonNull) {
|
|
314016
314059
|
lines.push(`pm.expect(${objectAccessor}, ${JSON.stringify(`${parentTypeName} is missing non-null field '${field.name}'`)}).to.have.property(${propName});`);
|
|
314060
|
+
lines.push(`pm.expect(${prop}, ${JSON.stringify(`${parentTypeName}.${field.name} is declared non-null but was null`)}).to.not.be.null;`);
|
|
314017
314061
|
}
|
|
314018
314062
|
const valueLines = emitValueAssertions(prop, field.type, field.selection, `${ctx}.${field.name}`, index, warnings);
|
|
314019
314063
|
if (valueLines.length > 0) {
|
|
@@ -314119,19 +314163,25 @@ function asArray6(value) {
|
|
|
314119
314163
|
}
|
|
314120
314164
|
var SCALAR_JSON_TYPE = {
|
|
314121
314165
|
double: { jsonType: "double" },
|
|
314122
|
-
float
|
|
314123
|
-
|
|
314124
|
-
|
|
314125
|
-
|
|
314126
|
-
|
|
314127
|
-
|
|
314128
|
-
|
|
314129
|
-
|
|
314130
|
-
|
|
314131
|
-
|
|
314132
|
-
|
|
314133
|
-
|
|
314134
|
-
|
|
314166
|
+
// proto float is float32; carry a format so the runtime enforces float32 range
|
|
314167
|
+
// (a finite double like 3.5e38 overflows float32 and must fail).
|
|
314168
|
+
float: { jsonType: "double", jsonFormat: "proto-float32" },
|
|
314169
|
+
// 32-bit integers JSON-encode as numbers; `intType` carries the exact protobuf
|
|
314170
|
+
// integer domain so the runtime range/sign-checks it (not just integrality).
|
|
314171
|
+
int32: { jsonType: "number", intType: "int32" },
|
|
314172
|
+
sint32: { jsonType: "number", intType: "sint32" },
|
|
314173
|
+
sfixed32: { jsonType: "number", intType: "sfixed32" },
|
|
314174
|
+
fixed32: { jsonType: "number", intType: "fixed32" },
|
|
314175
|
+
uint32: { jsonType: "number", intType: "uint32" },
|
|
314176
|
+
// 64-bit integers are JSON-encoded as strings by the proto JSON mapping and by
|
|
314177
|
+
// protobufjs default toObject; `intType` carries the exact domain so the runtime
|
|
314178
|
+
// lexically validates and RANGE-checks the string (string comparison avoids JS
|
|
314179
|
+
// double precision loss beyond 2^53).
|
|
314180
|
+
int64: { jsonType: "string", intType: "int64" },
|
|
314181
|
+
uint64: { jsonType: "string", intType: "uint64" },
|
|
314182
|
+
sint64: { jsonType: "string", intType: "sint64" },
|
|
314183
|
+
fixed64: { jsonType: "string", intType: "fixed64" },
|
|
314184
|
+
sfixed64: { jsonType: "string", intType: "sfixed64" },
|
|
314135
314185
|
bool: { jsonType: "boolean" },
|
|
314136
314186
|
string: { jsonType: "string" },
|
|
314137
314187
|
// bytes are base64 strings in proto JSON.
|
|
@@ -314142,11 +314192,11 @@ var WELL_KNOWN_JSON_TYPE = {
|
|
|
314142
314192
|
"google.protobuf.Duration": { jsonType: "string", jsonFormat: "proto-duration" },
|
|
314143
314193
|
"google.protobuf.FieldMask": { jsonType: "string", jsonFormat: "proto-field-mask" },
|
|
314144
314194
|
"google.protobuf.DoubleValue": { jsonType: "double", nullable: true },
|
|
314145
|
-
"google.protobuf.FloatValue": { jsonType: "double", nullable: true },
|
|
314146
|
-
"google.protobuf.Int32Value": { jsonType: "number", nullable: true },
|
|
314147
|
-
"google.protobuf.UInt32Value": { jsonType: "number", nullable: true },
|
|
314148
|
-
"google.protobuf.Int64Value": { jsonType: "string", nullable: true },
|
|
314149
|
-
"google.protobuf.UInt64Value": { jsonType: "string", nullable: true },
|
|
314195
|
+
"google.protobuf.FloatValue": { jsonType: "double", jsonFormat: "proto-float32", nullable: true },
|
|
314196
|
+
"google.protobuf.Int32Value": { jsonType: "number", intType: "int32", nullable: true },
|
|
314197
|
+
"google.protobuf.UInt32Value": { jsonType: "number", intType: "uint32", nullable: true },
|
|
314198
|
+
"google.protobuf.Int64Value": { jsonType: "string", intType: "int64", nullable: true },
|
|
314199
|
+
"google.protobuf.UInt64Value": { jsonType: "string", intType: "uint64", nullable: true },
|
|
314150
314200
|
"google.protobuf.BoolValue": { jsonType: "boolean", nullable: true },
|
|
314151
314201
|
"google.protobuf.StringValue": { jsonType: "string", nullable: true },
|
|
314152
314202
|
"google.protobuf.BytesValue": { jsonType: "string", jsonFormat: "proto-bytes", nullable: true },
|
|
@@ -314193,7 +314243,7 @@ function stripLeadingDot(name) {
|
|
|
314193
314243
|
}
|
|
314194
314244
|
function classifyValueType(protoType, resolved) {
|
|
314195
314245
|
const wkt = WELL_KNOWN_JSON_TYPE[stripLeadingDot(protoType)];
|
|
314196
|
-
if (wkt) return { jsonType: wkt.jsonType, jsonFormat: wkt.jsonFormat, nullable: wkt.nullable };
|
|
314246
|
+
if (wkt) return { jsonType: wkt.jsonType, jsonFormat: wkt.jsonFormat, nullable: wkt.nullable, intType: wkt.intType };
|
|
314197
314247
|
if (resolved && Array.isArray(resolved.fieldsArray)) {
|
|
314198
314248
|
return { jsonType: "object", messageType: stripLeadingDot(resolved.fullName) };
|
|
314199
314249
|
}
|
|
@@ -314201,9 +314251,14 @@ function classifyValueType(protoType, resolved) {
|
|
|
314201
314251
|
return { jsonType: "enum", enumType: stripLeadingDot(resolved.fullName) };
|
|
314202
314252
|
}
|
|
314203
314253
|
const scalar = SCALAR_JSON_TYPE[protoType];
|
|
314204
|
-
if (scalar) return { jsonType: scalar.jsonType, jsonFormat: scalar.jsonFormat };
|
|
314254
|
+
if (scalar) return { jsonType: scalar.jsonType, jsonFormat: scalar.jsonFormat, intType: scalar.intType };
|
|
314205
314255
|
return { jsonType: "unknown" };
|
|
314206
314256
|
}
|
|
314257
|
+
function classifyMapKey(keyType) {
|
|
314258
|
+
if (keyType === "bool") return "boolean";
|
|
314259
|
+
if (keyType && /^(?:u?int|sint|s?fixed)(?:32|64)$/.test(keyType)) return keyType;
|
|
314260
|
+
return void 0;
|
|
314261
|
+
}
|
|
314207
314262
|
function toLowerCamelCase(name) {
|
|
314208
314263
|
return name.replace(/_+([a-zA-Z0-9])/g, (_match, char) => char.toUpperCase()).replace(/_+$/g, "");
|
|
314209
314264
|
}
|
|
@@ -314232,6 +314287,7 @@ function fieldDescriptor(field, warnings, context) {
|
|
|
314232
314287
|
if (value.jsonType === "unknown") {
|
|
314233
314288
|
warnings.push(`PROTO_FIELD_TYPE_UNRESOLVED: map field ${context}.${field.name} has value type ${protoType} that could not be resolved; map values are not asserted`);
|
|
314234
314289
|
}
|
|
314290
|
+
const mapKeyType = classifyMapKey(field.keyType);
|
|
314235
314291
|
return {
|
|
314236
314292
|
name: String(field.name),
|
|
314237
314293
|
jsonName: protoJsonName(field),
|
|
@@ -314241,8 +314297,10 @@ function fieldDescriptor(field, warnings, context) {
|
|
|
314241
314297
|
map: true,
|
|
314242
314298
|
optional: Boolean(field.optional),
|
|
314243
314299
|
required: Boolean(field.required),
|
|
314300
|
+
...mapKeyType ? { mapKeyType } : {},
|
|
314244
314301
|
...value.jsonType !== "unknown" ? { mapValueType: value.jsonType } : {},
|
|
314245
314302
|
...value.jsonFormat ? { mapValueFormat: value.jsonFormat } : {},
|
|
314303
|
+
...value.intType ? { mapValueIntType: value.intType } : {},
|
|
314246
314304
|
...value.enumType ? { mapValueEnumType: value.enumType } : {},
|
|
314247
314305
|
...value.messageType ? { mapValueMessageType: value.messageType } : {}
|
|
314248
314306
|
};
|
|
@@ -314262,6 +314320,7 @@ function fieldDescriptor(field, warnings, context) {
|
|
|
314262
314320
|
optional: Boolean(field.optional),
|
|
314263
314321
|
required: Boolean(field.required),
|
|
314264
314322
|
...classified.nullable ? { nullable: true } : {},
|
|
314323
|
+
...classified.intType ? { intType: classified.intType } : {},
|
|
314265
314324
|
...classified.messageType ? { messageType: classified.messageType } : {},
|
|
314266
314325
|
...classified.enumType ? { enumType: classified.enumType } : {}
|
|
314267
314326
|
};
|
|
@@ -314497,13 +314556,16 @@ function buildShape(messageFullName, index, warnings, operationId, label, depth,
|
|
|
314497
314556
|
jsonName: field.jsonName,
|
|
314498
314557
|
jsonType: field.jsonType,
|
|
314499
314558
|
...field.jsonFormat ? { jsonFormat: field.jsonFormat } : {},
|
|
314559
|
+
...field.intType ? { intType: field.intType } : {},
|
|
314500
314560
|
repeated: field.repeated,
|
|
314501
314561
|
map: field.map,
|
|
314502
314562
|
required: field.required,
|
|
314503
314563
|
...field.nullable ? { nullable: true } : {},
|
|
314504
314564
|
...enumValues ? { enumValues } : {},
|
|
314565
|
+
...field.mapKeyType ? { mapKeyType: field.mapKeyType } : {},
|
|
314505
314566
|
...field.mapValueType ? { mapValueType: field.mapValueType } : {},
|
|
314506
314567
|
...field.mapValueFormat ? { mapValueFormat: field.mapValueFormat } : {},
|
|
314568
|
+
...field.mapValueIntType ? { mapValueIntType: field.mapValueIntType } : {},
|
|
314507
314569
|
...mapValueEnumValues ? { mapValueEnumValues } : {}
|
|
314508
314570
|
};
|
|
314509
314571
|
if (field.messageType && field.jsonType === "object" && !field.map) {
|
|
@@ -314570,18 +314632,38 @@ function createGrpcScript(spec) {
|
|
|
314570
314632
|
' if (expected === "any") return true;',
|
|
314571
314633
|
" return true;",
|
|
314572
314634
|
"}",
|
|
314635
|
+
'var GRPC_INT_SPECS = { int32:{s:true,b:32,min:"-2147483648",max:"2147483647"}, sint32:{s:true,b:32,min:"-2147483648",max:"2147483647"}, sfixed32:{s:true,b:32,min:"-2147483648",max:"2147483647"}, uint32:{s:false,b:32,min:"0",max:"4294967295"}, fixed32:{s:false,b:32,min:"0",max:"4294967295"}, int64:{s:true,b:64,min:"-9223372036854775808",max:"9223372036854775807"}, sint64:{s:true,b:64,min:"-9223372036854775808",max:"9223372036854775807"}, sfixed64:{s:true,b:64,min:"-9223372036854775808",max:"9223372036854775807"}, uint64:{s:false,b:64,min:"0",max:"18446744073709551615"}, fixed64:{s:false,b:64,min:"0",max:"18446744073709551615"} };',
|
|
314636
|
+
'function grpcDecStr(n) { var s = String(n); return (s.indexOf("e") === -1 && s.indexOf("E") === -1 && s.indexOf(".") === -1) ? s : null; }',
|
|
314637
|
+
'function grpcCmpIntStr(a, b) { var na = a.charAt(0) === "-", nb = b.charAt(0) === "-"; if (na !== nb) return na ? -1 : 1; var aa = (na ? a.slice(1) : a).replace(/^0+(?=[0-9])/, ""); var bb = (nb ? b.slice(1) : b).replace(/^0+(?=[0-9])/, ""); var mag; if (aa.length !== bb.length) mag = aa.length < bb.length ? -1 : 1; else mag = aa < bb ? -1 : (aa > bb ? 1 : 0); return na ? -mag : mag; }',
|
|
314638
|
+
'function grpcNormIntStr(s) { var neg = false; if (s.charAt(0) === "-") { neg = true; s = s.slice(1); } else if (s.charAt(0) === "+") { s = s.slice(1); } var ei = s.indexOf("e"); if (ei === -1) ei = s.indexOf("E"); var exp = 0; if (ei !== -1) { exp = parseInt(s.slice(ei + 1), 10); s = s.slice(0, ei); } var dot = s.indexOf("."); var intp = dot === -1 ? s : s.slice(0, dot); var frac = dot === -1 ? "" : s.slice(dot + 1); var digits = intp + frac; if (digits.length === 0) return null; if (/^0+$/.test(digits)) return "0"; if (exp >= 0) { var intpSize = intp === "0" ? 0 : intp.length; if (intpSize + exp > 20) return null; } var netExp = exp - frac.length; var out; if (netExp >= 0) { if (digits.length + netExp > 40) return null; out = digits; for (var z = 0; z < netExp; z++) out += "0"; } else { var cut = -netExp; var keepLen = digits.length - cut; var dropped = keepLen <= 0 ? digits : digits.slice(keepLen); for (var d = 0; d < dropped.length; d++) { if (dropped.charAt(d) !== "0") return null; } out = keepLen <= 0 ? "0" : digits.slice(0, keepLen); } var st = 0; while (st < out.length - 1 && out.charAt(st) === "0") st++; out = out.slice(st); if (out === "0") return "0"; if (out.length > 40) return null; return neg ? "-" + out : out; }',
|
|
314639
|
+
"function matchesInt(intType, value) {",
|
|
314640
|
+
" var spec = GRPC_INT_SPECS[intType]; if (!spec) return true;",
|
|
314641
|
+
" var num, canonical;",
|
|
314642
|
+
' if (typeof value === "number") { if (!Number.isFinite(value) || !Number.isInteger(value)) return false; num = value; canonical = grpcDecStr(value); }',
|
|
314643
|
+
' else if (typeof value === "string") { if (!/^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$/.test(value)) return false; canonical = grpcNormIntStr(value); if (canonical === null) return false; num = Number(value); }',
|
|
314644
|
+
" else { return false; }",
|
|
314645
|
+
' if (canonical === "-0") canonical = "0";',
|
|
314646
|
+
' if (!spec.s && ((canonical !== null && canonical.charAt(0) === "-") || num < 0)) return false;',
|
|
314647
|
+
" if (spec.b === 32) return num >= Number(spec.min) && num <= Number(spec.max);",
|
|
314648
|
+
" if (canonical !== null) return grpcCmpIntStr(canonical, spec.min) >= 0 && grpcCmpIntStr(canonical, spec.max) <= 0;",
|
|
314649
|
+
" return false;",
|
|
314650
|
+
"}",
|
|
314651
|
+
'function matchesIntKey(intType, key) { var spec = GRPC_INT_SPECS[intType]; if (!spec) return true; if (!(spec.s ? /^[+-]?[0-9]+$/ : /^[0-9]+$/).test(key)) return false; var neg = key.charAt(0) === "-"; var body = (key.charAt(0) === "+" || key.charAt(0) === "-") ? key.slice(1) : key; if (body.length === 0) return false; var canon = neg ? "-" + body : body; return grpcCmpIntStr(canon, spec.min) >= 0 && grpcCmpIntStr(canon, spec.max) <= 0; }',
|
|
314652
|
+
"function matchesEnumNumber(n) { return Number.isInteger(n) && n >= -2147483648 && n <= 2147483647; }",
|
|
314573
314653
|
"function daysFromCivil(y, m, d) { y -= m <= 2 ? 1 : 0; var era = Math.floor(y / 400); var yoe = y - era * 400; var mp = m + (m > 2 ? -3 : 9); var doy = Math.floor((153 * mp + 2) / 5) + d - 1; var doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy; return era * 146097 + doe - 719468; }",
|
|
314574
314654
|
"function validDate(y, m, d) { if (y < 1 || y > 9999 || m < 1 || m > 12 || d < 1) return false; var mdays = [31, ((y % 4 === 0 && y % 100 !== 0) || y % 400 === 0) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; return d <= mdays[m - 1]; }",
|
|
314575
314655
|
'function validProtoTimestamp(value) { if (typeof value !== "string") return false; var m = value.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:\\.([0-9]{1,9}))?(Z|[+-][0-9]{2}:[0-9]{2})$/); if (!m) return false; var y = Number(m[1]), mo = Number(m[2]), d = Number(m[3]), h = Number(m[4]), mi = Number(m[5]), s = Number(m[6]); if (!validDate(y, mo, d) || h > 23 || mi > 59 || s > 59) return false; var off = 0; if (m[8] !== "Z") { var sign = m[8][0] === "-" ? -1 : 1; var oh = Number(m[8].slice(1, 3)), om = Number(m[8].slice(4, 6)); if (oh > 23 || om > 59) return false; off = sign * (oh * 3600 + om * 60); } var sec = daysFromCivil(y, mo, d) * 86400 + h * 3600 + mi * 60 + s - off; return sec >= -62135596800 && sec <= 253402300799; }',
|
|
314576
314656
|
'function validProtoDuration(value) { if (typeof value !== "string") return false; var m = value.match(/^[+-]?(?:(0|[1-9][0-9]*)(?:\\.[0-9]{0,9})?|\\.[0-9]{0,9})s$/); if (!m) return false; return !m[1] || Number(m[1]) <= 315576000000; }',
|
|
314577
314657
|
'function validProtoFieldMask(value) { if (typeof value !== "string") return false; if (value === "") return true; var paths = value.split(","); for (var i = 0; i < paths.length; i++) { if (!/^[a-z][A-Za-z0-9]*(\\.[a-z][A-Za-z0-9]*)*$/.test(paths[i])) return false; } return true; }',
|
|
314578
314658
|
'function validProtoBytes(value) { if (typeof value !== "string") return false; if (!/^(?:[A-Za-z0-9+/]*|[A-Za-z0-9_-]*)={0,2}$/.test(value)) return false; var firstPad = value.indexOf("="); if (firstPad !== -1 && firstPad < value.length - (value.endsWith("==") ? 2 : 1)) return false; var pad = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0; var raw = value.length - pad; if (raw % 4 === 1) return false; return pad === 0 || (raw + pad) % 4 === 0 && pad === (4 - raw % 4) % 4; }',
|
|
314659
|
+
'function validProtoFloat32(value) { if (value === "NaN" || value === "Infinity" || value === "-Infinity") return true; var n = typeof value === "number" ? value : Number(value); if (!Number.isFinite(n)) return false; return Number.isFinite(Math.fround(n)); }',
|
|
314579
314660
|
"function matchesFormat(format, value) {",
|
|
314580
314661
|
" if (!format) return true;",
|
|
314581
314662
|
' if (format === "proto-timestamp") return validProtoTimestamp(value);',
|
|
314582
314663
|
' if (format === "proto-duration") return validProtoDuration(value);',
|
|
314583
314664
|
' if (format === "proto-field-mask") return validProtoFieldMask(value);',
|
|
314584
314665
|
' if (format === "proto-bytes") return validProtoBytes(value);',
|
|
314666
|
+
' if (format === "proto-float32") return validProtoFloat32(value);',
|
|
314585
314667
|
" return true;",
|
|
314586
314668
|
"}",
|
|
314587
314669
|
"function formatLabel(format) {",
|
|
@@ -314589,6 +314671,7 @@ function createGrpcScript(spec) {
|
|
|
314589
314671
|
' if (format === "proto-duration") return "a valid ProtoJSON Duration";',
|
|
314590
314672
|
' if (format === "proto-field-mask") return "a valid ProtoJSON FieldMask";',
|
|
314591
314673
|
' if (format === "proto-bytes") return "valid ProtoJSON base64 bytes";',
|
|
314674
|
+
' if (format === "proto-float32") return "a float32-representable number";',
|
|
314592
314675
|
' return format || "valid ProtoJSON";',
|
|
314593
314676
|
"}",
|
|
314594
314677
|
// Recursive shape checker: validates fields (with nested message descent,
|
|
@@ -314602,14 +314685,15 @@ function createGrpcScript(spec) {
|
|
|
314602
314685
|
' if (field.required && !present) { pm.expect.fail("gRPC response is missing required field " + label); return; }',
|
|
314603
314686
|
" if (!present) return;",
|
|
314604
314687
|
" var value = obj[key];",
|
|
314605
|
-
" if (
|
|
314688
|
+
" if (value === null) return;",
|
|
314606
314689
|
" if (field.repeated) {",
|
|
314607
314690
|
' if (!matchesScalar("array", value)) { pm.expect.fail("gRPC field " + label + " must be a repeated (array) value but was " + jsonTypeOf(value)); return; }',
|
|
314608
314691
|
" for (var i = 0; i < value.length; i++) {",
|
|
314609
314692
|
' var elem = value[i]; var elemLabel = label + "[" + i + "]";',
|
|
314610
314693
|
' if (field.shape) { if (!matchesScalar("object", elem)) { pm.expect.fail("gRPC repeated field " + elemLabel + " must be an object but was " + jsonTypeOf(elem)); } else { grpcCheckShape(elem, field.shape, elemLabel + "."); } continue; }',
|
|
314611
|
-
' if (field.enumValues && field.enumValues.length > 0) { if (typeof elem === "number") { if (!
|
|
314694
|
+
' if (field.enumValues && field.enumValues.length > 0) { if (typeof elem === "number") { if (!matchesEnumNumber(elem)) pm.expect.fail("gRPC repeated enum field " + elemLabel + " must be an int32-range integer but was " + elem); continue; } if (typeof elem !== "string") { pm.expect.fail("gRPC repeated enum field " + elemLabel + " must be a string or number but was " + jsonTypeOf(elem)); } else if (field.enumValues.indexOf(elem) === -1) { pm.expect.fail("gRPC repeated enum field " + elemLabel + " has value " + elem + " not in [" + field.enumValues.join(", ") + "]"); } continue; }',
|
|
314612
314695
|
' if (field.jsonType === "any") continue;',
|
|
314696
|
+
' if (field.intType) { if (!matchesInt(field.intType, elem)) pm.expect.fail("gRPC repeated field " + elemLabel + " must be a valid " + field.intType + " (in range) but was " + JSON.stringify(elem)); continue; }',
|
|
314613
314697
|
' if (!matchesScalar(field.jsonType, elem)) pm.expect.fail("gRPC repeated field " + elemLabel + " must be " + field.jsonType + " but was " + jsonTypeOf(elem));',
|
|
314614
314698
|
' else if (!matchesFormat(field.jsonFormat, elem)) pm.expect.fail("gRPC repeated field " + elemLabel + " must be " + formatLabel(field.jsonFormat));',
|
|
314615
314699
|
" }",
|
|
@@ -314617,17 +314701,28 @@ function createGrpcScript(spec) {
|
|
|
314617
314701
|
" }",
|
|
314618
314702
|
" if (field.map) {",
|
|
314619
314703
|
' if (!matchesScalar("object", value)) { pm.expect.fail("gRPC map field " + label + " must be an object but was " + jsonTypeOf(value)); return; }',
|
|
314620
|
-
|
|
314704
|
+
" var keys = Object.keys(value);",
|
|
314705
|
+
" for (var k = 0; k < keys.length; k++) {",
|
|
314706
|
+
' var mk = keys[k], mv = value[mk], mvLabel = label + "[" + mk + "]";',
|
|
314707
|
+
' if (field.mapKeyType === "boolean") { if (mk !== "true" && mk !== "false") pm.expect.fail("gRPC map key " + mvLabel + " must be the string true or false but was " + mk); }',
|
|
314708
|
+
' else if (field.mapKeyType) { if (!matchesIntKey(field.mapKeyType, mk)) pm.expect.fail("gRPC map key " + mvLabel + " must be a valid " + field.mapKeyType + " string (in range) but was " + mk); }',
|
|
314709
|
+
' if (field.mapValueShape && matchesScalar("object", mv)) { grpcCheckShape(mv, field.mapValueShape, mvLabel + "."); }',
|
|
314710
|
+
' else if (field.mapValueIntType) { if (!matchesInt(field.mapValueIntType, mv)) pm.expect.fail("gRPC map value " + mvLabel + " must be a valid " + field.mapValueIntType + " (in range) but was " + JSON.stringify(mv)); }',
|
|
314711
|
+
' else if (field.mapValueEnumValues && field.mapValueEnumValues.length > 0) { if (typeof mv === "number") { if (!matchesEnumNumber(mv)) pm.expect.fail("gRPC map enum value " + mvLabel + " must be an int32-range integer but was " + mv); } else if (typeof mv !== "string") { pm.expect.fail("gRPC map enum value " + mvLabel + " must be a string or number but was " + jsonTypeOf(mv)); } else if (field.mapValueEnumValues.indexOf(mv) === -1) { pm.expect.fail("gRPC map enum value " + mvLabel + " has value " + mv + " not in [" + field.mapValueEnumValues.join(", ") + "]"); } }',
|
|
314712
|
+
' else if (field.mapValueType && !matchesScalar(field.mapValueType, mv)) { pm.expect.fail("gRPC map value " + mvLabel + " must be " + field.mapValueType + " but was " + jsonTypeOf(mv)); }',
|
|
314713
|
+
' else if (field.mapValueType && !matchesFormat(field.mapValueFormat, mv)) { pm.expect.fail("gRPC map value " + mvLabel + " must be " + formatLabel(field.mapValueFormat)); }',
|
|
314714
|
+
" }",
|
|
314621
314715
|
" return;",
|
|
314622
314716
|
" }",
|
|
314623
314717
|
" if (field.enumValues && field.enumValues.length > 0) {",
|
|
314624
|
-
' if (typeof value === "number") { if (!
|
|
314718
|
+
' if (typeof value === "number") { if (!matchesEnumNumber(value)) pm.expect.fail("gRPC enum field " + label + " must be an int32-range integer but was " + value); return; }',
|
|
314625
314719
|
' if (typeof value !== "string") { pm.expect.fail("gRPC enum field " + label + " must be a string or number but was " + jsonTypeOf(value)); return; }',
|
|
314626
314720
|
' if (field.enumValues.indexOf(value) === -1) pm.expect.fail("gRPC enum field " + label + " has value " + value + " not in [" + field.enumValues.join(", ") + "]");',
|
|
314627
314721
|
" return;",
|
|
314628
314722
|
" }",
|
|
314629
314723
|
' if (field.jsonType === "any") return;',
|
|
314630
314724
|
' if (field.shape) { if (!matchesScalar("object", value)) { pm.expect.fail("gRPC field " + label + " must be an object but was " + jsonTypeOf(value)); return; } grpcCheckShape(value, field.shape, label + "."); return; }',
|
|
314725
|
+
' if (field.intType) { if (!matchesInt(field.intType, value)) pm.expect.fail("gRPC field " + label + " must be a valid " + field.intType + " (in range) but was " + JSON.stringify(value)); return; }',
|
|
314631
314726
|
' if (!matchesScalar(field.jsonType, value)) pm.expect.fail("gRPC field " + label + " must be " + field.jsonType + " but was " + jsonTypeOf(value));',
|
|
314632
314727
|
' else if (!matchesFormat(field.jsonFormat, value)) pm.expect.fail("gRPC field " + label + " must be " + formatLabel(field.jsonFormat));',
|
|
314633
314728
|
"}",
|
|
@@ -314677,6 +314772,103 @@ function methodPathOf(item) {
|
|
|
314677
314772
|
const value = payload?.methodPath;
|
|
314678
314773
|
return typeof value === "string" ? value : "";
|
|
314679
314774
|
}
|
|
314775
|
+
var GRPC_INT_SPECS = {
|
|
314776
|
+
int32: { signed: true, bits: 32, min: "-2147483648", max: "2147483647" },
|
|
314777
|
+
sint32: { signed: true, bits: 32, min: "-2147483648", max: "2147483647" },
|
|
314778
|
+
sfixed32: { signed: true, bits: 32, min: "-2147483648", max: "2147483647" },
|
|
314779
|
+
uint32: { signed: false, bits: 32, min: "0", max: "4294967295" },
|
|
314780
|
+
fixed32: { signed: false, bits: 32, min: "0", max: "4294967295" },
|
|
314781
|
+
int64: { signed: true, bits: 64, min: "-9223372036854775808", max: "9223372036854775807" },
|
|
314782
|
+
sint64: { signed: true, bits: 64, min: "-9223372036854775808", max: "9223372036854775807" },
|
|
314783
|
+
sfixed64: { signed: true, bits: 64, min: "-9223372036854775808", max: "9223372036854775807" },
|
|
314784
|
+
uint64: { signed: false, bits: 64, min: "0", max: "18446744073709551615" },
|
|
314785
|
+
fixed64: { signed: false, bits: 64, min: "0", max: "18446744073709551615" }
|
|
314786
|
+
};
|
|
314787
|
+
function grpcDecStr(n) {
|
|
314788
|
+
const s = String(n);
|
|
314789
|
+
return s.indexOf("e") === -1 && s.indexOf("E") === -1 && s.indexOf(".") === -1 ? s : null;
|
|
314790
|
+
}
|
|
314791
|
+
function grpcCmpIntStr(a, b) {
|
|
314792
|
+
const na = a.charAt(0) === "-";
|
|
314793
|
+
const nb = b.charAt(0) === "-";
|
|
314794
|
+
if (na !== nb) return na ? -1 : 1;
|
|
314795
|
+
const aa = (na ? a.slice(1) : a).replace(/^0+(?=[0-9])/, "");
|
|
314796
|
+
const bb = (nb ? b.slice(1) : b).replace(/^0+(?=[0-9])/, "");
|
|
314797
|
+
let mag;
|
|
314798
|
+
if (aa.length !== bb.length) mag = aa.length < bb.length ? -1 : 1;
|
|
314799
|
+
else mag = aa < bb ? -1 : aa > bb ? 1 : 0;
|
|
314800
|
+
return na ? -mag : mag;
|
|
314801
|
+
}
|
|
314802
|
+
function grpcNormIntStr(input) {
|
|
314803
|
+
let s = input;
|
|
314804
|
+
let neg = false;
|
|
314805
|
+
if (s.charAt(0) === "-") {
|
|
314806
|
+
neg = true;
|
|
314807
|
+
s = s.slice(1);
|
|
314808
|
+
} else if (s.charAt(0) === "+") {
|
|
314809
|
+
s = s.slice(1);
|
|
314810
|
+
}
|
|
314811
|
+
let ei = s.indexOf("e");
|
|
314812
|
+
if (ei === -1) ei = s.indexOf("E");
|
|
314813
|
+
let exp = 0;
|
|
314814
|
+
if (ei !== -1) {
|
|
314815
|
+
exp = parseInt(s.slice(ei + 1), 10);
|
|
314816
|
+
s = s.slice(0, ei);
|
|
314817
|
+
}
|
|
314818
|
+
const dot = s.indexOf(".");
|
|
314819
|
+
const intp = dot === -1 ? s : s.slice(0, dot);
|
|
314820
|
+
const frac = dot === -1 ? "" : s.slice(dot + 1);
|
|
314821
|
+
const digits = intp + frac;
|
|
314822
|
+
if (digits.length === 0) return null;
|
|
314823
|
+
if (/^0+$/.test(digits)) return "0";
|
|
314824
|
+
if (exp >= 0) {
|
|
314825
|
+
const intpSize = intp === "0" ? 0 : intp.length;
|
|
314826
|
+
if (intpSize + exp > 20) return null;
|
|
314827
|
+
}
|
|
314828
|
+
const netExp = exp - frac.length;
|
|
314829
|
+
let out;
|
|
314830
|
+
if (netExp >= 0) {
|
|
314831
|
+
if (digits.length + netExp > 40) return null;
|
|
314832
|
+
out = digits + "0".repeat(netExp);
|
|
314833
|
+
} else {
|
|
314834
|
+
const cut = -netExp;
|
|
314835
|
+
const keepLen = digits.length - cut;
|
|
314836
|
+
const dropped = keepLen <= 0 ? digits : digits.slice(keepLen);
|
|
314837
|
+
for (let d = 0; d < dropped.length; d += 1) {
|
|
314838
|
+
if (dropped.charAt(d) !== "0") return null;
|
|
314839
|
+
}
|
|
314840
|
+
out = keepLen <= 0 ? "0" : digits.slice(0, keepLen);
|
|
314841
|
+
}
|
|
314842
|
+
let st = 0;
|
|
314843
|
+
while (st < out.length - 1 && out.charAt(st) === "0") st += 1;
|
|
314844
|
+
out = out.slice(st);
|
|
314845
|
+
if (out === "0") return "0";
|
|
314846
|
+
if (out.length > 40) return null;
|
|
314847
|
+
return neg ? `-${out}` : out;
|
|
314848
|
+
}
|
|
314849
|
+
function matchesIntValue(intType, value) {
|
|
314850
|
+
const spec = GRPC_INT_SPECS[intType];
|
|
314851
|
+
if (!spec) return true;
|
|
314852
|
+
let num;
|
|
314853
|
+
let canonical;
|
|
314854
|
+
if (typeof value === "number") {
|
|
314855
|
+
if (!Number.isFinite(value) || !Number.isInteger(value)) return false;
|
|
314856
|
+
num = value;
|
|
314857
|
+
canonical = grpcDecStr(value);
|
|
314858
|
+
} else if (typeof value === "string") {
|
|
314859
|
+
if (!/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$/.test(value)) return false;
|
|
314860
|
+
canonical = grpcNormIntStr(value);
|
|
314861
|
+
if (canonical === null) return false;
|
|
314862
|
+
num = Number(value);
|
|
314863
|
+
} else {
|
|
314864
|
+
return false;
|
|
314865
|
+
}
|
|
314866
|
+
if (canonical === "-0") canonical = "0";
|
|
314867
|
+
if (!spec.signed && (canonical !== null && canonical.charAt(0) === "-" || num < 0)) return false;
|
|
314868
|
+
if (spec.bits === 32) return num >= Number(spec.min) && num <= Number(spec.max);
|
|
314869
|
+
if (canonical !== null) return grpcCmpIntStr(canonical, spec.min) >= 0 && grpcCmpIntStr(canonical, spec.max) <= 0;
|
|
314870
|
+
return false;
|
|
314871
|
+
}
|
|
314680
314872
|
function matchesScalarValue(expected, value) {
|
|
314681
314873
|
const isJsonNumberString = (text) => /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$/.test(text) && Number.isFinite(Number(text));
|
|
314682
314874
|
switch (expected) {
|
|
@@ -314765,6 +314957,12 @@ function validProtoBytes(value) {
|
|
|
314765
314957
|
if (raw % 4 === 1) return false;
|
|
314766
314958
|
return pad === 0 || (raw + pad) % 4 === 0 && pad === (4 - raw % 4) % 4;
|
|
314767
314959
|
}
|
|
314960
|
+
function validProtoFloat32(value) {
|
|
314961
|
+
if (value === "NaN" || value === "Infinity" || value === "-Infinity") return true;
|
|
314962
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
314963
|
+
if (!Number.isFinite(n)) return false;
|
|
314964
|
+
return Number.isFinite(Math.fround(n));
|
|
314965
|
+
}
|
|
314768
314966
|
function matchesFormatValue(format3, value) {
|
|
314769
314967
|
switch (format3) {
|
|
314770
314968
|
case void 0:
|
|
@@ -314777,6 +314975,8 @@ function matchesFormatValue(format3, value) {
|
|
|
314777
314975
|
return validProtoFieldMask(value);
|
|
314778
314976
|
case "proto-bytes":
|
|
314779
314977
|
return validProtoBytes(value);
|
|
314978
|
+
case "proto-float32":
|
|
314979
|
+
return validProtoFloat32(value);
|
|
314780
314980
|
default:
|
|
314781
314981
|
return true;
|
|
314782
314982
|
}
|
|
@@ -314811,6 +315011,12 @@ function staticRequestCheck(item, shape, methodPath2, warnings) {
|
|
|
314811
315011
|
continue;
|
|
314812
315012
|
}
|
|
314813
315013
|
if (field.jsonType === "any" || field.enumValues || field.map || field.shape) continue;
|
|
315014
|
+
if (field.intType) {
|
|
315015
|
+
if (!matchesIntValue(field.intType, value)) {
|
|
315016
|
+
warnings.push(`PROTO_REQUEST_FIELD_TYPE_MISMATCH: ${methodPath2} request field ${field.name} must be a valid ${field.intType} (in range)`);
|
|
315017
|
+
}
|
|
315018
|
+
continue;
|
|
315019
|
+
}
|
|
314814
315020
|
if (!matchesScalarValue(field.jsonType, value)) {
|
|
314815
315021
|
warnings.push(`PROTO_REQUEST_FIELD_TYPE_MISMATCH: ${methodPath2} request field ${field.name} must be ${field.jsonType}`);
|
|
314816
315022
|
} else if (!matchesFormatValue(field.jsonFormat, value)) {
|
|
@@ -314820,6 +315026,7 @@ function staticRequestCheck(item, shape, methodPath2, warnings) {
|
|
|
314820
315026
|
}
|
|
314821
315027
|
function instrumentGrpcCollection(collection, index) {
|
|
314822
315028
|
const warnings = [...index.warnings, ...index.operations.flatMap((operation) => operation.warnings)];
|
|
315029
|
+
warnings.push("GRPC_UNKNOWN_FIELDS_NOT_REJECTED: extra response JSON keys are not rejected (proto3 forward-compat + open well-known types; unknown wire fields are not surfaced by the binary->JSON decode)");
|
|
314823
315030
|
const specs = /* @__PURE__ */ new Map();
|
|
314824
315031
|
const requestShapes = /* @__PURE__ */ new Map();
|
|
314825
315032
|
for (const operation of index.operations) {
|
|
@@ -315326,6 +315533,7 @@ function createSoapScript(operation, warnings = []) {
|
|
|
315326
315533
|
` pm.expect(bodyText, "expected SOAP response element <" + soap.expectedResponseElement + "> not found").to.match(new RegExp(${JSON.stringify(responseRegex)}));`,
|
|
315327
315534
|
"});"
|
|
315328
315535
|
);
|
|
315536
|
+
warnings.push(`SOAP_RESPONSE_BODY_WRAPPER_ONLY: operation ${operation.name} asserts the SOAP envelope/body/fault and the top-level response element <${operation.expectedResponseElement}> but NOT its child element/scalar shapes (WSDL/XSD payload validation is out of scope)`);
|
|
315329
315537
|
} else if (operation.output) {
|
|
315330
315538
|
warnings.push(`SOAP_RESPONSE_ELEMENT_UNKNOWN: operation ${operation.name} has an output message but no resolvable response element; only Envelope/Body/Fault are asserted`);
|
|
315331
315539
|
}
|