@launchsecure/launch-kit 0.0.9 → 0.0.11

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.
@@ -0,0 +1,8 @@
1
+ ; db.user.findUnique(...), db.session.create(...), etc.
2
+ ; Matches any <ident>.<model>.<method>() — no hardcoded DB identifier
3
+ (call_expression
4
+ function: (member_expression
5
+ object: (member_expression
6
+ object: (identifier) @db.identifier
7
+ property: (property_identifier) @db.model)
8
+ property: (property_identifier) @db.method))
@@ -0,0 +1,10 @@
1
+ ; if (condition) { ... }
2
+ (if_statement
3
+ condition: (parenthesized_expression (_) @cond.test)
4
+ consequence: (_) @cond.consequence)
5
+
6
+ ; Ternary: condition ? a : b
7
+ (ternary_expression
8
+ condition: (_) @ternary.test
9
+ consequence: (_) @ternary.then
10
+ alternative: (_) @ternary.else) @ternary.expr
@@ -0,0 +1,21 @@
1
+ ; Self-closing JSX elements with props: <Input type="email" placeholder="..." />
2
+ (jsx_self_closing_element
3
+ name: (identifier) @el.tag
4
+ (jsx_attribute
5
+ (property_identifier) @el.prop.name
6
+ [(string (string_fragment) @el.prop.value.str)
7
+ (jsx_expression (_) @el.prop.value.expr)])) @el.self
8
+
9
+ ; Opening JSX elements with props: <Button variant="destructive">
10
+ (jsx_opening_element
11
+ name: (identifier) @el.tag
12
+ (jsx_attribute
13
+ (property_identifier) @el.prop.name
14
+ [(string (string_fragment) @el.prop.value.str)
15
+ (jsx_expression (_) @el.prop.value.expr)])) @el.open
16
+
17
+ ; JSX text content (direct text inside elements)
18
+ (jsx_element
19
+ (jsx_opening_element
20
+ name: (identifier) @el.text.tag)
21
+ (jsx_text) @el.text.content)
@@ -0,0 +1,24 @@
1
+ ; const { email, password } = await req.json()
2
+ (lexical_declaration
3
+ (variable_declarator
4
+ name: (object_pattern
5
+ (shorthand_property_identifier_pattern) @param.name)
6
+ value: (await_expression
7
+ (call_expression
8
+ function: (member_expression
9
+ object: (identifier) @_req
10
+ property: (property_identifier) @_method)
11
+ (#match? @_req "^(req|request)$")
12
+ (#eq? @_method "json")))))
13
+
14
+ ; const body = await req.json() (whole body capture)
15
+ (lexical_declaration
16
+ (variable_declarator
17
+ name: (identifier) @param.body
18
+ value: (await_expression
19
+ (call_expression
20
+ function: (member_expression
21
+ object: (identifier) @_req2
22
+ property: (property_identifier) @_method2)
23
+ (#match? @_req2 "^(req|request)$")
24
+ (#eq? @_method2 "json")))))
@@ -0,0 +1,26 @@
1
+ ; NextResponse.json(body, { status: N })
2
+ (call_expression
3
+ function: (member_expression
4
+ object: (identifier) @_nr
5
+ property: (property_identifier) @_json)
6
+ arguments: (arguments
7
+ (_) @resp.body
8
+ .
9
+ (object
10
+ (pair
11
+ key: (property_identifier) @_status_key
12
+ value: (number) @resp.status)))
13
+ (#eq? @_nr "NextResponse")
14
+ (#eq? @_json "json")
15
+ (#eq? @_status_key "status"))
16
+
17
+ ; NextResponse.json(body) — no explicit status (defaults to 200)
18
+ (call_expression
19
+ function: (member_expression
20
+ object: (identifier) @_nr2
21
+ property: (property_identifier) @_json2)
22
+ arguments: (arguments
23
+ .
24
+ (_) @resp.body.default)
25
+ (#eq? @_nr2 "NextResponse")
26
+ (#eq? @_json2 "json"))
@@ -0,0 +1,23 @@
1
+ ; useState with array destructuring: const [value, setValue] = useState(init)
2
+ (lexical_declaration
3
+ (variable_declarator
4
+ name: (array_pattern
5
+ (identifier) @hook.var
6
+ (identifier) @hook.setter)
7
+ value: (call_expression
8
+ function: (identifier) @hook.fn
9
+ arguments: (arguments . (_) @hook.init)
10
+ (#match? @hook.fn "^use[A-Z]"))))
11
+
12
+ ; useReducer: const [state, dispatch] = useReducer(reducer, init)
13
+ (lexical_declaration
14
+ (variable_declarator
15
+ name: (array_pattern
16
+ (identifier) @reducer.var
17
+ (identifier) @reducer.dispatch)
18
+ value: (call_expression
19
+ function: (identifier) @_useReducer
20
+ arguments: (arguments
21
+ (_) @reducer.fn
22
+ (_) @reducer.init)
23
+ (#eq? @_useReducer "useReducer"))))
@@ -0,0 +1,17 @@
1
+ ; const name = expression
2
+ (lexical_declaration
3
+ (variable_declarator
4
+ name: (identifier) @var.name
5
+ value: (_) @var.init)) @var.decl
6
+
7
+ ; Destructured object: const { a, b } = expression
8
+ (lexical_declaration
9
+ (variable_declarator
10
+ name: (object_pattern) @var.destructured.obj
11
+ value: (_) @var.destructured.init)) @var.destructured
12
+
13
+ ; Destructured array: const [a, b] = expression
14
+ (lexical_declaration
15
+ (variable_declarator
16
+ name: (array_pattern) @var.array.pattern
17
+ value: (_) @var.array.init)) @var.array
@@ -0,0 +1,66 @@
1
+ ; export default function Foo() {}
2
+ (export_statement
3
+ "default"
4
+ declaration: (function_declaration
5
+ name: (identifier) @export.default.func))
6
+
7
+ ; export default class Foo {}
8
+ (export_statement
9
+ "default"
10
+ declaration: (class_declaration
11
+ name: (type_identifier) @export.default.class))
12
+
13
+ ; export default <identifier>
14
+ (export_statement
15
+ "default"
16
+ value: (identifier) @export.default.value)
17
+
18
+ ; export function Foo() {}
19
+ (export_statement
20
+ declaration: (function_declaration
21
+ name: (identifier) @export.named.func))
22
+
23
+ ; export class Foo {}
24
+ (export_statement
25
+ declaration: (class_declaration
26
+ name: (type_identifier) @export.named.class))
27
+
28
+ ; export const Foo = ...
29
+ (export_statement
30
+ declaration: (lexical_declaration
31
+ (variable_declarator
32
+ name: (identifier) @export.named.const)))
33
+
34
+ ; export type Foo = ...
35
+ (export_statement
36
+ declaration: (type_alias_declaration
37
+ name: (type_identifier) @export.named.type))
38
+
39
+ ; export interface Foo {}
40
+ (export_statement
41
+ declaration: (interface_declaration
42
+ name: (type_identifier) @export.named.interface))
43
+
44
+ ; export enum Foo {}
45
+ (export_statement
46
+ declaration: (enum_declaration
47
+ name: (identifier) @export.named.enum))
48
+
49
+ ; export { A, B } from 'x' (re-exports with names)
50
+ (export_statement
51
+ (export_clause
52
+ (export_specifier
53
+ name: (identifier) @reexport.name))
54
+ source: (string (string_fragment) @reexport.source))
55
+
56
+ ; export * from 'x' (wildcard re-export — tree-sitter represents * as literal)
57
+ (export_statement
58
+ "*"
59
+ source: (string (string_fragment) @reexport.wildcard.source))
60
+
61
+ ; export { A, B } (bare named exports, no source)
62
+ (export_statement
63
+ (export_clause
64
+ (export_specifier
65
+ name: (identifier) @export.bare.name))
66
+ !source)
@@ -0,0 +1,57 @@
1
+ ; fetch('/api/foo')
2
+ (call_expression
3
+ function: (identifier) @_fetch
4
+ arguments: (arguments
5
+ .
6
+ (string (string_fragment) @fetch.url.literal))
7
+ (#eq? @_fetch "fetch"))
8
+
9
+ ; fetch(`/api/foo/${id}`)
10
+ (call_expression
11
+ function: (identifier) @_fetch2
12
+ arguments: (arguments
13
+ .
14
+ (template_string) @fetch.url.template)
15
+ (#eq? @_fetch2 "fetch"))
16
+
17
+ ; client.get('/api/foo') — direct call (no await, no type args)
18
+ (call_expression
19
+ function: (member_expression
20
+ object: (identifier) @fetch.client
21
+ property: (property_identifier) @fetch.method)
22
+ arguments: (arguments
23
+ .
24
+ (string (string_fragment) @fetch.client.url.literal))
25
+ (#match? @fetch.method "^(get|post|put|patch|delete|head|options)$"))
26
+
27
+ ; client.get(`/api/foo/${id}`) — template, direct call
28
+ (call_expression
29
+ function: (member_expression
30
+ object: (identifier) @fetch.client2
31
+ property: (property_identifier) @fetch.method.template)
32
+ arguments: (arguments
33
+ .
34
+ (template_string) @fetch.client.url.template)
35
+ (#match? @fetch.method.template "^(get|post|put|patch|delete|head|options)$"))
36
+
37
+ ; await client.post('/api/foo') — await wraps the member_expression
38
+ (call_expression
39
+ function: (await_expression
40
+ (member_expression
41
+ object: (identifier) @fetch.await.client
42
+ property: (property_identifier) @fetch.await.method))
43
+ arguments: (arguments
44
+ .
45
+ (string (string_fragment) @fetch.await.url.literal))
46
+ (#match? @fetch.await.method "^(get|post|put|patch|delete|head|options)$"))
47
+
48
+ ; await client.post(`/api/foo/${id}`) — await + template
49
+ (call_expression
50
+ function: (await_expression
51
+ (member_expression
52
+ object: (identifier) @fetch.await.client2
53
+ property: (property_identifier) @fetch.await.method.template))
54
+ arguments: (arguments
55
+ .
56
+ (template_string) @fetch.await.url.template)
57
+ (#match? @fetch.await.method.template "^(get|post|put|patch|delete|head|options)$"))
@@ -0,0 +1,14 @@
1
+ ; All import statements (used to find import nodes for direct AST walking)
2
+ (import_statement
3
+ source: (string (string_fragment) @import.source)) @import.statement
4
+
5
+ ; Type-only imports: import type { X } from 'x'
6
+ (import_statement
7
+ "type"
8
+ source: (string (string_fragment) @import.type_only_source)) @import.type_only
9
+
10
+ ; Dynamic imports: import('x')
11
+ (call_expression
12
+ function: (import)
13
+ arguments: (arguments
14
+ (string (string_fragment) @import.dynamic)))
@@ -0,0 +1,14 @@
1
+ ; JSX opening elements: <Foo ...>
2
+ (jsx_opening_element
3
+ name: (identifier) @jsx.tag)
4
+
5
+ ; JSX self-closing elements: <Foo ... />
6
+ (jsx_self_closing_element
7
+ name: (identifier) @jsx.tag)
8
+
9
+ ; JSX member expression elements: <Foo.Bar>
10
+ (jsx_opening_element
11
+ name: (member_expression) @jsx.member_tag)
12
+
13
+ (jsx_self_closing_element
14
+ name: (member_expression) @jsx.member_tag)
@@ -0,0 +1,85 @@
1
+ ; router.push('...')
2
+ (call_expression
3
+ function: (member_expression
4
+ object: (identifier) @_router
5
+ property: (property_identifier) @nav.method)
6
+ arguments: (arguments
7
+ .
8
+ (string (string_fragment) @nav.target.literal))
9
+ (#eq? @_router "router")
10
+ (#match? @nav.method "^(push|replace)$"))
11
+
12
+ ; router.push(`...`)
13
+ (call_expression
14
+ function: (member_expression
15
+ object: (identifier) @_router2
16
+ property: (property_identifier) @nav.method.template)
17
+ arguments: (arguments
18
+ .
19
+ (template_string) @nav.target.template)
20
+ (#eq? @_router2 "router")
21
+ (#match? @nav.method.template "^(push|replace)$"))
22
+
23
+ ; <Link href="..."> — scoped to Link elements only
24
+ (jsx_opening_element
25
+ name: (identifier) @_link_tag
26
+ attribute: (jsx_attribute
27
+ (property_identifier) @_href
28
+ (string (string_fragment) @nav.link.literal))
29
+ (#eq? @_link_tag "Link")
30
+ (#eq? @_href "href"))
31
+
32
+ ; <Link href="..."> — self-closing
33
+ (jsx_self_closing_element
34
+ name: (identifier) @_link_tag2
35
+ attribute: (jsx_attribute
36
+ (property_identifier) @_href2
37
+ (string (string_fragment) @nav.link.literal.self))
38
+ (#eq? @_link_tag2 "Link")
39
+ (#eq? @_href2 "href"))
40
+
41
+ ; <Link href={`...`}> — template
42
+ (jsx_opening_element
43
+ name: (identifier) @_link_tag3
44
+ attribute: (jsx_attribute
45
+ (property_identifier) @_href3
46
+ (jsx_expression
47
+ (template_string) @nav.link.template))
48
+ (#eq? @_link_tag3 "Link")
49
+ (#eq? @_href3 "href"))
50
+
51
+ ; <Link href={`...`}> — template, self-closing
52
+ (jsx_self_closing_element
53
+ name: (identifier) @_link_tag4
54
+ attribute: (jsx_attribute
55
+ (property_identifier) @_href4
56
+ (jsx_expression
57
+ (template_string) @nav.link.template.self))
58
+ (#eq? @_link_tag4 "Link")
59
+ (#eq? @_href4 "href"))
60
+
61
+ ; window.location.href = '...'
62
+ (assignment_expression
63
+ left: (member_expression
64
+ object: (member_expression
65
+ object: (identifier) @_win
66
+ property: (property_identifier) @_loc)
67
+ property: (property_identifier) @_href5)
68
+ right: (string (string_fragment) @nav.window.literal)
69
+ (#eq? @_win "window")
70
+ (#eq? @_loc "location")
71
+ (#eq? @_href5 "href"))
72
+
73
+ ; window.location.assign('...')
74
+ (call_expression
75
+ function: (member_expression
76
+ object: (member_expression
77
+ object: (identifier) @_win2
78
+ property: (property_identifier) @_loc2)
79
+ property: (property_identifier) @nav.window.method)
80
+ arguments: (arguments
81
+ .
82
+ (string (string_fragment) @nav.window.assign.target))
83
+ (#eq? @_win2 "window")
84
+ (#eq? @_loc2 "location")
85
+ (#match? @nav.window.method "^(assign|replace)$"))
@@ -0,0 +1,8 @@
1
+ ; export const GET = withAuth(async (req) => { ... })
2
+ ; Captures any function wrapping an exported const
3
+ (export_statement
4
+ declaration: (lexical_declaration
5
+ (variable_declarator
6
+ name: (identifier) @wrapper.export_name
7
+ value: (call_expression
8
+ function: (identifier) @wrapper.fn_name))))