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

@bast1oncz/entities

v4.1.8

Published

Local and remote graphql entity handling

Downloads

183

Readme

@bast1oncz/entities

This library offers complex features and a specific workflow with entities. This means frontend entities (javascript objects) but remote entities (graphql objects) as well. Conceptionally, it is not an problem to implement other remote services as well.

Take example of this complex entity: Product. Entity demo

All of this was generated using just this code:

function ProductDetailPage() {
    const {id} = useParams()
    
    const categoryOptions = useProductCategoryOptions()
    const countryOptions = useCountryOptions()
    
    return (
        <DetailPage
            id={id}
            type={id ? DetailType.UPDATE_DETAIL : DetailType.CREATE_DETAIL}
            listRoute="PRODUCT_LIST"
            detailRoute="PRODUCT_DETAIL"
            loading={!categoryOptions || !countryOptions}
            entityFragment={ProductFragmentDoc}
            filterName="ProductFilterInput"
            autoCreate
        >
            <Grid container spacing={4}>
                <Grid item md={6}>
                    <TranslatedStringField sourceKey={nameSourceKey} label="Name" validate={translatedNameValidator}/>
                </Grid>
                <Grid item md={6}>
                    <TranslatedStringField sourceKey={shortDescriptionSourceKey} label="Short description"
                                           validate={translatedShortDescriptionValidator}/>
                </Grid>
                <Grid item md={6}>
                    <StringField sourceKey="urlReference" label="Url reference" validate={urlReferenceValidator}/>
                </Grid>
                <Grid item md={6}>
                    <NumberField sourceKey="vatRate" label="Vat rate" format={PERCENT_FORMAT} validate={vatValidator} />
                </Grid>
                <Grid item md={6}>
                    <NumberField sourceKey="weight" label="Weight [kg]" validate={requiredValidator}
                                 format={WEIGHT_FORMAT}/>
                </Grid>
                <Grid item md={6}>
                    <ImageField sourceKey="mainImage" label="Main image" deletable/>
                </Grid>
                <Grid item md={6} container spacing={2}>
                    <Grid item xs={12}>
                        <SelectField sourceKey="category" label="Category"
                                     options={categoryOptions} deletable/>
                    </Grid>
                    <Grid item xs={12}>
                        <BooleanField sourceKey="adulthoodRequired" label="Adulthood required"/>
                    </Grid>
                </Grid>
                <Grid item xs={12}>
                    <ItemListField sourceKey="quotes" label="Quotes" orderable>
                        <SelectField sourceKey="country" label="Country" options={countryOptions}
                                     validate={requiredValidator}/>
                        <NumberField sourceKey="unitPrice.value" updateKey="unitPrice" label="Unit price"
                                     format={currencyFormat}
                                     validate={requiredValidator}/>
                    </ItemListField>
                </Grid>
                <Grid item xs={12}>
                    <TranslatedHtmlField sourceKey={fullDescriptionSourceKey} label="Full description" />
                </Grid>
            </Grid>
            <DetailActions>
                <DetailDeleteEntity/>
            </DetailActions>
        </DetailPage>
    )
}

Sync Concept

This library uses sync concept, so that every change by user is immediately synchronized with the store place of an entity. If an error occurs, user can lose maximum of 1 filled field's work. Aditionally, the storage place (such as api) can contain more complex logic to change other entity fields, which is immediately loaded on the frontend side.

Advantages

  • Do not let user lose data
  • Generate interactive entity editation environments
  • Generate them fast
  • Do not solve repetitive form bugs, because they were already solved for you
  • Save your time

Dependencies

The library is mainly based on react and @bast1oncz pack.

Usage

The use of this library is FREE, but the dependencies are private packages. If you'd like to try it, please contact me at my email.