@playcademy/sdk 0.0.1-beta.3 → 0.0.1-beta.31

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/dist/types.js CHANGED
@@ -0,0 +1,589 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, {
5
+ get: all[name],
6
+ enumerable: true,
7
+ configurable: true,
8
+ set: (newValue) => all[name] = () => newValue
9
+ });
10
+ };
11
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
12
+
13
+ // ../data/src/domains/game/table.ts
14
+ import {
15
+ jsonb,
16
+ pgEnum,
17
+ pgTable,
18
+ text,
19
+ timestamp,
20
+ uniqueIndex,
21
+ uuid,
22
+ varchar
23
+ } from "drizzle-orm/pg-core";
24
+ var gamePlatformEnum, gameBootModeEnum, games, gameSessions, gameStates;
25
+ var init_table = __esm(() => {
26
+ init_table3();
27
+ init_table4();
28
+ gamePlatformEnum = pgEnum("game_platform", ["web", "godot", "unity"]);
29
+ gameBootModeEnum = pgEnum("game_boot_mode", ["iframe", "module"]);
30
+ games = pgTable("games", {
31
+ id: uuid("id").primaryKey().defaultRandom(),
32
+ developerId: text("developer_id").references(() => users.id, {
33
+ onDelete: "set null"
34
+ }),
35
+ slug: varchar("slug", { length: 255 }).notNull().unique(),
36
+ displayName: varchar("display_name", { length: 255 }).notNull(),
37
+ version: varchar("version", { length: 50 }).notNull(),
38
+ assetBundleBase: text("asset_bundle_base").notNull(),
39
+ platform: gamePlatformEnum("platform").notNull().default("web"),
40
+ mapElementId: uuid("map_element_id").references(() => mapElements.id, {
41
+ onDelete: "set null"
42
+ }),
43
+ metadata: jsonb("metadata").default("{}"),
44
+ createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
45
+ updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow()
46
+ });
47
+ gameSessions = pgTable("game_sessions", {
48
+ id: uuid("id").primaryKey().defaultRandom(),
49
+ userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
50
+ gameId: uuid("game_id").notNull().references(() => games.id, { onDelete: "cascade" }),
51
+ startedAt: timestamp("started_at", { withTimezone: true }).notNull().defaultNow(),
52
+ endedAt: timestamp("ended_at", { withTimezone: true })
53
+ });
54
+ gameStates = pgTable("game_states", {
55
+ userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
56
+ gameId: uuid("game_id").notNull().references(() => games.id, { onDelete: "cascade" }),
57
+ data: jsonb("data").default("{}"),
58
+ updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow()
59
+ }, (table) => [uniqueIndex("unique_user_game_idx").on(table.userId, table.gameId)]);
60
+ });
61
+
62
+ // ../data/src/domains/inventory/table.ts
63
+ import { relations, sql } from "drizzle-orm";
64
+ import {
65
+ boolean,
66
+ integer,
67
+ jsonb as jsonb2,
68
+ pgEnum as pgEnum2,
69
+ pgTable as pgTable2,
70
+ text as text2,
71
+ timestamp as timestamp2,
72
+ uniqueIndex as uniqueIndex2,
73
+ uuid as uuid2
74
+ } from "drizzle-orm/pg-core";
75
+ var itemTypeEnum, items, inventoryItems, currencies, shopListings, itemsRelations, currenciesRelations, shopListingsRelations, inventoryItemsRelations;
76
+ var init_table2 = __esm(() => {
77
+ init_table();
78
+ init_table3();
79
+ init_table4();
80
+ itemTypeEnum = pgEnum2("item_type", [
81
+ "currency",
82
+ "badge",
83
+ "trophy",
84
+ "collectible",
85
+ "consumable",
86
+ "unlock",
87
+ "upgrade",
88
+ "accessory",
89
+ "other"
90
+ ]);
91
+ items = pgTable2("items", {
92
+ id: uuid2("id").primaryKey().defaultRandom(),
93
+ slug: text2("slug").notNull(),
94
+ gameId: uuid2("game_id").references(() => games.id, {
95
+ onDelete: "cascade"
96
+ }),
97
+ displayName: text2("display_name").notNull(),
98
+ description: text2("description"),
99
+ type: itemTypeEnum("type").notNull().default("other"),
100
+ isPlaceable: boolean("is_placeable").default(false).notNull(),
101
+ imageUrl: text2("image_url"),
102
+ metadata: jsonb2("metadata").default({}),
103
+ createdAt: timestamp2("created_at").defaultNow().notNull()
104
+ }, (table) => [
105
+ uniqueIndex2("items_game_slug_idx").on(table.gameId, table.slug),
106
+ uniqueIndex2("items_global_slug_idx").on(table.slug).where(sql`game_id IS NULL`)
107
+ ]);
108
+ inventoryItems = pgTable2("inventory_items", {
109
+ id: uuid2("id").primaryKey().defaultRandom(),
110
+ userId: text2("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
111
+ itemId: uuid2("item_id").notNull().references(() => items.id, { onDelete: "cascade" }),
112
+ quantity: integer("quantity").notNull().default(1),
113
+ updatedAt: timestamp2("updated_at", { withTimezone: true }).defaultNow()
114
+ }, (table) => [uniqueIndex2("unique_user_item_idx").on(table.userId, table.itemId)]);
115
+ currencies = pgTable2("currencies", {
116
+ id: uuid2("id").primaryKey().defaultRandom(),
117
+ itemId: uuid2("item_id").notNull().references(() => items.id, { onDelete: "cascade" }),
118
+ symbol: text2("symbol"),
119
+ isPrimary: boolean("is_primary").default(false).notNull(),
120
+ createdAt: timestamp2("created_at").defaultNow().notNull(),
121
+ updatedAt: timestamp2("updated_at", { withTimezone: true }).defaultNow().$onUpdate(() => new Date)
122
+ }, (table) => [uniqueIndex2("currency_item_id_idx").on(table.itemId)]);
123
+ shopListings = pgTable2("shop_listings", {
124
+ id: uuid2("id").primaryKey().defaultRandom(),
125
+ itemId: uuid2("item_id").notNull().references(() => items.id, { onDelete: "cascade" }),
126
+ currencyId: uuid2("currency_id").notNull().references(() => currencies.id, { onDelete: "restrict" }),
127
+ price: integer("price").notNull(),
128
+ sellBackPercentage: integer("sell_back_percentage"),
129
+ stock: integer("stock"),
130
+ isActive: boolean("is_active").default(true).notNull(),
131
+ availableFrom: timestamp2("available_from", { withTimezone: true }),
132
+ availableUntil: timestamp2("available_until", { withTimezone: true }),
133
+ createdAt: timestamp2("created_at").defaultNow().notNull(),
134
+ updatedAt: timestamp2("updated_at", { withTimezone: true }).defaultNow().$onUpdate(() => new Date)
135
+ }, (table) => [uniqueIndex2("unique_item_currency_listing_idx").on(table.itemId, table.currencyId)]);
136
+ itemsRelations = relations(items, ({ many }) => ({
137
+ shopListings: many(shopListings),
138
+ inventoryItems: many(inventoryItems),
139
+ mapObjects: many(mapObjects)
140
+ }));
141
+ currenciesRelations = relations(currencies, ({ many }) => ({
142
+ shopListings: many(shopListings)
143
+ }));
144
+ shopListingsRelations = relations(shopListings, ({ one }) => ({
145
+ item: one(items, {
146
+ fields: [shopListings.itemId],
147
+ references: [items.id]
148
+ }),
149
+ currency: one(currencies, {
150
+ fields: [shopListings.currencyId],
151
+ references: [currencies.id]
152
+ })
153
+ }));
154
+ inventoryItemsRelations = relations(inventoryItems, ({ one }) => ({
155
+ item: one(items, {
156
+ fields: [inventoryItems.itemId],
157
+ references: [items.id]
158
+ }),
159
+ user: one(users, {
160
+ fields: [inventoryItems.userId],
161
+ references: [users.id]
162
+ })
163
+ }));
164
+ });
165
+
166
+ // ../data/src/domains/map/table.ts
167
+ import { relations as relations2 } from "drizzle-orm";
168
+ import {
169
+ doublePrecision,
170
+ index,
171
+ integer as integer2,
172
+ jsonb as jsonb3,
173
+ pgEnum as pgEnum3,
174
+ pgTable as pgTable3,
175
+ text as text3,
176
+ timestamp as timestamp3,
177
+ uniqueIndex as uniqueIndex3,
178
+ uuid as uuid3,
179
+ varchar as varchar2
180
+ } from "drizzle-orm/pg-core";
181
+ var interactionTypeEnum, maps, mapElements, mapObjects, mapElementsRelations, mapsRelations, mapObjectsRelations;
182
+ var init_table3 = __esm(() => {
183
+ init_table();
184
+ init_table2();
185
+ init_table4();
186
+ interactionTypeEnum = pgEnum3("interaction_type", [
187
+ "game_entry",
188
+ "game_registry",
189
+ "info",
190
+ "teleport",
191
+ "door_in",
192
+ "door_out",
193
+ "npc_interaction",
194
+ "quest_trigger"
195
+ ]);
196
+ maps = pgTable3("maps", {
197
+ id: uuid3("id").primaryKey().defaultRandom(),
198
+ identifier: varchar2("identifier", { length: 255 }).notNull().unique(),
199
+ displayName: varchar2("display_name", { length: 255 }).notNull(),
200
+ filePath: varchar2("file_path", { length: 255 }).notNull(),
201
+ tilesetBasePath: varchar2("tileset_base_path", { length: 255 }).notNull().default("/tilesets"),
202
+ defaultSpawnTileX: doublePrecision("default_spawn_tile_x").notNull().default(0),
203
+ defaultSpawnTileY: doublePrecision("default_spawn_tile_y").notNull().default(0),
204
+ description: text3("description")
205
+ });
206
+ mapElements = pgTable3("map_elements", {
207
+ id: uuid3("id").primaryKey().defaultRandom(),
208
+ mapId: uuid3("map_id").references(() => maps.id, {
209
+ onDelete: "cascade"
210
+ }),
211
+ elementSlug: varchar2("element_slug", { length: 255 }).notNull(),
212
+ interactionType: interactionTypeEnum("interaction_type").notNull(),
213
+ gameId: uuid3("game_id").references(() => games.id, {
214
+ onDelete: "set null"
215
+ }),
216
+ metadata: jsonb3("metadata").$type().default({})
217
+ }, (table) => [uniqueIndex3("map_id_element_slug_unique_idx").on(table.mapId, table.elementSlug)]);
218
+ mapObjects = pgTable3("map_objects", {
219
+ id: uuid3("id").primaryKey().defaultRandom(),
220
+ userId: text3("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
221
+ mapId: uuid3("map_id").notNull().references(() => maps.id, { onDelete: "cascade" }),
222
+ itemId: uuid3("item_id").notNull().references(() => items.id, { onDelete: "cascade" }),
223
+ worldX: doublePrecision("world_x").notNull(),
224
+ worldY: doublePrecision("world_y").notNull(),
225
+ rotation: integer2("rotation").default(0).notNull(),
226
+ scale: doublePrecision("scale").default(1).notNull(),
227
+ createdAt: timestamp3("created_at").defaultNow().notNull()
228
+ }, (table) => [
229
+ index("map_objects_map_idx").on(table.mapId),
230
+ index("map_objects_spatial_idx").on(table.mapId, table.worldX, table.worldY)
231
+ ]);
232
+ mapElementsRelations = relations2(mapElements, ({ one }) => ({
233
+ game: one(games, {
234
+ fields: [mapElements.gameId],
235
+ references: [games.id]
236
+ }),
237
+ map: one(maps, {
238
+ fields: [mapElements.mapId],
239
+ references: [maps.id]
240
+ })
241
+ }));
242
+ mapsRelations = relations2(maps, ({ many }) => ({
243
+ elements: many(mapElements),
244
+ objects: many(mapObjects)
245
+ }));
246
+ mapObjectsRelations = relations2(mapObjects, ({ one }) => ({
247
+ user: one(users, {
248
+ fields: [mapObjects.userId],
249
+ references: [users.id]
250
+ }),
251
+ map: one(maps, {
252
+ fields: [mapObjects.mapId],
253
+ references: [maps.id]
254
+ }),
255
+ item: one(items, {
256
+ fields: [mapObjects.itemId],
257
+ references: [items.id]
258
+ })
259
+ }));
260
+ });
261
+
262
+ // ../data/src/domains/user/table.ts
263
+ import { relations as relations3 } from "drizzle-orm";
264
+ import { boolean as boolean2, pgEnum as pgEnum4, pgTable as pgTable4, text as text4, timestamp as timestamp4, uniqueIndex as uniqueIndex4 } from "drizzle-orm/pg-core";
265
+ var userRoleEnum, developerStatusEnum, users, accounts, sessions, verification, usersRelations;
266
+ var init_table4 = __esm(() => {
267
+ init_table3();
268
+ userRoleEnum = pgEnum4("user_role", ["admin", "player", "developer"]);
269
+ developerStatusEnum = pgEnum4("developer_status", ["none", "pending", "approved"]);
270
+ users = pgTable4("user", {
271
+ id: text4("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
272
+ name: text4("name").notNull(),
273
+ username: text4("username").unique(),
274
+ email: text4("email").notNull().unique(),
275
+ emailVerified: boolean2("email_verified").notNull().default(false),
276
+ image: text4("image"),
277
+ role: userRoleEnum("role").notNull().default("player"),
278
+ developerStatus: developerStatusEnum("developer_status").notNull().default("none"),
279
+ characterCreated: boolean2("character_created").notNull().default(false),
280
+ createdAt: timestamp4("created_at", {
281
+ mode: "date",
282
+ withTimezone: true
283
+ }).notNull(),
284
+ updatedAt: timestamp4("updated_at", {
285
+ mode: "date",
286
+ withTimezone: true
287
+ }).notNull()
288
+ });
289
+ accounts = pgTable4("account", {
290
+ id: text4("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
291
+ userId: text4("userId").notNull().references(() => users.id, { onDelete: "cascade" }),
292
+ accountId: text4("account_id").notNull(),
293
+ providerId: text4("provider_id").notNull(),
294
+ accessToken: text4("access_token"),
295
+ refreshToken: text4("refresh_token"),
296
+ idToken: text4("id_token"),
297
+ accessTokenExpiresAt: timestamp4("access_token_expires_at", {
298
+ mode: "date",
299
+ withTimezone: true
300
+ }),
301
+ refreshTokenExpiresAt: timestamp4("refresh_token_expires_at", {
302
+ mode: "date",
303
+ withTimezone: true
304
+ }),
305
+ scope: text4("scope"),
306
+ password: text4("password"),
307
+ createdAt: timestamp4("created_at", {
308
+ mode: "date",
309
+ withTimezone: true
310
+ }).notNull(),
311
+ updatedAt: timestamp4("updated_at", {
312
+ mode: "date",
313
+ withTimezone: true
314
+ }).notNull()
315
+ }, (table) => [uniqueIndex4("account_provider_providerId_idx").on(table.accountId, table.providerId)]);
316
+ sessions = pgTable4("session", {
317
+ id: text4("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
318
+ userId: text4("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
319
+ expiresAt: timestamp4("expires_at", {
320
+ mode: "date",
321
+ withTimezone: true
322
+ }).notNull(),
323
+ token: text4("token").notNull().unique(),
324
+ ipAddress: text4("ip_address"),
325
+ userAgent: text4("user_agent"),
326
+ createdAt: timestamp4("created_at", {
327
+ mode: "date",
328
+ withTimezone: true
329
+ }).notNull(),
330
+ updatedAt: timestamp4("updated_at", {
331
+ mode: "date",
332
+ withTimezone: true
333
+ }).notNull()
334
+ });
335
+ verification = pgTable4("verification", {
336
+ id: text4("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
337
+ identifier: text4("identifier").notNull(),
338
+ value: text4("value").notNull(),
339
+ expiresAt: timestamp4("expires_at", {
340
+ mode: "date",
341
+ withTimezone: true
342
+ }).notNull(),
343
+ createdAt: timestamp4("created_at", {
344
+ mode: "date",
345
+ withTimezone: true
346
+ }).notNull(),
347
+ updatedAt: timestamp4("updated_at", {
348
+ mode: "date",
349
+ withTimezone: true
350
+ }).notNull()
351
+ });
352
+ usersRelations = relations3(users, ({ many }) => ({
353
+ mapObjects: many(mapObjects)
354
+ }));
355
+ });
356
+
357
+ // ../data/src/domains/developer/table.ts
358
+ import { pgTable as pgTable5, text as text5, timestamp as timestamp5, uuid as uuid4, varchar as varchar3 } from "drizzle-orm/pg-core";
359
+ var developerKeys;
360
+ var init_table5 = __esm(() => {
361
+ init_table4();
362
+ developerKeys = pgTable5("developer_keys", {
363
+ id: uuid4("id").primaryKey().defaultRandom(),
364
+ userId: text5("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
365
+ label: varchar3("label", { length: 255 }),
366
+ keyHash: text5("key_hash").notNull().unique(),
367
+ createdAt: timestamp5("created_at", { withTimezone: true }).notNull().defaultNow()
368
+ });
369
+ });
370
+
371
+ // ../data/src/domains/level/table.ts
372
+ import { relations as relations4 } from "drizzle-orm";
373
+ import { integer as integer3, pgTable as pgTable6, text as text6, timestamp as timestamp6, uniqueIndex as uniqueIndex5, uuid as uuid5 } from "drizzle-orm/pg-core";
374
+ var userLevels, levelConfigs, userLevelsRelations;
375
+ var init_table6 = __esm(() => {
376
+ init_table4();
377
+ userLevels = pgTable6("user_levels", {
378
+ userId: text6("user_id").primaryKey().references(() => users.id, { onDelete: "cascade" }),
379
+ currentLevel: integer3("current_level").notNull().default(1),
380
+ currentXp: integer3("current_xp").notNull().default(0),
381
+ totalXP: integer3("total_xp").notNull().default(0),
382
+ lastLevelUpAt: timestamp6("last_level_up_at", { withTimezone: true }),
383
+ createdAt: timestamp6("created_at").defaultNow().notNull(),
384
+ updatedAt: timestamp6("updated_at", { withTimezone: true }).defaultNow().$onUpdate(() => new Date)
385
+ });
386
+ levelConfigs = pgTable6("level_configs", {
387
+ id: uuid5("id").primaryKey().defaultRandom(),
388
+ level: integer3("level").notNull().unique(),
389
+ xpRequired: integer3("xp_required").notNull(),
390
+ creditsReward: integer3("credits_reward").notNull().default(0),
391
+ createdAt: timestamp6("created_at").defaultNow().notNull()
392
+ }, (table) => [uniqueIndex5("unique_level_config_idx").on(table.level)]);
393
+ userLevelsRelations = relations4(userLevels, ({ one }) => ({
394
+ user: one(users, {
395
+ fields: [userLevels.userId],
396
+ references: [users.id]
397
+ })
398
+ }));
399
+ });
400
+
401
+ // ../data/src/domains/leaderboard/table.ts
402
+ import { relations as relations5 } from "drizzle-orm";
403
+ import { index as index2, integer as integer4, jsonb as jsonb4, pgTable as pgTable7, text as text7, timestamp as timestamp7, uuid as uuid6 } from "drizzle-orm/pg-core";
404
+ var gameScores, gameScoresRelations;
405
+ var init_table7 = __esm(() => {
406
+ init_table();
407
+ init_table4();
408
+ gameScores = pgTable7("game_scores", {
409
+ id: uuid6("id").primaryKey().defaultRandom(),
410
+ userId: text7("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
411
+ gameId: uuid6("game_id").notNull().references(() => games.id, { onDelete: "cascade" }),
412
+ score: integer4("score").notNull(),
413
+ metadata: jsonb4("metadata").default("{}"),
414
+ achievedAt: timestamp7("achieved_at", { withTimezone: true }).defaultNow().notNull(),
415
+ sessionId: uuid6("session_id").references(() => gameSessions.id, { onDelete: "set null" })
416
+ }, (table) => [
417
+ index2("game_scores_user_game_idx").on(table.userId, table.gameId),
418
+ index2("game_scores_game_score_idx").on(table.gameId, table.score),
419
+ index2("game_scores_achieved_at_idx").on(table.achievedAt)
420
+ ]);
421
+ gameScoresRelations = relations5(gameScores, ({ one }) => ({
422
+ user: one(users, {
423
+ fields: [gameScores.userId],
424
+ references: [users.id]
425
+ }),
426
+ game: one(games, {
427
+ fields: [gameScores.gameId],
428
+ references: [games.id]
429
+ }),
430
+ session: one(gameSessions, {
431
+ fields: [gameScores.sessionId],
432
+ references: [gameSessions.id]
433
+ })
434
+ }));
435
+ });
436
+
437
+ // ../data/src/domains/sprite/table.ts
438
+ import { relations as relations6 } from "drizzle-orm";
439
+ import { integer as integer5, pgTable as pgTable8, timestamp as timestamp8, uuid as uuid7, varchar as varchar4 } from "drizzle-orm/pg-core";
440
+ var spriteTemplates, spriteSheets, spriteTemplatesRelations, spriteSheetsRelations;
441
+ var init_table8 = __esm(() => {
442
+ spriteTemplates = pgTable8("sprite_templates", {
443
+ id: uuid7("id").primaryKey().defaultRandom(),
444
+ slug: varchar4("slug", { length: 64 }).notNull().unique(),
445
+ url: varchar4("url", { length: 255 }).notNull(),
446
+ createdAt: timestamp8("created_at", { withTimezone: true }).notNull().defaultNow(),
447
+ updatedAt: timestamp8("updated_at", { withTimezone: true }).notNull().defaultNow()
448
+ });
449
+ spriteSheets = pgTable8("sprite_sheets", {
450
+ id: uuid7("id").primaryKey().defaultRandom(),
451
+ templateId: uuid7("template_id").notNull().references(() => spriteTemplates.id, { onDelete: "cascade" }),
452
+ width: integer5("width").notNull(),
453
+ height: integer5("height").notNull(),
454
+ url: varchar4("url", { length: 255 }).notNull(),
455
+ createdAt: timestamp8("created_at", { withTimezone: true }).notNull().defaultNow(),
456
+ updatedAt: timestamp8("updated_at", { withTimezone: true }).notNull().defaultNow()
457
+ });
458
+ spriteTemplatesRelations = relations6(spriteTemplates, ({ many }) => ({
459
+ sheets: many(spriteSheets)
460
+ }));
461
+ spriteSheetsRelations = relations6(spriteSheets, ({ one }) => ({
462
+ template: one(spriteTemplates, {
463
+ fields: [spriteSheets.templateId],
464
+ references: [spriteTemplates.id]
465
+ })
466
+ }));
467
+ });
468
+
469
+ // ../data/src/domains/character/table.ts
470
+ import { relations as relations7 } from "drizzle-orm";
471
+ import { integer as integer6, pgEnum as pgEnum5, pgTable as pgTable9, text as text8, timestamp as timestamp9, uuid as uuid8, varchar as varchar5 } from "drizzle-orm/pg-core";
472
+ var characterComponentTypeEnum, characterComponents, playerCharacters, characterComponentsRelations, playerCharactersRelations;
473
+ var init_table9 = __esm(() => {
474
+ init_table8();
475
+ init_table4();
476
+ characterComponentTypeEnum = pgEnum5("character_component_type", [
477
+ "body",
478
+ "outfit",
479
+ "hairstyle",
480
+ "eyes",
481
+ "accessory"
482
+ ]);
483
+ characterComponents = pgTable9("character_components", {
484
+ id: uuid8("id").primaryKey().defaultRandom(),
485
+ componentType: characterComponentTypeEnum("component_type").notNull(),
486
+ slug: varchar5("slug", { length: 128 }).notNull().unique(),
487
+ displayName: varchar5("display_name", { length: 128 }).notNull(),
488
+ slot: varchar5("slot", { length: 64 }).notNull(),
489
+ spriteSheetId: uuid8("sprite_sheet_id").notNull().references(() => spriteSheets.id, { onDelete: "cascade" }),
490
+ unlockLevel: integer6("unlock_level").notNull().default(0),
491
+ variant: integer6("variant").notNull().default(0),
492
+ createdAt: timestamp9("created_at", { withTimezone: true }).notNull().defaultNow(),
493
+ updatedAt: timestamp9("updated_at", { withTimezone: true }).notNull().defaultNow()
494
+ });
495
+ playerCharacters = pgTable9("player_characters", {
496
+ id: uuid8("id").primaryKey().defaultRandom(),
497
+ userId: text8("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
498
+ bodyComponentId: uuid8("body_component_id").notNull().references(() => characterComponents.id, { onDelete: "restrict" }),
499
+ eyesComponentId: uuid8("eyes_component_id").notNull().references(() => characterComponents.id, { onDelete: "restrict" }),
500
+ hairstyleComponentId: uuid8("hairstyle_component_id").notNull().references(() => characterComponents.id, { onDelete: "restrict" }),
501
+ outfitComponentId: uuid8("outfit_component_id").notNull().references(() => characterComponents.id, { onDelete: "restrict" }),
502
+ accessoryComponentId: uuid8("accessory_component_id").references(() => characterComponents.id, {
503
+ onDelete: "set null"
504
+ }),
505
+ createdAt: timestamp9("created_at", { withTimezone: true }).notNull().defaultNow(),
506
+ updatedAt: timestamp9("updated_at", { withTimezone: true }).notNull().defaultNow()
507
+ });
508
+ characterComponentsRelations = relations7(characterComponents, ({ one }) => ({
509
+ sheet: one(spriteSheets, {
510
+ fields: [characterComponents.spriteSheetId],
511
+ references: [spriteSheets.id]
512
+ })
513
+ }));
514
+ playerCharactersRelations = relations7(playerCharacters, ({ one }) => ({
515
+ user: one(users, {
516
+ fields: [playerCharacters.userId],
517
+ references: [users.id]
518
+ }),
519
+ body: one(characterComponents, {
520
+ fields: [playerCharacters.bodyComponentId],
521
+ references: [characterComponents.id]
522
+ }),
523
+ eyes: one(characterComponents, {
524
+ fields: [playerCharacters.eyesComponentId],
525
+ references: [characterComponents.id]
526
+ }),
527
+ hair: one(characterComponents, {
528
+ fields: [playerCharacters.hairstyleComponentId],
529
+ references: [characterComponents.id]
530
+ }),
531
+ outfit: one(characterComponents, {
532
+ fields: [playerCharacters.outfitComponentId],
533
+ references: [characterComponents.id]
534
+ }),
535
+ accessory: one(characterComponents, {
536
+ fields: [playerCharacters.accessoryComponentId],
537
+ references: [characterComponents.id]
538
+ })
539
+ }));
540
+ });
541
+
542
+ // ../data/src/tables.index.ts
543
+ var init_tables_index = __esm(() => {
544
+ init_table4();
545
+ init_table5();
546
+ init_table();
547
+ init_table2();
548
+ init_table3();
549
+ init_table6();
550
+ init_table7();
551
+ init_table8();
552
+ init_table9();
553
+ });
554
+
555
+ // ../data/src/constants.ts
556
+ var ITEM_SLUGS, CURRENCIES, BADGES, INTERACTION_TYPE;
557
+ var init_constants = __esm(() => {
558
+ init_tables_index();
559
+ ITEM_SLUGS = {
560
+ PLAYCADEMY_CREDITS: "PLAYCADEMY_CREDITS",
561
+ PLAYCADEMY_XP: "PLAYCADEMY_XP",
562
+ FOUNDING_MEMBER_BADGE: "FOUNDING_MEMBER_BADGE",
563
+ EARLY_ADOPTER_BADGE: "EARLY_ADOPTER_BADGE",
564
+ FIRST_GAME_BADGE: "FIRST_GAME_BADGE",
565
+ COMMON_SWORD: "COMMON_SWORD",
566
+ SMALL_HEALTH_POTION: "SMALL_HEALTH_POTION",
567
+ SMALL_BACKPACK: "SMALL_BACKPACK",
568
+ LAVA_LAMP: "LAVA_LAMP",
569
+ BOOMBOX: "BOOMBOX",
570
+ CABIN_BED: "CABIN_BED"
571
+ };
572
+ CURRENCIES = {
573
+ PRIMARY: ITEM_SLUGS.PLAYCADEMY_CREDITS,
574
+ XP: ITEM_SLUGS.PLAYCADEMY_XP
575
+ };
576
+ BADGES = {
577
+ FOUNDING_MEMBER: ITEM_SLUGS.FOUNDING_MEMBER_BADGE,
578
+ EARLY_ADOPTER: ITEM_SLUGS.EARLY_ADOPTER_BADGE,
579
+ FIRST_GAME: ITEM_SLUGS.FIRST_GAME_BADGE
580
+ };
581
+ INTERACTION_TYPE = Object.fromEntries(interactionTypeEnum.enumValues.map((value) => [value, value]));
582
+ });
583
+
584
+ // src/types.ts
585
+ init_constants();
586
+ export {
587
+ CURRENCIES,
588
+ BADGES
589
+ };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@playcademy/sdk",
3
+ "version": "0.0.1-beta.31",
3
4
  "type": "module",
4
- "version": "0.0.1-beta.3",
5
5
  "exports": {
6
6
  ".": {
7
- "import": "./dist/runtime.js",
8
- "require": "./dist/runtime.js",
9
- "types": "./dist/runtime.d.ts"
7
+ "import": "./dist/index.js",
8
+ "require": "./dist/index.js",
9
+ "types": "./dist/index.d.ts"
10
10
  },
11
11
  "./types": {
12
12
  "import": "./dist/types.js",
@@ -14,24 +14,32 @@
14
14
  "types": "./dist/types.d.ts"
15
15
  }
16
16
  },
17
- "main": "dist/runtime.js",
18
- "module": "dist/runtime.js",
17
+ "main": "dist/index.js",
18
+ "module": "dist/index.js",
19
19
  "files": [
20
20
  "dist"
21
21
  ],
22
22
  "scripts": {
23
23
  "build": "bun build.js",
24
- "pub": "bun run build && bunx bumpp --no-tag --no-push && bun publish --access public"
24
+ "lint": "bunx eslint . --fix --ignore-pattern dist",
25
+ "bump": "SKIP_TESTS=1 bunx bumpp --no-tag --no-push -c \"chore(@playcademy/sdk): release v%s\"",
26
+ "pub": "bun run build && bun run bump && bun publish --access public",
27
+ "test": "bun test",
28
+ "test:watch": "bun test --watch"
25
29
  },
26
30
  "dependencies": {
27
- "@playcademy/data": "0.0.1"
31
+ "@playcademy/logger": "0.0.1"
28
32
  },
29
33
  "devDependencies": {
34
+ "@playcademy/data": "0.0.1",
35
+ "@playcademy/sandbox": "0.1.0-beta.14",
36
+ "@playcademy/test": "0.0.1",
30
37
  "@types/bun": "latest",
31
- "typescript": "^5.0.0",
32
- "yocto-spinner": "^0.2.1"
38
+ "typescript": "^5.7.2",
39
+ "yocto-spinner": "^0.2.2"
33
40
  },
34
41
  "peerDependencies": {
42
+ "drizzle-orm": "^0.42.0",
35
43
  "typescript": "^5"
36
44
  }
37
45
  }
package/dist/bus.d.ts DELETED
@@ -1,37 +0,0 @@
1
- import type { GameContextPayload } from './types';
2
- export declare enum BusEvents {
3
- INIT = "PLAYCADEMY_INIT",
4
- TOKEN_REFRESH = "PLAYCADEMY_TOKEN_REFRESH",
5
- PAUSE = "PLAYCADEMY_PAUSE",
6
- RESUME = "PLAYCADEMY_RESUME",
7
- FORCE_EXIT = "PLAYCADEMY_FORCE_EXIT",
8
- OVERLAY = "PLAYCADEMY_OVERLAY",
9
- READY = "PLAYCADEMY_READY",
10
- EXIT = "PLAYCADEMY_EXIT",
11
- TELEMETRY = "PLAYCADEMY_TELEMETRY"
12
- }
13
- type BusHandler<T = unknown> = (payload: T) => void;
14
- export type BusEventMap = {
15
- [BusEvents.INIT]: GameContextPayload;
16
- [BusEvents.TOKEN_REFRESH]: {
17
- token: string;
18
- exp: number;
19
- };
20
- [BusEvents.PAUSE]: void;
21
- [BusEvents.RESUME]: void;
22
- [BusEvents.FORCE_EXIT]: void;
23
- [BusEvents.OVERLAY]: boolean;
24
- [BusEvents.READY]: void;
25
- [BusEvents.EXIT]: void;
26
- [BusEvents.TELEMETRY]: {
27
- fps: number;
28
- mem: number;
29
- };
30
- };
31
- interface Bus {
32
- emit<K extends BusEvents>(type: K, payload: BusEventMap[K]): void;
33
- on<K extends BusEvents>(type: K, handler: BusHandler<BusEventMap[K]>): void;
34
- off<K extends BusEvents>(type: K, handler: BusHandler<BusEventMap[K]>): void;
35
- }
36
- export declare const bus: Bus;
37
- export {};