Skip to content

v2 refactor: @devrev/airsync-sdk (rename, state/adapter split, emit-from-return) - #208

Draft
radovanjorgic wants to merge 4 commits into
mainfrom
v2
Draft

v2 refactor: @devrev/airsync-sdk (rename, state/adapter split, emit-from-return)#208
radovanjorgic wants to merge 4 commits into
mainfrom
v2

Conversation

@radovanjorgic

@radovanjorgic radovanjorgic commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR is the v2 rebuild of the SDK, delivered as three single-purpose commits
(refactor / test / docs) for commit-by-commit review. Breaking changes are intended.

  • Rename & branding@devrev/ts-adaas@devrev/airsync-sdk (2.x);
    AirdropEvent/AirdropMessageAirSyncEvent/AirSyncMessage (hard rename).
  • Adapter & state splitWorkerAdapterExtractionAdapter + LoadingAdapter;
    StateExtractionState + LoadingState; on-disk state is now a
    { connectorState, sdkState } envelope with a v1→v2 read-time migration.
  • emit-from-returnemit() is now SDK-internal; task/onTimeout return a
    TaskResult (success / progress / delay / error) and the SDK emits once.
  • Cleanup — removed the deprecated event-type translation layer, dead
    migrateProcessedAttachments/createAdapterState shims, and src/deprecated/**.
  • Migration guide & skill — added MIGRATION.md (complete v1→v2 spec, shipped in the
    npm tarball) and the migrate-v2 skill that executes it.

Connected Issues

Checklist

  • Tests added/updated and ran with npm run test OR no tests needed.
  • Ran backwards compatibility tests with npm run test:backwards-compatibility.
  • Code formatted and checked with npm run lint.
  • Tested airdrop-template linked to this PR.
  • Documentation updated and provided a link to PR / new docs OR no docs needed.

Drops code that v2 no longer builds on, so the later commits do not have
to carry it. Call sites that still reference these modules are reworked
in a later commit, which is why the tree does not compile in between.

- src/deprecated/* (the pre-WorkerAdapter adapter, demo extractor,
  legacy http client and uploader)
- the legacy event-type translation layer
- the old src/http surface (axios-client, constants, index, types)
- the log-context layer (logger.constants, logger.context)
- REFERENCE.md, superseded by MIGRATION.md and the README

Verified unused by both known connectors, asana and template.

BREAKING CHANGE: the deprecated exports (Adapter, createAdapter,
DemoExtractor, HTTPClient, the legacy uploader) and the axios/axiosClient
surface are gone, along with legacy event-type translation. Log records
no longer carry is_sdk_log, so Datadog filters on @is_sdk_log stop
matching. See MIGRATION.md sections 9, 11 and 12.
Mechanical commit: the package rename, the module layout, and the
tooling that enforces it. No behavior changes.

Package:
- @devrev/ts-adaas -> @devrev/airsync-sdk, description reworded to
  AirSync, README install line updated

Module moves (pure renames, contents untouched):
- common/errors.ts                 -> types/errors.ts
- common/control-protocol.ts       -> multithreading/emit.ts
- common/test-utils.ts             -> testing/mock-event.ts
- common/time-value-resolver.ts    -> state/time-value-resolver.ts
- common/install-initial-domain-mapping.ts -> state/
- mock-server/*                    -> testing/
- http/axios-client-internal.ts    -> http/client.ts
- multithreading/worker-adapter/worker-adapter.helpers.ts
                                   -> multithreading/adapters/loading-adapter.helpers.ts
- mappers/mappers.interface.ts     -> mappers/mappers.interfaces.ts

Relative import paths were updated at every call site, and import
blocks are now sorted by the new simple-import-sort rule
(node builtins -> external -> parent-relative -> same-dir). The jest
project globs follow the renamed http client test.

tsconfig.build.json keeps tests out of the published build, so the
build no longer compiles *.test.ts into dist.

BREAKING CHANGE: the package is published as @devrev/airsync-sdk;
@devrev/ts-adaas receives no further releases. Deep imports into
moved modules no longer resolve - import from the package root
instead. See MIGRATION.md sections 1 and 13.
The behavioral half of v2. Everything here can break a connector.

Adapters:
- WorkerAdapter is split into ExtractionAdapter and LoadingAdapter over
  a shared BaseAdapter, so each phase only carries the surface it needs
- processTask is split into processExtractionTask and processLoadingTask

Emit contract:
- a worker's task returns a TaskResult
  ({ status: 'success' | 'progress' | 'delay' | 'error' }) and the SDK
  emits from it in emitFromResult
- adapter.emit is now protected; connectors no longer emit by hand, and
  double-emitting is no longer possible

State:
- split into base, extraction, and loading state, mirroring the adapters

Public API:
- the root barrel now names every export explicitly instead of
  re-exporting whole modules, so the public surface is one reviewable
  file and internals stay internal
- formatAxiosError and serializeAxiosError are replaced by a single
  serializeError

Carries #224 (pre_extraction_item_counts) over to the new contract.
Since emit is no longer public, the counts are supplied through the
ExtractionAdapter.preExtractionItemCounts setter, mirroring the existing
artifacts accessor, and the SDK attaches them to the metadata-done
event. Covered by a dummy-connector test asserting the emitted body.

Tests are rewritten against the new adapters and state.

BREAKING CHANGE: connectors must migrate to the split adapters and
process functions, return a TaskResult from their task instead of
emitting, and adopt the split state. Symbols that were previously
reachable through `export *` but are not in the new barrel are no
longer importable from the package root. Connectors that reported
pre_extraction_item_counts via adapter.emit must set
adapter.preExtractionItemCounts instead. See MIGRATION.md.
MIGRATION.md is the self-contained v1 -> v2 spec: an execution plan
plus sections 1-16 covering the package rename, the split adapters and
process functions, the TaskResult emit contract, the state split, the
narrowed public barrel, the removed deprecated and http surfaces, and
the jest mock updates.

It ships in the npm tarball so tooling can read the copy that matches
the installed version instead of guessing against the latest docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant