@spry-cli/decorators 0.0.1

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 ADDED
@@ -0,0 +1,99 @@
1
+ # @spry-cli/decorators
2
+
3
+ TypeScript decorators for defining [Spry](https://github.com/MerseniBilel/spry) repository contracts. Annotate an abstract class with HTTP verbs and parameter bindings, then let the Spry CLI generate your entire data layer, use cases, and state management.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @spry-cli/decorators
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import {
15
+ BaseURL,
16
+ GET,
17
+ POST,
18
+ PATCH,
19
+ DELETE,
20
+ Param,
21
+ Query,
22
+ Body,
23
+ Cache,
24
+ Paginated,
25
+ } from '@spry-cli/decorators'
26
+
27
+ @BaseURL('/api/v1')
28
+ export abstract class ProfileRepository {
29
+ @GET('/profile/:userId')
30
+ @Cache(60)
31
+ abstract getProfile(@Param('userId') userId: string): Promise<UserProfile>
32
+
33
+ @GET('/profiles')
34
+ @Paginated()
35
+ abstract getProfiles(@Query('page') page: number): Promise<PaginatedResult<UserProfile>>
36
+
37
+ @POST('/profile')
38
+ abstract createProfile(@Body() input: CreateProfileInput): Promise<UserProfile>
39
+
40
+ @PATCH('/profile/:userId')
41
+ abstract updateProfile(
42
+ @Param('userId') userId: string,
43
+ @Body() input: UpdateProfileInput
44
+ ): Promise<UserProfile>
45
+
46
+ @DELETE('/profile/:userId')
47
+ abstract deleteProfile(@Param('userId') userId: string): Promise<void>
48
+ }
49
+ ```
50
+
51
+ Then run:
52
+
53
+ ```bash
54
+ spry build profile
55
+ ```
56
+
57
+ Spry reads these decorators statically via the TypeScript AST — no runtime reflection or `reflect-metadata` required.
58
+
59
+ ## API Reference
60
+
61
+ ### Class Decorator
62
+
63
+ | Decorator | Description |
64
+ |-----------|-------------|
65
+ | `@BaseURL(url)` | Base path prepended to all method paths |
66
+
67
+ ### Method Decorators (HTTP Verbs)
68
+
69
+ | Decorator | Description |
70
+ |-----------|-------------|
71
+ | `@GET(path)` | HTTP GET request |
72
+ | `@POST(path)` | HTTP POST request |
73
+ | `@PATCH(path)` | HTTP PATCH request |
74
+ | `@PUT(path)` | HTTP PUT request |
75
+ | `@DELETE(path)` | HTTP DELETE request |
76
+
77
+ ### Method Decorators (Extras)
78
+
79
+ | Decorator | Description |
80
+ |-----------|-------------|
81
+ | `@Cache(seconds)` | Sets `staleTime` in generated React Query hooks |
82
+ | `@Paginated()` | Generates `useInfiniteQuery` instead of `useQuery` |
83
+
84
+ ### Parameter Decorators
85
+
86
+ | Decorator | Description |
87
+ |-----------|-------------|
88
+ | `@Param(name)` | Path parameter (e.g., `:userId`) |
89
+ | `@Query(name)` | Query string parameter (e.g., `?page=1`) |
90
+ | `@Body()` | Request body |
91
+ | `@Header(name)` | Request header |
92
+
93
+ ## How It Works
94
+
95
+ These decorators are intentionally no-op at runtime — they simply return the original descriptor/target unchanged. The Spry CLI uses [ts-morph](https://ts-morph.com/) to read decorator metadata directly from the AST at build time, so there is zero runtime overhead.
96
+
97
+ ## License
98
+
99
+ MIT
@@ -0,0 +1,13 @@
1
+ export declare function GET(_path: string): MethodDecorator;
2
+ export declare function POST(_path: string): MethodDecorator;
3
+ export declare function PATCH(_path: string): MethodDecorator;
4
+ export declare function PUT(_path: string): MethodDecorator;
5
+ export declare function DELETE(_path: string): MethodDecorator;
6
+ export declare function Param(_name: string): ParameterDecorator;
7
+ export declare function Query(_name: string): ParameterDecorator;
8
+ export declare function Body(): ParameterDecorator;
9
+ export declare function Header(_name: string): ParameterDecorator;
10
+ export declare function BaseURL(_url: string): ClassDecorator;
11
+ export declare function Cache(_seconds: number): MethodDecorator;
12
+ export declare function Paginated(): MethodDecorator;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAElD;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAEnD;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAEpD;AAED,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAElD;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAErD;AAGD,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,CAEvD;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,CAEvD;AAED,wBAAgB,IAAI,IAAI,kBAAkB,CAEzC;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,CAExD;AAGD,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAEpD;AAGD,wBAAgB,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAEvD;AAED,wBAAgB,SAAS,IAAI,eAAe,CAE3C"}
package/dist/index.js ADDED
@@ -0,0 +1,41 @@
1
+ // Method decorators — HTTP verb + path
2
+ export function GET(_path) {
3
+ return (_target, _propertyKey, descriptor) => descriptor;
4
+ }
5
+ export function POST(_path) {
6
+ return (_target, _propertyKey, descriptor) => descriptor;
7
+ }
8
+ export function PATCH(_path) {
9
+ return (_target, _propertyKey, descriptor) => descriptor;
10
+ }
11
+ export function PUT(_path) {
12
+ return (_target, _propertyKey, descriptor) => descriptor;
13
+ }
14
+ export function DELETE(_path) {
15
+ return (_target, _propertyKey, descriptor) => descriptor;
16
+ }
17
+ // Parameter decorators
18
+ export function Param(_name) {
19
+ return () => { };
20
+ }
21
+ export function Query(_name) {
22
+ return () => { };
23
+ }
24
+ export function Body() {
25
+ return () => { };
26
+ }
27
+ export function Header(_name) {
28
+ return () => { };
29
+ }
30
+ // Class decorator
31
+ export function BaseURL(_url) {
32
+ return (target) => target;
33
+ }
34
+ // Extra method decorators
35
+ export function Cache(_seconds) {
36
+ return (_target, _propertyKey, descriptor) => descriptor;
37
+ }
38
+ export function Paginated() {
39
+ return (_target, _propertyKey, descriptor) => descriptor;
40
+ }
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,MAAM,UAAU,GAAG,CAAC,KAAa;IAC/B,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,CAAA;AAC1D,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,KAAa;IAChC,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,CAAA;AAC1D,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,CAAA;AAC1D,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,KAAa;IAC/B,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,CAAA;AAC1D,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,KAAa;IAClC,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,CAAA;AAC1D,CAAC;AAED,uBAAuB;AACvB,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;AACjB,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;AACjB,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;AACjB,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,KAAa;IAClC,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;AACjB,CAAC;AAED,kBAAkB;AAClB,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAA;AAC3B,CAAC;AAED,0BAA0B;AAC1B,MAAM,UAAU,KAAK,CAAC,QAAgB;IACpC,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,CAAA;AAC1D,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,CAAA;AAC1D,CAAC"}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@spry-cli/decorators",
3
+ "version": "0.0.1",
4
+ "description": "TypeScript decorators for defining Spry repository contracts",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/MerseniBilel/spry.git",
21
+ "directory": "packages/decorators"
22
+ },
23
+ "keywords": [
24
+ "spry",
25
+ "decorators",
26
+ "react-native",
27
+ "expo",
28
+ "clean-architecture",
29
+ "typescript",
30
+ "code-generation"
31
+ ],
32
+ "scripts": {
33
+ "build": "tsc",
34
+ "lint": "eslint src/"
35
+ },
36
+ "devDependencies": {
37
+ "eslint": "10.2.0",
38
+ "typescript": "5.8.3"
39
+ }
40
+ }