atomic-server icon indicating copy to clipboard operation
atomic-server copied to clipboard

host js / ts modules for classes

Open joepio opened this issue 3 years ago • 0 comments

Atomic Classes can be used to generate Javascript / Typesript artifacts that help developers interact with instances of classes.

As a JS dev, I want the following when working in a JS / TS context

  • Full native types support for al properties
  • Use shortnames instead of URLs to get properties (resource.title instead of resource.get("https://atomicdata.dev/title"))
  • Traverse relationships and maintain

Ideally, I'd do something like this:

import ChatRoom from "https://atomicdata.dev/classes/ChatRoom.js";

let myChatRoom = store.get("https://atomicdata.dev/myChatRoom") as ChatRoom;

myChatRoom.messages.map(m => console.log(`I'm a chat message: ${m}`);

Or maybe in a React app something like this:

import ChatRoom from "https://atomicdata.dev/classes/ChatRoom.js";

const myChatRoom = useResourceMapped<ChatRoom>("https://atomicdata.dev/myChatRoom");

return (<div>{myChatRoom.title()}</div>)

I think this means that somewhere a JS thing (maybe a Class) needs to be generated from an Atomic Class. This generated thing probably depends on @tomic/lib. It might make sense to make it extend Resource and it has a bunch of generated methods / fields for every recommended / required property in the Atomic Class.

class ChatRoom extends Resource {
   messages() {
       this.get("https://atomicdata.dev/properties/chatroom/messages)
   } 
}

joepio avatar May 20 '22 09:05 joepio