@playcademy/sdk 0.1.11 → 0.1.13

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
@@ -3817,6 +3817,14 @@ declare class PlaycademyClient {
3817
3817
  }) => void) | (() => void) | ((isVisible: boolean) => void)) => void;
3818
3818
  removeAllListeners: () => void;
3819
3819
  getListenerCounts: () => Record<string, number>;
3820
+ cdn: {
3821
+ url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
3822
+ fetch: (path: string, options?: RequestInit) => Promise<Response>;
3823
+ json: <T = unknown>(path: string) => Promise<T>;
3824
+ blob: (path: string) => Promise<Blob>;
3825
+ text: (path: string) => Promise<string>;
3826
+ arrayBuffer: (path: string) => Promise<ArrayBuffer>;
3827
+ };
3820
3828
  };
3821
3829
  /** Game management methods (fetch, list, saveState, loadState, sessions) */
3822
3830
  games: {
@@ -3868,6 +3876,11 @@ declare class PlaycademyClient {
3868
3876
  deploy: {
3869
3877
  frontend: (slug: string, metadata: UpsertGameMetadataInput, file: File | Blob | null, hooks?: DevUploadHooks) => Promise<Game>;
3870
3878
  backend: (slug: string, bundle: BackendDeploymentBundle) => Promise<BackendDeploymentResponse>;
3879
+ seed: (slug: string, code: string, environment?: "staging" | "production") => Promise<{
3880
+ success: boolean;
3881
+ deploymentId: string;
3882
+ executedAt: string;
3883
+ }>;
3871
3884
  };
3872
3885
  upsert: (slug: string, metadata: UpsertGameMetadataInput) => Promise<Game>;
3873
3886
  delete: (gameId: string) => Promise<void>;
@@ -3877,6 +3890,17 @@ declare class PlaycademyClient {
3877
3890
  get: (slug: string) => Promise<Record<string, string>>;
3878
3891
  delete: (slug: string, key: string) => Promise<void>;
3879
3892
  };
3893
+ database: {
3894
+ reset: (slug: string, schema?: {
3895
+ sql: string;
3896
+ hash: string;
3897
+ }) => Promise<{
3898
+ success: boolean;
3899
+ deploymentId: string;
3900
+ resetAt: string;
3901
+ schemaPushed: boolean;
3902
+ }>;
3903
+ };
3880
3904
  bucket: {
3881
3905
  list: (slug: string, prefix?: string) => Promise<BucketFile[]>;
3882
3906
  get: (slug: string, key: string) => Promise<ArrayBuffer>;
package/dist/index.js CHANGED
@@ -839,6 +839,50 @@ function createRuntimeNamespace(client) {
839
839
  counts[eventType] = handlers.size;
840
840
  }
841
841
  return counts;
842
+ },
843
+ cdn: {
844
+ url(pathOrStrings, ...values) {
845
+ const cdnBase = client["initPayload"]?.cdnBase;
846
+ let path;
847
+ if (Array.isArray(pathOrStrings) && "raw" in pathOrStrings) {
848
+ const strings = pathOrStrings;
849
+ path = strings.reduce((acc, str, i) => {
850
+ return acc + str + (values[i] != null ? String(values[i]) : "");
851
+ }, "");
852
+ } else {
853
+ path = pathOrStrings;
854
+ }
855
+ if (!cdnBase) {
856
+ return path.startsWith("./") ? path : "./" + path;
857
+ }
858
+ const cleanPath = path.startsWith("./") ? path.slice(2) : path;
859
+ return cdnBase + cleanPath;
860
+ },
861
+ fetch: async (path, options) => {
862
+ const cdnBase = client["initPayload"]?.cdnBase;
863
+ if (!cdnBase) {
864
+ const relativePath = path.startsWith("./") ? path : "./" + path;
865
+ return fetch(relativePath, options);
866
+ }
867
+ const cleanPath = path.startsWith("./") ? path.slice(2) : path;
868
+ return fetch(cdnBase + cleanPath, options);
869
+ },
870
+ json: async (path) => {
871
+ const response = await client.runtime.cdn.fetch(path);
872
+ return response.json();
873
+ },
874
+ blob: async (path) => {
875
+ const response = await client.runtime.cdn.fetch(path);
876
+ return response.blob();
877
+ },
878
+ text: async (path) => {
879
+ const response = await client.runtime.cdn.fetch(path);
880
+ return response.text();
881
+ },
882
+ arrayBuffer: async (path) => {
883
+ const response = await client.runtime.cdn.fetch(path);
884
+ return response.arrayBuffer();
885
+ }
842
886
  }
843
887
  };
844
888
  }
@@ -1378,6 +1422,11 @@ function createDevNamespace(client) {
1378
1422
  },
1379
1423
  backend: async (slug, bundle) => {
1380
1424
  return client["request"](`/games/${slug}/backend/deploy`, "POST", { body: bundle });
1425
+ },
1426
+ seed: async (slug, code, environment) => {
1427
+ return client["request"](`/games/${slug}/seed`, "POST", {
1428
+ body: { code, environment }
1429
+ });
1381
1430
  }
1382
1431
  },
1383
1432
  upsert: async (slug, metadata) => {
@@ -1401,6 +1450,13 @@ function createDevNamespace(client) {
1401
1450
  await client["request"](`/games/${slug}/secrets/${key}`, "DELETE");
1402
1451
  }
1403
1452
  },
1453
+ database: {
1454
+ reset: async (slug, schema) => {
1455
+ return client["request"](`/games/${slug}/database/reset`, "POST", {
1456
+ body: { schema }
1457
+ });
1458
+ }
1459
+ },
1404
1460
  bucket: {
1405
1461
  list: async (slug, prefix) => {
1406
1462
  const params = prefix ? `?prefix=${encodeURIComponent(prefix)}` : "";
package/dist/types.d.ts CHANGED
@@ -4496,6 +4496,14 @@ declare class PlaycademyClient {
4496
4496
  }) => void) | (() => void) | ((isVisible: boolean) => void)) => void;
4497
4497
  removeAllListeners: () => void;
4498
4498
  getListenerCounts: () => Record<string, number>;
4499
+ cdn: {
4500
+ url(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
4501
+ fetch: (path: string, options?: RequestInit) => Promise<Response>;
4502
+ json: <T = unknown>(path: string) => Promise<T>;
4503
+ blob: (path: string) => Promise<Blob>;
4504
+ text: (path: string) => Promise<string>;
4505
+ arrayBuffer: (path: string) => Promise<ArrayBuffer>;
4506
+ };
4499
4507
  };
4500
4508
  /** Game management methods (fetch, list, saveState, loadState, sessions) */
4501
4509
  games: {
@@ -4547,6 +4555,11 @@ declare class PlaycademyClient {
4547
4555
  deploy: {
4548
4556
  frontend: (slug: string, metadata: UpsertGameMetadataInput, file: File | Blob | null, hooks?: DevUploadHooks) => Promise<Game>;
4549
4557
  backend: (slug: string, bundle: BackendDeploymentBundle) => Promise<BackendDeploymentResponse>;
4558
+ seed: (slug: string, code: string, environment?: "staging" | "production") => Promise<{
4559
+ success: boolean;
4560
+ deploymentId: string;
4561
+ executedAt: string;
4562
+ }>;
4550
4563
  };
4551
4564
  upsert: (slug: string, metadata: UpsertGameMetadataInput) => Promise<Game>;
4552
4565
  delete: (gameId: string) => Promise<void>;
@@ -4556,6 +4569,17 @@ declare class PlaycademyClient {
4556
4569
  get: (slug: string) => Promise<Record<string, string>>;
4557
4570
  delete: (slug: string, key: string) => Promise<void>;
4558
4571
  };
4572
+ database: {
4573
+ reset: (slug: string, schema?: {
4574
+ sql: string;
4575
+ hash: string;
4576
+ }) => Promise<{
4577
+ success: boolean;
4578
+ deploymentId: string;
4579
+ resetAt: string;
4580
+ schemaPushed: boolean;
4581
+ }>;
4582
+ };
4559
4583
  bucket: {
4560
4584
  list: (slug: string, prefix?: string) => Promise<BucketFile[]>;
4561
4585
  get: (slug: string, key: string) => Promise<ArrayBuffer>;
@@ -4906,6 +4930,7 @@ interface InitPayload {
4906
4930
  token: string;
4907
4931
  gameId: string;
4908
4932
  realtimeUrl?: string;
4933
+ cdnBase?: string;
4909
4934
  }
4910
4935
  type AuthProviderType = (typeof AUTH_PROVIDER_IDS)[keyof typeof AUTH_PROVIDER_IDS];
4911
4936
  interface AuthOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/sdk",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
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.7",
40
+ "@playcademy/sandbox": "0.1.9",
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.13.22",
45
+ "playcademy": "0.14.2",
46
46
  "rollup": "^4.50.2",
47
47
  "rollup-plugin-dts": "^6.2.3",
48
48
  "typescript": "^5.7.2",