{
  "version": 3,
  "sources": ["../../core-impl/src/platform/temporal/src/worker/plugin.ts", "../../core-impl/src/platform/temporal/src/version.ts", "../../core-impl/src/platform/temporal/src/worker/activities.ts", "../../core-impl/src/platform/temporal/src/common/activities.ts", "../../core-impl/src/platform/temporal/src/common/wire.ts", "../../core-impl/src/platform/temporal/src/worker/errors.ts", "../../core-impl/src/platform/temporal/src/common/errors.ts"],
  "sourcesContent": ["import type * as Ably from '@ably/pubsub-core/api';\nimport { createHttpClient } from '@ably/pubsub-server';\nimport { SimplePlugin } from '@temporalio/plugin';\nimport { version } from '../version.js';\nimport { createActivities, currentCancellationSignal } from './activities.js';\n\n/** Options for {@link AblyHttpPlugin}. */\nexport interface AblyHttpPluginOptions {\n  /**\n   * The options of the Ably HTTP client that the plugin creates for its activities, as passed to `createHttpClient`\n   * from `@ably/pubsub-server`. To use `channel.object` from workflows, include the `LiveObjects` plugin from\n   * `@ably/pubsub-server/liveobjects` in `plugins`.\n   */\n  clientOptions: Ably.ClientOptions;\n}\n\n/**\n * A Temporal worker plugin that registers the Ably activities, which perform Ably REST operations on behalf of\n * workflows. Workflow code calls them through `TemporalAblyHttpClient` from `@ably/pubsub-server/temporal/workflow`.\n *\n * ```ts\n * const worker = await Worker.create({\n *   // ...\n *   plugins: [new AblyHttpPlugin({ clientOptions: { key: process.env.ABLY_API_KEY } })],\n * });\n * ```\n *\n * The plugin creates its own Ably HTTP client from `clientOptions`, which only its activities use. The activities are\n * registered under the names in {@link ActivityNames}, which all start with `ably.`. The worker adds them over its own\n * `activities`, replacing any activity with the same name, so do not give your own activities names that start with\n * `ably.`.\n */\nexport class AblyHttpPlugin extends SimplePlugin {\n  /**\n   * @param options - The plugin options, including the options of the Ably HTTP client that the activities use.\n   * @throws `TypeError` if `options.clientOptions` is not an object.\n   */\n  constructor(options: AblyHttpPluginOptions) {\n    const clientOptions = validateClientOptions(options);\n    super({\n      name: 'AblyHttpPlugin',\n      version,\n      activities: createActivities(createHttpClient(withCancellation(clientOptions))),\n    });\n  }\n}\n\n/**\n * `requestSignal` is an internal option of the Ably client, absent from the public `ClientOptions`. The client calls it\n * once for each request, and abandons the request once the signal it returns has aborted.\n */\ntype ClientOptionsWithRequestSignal = Ably.ClientOptions & { requestSignal: () => AbortSignal | undefined };\n\n/**\n * Returns a copy of `clientOptions` that abandons each request once Temporal cancels the activity that makes it, or\n * times its attempt out.\n */\nfunction withCancellation(clientOptions: Ably.ClientOptions): Ably.ClientOptions {\n  const options: ClientOptionsWithRequestSignal = { ...clientOptions, requestSignal: currentCancellationSignal };\n  return options;\n}\n\n/** Returns `options.clientOptions`, after checking that it is an object. */\nfunction validateClientOptions(options: AblyHttpPluginOptions | undefined): Ably.ClientOptions {\n  const clientOptions: unknown = options?.clientOptions;\n  if (typeof clientOptions !== 'object' || clientOptions === null || Array.isArray(clientOptions)) {\n    throw new TypeError(\n      'AblyHttpPlugin options do not include the Ably ClientOptions object in `clientOptions`. Pass the options of the Ably HTTP client that the plugin creates for its activities, for example `new AblyHttpPlugin({ clientOptions: { key: process.env.ABLY_API_KEY } })`.',\n    );\n  }\n  return clientOptions as Ably.ClientOptions;\n}\n", "/**\n * The version of `@ably/pubsub-server`, which ships the Temporal plugin. `scripts/release.js` keeps it in step with the\n * package versions.\n */\nexport const version = '3.2.0';\n", "import type * as Ably from '@ably/pubsub-core/api';\nimport { asyncLocalStorage } from '@temporalio/activity';\nimport type { Context } from '@temporalio/activity';\nimport { ActivityNames } from '../common/activities.js';\nimport type { AblyActivities } from '../common/activities.js';\nimport { encodeBinaryData, mapOperationBytes, toWireValue } from '../common/wire.js';\nimport type { PageLinks, PageParams, WireHttpPaginatedResponse, WirePage } from '../common/wire.js';\nimport { toActivityFailure } from './errors.js';\n\n/**\n * Creates the Ably activities, keyed by their names in {@link ActivityNames}, which perform each operation with\n * `client`. {@link AblyHttpPlugin} registers them on a worker, so most applications do not need to call this\n * directly. Use it to register the activities on a worker without the plugin.\n *\n * Create `client` for the activities alone, and do not use it anywhere else. The activities get each channel from\n * `client` when they need it, and release it from `client` once no activity is using it. A channel that other code\n * gets from `client` would be released while that code still uses it, and the channel options it sets, such as a\n * `cipher`, would apply to the activities' requests on that channel.\n *\n * Every activity fails with an `ApplicationFailure` of type `AblyError` when the Ably HTTP client returns an error.\n * The failure is retryable only when the error is likely to be transient, such as a 5xx response, a timeout, a\n * rate limit or a network failure.\n *\n * While an activity with a `heartbeatTimeout` waits for Ably, it heartbeats every half of that timeout. The client\n * that {@link AblyHttpPlugin} creates also abandons its request, and tries no further host, once Temporal cancels the\n * activity or times the attempt out, and the activity then fails as cancelled. A `client` that you create is not\n * stopped, so one call can keep trying fallback hosts after Temporal has cancelled the activity.\n *\n * Accessing `channel.object` requires `client` to have been constructed with the `LiveObjects` plugin from\n * `@ably/pubsub-server/liveobjects`. Without it, the `ably.channel.object.*` activities fail non-retryably.\n *\n * @param client - The Ably HTTP client used to perform each operation.\n * @returns The activity implementations, keyed by activity name.\n */\nexport function createActivities(client: Ably.PubSubHttpClient): AblyActivities {\n  const leases = new ChannelLeases(client);\n  const admin = (): Ably.PushAdmin => client.push.admin;\n\n  return {\n    [ActivityNames.publish]: (input) =>\n      run(async () => {\n        const { channel: name, messages, options } = input;\n        return encode(await leases.use(name, (channel) => channel.publish(messages, options)));\n      }, idRetry(input.messages)),\n\n    [ActivityNames.history]: (input) =>\n      run(async () => {\n        const { channel: name, params } = input;\n        const page = await leases.use(name, (channel) => channel.history(params as Ably.HttpHistoryParams | undefined));\n        return encode(toWireMessagePage(page));\n      }),\n\n    [ActivityNames.status]: (input) =>\n      run(async () => {\n        const { channel: name } = input;\n        return encode(await leases.use(name, (channel) => channel.status()));\n      }),\n\n    [ActivityNames.getMessage]: (input) =>\n      run(async () => {\n        const { channel: name, serialOrMessage } = input;\n        return encode(encodeData(await leases.use(name, (channel) => channel.getMessage(serialOrMessage))));\n      }),\n\n    [ActivityNames.updateMessage]: (input) =>\n      run(async () => {\n        const { channel: name, message, operation, options } = input;\n        return encode(await leases.use(name, (channel) => channel.updateMessage(message, operation, options)));\n      }, idempotencyKeyRetry(input.options)),\n\n    [ActivityNames.deleteMessage]: (input) =>\n      run(async () => {\n        const { channel: name, message, operation, options } = input;\n        return encode(await leases.use(name, (channel) => channel.deleteMessage(message, operation, options)));\n      }, idempotencyKeyRetry(input.options)),\n\n    [ActivityNames.appendMessage]: (input) =>\n      run(async () => {\n        const { channel: name, message, operation, options } = input;\n        return encode(await leases.use(name, (channel) => channel.appendMessage(message, operation, options)));\n      }, NOT_IDEMPOTENT),\n\n    [ActivityNames.getMessageVersions]: (input) =>\n      run(async () => {\n        const { channel: name, serialOrMessage, params } = input;\n        const page = await leases.use(name, (channel) => channel.getMessageVersions(serialOrMessage, params));\n        return encode(toWireMessagePage(page));\n      }),\n\n    [ActivityNames.presenceGet]: (input) =>\n      run(async () => {\n        const { channel: name, params } = input;\n        const page = await leases.use(name, (channel) =>\n          channel.presence.get(params as Ably.HttpPresenceParams | undefined),\n        );\n        return encode(toWireMessagePage(page));\n      }),\n\n    [ActivityNames.presenceHistory]: (input) =>\n      run(async () => {\n        const { channel: name, params } = input;\n        const page = await leases.use(name, (channel) =>\n          channel.presence.history(params as Ably.HttpHistoryParams | undefined),\n        );\n        return encode(toWireMessagePage(page));\n      }),\n\n    [ActivityNames.annotationsPublish]: (input) =>\n      run(\n        async () => {\n          const { channel: name, messageOrSerial, annotation } = input;\n          await leases.use(name, ({ annotations }) =>\n            typeof messageOrSerial === 'string'\n              ? annotations.publish(messageOrSerial, annotation)\n              : annotations.publish(messageOrSerial, annotation),\n          );\n        },\n        idRetry([input.annotation]),\n      ),\n\n    [ActivityNames.annotationsDelete]: (input) =>\n      run(\n        async () => {\n          const { channel: name, messageOrSerial, annotation } = input;\n          await leases.use(name, ({ annotations }) =>\n            typeof messageOrSerial === 'string'\n              ? annotations.delete(messageOrSerial, annotation)\n              : annotations.delete(messageOrSerial, annotation),\n          );\n        },\n        idRetry([input.annotation]),\n      ),\n\n    [ActivityNames.annotationsGet]: (input) =>\n      run(async () => {\n        const { channel: name, messageOrSerial, params } = input;\n        const getParams = params as Ably.GetAnnotationsParams | null;\n        const page = await leases.use(name, ({ annotations }) =>\n          typeof messageOrSerial === 'string'\n            ? annotations.get(messageOrSerial, getParams)\n            : annotations.get(messageOrSerial, getParams),\n        );\n        return encode(toWireMessagePage(page));\n      }),\n\n    [ActivityNames.objectGet]: (input) =>\n      run(async () => {\n        const { channel: name, params } = input;\n        return encode(await leases.use(name, (channel) => channel.object.get(params)));\n      }),\n\n    [ActivityNames.objectPublish]: (input) =>\n      run(async () => {\n        const { channel: name, operations } = input;\n        // The `bytes` of each value are base64 strings, which the Ably SDK only sends as binary when given a Buffer.\n        const decoded = Array.isArray(operations)\n          ? operations.map((operation) => mapOperationBytes(operation, decodeBytes))\n          : mapOperationBytes(operations, decodeBytes);\n        return encode(await leases.use(name, (channel) => channel.object.publish(decoded)));\n      }, idRetry(input.operations)),\n\n    [ActivityNames.time]: () => run(async () => encode(await client.time())),\n\n    [ActivityNames.request]: (input) =>\n      run(async () => {\n        const { method, path, version, params, body, headers } = input;\n        const response = await client.request(method, path, version, params, body, headers);\n        const page: WireHttpPaginatedResponse<unknown> = {\n          ...toWirePage(response),\n          statusCode: response.statusCode,\n          success: response.success,\n          errorCode: response.errorCode,\n          errorMessage: response.errorMessage,\n          headers: response.headers,\n        };\n        if (response.errorDetail !== undefined) {\n          page.errorDetail = response.errorDetail;\n        }\n        return encode(page);\n      }),\n\n    [ActivityNames.batchPublish]: (input) =>\n      run(async () => {\n        const { specs } = input;\n        return Array.isArray(specs)\n          ? encode(await client.batchPublish(specs))\n          : encode(await client.batchPublish(specs));\n      }, batchPublishRetry(input.specs)),\n\n    [ActivityNames.batchPresence]: (input) =>\n      run(async () => {\n        const { channels } = input;\n        return encode((await client.batchPresence(channels)).map(encodeBatchPresenceData));\n      }),\n\n    [ActivityNames.pushPublish]: (input) =>\n      run(async () => {\n        const { recipient, payload } = input;\n        await admin().publish(recipient, payload);\n      }, NOT_IDEMPOTENT),\n\n    [ActivityNames.pushCreateApnsBroadcast]: (input) =>\n      run(async () => encode(await admin().createApnsBroadcast(input.argument)), NOT_IDEMPOTENT),\n\n    [ActivityNames.pushLiveActivityStart]: (input) =>\n      run(async () => {\n        await admin().liveActivity.start(input.argument);\n      }, NOT_IDEMPOTENT),\n\n    [ActivityNames.pushLiveActivityUpdate]: (input) =>\n      run(async () => {\n        await admin().liveActivity.update(input.argument);\n      }, NOT_IDEMPOTENT),\n\n    [ActivityNames.pushLiveActivityEnd]: (input) =>\n      run(async () => {\n        await admin().liveActivity.end(input.argument);\n      }),\n\n    [ActivityNames.pushDeviceRegistrationsSave]: (input) =>\n      run(async () => encode(await admin().deviceRegistrations.save(input.argument))),\n\n    [ActivityNames.pushDeviceRegistrationsGet]: (input) =>\n      run(async () => {\n        const { argument } = input;\n        const registrations = admin().deviceRegistrations;\n        return encode(await (typeof argument === 'string' ? registrations.get(argument) : registrations.get(argument)));\n      }),\n\n    [ActivityNames.pushDeviceRegistrationsList]: (input) =>\n      run(async () => {\n        const { params } = input;\n        const page = await admin().deviceRegistrations.list((params ?? {}) as Ably.DeviceRegistrationParams);\n        return encode(toWirePage(page));\n      }),\n\n    [ActivityNames.pushDeviceRegistrationsRemove]: (input) =>\n      run(async () => {\n        const { argument } = input;\n        const registrations = admin().deviceRegistrations;\n        await (typeof argument === 'string' ? registrations.remove(argument) : registrations.remove(argument));\n      }),\n\n    [ActivityNames.pushDeviceRegistrationsRemoveWhere]: (input) =>\n      run(async () => {\n        await admin().deviceRegistrations.removeWhere(input.argument);\n      }),\n\n    [ActivityNames.pushChannelSubscriptionsSave]: (input) =>\n      run(async () => encode(await admin().channelSubscriptions.save(input.argument))),\n\n    [ActivityNames.pushChannelSubscriptionsList]: (input) =>\n      run(async () => {\n        const { params } = input;\n        const page = await admin().channelSubscriptions.list((params ?? {}) as Ably.PushChannelSubscriptionParams);\n        return encode(toWirePage(page));\n      }),\n\n    [ActivityNames.pushChannelSubscriptionsListChannels]: (input) =>\n      run(async () => {\n        const { params } = input;\n        const page = await admin().channelSubscriptions.listChannels((params ?? {}) as Ably.PushChannelsParams);\n        return encode(toWirePage(page));\n      }),\n\n    [ActivityNames.pushChannelSubscriptionsRemove]: (input) =>\n      run(async () => {\n        await admin().channelSubscriptions.remove(input.argument);\n      }),\n\n    [ActivityNames.pushChannelSubscriptionsRemoveWhere]: (input) =>\n      run(async () => {\n        await admin().channelSubscriptions.removeWhere(input.argument);\n      }),\n  };\n}\n\n/**\n * Gets channels from the client for the activities, and releases each channel once no activity is using it, so that\n * `client.channels.all` does not keep every channel the worker has used.\n *\n * A REST channel holds only its options, so getting a released channel again costs a few small objects. An activity\n * that is using a channel keeps its reference to it after a release.\n */\nclass ChannelLeases {\n  /** The number of activities using each channel. */\n  private readonly counts = new Map<string, number>();\n\n  constructor(private readonly client: Ably.PubSubHttpClient) {}\n\n  /** Runs `operation` with the channel called `name`, which stays on the client until the operation settles. */\n  async use<T>(name: string, operation: (channel: Ably.HttpChannel) => Promise<T>): Promise<T> {\n    const channel = this.client.channels.get(name);\n    this.counts.set(name, (this.counts.get(name) ?? 0) + 1);\n    try {\n      return await operation(channel);\n    } finally {\n      this.release(name);\n    }\n  }\n\n  private release(name: string): void {\n    const count = (this.counts.get(name) ?? 1) - 1;\n    if (count > 0) {\n      this.counts.set(name, count);\n      return;\n    }\n    this.counts.delete(name);\n    this.client.channels.release(name);\n  }\n}\n\n/**\n * How long after Ably accepts a call it deduplicates a retry of it. The worker cannot see when Ably accepted the first\n * attempt, so the activity's first scheduled time stands in for it.\n */\nconst DEDUPLICATION_WINDOW_MS = 2 * 60 * 1000;\n\n/** The reasons why Ably may apply a retried call more than once. */\nconst NOT_IDEMPOTENT = 'operation is not idempotent';\nconst NO_IDS = 'no message IDs or idempotencyKey';\n\n/**\n * What Ably does with a retry of a call that reached it. `deduplicated` means that Ably discards a retry within its\n * deduplication window. A reason means that Ably applies a retry again. A call whose retry has the same effect as one\n * attempt, such as a read, has none.\n */\ntype RetryEffect = 'deduplicated' | typeof NOT_IDEMPOTENT | typeof NO_IDS;\n\n/**\n * Returns the cancellation signal of the activity attempt making a request, or `undefined` outside an activity.\n * {@link AblyHttpPlugin} passes it to its client as the internal `requestSignal` option, so that the client abandons\n * the request once Temporal cancels the activity or times the attempt out.\n */\nexport function currentCancellationSignal(): AbortSignal | undefined {\n  return asyncLocalStorage.getStore()?.cancellationSignal;\n}\n\n/**\n * Runs the body of an activity, converting any Ably error it throws into an activity failure. Once Temporal has\n * cancelled the activity or timed the attempt out, it throws the cancellation instead, whatever the body threw, so\n * that the worker reports the attempt as cancelled.\n *\n * While the body runs, it heartbeats as {@link heartbeatUntilSettled} describes.\n *\n * On a retry, it warns when Ably may apply the call more than once, as described by `retry`.\n */\nasync function run<T>(body: () => Promise<T>, retry?: RetryEffect): Promise<T> {\n  const activity = asyncLocalStorage.getStore();\n  if (activity) {\n    warnOfRepeatedRetry(activity, retry);\n  }\n  const stopHeartbeating = activity ? heartbeatUntilSettled(activity) : undefined;\n  try {\n    return await body();\n  } catch (err) {\n    if (activity?.cancellationSignal.aborted) {\n      throw activity.cancellationSignal.reason;\n    }\n    throw toActivityFailure(err);\n  } finally {\n    stopHeartbeating?.();\n  }\n}\n\n/**\n * Heartbeats every half of the activity's `heartbeatTimeout` until the returned function is called, so that Temporal\n * does not time out an attempt that is still waiting for Ably, and so that the activity learns of its cancellation,\n * which Temporal delivers in the response to a heartbeat. An activity without a `heartbeatTimeout` must not heartbeat,\n * so for one it does nothing.\n */\nfunction heartbeatUntilSettled(activity: Context): () => void {\n  const { heartbeatTimeoutMs } = activity.info;\n  if (heartbeatTimeoutMs === undefined || heartbeatTimeoutMs <= 0) {\n    return () => {};\n  }\n  const timer = setInterval(() => activity.heartbeat(), heartbeatTimeoutMs / 2);\n  return () => clearInterval(timer);\n}\n\nfunction warnOfRepeatedRetry(activity: Context, retry: RetryEffect | undefined): void {\n  const { attempt, scheduledTimestampMs } = activity.info;\n  if (attempt <= 1 || retry === undefined) {\n    return;\n  }\n  if (retry !== 'deduplicated') {\n    activity.log.warn('Ably: retrying a call that Ably does not deduplicate, so it may be applied more than once', {\n      reason: retry,\n    });\n    return;\n  }\n  const elapsedMs = Date.now() - scheduledTimestampMs;\n  if (elapsedMs > DEDUPLICATION_WINDOW_MS) {\n    activity.log.warn(\n      \"Ably: retrying a call more than 2 minutes after it was first scheduled. Ably's deduplication window may have passed, so the call may be applied more than once. Set scheduleToCloseTimeout in activityOptions to keep retries within the window.\",\n      { elapsedMs },\n    );\n  }\n}\n\n/**\n * The retry effect of a call that sends messages, annotations or LiveObjects operations, which Ably deduplicates only\n * when every one of them has an ID.\n */\nfunction idRetry(items: unknown): RetryEffect {\n  return toArray(items).every((item) => hasString(item, 'id')) ? 'deduplicated' : NO_IDS;\n}\n\n/** The retry effect of `batchPublish()`, which Ably deduplicates only when every message in every spec has an ID. */\nfunction batchPublishRetry(specs: Ably.BatchPublishSpec | Ably.BatchPublishSpec[]): RetryEffect {\n  return idRetry(toArray(specs).flatMap((spec) => toArray<unknown>(spec?.messages)));\n}\n\n/** The retry effect of an update or delete, which Ably deduplicates only when it has an `idempotencyKey`. */\nfunction idempotencyKeyRetry(options: Ably.PublishOptions | undefined): RetryEffect {\n  return hasString(options, 'idempotencyKey') ? 'deduplicated' : NO_IDS;\n}\n\n/** Whether `value` is an object whose `key` property is a non-empty string. */\nfunction hasString(value: unknown, key: string): boolean {\n  if (typeof value !== 'object' || value === null) {\n    return false;\n  }\n  const property = (value as Record<string, unknown>)[key];\n  return typeof property === 'string' && property !== '';\n}\n\nfunction toArray<T>(value: T | T[]): T[] {\n  return Array.isArray(value) ? value : [value];\n}\n\nfunction base64(bytes: Uint8Array): string {\n  return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString('base64');\n}\n\nfunction decodeBytes(bytes: unknown): unknown {\n  return typeof bytes === 'string' ? Buffer.from(bytes, 'base64') : bytes;\n}\n\n/**\n * Encodes an activity's result for the activity boundary, replacing binary data anywhere in it with a base64 string.\n * The result type is that of the value before encoding.\n */\nfunction encode<T>(value: T): T {\n  return toWireValue(value, base64) as T;\n}\n\n/** Encodes the binary `data` of a message, presence message or annotation as base64, with its `encoding`. */\nfunction encodeData<T>(message: T): T {\n  return encodeBinaryData(message, base64);\n}\n\nfunction encodeBatchPresenceData(\n  batch: Ably.BatchResult<Ably.BatchPresenceSuccessResult | Ably.BatchPresenceFailureResult>,\n): Ably.BatchResult<Ably.BatchPresenceSuccessResult | Ably.BatchPresenceFailureResult> {\n  const results = batch.results.map((result) =>\n    'presence' in result && Array.isArray(result.presence)\n      ? { ...result, presence: result.presence.map((message) => encodeData(message)) }\n      : result,\n  );\n  return { ...batch, results };\n}\n\n/** The links to the first, current and next pages of a paginated result, from its `Link` header. */\nfunction pageLinks(result: Ably.PaginatedResult<unknown>): PageLinks {\n  // `PaginatedResult` keeps the parsed `Link` header in a private field, and exposes no public way to read it.\n  const relParams = (result as unknown as { _relParams?: Record<string, PageParams> | null })._relParams;\n  const links: PageLinks = {};\n  for (const rel of ['first', 'current', 'next'] as const) {\n    const params = relParams?.[rel];\n    if (params) {\n      links[rel] = params;\n    }\n  }\n  return links;\n}\n\nfunction toWirePage<T>(result: Ably.PaginatedResult<T>): WirePage<T> {\n  return { items: result.items, links: pageLinks(result) };\n}\n\n/** A page of messages, presence messages or annotations, with their binary `data` encoded as base64. */\nfunction toWireMessagePage<T>(result: Ably.PaginatedResult<T>): WirePage<T> {\n  return { items: result.items.map((item) => encodeData(item)), links: pageLinks(result) };\n}\n", "// 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 } from '../common/errors.js';\nimport type { AblyErrorDetails } from '../common/errors.js';\n\n/** The fields of an Ably `ErrorInfo` that the activities read. */\ninterface ErrorInfoLike {\n  code: number;\n  message: string;\n  statusCode?: unknown;\n  href?: unknown;\n  remediation?: unknown;\n  detail?: unknown;\n}\n\n/**\n * Whether `err` is an Ably `ErrorInfo`. This is a structural check, because the error may come from a different\n * copy of the Ably SDK than the one this module would import. A numeric `code` distinguishes an Ably error from a\n * Node.js system error, whose `code` is a string such as `ECONNREFUSED`.\n */\nfunction isErrorInfoLike(err: unknown): err is ErrorInfoLike {\n  return (\n    typeof err === 'object' &&\n    err !== null &&\n    typeof (err as ErrorInfoLike).code === 'number' &&\n    typeof (err as ErrorInfoLike).message === 'string'\n  );\n}\n\n/** The code of the error the Ably SDK reports when the client's `authUrl` or `authCallback` fails. */\nconst TOKEN_CALLBACK_ERROR_CODE = 40170;\n\n/**\n * Whether a failed request is likely to succeed if retried: a server error, a timeout, a rate limit, or an error\n * with no status at all, such as a network failure. A failed `authUrl` or `authCallback` is also retryable, because\n * the cause is often a timeout or network error reaching the application's auth endpoint.\n */\nfunction isRetryable(code: number | null, statusCode: number | undefined): boolean {\n  return (\n    statusCode === undefined ||\n    statusCode >= 500 ||\n    statusCode === 408 ||\n    statusCode === 429 ||\n    code === TOKEN_CALLBACK_ERROR_CODE\n  );\n}\n\n/**\n * Converts an error thrown by the Ably HTTP client into the error that an Ably activity fails with.\n *\n * An Ably `ErrorInfo` becomes an `ApplicationFailure` of type {@link ABLY_ERROR_TYPE}, with the error's fields as\n * an {@link AblyErrorDetails} in `details[0]`. The failure is non-retryable unless the error is likely to be\n * transient. The original error is kept as the failure's `cause`, so that its stack trace and any nested cause\n * are recorded in the workflow history.\n *\n * Any other error is returned unchanged, and Temporal retries the activity according to its retry policy.\n *\n * @param err - The error thrown by the Ably HTTP client.\n * @returns The error for the activity to throw.\n */\nexport function toActivityFailure(err: unknown): unknown {\n  if (!isErrorInfoLike(err)) {\n    return err;\n  }\n\n  const statusCode = typeof err.statusCode === 'number' && err.statusCode > 0 ? err.statusCode : undefined;\n  // The SDK reports a code of NaN for an error response without an Ably error code, such as one from a proxy.\n  const code = Number.isFinite(err.code) ? err.code : null;\n  const details: AblyErrorDetails = { code, message: err.message };\n  if (statusCode !== undefined) {\n    details.statusCode = statusCode;\n  }\n  if (typeof err.href === 'string') {\n    details.href = err.href;\n  }\n  if (typeof err.remediation === 'string') {\n    details.remediation = err.remediation;\n  }\n  if (typeof err.detail === 'object' && err.detail !== null) {\n    details.detail = err.detail as Record<string, string>;\n  }\n\n  return ApplicationFailure.create({\n    type: ABLY_ERROR_TYPE,\n    message: err.message,\n    nonRetryable: !isRetryable(code, statusCode),\n    details: [details],\n    cause: err instanceof Error ? err : undefined,\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"],
  "mappings": ";;;;;;;;;;AACA,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;;;ACEtB,IAAM,UAAU;;;ACHvB,SAAS,yBAAyB;;;ACuB3B,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;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