workos / workos-node

Official Node SDK for interacting with the WorkOS API
https://workos.com/docs/sdk/node
MIT License
119 stars 29 forks source link

Audit logs create schema #1141

Open PaulAsjes opened 1 day ago

PaulAsjes commented 1 day ago

Description

Adds a createSchema method. Example use:

const schema = await workos.auditLogs.createSchema({
  action: 'user.deleted',
  actor: {
    metadata: {
      actor_id: 'string',
    },
  },
  targets: [
    {
      type: 'user',
      metadata: {
        user_id: 'string',
      },
    },
  ],
  metadata: {
    foo: 'number',
    baz: 'boolean',
  },
});

console.log('schema created:', schema);

The above logs:

schema created: {
  object: 'audit_log_schema',
  version: 1,
  targets: [ { type: 'user', metadata: [Object] } ],
  actor: { metadata: { actor_id: 'string' } },
  metadata: { baz: 'boolean', foo: 'number' },
  createdAt: '2024-10-14T15:09:44.537Z'
}

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.