@@ -15,12 +15,15 @@ type DbRef = {
1515export type Ref = LocalRef | DbRef ;
1616
1717// Common attributes for most types
18- type CrossAppBase = LocalRef & {
18+ type BaseAttributes = {
1919 createdAt : Date ;
2020 modifiedAt ?: Date ;
2121 author : Ref ;
2222} ;
2323
24+ // Common attributes for most types
25+ type CrossAppBase = LocalRef & BaseAttributes ;
26+
2427type SpaceRef = DbRef | { url : string ; sourceApp : Enums < "Platform" > } ;
2528
2629export type LocalOrRemoteRef =
@@ -35,6 +38,19 @@ export type LocalOrRemoteRef =
3538 rid : string ;
3639 } ;
3740
41+ type WithOptionalLocalRef < Extra > = ( LocalRef & Extra ) | Extra ;
42+
43+ /*
44+ Note on Inline vs Standalone:
45+ The db `upsert_...` functions allow to put some objects inline inside related objects instead of passing a reference.
46+ Those objects will either get upserted or resolved by the upsert functions.
47+ When we provide an inline object, some shared attributes can be specified in the enclosing object.
48+ Hence, the inline version of the object has less required attributes than the standalone version.
49+ */
50+
51+ // Partial version of above, utility type for functions that can receive many of the above.
52+ export type InlineAbstractBase = WithOptionalLocalRef < Partial < BaseAttributes > > ;
53+
3854// A node schema
3955export type CrossAppNodeSchema = CrossAppBase & {
4056 label : string ;
@@ -64,27 +80,80 @@ export type CrossAppEmbedding = {
6480 embedding ?: Enums < "EmbeddingName" > ;
6581} ;
6682
67- // A Content object. It can be put inline inside a concept.
68- // Missing CrossAppBase attributes are inferred from enclosing object.
69- export type InlineCrossAppContent = Partial < CrossAppBase > & {
83+ // An asset reference
84+ export type CrossAppAsset = {
85+ content : ArrayBuffer ;
86+ mimetype : string ;
87+ createdAt : Date ;
88+ modifiedAt ?: Date ;
89+ filepath ?: string ;
90+ } ;
91+
92+ // Document fields
93+ type CrossAppDocumentExtras = {
94+ // MIME type
95+ contentType : string ;
96+ } ;
97+
98+ // An inline document, to put inside Content or Concept.
99+ // Currently, we fully infer Documents (setting content_as_document=true)
100+ // since our nodes are pages; so this is not used yet.
101+ export type InlineCrossAppDocument = WithOptionalLocalRef <
102+ Partial < BaseAttributes > & CrossAppDocumentExtras
103+ > ;
104+
105+ // A standalone document, for `upsert_documents`. Not currently used.
106+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
107+ type StandaloneCrossAppDocument = LocalRef &
108+ BaseAttributes &
109+ CrossAppDocumentExtras ;
110+
111+ // Content fields
112+ type CrossAppContentExtras = {
70113 value : string ;
71114 embedding ?: CrossAppEmbedding ;
72115 scale ?: Enums < "Scale" > ;
116+ partOf ?: Ref ;
117+ assets ?: CrossAppAsset [ ] ;
118+ document ?: InlineCrossAppDocument ;
73119 contentType ?: ContentType ;
74120} ;
75121
122+ // An inline content object, to be put inside a Concept.
123+ export type InlineCrossAppContent = Partial < CrossAppBase > &
124+ CrossAppContentExtras ;
125+
126+ // A standalone content object, for `upsert_content`
127+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
128+ type StandaloneCrossAppContent = LocalRef &
129+ BaseAttributes &
130+ CrossAppContentExtras ;
131+
76132// An inline Content with obligatory typing
77133export type InlineCrossAppTypedContent = InlineCrossAppContent & {
78134 contentType : ContentType ;
79135} ;
80136
137+ // A platform account
138+ // either standalone for `upsert_account_in_space`,
139+ // or inline in Content or Concept
140+ export type CrossAppAccount = {
141+ accountLocalId : string ;
142+ name ?: string ;
143+ email ?: string ;
144+ // agentType: Enums<"AgentType"> = 'person' // inferred
145+ // dgAccount?: string; // uuid
146+ } ;
147+
81148// A node instance
82149export type CrossAppNode = CrossAppBase & {
83150 nodeType : Ref ;
84151 content : {
85152 direct : InlineCrossAppContent ;
86153 full : InlineCrossAppTypedContent ;
87154 } ;
155+ // This is a way to define document globally for all contents
156+ document ?: InlineCrossAppDocument ;
88157} ;
89158
90159// A relation instance
0 commit comments