Basic types & utilities for Strapi v4 and plugin creators

Overview

Strapi v4 - Types & utilities

Basic set of types and utilities for Strapi v4 and plugins creators

GitHub package.json version Monthly download on NPM

A developers goodie for Strapi Headless CMS which provides a basic core set of types & interfaces and generic utilities useful for every plugin creator or team which is extending the core implementation.

What's included?

  • Strapi Core: Basic set of types & interfaces which include Strapi, DB, ContentType and more.
  • Generic utility types: Useful for plugin creators and teams which are extending Strapi.

Installation

(Use yarn to install this dependency within your Strapi project (recommended). Install yarn with these docs.)

yarn add -D strapi-typed@latest

and then use

import { IStrapi } from 'strapi-typed';

Enjoy 🎉

🤝 Contributing

Feel free to fork and make a Pull Request to this project. All the input is warmly welcome!

👨‍💻 Community support

For general help using Strapi, please refer to the official Strapi documentation. For additional help, you can use one of these channels to ask a question:

  • Discord We're present on official Strapi Discord workspace. Find us by [VirtusLab] prefix and DM.
  • Slack - VirtusLab Open Source We're present on a public channel #strapi-molecules
  • GitHub (Bug reports, Contributions, Questions and Discussions)
  • E-mail - we will respond back as soon as possible

📝 License

MIT License Copyright (c) VirtusLab Sp. z o.o. & Strapi Solutions.

Comments
  • feat: custom fields support

    feat: custom fields support

    What did you implement

    • typings of custom fields

    How can I test it?

    • symbolic link repository to node_modules of your plugin/server
    • types are present on IStrapi
    opened by CodeVoyager 0
  • fix: db queries

    fix: db queries

    What did you implement

    • duplicates removed
    • less restrictive OR and AND query statements

    How can I test it?

    declare const foo: StrapiDBQuery<{ test: string, notRequired: string }> ;
    
    foo.findMany({
        where: {
            $or: [
                { test: { $startsWith: "F" } },
                {
                    test: "FOO",
                }
            ] 
            
        }
    })
    

    Should be valid

    bug 
    opened by CodeVoyager 0
  • fix: where clause was too strict and demands all properties

    fix: where clause was too strict and demands all properties

    Fixes issue for constructions like:

       strapi.db
          .query<CommentReport>(getModelUid("comment-report"))
          .updateMany({
            where: {
              $and: [
                { id: ids },
                { related: commentId }
              ]
            },
            data: { resolved: true },
          });
    

    Causing error like

    Type '{ id: Id[]; }' is missing the following properties from type 'Record<keyof CommentReport, WhereOperator<Primitive>>': related, content, reason, resolved

    That was because $and / $or weren't defined as Partial<Record<...>>

    opened by cyp3rius 0
  • feat: db bulk actions response

    feat: db bulk actions response

    Aligns createMany, updateMany, deleteMany response to the Strapi docs:

    https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/query-engine/bulk-operations.html#createmany

    opened by cyp3rius 0
  • chore: controllers typings

    chore: controllers typings

    What did you implement

    • extend typings of strapi controller

    How can I test it?

    • describe a controller with new typings
    • provide generic type arguments
    • controller should have context provided (now with error constructors)
    opened by CodeVoyager 0
  • feat: types for DB Query populate & select

    feat: types for DB Query populate & select

    Let populate work by three different and supported ways:

    • boolean like populate: true
    • array like populate: ['field1', 'field2']
    • object with field names of query type (nested) like:
      {
         field: {
             nestedField: { ... }
         }
      }
      

    And introduce the select property to DB query.

    opened by cyp3rius 0
  • feat: content type schema typings

    feat: content type schema typings

    What did you implement

    • typings for strapi's content type definition

    How can I test it?

    • define a content type schema like:
    export const foo: StrapiContentTypeSchema<
      "firstName" | "lastName" | "age" | "profilePicture" | "friends"
    > = {
      attributes: {
        age: {
          type: "integer",
        },
        firstName: {
          type: "string",
          required: true,
        },
        lastName: {
          type: "string",
          required: true,
        },
        friends: {
          type: "relation",
          relation: "manyToMany",
          target: "api::some.other",
        },
        profilePicture: {
          type: "media",
          allowedTypes: ["images", "videos"],
        },
      },
      info: {
        description: "",
        displayName: "Foo",
        pluralName: "Foos",
        singularName: "Foo",
      },
      kind: "collectionType",
      options: {},
    };
    
    • check if all specified fields are required (should be)
    • check if validation/suggestions change on type specification
    opened by CodeVoyager 0
  • feat: webhooks patch for core

    feat: webhooks patch for core

    Summary

    Typings for all parts of strapi core related to webhooks.

    Testing

    There should be no errors when using the below snippet.

    const webhookBody = {
      name: 'test_name',
      type: '',
      url: 'http://localhost:3000',
      headers: {},
      events: [],
      enabled: false,
    };
    
    const webhooks = await strapi.webhookStore.findWebhooks();
    const webhook = await strapi.webhookStore.findWebhook(1);
    const newWebhook = await strapi.webhookStore.createWebhook(webhookBody);
    const runResponse = await strapi.webhookRunner.run(webhook, 'trigger-test', {});
    strapi.webhookRunner.eventHub.emit('entry.create');
    
    opened by ltsNotMike 0
  • chore: typings declarations for DB querying

    chore: typings declarations for DB querying

    What did you implement?

    • typings for DB querying
    • minor styling issues
    • minor typing improvements (simplification, alternatives)

    How it can be tested?

    Statement below should be valid and auto-completion should, well, autocomplete as you expand on this example.

    type FooUser = {
      firstName: string,
      lastName: string,
      age: number,
    }
    type Foo = TypeResult<
        WhereClause<keyof FooUser, string | number>
    >;
    const foo: Foo = {
        firstName: "Lorem",
        lastName: {
            $containsi: "Ipsum",
        },
        $or: [
            {
                firstName: {
                    $null: true,
                },
            },
            {
                age: {
                    $gt: 9000
                }
            }
        ],
        $and: [
            {
                firstName: "Dull",
                lastName: {
                    $notContains: "Boy",
                },
            },
        ],
    };
    
    opened by CodeVoyager 0
  • refactor: move declarations to ambient modules

    refactor: move declarations to ambient modules

    What did you implement

    • move of declarations to ambient modules to enable interface merging
    • this is a BREAKING CHANGE

    How can I test it?

    • symbolic link repository to node_modules of your plugin/server
    • types are available at @strapi/strapi and @strapi/typed
    opened by CodeVoyager 0
Releases(v1.0.15)
Owner
VirtusLab Open-Source
 VirtusLab Open-Source
Compile-time tests for types. Useful to make sure types don't regress into being overly-permissive as changes go in over time.

expect-type Compile-time tests for types. Useful to make sure types don't regress into being overly-permissive as changes go in over time. Similar to

Misha Kaletsky 82 Jan 8, 2023
TSServer plugin & Utilities for "expanding" TypeScript types

ts-expand-type This repo provides a TS Server plugin which amends quick info to include the fully "expanded" type. "Expanded" means that object inters

Max Stoumen 6 Nov 20, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A "Basic-to-Lisp" compiler. But Basic is not real Basic, and Lisp is not real Lisp.

Basic2Lisp A "Basic-to-Lisp" compiler. But Basic is not real Basic, and Lisp is not real Lisp. Syntax Print-Sth Put some-value to standard output. PRI

Hana Yabuki 5 Jul 10, 2022
Opinionated collection of TypeScript definitions and utilities for Deno and Deno Deploy. With complete types for Deno/NPM/TS config files, constructed from official JSON schemas.

Schemas Note: You can also import any type from the default module, ./mod.ts deno.json import { type DenoJson } from "https://deno.land/x/[email protected]

deno911 2 Oct 12, 2022
🚀 The super app for creators and their audience.

OneSocial It's the ultimate super app for creators and their audience. With OneSocial, you can share your thoughts on blog, manage an active newslette

Subham Sahu 16 Oct 21, 2022
Pay Creators to Promote your Product in $CRYPTO

Next.js + Tailwind CSS Example This example shows how to use Tailwind CSS (v3.0) with Next.js. It follows the steps outlined in the official Tailwind

Satyam Kulkarni 1 Feb 7, 2022
✂ An online image cropper for content creators

Introducing CropScore ✂️ Resolutions and aspect ratios should be the last things you worry about. About ?? CropScore is an online image cropper for co

Madza 49 Dec 30, 2022
Omnuum. All about creators.

Summary There are a lot of NFT projects and PFP projects. But, there are limited tools and services for trying new project. Artists or creator whoever

Omnuum 18 Dec 15, 2022
A website to list tech twitter creators, across the world.

TechCreators A website to list tech twitter creators, across the world. Languages/Tools ????‍?? Demo Check out the website: TechCreators ???? Prerequi

Pushkaraj Kulkarni 18 Jan 3, 2023
Strapi V4 Plugin to schedule publish and depublish actions

Strapi plugin scheduler This plugin allows you to publish and depublish collection types in the future. There are a couple of steps necessary to get t

Webbio 12 Nov 24, 2022
A plugin for Strapi that provides the ability to easily schedule publishing and unpublishing of any content type

strapi-plugin-publisher A plugin for Strapi that provides the ability to easily schedule publishing and unpublishing of any content type. Requirements

daedalus 19 Dec 7, 2022
A plugin for Strapi CMS that adds a preview button and live view button to the content manager edit view.

Strapi Preview Button A plugin for Strapi CMS that adds a preview button and live view button to the content manager edit view. Get Started Features I

Matt Milburn 53 Dec 30, 2022
Experience Lab is a set of utilities that assist in creating instances of Microsoft Energy Data Services, performing data loads, and performing basic management operations.

Experience Lab - Microsoft Energy Data Services Build Status About Experience Lab is an automated, end-to-end deployment accelerator for Microsoft Ene

Microsoft 9 Dec 14, 2022
A plugin for Strapi Headless CMS that provides ability to sign-in/sign-up to an application by link had sent to email.

Strapi PasswordLess Plugin A plugin for Strapi Headless CMS that provides ability to sign-in/sign-up to an application by link had sent to email. A pl

Andrey Kucherenko 51 Dec 12, 2022
A plugin for Strapi that provides the ability to auto slugify a field for any content type

strapi-plugin-slugify A plugin for Strapi that provides the ability to auto slugify a field for any content type. It also provides a findOne by slug e

daedalus 25 Nov 28, 2022
A plugin for Strapi Headless CMS that provides the ability to transform the API request or response.

strapi-plugin-transformer A plugin for Strapi that provides the ability to transform the API request and/or response. Requirements The installation re

daedalus 71 Jan 6, 2023