tthr 0.0.39 → 0.0.41

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 (2) hide show
  1. package/dist/index.js +16 -28
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -78,10 +78,16 @@ async function deploySchemaToServer(projectId, token, schemaPath, environment, d
78
78
  `));
79
79
  return;
80
80
  }
81
+ console.log(chalk.dim(` Schema path: ${schemaPath}`));
81
82
  const schemaSource = await fs.readFile(schemaPath, "utf-8");
83
+ console.log(chalk.dim(` Schema source length: ${schemaSource.length} chars`));
84
+ console.log(chalk.dim(` Parsing schema...`));
82
85
  const tables = parseSchema(schemaSource);
86
+ console.log(chalk.dim(` Parsed ${tables.length} tables`));
83
87
  spinner.text = `Found ${tables.length} table(s)`;
88
+ console.log(chalk.dim(` Generating SQL...`));
84
89
  const sql = generateSchemaSQL(tables);
90
+ console.log(chalk.dim(` Generated SQL length: ${sql.length} chars`));
85
91
  if (dryRun) {
86
92
  spinner.info("Dry run - would deploy schema:");
87
93
  for (const table of tables) {
@@ -129,7 +135,14 @@ async function deploySchemaToServer(projectId, token, schemaPath, environment, d
129
135
  spinner.succeed(`Schema deployed (${tables.length} table(s))`);
130
136
  } catch (error) {
131
137
  spinner.fail("Failed to deploy schema");
132
- console.error(chalk.red(error instanceof Error ? error.message : "Unknown error"));
138
+ if (error instanceof Error) {
139
+ console.error(chalk.red(error.message));
140
+ if (error.stack) {
141
+ console.error(chalk.dim(error.stack));
142
+ }
143
+ } else {
144
+ console.error(chalk.red("Unknown error:"), error);
145
+ }
133
146
  }
134
147
  }
135
148
  async function deployFunctionsToServer(projectId, token, functionsDir, environment, dryRun) {
@@ -266,40 +279,15 @@ function parseSchema(source) {
266
279
  const colName = colMatch[1];
267
280
  const colType = colMatch[2];
268
281
  const modifiers = colMatch[3];
269
- if (colName === "_id" || colName === "_createdAt") {
270
- console.warn(`Warning: Column '${colName}' is a reserved system column and will be ignored.`);
271
- continue;
272
- }
273
- const userWantsPrimaryKey = modifiers.includes(".primaryKey()");
274
- if (userWantsPrimaryKey) {
275
- console.warn(`Warning: Column '${colName}' has .primaryKey() which will be ignored. Tether uses '_id' as the primary key.`);
276
- }
277
282
  columns[colName] = {
278
283
  type: colType,
279
- primaryKey: false,
280
- // _id is always the primary key, ignore user-defined primary keys
284
+ primaryKey: modifiers.includes(".primaryKey()"),
281
285
  notNull: modifiers.includes(".notNull()"),
282
- unique: modifiers.includes(".unique()") || userWantsPrimaryKey,
283
- // Make it unique if they wanted PK
286
+ unique: modifiers.includes(".unique()"),
284
287
  hasDefault: modifiers.includes(".default("),
285
288
  references: modifiers.match(/\.references\s*\(\s*['"]([^'"]+)['"]\s*\)/)?.[1]
286
289
  };
287
290
  }
288
- columns["_id"] = {
289
- type: "text",
290
- primaryKey: true,
291
- notNull: true,
292
- unique: true,
293
- // Also set unique so ALTER TABLE adds UNIQUE constraint
294
- hasDefault: false
295
- };
296
- columns["_createdAt"] = {
297
- type: "timestamp",
298
- primaryKey: false,
299
- notNull: true,
300
- unique: false,
301
- hasDefault: true
302
- };
303
291
  tables.push({ name: tableName, columns, source: tableSource });
304
292
  }
305
293
  return tables;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tthr",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "description": "Tether CLI - project scaffolding and deployment",
5
5
  "type": "module",
6
6
  "bin": {