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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@izara_frontend/service-schemas

v1.0.6

Published

Quick guide — initialize the schema tools and use the provided hooks (e.g. `getObjectLinks`).

Downloads

310

Readme

@izara_frontend/service-schemas

Quick guide — initialize the schema tools and use the provided hooks (e.g. getObjectLinks).

Requirement

  • react: "^18.3.1",
  • react-dom: "^18.3.1"

Purpose

  • This package exports helpers and hook-like functions to fetch and work with service object schemas (links, object schemas, validators, etc.).
  • It expects you to initialize a small runtime integration once (injecting reducers and the posts API) and then use the exported functions inside components or utility modules.

Install

  • This package is intended to be consumed from your monorepo packages. Example (if published):
npm install @izara_frontend/service-schemas

Initialization (required once, before using hooks)

  • Call initGetSchemaTools in a parent component or application bootstrap code. The initGetSchemaTools call persists across components and only needs to be done once per app lifetime.

Example (typical place: app entry or parent module):

import { initGetSchemaTools } from "@izara_frontend/service-schemas";

// These values come from your app: an injection helper, the Redux store, and your RTK Query postsApi factory.
initGetSchemaTools({
  injectReducer: injectReducerV2,
  store,
  createPostsApi: createPostsApiV2
});
  • injectReducer should be a function that knows how to inject a reducer into your store (your app's implementation). If you use a helper injectReducerV2 in your repo, pass it.
  • store is the Redux store instance used by your app.
  • createPostsApi is the factory that creates the postsApi used by the package; pass your app variant if you have one.

Using exported helpers (example: getObjectLinks)

  • Each helper follows a small pattern: when called it returns a tuple and a callable object you can use directly.

Typical usage inside a component:

import React, { useEffect } from 'react';
import { getObjectLinks } from '@izara_frontend/service-schemas';

export default function MyComponent() {
  // call at top-level of component
  const [objLinksResults, getObjectLinksFn, objLinksOption] = getObjectLinks();

  // objLinksResults and objLinksOption are React state objects managed by the hook
  useEffect(() => {
    async function load() {
      // "normal" call: the helper will update objLinksResults and objLinksOption state
      const [schema, errorsFound] = await getObjectLinksFn({ serviceTag: 'xx', objectType: 'xx' });
      // schema and errorsFound are the results of this call
    }
    load();
  }, []);

  return <div>...render using objLinksResults...</div>;
}

Direct-trigger usage via .initiate (RTK-style)

  • Some helper callables expose an .initiate(params) method. This returns a promise with the response and does NOT automatically push results into the returned React state tuple — it gives the result directly.
// using initiate to get the value directly
const [schema, errorsFound] = await getObjectLinksFn().initiate({ serviceTag: 'xx', objectType: 'xx' });
// This returns the fetched value immediately; it does not mutate objLinksResults / objLinksOption state.

Difference between "normal" and .initiate()

  • Normal call (calling getObjectLinksFn(params)):
    • Updates the returned objLinksResults and objLinksOption React state (so components re-render and you can read them directly).
    • Useful when you want to keep the result in component state and react to changes.
  • .initiate(params) call:
    • Returns the response directly (a promise). It is useful when you want a one-off result (for example inside an async handler) and don't need the returned hook state to update.
    • That call is usually useful for programmatic flows or server-side usage where you only need the returned value.

Return shapes / tuple explained

  • The pattern is typically:
const [resultsState, actionFn, optionsState] = someGetFunction();
  • resultsState — React state managed by the helper: contains last response (schema, data) and flags.
  • actionFn — a callable function you can call with params to fetch. Also may expose .initiate() for direct returns.
  • optionsState — optional object with metadata such as isLoading, isError, status, etc.

Examples

  • Normal usage (keeps result in state):
const [objLinksResults, getObjectLinksFn, objLinksOption] = getObjectLinks();

useEffect(() => {
  getObjectLinksFn({ serviceTag: 'shop', objectType: 'product' });
}, []);

// read results from objLinksResults
  • One-off result via .initiate (direct):
const [, getObjectLinksFn] = getObjectLinks();

async function fetchNow() {
  const [schema, errorsFound] = await getObjectLinksFn().initiate({ serviceTag: 'shop', objectType: 'product' });
  // use schema directly
}

Notes & best practices

  • Initialize initGetSchemaTools before using any of the exported helpers. A safe place is your app root or a parent component that mounts early.
  • Place the getObjectX call (the someGetFunction() call) at top-level of your React component (not inside conditionals) so hooks rules are respected.
  • Many helpers accept different params — check the helper signature you use. The package provides multiple fetch helpers (links, object schema, validators, etc.) each with their own param set.
  • .initiate() will not update the hook-managed state; use it when you need a single direct result.

Troubleshooting

  • If results are not appearing in resultsState after a normal call:
    • Ensure initGetSchemaTools was called with the correct store and createPostsApi.
    • Ensure the helper is used inside a component where the hook can run.
  • If you get multiple or stale values, check cache keys and parameters passed to the helper.