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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@methodexists/me-core

v0.1.2

Published

Core functionality for MethodExists apps

Downloads

11

Readme

me-core

Core functionality for MethodExists apps.

Usage

Init core module

core.init({
  apiService: APIService, // api service module with REST methods
  getLocale: () => app._store.getState().app.locale, // getter of the current app locale (for error messages i18n)
});

apiService is required for me-core functioning. getLocale is optional. 'en-US' locale is used by default.

Register formulas in records model

import recordsModel, { init as recordsModelInit } from '~/models/records';

app.model(recordsModel);
recordsModelInit({
  formulas: {
    users: record => ({
      ...record,
      generatedByFormula: Math.random(),
    }),
  },
});

Provide options into notifications model

import notificationsModel, { init as notificationsModelInit } from '~/models/notifications';
import icon from '~/assets/images/icon.png';
import { profileUsernameSelector } from '~/selectors';

app.model(notificationsModel);
notificationsModelInit({
  icon,
  profileUsernameSelector,
});

Examples

ListProvider passing props:

<ListProvider namespace="users" table="users" primaryKey="username">
  {({ list, isLoading } => (
    isLoading ? <div>Loading...</div> : <div>{ list.map(renderListItem) }</div>
  )}
</ListProvider>

API

<ListProvider /> component

import { ListProvider } from 'me-core';

| Prop | Type | Default | Description | --------------| ----------------|-------------------------|------------ | * namespace | string | | | * table | string | | | * children | element or func | | If children is func then ListProvider will pass { isLoading, list, total, schema } as arguments | filters | object | {} | | esQuery | object | undefined | | sort | object | { 'name.raw': 'asc' } | | limit | number | 20 | | primaryKey | string | 'id' | | source | object | |

<RecordProvider /> component

import { RecordProvider } from 'me-core';

| Prop | Type | Default | Description | -------------- | --------------- | -------- | ------------ | * namespace | string | | | * table | string | | | * children | element or func | | If children is func then RecordProvider will pass { isLoading, record, schema } as arguments | primaryKey | string | 'id' | | id | string | |

<AuditLogProvider /> component

import { AuditLogProvider } from 'me-core';

| Prop | Type | Description | -------------- | --------------- | ------------ | * namespace | string | | * table | string | | * children | element or func | If children is func then provider will pass { isLoading, log, schema } as argument | * id | string |

Selectors

recordHasUnsavedChangesSelector

Compares metafields lastSynced and lastChanged to figure out if the record was changed and not saved. lastSynced field updated on any Save/Fetch operation (setRecord action). lastChanged field updated on any Update operation (update action).

Models

lists

Lists model works with /table API by default. If the tableName is users it calls /user API. To use /dynamo API you need to set params.useDynamo = true.

Contributing

See CONTRIBUTING.md for how to develop a component.