{"version":3,"file":"TransactionSerializer.cjs","sources":["../../../src/outbox/TransactionSerializer.ts"],"sourcesContent":["import type {\n  OfflineTransaction,\n  SerializedError,\n  SerializedMutation,\n  SerializedOfflineTransaction,\n} from '../types'\nimport type { Collection, PendingMutation } from '@tanstack/db'\n\nconst temporalConstructorNames = [\n  `Duration`,\n  `Instant`,\n  `PlainDate`,\n  `PlainDateTime`,\n  `PlainMonthDay`,\n  `PlainTime`,\n  `PlainYearMonth`,\n  `ZonedDateTime`,\n] as const\n\ntype TemporalConstructorName = (typeof temporalConstructorNames)[number]\ntype TemporalConstructor = {\n  from: (value: string) => unknown\n  prototype?: { toString?: () => string }\n}\n\nfunction getTemporalConstructorName(\n  type: unknown,\n): TemporalConstructorName | undefined {\n  if (typeof type !== `string` || !type.startsWith(`Temporal.`)) return\n  const constructorName = type.slice(\n    `Temporal.`.length,\n  ) as TemporalConstructorName\n  return temporalConstructorNames.includes(constructorName)\n    ? constructorName\n    : undefined\n}\n\nfunction requireTemporalConstructor(\n  name: TemporalConstructorName,\n): TemporalConstructor {\n  const constructor = (\n    globalThis as {\n      Temporal?: Partial<Record<TemporalConstructorName, TemporalConstructor>>\n    }\n  ).Temporal?.[name]\n  if (typeof constructor?.from !== `function`)\n    throw new MissingTemporalConstructorError(\n      `Missing global Temporal.${name} constructor`,\n    )\n  return constructor\n}\n\nfunction serializeTemporalValue(\n  value: object,\n  name: TemporalConstructorName,\n): string | undefined {\n  const constructor = requireTemporalConstructor(name)\n  const toString = constructor.prototype?.toString\n  if (typeof toString !== `function` || toString === Object.prototype.toString)\n    return\n  try {\n    const serialized = toString.call(value)\n    return typeof serialized === `string` ? serialized : undefined\n  } catch {\n    // Temporal prototype methods brand-check their receiver. A matching\n    // Symbol.toStringTag without the corresponding internal slots is user data.\n    return\n  }\n}\n\nfunction mayBeNativeScalar(value: object): boolean {\n  const prototype = Object.getPrototypeOf(value)\n  return (\n    prototype !== null &&\n    prototype !== Object.prototype &&\n    !Array.isArray(value)\n  )\n}\n\nexport class MissingTemporalConstructorError extends Error {}\n\nfunction setDataProperty(\n  object: Record<string, unknown>,\n  key: string,\n  value: unknown,\n): void {\n  if (key !== `__proto__`) object[key] = value\n  else\n    Object.defineProperty(object, key, {\n      value,\n      enumerable: true,\n      configurable: true,\n      writable: true,\n    })\n}\n\nfunction assertOutboxPhase(\n  phase: unknown,\n): asserts phase is `deletion-pending` | `rejection-pending` | undefined {\n  if (\n    phase !== undefined &&\n    phase !== `deletion-pending` &&\n    phase !== `rejection-pending`\n  )\n    throw new Error(`Unsupported transaction outbox phase`)\n}\n\nexport class TransactionSerializer {\n  private collections: Record<string, Collection<any, any, any, any, any>>\n  private collectionIdToKey: Map<string, string>\n\n  constructor(\n    collections: Record<string, Collection<any, any, any, any, any>>,\n  ) {\n    this.collections = collections\n    // Create reverse lookup from collection.id to registry key\n    this.collectionIdToKey = new Map()\n    for (const [key, collection] of Object.entries(collections)) {\n      this.collectionIdToKey.set(collection.id, key)\n    }\n  }\n\n  serialize(transaction: OfflineTransaction): string {\n    assertOutboxPhase(transaction.outboxPhase)\n    const serialized: SerializedOfflineTransaction = {\n      ...transaction,\n      valueEncoding: 3,\n      createdAt: transaction.createdAt.toISOString(),\n      metadata: this.serializeValue(transaction.metadata, `metadata`),\n      mutations: transaction.mutations.map((mutation) =>\n        this.serializeMutation(mutation),\n      ),\n    }\n    return JSON.stringify(serialized)\n  }\n\n  deserialize(data: string): OfflineTransaction {\n    // Old records retain their Date-marker meaning. New records also escape\n    // marker-shaped user objects; the encoding tag is not application metadata.\n    const {\n      valueEncoding,\n      outboxPhase,\n      ...parsed\n    }: Omit<SerializedOfflineTransaction, `valueEncoding` | `outboxPhase`> & {\n      valueEncoding?: unknown\n      outboxPhase?: unknown\n    } = JSON.parse(data)\n    if (\n      valueEncoding !== undefined &&\n      valueEncoding !== 2 &&\n      valueEncoding !== 3\n    ) {\n      throw new Error(\n        `Unsupported transaction value encoding: ${valueEncoding}`,\n      )\n    }\n    assertOutboxPhase(outboxPhase)\n\n    const createdAt = new Date(parsed.createdAt)\n    if (isNaN(createdAt.getTime())) {\n      throw new Error(\n        `Failed to deserialize transaction: invalid createdAt value \"${parsed.createdAt}\"`,\n      )\n    }\n\n    return {\n      ...parsed,\n      ...(outboxPhase === undefined ? {} : { outboxPhase }),\n      createdAt,\n      metadata:\n        valueEncoding === 3\n          ? this.deserializeValue(parsed.metadata, valueEncoding)\n          : parsed.metadata,\n      mutations: parsed.mutations.map((mutationData) =>\n        this.deserializeMutation(mutationData, valueEncoding),\n      ),\n    }\n  }\n\n  private serializeMutation(mutation: PendingMutation): SerializedMutation {\n    const registryKey = this.collectionIdToKey.get(mutation.collection.id)\n    if (!registryKey) {\n      throw new Error(\n        `Collection with id ${mutation.collection.id} not found in registry`,\n      )\n    }\n\n    return {\n      globalKey: mutation.globalKey,\n      type: mutation.type,\n      modified: this.serializeValue(mutation.modified),\n      original: this.serializeValue(mutation.original),\n      changes: this.serializeValue(mutation.changes),\n      collectionId: registryKey, // Store registry key instead of collection.id\n    }\n  }\n\n  private deserializeMutation(\n    data: SerializedMutation,\n    valueEncoding: 2 | 3 | undefined,\n  ): PendingMutation {\n    const collection = this.collections[data.collectionId]\n    if (!collection) {\n      throw new Error(`Collection with id ${data.collectionId} not found`)\n    }\n\n    const modified = this.deserializeValue(data.modified, valueEncoding)\n\n    // Extract the key from the modified data using the collection's getKey function\n    // This is needed for optimistic state restoration to work correctly\n    const key = modified ? collection.getKeyFromItem(modified) : null\n\n    // Create a partial PendingMutation - we can't fully reconstruct it but\n    // we provide what we can. The executor will need to handle the rest.\n    return {\n      globalKey: data.globalKey,\n      type: data.type as any,\n      modified,\n      original: this.deserializeValue(data.original, valueEncoding),\n      changes: this.deserializeValue(data.changes, valueEncoding) ?? {},\n      collection,\n      // These fields would need to be reconstructed by the executor\n      mutationId: ``, // Will be regenerated\n      key,\n      metadata: undefined,\n      syncMetadata: {},\n      optimistic: true,\n      createdAt: new Date(),\n      updatedAt: new Date(),\n    } as PendingMutation\n  }\n\n  private serializeValue(\n    value: any,\n    jsonKey?: string | false,\n    ancestors = new WeakSet<object>(),\n  ): any {\n    if (value === null || typeof value !== `object`) return value\n\n    if (jsonKey !== false && value instanceof Date) {\n      return { __type: `Date`, value: value.toISOString() }\n    }\n\n    const temporalConstructorName =\n      jsonKey !== false && mayBeNativeScalar(value)\n        ? getTemporalConstructorName(value[Symbol.toStringTag])\n        : undefined\n    if (temporalConstructorName) {\n      const temporalValue = serializeTemporalValue(\n        value,\n        temporalConstructorName,\n      )\n      if (temporalValue !== undefined)\n        return {\n          __type: `Temporal`,\n          type: `Temporal.${temporalConstructorName}`,\n          value: temporalValue,\n        }\n    }\n\n    if (ancestors.has(value))\n      throw new TypeError(`Converting circular structure to JSON`)\n\n    const toJSON = typeof jsonKey === `string` && value.toJSON\n    if (typeof toJSON === `function`) {\n      const replacement = toJSON.call(value, jsonKey)\n      if (replacement === value) {\n        return this.serializeValue(replacement, false, ancestors)\n      }\n\n      ancestors.add(value)\n      try {\n        return this.serializeValue(replacement, false, ancestors)\n      } finally {\n        ancestors.delete(value)\n      }\n    }\n    if (\n      jsonKey !== undefined &&\n      (value instanceof Boolean ||\n        value instanceof BigInt ||\n        value instanceof Number ||\n        value instanceof String)\n    ) {\n      return value.valueOf()\n    }\n\n    ancestors.add(value)\n\n    const isArray = Array.isArray(value)\n    const result: any = isArray ? [] : {}\n    try {\n      if (isArray) {\n        const length = value.length\n        for (let index = 0; index < length; index++) {\n          const key = String(index)\n          setDataProperty(\n            result,\n            key,\n            this.serializeValue(\n              value[index],\n              jsonKey === undefined ? undefined : key,\n              ancestors,\n            ),\n          )\n        }\n      } else {\n        for (const key of Object.keys(value)) {\n          setDataProperty(\n            result,\n            key,\n            this.serializeValue(\n              value[key],\n              jsonKey === undefined ? undefined : key,\n              ancestors,\n            ),\n          )\n        }\n      }\n    } finally {\n      ancestors.delete(value)\n    }\n    if (jsonKey === false && typeof result.toJSON === `function`)\n      delete result.toJSON\n    return !isArray && Object.prototype.hasOwnProperty.call(value, `__type`)\n      ? { __type: `Object`, value: result }\n      : result\n  }\n\n  private deserializeValue(value: any, valueEncoding: 2 | 3 | undefined): any {\n    if (value === null || value === undefined) {\n      return value\n    }\n\n    if (typeof value === `object` && value.__type === `Date`) {\n      if (value.value === undefined || value.value === null) {\n        throw new Error(`Corrupted Date marker: missing value field`)\n      }\n      const date = new Date(value.value)\n      if (isNaN(date.getTime())) {\n        throw new Error(\n          `Failed to deserialize Date marker: invalid date value \"${value.value}\"`,\n        )\n      }\n      return date\n    }\n\n    if (\n      valueEncoding === 3 &&\n      typeof value === `object` &&\n      value.__type === `Temporal`\n    ) {\n      const constructorName = getTemporalConstructorName(value.type)\n      if (!constructorName)\n        throw new Error(`Corrupted Temporal marker: invalid type field`)\n      if (typeof value.value !== `string`)\n        throw new Error(`Corrupted Temporal marker: missing value field`)\n      return requireTemporalConstructor(constructorName).from(value.value)\n    }\n\n    if (typeof value === `object`) {\n      // Unwrap once, then decode only the fields: the object's own __type is data.\n      if (valueEncoding !== undefined && value.__type === `Object`) {\n        if (\n          value.value === null ||\n          typeof value.value !== `object` ||\n          Array.isArray(value.value)\n        ) {\n          throw new Error(`Corrupted Object marker: expected an object value`)\n        }\n        value = value.value\n      }\n      const result: any = Array.isArray(value) ? [] : {}\n      for (const key in value) {\n        if (Object.prototype.hasOwnProperty.call(value, key)) {\n          setDataProperty(\n            result,\n            key,\n            this.deserializeValue(value[key], valueEncoding),\n          )\n        }\n      }\n      return result\n    }\n\n    return value\n  }\n\n  serializeError(error: Error): SerializedError {\n    return {\n      name: error.name,\n      message: error.message,\n      stack: error.stack,\n    }\n  }\n\n  deserializeError(data: SerializedError): Error {\n    const error = new Error(data.message)\n    error.name = data.name\n    error.stack = data.stack\n    return error\n  }\n}\n"],"names":[],"mappings":";;AAQA,MAAM,2BAA2B;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF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