rimecms 0.32.0 → 0.32.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.
@@ -129,15 +129,17 @@ export declare const templateRelations: (tree: Record<string, string[]>, referen
129
129
  }[]) => string;
130
130
  /** Templates Field Relations */
131
131
  /**
132
- * Generates a foreign key column for a relation field
133
- * Creates a reference to another table's primary key with cascade delete
132
+ * The junction column pointing at one target collection. The property is keyed by the slug, which
133
+ * is how the adapter reads it back; the SQL column and the referenced table carry the table name.
134
134
  *
135
- * @example
136
- * ```typescript
135
+ * ```ts
136
+ * // 'medias'
137
137
  * mediasId: text('medias_id').references(() => medias.id, { onDelete: 'cascade' })
138
+ * // 'eventsCategories'
139
+ * eventsCategoriesId: text('events_categories_id').references(() => events_categories.id, { onDelete: 'cascade' })
138
140
  * ```
139
141
  */
140
- export declare const templateFieldRelationColumn: (table: string) => string;
142
+ export declare const templateFieldRelationColumn: (slug: string) => string;
141
143
  /**
142
144
  * Generates a junction table for many-to-many relationships
143
145
  * Creates a table with references to the owner table and related tables
@@ -208,16 +208,19 @@ ${entries.join(',\n')}
208
208
  };
209
209
  /** Templates Field Relations */
210
210
  /**
211
- * Generates a foreign key column for a relation field
212
- * Creates a reference to another table's primary key with cascade delete
211
+ * The junction column pointing at one target collection. The property is keyed by the slug, which
212
+ * is how the adapter reads it back; the SQL column and the referenced table carry the table name.
213
213
  *
214
- * @example
215
- * ```typescript
214
+ * ```ts
215
+ * // 'medias'
216
216
  * mediasId: text('medias_id').references(() => medias.id, { onDelete: 'cascade' })
217
+ * // 'eventsCategories'
218
+ * eventsCategoriesId: text('events_categories_id').references(() => events_categories.id, { onDelete: 'cascade' })
217
219
  * ```
218
220
  */
219
- export const templateFieldRelationColumn = (table) => {
220
- return `${table}Id: text('${s(table)}_id').references(() => ${table}.id, { onDelete: 'cascade' })`;
221
+ export const templateFieldRelationColumn = (slug) => {
222
+ const table = baseTableName(slug);
223
+ return `${slug}Id: text('${table}_id').references(() => ${table}.id, { onDelete: 'cascade' })`;
221
224
  };
222
225
  /**
223
226
  * Generates a junction table for many-to-many relationships
@@ -23,7 +23,12 @@ export function regenerateModulesDeclaration() {
23
23
  })
24
24
  .filter((block) => block !== null)
25
25
  .join('\n\n');
26
- writeFileSync(path.resolve(process.cwd(), 'src/rime.modules.generated.d.ts'), `${blocks}\n`);
26
+ // Nothing to declare, no file.
27
+ const file = path.resolve(process.cwd(), 'src/rime.modules.generated.d.ts');
28
+ if (blocks)
29
+ writeFileSync(file, `${blocks}\n`);
30
+ else
31
+ rmSync(file, { force: true });
27
32
  }
28
33
  export function rime() {
29
34
  /** Two reserved names, always resolved to *the currently running app's* generated
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rimecms",
3
- "version": "0.32.0",
3
+ "version": "0.32.1",
4
4
  "homepage": "https://github.com/bienbiendev/rime",
5
5
  "packageManager": "bun@1.3.0",
6
6
  "scripts": {