Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@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 = useDirectus<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(...)
, .message(...)
, .receive((message) => {})
on the clientsubscription()
GraphQL Subscriptions [not available]
.subscription()
For this example we'll build a client including rest
and graphql
:
const client = useDirectus<Schema>('https://api.directus.io').use(rest()).use(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 = useDirectus<Schema>('https://api.directus.io').use(rest()).use(authentication('json'));
await client.login('admin@example.com', 'd1r3ctu5');
// do authenticated requests
const client = useDirectus<Schema>('https://api.directus.io').use(rest()).use(staticToken('super-secure-token'));
// do authenticated requests
The realtime()
extension allows you to work with a Directus REST WebSocket.
Subscribing to updates:
const client = useDirectus<Schema>('https://api.directus.io').use(
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 = useDirectus<Schema>('https://api.directus.io').use(
realtime({
authMode: 'public',
})
);
const stop = client.receive((message) => {
if ('type' in message && message['type'] === 'pong') {
console.log('PONG received');
stop();
}
});
client.message({ 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: CollectionB;
o2m: CollectionB[];
m2m: CollectionAB_Many[];
m2a: 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,440 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 2 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.