Registry / database / spraypaint-machinetools

spraypaint-machinetools

JSON →
library0.10.22-mt-2jsnpmunverified

An isomorphic JavaScript/TypeScript ORM client for Graphiti APIs, modeled after ActiveRecord. This fork (v0.10.22-mt-2) is maintained by MachineTools developers. It supports decorator-based model definitions, query building with scoping, pagination, sorting, and includes, and works in both browser and Node.js environments. Unlike generic HTTP clients, it provides a structured, type-safe way to interact with JSON:API-compliant backends. The library ships TypeScript definitions but also works with plain ES5. Release cadence is irregular as it's a fork maintained for specific project needs.

npm install spraypaint-machinetools
INSTALL
IMPORT
SIG · SPRAYPAINT-MACHINE
S
spraypaint-machinetools
databasejavascriptv0.10.22-mt-2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SpraypaintBase
import { SpraypaintBase } from 'spraypaint'
import SpraypaintBase from 'spraypaint'
SpraypaintBase is a named export, not the default.
Model
import { Model } from 'spraypaint'
import { Model } from 'spraypaint/lib/Model'
Model is exported from the main package entry point.
Attr
import { Attr } from 'spraypaint'
import { Attribute } from 'spraypaint'
The decorator is named Attr, not Attribute.
HasMany
import { HasMany } from 'spraypaint'
import { HasMany } from 'spraypaint/decorators'
All decorators are exported from the main package.

Defines a Pet model with an attribute and fetches all records from the API.

import { SpraypaintBase, Model, Attr, HasMany } from 'spraypaint' @Model() class ApplicationRecord extends SpraypaintBase { static baseUrl = 'http://localhost:3000' static apiNamespace = '/api/v1' } @Model() class Pet extends ApplicationRecord { static jsonapiType = 'pets' @Attr() name: string } async function main() { const { data } = await Pet.all() console.log(data.map(p => p.name)) } main().catch(console.error)
Debug
Known issues
gotchaDecorators require TypeScript's experimentalDecorators and emitDecoratorMetadata enabled.
fix
Set "experimentalDecorators": true in tsconfig.json.
affects: >=0.10
breakingVersion 0.10 changed the way models are registered. Previously required explicit registration.
fix
Use @Model() decorator on the class instead of a separate registration call.
affects: >=0.10.0
gotchabaseUrl and apiNamespace must be static properties, not instance properties.
fix
Declare static baseUrl = '...' and static apiNamespace = '...' in the base class.
affects: >=0.10
deprecatedThe .includes() method is deprecated in favor of .include().
fix
Use .include('pets') instead of .includes('pets').
affects: >=0.10.22
Errors
Common errors & fixes
Cannot find name 'SpraypaintBase'. Did you mean 'SpraypaintBase'?
Missing import for SpraypaintBase.
fix
Import { SpraypaintBase } from 'spraypaint'.
Experimental support for decorators is a feature that is subject to change in a future release.
TypeScript decorators are experimental.
fix
Enable 'experimentalDecorators' in tsconfig.json.
TypeError: Cannot read properties of undefined (reading 'baseUrl')
baseUrl not defined as a static property on the model class.
fix
Add static baseUrl = 'http://example.com' to your ApplicationRecord class.
Upgrade
Version history
0.10.22-mt-2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
8
Meta
2
Resources
spraypaint-machinetools — npm install spraypaint-machinetools · libregistry