abxbus 2.5.16 → 2.5.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abxbus",
3
- "version": "2.5.16",
3
+ "version": "2.5.18",
4
4
  "description": "Event bus library for browsers and ESM Node.js",
5
5
  "type": "module",
6
6
  "sideEffects": false,
package/src/BaseEvent.ts CHANGED
@@ -42,6 +42,9 @@ function assertNoReservedUserEventFields(data: Record<string, unknown>, context:
42
42
 
43
43
  function assertNoUnknownEventPrefixedFields(data: Record<string, unknown>, context: string): void {
44
44
  for (const field_name of Object.keys(data)) {
45
+ if (field_name === 'event_extra_payload') {
46
+ throw new Error(`${context} JSON must be flat; event_extra_payload is runtime-only and must not appear on the wire`)
47
+ }
45
48
  if (field_name.startsWith('event_') && !KNOWN_BASE_EVENT_FIELDS.has(field_name)) {
46
49
  throw new Error(`${context} field "${field_name}" starts with "event_" but is not a recognized BaseEvent field`)
47
50
  }
@@ -530,15 +533,7 @@ function eventResultTypeToJSON(schema: z.ZodTypeAny | undefined): JsonSchema | u
530
533
  if (!schema) {
531
534
  return undefined
532
535
  }
533
- try {
534
- return toJsonSchema(schema)
535
- } catch {
536
- try {
537
- return toJsonSchema(schema, { io: 'input' })
538
- } catch {
539
- return undefined
540
- }
541
- }
536
+ return toJsonSchema(schema)
542
537
  }
543
538
 
544
539
  export class BaseEvent {
package/src/jsonschema.ts CHANGED
@@ -138,7 +138,14 @@ const normalizeJsonSchemaValue = (schema: unknown): unknown => {
138
138
  }
139
139
 
140
140
  export const toJsonSchema = (schema: z.core.$ZodType, params?: z.core.ToJSONSchemaParams): JsonSchema => {
141
- return normalizeJsonSchema(z.toJSONSchema(schema, params) as JsonSchema)
141
+ try {
142
+ return normalizeJsonSchema(z.toJSONSchema(schema, params) as JsonSchema)
143
+ } catch (error) {
144
+ if (params?.io === 'input') {
145
+ throw error
146
+ }
147
+ return normalizeJsonSchema(z.toJSONSchema(schema, { ...params, io: 'input' }) as JsonSchema)
148
+ }
142
149
  }
143
150
 
144
151
  export const fromJsonSchema = (schema: JsonSchema): z.ZodTypeAny => {