@suss/packs 0.22.0 → 0.22.2
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/express.js +45 -30
- package/dist/rails.js +7 -7
- package/package.json +10 -10
package/dist/express.js
CHANGED
|
@@ -6,6 +6,27 @@ import {
|
|
|
6
6
|
wrapperDiscovery
|
|
7
7
|
} from "@suss/extractor";
|
|
8
8
|
var METHODS = [".get", ".post", ".put", ".delete", ".patch", ".all"];
|
|
9
|
+
var HEADER_SETTERS = [
|
|
10
|
+
"set",
|
|
11
|
+
"header",
|
|
12
|
+
"type",
|
|
13
|
+
"contentType",
|
|
14
|
+
"location",
|
|
15
|
+
"cookie",
|
|
16
|
+
"clearCookie",
|
|
17
|
+
"append",
|
|
18
|
+
"vary",
|
|
19
|
+
"links",
|
|
20
|
+
"attachment"
|
|
21
|
+
];
|
|
22
|
+
function responseChain(...methodChain) {
|
|
23
|
+
return {
|
|
24
|
+
type: "parameterMethodCall",
|
|
25
|
+
parameterPosition: 1,
|
|
26
|
+
methodChain,
|
|
27
|
+
passThroughMethods: HEADER_SETTERS
|
|
28
|
+
};
|
|
29
|
+
}
|
|
9
30
|
var optionsSchema = z.object({}).strict();
|
|
10
31
|
function expressFramework(_options = {}) {
|
|
11
32
|
return {
|
|
@@ -54,11 +75,7 @@ function expressFramework(_options = {}) {
|
|
|
54
75
|
{
|
|
55
76
|
// res.status(N).json(body)
|
|
56
77
|
kind: "response",
|
|
57
|
-
match:
|
|
58
|
-
type: "parameterMethodCall",
|
|
59
|
-
parameterPosition: 1,
|
|
60
|
-
methodChain: ["status", "json"]
|
|
61
|
-
},
|
|
78
|
+
match: responseChain("status", "json"),
|
|
62
79
|
extraction: {
|
|
63
80
|
statusCode: { from: "argument", position: 0 },
|
|
64
81
|
body: { from: "argument", position: 0 }
|
|
@@ -67,11 +84,7 @@ function expressFramework(_options = {}) {
|
|
|
67
84
|
{
|
|
68
85
|
// res.json(body): implicit 200
|
|
69
86
|
kind: "response",
|
|
70
|
-
match:
|
|
71
|
-
type: "parameterMethodCall",
|
|
72
|
-
parameterPosition: 1,
|
|
73
|
-
methodChain: ["json"]
|
|
74
|
-
},
|
|
87
|
+
match: responseChain("json"),
|
|
75
88
|
extraction: {
|
|
76
89
|
body: { from: "argument", position: 0 },
|
|
77
90
|
defaultStatusCode: 200
|
|
@@ -80,11 +93,7 @@ function expressFramework(_options = {}) {
|
|
|
80
93
|
{
|
|
81
94
|
// res.status(N).send(body)
|
|
82
95
|
kind: "response",
|
|
83
|
-
match:
|
|
84
|
-
type: "parameterMethodCall",
|
|
85
|
-
parameterPosition: 1,
|
|
86
|
-
methodChain: ["status", "send"]
|
|
87
|
-
},
|
|
96
|
+
match: responseChain("status", "send"),
|
|
88
97
|
extraction: {
|
|
89
98
|
statusCode: { from: "argument", position: 0 },
|
|
90
99
|
body: { from: "argument", position: 0 }
|
|
@@ -93,11 +102,25 @@ function expressFramework(_options = {}) {
|
|
|
93
102
|
{
|
|
94
103
|
// res.send(body): implicit 200
|
|
95
104
|
kind: "response",
|
|
96
|
-
match:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
105
|
+
match: responseChain("send"),
|
|
106
|
+
extraction: {
|
|
107
|
+
body: { from: "argument", position: 0 },
|
|
108
|
+
defaultStatusCode: 200
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
// res.status(N).end(): a status with no body, 204 most often
|
|
113
|
+
kind: "response",
|
|
114
|
+
match: responseChain("status", "end"),
|
|
115
|
+
extraction: {
|
|
116
|
+
statusCode: { from: "argument", position: 0 },
|
|
117
|
+
body: { from: "argument", position: 0 }
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
// res.end(): implicit 200 with no body
|
|
122
|
+
kind: "response",
|
|
123
|
+
match: responseChain("end"),
|
|
101
124
|
extraction: {
|
|
102
125
|
body: { from: "argument", position: 0 },
|
|
103
126
|
defaultStatusCode: 200
|
|
@@ -106,11 +129,7 @@ function expressFramework(_options = {}) {
|
|
|
106
129
|
{
|
|
107
130
|
// res.sendStatus(N): sends status code with status text as body
|
|
108
131
|
kind: "response",
|
|
109
|
-
match:
|
|
110
|
-
type: "parameterMethodCall",
|
|
111
|
-
parameterPosition: 1,
|
|
112
|
-
methodChain: ["sendStatus"]
|
|
113
|
-
},
|
|
132
|
+
match: responseChain("sendStatus"),
|
|
114
133
|
extraction: {
|
|
115
134
|
statusCode: { from: "argument", position: 0 }
|
|
116
135
|
}
|
|
@@ -120,11 +139,7 @@ function expressFramework(_options = {}) {
|
|
|
120
139
|
// Arg 0 is a status code only in the 2-arg form; minArgs prevents
|
|
121
140
|
// extracting the URL string as a status code in the 1-arg form.
|
|
122
141
|
kind: "response",
|
|
123
|
-
match:
|
|
124
|
-
type: "parameterMethodCall",
|
|
125
|
-
parameterPosition: 1,
|
|
126
|
-
methodChain: ["redirect"]
|
|
127
|
-
},
|
|
142
|
+
match: responseChain("redirect"),
|
|
128
143
|
extraction: {
|
|
129
144
|
statusCode: { from: "argument", position: 0, minArgs: 2 },
|
|
130
145
|
defaultStatusCode: 302
|
package/dist/rails.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
field,
|
|
9
9
|
hashKeySymbolName,
|
|
10
10
|
parseRubySync,
|
|
11
|
-
|
|
11
|
+
stringValueOf,
|
|
12
12
|
symbolValue
|
|
13
13
|
} from "@suss/adapter-ruby";
|
|
14
14
|
function readSimpleArgs(call) {
|
|
@@ -42,7 +42,7 @@ function wordValue(node) {
|
|
|
42
42
|
if (node === void 0) {
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
|
-
return symbolValue(node) ??
|
|
45
|
+
return symbolValue(node) ?? stringValueOf(node);
|
|
46
46
|
}
|
|
47
47
|
function splitControllerAction(text) {
|
|
48
48
|
const index = text.indexOf("#");
|
|
@@ -52,14 +52,14 @@ function splitControllerAction(text) {
|
|
|
52
52
|
return { controllerKey: text.slice(0, index), action: text.slice(index + 1) };
|
|
53
53
|
}
|
|
54
54
|
function readRouteTarget(args) {
|
|
55
|
-
const toText = args.keyword.to ?
|
|
55
|
+
const toText = args.keyword.to ? stringValueOf(args.keyword.to) : null;
|
|
56
56
|
if (toText !== null) {
|
|
57
57
|
const target = splitControllerAction(toText);
|
|
58
58
|
return target === null ? null : { ...target, path: null };
|
|
59
59
|
}
|
|
60
60
|
if (args.hashRocketPair !== null) {
|
|
61
|
-
const pathText =
|
|
62
|
-
const actionText =
|
|
61
|
+
const pathText = stringValueOf(args.hashRocketPair.key);
|
|
62
|
+
const actionText = stringValueOf(args.hashRocketPair.value);
|
|
63
63
|
const target = actionText !== null ? splitControllerAction(actionText) : null;
|
|
64
64
|
return target !== null && pathText !== null ? { ...target, path: pathText } : null;
|
|
65
65
|
}
|
|
@@ -190,7 +190,7 @@ function handleVerb(call, ctx, out, method) {
|
|
|
190
190
|
const args = readSimpleArgs(call);
|
|
191
191
|
const target = readRouteTarget(args);
|
|
192
192
|
if (target !== null) {
|
|
193
|
-
const literalPath = args.positional[0] ?
|
|
193
|
+
const literalPath = args.positional[0] ? stringValueOf(args.positional[0]) : null;
|
|
194
194
|
const path2 = target.path ?? literalPath;
|
|
195
195
|
if (path2 !== null) {
|
|
196
196
|
out.add(target.controllerKey, target.action, {
|
|
@@ -219,7 +219,7 @@ function handleVerb(call, ctx, out, method) {
|
|
|
219
219
|
}
|
|
220
220
|
function handleRoot(call, ctx, out) {
|
|
221
221
|
const args = readSimpleArgs(call);
|
|
222
|
-
const target = readRouteTarget(args) ?? (args.positional[0] ? splitControllerAction(
|
|
222
|
+
const target = readRouteTarget(args) ?? (args.positional[0] ? splitControllerAction(stringValueOf(args.positional[0]) ?? "") : null);
|
|
223
223
|
if (target !== null) {
|
|
224
224
|
out.add(target.controllerKey, target.action, {
|
|
225
225
|
method: "GET",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suss/packs",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Every pack suss ships, as one package with a subpath per pack.",
|
|
6
6
|
"keywords": [
|
|
@@ -189,15 +189,15 @@
|
|
|
189
189
|
"ts-morph": "^23.0.0"
|
|
190
190
|
},
|
|
191
191
|
"dependencies": {
|
|
192
|
-
"@suss/adapter-python": "0.22.
|
|
193
|
-
"@suss/adapter-ruby": "0.22.
|
|
194
|
-
"@suss/adapter-typescript": "0.22.
|
|
195
|
-
"@suss/behavioral-ir": "0.22.
|
|
196
|
-
"@suss/contract-graphql": "0.22.
|
|
197
|
-
"@suss/extractor": "0.22.
|
|
198
|
-
"@suss/manifest-aws": "0.22.
|
|
199
|
-
"@suss/recognize": "0.22.
|
|
200
|
-
"@suss/sql": "0.22.
|
|
192
|
+
"@suss/adapter-python": "0.22.2",
|
|
193
|
+
"@suss/adapter-ruby": "0.22.2",
|
|
194
|
+
"@suss/adapter-typescript": "0.22.2",
|
|
195
|
+
"@suss/behavioral-ir": "0.22.2",
|
|
196
|
+
"@suss/contract-graphql": "0.22.2",
|
|
197
|
+
"@suss/extractor": "0.22.2",
|
|
198
|
+
"@suss/manifest-aws": "0.22.2",
|
|
199
|
+
"@suss/recognize": "0.22.2",
|
|
200
|
+
"@suss/sql": "0.22.2",
|
|
201
201
|
"zod": "^4.0.0"
|
|
202
202
|
},
|
|
203
203
|
"devDependencies": {
|