npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@stackone/datasync

v1.9.3

Published

DataSync document model, s1query grammar, OpenSearch query builders and client construction

Readme

@stackone/datasync

Description

The DataSync document model and s1query grammar, extracted from unified-cloud-api so its read and write paths and the datasync-read-handler Lambda can share one source of truth:

  • documents — flatten/unflatten synced items (with overflow, via flattenRecord/restoreRecord), infer field types, allocate field-map slots.
  • query / aggregations — validate and translate the caller-supplied s1query filter, search, source, sort and aggs into OpenSearch DSL over aliased columns. search covers every string field unless the caller scopes it to the fields its policy leaves visible. A terms aggregation with no bucket aggregation above or below it gets a shard_size of at least 1000, so its counts are exact under concurrent segment search while each slice holds at most that many values.
  • limits — page bounds shared by every surface.
  • aggregation-buckets — keeps a synced aggregation under OpenSearch's search.max_buckets, which a narrow histogram interval or nested terms/range can exceed for every tenant on the cluster. needsBucketProbe says whether the request alone proves it fits; when it does not, run buildBucketProbeBody (a size-0 search under the same scope and filter), read its response with readBucketProbe(aggs, response.aggregations), which throws on a missing or malformed result rather than reading it as empty, then assertAggBucketBudget rejects anything over MAX_AGG_BUCKETS. isTooManyBucketsError recognises, in the thrown error or the returned response, the 503 OpenSearch still answers if data grew after the probe; map it to tooManyBucketsRejection() rather than a server error. Send both the probe and the aggregation with the client option ignore: [503] so it hands that response back instead of retrying it and marking the node dead. That option also stops the client throwing, so any other 503 must still be raised as an outage: isTooManyBucketsError matches on the cause, never the status.
  • opensearch — tenant-scoped search/aggregation body builders and response predicates.
    • describeOpenSearchRejection returns { message, parameters, reason } only; the consumer adds its own transport fields (error, statusCode), unlike SyncedQueryRejection.toResponse() which is complete.
    • buildAggregationBody takes TranslatedAggregations from translateAggs, not a raw object, so an untranslated aggregation cannot reach the request.
    • buildSearchBody also takes optional aggregations, returning a page of hits and the aggregations over the same query in one request. Guard it like an aggregation: bucket probe first, ignore: [503].
    • Both body builders accept only translator outputs — TranslatedQuery, TranslatedSource, TranslatedSort, FullTextQuery and TranslatedAggregations — never raw caller objects.
  • read-contract — the wire contract between unified-cloud-api and the datasync-read-handler Lambda: DataSyncReadEvent/DataSyncReadResult types plus a zod schema for each direction. dataSyncReadEventSchema validates the event's shape and per-field bounds; the skip + pageSize window is assertPageWindow's job, called separately. dataSyncReadResultSchema validates what comes back, and is deliberately not .strict() — the Lambda deploys independently and may run ahead, so an unknown result key is stripped rather than failing every read during the skew window. Its two arms are mutually exclusive, so a response carrying both data and error is rejected rather than silently resolved to one of them. This package pins [email protected] while unified-cloud-api uses zod 4. Each side calls these schema instances' own parse/safeParse, which is safe; what a future consumer must not do is import a schema from here and compose or merge it with a zod-4 one.
  • opensearch-client — buildClientOptions, the pure env-driven OpenSearch client construction shared by unified-cloud-api and the datasync-read-handler Lambda: IAM SigV4, either signed directly with the caller's own task/execution role or — only when OPENSEARCH_MASTER_ROLE_ARN is set — via an assumed master role, or basic auth otherwise.
  • errors — SyncedQueryRejection, the framework-free 400 every consumer maps to its own transport.

This package uses the tech stack provided by the Connect Monorepo global setup. Please check the root README for more information.

Depth limit and overflow

flattenItem stops at depth 5 (an object costs 1, an array of objects 2) and drops anything deeper; arrays of arrays pass through it as-is. flattenRecord keeps both: each such subtree is stored whole in overflow, keyed by its flattened path, and restoreRecord merges it back on read. Overflow is not indexed: filter, sort and aggs reject paths past the limit, and source selects the whole subtree at the cut point. maxOverflowBytes caps a record's overflow; over it, the largest paths are dropped first. An array of arrays within the depth limit has no column, so it is returned with the record but cannot be selected through source; past the limit it sits inside the overflow subtree a deep source path selects.