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

@oarepo/invenio-api-vue-composition

v1.0.9

Published

## Run demo ``` docker-compose -f docker-compose-server.yml up yarn serve ``` ## Installation

Downloads

17

Readme

@oarepo/invenio-api-vue-composition

Run demo

    docker-compose -f docker-compose-server.yml up
    yarn serve

Installation

    yarn add @vue/composition-api
    yarn add @oarepo/vue-query-synchronizer
    yarn add @oarepo/invenio-api-vue-composition
    // main.js
    Vue.use(VueCompositionAPI)
    Vue.use(VueQuerySynchronizer, {
        debug: true,
        router: router
    })

Common usage - API passed as props to your component

Collection and record viewers

Wrap your components when you add them into routes:

export const routes = [
    
    // note: record needs to be the first because of its path 
    record({
        name: 'record-viewer-editor',
        // path is implicitely '/${collectionCode}'  -we want the records in the root, so have to create it manually
        path: '/:recordId',
        collectionCode: 'records',
        component: RecordViewer
    }),

    collection({
        name: 'record-list',
        path: '/',
        collectionCode: 'records',
        component: CollectionViewer,
        recordRouteName: 'record-viewer'
    })
] 

This will inject a wrapper component (invisible in DOM tree) that fetches the collection/record, shows the loading status and possible errors, on success pass records and facets to your component and reacts to facet selection, pagination and search as emitted by your component.

A sample implementation of CollectionViewer is in the demo.

Facet shows that each facet contains a reactive model that can be used to directly toggle the facet on/off.

For a record viewer see RecordViewer

See the collection API docs and record API docs for possible parameters and for an extensive list of properties that are passed to your component.

API access

You can have an access to API either via the wrappers above - but they always fetch the data before your component gets called - or via the "api" wrappers:

export const routes = [
    collectionApi({
        name: 'record-creator',
        path: '/create',
        collectionCode: 'records',
        component: RecordCreator
    }),
] 

This wrapper just creates the API, pre-populates it with the baseUrl and collection code and passes control (with all props) to your component.

It is usable for example, for creating new records as shown above, as there is no need to load the collection when a new record is created within it.

See collection API docs for details

Composable API

The collectionApi or recordApi props passed to your component are return values of Composable API functions useInvenioCollection and useInvenioRecord.

If you want you can use them directly without the wrapper components ( but always directly in the setup function, you can not initialize them later, as in event handlers):

<template>...</template>
<script>
import {useInvenioCollection} from '@oarepo/invenio-api-vue-composition'

export default {
    function setup(props, ctx) {
        {
            error,
            facets,
            records,
            load
            // see the docs for other options here
        } = useInvenioCollection('/api')

        load('records')
        return {
           error, facets, records
        }
    }
}
</script>

More documentation is at API docs