@playcademy/sdk 0.1.4 → 0.1.6

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,33 @@ 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;
3163
+ /** Key-Value storage (optional) */
3164
+ kv?: boolean;
3143
3165
  }
3144
3166
  /**
3145
3167
  * Unified Playcademy configuration
@@ -3162,15 +3184,22 @@ interface PlaycademyConfig {
3162
3184
  externalUrl?: string;
3163
3185
  /** Game platform */
3164
3186
  platform?: 'web' | 'unity' | 'godot';
3165
- /** Backend configuration */
3166
- backend?: {
3167
- /** Custom API routes directory (defaults to 'api') */
3168
- directory?: string;
3169
- };
3170
- /** External integrations */
3187
+ /** Integrations (database, custom routes, external services) */
3171
3188
  integrations?: IntegrationsConfig;
3172
3189
  }
3173
3190
 
3191
+ /**
3192
+ * Resource bindings for backend deployment
3193
+ * Provider-agnostic abstraction for cloud resources
3194
+ */
3195
+ interface BackendResourceBindings {
3196
+ /** SQL database instances to create and bind (maps to D1 on Cloudflare) */
3197
+ database?: string[];
3198
+ /** Key-value store namespaces to create and bind (maps to KV on Cloudflare) */
3199
+ keyValue?: string[];
3200
+ /** Object storage buckets to bind (maps to R2 on Cloudflare) */
3201
+ bucket?: string[];
3202
+ }
3174
3203
  /**
3175
3204
  * Backend deployment bundle for uploading to Playcademy platform
3176
3205
  */
@@ -3179,6 +3208,10 @@ interface BackendDeploymentBundle {
3179
3208
  code: string;
3180
3209
  /** Game configuration */
3181
3210
  config: PlaycademyConfig;
3211
+ /** Optional resource bindings (database, storage, etc.) */
3212
+ bindings?: BackendResourceBindings;
3213
+ /** Optional schema information for database setup */
3214
+ schema?: SchemaInfo;
3182
3215
  }
3183
3216
 
3184
3217
  type TokenType = 'session' | 'apiKey' | 'gameJwt';
@@ -3854,11 +3887,11 @@ declare class PlaycademyClient {
3854
3887
  };
3855
3888
  items: {
3856
3889
  create: (props: InsertItemInput) => Promise<{
3890
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3891
+ slug: string;
3857
3892
  id: string;
3858
3893
  createdAt: Date;
3859
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3860
3894
  gameId: string | null;
3861
- slug: string;
3862
3895
  displayName: string;
3863
3896
  metadata: unknown;
3864
3897
  description: string | null;
@@ -3866,11 +3899,11 @@ declare class PlaycademyClient {
3866
3899
  imageUrl: string | null;
3867
3900
  }>;
3868
3901
  get: (itemId: string) => Promise<{
3902
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3903
+ slug: string;
3869
3904
  id: string;
3870
3905
  createdAt: Date;
3871
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3872
3906
  gameId: string | null;
3873
- slug: string;
3874
3907
  displayName: string;
3875
3908
  metadata: unknown;
3876
3909
  description: string | null;
@@ -3878,11 +3911,11 @@ declare class PlaycademyClient {
3878
3911
  imageUrl: string | null;
3879
3912
  }>;
3880
3913
  list: () => Promise<{
3914
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3915
+ slug: string;
3881
3916
  id: string;
3882
3917
  createdAt: Date;
3883
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3884
3918
  gameId: string | null;
3885
- slug: string;
3886
3919
  displayName: string;
3887
3920
  metadata: unknown;
3888
3921
  description: string | null;
@@ -3890,11 +3923,11 @@ declare class PlaycademyClient {
3890
3923
  imageUrl: string | null;
3891
3924
  }[]>;
3892
3925
  update: (itemId: string, props: UpdateItemInput) => Promise<{
3926
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3927
+ slug: string;
3893
3928
  id: string;
3894
3929
  createdAt: Date;
3895
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
3896
3930
  gameId: string | null;
3897
- slug: string;
3898
3931
  displayName: string;
3899
3932
  metadata: unknown;
3900
3933
  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,33 @@ 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;
53
+ /** Key-Value storage (optional) */
54
+ kv?: boolean;
33
55
  }
34
56
  /**
35
57
  * Unified Playcademy configuration
@@ -52,12 +74,7 @@ interface PlaycademyConfig {
52
74
  externalUrl?: string;
53
75
  /** Game platform */
54
76
  platform?: 'web' | 'unity' | 'godot';
55
- /** Backend configuration */
56
- backend?: {
57
- /** Custom API routes directory (defaults to 'api') */
58
- directory?: string;
59
- };
60
- /** External integrations */
77
+ /** Integrations (database, custom routes, external services) */
61
78
  integrations?: IntegrationsConfig;
62
79
  }
63
80
 
@@ -130,6 +147,18 @@ interface PlaycademyServerClientState {
130
147
  courseId?: string;
131
148
  }
132
149
 
150
+ /**
151
+ * Resource bindings for backend deployment
152
+ * Provider-agnostic abstraction for cloud resources
153
+ */
154
+ interface BackendResourceBindings {
155
+ /** SQL database instances to create and bind (maps to D1 on Cloudflare) */
156
+ database?: string[];
157
+ /** Key-value store namespaces to create and bind (maps to KV on Cloudflare) */
158
+ keyValue?: string[];
159
+ /** Object storage buckets to bind (maps to R2 on Cloudflare) */
160
+ bucket?: string[];
161
+ }
133
162
  /**
134
163
  * Backend deployment bundle for uploading to Playcademy platform
135
164
  */
@@ -138,6 +167,10 @@ interface BackendDeploymentBundle {
138
167
  code: string;
139
168
  /** Game configuration */
140
169
  config: PlaycademyConfig;
170
+ /** Optional resource bindings (database, storage, etc.) */
171
+ bindings?: BackendResourceBindings;
172
+ /** Optional schema information for database setup */
173
+ schema?: SchemaInfo;
141
174
  }
142
175
 
143
176
  /**
@@ -334,4 +367,4 @@ declare function verifyGameToken(gameToken: string, options?: {
334
367
  }>;
335
368
 
336
369
  export { PlaycademyClient, verifyGameToken };
337
- export type { BackendDeploymentBundle, IntegrationsConfig, PlaycademyConfig, PlaycademyServerClientConfig, PlaycademyServerClientState, TimebackIntegrationConfig };
370
+ 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,33 @@ 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;
3932
+ /** Key-Value storage (optional) */
3933
+ kv?: boolean;
3912
3934
  }
3913
3935
  /**
3914
3936
  * Unified Playcademy configuration
@@ -3931,12 +3953,7 @@ interface PlaycademyConfig {
3931
3953
  externalUrl?: string;
3932
3954
  /** Game platform */
3933
3955
  platform?: 'web' | 'unity' | 'godot';
3934
- /** Backend configuration */
3935
- backend?: {
3936
- /** Custom API routes directory (defaults to 'api') */
3937
- directory?: string;
3938
- };
3939
- /** External integrations */
3956
+ /** Integrations (database, custom routes, external services) */
3940
3957
  integrations?: IntegrationsConfig;
3941
3958
  }
3942
3959
 
@@ -4009,6 +4026,18 @@ interface PlaycademyServerClientState {
4009
4026
  courseId?: string;
4010
4027
  }
4011
4028
 
4029
+ /**
4030
+ * Resource bindings for backend deployment
4031
+ * Provider-agnostic abstraction for cloud resources
4032
+ */
4033
+ interface BackendResourceBindings {
4034
+ /** SQL database instances to create and bind (maps to D1 on Cloudflare) */
4035
+ database?: string[];
4036
+ /** Key-value store namespaces to create and bind (maps to KV on Cloudflare) */
4037
+ keyValue?: string[];
4038
+ /** Object storage buckets to bind (maps to R2 on Cloudflare) */
4039
+ bucket?: string[];
4040
+ }
4012
4041
  /**
4013
4042
  * Backend deployment bundle for uploading to Playcademy platform
4014
4043
  */
@@ -4017,6 +4046,10 @@ interface BackendDeploymentBundle {
4017
4046
  code: string;
4018
4047
  /** Game configuration */
4019
4048
  config: PlaycademyConfig;
4049
+ /** Optional resource bindings (database, storage, etc.) */
4050
+ bindings?: BackendResourceBindings;
4051
+ /** Optional schema information for database setup */
4052
+ schema?: SchemaInfo;
4020
4053
  }
4021
4054
 
4022
4055
  interface UserScore {
@@ -4542,11 +4575,11 @@ declare class PlaycademyClient {
4542
4575
  };
4543
4576
  items: {
4544
4577
  create: (props: InsertItemInput) => Promise<{
4578
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4579
+ slug: string;
4545
4580
  id: string;
4546
4581
  createdAt: Date;
4547
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4548
4582
  gameId: string | null;
4549
- slug: string;
4550
4583
  displayName: string;
4551
4584
  metadata: unknown;
4552
4585
  description: string | null;
@@ -4554,11 +4587,11 @@ declare class PlaycademyClient {
4554
4587
  imageUrl: string | null;
4555
4588
  }>;
4556
4589
  get: (itemId: string) => Promise<{
4590
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4591
+ slug: string;
4557
4592
  id: string;
4558
4593
  createdAt: Date;
4559
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4560
4594
  gameId: string | null;
4561
- slug: string;
4562
4595
  displayName: string;
4563
4596
  metadata: unknown;
4564
4597
  description: string | null;
@@ -4566,11 +4599,11 @@ declare class PlaycademyClient {
4566
4599
  imageUrl: string | null;
4567
4600
  }>;
4568
4601
  list: () => Promise<{
4602
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4603
+ slug: string;
4569
4604
  id: string;
4570
4605
  createdAt: Date;
4571
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4572
4606
  gameId: string | null;
4573
- slug: string;
4574
4607
  displayName: string;
4575
4608
  metadata: unknown;
4576
4609
  description: string | null;
@@ -4578,11 +4611,11 @@ declare class PlaycademyClient {
4578
4611
  imageUrl: string | null;
4579
4612
  }[]>;
4580
4613
  update: (itemId: string, props: UpdateItemInput) => Promise<{
4614
+ type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4615
+ slug: string;
4581
4616
  id: string;
4582
4617
  createdAt: Date;
4583
- type: "accessory" | "currency" | "badge" | "trophy" | "collectible" | "consumable" | "unlock" | "upgrade" | "other";
4584
4618
  gameId: string | null;
4585
- slug: string;
4586
4619
  displayName: string;
4587
4620
  metadata: unknown;
4588
4621
  description: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/sdk",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -37,12 +37,12 @@
37
37
  "@playcademy/constants": "0.0.1",
38
38
  "@playcademy/data": "0.0.1",
39
39
  "@playcademy/logger": "0.0.1",
40
- "@playcademy/sandbox": "0.1.0",
40
+ "@playcademy/sandbox": "0.1.1",
41
41
  "@playcademy/test": "0.0.1",
42
42
  "@playcademy/timeback": "0.0.1",
43
43
  "@playcademy/utils": "0.0.1",
44
44
  "@types/bun": "latest",
45
- "playcademy": "0.11.13",
45
+ "playcademy": "0.12.9",
46
46
  "rollup": "^4.50.2",
47
47
  "rollup-plugin-dts": "^6.2.3",
48
48
  "typescript": "^5.7.2",