A lightweight layer for working with JSON:API data.
MIT License
Bot releases are hidden (Show)
Rewrite TypeScript support to allow Intellisense based on JSON:API resource schema. For example:
type UsersSchema = {
type: 'users';
id: string;
attributes: {
name: string;
};
relationships: {
dog: { data?: { type: 'dogs'; id: string } | null };
};
};
class User extends Model<UsersSchema> {}
To type related resources, you can provide a collection of all models as the second generic.
type DogsSchema = {
// ...
};
type Schemas = {
users: User;
dogs: Dog;
};
class User extends Model<UsersSchema, Schemas> {}
class Dog extends Model<DogsSchema, Schemas> {}
The Store
now returns proxied Model
instances to implement field getters, instead of Model
depending on Store
and defining getters for present fields.
Remove the Query
helper. Use URLSearchParams
instead.
Remove Model
attribute casting functionality. Define getters instead:
class User extends Model<UserSchema> {
get createdAtDate() {
return new Date(this.createdAt);
}
}
Remove the Model.getAttribute()
and Model.getRelationship()
methods.
Remove CJS and IIFE exports. Package is now only exported as an ES module.
Published by tobyzerner over 2 years ago
const store = new Store({ users: User });
store.find('users', '1') // User
Store.model
method. Models must now be defined when the Store is constructed.Published by tobyzerner about 3 years ago
Published by tobyzerner about 3 years ago
new
.Published by tobyzerner about 3 years ago
append
, set
, and delete
methods.JsonApiDocument
, JsonApiIdentifier
, JsonApiResource
, JsonApiRelationships
, and JsonApiRelationship
.push
method.Published by tobyzerner over 3 years ago
Published by tobyzerner over 3 years ago
es2017
for Object.entries
support.