Registry / database / lz-schema

lz-schema

JSON →
library0.35.1jsnpmunverified

lz-schema v0.35.1 provides TypeScript type definitions and Zod validation schemas for the LayerZ API entities. It is part of the LayerZ project and is co-released with the API. Key differentiator: tightly coupled with LayerZ API contracts, ensuring schema consistency. Schemas include campaign, workspace, and other domain models. Release cadence follows LayerZ backend updates. Requires Zod as a peer dependency.

npm install lz-schema
INSTALL
IMPORT
SIG · LZ-SCHEMA
L
lz-schema
databasejavascriptv0.35.1
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.

createCampaignSchema
import { createCampaignSchema } from 'lz-schema'
const { createCampaignSchema } = require('lz-schema')
ESM-only. CJS not supported.
CreateCampaignBody
import { CreateCampaignBody } from 'lz-schema'
import { CreateCampaignBody } from 'lz-schema/types'
Types are re-exported from the main entry.
z
import { z } from 'zod'
import { z } from 'lz-schema'
z is not re-exported; import directly from zod.

Validates a campaign object using the createCampaignSchema and handles success/error.

import { createCampaignSchema } from 'lz-schema'; import { z } from 'zod'; const campaignData = { name: 'Summer Sale', from: Date.now(), to: Date.now() + 86400000, priority: 1, workspaceId: '673517701433191f766ebfa4', }; const result = createCampaignSchema.safeParse(campaignData); if (!result.success) { console.error(result.error); } else { console.log(result.data); }
Debug
Known issues
breakingPrior to v0.30.0, schemas used 'Yup' and were exported differently; migration required.
fix
Update to v0.30.0+ and change imports to use Zod schemas.
affects: <0.30.0
deprecatedThe 'workspaceSchema' has been deprecated in favor of 'workspaceUpdateSchema' and 'workspaceCreateSchema'.
fix
Use workspaceCreateSchema or workspaceUpdateSchema as appropriate.
affects: >=0.32.0
gotchaAll date fields (from, to) expect Unix timestamps in milliseconds, not Date objects or ISO strings.
fix
Convert Date objects to getTime() before validation.
affects: >=0.28.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'safeParse')
Importing createCampaignSchema but Zod is not installed or version mismatch.
fix
Install zod as a dependency: npm install zod
Module not found: Error: Can't resolve 'lz-schema'
Package not installed or wrong import path (CJS wrong).
fix
npm install lz-schema and use ESM import syntax.
ZodError: [ { code: 'invalid_type', expected: 'number', received: 'string', path: ['from'] } ]
Passing a string (e.g., ISO date) to a date field expecting a number (timestamp).
fix
Convert ISO strings to numeric timestamps: new Date('...').getTime().
Upgrade
Version history
0.35.1latest on npm
Audit
Dependencies
zodrequiredPeer dependency for schema validation utilities (safeParse, etc.)
Agent activity
7 hits · last 30 days
node
6
Resources
lz-schema — npm install lz-schema · libregistry