@playcademy/sandbox 0.1.8 → 0.1.9

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/cli.js CHANGED
@@ -119329,7 +119329,7 @@ var logger2 = (fn = console.log) => {
119329
119329
  // package.json
119330
119330
  var package_default = {
119331
119331
  name: "@playcademy/sandbox",
119332
- version: "0.1.7",
119332
+ version: "0.1.8",
119333
119333
  description: "Local development server for Playcademy game development",
119334
119334
  type: "module",
119335
119335
  exports: {
@@ -153235,6 +153235,62 @@ function createD1Namespace(config2) {
153235
153235
  error: error2
153236
153236
  });
153237
153237
  }
153238
+ },
153239
+ async reset(databaseName) {
153240
+ log2.debug("[CloudflareProvider] Resetting D1 database", { databaseName });
153241
+ const databases = await client.d1.database.list({ account_id: accountId });
153242
+ let databaseId = null;
153243
+ for await (const db2 of databases) {
153244
+ if (db2.name === databaseName && db2.uuid) {
153245
+ databaseId = db2.uuid;
153246
+ break;
153247
+ }
153248
+ }
153249
+ if (!databaseId) {
153250
+ throw new Error(`D1 database not found: ${databaseName}`);
153251
+ }
153252
+ const tablesResult = await client.d1.database.query(databaseId, {
153253
+ account_id: accountId,
153254
+ sql: "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' AND name NOT LIKE '_cf_%'"
153255
+ });
153256
+ const tables = tablesResult.result?.[0]?.results || [];
153257
+ if (tables.length === 0) {
153258
+ log2.info("[CloudflareProvider] No tables to drop", { databaseName, databaseId });
153259
+ return;
153260
+ }
153261
+ log2.debug("[CloudflareProvider] Found tables to drop", {
153262
+ databaseId,
153263
+ count: tables.length,
153264
+ tables: tables.map((t2) => t2.name)
153265
+ });
153266
+ await client.d1.database.query(databaseId, {
153267
+ account_id: accountId,
153268
+ sql: "PRAGMA defer_foreign_keys = on"
153269
+ });
153270
+ for (const table16 of tables) {
153271
+ if (!table16.name) {
153272
+ log2.warn("[CloudflareProvider] Skipping table with undefined name", { table: table16 });
153273
+ continue;
153274
+ }
153275
+ log2.debug("[CloudflareProvider] Dropping table", {
153276
+ databaseName,
153277
+ databaseId,
153278
+ table: table16.name
153279
+ });
153280
+ await client.d1.database.query(databaseId, {
153281
+ account_id: accountId,
153282
+ sql: `DROP TABLE IF EXISTS "${table16.name}"`
153283
+ });
153284
+ }
153285
+ await client.d1.database.query(databaseId, {
153286
+ account_id: accountId,
153287
+ sql: "PRAGMA defer_foreign_keys = off"
153288
+ });
153289
+ log2.info("[CloudflareProvider] D1 database reset complete", {
153290
+ databaseName,
153291
+ databaseId,
153292
+ tablesDropped: tables.length
153293
+ });
153238
153294
  }
153239
153295
  };
153240
153296
  }
@@ -153562,6 +153618,7 @@ class CloudflareProvider {
153562
153618
  client;
153563
153619
  config;
153564
153620
  workers;
153621
+ d1;
153565
153622
  constructor(config2) {
153566
153623
  this.config = {
153567
153624
  dispatchNamespace: DISPATCH_NAMESPACE_NAME,
@@ -153570,6 +153627,10 @@ class CloudflareProvider {
153570
153627
  this.client = new cloudflare_default({
153571
153628
  apiToken: config2.apiToken
153572
153629
  });
153630
+ this.d1 = createD1Namespace({
153631
+ client: this.client,
153632
+ accountId: this.config.accountId
153633
+ });
153573
153634
  this.workers = createWorkersNamespace({
153574
153635
  client: this.client,
153575
153636
  accountId: this.config.accountId,
package/dist/server.js CHANGED
@@ -117419,7 +117419,7 @@ var logger2 = (fn = console.log) => {
117419
117419
  // package.json
117420
117420
  var package_default = {
117421
117421
  name: "@playcademy/sandbox",
117422
- version: "0.1.7",
117422
+ version: "0.1.8",
117423
117423
  description: "Local development server for Playcademy game development",
117424
117424
  type: "module",
117425
117425
  exports: {
@@ -151325,6 +151325,62 @@ function createD1Namespace(config2) {
151325
151325
  error: error2
151326
151326
  });
151327
151327
  }
151328
+ },
151329
+ async reset(databaseName) {
151330
+ log2.debug("[CloudflareProvider] Resetting D1 database", { databaseName });
151331
+ const databases = await client.d1.database.list({ account_id: accountId });
151332
+ let databaseId = null;
151333
+ for await (const db2 of databases) {
151334
+ if (db2.name === databaseName && db2.uuid) {
151335
+ databaseId = db2.uuid;
151336
+ break;
151337
+ }
151338
+ }
151339
+ if (!databaseId) {
151340
+ throw new Error(`D1 database not found: ${databaseName}`);
151341
+ }
151342
+ const tablesResult = await client.d1.database.query(databaseId, {
151343
+ account_id: accountId,
151344
+ sql: "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' AND name NOT LIKE '_cf_%'"
151345
+ });
151346
+ const tables = tablesResult.result?.[0]?.results || [];
151347
+ if (tables.length === 0) {
151348
+ log2.info("[CloudflareProvider] No tables to drop", { databaseName, databaseId });
151349
+ return;
151350
+ }
151351
+ log2.debug("[CloudflareProvider] Found tables to drop", {
151352
+ databaseId,
151353
+ count: tables.length,
151354
+ tables: tables.map((t2) => t2.name)
151355
+ });
151356
+ await client.d1.database.query(databaseId, {
151357
+ account_id: accountId,
151358
+ sql: "PRAGMA defer_foreign_keys = on"
151359
+ });
151360
+ for (const table16 of tables) {
151361
+ if (!table16.name) {
151362
+ log2.warn("[CloudflareProvider] Skipping table with undefined name", { table: table16 });
151363
+ continue;
151364
+ }
151365
+ log2.debug("[CloudflareProvider] Dropping table", {
151366
+ databaseName,
151367
+ databaseId,
151368
+ table: table16.name
151369
+ });
151370
+ await client.d1.database.query(databaseId, {
151371
+ account_id: accountId,
151372
+ sql: `DROP TABLE IF EXISTS "${table16.name}"`
151373
+ });
151374
+ }
151375
+ await client.d1.database.query(databaseId, {
151376
+ account_id: accountId,
151377
+ sql: "PRAGMA defer_foreign_keys = off"
151378
+ });
151379
+ log2.info("[CloudflareProvider] D1 database reset complete", {
151380
+ databaseName,
151381
+ databaseId,
151382
+ tablesDropped: tables.length
151383
+ });
151328
151384
  }
151329
151385
  };
151330
151386
  }
@@ -151652,6 +151708,7 @@ class CloudflareProvider {
151652
151708
  client;
151653
151709
  config;
151654
151710
  workers;
151711
+ d1;
151655
151712
  constructor(config2) {
151656
151713
  this.config = {
151657
151714
  dispatchNamespace: DISPATCH_NAMESPACE_NAME,
@@ -151660,6 +151717,10 @@ class CloudflareProvider {
151660
151717
  this.client = new cloudflare_default({
151661
151718
  apiToken: config2.apiToken
151662
151719
  });
151720
+ this.d1 = createD1Namespace({
151721
+ client: this.client,
151722
+ accountId: this.config.accountId
151723
+ });
151663
151724
  this.workers = createWorkersNamespace({
151664
151725
  client: this.client,
151665
151726
  accountId: this.config.accountId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/sandbox",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Local development server for Playcademy game development",
5
5
  "type": "module",
6
6
  "exports": {