@chaim-tools/chaim 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 (84) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +211 -0
  3. package/dist/commands/apps/link.d.ts +26 -0
  4. package/dist/commands/apps/link.d.ts.map +1 -0
  5. package/dist/commands/apps/link.js +49 -0
  6. package/dist/commands/apps/link.js.map +1 -0
  7. package/dist/commands/apps/list.d.ts +25 -0
  8. package/dist/commands/apps/list.d.ts.map +1 -0
  9. package/dist/commands/apps/list.js +46 -0
  10. package/dist/commands/apps/list.js.map +1 -0
  11. package/dist/commands/auth/login.d.ts +29 -0
  12. package/dist/commands/auth/login.d.ts.map +1 -0
  13. package/dist/commands/auth/login.js +51 -0
  14. package/dist/commands/auth/login.js.map +1 -0
  15. package/dist/commands/auth/logout.d.ts +26 -0
  16. package/dist/commands/auth/logout.d.ts.map +1 -0
  17. package/dist/commands/auth/logout.js +49 -0
  18. package/dist/commands/auth/logout.js.map +1 -0
  19. package/dist/commands/auth/refresh.d.ts +27 -0
  20. package/dist/commands/auth/refresh.d.ts.map +1 -0
  21. package/dist/commands/auth/refresh.js +47 -0
  22. package/dist/commands/auth/refresh.js.map +1 -0
  23. package/dist/commands/auth/whoami.d.ts +28 -0
  24. package/dist/commands/auth/whoami.d.ts.map +1 -0
  25. package/dist/commands/auth/whoami.js +48 -0
  26. package/dist/commands/auth/whoami.js.map +1 -0
  27. package/dist/commands/clean.d.ts +25 -0
  28. package/dist/commands/clean.d.ts.map +1 -0
  29. package/dist/commands/clean.js +345 -0
  30. package/dist/commands/clean.js.map +1 -0
  31. package/dist/commands/config/show.d.ts +25 -0
  32. package/dist/commands/config/show.d.ts.map +1 -0
  33. package/dist/commands/config/show.js +49 -0
  34. package/dist/commands/config/show.js.map +1 -0
  35. package/dist/commands/configure.d.ts +26 -0
  36. package/dist/commands/configure.d.ts.map +1 -0
  37. package/dist/commands/configure.js +53 -0
  38. package/dist/commands/configure.js.map +1 -0
  39. package/dist/commands/doctor.d.ts +2 -0
  40. package/dist/commands/doctor.d.ts.map +1 -0
  41. package/dist/commands/doctor.js +96 -0
  42. package/dist/commands/doctor.js.map +1 -0
  43. package/dist/commands/generate.d.ts +11 -0
  44. package/dist/commands/generate.d.ts.map +1 -0
  45. package/dist/commands/generate.js +395 -0
  46. package/dist/commands/generate.js.map +1 -0
  47. package/dist/commands/init.d.ts +8 -0
  48. package/dist/commands/init.d.ts.map +1 -0
  49. package/dist/commands/init.js +302 -0
  50. package/dist/commands/init.js.map +1 -0
  51. package/dist/commands/validate.d.ts +2 -0
  52. package/dist/commands/validate.d.ts.map +1 -0
  53. package/dist/commands/validate.js +58 -0
  54. package/dist/commands/validate.js.map +1 -0
  55. package/dist/config/types.d.ts +138 -0
  56. package/dist/config/types.d.ts.map +1 -0
  57. package/dist/config/types.js +48 -0
  58. package/dist/config/types.js.map +1 -0
  59. package/dist/index.d.ts +3 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +114 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/planned-commands.d.ts +51 -0
  64. package/dist/planned-commands.d.ts.map +1 -0
  65. package/dist/planned-commands.js +199 -0
  66. package/dist/planned-commands.js.map +1 -0
  67. package/dist/services/os-cache-paths.d.ts +15 -0
  68. package/dist/services/os-cache-paths.d.ts.map +1 -0
  69. package/dist/services/os-cache-paths.js +57 -0
  70. package/dist/services/os-cache-paths.js.map +1 -0
  71. package/dist/services/snapshot-discovery.d.ts +111 -0
  72. package/dist/services/snapshot-discovery.d.ts.map +1 -0
  73. package/dist/services/snapshot-discovery.js +249 -0
  74. package/dist/services/snapshot-discovery.js.map +1 -0
  75. package/dist/types/index.d.ts +8 -0
  76. package/dist/types/index.d.ts.map +1 -0
  77. package/dist/types/index.js +9 -0
  78. package/dist/types/index.js.map +1 -0
  79. package/dist/types/snapshot-payload.d.ts +205 -0
  80. package/dist/types/snapshot-payload.d.ts.map +1 -0
  81. package/dist/types/snapshot-payload.js +9 -0
  82. package/dist/types/snapshot-payload.js.map +1 -0
  83. package/package.json +65 -0
  84. package/shared/scripts/setup.sh +47 -0
@@ -0,0 +1,249 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getSnapshotDirPath = exports.resolveAllSnapshots = exports.resolveSnapshot = exports.getLatestSnapshot = exports.listSnapshots = exports.discoverSnapshots = void 0;
27
+ const fs = __importStar(require("fs"));
28
+ const path = __importStar(require("path"));
29
+ const os_cache_paths_1 = require("./os-cache-paths");
30
+ /**
31
+ * Parse a resource ID into its components.
32
+ * Format: {resourceName}__{entityName}[__N]
33
+ *
34
+ * @param resourceId - Resource ID to parse
35
+ * @returns Parsed components or null if invalid format
36
+ */
37
+ function parseResourceId(resourceId) {
38
+ const parts = resourceId.split('__');
39
+ if (parts.length < 2) {
40
+ return null;
41
+ }
42
+ return {
43
+ resourceName: parts[0],
44
+ entityName: parts[1],
45
+ suffix: parts.length > 2 ? parts.slice(2).join('__') : undefined,
46
+ };
47
+ }
48
+ /**
49
+ * Recursively discover all LOCAL snapshot files in the OS cache.
50
+ *
51
+ * Directory structure:
52
+ * aws/{accountId}/{region}/{stackName}/{datastoreType}/{resourceId}.json
53
+ *
54
+ * @param snapshotDir - Base snapshot directory (defaults to OS cache)
55
+ * @param options - Discovery options for filtering
56
+ * @returns Array of snapshot file info, sorted by capturedAt descending (newest first)
57
+ */
58
+ function discoverSnapshots(snapshotDir, options = {}) {
59
+ const baseDir = snapshotDir ?? (0, os_cache_paths_1.getSnapshotBaseDir)();
60
+ const snapshots = [];
61
+ const { stackName: filterStack } = options;
62
+ const awsDir = path.join(baseDir, 'aws');
63
+ if (!fs.existsSync(awsDir)) {
64
+ return [];
65
+ }
66
+ // Scan accounts
67
+ const accounts = safeReadDir(awsDir);
68
+ for (const accountId of accounts) {
69
+ const accountDir = path.join(awsDir, accountId);
70
+ if (!fs.statSync(accountDir).isDirectory())
71
+ continue;
72
+ // Scan regions
73
+ const regions = safeReadDir(accountDir);
74
+ for (const region of regions) {
75
+ const regionDir = path.join(accountDir, region);
76
+ if (!fs.statSync(regionDir).isDirectory())
77
+ continue;
78
+ // Scan stacks
79
+ const stacks = safeReadDir(regionDir);
80
+ for (const stackName of stacks) {
81
+ // Apply stack filter if provided
82
+ if (filterStack && stackName !== filterStack)
83
+ continue;
84
+ const stackDir = path.join(regionDir, stackName);
85
+ if (!fs.statSync(stackDir).isDirectory())
86
+ continue;
87
+ // Scan data store types
88
+ const datastores = safeReadDir(stackDir);
89
+ for (const datastoreType of datastores) {
90
+ const datastoreDir = path.join(stackDir, datastoreType);
91
+ if (!fs.statSync(datastoreDir).isDirectory())
92
+ continue;
93
+ // Scan snapshot files
94
+ const files = safeReadDir(datastoreDir);
95
+ for (const file of files) {
96
+ if (!file.endsWith('.json'))
97
+ continue;
98
+ const filePath = path.join(datastoreDir, file);
99
+ const stat = fs.statSync(filePath);
100
+ if (!stat.isFile())
101
+ continue;
102
+ // Parse filename
103
+ const resourceId = file.slice(0, -5); // Remove .json
104
+ const parsed = parseResourceId(resourceId);
105
+ if (!parsed)
106
+ continue;
107
+ // Read capturedAt from payload for sorting
108
+ let capturedAt;
109
+ try {
110
+ const content = fs.readFileSync(filePath, 'utf-8');
111
+ const payload = JSON.parse(content);
112
+ capturedAt = new Date(payload.capturedAt || stat.mtime);
113
+ }
114
+ catch {
115
+ capturedAt = stat.mtime; // Fallback to mtime
116
+ }
117
+ snapshots.push({
118
+ filePath,
119
+ accountId,
120
+ region,
121
+ stackName,
122
+ datastoreType,
123
+ resourceId,
124
+ resourceName: parsed.resourceName,
125
+ entityName: parsed.entityName,
126
+ capturedAt,
127
+ });
128
+ }
129
+ }
130
+ }
131
+ }
132
+ }
133
+ // Sort by capturedAt descending (newest first)
134
+ snapshots.sort((a, b) => b.capturedAt.getTime() - a.capturedAt.getTime());
135
+ return snapshots;
136
+ }
137
+ exports.discoverSnapshots = discoverSnapshots;
138
+ /**
139
+ * Safely read a directory, returning empty array if it doesn't exist.
140
+ */
141
+ function safeReadDir(dir) {
142
+ try {
143
+ if (!fs.existsSync(dir)) {
144
+ return [];
145
+ }
146
+ return fs.readdirSync(dir);
147
+ }
148
+ catch {
149
+ return [];
150
+ }
151
+ }
152
+ /**
153
+ * List all snapshot files with optional stack filtering.
154
+ *
155
+ * @param snapshotDir - Base snapshot directory (defaults to OS cache)
156
+ * @param stackName - Optional stack name filter
157
+ * @returns Array of snapshot file info, sorted by capturedAt descending (newest first)
158
+ */
159
+ function listSnapshots(snapshotDir, stackName) {
160
+ return discoverSnapshots(snapshotDir, { stackName });
161
+ }
162
+ exports.listSnapshots = listSnapshots;
163
+ /**
164
+ * Get the latest snapshot matching the given options.
165
+ *
166
+ * @param snapshotDir - Base snapshot directory (defaults to OS cache)
167
+ * @param options - Discovery options for filtering
168
+ * @returns The latest snapshot file info, or undefined if none found
169
+ */
170
+ function getLatestSnapshot(snapshotDir, options = {}) {
171
+ const snapshots = discoverSnapshots(snapshotDir, options);
172
+ return snapshots[0]; // Already sorted by capturedAt descending
173
+ }
174
+ exports.getLatestSnapshot = getLatestSnapshot;
175
+ /**
176
+ * Resolve which snapshot to use based on the requested options.
177
+ *
178
+ * Selection logic:
179
+ * 1. Find all snapshots matching filter (--stack if provided)
180
+ * 2. Select the newest by capturedAt
181
+ * 3. If none found, return undefined
182
+ *
183
+ * @param snapshotDir - Base snapshot directory (defaults to OS cache)
184
+ * @param stackName - Optional stack name filter
185
+ * @returns Resolved snapshot info, or undefined if no snapshot found
186
+ */
187
+ function resolveSnapshot(snapshotDir, stackName) {
188
+ const snapshotInfo = getLatestSnapshot(snapshotDir, { stackName });
189
+ if (!snapshotInfo) {
190
+ return undefined;
191
+ }
192
+ // Read and parse the snapshot file
193
+ const content = fs.readFileSync(snapshotInfo.filePath, 'utf-8');
194
+ const snapshot = JSON.parse(content);
195
+ return {
196
+ filePath: snapshotInfo.filePath,
197
+ snapshot,
198
+ stackName: snapshotInfo.stackName,
199
+ accountId: snapshotInfo.accountId,
200
+ region: snapshotInfo.region,
201
+ datastoreType: snapshotInfo.datastoreType,
202
+ resourceName: snapshotInfo.resourceName,
203
+ entityName: snapshotInfo.entityName,
204
+ };
205
+ }
206
+ exports.resolveSnapshot = resolveSnapshot;
207
+ /**
208
+ * Resolve all snapshots matching the given options.
209
+ * Used for multi-entity generation.
210
+ *
211
+ * @param snapshotDir - Base snapshot directory (defaults to OS cache)
212
+ * @param options - Discovery options for filtering
213
+ * @returns Array of resolved snapshots, or empty array if none found
214
+ */
215
+ function resolveAllSnapshots(snapshotDir, options = {}) {
216
+ const snapshotInfos = discoverSnapshots(snapshotDir, options);
217
+ return snapshotInfos.map((info) => {
218
+ const content = fs.readFileSync(info.filePath, 'utf-8');
219
+ const snapshot = JSON.parse(content);
220
+ return {
221
+ filePath: info.filePath,
222
+ snapshot,
223
+ stackName: info.stackName,
224
+ accountId: info.accountId,
225
+ region: info.region,
226
+ datastoreType: info.datastoreType,
227
+ resourceName: info.resourceName,
228
+ entityName: info.entityName,
229
+ };
230
+ });
231
+ }
232
+ exports.resolveAllSnapshots = resolveAllSnapshots;
233
+ /**
234
+ * Get the full path to the snapshot directory.
235
+ *
236
+ * @param snapshotDir - Snapshot directory (relative or absolute, or undefined for OS cache)
237
+ * @returns Absolute path to the snapshot directory
238
+ */
239
+ function getSnapshotDirPath(snapshotDir) {
240
+ if (!snapshotDir) {
241
+ return (0, os_cache_paths_1.getSnapshotBaseDir)();
242
+ }
243
+ if (path.isAbsolute(snapshotDir)) {
244
+ return snapshotDir;
245
+ }
246
+ return path.join(process.cwd(), snapshotDir);
247
+ }
248
+ exports.getSnapshotDirPath = getSnapshotDirPath;
249
+ //# sourceMappingURL=snapshot-discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot-discovery.js","sourceRoot":"","sources":["../../src/services/snapshot-discovery.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,qDAAsD;AA2DtD;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,UAAkB;IACzC,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QACpB,OAAO,IAAI,CAAC;KACb;IACD,OAAO;QACL,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;QACtB,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;QACpB,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;KACjE,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,iBAAiB,CAC/B,WAAoB,EACpB,UAA4B,EAAE;IAE9B,MAAM,OAAO,GAAG,WAAW,IA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,CAAC,CAAC,CAAC;AACL,CAAC;AArBD,kDAqBC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,WAAoB;IACrD,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO,IAAA,mCAAkB,GAAE,CAAC;KAC7B;IACD,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QAChC,OAAO,WAAW,CAAC;KACpB;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,WAAW,CAAC,CAAC;AAC/C,CAAC;AARD,gDAQC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Type definitions for chaim-cli.
3
+ *
4
+ * These types match the snapshot format produced by chaim-cdk and
5
+ * provide type safety for snapshot consumption and code generation.
6
+ */
7
+ export { PrimaryKey, SchemaField, SchemaData, Annotations, GSIMetadata, LSIMetadata, BaseDataStoreMetadata, DynamoDBMetadata, DataStoreMetadata, StackContext, StableIdentity, LocalSnapshotPayload, TableMetadata, } from './snapshot-payload';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EAGX,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAGjB,YAAY,EACZ,cAAc,EAGd,oBAAoB,EAGpB,aAAa,GACd,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * Type definitions for chaim-cli.
4
+ *
5
+ * These types match the snapshot format produced by chaim-cdk and
6
+ * provide type safety for snapshot consumption and code generation.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Type definitions for LOCAL snapshot payloads produced by chaim-cdk.
3
+ *
4
+ * These types match the snapshot format written to the OS cache by chaim-cdk.
5
+ * The CLI reads these snapshots to generate DTOs and mapper clients.
6
+ */
7
+ /**
8
+ * Primary key configuration for the entity.
9
+ */
10
+ export interface PrimaryKey {
11
+ partitionKey: string;
12
+ sortKey?: string;
13
+ }
14
+ /**
15
+ * Field definition in the entity schema.
16
+ */
17
+ export interface SchemaField {
18
+ name: string;
19
+ type: 'string' | 'number' | 'boolean' | 'timestamp';
20
+ required?: boolean;
21
+ default?: string | number | boolean;
22
+ enum?: string[];
23
+ description?: string;
24
+ }
25
+ /**
26
+ * Annotations for schema metadata.
27
+ */
28
+ export interface Annotations {
29
+ pii?: boolean;
30
+ retention?: string;
31
+ encryption?: string;
32
+ }
33
+ /**
34
+ * Complete schema data from a .bprint file.
35
+ * Schema v1.1 - flattened structure (no nested entity object).
36
+ */
37
+ export interface SchemaData {
38
+ schemaVersion: number;
39
+ entityName: string;
40
+ description: string;
41
+ primaryKey: PrimaryKey;
42
+ fields: SchemaField[];
43
+ annotations?: Annotations;
44
+ }
45
+ /**
46
+ * Global Secondary Index metadata
47
+ */
48
+ export interface GSIMetadata {
49
+ indexName: string;
50
+ partitionKey: string;
51
+ sortKey?: string;
52
+ projectionType: 'ALL' | 'KEYS_ONLY' | 'INCLUDE';
53
+ nonKeyAttributes?: string[];
54
+ }
55
+ /**
56
+ * Local Secondary Index metadata
57
+ */
58
+ export interface LSIMetadata {
59
+ indexName: string;
60
+ sortKey: string;
61
+ projectionType: 'ALL' | 'KEYS_ONLY' | 'INCLUDE';
62
+ nonKeyAttributes?: string[];
63
+ }
64
+ /**
65
+ * Base metadata interface for all data store types.
66
+ */
67
+ export interface BaseDataStoreMetadata {
68
+ /** Data store type identifier */
69
+ type: string;
70
+ /** AWS ARN of the data store resource */
71
+ arn: string;
72
+ /** Resource name */
73
+ name: string;
74
+ /** AWS region */
75
+ region: string;
76
+ /** AWS account ID */
77
+ account: string;
78
+ /** Encryption key ARN (if configured) */
79
+ encryptionKeyArn?: string;
80
+ }
81
+ /**
82
+ * DynamoDB table metadata captured during binding.
83
+ */
84
+ export interface DynamoDBMetadata extends BaseDataStoreMetadata {
85
+ type: 'dynamodb';
86
+ /** Table name */
87
+ tableName: string;
88
+ /** Table ARN */
89
+ tableArn: string;
90
+ /** Partition key attribute name */
91
+ partitionKey: string;
92
+ /** Sort key attribute name (if composite key) */
93
+ sortKey?: string;
94
+ /** Global Secondary Indexes */
95
+ globalSecondaryIndexes?: GSIMetadata[];
96
+ /** Local Secondary Indexes */
97
+ localSecondaryIndexes?: LSIMetadata[];
98
+ /** TTL attribute name (if enabled) */
99
+ ttlAttribute?: string;
100
+ /** Whether DynamoDB Streams is enabled */
101
+ streamEnabled?: boolean;
102
+ /** Stream view type (if streams enabled) */
103
+ streamViewType?: string;
104
+ /** Billing mode */
105
+ billingMode?: 'PAY_PER_REQUEST' | 'PROVISIONED';
106
+ }
107
+ /**
108
+ * Union type for all supported data store metadata.
109
+ */
110
+ export type DataStoreMetadata = DynamoDBMetadata;
111
+ /**
112
+ * Stack context captured during CDK synthesis.
113
+ */
114
+ export interface StackContext {
115
+ /** AWS account ID (may be 'unknown' if unresolved at synth time) */
116
+ account: string;
117
+ /** AWS region (may be 'unknown' if unresolved at synth time) */
118
+ region: string;
119
+ /** CloudFormation stack ID */
120
+ stackId: string;
121
+ /** CloudFormation stack name */
122
+ stackName: string;
123
+ }
124
+ /**
125
+ * Stable identity for collision detection.
126
+ * Uses synth-stable fields only (no tokens).
127
+ */
128
+ export interface StableIdentity {
129
+ /** Application ID (user input, always stable) */
130
+ appId: string;
131
+ /** CDK stack name */
132
+ stackName: string;
133
+ /** Data store type (e.g., 'dynamodb') */
134
+ datastoreType: string;
135
+ /** Entity name from schema */
136
+ entityName: string;
137
+ /** Best available stable resource key */
138
+ stableResourceKey: string;
139
+ }
140
+ /**
141
+ * LOCAL snapshot payload written to OS cache during CDK synthesis.
142
+ *
143
+ * This is the primary snapshot type used for CLI code generation.
144
+ * Written at synth-time (runs for both `cdk synth` and `cdk deploy`).
145
+ */
146
+ export interface LocalSnapshotPayload {
147
+ /**
148
+ * Action type for this snapshot.
149
+ * - UPSERT: Create or update entity metadata (default)
150
+ * - DELETE: Mark entity as deleted
151
+ *
152
+ * If omitted, defaults to 'UPSERT' for backward compatibility.
153
+ */
154
+ action?: 'UPSERT' | 'DELETE';
155
+ /** Cloud provider */
156
+ provider: 'aws';
157
+ /** AWS account ID (may be 'unknown' if unresolved at synth) */
158
+ accountId: string;
159
+ /** AWS region (may be 'unknown' if unresolved at synth) */
160
+ region: string;
161
+ /** CDK stack name */
162
+ stackName: string;
163
+ /** Data store type (e.g., 'dynamodb') */
164
+ datastoreType: string;
165
+ /** User-provided display label for the resource */
166
+ resourceName: string;
167
+ /** Generated resource ID: {resourceName}__{entityName}[__N] */
168
+ resourceId: string;
169
+ /** Stable identity for collision detection */
170
+ identity: StableIdentity;
171
+ /** Application ID from ChaimBinder props */
172
+ appId: string;
173
+ /** Validated .bprint schema data (null for DELETE actions) */
174
+ schema: SchemaData | null;
175
+ /** Data store metadata (DynamoDB, Aurora, etc.) */
176
+ dataStore: DataStoreMetadata;
177
+ /** CDK stack context */
178
+ context: StackContext;
179
+ /** ISO 8601 timestamp of snapshot creation */
180
+ capturedAt: string;
181
+ }
182
+ /**
183
+ * Table metadata object passed to the Java generator.
184
+ *
185
+ * IMPORTANT: This is a plain object with properties, NOT getter functions.
186
+ * The JavaGenerator serializes this to JSON via JSON.stringify(), and arrow
187
+ * functions are not JSON-serializable (they get stripped).
188
+ */
189
+ export interface TableMetadata {
190
+ /** Table name */
191
+ tableName: string;
192
+ /** Table ARN */
193
+ tableArn: string;
194
+ /** AWS region */
195
+ region: string;
196
+ /** Partition key attribute name */
197
+ partitionKey: string;
198
+ /** Sort key attribute name (if composite key) */
199
+ sortKey?: string;
200
+ /** Global Secondary Indexes */
201
+ globalSecondaryIndexes?: GSIMetadata[];
202
+ /** Local Secondary Indexes */
203
+ localSecondaryIndexes?: LSIMetadata[];
204
+ }
205
+ //# sourceMappingURL=snapshot-payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot-payload.d.ts","sourceRoot":"","sources":["../../src/types/snapshot-payload.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAMD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,EAA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,CAAC;IAEtB,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;CACpB;AAMD;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,iBAAiB;IACjB,SAAS,EAAE,MAAM,CAAC;IAElB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IAEjB,iBAAiB;IACjB,MAAM,EAAE,MAAM,CAAC;IAEf,mCAAmC;IACnC,YAAY,EAAE,MAAM,CAAC;IAErB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,+BAA+B;IAC/B,sBAAsB,CAAC,EAAE,WAAW,EAAE,CAAC;IAEvC,8BAA8B;IAC9B,qBAAqB,CAAC,EAAE,WAAW,EAAE,CAAC;CACvC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * Type definitions for LOCAL snapshot payloads produced by chaim-cdk.
4
+ *
5
+ * These types match the snapshot format written to the OS cache by chaim-cdk.
6
+ * The CLI reads these snapshots to generate DTOs and mapper clients.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ //# sourceMappingURL=snapshot-payload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot-payload.js","sourceRoot":"","sources":["../../src/types/snapshot-payload.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@chaim-tools/chaim",
3
+ "version": "0.1.0",
4
+ "description": "Schema-driven code generation tool for DynamoDB - Pure TypeScript CLI",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "shared/scripts",
10
+ "README.md",
11
+ "LICENSE"
12
+ ],
13
+ "engines": {
14
+ "node": ">=18"
15
+ },
16
+ "bin": {
17
+ "chaim": "./dist/index.js"
18
+ },
19
+ "scripts": {
20
+ "build": "npm run build:cli",
21
+ "build:cli": "tsc",
22
+ "setup": "./shared/scripts/setup.sh",
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",
28
+ "start": "node dist/index.js"
29
+ },
30
+ "keywords": [
31
+ "chaim",
32
+ "cli",
33
+ "code-generation",
34
+ "dynamodb",
35
+ "schema",
36
+ "typescript"
37
+ ],
38
+ "author": "Chaim Builder",
39
+ "license": "Apache-2.0",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/chaim-tools/chaim-cli.git"
43
+ },
44
+ "bugs": {
45
+ "url": "https://github.com/chaim-tools/chaim-cli/issues"
46
+ },
47
+ "homepage": "https://github.com/chaim-tools/chaim-cli#readme",
48
+ "dependencies": {
49
+ "@aws-sdk/client-sts": "^3.883.0",
50
+ "@chaim-tools/chaim-bprint-spec": "workspace:^0.2.0",
51
+ "@chaim-tools/client-java": "workspace:^0.1.0",
52
+ "chalk": "^4.1.2",
53
+ "commander": "^11.0.0",
54
+ "ora": "^5.4.1"
55
+ },
56
+ "devDependencies": {
57
+ "@types/node": "^20.0.0",
58
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
59
+ "@typescript-eslint/parser": "^6.21.0",
60
+ "eslint": "^8.0.0",
61
+ "ts-node": "^10.9.0",
62
+ "typescript": "~5.0.0",
63
+ "vitest": "^1.0.0"
64
+ }
65
+ }
@@ -0,0 +1,47 @@
1
+ #!/bin/bash
2
+
3
+ echo "🚀 Setting up Chaim CLI (TypeScript)"
4
+
5
+ # Check if Node.js is installed
6
+ if ! command -v node &> /dev/null; then
7
+ echo "❌ Node.js is not installed. Please install Node.js v18 or higher."
8
+ exit 1
9
+ fi
10
+
11
+ # Check Node.js version
12
+ NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
13
+ if [ "$NODE_VERSION" -lt 18 ]; then
14
+ echo "❌ Node.js version 18 or higher is required. Current version: $(node -v)"
15
+ exit 1
16
+ fi
17
+
18
+ echo "✅ Node.js version: $(node -v)"
19
+
20
+ # Install dependencies
21
+ echo "📦 Installing CLI dependencies..."
22
+ cd cli && npm install
23
+
24
+ # 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
41
+
42
+ echo "✅ Setup complete!"
43
+ echo ""
44
+ 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"