@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/action.cjs
CHANGED
|
@@ -298358,9 +298358,19 @@ function collectParameterChecks(root, pathItem, operation, version2, operationId
|
|
|
298358
298358
|
if (defaultSerialization) warnings.push(`CONTRACT_SCHEMA_NOT_COMPILED: parameter ${location2}:${name} schema on ${operationId} skipped (${packed.unsupported})`);
|
|
298359
298359
|
continue;
|
|
298360
298360
|
}
|
|
298361
|
-
if (location2 === "path"
|
|
298362
|
-
|
|
298363
|
-
|
|
298361
|
+
if (location2 === "path") {
|
|
298362
|
+
const containingSegment = pathTemplate.split("/").find((segment) => segment.includes(`{${name}}`));
|
|
298363
|
+
if (containingSegment !== void 0 && containingSegment !== `{${name}}`) {
|
|
298364
|
+
const segmentParts = containingSegment.split(/(\{[^}]+\})/).filter(Boolean);
|
|
298365
|
+
let extractable = true;
|
|
298366
|
+
for (let partIndex = 0; partIndex < segmentParts.length - 1; partIndex += 1) {
|
|
298367
|
+
if (/^\{[^}]+\}$/.test(segmentParts[partIndex]) && /^\{[^}]+\}$/.test(segmentParts[partIndex + 1])) extractable = false;
|
|
298368
|
+
}
|
|
298369
|
+
if (!extractable) {
|
|
298370
|
+
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`);
|
|
298371
|
+
continue;
|
|
298372
|
+
}
|
|
298373
|
+
}
|
|
298364
298374
|
}
|
|
298365
298375
|
const scalarSchema = packedScalarSchema(packed);
|
|
298366
298376
|
if (scalarSchema !== void 0) {
|
|
@@ -299080,7 +299090,7 @@ function createContractScript(operation, warnings = []) {
|
|
|
299080
299090
|
' 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; }); }',
|
|
299081
299091
|
// Server path prefixes sit ahead of the template segments, so the
|
|
299082
299092
|
// template aligns against the trailing request segments.
|
|
299083
|
-
' 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) {
|
|
299093
|
+
' 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; }',
|
|
299084
299094
|
' function isPlaceholder(value) { var text = String(value).trim(); return /^<[^<>]*>$/.test(text) || text.indexOf("{{") !== -1; }',
|
|
299085
299095
|
' function splitDelimited(value, decode) { if (decode === "csv") return value.split(","); if (decode === "ssv") return value.split(/%20| /); return value.split(/%7C|\\|/i); }',
|
|
299086
299096
|
" function decodeComponent(value) { try { return decodeURIComponent(value); } catch (ignored) { return value; } }",
|
|
@@ -301037,7 +301047,7 @@ function resolveActionVersion(explicit) {
|
|
|
301037
301047
|
if (explicit) {
|
|
301038
301048
|
return explicit;
|
|
301039
301049
|
}
|
|
301040
|
-
return "2.1.
|
|
301050
|
+
return "2.1.1" ? "2.1.1" : "unknown";
|
|
301041
301051
|
}
|
|
301042
301052
|
function telemetryDisabled(env) {
|
|
301043
301053
|
const flag = String(env.POSTMAN_ACTIONS_TELEMETRY ?? "").trim().toLowerCase();
|
|
@@ -313621,27 +313631,28 @@ function classifyNamedType(named) {
|
|
|
313621
313631
|
function describeType(type) {
|
|
313622
313632
|
let current = type;
|
|
313623
313633
|
let nonNull = false;
|
|
313624
|
-
let list = false;
|
|
313625
|
-
let listItemNonNull = false;
|
|
313626
313634
|
if ((0, import_graphql.isNonNullType)(current)) {
|
|
313627
313635
|
nonNull = true;
|
|
313628
313636
|
current = current.ofType;
|
|
313629
313637
|
}
|
|
313630
|
-
|
|
313631
|
-
|
|
313638
|
+
const lists = [];
|
|
313639
|
+
while ((0, import_graphql.isListType)(current)) {
|
|
313632
313640
|
current = current.ofType;
|
|
313641
|
+
let itemNonNull = false;
|
|
313633
313642
|
if ((0, import_graphql.isNonNullType)(current)) {
|
|
313634
|
-
|
|
313643
|
+
itemNonNull = true;
|
|
313635
313644
|
current = current.ofType;
|
|
313636
313645
|
}
|
|
313646
|
+
lists.push({ itemNonNull });
|
|
313637
313647
|
}
|
|
313638
313648
|
const named = (0, import_graphql.getNamedType)(current);
|
|
313639
313649
|
return {
|
|
313640
313650
|
name: named.name,
|
|
313641
313651
|
kind: classifyNamedType(named),
|
|
313642
313652
|
nonNull,
|
|
313643
|
-
list,
|
|
313644
|
-
listItemNonNull
|
|
313653
|
+
list: lists.length > 0,
|
|
313654
|
+
listItemNonNull: lists.length > 0 ? lists[0].itemNonNull : false,
|
|
313655
|
+
lists
|
|
313645
313656
|
};
|
|
313646
313657
|
}
|
|
313647
313658
|
function describeArgument(arg) {
|
|
@@ -313678,7 +313689,7 @@ function collectRootOperations(rootType, kind, schema, shapes) {
|
|
|
313678
313689
|
}
|
|
313679
313690
|
if (returns.kind === "union") {
|
|
313680
313691
|
opWarnings.push(
|
|
313681
|
-
`
|
|
313692
|
+
`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`
|
|
313682
313693
|
);
|
|
313683
313694
|
}
|
|
313684
313695
|
if (returns.kind === "unknown") {
|
|
@@ -313742,9 +313753,12 @@ function parseGraphQLSchema(content, opts = {}) {
|
|
|
313742
313753
|
}
|
|
313743
313754
|
for (const operation of operations) warnings.push(...operation.warnings);
|
|
313744
313755
|
const enumValues = {};
|
|
313756
|
+
const unionMembers = {};
|
|
313745
313757
|
for (const namedType of Object.values(schema.getTypeMap())) {
|
|
313746
313758
|
if ((0, import_graphql.isEnumType)(namedType)) {
|
|
313747
313759
|
enumValues[namedType.name] = namedType.getValues().map((value) => value.name);
|
|
313760
|
+
} else if ((0, import_graphql.isUnionType)(namedType)) {
|
|
313761
|
+
unionMembers[namedType.name] = namedType.getTypes().map((member) => member.name).sort((x, y) => x.localeCompare(y));
|
|
313748
313762
|
}
|
|
313749
313763
|
}
|
|
313750
313764
|
return {
|
|
@@ -313752,6 +313766,7 @@ function parseGraphQLSchema(content, opts = {}) {
|
|
|
313752
313766
|
operations,
|
|
313753
313767
|
objectShapes,
|
|
313754
313768
|
enumValues,
|
|
313769
|
+
unionMembers,
|
|
313755
313770
|
warnings
|
|
313756
313771
|
};
|
|
313757
313772
|
}
|
|
@@ -313759,6 +313774,7 @@ function parseGraphQLSchema(content, opts = {}) {
|
|
|
313759
313774
|
// src/lib/protocols/graphql/selection.ts
|
|
313760
313775
|
var SELECTION_DEPTH = 1;
|
|
313761
313776
|
function selectFields(typeRef, index, depth) {
|
|
313777
|
+
if (typeRef.kind === "union") return [];
|
|
313762
313778
|
if (typeRef.kind !== "object" && typeRef.kind !== "interface") return null;
|
|
313763
313779
|
const shape = index.objectShapes[typeRef.name];
|
|
313764
313780
|
if (!shape) return [];
|
|
@@ -313792,8 +313808,8 @@ var DEFAULT_URL = "{{baseUrl}}/graphql";
|
|
|
313792
313808
|
function argTypeSdl(arg) {
|
|
313793
313809
|
const ref = arg.type;
|
|
313794
313810
|
let inner = ref.name;
|
|
313795
|
-
|
|
313796
|
-
inner = ref.
|
|
313811
|
+
for (let i = ref.lists.length - 1; i >= 0; i -= 1) {
|
|
313812
|
+
inner = ref.lists[i].itemNonNull ? `[${inner}!]` : `[${inner}]`;
|
|
313797
313813
|
}
|
|
313798
313814
|
return ref.nonNull ? `${inner}!` : inner;
|
|
313799
313815
|
}
|
|
@@ -313962,12 +313978,25 @@ function buildShapeAssertions(operation, index, warnings) {
|
|
|
313962
313978
|
return emitValueAssertions("value", operation.returns, selection, operation.id, index, warnings);
|
|
313963
313979
|
}
|
|
313964
313980
|
function emitValueAssertions(accessor, ref, selection, ctx, index, warnings) {
|
|
313965
|
-
if (ref.
|
|
313966
|
-
const
|
|
313967
|
-
const
|
|
313981
|
+
if (ref.lists.length > 0) {
|
|
313982
|
+
const [outer, ...rest] = ref.lists;
|
|
313983
|
+
const innerRef = {
|
|
313984
|
+
...ref,
|
|
313985
|
+
lists: rest,
|
|
313986
|
+
list: rest.length > 0,
|
|
313987
|
+
listItemNonNull: rest.length > 0 ? rest[0].itemNonNull : false
|
|
313988
|
+
};
|
|
313989
|
+
const elementLines = emitValueAssertions("__el", innerRef, selection, `${ctx} (list element)`, index, warnings);
|
|
313968
313990
|
const lines = [`pm.expect(${accessor}, ${JSON.stringify(`${ctx}: expected a list`)}).to.be.an("array");`];
|
|
313969
|
-
|
|
313970
|
-
|
|
313991
|
+
const body = [];
|
|
313992
|
+
if (outer.itemNonNull) {
|
|
313993
|
+
body.push(`pm.expect(__el, ${JSON.stringify(`${ctx} (list element): a non-null list item ([T!]) was null`)}).to.not.be.null;`);
|
|
313994
|
+
body.push(...elementLines);
|
|
313995
|
+
} else if (elementLines.length > 0) {
|
|
313996
|
+
body.push("if (__el === null || __el === undefined) return;", ...elementLines);
|
|
313997
|
+
}
|
|
313998
|
+
if (body.length > 0) {
|
|
313999
|
+
lines.push(`${accessor}.forEach(function (__el) {`, ...body.map((line) => ` ${line}`), "});");
|
|
313971
314000
|
}
|
|
313972
314001
|
return lines;
|
|
313973
314002
|
}
|
|
@@ -313985,8 +314014,22 @@ function emitValueAssertions(accessor, ref, selection, ctx, index, warnings) {
|
|
|
313985
314014
|
return lines;
|
|
313986
314015
|
}
|
|
313987
314016
|
if (ref.kind === "union") {
|
|
313988
|
-
|
|
313989
|
-
|
|
314017
|
+
const members = index.unionMembers[ref.name];
|
|
314018
|
+
const objMsg = JSON.stringify(ctx + ": expected union " + ref.name + " value as an object");
|
|
314019
|
+
const presentMsg = JSON.stringify(ctx + ": union " + ref.name + " value must carry __typename");
|
|
314020
|
+
const stringMsg = JSON.stringify(ctx + ": union " + ref.name + " __typename must be a string");
|
|
314021
|
+
const lines = [
|
|
314022
|
+
"pm.expect(" + accessor + ", " + objMsg + ').to.be.an("object");',
|
|
314023
|
+
"pm.expect(" + accessor + ", " + presentMsg + ').to.have.property("__typename");',
|
|
314024
|
+
"pm.expect(" + accessor + " && " + accessor + ".__typename, " + stringMsg + ').to.be.a("string");'
|
|
314025
|
+
];
|
|
314026
|
+
if (members && members.length > 0) {
|
|
314027
|
+
const memberMsg = JSON.stringify(ctx + ": __typename is not a declared member of union " + ref.name);
|
|
314028
|
+
lines.push("pm.expect(" + accessor + " && " + accessor + ".__typename, " + memberMsg + ").to.be.oneOf(" + JSON.stringify(members) + ");");
|
|
314029
|
+
} else {
|
|
314030
|
+
warnings.push("GQL_UNION_MEMBERS_UNKNOWN: " + ctx + " union " + ref.name + " member set was not resolved; only object + string __typename is asserted");
|
|
314031
|
+
}
|
|
314032
|
+
return lines;
|
|
313990
314033
|
}
|
|
313991
314034
|
warnings.push(`GQL_UNKNOWN_RETURN_TYPE: ${ctx} return type ${ref.name} could not be classified; only presence is asserted`);
|
|
313992
314035
|
return [];
|
|
@@ -313997,6 +314040,7 @@ function emitFieldAssertions(objectAccessor, parentTypeName, field, ctx, index,
|
|
|
313997
314040
|
const lines = [];
|
|
313998
314041
|
if (field.type.nonNull) {
|
|
313999
314042
|
lines.push(`pm.expect(${objectAccessor}, ${JSON.stringify(`${parentTypeName} is missing non-null field '${field.name}'`)}).to.have.property(${propName});`);
|
|
314043
|
+
lines.push(`pm.expect(${prop}, ${JSON.stringify(`${parentTypeName}.${field.name} is declared non-null but was null`)}).to.not.be.null;`);
|
|
314000
314044
|
}
|
|
314001
314045
|
const valueLines = emitValueAssertions(prop, field.type, field.selection, `${ctx}.${field.name}`, index, warnings);
|
|
314002
314046
|
if (valueLines.length > 0) {
|
|
@@ -314102,19 +314146,25 @@ function asArray6(value) {
|
|
|
314102
314146
|
}
|
|
314103
314147
|
var SCALAR_JSON_TYPE = {
|
|
314104
314148
|
double: { jsonType: "double" },
|
|
314105
|
-
float
|
|
314106
|
-
|
|
314107
|
-
|
|
314108
|
-
|
|
314109
|
-
|
|
314110
|
-
|
|
314111
|
-
|
|
314112
|
-
|
|
314113
|
-
|
|
314114
|
-
|
|
314115
|
-
|
|
314116
|
-
|
|
314117
|
-
|
|
314149
|
+
// proto float is float32; carry a format so the runtime enforces float32 range
|
|
314150
|
+
// (a finite double like 3.5e38 overflows float32 and must fail).
|
|
314151
|
+
float: { jsonType: "double", jsonFormat: "proto-float32" },
|
|
314152
|
+
// 32-bit integers JSON-encode as numbers; `intType` carries the exact protobuf
|
|
314153
|
+
// integer domain so the runtime range/sign-checks it (not just integrality).
|
|
314154
|
+
int32: { jsonType: "number", intType: "int32" },
|
|
314155
|
+
sint32: { jsonType: "number", intType: "sint32" },
|
|
314156
|
+
sfixed32: { jsonType: "number", intType: "sfixed32" },
|
|
314157
|
+
fixed32: { jsonType: "number", intType: "fixed32" },
|
|
314158
|
+
uint32: { jsonType: "number", intType: "uint32" },
|
|
314159
|
+
// 64-bit integers are JSON-encoded as strings by the proto JSON mapping and by
|
|
314160
|
+
// protobufjs default toObject; `intType` carries the exact domain so the runtime
|
|
314161
|
+
// lexically validates and RANGE-checks the string (string comparison avoids JS
|
|
314162
|
+
// double precision loss beyond 2^53).
|
|
314163
|
+
int64: { jsonType: "string", intType: "int64" },
|
|
314164
|
+
uint64: { jsonType: "string", intType: "uint64" },
|
|
314165
|
+
sint64: { jsonType: "string", intType: "sint64" },
|
|
314166
|
+
fixed64: { jsonType: "string", intType: "fixed64" },
|
|
314167
|
+
sfixed64: { jsonType: "string", intType: "sfixed64" },
|
|
314118
314168
|
bool: { jsonType: "boolean" },
|
|
314119
314169
|
string: { jsonType: "string" },
|
|
314120
314170
|
// bytes are base64 strings in proto JSON.
|
|
@@ -314125,11 +314175,11 @@ var WELL_KNOWN_JSON_TYPE = {
|
|
|
314125
314175
|
"google.protobuf.Duration": { jsonType: "string", jsonFormat: "proto-duration" },
|
|
314126
314176
|
"google.protobuf.FieldMask": { jsonType: "string", jsonFormat: "proto-field-mask" },
|
|
314127
314177
|
"google.protobuf.DoubleValue": { jsonType: "double", nullable: true },
|
|
314128
|
-
"google.protobuf.FloatValue": { jsonType: "double", nullable: true },
|
|
314129
|
-
"google.protobuf.Int32Value": { jsonType: "number", nullable: true },
|
|
314130
|
-
"google.protobuf.UInt32Value": { jsonType: "number", nullable: true },
|
|
314131
|
-
"google.protobuf.Int64Value": { jsonType: "string", nullable: true },
|
|
314132
|
-
"google.protobuf.UInt64Value": { jsonType: "string", nullable: true },
|
|
314178
|
+
"google.protobuf.FloatValue": { jsonType: "double", jsonFormat: "proto-float32", nullable: true },
|
|
314179
|
+
"google.protobuf.Int32Value": { jsonType: "number", intType: "int32", nullable: true },
|
|
314180
|
+
"google.protobuf.UInt32Value": { jsonType: "number", intType: "uint32", nullable: true },
|
|
314181
|
+
"google.protobuf.Int64Value": { jsonType: "string", intType: "int64", nullable: true },
|
|
314182
|
+
"google.protobuf.UInt64Value": { jsonType: "string", intType: "uint64", nullable: true },
|
|
314133
314183
|
"google.protobuf.BoolValue": { jsonType: "boolean", nullable: true },
|
|
314134
314184
|
"google.protobuf.StringValue": { jsonType: "string", nullable: true },
|
|
314135
314185
|
"google.protobuf.BytesValue": { jsonType: "string", jsonFormat: "proto-bytes", nullable: true },
|
|
@@ -314176,7 +314226,7 @@ function stripLeadingDot(name) {
|
|
|
314176
314226
|
}
|
|
314177
314227
|
function classifyValueType(protoType, resolved) {
|
|
314178
314228
|
const wkt = WELL_KNOWN_JSON_TYPE[stripLeadingDot(protoType)];
|
|
314179
|
-
if (wkt) return { jsonType: wkt.jsonType, jsonFormat: wkt.jsonFormat, nullable: wkt.nullable };
|
|
314229
|
+
if (wkt) return { jsonType: wkt.jsonType, jsonFormat: wkt.jsonFormat, nullable: wkt.nullable, intType: wkt.intType };
|
|
314180
314230
|
if (resolved && Array.isArray(resolved.fieldsArray)) {
|
|
314181
314231
|
return { jsonType: "object", messageType: stripLeadingDot(resolved.fullName) };
|
|
314182
314232
|
}
|
|
@@ -314184,9 +314234,14 @@ function classifyValueType(protoType, resolved) {
|
|
|
314184
314234
|
return { jsonType: "enum", enumType: stripLeadingDot(resolved.fullName) };
|
|
314185
314235
|
}
|
|
314186
314236
|
const scalar = SCALAR_JSON_TYPE[protoType];
|
|
314187
|
-
if (scalar) return { jsonType: scalar.jsonType, jsonFormat: scalar.jsonFormat };
|
|
314237
|
+
if (scalar) return { jsonType: scalar.jsonType, jsonFormat: scalar.jsonFormat, intType: scalar.intType };
|
|
314188
314238
|
return { jsonType: "unknown" };
|
|
314189
314239
|
}
|
|
314240
|
+
function classifyMapKey(keyType) {
|
|
314241
|
+
if (keyType === "bool") return "boolean";
|
|
314242
|
+
if (keyType && /^(?:u?int|sint|s?fixed)(?:32|64)$/.test(keyType)) return keyType;
|
|
314243
|
+
return void 0;
|
|
314244
|
+
}
|
|
314190
314245
|
function toLowerCamelCase(name) {
|
|
314191
314246
|
return name.replace(/_+([a-zA-Z0-9])/g, (_match, char) => char.toUpperCase()).replace(/_+$/g, "");
|
|
314192
314247
|
}
|
|
@@ -314215,6 +314270,7 @@ function fieldDescriptor(field, warnings, context) {
|
|
|
314215
314270
|
if (value.jsonType === "unknown") {
|
|
314216
314271
|
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`);
|
|
314217
314272
|
}
|
|
314273
|
+
const mapKeyType = classifyMapKey(field.keyType);
|
|
314218
314274
|
return {
|
|
314219
314275
|
name: String(field.name),
|
|
314220
314276
|
jsonName: protoJsonName(field),
|
|
@@ -314224,8 +314280,10 @@ function fieldDescriptor(field, warnings, context) {
|
|
|
314224
314280
|
map: true,
|
|
314225
314281
|
optional: Boolean(field.optional),
|
|
314226
314282
|
required: Boolean(field.required),
|
|
314283
|
+
...mapKeyType ? { mapKeyType } : {},
|
|
314227
314284
|
...value.jsonType !== "unknown" ? { mapValueType: value.jsonType } : {},
|
|
314228
314285
|
...value.jsonFormat ? { mapValueFormat: value.jsonFormat } : {},
|
|
314286
|
+
...value.intType ? { mapValueIntType: value.intType } : {},
|
|
314229
314287
|
...value.enumType ? { mapValueEnumType: value.enumType } : {},
|
|
314230
314288
|
...value.messageType ? { mapValueMessageType: value.messageType } : {}
|
|
314231
314289
|
};
|
|
@@ -314245,6 +314303,7 @@ function fieldDescriptor(field, warnings, context) {
|
|
|
314245
314303
|
optional: Boolean(field.optional),
|
|
314246
314304
|
required: Boolean(field.required),
|
|
314247
314305
|
...classified.nullable ? { nullable: true } : {},
|
|
314306
|
+
...classified.intType ? { intType: classified.intType } : {},
|
|
314248
314307
|
...classified.messageType ? { messageType: classified.messageType } : {},
|
|
314249
314308
|
...classified.enumType ? { enumType: classified.enumType } : {}
|
|
314250
314309
|
};
|
|
@@ -314480,13 +314539,16 @@ function buildShape(messageFullName, index, warnings, operationId, label, depth,
|
|
|
314480
314539
|
jsonName: field.jsonName,
|
|
314481
314540
|
jsonType: field.jsonType,
|
|
314482
314541
|
...field.jsonFormat ? { jsonFormat: field.jsonFormat } : {},
|
|
314542
|
+
...field.intType ? { intType: field.intType } : {},
|
|
314483
314543
|
repeated: field.repeated,
|
|
314484
314544
|
map: field.map,
|
|
314485
314545
|
required: field.required,
|
|
314486
314546
|
...field.nullable ? { nullable: true } : {},
|
|
314487
314547
|
...enumValues ? { enumValues } : {},
|
|
314548
|
+
...field.mapKeyType ? { mapKeyType: field.mapKeyType } : {},
|
|
314488
314549
|
...field.mapValueType ? { mapValueType: field.mapValueType } : {},
|
|
314489
314550
|
...field.mapValueFormat ? { mapValueFormat: field.mapValueFormat } : {},
|
|
314551
|
+
...field.mapValueIntType ? { mapValueIntType: field.mapValueIntType } : {},
|
|
314490
314552
|
...mapValueEnumValues ? { mapValueEnumValues } : {}
|
|
314491
314553
|
};
|
|
314492
314554
|
if (field.messageType && field.jsonType === "object" && !field.map) {
|
|
@@ -314553,18 +314615,38 @@ function createGrpcScript(spec) {
|
|
|
314553
314615
|
' if (expected === "any") return true;',
|
|
314554
314616
|
" return true;",
|
|
314555
314617
|
"}",
|
|
314618
|
+
'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"} };',
|
|
314619
|
+
'function grpcDecStr(n) { var s = String(n); return (s.indexOf("e") === -1 && s.indexOf("E") === -1 && s.indexOf(".") === -1) ? s : null; }',
|
|
314620
|
+
'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; }',
|
|
314621
|
+
'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; }',
|
|
314622
|
+
"function matchesInt(intType, value) {",
|
|
314623
|
+
" var spec = GRPC_INT_SPECS[intType]; if (!spec) return true;",
|
|
314624
|
+
" var num, canonical;",
|
|
314625
|
+
' if (typeof value === "number") { if (!Number.isFinite(value) || !Number.isInteger(value)) return false; num = value; canonical = grpcDecStr(value); }',
|
|
314626
|
+
' 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); }',
|
|
314627
|
+
" else { return false; }",
|
|
314628
|
+
' if (canonical === "-0") canonical = "0";',
|
|
314629
|
+
' if (!spec.s && ((canonical !== null && canonical.charAt(0) === "-") || num < 0)) return false;',
|
|
314630
|
+
" if (spec.b === 32) return num >= Number(spec.min) && num <= Number(spec.max);",
|
|
314631
|
+
" if (canonical !== null) return grpcCmpIntStr(canonical, spec.min) >= 0 && grpcCmpIntStr(canonical, spec.max) <= 0;",
|
|
314632
|
+
" return false;",
|
|
314633
|
+
"}",
|
|
314634
|
+
'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; }',
|
|
314635
|
+
"function matchesEnumNumber(n) { return Number.isInteger(n) && n >= -2147483648 && n <= 2147483647; }",
|
|
314556
314636
|
"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; }",
|
|
314557
314637
|
"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]; }",
|
|
314558
314638
|
'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; }',
|
|
314559
314639
|
'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; }',
|
|
314560
314640
|
'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; }',
|
|
314561
314641
|
'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; }',
|
|
314642
|
+
'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)); }',
|
|
314562
314643
|
"function matchesFormat(format, value) {",
|
|
314563
314644
|
" if (!format) return true;",
|
|
314564
314645
|
' if (format === "proto-timestamp") return validProtoTimestamp(value);',
|
|
314565
314646
|
' if (format === "proto-duration") return validProtoDuration(value);',
|
|
314566
314647
|
' if (format === "proto-field-mask") return validProtoFieldMask(value);',
|
|
314567
314648
|
' if (format === "proto-bytes") return validProtoBytes(value);',
|
|
314649
|
+
' if (format === "proto-float32") return validProtoFloat32(value);',
|
|
314568
314650
|
" return true;",
|
|
314569
314651
|
"}",
|
|
314570
314652
|
"function formatLabel(format) {",
|
|
@@ -314572,6 +314654,7 @@ function createGrpcScript(spec) {
|
|
|
314572
314654
|
' if (format === "proto-duration") return "a valid ProtoJSON Duration";',
|
|
314573
314655
|
' if (format === "proto-field-mask") return "a valid ProtoJSON FieldMask";',
|
|
314574
314656
|
' if (format === "proto-bytes") return "valid ProtoJSON base64 bytes";',
|
|
314657
|
+
' if (format === "proto-float32") return "a float32-representable number";',
|
|
314575
314658
|
' return format || "valid ProtoJSON";',
|
|
314576
314659
|
"}",
|
|
314577
314660
|
// Recursive shape checker: validates fields (with nested message descent,
|
|
@@ -314585,14 +314668,15 @@ function createGrpcScript(spec) {
|
|
|
314585
314668
|
' if (field.required && !present) { pm.expect.fail("gRPC response is missing required field " + label); return; }',
|
|
314586
314669
|
" if (!present) return;",
|
|
314587
314670
|
" var value = obj[key];",
|
|
314588
|
-
" if (
|
|
314671
|
+
" if (value === null) return;",
|
|
314589
314672
|
" if (field.repeated) {",
|
|
314590
314673
|
' if (!matchesScalar("array", value)) { pm.expect.fail("gRPC field " + label + " must be a repeated (array) value but was " + jsonTypeOf(value)); return; }',
|
|
314591
314674
|
" for (var i = 0; i < value.length; i++) {",
|
|
314592
314675
|
' var elem = value[i]; var elemLabel = label + "[" + i + "]";',
|
|
314593
314676
|
' 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; }',
|
|
314594
|
-
' if (field.enumValues && field.enumValues.length > 0) { if (typeof elem === "number") { if (!
|
|
314677
|
+
' 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; }',
|
|
314595
314678
|
' if (field.jsonType === "any") continue;',
|
|
314679
|
+
' 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; }',
|
|
314596
314680
|
' if (!matchesScalar(field.jsonType, elem)) pm.expect.fail("gRPC repeated field " + elemLabel + " must be " + field.jsonType + " but was " + jsonTypeOf(elem));',
|
|
314597
314681
|
' else if (!matchesFormat(field.jsonFormat, elem)) pm.expect.fail("gRPC repeated field " + elemLabel + " must be " + formatLabel(field.jsonFormat));',
|
|
314598
314682
|
" }",
|
|
@@ -314600,17 +314684,28 @@ function createGrpcScript(spec) {
|
|
|
314600
314684
|
" }",
|
|
314601
314685
|
" if (field.map) {",
|
|
314602
314686
|
' if (!matchesScalar("object", value)) { pm.expect.fail("gRPC map field " + label + " must be an object but was " + jsonTypeOf(value)); return; }',
|
|
314603
|
-
|
|
314687
|
+
" var keys = Object.keys(value);",
|
|
314688
|
+
" for (var k = 0; k < keys.length; k++) {",
|
|
314689
|
+
' var mk = keys[k], mv = value[mk], mvLabel = label + "[" + mk + "]";',
|
|
314690
|
+
' 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); }',
|
|
314691
|
+
' 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); }',
|
|
314692
|
+
' if (field.mapValueShape && matchesScalar("object", mv)) { grpcCheckShape(mv, field.mapValueShape, mvLabel + "."); }',
|
|
314693
|
+
' 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)); }',
|
|
314694
|
+
' 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(", ") + "]"); } }',
|
|
314695
|
+
' else if (field.mapValueType && !matchesScalar(field.mapValueType, mv)) { pm.expect.fail("gRPC map value " + mvLabel + " must be " + field.mapValueType + " but was " + jsonTypeOf(mv)); }',
|
|
314696
|
+
' else if (field.mapValueType && !matchesFormat(field.mapValueFormat, mv)) { pm.expect.fail("gRPC map value " + mvLabel + " must be " + formatLabel(field.mapValueFormat)); }',
|
|
314697
|
+
" }",
|
|
314604
314698
|
" return;",
|
|
314605
314699
|
" }",
|
|
314606
314700
|
" if (field.enumValues && field.enumValues.length > 0) {",
|
|
314607
|
-
' if (typeof value === "number") { if (!
|
|
314701
|
+
' if (typeof value === "number") { if (!matchesEnumNumber(value)) pm.expect.fail("gRPC enum field " + label + " must be an int32-range integer but was " + value); return; }',
|
|
314608
314702
|
' if (typeof value !== "string") { pm.expect.fail("gRPC enum field " + label + " must be a string or number but was " + jsonTypeOf(value)); return; }',
|
|
314609
314703
|
' if (field.enumValues.indexOf(value) === -1) pm.expect.fail("gRPC enum field " + label + " has value " + value + " not in [" + field.enumValues.join(", ") + "]");',
|
|
314610
314704
|
" return;",
|
|
314611
314705
|
" }",
|
|
314612
314706
|
' if (field.jsonType === "any") return;',
|
|
314613
314707
|
' 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; }',
|
|
314708
|
+
' 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; }',
|
|
314614
314709
|
' if (!matchesScalar(field.jsonType, value)) pm.expect.fail("gRPC field " + label + " must be " + field.jsonType + " but was " + jsonTypeOf(value));',
|
|
314615
314710
|
' else if (!matchesFormat(field.jsonFormat, value)) pm.expect.fail("gRPC field " + label + " must be " + formatLabel(field.jsonFormat));',
|
|
314616
314711
|
"}",
|
|
@@ -314660,6 +314755,103 @@ function methodPathOf(item) {
|
|
|
314660
314755
|
const value = payload?.methodPath;
|
|
314661
314756
|
return typeof value === "string" ? value : "";
|
|
314662
314757
|
}
|
|
314758
|
+
var GRPC_INT_SPECS = {
|
|
314759
|
+
int32: { signed: true, bits: 32, min: "-2147483648", max: "2147483647" },
|
|
314760
|
+
sint32: { signed: true, bits: 32, min: "-2147483648", max: "2147483647" },
|
|
314761
|
+
sfixed32: { signed: true, bits: 32, min: "-2147483648", max: "2147483647" },
|
|
314762
|
+
uint32: { signed: false, bits: 32, min: "0", max: "4294967295" },
|
|
314763
|
+
fixed32: { signed: false, bits: 32, min: "0", max: "4294967295" },
|
|
314764
|
+
int64: { signed: true, bits: 64, min: "-9223372036854775808", max: "9223372036854775807" },
|
|
314765
|
+
sint64: { signed: true, bits: 64, min: "-9223372036854775808", max: "9223372036854775807" },
|
|
314766
|
+
sfixed64: { signed: true, bits: 64, min: "-9223372036854775808", max: "9223372036854775807" },
|
|
314767
|
+
uint64: { signed: false, bits: 64, min: "0", max: "18446744073709551615" },
|
|
314768
|
+
fixed64: { signed: false, bits: 64, min: "0", max: "18446744073709551615" }
|
|
314769
|
+
};
|
|
314770
|
+
function grpcDecStr(n) {
|
|
314771
|
+
const s = String(n);
|
|
314772
|
+
return s.indexOf("e") === -1 && s.indexOf("E") === -1 && s.indexOf(".") === -1 ? s : null;
|
|
314773
|
+
}
|
|
314774
|
+
function grpcCmpIntStr(a, b) {
|
|
314775
|
+
const na = a.charAt(0) === "-";
|
|
314776
|
+
const nb = b.charAt(0) === "-";
|
|
314777
|
+
if (na !== nb) return na ? -1 : 1;
|
|
314778
|
+
const aa = (na ? a.slice(1) : a).replace(/^0+(?=[0-9])/, "");
|
|
314779
|
+
const bb = (nb ? b.slice(1) : b).replace(/^0+(?=[0-9])/, "");
|
|
314780
|
+
let mag;
|
|
314781
|
+
if (aa.length !== bb.length) mag = aa.length < bb.length ? -1 : 1;
|
|
314782
|
+
else mag = aa < bb ? -1 : aa > bb ? 1 : 0;
|
|
314783
|
+
return na ? -mag : mag;
|
|
314784
|
+
}
|
|
314785
|
+
function grpcNormIntStr(input) {
|
|
314786
|
+
let s = input;
|
|
314787
|
+
let neg = false;
|
|
314788
|
+
if (s.charAt(0) === "-") {
|
|
314789
|
+
neg = true;
|
|
314790
|
+
s = s.slice(1);
|
|
314791
|
+
} else if (s.charAt(0) === "+") {
|
|
314792
|
+
s = s.slice(1);
|
|
314793
|
+
}
|
|
314794
|
+
let ei = s.indexOf("e");
|
|
314795
|
+
if (ei === -1) ei = s.indexOf("E");
|
|
314796
|
+
let exp = 0;
|
|
314797
|
+
if (ei !== -1) {
|
|
314798
|
+
exp = parseInt(s.slice(ei + 1), 10);
|
|
314799
|
+
s = s.slice(0, ei);
|
|
314800
|
+
}
|
|
314801
|
+
const dot = s.indexOf(".");
|
|
314802
|
+
const intp = dot === -1 ? s : s.slice(0, dot);
|
|
314803
|
+
const frac = dot === -1 ? "" : s.slice(dot + 1);
|
|
314804
|
+
const digits = intp + frac;
|
|
314805
|
+
if (digits.length === 0) return null;
|
|
314806
|
+
if (/^0+$/.test(digits)) return "0";
|
|
314807
|
+
if (exp >= 0) {
|
|
314808
|
+
const intpSize = intp === "0" ? 0 : intp.length;
|
|
314809
|
+
if (intpSize + exp > 20) return null;
|
|
314810
|
+
}
|
|
314811
|
+
const netExp = exp - frac.length;
|
|
314812
|
+
let out;
|
|
314813
|
+
if (netExp >= 0) {
|
|
314814
|
+
if (digits.length + netExp > 40) return null;
|
|
314815
|
+
out = digits + "0".repeat(netExp);
|
|
314816
|
+
} else {
|
|
314817
|
+
const cut = -netExp;
|
|
314818
|
+
const keepLen = digits.length - cut;
|
|
314819
|
+
const dropped = keepLen <= 0 ? digits : digits.slice(keepLen);
|
|
314820
|
+
for (let d = 0; d < dropped.length; d += 1) {
|
|
314821
|
+
if (dropped.charAt(d) !== "0") return null;
|
|
314822
|
+
}
|
|
314823
|
+
out = keepLen <= 0 ? "0" : digits.slice(0, keepLen);
|
|
314824
|
+
}
|
|
314825
|
+
let st = 0;
|
|
314826
|
+
while (st < out.length - 1 && out.charAt(st) === "0") st += 1;
|
|
314827
|
+
out = out.slice(st);
|
|
314828
|
+
if (out === "0") return "0";
|
|
314829
|
+
if (out.length > 40) return null;
|
|
314830
|
+
return neg ? `-${out}` : out;
|
|
314831
|
+
}
|
|
314832
|
+
function matchesIntValue(intType, value) {
|
|
314833
|
+
const spec = GRPC_INT_SPECS[intType];
|
|
314834
|
+
if (!spec) return true;
|
|
314835
|
+
let num;
|
|
314836
|
+
let canonical;
|
|
314837
|
+
if (typeof value === "number") {
|
|
314838
|
+
if (!Number.isFinite(value) || !Number.isInteger(value)) return false;
|
|
314839
|
+
num = value;
|
|
314840
|
+
canonical = grpcDecStr(value);
|
|
314841
|
+
} else if (typeof value === "string") {
|
|
314842
|
+
if (!/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$/.test(value)) return false;
|
|
314843
|
+
canonical = grpcNormIntStr(value);
|
|
314844
|
+
if (canonical === null) return false;
|
|
314845
|
+
num = Number(value);
|
|
314846
|
+
} else {
|
|
314847
|
+
return false;
|
|
314848
|
+
}
|
|
314849
|
+
if (canonical === "-0") canonical = "0";
|
|
314850
|
+
if (!spec.signed && (canonical !== null && canonical.charAt(0) === "-" || num < 0)) return false;
|
|
314851
|
+
if (spec.bits === 32) return num >= Number(spec.min) && num <= Number(spec.max);
|
|
314852
|
+
if (canonical !== null) return grpcCmpIntStr(canonical, spec.min) >= 0 && grpcCmpIntStr(canonical, spec.max) <= 0;
|
|
314853
|
+
return false;
|
|
314854
|
+
}
|
|
314663
314855
|
function matchesScalarValue(expected, value) {
|
|
314664
314856
|
const isJsonNumberString = (text) => /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$/.test(text) && Number.isFinite(Number(text));
|
|
314665
314857
|
switch (expected) {
|
|
@@ -314748,6 +314940,12 @@ function validProtoBytes(value) {
|
|
|
314748
314940
|
if (raw % 4 === 1) return false;
|
|
314749
314941
|
return pad === 0 || (raw + pad) % 4 === 0 && pad === (4 - raw % 4) % 4;
|
|
314750
314942
|
}
|
|
314943
|
+
function validProtoFloat32(value) {
|
|
314944
|
+
if (value === "NaN" || value === "Infinity" || value === "-Infinity") return true;
|
|
314945
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
314946
|
+
if (!Number.isFinite(n)) return false;
|
|
314947
|
+
return Number.isFinite(Math.fround(n));
|
|
314948
|
+
}
|
|
314751
314949
|
function matchesFormatValue(format3, value) {
|
|
314752
314950
|
switch (format3) {
|
|
314753
314951
|
case void 0:
|
|
@@ -314760,6 +314958,8 @@ function matchesFormatValue(format3, value) {
|
|
|
314760
314958
|
return validProtoFieldMask(value);
|
|
314761
314959
|
case "proto-bytes":
|
|
314762
314960
|
return validProtoBytes(value);
|
|
314961
|
+
case "proto-float32":
|
|
314962
|
+
return validProtoFloat32(value);
|
|
314763
314963
|
default:
|
|
314764
314964
|
return true;
|
|
314765
314965
|
}
|
|
@@ -314794,6 +314994,12 @@ function staticRequestCheck(item, shape, methodPath2, warnings) {
|
|
|
314794
314994
|
continue;
|
|
314795
314995
|
}
|
|
314796
314996
|
if (field.jsonType === "any" || field.enumValues || field.map || field.shape) continue;
|
|
314997
|
+
if (field.intType) {
|
|
314998
|
+
if (!matchesIntValue(field.intType, value)) {
|
|
314999
|
+
warnings.push(`PROTO_REQUEST_FIELD_TYPE_MISMATCH: ${methodPath2} request field ${field.name} must be a valid ${field.intType} (in range)`);
|
|
315000
|
+
}
|
|
315001
|
+
continue;
|
|
315002
|
+
}
|
|
314797
315003
|
if (!matchesScalarValue(field.jsonType, value)) {
|
|
314798
315004
|
warnings.push(`PROTO_REQUEST_FIELD_TYPE_MISMATCH: ${methodPath2} request field ${field.name} must be ${field.jsonType}`);
|
|
314799
315005
|
} else if (!matchesFormatValue(field.jsonFormat, value)) {
|
|
@@ -314803,6 +315009,7 @@ function staticRequestCheck(item, shape, methodPath2, warnings) {
|
|
|
314803
315009
|
}
|
|
314804
315010
|
function instrumentGrpcCollection(collection, index) {
|
|
314805
315011
|
const warnings = [...index.warnings, ...index.operations.flatMap((operation) => operation.warnings)];
|
|
315012
|
+
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)");
|
|
314806
315013
|
const specs = /* @__PURE__ */ new Map();
|
|
314807
315014
|
const requestShapes = /* @__PURE__ */ new Map();
|
|
314808
315015
|
for (const operation of index.operations) {
|
|
@@ -315309,6 +315516,7 @@ function createSoapScript(operation, warnings = []) {
|
|
|
315309
315516
|
` pm.expect(bodyText, "expected SOAP response element <" + soap.expectedResponseElement + "> not found").to.match(new RegExp(${JSON.stringify(responseRegex)}));`,
|
|
315310
315517
|
"});"
|
|
315311
315518
|
);
|
|
315519
|
+
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)`);
|
|
315312
315520
|
} else if (operation.output) {
|
|
315313
315521
|
warnings.push(`SOAP_RESPONSE_ELEMENT_UNKNOWN: operation ${operation.name} has an output message but no resolvable response element; only Envelope/Body/Fault are asserted`);
|
|
315314
315522
|
}
|