lombok-typescript 0.1.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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +98 -0
  3. package/dist/backend-CkLBcDd8.d.cts +59 -0
  4. package/dist/backend-CkLBcDd8.d.ts +59 -0
  5. package/dist/cli/index.cjs +585 -0
  6. package/dist/cli/index.cjs.map +1 -0
  7. package/dist/cli/index.d.cts +14 -0
  8. package/dist/cli/index.d.ts +14 -0
  9. package/dist/cli/index.js +579 -0
  10. package/dist/cli/index.js.map +1 -0
  11. package/dist/codegen/index.cjs +450 -0
  12. package/dist/codegen/index.cjs.map +1 -0
  13. package/dist/codegen/index.d.cts +109 -0
  14. package/dist/codegen/index.d.ts +109 -0
  15. package/dist/codegen/index.js +443 -0
  16. package/dist/codegen/index.js.map +1 -0
  17. package/dist/core/index.cjs +132 -0
  18. package/dist/core/index.cjs.map +1 -0
  19. package/dist/core/index.d.cts +73 -0
  20. package/dist/core/index.d.ts +73 -0
  21. package/dist/core/index.js +128 -0
  22. package/dist/core/index.js.map +1 -0
  23. package/dist/index.cjs +142 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.cts +93 -0
  26. package/dist/index.d.ts +93 -0
  27. package/dist/index.js +136 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/legacy/index.cjs +271 -0
  30. package/dist/legacy/index.cjs.map +1 -0
  31. package/dist/legacy/index.d.cts +32 -0
  32. package/dist/legacy/index.d.ts +32 -0
  33. package/dist/legacy/index.js +252 -0
  34. package/dist/legacy/index.js.map +1 -0
  35. package/dist/memoize-Bj9pm_cK.d.cts +48 -0
  36. package/dist/memoize-DvelzGDl.d.ts +48 -0
  37. package/dist/stage3/index.cjs +275 -0
  38. package/dist/stage3/index.cjs.map +1 -0
  39. package/dist/stage3/index.d.cts +97 -0
  40. package/dist/stage3/index.d.ts +97 -0
  41. package/dist/stage3/index.js +255 -0
  42. package/dist/stage3/index.js.map +1 -0
  43. package/package.json +120 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 lombok-typescript contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # lombok-typescript
2
+
3
+ [![CI](https://github.com/A-Dev-Kit/lombok-typescript/actions/workflows/ci.yml/badge.svg)](https://github.com/A-Dev-Kit/lombok-typescript/actions/workflows/ci.yml)
4
+ [![Docs](https://github.com/A-Dev-Kit/lombok-typescript/actions/workflows/docs.yml/badge.svg)](https://a-dev-kit.github.io/lombok-typescript/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
6
+ [![npm version](https://img.shields.io/npm/v/lombok-typescript.svg?label=npm)](https://www.npmjs.com/package/lombok-typescript)
7
+ [![coverage](https://img.shields.io/codecov/c/github/A-Dev-Kit/lombok-typescript/main?label=coverage)](https://codecov.io/gh/A-Dev-Kit/lombok-typescript)
8
+ [![Node](https://img.shields.io/badge/node-%E2%89%A522-brightgreen)](https://nodejs.org/)
9
+ [![TypeScript](https://img.shields.io/badge/TypeScript-%E2%89%A55.0-blue?logo=typescript)](https://www.typescriptlang.org/)
10
+
11
+ A TypeScript port of Java's [Project Lombok](https://projectlombok.org/) with Gang-of-Four design patterns as decorators. Legacy `experimentalDecorators` and Stage 3 ECMAScript decorators are supported side-by-side.
12
+
13
+ ## Status
14
+
15
+ **Version `0.1.0` — code-complete, not on npm yet.** Batch publish is deferred until the full release queue is ready. See [CHANGELOG.md](./CHANGELOG.md).
16
+
17
+ Phase 1 decorators are implemented: `@NonNull`, `@ToString`, `@Builder`, `@Data`, `@Singleton`, `@Prototype`, `@Factory`, `@Memoize`.
18
+
19
+ Documentation site: [a-dev-kit.github.io/lombok-typescript](https://a-dev-kit.github.io/lombok-typescript/) (after GitHub Pages deploy).
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ # Not on npm yet — clone and link locally:
25
+ git clone https://github.com/A-Dev-Kit/lombok-typescript.git
26
+ cd lombok-typescript && pnpm install && pnpm build && pnpm link --global
27
+
28
+ # When published (preview tag):
29
+ npm install lombok-typescript@preview
30
+ ```
31
+
32
+ ## Pick a decorator standard
33
+
34
+ ### Legacy (`lombok-typescript/legacy`)
35
+
36
+ For NestJS, TypeORM, and most existing decorator-based projects.
37
+
38
+ ```jsonc
39
+ { "compilerOptions": { "experimentalDecorators": true, "emitDecoratorMetadata": true } }
40
+ ```
41
+
42
+ ### Stage 3 (`lombok-typescript/stage3`)
43
+
44
+ For TS 5.0+ projects without `experimentalDecorators`.
45
+
46
+ ```jsonc
47
+ { "compilerOptions": { "experimentalDecorators": false } }
48
+ ```
49
+
50
+ ## Quick start
51
+
52
+ ```bash
53
+ npx lombok-ts init
54
+ npx lombok-ts generate
55
+ ```
56
+
57
+ ```ts
58
+ import { Data, Builder, NonNull, Memoize, Singleton } from 'lombok-typescript/legacy';
59
+
60
+ @Data
61
+ @Builder
62
+ class User {
63
+ @NonNull name!: string;
64
+ age!: number;
65
+ }
66
+
67
+ @Singleton
68
+ class Cache {
69
+ @Memoize()
70
+ get(key: string) {
71
+ return key;
72
+ }
73
+ }
74
+ ```
75
+
76
+ After codegen, import and call `applyAllGenerated` from the `.lombok/` companion file. See [docs-site/guide/getting-started.md](./docs-site/guide/getting-started.md).
77
+
78
+ ## CLI
79
+
80
+ | Command | Description |
81
+ | -------------------- | --------------------------------------------- |
82
+ | `lombok-ts generate` | Emit `.lombok.ts` + `.lombok.d.ts` companions |
83
+ | `lombok-ts init` | Create `lombok.config.ts` |
84
+ | `lombok-ts clean` | Remove `.lombok/`, `dist/`, `coverage/` |
85
+ | `lombok-ts watch` | Phase 2 stub |
86
+
87
+ ## Examples
88
+
89
+ - [examples/plain-ts](./examples/plain-ts/) — legacy backend + codegen
90
+ - [examples/nestjs](./examples/nestjs/) — `@Injectable()` with `@Singleton`, `@Factory`, `@Memoize`
91
+
92
+ ## Contributing
93
+
94
+ See [CONTRIBUTING.md](./CONTRIBUTING.md). Tests require **95%+** coverage on changed code.
95
+
96
+ ## License
97
+
98
+ [MIT](./LICENSE)
@@ -0,0 +1,59 @@
1
+ /** Decorator target kind. */
2
+ type DecoratorKind = 'class' | 'field' | 'method' | 'getter' | 'setter' | 'parameter';
3
+ /** Which decorator standard a backend implements. */
4
+ type BackendKind = 'legacy' | 'stage3';
5
+ /** Property identifier (string or symbol). */
6
+ type PropertyName = string | symbol;
7
+ /** Where metadata sits. `propertyKey` undefined means class-level. */
8
+ interface MetadataScope {
9
+ readonly target: object;
10
+ readonly propertyKey?: PropertyName;
11
+ }
12
+ /** Returned from `MetadataStore.list()`. */
13
+ type MetadataKeyList = readonly string[];
14
+
15
+ /**
16
+ * Storage interface used by both decorator backends. Legacy delegates to
17
+ * `reflect-metadata`; Stage 3 uses the WeakMap implementation below.
18
+ */
19
+ interface MetadataStore {
20
+ /** Store `value` under `key`. Omit `propertyKey` for class-level scope. */
21
+ set<V>(key: string, target: object, propertyKey: PropertyName | undefined, value: V): void;
22
+ /** Read the value stored under `key`, or `undefined`. */
23
+ get<V>(key: string, target: object, propertyKey?: PropertyName): V | undefined;
24
+ /** True if `key` exists at the given scope. */
25
+ has(key: string, target: object, propertyKey?: PropertyName): boolean;
26
+ /** Remove the entry. Returns true if it existed. */
27
+ delete(key: string, target: object, propertyKey?: PropertyName): boolean;
28
+ /** All keys at the given scope. */
29
+ list(target: object, propertyKey?: PropertyName): MetadataKeyList;
30
+ }
31
+ /**
32
+ * WeakMap-backed `MetadataStore`. Used directly by the Stage 3 backend.
33
+ * Layout: target -> (propertyKey or class-level) -> key -> value.
34
+ */
35
+ declare class WeakMapMetadataStore implements MetadataStore {
36
+ private readonly classScopes;
37
+ private readonly memberScopes;
38
+ set<V>(key: string, target: object, propertyKey: PropertyName | undefined, value: V): void;
39
+ get<V>(key: string, target: object, propertyKey?: PropertyName): V | undefined;
40
+ has(key: string, target: object, propertyKey?: PropertyName): boolean;
41
+ delete(key: string, target: object, propertyKey?: PropertyName): boolean;
42
+ list(target: object, propertyKey?: PropertyName): MetadataKeyList;
43
+ private bucket;
44
+ }
45
+
46
+ /**
47
+ * Abstraction over a TypeScript decorator standard.
48
+ *
49
+ * Two implementations: `LegacyBackend` (wraps `reflect-metadata` for
50
+ * `experimentalDecorators`) and `Stage3Backend` (uses `Symbol.metadata`).
51
+ * Decorator authors target this interface so the same logic can be exposed
52
+ * under both standards.
53
+ */
54
+ interface Backend {
55
+ readonly kind: BackendKind;
56
+ readonly metadata: MetadataStore;
57
+ }
58
+
59
+ export { type BackendKind as B, type DecoratorKind as D, type MetadataStore as M, type PropertyName as P, WeakMapMetadataStore as W, type Backend as a, type MetadataKeyList as b, type MetadataScope as c };
@@ -0,0 +1,59 @@
1
+ /** Decorator target kind. */
2
+ type DecoratorKind = 'class' | 'field' | 'method' | 'getter' | 'setter' | 'parameter';
3
+ /** Which decorator standard a backend implements. */
4
+ type BackendKind = 'legacy' | 'stage3';
5
+ /** Property identifier (string or symbol). */
6
+ type PropertyName = string | symbol;
7
+ /** Where metadata sits. `propertyKey` undefined means class-level. */
8
+ interface MetadataScope {
9
+ readonly target: object;
10
+ readonly propertyKey?: PropertyName;
11
+ }
12
+ /** Returned from `MetadataStore.list()`. */
13
+ type MetadataKeyList = readonly string[];
14
+
15
+ /**
16
+ * Storage interface used by both decorator backends. Legacy delegates to
17
+ * `reflect-metadata`; Stage 3 uses the WeakMap implementation below.
18
+ */
19
+ interface MetadataStore {
20
+ /** Store `value` under `key`. Omit `propertyKey` for class-level scope. */
21
+ set<V>(key: string, target: object, propertyKey: PropertyName | undefined, value: V): void;
22
+ /** Read the value stored under `key`, or `undefined`. */
23
+ get<V>(key: string, target: object, propertyKey?: PropertyName): V | undefined;
24
+ /** True if `key` exists at the given scope. */
25
+ has(key: string, target: object, propertyKey?: PropertyName): boolean;
26
+ /** Remove the entry. Returns true if it existed. */
27
+ delete(key: string, target: object, propertyKey?: PropertyName): boolean;
28
+ /** All keys at the given scope. */
29
+ list(target: object, propertyKey?: PropertyName): MetadataKeyList;
30
+ }
31
+ /**
32
+ * WeakMap-backed `MetadataStore`. Used directly by the Stage 3 backend.
33
+ * Layout: target -> (propertyKey or class-level) -> key -> value.
34
+ */
35
+ declare class WeakMapMetadataStore implements MetadataStore {
36
+ private readonly classScopes;
37
+ private readonly memberScopes;
38
+ set<V>(key: string, target: object, propertyKey: PropertyName | undefined, value: V): void;
39
+ get<V>(key: string, target: object, propertyKey?: PropertyName): V | undefined;
40
+ has(key: string, target: object, propertyKey?: PropertyName): boolean;
41
+ delete(key: string, target: object, propertyKey?: PropertyName): boolean;
42
+ list(target: object, propertyKey?: PropertyName): MetadataKeyList;
43
+ private bucket;
44
+ }
45
+
46
+ /**
47
+ * Abstraction over a TypeScript decorator standard.
48
+ *
49
+ * Two implementations: `LegacyBackend` (wraps `reflect-metadata` for
50
+ * `experimentalDecorators`) and `Stage3Backend` (uses `Symbol.metadata`).
51
+ * Decorator authors target this interface so the same logic can be exposed
52
+ * under both standards.
53
+ */
54
+ interface Backend {
55
+ readonly kind: BackendKind;
56
+ readonly metadata: MetadataStore;
57
+ }
58
+
59
+ export { type BackendKind as B, type DecoratorKind as D, type MetadataStore as M, type PropertyName as P, WeakMapMetadataStore as W, type Backend as a, type MetadataKeyList as b, type MetadataScope as c };