@voxgig/sdkgen 4.3.0 → 4.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/bin/voxgig-sdkgen +1 -1
- package/package.json +1 -1
- package/project/.sdk/src/cmp/zig/Config_zig.ts +1 -1
- package/project/.sdk/tm/c/tests/primary_corpus_test.c +565 -0
- package/project/.sdk/tm/c/utility/prepare_method.c +3 -1
- package/project/.sdk/tm/c/utility/transform_request.c +4 -3
- package/project/.sdk/tm/clojure/src/sdk/core.clj +55 -5
- package/project/.sdk/tm/clojure/test/sdk/test/primary.clj +171 -1
- package/project/.sdk/tm/clojure/test/sdk/test/struct_corpus.clj +13 -2
- package/project/.sdk/tm/clojure/test/sdk/test_runner.clj +2 -0
- package/project/.sdk/tm/csharp/test/CustomUtilityTest.cs +104 -0
- package/project/.sdk/tm/csharp/utility/MakeOptions.cs +82 -2
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +50 -2
- package/project/.sdk/tm/elixir/test/primary_utility_test.exs +18 -200
- package/project/.sdk/tm/elixir/test/support/struct_corpus.ex +413 -2
- package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +56 -2
- package/project/.sdk/tm/lua/utility/make_options.lua +22 -2
- package/project/.sdk/tm/ocaml/Makefile +15 -4
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +8 -1
- package/project/.sdk/tm/ocaml/test/corpus_runner.ml +185 -0
- package/project/.sdk/tm/ocaml/test/primary_utility_test.ml +238 -0
- package/project/.sdk/tm/ocaml/test/struct_corpus.ml +5 -160
- package/project/.sdk/tm/scala/Makefile +1 -0
- package/project/.sdk/tm/scala/sdktest/PrimaryCorpus.scala +294 -0
- package/project/.sdk/tm/scala/sdktest/StructCorpus.scala +0 -0
- package/project/.sdk/tm/scala/utility/Make.scala +49 -2
- package/project/.sdk/tm/scala/utility/Prepare.scala +3 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +21 -3
- package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +13 -2
- package/project/.sdk/tm/zig/core/utility.zig +8 -1
- package/project/.sdk/tm/zig/test/primary_utility_test.zig +445 -0
- package/project/.sdk/tm/zig/test/struct_runner.zig +238 -0
- package/project/sdkgen-package.json +1 -1
|
@@ -344,3 +344,448 @@ test "primary new sdk smoke" {
|
|
|
344
344
|
const client = sdk.new();
|
|
345
345
|
try testing.expect(std.mem.eql(u8, client.mode, "live"));
|
|
346
346
|
}
|
|
347
|
+
|
|
348
|
+
// ---------------------------------------------------------------------------
|
|
349
|
+
// THE SHARED CORPUS.
|
|
350
|
+
//
|
|
351
|
+
// Everything above asserts against inputs written here; this drives
|
|
352
|
+
// .sdk/test/test.json -> "primary" through the same utilities, so the cases
|
|
353
|
+
// cannot drift from the reference implementation. That is what moves zig from
|
|
354
|
+
// the MIRRORED parity tier to FULL: a mirrored suite cannot notice a corpus
|
|
355
|
+
// case that changed, or one that was added.
|
|
356
|
+
// ---------------------------------------------------------------------------
|
|
357
|
+
|
|
358
|
+
const runner = @import("struct_runner.zig");
|
|
359
|
+
const vs = @import("../utility/voxgigstruct/struct.zig");
|
|
360
|
+
|
|
361
|
+
const StdJson = std.json.Value;
|
|
362
|
+
|
|
363
|
+
/// A LIVE context from a corpus map: the utilities read and MUTATE spec,
|
|
364
|
+
/// result and response through their types, so a bare value leaves them
|
|
365
|
+
/// nothing to work on and every match reads null.
|
|
366
|
+
fn corpusCtx(alloc: std.mem.Allocator, ctxstd: StdJson) !*sdk.Context {
|
|
367
|
+
return corpusCtxOpts(alloc, ctxstd, sdk.Value{ .null = {} });
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/// As corpusCtx, with SDK options — make_spec and prepare_auth read their
|
|
371
|
+
/// defaults off the CLIENT (client.options_map()), as the ts reference does
|
|
372
|
+
/// via client.options(), so a section's DEF.setup cannot reach them through
|
|
373
|
+
/// ctx.options.
|
|
374
|
+
fn corpusCtxOpts(alloc: std.mem.Allocator, ctxstd: StdJson, sdkopts: sdk.Value) !*sdk.Context {
|
|
375
|
+
const client = sdk.test_sdk(sdk.Value{ .null = {} }, sdkopts);
|
|
376
|
+
const utility = client.get_utility();
|
|
377
|
+
|
|
378
|
+
// Only when the corpus names one. Defaulting to "load" made the SDK report
|
|
379
|
+
// the wrong operation in the error messages the corpus matches on — it
|
|
380
|
+
// expects "unknown operation" where no op is named.
|
|
381
|
+
const opname: ?[]const u8 = blk: {
|
|
382
|
+
if (ctxstd == .object) {
|
|
383
|
+
if (ctxstd.object.get("opname")) |o| {
|
|
384
|
+
if (o == .string) break :blk o.string;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
break :blk null;
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
const ctx = utility.make_context(sdk.CtxSpec{
|
|
391
|
+
.opname = opname,
|
|
392
|
+
.client = client,
|
|
393
|
+
.utility = utility,
|
|
394
|
+
}, client.get_root_ctx());
|
|
395
|
+
|
|
396
|
+
if (ctxstd != .object) return ctx;
|
|
397
|
+
|
|
398
|
+
if (ctxstd.object.get("spec")) |v| {
|
|
399
|
+
ctx.spec = sdk.Spec.make(try vs.fromStdJson(alloc, v));
|
|
400
|
+
}
|
|
401
|
+
if (ctxstd.object.get("result")) |v| {
|
|
402
|
+
const r = sdk.SdkResult.make(try vs.fromStdJson(alloc, v));
|
|
403
|
+
// SdkResult.make does not carry `err` across, so a corpus result that
|
|
404
|
+
// declares one arrives empty and make_error reports "unknown error".
|
|
405
|
+
if (v == .object) {
|
|
406
|
+
if (v.object.get("err")) |ev| {
|
|
407
|
+
if (ev == .object) {
|
|
408
|
+
if (ev.object.get("message")) |m| {
|
|
409
|
+
if (m == .string and 0 < m.string.len) {
|
|
410
|
+
r.err = sdk.ProjectNameError.make("", m.string);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
ctx.result = r;
|
|
417
|
+
}
|
|
418
|
+
if (ctxstd.object.get("response")) |v| {
|
|
419
|
+
const rs = sdk.Response.make(try vs.fromStdJson(alloc, v));
|
|
420
|
+
// result_body_util requires response.json to be CALLABLE; the corpus
|
|
421
|
+
// supplies a plain `body`, so wrap it, as every other port's driver
|
|
422
|
+
// does. Without it every ctx.result.body match reads empty.
|
|
423
|
+
if (!h.is_noval(rs.body)) rs.json = h.json_thunk(rs.body);
|
|
424
|
+
// Header names arrive from the wire in any case and the contract is
|
|
425
|
+
// lowercase; result_headers_util copies them verbatim, so the corpus's
|
|
426
|
+
// mixed-case fixture never matches unless the driver normalises.
|
|
427
|
+
if (v == .object) {
|
|
428
|
+
if (v.object.get("headers")) |hv| {
|
|
429
|
+
if (hv == .object) {
|
|
430
|
+
const low = h.omap();
|
|
431
|
+
var it = hv.object.iterator();
|
|
432
|
+
while (it.next()) |kv| {
|
|
433
|
+
const lk = try std.ascii.allocLowerString(alloc, kv.key_ptr.*);
|
|
434
|
+
h.setp(low, lk, try vs.fromStdJson(alloc, kv.value_ptr.*));
|
|
435
|
+
}
|
|
436
|
+
rs.headers = low;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
ctx.response = rs;
|
|
441
|
+
}
|
|
442
|
+
if (ctxstd.object.get("point")) |v| {
|
|
443
|
+
ctx.point = try vs.fromStdJson(alloc, v);
|
|
444
|
+
}
|
|
445
|
+
if (ctxstd.object.get("reqdata")) |v| {
|
|
446
|
+
ctx.reqdata = try vs.fromStdJson(alloc, v);
|
|
447
|
+
}
|
|
448
|
+
if (ctxstd.object.get("reqmatch")) |v| {
|
|
449
|
+
ctx.reqmatch = try vs.fromStdJson(alloc, v);
|
|
450
|
+
}
|
|
451
|
+
return ctx;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/// Publish a neutral-named view of the mutated ctx, for `match: ctx.*`.
|
|
455
|
+
fn publishCtx(alloc: std.mem.Allocator, ctx: *sdk.Context) !StdJson {
|
|
456
|
+
var out = std.json.ObjectMap.init(alloc);
|
|
457
|
+
if (ctx.spec) |sp| try out.put("spec", try vs.toStdJson(alloc, sp.to_value()));
|
|
458
|
+
if (ctx.result) |rt| try out.put("result", try vs.toStdJson(alloc, rt.to_value()));
|
|
459
|
+
if (ctx.response) |rs| {
|
|
460
|
+
// makeRequest asserts `ctx.response: __EXISTS__`, so the response has
|
|
461
|
+
// to appear here at all; publish a neutral view of it while we are at
|
|
462
|
+
// it, since the corpus is camelCase and this port stores status_text.
|
|
463
|
+
var r = std.json.ObjectMap.init(alloc);
|
|
464
|
+
try r.put("status", StdJson{ .integer = @intCast(rs.status) });
|
|
465
|
+
try r.put("statusText", StdJson{ .string = rs.status_text });
|
|
466
|
+
try r.put("headers", try vs.toStdJson(alloc, rs.headers));
|
|
467
|
+
try r.put("body", try vs.toStdJson(alloc, rs.body));
|
|
468
|
+
try out.put("response", StdJson{ .object = r });
|
|
469
|
+
}
|
|
470
|
+
return StdJson{ .object = out };
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/// A section's `basic` set. The corpus nests one level — {"basic": {"set": []}}
|
|
474
|
+
/// — and passing the section node itself found no `set`, so every case was
|
|
475
|
+
/// skipped and the suite passed having run nothing.
|
|
476
|
+
fn section(spec: runner.Spec, name: []const u8) !StdJson {
|
|
477
|
+
const sec = spec.get(name) orelse return error.NoSection;
|
|
478
|
+
if (sec != .object) return error.NoSection;
|
|
479
|
+
return sec.object.get("basic") orelse error.NoSection;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/// A section's DEF.setup.a block, as SDK options.
|
|
483
|
+
fn setupOpts(a_unused: std.mem.Allocator, spec: runner.Spec, name: []const u8) !sdk.Value {
|
|
484
|
+
// The SDK's own arena, not the testing allocator: these values outlive the
|
|
485
|
+
// call and are owned by the SDK for the run, so allocating them from the
|
|
486
|
+
// test allocator reports a leak at teardown.
|
|
487
|
+
_ = a_unused;
|
|
488
|
+
const a = h.A();
|
|
489
|
+
const sec = spec.get(name) orelse return sdk.Value{ .null = {} };
|
|
490
|
+
if (sec != .object) return sdk.Value{ .null = {} };
|
|
491
|
+
const def = sec.object.get("DEF") orelse return sdk.Value{ .null = {} };
|
|
492
|
+
if (def != .object) return sdk.Value{ .null = {} };
|
|
493
|
+
const setup = def.object.get("setup") orelse return sdk.Value{ .null = {} };
|
|
494
|
+
if (setup != .object) return sdk.Value{ .null = {} };
|
|
495
|
+
const aa = setup.object.get("a") orelse return sdk.Value{ .null = {} };
|
|
496
|
+
return try vs.fromStdJson(a, aa);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
var setup_spec: sdk.Value = .{ .null = {} };
|
|
500
|
+
var setup_auth: sdk.Value = .{ .null = {} };
|
|
501
|
+
|
|
502
|
+
fn entryCtx(entry: StdJson) StdJson {
|
|
503
|
+
if (entry == .object) {
|
|
504
|
+
if (entry.object.get("ctx")) |c| return c;
|
|
505
|
+
}
|
|
506
|
+
return StdJson{ .null = {} };
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
test "primary corpus: the shared cases drive this SDK's utilities" {
|
|
510
|
+
const alloc = testing.allocator;
|
|
511
|
+
var pack = try runner.makeRunnerFor(alloc, "primary");
|
|
512
|
+
defer pack.deinit();
|
|
513
|
+
|
|
514
|
+
setup_spec = try setupOpts(alloc, pack.spec, "makeSpec");
|
|
515
|
+
setup_auth = try setupOpts(alloc, pack.spec, "prepareAuth");
|
|
516
|
+
|
|
517
|
+
const S = struct {
|
|
518
|
+
fn ctxOf(a: std.mem.Allocator, entry: StdJson) anyerror!*sdk.Context {
|
|
519
|
+
return corpusCtx(a, entryCtx(entry));
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/// Record the SDK's own message before letting the error propagate.
|
|
523
|
+
fn sdkfail(ctx: *sdk.Context, em: *?[]const u8, e: anyerror) anyerror {
|
|
524
|
+
if (ctx.pending_err) |pe| em.* = pe.msg;
|
|
525
|
+
return e;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
fn argAt(a: std.mem.Allocator, entry: StdJson, i: usize) anyerror!sdk.Value {
|
|
529
|
+
if (entry == .object) {
|
|
530
|
+
if (entry.object.get("args")) |args| {
|
|
531
|
+
if (args == .array and i < args.array.items.len) {
|
|
532
|
+
return try vs.fromStdJson(a, args.array.items[i]);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
return sdk.Value{ .null = {} };
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
fn argStd(entry: StdJson, i: usize) StdJson {
|
|
540
|
+
if (entry == .object) {
|
|
541
|
+
if (entry.object.get("args")) |args| {
|
|
542
|
+
if (args == .array and i < args.array.items.len) return args.array.items[i];
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return StdJson{ .null = {} };
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
fn inOf(entry: StdJson) StdJson {
|
|
549
|
+
if (entry == .object) {
|
|
550
|
+
if (entry.object.get("in")) |v| return v;
|
|
551
|
+
}
|
|
552
|
+
return StdJson{ .null = {} };
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
fn done(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
556
|
+
const ctx = try ctxOf(a, e);
|
|
557
|
+
const v = util.done_util(ctx) catch |er| return sdkfail(ctx, em, er);
|
|
558
|
+
po.* = try publishCtx(a, ctx);
|
|
559
|
+
return try vs.toStdJson(a, v);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
fn makeContext(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
563
|
+
_ = em;
|
|
564
|
+
const ctx = try corpusCtx(a, inOf(e));
|
|
565
|
+
po.* = try publishCtx(a, ctx);
|
|
566
|
+
var out = std.json.ObjectMap.init(a);
|
|
567
|
+
var op = std.json.ObjectMap.init(a);
|
|
568
|
+
try op.put("entity", StdJson{ .string = ctx.op.entity });
|
|
569
|
+
try op.put("name", StdJson{ .string = ctx.op.name });
|
|
570
|
+
try op.put("input", StdJson{ .string = ctx.op.input });
|
|
571
|
+
try op.put("points", try vs.toStdJson(a, ctx.op.points));
|
|
572
|
+
try out.put("op", StdJson{ .object = op });
|
|
573
|
+
return StdJson{ .object = out };
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
fn makeError(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
577
|
+
const ctx = try corpusCtx(a, argStd(e, 0));
|
|
578
|
+
|
|
579
|
+
// make_error_util takes no error argument — it reads one off the
|
|
580
|
+
// ctx (pending_err, else result.err). The corpus passes it as
|
|
581
|
+
// args[1], so put it where the utility will find it, or every case
|
|
582
|
+
// reports "unknown error".
|
|
583
|
+
const errarg = argStd(e, 1);
|
|
584
|
+
if (errarg == .object) {
|
|
585
|
+
if (errarg.object.get("message")) |m| {
|
|
586
|
+
if (m == .string and 0 < m.string.len) {
|
|
587
|
+
const r: *sdk.SdkResult = ctx.result orelse blk: {
|
|
588
|
+
const rr = sdk.SdkResult.make(h.omap());
|
|
589
|
+
ctx.result = rr;
|
|
590
|
+
break :blk rr;
|
|
591
|
+
};
|
|
592
|
+
r.err = sdk.ProjectNameError.make("", m.string);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
po.* = try publishCtx(a, ctx);
|
|
598
|
+
const v = util.make_error_util(ctx) catch |er| return sdkfail(ctx, em, er);
|
|
599
|
+
return try vs.toStdJson(a, v);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
fn makeOptions(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
603
|
+
_ = em;
|
|
604
|
+
// `in` is {config, options}, not a ctx — the utility reads them off
|
|
605
|
+
// the context, so split them out rather than passing the wrapper.
|
|
606
|
+
const inv = inOf(e);
|
|
607
|
+
const ctx = try corpusCtx(a, StdJson{ .null = {} });
|
|
608
|
+
if (inv == .object) {
|
|
609
|
+
if (inv.object.get("config")) |c| ctx.config = try vs.fromStdJson(a, c);
|
|
610
|
+
if (inv.object.get("options")) |o| ctx.options = try vs.fromStdJson(a, o);
|
|
611
|
+
}
|
|
612
|
+
const v = util.make_options_util(ctx);
|
|
613
|
+
po.* = try publishCtx(a, ctx);
|
|
614
|
+
return try vs.toStdJson(a, v);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
fn makeRequest(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
618
|
+
const ctx = try ctxOf(a, e);
|
|
619
|
+
_ = util.make_request_util(ctx) catch |er| return sdkfail(ctx, em, er);
|
|
620
|
+
po.* = try publishCtx(a, ctx);
|
|
621
|
+
return StdJson{ .null = {} };
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
fn makeResponse(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
625
|
+
const ctx = try ctxOf(a, e);
|
|
626
|
+
_ = util.make_response_util(ctx) catch |er| return sdkfail(ctx, em, er);
|
|
627
|
+
po.* = try publishCtx(a, ctx);
|
|
628
|
+
return StdJson{ .null = {} };
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
fn makeSpec(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
632
|
+
const ctx = try corpusCtxOpts(a, entryCtx(e), setup_spec);
|
|
633
|
+
const sp = util.make_spec_util(ctx) catch |er| return sdkfail(ctx, em, er);
|
|
634
|
+
po.* = try publishCtx(a, ctx);
|
|
635
|
+
return try vs.toStdJson(a, sp.to_value());
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
fn url(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
639
|
+
const ctx = try ctxOf(a, e);
|
|
640
|
+
const u = util.make_url_util(ctx) catch |er| return sdkfail(ctx, em, er);
|
|
641
|
+
po.* = try publishCtx(a, ctx);
|
|
642
|
+
return StdJson{ .string = u };
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
fn operator(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
646
|
+
_ = po;
|
|
647
|
+
_ = em;
|
|
648
|
+
const op = sdk.Operation.make(try vs.fromStdJson(a, inOf(e)));
|
|
649
|
+
var out = std.json.ObjectMap.init(a);
|
|
650
|
+
try out.put("entity", StdJson{ .string = op.entity });
|
|
651
|
+
try out.put("input", StdJson{ .string = op.input });
|
|
652
|
+
try out.put("name", StdJson{ .string = op.name });
|
|
653
|
+
try out.put("points", try vs.toStdJson(a, op.points));
|
|
654
|
+
return StdJson{ .object = out };
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
fn param(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
658
|
+
_ = em;
|
|
659
|
+
const ctx = try corpusCtx(a, argStd(e, 0));
|
|
660
|
+
const pd = try argAt(a, e, 1);
|
|
661
|
+
const v = util.param_util(ctx, pd);
|
|
662
|
+
po.* = try publishCtx(a, ctx);
|
|
663
|
+
return try vs.toStdJson(a, v);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
fn auth(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
667
|
+
const ctx = try corpusCtxOpts(a, entryCtx(e), setup_auth);
|
|
668
|
+
_ = util.prepare_auth_util(ctx) catch |er| return sdkfail(ctx, em, er);
|
|
669
|
+
po.* = try publishCtx(a, ctx);
|
|
670
|
+
return StdJson{ .null = {} };
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
fn body(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
674
|
+
_ = em;
|
|
675
|
+
const ctx = try ctxOf(a, e);
|
|
676
|
+
const v = util.prepare_body_util(ctx);
|
|
677
|
+
po.* = try publishCtx(a, ctx);
|
|
678
|
+
return try vs.toStdJson(a, v);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
fn headers(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
682
|
+
_ = em;
|
|
683
|
+
const ctx = try ctxOf(a, e);
|
|
684
|
+
const v = util.prepare_headers_util(ctx);
|
|
685
|
+
po.* = try publishCtx(a, ctx);
|
|
686
|
+
return try vs.toStdJson(a, v);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
fn method(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
690
|
+
_ = em;
|
|
691
|
+
const ctx = try ctxOf(a, e);
|
|
692
|
+
const m = util.prepare_method_util(ctx);
|
|
693
|
+
po.* = try publishCtx(a, ctx);
|
|
694
|
+
if (m.len == 0) return StdJson{ .null = {} };
|
|
695
|
+
return StdJson{ .string = m };
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
fn params(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
699
|
+
_ = em;
|
|
700
|
+
const ctx = try ctxOf(a, e);
|
|
701
|
+
const v = util.prepare_params_util(ctx);
|
|
702
|
+
po.* = try publishCtx(a, ctx);
|
|
703
|
+
return try vs.toStdJson(a, v);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
fn path(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
707
|
+
_ = em;
|
|
708
|
+
const ctx = try ctxOf(a, e);
|
|
709
|
+
const v = util.prepare_path_util(ctx);
|
|
710
|
+
po.* = try publishCtx(a, ctx);
|
|
711
|
+
return StdJson{ .string = v };
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
fn query(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
715
|
+
_ = em;
|
|
716
|
+
const ctx = try ctxOf(a, e);
|
|
717
|
+
const v = util.prepare_query_util(ctx);
|
|
718
|
+
po.* = try publishCtx(a, ctx);
|
|
719
|
+
return try vs.toStdJson(a, v);
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
fn rbasic(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
723
|
+
_ = em;
|
|
724
|
+
const ctx = try ctxOf(a, e);
|
|
725
|
+
const r = util.result_basic_util(ctx);
|
|
726
|
+
po.* = try publishCtx(a, ctx);
|
|
727
|
+
if (r) |rr| return try vs.toStdJson(a, rr.to_value());
|
|
728
|
+
return StdJson{ .null = {} };
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
fn rbody(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
732
|
+
_ = em;
|
|
733
|
+
const ctx = try ctxOf(a, e);
|
|
734
|
+
const r = util.result_body_util(ctx);
|
|
735
|
+
po.* = try publishCtx(a, ctx);
|
|
736
|
+
if (r) |rr| return try vs.toStdJson(a, rr.to_value());
|
|
737
|
+
return StdJson{ .null = {} };
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
fn rheaders(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
741
|
+
_ = em;
|
|
742
|
+
const ctx = try ctxOf(a, e);
|
|
743
|
+
const r = util.result_headers_util(ctx);
|
|
744
|
+
po.* = try publishCtx(a, ctx);
|
|
745
|
+
if (r) |rr| return try vs.toStdJson(a, rr.to_value());
|
|
746
|
+
return StdJson{ .null = {} };
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
fn treq(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
750
|
+
_ = em;
|
|
751
|
+
const ctx = try ctxOf(a, e);
|
|
752
|
+
const v = util.transform_request_util(ctx);
|
|
753
|
+
po.* = try publishCtx(a, ctx);
|
|
754
|
+
return try vs.toStdJson(a, v);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
fn tres(a: std.mem.Allocator, e: StdJson, po: *?StdJson, em: *?[]const u8) anyerror!StdJson {
|
|
758
|
+
_ = em;
|
|
759
|
+
const ctx = try ctxOf(a, e);
|
|
760
|
+
const v = util.transform_response_util(ctx);
|
|
761
|
+
po.* = try publishCtx(a, ctx);
|
|
762
|
+
return try vs.toStdJson(a, v);
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
// Every section the corpus carries, looked up in `primary` and driven.
|
|
767
|
+
try pack.runsetEntry(try section(pack.spec, "done"), S.done);
|
|
768
|
+
try pack.runsetEntry(try section(pack.spec, "makeContext"), S.makeContext);
|
|
769
|
+
try pack.runsetEntry(try section(pack.spec, "makeError"), S.makeError);
|
|
770
|
+
try pack.runsetEntry(try section(pack.spec, "makeOptions"), S.makeOptions);
|
|
771
|
+
try pack.runsetEntry(try section(pack.spec, "makeRequest"), S.makeRequest);
|
|
772
|
+
try pack.runsetEntry(try section(pack.spec, "makeResponse"), S.makeResponse);
|
|
773
|
+
try pack.runsetEntry(try section(pack.spec, "makeSpec"), S.makeSpec);
|
|
774
|
+
try pack.runsetEntry(try section(pack.spec, "makeUrl"), S.url);
|
|
775
|
+
try pack.runsetEntry(try section(pack.spec, "operator"), S.operator);
|
|
776
|
+
try pack.runsetEntry(try section(pack.spec, "param"), S.param);
|
|
777
|
+
try pack.runsetEntry(try section(pack.spec, "prepareAuth"), S.auth);
|
|
778
|
+
try pack.runsetEntry(try section(pack.spec, "prepareBody"), S.body);
|
|
779
|
+
try pack.runsetEntry(try section(pack.spec, "prepareHeaders"), S.headers);
|
|
780
|
+
try pack.runsetEntry(try section(pack.spec, "prepareMethod"), S.method);
|
|
781
|
+
try pack.runsetEntry(try section(pack.spec, "prepareParams"), S.params);
|
|
782
|
+
try pack.runsetEntry(try section(pack.spec, "preparePath"), S.path);
|
|
783
|
+
try pack.runsetEntry(try section(pack.spec, "prepareQuery"), S.query);
|
|
784
|
+
try pack.runsetEntry(try section(pack.spec, "resultBasic"), S.rbasic);
|
|
785
|
+
try pack.runsetEntry(try section(pack.spec, "resultBody"), S.rbody);
|
|
786
|
+
try pack.runsetEntry(try section(pack.spec, "resultHeaders"), S.rheaders);
|
|
787
|
+
try pack.runsetEntry(try section(pack.spec, "transformRequest"), S.treq);
|
|
788
|
+
try pack.runsetEntry(try section(pack.spec, "transformResponse"), S.tres);
|
|
789
|
+
|
|
790
|
+
try testing.expect(0 < pack.ran);
|
|
791
|
+
}
|