@zodic/shared 0.0.391 → 0.0.393
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/db/migrations/0019_abandoned_orphan.sql +59 -0
- package/db/migrations/meta/0019_snapshot.json +3244 -0
- package/db/migrations/meta/_journal.json +7 -0
- package/db/schema.ts +79 -4
- package/package.json +1 -1
- package/types/scopes/generic.ts +8 -0
- package/utils/index.ts +0 -2
- package/utils/productLabels.ts +46 -0
package/db/schema.ts
CHANGED
|
@@ -37,21 +37,96 @@ export const users = sqliteTable(
|
|
|
37
37
|
tzone: real('tzone'), // Nullable for inferred timezone
|
|
38
38
|
birthLocation: text('birth_location').notNull(),
|
|
39
39
|
instagramUsername: text('instagram_username').unique(), // Nullable for optional social media
|
|
40
|
-
tiktokUsername: text('tiktok_username').unique(),
|
|
40
|
+
tiktokUsername: text('tiktok_username').unique(),
|
|
41
41
|
oauthProvider: text('oauth_provider'), // e.g., "google", "facebook", "apple", nullable for password-based login
|
|
42
42
|
oauthProviderId: text('oauth_provider_id').unique(), // Unique identifier from the provider
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
customerId: text('customer_id'), // Asaas customer ID (e.g., "cus_000000018936"), nullable
|
|
44
|
+
creditsBalance: integer('credits_balance').default(0).notNull(), // Can be removed if credits are obsolete
|
|
45
|
+
totalCreditsEarned: integer('total_credits_earned').default(0).notNull(), // Can be removed if credits are obsolete
|
|
45
46
|
lastTransactionAt: integer('last_transaction_at', { mode: 'timestamp' }), // Nullable for no transactions
|
|
46
47
|
language: text('language').notNull(),
|
|
47
48
|
...timestampFields,
|
|
48
49
|
},
|
|
49
50
|
(t) => [
|
|
50
51
|
index('users_email_idx').on(t.email),
|
|
51
|
-
index('users_oauth_provider_idx').on(t.oauthProvider, t.oauthProviderId),
|
|
52
|
+
index('users_oauth_provider_idx').on(t.oauthProvider, t.oauthProviderId),
|
|
53
|
+
index('users_customer_id_idx').on(t.customerId), // Index for efficient lookups by customerId
|
|
52
54
|
]
|
|
53
55
|
);
|
|
54
56
|
|
|
57
|
+
export const products = sqliteTable(
|
|
58
|
+
'products',
|
|
59
|
+
{
|
|
60
|
+
id: text('id').primaryKey(), // Unique product ID (e.g., UUID)
|
|
61
|
+
slug: text('slug').notNull().unique(), // e.g., "premium-astrology-reports", "concepts", "cosmic-mirror"
|
|
62
|
+
price: real('price').notNull(), // Price in BRL (e.g., 49.90)
|
|
63
|
+
imageUrl: text('image_url'), // Nullable URL for the product image in the app
|
|
64
|
+
imageBase64: text('image_base64'), // Nullable Base64-encoded image for Asaas checkout
|
|
65
|
+
...timestampFields,
|
|
66
|
+
},
|
|
67
|
+
(t) => [index('products_slug_idx').on(t.slug)]
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
export const userProducts = sqliteTable(
|
|
71
|
+
'user_products',
|
|
72
|
+
{
|
|
73
|
+
id: text('id').primaryKey(), // Unique ID for the user-product association
|
|
74
|
+
userId: text('user_id')
|
|
75
|
+
.notNull()
|
|
76
|
+
.references(() => users.id, { onDelete: 'cascade' }),
|
|
77
|
+
productId: text('product_id')
|
|
78
|
+
.notNull()
|
|
79
|
+
.references(() => products.id, { onDelete: 'cascade' }),
|
|
80
|
+
checkoutId: text('checkout_id'), // Asaas checkout ID (e.g., "2bd251f0-09b2-44ff-8a0c-a5cb29e5bbda")
|
|
81
|
+
paymentId: text('payment_id').references(() => payments.id, {
|
|
82
|
+
onDelete: 'set null',
|
|
83
|
+
}), // Nullable if payment fails
|
|
84
|
+
status: text('status', {
|
|
85
|
+
enum: ['processing_payment', 'unlocked', 'locked'],
|
|
86
|
+
})
|
|
87
|
+
.notNull()
|
|
88
|
+
.default('locked'),
|
|
89
|
+
|
|
90
|
+
...timestampFields,
|
|
91
|
+
},
|
|
92
|
+
(t) => [
|
|
93
|
+
index('user_products_user_id_idx').on(t.userId),
|
|
94
|
+
index('user_products_product_id_idx').on(t.productId),
|
|
95
|
+
index('user_products_payment_id_idx').on(t.paymentId),
|
|
96
|
+
index('user_products_checkout_id_idx').on(t.checkoutId),
|
|
97
|
+
]
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
export const payments = sqliteTable(
|
|
101
|
+
'payments',
|
|
102
|
+
{
|
|
103
|
+
id: text('id').primaryKey(), // Unique payment ID
|
|
104
|
+
userId: text('user_id')
|
|
105
|
+
.notNull()
|
|
106
|
+
.references(() => users.id, { onDelete: 'cascade' }),
|
|
107
|
+
checkoutId: text('checkout_id').notNull().unique(), // Asaas checkout ID
|
|
108
|
+
amount: real('amount').notNull(), // Total amount in BRL
|
|
109
|
+
status: text('status', { enum: ['pending', 'completed', 'failed', 'expired', 'canceled'] }).notNull().default('pending'),
|
|
110
|
+
...timestampFields,
|
|
111
|
+
},
|
|
112
|
+
(t) => [
|
|
113
|
+
index('payments_user_id_idx').on(t.userId),
|
|
114
|
+
index('payments_checkout_id_idx').on(t.checkoutId),
|
|
115
|
+
]
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
export const asaasEvents = sqliteTable(
|
|
119
|
+
'asaas_events',
|
|
120
|
+
{
|
|
121
|
+
id: text('id').primaryKey(), // Unique event ID (can use Asaas event ID or generate your own)
|
|
122
|
+
asaasEventId: text('asaas_event_id').notNull().unique(), // Asaas event ID (e.g., "evt_37260be8159d4472b4458d3de13efc2d&15370")
|
|
123
|
+
payload: text('payload').notNull(), // JSON string of the webhook payload
|
|
124
|
+
status: text('status', { enum: ['pending', 'done'] }).notNull().default('pending'),
|
|
125
|
+
...timestampFields,
|
|
126
|
+
},
|
|
127
|
+
(t) => [index('asaas_events_asaas_event_id_idx').on(t.asaasEventId)]
|
|
128
|
+
);
|
|
129
|
+
|
|
55
130
|
export const conceptsData = sqliteTable(
|
|
56
131
|
'concepts_data',
|
|
57
132
|
{
|
package/package.json
CHANGED
package/types/scopes/generic.ts
CHANGED
|
@@ -655,3 +655,11 @@ export enum Status {
|
|
|
655
655
|
Processing = 'Processing',
|
|
656
656
|
Staged = 'Staged',
|
|
657
657
|
}
|
|
658
|
+
|
|
659
|
+
export interface ProductLabels {
|
|
660
|
+
[key: string]: {
|
|
661
|
+
'pt-br': { name: string; description: string };
|
|
662
|
+
'en-us': { name: string; description: string };
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
|
package/utils/index.ts
CHANGED
|
@@ -13,8 +13,6 @@ export const verifyToken = async (
|
|
|
13
13
|
token: string
|
|
14
14
|
): Promise<{ userId: string; email?: string; roles?: string[] }> => {
|
|
15
15
|
const jwtSecret = await c.env.JWT_SECRET.get();
|
|
16
|
-
console.log('JWT_SECRET: ', c.env.JWT_SECRET)
|
|
17
|
-
console.log('JWT_SECRET.get(): ', jwtSecret)
|
|
18
16
|
const audience = c.env.GOOGLE_OAUTH_CLIENT_ID;
|
|
19
17
|
const issuer = 'https://accounts.google.com';
|
|
20
18
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Languages, ProductLabels } from "../types";
|
|
2
|
+
|
|
3
|
+
export const productLabels: ProductLabels = {
|
|
4
|
+
'premium-astrology-reports': {
|
|
5
|
+
'pt-br': {
|
|
6
|
+
name: 'Leitura Astrológica Premium',
|
|
7
|
+
description: 'Desbloqueie relatórios de posições avançadas, casas e aspectos.',
|
|
8
|
+
},
|
|
9
|
+
'en-us': {
|
|
10
|
+
name: 'Premium Astrology Reports',
|
|
11
|
+
description: 'Unlock advanced reports, houses, and aspects.',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
concepts: {
|
|
15
|
+
'pt-br': {
|
|
16
|
+
name: 'Conceitos',
|
|
17
|
+
description:
|
|
18
|
+
'Desbloqueie todos os Conceitos.',
|
|
19
|
+
},
|
|
20
|
+
'en-us': {
|
|
21
|
+
name: 'Concepts',
|
|
22
|
+
description: 'Unlock all Concepts.',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
'cosmic-mirror': {
|
|
26
|
+
'pt-br': {
|
|
27
|
+
name: 'Espelho Cósmico',
|
|
28
|
+
description: 'Contemple-se com os olhos do Universo.',
|
|
29
|
+
},
|
|
30
|
+
'en-us': {
|
|
31
|
+
name: 'Cosmic Mirror',
|
|
32
|
+
description: 'See yourself as the Universe sees you.',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const getProductLabel = (slug: string, lang: Languages) => {
|
|
38
|
+
console.log('getProductLabel -> Slug: ', slug)
|
|
39
|
+
console.log('getProductLabel -> Lang: ', lang)
|
|
40
|
+
const labels = productLabels[slug] || {
|
|
41
|
+
'pt-br': { name: slug, description: '' },
|
|
42
|
+
'en-us': { name: slug, description: '' },
|
|
43
|
+
};
|
|
44
|
+
console.log('getProductLabel -> Labels: ', labels)
|
|
45
|
+
return labels[lang];
|
|
46
|
+
};
|