Socket
Socket
Sign inDemoInstall

@aws-amplify/datastore

Package Overview
Dependencies
28
Maintainers
9
Versions
1586
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @aws-amplify/datastore

AppSyncLocal support for aws-amplify


Version published
Weekly downloads
587K
decreased by-1.77%
Maintainers
9
Created
Weekly downloads
Ā 

Readme

Source

INTERNAL USE ONLY

This package contains the AWS Amplify DataStore category and is intended for internal use only. To integrate Amplify into your app, please use aws-amplify.

AWS Amplify DataStore Docs

Amplify DataStore provides a programming model for leveraging shared and distributed data without writing additional code for offline and online scenarios, which makes working with distributed, cross-user data just as simple as working with local-only data.


packageversionopen issuesclosed issues
@aws-amplify/datastorenpmOpen IssuesClosed Issues

šŸ‘‹ Note For Contributers: šŸ‘‹

Please update these docs any time you find something that is incorrect or lacking. In particular, if a line in the docs prompts a question, take a moment to figure out the answer, then update the docs with the necessary detail.


Getting Started

Before you start reading through these docs, take a moment to understand how DataStore works at a high level. Additionally, we recommend first reading through docs.amplify.aws. The purpose of these docs is to dive deep into the codebase itself and understand the inner workings of DataStore for the purpose of contributing. Understanding these docs is not necessary for using DataStore. Lastly, before reading, take a look at the diagrams below.


Docs


Diagrams

Note: relationships with dotted lines are explained more in a separate diagram.

How the DataStore API and Storage Engine Interact

flowchart TD
  %% API and Storage
  api[[DS API]]-- observe -->storage{Storage Engine}
  storage-- next -->adapter[[Adapter]]
  adapter-->db[[Local DB]]
  db-->api
  sync[[Sync Engine*]]-.-storage
  sync-.-appSync[(AppSync)]

How the Sync Engine Observes Changes in Storage and AppSync

Note: All green nodes belong to the Sync Engine.

* Merger first checks outbox

** Outbox sends outgoing messages to AppSync

flowchart TD

  subgraph SyncEngine
  index{index.ts}-- observe -->reach[Core reachability]

  subgraph processors
  mp[Mutation Processor]
  sp[Subscription Processor]
  syp[Sync Processor]
  end

  reach--next-->mp[Mutation Processor]
  reach--next-->sp[Subscription Processor]
  reach--next-->syp[Sync Processor]

  subgraph outbox / merger
  outbox[Outbox]
  merger[Merger]
  outbox---merger
  end

  end

  api[DS API]-.->storage
  mp-- 1. observe -->storage{Storage Engine}
  storage-- 2. next -->merger[merger*]-- next -->storage


  sp-- observe -->appsync[(AppSync)]
  appsync-- next -->sp

  syp---appsync

  mp-->outbox[outbox**]

  appsync<--->outbox
  %% styling
  classDef syncEngineClass fill:#8FB,stroke:#333,stroke-width:4px,color:#333;
  class index,mp,sp,syp,merger,outbox syncEngineClass;

Project Structure

amplify-js/packages/datastore/src
ā”œā”€ā”€ authModeStrategies
ā”‚   ā””ā”€ā”€ defaultAuthStraegy.ts
ā”‚   ā””ā”€ā”€ index.ts
ā”‚   ā””ā”€ā”€ multiAuthStrategy.ts
ā”œā”€ā”€ datastore
ā”‚   ā””ā”€ā”€ datastore.ts # Entry point for DataStore
ā”œā”€ā”€ predicates
ā”‚   ā””ā”€ā”€ index.ts
ā”‚   ā””ā”€ā”€ sort.ts
ā”œā”€ā”€ ssr
ā”œā”€ā”€ storage # Storage Engine
ā”‚   ā””ā”€ā”€ adapter # Platform-specific Storage Adapters
ā”‚      ā””ā”€ā”€ getDefaultAdapter
ā”‚      ā””ā”€ā”€ AsyncStorageAdapter.ts
ā”‚      ā””ā”€ā”€ AsyncStorageDatabase.ts
ā”‚      ā””ā”€ā”€ index.ts
ā”‚      ā””ā”€ā”€ IndexedDBAdapter.ts
ā”‚      ā””ā”€ā”€ InMemoryStore.native.ts
ā”‚      ā””ā”€ā”€ InMemoryStore.ts
ā”‚   ā””ā”€ā”€ storage.ts # Entry point for Storage
ā”œā”€ā”€ sync # Sync Engine
ā”‚   ā””ā”€ā”€ dataStoreReachability
ā”‚      ā””ā”€ā”€ index.native.ts
ā”‚      ā””ā”€ā”€ index.ts
ā”‚   ā””ā”€ā”€ processors # Sync Engine Processors
ā”‚      ā””ā”€ā”€ mutation.ts
ā”‚      ā””ā”€ā”€ subscription.ts
ā”‚      ā””ā”€ā”€ sync.ts
ā”‚   ā””ā”€ā”€ datastoreConnectivity.ts # Subscribe to reachability monitor
ā”‚   ā””ā”€ā”€ index.ts # Entry point for Sync Engine
ā”‚   ā””ā”€ā”€ merger.ts # doc
ā”‚   ā””ā”€ā”€ outbox.ts # doc

Other Resources:

FAQs

Last updated on 29 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with āš”ļø by Socket Inc