7.5.0 • Published 16 days ago

@laboratoria/sdk-js v7.5.0

Weekly downloads
-
License
MIT
Repository
-
Last release
16 days ago

Laboratoria JavaScript (browser) SDK

Node.js CI

:warning: This tool is still in draft stage and is likely to change without notice.

Installation

npm i --save @laboratoria/sdk-js

Usage

import { createApp } from '@laboratoria/sdk-js';

const app = createApp();

With options:

const app = createApp({
  firebaseApiKey: '',
  firebaseProject: '',
  coreApiUrl: '',
  jobsApiUrl: '',
});

API

Auth

app.auth.onChange(({ authUser, user }) => {
  // `authUser` is the Firebase Auth user
  // `user` is the user profile stored in Laboratoria Core
});

app.auth.signIn(email, password);
app.auth.signOut();

Models

The app object exposes data models used to access data. Each model represents a type of object, which is stored in a database table.

All models have the following methods and properties.

CRUD methods

  • create
  • delete
  • findById
  • findMany
  • update
  • upsert

Other methods

  • parse
  • stats
  • validate
  • validateAttr

Properties

  • relations
  • schema

Model Schema

Each model has a schema (model.schema) that describes the shape of the data, what properties (columns) it has, what data types these columns are, whether they are required or not, etc.

The model.schema is an object with the following properties:

  • inputProps: An array listing properties to be taken into account when building input UI or sending data (via model.create, model.update, etc).
  • primaryKey: Primary key in the underlying table.
  • properties: An object with the model properties. Each property is described by an object having the following keys:
    • type: It can be: boolean, integer, string, date o una referncia a un modelo, en cuyo caso el string será el nombre del modelo de prisma.
    • default
    • enum
    • format: date-time
    • $ref
    • anyOf
    • items
    • inputType
    • isRequired
    • isScalar
    • isRef
  • type: The schema for the whole model will always be of type object.

Users

app.user.findMany({
  where: { name: { contains: 'foo' } },
  include: { students: true },
  take: 10,
  skip: 0,
});

app.user.findById('some-firebase-uid', {
  include: { gigs: true },
});

app.user.update({
  where: { uid: 'some-firebase-uid' },
  data: {
    name: 'OMG',
  },
});

app.user.delete('some-firebase-uid');

app.user.create({
  data: {
    name: 'OMG',
    email: 'omg@omg.omg',
    password: 'secret',
  },
});

Cohorts

app.cohort.findMany({
  where: {
    end: { gt: new Date() },
    stage: { name: 'bootcamp' },
  },
  include: {
    program: true,
    stage: true,
    students: true,
    dropouts: true,
  },
})

Students

WIP

Dropouts

WIP

Projects

app.project.findMany();

app.project.findMany({ tag: 'v3.0.0' });

app.project.findMany({
  locale: 'es-ES',
  track: 'js',
});

app.project.findById('cipher');

app.project.findById('cipher', { tag: 'v3.0.0' });

Topics

app.topic.findMany();

app.topic.findMany({ tag: 'v3.0.0' });

app.topic.findMany({
  locale: 'es-ES',
  track: 'js',
});

app.topic.findById('javascript');

app.topic.findById('javascript', { tag: 'v3.0.0' });

Learning Objectives

app.learningObjective.findMany();

app.learningObjective.findMany({ tag: 'v3.0.0' });
7.6.0-beta.4

17 days ago

7.6.0-beta.5

16 days ago

7.6.0-beta.2

17 days ago

7.6.0-beta.0

18 days ago

7.6.0-beta.1

18 days ago

7.5.0

2 months ago

7.4.0

3 months ago

7.3.0

3 months ago

7.3.0-beta.0

3 months ago

7.2.3

3 months ago

7.2.2-0

3 months ago

7.2.2

3 months ago

7.2.1

3 months ago

7.2.0

3 months ago

7.2.0-beta.3

3 months ago

7.2.0-beta.2

3 months ago

7.2.0-beta.0

3 months ago

7.2.0-beta.1

3 months ago

7.1.2

4 months ago

7.1.1

4 months ago

7.1.0

4 months ago

7.0.1

5 months ago

5.3.2

9 months ago

5.3.1

10 months ago

5.3.0

10 months ago

6.0.0-beta.0

9 months ago

6.1.0

6 months ago

6.0.0-beta.1

9 months ago

6.0.0-beta.2

9 months ago

5.3.0-beta.0

10 months ago

5.3.0-beta.2

10 months ago

5.3.0-beta.1

10 months ago

6.1.0-beta.1

7 months ago

6.1.0-beta.0

7 months ago

5.3.0-beta.3

10 months ago

5.2.0

10 months ago

6.0.0

8 months ago

7.0.0

6 months ago

7.0.0-beta.2

6 months ago

7.0.0-beta.0

6 months ago

7.0.0-beta.1

6 months ago

5.1.1

11 months ago

5.1.0

11 months ago

5.0.1

1 year ago

5.2.0-beta.2

11 months ago

5.2.0-beta.1

11 months ago

5.2.0-beta.0

11 months ago

5.1.0-beta.0

12 months ago

5.1.0-beta.1

12 months ago

5.1.0-beta.2

12 months ago

5.1.0-beta.3

12 months ago

5.1.0-beta.4

12 months ago

5.1.0-beta.5

12 months ago

4.0.1

1 year ago

4.0.0

1 year ago

4.0.2

1 year ago

4.1.0-beta.0

1 year ago

5.0.0

1 year ago

4.0.0-beta.3

1 year ago

4.0.0-beta.2

1 year ago

4.0.0-alpha.3

1 year ago

4.0.0-alpha.1

1 year ago

4.0.0-alpha.2

1 year ago

4.0.0-alpha.0

1 year ago

3.4.0

1 year ago

3.4.1

1 year ago

3.3.0

1 year ago

4.0.0-beta.1

1 year ago

4.0.0-beta.0

1 year ago

3.0.0-beta.0

1 year ago

3.0.0-alpha.1

1 year ago

3.0.0-alpha.0

2 years ago

3.2.1

1 year ago

3.2.0

1 year ago

3.1.0

1 year ago

3.0.0

1 year ago

2.6.2

2 years ago

2.5.0

2 years ago

2.4.0

2 years ago

2.6.1

2 years ago

2.6.0

2 years ago

2.3.0

2 years ago

2.2.0

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.7.1

2 years ago

2.0.0-alpha.4

2 years ago

2.0.0-alpha.5

2 years ago

1.7.0

2 years ago

1.5.2

2 years ago

1.6.0

2 years ago

1.5.1

2 years ago

2.0.0-alpha.3

2 years ago

2.0.0-alpha.0

2 years ago

2.0.0-alpha.1

2 years ago

2.0.0-alpha.2

2 years ago

1.5.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

0.2.0

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.0

2 years ago