Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collections #789

Merged
merged 24 commits into from
Oct 23, 2024
Merged

Collections #789

merged 24 commits into from
Oct 23, 2024

Conversation

josephjclark
Copy link
Collaborator

@josephjclark josephjclark commented Oct 16, 2024

Summary

Adds a new Collections adaptor

Fixes #758

TODO

  • Pass query options like updated_before
  • Add proper documentation
  • Add richer logging output
  • Maybe mock date filters for better tests? Doesn't really feel material...

Details

The adaptor provides a fairly simple API.

This implementation and tests rely heavily on a little mock collections server, which uses undici interceptors.

At the moment, because there's no backend and no worker support, the adaptor really only works through the mock interface.

Here's a test job which works through the CLI:

// Set up the test
fn((state = {}) => {
  // set up a mock
  const server = mock.createServer();
  collections.setMockClient(server);

  server.api.createCollection('collection');

  state.configuration = {
    collections_token: 'abc',
  };

  state.data = [
    { key: 'a', value: { id: 'a' } },
    { key: 'b', value: { id: 'b' } },
    { key: 'c', value: { id: 'c' } },
  ];

  return state;
});

collections.set('collection', $.data);

collections.each('collection', '*', (state, key, value) => {
  console.log(key, value);
});

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to know!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

@josephjclark
Copy link
Collaborator Author

Here's a thought: do we need to do something to stop the collections adaptor appearing in the lightning drop-down list? 🤔

@josephjclark josephjclark marked this pull request as ready for review October 22, 2024 09:43
@josephjclark josephjclark merged commit 9bdd371 into main Oct 23, 2024
2 checks passed
@josephjclark josephjclark deleted the collections branch October 23, 2024 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Build a collections adaptor
1 participant