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

@runmorph/core

v0.0.22

Published

morph-core/ ├── src/ │ ├── Morph.ts │ ├── Connection.ts │ ├── Session.ts │ ├── Resource.ts │ ├── clients/ │ │ ├── BaseClient.ts │ │ ├── ConnectionClient.ts │ │ ├── SessionClient.ts │ │ └── ResourceClient.ts │ ├── authorization/ │ │ ├── BaseAuth.ts │ │ ├──

Readme

Core SDK Strucutre

morph-core/ ├── src/ │ ├── Morph.ts │ ├── Connection.ts │ ├── Session.ts │ ├── Resource.ts │ ├── clients/ │ │ ├── BaseClient.ts │ │ ├── ConnectionClient.ts │ │ ├── SessionClient.ts │ │ └── ResourceClient.ts │ ├── authorization/ │ │ ├── BaseAuth.ts │ │ ├── OAuth2/ │ │ │ ├── OAuth2Client.ts │ │ │ ├── AuthorizationCodeFlow.ts │ │ │ └── TokenManager.ts │ │ ├── APIKey/ │ │ │ └── APIKeyAuth.ts │ │ ├── BasicAuth/ │ │ │ └── BasicAuth.ts │ │ └── PKE/ │ │ └── PKEAuth.ts │ ├── types/ │ │ ├── index.ts │ │ ├── connection.ts │ │ ├── session.ts │ │ ├── resource.ts │ │ └── error.ts │ ├── utils/ │ │ ├── encryption.ts │ │ ├── httpClient.ts │ │ └── iterator.ts │ ├── errors/ │ │ ├── MorphError.ts │ │ ├── ConnectionError.ts │ │ └── AuthError.ts │ └── index.ts ├── tests/ │ ├── unit/ │ ├── integration/ │ └── mocks/ ├── examples/ │ ├── basic-usage.ts │ ├── connection-management.ts │ ├── session-handling.ts │ ├── resource-operations.ts │ └── auth-methods/ │ ├── oauth2-example.ts │ ├── api-key-example.ts │ ├── basic-auth-example.ts │ └── pke-auth-example.ts ├── docs/ │ ├── API.md │ ├── AUTHENTICATION.md │ └── CONTRIBUTING.md ├── package.json ├── tsconfig.json ├── .eslintrc.js ├── .prettierrc ├── CHANGELOG.md └── README.md

SDK Usage

Creating an instance of Morph client:

// Import runmorph packages
import { NextMorph } from "@runmorph/framework-nextjs";
import { PrismaAdapter } from "@runmorph/adapter-prisma";
import HubSpot from "@runmorph/connector-hubspot";
import Salesforce from "@runmorph/connector-salesforce";

// Import from current project
import { prisma, PrismaClient, Prisma } from "@repo/database/server";

// Create a morph instance and export it
export const morph = NextMorph({
  database: {
    adapter: PrismaAdapter(prisma),
  },
  connectors: [HubSpot, Salesforce],
});

Creating and authorizing a new connection:

const { data, error } = await morph
  .connection({
    connectorId: "salesforce",
    ownerId: "user123",
  })
  .create({
    authorization: {
      scopes: ["read_contacts", "write_opportunities"],
      setting: {
        environment: "sandbox",
      },
    },
    operations: ["generic.contact.list", "crm.opportunity.create"],
  });

/* data
{
	"object": "connection",
  "connectorId": "string",
  "ownerId": "string",
  "operations": ["string"],  
  "authorization": {	  
	  "scopes": ["string"],
	  "settings": {
		  "environment":"sandbox"
	  }
	}
  "status": "string",
  "createdAt": "string",
  "updatedAt": "string"
}
*/
/* error
{
	"object": "error",
	"type": "MORPH_....",
	"message": Some message"
}
*/

Listing and paginating through contacts from the server:

// No await as this just store the connectorId and ownerId in the Conection class it returns
const connection = morph.connection({
  connectorId: "salesforce",
  ownerId: "user123",
});

const contactIterator = connection.resource("generic.contact").list({
  limit: 50,
  filter: {
    first_name: "john",
  },
  sort: "createdAt:desc",
  iterator: true,
});

for await (const contact of contactIterator) {
  console.log("Contact:", contact);
}

Creating a new opportunity from the server:

const connection = morph.connection({
  connectorId: "salesforce",
  ownerId: "user123",
});

const { data, error } = await connection.resource("crm.opportunity").create({
  name: "Big Deal Q3",
  amount: 100000,
  closeDate: "2024-09-30",
  stage: "Proposal",
});

Updating a contact from the server::

const connection = morph.connection({
  connectorId: "salesforce",
  ownerId: "user123",
});

const { data, error } = await connection
  .resource("generic.contact")
  .update("cont456", {
    firstName: "Jane",
    lastName: "Doe",
    email: "[email protected]",
  });

Deleting a resource from the server:

const connection = morph.connection({
  connectorId: "salesforce",
  ownerId: "user123",
});
await connection.resource("generic.contact").delete("cont789");

Creating a session for an existing connection:

const { data, error } = await morph.session.create({
  connection: {
    connectorId: "salesforce",
    ownerId: "user123",
  },
  expiresIn: 3600,
});
/* data
{
	"object": "session",
	"connection": {
		"connectorId": "string",
	  "ownerId": "string"
	},
	"sessionToken": "string",
  "expiresAt": "string"
}
*/
/* error
{
	"error": "MORPH_CONNECTION_DOES_NOT_EXIST",
	"message": "No connection exist for 'salesforce' and 'user123'. If you meant to create an intent connection, add the 'connectionIntent' attribute to your session creation."
}
*/

Creating a session for a connection not yet create – but can be used to create it:

const { data, error } = await morph.session.create({
	connectionItent: {
		connectorId: "string",
	  ownerId: "string"
	  authorization: {
	    scopes: ['read_contacts', 'write_opportunities'],
	    "setting": {
		    "environment":"sandbox"
		  }
	  },
    operations: ['generic.contact.list', 'crm.opportunity.create']
  },
	expiresIn: 3600,
});
/* data
{
	"object": "session",
  "connectionIntent":{
	  "connectorId": "string",
	  "ownerId": "string",
	  "operations": ["string"],
	  "authorization": {
		  "scopes": ["string"],
		  "settings": {
			  "environment":"sandbox"
		  }
		}
	},
	"sessionToken": "string",
  "expiresAt": "string"
}
*/

Using a session token for operations in fronted / client app:

const sessionToken = "jwtToken";
const connection = morph.connection({ sessionToken });

// In case of an connectionIntent session, this will create the actual connection
const { data, error } = await connection.authorize();
/* data
{ 
	"object": "connection.authorize",
	"connectorId": "string",
  "ownerId": "string",
  "status": "string",
  "authorizationUrl": "string"
}
*/

if (authorizationUrl) {
  // open pop up windows with authorizationUrl
}

const { data, error } = await connection.resource("crm.opportunity").list({
  filter: { stage: "Closed Won" },
  sort: "amount:desc",
  iterator: false,
});

/* data
[{ "object":"resource", ...}, {...}]
*/