@playcademy/sdk 0.0.1-beta.24 → 0.0.1-beta.26
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/README.md +4 -6
- package/dist/core/client.d.ts +67 -47
- package/dist/core/namespaces/admin.d.ts +24 -20
- package/dist/core/namespaces/auth.d.ts +1 -1
- package/dist/core/namespaces/credits.d.ts +1 -1
- package/dist/core/namespaces/dev.d.ts +185 -15
- package/dist/core/namespaces/games.d.ts +8 -4
- package/dist/core/namespaces/levels.d.ts +2 -2
- package/dist/core/namespaces/maps.d.ts +4 -9
- package/dist/core/namespaces/runtime.d.ts +1 -2
- package/dist/core/namespaces/shop.d.ts +1 -2
- package/dist/core/namespaces/telemetry.d.ts +1 -1
- package/dist/core/namespaces/users.d.ts +18 -18
- package/dist/core/request.d.ts +1 -1
- package/dist/core/static/init.d.ts +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +575 -97
- package/dist/types.d.ts +3 -36
- package/dist/types.js +363 -8
- package/package.json +5 -3
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
1
|
+
export type * from '@playcademy/data/types';
|
|
2
|
+
export { CURRENCIES, BADGES } from '@playcademy/data/constants';
|
|
3
|
+
export type { PlaycademyClient } from './core/client';
|
|
3
4
|
export interface ClientConfig {
|
|
4
5
|
baseUrl: string;
|
|
5
6
|
token?: string;
|
|
@@ -33,11 +34,6 @@ export type GameContextPayload = {
|
|
|
33
34
|
export type EventListeners = {
|
|
34
35
|
[E in keyof ClientEvents]?: Array<(payload: ClientEvents[E]) => void>;
|
|
35
36
|
};
|
|
36
|
-
export type GameWithManifest = Game & {
|
|
37
|
-
manifest: ManifestV1;
|
|
38
|
-
};
|
|
39
|
-
export type DeveloperStatusValue = DeveloperStatusResponse['status'];
|
|
40
|
-
export type GameState = Record<string, unknown>;
|
|
41
37
|
export type LoginResponse = {
|
|
42
38
|
token: string;
|
|
43
39
|
};
|
|
@@ -51,32 +47,3 @@ export type StartSessionResponse = {
|
|
|
51
47
|
export type InventoryMutationResponse = {
|
|
52
48
|
newTotal: number;
|
|
53
49
|
};
|
|
54
|
-
export interface ShopDisplayItem extends Item {
|
|
55
|
-
listingId: string;
|
|
56
|
-
shopPrice: number;
|
|
57
|
-
currencyId: string;
|
|
58
|
-
currencySymbol?: string | null;
|
|
59
|
-
currencyDisplayName?: string | null;
|
|
60
|
-
currencyImageUrl?: string | null;
|
|
61
|
-
stock?: number | null;
|
|
62
|
-
sellBackPercentage?: number | null;
|
|
63
|
-
}
|
|
64
|
-
export interface UserCurrencyInfo {
|
|
65
|
-
id: string;
|
|
66
|
-
balance: number;
|
|
67
|
-
symbol?: string | null;
|
|
68
|
-
imageUrl?: string | null;
|
|
69
|
-
isPrimary: boolean;
|
|
70
|
-
}
|
|
71
|
-
export interface CurrencyInfo {
|
|
72
|
-
id: string;
|
|
73
|
-
symbol?: string | null;
|
|
74
|
-
imageUrl?: string | null;
|
|
75
|
-
displayName?: string | null;
|
|
76
|
-
isPrimary: boolean;
|
|
77
|
-
}
|
|
78
|
-
export interface ShopViewResponse {
|
|
79
|
-
shopItems: ShopDisplayItem[];
|
|
80
|
-
currencies: CurrencyInfo[];
|
|
81
|
-
}
|
|
82
|
-
export type { User, InventoryItemWithItem, Game, ManifestV1, DeveloperKey, DeveloperStatusResponse, MapElement, Item, InsertItem, UpdateItem, Currency, InsertCurrency, UpdateCurrency, ShopListing, InsertShopListing, UpdateShopListing, UserLevel, LevelConfig, XPAddResult, UserLevelWithConfig, XPActionInput, };
|
package/dist/types.js
CHANGED
|
@@ -10,10 +10,365 @@ var __export = (target, all) => {
|
|
|
10
10
|
};
|
|
11
11
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
12
12
|
|
|
13
|
+
// ../data/src/domains/user/table.ts
|
|
14
|
+
import { boolean, pgEnum, pgTable, text, timestamp, uniqueIndex } from "drizzle-orm/pg-core";
|
|
15
|
+
var userRoleEnum, developerStatusEnum, users, accounts, sessions, verification;
|
|
16
|
+
var init_table = __esm(() => {
|
|
17
|
+
userRoleEnum = pgEnum("user_role", ["admin", "player", "developer"]);
|
|
18
|
+
developerStatusEnum = pgEnum("developer_status", ["none", "pending", "approved"]);
|
|
19
|
+
users = pgTable("user", {
|
|
20
|
+
id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
21
|
+
name: text("name").notNull(),
|
|
22
|
+
username: text("username").unique(),
|
|
23
|
+
email: text("email").notNull().unique(),
|
|
24
|
+
emailVerified: boolean("email_verified").notNull().default(false),
|
|
25
|
+
image: text("image"),
|
|
26
|
+
role: userRoleEnum("role").notNull().default("player"),
|
|
27
|
+
developerStatus: developerStatusEnum("developer_status").notNull().default("none"),
|
|
28
|
+
createdAt: timestamp("created_at", {
|
|
29
|
+
mode: "date",
|
|
30
|
+
withTimezone: true
|
|
31
|
+
}).notNull(),
|
|
32
|
+
updatedAt: timestamp("updated_at", {
|
|
33
|
+
mode: "date",
|
|
34
|
+
withTimezone: true
|
|
35
|
+
}).notNull()
|
|
36
|
+
});
|
|
37
|
+
accounts = pgTable("account", {
|
|
38
|
+
id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
39
|
+
userId: text("userId").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
40
|
+
accountId: text("account_id").notNull(),
|
|
41
|
+
providerId: text("provider_id").notNull(),
|
|
42
|
+
accessToken: text("access_token"),
|
|
43
|
+
refreshToken: text("refresh_token"),
|
|
44
|
+
idToken: text("id_token"),
|
|
45
|
+
accessTokenExpiresAt: timestamp("access_token_expires_at", {
|
|
46
|
+
mode: "date",
|
|
47
|
+
withTimezone: true
|
|
48
|
+
}),
|
|
49
|
+
refreshTokenExpiresAt: timestamp("refresh_token_expires_at", {
|
|
50
|
+
mode: "date",
|
|
51
|
+
withTimezone: true
|
|
52
|
+
}),
|
|
53
|
+
scope: text("scope"),
|
|
54
|
+
password: text("password"),
|
|
55
|
+
createdAt: timestamp("created_at", {
|
|
56
|
+
mode: "date",
|
|
57
|
+
withTimezone: true
|
|
58
|
+
}).notNull(),
|
|
59
|
+
updatedAt: timestamp("updated_at", {
|
|
60
|
+
mode: "date",
|
|
61
|
+
withTimezone: true
|
|
62
|
+
}).notNull()
|
|
63
|
+
}, (table) => [uniqueIndex("account_provider_providerId_idx").on(table.accountId, table.providerId)]);
|
|
64
|
+
sessions = pgTable("session", {
|
|
65
|
+
id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
66
|
+
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
67
|
+
expiresAt: timestamp("expires_at", {
|
|
68
|
+
mode: "date",
|
|
69
|
+
withTimezone: true
|
|
70
|
+
}).notNull(),
|
|
71
|
+
token: text("token").notNull().unique(),
|
|
72
|
+
ipAddress: text("ip_address"),
|
|
73
|
+
userAgent: text("user_agent"),
|
|
74
|
+
createdAt: timestamp("created_at", {
|
|
75
|
+
mode: "date",
|
|
76
|
+
withTimezone: true
|
|
77
|
+
}).notNull(),
|
|
78
|
+
updatedAt: timestamp("updated_at", {
|
|
79
|
+
mode: "date",
|
|
80
|
+
withTimezone: true
|
|
81
|
+
}).notNull()
|
|
82
|
+
});
|
|
83
|
+
verification = pgTable("verification", {
|
|
84
|
+
id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
85
|
+
identifier: text("identifier").notNull(),
|
|
86
|
+
value: text("value").notNull(),
|
|
87
|
+
expiresAt: timestamp("expires_at", {
|
|
88
|
+
mode: "date",
|
|
89
|
+
withTimezone: true
|
|
90
|
+
}).notNull(),
|
|
91
|
+
createdAt: timestamp("created_at", {
|
|
92
|
+
mode: "date",
|
|
93
|
+
withTimezone: true
|
|
94
|
+
}).notNull(),
|
|
95
|
+
updatedAt: timestamp("updated_at", {
|
|
96
|
+
mode: "date",
|
|
97
|
+
withTimezone: true
|
|
98
|
+
}).notNull()
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// ../data/src/domains/developer/table.ts
|
|
103
|
+
import { pgTable as pgTable2, text as text2, timestamp as timestamp2, uuid, varchar } from "drizzle-orm/pg-core";
|
|
104
|
+
var developerKeys;
|
|
105
|
+
var init_table2 = __esm(() => {
|
|
106
|
+
init_table();
|
|
107
|
+
developerKeys = pgTable2("developer_keys", {
|
|
108
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
109
|
+
userId: text2("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
110
|
+
label: varchar("label", { length: 255 }),
|
|
111
|
+
keyHash: text2("key_hash").notNull().unique(),
|
|
112
|
+
createdAt: timestamp2("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// ../data/src/domains/map/table.ts
|
|
117
|
+
import { relations } from "drizzle-orm";
|
|
118
|
+
import {
|
|
119
|
+
doublePrecision,
|
|
120
|
+
jsonb,
|
|
121
|
+
pgEnum as pgEnum2,
|
|
122
|
+
pgTable as pgTable3,
|
|
123
|
+
text as text3,
|
|
124
|
+
uniqueIndex as uniqueIndex2,
|
|
125
|
+
uuid as uuid2,
|
|
126
|
+
varchar as varchar2
|
|
127
|
+
} from "drizzle-orm/pg-core";
|
|
128
|
+
var interactionTypeEnum, maps, mapElements, mapElementsRelations, mapsRelations;
|
|
129
|
+
var init_table3 = __esm(() => {
|
|
130
|
+
init_table4();
|
|
131
|
+
interactionTypeEnum = pgEnum2("interaction_type", [
|
|
132
|
+
"game_entry",
|
|
133
|
+
"game_registry",
|
|
134
|
+
"info",
|
|
135
|
+
"teleport",
|
|
136
|
+
"door_in",
|
|
137
|
+
"door_out",
|
|
138
|
+
"npc_interaction",
|
|
139
|
+
"quest_trigger"
|
|
140
|
+
]);
|
|
141
|
+
maps = pgTable3("maps", {
|
|
142
|
+
id: uuid2("id").primaryKey().defaultRandom(),
|
|
143
|
+
identifier: varchar2("identifier", { length: 255 }).notNull().unique(),
|
|
144
|
+
displayName: varchar2("display_name", { length: 255 }).notNull(),
|
|
145
|
+
filePath: varchar2("file_path", { length: 255 }).notNull(),
|
|
146
|
+
tilesetBasePath: varchar2("tileset_base_path", { length: 255 }).notNull().default("/tilesets"),
|
|
147
|
+
defaultSpawnTileX: doublePrecision("default_spawn_tile_x").notNull().default(0),
|
|
148
|
+
defaultSpawnTileY: doublePrecision("default_spawn_tile_y").notNull().default(0),
|
|
149
|
+
description: text3("description")
|
|
150
|
+
});
|
|
151
|
+
mapElements = pgTable3("map_elements", {
|
|
152
|
+
id: uuid2("id").primaryKey().defaultRandom(),
|
|
153
|
+
mapId: uuid2("map_id").references(() => maps.id, {
|
|
154
|
+
onDelete: "cascade"
|
|
155
|
+
}),
|
|
156
|
+
elementSlug: varchar2("element_slug", { length: 255 }).notNull(),
|
|
157
|
+
interactionType: interactionTypeEnum("interaction_type").notNull(),
|
|
158
|
+
gameId: uuid2("game_id").references(() => games.id, {
|
|
159
|
+
onDelete: "set null"
|
|
160
|
+
}),
|
|
161
|
+
metadata: jsonb("metadata").$type().default({})
|
|
162
|
+
}, (table) => [uniqueIndex2("map_id_element_slug_unique_idx").on(table.mapId, table.elementSlug)]);
|
|
163
|
+
mapElementsRelations = relations(mapElements, ({ one }) => ({
|
|
164
|
+
game: one(games, {
|
|
165
|
+
fields: [mapElements.gameId],
|
|
166
|
+
references: [games.id]
|
|
167
|
+
}),
|
|
168
|
+
map: one(maps, {
|
|
169
|
+
fields: [mapElements.mapId],
|
|
170
|
+
references: [maps.id]
|
|
171
|
+
})
|
|
172
|
+
}));
|
|
173
|
+
mapsRelations = relations(maps, ({ many }) => ({
|
|
174
|
+
elements: many(mapElements)
|
|
175
|
+
}));
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// ../data/src/domains/game/table.ts
|
|
179
|
+
import {
|
|
180
|
+
jsonb as jsonb2,
|
|
181
|
+
pgEnum as pgEnum3,
|
|
182
|
+
pgTable as pgTable4,
|
|
183
|
+
text as text4,
|
|
184
|
+
timestamp as timestamp3,
|
|
185
|
+
uniqueIndex as uniqueIndex3,
|
|
186
|
+
uuid as uuid3,
|
|
187
|
+
varchar as varchar3
|
|
188
|
+
} from "drizzle-orm/pg-core";
|
|
189
|
+
var gamePlatformEnum, gameBootModeEnum, games, gameSessions, gameStates;
|
|
190
|
+
var init_table4 = __esm(() => {
|
|
191
|
+
init_table3();
|
|
192
|
+
init_table();
|
|
193
|
+
gamePlatformEnum = pgEnum3("game_platform", ["web", "godot", "unity"]);
|
|
194
|
+
gameBootModeEnum = pgEnum3("game_boot_mode", ["iframe", "module"]);
|
|
195
|
+
games = pgTable4("games", {
|
|
196
|
+
id: uuid3("id").primaryKey().defaultRandom(),
|
|
197
|
+
developerId: text4("developer_id").references(() => users.id, {
|
|
198
|
+
onDelete: "set null"
|
|
199
|
+
}),
|
|
200
|
+
slug: varchar3("slug", { length: 255 }).notNull().unique(),
|
|
201
|
+
displayName: varchar3("display_name", { length: 255 }).notNull(),
|
|
202
|
+
version: varchar3("version", { length: 50 }).notNull(),
|
|
203
|
+
assetBundleBase: text4("asset_bundle_base").notNull(),
|
|
204
|
+
platform: gamePlatformEnum("platform").notNull().default("web"),
|
|
205
|
+
mapElementId: uuid3("map_element_id").references(() => mapElements.id, {
|
|
206
|
+
onDelete: "set null"
|
|
207
|
+
}),
|
|
208
|
+
metadata: jsonb2("metadata").default("{}"),
|
|
209
|
+
createdAt: timestamp3("created_at", { withTimezone: true }).defaultNow(),
|
|
210
|
+
updatedAt: timestamp3("updated_at", { withTimezone: true }).defaultNow()
|
|
211
|
+
});
|
|
212
|
+
gameSessions = pgTable4("game_sessions", {
|
|
213
|
+
id: uuid3("id").primaryKey().defaultRandom(),
|
|
214
|
+
userId: text4("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
215
|
+
gameId: uuid3("game_id").notNull().references(() => games.id, { onDelete: "cascade" }),
|
|
216
|
+
startedAt: timestamp3("started_at", { withTimezone: true }).notNull().defaultNow(),
|
|
217
|
+
endedAt: timestamp3("ended_at", { withTimezone: true })
|
|
218
|
+
});
|
|
219
|
+
gameStates = pgTable4("game_states", {
|
|
220
|
+
userId: text4("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
221
|
+
gameId: uuid3("game_id").notNull().references(() => games.id, { onDelete: "cascade" }),
|
|
222
|
+
data: jsonb2("data").default("{}"),
|
|
223
|
+
updatedAt: timestamp3("updated_at", { withTimezone: true }).defaultNow()
|
|
224
|
+
}, (table) => [uniqueIndex3("unique_user_game_idx").on(table.userId, table.gameId)]);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// ../data/src/domains/inventory/table.ts
|
|
228
|
+
import { relations as relations2, sql } from "drizzle-orm";
|
|
229
|
+
import {
|
|
230
|
+
boolean as boolean2,
|
|
231
|
+
integer,
|
|
232
|
+
jsonb as jsonb3,
|
|
233
|
+
pgEnum as pgEnum4,
|
|
234
|
+
pgTable as pgTable5,
|
|
235
|
+
text as text5,
|
|
236
|
+
timestamp as timestamp4,
|
|
237
|
+
uniqueIndex as uniqueIndex4,
|
|
238
|
+
uuid as uuid4
|
|
239
|
+
} from "drizzle-orm/pg-core";
|
|
240
|
+
var itemTypeEnum, items, inventoryItems, currencies, shopListings, itemsRelations, currenciesRelations, shopListingsRelations, inventoryItemsRelations;
|
|
241
|
+
var init_table5 = __esm(() => {
|
|
242
|
+
init_table4();
|
|
243
|
+
init_table();
|
|
244
|
+
itemTypeEnum = pgEnum4("item_type", [
|
|
245
|
+
"currency",
|
|
246
|
+
"badge",
|
|
247
|
+
"trophy",
|
|
248
|
+
"collectible",
|
|
249
|
+
"consumable",
|
|
250
|
+
"unlock",
|
|
251
|
+
"upgrade",
|
|
252
|
+
"other"
|
|
253
|
+
]);
|
|
254
|
+
items = pgTable5("items", {
|
|
255
|
+
id: uuid4("id").primaryKey().defaultRandom(),
|
|
256
|
+
slug: text5("slug").notNull(),
|
|
257
|
+
gameId: uuid4("game_id").references(() => games.id, {
|
|
258
|
+
onDelete: "cascade"
|
|
259
|
+
}),
|
|
260
|
+
displayName: text5("display_name").notNull(),
|
|
261
|
+
description: text5("description"),
|
|
262
|
+
type: itemTypeEnum("type").notNull().default("other"),
|
|
263
|
+
imageUrl: text5("image_url"),
|
|
264
|
+
metadata: jsonb3("metadata").default({}),
|
|
265
|
+
createdAt: timestamp4("created_at").defaultNow().notNull()
|
|
266
|
+
}, (table) => [
|
|
267
|
+
uniqueIndex4("items_game_slug_idx").on(table.gameId, table.slug),
|
|
268
|
+
uniqueIndex4("items_global_slug_idx").on(table.slug).where(sql`game_id IS NULL`)
|
|
269
|
+
]);
|
|
270
|
+
inventoryItems = pgTable5("inventory_items", {
|
|
271
|
+
id: uuid4("id").primaryKey().defaultRandom(),
|
|
272
|
+
userId: text5("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
273
|
+
itemId: uuid4("item_id").notNull().references(() => items.id, { onDelete: "cascade" }),
|
|
274
|
+
quantity: integer("quantity").notNull().default(1),
|
|
275
|
+
updatedAt: timestamp4("updated_at", { withTimezone: true }).defaultNow()
|
|
276
|
+
}, (table) => [uniqueIndex4("unique_user_item_idx").on(table.userId, table.itemId)]);
|
|
277
|
+
currencies = pgTable5("currencies", {
|
|
278
|
+
id: uuid4("id").primaryKey().defaultRandom(),
|
|
279
|
+
itemId: uuid4("item_id").notNull().references(() => items.id, { onDelete: "cascade" }),
|
|
280
|
+
symbol: text5("symbol"),
|
|
281
|
+
isPrimary: boolean2("is_primary").default(false).notNull(),
|
|
282
|
+
createdAt: timestamp4("created_at").defaultNow().notNull(),
|
|
283
|
+
updatedAt: timestamp4("updated_at", { withTimezone: true }).defaultNow().$onUpdate(() => new Date)
|
|
284
|
+
}, (table) => [uniqueIndex4("currency_item_id_idx").on(table.itemId)]);
|
|
285
|
+
shopListings = pgTable5("shop_listings", {
|
|
286
|
+
id: uuid4("id").primaryKey().defaultRandom(),
|
|
287
|
+
itemId: uuid4("item_id").notNull().references(() => items.id, { onDelete: "cascade" }),
|
|
288
|
+
currencyId: uuid4("currency_id").notNull().references(() => currencies.id, { onDelete: "restrict" }),
|
|
289
|
+
price: integer("price").notNull(),
|
|
290
|
+
sellBackPercentage: integer("sell_back_percentage"),
|
|
291
|
+
stock: integer("stock"),
|
|
292
|
+
isActive: boolean2("is_active").default(true).notNull(),
|
|
293
|
+
availableFrom: timestamp4("available_from", { withTimezone: true }),
|
|
294
|
+
availableUntil: timestamp4("available_until", { withTimezone: true }),
|
|
295
|
+
createdAt: timestamp4("created_at").defaultNow().notNull(),
|
|
296
|
+
updatedAt: timestamp4("updated_at", { withTimezone: true }).defaultNow().$onUpdate(() => new Date)
|
|
297
|
+
}, (table) => [uniqueIndex4("unique_item_currency_listing_idx").on(table.itemId, table.currencyId)]);
|
|
298
|
+
itemsRelations = relations2(items, ({ many }) => ({
|
|
299
|
+
shopListings: many(shopListings),
|
|
300
|
+
inventoryItems: many(inventoryItems)
|
|
301
|
+
}));
|
|
302
|
+
currenciesRelations = relations2(currencies, ({ many }) => ({
|
|
303
|
+
shopListings: many(shopListings)
|
|
304
|
+
}));
|
|
305
|
+
shopListingsRelations = relations2(shopListings, ({ one }) => ({
|
|
306
|
+
item: one(items, {
|
|
307
|
+
fields: [shopListings.itemId],
|
|
308
|
+
references: [items.id]
|
|
309
|
+
}),
|
|
310
|
+
currency: one(currencies, {
|
|
311
|
+
fields: [shopListings.currencyId],
|
|
312
|
+
references: [currencies.id]
|
|
313
|
+
})
|
|
314
|
+
}));
|
|
315
|
+
inventoryItemsRelations = relations2(inventoryItems, ({ one }) => ({
|
|
316
|
+
item: one(items, {
|
|
317
|
+
fields: [inventoryItems.itemId],
|
|
318
|
+
references: [items.id]
|
|
319
|
+
}),
|
|
320
|
+
user: one(users, {
|
|
321
|
+
fields: [inventoryItems.userId],
|
|
322
|
+
references: [users.id]
|
|
323
|
+
})
|
|
324
|
+
}));
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
// ../data/src/domains/level/table.ts
|
|
328
|
+
import { relations as relations3 } from "drizzle-orm";
|
|
329
|
+
import { integer as integer2, pgTable as pgTable6, text as text6, timestamp as timestamp5, uniqueIndex as uniqueIndex5, uuid as uuid5 } from "drizzle-orm/pg-core";
|
|
330
|
+
var userLevels, levelConfigs, userLevelsRelations;
|
|
331
|
+
var init_table6 = __esm(() => {
|
|
332
|
+
init_table();
|
|
333
|
+
userLevels = pgTable6("user_levels", {
|
|
334
|
+
userId: text6("user_id").primaryKey().references(() => users.id, { onDelete: "cascade" }),
|
|
335
|
+
currentLevel: integer2("current_level").notNull().default(1),
|
|
336
|
+
currentXp: integer2("current_xp").notNull().default(0),
|
|
337
|
+
totalXP: integer2("total_xp").notNull().default(0),
|
|
338
|
+
lastLevelUpAt: timestamp5("last_level_up_at", { withTimezone: true }),
|
|
339
|
+
createdAt: timestamp5("created_at").defaultNow().notNull(),
|
|
340
|
+
updatedAt: timestamp5("updated_at", { withTimezone: true }).defaultNow().$onUpdate(() => new Date)
|
|
341
|
+
});
|
|
342
|
+
levelConfigs = pgTable6("level_configs", {
|
|
343
|
+
id: uuid5("id").primaryKey().defaultRandom(),
|
|
344
|
+
level: integer2("level").notNull().unique(),
|
|
345
|
+
xpRequired: integer2("xp_required").notNull(),
|
|
346
|
+
creditsReward: integer2("credits_reward").notNull().default(0),
|
|
347
|
+
createdAt: timestamp5("created_at").defaultNow().notNull()
|
|
348
|
+
}, (table) => [uniqueIndex5("unique_level_config_idx").on(table.level)]);
|
|
349
|
+
userLevelsRelations = relations3(userLevels, ({ one }) => ({
|
|
350
|
+
user: one(users, {
|
|
351
|
+
fields: [userLevels.userId],
|
|
352
|
+
references: [users.id]
|
|
353
|
+
})
|
|
354
|
+
}));
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// ../data/src/tables.index.ts
|
|
358
|
+
var init_tables_index = __esm(() => {
|
|
359
|
+
init_table();
|
|
360
|
+
init_table2();
|
|
361
|
+
init_table4();
|
|
362
|
+
init_table5();
|
|
363
|
+
init_table3();
|
|
364
|
+
init_table6();
|
|
365
|
+
});
|
|
366
|
+
|
|
13
367
|
// ../data/src/constants.ts
|
|
14
|
-
var
|
|
368
|
+
var ITEM_SLUGS, CURRENCIES, BADGES, INTERACTION_TYPE;
|
|
15
369
|
var init_constants = __esm(() => {
|
|
16
|
-
|
|
370
|
+
init_tables_index();
|
|
371
|
+
ITEM_SLUGS = {
|
|
17
372
|
PLAYCADEMY_CREDITS: "PLAYCADEMY_CREDITS",
|
|
18
373
|
PLAYCADEMY_XP: "PLAYCADEMY_XP",
|
|
19
374
|
FOUNDING_MEMBER_BADGE: "FOUNDING_MEMBER_BADGE",
|
|
@@ -24,20 +379,20 @@ var init_constants = __esm(() => {
|
|
|
24
379
|
SMALL_BACKPACK: "SMALL_BACKPACK"
|
|
25
380
|
};
|
|
26
381
|
CURRENCIES = {
|
|
27
|
-
PRIMARY:
|
|
28
|
-
XP:
|
|
382
|
+
PRIMARY: ITEM_SLUGS.PLAYCADEMY_CREDITS,
|
|
383
|
+
XP: ITEM_SLUGS.PLAYCADEMY_XP
|
|
29
384
|
};
|
|
30
385
|
BADGES = {
|
|
31
|
-
FOUNDING_MEMBER:
|
|
32
|
-
EARLY_ADOPTER:
|
|
33
|
-
FIRST_GAME:
|
|
386
|
+
FOUNDING_MEMBER: ITEM_SLUGS.FOUNDING_MEMBER_BADGE,
|
|
387
|
+
EARLY_ADOPTER: ITEM_SLUGS.EARLY_ADOPTER_BADGE,
|
|
388
|
+
FIRST_GAME: ITEM_SLUGS.FIRST_GAME_BADGE
|
|
34
389
|
};
|
|
390
|
+
INTERACTION_TYPE = Object.fromEntries(interactionTypeEnum.enumValues.map((value) => [value, value]));
|
|
35
391
|
});
|
|
36
392
|
|
|
37
393
|
// src/types.ts
|
|
38
394
|
init_constants();
|
|
39
395
|
export {
|
|
40
|
-
ITEM_INTERNAL_NAMES,
|
|
41
396
|
CURRENCIES,
|
|
42
397
|
BADGES
|
|
43
398
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcademy/sdk",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.26",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -24,14 +24,16 @@
|
|
|
24
24
|
"bump": "bunx bumpp --no-tag --no-push -c \"chore(@playcademy/sdk): release v%s\"",
|
|
25
25
|
"pub": "bun run build && bun run bump && bun publish --access public"
|
|
26
26
|
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@playcademy/logger": "0.0.1"
|
|
29
|
+
},
|
|
27
30
|
"devDependencies": {
|
|
28
|
-
"@playcademy/
|
|
31
|
+
"@playcademy/data": "0.0.1",
|
|
29
32
|
"@types/bun": "latest",
|
|
30
33
|
"typescript": "^5.7.2",
|
|
31
34
|
"yocto-spinner": "^0.2.2"
|
|
32
35
|
},
|
|
33
36
|
"peerDependencies": {
|
|
34
|
-
"@playcademy/types": "latest",
|
|
35
37
|
"drizzle-orm": "^0.42.0",
|
|
36
38
|
"typescript": "^5"
|
|
37
39
|
}
|