
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@directus/sdk
Advanced tools
This is a BETA release, expect that things do not work!
The design goals for this rebuild:
The client is split up in separate features you can mix and match to compose a client with only the features you need or want.
const client = createDirectus<Schema>('https://api.directus.io');
This client is currently an empty wrapper without any functionality.Before you can do anything with it you'll need to add some features. The following composables are available/in progress:
rest()
REST request functions
.request(...)
on the clientgraphql()
GraphQL request functions
.query(...)
on the clientstaticToken()
authentication functions
.getToken()
and .setToken()
on the clientauthenticate()
authentication functions
.login({ email, password })
, .logout()
, .refresh()
on the client.getToken()
and .setToken()
on the clientrealtime()
websocket connectivity
.subscribe(...)
, .sendMessage(...)
, .onWebsocket('message', (message) => {})
on the clientFor this example we'll build a client including rest
and graphql
:
const client = createDirectus<Schema>('https://api.directus.io').with(rest()).with(graphql());
// do a REST request
const restResult = await client.request(readItems('articles'));
// do a GraphQL request
const gqlResult = await client.query<OutputType>(`
query {
articles {
id
title
author {
first_name
}
}
}
`);
const client = createDirectus<Schema>('https://api.directus.io').with(rest()).with(authentication('json'));
await client.login('admin@example.com', 'd1r3ctu5');
// do authenticated requests
const client = createDirectus<Schema>('https://api.directus.io').with(rest()).with(staticToken('super-secure-token'));
// do authenticated requests
The realtime()
extension allows you to work with a Directus REST WebSocket.
Subscribing to updates:
const client = createDirectus<Schema>('https://api.directus.io').with(
realtime({
authMode: 'public',
})
);
const { subscription, unsubscribe } = await client.subscribe('test', {
query: { fields: ['*'] },
});
for await (const item of subscription) {
console.log('subscription', { item });
}
// unsubscribe()
Receive/Send messages:
const client = createDirectus<Schema>('https://api.directus.io').with(
realtime({
authMode: 'public',
})
);
const stop = client.onWebSocket('message', (message) => {
if ('type' in message && message['type'] === 'pong') {
console.log('PONG received');
stop();
}
});
client.sendMessage({ type: 'ping' });
// The main schema type containing all collections available
interface MySchema {
collection_a: CollectionA[]; // regular collections are array types
collection_b: CollectionB[];
collection_c: CollectionC; // this is a singleton
// junction collections are collections too
collection_a_b_m2m: CollectionAB_Many[];
collection_a_b_m2a: CollectionAB_Any[];
}
// collection A
interface CollectionA {
id: number;
status: string;
// relations
m2o: number | CollectionB;
o2m: number[] | CollectionB[];
m2m: number[] | CollectionAB_Many[];
m2a: number[] | CollectionAB_Any[];
}
// Many-to-Many junction table
interface CollectionAB_Many {
id: number;
collection_a_id: CollectionA;
collection_b_id: CollectionB;
}
// Many-to-Any junction table
interface CollectionAB_Any {
id: number;
collection_a_id: CollectionA;
collection: 'collection_b' | 'collection_c';
item: string | CollectionB | CollectionC;
}
// collection B
interface CollectionB {
id: number;
value: string;
}
// singleton collection
interface CollectionC {
id: number;
app_settings: string;
something: string;
}
FAQs
Directus JavaScript SDK
The npm package @directus/sdk receives a total of 29,185 weekly downloads. As such, @directus/sdk popularity was classified as popular.
We found that @directus/sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.