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

@md_team/strapi-share

v0.3.4

Published

- [Содержание](#содержание) - [О проекте](#о-проекте) - [Перенос типов из Strapi](#перенос-типов-из-strapi) - [StrapiModelUID](#strapimodeluid) - [Strapi.Types](#strapitypes) - [Model](#model) - [Payload](#payload) - [Response](#response)

Readme

Содержание

О проекте

В проекте представлено решение, помогающее получить доступ к типам Strapi извне.

Проект построен на базе Strapi 5.

Перенос типов из Strapi

  1. Создать в корне проекта файл copyTypes.ts / copyTypes.js
// copyTypes.ts

import { copyStrapiTypes } from '@md_team/strapi-share';

copyStrapiTypes({
    // путь до папки проекта Strapi
    strapiPath: 'path/to/strapi',
    // путь, куда будут помещены сгенерированные типы
    destPath: './src/types/strapi',
});
// copyTypes.js

const copyStrapiTypes = require('@md_team/strapi-share').copyStrapiTypes;

copyStrapiTypes({
    // путь до папки проекта Strapi
    strapiPath: 'path/to/strapi',
    // путь, куда будут помещены сгенерированные типы
    destPath: './src/types/strapi',
});
  1. Добавить скрипт в package.json для .ts или .js файла
{
    "scripts": {
        "types": "node copyTypes.js",
        "types": "npx ts-node copyTypes.ts"
    }
}
  1. Запустить скрипт в терминале
npm run types

StrapiModelUID

Создание типа, описывающего UID моделей. Может использоваться для помещения определенного UID модели в константу

import { UID } from '@strapi/strapi'

type StrapiModelUID = UID.ContentType | UID.Component;

Если в Strapi создан хотя бы один компонент, можно использовать UID.ContentType | UID.Component, иначе необходимо использовать UID.ContentType

Strapi.Types

Для правильного подтягивания типов необходимо установить пакет @strapi/strapi

Model

Получение типа модели

import { Strapi } from '@md_team/strapi-share';

type User = Strapi.Types.Model<'plugin::users-permissions.user'>;

Payload

Получение обработанного типа модели для его использования в POST/PUT-запросах

type UserPayload = Strapi.Types.Payload<'plugin::users-permissions.user'>

Response

Получение типа ответа Strapi на запрос экземпляра модели

type UserApi = Strapi.Types.Response<'plugin::users-permissions.user'>;

ResponseCollection

Получение типа ответа Strapi на запрос коллекции моделей Strapi по UID

type UsersApi = Strapi.Types.ResponseCollection<'plugin::users-permissions.user'>;

Wrapper

Оборачивает данные в { data: T }, имитируя формат body POST/PUT-запросов, необходимый для создания и обновления данных в Strapi

import { Strapi } from '@md_team/strapi-share';

type User = Strapi.Types.Model<'plugin::users-permissions.user'>;
type UserUpdateCustom = Strapi.Types.Wrapper<Pick<User, 'age'>>
// Итого получим: { data: { age: number } }

Strapi.Utils

Params

Типизирует объект параметров, который можно прокинуть, например, в params у Axios, который далее будет переведен в формат, принимаемый Strapi.

Типизация поддерживает основные методы работы с данными, приходящими из Strapi через REST API:

  • filters - фильтрация
  • populate - добавление вложенных полей
  • sort - сортировка
  • fields - выбор полей
  • pagination - настройка пагинации
import { Strapi } from '..';

const params: Strapi.Utils.Params<'plugin::users-permissions.user'> = {
    filters: {
        age: {
            $eq: 30,
        },
        name: 'Steve',
    },
    populate: {
        user_info: true,
    },
    sort: {
        username: 'desc',
    },
    fields: ['id', 'documentId', 'age', 'username', 'name'],
    pagination: {
        page: 1,
        pageSize: 5,
    },
};

Интеграция с нашими продуктами

@md_team/api-factory

ApiStrapiTypes создает типы, которые можно использовать для типизации ApiFactory на базе стандартных ответов Strapi

import { Api, ApiFactory } from '@md_team/api-factory';
import { ApiStrapiTypes } from '@md_team/strapi-share';

// Использование утилиты для создания кастомных типов под Strapi
type ApiTypes = ApiStrapiTypes<'plugin::users-permissions.user'>;

// ApiFactory
const { apis } = new ApiFactory({
    httpConfig: {
        baseURL: 'https://admin.strapi.io/api'
    },
    apisConfig: {
        usersApi: {
            apiClass: Api<ApiTypes>,
            endpoint: 'users',
        },
    },
});