awaitly 1.34.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{duration.d.ts → di-BDlT7InM.d.cts} +15 -1
- package/dist/{duration.d.cts → di-BbFFfO8y.d.ts} +15 -1
- package/dist/errors-DtXvrCiO.d.cts +708 -0
- package/dist/errors-DtXvrCiO.d.ts +708 -0
- package/dist/index.cjs +4594 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1970 -141
- package/dist/index.d.ts +1970 -141
- package/dist/index.js +4398 -1
- package/dist/index.js.map +1 -1
- package/dist/result.cjs +641 -1
- package/dist/result.cjs.map +1 -1
- package/dist/result.d.cts +35 -5
- package/dist/result.d.ts +35 -5
- package/dist/result.js +561 -1
- package/dist/result.js.map +1 -1
- package/dist/testing.cjs +4202 -8
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +2 -6
- package/dist/testing.d.ts +2 -6
- package/dist/testing.js +4154 -8
- package/dist/testing.js.map +1 -1
- package/dist/{run-entry-D2MmJFj9.d.cts → types-B8NfNRGX.d.ts} +1152 -1499
- package/dist/{run-entry-Dduz-is2.d.ts → types-BZ2f4MRR.d.cts} +1152 -1499
- package/dist/workflow.cjs +7096 -6
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +3346 -22
- package/dist/workflow.d.ts +3346 -22
- package/dist/workflow.js +6929 -6
- package/dist/workflow.js.map +1 -1
- package/package.json +13 -178
- package/dist/adapters.cjs +0 -7
- package/dist/adapters.cjs.map +0 -1
- package/dist/adapters.d.cts +0 -179
- package/dist/adapters.d.ts +0 -179
- package/dist/adapters.js +0 -7
- package/dist/adapters.js.map +0 -1
- package/dist/batch.cjs +0 -7
- package/dist/batch.cjs.map +0 -1
- package/dist/batch.d.cts +0 -200
- package/dist/batch.d.ts +0 -200
- package/dist/batch.js +0 -7
- package/dist/batch.js.map +0 -1
- package/dist/bind-deps.cjs +0 -2
- package/dist/bind-deps.cjs.map +0 -1
- package/dist/bind-deps.d.cts +0 -28
- package/dist/bind-deps.d.ts +0 -28
- package/dist/bind-deps.js +0 -2
- package/dist/bind-deps.js.map +0 -1
- package/dist/cache.cjs +0 -2
- package/dist/cache.cjs.map +0 -1
- package/dist/cache.d.cts +0 -269
- package/dist/cache.d.ts +0 -269
- package/dist/cache.js +0 -2
- package/dist/cache.js.map +0 -1
- package/dist/circuit-breaker.cjs +0 -7
- package/dist/circuit-breaker.cjs.map +0 -1
- package/dist/circuit-breaker.d.cts +0 -211
- package/dist/circuit-breaker.d.ts +0 -211
- package/dist/circuit-breaker.js +0 -7
- package/dist/circuit-breaker.js.map +0 -1
- package/dist/conditional.cjs +0 -2
- package/dist/conditional.cjs.map +0 -1
- package/dist/conditional.d.cts +0 -252
- package/dist/conditional.d.ts +0 -252
- package/dist/conditional.js +0 -2
- package/dist/conditional.js.map +0 -1
- package/dist/core.cjs +0 -7
- package/dist/core.cjs.map +0 -1
- package/dist/core.d.cts +0 -5
- package/dist/core.d.ts +0 -5
- package/dist/core.js +0 -7
- package/dist/core.js.map +0 -1
- package/dist/di-COl5oFnR.d.cts +0 -15
- package/dist/di-CyDj_JyZ.d.ts +0 -15
- package/dist/diagnostics.cjs +0 -8
- package/dist/diagnostics.cjs.map +0 -1
- package/dist/diagnostics.d.cts +0 -68
- package/dist/diagnostics.d.ts +0 -68
- package/dist/diagnostics.js +0 -8
- package/dist/diagnostics.js.map +0 -1
- package/dist/durable.cjs +0 -11
- package/dist/durable.cjs.map +0 -1
- package/dist/durable.d.cts +0 -9
- package/dist/durable.d.ts +0 -9
- package/dist/durable.js +0 -11
- package/dist/durable.js.map +0 -1
- package/dist/duration.cjs +0 -2
- package/dist/duration.cjs.map +0 -1
- package/dist/duration.js +0 -2
- package/dist/duration.js.map +0 -1
- package/dist/engine.cjs +0 -11
- package/dist/engine.cjs.map +0 -1
- package/dist/engine.d.cts +0 -115
- package/dist/engine.d.ts +0 -115
- package/dist/engine.js +0 -11
- package/dist/engine.js.map +0 -1
- package/dist/errors.cjs +0 -2
- package/dist/errors.cjs.map +0 -1
- package/dist/errors.d.cts +0 -361
- package/dist/errors.d.ts +0 -361
- package/dist/errors.js +0 -2
- package/dist/errors.js.map +0 -1
- package/dist/fetch.cjs +0 -7
- package/dist/fetch.cjs.map +0 -1
- package/dist/fetch.d.cts +0 -86
- package/dist/fetch.d.ts +0 -86
- package/dist/fetch.js +0 -7
- package/dist/fetch.js.map +0 -1
- package/dist/flow.cjs +0 -7
- package/dist/flow.cjs.map +0 -1
- package/dist/flow.d.cts +0 -163
- package/dist/flow.d.ts +0 -163
- package/dist/flow.js +0 -7
- package/dist/flow.js.map +0 -1
- package/dist/functional.cjs +0 -2
- package/dist/functional.cjs.map +0 -1
- package/dist/functional.d.cts +0 -444
- package/dist/functional.d.ts +0 -444
- package/dist/functional.js +0 -2
- package/dist/functional.js.map +0 -1
- package/dist/guards-BodHXLzX.d.cts +0 -72
- package/dist/guards-CeWoQ8fn.d.ts +0 -72
- package/dist/hitl-BPE_1UiM.d.cts +0 -468
- package/dist/hitl-byp570uC.d.ts +0 -468
- package/dist/hitl.cjs +0 -7
- package/dist/hitl.cjs.map +0 -1
- package/dist/hitl.d.cts +0 -442
- package/dist/hitl.d.ts +0 -442
- package/dist/hitl.js +0 -7
- package/dist/hitl.js.map +0 -1
- package/dist/index-BYT3amEz.d.ts +0 -417
- package/dist/index-C_ak66jy.d.cts +0 -417
- package/dist/match-entry-DjI2bLpD.d.cts +0 -209
- package/dist/match-entry-DjI2bLpD.d.ts +0 -209
- package/dist/match.cjs +0 -2
- package/dist/match.cjs.map +0 -1
- package/dist/match.d.cts +0 -1
- package/dist/match.d.ts +0 -1
- package/dist/match.js +0 -2
- package/dist/match.js.map +0 -1
- package/dist/otel.cjs +0 -2
- package/dist/otel.cjs.map +0 -1
- package/dist/otel.d.cts +0 -188
- package/dist/otel.d.ts +0 -188
- package/dist/otel.js +0 -2
- package/dist/otel.js.map +0 -1
- package/dist/persistence-entry-DOMx3woy.d.ts +0 -822
- package/dist/persistence-entry-ymCA4iDu.d.cts +0 -822
- package/dist/persistence.cjs +0 -2
- package/dist/persistence.cjs.map +0 -1
- package/dist/persistence.d.cts +0 -7
- package/dist/persistence.d.ts +0 -7
- package/dist/persistence.js +0 -2
- package/dist/persistence.js.map +0 -1
- package/dist/policies.cjs +0 -2
- package/dist/policies.cjs.map +0 -1
- package/dist/policies.d.cts +0 -379
- package/dist/policies.d.ts +0 -379
- package/dist/policies.js +0 -2
- package/dist/policies.js.map +0 -1
- package/dist/ratelimit.cjs +0 -7
- package/dist/ratelimit.cjs.map +0 -1
- package/dist/ratelimit.d.cts +0 -458
- package/dist/ratelimit.d.ts +0 -458
- package/dist/ratelimit.js +0 -7
- package/dist/ratelimit.js.map +0 -1
- package/dist/reliability.cjs +0 -11
- package/dist/reliability.cjs.map +0 -1
- package/dist/reliability.d.cts +0 -11
- package/dist/reliability.d.ts +0 -11
- package/dist/reliability.js +0 -11
- package/dist/reliability.js.map +0 -1
- package/dist/resolver.cjs +0 -7
- package/dist/resolver.cjs.map +0 -1
- package/dist/resolver.d.cts +0 -68
- package/dist/resolver.d.ts +0 -68
- package/dist/resolver.js +0 -7
- package/dist/resolver.js.map +0 -1
- package/dist/resource.cjs +0 -7
- package/dist/resource.cjs.map +0 -1
- package/dist/resource.d.cts +0 -174
- package/dist/resource.d.ts +0 -174
- package/dist/resource.js +0 -7
- package/dist/resource.js.map +0 -1
- package/dist/result/retry.cjs +0 -2
- package/dist/result/retry.cjs.map +0 -1
- package/dist/result/retry.d.cts +0 -70
- package/dist/result/retry.d.ts +0 -70
- package/dist/result/retry.js +0 -2
- package/dist/result/retry.js.map +0 -1
- package/dist/retry.cjs +0 -2
- package/dist/retry.cjs.map +0 -1
- package/dist/retry.d.cts +0 -388
- package/dist/retry.d.ts +0 -388
- package/dist/retry.js +0 -2
- package/dist/retry.js.map +0 -1
- package/dist/run.cjs +0 -7
- package/dist/run.cjs.map +0 -1
- package/dist/run.d.cts +0 -4
- package/dist/run.d.ts +0 -4
- package/dist/run.js +0 -7
- package/dist/run.js.map +0 -1
- package/dist/saga.cjs +0 -11
- package/dist/saga.cjs.map +0 -1
- package/dist/saga.d.cts +0 -164
- package/dist/saga.d.ts +0 -164
- package/dist/saga.js +0 -11
- package/dist/saga.js.map +0 -1
- package/dist/singleflight.cjs +0 -2
- package/dist/singleflight.cjs.map +0 -1
- package/dist/singleflight.d.cts +0 -145
- package/dist/singleflight.d.ts +0 -145
- package/dist/singleflight.js +0 -2
- package/dist/singleflight.js.map +0 -1
- package/dist/slugs.cjs +0 -2
- package/dist/slugs.cjs.map +0 -1
- package/dist/slugs.d.cts +0 -67
- package/dist/slugs.d.ts +0 -67
- package/dist/slugs.js +0 -2
- package/dist/slugs.js.map +0 -1
- package/dist/streaming.cjs +0 -9
- package/dist/streaming.cjs.map +0 -1
- package/dist/streaming.d.cts +0 -596
- package/dist/streaming.d.ts +0 -596
- package/dist/streaming.js +0 -9
- package/dist/streaming.js.map +0 -1
- package/dist/tagged-error.cjs +0 -2
- package/dist/tagged-error.cjs.map +0 -1
- package/dist/tagged-error.d.cts +0 -275
- package/dist/tagged-error.d.ts +0 -275
- package/dist/tagged-error.js +0 -2
- package/dist/tagged-error.js.map +0 -1
- package/dist/types-DQmzO9f4.d.ts +0 -323
- package/dist/types-qBUOYi-4.d.cts +0 -323
- package/dist/webhook.cjs +0 -7
- package/dist/webhook.cjs.map +0 -1
- package/dist/webhook.d.cts +0 -499
- package/dist/webhook.d.ts +0 -499
- package/dist/webhook.js +0 -7
- package/dist/webhook.js.map +0 -1
package/dist/tagged-error.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/slugs.ts","../src/tagged-error.ts"],"sourcesContent":["/**\n * awaitly/slugs\n *\n * Source-of-truth slug namespace. Every concept that surfaces as a runtime\n * error, lint rule, static-analyzer diagnostic, visualizer event, or skill rule\n * has exactly one canonical kebab-case slug here.\n *\n * Slugs are public API. Renames are a major version bump. Adds are non-breaking.\n *\n * Categories:\n * - step-* step() discipline\n * - workflow-* createWorkflow / run / runWithState shape\n * - result-* Result usage\n * - error-* Boundary handling\n * - concurrency-* step.all/map/race vs Promise.*\n * - runtime-* Failures only observable at runtime\n */\n\nexport const AWAITLY_SLUGS = {\n // --- step-* ---\n \"step-require-id\": \"step-require-id\",\n \"step-no-immediate-execution\": \"step-no-immediate-execution\",\n \"step-require-thunk-for-key\": \"step-require-thunk-for-key\",\n \"step-no-bare-await\": \"step-no-bare-await\",\n \"step-no-try-catch-wrap\": \"step-no-try-catch-wrap\",\n \"step-stable-cache-keys\": \"step-stable-cache-keys\",\n\n // --- workflow-* ---\n \"workflow-no-floating\": \"workflow-no-floating\",\n \"workflow-options-position\": \"workflow-options-position\",\n \"workflow-callback-shape\": \"workflow-callback-shape\",\n \"workflow-no-callable-form\": \"workflow-no-callable-form\",\n \"workflow-no-dynamic-import\": \"workflow-no-dynamic-import\",\n\n // --- result-* ---\n \"result-no-floating\": \"result-no-floating\",\n \"result-require-handling\": \"result-require-handling\",\n \"result-no-double-wrap\": \"result-no-double-wrap\",\n \"result-no-manual-propagation\": \"result-no-manual-propagation\",\n \"result-no-direct-ok-err\": \"result-no-direct-ok-err\",\n\n // --- error-* ---\n \"error-check-unexpected-first\": \"error-check-unexpected-first\",\n \"error-access-cause\": \"error-access-cause\",\n \"error-normalize\": \"error-normalize\",\n \"error-no-throw-in-deps\": \"error-no-throw-in-deps\",\n\n // --- concurrency-* ---\n \"concurrency-no-promise-all\": \"concurrency-no-promise-all\",\n \"concurrency-no-promise-race\": \"concurrency-no-promise-race\",\n \"concurrency-no-promise-allsettled\": \"concurrency-no-promise-allsettled\",\n\n // --- runtime-* ---\n \"runtime-step-timeout\": \"runtime-step-timeout\",\n \"runtime-step-aborted\": \"runtime-step-aborted\",\n \"runtime-retry-exhausted\": \"runtime-retry-exhausted\",\n \"runtime-rate-limit\": \"runtime-rate-limit\",\n \"runtime-circuit-open\": \"runtime-circuit-open\",\n \"runtime-unexpected\": \"runtime-unexpected\",\n \"runtime-resolver-not-found\": \"runtime-resolver-not-found\",\n \"runtime-saga-compensation\": \"runtime-saga-compensation\",\n} as const;\n\n/** All canonical awaitly slugs as a string-literal union. */\nexport type AwaitlySlug = keyof typeof AWAITLY_SLUGS;\n\n/** Categories derived from slug prefixes. */\nexport type AwaitlySlugCategory =\n | \"step\"\n | \"workflow\"\n | \"result\"\n | \"error\"\n | \"concurrency\"\n | \"runtime\";\n\n/** Returns the category (prefix) of a slug. */\nexport function slugCategory(slug: AwaitlySlug): AwaitlySlugCategory {\n return slug.split(\"-\")[0] as AwaitlySlugCategory;\n}\n\n/**\n * Returns the canonical docs URL for a slug. Resolves to the matching\n * anchored section on the consolidated rule index page.\n */\nexport function slugDocsUrl(slug: AwaitlySlug): string {\n return `https://jagreehal.github.io/awaitly/rules/#${slug}`;\n}\n\n/** Type guard: is a string a known awaitly slug? */\nexport function isAwaitlySlug(value: string): value is AwaitlySlug {\n return Object.prototype.hasOwnProperty.call(AWAITLY_SLUGS, value);\n}\n\n/** All slugs as an array. */\n// Object.keys returns string[] — cast is safe because AWAITLY_SLUGS is `as const`\n// and the module's keys are never mutated.\nexport const ALL_SLUGS: readonly AwaitlySlug[] = Object.keys(\n AWAITLY_SLUGS\n) as AwaitlySlug[];\n","/**\n * awaitly/tagged-error\n *\n * Factory for creating tagged error types with exhaustive pattern matching.\n * Enables TypeScript to enforce that all error variants are handled.\n *\n * @example\n * ```typescript\n * // Define error types (Props via generic)\n * class NotFoundError extends TaggedError(\"NotFoundError\")<{\n * id: string;\n * resource: string;\n * }> {}\n *\n * // Define with type-safe message (Props inferred from callback annotation)\n * class ValidationError extends TaggedError(\"ValidationError\", {\n * message: (p: { field: string; reason: string }) => `Invalid ${p.field}: ${p.reason}`,\n * }) {}\n *\n * // Create instances\n * const error = new NotFoundError({ id: \"123\", resource: \"User\" });\n *\n * // Runtime type check: instanceof TaggedError works!\n * console.log(error instanceof TaggedError); // true\n *\n * // Exhaustive matching\n * type AppError = NotFoundError | ValidationError;\n * const message = TaggedError.match(error as AppError, {\n * NotFoundError: (e) => `Missing: ${e.resource} ${e.id}`,\n * ValidationError: (e) => `Invalid ${e.field}: ${e.reason}`,\n * });\n * ```\n */\n\nimport { type AwaitlySlug, slugDocsUrl } from \"./slugs\";\n\n/**\n * Options for Error constructor (compatible with ES2022 ErrorOptions).\n */\nexport interface TaggedErrorOptions {\n cause?: unknown;\n}\n\n/**\n * Options for TaggedError factory with type-safe message callback.\n */\nexport interface TaggedErrorCreateOptions<Props extends Record<string, unknown>> {\n /** Custom message generator from props. Annotate parameter for type safety. */\n message: (props: Props) => string;\n /**\n * Canonical awaitly slug for this error class. When set, instances carry\n * `code`, `hint`, and `docsUrl` populated from the slugs namespace.\n * Required together with `hint` for awaitly-system errors.\n */\n slug?: AwaitlySlug;\n /**\n * One-line \"do X instead\" guidance shown alongside the error.\n * Required when `slug` is set.\n */\n hint?: string;\n}\n\n/**\n * Base interface for all tagged errors.\n */\nexport interface TaggedErrorBase extends Error {\n readonly _tag: string;\n /** Canonical slug for awaitly-system errors. Undefined for user errors that opt out. */\n readonly code?: AwaitlySlug;\n /** One-line guidance. Undefined when no slug is set. */\n readonly hint?: string;\n /** Canonical docs URL. Undefined when no slug is set. */\n readonly docsUrl?: string;\n}\n\n/**\n * Internal base class for instanceof checks.\n * All TaggedError-created classes extend this.\n * @internal\n */\nclass InternalTaggedErrorBase extends Error implements TaggedErrorBase {\n readonly _tag!: string;\n}\n\n/**\n * Instance type for factory-created TaggedErrors.\n */\ntype TaggedErrorInstance<Tag extends string, Props> = TaggedErrorBase & {\n readonly _tag: Tag;\n} & Readonly<Props>;\n\n/**\n * Constructor args type - conditionally optional based on whether Props has required fields.\n * - If Props is empty or all properties are optional: props argument is optional\n * - If Props has any required properties: props argument is required\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\ntype ConstructorArgs<Props extends Record<string, unknown>> = {} extends Props\n ? [props?: Props | void, options?: TaggedErrorOptions]\n : [props: Props, options?: TaggedErrorOptions];\n\n/**\n * Constructor type returned by TaggedError factory.\n */\nexport interface TaggedErrorConstructor<\n Tag extends string,\n Props extends Record<string, unknown>,\n> {\n new (...args: ConstructorArgs<Props>): TaggedErrorInstance<Tag, Props>;\n readonly prototype: TaggedErrorInstance<Tag, Props>;\n}\n\n/**\n * Generic class factory type that allows `<Props>` parameterization.\n * This enables the Effect.js-style syntax: `class X extends TaggedError(\"X\")<Props> {}`\n * @internal\n */\nexport interface TaggedErrorClassFactory<Tag extends string> {\n new <Props extends Record<string, unknown> = Record<string, never>>(\n ...args: ConstructorArgs<Props>\n ): TaggedErrorInstance<Tag, Props>;\n}\n\n/**\n * Helper type to extract return type from a function type.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype FnReturnType<T> = T extends (...args: any[]) => infer R ? R : never;\n\n/**\n * Helper type to get union of return types from all handlers.\n * @internal\n */\ntype HandlersReturnType<H> = { [K in keyof H]: FnReturnType<H[K]> }[keyof H];\n\n/**\n * Helper type to extract keys whose values are definitely functions (not undefined).\n * Only excludes a tag from the fallback type if its handler is guaranteed to be\n * a function. Keys where the value type includes undefined are NOT excluded,\n * ensuring type safety with dynamic/conditional handlers.\n * @internal\n */\ntype DefinitelyHandledKeys<H> = {\n [K in keyof H]-?: undefined extends H[K] ? never : K;\n}[keyof H];\n\n/**\n * Factory function to create tagged error classes.\n *\n * Two usage patterns:\n *\n * 1. **Props via generic** (default message is tag name):\n * ```typescript\n * class NotFoundError extends TaggedError(\"NotFoundError\")<{ id: string }> {}\n * ```\n *\n * 2. **Props inferred from message callback** (type-safe message):\n * ```typescript\n * class NotFoundError extends TaggedError(\"NotFoundError\", {\n * message: (p: { id: string }) => `Not found: ${p.id}`,\n * }) {}\n * ```\n *\n * Both support `instanceof TaggedError` checks at runtime.\n *\n * @param tag - The unique tag string for this error type\n * @param options - Optional configuration with message generator (annotate param for type safety)\n * @returns A class constructor that can be extended\n */\n\n// Overload 1: No options - use <Props> generic syntax, default message is tag\nfunction TaggedError<Tag extends string>(\n tag: Tag\n): TaggedErrorClassFactory<Tag>;\n\n// Overload 2: With message option - Props inferred from callback parameter annotation\nfunction TaggedError<Tag extends string, Props extends Record<string, unknown>>(\n tag: Tag,\n options: TaggedErrorCreateOptions<Props>\n): TaggedErrorConstructor<Tag, Props>;\n\n// Implementation\nfunction TaggedError<Tag extends string, Props extends Record<string, unknown>>(\n tag: Tag,\n options?: TaggedErrorCreateOptions<Props>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n return class extends InternalTaggedErrorBase {\n override readonly _tag: Tag = tag;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(props?: any, errorOptions?: TaggedErrorOptions) {\n // Generate message: call callback if provided (even for prop-less errors), else use tag\n const message = options?.message ? options.message(props ?? {}) : tag;\n\n super(message);\n this.name = tag;\n\n // Spine fields: populate when factory was given a slug\n if (options?.slug !== undefined) {\n if (!options.hint) {\n throw new TypeError(\n `TaggedError: 'hint' is required when 'slug' is set (slug: \"${options.slug}\")`\n );\n }\n Object.defineProperty(this, \"code\", {\n value: options.slug,\n enumerable: true,\n writable: false,\n configurable: false,\n });\n Object.defineProperty(this, \"hint\", {\n value: options.hint,\n enumerable: true,\n writable: false,\n configurable: false,\n });\n Object.defineProperty(this, \"docsUrl\", {\n value: slugDocsUrl(options.slug),\n enumerable: true,\n writable: false,\n configurable: false,\n });\n }\n\n // Maintains proper prototype chain for instanceof checks\n Object.setPrototypeOf(this, new.target.prototype);\n\n // Assign props to instance, stripping reserved keys:\n // - _tag: discriminant for pattern matching (cannot be forged)\n // - name, message, stack: Error internals (preserve for logging/debugging)\n // - code, hint, docsUrl: spine fields stripped when slug is set, to prevent\n // Object.assign from clobbering the non-configurable/non-writable own props\n // Note: 'cause' is allowed as a user prop (common for domain errors)\n if (props && typeof props === \"object\") {\n let safeProps: Record<string, unknown>;\n if (options?.slug !== undefined) {\n const {\n _tag: _,\n name: _n,\n message: _m,\n stack: _s,\n code: _c,\n hint: _h,\n docsUrl: _d,\n ...rest\n } = props;\n safeProps = rest;\n } else {\n const {\n _tag: _,\n name: _n,\n message: _m,\n stack: _s,\n ...rest\n } = props;\n safeProps = rest;\n }\n\n const hasUserCause = Object.prototype.hasOwnProperty.call(\n safeProps,\n \"cause\"\n );\n const userCause = hasUserCause\n ? (safeProps as { cause?: unknown }).cause\n : undefined;\n if (hasUserCause) {\n delete (safeProps as { cause?: unknown }).cause;\n }\n\n const hasOptionsCause = errorOptions?.cause !== undefined;\n if (hasUserCause && hasOptionsCause) {\n throw new TypeError(\n \"TaggedError: cannot provide 'cause' in props when also setting ErrorOptions.cause\"\n );\n }\n\n Object.assign(this, safeProps);\n\n if (hasUserCause) {\n (this as { cause?: unknown }).cause = userCause;\n }\n if (hasOptionsCause) {\n (this as { cause?: unknown }).cause = errorOptions?.cause;\n }\n } else if (errorOptions?.cause !== undefined) {\n (this as { cause?: unknown }).cause = errorOptions.cause;\n }\n }\n };\n}\n\n// Add Symbol.hasInstance so `instanceof TaggedError` works\nObject.defineProperty(TaggedError, Symbol.hasInstance, {\n value: (instance: unknown): boolean => instance instanceof InternalTaggedErrorBase,\n});\n\n/**\n * Namespace for static methods on TaggedError.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nnamespace TaggedError {\n /**\n * Type guard to check if a value is an Error instance.\n */\n export function isError(value: unknown): value is Error {\n return value instanceof Error;\n }\n\n /**\n * Type guard to check if a value is a TaggedError instance.\n * Uses the same check as `instanceof TaggedError` - only genuine\n * TaggedError instances (created via the factory) pass this guard.\n */\n export function isTaggedError(value: unknown): value is TaggedErrorBase {\n return value instanceof InternalTaggedErrorBase;\n }\n\n /**\n * Exhaustively matches on a tagged error, requiring handlers for all variants.\n *\n * TypeScript will error if any variant in the error union is not handled.\n *\n * @remarks When to use: You want compile-time enforcement that every tagged variant is handled.\n *\n * @param error - The tagged error to match\n * @param handlers - Object mapping _tag values to handler functions\n * @returns The return value of the matched handler\n *\n * @example\n * ```typescript\n * type AppError = NotFoundError | ValidationError;\n *\n * const message = TaggedError.match(error, {\n * NotFoundError: (e) => `Not found: ${e.id}`,\n * ValidationError: (e) => `Invalid: ${e.field}`,\n * });\n * ```\n */\n export function match<\n E extends TaggedErrorBase,\n H extends { [K in E[\"_tag\"]]: (e: Extract<E, { _tag: K }>) => unknown },\n >(error: E, handlers: H): HandlersReturnType<H> {\n const tag = error._tag as E[\"_tag\"];\n const handler = handlers[tag];\n return handler(\n error as Extract<E, { _tag: typeof tag }>\n ) as HandlersReturnType<H>;\n }\n\n /**\n * Partially matches on a tagged error with a fallback for unhandled variants.\n *\n * The fallback receives variants that are NOT definitely handled. A tag is\n * considered \"definitely handled\" only if its handler is a function (not\n * `undefined`). This ensures type safety even with dynamic/conditional handlers:\n *\n * ```typescript\n * const maybeHandle = featureFlag ? (e) => e.id : undefined;\n * TaggedError.matchPartial(\n * error,\n * { NotFoundError: maybeHandle }, // maybeHandle might be undefined\n * (e) => e._tag // e correctly includes NotFoundError\n * );\n * ```\n *\n * @param error - The tagged error to match\n * @param handlers - Partial object mapping _tag values to handler functions\n * @param otherwise - Fallback handler for unmatched variants\n * @returns The return value of the matched handler or fallback\n *\n * @example\n * ```typescript\n * const message = TaggedError.matchPartial(\n * error,\n * { NotFoundError: (e) => `Not found: ${e.id}` },\n * (e) => `Other error: ${e.message}`\n * );\n * ```\n */\n export function matchPartial<\n E extends TaggedErrorBase,\n H extends Partial<{\n [K in E[\"_tag\"]]: (e: Extract<E, { _tag: K }>) => unknown;\n }>,\n T,\n >(\n error: E,\n handlers: H,\n otherwise: (e: Exclude<E, { _tag: DefinitelyHandledKeys<H> }>) => T\n ): HandlersReturnType<H> | T {\n const tag = error._tag as E[\"_tag\"];\n const handler = handlers[tag];\n if (handler) {\n return handler(\n error as Extract<E, { _tag: typeof tag }>\n ) as HandlersReturnType<H>;\n }\n return otherwise(error as Exclude<E, { _tag: DefinitelyHandledKeys<H> }>);\n }\n}\n\nexport { TaggedError };\n\n/**\n * Helper type to extract the _tag literal type from a TaggedError.\n *\n * @example\n * ```typescript\n * class MyError extends TaggedError(\"MyError\")<{ id: string }> {}\n * type Tag = TagOf<MyError>; // \"MyError\"\n * ```\n */\nexport type TagOf<E extends TaggedErrorBase> = E[\"_tag\"];\n\n/**\n * Helper type to extract a specific variant from a TaggedError union by tag.\n *\n * @example\n * ```typescript\n * type AppError = NotFoundError | ValidationError;\n * type NotFound = ErrorByTag<AppError, \"NotFoundError\">; // NotFoundError\n * ```\n */\nexport type ErrorByTag<\n E extends TaggedErrorBase,\n Tag extends E[\"_tag\"],\n> = Extract<E, { _tag: Tag }>;\n\n/**\n * Reserved keys that are stripped from user props at runtime.\n * These keys cannot be used as user-defined properties:\n * - _tag: discriminant for pattern matching\n * - name, message, stack: Error internals (preserved for logging/debugging)\n * - code, hint, docsUrl: spine fields (non-configurable own properties when slug is set)\n *\n * Note: 'cause' is NOT reserved - it can be used as a user prop.\n */\ntype ReservedErrorKeys = \"_tag\" | \"name\" | \"message\" | \"stack\" | \"code\" | \"hint\" | \"docsUrl\";\n\n/**\n * Helper type to extract props from a TaggedError.\n * Excludes reserved keys that are stripped at runtime.\n *\n * @example\n * ```typescript\n * class MyError extends TaggedError(\"MyError\")<{ id: string }> {}\n * type Props = PropsOf<MyError>; // { id: string }\n *\n * // 'cause' is allowed as a user prop\n * class DomainError extends TaggedError(\"DomainError\")<{ cause: { field: string } }> {}\n * type DomainProps = PropsOf<DomainError>; // { cause: { field: string } }\n * ```\n */\nexport type PropsOf<E extends TaggedErrorBase> = Omit<E, ReservedErrorKeys>;\n"],"mappings":"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","names":["AWAITLY_SLUGS","slugDocsUrl","slug","ALL_SLUGS","AWAITLY_SLUGS","InternalTaggedErrorBase","TaggedError","tag","options","props","errorOptions","message","slugDocsUrl","safeProps","_","_n","_m","_s","_c","_h","_d","rest","hasUserCause","userCause","hasOptionsCause","instance","isError","value","isTaggedError","match","error","handlers","handler","matchPartial","otherwise"]}
|
package/dist/types-DQmzO9f4.d.ts
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import { c as AsyncResult } from './run-entry-Dduz-is2.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* awaitly/streaming - Types
|
|
5
|
-
*
|
|
6
|
-
* Core types for Result-aware streaming in workflows.
|
|
7
|
-
* All stream operations return Result types, enabling typed error handling
|
|
8
|
-
* throughout the streaming pipeline.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/** Discriminant for stream write errors */
|
|
12
|
-
declare const STREAM_WRITE_ERROR: "STREAM_WRITE_ERROR";
|
|
13
|
-
/** Discriminant for stream read errors */
|
|
14
|
-
declare const STREAM_READ_ERROR: "STREAM_READ_ERROR";
|
|
15
|
-
/** Discriminant for stream close errors */
|
|
16
|
-
declare const STREAM_CLOSE_ERROR: "STREAM_CLOSE_ERROR";
|
|
17
|
-
/** Discriminant for stream store errors */
|
|
18
|
-
declare const STREAM_STORE_ERROR: "STREAM_STORE_ERROR";
|
|
19
|
-
/** Discriminant for stream ended marker */
|
|
20
|
-
declare const STREAM_ENDED: "STREAM_ENDED";
|
|
21
|
-
/** Discriminant for stream backpressure errors */
|
|
22
|
-
declare const STREAM_BACKPRESSURE_ERROR: "STREAM_BACKPRESSURE_ERROR";
|
|
23
|
-
/**
|
|
24
|
-
* Error returned when a write operation fails.
|
|
25
|
-
*/
|
|
26
|
-
type StreamWriteError = {
|
|
27
|
-
type: typeof STREAM_WRITE_ERROR;
|
|
28
|
-
reason: "closed" | "aborted" | "store_error";
|
|
29
|
-
message: string;
|
|
30
|
-
cause?: unknown;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Error returned when a read operation fails.
|
|
34
|
-
*/
|
|
35
|
-
type StreamReadError = {
|
|
36
|
-
type: typeof STREAM_READ_ERROR;
|
|
37
|
-
reason: "closed" | "store_error";
|
|
38
|
-
message: string;
|
|
39
|
-
cause?: unknown;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Error returned when closing a stream fails.
|
|
43
|
-
*/
|
|
44
|
-
type StreamCloseError = {
|
|
45
|
-
type: typeof STREAM_CLOSE_ERROR;
|
|
46
|
-
reason: "already_closed" | "store_error";
|
|
47
|
-
message: string;
|
|
48
|
-
cause?: unknown;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Error returned from StreamStore operations.
|
|
52
|
-
*/
|
|
53
|
-
type StreamStoreError = {
|
|
54
|
-
type: typeof STREAM_STORE_ERROR;
|
|
55
|
-
reason: "read_error" | "write_error" | "metadata_error" | "close_error";
|
|
56
|
-
message: string;
|
|
57
|
-
cause?: unknown;
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Marker indicating stream has ended (not an error, but a terminal state).
|
|
61
|
-
* Used as the "error" type when stream is exhausted.
|
|
62
|
-
*/
|
|
63
|
-
type StreamEndedMarker = {
|
|
64
|
-
type: typeof STREAM_ENDED;
|
|
65
|
-
finalPosition: number;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Backpressure error when writer is paused.
|
|
69
|
-
*/
|
|
70
|
-
type StreamBackpressureError = {
|
|
71
|
-
type: typeof STREAM_BACKPRESSURE_ERROR;
|
|
72
|
-
bufferedCount: number;
|
|
73
|
-
highWaterMark: number;
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Union of all stream errors.
|
|
77
|
-
*/
|
|
78
|
-
type StreamError = StreamWriteError | StreamReadError | StreamCloseError | StreamStoreError | StreamBackpressureError;
|
|
79
|
-
/**
|
|
80
|
-
* A single item in the stream with metadata.
|
|
81
|
-
*/
|
|
82
|
-
interface StreamItem<T> {
|
|
83
|
-
/** The value stored in this stream item */
|
|
84
|
-
value: T;
|
|
85
|
-
/** Position in the stream (0-indexed) */
|
|
86
|
-
position: number;
|
|
87
|
-
/** Timestamp when item was written */
|
|
88
|
-
ts: number;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Metadata about a stream.
|
|
92
|
-
*/
|
|
93
|
-
interface StreamMetadata {
|
|
94
|
-
/** Unique identifier for the stream (workflowId + namespace) */
|
|
95
|
-
id: string;
|
|
96
|
-
/** Namespace within the workflow */
|
|
97
|
-
namespace: string;
|
|
98
|
-
/** Workflow ID that owns this stream */
|
|
99
|
-
workflowId: string;
|
|
100
|
-
/** Number of items in the stream */
|
|
101
|
-
length: number;
|
|
102
|
-
/** Whether the stream has been closed */
|
|
103
|
-
closed: boolean;
|
|
104
|
-
/** Timestamp when stream was created */
|
|
105
|
-
createdAt: number;
|
|
106
|
-
/** Timestamp when stream was last written to */
|
|
107
|
-
lastWriteAt?: number;
|
|
108
|
-
/** Timestamp when stream was closed */
|
|
109
|
-
closedAt?: number;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Options for creating a writable stream.
|
|
113
|
-
*/
|
|
114
|
-
interface StreamOptions {
|
|
115
|
-
/** Named streams (default: 'default') */
|
|
116
|
-
namespace?: string;
|
|
117
|
-
/** Backpressure threshold (default: 16) */
|
|
118
|
-
highWaterMark?: number;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Options for creating a readable stream.
|
|
122
|
-
*/
|
|
123
|
-
interface StreamReadOptions {
|
|
124
|
-
/** Named streams (default: 'default') */
|
|
125
|
-
namespace?: string;
|
|
126
|
-
/** Resume from position (0-indexed) */
|
|
127
|
-
startIndex?: number;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Options for streamForEach operation.
|
|
131
|
-
*/
|
|
132
|
-
interface StreamForEachOptions {
|
|
133
|
-
/** Name for the operation (used in events) */
|
|
134
|
-
name?: string;
|
|
135
|
-
/** Checkpoint after every N items (default: 1 = checkpoint each item) */
|
|
136
|
-
checkpointInterval?: number;
|
|
137
|
-
/** Maximum concurrent processors (default: 1 = sequential) */
|
|
138
|
-
concurrency?: number;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Result from streamForEach operation.
|
|
142
|
-
*/
|
|
143
|
-
interface StreamForEachResult<R> {
|
|
144
|
-
/** Results from each processed item */
|
|
145
|
-
results: R[];
|
|
146
|
-
/** Total items processed */
|
|
147
|
-
processedCount: number;
|
|
148
|
-
/** Position of last processed item */
|
|
149
|
-
lastPosition: number;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Writable stream interface - never throws, returns Results.
|
|
153
|
-
*
|
|
154
|
-
* Use within a step to write values to a stream that can be consumed
|
|
155
|
-
* by readers (e.g., HTTP response streaming, AI token streaming).
|
|
156
|
-
*
|
|
157
|
-
* @template T - Type of values written to the stream
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* ```typescript
|
|
161
|
-
* const writer = step.getWritable<string>({ namespace: 'ai-response' });
|
|
162
|
-
*
|
|
163
|
-
* await step(() => generateAI({
|
|
164
|
-
* prompt: 'Hello',
|
|
165
|
-
* onToken: async (token) => { await writer.write(token); }
|
|
166
|
-
* }), { key: 'generate' });
|
|
167
|
-
*
|
|
168
|
-
* await writer.close();
|
|
169
|
-
* ```
|
|
170
|
-
*/
|
|
171
|
-
interface StreamWriter<T> {
|
|
172
|
-
/**
|
|
173
|
-
* Write a value to the stream.
|
|
174
|
-
* Returns an error if the stream is closed, aborted, or store fails.
|
|
175
|
-
*/
|
|
176
|
-
write(value: T): AsyncResult<void, StreamWriteError>;
|
|
177
|
-
/**
|
|
178
|
-
* Close the stream normally.
|
|
179
|
-
* Signals to readers that no more data will be written.
|
|
180
|
-
*/
|
|
181
|
-
close(): AsyncResult<void, StreamCloseError>;
|
|
182
|
-
/**
|
|
183
|
-
* Abort the stream with a reason.
|
|
184
|
-
* Use for error conditions that should terminate the stream.
|
|
185
|
-
*/
|
|
186
|
-
abort(reason: unknown): void;
|
|
187
|
-
/** Whether the stream is still writable */
|
|
188
|
-
readonly writable: boolean;
|
|
189
|
-
/** Current write position (number of items written) */
|
|
190
|
-
readonly position: number;
|
|
191
|
-
/** Stream namespace */
|
|
192
|
-
readonly namespace: string;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Readable stream interface - returns STREAM_ENDED marker when complete.
|
|
196
|
-
*
|
|
197
|
-
* Use to consume values from a stream, with support for resuming from
|
|
198
|
-
* a specific position.
|
|
199
|
-
*
|
|
200
|
-
* @template T - Type of values read from the stream
|
|
201
|
-
*
|
|
202
|
-
* @example
|
|
203
|
-
* ```typescript
|
|
204
|
-
* const reader = getStreamReader<string>(runId, { namespace: 'ai-response' });
|
|
205
|
-
*
|
|
206
|
-
* let result = await reader.read();
|
|
207
|
-
* while (result.ok) {
|
|
208
|
-
* response.write(result.value);
|
|
209
|
-
* result = await reader.read();
|
|
210
|
-
* }
|
|
211
|
-
*
|
|
212
|
-
* if (result.error.type === 'STREAM_ENDED') {
|
|
213
|
-
* console.log('Stream complete at position', result.error.finalPosition);
|
|
214
|
-
* }
|
|
215
|
-
* ```
|
|
216
|
-
*/
|
|
217
|
-
interface StreamReader<T> {
|
|
218
|
-
/**
|
|
219
|
-
* Read the next value from the stream.
|
|
220
|
-
* Returns StreamEndedMarker when stream is exhausted.
|
|
221
|
-
*/
|
|
222
|
-
read(): AsyncResult<T, StreamReadError | StreamEndedMarker>;
|
|
223
|
-
/**
|
|
224
|
-
* Close the reader (stop consuming).
|
|
225
|
-
* Does not affect the underlying stream.
|
|
226
|
-
*/
|
|
227
|
-
close(): void;
|
|
228
|
-
/** Whether there may be more data to read */
|
|
229
|
-
readonly readable: boolean;
|
|
230
|
-
/** Current read position */
|
|
231
|
-
readonly position: number;
|
|
232
|
-
/** Stream namespace */
|
|
233
|
-
readonly namespace: string;
|
|
234
|
-
}
|
|
235
|
-
/** Unsubscribe function returned by subscribe */
|
|
236
|
-
type Unsubscribe = () => void;
|
|
237
|
-
/**
|
|
238
|
-
* Storage backend for stream data.
|
|
239
|
-
* Follows the same patterns as persistence.ts adapters.
|
|
240
|
-
*
|
|
241
|
-
* @example In-memory store
|
|
242
|
-
* ```typescript
|
|
243
|
-
* const store = createMemoryStreamStore();
|
|
244
|
-
* ```
|
|
245
|
-
*
|
|
246
|
-
* @example File-based store
|
|
247
|
-
* ```typescript
|
|
248
|
-
* const store = createFileStreamStore({ directory: './streams', fs });
|
|
249
|
-
* ```
|
|
250
|
-
*/
|
|
251
|
-
interface StreamStore {
|
|
252
|
-
/**
|
|
253
|
-
* Append an item to the stream.
|
|
254
|
-
*/
|
|
255
|
-
append<T>(workflowId: string, namespace: string, item: StreamItem<T>): AsyncResult<void, StreamStoreError>;
|
|
256
|
-
/**
|
|
257
|
-
* Read items from the stream starting at an index.
|
|
258
|
-
* @param startIndex - Position to start reading from (0-indexed)
|
|
259
|
-
* @param limit - Maximum number of items to read (default: all remaining)
|
|
260
|
-
*/
|
|
261
|
-
read<T>(workflowId: string, namespace: string, startIndex: number, limit?: number): AsyncResult<StreamItem<T>[], StreamStoreError>;
|
|
262
|
-
/**
|
|
263
|
-
* Get metadata about a stream.
|
|
264
|
-
* Returns undefined if stream doesn't exist.
|
|
265
|
-
*/
|
|
266
|
-
getMetadata(workflowId: string, namespace: string): AsyncResult<StreamMetadata | undefined, StreamStoreError>;
|
|
267
|
-
/**
|
|
268
|
-
* Mark stream as closed.
|
|
269
|
-
*/
|
|
270
|
-
closeStream(workflowId: string, namespace: string): AsyncResult<void, StreamStoreError>;
|
|
271
|
-
/**
|
|
272
|
-
* Subscribe to new items in a stream.
|
|
273
|
-
* Callback is invoked for each new item written.
|
|
274
|
-
* Returns unsubscribe function.
|
|
275
|
-
*/
|
|
276
|
-
subscribe<T>(workflowId: string, namespace: string, callback: (item: StreamItem<T>) => void): Unsubscribe;
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Check if an error is a StreamEndedMarker.
|
|
280
|
-
*/
|
|
281
|
-
declare function isStreamEnded(error: unknown): error is StreamEndedMarker;
|
|
282
|
-
/**
|
|
283
|
-
* Check if an error is a StreamWriteError.
|
|
284
|
-
*/
|
|
285
|
-
declare function isStreamWriteError(error: unknown): error is StreamWriteError;
|
|
286
|
-
/**
|
|
287
|
-
* Check if an error is a StreamReadError.
|
|
288
|
-
*/
|
|
289
|
-
declare function isStreamReadError(error: unknown): error is StreamReadError;
|
|
290
|
-
/**
|
|
291
|
-
* Check if an error is a StreamStoreError.
|
|
292
|
-
*/
|
|
293
|
-
declare function isStreamStoreError(error: unknown): error is StreamStoreError;
|
|
294
|
-
/**
|
|
295
|
-
* Check if an error is a StreamBackpressureError.
|
|
296
|
-
*/
|
|
297
|
-
declare function isStreamBackpressureError(error: unknown): error is StreamBackpressureError;
|
|
298
|
-
/**
|
|
299
|
-
* Create a StreamWriteError.
|
|
300
|
-
*/
|
|
301
|
-
declare function streamWriteError(reason: StreamWriteError["reason"], message: string, cause?: unknown): StreamWriteError;
|
|
302
|
-
/**
|
|
303
|
-
* Create a StreamReadError.
|
|
304
|
-
*/
|
|
305
|
-
declare function streamReadError(reason: StreamReadError["reason"], message: string, cause?: unknown): StreamReadError;
|
|
306
|
-
/**
|
|
307
|
-
* Create a StreamCloseError.
|
|
308
|
-
*/
|
|
309
|
-
declare function streamCloseError(reason: StreamCloseError["reason"], message: string, cause?: unknown): StreamCloseError;
|
|
310
|
-
/**
|
|
311
|
-
* Create a StreamStoreError.
|
|
312
|
-
*/
|
|
313
|
-
declare function streamStoreError(reason: StreamStoreError["reason"], message: string, cause?: unknown): StreamStoreError;
|
|
314
|
-
/**
|
|
315
|
-
* Create a StreamEndedMarker.
|
|
316
|
-
*/
|
|
317
|
-
declare function streamEnded(finalPosition: number): StreamEndedMarker;
|
|
318
|
-
/**
|
|
319
|
-
* Create a StreamBackpressureError.
|
|
320
|
-
*/
|
|
321
|
-
declare function streamBackpressureError(bufferedCount: number, highWaterMark: number): StreamBackpressureError;
|
|
322
|
-
|
|
323
|
-
export { streamBackpressureError as A, streamCloseError as B, streamEnded as C, streamReadError as D, streamStoreError as E, streamWriteError as F, type StreamStore as S, type Unsubscribe as U, type StreamReader as a, STREAM_BACKPRESSURE_ERROR as b, STREAM_CLOSE_ERROR as c, STREAM_ENDED as d, STREAM_READ_ERROR as e, STREAM_STORE_ERROR as f, STREAM_WRITE_ERROR as g, type StreamBackpressureError as h, type StreamCloseError as i, type StreamEndedMarker as j, type StreamError as k, type StreamForEachOptions as l, type StreamForEachResult as m, type StreamItem as n, type StreamMetadata as o, type StreamOptions as p, type StreamReadError as q, type StreamReadOptions as r, type StreamStoreError as s, type StreamWriteError as t, type StreamWriter as u, isStreamBackpressureError as v, isStreamEnded as w, isStreamReadError as x, isStreamStoreError as y, isStreamWriteError as z };
|