carrick 0.3.112 → 0.3.113

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.
@@ -944,6 +944,180 @@ export declare class TypeInferrer {
944
944
  * return statements are.
945
945
  */
946
946
  private recoverPayloadFromResponseExpressions;
947
+ /** How one payload node reads: its stated annotation, else its resolved type. */
948
+ private payloadCandidateOf;
949
+ /** A payload whose contract a type node in the source states. */
950
+ private statedPayloadCandidate;
951
+ /**
952
+ * Join the payloads of several response branches into one contract, as
953
+ * several return statements are joined: an empty object drops beside a
954
+ * branch with members, equal texts dedupe, and the rest is a union.
955
+ */
956
+ private joinPayloadCandidates;
957
+ /**
958
+ * True when a handler's awaited return, or a member of its union, is a
959
+ * serialised-body envelope: an object with a numeric `statusCode` or
960
+ * `status` member and a `body` member typed `string`. Either member may be
961
+ * optional, as a platform's result type declares them.
962
+ *
963
+ * HTTP vocabulary only, the class `RESPONSE_INIT_MEMBER_NAMES` is. A `body`
964
+ * typed as an object is not an envelope: a runtime that serialises the
965
+ * handler's return value sends that object as the payload, so the shape is
966
+ * ambiguous and keeps the ordinary reading.
967
+ */
968
+ private typeIsSerialisedBodyEnvelope;
969
+ /** A member's type with `undefined` and `null` removed, or `undefined` if absent. */
970
+ private envelopeMemberType;
971
+ /**
972
+ * True when a handler's return is a serialised-body envelope AND the source
973
+ * shows the body is serialised, so the envelope reading applies:
974
+ * - a returned branch builds an envelope whose `body` is `JSON.stringify`
975
+ * of a value, inline, through a `const`, or in a builder the reading can
976
+ * follow (`branchShowsSerialisation`); or
977
+ * - the envelope type is declared outside the repository (a platform's
978
+ * result type) with every member optional. Nothing else returns such a
979
+ * type, so a value of it returned as-is is still transport. The repo's
980
+ * own all-optional types (`Partial<Article>`) engage only on evidence.
981
+ *
982
+ * A domain object that merely has `status` and `body` members (an article,
983
+ * a message) shows neither and keeps the ordinary reading.
984
+ */
985
+ private serialisedBodyEnvelopeEngages;
986
+ /**
987
+ * True when a returned branch builds an envelope from a serialised value:
988
+ * a literal whose `body` is `JSON.stringify(...)`, a call to a builder the
989
+ * reading can follow, or a call handing on one such envelope.
990
+ */
991
+ private branchShowsSerialisation;
992
+ /**
993
+ * The arguments a call could hand back as its result: every argument but
994
+ * an object literal, which is the call's input (`create({ body:
995
+ * JSON.stringify(doc) })` stores a document, it does not respond with it),
996
+ * and but a function, whose returns are read as the call's callbacks.
997
+ */
998
+ private handedOnArguments;
999
+ /**
1000
+ * The returned branches of an envelope handler: each returned expression,
1001
+ * conditional sides split. A returned call whose callbacks return values
1002
+ * (`settle().then(ok, fail)`) is carried by those returns, plus every
1003
+ * envelope it is handed directly (`withFallback(() => a, b)` can answer
1004
+ * `b`); a call whose callbacks return nothing stays a branch of its own.
1005
+ */
1006
+ private envelopeBranches;
1007
+ /**
1008
+ * The `function_return` answer for a handler that returns a serialised-body
1009
+ * envelope: the union of the values its success branches serialised.
1010
+ *
1011
+ * Each returned branch is read by `readEnvelopeBranch`. Error and redirect
1012
+ * branches contribute nothing (carrick#1161). If any branch cannot be read,
1013
+ * the answer is `unknown` with the decided reason `serialised_body_unread`
1014
+ * and one sentence per cause: the branches that did read are part of the
1015
+ * contract, and neither the envelope nor its `string` body is any of it.
1016
+ */
1017
+ private inferSerialisedBodyEnvelope;
1018
+ /** An `unknown` answer the inferrer decided, carrying its reason at the root. */
1019
+ private decidedAbstain;
1020
+ /**
1021
+ * What one returned branch of an envelope handler serialised:
1022
+ * - an envelope object literal: the argument of the `JSON.stringify` that
1023
+ * produced its `body`, inline or through a `const` in the same function;
1024
+ * its status member decides the branch;
1025
+ * - a call to a response builder this repository declares
1026
+ * (`envelopeBuilderOf`): the argument the builder serialises; the
1027
+ * argument or literal its status member takes decides the branch;
1028
+ * - any other call handing on exactly one envelope argument (never an
1029
+ * object literal, which is the call's input): that
1030
+ * envelope is read in its place. Its own stated status decides the
1031
+ * branch; only when it states none does a status the outer call's
1032
+ * arguments state decide (`log(ctx, 503, "code", prebuilt)`).
1033
+ * Anything else, and a payload holding `any` or `unknown`, is unread, with
1034
+ * its cause.
1035
+ */
1036
+ private readEnvelopeBranch;
1037
+ /** The status a builder call sends: its status argument, or the builder's literal. */
1038
+ private builderCallStatus;
1039
+ /**
1040
+ * The status an envelope expression states itself: a literal's status
1041
+ * member, or what a followable builder call sends. `'undecided'` for
1042
+ * anything else (a variable holding an envelope states nothing here).
1043
+ */
1044
+ private envelopeOwnStatus;
1045
+ /** The status an envelope literal's `statusCode` or `status` member states. */
1046
+ private envelopeLiteralStatus;
1047
+ /** The status a value states, classified as a send's status argument is. */
1048
+ private statusOfValue;
1049
+ /**
1050
+ * The value node an object literal gives a member: a property assignment's
1051
+ * initializer, or a shorthand's own name.
1052
+ */
1053
+ private envelopeMemberValue;
1054
+ /**
1055
+ * The value an envelope literal's `body` serialises: the argument of a
1056
+ * `JSON.stringify` written there, or written as the initializer of a
1057
+ * `const` that `scope` declares and `body` names. `undefined` when `body`
1058
+ * is built any other way.
1059
+ */
1060
+ private serialisedBodyArgument;
1061
+ /**
1062
+ * The initializer of the `const` an identifier (or a shorthand member's
1063
+ * name) refers to, when `scope` itself declares it.
1064
+ */
1065
+ private constInitializerInScope;
1066
+ /**
1067
+ * The symbol of the value a node names: a shorthand member's value symbol
1068
+ * (its own symbol is the property), else the identifier's symbol.
1069
+ */
1070
+ private valueSymbolOf;
1071
+ /** The index of the `params` entry a node names, or `undefined`. */
1072
+ private parameterIndexOf;
1073
+ /**
1074
+ * How a call's callee builds an envelope, when the callee is a function this
1075
+ * repository declares (not lib, not an installed package) and every return
1076
+ * it makes is an envelope literal:
1077
+ * - returns whose status member is a literal 4xx or 5xx are its failure
1078
+ * path and are ignored; a builder with nothing else is `'failure'`, so a
1079
+ * call to it is an error branch;
1080
+ * - every other return must serialise the same parameter into `body` and
1081
+ * take its status from the same parameter, or state the same literal
1082
+ * success or redirect status.
1083
+ * `undefined` when the callee is anything else.
1084
+ */
1085
+ private envelopeBuilderOf;
1086
+ /**
1087
+ * The single function a callee symbol declares with a body: a function
1088
+ * declaration, or a variable initialised with an arrow or function
1089
+ * expression.
1090
+ */
1091
+ private builderFunctionOf;
1092
+ /**
1093
+ * The payload a builder call serialises. The source states it, and the
1094
+ * answer is explicit, when the argument carries `satisfies`/`as`, when the
1095
+ * builder's parameter is one of its type parameters and the call passes
1096
+ * type arguments (`reply<AddNoteResult>(201, x)`), or when the parameter is
1097
+ * declared with a type that says something. Otherwise the argument's own
1098
+ * type is read.
1099
+ */
1100
+ private builderPayloadCandidate;
1101
+ /**
1102
+ * True when a declared parameter type does not say what is sent: a top
1103
+ * type, the `object` keyword, an object type that names no member (`{}`,
1104
+ * `Record<string, unknown>`), a union that admits both primitives and
1105
+ * objects (a JSON-value type such as `string | number | Json[] | { [k:
1106
+ * string]: Json }`), or a type that mentions a type parameter. A builder
1107
+ * that takes "any value" states nothing about the payload a call hands it,
1108
+ * so the argument's own type is read instead.
1109
+ */
1110
+ private typeNodeStatesNothing;
1111
+ /** A serialised value's candidate, unread when it holds a top type. */
1112
+ private envelopePayloadCandidate;
1113
+ /**
1114
+ * A payload candidate, or unread when its printed type is or holds `any`
1115
+ * or `unknown` anywhere (`{ [x: string]: any }`, `{ data: any }`). A
1116
+ * contract with a hole in it is not published on this path: the capture
1117
+ * would refuse the text and re-read the line, which can publish the
1118
+ * envelope.
1119
+ */
1120
+ private checkedEnvelopeCandidate;
947
1121
  /**
948
1122
  * The request field each member of a joined union answers
949
1123
  * (`response-modes.ts`). Case texts are joined by the published union's