feat: add authenticated iOS background presence beacon (#73330)

* feat: add iOS background presence beacon

Co-authored-by: ngutman <1540134+ngutman@users.noreply.github.com>

* fix: keep iOS background reconnects ahead of beacon throttle

* build: refresh gateway protocol swift models

* fix: emit swift protocol string enums

---------

Co-authored-by: ngutman <1540134+ngutman@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-04-28 08:10:35 +01:00
committed by GitHub
parent d525d6486d
commit bdba90a20b
27 changed files with 1082 additions and 76 deletions

View File

@@ -72,6 +72,9 @@ function camelCase(input: string) {
function safeName(name: string) {
const cc = camelCase(name.replace(/-/g, "_"));
if (/^\d/.test(cc)) {
return `_${cc}`;
}
if (reserved.has(cc)) {
return `_${cc}`;
}
@@ -152,6 +155,16 @@ function swiftType(schema: JsonSchema, required: boolean, allowStructuralNamed =
return isOptional ? `${base}?` : base;
}
function emitEnum(name: string, schema: JsonSchema): string {
const cases = schema.enum ?? [];
return [
`public enum ${name}: String, Codable, Sendable {`,
...cases.map((value) => ` case ${safeName(value)} = "${value}"`),
"}",
"",
].join("\n");
}
function emitStruct(name: string, schema: JsonSchema): string {
const props = schema.properties ?? {};
const required = new Set(schema.required ?? []);
@@ -262,7 +275,16 @@ async function generate() {
const parts: string[] = [];
parts.push(header);
// Value structs
// Named enums and value structs
for (const [name, schema] of definitions) {
if (name === "GatewayFrame") {
continue;
}
if (schema.type === "string" && schema.enum) {
parts.push(emitEnum(name, schema));
}
}
for (const [name, schema] of definitions) {
if (name === "GatewayFrame") {
continue;