@chaim-tools/chaim 0.1.4 → 0.1.6

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 CHANGED
@@ -1,110 +1,146 @@
1
1
  # chaim-cli
2
2
 
3
- A **schema-driven code generation tool** that transforms `.bprint` schema snapshots into complete SDKs with DynamoDB Mapper clients, DTOs, and configuration management. Currently supports **Java** (default), with more languages coming soon.
3
+ The command-line tool that generates type-safe Java SDKs from your DynamoDB schema snapshots. It reads the local snapshots produced by `chaim-cdk`, groups entities by table, validates key consistency, and invokes the Java code generator to produce ready-to-use entity classes, repositories, validators, and configuration.
4
4
 
5
- ## Prerequisite
5
+ **npm**: [`@chaim-tools/chaim`](https://www.npmjs.com/package/@chaim-tools/chaim)
6
6
 
7
- > **IMPORTANT**: You must run `cdk synth` or `cdk deploy` in your CDK project before using this CLI.
7
+ ## Where This Fits
8
+
9
+ ```
10
+ .bprint file ──> chaim-cdk ──> chaim-cli ──> chaim-client-java
11
+ ^ │
12
+ │ v
13
+ YOU RUN THIS Generated Java SDK
14
+ ```
15
+
16
+ The CLI sits between the CDK construct and the code generator. It discovers cached snapshots from your file system, resolves table metadata (including GSIs and LSIs), and delegates to `chaim-client-java` for Java source file generation. The generated code supports all `.bprint` field types including recursive nesting (maps within maps, lists of maps within maps) with no depth limit.
17
+
18
+ ## Installation
8
19
 
9
20
  ```bash
10
- # In your CDK project directory
11
- cdk synth # Creates LOCAL snapshot in OS cache
12
- # OR
13
- cdk deploy # Creates LOCAL snapshot + publishes to Chaim SaaS
21
+ npm install -g @chaim-tools/chaim
14
22
  ```
15
23
 
16
- The CLI reads snapshot files from the **OS cache** (`~/.chaim/cache/snapshots/`) produced by [chaim-cdk](https://github.com/chaim-tools/chaim-cdk). You can run the CLI from **any directory**.
24
+ **Requirements**: Node.js 18+, Java 11+ (runtime for code generation)
17
25
 
18
26
  ## Quick Start
19
27
 
20
28
  ```bash
21
- # 1. In your CDK project, create a snapshot
29
+ # 1. Synthesize your CDK project to create a local snapshot
22
30
  cd my-cdk-project
23
31
  cdk synth
24
32
 
25
- # 2. Generate SDK (run from your Java application directory)
26
- cd my-java-app
33
+ # 2. Generate the Java SDK (run from your Java application directory)
34
+ cd ../my-java-app
27
35
  chaim generate --package com.mycompany.myapp.model
28
36
 
29
- # That's it! Your Java SDK is ready in ./src/main/java/
37
+ # Your Java SDK is now in ./src/main/java/
30
38
  ```
31
39
 
32
- ## Installation
40
+ The CLI reads snapshots from the OS cache (`~/.chaim/cache/snapshots/`). You can run it from any directory.
41
+
42
+ ## CDK Prerequisites
43
+
44
+ Before running `chaim generate`, your CDK project must produce valid snapshots via `cdk synth`. The CDK construct enforces two important safeguards:
45
+
46
+ - **Field reference validation** — All DynamoDB key attributes (table PK/SK, GSI/LSI keys, TTL attribute) must exist as fields in the `.bprint` schema. Mismatches fail the CDK synth immediately with a descriptive error.
47
+ - **Strict failure mode** — Deployment defaults to `STRICT`, meaning ingestion failures cause CloudFormation rollback. Use `FailureMode.BEST_EFFORT` explicitly if you want deployment to continue on ingestion errors.
48
+
49
+ ## Commands
50
+
51
+ ### `chaim generate`
52
+
53
+ Generates Java SDK code from local snapshots.
33
54
 
34
55
  ```bash
35
- npm install -g @chaim-tools/chaim
56
+ chaim generate --package com.mycompany.myapp.model
36
57
  ```
37
58
 
38
- ## System Requirements
59
+ | Option | Required | Default | Description |
60
+ |--------|----------|---------|-------------|
61
+ | `--package <name>` | Yes | — | Java package name (e.g., `com.mycompany.myapp.model`) |
62
+ | `-l, --language <lang>` | No | `java` | Target language |
63
+ | `--output <dir>` | No | `./src/main/java` | Output directory |
64
+ | `--stack <name>` | No | — | Filter snapshots by CDK stack name |
65
+ | `--snapshot-dir <path>` | No | OS cache | Override snapshot directory |
66
+ | `--skip-checks` | No | `false` | Skip environment validation |
67
+
68
+ **What it does**:
39
69
 
40
- Run `chaim doctor` to verify your environment:
70
+ 1. Scans the OS cache for snapshot files produced by `chaim-cdk`
71
+ 2. Filters by stack name (if provided) and discards DELETE-action snapshots
72
+ 3. Groups entities by physical DynamoDB table (using table ARN or composite key)
73
+ 4. Validates that all entities sharing a table have matching partition/sort key field names
74
+ 5. Detects field name collisions from `nameOverride` or auto-conversion
75
+ 6. Passes schemas and table metadata (including GSI/LSI definitions) to the Java generator. LSI metadata does not include `partitionKey` — the generator uses the table's own partition key since LSIs always share it
76
+ 7. Writes generated `.java` files to the output directory
77
+
78
+ ### `chaim validate`
79
+
80
+ Validates a `.bprint` schema file and displays the field mapping table.
41
81
 
42
82
  ```bash
43
- chaim doctor
83
+ chaim validate ./schemas/user.bprint
44
84
  ```
45
85
 
46
- **Required:**
47
- - Node.js v18+
48
- - Java 11+ (for code generation)
49
- - AWS CLI (configured)
86
+ ### `chaim doctor`
50
87
 
51
- ## CLI Commands
52
-
53
- ### Generate SDK
88
+ Checks your system environment for required dependencies.
54
89
 
55
90
  ```bash
56
- # Generate all entities from snapshots (defaults to Java)
57
- chaim generate --package com.mycompany.myapp.model
91
+ chaim doctor
92
+ ```
58
93
 
59
- # Explicitly specify language
60
- chaim generate --package com.mycompany.myapp.model --language java
94
+ Verifies: Node.js version, Java installation, AWS CLI availability.
61
95
 
62
- # Filter by CDK stack name
63
- chaim generate --package com.mycompany.myapp.model --stack MyStack
96
+ ### `chaim init`
64
97
 
65
- # Custom output directory
66
- chaim generate --package com.mycompany.myapp.model --output ./generated
98
+ Verifies and optionally installs prerequisites.
67
99
 
68
- # Skip environment checks
69
- chaim generate --package com.mycompany.myapp.model --skip-checks
100
+ ```bash
101
+ chaim init # Verify only
102
+ chaim init --install # Install missing dependencies
70
103
  ```
71
104
 
72
- **Options:**
105
+ ### `chaim bump`
73
106
 
74
- | Option | Required | Description | Default |
75
- |--------|----------|-------------|---------|
76
- | `--package` | **Yes** | Package name (e.g., `com.mycompany.myapp.model` for Java) | - |
77
- | `-l, --language` | No | Target language for code generation | java |
78
- | `--output` | No | Output directory | ./src/main/java |
79
- | `--stack` | No | Filter by CDK stack name | - |
80
- | `--snapshot-dir` | No | Override snapshot directory | OS cache |
81
- | `--skip-checks` | No | Skip environment checks | false |
107
+ Increments the `schemaVersion` in a `.bprint` file.
82
108
 
83
- **Supported Languages:**
84
- - `java` (default) generates Java DTOs, ChaimConfig, and ChaimMapperClient
109
+ ```bash
110
+ chaim bump ./schemas/user.bprint # minor bump: 1.3 -> 1.4
111
+ chaim bump ./schemas/user.bprint --major # major bump: 1.3 -> 2.0
112
+ ```
85
113
 
86
- ### Other Commands
114
+ | Option | Required | Default | Description |
115
+ |--------|----------|---------|-------------|
116
+ | `<schemaFile>` | Yes | — | Path to the `.bprint` file |
117
+ | `--major` | No | `false` | Major version bump instead of minor |
87
118
 
88
- ```bash
89
- # Verify prerequisites
90
- chaim init
119
+ The `schemaVersion` is a customer-controlled field. The Chaim system validates during `cdk deploy` that the version was bumped when schema content changes. Use this command to increment the version before deploying.
91
120
 
92
- # Validate a schema file
93
- chaim validate ./schemas/user.bprint
121
+ ### `chaim clean`
94
122
 
95
- # Check environment health
96
- chaim doctor
123
+ Prunes old or stack-specific snapshots from the local cache.
124
+
125
+ ```bash
126
+ chaim clean --all # Remove all snapshots
127
+ chaim clean --stack MyStack # Remove snapshots for a specific stack
128
+ chaim clean --older-than 30 # Remove snapshots older than 30 days
129
+ chaim clean --dry-run # Show what would be deleted
97
130
  ```
98
131
 
99
132
  ## Snapshot Locations
100
133
 
101
- Snapshots are stored in a **global OS cache**, allowing the CLI to work from any directory.
134
+ The CLI reads from the global OS cache, so it works regardless of your current directory.
102
135
 
103
- **Default locations:**
104
- - macOS/Linux: `~/.chaim/cache/snapshots/`
105
- - Windows: `%LOCALAPPDATA%/chaim/cache/snapshots/`
136
+ | OS | Default Path |
137
+ |----|--------------|
138
+ | macOS / Linux | `~/.chaim/cache/snapshots/` |
139
+ | Windows | `%LOCALAPPDATA%/chaim/cache/snapshots/` |
106
140
 
107
- **Directory structure:**
141
+ Override with `CHAIM_SNAPSHOT_DIR` or `--snapshot-dir`.
142
+
143
+ Directory structure:
108
144
  ```
109
145
  ~/.chaim/cache/snapshots/
110
146
  └── aws/
@@ -115,97 +151,306 @@ Snapshots are stored in a **global OS cache**, allowing the CLI to work from any
115
151
  └── {resourceId}.json
116
152
  ```
117
153
 
118
- ## Error: No Snapshot Found
154
+ ## Generated Output
155
+
156
+ For a package `com.example.model` with `User` and `Order` entities on the same table:
157
+
158
+ ```
159
+ src/main/java/com/example/model/
160
+ ├── User.java # Entity DTO (@DynamoDbBean + Lombok)
161
+ ├── Order.java # Entity DTO
162
+ ├── keys/
163
+ │ ├── UserKeys.java # Key constants, INDEX_ constants, key() helper
164
+ │ └── OrderKeys.java
165
+ ├── repository/
166
+ │ ├── UserRepository.java # save(), findByKey(), deleteByKey(), queryBy{Index}()
167
+ │ └── OrderRepository.java
168
+ ├── validation/
169
+ │ ├── UserValidator.java # Required, constraint, and enum checks
170
+ │ ├── OrderValidator.java
171
+ │ └── ChaimValidationException.java # Structured validation errors
172
+ ├── client/
173
+ │ └── ChaimDynamoDbClient.java # DI-friendly DynamoDB client wrapper
174
+ └── config/
175
+ └── ChaimConfig.java # Table constants, lazy client, repository factories
176
+ ```
177
+
178
+ ## Field Type Mappings
179
+
180
+ | .bprint Type | Java Type | Notes |
181
+ |--------------|-----------|-------|
182
+ | `string` | `String` | |
183
+ | `number` | `Double` | |
184
+ | `boolean` | `Boolean` | |
185
+ | `timestamp` | `Instant` | `java.time.Instant` |
186
+ | `list` (scalar) | `List<String>`, `List<Double>`, etc. | Parameterized by `items.type` |
187
+ | `list` (map) | `List<{FieldName}Item>` | Inner `@DynamoDbBean` class |
188
+ | `map` | `{FieldName}` (inner class) | Inner `@DynamoDbBean` class; supports recursive nesting |
189
+ | `stringSet` | `Set<String>` | |
190
+ | `numberSet` | `Set<Double>` | |
191
+
192
+ Recursive nesting is fully supported. A `map` field can contain nested `map` or `list` fields, which generate further inner static classes. There is no hardcoded depth limit — the database itself is the guardrail.
193
+
194
+ ## Using the Generated Code
195
+
196
+ ### Add Dependencies to Your Java Project
197
+
198
+ The generated code requires these dependencies (Gradle example):
199
+
200
+ ```kotlin
201
+ dependencies {
202
+ implementation("software.amazon.awssdk:dynamodb-enhanced:2.21.+")
203
+ compileOnly("org.projectlombok:lombok:1.18.+")
204
+ annotationProcessor("org.projectlombok:lombok:1.18.+")
205
+ }
206
+ ```
207
+
208
+ ### Basic Usage
209
+
210
+ ```java
211
+ // Use the generated config for a singleton client
212
+ UserRepository users = ChaimConfig.userRepository();
213
+
214
+ // Save an entity (validates constraints automatically)
215
+ User user = User.builder()
216
+ .userId("user-123")
217
+ .email("alice@example.com")
218
+ .isActive(true)
219
+ .build();
220
+ users.save(user);
221
+
222
+ // Find by key
223
+ Optional<User> found = users.findByKey("user-123");
224
+
225
+ // Delete
226
+ users.deleteByKey("user-123");
227
+ ```
228
+
229
+ ### GSI/LSI Queries
230
+
231
+ The generator produces typed query methods for every GSI and LSI on the table. Each index generates a PK-only method and a PK+SK overloaded method (when the index has a sort key).
232
+
233
+ ```java
234
+ OrderRepository orders = ChaimConfig.orderRepository();
235
+
236
+ // GSI query — uses the GSI's own partition key
237
+ List<Order> customerOrders = orders.queryByCustomerIndex("customer-123");
238
+
239
+ // GSI query with sort key — PK + SK overload
240
+ List<Order> filtered = orders.queryByCustomerDateIndex("customer-123", "2024-01-15");
241
+
242
+ // LSI query — uses the table's partition key (LSIs always share it)
243
+ List<Order> sorted = orders.queryByAmountIndex("order-456");
244
+ List<Order> ranged = orders.queryByAmountIndex("order-456", "100.00");
245
+ ```
246
+
247
+ ### Custom Client (Local DynamoDB, Testing)
248
+
249
+ ```java
250
+ ChaimDynamoDbClient client = ChaimConfig.clientBuilder()
251
+ .endpoint("http://localhost:8000")
252
+ .build();
253
+ UserRepository users = ChaimConfig.userRepository(client);
254
+ ```
255
+
256
+ ## Troubleshooting
119
257
 
120
- If you see "No snapshot found", **you need to create a snapshot first**. Snapshots are created by `chaim-cdk`:
258
+ ### "No snapshot found"
259
+
260
+ You need to create a snapshot first by running `cdk synth` or `cdk deploy` in your CDK project:
121
261
 
122
262
  ```bash
123
- # Navigate to your CDK project
124
263
  cd my-cdk-project
264
+ cdk synth
265
+ ```
125
266
 
126
- # Create a snapshot
127
- cdk synth # For development
128
- # OR
129
- cdk deploy # For production
267
+ Then run `chaim generate` from any directory.
130
268
 
131
- # Then generate (from any directory)
132
- chaim generate --package com.mycompany.myapp.model
269
+ ### Stack filter does not match
270
+
271
+ The CLI shows existing snapshots that did not match your `--stack` filter, helping you adjust the value.
272
+
273
+ ## Using in Your Application Codebase
274
+
275
+ A typical project layout:
276
+
277
+ ```
278
+ my-cdk-project/ # CDK infrastructure
279
+ ├── schemas/
280
+ │ ├── user.bprint
281
+ │ └── order.bprint
282
+ ├── lib/my-stack.ts
283
+ └── package.json
284
+
285
+ my-java-app/ # Java application
286
+ ├── src/main/java/com/example/model/ # ← generated by `chaim generate`
287
+ │ ├── User.java
288
+ │ ├── Order.java
289
+ │ └── ...
290
+ ├── src/main/java/com/example/ # Your application code
291
+ │ └── service/UserService.java
292
+ ├── build.gradle.kts
293
+ └── ...
133
294
  ```
134
295
 
135
- **Common causes:**
136
- - Haven't run `cdk synth` or `cdk deploy` yet
137
- - Filters (`--stack`) don't match existing snapshots
138
- - Snapshots in non-default location (use `--snapshot-dir`)
296
+ Run `cdk synth` once, then `chaim generate --package com.example.model` in your Java project. Re-run whenever you change a `.bprint` file or add a new entity.
139
297
 
140
- **Tip:** The CLI shows existing snapshots that didn't match your filters, helping you adjust.
298
+ ## Development
141
299
 
142
- ## Generated Output
300
+ ### Prerequisites
301
+
302
+ - **Node.js 18+** — required for building and running the CLI
303
+ - **npm** — comes with Node.js
304
+
305
+ ### Setup
306
+
307
+ Clone the repository and install dependencies:
143
308
 
309
+ ```bash
310
+ npm install
144
311
  ```
145
- src/main/java/com/mycompany/myapp/model/
146
- ├── Users.java # Entity DTO
147
- ├── config/
148
- │ └── ChaimConfig.java # Table configuration
149
- └── mapper/
150
- └── ChaimMapperClient.java # DynamoDB mapper
312
+
313
+ Or use the included setup script, which validates your Node.js version, installs dependencies, and builds in one step:
314
+
315
+ ```bash
316
+ npm run setup
151
317
  ```
152
318
 
153
- ### Using the Generated SDK
319
+ ### Building
154
320
 
155
- ```java
156
- // Create mapper client
157
- ChaimMapperClient mapper = ChaimConfig.createMapper();
321
+ The CLI is written in TypeScript and compiles to `dist/` via the TypeScript compiler.
322
+
323
+ ```bash
324
+ npm run build # Compile TypeScript → dist/
325
+ ```
158
326
 
159
- // Save entity
160
- User user = new User();
161
- user.setUserId("user-123");
162
- user.setEmail("john@example.com");
163
- mapper.save(user);
327
+ To start from a clean state:
164
328
 
165
- // Find by ID
166
- Optional<User> found = mapper.findById(User.class, "user-123");
329
+ ```bash
330
+ npm run clean # Delete dist/
331
+ npm run build # Rebuild
167
332
  ```
168
333
 
169
- ## Optional Configuration
334
+ The build emits CommonJS modules targeting ES2020 with declarations, declaration maps, and source maps (configured in `tsconfig.json`).
170
335
 
171
- Create `chaim.json` to set defaults:
336
+ ### Running Locally (Development)
172
337
 
173
- ```json
174
- {
175
- "defaults": {
176
- "package": "com.mycompany.myapp.model",
177
- "output": "./src/main/java"
178
- }
179
- }
338
+ You can run the CLI directly from source without compiling first:
339
+
340
+ ```bash
341
+ npm run dev -- generate --package com.example.model
180
342
  ```
181
343
 
182
- Then run without arguments:
344
+ Or after building, run the compiled output:
345
+
183
346
  ```bash
184
- chaim generate
347
+ npm start -- generate --package com.example.model
348
+ # equivalent to: node dist/index.js generate --package com.example.model
185
349
  ```
186
350
 
187
- ## Field Type Mappings
351
+ ### Testing
352
+
353
+ Tests use [Vitest](https://vitest.dev/) and live alongside the source files (`*.test.ts`).
354
+
355
+ ```bash
356
+ npm test # Run all tests in watch mode
357
+ ```
358
+
359
+ To run tests once (CI-friendly):
360
+
361
+ ```bash
362
+ npx vitest run
363
+ ```
364
+
365
+ To run a specific test file:
366
+
367
+ ```bash
368
+ npx vitest run src/commands/generate.test.ts
369
+ ```
370
+
371
+ Test files:
372
+
373
+ | File | Covers |
374
+ |------|--------|
375
+ | `src/index.test.ts` | CLI entry point and command registration |
376
+ | `src/commands/generate.test.ts` | `chaim generate` command |
377
+ | `src/commands/validate.test.ts` | `chaim validate` command |
378
+ | `src/commands/init.test.ts` | `chaim init` command |
379
+ | `src/commands/doctor.test.ts` | `chaim doctor` command |
380
+ | `src/services/snapshot-discovery.test.ts` | Snapshot file discovery logic |
381
+ | `src/services/name-resolver.test.ts` | Field name resolution and collision detection |
382
+
383
+ ### Linting
384
+
385
+ The project uses ESLint with TypeScript support.
386
+
387
+ ```bash
388
+ npm run lint # Check for lint errors
389
+ npm run lint:fix # Auto-fix lint errors
390
+ ```
391
+
392
+ ### Project Structure
393
+
394
+ ```
395
+ chaim-cli/
396
+ ├── src/ # TypeScript source
397
+ │ ├── index.ts # CLI entry point (Commander.js)
398
+ │ ├── commands/ # Command implementations
399
+ │ │ ├── generate.ts
400
+ │ │ ├── validate.ts
401
+ │ │ ├── init.ts
402
+ │ │ ├── doctor.ts
403
+ │ │ ├── bump.ts
404
+ │ │ └── clean.ts
405
+ │ └── services/ # Shared logic
406
+ │ ├── snapshot-discovery.ts
407
+ │ └── name-resolver.ts
408
+ ├── dist/ # Compiled output (git-ignored)
409
+ ├── shared/scripts/setup.sh # One-time setup helper
410
+ ├── tsconfig.json # TypeScript configuration
411
+ ├── .eslintrc.js # ESLint configuration
412
+ └── package.json
413
+ ```
188
414
 
189
- | .bprint Type | Java Type |
190
- |--------------|-----------|
191
- | `string` | `String` |
192
- | `number` | `Double` |
193
- | `boolean` | `Boolean` |
194
- | `timestamp` | `Instant` |
415
+ ## Publishing to npm
195
416
 
196
- ## Related Packages
417
+ Publishing is automated via GitHub Actions. The workflow triggers when you create a GitHub release.
197
418
 
198
- | Package | Purpose |
199
- |---------|---------|
200
- | [chaim-cdk](https://github.com/chaim-tools/chaim-cdk) | AWS CDK constructs (creates snapshots) |
201
- | [chaim-bprint-spec](https://github.com/chaim-tools/chaim-bprint-spec) | Schema specification |
202
- | [chaim-client-java](https://github.com/chaim-tools/chaim-client-java) | Java code generation |
419
+ ### Steps
203
420
 
204
- ## Getting Help
421
+ 1. **Update the version** in `package.json`:
422
+
423
+ ```bash
424
+ npm version patch # 0.1.5 → 0.1.6
425
+ npm version minor # 0.1.5 → 0.2.0
426
+ npm version major # 0.1.5 → 1.0.0
427
+ ```
428
+
429
+ 2. **Push the commit and tag**:
430
+
431
+ ```bash
432
+ git push && git push --tags
433
+ ```
434
+
435
+ 3. **Create a GitHub release** from the tag. Go to the repository's **Releases** page, click **Draft a new release**, select the tag, and publish.
436
+
437
+ 4. The `publish.yml` workflow runs automatically: checks out the code, runs `npm ci`, builds, and publishes to npm with `--access public`.
438
+
439
+ ### Prerequisites
440
+
441
+ - The repository must have an `NPM_TOKEN` secret configured in **Settings > Secrets and variables > Actions**. This token must have publish permissions for the `@chaim-tools` scope.
442
+
443
+ ### Manual Publishing (Emergency)
444
+
445
+ If the workflow fails or you need to publish from your local machine:
446
+
447
+ ```bash
448
+ npm run build
449
+ npm publish --access public
450
+ ```
205
451
 
206
- - **Issues**: [GitHub Issues](https://github.com/chaim-tools/chaim-cli/issues)
207
- - **Examples**: [chaim-examples](https://github.com/chaim-tools/chaim-examples)
452
+ You must be logged in to npm (`npm login`) with publish access to the `@chaim-tools` scope.
208
453
 
209
- ---
454
+ ## License
210
455
 
211
- **Chaim** means life, representing our mission: supporting the life (data) of software applications as they grow and evolve alongside businesses.
456
+ Apache-2.0
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Increment the schemaVersion in a .bprint file.
3
+ *
4
+ * Default is a minor bump (e.g., 1.3 -> 1.4).
5
+ * With --major, performs a major bump (e.g., 1.3 -> 2.0).
6
+ */
7
+ export declare function bumpCommand(schemaFile: string, options: {
8
+ major?: boolean;
9
+ }): Promise<void>;
10
+ //# sourceMappingURL=bump.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bump.d.ts","sourceRoot":"","sources":["../../src/commands/bump.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC3B,OAAO,CAAC,IAAI,CAAC,CA8Df"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.bumpCommand = void 0;
30
+ const chalk_1 = __importDefault(require("chalk"));
31
+ const fs = __importStar(require("fs"));
32
+ const path = __importStar(require("path"));
33
+ /**
34
+ * Increment the schemaVersion in a .bprint file.
35
+ *
36
+ * Default is a minor bump (e.g., 1.3 -> 1.4).
37
+ * With --major, performs a major bump (e.g., 1.3 -> 2.0).
38
+ */
39
+ async function bumpCommand(schemaFile, options) {
40
+ try {
41
+ const resolvedPath = path.resolve(schemaFile);
42
+ if (!fs.existsSync(resolvedPath)) {
43
+ console.error(chalk_1.default.red(`Error: File not found: ${schemaFile}`));
44
+ process.exit(1);
45
+ }
46
+ if (!schemaFile.endsWith('.bprint')) {
47
+ console.error(chalk_1.default.red('Error: File must have a .bprint extension'));
48
+ process.exit(1);
49
+ }
50
+ const content = fs.readFileSync(resolvedPath, 'utf-8');
51
+ let schema;
52
+ try {
53
+ schema = JSON.parse(content);
54
+ }
55
+ catch {
56
+ console.error(chalk_1.default.red('Error: File is not valid JSON'));
57
+ process.exit(1);
58
+ }
59
+ const currentVersion = schema.schemaVersion;
60
+ if (!currentVersion || typeof currentVersion !== 'string') {
61
+ console.error(chalk_1.default.red('Error: File does not contain a valid schemaVersion field'));
62
+ process.exit(1);
63
+ }
64
+ const versionPattern = /^\d+\.\d+$/;
65
+ if (!versionPattern.test(currentVersion)) {
66
+ console.error(chalk_1.default.red(`Error: Current schemaVersion "${currentVersion}" is not in "major.minor" format`));
67
+ process.exit(1);
68
+ }
69
+ const [major, minor] = currentVersion.split('.').map(Number);
70
+ let newVersion;
71
+ if (options.major) {
72
+ newVersion = `${major + 1}.0`;
73
+ }
74
+ else {
75
+ newVersion = `${major}.${minor + 1}`;
76
+ }
77
+ schema.schemaVersion = newVersion;
78
+ fs.writeFileSync(resolvedPath, JSON.stringify(schema, null, 2) + '\n', 'utf-8');
79
+ const fileName = path.basename(schemaFile);
80
+ const bumpType = options.major ? 'major' : 'minor';
81
+ console.log(chalk_1.default.green(`Bumped ${fileName}: ${currentVersion} -> ${newVersion}`) +
82
+ chalk_1.default.gray(` (${bumpType})`));
83
+ }
84
+ catch (error) {
85
+ console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : error);
86
+ process.exit(1);
87
+ }
88
+ }
89
+ exports.bumpCommand = bumpCommand;
90
+ //# sourceMappingURL=bump.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bump.js","sourceRoot":"","sources":["../../src/commands/bump.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CAAC,KAAK,CAC/C,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;AACH,CAAC;AAjED,kCAiEC"}
package/dist/index.js CHANGED
@@ -5,12 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const commander_1 = require("commander");
8
+ const fs_1 = require("fs");
9
+ const path_1 = require("path");
8
10
  const generate_1 = require("./commands/generate");
9
11
  const validate_1 = require("./commands/validate");
10
12
  const doctor_1 = require("./commands/doctor");
11
13
  const init_1 = require("./commands/init");
12
14
  const clean_1 = require("./commands/clean");
15
+ const bump_1 = require("./commands/bump");
13
16
  const chalk_1 = __importDefault(require("chalk"));
17
+ const pkg = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '..', 'package.json'), 'utf-8'));
14
18
  /**
15
19
  * ==========================
16
20
  * Planned Commands (Roadmap)
@@ -39,7 +43,7 @@ const program = new commander_1.Command();
39
43
  program
40
44
  .name('chaim')
41
45
  .description('Schema-driven code generation tool for DynamoDB')
42
- .version('0.1.0');
46
+ .version(pkg.version);
43
47
  program
44
48
  .command('generate')
45
49
  .description('Generate SDK code from LOCAL snapshot (reads from OS cache)')
@@ -75,6 +79,12 @@ program
75
79
  .option('--dry-run', 'Show what would be deleted without deleting')
76
80
  .option('--verbose', 'Show detailed output')
77
81
  .action(clean_1.cleanCommand);
82
+ program
83
+ .command('bump')
84
+ .description('Increment the schemaVersion in a .bprint file')
85
+ .argument('<schemaFile>', '.bprint file to version bump')
86
+ .option('--major', 'Major version bump (X.Y -> X+1.0) instead of minor (X.Y -> X.Y+1)')
87
+ .action(bump_1.bumpCommand);
78
88
  /**
79
89
  * ==========================
80
90
  * Planned Command Registration
@@ -104,6 +114,7 @@ if (process.argv.length <= 2) {
104
114
  console.log(' init - Verify and install all prerequisites');
105
115
  console.log(' generate - Generate SDK code from CDK snapshot (default: java)');
106
116
  console.log(' validate - Validate a .bprint schema file');
117
+ console.log(' bump - Increment the schemaVersion in a .bprint file');
107
118
  console.log(' doctor - Check system environment and dependencies');
108
119
  console.log(' clean - Clean snapshot cache (remove old or stale snapshots)');
109
120
  console.log('');
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,kDAAsD;AACtD,kDAAsD;AACtD,8CAAkD;AAClD,0CAA8C;AAC9C,4CAAgD;AAChD,kDAA0B;AAE1B;;;;;;;;;;;;GAYG;AAEH,gFAAgF;AAChF,oEAAoE;AACpE,sEAAsE;AACtE,sEAAsE;AAEtE,gFAAgF;AAChF,mEAAmE;AACnE,kEAAkE;AAElE,gFAAgF;AAChF,wEAAwE;AACxE,kEAAkE;AAClE,sEAAsE;AAEtE,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,OAAO,CAAC;KACb,WAAW,CAAC,iDAAiD,CAAC;KAC9D,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CAAC,6DAA6D,CAAC;KAC1E,cAAc,CAAC,yBAAyB,EAAE,yDAAyD,CAAC;KACpG,MAAM,CAAC,2BAA2B,EAAE,qDAAqD,CAAC;KAC1F,MAAM,CAAC,sBAAsB,EAAE,kBAAkB,EAAE,iBAAiB,CAAC;KACrE,MAAM,CAAC,qBAAqB,EAAE,qCAAqC,CAAC;KACpE,MAAM,CAAC,uBAAuB,EAAE,iDAAiD,CAAC;KAClF,MAAM,CAAC,eAAe,EAAE,+CAA+C,CAAC;KACxE,MAAM,CAAC,0BAAe,CAAC,CAAC;AAE3B,OAAO;KACJ,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CAAC,gCAAgC,CAAC;KAC7C,QAAQ,CAAC,cAAc,EAAE,yBAAyB,CAAC;KACnD,MAAM,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AC,GAAG,CAAC,oEAAoE,CAAC,CAAC;IAClF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;IACnE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CACjB;AAED,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -55,7 +55,7 @@ export interface Annotations {
55
55
  * Schema v1.1 - flattened structure (no nested entity object).
56
56
  */
57
57
  export interface SchemaData {
58
- schemaVersion: number;
58
+ schemaVersion: string;
59
59
  entityName: string;
60
60
  description: string;
61
61
  primaryKey: PrimaryKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chaim-tools/chaim",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Schema-driven code generation tool for DynamoDB - Pure TypeScript CLI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,13 +18,13 @@
18
18
  },
19
19
  "scripts": {
20
20
  "build": "npm run build:cli",
21
- "build:cli": "tsc",
21
+ "build:cli": "npx tsc",
22
22
  "setup": "./shared/scripts/setup.sh",
23
23
  "clean": "rm -rf dist",
24
- "test": "vitest",
25
- "lint": "eslint . --ext .ts",
26
- "lint:fix": "eslint . --ext .ts --fix",
27
- "dev": "ts-node src/index.ts",
24
+ "test": "npx vitest",
25
+ "lint": "npx eslint . --ext .ts",
26
+ "lint:fix": "npx eslint . --ext .ts --fix",
27
+ "dev": "npx ts-node src/index.ts",
28
28
  "start": "node dist/index.js"
29
29
  },
30
30
  "keywords": [
@@ -47,8 +47,8 @@
47
47
  "homepage": "https://github.com/chaim-tools/chaim-cli#readme",
48
48
  "dependencies": {
49
49
  "@aws-sdk/client-sts": "^3.883.0",
50
- "@chaim-tools/chaim-bprint-spec": "^0.2.4",
51
- "@chaim-tools/client-java": "^0.1.3",
50
+ "@chaim-tools/chaim-bprint-spec": "^0.2.5",
51
+ "@chaim-tools/client-java": "^0.1.5",
52
52
  "chalk": "^4.1.2",
53
53
  "commander": "^11.0.0",
54
54
  "ora": "^5.4.1"
@@ -1,47 +1,41 @@
1
1
  #!/bin/bash
2
2
 
3
- echo "🚀 Setting up Chaim CLI (TypeScript)"
3
+ set -e
4
+
5
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
+ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
7
+
8
+ echo "Setting up Chaim CLI (TypeScript)"
9
+ echo ""
4
10
 
5
11
  # Check if Node.js is installed
6
12
  if ! command -v node &> /dev/null; then
7
- echo " Node.js is not installed. Please install Node.js v18 or higher."
13
+ echo "ERROR: Node.js is not installed. Please install Node.js v18 or higher."
8
14
  exit 1
9
15
  fi
10
16
 
11
17
  # Check Node.js version
12
18
  NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
13
19
  if [ "$NODE_VERSION" -lt 18 ]; then
14
- echo " Node.js version 18 or higher is required. Current version: $(node -v)"
20
+ echo "ERROR: Node.js version 18 or higher is required. Current version: $(node -v)"
15
21
  exit 1
16
22
  fi
17
23
 
18
- echo "Node.js version: $(node -v)"
24
+ echo "Node.js version: $(node -v) OK"
19
25
 
20
26
  # Install dependencies
21
- echo "📦 Installing CLI dependencies..."
22
- cd cli && npm install
27
+ echo "Installing dependencies..."
28
+ cd "$PROJECT_ROOT"
29
+ npm install
23
30
 
24
31
  # Build the TypeScript CLI
25
- echo "🔨 Building TypeScript CLI..."
26
- npm run build
27
-
28
- # Build Java modules (for code generation)
29
- echo "☕ Building Java modules..."
30
- cd ../java
31
- if [ -f "gradlew" ]; then
32
- ./gradlew :schema-core:build
33
- ./gradlew :codegen-java:build
34
- ./gradlew :cdk-integration:build
35
- else
36
- echo "⚠️ Gradle wrapper not found. Please install Gradle and run:"
37
- echo " gradle :schema-core:build"
38
- echo " gradle :codegen-java:build"
39
- echo " gradle :cdk-integration:build"
40
- fi
32
+ echo "Building TypeScript CLI..."
33
+ npx tsc
41
34
 
42
- echo "✅ Setup complete!"
35
+ echo ""
36
+ echo "Setup complete!"
43
37
  echo ""
44
38
  echo "Usage:"
45
- echo " ./cli/dist/index.js generate --stack MyStack --package com.example"
46
- echo " ./cli/dist/index.js validate ./shared/examples/user.bprint"
47
- echo " ./cli/dist/index.js doctor"
39
+ echo " npx chaim generate --stack MyStack --package com.example"
40
+ echo " npx chaim validate ./schemas/user.bprint"
41
+ echo " npx chaim doctor"