@lovrozagar/oat 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -20
- package/dist/cli.js +3 -1
- package/dist/config/define-config.d.ts +41 -1
- package/dist/config/define-config.d.ts.map +1 -1
- package/dist/config/define-config.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/report/render.d.ts.map +1 -1
- package/dist/report/render.js +28 -5
- package/dist/report/render.js.map +1 -1
- package/dist/runtime/auth.d.ts.map +1 -1
- package/dist/runtime/auth.js +30 -3
- package/dist/runtime/auth.js.map +1 -1
- package/dist/runtime/body.d.ts +33 -0
- package/dist/runtime/body.d.ts.map +1 -0
- package/dist/runtime/body.js +218 -0
- package/dist/runtime/body.js.map +1 -0
- package/dist/runtime/checks.d.ts +3 -0
- package/dist/runtime/checks.d.ts.map +1 -1
- package/dist/runtime/checks.js +45 -18
- package/dist/runtime/checks.js.map +1 -1
- package/dist/runtime/client.d.ts +20 -1
- package/dist/runtime/client.d.ts.map +1 -1
- package/dist/runtime/client.js +207 -8
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/dummy.d.ts +23 -0
- package/dist/runtime/dummy.d.ts.map +1 -0
- package/dist/runtime/dummy.js +214 -0
- package/dist/runtime/dummy.js.map +1 -0
- package/dist/runtime/progress.d.ts +4 -0
- package/dist/runtime/progress.d.ts.map +1 -1
- package/dist/runtime/progress.js +23 -0
- package/dist/runtime/progress.js.map +1 -1
- package/dist/runtime/run.d.ts +4 -1
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +15 -1
- package/dist/runtime/run.js.map +1 -1
- package/dist/runtime/upload.d.ts +21 -0
- package/dist/runtime/upload.d.ts.map +1 -0
- package/dist/runtime/upload.js +247 -0
- package/dist/runtime/upload.js.map +1 -0
- package/dist/runtime/world.d.ts +2 -0
- package/dist/runtime/world.d.ts.map +1 -1
- package/dist/runtime/world.js +16 -11
- package/dist/runtime/world.js.map +1 -1
- package/dist/spec/collection.d.ts +13 -0
- package/dist/spec/collection.d.ts.map +1 -1
- package/dist/spec/collection.js +36 -6
- package/dist/spec/collection.js.map +1 -1
- package/dist/spec/graph.js +2 -2
- package/dist/spec/graph.js.map +1 -1
- package/dist/spec/types.d.ts +3 -0
- package/dist/spec/types.d.ts.map +1 -1
- package/dist/spec/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns a generated field map into the body the document asked for.
|
|
3
|
+
*
|
|
4
|
+
* JSON stays a plain object. urlencoded becomes URLSearchParams. Multipart becomes
|
|
5
|
+
* FormData — file parts are resolved (hook → pool → dummy), never JSON.stringified.
|
|
6
|
+
*/
|
|
7
|
+
import { requestContent } from "../spec/collection.ts";
|
|
8
|
+
import type { OperationModel, SpecModel } from "../spec/graph.ts";
|
|
9
|
+
import { type UploadContext } from "./upload.ts";
|
|
10
|
+
export interface EncodedBody {
|
|
11
|
+
body: unknown;
|
|
12
|
+
/** `null` means headers are already final (FormData — fetch sets the boundary). */
|
|
13
|
+
contentType: string | null | undefined;
|
|
14
|
+
}
|
|
15
|
+
export interface EncodeOptions {
|
|
16
|
+
operationId: string;
|
|
17
|
+
mediaType: string;
|
|
18
|
+
schema: Record<string, unknown>;
|
|
19
|
+
encoding?: Record<string, {
|
|
20
|
+
contentType?: string;
|
|
21
|
+
}>;
|
|
22
|
+
fields: Record<string, unknown>;
|
|
23
|
+
variant: string;
|
|
24
|
+
index: number;
|
|
25
|
+
uploads: UploadContext;
|
|
26
|
+
}
|
|
27
|
+
export declare function requestContentOf(op: OperationModel, model: SpecModel): ReturnType<typeof requestContent>;
|
|
28
|
+
export declare function encodeForOperation(op: OperationModel, model: SpecModel, fields: Record<string, unknown>, uploads: UploadContext, variant?: string, index?: number): Promise<EncodedBody>;
|
|
29
|
+
export declare function encodeRequest(options: EncodeOptions): Promise<EncodedBody>;
|
|
30
|
+
export declare function isFilePart(schema: unknown, encoding?: {
|
|
31
|
+
contentType?: string;
|
|
32
|
+
}): boolean;
|
|
33
|
+
//# sourceMappingURL=body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../src/runtime/body.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EACN,KAAK,aAAa,EAKlB,MAAM,aAAa,CAAA;AAEpB,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,OAAO,CAAA;IACb,mFAAmF;IACnF,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CACtC;AAED,MAAM,WAAW,aAAa;IAC7B,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACnD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,aAAa,CAAA;CACtB;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAGxG;AAED,wBAAsB,kBAAkB,CACvC,EAAE,EAAE,cAAc,EAClB,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,aAAa,EACtB,OAAO,SAAa,EACpB,KAAK,SAAI,GACP,OAAO,CAAC,WAAW,CAAC,CActB;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CAShF;AA6HD,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CASxF"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns a generated field map into the body the document asked for.
|
|
3
|
+
*
|
|
4
|
+
* JSON stays a plain object. urlencoded becomes URLSearchParams. Multipart becomes
|
|
5
|
+
* FormData — file parts are resolved (hook → pool → dummy), never JSON.stringified.
|
|
6
|
+
*/
|
|
7
|
+
import { requestContent } from "../spec/collection.js";
|
|
8
|
+
import { isFieldOverride, isUploadFile, resolveUploadFile, resolveUploadOverride, } from "./upload.js";
|
|
9
|
+
export function requestContentOf(op, model) {
|
|
10
|
+
const raw = model.rawOperations.get(op.operationId);
|
|
11
|
+
return raw === undefined ? null : requestContent(raw);
|
|
12
|
+
}
|
|
13
|
+
export async function encodeForOperation(op, model, fields, uploads, variant = "baseline", index = 0) {
|
|
14
|
+
const content = requestContentOf(op, model);
|
|
15
|
+
if (content === null)
|
|
16
|
+
return { body: fields, contentType: undefined };
|
|
17
|
+
const options = {
|
|
18
|
+
fields,
|
|
19
|
+
index,
|
|
20
|
+
mediaType: content.mediaType,
|
|
21
|
+
operationId: op.operationId,
|
|
22
|
+
schema: content.schema,
|
|
23
|
+
uploads,
|
|
24
|
+
variant,
|
|
25
|
+
};
|
|
26
|
+
if (content.encoding !== undefined)
|
|
27
|
+
options.encoding = content.encoding;
|
|
28
|
+
return encodeRequest(options);
|
|
29
|
+
}
|
|
30
|
+
export async function encodeRequest(options) {
|
|
31
|
+
const media = options.mediaType.toLowerCase();
|
|
32
|
+
if (media.startsWith("multipart/")) {
|
|
33
|
+
return { body: await encodeMultipart(options), contentType: null };
|
|
34
|
+
}
|
|
35
|
+
if (media.includes("x-www-form-urlencoded")) {
|
|
36
|
+
return { body: encodeUrlencoded(options.fields), contentType: "application/x-www-form-urlencoded" };
|
|
37
|
+
}
|
|
38
|
+
return { body: options.fields, contentType: undefined };
|
|
39
|
+
}
|
|
40
|
+
async function encodeMultipart(options) {
|
|
41
|
+
const form = new FormData();
|
|
42
|
+
const properties = propertiesOf(options.schema);
|
|
43
|
+
const required = requiredOf(options.schema);
|
|
44
|
+
const names = filePartNames(properties, required, options);
|
|
45
|
+
const hookHits = new Map();
|
|
46
|
+
for (const name of names) {
|
|
47
|
+
const schema = properties[name] ?? additionalSchema(options.schema) ?? {};
|
|
48
|
+
const resolved = await resolveUploadOverride(uploadRequest(name, schema, options), options.uploads);
|
|
49
|
+
hookHits.set(name, resolved);
|
|
50
|
+
if (isFieldOverride(resolved)) {
|
|
51
|
+
appendFields(form, resolved.fields);
|
|
52
|
+
return form;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const sent = new Set();
|
|
56
|
+
for (const [name, schema] of Object.entries(properties)) {
|
|
57
|
+
sent.add(name);
|
|
58
|
+
if (isFilePart(schema, options.encoding?.[name])) {
|
|
59
|
+
const hit = hookHits.get(name);
|
|
60
|
+
const file = isUploadFile(hit)
|
|
61
|
+
? hit
|
|
62
|
+
: await fileForPart(name, schema, { ...options, uploads: { ...options.uploads, resolveUpload: undefined } });
|
|
63
|
+
appendFile(form, name, file);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const value = options.fields[name];
|
|
67
|
+
if (value === undefined || value === null)
|
|
68
|
+
continue;
|
|
69
|
+
appendScalar(form, name, value);
|
|
70
|
+
}
|
|
71
|
+
await appendAdditionalFile(form, options, sent, required);
|
|
72
|
+
return form;
|
|
73
|
+
}
|
|
74
|
+
function encodeUrlencoded(fields) {
|
|
75
|
+
const params = new URLSearchParams();
|
|
76
|
+
for (const [name, value] of Object.entries(fields)) {
|
|
77
|
+
if (value === undefined || value === null)
|
|
78
|
+
continue;
|
|
79
|
+
if (typeof value === "object")
|
|
80
|
+
continue;
|
|
81
|
+
params.set(name, String(value));
|
|
82
|
+
}
|
|
83
|
+
return params;
|
|
84
|
+
}
|
|
85
|
+
function filePartNames(properties, required, options) {
|
|
86
|
+
const fromProps = Object.entries(properties)
|
|
87
|
+
.filter(([name, schema]) => isFilePart(schema, options.encoding?.[name]))
|
|
88
|
+
.map(([name]) => name);
|
|
89
|
+
if (fromProps.length > 0)
|
|
90
|
+
return fromProps;
|
|
91
|
+
if (isFilePart(additionalSchema(options.schema) ?? {}, undefined)) {
|
|
92
|
+
const extra = required.find((name) => properties[name] === undefined);
|
|
93
|
+
if (extra !== undefined)
|
|
94
|
+
return [extra];
|
|
95
|
+
}
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
async function appendAdditionalFile(form, options, sent, required) {
|
|
99
|
+
const additional = additionalSchema(options.schema);
|
|
100
|
+
if (!isFilePart(additional ?? {}, undefined))
|
|
101
|
+
return;
|
|
102
|
+
const already = [...form.keys()].some((name) => {
|
|
103
|
+
const value = form.get(name);
|
|
104
|
+
return typeof File !== "undefined" && value instanceof File;
|
|
105
|
+
});
|
|
106
|
+
if (already)
|
|
107
|
+
return;
|
|
108
|
+
const name = required.find((item) => !sent.has(item)) ??
|
|
109
|
+
required.find((item) => isFilePart(propertiesOf(options.schema)[item] ?? {}, options.encoding?.[item]));
|
|
110
|
+
if (name === undefined)
|
|
111
|
+
return;
|
|
112
|
+
appendFile(form, name, await fileForPart(name, additional ?? {}, options));
|
|
113
|
+
}
|
|
114
|
+
async function fileForPart(name, schema, options) {
|
|
115
|
+
const request = uploadRequest(name, schema, options);
|
|
116
|
+
const file = await resolveUploadFile(request, options.uploads);
|
|
117
|
+
return file;
|
|
118
|
+
}
|
|
119
|
+
function uploadRequest(name, schema, options) {
|
|
120
|
+
const contentMediaType = contentMediaTypeOf(schema, options.encoding?.[name]);
|
|
121
|
+
const request = {
|
|
122
|
+
field: name,
|
|
123
|
+
index: options.index,
|
|
124
|
+
mediaType: options.mediaType,
|
|
125
|
+
operationId: options.operationId,
|
|
126
|
+
variant: options.variant,
|
|
127
|
+
};
|
|
128
|
+
if (contentMediaType !== undefined)
|
|
129
|
+
request.contentMediaType = contentMediaType;
|
|
130
|
+
const filename = typeof schema.filename === "string" ? schema.filename : undefined;
|
|
131
|
+
if (filename !== undefined)
|
|
132
|
+
request.filename = filename;
|
|
133
|
+
return request;
|
|
134
|
+
}
|
|
135
|
+
function appendFields(form, fields) {
|
|
136
|
+
for (const [name, value] of Object.entries(fields)) {
|
|
137
|
+
if (typeof value === "string")
|
|
138
|
+
form.append(name, value);
|
|
139
|
+
else
|
|
140
|
+
appendFile(form, name, value);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function appendFile(form, name, file) {
|
|
144
|
+
const blob = new File([file.bytes], file.filename, { type: file.mediaType });
|
|
145
|
+
form.append(name, blob, file.filename);
|
|
146
|
+
}
|
|
147
|
+
function appendScalar(form, name, value) {
|
|
148
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
149
|
+
form.append(name, String(value));
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
form.append(name, JSON.stringify(value));
|
|
153
|
+
}
|
|
154
|
+
export function isFilePart(schema, encoding) {
|
|
155
|
+
if (schema === null || typeof schema !== "object")
|
|
156
|
+
return false;
|
|
157
|
+
const record = schema;
|
|
158
|
+
if (isBinarySchema(record))
|
|
159
|
+
return true;
|
|
160
|
+
const encoded = encoding?.contentType;
|
|
161
|
+
if (typeof encoded === "string" && encoded !== "" && !isJsonMedia(encoded))
|
|
162
|
+
return true;
|
|
163
|
+
const union = record.oneOf ?? record.anyOf;
|
|
164
|
+
if (Array.isArray(union))
|
|
165
|
+
return union.some((branch) => isFilePart(branch, encoding));
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
function isBinarySchema(schema) {
|
|
169
|
+
const format = typeof schema.format === "string" ? schema.format.toLowerCase() : "";
|
|
170
|
+
if (format === "binary" || format === "byte")
|
|
171
|
+
return true;
|
|
172
|
+
const encoding = typeof schema.contentEncoding === "string" ? schema.contentEncoding.toLowerCase() : "";
|
|
173
|
+
if (encoding === "binary" || encoding === "base64")
|
|
174
|
+
return true;
|
|
175
|
+
const media = typeof schema.contentMediaType === "string" ? schema.contentMediaType : "";
|
|
176
|
+
if (media !== "" && !isJsonMedia(media))
|
|
177
|
+
return true;
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
function isJsonMedia(mediaType) {
|
|
181
|
+
const bare = mediaType.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
182
|
+
return bare.includes("json");
|
|
183
|
+
}
|
|
184
|
+
function contentMediaTypeOf(schema, encoding) {
|
|
185
|
+
if (typeof encoding?.contentType === "string" && encoding.contentType !== "") {
|
|
186
|
+
return encoding.contentType.split(",")[0]?.trim();
|
|
187
|
+
}
|
|
188
|
+
if (typeof schema.contentMediaType === "string" && schema.contentMediaType !== "") {
|
|
189
|
+
return schema.contentMediaType;
|
|
190
|
+
}
|
|
191
|
+
const format = typeof schema.format === "string" ? schema.format.toLowerCase() : "";
|
|
192
|
+
if (format === "binary" || format === "byte")
|
|
193
|
+
return "application/octet-stream";
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
function propertiesOf(schema) {
|
|
197
|
+
const properties = schema.properties;
|
|
198
|
+
if (properties === null || typeof properties !== "object" || Array.isArray(properties))
|
|
199
|
+
return {};
|
|
200
|
+
const out = {};
|
|
201
|
+
for (const [name, raw] of Object.entries(properties)) {
|
|
202
|
+
if (raw !== null && typeof raw === "object" && !Array.isArray(raw))
|
|
203
|
+
out[name] = raw;
|
|
204
|
+
}
|
|
205
|
+
return out;
|
|
206
|
+
}
|
|
207
|
+
function requiredOf(schema) {
|
|
208
|
+
return Array.isArray(schema.required)
|
|
209
|
+
? schema.required.filter((item) => typeof item === "string")
|
|
210
|
+
: [];
|
|
211
|
+
}
|
|
212
|
+
function additionalSchema(schema) {
|
|
213
|
+
const additional = schema.additionalProperties;
|
|
214
|
+
if (additional === null || typeof additional !== "object" || Array.isArray(additional))
|
|
215
|
+
return undefined;
|
|
216
|
+
return additional;
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body.js","sourceRoot":"","sources":["../../src/runtime/body.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAEN,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,GACrB,MAAM,aAAa,CAAA;AAmBpB,MAAM,UAAU,gBAAgB,CAAC,EAAkB,EAAE,KAAgB;IACpE,MAAM,GAAG,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;IACnD,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;AACtD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,EAAkB,EAClB,KAAgB,EAChB,MAA+B,EAC/B,OAAsB,EACtB,OAAO,GAAG,UAAU,EACpB,KAAK,GAAG,CAAC;IAET,MAAM,OAAO,GAAG,gBAAgB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;IAC3C,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,CAAA;IACrE,MAAM,OAAO,GAAkB;QAC9B,MAAM;QACN,KAAK;QACL,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,WAAW,EAAE,EAAE,CAAC,WAAW;QAC3B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO;QACP,OAAO;KACP,CAAA;IACD,IAAI,OAAO,CAAC,QAAQ,KAAK,SAA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,CAAA;AACN,CAAC;AAED,SAAS,gBAAgB,CAAC,MAA+B;IACxD,MAAM,UAAU,GAAG,MAAM,CAAC,oBAAoB,CAAA;IAC9C,IAAI,UAAU,KAAK,IAAI,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;QAAE,OAAO,SAAS,CAAA;IACxG,OAAO,UAAqC,CAAA;AAC7C,CAAC"}
|
package/dist/runtime/checks.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { QueryCapability } from "../spec/extensions.ts";
|
|
|
10
10
|
import type { OperationModel, SpecModel } from "../spec/graph.ts";
|
|
11
11
|
import type { Client } from "./client.ts";
|
|
12
12
|
import type { FindingCollector } from "./finding.ts";
|
|
13
|
+
import type { UploadContext } from "./upload.ts";
|
|
13
14
|
import type { SchemaValidator } from "./validate.ts";
|
|
14
15
|
import { type Record_ } from "./world.ts";
|
|
15
16
|
/** A resolved principal as checks see it — identity, lattice position, and how to speak as it. */
|
|
@@ -53,6 +54,8 @@ export interface CheckContext {
|
|
|
53
54
|
altScope: Record<string, string> | undefined;
|
|
54
55
|
validator: SchemaValidator | undefined;
|
|
55
56
|
seed: number;
|
|
57
|
+
/** File pool / dummy resolution for multipart parts. */
|
|
58
|
+
uploads: UploadContext;
|
|
56
59
|
/** Operations on this entity declared async via `x-async`. */
|
|
57
60
|
asyncOps: OperationModel[];
|
|
58
61
|
/** Operations on this entity that declare `x-effects`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../../src/runtime/checks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../../src/runtime/checks.ts"],"names":[],"mappings":"AAAA;;;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AM,EAAE,SAAS,KAAK,EA0ElC,CAAA"}
|
package/dist/runtime/checks.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* the oracle of what oat just wrote. Check ids are stable: the conformance suite asserts on them.
|
|
7
7
|
*/
|
|
8
8
|
import { filterTerm, selectTerm, sortTerm } from "../spec/conventions.js";
|
|
9
|
+
import { requestContent } from "../spec/collection.js";
|
|
10
|
+
import { encodeForOperation } from "./body.js";
|
|
9
11
|
import { describeFeatureGate, isDocumentedFeatureGateDenial, reportFeatureGateSchemaDrift } from "./feature-gate.js";
|
|
10
12
|
import { driveAsync } from "./async.js";
|
|
11
13
|
import { buildCohort } from "./fixture.js";
|
|
@@ -1312,19 +1314,20 @@ const idempotentReplay = {
|
|
|
1312
1314
|
return;
|
|
1313
1315
|
const schema = requestSchemaOf(ctx, createOp);
|
|
1314
1316
|
if (schema === null) {
|
|
1315
|
-
return ctx.findings.unresolved(this.id, ctx.entityName, "the create operation declares no
|
|
1317
|
+
return ctx.findings.unresolved(this.id, ctx.entityName, "the create operation declares no request body to replay");
|
|
1316
1318
|
}
|
|
1317
1319
|
const body = validBody(ctx, schema);
|
|
1318
1320
|
const key = `oat-idem-${ctx.seed}-${ctx.entityName}`;
|
|
1319
1321
|
const path = fillPath(createOp.path, ctx.scope);
|
|
1320
1322
|
const headers = { ...ctx.auth(), [header]: key };
|
|
1321
|
-
const
|
|
1323
|
+
const encoded = await encodeOpBody(ctx, createOp, body);
|
|
1324
|
+
const first = await ctx.client.request("POST", path, { ...encoded, headers });
|
|
1322
1325
|
if (standDownForFeatureGate(ctx, createOp, first, this.id))
|
|
1323
1326
|
return;
|
|
1324
1327
|
if (first.status >= 300) {
|
|
1325
1328
|
return ctx.findings.unresolved(this.id, ctx.entityName, `the first create returned ${first.status}, so there was nothing to replay`);
|
|
1326
1329
|
}
|
|
1327
|
-
const second = await ctx.client.request("POST", path, {
|
|
1330
|
+
const second = await ctx.client.request("POST", path, { ...encoded, headers });
|
|
1328
1331
|
if (standDownForFeatureGate(ctx, createOp, second, this.id))
|
|
1329
1332
|
return;
|
|
1330
1333
|
if (second.status >= 300) {
|
|
@@ -1370,7 +1373,7 @@ const declaredInvalidationHappens = {
|
|
|
1370
1373
|
return;
|
|
1371
1374
|
const schema = requestSchemaOf(ctx, createOp);
|
|
1372
1375
|
if (schema === null) {
|
|
1373
|
-
return ctx.findings.unresolved(this.id, ctx.entityName, "the create operation declares no
|
|
1376
|
+
return ctx.findings.unresolved(this.id, ctx.entityName, "the create operation declares no request body, so no write can be made");
|
|
1374
1377
|
}
|
|
1375
1378
|
/* Only routes whose path can be filled from this entity's scope are probed: a route
|
|
1376
1379
|
* needing an identifier oat does not hold would 404 for a reason unrelated to staleness. */
|
|
@@ -1395,7 +1398,7 @@ const declaredInvalidationHappens = {
|
|
|
1395
1398
|
return ctx.findings.unresolved(this.id, ctx.entityName, "none of the declared routes could be read before the write");
|
|
1396
1399
|
}
|
|
1397
1400
|
const created = await ctx.client.request("POST", fillPath(createOp.path, ctx.scope), {
|
|
1398
|
-
|
|
1401
|
+
...(await encodeOpBody(ctx, createOp, validBody(ctx, schema))),
|
|
1399
1402
|
headers: ctx.auth(),
|
|
1400
1403
|
});
|
|
1401
1404
|
if (standDownForFeatureGate(ctx, createOp, created, this.id))
|
|
@@ -2775,7 +2778,9 @@ const createPersistsFields = {
|
|
|
2775
2778
|
const sent = createExchange(ctx);
|
|
2776
2779
|
if (sent === undefined || sent.requestBody === undefined)
|
|
2777
2780
|
return;
|
|
2778
|
-
const request = sent.requestBody;
|
|
2781
|
+
const request = submittedFields(sent.requestBody);
|
|
2782
|
+
if (Object.keys(request).length === 0)
|
|
2783
|
+
return;
|
|
2779
2784
|
const response = (sent.responseBody ?? {});
|
|
2780
2785
|
const dropped = Object.entries(request).filter(([key, value]) => {
|
|
2781
2786
|
if (value === null || value === undefined)
|
|
@@ -2811,7 +2816,7 @@ const enumValidated = {
|
|
|
2811
2816
|
return;
|
|
2812
2817
|
const body = { ...validBody(ctx, schema), [target.name]: "oat-not-a-member" };
|
|
2813
2818
|
const exchange = await ctx.client.request("POST", fillPath(createOp.path, ctx.scope), {
|
|
2814
|
-
body,
|
|
2819
|
+
...(await encodeOpBody(ctx, createOp, body)),
|
|
2815
2820
|
headers: ctx.auth(),
|
|
2816
2821
|
});
|
|
2817
2822
|
if (standDownForFeatureGate(ctx, createOp, exchange, this.id))
|
|
@@ -2842,7 +2847,7 @@ const maxLengthValidated = {
|
|
|
2842
2847
|
const max = target.schema.maxLength;
|
|
2843
2848
|
const body = { ...validBody(ctx, schema), [target.name]: "x".repeat(max + 25) };
|
|
2844
2849
|
const exchange = await ctx.client.request("POST", fillPath(createOp.path, ctx.scope), {
|
|
2845
|
-
body,
|
|
2850
|
+
...(await encodeOpBody(ctx, createOp, body)),
|
|
2846
2851
|
headers: ctx.auth(),
|
|
2847
2852
|
});
|
|
2848
2853
|
if (standDownForFeatureGate(ctx, createOp, exchange, this.id))
|
|
@@ -2871,7 +2876,7 @@ const requiredValidated = {
|
|
|
2871
2876
|
return;
|
|
2872
2877
|
const { [field]: _omitted, ...body } = validBody(ctx, schema);
|
|
2873
2878
|
const exchange = await ctx.client.request("POST", fillPath(createOp.path, ctx.scope), {
|
|
2874
|
-
body,
|
|
2879
|
+
...(await encodeOpBody(ctx, createOp, body)),
|
|
2875
2880
|
headers: ctx.auth(),
|
|
2876
2881
|
});
|
|
2877
2882
|
if (standDownForFeatureGate(ctx, createOp, exchange, this.id))
|
|
@@ -2971,6 +2976,8 @@ const successSchemaHonoured = {
|
|
|
2971
2976
|
const exchange = createExchange(ctx);
|
|
2972
2977
|
if (exchange === undefined)
|
|
2973
2978
|
return;
|
|
2979
|
+
if (isEventStream(exchange))
|
|
2980
|
+
return;
|
|
2974
2981
|
if (!validator.documents(raw, exchange.status)) {
|
|
2975
2982
|
return ctx.findings.unresolved(this.id, ctx.entityName, `create returned ${exchange.status}, which the document declares no schema for — ` +
|
|
2976
2983
|
"there is nothing to validate the body against");
|
|
@@ -3005,14 +3012,34 @@ function bodyForOp(ctx, op) {
|
|
|
3005
3012
|
}
|
|
3006
3013
|
function requestSchemaOf(ctx, op) {
|
|
3007
3014
|
const raw = ctx.model.rawOperations.get(op.operationId);
|
|
3008
|
-
const
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3015
|
+
const picked = raw === undefined ? null : requestContent(raw);
|
|
3016
|
+
return picked === null ? null : picked.schema;
|
|
3017
|
+
}
|
|
3018
|
+
async function encodeOpBody(ctx, op, fields, variant = "baseline", index = 0) {
|
|
3019
|
+
const encoded = await encodeForOperation(op, ctx.model, fields, ctx.uploads, variant, index);
|
|
3020
|
+
return encoded.contentType === undefined
|
|
3021
|
+
? { body: encoded.body }
|
|
3022
|
+
: { body: encoded.body, contentType: encoded.contentType };
|
|
3023
|
+
}
|
|
3024
|
+
function submittedFields(body) {
|
|
3025
|
+
if (typeof FormData !== "undefined" && body instanceof FormData) {
|
|
3026
|
+
const out = {};
|
|
3027
|
+
for (const [name, value] of body.entries()) {
|
|
3028
|
+
if (typeof value === "string")
|
|
3029
|
+
out[name] = value;
|
|
3030
|
+
}
|
|
3031
|
+
return out;
|
|
3014
3032
|
}
|
|
3015
|
-
|
|
3033
|
+
if (typeof URLSearchParams !== "undefined" && body instanceof URLSearchParams) {
|
|
3034
|
+
return Object.fromEntries(body.entries());
|
|
3035
|
+
}
|
|
3036
|
+
if (body !== null && typeof body === "object" && !Array.isArray(body))
|
|
3037
|
+
return body;
|
|
3038
|
+
return {};
|
|
3039
|
+
}
|
|
3040
|
+
function isEventStream(exchange) {
|
|
3041
|
+
const type = exchange.responseHeaders["content-type"] ?? "";
|
|
3042
|
+
return type.includes("text/event-stream");
|
|
3016
3043
|
}
|
|
3017
3044
|
function findConstrained(schema, predicate) {
|
|
3018
3045
|
const props = schema.properties;
|
|
@@ -3265,7 +3292,7 @@ const declaredEffectsOccur = {
|
|
|
3265
3292
|
const body = op.hasRequestBody ? bodyForOp(ctx, op) : undefined;
|
|
3266
3293
|
const invoked = await ctx.client.request(op.method, fillPath(op.path, ctx.scope), {
|
|
3267
3294
|
headers: ctx.auth(),
|
|
3268
|
-
...(body === undefined ? {} :
|
|
3295
|
+
...(body === undefined ? {} : await encodeOpBody(ctx, op, body)),
|
|
3269
3296
|
});
|
|
3270
3297
|
if (standDownForFeatureGate(ctx, op, invoked, this.id))
|
|
3271
3298
|
continue;
|
|
@@ -3337,7 +3364,7 @@ const asyncReachesTerminalState = {
|
|
|
3337
3364
|
const body = op.hasRequestBody ? bodyForOp(ctx, op) : undefined;
|
|
3338
3365
|
const start = await ctx.client.request(op.method, fillPath(op.path, ctx.scope), {
|
|
3339
3366
|
headers: ctx.auth(),
|
|
3340
|
-
...(body === undefined ? {} :
|
|
3367
|
+
...(body === undefined ? {} : await encodeOpBody(ctx, op, body)),
|
|
3341
3368
|
});
|
|
3342
3369
|
if (standDownForFeatureGate(ctx, op, start, this.id))
|
|
3343
3370
|
continue;
|