@playcademy/sandbox 0.12.2-beta.7 → 0.13.0

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.
Files changed (3) hide show
  1. package/dist/cli.js +26 -11
  2. package/dist/server.js +26 -11
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2517,7 +2517,7 @@ var package_default;
2517
2517
  var init_package = __esm(() => {
2518
2518
  package_default = {
2519
2519
  name: "@playcademy/sandbox",
2520
- version: "0.12.2-beta.7",
2520
+ version: "0.13.0",
2521
2521
  description: "Local development server for Playcademy game development",
2522
2522
  type: "module",
2523
2523
  exports: {
@@ -50831,7 +50831,7 @@ function isCanonicalOrigin(value) {
50831
50831
  }
50832
50832
  return url.protocol === "https:" || url.protocol === "http:" && isLocalHostname(url.hostname);
50833
50833
  }
50834
- var LOCAL_HOSTNAMES, EmbedOriginSchema, EmbedContextIdSchema, MAX_CONTEXT_ATTRIBUTES = 10, EmbedContextAttributesSchema, EmbedContextSchema, EmbedPartnerClientIdSchema, EnsureEmbedPartnerSchema, AddEmbedPartnerOriginSchema, CreateEmbedLaunchSchema, RedeemEmbedPassSchema;
50834
+ var LOCAL_HOSTNAMES, EmbedOriginSchema, EmbedContextIdSchema, MAX_CONTEXT_ATTRIBUTES = 10, EmbedContextAttributesSchema, EmbedContextSchema, EmbedPartnerClientIdSchema, EmbedPartnerHandleSchema, EnsureEmbedPartnerSchema, AddEmbedPartnerOriginSchema, CreateEmbedLaunchSchema, RedeemEmbedPassSchema;
50835
50835
  var init_schemas5 = __esm(() => {
50836
50836
  init_esm();
50837
50837
  init_table8();
@@ -50855,8 +50855,10 @@ var init_schemas5 = __esm(() => {
50855
50855
  attributes: EmbedContextAttributesSchema.optional()
50856
50856
  }).strict();
50857
50857
  EmbedPartnerClientIdSchema = stringType().trim().min(1).max(200);
50858
+ EmbedPartnerHandleSchema = stringType().max(253).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?([.][a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/);
50858
50859
  EnsureEmbedPartnerSchema = objectType({
50859
- name: stringType().trim().min(1).max(100)
50860
+ name: stringType().trim().min(1).max(100),
50861
+ handle: EmbedPartnerHandleSchema.optional()
50860
50862
  }).strict();
50861
50863
  AddEmbedPartnerOriginSchema = objectType({
50862
50864
  origin: EmbedOriginSchema
@@ -95662,15 +95664,28 @@ class EmbedPartnerService {
95662
95664
  constructor(deps) {
95663
95665
  this.deps = deps;
95664
95666
  }
95665
- async ensurePartner(clientId, name2) {
95666
- const [partner] = await this.deps.db.insert(embedPartners).values({ clientId, name: name2 }).onConflictDoUpdate({
95667
+ async ensurePartner(clientId, name2, handle2) {
95668
+ const [partner] = await this.deps.db.insert(embedPartners).values({ clientId, name: name2, handle: handle2 }).onConflictDoUpdate({
95667
95669
  target: embedPartners.clientId,
95668
- set: { name: name2, updatedAt: new Date }
95669
- }).returning();
95670
- if (!partner) {
95671
- throw new InternalError("Failed to ensure embed partner");
95670
+ set: {
95671
+ name: name2,
95672
+ handle: sql`coalesce(${embedPartners.handle}, excluded.handle)`,
95673
+ updatedAt: new Date
95674
+ },
95675
+ setWhere: sql`excluded.handle IS NULL OR ${embedPartners.handle} IS NULL OR ${embedPartners.handle} = excluded.handle`
95676
+ }).returning().catch((error) => {
95677
+ if (isUniqueViolation(error)) {
95678
+ throw new ConflictError(`Another embed partner has the handle ${handle2}`);
95679
+ }
95680
+ throw error;
95681
+ });
95682
+ if (partner) {
95683
+ return partner;
95672
95684
  }
95673
- return partner;
95685
+ if (handle2) {
95686
+ throw new ConflictError("This embed partner already has a different handle, and it never changes");
95687
+ }
95688
+ throw new InternalError("Failed to ensure embed partner");
95674
95689
  }
95675
95690
  addOrigin(clientId, origin) {
95676
95691
  return this.setOrigins(clientId, sql`CASE WHEN ${origin} = ANY(${embedPartners.allowedOrigins})
@@ -152679,7 +152694,7 @@ async function ensurePartner(ctx) {
152679
152694
  await requireEmbedAdmin(ctx);
152680
152695
  const clientId = requireClientIdParam(ctx);
152681
152696
  const body2 = await parseRequestBody(ctx.request, EnsureEmbedPartnerSchema);
152682
- return ctx.services.embedPartner.ensurePartner(clientId, body2.name);
152697
+ return ctx.services.embedPartner.ensurePartner(clientId, body2.name, body2.handle);
152683
152698
  }
152684
152699
  async function addPartnerOrigin(ctx) {
152685
152700
  await requireEmbedAdmin(ctx);
package/dist/server.js CHANGED
@@ -697,7 +697,7 @@ var package_default;
697
697
  var init_package = __esm(() => {
698
698
  package_default = {
699
699
  name: "@playcademy/sandbox",
700
- version: "0.12.2-beta.7",
700
+ version: "0.13.0",
701
701
  description: "Local development server for Playcademy game development",
702
702
  type: "module",
703
703
  exports: {
@@ -49011,7 +49011,7 @@ function isCanonicalOrigin(value) {
49011
49011
  }
49012
49012
  return url.protocol === "https:" || url.protocol === "http:" && isLocalHostname(url.hostname);
49013
49013
  }
49014
- var LOCAL_HOSTNAMES, EmbedOriginSchema, EmbedContextIdSchema, MAX_CONTEXT_ATTRIBUTES = 10, EmbedContextAttributesSchema, EmbedContextSchema, EmbedPartnerClientIdSchema, EnsureEmbedPartnerSchema, AddEmbedPartnerOriginSchema, CreateEmbedLaunchSchema, RedeemEmbedPassSchema;
49014
+ var LOCAL_HOSTNAMES, EmbedOriginSchema, EmbedContextIdSchema, MAX_CONTEXT_ATTRIBUTES = 10, EmbedContextAttributesSchema, EmbedContextSchema, EmbedPartnerClientIdSchema, EmbedPartnerHandleSchema, EnsureEmbedPartnerSchema, AddEmbedPartnerOriginSchema, CreateEmbedLaunchSchema, RedeemEmbedPassSchema;
49015
49015
  var init_schemas5 = __esm(() => {
49016
49016
  init_esm();
49017
49017
  init_table8();
@@ -49035,8 +49035,10 @@ var init_schemas5 = __esm(() => {
49035
49035
  attributes: EmbedContextAttributesSchema.optional()
49036
49036
  }).strict();
49037
49037
  EmbedPartnerClientIdSchema = stringType().trim().min(1).max(200);
49038
+ EmbedPartnerHandleSchema = stringType().max(253).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?([.][a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/);
49038
49039
  EnsureEmbedPartnerSchema = objectType({
49039
- name: stringType().trim().min(1).max(100)
49040
+ name: stringType().trim().min(1).max(100),
49041
+ handle: EmbedPartnerHandleSchema.optional()
49040
49042
  }).strict();
49041
49043
  AddEmbedPartnerOriginSchema = objectType({
49042
49044
  origin: EmbedOriginSchema
@@ -93842,15 +93844,28 @@ class EmbedPartnerService {
93842
93844
  constructor(deps) {
93843
93845
  this.deps = deps;
93844
93846
  }
93845
- async ensurePartner(clientId, name2) {
93846
- const [partner] = await this.deps.db.insert(embedPartners).values({ clientId, name: name2 }).onConflictDoUpdate({
93847
+ async ensurePartner(clientId, name2, handle2) {
93848
+ const [partner] = await this.deps.db.insert(embedPartners).values({ clientId, name: name2, handle: handle2 }).onConflictDoUpdate({
93847
93849
  target: embedPartners.clientId,
93848
- set: { name: name2, updatedAt: new Date }
93849
- }).returning();
93850
- if (!partner) {
93851
- throw new InternalError("Failed to ensure embed partner");
93850
+ set: {
93851
+ name: name2,
93852
+ handle: sql`coalesce(${embedPartners.handle}, excluded.handle)`,
93853
+ updatedAt: new Date
93854
+ },
93855
+ setWhere: sql`excluded.handle IS NULL OR ${embedPartners.handle} IS NULL OR ${embedPartners.handle} = excluded.handle`
93856
+ }).returning().catch((error) => {
93857
+ if (isUniqueViolation(error)) {
93858
+ throw new ConflictError(`Another embed partner has the handle ${handle2}`);
93859
+ }
93860
+ throw error;
93861
+ });
93862
+ if (partner) {
93863
+ return partner;
93852
93864
  }
93853
- return partner;
93865
+ if (handle2) {
93866
+ throw new ConflictError("This embed partner already has a different handle, and it never changes");
93867
+ }
93868
+ throw new InternalError("Failed to ensure embed partner");
93854
93869
  }
93855
93870
  addOrigin(clientId, origin) {
93856
93871
  return this.setOrigins(clientId, sql`CASE WHEN ${origin} = ANY(${embedPartners.allowedOrigins})
@@ -150859,7 +150874,7 @@ async function ensurePartner(ctx) {
150859
150874
  await requireEmbedAdmin(ctx);
150860
150875
  const clientId = requireClientIdParam(ctx);
150861
150876
  const body2 = await parseRequestBody(ctx.request, EnsureEmbedPartnerSchema);
150862
- return ctx.services.embedPartner.ensurePartner(clientId, body2.name);
150877
+ return ctx.services.embedPartner.ensurePartner(clientId, body2.name, body2.handle);
150863
150878
  }
150864
150879
  async function addPartnerOrigin(ctx) {
150865
150880
  await requireEmbedAdmin(ctx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/sandbox",
3
- "version": "0.12.2-beta.7",
3
+ "version": "0.13.0",
4
4
  "description": "Local development server for Playcademy game development",
5
5
  "type": "module",
6
6
  "exports": {