@stacks/rendezvous 0.7.3 → 0.7.4
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/package.json +1 -1
- package/dist/traits.js +24 -8
- package/package.json +1 -1
package/dist/package.json
CHANGED
package/dist/traits.js
CHANGED
|
@@ -17,21 +17,37 @@ const enrichInterfaceWithTraitData = (ast, traitReferenceMap, functionInterfaceL
|
|
|
17
17
|
const enriched = new Map();
|
|
18
18
|
const enrichArgs = (args, functionName, traitReferenceMap, path = []) => {
|
|
19
19
|
return args.map((arg) => {
|
|
20
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
21
21
|
const listNested = !arg.name;
|
|
22
22
|
const currentPath = listNested ? path : [...path, arg.name];
|
|
23
|
+
// Exit early if the traitReferenceMap does not have anything we are
|
|
24
|
+
// looking for. It means that the current parameter does not have an
|
|
25
|
+
// associated trait reference.
|
|
26
|
+
if (!traitReferenceMap ||
|
|
27
|
+
(!traitReferenceMap[arg.name] &&
|
|
28
|
+
!traitReferenceMap.tuple &&
|
|
29
|
+
!traitReferenceMap.list &&
|
|
30
|
+
!traitReferenceMap.response &&
|
|
31
|
+
!traitReferenceMap.optional &&
|
|
32
|
+
!((_a = traitReferenceMap[arg.name]) === null || _a === void 0 ? void 0 : _a.tuple) &&
|
|
33
|
+
!((_b = traitReferenceMap[arg.name]) === null || _b === void 0 ? void 0 : _b.list) &&
|
|
34
|
+
!((_c = traitReferenceMap[arg.name]) === null || _c === void 0 ? void 0 : _c.response) &&
|
|
35
|
+
!((_d = traitReferenceMap[arg.name]) === null || _d === void 0 ? void 0 : _d.optional) &&
|
|
36
|
+
traitReferenceMap !== "trait_reference")) {
|
|
37
|
+
return arg;
|
|
38
|
+
}
|
|
23
39
|
if (arg.type && arg.type.tuple) {
|
|
24
40
|
return Object.assign(Object.assign({}, arg), { type: {
|
|
25
41
|
tuple: enrichArgs(arg.type.tuple, functionName, listNested
|
|
26
42
|
? traitReferenceMap.tuple
|
|
27
|
-
: (
|
|
43
|
+
: (_e = traitReferenceMap[arg.name]) === null || _e === void 0 ? void 0 : _e.tuple, currentPath),
|
|
28
44
|
} });
|
|
29
45
|
}
|
|
30
46
|
else if (arg.type && arg.type.list) {
|
|
31
47
|
return Object.assign(Object.assign({}, arg), { type: {
|
|
32
48
|
list: enrichArgs([arg.type.list], functionName, listNested
|
|
33
49
|
? traitReferenceMap.list
|
|
34
|
-
: (
|
|
50
|
+
: (_f = traitReferenceMap[arg.name]) === null || _f === void 0 ? void 0 : _f.list, arg.type.list.type.tuple
|
|
35
51
|
? [...currentPath, "tuple"]
|
|
36
52
|
: arg.type.list.type.response
|
|
37
53
|
? [...currentPath, "response"]
|
|
@@ -45,13 +61,13 @@ const enrichInterfaceWithTraitData = (ast, traitReferenceMap, functionInterfaceL
|
|
|
45
61
|
const errorPath = listNested ? currentPath : [...currentPath, "error"];
|
|
46
62
|
const okTraitReference = enrichArgs([{ name: "ok", type: arg.type.response.ok }], functionName, {
|
|
47
63
|
ok: listNested
|
|
48
|
-
? (
|
|
49
|
-
: (
|
|
64
|
+
? (_g = traitReferenceMap.response) === null || _g === void 0 ? void 0 : _g.ok
|
|
65
|
+
: (_j = (_h = traitReferenceMap[arg.name]) === null || _h === void 0 ? void 0 : _h.response) === null || _j === void 0 ? void 0 : _j.ok,
|
|
50
66
|
}, okPath)[0];
|
|
51
67
|
const errorTraitReference = enrichArgs([{ name: "error", type: arg.type.response.error }], functionName, {
|
|
52
68
|
error: listNested
|
|
53
|
-
? (
|
|
54
|
-
: (
|
|
69
|
+
? (_k = traitReferenceMap.response) === null || _k === void 0 ? void 0 : _k.error
|
|
70
|
+
: (_m = (_l = traitReferenceMap[arg.name]) === null || _l === void 0 ? void 0 : _l.response) === null || _m === void 0 ? void 0 : _m.error,
|
|
55
71
|
}, errorPath)[0];
|
|
56
72
|
return Object.assign(Object.assign({}, arg), { type: {
|
|
57
73
|
response: {
|
|
@@ -65,7 +81,7 @@ const enrichInterfaceWithTraitData = (ast, traitReferenceMap, functionInterfaceL
|
|
|
65
81
|
const optionalTraitReference = enrichArgs([{ name: "optional", type: arg.type.optional }], functionName, {
|
|
66
82
|
optional: listNested
|
|
67
83
|
? traitReferenceMap.optional
|
|
68
|
-
: (
|
|
84
|
+
: (_o = traitReferenceMap[arg.name]) === null || _o === void 0 ? void 0 : _o.optional,
|
|
69
85
|
}, optionalPath)[0];
|
|
70
86
|
return Object.assign(Object.assign({}, arg), { type: {
|
|
71
87
|
optional: optionalTraitReference.type,
|