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.
createORM
✓ import { createORM } from 'crm-orm'
✗ const { createORM } = require('crm-orm')
The package is ESM-only. CommonJS require will fail.
sf
✓ import { sf } from 'crm-orm'
✗ import { Salesforce } from 'crm-orm'
sf is a namespace export (not a class) containing helpers like sf.model.
AmpersandAdapter
✓ import { AmpersandAdapter } from 'crm-orm'
Adapter class to wrap an Ampersand transport client.
Sets up a CRM ORM instance, defines a Salesforce Opportunity model with Zod, and runs a typed query with filtering, sorting, and limiting.
import { createORM, sf, AmpersandAdapter } from 'crm-orm';
import type { AmpersandTransportRequest, AmpersandTransportResponse } from 'crm-orm';
import { z } from 'zod';
class AmpersandPassthroughAPI {
async request<T = unknown>(req: AmpersandTransportRequest): Promise<AmpersandTransportResponse<T>> {
// delegate to your Ampersand instance
throw new Error('wire me to Ampersand');
}
}
const transport = new AmpersandAdapter(new AmpersandPassthroughAPI());
const orm = createORM({
transport,
salesforce: { version: '59.0', providerName: 'salesforce' },
});
const Opportunity = sf.model({
name: 'Opportunity',
object: 'Opportunity',
schema: z.object({
id: z.string(),
name: z.string(),
amount: z.number().nullable(),
createdDate: z.string(),
}),
fields: {
id: { path: 'Id' },
name: { path: 'Name' },
amount: { path: 'Amount' },
createdDate: { path: 'CreatedDate' },
},
});
const opps = await orm
.from(Opportunity)
.select({ id: true, name: true, amount: true, createdDate: true })
.where({ name: { $like: 'Acme%' }, amount: { $gte: 25000 } })
.orderBy({ createdDate: 'desc' })
.limit(100)
.getMany();
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Using require() on an ESM-only module.
fixChange to use import syntax: import { createORM } from 'crm-orm'; Error: Cannot find module 'zod'
Zod is a peer dependency not automatically installed.
TypeError: createORM is not a function
Incorrect import (e.g., default import instead of named).
fixUse: import { createORM } from 'crm-orm'; Audit
Dependencies
zodrequiredPeer dependency for defining model schemas