@zodic/shared 0.0.18 → 0.0.20

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.
@@ -22,6 +22,20 @@
22
22
  "when": 1737480263536,
23
23
  "tag": "0002_condemned_turbo",
24
24
  "breakpoints": true
25
+ },
26
+ {
27
+ "idx": 3,
28
+ "version": "6",
29
+ "when": 1737649237207,
30
+ "tag": "0003_cynical_frog_thor",
31
+ "breakpoints": true
32
+ },
33
+ {
34
+ "idx": 4,
35
+ "version": "6",
36
+ "when": 1737649768416,
37
+ "tag": "0004_light_masked_marvel",
38
+ "breakpoints": true
25
39
  }
26
40
  ]
27
41
  }
package/db/schema.ts CHANGED
@@ -7,6 +7,15 @@ import {
7
7
  text,
8
8
  } from 'drizzle-orm/sqlite-core';
9
9
 
10
+ export const timestampFields = {
11
+ createdAt: integer('created_at', { mode: 'timestamp' })
12
+ .default(sql`CURRENT_TIMESTAMP`)
13
+ .notNull(),
14
+ updatedAt: integer('updated_at', { mode: 'timestamp' })
15
+ .default(sql`CURRENT_TIMESTAMP`)
16
+ .notNull(),
17
+ };
18
+
10
19
  export const users = sqliteTable(
11
20
  'users',
12
21
  {
@@ -30,9 +39,7 @@ export const users = sqliteTable(
30
39
  credits_balance: integer('credits_balance'),
31
40
  totalCreditsEarned: integer('total_credits_earned').default(0),
32
41
  lastTransactionAt: integer('last_transaction_at', { mode: 'timestamp' }),
33
- createdAt: text('created_at')
34
- .default(sql`CURRENT_TIMESTAMP`)
35
- .notNull(),
42
+ ...timestampFields,
36
43
  },
37
44
  (t) => [index('users_email_idx').on(t.email)]
38
45
  );
@@ -50,9 +57,7 @@ export const creditsTransactions = sqliteTable(
50
57
  productType: text('product_type'), // e.g., "concept", "artifact", "astrology_report"
51
58
  productId: text('product_id'), // Corresponding ID for the product (concept_id, artifact_id, etc.)
52
59
  paymentId: text('payment_id'), // References the payment for purchases
53
- createdAt: integer('created_at', { mode: 'timestamp' }).default(
54
- sql`CURRENT_TIMESTAMP`
55
- ),
60
+ ...timestampFields,
56
61
  },
57
62
  (t) => [index('credits_transactions_user_id_idx').on(t.userId)]
58
63
  );
@@ -156,12 +161,7 @@ export const userConcepts = sqliteTable(
156
161
  conceptCombinationId: text('concept_combination_id')
157
162
  .notNull()
158
163
  .references(() => conceptCombinations.id, { onDelete: 'cascade' }),
159
- createdAt: integer('created_at', { mode: 'timestamp' }).default(
160
- sql`CURRENT_TIMESTAMP`
161
- ),
162
- updatedAt: integer('updated_at', { mode: 'timestamp' }).default(
163
- sql`CURRENT_TIMESTAMP`
164
- ),
164
+ ...timestampFields,
165
165
  },
166
166
  (t) => [
167
167
  index('user_concepts_user_id_idx').on(t.userId),
@@ -174,7 +174,7 @@ export const artifacts = sqliteTable(
174
174
  {
175
175
  id: text('id').primaryKey(),
176
176
  name: text('name').notNull(), // Name of the artifact (e.g., "Cosmic Mirror")
177
- slug: text('slug').notNull(), // Slug of the artifact (e.g., "cosmic-mirror")
177
+ slug: text('slug').notNull().unique(), // Slug of the artifact (e.g., "cosmic-mirror")
178
178
  conceptId: text('concept_id')
179
179
  .notNull()
180
180
  .references(() => concepts.id, { onDelete: 'cascade' }),
@@ -212,12 +212,7 @@ export const userArtifacts = sqliteTable(
212
212
  status: text('status')
213
213
  .default('pending') // Possible statuses: 'pending', 'post_ready', 'reel_ready', 'completed'
214
214
  .notNull(),
215
- createdAt: integer('created_at', { mode: 'timestamp' }).default(
216
- sql`CURRENT_TIMESTAMP`
217
- ),
218
- updatedAt: integer('updated_at', { mode: 'timestamp' }).default(
219
- sql`CURRENT_TIMESTAMP`
220
- ),
215
+ ...timestampFields,
221
216
  },
222
217
  (t) => [
223
218
  index('user_artifacts_user_id_idx').on(t.userId),
@@ -248,12 +243,7 @@ export const generations = sqliteTable(
248
243
  type: text('type').notNull(), // e.g., "concept_image"
249
244
  status: text('status').default('pending').notNull(), // "pending", "completed", "failed"
250
245
  url: text('url'), // URL for the generated image
251
- createdAt: integer('created_at', { mode: 'timestamp' }).default(
252
- sql`CURRENT_TIMESTAMP`
253
- ),
254
- updatedAt: integer('updated_at', { mode: 'timestamp' }).default(
255
- sql`CURRENT_TIMESTAMP`
256
- ),
246
+ ...timestampFields,
257
247
  },
258
248
  (t) => [
259
249
  index('generations_user_id_idx').on(t.userId),
@@ -269,12 +259,7 @@ export const artifactFaceswap = sqliteTable(
269
259
  .notNull()
270
260
  .references(() => userArtifacts.id, { onDelete: 'cascade' }),
271
261
  faceSwappedImageUrl: text('face_swapped_image_url'), // Final URL of the face-swapped image
272
- createdAt: integer('created_at', { mode: 'timestamp' }).default(
273
- sql`CURRENT_TIMESTAMP`
274
- ),
275
- updatedAt: integer('updated_at', { mode: 'timestamp' }).default(
276
- sql`CURRENT_TIMESTAMP`
277
- ),
262
+ ...timestampFields,
278
263
  },
279
264
  () => []
280
265
  );
@@ -290,6 +275,7 @@ export const artifactVideoGeneration = sqliteTable(
290
275
  videoUrl: text('video_url'), // URL of the final video
291
276
  description: text('description'), // Optional description for the video
292
277
  duration: integer('duration'), // Duration of the video in seconds
278
+ ...timestampFields,
293
279
  },
294
280
  (t) => [index('artifact_video_generation_status_idx').on(t.videoStatus)]
295
281
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zodic/shared",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "publishConfig": {