{
  "version": 3,
  "sources": ["../../core-impl/src/platform/temporal/src/common/activities.ts", "../../core-impl/src/platform/temporal/src/common/wire.ts", "../../core-impl/src/platform/temporal/src/workflow/failure.ts", "../../core-impl/src/platform/temporal/src/common/errors.ts", "../../core-impl/src/platform/temporal/src/workflow/arguments.ts", "../../core-impl/src/platform/temporal/src/workflow/paginated.ts", "../../core-impl/src/platform/temporal/src/workflow/annotations.ts", "../../core-impl/src/platform/temporal/src/workflow/object.ts", "../../core-impl/src/platform/temporal/src/workflow/presence.ts", "../../core-impl/src/platform/temporal/src/workflow/channel.ts", "../../core-impl/src/platform/temporal/src/workflow/invoker.ts", "../../core-impl/src/platform/temporal/src/workflow/push.ts", "../../core-impl/src/platform/temporal/src/workflow/client.ts"],
  "sourcesContent": ["// The contract between the workflow-side proxy and the worker-side activities: the activity names, and the\n// shape of each activity's input and result.\n//\n// Shared between the workflow and worker entry points, so this module must stay workflow-safe. It only\n// imports types from '@ably/pubsub-core/api', never values.\n//\n// Binary data crosses the activity boundary as base64 strings, as described in ./wire.ts. The types below describe\n// the values that workflow code passes and receives, before that encoding and after decoding.\n\nimport type * as Ably from '@ably/pubsub-core/api';\nimport type {\n  HttpObjectGetCompactResult,\n  HttpObjectGetFullResult,\n  HttpObjectGetParams,\n  HttpObjectOperation,\n  HttpObjectPublishResult,\n} from '@ably/pubsub-core/liveobjects';\nimport type { WireHttpPaginatedResponse, WirePage } from './wire.js';\n\n/**\n * The names under which the Ably activities are registered on the worker. Every name is prefixed with `ably.`.\n * `AblyHttpPlugin` adds the Ably activities over the worker's own `activities`, so an application activity with\n * the same name is replaced. Application activities must not use names that start with `ably.`.\n */\nexport const ActivityNames = {\n  publish: 'ably.channel.publish',\n  history: 'ably.channel.history',\n  status: 'ably.channel.status',\n  getMessage: 'ably.channel.getMessage',\n  updateMessage: 'ably.channel.updateMessage',\n  deleteMessage: 'ably.channel.deleteMessage',\n  appendMessage: 'ably.channel.appendMessage',\n  getMessageVersions: 'ably.channel.getMessageVersions',\n  presenceGet: 'ably.channel.presence.get',\n  presenceHistory: 'ably.channel.presence.history',\n  annotationsPublish: 'ably.channel.annotations.publish',\n  annotationsDelete: 'ably.channel.annotations.delete',\n  annotationsGet: 'ably.channel.annotations.get',\n  objectGet: 'ably.channel.object.get',\n  objectPublish: 'ably.channel.object.publish',\n  time: 'ably.time',\n  request: 'ably.request',\n  batchPublish: 'ably.batchPublish',\n  batchPresence: 'ably.batchPresence',\n  pushPublish: 'ably.push.admin.publish',\n  pushCreateApnsBroadcast: 'ably.push.admin.createApnsBroadcast',\n  pushLiveActivityStart: 'ably.push.admin.liveActivity.start',\n  pushLiveActivityUpdate: 'ably.push.admin.liveActivity.update',\n  pushLiveActivityEnd: 'ably.push.admin.liveActivity.end',\n  pushDeviceRegistrationsSave: 'ably.push.admin.deviceRegistrations.save',\n  pushDeviceRegistrationsGet: 'ably.push.admin.deviceRegistrations.get',\n  pushDeviceRegistrationsList: 'ably.push.admin.deviceRegistrations.list',\n  pushDeviceRegistrationsRemove: 'ably.push.admin.deviceRegistrations.remove',\n  pushDeviceRegistrationsRemoveWhere: 'ably.push.admin.deviceRegistrations.removeWhere',\n  pushChannelSubscriptionsSave: 'ably.push.admin.channelSubscriptions.save',\n  pushChannelSubscriptionsList: 'ably.push.admin.channelSubscriptions.list',\n  pushChannelSubscriptionsListChannels: 'ably.push.admin.channelSubscriptions.listChannels',\n  pushChannelSubscriptionsRemove: 'ably.push.admin.channelSubscriptions.remove',\n  pushChannelSubscriptionsRemoveWhere: 'ably.push.admin.channelSubscriptions.removeWhere',\n} as const;\n\nexport type ActivityName = (typeof ActivityNames)[keyof typeof ActivityNames];\n\n/** Identifies the channel that a channel-scoped activity operates on. */\nexport interface ChannelInput {\n  channel: string;\n}\n\n/**\n * Input for {@link ActivityNames.publish}. The workflow normalises every overload of `channel.publish()` to an\n * array of messages, and assigns message IDs when idempotent publishing is enabled.\n */\nexport interface PublishInput extends ChannelInput {\n  messages: Ably.Message[];\n  options?: Ably.PublishOptions;\n}\n\n/**\n * Input for an activity that returns a paginated result. `params` is either the caller's query parameters for\n * the first page, or the {@link PageParams} from a {@link WirePage}'s links when fetching a related page.\n */\nexport interface PaginatedInput<P> extends ChannelInput {\n  params?: P | Record<string, string>;\n}\n\nexport interface GetMessageInput extends ChannelInput {\n  serialOrMessage: string | Ably.Message;\n}\n\nexport interface MessageOperationInput extends ChannelInput {\n  message: Ably.Message;\n  operation?: Ably.MessageOperation;\n  options?: Ably.PublishOptions;\n}\n\nexport interface GetMessageVersionsInput extends ChannelInput {\n  serialOrMessage: string | Ably.Message;\n  params?: Record<string, any>;\n}\n\nexport interface AnnotationInput extends ChannelInput {\n  messageOrSerial: string | Ably.Message;\n  annotation: Ably.OutboundAnnotation;\n}\n\nexport interface GetAnnotationsInput extends ChannelInput {\n  messageOrSerial: string | Ably.Message;\n  params: Ably.GetAnnotationsParams | Record<string, string> | null;\n}\n\nexport interface ObjectGetInput extends ChannelInput {\n  params?: HttpObjectGetParams;\n}\n\nexport interface ObjectPublishInput extends ChannelInput {\n  operations: HttpObjectOperation | HttpObjectOperation[];\n}\n\nexport interface RequestInput {\n  method: string;\n  path: string;\n  version: number;\n  params?: Record<string, any>;\n  body?: unknown;\n  headers?: Record<string, string>;\n}\n\nexport interface BatchPublishInput {\n  specs: Ably.BatchPublishSpec | Ably.BatchPublishSpec[];\n}\n\nexport interface BatchPresenceInput {\n  channels: string[];\n}\n\nexport interface PushPublishInput {\n  recipient: any;\n  payload: any;\n}\n\n/** Input for a push admin activity that takes a single argument, such as a device or a set of filter parameters. */\nexport interface PushArgumentInput<T> {\n  argument: T;\n}\n\n/**\n * Input for a push admin activity that returns a paginated result. `params` is either the caller's filter\n * parameters for the first page, or the {@link PageParams} from a {@link WirePage}'s links when fetching a related\n * page.\n */\nexport interface PushListInput<P> {\n  params?: P | Record<string, string>;\n}\n\n/**\n * The Ably activities, keyed by activity name. This is the type the workflow passes to `proxyActivities()`, and\n * the type that the worker's activity implementations satisfy.\n */\nexport interface AblyActivities {\n  [ActivityNames.publish](input: PublishInput): Promise<Ably.PublishResult>;\n  [ActivityNames.history](input: PaginatedInput<Ably.HttpHistoryParams>): Promise<WirePage<Ably.InboundMessage>>;\n  [ActivityNames.status](input: ChannelInput): Promise<Ably.ChannelDetails>;\n  [ActivityNames.getMessage](input: GetMessageInput): Promise<Ably.Message>;\n  [ActivityNames.updateMessage](input: MessageOperationInput): Promise<Ably.UpdateDeleteResult>;\n  [ActivityNames.deleteMessage](input: MessageOperationInput): Promise<Ably.UpdateDeleteResult>;\n  [ActivityNames.appendMessage](input: MessageOperationInput): Promise<Ably.UpdateDeleteResult>;\n  [ActivityNames.getMessageVersions](input: GetMessageVersionsInput): Promise<WirePage<Ably.Message>>;\n  [ActivityNames.presenceGet](input: PaginatedInput<Ably.HttpPresenceParams>): Promise<WirePage<Ably.PresenceMessage>>;\n  [ActivityNames.presenceHistory](\n    input: PaginatedInput<Ably.HttpHistoryParams>,\n  ): Promise<WirePage<Ably.PresenceMessage>>;\n  [ActivityNames.annotationsPublish](input: AnnotationInput): Promise<void>;\n  [ActivityNames.annotationsDelete](input: AnnotationInput): Promise<void>;\n  [ActivityNames.annotationsGet](input: GetAnnotationsInput): Promise<WirePage<Ably.Annotation>>;\n  [ActivityNames.objectGet](input: ObjectGetInput): Promise<HttpObjectGetCompactResult | HttpObjectGetFullResult>;\n  [ActivityNames.objectPublish](input: ObjectPublishInput): Promise<HttpObjectPublishResult>;\n  [ActivityNames.time](): Promise<number>;\n  [ActivityNames.request](input: RequestInput): Promise<WireHttpPaginatedResponse<any>>;\n  [ActivityNames.batchPublish](\n    input: BatchPublishInput,\n  ): Promise<\n    | Ably.BatchResult<Ably.BatchPublishSuccessResult | Ably.BatchPublishFailureResult>\n    | Ably.BatchResult<Ably.BatchPublishSuccessResult | Ably.BatchPublishFailureResult>[]\n  >;\n  [ActivityNames.batchPresence](\n    input: BatchPresenceInput,\n  ): Promise<Ably.BatchResult<Ably.BatchPresenceSuccessResult | Ably.BatchPresenceFailureResult>[]>;\n  [ActivityNames.pushPublish](input: PushPublishInput): Promise<void>;\n  [ActivityNames.pushCreateApnsBroadcast](\n    input: PushArgumentInput<Ably.PushApnsBroadcastOptions>,\n  ): Promise<Ably.PushApnsBroadcast>;\n  [ActivityNames.pushLiveActivityStart](input: PushArgumentInput<Ably.PushLiveActivityStartParams>): Promise<void>;\n  [ActivityNames.pushLiveActivityUpdate](input: PushArgumentInput<Ably.PushLiveActivityUpdateParams>): Promise<void>;\n  [ActivityNames.pushLiveActivityEnd](input: PushArgumentInput<Ably.PushLiveActivityEndParams>): Promise<void>;\n  [ActivityNames.pushDeviceRegistrationsSave](\n    input: PushArgumentInput<Ably.DeviceDetails>,\n  ): Promise<Ably.DeviceDetails>;\n  [ActivityNames.pushDeviceRegistrationsGet](\n    input: PushArgumentInput<string | Ably.DeviceDetails>,\n  ): Promise<Ably.DeviceDetails>;\n  [ActivityNames.pushDeviceRegistrationsList](\n    input: PushListInput<Ably.DeviceRegistrationParams>,\n  ): Promise<WirePage<Ably.DeviceDetails>>;\n  [ActivityNames.pushDeviceRegistrationsRemove](input: PushArgumentInput<string | Ably.DeviceDetails>): Promise<void>;\n  [ActivityNames.pushDeviceRegistrationsRemoveWhere](\n    input: PushArgumentInput<Ably.DeviceRegistrationParams>,\n  ): Promise<void>;\n  [ActivityNames.pushChannelSubscriptionsSave](\n    input: PushArgumentInput<Ably.PushChannelSubscription>,\n  ): Promise<Ably.PushChannelSubscription>;\n  [ActivityNames.pushChannelSubscriptionsList](\n    input: PushListInput<Ably.PushChannelSubscriptionParams>,\n  ): Promise<WirePage<Ably.PushChannelSubscription>>;\n  [ActivityNames.pushChannelSubscriptionsListChannels](\n    input: PushListInput<Ably.PushChannelsParams>,\n  ): Promise<WirePage<string>>;\n  [ActivityNames.pushChannelSubscriptionsRemove](input: PushArgumentInput<Ably.PushChannelSubscription>): Promise<void>;\n  [ActivityNames.pushChannelSubscriptionsRemoveWhere](\n    input: PushArgumentInput<Ably.PushChannelSubscriptionParams>,\n  ): Promise<void>;\n}\n", "// Values that cross the activity boundary are serialised by Temporal's payload converter, which is JSON-based\n// by default. JSON cannot represent binary data, so binary data crosses the boundary as Ably's JSON protocol carries\n// it:\n//\n// - The `data` of a message, presence message or annotation is a base64 string, with `base64` appended to its\n//   `encoding` (RSL4d1). The worker passes it to Ably as it is, and the workflow decodes it back to a `Uint8Array`.\n// - The `bytes` of a LiveObjects value is a base64 string.\n//\n// Workflow code rejects binary data anywhere else in an activity's arguments, and the worker returns binary data\n// anywhere else in a result as a base64 string.\n//\n// This module is imported by both the workflow and the worker entry points, so it must stay\n// workflow-safe: no runtime imports, no Node built-ins, and no I/O.\n\n/**\n * The query parameters for a page of a paginated result, taken from the `Link` header of the response.\n * Fetching a page again with these parameters is equivalent to calling `first()`, `current()` or `next()` on an\n * Ably `PaginatedResult`.\n */\nexport type PageParams = Record<string, string>;\n\n/** The links from a page of a paginated result to its related pages. */\nexport interface PageLinks {\n  first?: PageParams;\n  current?: PageParams;\n  next?: PageParams;\n}\n\n/** A page of a paginated result, as returned from an activity. */\nexport interface WirePage<T> {\n  items: T[];\n  links: PageLinks;\n}\n\n/** A page of the result of `rest.request()`, as returned from an activity. */\nexport interface WireHttpPaginatedResponse<T> extends WirePage<T> {\n  statusCode: number;\n  success: boolean;\n  errorCode?: number | null;\n  errorMessage?: string | null;\n  errorDetail?: Record<string, string>;\n  headers: Record<string, string | string[]>;\n}\n\n/** Encodes bytes as a base64 string. */\nexport type Base64Encoder = (bytes: Uint8Array) => string;\n\n/**\n * Handles a binary value found by {@link toWireValue}, and returns the value to replace it with.\n *\n * @param bytes - The bytes of the binary value.\n * @param path - Where the value is, such as `messages[0].data.image`.\n */\nexport type BinaryHandler = (bytes: Uint8Array, path: string) => unknown;\n\nexport function isBinary(value: unknown): value is ArrayBuffer | ArrayBufferView {\n  return value instanceof ArrayBuffer || ArrayBuffer.isView(value);\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n  return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\n/**\n * Sets an own enumerable property on `target`. A key of `__proto__` is defined as an own property, because\n * assigning it would set the prototype of `target` instead.\n */\nexport function setOwnProperty(target: Record<string, unknown>, key: string, value: unknown): void {\n  if (key === '__proto__') {\n    Object.defineProperty(target, key, { value, enumerable: true, writable: true, configurable: true });\n  } else {\n    target[key] = value;\n  }\n}\n\n/** Returns a copy of `value`, a plain object, with each of its own enumerable properties replaced by `map`. */\nfunction mapProperties(value: Record<string, unknown>, map: (property: unknown) => unknown): Record<string, unknown> {\n  const result: Record<string, unknown> = {};\n  for (const key of Object.keys(value)) {\n    setOwnProperty(result, key, map(value[key]));\n  }\n  return result;\n}\n\n/**\n * Returns a copy of `value` that can be safely JSON-serialised: every binary value (an `ArrayBuffer`, or an\n * `ArrayBufferView` such as a `Uint8Array` or Node `Buffer`) is replaced with the result of `onBinary`, and every\n * other non-null object is copied to a plain object of its own enumerable properties.\n *\n * As with `JSON.stringify()`, an object with a `toJSON()` method is replaced by the result of calling it. A `Date`\n * is left for the payload converter to serialise as an ISO string, and an `Error` also keeps its non-enumerable\n * `message` and `cause`.\n */\nexport function toWireValue(value: unknown, onBinary: BinaryHandler): unknown {\n  return copyValue(value, onBinary, '', true);\n}\n\nfunction copyValue(value: unknown, onBinary: BinaryHandler, path: string, callToJSON: boolean): unknown {\n  if (isBinary(value)) {\n    return onBinary(toBytes(value), path);\n  }\n  if (Array.isArray(value)) {\n    return value.map((item, index) => copyValue(item, onBinary, `${path}[${index}]`, true));\n  }\n  if (value instanceof Date) {\n    return value;\n  }\n  if (value !== null && typeof value === 'object') {\n    const toJSON = (value as { toJSON?: unknown }).toJSON;\n    if (callToJSON && typeof toJSON === 'function') {\n      // The result of toJSON() is not converted again, as in JSON.stringify().\n      return copyValue(toJSON.call(value), onBinary, path, false);\n    }\n    const result: Record<string, unknown> = {};\n    if (value instanceof Error) {\n      result.message = value.message;\n      const cause = (value as { cause?: unknown }).cause;\n      if (cause !== undefined) {\n        result.cause = copyValue(cause, onBinary, propertyPath(path, 'cause'), true);\n      }\n    }\n    for (const key of Object.keys(value)) {\n      const property = (value as Record<string, unknown>)[key];\n      if (property !== undefined && typeof property !== 'function') {\n        setOwnProperty(result, key, copyValue(property, onBinary, propertyPath(path, key), true));\n      }\n    }\n    return result;\n  }\n  return value;\n}\n\nfunction propertyPath(path: string, key: string): string {\n  return path ? `${path}.${key}` : key;\n}\n\n/**\n * Returns `message` with binary `data` encoded as base64, and `base64` appended to its `encoding`, as Ably's JSON\n * protocol sends binary data (RSL4d1). Anything else is returned as it is. The message passed in is not modified.\n *\n * @param message - A message, presence message or annotation.\n * @param base64 - Encodes the data as base64.\n */\nexport function encodeBinaryData<T>(message: T, base64: Base64Encoder = bytesToBase64): T {\n  if (!isObject(message) || !isBinary(message.data)) {\n    return message;\n  }\n  const encoding = message.encoding;\n  return {\n    ...message,\n    data: base64(toBytes(message.data)),\n    encoding: typeof encoding === 'string' && encoding ? `${encoding}/base64` : 'base64',\n  } as T;\n}\n\n/**\n * Reverses {@link encodeBinaryData}: returns `message` with string `data` whose last `encoding` is `base64` decoded\n * to a `Uint8Array`, and that encoding removed. When no encoding remains, `encoding` is `null`, as for a message the\n * Ably SDK has decoded. Anything else is returned as it is. The message passed in is not modified.\n *\n * @param message - A message, presence message or annotation.\n */\nexport function decodeBinaryData<T>(message: T): T {\n  if (!isObject(message) || typeof message.data !== 'string' || typeof message.encoding !== 'string') {\n    return message;\n  }\n  const encodings = message.encoding.split('/');\n  if (encodings[encodings.length - 1] !== 'base64') {\n    return message;\n  }\n  encodings.pop();\n  return { ...message, data: base64ToBytes(message.data), encoding: encodings.join('/') || null } as T;\n}\n\n/** Applies {@link decodeBinaryData} to each item of a page of messages. The page passed in is not modified. */\nexport function decodePageData<P extends WirePage<unknown>>(page: P): P {\n  return isObject(page) && Array.isArray(page.items)\n    ? ({ ...page, items: page.items.map((item) => decodeBinaryData(item)) } as P)\n    : page;\n}\n\n/**\n * Returns a LiveObjects operation with `map` applied to the `bytes` of each value it publishes: the `value` of a\n * `mapSet`, and the `data` of each entry of a `mapCreate`. The operation passed in is not modified.\n */\nexport function mapOperationBytes<T>(operation: T, map: (bytes: unknown) => unknown): T {\n  if (!isObject(operation)) {\n    return operation;\n  }\n  const { mapSet, mapCreate } = operation;\n  let result: Record<string, unknown> = operation;\n  if (isObject(mapSet) && isObject(mapSet.value) && mapSet.value.bytes != null) {\n    result = { ...result, mapSet: { ...mapSet, value: { ...mapSet.value, bytes: map(mapSet.value.bytes) } } };\n  }\n  if (isObject(mapCreate) && isObject(mapCreate.entries)) {\n    const entries = mapProperties(mapCreate.entries, (entry) =>\n      isObject(entry) && isObject(entry.data) && entry.data.bytes != null\n        ? { ...entry, data: { ...entry.data, bytes: map(entry.data.bytes) } }\n        : entry,\n    );\n    result = { ...result, mapCreate: { ...mapCreate, entries } };\n  }\n  return result as T;\n}\n\n/**\n * Returns a full-format LiveObjects `get()` result with `map` applied to the `bytes` of each value in it: those of a\n * leaf value, and those of each map entry, at any depth. The result passed in is not modified.\n */\nexport function mapFullObjectBytes<T>(node: T, map: (bytes: unknown) => unknown): T {\n  if (!isObject(node)) {\n    return node;\n  }\n  if (isObject(node.map)) {\n    const { entries } = node.map;\n    if (!isObject(entries)) {\n      return node;\n    }\n    const mapped = mapProperties(entries, (entry) =>\n      isObject(entry) ? { ...entry, data: mapFullObjectBytes(entry.data, map) } : entry,\n    );\n    return { ...node, map: { ...node.map, entries: mapped } } as T;\n  }\n  if ('counter' in node || node.bytes == null) {\n    return node;\n  }\n  return { ...node, bytes: map(node.bytes) } as T;\n}\n\nexport function toBytes(value: ArrayBuffer | ArrayBufferView): Uint8Array {\n  if (value instanceof ArrayBuffer) {\n    return new Uint8Array(value);\n  }\n  return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n}\n\n// Neither `Buffer` nor `btoa`/`atob` is guaranteed to exist in the workflow sandbox, so base64 is implemented here.\nconst BASE64_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nconst BASE64_LOOKUP: Record<string, number> = {};\nfor (let i = 0; i < BASE64_ALPHABET.length; i++) {\n  BASE64_LOOKUP[BASE64_ALPHABET[i]] = i;\n}\n\nexport function bytesToBase64(bytes: Uint8Array): string {\n  let result = '';\n  for (let i = 0; i < bytes.length; i += 3) {\n    const b0 = bytes[i];\n    const b1 = i + 1 < bytes.length ? bytes[i + 1] : 0;\n    const b2 = i + 2 < bytes.length ? bytes[i + 2] : 0;\n    const triple = (b0 << 16) | (b1 << 8) | b2;\n    result += BASE64_ALPHABET[(triple >> 18) & 0x3f];\n    result += BASE64_ALPHABET[(triple >> 12) & 0x3f];\n    result += i + 1 < bytes.length ? BASE64_ALPHABET[(triple >> 6) & 0x3f] : '=';\n    result += i + 2 < bytes.length ? BASE64_ALPHABET[triple & 0x3f] : '=';\n  }\n  return result;\n}\n\nexport function base64ToBytes(base64: string): Uint8Array {\n  const stripped = base64.replace(/=+$/, '');\n  const bytes = new Uint8Array(Math.floor((stripped.length * 3) / 4));\n  let byteIndex = 0;\n  for (let i = 0; i < stripped.length; i += 4) {\n    const c0 = BASE64_LOOKUP[stripped[i]] ?? 0;\n    const c1 = BASE64_LOOKUP[stripped[i + 1]] ?? 0;\n    const c2 = BASE64_LOOKUP[stripped[i + 2]] ?? 0;\n    const c3 = BASE64_LOOKUP[stripped[i + 3]] ?? 0;\n    const triple = (c0 << 18) | (c1 << 12) | (c2 << 6) | c3;\n    if (byteIndex < bytes.length) bytes[byteIndex++] = (triple >> 16) & 0xff;\n    if (byteIndex < bytes.length) bytes[byteIndex++] = (triple >> 8) & 0xff;\n    if (byteIndex < bytes.length) bytes[byteIndex++] = triple & 0xff;\n  }\n  return bytes;\n}\n", "import { ApplicationFailure } from '@temporalio/common';\nimport { ABLY_ERROR_TYPE, type AblyErrorDetails } from '../common/errors.js';\n\n/**\n * Creates the failure to throw for an error detected in workflow code, before any activity runs.\n *\n * It has the same shape as the failure an Ably activity fails with, so `getAblyErrorDetails` finds its details.\n * Throwing an `ApplicationFailure` fails the workflow. Any other error would fail the workflow task instead,\n * which retries it indefinitely.\n */\nexport function ablyFailure(details: Omit<AblyErrorDetails, 'href'>): ApplicationFailure {\n  return ApplicationFailure.create({\n    type: ABLY_ERROR_TYPE,\n    message: details.message,\n    nonRetryable: true,\n    details: [{ ...details, href: `https://help.ably.io/error/${details.code}` }],\n  });\n}\n", "// Shared between the workflow and worker entry points, so this module must stay workflow-safe.\n\nimport { ApplicationFailure } from '@temporalio/common';\n\n/**\n * The `type` of the `ApplicationFailure` that an Ably activity fails with when the Ably HTTP client returns an\n * error. It can be listed in a retry policy's `nonRetryableErrorTypes` to stop Temporal from retrying any failed\n * Ably request.\n */\nexport const ABLY_ERROR_TYPE = 'AblyError';\n\n/**\n * The details of an Ably `ErrorInfo`, carried across the activity boundary as the first entry in the\n * `details` of an `ApplicationFailure` whose `type` is {@link ABLY_ERROR_TYPE}.\n */\nexport interface AblyErrorDetails {\n  /**\n   * The Ably error code, or `null` if the error has none. An error response that did not come from Ably, such as\n   * one from a proxy, has no Ably error code.\n   */\n  code: number | null;\n  /** The HTTP status code of the error, if the error has one. */\n  statusCode?: number;\n  /** The error message. */\n  message: string;\n  /** A link to documentation for the error code, if available. */\n  href?: string;\n  /** How to fix the error, if the Ably SDK provided a remediation. */\n  remediation?: string;\n  /** Additional key-value details about the error, if the error has any. */\n  detail?: Record<string, string>;\n}\n\n/**\n * Finds the details of the Ably error that caused an operation to fail.\n *\n * When an Ably operation fails in workflow code, the error thrown is the Temporal `ActivityFailure` for the\n * activity that ran it, with an `ApplicationFailure` of type {@link ABLY_ERROR_TYPE} as its cause. This walks the\n * `cause` chain of `error` and returns the Ably error details from the first such failure.\n *\n * @param error - The error caught from an Ably operation.\n * @returns The Ably error details, or `undefined` if `error` was not caused by an Ably error.\n */\nexport function getAblyErrorDetails(error: unknown): AblyErrorDetails | undefined {\n  let current: unknown = error;\n  // Guard against cyclic cause chains.\n  for (let depth = 0; depth < 32 && current != null; depth++) {\n    if (current instanceof ApplicationFailure && current.type === ABLY_ERROR_TYPE) {\n      const details = current.details?.[0];\n      return isAblyErrorDetails(details) ? details : undefined;\n    }\n    current = (current as { cause?: unknown }).cause;\n  }\n  return undefined;\n}\n\nfunction isAblyErrorDetails(value: unknown): value is AblyErrorDetails {\n  return (\n    value !== null &&\n    typeof value === 'object' &&\n    (typeof (value as AblyErrorDetails).code === 'number' || (value as AblyErrorDetails).code === null) &&\n    typeof (value as AblyErrorDetails).message === 'string'\n  );\n}\n", "import type { ApplicationFailure } from '@temporalio/common';\nimport { encodeBinaryData } from '../common/wire.js';\nimport { ablyFailure } from './failure.js';\n\n// Arguments are checked in workflow code when passing them to the activity would make the Ably SDK throw a\n// `TypeError`. The activity would rethrow that error as it is, and Temporal would retry it indefinitely.\n\nfunction invalidArgument(message: string, remediation: string): ApplicationFailure {\n  return ablyFailure({ message, code: 40003, statusCode: 400, remediation });\n}\n\nfunction isObject(value: unknown): value is object {\n  return value !== null && typeof value === 'object';\n}\n\n/**\n * Returns the value to send for an argument that is either a message serial or a message carrying a `serial`. A\n * message with a serial is reduced to its serial, so that only the serial is recorded in the workflow history. A\n * message without one is sent as it is, with binary data encoded, so that the activity fails with the Ably SDK's own\n * error.\n *\n * @param method - The name of the method, for the error message, such as `getMessage`.\n * @param serialOrMessage - The argument passed to the method.\n */\nexport function serialArgument<M extends object>(method: string, serialOrMessage: string | M): string | M {\n  if (typeof serialOrMessage === 'string') {\n    return serialOrMessage;\n  }\n  if (isObject(serialOrMessage)) {\n    const serial = (serialOrMessage as { serial?: unknown }).serial;\n    return typeof serial === 'string' && serial.length > 0 ? serial : encodeBinaryData(serialOrMessage);\n  }\n  throw invalidArgument(\n    `${method}() expects a message serial or a message object, but was called with ${describeValue(serialOrMessage)}`,\n    `Pass the Message received from history() or a subscribe callback, which carries a serial, or its serial string.`,\n  );\n}\n\n/**\n * Returns the value to send for an argument that is either a push device ID or a device carrying an `id`. A device\n * with an ID is reduced to its ID, so that only the ID is recorded in the workflow history. A device without one is\n * sent as it is, so that the activity fails with the Ably SDK's own error.\n *\n * @param method - The name of the method, for the error message, such as `push.admin.deviceRegistrations.get`.\n * @param deviceIdOrDetails - The argument passed to the method.\n */\nexport function deviceIdArgument<D extends object>(method: string, deviceIdOrDetails: string | D): string | D {\n  if (typeof deviceIdOrDetails === 'string') {\n    return deviceIdOrDetails;\n  }\n  if (isObject(deviceIdOrDetails)) {\n    const id = (deviceIdOrDetails as { id?: unknown }).id;\n    return typeof id === 'string' && id.length > 0 ? id : deviceIdOrDetails;\n  }\n  throw invalidArgument(\n    `${method}() expects a device ID or a DeviceDetails object, but was called with ${describeValue(deviceIdOrDetails)}`,\n    'Pass the device ID string, or the DeviceDetails object returned by push.admin.deviceRegistrations.save() or get().',\n  );\n}\n\n/**\n * Checks that an argument is an object.\n *\n * @param method - The name of the method, for the error message, such as `updateMessage`.\n * @param name - The name of the argument, for the error message.\n * @param value - The argument passed to the method.\n * @param remediation - How to fix a call that passes something else.\n */\nexport function requireObject(method: string, name: string, value: unknown, remediation: string): void {\n  if (!isObject(value) || Array.isArray(value)) {\n    throw invalidArgument(\n      `${method}() expects ${name} to be an object, but was called with ${describeValue(value)}`,\n      remediation,\n    );\n  }\n}\n\n/**\n * Checks that an argument is a string.\n *\n * @param method - The name of the method, for the error message, such as `request`.\n * @param name - The name of the argument, for the error message.\n * @param value - The argument passed to the method.\n */\nexport function requireString(method: string, name: string, value: unknown): void {\n  if (typeof value !== 'string') {\n    throw invalidArgument(\n      `${method}() expects ${name} to be a string, but was called with ${describeValue(value)}`,\n      `Pass ${name} as a string.`,\n    );\n  }\n}\n\n/**\n * Checks that an argument is an array of strings.\n *\n * @param method - The name of the method, for the error message, such as `batchPresence`.\n * @param name - The name of the argument, for the error message.\n * @param value - The argument passed to the method.\n */\nexport function requireStringArray(method: string, name: string, value: unknown): void {\n  if (!Array.isArray(value) || !value.every((item) => typeof item === 'string')) {\n    throw invalidArgument(\n      `${method}() expects ${name} to be an array of strings, but was called with ${describeValue(value)}`,\n      `Pass ${name} as an array of strings.`,\n    );\n  }\n}\n\nfunction describeValue(value: unknown): string {\n  if (value === null) {\n    return 'null';\n  }\n  if (Array.isArray(value)) {\n    return 'an array';\n  }\n  return typeof value === 'object' ? 'an object' : `a value of type ${typeof value}`;\n}\n", "import type { PageLinks, PageParams, WireHttpPaginatedResponse, WirePage } from '../common/wire.js';\nimport { ablyFailure } from './failure.js';\n\n/**\n * A page of results from a paginated Ably REST query made from workflow code, such as channel history or\n * presence. It mirrors the Ably `PaginatedResult`.\n *\n * Fetching a related page with {@link TemporalAblyPaginatedResult.next | next()}, {@link TemporalAblyPaginatedResult.first\n * | first()} or {@link TemporalAblyPaginatedResult.current | current()} runs the query's activity again with the\n * parameters from that page's link.\n */\nexport interface TemporalAblyPaginatedResult<T> {\n  /** The items in this page of results. */\n  readonly items: T[];\n  /**\n   * Fetches the first page of results. Runs as a Temporal activity.\n   *\n   * @returns A promise which is fulfilled with the first page of results. It is rejected with an\n   * `ApplicationFailure` of type `AblyError` if this page has no link to the first page.\n   */\n  first(): Promise<TemporalAblyPaginatedResult<T>>;\n  /**\n   * Fetches the next page of results. Runs as a Temporal activity when there is a next page.\n   *\n   * @returns A promise which is fulfilled with the next page of results, or with `null` if this is the last page.\n   */\n  next(): Promise<TemporalAblyPaginatedResult<T> | null>;\n  /**\n   * Fetches the current page of results again. Runs as a Temporal activity.\n   *\n   * @returns A promise which is fulfilled with the current page of results. It is rejected with an\n   * `ApplicationFailure` of type `AblyError` if this page has no link to the current page.\n   */\n  current(): Promise<TemporalAblyPaginatedResult<T>>;\n  /**\n   * Returns whether there are more pages of results after this one.\n   *\n   * @returns `true` if {@link TemporalAblyPaginatedResult.next | next()} returns another page, otherwise `false`.\n   */\n  hasNext(): boolean;\n  /**\n   * Returns whether this is the last page of results.\n   *\n   * @returns `true` if this is the last page, otherwise `false`.\n   */\n  isLast(): boolean;\n}\n\n/**\n * A page of the response to `TemporalAblyHttpClient.request()`, with the details of the HTTP response. It\n * mirrors the Ably `HttpPaginatedResponse`.\n *\n * Related pages are fetched with a `GET` request to the same path, with the same API version and headers.\n */\nexport interface TemporalAblyHttpPaginatedResponse<T = any> extends TemporalAblyPaginatedResult<T> {\n  /** The HTTP status code of the response. */\n  readonly statusCode: number;\n  /** Whether `statusCode` indicates success. This is equivalent to `200 <= statusCode < 300`. */\n  readonly success: boolean;\n  /** The error code from the `X-Ably-Errorcode` response header, or `null` if the response has none. */\n  readonly errorCode: number | null;\n  /** The error message from the `X-Ably-Errormessage` response header, or `null` if the response has none. */\n  readonly errorMessage: string | null;\n  /** Additional details about the error, if the response has any. */\n  readonly errorDetail?: Record<string, string>;\n  /** The headers of the response. */\n  readonly headers: Record<string, string | string[]>;\n  first(): Promise<TemporalAblyHttpPaginatedResponse<T>>;\n  next(): Promise<TemporalAblyHttpPaginatedResponse<T> | null>;\n  current(): Promise<TemporalAblyHttpPaginatedResponse<T>>;\n}\n\n/** Which related page of a paginated result to fetch. */\nexport type PageRelation = keyof PageLinks;\n\n/** Fetches the page at a link of a paginated result, by running the query's activity with the link's params. */\nexport type PageFetcher<P> = (params: PageParams, relation: PageRelation) => Promise<P>;\n\nclass PaginatedResultImpl<T, P> {\n  readonly items: T[];\n  private readonly links: PageLinks;\n\n  constructor(\n    page: WirePage<T>,\n    private readonly fetchPage: PageFetcher<P>,\n  ) {\n    this.items = page.items ?? [];\n    this.links = page.links ?? {};\n  }\n\n  async first(): Promise<P> {\n    if (this.links.first) {\n      return this.fetchPage(this.links.first, 'first');\n    }\n    throw ablyFailure({\n      message: 'No link to the first page of results',\n      code: 40400,\n      statusCode: 404,\n      remediation:\n        'first() is only available on results from a paginated REST query (such as channel history or presence), whose response includes a link to the first page. This result has no such link, so there is no first page to return.',\n    });\n  }\n\n  async current(): Promise<P> {\n    if (this.links.current) {\n      return this.fetchPage(this.links.current, 'current');\n    }\n    throw ablyFailure({\n      message: 'No link to the current page of results',\n      code: 40400,\n      statusCode: 404,\n      remediation:\n        'current() reloads the current page and is only available on results from a paginated REST query (such as channel history or presence). This result has no such link. To page through results, use next() with hasNext() or isLast() instead.',\n    });\n  }\n\n  async next(): Promise<P | null> {\n    return this.links.next ? this.fetchPage(this.links.next, 'next') : null;\n  }\n\n  hasNext(): boolean {\n    return !!this.links.next;\n  }\n\n  isLast(): boolean {\n    return !this.hasNext();\n  }\n}\n\nclass HttpPaginatedResponseImpl<T, P> extends PaginatedResultImpl<T, P> {\n  readonly statusCode: number;\n  readonly success: boolean;\n  readonly errorCode: number | null;\n  readonly errorMessage: string | null;\n  readonly errorDetail?: Record<string, string>;\n  readonly headers: Record<string, string | string[]>;\n\n  constructor(page: WireHttpPaginatedResponse<T>, fetchPage: PageFetcher<P>) {\n    super(page, fetchPage);\n    this.statusCode = page.statusCode;\n    this.success = page.success;\n    this.errorCode = page.errorCode ?? null;\n    this.errorMessage = page.errorMessage ?? null;\n    if (page.errorDetail !== undefined) {\n      this.errorDetail = page.errorDetail;\n    }\n    this.headers = page.headers ?? {};\n  }\n}\n\n/** Creates a {@link TemporalAblyPaginatedResult} from a page returned by an activity. */\nexport function paginatedResult<T>(\n  page: WirePage<T>,\n  fetchPage: PageFetcher<TemporalAblyPaginatedResult<T>>,\n): TemporalAblyPaginatedResult<T> {\n  return new PaginatedResultImpl(page, fetchPage);\n}\n\n/** Creates a {@link TemporalAblyHttpPaginatedResponse} from a page returned by the request activity. */\nexport function httpPaginatedResponse<T>(\n  page: WireHttpPaginatedResponse<T>,\n  fetchPage: PageFetcher<TemporalAblyHttpPaginatedResponse<T>>,\n): TemporalAblyHttpPaginatedResponse<T> {\n  return new HttpPaginatedResponseImpl(page, fetchPage);\n}\n\n/**\n * Runs a paginated query and wraps the page it returns. Related pages are fetched by running the same query\n * with the link's params in place of the caller's params.\n *\n * @param fetch - Runs the query's activity with the given params. `relation` is set when fetching a related page.\n * @param params - The caller's params for the first page.\n */\nexport async function paginate<T, P>(\n  fetch: (params: P | PageParams | undefined, relation?: PageRelation) => Promise<WirePage<T>>,\n  params: P | undefined,\n): Promise<TemporalAblyPaginatedResult<T>> {\n  const fetchPage = async (pageParams: PageParams, relation: PageRelation): Promise<TemporalAblyPaginatedResult<T>> =>\n    paginatedResult(await fetch(pageParams, relation), fetchPage);\n  return paginatedResult(await fetch(params), fetchPage);\n}\n\n/** Returns the activity summary for fetching a page of a paginated query, naming the related page if there is one. */\nexport function pageSummary(summary: string, relation: PageRelation | undefined): string {\n  return relation ? `${summary} (${relation} page)` : summary;\n}\n", "import type * as Ably from '@ably/pubsub-core/api';\nimport { ActivityNames } from '../common/activities.js';\nimport { decodePageData, encodeBinaryData } from '../common/wire.js';\nimport { requireObject, serialArgument } from './arguments.js';\nimport type { ActivityInvoker } from './invoker.js';\nimport { paginate, pageSummary, type TemporalAblyPaginatedResult } from './paginated.js';\n\nconst ANNOTATION_REMEDIATION =\n  'Pass an Annotation-shaped object as the second argument, e.g. { type: \"reaction:unique.v1\", name: \"\uD83D\uDC4D\" }.';\n\n/**\n * Publishes and retrieves annotations on the messages of a channel from workflow code. It mirrors the Ably\n * `HttpAnnotations`, and is obtained from `TemporalAblyHttpChannel.annotations`.\n *\n * Each method runs as a Temporal activity. Message annotations must be enabled for the channel's namespace by a\n * rule, or the activity fails.\n *\n * When idempotent publishing is enabled (see `TemporalAblyHttpClientOptions.idempotentPublishing`), an annotation published\n * or deleted without an `id` is sent with an ID of the form `<base>:0`. The workflow derives the base\n * deterministically, so every attempt of the activity sends the same ID, and Ably deduplicates a retry that arrives\n * within its deduplication window. The object passed in is not modified.\n */\nexport class TemporalAblyHttpAnnotations {\n  /** @internal */\n  constructor(\n    private readonly invoker: ActivityInvoker,\n    private readonly channel: string,\n  ) {}\n\n  /**\n   * Publishes an annotation for a message. If the annotation specifies no `action`, it defaults to\n   * `annotation.create`. Runs as a Temporal activity.\n   *\n   * @param messageOrSerial - The message to annotate, or its `serial`. A message must have a populated `serial`.\n   * @param annotation - The annotation to publish. It must include at least the `type`.\n   * @returns A promise which is fulfilled when the annotation has been published.\n   */\n  async publish(messageOrSerial: Ably.Message | string, annotation: Ably.OutboundAnnotation): Promise<void> {\n    requireObject('annotations.publish', 'the annotation', annotation, ANNOTATION_REMEDIATION);\n    await this.invoker.invoke(ActivityNames.annotationsPublish, `annotations.publish ${this.channel}`, {\n      channel: this.channel,\n      messageOrSerial: serialArgument('annotations.publish', messageOrSerial),\n      annotation: encodeBinaryData(this.invoker.assignMessageIds([annotation])[0]),\n    });\n  }\n\n  /**\n   * Publishes a request to remove an annotation from a message's annotation summary. The annotation is sent with\n   * its `action` set to `annotation.delete`. Runs as a Temporal activity.\n   *\n   * @param messageOrSerial - The message to remove the annotation from, or its `serial`. A message must have a\n   * populated `serial`.\n   * @param annotation - The annotation deletion request. It must include at least the `type`.\n   * @returns A promise which is fulfilled when the deletion request has been published.\n   */\n  async delete(messageOrSerial: Ably.Message | string, annotation: Ably.OutboundAnnotation): Promise<void> {\n    requireObject('annotations.delete', 'the annotation', annotation, ANNOTATION_REMEDIATION);\n    await this.invoker.invoke(ActivityNames.annotationsDelete, `annotations.delete ${this.channel}`, {\n      channel: this.channel,\n      messageOrSerial: serialArgument('annotations.delete', messageOrSerial),\n      annotation: encodeBinaryData(this.invoker.assignMessageIds([annotation])[0]),\n    });\n  }\n\n  /**\n   * Retrieves the annotations for a message. Runs as a Temporal activity.\n   *\n   * @param messageOrSerial - The message to get annotations for, or its `serial`. A message must have a populated\n   * `serial`.\n   * @param params - Restrictions on which annotations to get, such as a `limit`.\n   * @returns A promise which is fulfilled with the first page of {@link Ably.Annotation} objects.\n   */\n  async get(\n    messageOrSerial: Ably.Message | string,\n    params: Ably.GetAnnotationsParams | null,\n  ): Promise<TemporalAblyPaginatedResult<Ably.Annotation>> {\n    const serial = serialArgument('annotations.get', messageOrSerial);\n    return paginate(\n      (pageParams, relation) =>\n        this.invoker\n          .invoke(ActivityNames.annotationsGet, pageSummary(`annotations.get ${this.channel}`, relation), {\n            channel: this.channel,\n            messageOrSerial: serial,\n            params: pageParams ?? null,\n          })\n          .then(decodePageData),\n      params ?? undefined,\n    );\n  }\n}\n", "import type {\n  HttpObjectGetCompactParams,\n  HttpObjectGetCompactResult,\n  HttpObjectGetFullParams,\n  HttpObjectGetFullResult,\n  HttpObjectGetParams,\n  HttpObjectOperation,\n  HttpObjectPublishResult,\n} from '@ably/pubsub-core/liveobjects';\nimport { ActivityNames } from '../common/activities.js';\nimport {\n  base64ToBytes,\n  bytesToBase64,\n  isBinary,\n  mapFullObjectBytes,\n  mapOperationBytes,\n  toBytes,\n} from '../common/wire.js';\nimport { requireObject } from './arguments.js';\nimport { ablyFailure } from './failure.js';\nimport type { ActivityInvoker } from './invoker.js';\n\n/** Options for {@link TemporalAblyHttpObject.publish}. */\nexport interface TemporalAblyHttpObjectPublishOptions {\n  /**\n   * Whether to publish the operations with IDs that Ably deduplicates a retried activity on. When set, it overrides\n   * `TemporalAblyHttpClientOptions.idempotentPublishing` for this call. When `false`, the operations are published as\n   * they are.\n   */\n  idempotentPublishing?: boolean;\n}\n\n/**\n * Reads and modifies the objects on a channel from workflow code. It mirrors the Ably `HttpObject`, and is obtained\n * from `TemporalAblyHttpChannel.object`.\n *\n * Each method runs as a Temporal activity, which fails unless the worker's Ably client has the LiveObjects plugin.\n * Binary values are published as `bytes` in a `Uint8Array`, an `ArrayBuffer` or another typed array. In a full-format\n * result, binary values are returned as `Uint8Array`. In a compact result, they are returned as base64 strings, as Ably\n * returns them over its JSON protocol.\n */\nexport class TemporalAblyHttpObject {\n  /** @internal */\n  constructor(\n    private readonly invoker: ActivityInvoker,\n    private readonly channel: string,\n  ) {}\n\n  /**\n   * Reads object data from the channel in compact format. If no `objectId` is given, the entire channel object is\n   * returned. Runs as a Temporal activity.\n   *\n   * @param params - Specifies the object to fetch.\n   * @returns A promise which is fulfilled with the object data in compact format, with binary values as base64\n   * strings.\n   */\n  get(params?: HttpObjectGetCompactParams): Promise<HttpObjectGetCompactResult>;\n  /**\n   * Reads object data from the channel in full format, with object IDs and type metadata. If no `objectId` is\n   * given, the entire channel object is returned. Runs as a Temporal activity.\n   *\n   * @param params - Specifies the object to fetch, with `compact: false`.\n   * @returns A promise which is fulfilled with the object data in full format, with binary values as `Uint8Array`.\n   */\n  get(params: HttpObjectGetFullParams): Promise<HttpObjectGetFullResult>;\n  /**\n   * Reads object data from the channel, in compact format unless `compact` is `false`. If no `objectId` is given,\n   * the entire channel object is returned. Runs as a Temporal activity.\n   *\n   * @param params - Specifies the object to fetch and the format of the result.\n   * @returns A promise which is fulfilled with the object data in the requested format.\n   */\n  get(params?: HttpObjectGetParams): Promise<HttpObjectGetCompactResult | HttpObjectGetFullResult>;\n  async get(params?: HttpObjectGetParams): Promise<HttpObjectGetCompactResult | HttpObjectGetFullResult> {\n    const result = await this.invoker.invoke(ActivityNames.objectGet, `object.get ${this.channel}`, {\n      channel: this.channel,\n      params,\n    });\n    return params?.compact === false ? mapFullObjectBytes(result, decodeBytes) : result;\n  }\n\n  /**\n   * Publishes one or more operations to modify objects on the channel. An array of operations is published as an\n   * atomic batch. Runs as a Temporal activity.\n   *\n   * When idempotent publishing is enabled, and provided that no operation already has an `id`, each operation is\n   * assigned an ID that is the same on every attempt of the activity and every replay of the workflow. Ably uses these\n   * IDs to discard an operation that a retried activity publishes again, for at least 2 minutes after the first\n   * attempt. `TemporalAblyHttpClientOptions.idempotentPublishing` enables it, unless `options.idempotentPublishing`\n   * sets it for this call.\n   *\n   * Ably cannot deduplicate a retry of a `mapCreate` or `counterCreate` operation, or of an operation whose `path` has\n   * a wildcard, so a call that includes one throws when idempotent publishing is enabled and no operation has an `id`:\n   *\n   * - Ably rejects an ID on a create at a `path`, and on a wildcard `path`, because it expands such an operation into\n   *   several object messages.\n   * - When Ably discards a retried create by its ID, it responds with the ID of an object that it did not create.\n   *\n   * To publish such a call, pass `{ idempotentPublishing: false }`. A retried activity then applies every operation in\n   * the call again. A create without a `path` creates another object. A create at a `path` fails with error 92007 if\n   * the first attempt succeeded, because the path then holds an object. A wildcard operation is applied to each match\n   * again. `mapCreateWithObjectId` and `counterCreateWithObjectId` operations can be deduplicated.\n   *\n   * A call in which an operation already has an `id` is published with the IDs it has, and does not throw. A\n   * `mapCreate` or `counterCreate` with an `id` of the caller's has the same problem as above: when Ably discards a\n   * retry of it as a duplicate, it responds with the ID of an object that it did not create, so `objectIds` in the\n   * result of the retried call can name an object that does not exist. To create an object that a retry does not\n   * create again, generate its object ID with `channel.object.generateObjectId()` in an activity of your own, and\n   * publish a `mapCreateWithObjectId` or `counterCreateWithObjectId` operation instead.\n   *\n   * @param op - The operation, or array of operations, to publish.\n   * @param options - Options for this call.\n   * @returns A promise which is fulfilled with the ID of the published message and the IDs of the affected objects.\n   * @throws An `ApplicationFailure` of type `AblyError` with code 40003 if idempotent publishing is enabled, no\n   * operation has an `id`, and an operation cannot be deduplicated.\n   */\n  async publish(\n    op: HttpObjectOperation | HttpObjectOperation[],\n    options?: TemporalAblyHttpObjectPublishOptions,\n  ): Promise<HttpObjectPublishResult> {\n    if (Array.isArray(op)) {\n      op.forEach((operation, index) =>\n        requireObject('object.publish', `operations[${index}]`, operation, INVALID_OPERATION_REMEDIATION),\n      );\n    } else {\n      requireObject('object.publish', 'the operation', op, INVALID_OPERATION_REMEDIATION);\n    }\n    const list = Array.isArray(op) ? op : [op];\n    const idempotentPublishing = options?.idempotentPublishing ?? this.invoker.idempotentPublishing;\n    if (idempotentPublishing && !list.some((operation) => operation?.id)) {\n      const index = list.findIndex((operation) => notDeduplicatedReason(operation) !== undefined);\n      if (index !== -1) {\n        throw notDeduplicatedFailure(Array.isArray(op) ? `operations[${index}]` : 'the operation', list[index]);\n      }\n    }\n    const withIds = this.invoker\n      .assignMessageIds(list, idempotentPublishing)\n      .map((operation) => mapOperationBytes(operation, encodeBytes));\n    const operations = Array.isArray(op) ? withIds : withIds[0];\n    return this.invoker.invoke(ActivityNames.objectPublish, `object.publish ${this.channel}`, {\n      channel: this.channel,\n      operations,\n    });\n  }\n}\n\nconst INVALID_OPERATION_REMEDIATION =\n  'Pass an operation object, such as { objectId: \"counter:abc\", counterInc: { number: 1 } }, or an array of operation objects.';\n\nfunction encodeBytes(bytes: unknown): unknown {\n  return isBinary(bytes) ? bytesToBase64(toBytes(bytes)) : bytes;\n}\n\nfunction decodeBytes(bytes: unknown): unknown {\n  return typeof bytes === 'string' ? base64ToBytes(bytes) : bytes;\n}\n\nfunction isCreate(operation: object): boolean {\n  return 'mapCreate' in operation || 'counterCreate' in operation;\n}\n\n/**\n * Why Ably cannot deduplicate a retry of `operation` by an ID, or `undefined` if it can. Ably needs every operation\n * in a publish to have an ID, or none, so one such operation applies to the whole call.\n *\n * - A create, because when Ably discards a retried create by its ID, the response names the object that the retry\n *   would have created, which does not exist. A create at a path also gets error 40031 with an ID, because Ably\n *   expands it into the create and a set on the parent map.\n * - An operation whose path has a wildcard, because Ably expands it into one object message for each match, and\n *   rejects the publish with error 40031 if it has an ID.\n */\nfunction notDeduplicatedReason(operation: unknown): string | undefined {\n  if (operation === null || typeof operation !== 'object') {\n    return undefined;\n  }\n  const path = (operation as { path?: unknown }).path;\n  if (isCreate(operation)) {\n    return typeof path === 'string'\n      ? 'Ably rejects an operation ID on a create at a path'\n      : 'Ably responds to a retried create that it discards as a duplicate with the ID of an object that it did not create';\n  }\n  if (typeof path === 'string' && path.includes('*')) {\n    return 'Ably rejects an operation ID on an operation whose path has a wildcard';\n  }\n  return undefined;\n}\n\nfunction notDeduplicatedFailure(description: string, operation: object) {\n  return ablyFailure({\n    message: `object.publish() cannot deduplicate a retry of ${description}, because ${notDeduplicatedReason(operation)}`,\n    code: 40003,\n    statusCode: 400,\n    remediation: [\n      'Pass { idempotentPublishing: false } as the second argument to object.publish() to publish without deduplication.',\n      'A retried activity then applies every operation in the call again.',\n      'Publish the operations that can be deduplicated in a separate call, so that they keep their IDs.',\n      isCreate(operation)\n        ? 'To create an object that a retry does not create again, generate its object ID with channel.object.generateObjectId() in an activity of your own, and publish a mapCreateWithObjectId or counterCreateWithObjectId operation instead.'\n        : 'To deduplicate the operation, target each object by its objectId or by a path without a wildcard.',\n    ].join(' '),\n  });\n}\n", "import type * as Ably from '@ably/pubsub-core/api';\nimport { ActivityNames } from '../common/activities.js';\nimport { decodePageData } from '../common/wire.js';\nimport type { ActivityInvoker } from './invoker.js';\nimport { paginate, pageSummary, type TemporalAblyPaginatedResult } from './paginated.js';\n\n/**\n * Retrieves the current and historic presence set of a channel from workflow code. It mirrors the Ably REST\n * `Presence`, and is obtained from `TemporalAblyHttpChannel.presence`.\n *\n * Each method runs as a Temporal activity. Binary presence data is returned as `Uint8Array`.\n */\nexport class TemporalAblyHttpPresence {\n  /** @internal */\n  constructor(\n    private readonly invoker: ActivityInvoker,\n    private readonly channel: string,\n  ) {}\n\n  /**\n   * Retrieves the members currently present on the channel. Runs as a Temporal activity.\n   *\n   * @param params - Restricts which presence members are retrieved.\n   * @returns A promise which is fulfilled with the first page of {@link Ably.PresenceMessage} objects.\n   */\n  async get(params?: Ably.HttpPresenceParams): Promise<TemporalAblyPaginatedResult<Ably.PresenceMessage>> {\n    return paginate(\n      (pageParams, relation) =>\n        this.invoker\n          .invoke(ActivityNames.presenceGet, pageSummary(`presence.get ${this.channel}`, relation), {\n            channel: this.channel,\n            params: pageParams,\n          })\n          .then(decodePageData),\n      params,\n    );\n  }\n\n  /**\n   * Retrieves the presence history of the channel. Runs as a Temporal activity.\n   *\n   * @param params - Restricts which presence messages are retrieved.\n   * @returns A promise which is fulfilled with the first page of {@link Ably.PresenceMessage} objects.\n   */\n  async history(params?: Ably.HttpHistoryParams): Promise<TemporalAblyPaginatedResult<Ably.PresenceMessage>> {\n    return paginate(\n      (pageParams, relation) =>\n        this.invoker\n          .invoke(ActivityNames.presenceHistory, pageSummary(`presence.history ${this.channel}`, relation), {\n            channel: this.channel,\n            params: pageParams,\n          })\n          .then(decodePageData),\n      params,\n    );\n  }\n}\n", "import type * as Ably from '@ably/pubsub-core/api';\nimport { ActivityNames } from '../common/activities.js';\nimport { decodeBinaryData, decodePageData, encodeBinaryData } from '../common/wire.js';\nimport { TemporalAblyHttpAnnotations } from './annotations.js';\nimport { requireObject, serialArgument } from './arguments.js';\nimport { ablyFailure } from './failure.js';\nimport type { ActivityInvoker } from './invoker.js';\nimport { TemporalAblyHttpObject } from './object.js';\nimport { paginate, pageSummary, type TemporalAblyPaginatedResult } from './paginated.js';\nimport { TemporalAblyHttpPresence } from './presence.js';\n\nconst MESSAGE_REMEDIATION =\n  'Pass the Message received from history() or a subscribe callback, which carries a serial, with the fields to change.';\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n  return Object.prototype.toString.call(value) === '[object Object]';\n}\n\n/**\n * A channel used from workflow code. It mirrors the Ably REST `Channel`, and is obtained from\n * {@link TemporalAblyHttpChannels.get | TemporalAblyHttpClient.channels.get()}.\n *\n * Each method runs as a Temporal activity on the worker's Ably HTTP client. If the request fails, the method\n * rejects with the activity's `ActivityFailure`. Use `getAblyErrorDetails()` to get the Ably error from it. Binary\n * message data is returned as `Uint8Array`.\n */\nexport class TemporalAblyHttpChannel {\n  /** The channel name. */\n  readonly name: string;\n  /** Retrieves the current and historic presence set of the channel. */\n  readonly presence: TemporalAblyHttpPresence;\n  /** Publishes and retrieves annotations on the channel's messages. */\n  readonly annotations: TemporalAblyHttpAnnotations;\n  /** Reads and modifies the objects on the channel. */\n  readonly object: TemporalAblyHttpObject;\n\n  /** @internal */\n  constructor(\n    private readonly invoker: ActivityInvoker,\n    name: string,\n  ) {\n    this.name = name;\n    this.presence = new TemporalAblyHttpPresence(invoker, name);\n    this.annotations = new TemporalAblyHttpAnnotations(invoker, name);\n    this.object = new TemporalAblyHttpObject(invoker, name);\n  }\n\n  /**\n   * Publishes an array of messages to the channel. Runs as a Temporal activity.\n   *\n   * When idempotent publishing is enabled (see `TemporalAblyHttpClientOptions.idempotentPublishing`) and none of the\n   * messages has an `id`, the messages are published with IDs of the form `<base>:<index>`. The workflow derives\n   * the base deterministically, so every attempt of the activity publishes the same IDs, and Ably deduplicates a\n   * retry that arrives within its idempotency window. The objects passed in are not modified.\n   *\n   * @param messages - The messages to publish.\n   * @param options - Optional parameters sent as part of the query string.\n   * @returns A promise which is fulfilled with the serials of the published messages.\n   */\n  publish(messages: Ably.Message[], options?: Ably.PublishOptions): Promise<Ably.PublishResult>;\n  /**\n   * Publishes a message to the channel. Runs as a Temporal activity.\n   *\n   * When idempotent publishing is enabled (see `TemporalAblyHttpClientOptions.idempotentPublishing`) and the message has\n   * no `id`, it is published with an ID of the form `<base>:0`. The workflow derives the base deterministically,\n   * so every attempt of the activity publishes the same ID, and Ably deduplicates a retry that arrives within its\n   * idempotency window. The object passed in is not modified.\n   *\n   * @param message - The message to publish.\n   * @param options - Optional parameters sent as part of the query string.\n   * @returns A promise which is fulfilled with the serial of the published message.\n   */\n  publish(message: Ably.Message, options?: Ably.PublishOptions): Promise<Ably.PublishResult>;\n  /**\n   * Publishes a message with the given event name and payload to the channel. Runs as a Temporal activity.\n   *\n   * When idempotent publishing is enabled (see `TemporalAblyHttpClientOptions.idempotentPublishing`), the message is\n   * published with an ID of the form `<base>:0`. The workflow derives the base deterministically, so every attempt\n   * of the activity publishes the same ID, and Ably deduplicates a retry that arrives within its idempotency\n   * window.\n   *\n   * @param name - The event name of the message.\n   * @param data - The payload of the message.\n   * @param options - Optional parameters sent as part of the query string.\n   * @returns A promise which is fulfilled with the serial of the published message.\n   */\n  publish(name: string, data: any, options?: Ably.PublishOptions): Promise<Ably.PublishResult>;\n  async publish(...args: any[]): Promise<Ably.PublishResult> {\n    const [first, second] = args;\n    let messages: Ably.Message[];\n    let options: Ably.PublishOptions | undefined;\n\n    if (typeof first === 'string' || first === null) {\n      messages = [{ name: first, data: second }];\n      options = args[2];\n    } else if (isPlainObject(first)) {\n      messages = [first];\n      options = args[1];\n    } else if (Array.isArray(first)) {\n      messages = first;\n      options = args[1];\n    } else {\n      throw ablyFailure({\n        message:\n          'publish() expects an event name (string or null), a message object, or an array of message objects as its first argument',\n        code: 40003,\n        statusCode: 400,\n        remediation:\n          'Call publish(name, data) for a single event, or publish(message | message[]) with a Message-shaped object.',\n      });\n    }\n\n    return this.invoker.invoke(ActivityNames.publish, `publish ${this.name}`, {\n      channel: this.name,\n      messages: this.invoker.assignMessageIds(messages).map((message) => encodeBinaryData(message)),\n      ...(options ? { options } : {}),\n    });\n  }\n\n  /**\n   * Retrieves the message history of the channel. Runs as a Temporal activity.\n   *\n   * @param params - Restricts which messages are retrieved.\n   * @returns A promise which is fulfilled with the first page of {@link Ably.InboundMessage} objects.\n   */\n  async history(params?: Ably.HttpHistoryParams): Promise<TemporalAblyPaginatedResult<Ably.InboundMessage>> {\n    return paginate(\n      (pageParams, relation) =>\n        this.invoker\n          .invoke(ActivityNames.history, pageSummary(`history ${this.name}`, relation), {\n            channel: this.name,\n            params: pageParams,\n          })\n          .then(decodePageData),\n      params,\n    );\n  }\n\n  /**\n   * Retrieves the status and occupancy metrics of the channel. Runs as a Temporal activity.\n   *\n   * @returns A promise which is fulfilled with the {@link Ably.ChannelDetails} of the channel.\n   */\n  async status(): Promise<Ably.ChannelDetails> {\n    return this.invoker.invoke(ActivityNames.status, `status ${this.name}`, { channel: this.name });\n  }\n\n  /**\n   * Retrieves the latest version of a message. Runs as a Temporal activity.\n   *\n   * @param serialOrMessage - The `serial` of the message, or a message with a populated `serial`.\n   * @returns A promise which is fulfilled with the latest version of the message.\n   */\n  async getMessage(serialOrMessage: string | Ably.Message): Promise<Ably.Message> {\n    const message = await this.invoker.invoke(ActivityNames.getMessage, `getMessage ${this.name}`, {\n      channel: this.name,\n      serialOrMessage: serialArgument('getMessage', serialOrMessage),\n    });\n    return decodeBinaryData(message);\n  }\n\n  /**\n   * Publishes an update to an existing message, with patch semantics. Runs as a Temporal activity.\n   *\n   * When idempotent publishing is enabled (see `TemporalAblyHttpClientOptions.idempotentPublishing`) and `options` has no\n   * `idempotencyKey`, the update is published with a key that the workflow derives deterministically, so every attempt\n   * of the activity sends the same key. Ably returns the result of the first attempt for a retry that arrives within\n   * its deduplication window. A caller-supplied `idempotencyKey` must be unique among the operations on the channel.\n   *\n   * @param message - A message with a populated `serial`, and the fields to update.\n   * @param operation - Metadata about the update operation.\n   * @param options - Optional parameters sent as part of the query string.\n   * @returns A promise which is fulfilled with the serial of the new version of the message.\n   */\n  async updateMessage(\n    message: Ably.Message,\n    operation?: Ably.MessageOperation,\n    options?: Ably.PublishOptions,\n  ): Promise<Ably.UpdateDeleteResult> {\n    requireObject('updateMessage', 'message', message, MESSAGE_REMEDIATION);\n    return this.invoker.invoke(ActivityNames.updateMessage, `updateMessage ${this.name}`, {\n      channel: this.name,\n      message: encodeBinaryData(message),\n      operation,\n      options: this.invoker.withIdempotencyKey(options),\n    });\n  }\n\n  /**\n   * Marks a message as deleted by publishing an update with an action of `message.delete`, with patch semantics.\n   * Runs as a Temporal activity.\n   *\n   * When idempotent publishing is enabled (see `TemporalAblyHttpClientOptions.idempotentPublishing`) and `options` has no\n   * `idempotencyKey`, the delete is published with a key that the workflow derives deterministically, so every attempt\n   * of the activity sends the same key. Ably returns the result of the first attempt for a retry that arrives within\n   * its deduplication window. A caller-supplied `idempotencyKey` must be unique among the operations on the channel.\n   *\n   * @param message - A message with a populated `serial`.\n   * @param operation - Metadata about the delete operation.\n   * @param options - Optional parameters sent as part of the query string.\n   * @returns A promise which is fulfilled with the serial of the new version of the message.\n   */\n  async deleteMessage(\n    message: Ably.Message,\n    operation?: Ably.MessageOperation,\n    options?: Ably.PublishOptions,\n  ): Promise<Ably.UpdateDeleteResult> {\n    requireObject('deleteMessage', 'message', message, MESSAGE_REMEDIATION);\n    return this.invoker.invoke(ActivityNames.deleteMessage, `deleteMessage ${this.name}`, {\n      channel: this.name,\n      message: encodeBinaryData(message),\n      operation,\n      options: this.invoker.withIdempotencyKey(options),\n    });\n  }\n\n  /**\n   * Appends data to an existing message. Runs as a Temporal activity.\n   *\n   * The append is published without an idempotency key, because Ably applies a retried append again even when the\n   * retry has the same key. A retried activity appends the data again.\n   *\n   * @param message - A message with a populated `serial`, and the data to append.\n   * @param operation - Metadata about the append operation.\n   * @param options - Optional parameters sent as part of the query string.\n   * @returns A promise which is fulfilled with the serial of the new version of the message.\n   */\n  async appendMessage(\n    message: Ably.Message,\n    operation?: Ably.MessageOperation,\n    options?: Ably.PublishOptions,\n  ): Promise<Ably.UpdateDeleteResult> {\n    requireObject('appendMessage', 'message', message, MESSAGE_REMEDIATION);\n    return this.invoker.invoke(ActivityNames.appendMessage, `appendMessage ${this.name}`, {\n      channel: this.name,\n      message: encodeBinaryData(message),\n      operation,\n      options,\n    });\n  }\n\n  /**\n   * Retrieves every version of a message, ordered by version. Runs as a Temporal activity.\n   *\n   * @param serialOrMessage - The `serial` of the message, or a message with a populated `serial`.\n   * @param params - Optional parameters sent as part of the query string.\n   * @returns A promise which is fulfilled with the first page of versions of the message.\n   */\n  async getMessageVersions(\n    serialOrMessage: string | Ably.Message,\n    params?: Record<string, any>,\n  ): Promise<TemporalAblyPaginatedResult<Ably.Message>> {\n    const serial = serialArgument('getMessageVersions', serialOrMessage);\n    return paginate(\n      (pageParams, relation) =>\n        this.invoker\n          .invoke(ActivityNames.getMessageVersions, pageSummary(`getMessageVersions ${this.name}`, relation), {\n            channel: this.name,\n            serialOrMessage: serial,\n            params: pageParams,\n          })\n          .then(decodePageData),\n      params,\n    );\n  }\n}\n\n/**\n * Creates and caches the channels of a `TemporalAblyHttpClient` instance. It mirrors the Ably REST `Channels`.\n */\nexport class TemporalAblyHttpChannels {\n  private readonly all: Record<string, TemporalAblyHttpChannel> = Object.create(null);\n\n  /** @internal */\n  constructor(private readonly invoker: ActivityInvoker) {}\n\n  /**\n   * Gets the channel with the given name, creating it if it does not exist. Getting a channel does not run an\n   * activity.\n   *\n   * Channel options, such as a `cipher`, are not supported, so workflow code cannot use encrypted channels.\n   *\n   * @param name - The channel name.\n   * @returns The channel.\n   */\n  get(name: string): TemporalAblyHttpChannel {\n    // A caller that bypasses the type of this method could pass channel options. Ignoring them would publish\n    // plain text to a channel the caller meant to encrypt.\n    if (arguments.length > 1 && arguments[1] !== undefined) {\n      throw ablyFailure({\n        message: `channels.get() in workflow code does not support channel options such as cipher, but was called with options for channel \"${name}\"`,\n        code: 40003,\n        statusCode: 400,\n        remediation:\n          'Call channels.get() with the channel name only. The Temporal plugin does not support encrypted channels, so use a channel that does not need a cipher.',\n      });\n    }\n    name = String(name);\n    return (this.all[name] ??= new TemporalAblyHttpChannel(this.invoker, name));\n  }\n}\n", "import {\n  getRandomStream,\n  proxyActivities,\n  proxyLocalActivities,\n  type ActivityOptions,\n  type LocalActivityOptions,\n} from '@temporalio/workflow';\nimport type { AblyActivities, ActivityName } from '../common/activities.js';\nimport { toWireValue } from '../common/wire.js';\nimport { ablyFailure } from './failure.js';\n\n/** The activity options applied beneath the caller's own options. */\nexport const DEFAULT_ACTIVITY_OPTIONS = { startToCloseTimeout: '30 seconds' } as const;\n\n/** The name of the random stream that message IDs and idempotency keys are drawn from. */\nconst MESSAGE_ID_STREAM = 'ably.temporal.messageIds';\n\n/**\n * Returns the random stream that message IDs and idempotency keys are drawn from. Named random streams were added\n * in `@temporalio/workflow` 1.18.0, so on an earlier version this throws, which fails the workflow task until the\n * worker is redeployed with a supported version.\n */\nfunction messageIdStream() {\n  if (typeof getRandomStream !== 'function') {\n    throw new TypeError(\n      'Idempotent publishing from workflow code requires @temporalio/workflow 1.18.0 or later. Upgrade the @temporalio packages used by your worker to 1.18.0 or later, or set TemporalAblyHttpClientOptions.idempotentPublishing to false.',\n    );\n  }\n  return getRandomStream(MESSAGE_ID_STREAM);\n}\n\ntype ActivityArgs<N extends ActivityName> = Parameters<AblyActivities[N]>;\ntype ActivityResult<N extends ActivityName> = Awaited<ReturnType<AblyActivities[N]>>;\n\n/** Options for an {@link ActivityInvoker}, from `TemporalAblyHttpClientOptions`. */\nexport interface ActivityInvokerOptions {\n  activityOptions?: Omit<ActivityOptions, 'summary'>;\n  localActivityOptions?: Omit<LocalActivityOptions, 'summary'>;\n  idempotentPublishing: boolean;\n}\n\n/** The name of the method that runs the activity `name`, for an error message, such as `object.publish`. */\nfunction methodName(name: ActivityName): string {\n  return name.replace(/^ably\\.(channel\\.)?/, '');\n}\n\n/**\n * Returns `arg` as it is sent to the activity, after checking that it contains no binary values. Binary data is only\n * sent where it is encoded as base64 before this, such as the `data` of a message, because Temporal's JSON payload\n * converter would otherwise serialise it as an object of numbered bytes.\n */\nfunction activityArgument(name: ActivityName, arg: unknown): unknown {\n  return toWireValue(arg, (_bytes, path) => {\n    throw ablyFailure({\n      message: `${methodName(name)}() was called with binary data at ${path || 'its argument'}, where workflow code cannot pass binary data to an Ably activity`,\n      code: 40003,\n      statusCode: 400,\n      remediation:\n        'Pass binary data only as the data of a message or annotation, or as the bytes of a LiveObjects value. Encode any other binary value, such as one nested inside an object, as a base64 string.',\n    });\n  });\n}\n\n/**\n * Runs Ably activities on behalf of a `TemporalAblyHttpClient` instance and the channels it creates.\n *\n * The activity proxy is created on each call rather than up front, because creating one is only allowed inside a\n * workflow, and `TemporalAblyHttpClient` can be constructed at module scope. This also lets each call carry its own summary.\n */\nexport class ActivityInvoker {\n  constructor(private readonly options: ActivityInvokerOptions) {}\n\n  /** Whether idempotent publishing is enabled for the client. */\n  get idempotentPublishing(): boolean {\n    return this.options.idempotentPublishing;\n  }\n\n  /**\n   * Runs the activity `name`. Binary data in its arguments must already be encoded, as described in\n   * ../common/wire.ts, and binary data in its result is returned encoded.\n   *\n   * @param summary - The summary shown for the activity in the Temporal UI.\n   * @throws An `ApplicationFailure` of type `AblyError` if the arguments contain a binary value.\n   */\n  async invoke<N extends ActivityName>(name: N, summary: string, ...args: ActivityArgs<N>): Promise<ActivityResult<N>> {\n    const wireArgs = args.map((arg) => activityArgument(name, arg));\n    const activity = this.proxy(summary)[name] as unknown as (...args: unknown[]) => Promise<unknown>;\n    return (await activity(...wireArgs)) as ActivityResult<N>;\n  }\n\n  /**\n   * Returns `messages` with an ID assigned to each message when idempotent publishing is enabled and no message\n   * has an ID. The IDs are `<base>:<index>`, where `base` is a UUID drawn from a named random stream, so the IDs\n   * are the same on every replay of the workflow and on every attempt of the activity.\n   *\n   * This applies to anything published with an `id` that Ably uses for deduplication, such as messages, annotations\n   * and object operations. The caller's objects are never modified. Messages that need IDs are copied.\n   *\n   * @param idempotentPublishing - Whether idempotent publishing is enabled for this call. Defaults to the client's\n   * option.\n   */\n  assignMessageIds<T extends { id?: string }>(\n    messages: T[],\n    idempotentPublishing: boolean = this.options.idempotentPublishing,\n  ): T[] {\n    if (!idempotentPublishing || messages.length === 0 || !messages.every((message) => !message?.id)) {\n      return messages;\n    }\n    const base = messageIdStream().uuid4();\n    return messages.map((message, index) => ({ ...message, id: `${base}:${index}` }));\n  }\n\n  /**\n   * Returns `options` with an `idempotencyKey` when idempotent publishing is enabled and `options` has none. The key\n   * is a UUID drawn from the same random stream as message IDs, so it is the same on every replay of the workflow\n   * and on every attempt of the activity. Ably sends the key as the `idempotencyKey` query parameter, and returns\n   * the result of the first attempt for a retry with the same key. The caller's object is never modified.\n   */\n  withIdempotencyKey<T extends Record<string, unknown>>(options: T | undefined): T | undefined {\n    if (!this.options.idempotentPublishing || options?.idempotencyKey !== undefined) {\n      return options;\n    }\n    return { ...options, idempotencyKey: messageIdStream().uuid4() } as unknown as T;\n  }\n\n  private proxy(summary: string) {\n    const { activityOptions, localActivityOptions } = this.options;\n    if (localActivityOptions) {\n      return proxyLocalActivities<AblyActivities>({ ...DEFAULT_ACTIVITY_OPTIONS, ...localActivityOptions, summary });\n    }\n    return proxyActivities<AblyActivities>({ ...DEFAULT_ACTIVITY_OPTIONS, ...activityOptions, summary });\n  }\n}\n", "import type * as Ably from '@ably/pubsub-core/api';\nimport { ActivityNames } from '../common/activities.js';\nimport { deviceIdArgument, requireObject } from './arguments.js';\nimport type { ActivityInvoker } from './invoker.js';\nimport { paginate, pageSummary, type TemporalAblyPaginatedResult } from './paginated.js';\n\n/**\n * Push notifications from workflow code. It mirrors the push functionality of the Ably HTTP client that does not\n * need a device, and is obtained from `TemporalAblyHttpClient.push`.\n */\nexport class TemporalAblyHttpPush {\n  /** Manages device registrations and channel subscriptions, and publishes push notifications. */\n  readonly admin: TemporalAblyHttpPushAdmin;\n\n  /** @internal */\n  constructor(invoker: ActivityInvoker) {\n    this.admin = new TemporalAblyHttpPushAdmin(invoker);\n  }\n}\n\n/**\n * Manages device registrations and channel subscriptions, and publishes push notifications, from workflow code. It\n * mirrors the Ably `PushAdmin`, and is obtained from `TemporalAblyHttpClient.push.admin`.\n *\n * Each method runs as a Temporal activity with the retry policy in `TemporalAblyHttpClientOptions`. Ably does not deduplicate\n * the calls that send a notification or create an APNs broadcast channel, so a retry of `publish()`,\n * `createApnsBroadcast()`, `liveActivity.start()` or `liveActivity.update()` repeats the call. Within an attempt, the\n * worker's Ably client can also send the request again to a fallback host after a timeout, a connection error or a\n * 500 to 504 response.\n */\nexport class TemporalAblyHttpPushAdmin {\n  /** Registers, retrieves and removes the devices that receive push notifications. */\n  readonly deviceRegistrations: TemporalAblyHttpPushDeviceRegistrations;\n  /** Subscribes devices and clients to push notifications on channels, and retrieves and removes subscriptions. */\n  readonly channelSubscriptions: TemporalAblyHttpPushChannelSubscriptions;\n  /**\n   * Controls the lifecycle of iOS Live Activities over an APNs broadcast channel created with\n   * {@link TemporalAblyHttpPushAdmin.createApnsBroadcast}.\n   *\n   * @experimental This is a preview feature of Ably and may change in a future non-major release.\n   */\n  readonly liveActivity: TemporalAblyHttpPushLiveActivity;\n\n  /** @internal */\n  constructor(private readonly invoker: ActivityInvoker) {\n    this.deviceRegistrations = new TemporalAblyHttpPushDeviceRegistrations(invoker);\n    this.channelSubscriptions = new TemporalAblyHttpPushChannelSubscriptions(invoker);\n    this.liveActivity = new TemporalAblyHttpPushLiveActivity(invoker);\n  }\n\n  /**\n   * Sends a push notification directly to a device, or a group of devices sharing the same `clientId`. Runs as a\n   * Temporal activity. A retry sends the notification again.\n   *\n   * @param recipient - The recipient details, using `clientId`, `deviceId` or the underlying notifications service.\n   * @param payload - The push notification payload.\n   * @returns A promise which is fulfilled when Ably has accepted the notification.\n   */\n  async publish(recipient: any, payload: any): Promise<void> {\n    requireObject('push.admin.publish', 'recipient', recipient, PUBLISH_REMEDIATION);\n    requireObject('push.admin.publish', 'payload', payload, PUBLISH_REMEDIATION);\n    await this.invoker.invoke(ActivityNames.pushPublish, 'push.admin.publish', { recipient, payload });\n  }\n\n  /**\n   * Creates an APNs broadcast channel for use with an iOS Live Activity. Runs as a Temporal activity. A retry creates\n   * another broadcast channel, and Ably has no call to list or delete a channel that an earlier attempt created.\n   *\n   * @experimental This is a preview feature of Ably and may change in a future non-major release.\n   *\n   * @param options - Options for the broadcast, including the `messageStoragePolicy`.\n   * @returns A promise which is fulfilled with the broadcast `{ id, apnsChannelId }`.\n   */\n  async createApnsBroadcast(options: Ably.PushApnsBroadcastOptions): Promise<Ably.PushApnsBroadcast> {\n    requireObject(\n      'push.admin.createApnsBroadcast',\n      'options',\n      options,\n      'Pass an options object with a messageStoragePolicy of 0 or 1, e.g. { messageStoragePolicy: 1 }.',\n    );\n    return this.invoker.invoke(ActivityNames.pushCreateApnsBroadcast, 'push.admin.createApnsBroadcast', {\n      argument: options,\n    });\n  }\n}\n\nconst PUBLISH_REMEDIATION =\n  'Pass the recipient and the payload as objects, e.g. publish({ clientId: \"user-1\" }, { notification: { title: \"Hello\" } }).';\n\nconst LIVE_ACTIVITY_REMEDIATION =\n  'Pass a params object with the apnsBroadcast id returned by createApnsBroadcast() and an apns payload.';\n\n/**\n * Controls the lifecycle of iOS Live Activities from workflow code. It mirrors the Ably `PushLiveActivity`, and is\n * obtained from `TemporalAblyHttpClient.push.admin.liveActivity`.\n *\n * Each method runs as a Temporal activity with the retry policy in `TemporalAblyHttpClientOptions`.\n *\n * @experimental This is a preview feature of Ably and may change in a future non-major release.\n */\nexport class TemporalAblyHttpPushLiveActivity {\n  /** @internal */\n  constructor(private readonly invoker: ActivityInvoker) {}\n\n  /**\n   * Sends a push-to-start notification to the devices subscribed to the given channels, or to a single device. A\n   * retry sends the notification again, and each device shows a second Live Activity.\n   *\n   * @param params - The recipient, the broadcast `id`, and an APNs Live Activity start payload.\n   * @returns A promise which is fulfilled when Ably has accepted the notification.\n   */\n  async start(params: Ably.PushLiveActivityStartParams): Promise<void> {\n    requireObject('push.admin.liveActivity.start', 'params', params, LIVE_ACTIVITY_REMEDIATION);\n    requireObject(\n      'push.admin.liveActivity.start',\n      'params.recipient',\n      params.recipient,\n      'Set params.recipient to { channels: [...] } or { deviceId: \"...\" }.',\n    );\n    await this.invoker.invoke(ActivityNames.pushLiveActivityStart, 'push.admin.liveActivity.start', {\n      argument: params,\n    });\n  }\n\n  /**\n   * Sends a `content-state` update to all devices with an active Live Activity on the broadcast channel. Neither\n   * Ably nor APNs deduplicates the update, so a retry sends it again. If the workflow sets `aps.timestamp` in\n   * workflow code and the payload has no `alert`, the device shows the same state after a repeated update. A payload\n   * with an `alert` alerts again, and a repeated update counts against Apple's budget for priority 10 updates.\n   *\n   * @param params - The broadcast `id` and an APNs Live Activity update payload.\n   * @returns A promise which is fulfilled when Ably has accepted the notification.\n   */\n  async update(params: Ably.PushLiveActivityUpdateParams): Promise<void> {\n    requireObject('push.admin.liveActivity.update', 'params', params, LIVE_ACTIVITY_REMEDIATION);\n    await this.invoker.invoke(ActivityNames.pushLiveActivityUpdate, 'push.admin.liveActivity.update', {\n      argument: params,\n    });\n  }\n\n  /**\n   * Ends the Live Activity on all subscribed devices and cleans up the APNs channel. After this call, the broadcast\n   * `id` is no longer valid. A retry is safe, because Ably accepts a repeated end for a broadcast channel that it has\n   * already deleted.\n   *\n   * @param params - The broadcast `id` and an APNs Live Activity end payload.\n   * @returns A promise which is fulfilled when Ably has accepted the notification.\n   */\n  async end(params: Ably.PushLiveActivityEndParams): Promise<void> {\n    requireObject('push.admin.liveActivity.end', 'params', params, LIVE_ACTIVITY_REMEDIATION);\n    await this.invoker.invoke(ActivityNames.pushLiveActivityEnd, 'push.admin.liveActivity.end', {\n      argument: params,\n    });\n  }\n}\n\nconst PARAMS_REMEDIATION = 'Pass the filter parameters as an object, e.g. { clientId: \"user-1\" }.';\n\n/**\n * Registers, retrieves and removes push devices from workflow code. It mirrors the Ably `PushDeviceRegistrations`,\n * and is obtained from `TemporalAblyHttpClient.push.admin.deviceRegistrations`.\n *\n * Each method runs as a Temporal activity with the retry policy in `TemporalAblyHttpClientOptions`. A save is an upsert keyed\n * by the device ID, so a retried save has the same effect as one attempt.\n */\nexport class TemporalAblyHttpPushDeviceRegistrations {\n  /** @internal */\n  constructor(private readonly invoker: ActivityInvoker) {}\n\n  /**\n   * Registers or updates a device.\n   *\n   * @param deviceDetails - The device to register, with its `id`.\n   * @returns A promise which is fulfilled with the registered device.\n   */\n  async save(deviceDetails: Ably.DeviceDetails): Promise<Ably.DeviceDetails> {\n    requireObject(\n      'push.admin.deviceRegistrations.save',\n      'deviceDetails',\n      deviceDetails,\n      'Pass a DeviceDetails object with an id, platform, formFactor and push recipient.',\n    );\n    return this.invoker.invoke(ActivityNames.pushDeviceRegistrationsSave, 'push.admin.deviceRegistrations.save', {\n      argument: deviceDetails,\n    });\n  }\n\n  /**\n   * Retrieves a registered device.\n   *\n   * @param deviceIdOrDetails - The ID of the device, or a device with its `id`.\n   * @returns A promise which is fulfilled with the device.\n   */\n  async get(deviceIdOrDetails: string | Ably.DeviceDetails): Promise<Ably.DeviceDetails> {\n    return this.invoker.invoke(ActivityNames.pushDeviceRegistrationsGet, 'push.admin.deviceRegistrations.get', {\n      argument: deviceIdArgument('push.admin.deviceRegistrations.get', deviceIdOrDetails),\n    });\n  }\n\n  /**\n   * Retrieves the registered devices that match the filter parameters.\n   *\n   * @param params - Restricts which devices are retrieved, such as by `clientId`.\n   * @returns A promise which is fulfilled with the first page of devices.\n   */\n  async list(params: Ably.DeviceRegistrationParams): Promise<TemporalAblyPaginatedResult<Ably.DeviceDetails>> {\n    return paginate(\n      (pageParams, relation) =>\n        this.invoker.invoke(\n          ActivityNames.pushDeviceRegistrationsList,\n          pageSummary('push.admin.deviceRegistrations.list', relation),\n          { params: pageParams },\n        ),\n      params,\n    );\n  }\n\n  /**\n   * Removes a registered device, and its channel subscriptions.\n   *\n   * @param deviceIdOrDetails - The ID of the device, or a device with its `id`.\n   * @returns A promise which is fulfilled when the device has been removed.\n   */\n  async remove(deviceIdOrDetails: string | Ably.DeviceDetails): Promise<void> {\n    await this.invoker.invoke(ActivityNames.pushDeviceRegistrationsRemove, 'push.admin.deviceRegistrations.remove', {\n      argument: deviceIdArgument('push.admin.deviceRegistrations.remove', deviceIdOrDetails),\n    });\n  }\n\n  /**\n   * Removes the registered devices that match the filter parameters.\n   *\n   * @param params - Restricts which devices are removed, such as by `clientId`.\n   * @returns A promise which is fulfilled when the devices have been removed.\n   */\n  async removeWhere(params: Ably.DeviceRegistrationParams): Promise<void> {\n    requireObject('push.admin.deviceRegistrations.removeWhere', 'params', params, PARAMS_REMEDIATION);\n    await this.invoker.invoke(\n      ActivityNames.pushDeviceRegistrationsRemoveWhere,\n      'push.admin.deviceRegistrations.removeWhere',\n      { argument: params },\n    );\n  }\n}\n\nconst SUBSCRIPTION_REMEDIATION =\n  'Pass a subscription object with a channel and either a deviceId or a clientId, e.g. { channel: \"news\", clientId: \"user-1\" }.';\n\n/**\n * Subscribes devices and clients to push notifications on channels from workflow code. It mirrors the Ably\n * `PushChannelSubscriptions`, and is obtained from `TemporalAblyHttpClient.push.admin.channelSubscriptions`.\n *\n * Each method runs as a Temporal activity with the retry policy in `TemporalAblyHttpClientOptions`. A subscription is keyed by\n * its channel and its device or client, so a retried save has the same effect as one attempt.\n */\nexport class TemporalAblyHttpPushChannelSubscriptions {\n  /** @internal */\n  constructor(private readonly invoker: ActivityInvoker) {}\n\n  /**\n   * Subscribes a device, or every device of a client, to push notifications on a channel.\n   *\n   * @param subscription - The channel, and the `deviceId` or `clientId` to subscribe.\n   * @returns A promise which is fulfilled with the saved subscription.\n   */\n  async save(subscription: Ably.PushChannelSubscription): Promise<Ably.PushChannelSubscription> {\n    requireObject('push.admin.channelSubscriptions.save', 'subscription', subscription, SUBSCRIPTION_REMEDIATION);\n    return this.invoker.invoke(ActivityNames.pushChannelSubscriptionsSave, 'push.admin.channelSubscriptions.save', {\n      argument: subscription,\n    });\n  }\n\n  /**\n   * Retrieves the channel subscriptions that match the filter parameters.\n   *\n   * @param params - Restricts which subscriptions are retrieved, such as by `channel` or `clientId`.\n   * @returns A promise which is fulfilled with the first page of subscriptions.\n   */\n  async list(\n    params: Ably.PushChannelSubscriptionParams,\n  ): Promise<TemporalAblyPaginatedResult<Ably.PushChannelSubscription>> {\n    return paginate(\n      (pageParams, relation) =>\n        this.invoker.invoke(\n          ActivityNames.pushChannelSubscriptionsList,\n          pageSummary('push.admin.channelSubscriptions.list', relation),\n          { params: pageParams },\n        ),\n      params,\n    );\n  }\n\n  /**\n   * Retrieves the names of the channels that have at least one push subscription.\n   *\n   * @param params - Restrictions on the channels retrieved, such as a `limit`.\n   * @returns A promise which is fulfilled with the first page of channel names.\n   */\n  async listChannels(params: Ably.PushChannelsParams): Promise<TemporalAblyPaginatedResult<string>> {\n    return paginate(\n      (pageParams, relation) =>\n        this.invoker.invoke(\n          ActivityNames.pushChannelSubscriptionsListChannels,\n          pageSummary('push.admin.channelSubscriptions.listChannels', relation),\n          { params: pageParams },\n        ),\n      params,\n    );\n  }\n\n  /**\n   * Unsubscribes a device, or every device of a client, from push notifications on a channel.\n   *\n   * @param subscription - The channel, and the `deviceId` or `clientId` to unsubscribe.\n   * @returns A promise which is fulfilled when the subscription has been removed.\n   */\n  async remove(subscription: Ably.PushChannelSubscription): Promise<void> {\n    requireObject('push.admin.channelSubscriptions.remove', 'subscription', subscription, SUBSCRIPTION_REMEDIATION);\n    await this.invoker.invoke(ActivityNames.pushChannelSubscriptionsRemove, 'push.admin.channelSubscriptions.remove', {\n      argument: subscription,\n    });\n  }\n\n  /**\n   * Removes the channel subscriptions that match the filter parameters.\n   *\n   * @param params - Restricts which subscriptions are removed, such as by `channel` or `clientId`.\n   * @returns A promise which is fulfilled when the subscriptions have been removed.\n   */\n  async removeWhere(params: Ably.PushChannelSubscriptionParams): Promise<void> {\n    requireObject('push.admin.channelSubscriptions.removeWhere', 'params', params, PARAMS_REMEDIATION);\n    await this.invoker.invoke(\n      ActivityNames.pushChannelSubscriptionsRemoveWhere,\n      'push.admin.channelSubscriptions.removeWhere',\n      { argument: params },\n    );\n  }\n}\n", "import type { ActivityOptions, LocalActivityOptions } from '@temporalio/workflow';\nimport type * as Ably from '@ably/pubsub-core/api';\nimport { ActivityNames } from '../common/activities.js';\nimport { decodeBinaryData, encodeBinaryData, type PageParams } from '../common/wire.js';\nimport { TemporalAblyHttpChannels } from './channel.js';\nimport { requireString, requireStringArray } from './arguments.js';\nimport { ActivityInvoker } from './invoker.js';\nimport { TemporalAblyHttpPush } from './push.js';\nimport {\n  httpPaginatedResponse,\n  pageSummary,\n  type PageRelation,\n  type TemporalAblyHttpPaginatedResponse,\n} from './paginated.js';\n\n/** Options for {@link TemporalAblyHttpClient}. */\nexport interface TemporalAblyHttpClientOptions {\n  /**\n   * The options for the activities that run Ably operations. They are applied on top of the defaults, which are a\n   * `startToCloseTimeout` of 30 seconds and Temporal's default retry policy.\n   *\n   * They cannot set the `summary`. Each activity gets a summary for the Temporal UI that names the operation and\n   * channel, such as `publish chat:123`.\n   */\n  activityOptions?: Omit<ActivityOptions, 'summary'>;\n  /**\n   * When set, Ably operations run as local activities with these options, applied on top of a default\n   * `startToCloseTimeout` of 30 seconds. Local activities have lower latency, which suits short operations such as\n   * status updates. Cannot be set together with `activityOptions`. They cannot set the `summary`.\n   */\n  localActivityOptions?: Omit<LocalActivityOptions, 'summary'>;\n  /**\n   * Whether the workflow derives idempotency keys for calls that have none, so that Ably deduplicates a retried\n   * activity. Each key is the same on every attempt of the activity and every replay of the workflow. The key is\n   * sent in the form that each endpoint deduplicates on:\n   *\n   * - Message IDs for `TemporalAblyHttpChannel.publish()` and {@link TemporalAblyHttpClient.batchPublish}.\n   * - The `idempotencyKey` option for `TemporalAblyHttpChannel.updateMessage()` and `deleteMessage()`.\n   * - The annotation `id` for `TemporalAblyHttpAnnotations.publish()` and `delete()`.\n   * - Operation IDs for `TemporalAblyHttpObject.publish()`, which can also set this option for a single call.\n   *\n   * A call whose messages, annotation or operations already have an `id`, or whose options already have an\n   * `idempotencyKey`, is sent as it is. When `false`, every call is sent as it is.\n   *\n   * @defaultValue `true`\n   */\n  idempotentPublishing?: boolean;\n}\n\n/**\n * An Ably HTTP client for workflow code. It mirrors the `PubSubHttpClient` from `@ably/pubsub-server`, but each operation runs as a Temporal\n * activity on a worker that has the `AblyHttpPlugin` from `@ably/pubsub-server/temporal`, which makes the request with its own\n * Ably HTTP client.\n *\n * Construct it at module scope or inside a workflow. Constructing it does not run an activity.\n *\n * If an operation fails, it rejects with the activity's `ActivityFailure`. Use `getAblyErrorDetails()` to get the\n * Ably error from it. Errors detected in workflow code, such as invalid arguments, are thrown as an\n * `ApplicationFailure` of type `AblyError`, which `getAblyErrorDetails()` also accepts.\n *\n * Binary data can be passed as the `data` of a message or annotation, and as the `bytes` of a LiveObjects value, as a\n * `Uint8Array`, an `ArrayBuffer` or another typed array. Passing it anywhere else throws an `ApplicationFailure` of\n * type `AblyError`. Binary data in results, such as the `data` of a message or presence message, is returned as a\n * `Uint8Array`, except where a method's documentation says otherwise.\n *\n * @example\n * ```ts\n * import { workflowInfo } from '@temporalio/workflow';\n * import { TemporalAblyHttpClient } from '@ably/pubsub-server/temporal/workflow';\n *\n * const ably = new TemporalAblyHttpClient({ activityOptions: { retry: { maximumAttempts: 3 } } });\n *\n * export async function agentWorkflow(): Promise<void> {\n *   const channel = ably.channels.get(`chat:${workflowInfo().workflowId}`);\n *   await channel.publish('agent.status', { status: 'thinking' });\n * }\n * ```\n */\nexport class TemporalAblyHttpClient {\n  /** Creates and caches the channels used from this client. */\n  readonly channels: TemporalAblyHttpChannels;\n  /** Manages push notification device registrations and channel subscriptions, and publishes push notifications. */\n  readonly push: TemporalAblyHttpPush;\n  private readonly invoker: ActivityInvoker;\n\n  /**\n   * @param options - Options for the activities that run Ably operations, and for idempotent publishing.\n   * @throws `TypeError` if both `activityOptions` and `localActivityOptions` are set.\n   */\n  constructor(options: TemporalAblyHttpClientOptions = {}) {\n    if (options.activityOptions && options.localActivityOptions) {\n      throw new TypeError(\n        'TemporalAblyHttpClientOptions cannot set both activityOptions and localActivityOptions. Set localActivityOptions to run Ably operations as local activities, or activityOptions to run them as regular activities.',\n      );\n    }\n    this.invoker = new ActivityInvoker({\n      activityOptions: options.activityOptions,\n      localActivityOptions: options.localActivityOptions,\n      idempotentPublishing: options.idempotentPublishing ?? true,\n    });\n    this.channels = new TemporalAblyHttpChannels(this.invoker);\n    this.push = new TemporalAblyHttpPush(this.invoker);\n  }\n\n  /**\n   * Retrieves the time from the Ably service. Runs as a Temporal activity.\n   *\n   * Use `Date.now()` for the current time in workflow logic. It is deterministic in a workflow, while this result\n   * is recorded in the workflow history.\n   *\n   * @returns A promise which is fulfilled with the time as milliseconds since the Unix epoch.\n   */\n  async time(): Promise<number> {\n    return this.invoker.invoke(ActivityNames.time, 'time');\n  }\n\n  /**\n   * Makes a request to an Ably REST API endpoint, for functionality this client does not wrap. Runs as a Temporal\n   * activity.\n   *\n   * @param method - The request method, such as `GET` or `POST`.\n   * @param path - The request path.\n   * @param version - The version of the Ably REST API to use.\n   * @param params - The parameters to include in the URL query of the request.\n   * @param body - The JSON body of the request. It cannot contain binary data.\n   * @param headers - Additional HTTP headers to include in the request.\n   * @returns A promise which is fulfilled with the first page of the response. An error response from Ably is\n   * returned with `success` set to `false`, rather than rejected. Binary data in the response, which Ably only sends\n   * when the worker's client uses the MessagePack protocol, is returned as a base64 string.\n   */\n  async request<T = any>(\n    method: string,\n    path: string,\n    version: number,\n    params?: any,\n    body?: any[] | any,\n    headers?: any,\n  ): Promise<TemporalAblyHttpPaginatedResponse<T>> {\n    requireString('request', 'method', method);\n    requireString('request', 'path', path);\n    const summary = `request ${method.toUpperCase()} ${path}`;\n    const fetchPage = async (\n      pageParams: PageParams,\n      relation: PageRelation,\n    ): Promise<TemporalAblyHttpPaginatedResponse<T>> => {\n      const page = await this.invoker.invoke(ActivityNames.request, pageSummary(summary, relation), {\n        method: 'get',\n        path,\n        version,\n        params: pageParams,\n        headers,\n      });\n      return httpPaginatedResponse<T>(page, fetchPage);\n    };\n    const page = await this.invoker.invoke(ActivityNames.request, summary, {\n      method,\n      path,\n      version,\n      params,\n      body,\n      headers,\n    });\n    return httpPaginatedResponse<T>(page, fetchPage);\n  }\n\n  /**\n   * Publishes messages to one or more channels, up to a maximum of 100 channels. Runs as a Temporal activity.\n   *\n   * When idempotent publishing is enabled (see {@link TemporalAblyHttpClientOptions.idempotentPublishing}) and none of the\n   * spec's messages has an `id`, the messages are published with deterministic IDs, as for\n   * `TemporalAblyHttpChannel.publish()`. The objects passed in are not modified.\n   *\n   * @param spec - The messages to publish, and the channels to publish them to.\n   * @returns A promise which is fulfilled with the result of the publish to each channel. The `error` of a failure\n   * result is a plain object with the fields of an `ErrorInfo`.\n   */\n  batchPublish(\n    spec: Ably.BatchPublishSpec,\n  ): Promise<Ably.BatchResult<Ably.BatchPublishSuccessResult | Ably.BatchPublishFailureResult>>;\n  /**\n   * Publishes messages to one or more channels, up to a maximum of 100 channels. Runs as a Temporal activity.\n   *\n   * When idempotent publishing is enabled (see {@link TemporalAblyHttpClientOptions.idempotentPublishing}), the messages of\n   * each spec in which no message has an `id` are published with deterministic IDs, as for\n   * `TemporalAblyHttpChannel.publish()`. Each spec gets its own ID base. The objects passed in are not modified.\n   *\n   * @param specs - The messages to publish, and the channels to publish them to.\n   * @returns A promise which is fulfilled with an array of results, in the same order as `specs`. The `error` of a\n   * failure result is a plain object with the fields of an `ErrorInfo`.\n   */\n  batchPublish(\n    specs: Ably.BatchPublishSpec[],\n  ): Promise<Ably.BatchResult<Ably.BatchPublishSuccessResult | Ably.BatchPublishFailureResult>[]>;\n  async batchPublish(\n    specOrSpecs: Ably.BatchPublishSpec | Ably.BatchPublishSpec[],\n  ): Promise<\n    | Ably.BatchResult<Ably.BatchPublishSuccessResult | Ably.BatchPublishFailureResult>\n    | Ably.BatchResult<Ably.BatchPublishSuccessResult | Ably.BatchPublishFailureResult>[]\n  > {\n    const withIds = (spec: Ably.BatchPublishSpec): Ably.BatchPublishSpec => {\n      // The batch publish endpoint also accepts a single message object in place of an array.\n      const messages: Ably.Message[] | Ably.Message | undefined = spec?.messages;\n      if (Array.isArray(messages)) {\n        return {\n          ...spec,\n          messages: this.invoker.assignMessageIds(messages).map((message) => encodeBinaryData(message)),\n        };\n      }\n      if (messages !== null && typeof messages === 'object') {\n        const message = encodeBinaryData(this.invoker.assignMessageIds([messages])[0]);\n        return { ...spec, messages: message as unknown as Ably.Message[] };\n      }\n      return spec;\n    };\n    const specs = Array.isArray(specOrSpecs) ? specOrSpecs.map(withIds) : withIds(specOrSpecs);\n    const channels = new Set((Array.isArray(specs) ? specs : [specs]).flatMap((spec) => spec?.channels ?? []));\n    return this.invoker.invoke(ActivityNames.batchPublish, `batchPublish (${channelCount(channels.size)})`, {\n      specs,\n    });\n  }\n\n  /**\n   * Retrieves the presence members of one or more channels, up to a maximum of 100 channels. Runs as a Temporal\n   * activity.\n   *\n   * @param channels - The names of the channels.\n   * @returns A promise which is fulfilled with the result for each channel. The `error` of a failure result is a\n   * plain object with the fields of an `ErrorInfo`. The presence messages are returned as Ably sent them, without\n   * decoding their `data`, as in the Ably HTTP client, except that binary `data` is returned as a `Uint8Array`.\n   */\n  async batchPresence(\n    channels: string[],\n  ): Promise<Ably.BatchResult<Ably.BatchPresenceSuccessResult | Ably.BatchPresenceFailureResult>[]> {\n    requireStringArray('batchPresence', 'channels', channels);\n    const batches = await this.invoker.invoke(\n      ActivityNames.batchPresence,\n      `batchPresence (${channelCount(channels.length)})`,\n      { channels },\n    );\n    return Array.isArray(batches) ? batches.map(decodeBatchPresence) : batches;\n  }\n}\n\n/** Decodes the binary `data` of the presence messages in a batch presence result. */\nfunction decodeBatchPresence(\n  batch: Ably.BatchResult<Ably.BatchPresenceSuccessResult | Ably.BatchPresenceFailureResult>,\n): Ably.BatchResult<Ably.BatchPresenceSuccessResult | Ably.BatchPresenceFailureResult> {\n  if (!Array.isArray(batch?.results)) {\n    return batch;\n  }\n  const results = batch.results.map((result) =>\n    result && 'presence' in result && Array.isArray(result.presence)\n      ? { ...result, presence: result.presence.map((message) => decodeBinaryData(message)) }\n      : result,\n  );\n  return { ...batch, results };\n}\n\nfunction channelCount(count: number): string {\n  return count === 1 ? '1 channel' : `${count} channels`;\n}\n"],
  "mappings": ";;;;;;;;AAwBO,IAAM,gBAAgB;AAAA,EAC3B,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,eAAe;AAAA,EACf,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,eAAe;AAAA,EACf,MAAM;AAAA,EACN,SAAS;AAAA,EACT,cAAc;AAAA,EACd,eAAe;AAAA,EACf,aAAa;AAAA,EACb,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB,wBAAwB;AAAA,EACxB,qBAAqB;AAAA,EACrB,6BAA6B;AAAA,EAC7B,4BAA4B;AAAA,EAC5B,6BAA6B;AAAA,EAC7B,+BAA+B;AAAA,EAC/B,oCAAoC;AAAA,EACpC,8BAA8B;AAAA,EAC9B,8BAA8B;AAAA,EAC9B,sCAAsC;AAAA,EACtC,gCAAgC;AAAA,EAChC,qCAAqC;AACvC;;;ACJO,SAAS,SAAS,OAAwD;AAC/E,SAAO,iBAAiB,eAAe,YAAY,OAAO,KAAK;AACjE;AAEA,SAAS,SAAS,OAAkD;AAClE,SAAO,UAAU,QAAQ,OAAO,UAAU,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