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

@sierralabs/forms-api

v1.1.22

Published

Sierra Labs Forms API Library

Downloads

266

Readme

Sierra Labs Forms API

Sierra Labs Forms API Library for managing form schemas, form templates, form data as well as generating/publishing form tables. The library consists of:

  • TypeORM entities:
    • FormSchema - Stores latest working draft of a form schema JSON. The form schema JSON is based on TypeORM's EntitySchema data type.
    • FormSchemaVersion - Stores published versions of the schema JSON. The schema JSON should match exactly 1:1 with the published Form table.
    • FormSchemaDelta - Stores history of all form schema changes allowing for undo/redo and operational transformation logic. The Delta json is based on the @sierralabs/track-changes module.
    • FormTemplate - Stores latest working draft of a form template JSON. The form template JSON is based on the StateNodeConfig data type from the @sierralabs/state-machine.
    • FormTemplateVersion - Stores published versions of the form template JSON.
  • NestJS Form API endpoints:
    • Form Schema API
    • Form Template API
    • Form API
    • Form Permission Guards
    • Schema Table Migration library

Getting Started

Install the @sierralabs/forms-api package along with peer dependencies

# for npm
$ npm install @sierralabs/core @sierralabs/forms-core @sierralabs/track-changes @sierralabs/state-machine @sierralabs/nest-utils @sierralabs/forms-api

# or for yarn
$ yarn add @sierralabs/core @sierralabs/forms-core @sierralabs/track-changes @sierralabs/state-machine @sierralabs/nest-utils @sierralabs/forms-api

Modify your project's AppModule to import the FormModule and configure the API permissions (See FormModulePermissions interface for more details). The API permissions are based on @sierralabs/user-api user permissions.

import {
  FormModule,
  FormSchema,
  FormSchemaDelta,
  FormSchemaVersion,
  FormTemplate,
  FormTemplateVersion,
} from '@sierralabs/forms-api';

@Module({
  imports: [
    ConfigModule.forRoot(),
    TypeOrmModule.forRoot({
      ...
      entities: [
        __dirname + '/entities/**.entity{.ts,.js}',
        //Include the below entities from the forms-api package
        FormSchema,
        FormSchemaVersion,
        FormSchemaDelta,
        FormTemplate,
        FormTemplateVersion,
      ],
      ...
    }),
    ...
    // You can set up basic permissions by passing in the `permissions` options property
    FormModule.forRoot({ permissions: { roles: ['Admin'] } }),

    // For more granular permissions you can set roles for each Entity CRUD
    FormModule.forRoot({ permissions: {
      schema: {
        create: { role: 'Admin' }, // You can use a role name string
        read: { roles: ['$everyone'] }, // You can pass in an array of role names
        update: { roles: ['Admin'] },
        delete: { guard: CustomGuard } // write your own custom NestJS Guard
      },
      template: {...},
      form: {...}
     } }),
  ],
  ...
})
export class AppModule {}

Development & Contributing

To develop and contribute to the @sierralabs/forms-api project from another project that has a dependency on this module you can use Yalc. Yalc works better then yarn/npm link due to node_module dependency issues with symlinking that impact modules like typeorm and nestjs.

# Install yalc if you don't already have it installed
$ npm install -g yalc

# Publish `@sierralabs/forms-api` into your local yalc repo
$ yalc publish

# On the project that is using `@sierralabs/forms-api` run
dependent-project $ yalc link @sierralabs/forms-api

# Now back on the `@sierralabs/forms-api` folder you can push changes to the linked projects by
$ yalc push

# Lastly, to undo the yalc link reference, you'll need to force the package install on the dependent project
dependent-project $ yarn install --force