@playcademy/sdk 0.1.3 → 0.1.5

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/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import * as drizzle_zod from 'drizzle-zod';
5
5
  import { z } from 'zod';
6
6
  import * as _playcademy_timeback_types from '@playcademy/timeback/types';
7
7
  import { OrganizationConfig, CourseConfig, ComponentConfig, ResourceConfig, ComponentResourceConfig } from '@playcademy/timeback/types';
8
+ import { SchemaInfo } from '@playcademy/cloudflare';
8
9
  import { AUTH_PROVIDER_IDS } from '@playcademy/constants';
9
10
 
10
11
  declare const users: drizzle_orm_pg_core.PgTableWithColumns<{
@@ -3134,12 +3135,31 @@ interface TimebackIntegrationConfig {
3134
3135
  /** Component-Resource link overrides */
3135
3136
  componentResource?: Partial<ComponentResourceConfig>;
3136
3137
  }
3138
+ /**
3139
+ * Custom API routes integration
3140
+ */
3141
+ interface CustomRoutesIntegration {
3142
+ /** Directory for custom API routes (defaults to 'server/api') */
3143
+ directory?: string;
3144
+ }
3145
+ /**
3146
+ * Database integration
3147
+ */
3148
+ interface DatabaseIntegration {
3149
+ /** Database directory (defaults to 'db') */
3150
+ directory?: string;
3151
+ }
3137
3152
  /**
3138
3153
  * Integrations configuration
3154
+ * All backend features (database, custom routes, external services) are configured here
3139
3155
  */
3140
3156
  interface IntegrationsConfig {
3141
3157
  /** TimeBack integration (optional) */
3142
3158
  timeback?: TimebackIntegrationConfig;
3159
+ /** Custom API routes (optional) */
3160
+ customRoutes?: CustomRoutesIntegration | boolean;
3161
+ /** Database (optional) */
3162
+ database?: DatabaseIntegration | boolean;
3143
3163
  }
3144
3164
  /**
3145
3165
  * Unified Playcademy configuration
@@ -3162,15 +3182,22 @@ interface PlaycademyConfig {
3162
3182
  externalUrl?: string;
3163
3183
  /** Game platform */
3164
3184
  platform?: 'web' | 'unity' | 'godot';
3165
- /** Backend configuration */
3166
- backend?: {
3167
- /** Custom API routes directory (defaults to 'api') */
3168
- directory?: string;
3169
- };
3170
- /** External integrations */
3185
+ /** Integrations (database, custom routes, external services) */
3171
3186
  integrations?: IntegrationsConfig;
3172
3187
  }
3173
3188
 
3189
+ /**
3190
+ * Resource bindings for backend deployment
3191
+ * Provider-agnostic abstraction for cloud resources
3192
+ */
3193
+ interface BackendResourceBindings {
3194
+ /** SQL database instances to create and bind (maps to D1 on Cloudflare) */
3195
+ database?: string[];
3196
+ /** Key-value store namespaces to create and bind (maps to KV on Cloudflare) */
3197
+ keyValue?: string[];
3198
+ /** Object storage buckets to bind (maps to R2 on Cloudflare) */
3199
+ bucket?: string[];
3200
+ }
3174
3201
  /**
3175
3202
  * Backend deployment bundle for uploading to Playcademy platform
3176
3203
  */
@@ -3179,6 +3206,10 @@ interface BackendDeploymentBundle {
3179
3206
  code: string;
3180
3207
  /** Game configuration */
3181
3208
  config: PlaycademyConfig;
3209
+ /** Optional resource bindings (database, storage, etc.) */
3210
+ bindings?: BackendResourceBindings;
3211
+ /** Optional schema information for database setup */
3212
+ schema?: SchemaInfo;
3182
3213
  }
3183
3214
 
3184
3215
  type TokenType = 'session' | 'apiKey' | 'gameJwt';
@@ -3854,11 +3885,11 @@ declare class PlaycademyClient {
3854
3885
  };
3855
3886
  items: {
3856
3887
  create: (props: InsertItemInput) => Promise<{
3888
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3889
+ slug: string;
3857
3890
  id: string;
3858
3891
  createdAt: Date;
3859
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3860
3892
  gameId: string | null;
3861
- slug: string;
3862
3893
  displayName: string;
3863
3894
  metadata: unknown;
3864
3895
  description: string | null;
@@ -3866,11 +3897,11 @@ declare class PlaycademyClient {
3866
3897
  imageUrl: string | null;
3867
3898
  }>;
3868
3899
  get: (itemId: string) => Promise<{
3900
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3901
+ slug: string;
3869
3902
  id: string;
3870
3903
  createdAt: Date;
3871
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3872
3904
  gameId: string | null;
3873
- slug: string;
3874
3905
  displayName: string;
3875
3906
  metadata: unknown;
3876
3907
  description: string | null;
@@ -3878,11 +3909,11 @@ declare class PlaycademyClient {
3878
3909
  imageUrl: string | null;
3879
3910
  }>;
3880
3911
  list: () => Promise<{
3912
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3913
+ slug: string;
3881
3914
  id: string;
3882
3915
  createdAt: Date;
3883
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3884
3916
  gameId: string | null;
3885
- slug: string;
3886
3917
  displayName: string;
3887
3918
  metadata: unknown;
3888
3919
  description: string | null;
@@ -3890,11 +3921,11 @@ declare class PlaycademyClient {
3890
3921
  imageUrl: string | null;
3891
3922
  }[]>;
3892
3923
  update: (itemId: string, props: UpdateItemInput) => Promise<{
3924
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3925
+ slug: string;
3893
3926
  id: string;
3894
3927
  createdAt: Date;
3895
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3896
3928
  gameId: string | null;
3897
- slug: string;
3898
3929
  displayName: string;
3899
3930
  metadata: unknown;
3900
3931
  description: string | null;
package/dist/index.js CHANGED
@@ -15,22 +15,22 @@ var isBrowser = () => {
15
15
  const g = globalThis;
16
16
  return typeof g.window !== "undefined" && typeof g.document !== "undefined";
17
17
  }, isProduction = () => {
18
- return false;
18
+ return typeof process !== "undefined" && false;
19
19
  }, isDevelopment = () => {
20
- return true;
20
+ return typeof process !== "undefined" && true;
21
21
  }, isInteractiveTTY = () => {
22
- return Boolean(process.stdout && process.stdout.isTTY);
22
+ return typeof process !== "undefined" && Boolean(process.stdout && process.stdout.isTTY);
23
23
  }, detectOutputFormat = () => {
24
24
  if (isBrowser()) {
25
25
  return "browser";
26
26
  }
27
- if (process.env.LOG_FORMAT === "json") {
27
+ if (typeof process !== "undefined" && process.env.LOG_FORMAT === "json") {
28
28
  return "json-single-line";
29
29
  }
30
- if (process.env.LOG_PRETTY === "true" && isDevelopment()) {
30
+ if (typeof process !== "undefined" && process.env.LOG_PRETTY === "true" && isDevelopment()) {
31
31
  return "json-pretty";
32
32
  }
33
- const colorPreference = (process.env.LOG_COLOR ?? "auto").toLowerCase();
33
+ const colorPreference = typeof process !== "undefined" ? (process.env.LOG_COLOR ?? "auto").toLowerCase() : "auto";
34
34
  if (colorPreference === "always" && !isProduction()) {
35
35
  return "color-tty";
36
36
  }
@@ -111,7 +111,7 @@ var isBrowser = () => {
111
111
  return console.log;
112
112
  }
113
113
  }, levelPriority, getMinimumLogLevel = () => {
114
- const envLevel = (process.env.LOG_LEVEL ?? "").toLowerCase();
114
+ const envLevel = typeof process !== "undefined" ? (process.env.LOG_LEVEL ?? "").toLowerCase() : "";
115
115
  if (envLevel && ["debug", "info", "warn", "error"].includes(envLevel)) {
116
116
  return envLevel;
117
117
  }
package/dist/server.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { SchemaInfo } from '@playcademy/cloudflare';
1
2
  import * as _playcademy_timeback_types from '@playcademy/timeback/types';
2
3
  import { OrganizationConfig, CourseConfig, ComponentConfig, ResourceConfig, ComponentResourceConfig } from '@playcademy/timeback/types';
3
4
  export { ActivityData, ComponentConfig, ComponentResourceConfig, CourseConfig, EndActivityPayload, OrganizationConfig, ResourceConfig, TimebackGrade, TimebackSubject } from '@playcademy/timeback/types';
@@ -24,12 +25,31 @@ interface TimebackIntegrationConfig {
24
25
  /** Component-Resource link overrides */
25
26
  componentResource?: Partial<ComponentResourceConfig>;
26
27
  }
28
+ /**
29
+ * Custom API routes integration
30
+ */
31
+ interface CustomRoutesIntegration {
32
+ /** Directory for custom API routes (defaults to 'server/api') */
33
+ directory?: string;
34
+ }
35
+ /**
36
+ * Database integration
37
+ */
38
+ interface DatabaseIntegration {
39
+ /** Database directory (defaults to 'db') */
40
+ directory?: string;
41
+ }
27
42
  /**
28
43
  * Integrations configuration
44
+ * All backend features (database, custom routes, external services) are configured here
29
45
  */
30
46
  interface IntegrationsConfig {
31
47
  /** TimeBack integration (optional) */
32
48
  timeback?: TimebackIntegrationConfig;
49
+ /** Custom API routes (optional) */
50
+ customRoutes?: CustomRoutesIntegration | boolean;
51
+ /** Database (optional) */
52
+ database?: DatabaseIntegration | boolean;
33
53
  }
34
54
  /**
35
55
  * Unified Playcademy configuration
@@ -52,12 +72,7 @@ interface PlaycademyConfig {
52
72
  externalUrl?: string;
53
73
  /** Game platform */
54
74
  platform?: 'web' | 'unity' | 'godot';
55
- /** Backend configuration */
56
- backend?: {
57
- /** Custom API routes directory (defaults to 'api') */
58
- directory?: string;
59
- };
60
- /** External integrations */
75
+ /** Integrations (database, custom routes, external services) */
61
76
  integrations?: IntegrationsConfig;
62
77
  }
63
78
 
@@ -130,6 +145,18 @@ interface PlaycademyServerClientState {
130
145
  courseId?: string;
131
146
  }
132
147
 
148
+ /**
149
+ * Resource bindings for backend deployment
150
+ * Provider-agnostic abstraction for cloud resources
151
+ */
152
+ interface BackendResourceBindings {
153
+ /** SQL database instances to create and bind (maps to D1 on Cloudflare) */
154
+ database?: string[];
155
+ /** Key-value store namespaces to create and bind (maps to KV on Cloudflare) */
156
+ keyValue?: string[];
157
+ /** Object storage buckets to bind (maps to R2 on Cloudflare) */
158
+ bucket?: string[];
159
+ }
133
160
  /**
134
161
  * Backend deployment bundle for uploading to Playcademy platform
135
162
  */
@@ -138,6 +165,10 @@ interface BackendDeploymentBundle {
138
165
  code: string;
139
166
  /** Game configuration */
140
167
  config: PlaycademyConfig;
168
+ /** Optional resource bindings (database, storage, etc.) */
169
+ bindings?: BackendResourceBindings;
170
+ /** Optional schema information for database setup */
171
+ schema?: SchemaInfo;
141
172
  }
142
173
 
143
174
  /**
@@ -334,4 +365,4 @@ declare function verifyGameToken(gameToken: string, options?: {
334
365
  }>;
335
366
 
336
367
  export { PlaycademyClient, verifyGameToken };
337
- export type { BackendDeploymentBundle, IntegrationsConfig, PlaycademyConfig, PlaycademyServerClientConfig, PlaycademyServerClientState, TimebackIntegrationConfig };
368
+ export type { BackendDeploymentBundle, BackendResourceBindings, IntegrationsConfig, PlaycademyConfig, PlaycademyServerClientConfig, PlaycademyServerClientState, TimebackIntegrationConfig };
package/dist/types.d.ts CHANGED
@@ -6,6 +6,7 @@ import { z } from 'zod';
6
6
  import * as _playcademy_realtime_server_types from '@playcademy/realtime/server/types';
7
7
  import * as _playcademy_timeback_types from '@playcademy/timeback/types';
8
8
  import { OrganizationConfig, CourseConfig, ComponentConfig, ResourceConfig, ComponentResourceConfig } from '@playcademy/timeback/types';
9
+ import { SchemaInfo } from '@playcademy/cloudflare';
9
10
 
10
11
  declare const userRoleEnum: drizzle_orm_pg_core.PgEnum<["admin", "player", "developer"]>;
11
12
  declare const users: drizzle_orm_pg_core.PgTableWithColumns<{
@@ -3903,12 +3904,31 @@ interface TimebackIntegrationConfig {
3903
3904
  /** Component-Resource link overrides */
3904
3905
  componentResource?: Partial<ComponentResourceConfig>;
3905
3906
  }
3907
+ /**
3908
+ * Custom API routes integration
3909
+ */
3910
+ interface CustomRoutesIntegration {
3911
+ /** Directory for custom API routes (defaults to 'server/api') */
3912
+ directory?: string;
3913
+ }
3914
+ /**
3915
+ * Database integration
3916
+ */
3917
+ interface DatabaseIntegration {
3918
+ /** Database directory (defaults to 'db') */
3919
+ directory?: string;
3920
+ }
3906
3921
  /**
3907
3922
  * Integrations configuration
3923
+ * All backend features (database, custom routes, external services) are configured here
3908
3924
  */
3909
3925
  interface IntegrationsConfig {
3910
3926
  /** TimeBack integration (optional) */
3911
3927
  timeback?: TimebackIntegrationConfig;
3928
+ /** Custom API routes (optional) */
3929
+ customRoutes?: CustomRoutesIntegration | boolean;
3930
+ /** Database (optional) */
3931
+ database?: DatabaseIntegration | boolean;
3912
3932
  }
3913
3933
  /**
3914
3934
  * Unified Playcademy configuration
@@ -3931,12 +3951,7 @@ interface PlaycademyConfig {
3931
3951
  externalUrl?: string;
3932
3952
  /** Game platform */
3933
3953
  platform?: 'web' | 'unity' | 'godot';
3934
- /** Backend configuration */
3935
- backend?: {
3936
- /** Custom API routes directory (defaults to 'api') */
3937
- directory?: string;
3938
- };
3939
- /** External integrations */
3954
+ /** Integrations (database, custom routes, external services) */
3940
3955
  integrations?: IntegrationsConfig;
3941
3956
  }
3942
3957
 
@@ -4009,6 +4024,18 @@ interface PlaycademyServerClientState {
4009
4024
  courseId?: string;
4010
4025
  }
4011
4026
 
4027
+ /**
4028
+ * Resource bindings for backend deployment
4029
+ * Provider-agnostic abstraction for cloud resources
4030
+ */
4031
+ interface BackendResourceBindings {
4032
+ /** SQL database instances to create and bind (maps to D1 on Cloudflare) */
4033
+ database?: string[];
4034
+ /** Key-value store namespaces to create and bind (maps to KV on Cloudflare) */
4035
+ keyValue?: string[];
4036
+ /** Object storage buckets to bind (maps to R2 on Cloudflare) */
4037
+ bucket?: string[];
4038
+ }
4012
4039
  /**
4013
4040
  * Backend deployment bundle for uploading to Playcademy platform
4014
4041
  */
@@ -4017,6 +4044,10 @@ interface BackendDeploymentBundle {
4017
4044
  code: string;
4018
4045
  /** Game configuration */
4019
4046
  config: PlaycademyConfig;
4047
+ /** Optional resource bindings (database, storage, etc.) */
4048
+ bindings?: BackendResourceBindings;
4049
+ /** Optional schema information for database setup */
4050
+ schema?: SchemaInfo;
4020
4051
  }
4021
4052
 
4022
4053
  interface UserScore {
@@ -4542,11 +4573,11 @@ declare class PlaycademyClient {
4542
4573
  };
4543
4574
  items: {
4544
4575
  create: (props: InsertItemInput) => Promise<{
4576
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4577
+ slug: string;
4545
4578
  id: string;
4546
4579
  createdAt: Date;
4547
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4548
4580
  gameId: string | null;
4549
- slug: string;
4550
4581
  displayName: string;
4551
4582
  metadata: unknown;
4552
4583
  description: string | null;
@@ -4554,11 +4585,11 @@ declare class PlaycademyClient {
4554
4585
  imageUrl: string | null;
4555
4586
  }>;
4556
4587
  get: (itemId: string) => Promise<{
4588
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4589
+ slug: string;
4557
4590
  id: string;
4558
4591
  createdAt: Date;
4559
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4560
4592
  gameId: string | null;
4561
- slug: string;
4562
4593
  displayName: string;
4563
4594
  metadata: unknown;
4564
4595
  description: string | null;
@@ -4566,11 +4597,11 @@ declare class PlaycademyClient {
4566
4597
  imageUrl: string | null;
4567
4598
  }>;
4568
4599
  list: () => Promise<{
4600
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4601
+ slug: string;
4569
4602
  id: string;
4570
4603
  createdAt: Date;
4571
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4572
4604
  gameId: string | null;
4573
- slug: string;
4574
4605
  displayName: string;
4575
4606
  metadata: unknown;
4576
4607
  description: string | null;
@@ -4578,11 +4609,11 @@ declare class PlaycademyClient {
4578
4609
  imageUrl: string | null;
4579
4610
  }[]>;
4580
4611
  update: (itemId: string, props: UpdateItemInput) => Promise<{
4612
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4613
+ slug: string;
4581
4614
  id: string;
4582
4615
  createdAt: Date;
4583
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4584
4616
  gameId: string | null;
4585
- slug: string;
4586
4617
  displayName: string;
4587
4618
  metadata: unknown;
4588
4619
  description: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {