b53a97d26633a1f174a7031559a69d37e393379f
chmalee
  Fri May 1 14:19:19 2026 -0700
Allow myVariants tracks to be shared similar to google docs, read only and read+edit access by username or for all. Last write wins. Currently no history of changes, leaving that for the next version of the feature

diff --git src/hg/inc/myVariantsShare.h src/hg/inc/myVariantsShare.h
new file mode 100644
index 00000000000..f1e2d1c35f3
--- /dev/null
+++ src/hg/inc/myVariantsShare.h
@@ -0,0 +1,126 @@
+/* myVariantsShare.h was originally generated by the autoSql program, which also 
+ * generated myVariantsShare.c and myVariantsShare.sql.  This header links the database and
+ * the RAM representation of objects. */
+
+#ifndef MYVARIANTSSHARE_H
+#define MYVARIANTSSHARE_H
+
+#include "jksql.h"
+#define MYVARIANTSSHARE_NUM_COLS 9
+#define MYVAR_TOKEN_LENGTH 48
+
+extern char *myVariantsShareCommaSepFieldNames;
+
+struct myVariantsShare
+/* A share record linking an owner's myVariants project to a recipient. */
+    {
+    struct myVariantsShare *next;  /* Next in singly linked list. */
+    unsigned id;	/* Auto-increment primary key */
+    char *ownerUser;	/* Owner who created the share */
+    char *shareToken;	/* 48-char URL-safe token */
+    char *project;	/* Project name, or * for all */
+    char *db;	/* Assembly (hg38, mm39, etc.) */
+    unsigned char permission;	/* 0=read-only, 1=read-write */
+    char *targetUser;	/* Specific user, or NULL for anyone with link */
+    char *label;	/* Optional human-readable label */
+    char *createdAt;	/* Timestamp of creation */
+    };
+
+void myVariantsShareStaticLoad(char **row, struct myVariantsShare *ret);
+/* Load a row from myVariantsShare table into ret.  The contents of ret will
+ * be replaced at the next call to this function. */
+
+struct myVariantsShare *myVariantsShareLoadByQuery(struct sqlConnection *conn, char *query);
+/* Load all myVariantsShare from table that satisfy the query given.  
+ * Where query is of the form 'select * from example where something=something'
+ * or 'select example.* from example, anotherTable where example.something = 
+ * anotherTable.something'.
+ * Dispose of this with myVariantsShareFreeList(). */
+
+void myVariantsShareSaveToDb(struct sqlConnection *conn, struct myVariantsShare *el, char *tableName, int updateSize);
+/* Save myVariantsShare as a row to the table specified by tableName. 
+ * As blob fields may be arbitrary size updateSize specifies the approx size
+ * of a string that would contain the entire query. Arrays of native types are
+ * converted to comma separated strings and loaded as such, User defined types are
+ * inserted as NULL. This function automatically escapes quoted strings for mysql. */
+
+struct myVariantsShare *myVariantsShareLoad(char **row);
+/* Load a myVariantsShare from row fetched with select * from myVariantsShare
+ * from database.  Dispose of this with myVariantsShareFree(). */
+
+struct myVariantsShare *myVariantsShareLoadAll(char *fileName);
+/* Load all myVariantsShare from whitespace-separated file.
+ * Dispose of this with myVariantsShareFreeList(). */
+
+struct myVariantsShare *myVariantsShareLoadAllByChar(char *fileName, char chopper);
+/* Load all myVariantsShare from chopper separated file.
+ * Dispose of this with myVariantsShareFreeList(). */
+
+#define myVariantsShareLoadAllByTab(a) myVariantsShareLoadAllByChar(a, '\t');
+/* Load all myVariantsShare from tab separated file.
+ * Dispose of this with myVariantsShareFreeList(). */
+
+struct myVariantsShare *myVariantsShareCommaIn(char **pS, struct myVariantsShare *ret);
+/* Create a myVariantsShare out of a comma separated string. 
+ * This will fill in ret if non-null, otherwise will
+ * return a new myVariantsShare */
+
+void myVariantsShareFree(struct myVariantsShare **pEl);
+/* Free a single dynamically allocated myVariantsShare such as created
+ * with myVariantsShareLoad(). */
+
+void myVariantsShareFreeList(struct myVariantsShare **pList);
+/* Free a list of dynamically allocated myVariantsShare's */
+
+void myVariantsShareOutput(struct myVariantsShare *el, FILE *f, char sep, char lastSep);
+/* Print out myVariantsShare.  Separate fields with sep. Follow last field with lastSep. */
+
+#define myVariantsShareTabOut(el,f) myVariantsShareOutput(el,f,'\t','\n');
+/* Print out myVariantsShare as a line in a tab-separated file. */
+
+#define myVariantsShareCommaOut(el,f) myVariantsShareOutput(el,f,',',',');
+/* Print out myVariantsShare as a comma separated list including final comma. */
+
+/* -------------------------------- End autoSql Generated Code -------------------------------- */
+
+#define MYVAR_PERM_READONLY   0
+#define MYVAR_PERM_READWRITE  1
+
+struct myVariantsShare *myVariantsCreateShare(struct sqlConnection *conn,
+    char *ownerUser, char *project, char *db, int permission,
+    char *targetUser, char *label);
+/* Create a new share record. Returns the share with token and id filled in.
+ * Free with myVariantsShareFree. */
+
+struct myVariantsShare *myVariantsGetShareByToken(struct sqlConnection *conn,
+    char *token);
+/* Look up a single share by token. Returns NULL if not found. */
+
+struct myVariantsShare *myVariantsGetSharesForOwner(struct sqlConnection *conn,
+    char *ownerUser, char *db);
+/* Get all shares created by this user for the given assembly. */
+
+struct myVariantsShare *myVariantsGetSharesForUser(struct sqlConnection *conn,
+    char *targetUser, char *db);
+/* Get all shares targeted at this user for the given assembly. */
+
+boolean myVariantsRevokeShare(struct sqlConnection *conn,
+    char *shareToken, char *ownerUser);
+/* Delete a share record. ownerUser must match the share's owner.
+ * Returns TRUE if a row was deleted, FALSE if not found or not owner. */
+
+#define MYVAR_SHARE_CGI_VAR "myVarShare"
+#define MYVAR_SHARED_CART_PREFIX "myVarShared_"
+
+char *myVariantsShareCartValue(struct myVariantsShare *share);
+/* Build JSON cart value string from a share record.
+ * Caller must freeMem the result. */
+
+boolean myVariantsParseShareCartValue(char *val, char **retOwner,
+    char **retProject, char **retDb, int *retPermission, char **retLabel);
+/* Parse a JSON cart value string back into components. Returns FALSE on bad format.
+ * retOwner, retProject, retDb, retLabel are cloneString'd; caller must free.
+ * Any ret* param may be NULL; pass NULL to skip. */
+
+#endif /* MYVARIANTSSHARE_H */
+