@@ -18,101 +18,56 @@ import { PublisherVerificationSchema } from './marketplace.zod';
1818 * - **Shopify Partner Dashboard**: App management, analytics, billing
1919 * - **VS Code Marketplace Management**: Extension publishing, statistics, tokens
2020 *
21+ * ## Identity Integration (better-auth)
22+ * Authentication, organization management, and API keys are handled by the
23+ * Identity module (`@objectstack/spec` Identity namespace), which follows the
24+ * better-auth specification. This module only defines marketplace-specific
25+ * extensions on top of the shared identity layer:
26+ *
27+ * - **User & Session** → `Identity.UserSchema`, `Identity.SessionSchema`
28+ * - **Organization & Members** → `Identity.OrganizationSchema`, `Identity.MemberSchema`
29+ * - **API Keys** → `Identity.ApiKeySchema` (with marketplace scopes)
30+ *
2131 * ## Key Concepts
22- * - **Developer Account **: Registration and API key management
32+ * - **Publisher Profile **: Links an Identity Organization to a marketplace publisher
2333 * - **App Listing Management**: CRUD for marketplace listings (draft → published)
2434 * - **Version Channels**: alpha / beta / rc / stable release channels
2535 * - **Publishing Analytics**: Install trends, revenue, ratings over time
2636 */
2737
2838// ==========================================
29- // Developer Account & API Keys
39+ // Publisher Profile (extends Identity.Organization)
3040// ==========================================
3141
3242/**
33- * Developer Account Status
34- */
35- export const DeveloperAccountStatusSchema = z . enum ( [
36- 'pending' , // Registration submitted, awaiting approval
37- 'active' , // Account active and can publish
38- 'suspended' , // Temporarily suspended (policy violation)
39- 'deactivated' , // Deactivated by developer
40- ] ) ;
41-
42- /**
43- * API Key Scope — controls what the key can do
44- */
45- export const ApiKeyScopeSchema = z . enum ( [
46- 'publish' , // Publish packages to registry
47- 'read' , // Read listing/analytics data
48- 'manage' , // Manage listings (update, deprecate)
49- 'admin' , // Full access (manage team, keys)
50- ] ) ;
51-
52- /**
53- * Developer API Key
54- */
55- export const DeveloperApiKeySchema = z . object ( {
56- /** Key identifier (not the secret) */
57- id : z . string ( ) . describe ( 'API key identifier' ) ,
58-
59- /** Human-readable label */
60- label : z . string ( ) . describe ( 'Key label (e.g., "CI/CD Pipeline")' ) ,
61-
62- /** Scopes granted to this key */
63- scopes : z . array ( ApiKeyScopeSchema ) . min ( 1 ) . describe ( 'Permissions granted' ) ,
64-
65- /** Key prefix (first 8 chars) for identification */
66- prefix : z . string ( ) . max ( 8 ) . optional ( ) . describe ( 'Key prefix for display' ) ,
67-
68- /** Expiration date (optional) */
69- expiresAt : z . string ( ) . datetime ( ) . optional ( ) ,
70-
71- /** Creation timestamp */
72- createdAt : z . string ( ) . datetime ( ) ,
73-
74- /** Last used timestamp */
75- lastUsedAt : z . string ( ) . datetime ( ) . optional ( ) ,
76-
77- /** Whether this key is currently active */
78- active : z . boolean ( ) . default ( true ) ,
79- } ) ;
80-
81- /**
82- * Developer Account Schema
43+ * Publisher Profile Schema
8344 *
84- * Represents a registered developer or organization in the portal.
45+ * Links an Identity Organization to a marketplace publisher identity.
46+ * The organization itself (name, slug, logo, members) is managed via
47+ * Identity.OrganizationSchema and Identity.MemberSchema (better-auth aligned).
48+ *
49+ * This schema only holds marketplace-specific publisher metadata.
8550 */
86- export const DeveloperAccountSchema = z . object ( {
87- /** Account unique identifier */
88- id : z . string ( ) . describe ( 'Developer account ID' ) ,
89-
90- /** Publisher ID (links to PublisherSchema in marketplace) */
91- publisherId : z . string ( ) . describe ( 'Associated publisher ID' ) ,
51+ export const PublisherProfileSchema = z . object ( {
52+ /** Organization ID (references Identity.Organization.id) */
53+ organizationId : z . string ( ) . describe ( 'Identity Organization ID' ) ,
9254
93- /** Account status */
94- status : DeveloperAccountStatusSchema . default ( 'pending ') ,
55+ /** Publisher ID (marketplace-assigned identifier) */
56+ publisherId : z . string ( ) . describe ( 'Marketplace publisher ID ') ,
9557
96- /** Verification level (from marketplace publisher ) */
58+ /** Verification level (marketplace trust tier ) */
9759 verification : PublisherVerificationSchema . default ( 'unverified' ) ,
9860
99- /** Organization name */
100- organizationName : z . string ( ) . describe ( 'Organization or developer name' ) ,
101-
102- /** Primary contact email */
103- email : z . string ( ) . email ( ) . describe ( 'Primary contact email' ) ,
61+ /** Accepted developer program agreement version */
62+ agreementVersion : z . string ( ) . optional ( ) . describe ( 'Accepted developer agreement version' ) ,
10463
105- /** Team members (user IDs with roles) */
106- teamMembers : z . array ( z . object ( {
107- userId : z . string ( ) ,
108- role : z . enum ( [ 'owner' , 'admin' , 'developer' , 'viewer' ] ) ,
109- joinedAt : z . string ( ) . datetime ( ) . optional ( ) ,
110- } ) ) . optional ( ) . describe ( 'Team member list' ) ,
64+ /** Publisher-specific website (may differ from org) */
65+ website : z . string ( ) . url ( ) . optional ( ) . describe ( 'Publisher website' ) ,
11166
112- /** Accepted developer agreement version */
113- agreementVersion : z . string ( ) . optional ( ) . describe ( 'Accepted ToS version ' ) ,
67+ /** Publisher-specific support email */
68+ supportEmail : z . string ( ) . email ( ) . optional ( ) . describe ( 'Publisher support email ' ) ,
11469
115- /** Registration timestamp */
70+ /** Registration timestamp (when org became a publisher) */
11671 registeredAt : z . string ( ) . datetime ( ) ,
11772} ) ;
11873
@@ -354,10 +309,7 @@ export const PublishingAnalyticsResponseSchema = z.object({
354309// Export Types
355310// ==========================================
356311
357- export type DeveloperAccountStatus = z . infer < typeof DeveloperAccountStatusSchema > ;
358- export type ApiKeyScope = z . infer < typeof ApiKeyScopeSchema > ;
359- export type DeveloperApiKey = z . infer < typeof DeveloperApiKeySchema > ;
360- export type DeveloperAccount = z . infer < typeof DeveloperAccountSchema > ;
312+ export type PublisherProfile = z . infer < typeof PublisherProfileSchema > ;
361313export type ReleaseChannel = z . infer < typeof ReleaseChannelSchema > ;
362314export type VersionRelease = z . infer < typeof VersionReleaseSchema > ;
363315export type CreateListingRequest = z . infer < typeof CreateListingRequestSchema > ;
0 commit comments