@burdenoff/be-sdk 2026.530.1 → 2026.601.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-XD5ZK727.js +1006 -0
- package/dist/chunk-XD5ZK727.js.map +1 -0
- package/dist/index-kssw5ziY.d.ts +250 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/sharing/index.d.ts +1 -0
- package/dist/sharing/index.js +5 -0
- package/dist/sharing/index.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sharing/index.ts","../src/sharing/types.ts","../src/sharing/share-service.ts","../src/sharing/email.ts","../src/sharing/sdl.ts","../src/sharing/prisma-fragment.ts"],"names":["ShareVisibility","ShareRole","ShareStatus","ROLE_ORDER","roleAtLeast","role","required","maxRole","a","b","ROLE_CAPABILITIES","canView","canComment","canEdit","canManage","canExecute","capabilitiesFor","RESOURCE_CAPABILITY_MAP","session","vibedeck","file","folder","roleToLegacy","resourceType","legacyToRole","legacy","table","toUpperCase","normalizeStatus","status","upper","ACTIVE_STATUSES","ACCEPTED","DENY","allowed","effectiveRole","via","notFound","message","GraphQLError","extensions","code","forbidden","badRequest","generateToken","randomBytes","toString","emailsMatch","trim","toLowerCase","pickHighestRole","candidates","best","c","ShareService","prisma","workspaceId","deps","sharedWithVibeRole","requireWorkspaceMember","config","options","VIEWER","resolveAccess","actorId","resourceId","meta","loadResourceMeta","ownerId","MANAGER","visibility","SHARED_WITH_VIBE","vibeId","hasVibeAccess","push","grant","queryActiveAccessGrants","isPublic","PUBLIC_LINK","isMyUserGrant","SHARED_WITH_USERS","granteeUserId","err","logger","warn","findMany","where","deletedAt","in","OR","AND","expiresAt","gt","Date","canAccess","requiredRole","result","assertAccess","mode","createUserShare","actor","input","id","email","granteeEmail","resolveUserByEmail","isMember","isWorkspaceMember","existing","findFirst","PENDING","update","data","create","token","createdBy","onBehalfOf","fireShareEmail","name","createLinkShare","acceptShare","findActiveByToken","idMatches","emailMatches","now","res","updateMany","acceptedAt","acceptedBy","count","fresh","updated","declineShare","REVOKED","revokedAt","revokedBy","shareGrantByToken","revoke","grantId","updateRole","resourceShares","orderBy","createdAt","sharesSharedWithMe","opts","take","skip","listAccessibleResourceIds","grants","Array","from","Set","map","g","listPublicResourceIds","touchAccess","lastAccessAt","accessCount","increment","debug","getTime","resourceName","sendShareEmail","recipientEmail","recipientUserId","acceptUrl","buildAcceptUrl","sharerName","idempotencyKey","SHARE_EMAIL_TEMPLATE_SLUG","RESOURCE_TYPE_LABELS","vibe","note","aiprompt","aicontext","instructionfile","tunnel","action","conversation","catalog","component","template","docs","resourceTypeLabel","ROLE_LABELS","COMMENTER","EDITOR","roleLabel","buildShareEmailVariables","args","makeSendShareEmail","notifier","recipient","userId","info","templateSlug","sendWithTemplate","variables","SHARE_GRANT_SDL","buildPerEntityShareSdl","entity","rbacResource","SHARE_GRANT_PRISMA","SHARE_GRANT_PARTIAL_UNIQUE_SQL"],"mappings":";;;;;;AAAA,IAAA,eAAA,GAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACuBO,IAAKA,eAAAA,6BAAAA,gBAAAA,EAAAA;AACkB,EAAAA,gBAAAA,CAAA,SAAA,CAAA,GAAA,SAAA;AAEsD,EAAAA,gBAAAA,CAAA,mBAAA,CAAA,GAAA,mBAAA;AAElC,EAAAA,gBAAAA,CAAA,kBAAA,CAAA,GAAA,kBAAA;AAEtB,EAAAA,gBAAAA,CAAA,aAAA,CAAA,GAAA,aAAA;AAPhBA,EAAAA,OAAAA,gBAAAA;;AAeL,IAAKC,SAAAA,6BAAAA,UAAAA,EAAAA;AACK,EAAAA,UAAAA,CAAA,QAAA,CAAA,GAAA,QAAA;AAEK,EAAAA,UAAAA,CAAA,WAAA,CAAA,GAAA,WAAA;AAEiD,EAAAA,UAAAA,CAAA,QAAA,CAAA,GAAA,QAAA;AAEvC,EA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AACF,EAAA,CAAA;AACF;AApBgBF,MAAAA,CAAAA,kBAAAA,EAAAA,oBAAAA,CAAAA;;;AChET,IAAMQ,eAAAA;;AAAgC,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgHtC,SAASC,sBAAAA,CAAuBC,QAAgBC,YAAAA,EAAoB;AACzE,EAAA;;AAAqB,IAAA;;SAEdD,MAAAA,CAAAA;wCAC+BC,YAAAA,CAAAA;UAC9BD,MAAAA,CAAAA;wCAC8BC,YAAAA,CAAAA;UAC9BD,MAAAA,CAAAA;wCAC8BC,YAAAA,CAAAA;UAC9BD,MAAAA,CAAAA;wCAC8BC,YAAAA,CAAAA;UAC9BD,MAAAA,CAAAA;wCAC8BC,YAAAA,CAAAA;;;;AAGxC;AAfgBF,MAAAA,CAAAA,sBAAAA,EAAAA,wBAAAA,CAAAA;;;ACnHT,IAAMG,kBAAAA,GAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmE3B,IAAMC,8BAAAA,GAAiC","file":"chunk-XD5ZK727.js","sourcesContent":["/**\n * @burdenoff/be-sdk/sharing\n *\n * Generic, Google-Docs-style sharing for any entity: invite → email → explicit\n * accept → enforced permission, plus shared-with-vibe / public-link / private\n * modes. Ship the `ShareGrant` table per service (see {@link SHARE_GRANT_PRISMA})\n * and drive everything through {@link ShareService}.\n */\n\nexport {\n ShareVisibility,\n ShareRole,\n ShareStatus,\n ROLE_ORDER,\n ROLE_CAPABILITIES,\n RESOURCE_CAPABILITY_MAP,\n roleAtLeast,\n maxRole,\n capabilitiesFor,\n roleToLegacy,\n legacyToRole,\n normalizeStatus,\n type ShareCapabilities,\n type ShareGrantRecord,\n type ShareGrantDelegate,\n type ResourceMeta,\n type SendShareEmailArgs,\n type ShareServiceDeps,\n type ShareServiceOptions,\n type ShareActor,\n type CreateUserShareInput,\n type CreateLinkShareInput,\n type AccessVia,\n type AccessResult,\n} from './types.js';\n\nexport { ShareService, type ShareServiceConfig } from './share-service.js';\n\nexport {\n SHARE_EMAIL_TEMPLATE_SLUG,\n RESOURCE_TYPE_LABELS,\n resourceTypeLabel,\n roleLabel,\n buildShareEmailVariables,\n makeSendShareEmail,\n type ShareEmailNotifier,\n} from './email.js';\n\nexport { SHARE_GRANT_SDL, buildPerEntityShareSdl } from './sdl.js';\n\nexport { SHARE_GRANT_PRISMA, SHARE_GRANT_PARTIAL_UNIQUE_SQL } from './prisma-fragment.js';\n","/**\n * Generic Sharing — canonical domain types\n *\n * One sharing model for every entity across the platform (sessions, vibes,\n * vibedecks, files, folders, notes, …). Each service pastes the `ShareGrant`\n * Prisma model (see `prisma-fragment.ts`) into its own schema and drives all\n * share/accept/permission logic through `ShareService` (see `share-service.ts`).\n *\n * The module owns ZERO database tables — three services keep three Postgres DBs,\n * so it talks to whatever Prisma client the host generates via the structural\n * {@link ShareGrantDelegate} type and never imports a concrete `@prisma/client`.\n *\n * @example\n * ```ts\n * import { ShareService, ShareRole, ShareVisibility } from '@burdenoff/be-sdk/sharing';\n * ```\n */\n\n// ---------------------------------------------------------------------------\n// Canonical enums (string values are stable across all services)\n// ---------------------------------------------------------------------------\n\n/** Who can reach a shared resource. */\nexport enum ShareVisibility {\n /** Only the creator/owner. */\n PRIVATE = 'PRIVATE',\n /** Specific people, by email invite + EXPLICIT accept (no access before accept). */\n SHARED_WITH_USERS = 'SHARED_WITH_USERS',\n /** Everyone who has access to the parent Vibe. */\n SHARED_WITH_VIBE = 'SHARED_WITH_VIBE',\n /** Anyone with the link. */\n PUBLIC_LINK = 'PUBLIC_LINK',\n}\n\n/**\n * The canonical permission ladder (ordinal: VIEWER < COMMENTER < EDITOR < MANAGER).\n * Mapped to per-entity verbs via {@link RESOURCE_CAPABILITY_MAP}.\n */\nexport enum ShareRole {\n /** Read only. */\n VIEWER = 'VIEWER',\n /** Read + comment. */\n COMMENTER = 'COMMENTER',\n /** Read + edit/run (session INTERACT, vibedeck EXECUTE, file EDIT). */\n EDITOR = 'EDITOR',\n /** Edit + re-share + revoke. */\n MANAGER = 'MANAGER',\n}\n\n/** Lifecycle of a share grant. */\nexport enum ShareStatus {\n /** Invited; recipient has NOT accepted — grants NO access. */\n PENDING = 'PENDING',\n /** Accepted (or immediately-active for public links) — grants access. */\n ACCEPTED = 'ACCEPTED',\n /** Manually revoked. */\n REVOKED = 'REVOKED',\n /** Past its expiry. */\n EXPIRED = 'EXPIRED',\n}\n\n/** Ordinal rank used for `>=` role comparisons. */\nexport const ROLE_ORDER: Record<ShareRole, number> = {\n [ShareRole.VIEWER]: 0,\n [ShareRole.COMMENTER]: 1,\n [ShareRole.EDITOR]: 2,\n [ShareRole.MANAGER]: 3,\n};\n\n/** True when `role` is at least as powerful as `required`. */\nexport function roleAtLeast(role: ShareRole, required: ShareRole): boolean {\n return ROLE_ORDER[role] >= ROLE_ORDER[required];\n}\n\n/** Returns the more powerful of two roles. */\nexport function maxRole(a: ShareRole, b: ShareRole): ShareRole {\n return ROLE_ORDER[a] >= ROLE_ORDER[b] ? a : b;\n}\n\n// ---------------------------------------------------------------------------\n// Capabilities\n// ---------------------------------------------------------------------------\n\nexport interface ShareCapabilities {\n canView: boolean;\n canComment: boolean;\n canEdit: boolean;\n canManage: boolean;\n /** EDITOR+ may run/execute (session INTERACT, vibedeck EXECUTE). */\n canExecute: boolean;\n}\n\nexport const ROLE_CAPABILITIES: Record<ShareRole, ShareCapabilities> = {\n [ShareRole.VIEWER]: { canView: true, canComment: false, canEdit: false, canManage: false, canExecute: false },\n [ShareRole.COMMENTER]: { canView: true, canComment: true, canEdit: false, canManage: false, canExecute: false },\n [ShareRole.EDITOR]: { canView: true, canComment: true, canEdit: true, canManage: false, canExecute: true },\n [ShareRole.MANAGER]: { canView: true, canComment: true, canEdit: true, canManage: true, canExecute: true },\n};\n\n/** Resolve the capability set for a role. */\nexport function capabilitiesFor(role: ShareRole): ShareCapabilities {\n return ROLE_CAPABILITIES[role];\n}\n\n/**\n * Per-entity translation of the canonical role to the entity's legacy permission\n * verb, for resolvers/data that still speak the old vocabulary. Unmapped\n * (resourceType, role) pairs fall back to the role name itself.\n */\nexport const RESOURCE_CAPABILITY_MAP: Record<string, Partial<Record<ShareRole, string>>> = {\n session: {\n [ShareRole.VIEWER]: 'VIEW',\n [ShareRole.COMMENTER]: 'VIEW',\n [ShareRole.EDITOR]: 'INTERACT',\n [ShareRole.MANAGER]: 'INTERACT',\n },\n vibedeck: {\n [ShareRole.VIEWER]: 'VIEW',\n [ShareRole.COMMENTER]: 'VIEW',\n [ShareRole.EDITOR]: 'EXECUTE',\n [ShareRole.MANAGER]: 'EXECUTE',\n },\n file: {\n [ShareRole.VIEWER]: 'VIEW',\n [ShareRole.COMMENTER]: 'COMMENT',\n [ShareRole.EDITOR]: 'EDIT',\n [ShareRole.MANAGER]: 'EDIT',\n },\n folder: {\n [ShareRole.VIEWER]: 'VIEW',\n [ShareRole.COMMENTER]: 'COMMENT',\n [ShareRole.EDITOR]: 'EDIT',\n [ShareRole.MANAGER]: 'EDIT',\n },\n};\n\n/** Map a canonical role to a resource's legacy permission verb. */\nexport function roleToLegacy(resourceType: string, role: ShareRole): string {\n return RESOURCE_CAPABILITY_MAP[resourceType]?.[role] ?? role;\n}\n\n/**\n * Map a legacy permission verb back to the canonical role for backfills.\n * Unknown verbs default to VIEWER (least privilege).\n */\nexport function legacyToRole(resourceType: string, legacy: string): ShareRole {\n const table = RESOURCE_CAPABILITY_MAP[resourceType];\n if (table) {\n // Ascending so a verb shared by two roles maps to the MINIMAL (least-privilege)\n // role — e.g. session INTERACT (EDITOR & MANAGER both map to it) ⇒ EDITOR.\n for (const role of [ShareRole.VIEWER, ShareRole.COMMENTER, ShareRole.EDITOR, ShareRole.MANAGER]) {\n if (table[role] === legacy) return role;\n }\n }\n switch (legacy.toUpperCase()) {\n case 'MANAGER':\n case 'OWNER':\n case 'ADMIN':\n return ShareRole.MANAGER;\n case 'EDITOR':\n case 'EDIT':\n case 'INTERACT':\n case 'EXECUTE':\n case 'WRITE':\n return ShareRole.EDITOR;\n case 'COMMENTER':\n case 'COMMENT':\n return ShareRole.COMMENTER;\n default:\n return ShareRole.VIEWER;\n }\n}\n\n/**\n * Normalize a legacy status string onto the canonical ladder. Older share tables\n * used `ACTIVE`; the canonical model uses `ACCEPTED`. Everything else maps 1:1.\n */\nexport function normalizeStatus(status: string): ShareStatus {\n const upper = status.toUpperCase();\n if (upper === 'ACTIVE') return ShareStatus.ACCEPTED;\n if (upper in ShareStatus) return upper as ShareStatus;\n return ShareStatus.PENDING;\n}\n\n// ---------------------------------------------------------------------------\n// Persisted record shape (mirrors SHARE_GRANT_PRISMA)\n// ---------------------------------------------------------------------------\n\nexport interface ShareGrantRecord {\n id: string;\n workspaceId: string;\n resourceType: string;\n resourceId: string;\n granteeUserId: string | null;\n granteeEmail: string | null;\n role: ShareRole;\n visibility: ShareVisibility;\n status: ShareStatus;\n token: string | null;\n expiresAt: Date | null;\n message: string | null;\n createdBy: string;\n onBehalfOf: string;\n acceptedAt: Date | null;\n acceptedBy: string | null;\n revokedAt: Date | null;\n revokedBy: string | null;\n lastAccessAt: Date | null;\n accessCount: number;\n context: unknown;\n createdAt: Date;\n updatedAt: Date;\n deletedAt: Date | null;\n}\n\n/**\n * Structural subset of a Prisma model delegate that {@link ShareService} needs.\n * Host services pass `prisma.shareGrant` here (cast with `as unknown as\n * ShareGrantDelegate` if their generated overloads don't line up structurally).\n * be-sdk never imports a concrete Prisma client.\n */\nexport interface ShareGrantDelegate {\n findFirst(args: { where: Record<string, unknown>; orderBy?: unknown }): Promise<ShareGrantRecord | null>;\n findMany(args: {\n where: Record<string, unknown>;\n orderBy?: unknown;\n take?: number;\n skip?: number;\n }): Promise<ShareGrantRecord[]>;\n create(args: { data: Record<string, unknown> }): Promise<ShareGrantRecord>;\n update(args: { where: Record<string, unknown>; data: Record<string, unknown> }): Promise<ShareGrantRecord>;\n updateMany(args: { where: Record<string, unknown>; data: Record<string, unknown> }): Promise<{ count: number }>;\n count(args: { where: Record<string, unknown> }): Promise<number>;\n}\n\n// ---------------------------------------------------------------------------\n// Host-supplied dependency seams\n// ---------------------------------------------------------------------------\n\n/** Metadata about the resource a grant points at, resolved by the host service. */\nexport interface ResourceMeta {\n /** The owner/creator actor id (always treated as MANAGER). */\n ownerId: string;\n /** Parent vibe id, when the resource is vibe-linked (enables SHARED_WITH_VIBE). */\n vibeId: string | null;\n /** The resource's own visibility flag. */\n visibility: ShareVisibility;\n /** Human-friendly name used in the share email. */\n name: string;\n}\n\nexport interface SendShareEmailArgs {\n recipientEmail: string | null;\n recipientUserId: string | null;\n resourceType: string;\n resourceName: string;\n role: ShareRole;\n acceptUrl: string;\n message: string | null;\n sharerName: string | null;\n /** Dedupe key (the grant id) so re-sends don't duplicate emails. */\n idempotencyKey: string;\n}\n\n/**\n * Host-specific seams injected into {@link ShareService}. All async functions must\n * fail-closed semantics where noted: `canAccess` treats a thrown `loadResourceMeta`\n * / `hasVibeAccess` as DENY.\n */\nexport interface ShareServiceDeps {\n /** Resolve an email to a user id, or null if no such user exists (fail-soft). */\n resolveUserByEmail(email: string): Promise<string | null>;\n /**\n * True/false if the user is/ isn't an active workspace member; null if the\n * lookup failed (caller decides — share-create denies only on explicit false).\n */\n isWorkspaceMember(userId: string, workspaceId: string): Promise<boolean | null>;\n /** True if the actor has access to the given vibe (owner / accepted grant / member). */\n hasVibeAccess(actorId: string, vibeId: string, workspaceId: string): Promise<boolean>;\n /** Load resource metadata; return null if the resource doesn't exist. */\n loadResourceMeta(resourceId: string): Promise<ResourceMeta | null>;\n /** Fire-and-forget share email; failures must not roll back the grant. */\n sendShareEmail(args: SendShareEmailArgs): Promise<void>;\n /** Build the public accept URL for a token (frontend owns the base route). */\n buildAcceptUrl(token: string): string;\n}\n\nexport interface ShareServiceOptions {\n /** Baseline role granted by SHARED_WITH_VIBE access. Defaults to VIEWER. */\n sharedWithVibeRole?: ShareRole;\n /**\n * When true (default), sharing with a user who resolves to a NON-member of the\n * workspace is rejected. Emails that don't resolve to any user are always\n * allowed (external invite — access still gated on accept).\n */\n requireWorkspaceMember?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Method inputs / results\n// ---------------------------------------------------------------------------\n\nexport interface ShareActor {\n id: string;\n email?: string | null;\n name?: string | null;\n}\n\nexport interface CreateUserShareInput {\n resourceId: string;\n granteeEmail: string;\n role: ShareRole;\n message?: string | null;\n expiresAt?: Date | null;\n}\n\nexport interface CreateLinkShareInput {\n resourceId: string;\n role: ShareRole;\n expiresAt?: Date | null;\n}\n\nexport type AccessVia = 'owner' | 'public_link' | 'vibe' | 'user_grant' | 'none';\n\nexport interface AccessResult {\n allowed: boolean;\n effectiveRole: ShareRole | null;\n via: AccessVia;\n}\n","/**\n * ShareService — generic, framework-agnostic share/accept/permission engine.\n *\n * Construct one per request, bound to a single resourceType:\n * ```ts\n * const svc = new ShareService({\n * prisma: ctx.prisma.shareGrant as unknown as ShareGrantDelegate,\n * resourceType: 'session',\n * workspaceId: ctx.workspace.id,\n * deps: { ... },\n * });\n * ```\n *\n * The security-critical primitive is {@link ShareService.canAccess}: it is\n * default-DENY, ignores PENDING grants (no access before accept), and fails\n * CLOSED on any thrown dependency.\n */\n\nimport { randomBytes } from 'node:crypto';\n\nimport { GraphQLError } from 'graphql';\n\nimport { logger } from '../logger/index.js';\nimport {\n ShareRole,\n ShareStatus,\n ShareVisibility,\n maxRole,\n roleAtLeast,\n type AccessResult,\n type CreateLinkShareInput,\n type CreateUserShareInput,\n type ShareActor,\n type ShareGrantDelegate,\n type ShareGrantRecord,\n type ShareServiceDeps,\n type ShareServiceOptions,\n} from './types.js';\n\n// The ShareGrant table's enum is PENDING/ACCEPTED/REVOKED/EXPIRED — there is no\n// 'ACTIVE' member. Including the legacy 'ACTIVE' literal here made every\n// `status: { in: [...] }` grant lookup throw PrismaClientValidationError, which\n// resolveAccess swallows and fail-closes — silently breaking ALL accepted-grant\n// access. Legacy 'ACTIVE' rows (if any) are normalized to ACCEPTED on read via\n// normalizeStatus(); the active-status filter is exactly ACCEPTED.\nconst ACTIVE_STATUSES = [ShareStatus.ACCEPTED] as const;\n\nconst DENY: AccessResult = { allowed: false, effectiveRole: null, via: 'none' };\n\nfunction notFound(message = 'Not found'): GraphQLError {\n return new GraphQLError(message, { extensions: { code: 'NOT_FOUND' } });\n}\nfunction forbidden(message = 'Forbidden'): GraphQLError {\n return new GraphQLError(message, { extensions: { code: 'FORBIDDEN' } });\n}\nfunction badRequest(message: string): GraphQLError {\n return new GraphQLError(message, { extensions: { code: 'BAD_REQUEST' } });\n}\n\nfunction generateToken(): string {\n // 32 bytes hex = 64 chars, matches token VarChar(64) column.\n return randomBytes(32).toString('hex');\n}\n\nfunction emailsMatch(a: string | null | undefined, b: string | null | undefined): boolean {\n return !!a && !!b && a.trim().toLowerCase() === b.trim().toLowerCase();\n}\n\ninterface RoleCandidate {\n role: ShareRole;\n via: AccessResult['via'];\n}\n\n/** Highest-role candidate, or null when there are none. */\nfunction pickHighestRole(candidates: RoleCandidate[]): RoleCandidate | null {\n let best: RoleCandidate | null = null;\n for (const c of candidates) {\n if (!best || (maxRole(best.role, c.role) === c.role && c.role !== best.role)) best = c;\n }\n return best;\n}\n\nexport interface ShareServiceConfig {\n prisma: ShareGrantDelegate;\n resourceType: string;\n workspaceId: string;\n deps: ShareServiceDeps;\n options?: ShareServiceOptions;\n}\n\nexport class ShareService {\n private readonly prisma: ShareGrantDelegate;\n private readonly resourceType: string;\n private readonly workspaceId: string;\n private readonly deps: ShareServiceDeps;\n private readonly sharedWithVibeRole: ShareRole;\n private readonly requireWorkspaceMember: boolean;\n\n constructor(config: ShareServiceConfig) {\n this.prisma = config.prisma;\n this.resourceType = config.resourceType;\n this.workspaceId = config.workspaceId;\n this.deps = config.deps;\n this.sharedWithVibeRole = config.options?.sharedWithVibeRole ?? ShareRole.VIEWER;\n this.requireWorkspaceMember = config.options?.requireWorkspaceMember ?? true;\n }\n\n // -------------------------------------------------------------------------\n // Access decisions\n // -------------------------------------------------------------------------\n\n /**\n * Resolve the EFFECTIVE access of `actorId` on `resourceId`.\n *\n * Default-DENY. Considers (highest wins): owner ⇒ MANAGER, an active\n * PUBLIC_LINK grant ⇒ its role, SHARED_WITH_VIBE + hasVibeAccess ⇒ baseline,\n * an ACCEPTED (never PENDING) non-expired SHARED_WITH_USERS grant ⇒ its role.\n * Fails CLOSED if a dependency throws.\n */\n async resolveAccess(actorId: string, resourceId: string): Promise<AccessResult> {\n try {\n const meta = await this.deps.loadResourceMeta(resourceId);\n if (!meta) return DENY;\n\n // Owner is always MANAGER.\n if (actorId && meta.ownerId === actorId) {\n return { allowed: true, effectiveRole: ShareRole.MANAGER, via: 'owner' };\n }\n\n const candidates: RoleCandidate[] = [];\n\n // SHARED_WITH_VIBE: everyone with parent-vibe access.\n if (meta.visibility === ShareVisibility.SHARED_WITH_VIBE && meta.vibeId && actorId) {\n if (await this.deps.hasVibeAccess(actorId, meta.vibeId, this.workspaceId)) {\n candidates.push({ role: this.sharedWithVibeRole, via: 'vibe' });\n }\n }\n\n // Grant-based: active PUBLIC_LINK (anyone) or an ACCEPTED user grant (this actor).\n for (const grant of await this.queryActiveAccessGrants(actorId, resourceId)) {\n const isPublic = grant.visibility === ShareVisibility.PUBLIC_LINK;\n const isMyUserGrant = grant.visibility === ShareVisibility.SHARED_WITH_USERS && grant.granteeUserId === actorId;\n if (isPublic) candidates.push({ role: grant.role, via: 'public_link' });\n else if (isMyUserGrant) candidates.push({ role: grant.role, via: 'user_grant' });\n }\n\n const best = pickHighestRole(candidates);\n if (!best) return DENY;\n return { allowed: true, effectiveRole: best.role, via: best.via };\n } catch (err) {\n // Fail CLOSED — never expose a resource because a dependency errored.\n logger.warn('[ShareService] resolveAccess failed; denying', {\n resourceType: this.resourceType,\n resourceId,\n err,\n });\n return DENY;\n }\n }\n\n /** Active (non-expired) PUBLIC_LINK grants + this actor's SHARED_WITH_USERS grants. */\n private async queryActiveAccessGrants(actorId: string, resourceId: string): Promise<ShareGrantRecord[]> {\n return this.prisma.findMany({\n where: {\n resourceType: this.resourceType,\n resourceId,\n deletedAt: null,\n status: { in: [...ACTIVE_STATUSES] },\n OR: [\n { visibility: ShareVisibility.PUBLIC_LINK },\n ...(actorId ? [{ granteeUserId: actorId, visibility: ShareVisibility.SHARED_WITH_USERS }] : []),\n ],\n AND: [{ OR: [{ expiresAt: null }, { expiresAt: { gt: new Date() } }] }],\n },\n });\n }\n\n /** True if `actorId` may act on `resourceId` at >= `requiredRole`. */\n async canAccess(actorId: string, resourceId: string, requiredRole: ShareRole): Promise<boolean> {\n const result = await this.resolveAccess(actorId, resourceId);\n return result.allowed && result.effectiveRole !== null && roleAtLeast(result.effectiveRole, requiredRole);\n }\n\n /** Assert >= requiredRole; throws NOT_FOUND (read) / FORBIDDEN (mutate) otherwise. */\n async assertAccess(\n actorId: string,\n resourceId: string,\n requiredRole: ShareRole,\n mode: 'read' | 'mutate' = 'read'\n ): Promise<void> {\n if (await this.canAccess(actorId, resourceId, requiredRole)) return;\n // Reads must not leak existence → NOT_FOUND; mutations → FORBIDDEN.\n throw mode === 'read' ? notFound() : forbidden('You do not have permission to perform this action');\n }\n\n // -------------------------------------------------------------------------\n // Share creation\n // -------------------------------------------------------------------------\n\n /** Invite a specific person by email (PENDING + token + email). */\n async createUserShare(actor: ShareActor, input: CreateUserShareInput): Promise<ShareGrantRecord> {\n const meta = await this.deps.loadResourceMeta(input.resourceId);\n if (!meta) throw notFound('Resource not found');\n\n // Only owner/MANAGER may share.\n await this.assertAccess(actor.id, input.resourceId, ShareRole.MANAGER, 'mutate');\n\n const email = input.granteeEmail.trim().toLowerCase();\n if (!email) throw badRequest('A recipient email is required');\n\n const granteeUserId = await this.deps.resolveUserByEmail(email);\n\n if (granteeUserId && granteeUserId === actor.id) {\n throw badRequest('You cannot share a resource with yourself');\n }\n\n // Workspace-member guard: deny only on an explicit non-member (null = lookup\n // failed → allow, fail-open on transient errors; access still gated on accept).\n if (granteeUserId && this.requireWorkspaceMember) {\n const isMember = await this.deps.isWorkspaceMember(granteeUserId, this.workspaceId);\n if (isMember === false) {\n throw forbidden('You can only share with members of this workspace');\n }\n }\n\n // Idempotent: reuse an existing active grant for the same recipient.\n const existing = await this.prisma.findFirst({\n where: {\n resourceType: this.resourceType,\n resourceId: input.resourceId,\n deletedAt: null,\n status: { in: [ShareStatus.PENDING, ShareStatus.ACCEPTED] },\n OR: [...(granteeUserId ? [{ granteeUserId }] : []), { granteeEmail: email }],\n },\n });\n\n let grant: ShareGrantRecord;\n if (existing) {\n grant = await this.prisma.update({\n where: { id: existing.id },\n data: {\n role: input.role,\n message: input.message ?? null,\n expiresAt: input.expiresAt ?? null,\n ...(granteeUserId && !existing.granteeUserId ? { granteeUserId } : {}),\n },\n });\n } else {\n grant = await this.prisma.create({\n data: {\n workspaceId: this.workspaceId,\n resourceType: this.resourceType,\n resourceId: input.resourceId,\n granteeUserId: granteeUserId ?? null,\n granteeEmail: email,\n role: input.role,\n visibility: ShareVisibility.SHARED_WITH_USERS,\n status: ShareStatus.PENDING,\n token: generateToken(),\n expiresAt: input.expiresAt ?? null,\n message: input.message ?? null,\n createdBy: actor.id,\n onBehalfOf: actor.id,\n },\n });\n }\n\n await this.fireShareEmail(actor, grant, meta.name);\n return grant;\n }\n\n /** Create an immediately-active public link (anyone with the URL). */\n async createLinkShare(actor: ShareActor, input: CreateLinkShareInput): Promise<ShareGrantRecord> {\n const meta = await this.deps.loadResourceMeta(input.resourceId);\n if (!meta) throw notFound('Resource not found');\n await this.assertAccess(actor.id, input.resourceId, ShareRole.MANAGER, 'mutate');\n\n return this.prisma.create({\n data: {\n workspaceId: this.workspaceId,\n resourceType: this.resourceType,\n resourceId: input.resourceId,\n granteeUserId: null,\n granteeEmail: null,\n role: input.role,\n visibility: ShareVisibility.PUBLIC_LINK,\n status: ShareStatus.ACCEPTED, // links are active on creation\n token: generateToken(),\n expiresAt: input.expiresAt ?? null,\n message: null,\n createdBy: actor.id,\n onBehalfOf: actor.id,\n },\n });\n }\n\n // -------------------------------------------------------------------------\n // Accept / decline\n // -------------------------------------------------------------------------\n\n /** Explicitly accept a SHARED_WITH_USERS invite. Idempotent. */\n async acceptShare(token: string, actor: ShareActor): Promise<ShareGrantRecord> {\n const grant = await this.findActiveByToken(token);\n if (!grant) throw notFound('This share link is invalid or has expired');\n\n if (grant.visibility === ShareVisibility.PUBLIC_LINK) {\n // Nothing to accept for a public link.\n return grant;\n }\n\n const idMatches = !!grant.granteeUserId && grant.granteeUserId === actor.id;\n const emailMatches = emailsMatch(grant.granteeEmail, actor.email);\n if (!idMatches && !emailMatches) {\n throw forbidden('This invitation was sent to a different account');\n }\n\n if (grant.status === ShareStatus.ACCEPTED) {\n // Idempotent — backfill granteeUserId if it was an email-only invite.\n if (!grant.granteeUserId) {\n return this.prisma.update({ where: { id: grant.id }, data: { granteeUserId: actor.id } });\n }\n return grant;\n }\n\n const now = new Date();\n const res = await this.prisma.updateMany({\n where: { id: grant.id, status: ShareStatus.PENDING },\n data: { status: ShareStatus.ACCEPTED, acceptedAt: now, acceptedBy: actor.id, granteeUserId: actor.id },\n });\n if (res.count === 0) {\n // Lost a race or already terminal — return current state.\n const fresh = await this.prisma.findFirst({ where: { id: grant.id } });\n if (fresh) return fresh;\n }\n const updated = await this.prisma.findFirst({ where: { id: grant.id } });\n if (!updated) throw notFound();\n return updated;\n }\n\n /** Decline an invite (marks it REVOKED). */\n async declineShare(token: string, actor: ShareActor): Promise<boolean> {\n const grant = await this.findActiveByToken(token);\n if (!grant) return false;\n const idMatches = !!grant.granteeUserId && grant.granteeUserId === actor.id;\n const emailMatches = emailsMatch(grant.granteeEmail, actor.email);\n if (!idMatches && !emailMatches) throw forbidden('This invitation was sent to a different account');\n await this.prisma.update({\n where: { id: grant.id },\n data: { status: ShareStatus.REVOKED, revokedAt: new Date(), revokedBy: actor.id },\n });\n return true;\n }\n\n /** Public preview of a grant by token (safe fields only — never the resource body). */\n async shareGrantByToken(token: string): Promise<ShareGrantRecord | null> {\n return this.findActiveByToken(token);\n }\n\n // -------------------------------------------------------------------------\n // Management\n // -------------------------------------------------------------------------\n\n /** Revoke a grant or link. Owner/MANAGER only. */\n async revoke(grantId: string, actor: ShareActor): Promise<ShareGrantRecord> {\n const grant = await this.prisma.findFirst({ where: { id: grantId, resourceType: this.resourceType } });\n if (!grant || grant.deletedAt) throw notFound();\n await this.assertAccess(actor.id, grant.resourceId, ShareRole.MANAGER, 'mutate');\n return this.prisma.update({\n where: { id: grantId },\n data: { status: ShareStatus.REVOKED, revokedAt: new Date(), revokedBy: actor.id },\n });\n }\n\n /** Change the role on a grant. Owner/MANAGER only. */\n async updateRole(grantId: string, role: ShareRole, actor: ShareActor): Promise<ShareGrantRecord> {\n const grant = await this.prisma.findFirst({ where: { id: grantId, resourceType: this.resourceType } });\n if (!grant || grant.deletedAt) throw notFound();\n await this.assertAccess(actor.id, grant.resourceId, ShareRole.MANAGER, 'mutate');\n return this.prisma.update({ where: { id: grantId }, data: { role } });\n }\n\n // -------------------------------------------------------------------------\n // Reads\n // -------------------------------------------------------------------------\n\n /** All active grants on a resource (caller must be owner/MANAGER — gate in resolver). */\n async resourceShares(resourceId: string): Promise<ShareGrantRecord[]> {\n return this.prisma.findMany({\n where: {\n resourceType: this.resourceType,\n resourceId,\n deletedAt: null,\n status: { in: [ShareStatus.PENDING, ShareStatus.ACCEPTED] },\n },\n orderBy: { createdAt: 'desc' },\n });\n }\n\n /** Grants where the actor is the (accepted-or-pending) grantee. */\n async sharesSharedWithMe(\n actorId: string,\n opts?: { resourceType?: string; take?: number; skip?: number }\n ): Promise<ShareGrantRecord[]> {\n return this.prisma.findMany({\n where: {\n ...(opts?.resourceType ? { resourceType: opts.resourceType } : {}),\n granteeUserId: actorId,\n deletedAt: null,\n status: ShareStatus.ACCEPTED,\n OR: [{ expiresAt: null }, { expiresAt: { gt: new Date() } }],\n },\n orderBy: { acceptedAt: 'desc' },\n take: opts?.take,\n skip: opts?.skip,\n });\n }\n\n /**\n * Resource ids the actor can see via an ACCEPTED user grant — for narrowing\n * list resolvers (`WHERE id IN (...)`).\n */\n async listAccessibleResourceIds(actorId: string): Promise<string[]> {\n const grants = await this.prisma.findMany({\n where: {\n resourceType: this.resourceType,\n granteeUserId: actorId,\n deletedAt: null,\n status: ShareStatus.ACCEPTED,\n visibility: ShareVisibility.SHARED_WITH_USERS,\n OR: [{ expiresAt: null }, { expiresAt: { gt: new Date() } }],\n },\n });\n return Array.from(new Set(grants.map((g) => g.resourceId)));\n }\n\n /** Resource ids with an active public link — for list narrowing. */\n async listPublicResourceIds(): Promise<string[]> {\n const grants = await this.prisma.findMany({\n where: {\n resourceType: this.resourceType,\n deletedAt: null,\n status: { in: [...ACTIVE_STATUSES] },\n visibility: ShareVisibility.PUBLIC_LINK,\n OR: [{ expiresAt: null }, { expiresAt: { gt: new Date() } }],\n },\n });\n return Array.from(new Set(grants.map((g) => g.resourceId)));\n }\n\n /** Increment access analytics (best-effort). */\n async touchAccess(grantId: string): Promise<void> {\n try {\n await this.prisma.update({\n where: { id: grantId },\n data: { lastAccessAt: new Date(), accessCount: { increment: 1 } },\n });\n } catch (err) {\n logger.debug('[ShareService] touchAccess failed', { grantId, err });\n }\n }\n\n // -------------------------------------------------------------------------\n // Internals\n // -------------------------------------------------------------------------\n\n private async findActiveByToken(token: string): Promise<ShareGrantRecord | null> {\n if (!token) return null;\n const grant = await this.prisma.findFirst({ where: { token, deletedAt: null } });\n if (!grant) return null;\n if (grant.status === ShareStatus.REVOKED) return null;\n if (grant.expiresAt && grant.expiresAt.getTime() <= Date.now()) return null;\n return grant;\n }\n\n private async fireShareEmail(actor: ShareActor, grant: ShareGrantRecord, resourceName: string): Promise<void> {\n if (!grant.token) return;\n try {\n await this.deps.sendShareEmail({\n recipientEmail: grant.granteeEmail,\n recipientUserId: grant.granteeUserId,\n resourceType: this.resourceType,\n resourceName,\n role: grant.role,\n acceptUrl: this.deps.buildAcceptUrl(grant.token),\n message: grant.message,\n sharerName: actor.name ?? null,\n idempotencyKey: grant.id,\n });\n } catch (err) {\n // Email is best-effort — the grant is the source of truth.\n logger.warn('[ShareService] share email failed; grant still created', {\n grantId: grant.id,\n resourceType: this.resourceType,\n err,\n });\n }\n }\n}\n","/**\n * Share-email helpers.\n *\n * The `resource-shared` template must be registered in global-notification-svc.\n * Services wire `ShareServiceDeps.sendShareEmail` via {@link makeSendShareEmail},\n * passing an object that speaks `sendWithTemplate` (e.g. `sdk.tenantNotifications`).\n */\n\nimport { logger } from '../logger/index.js';\nimport { ShareRole, type SendShareEmailArgs } from './types.js';\n\n/** notification-svc template slug for \"X shared <entity> with you\" emails. */\nexport const SHARE_EMAIL_TEMPLATE_SLUG = 'resource-shared';\n\n/** Human-friendly labels per resourceType for the email body. */\nexport const RESOURCE_TYPE_LABELS: Record<string, string> = {\n session: 'terminal session',\n vibe: 'Vibe',\n vibedeck: 'VibeDeck',\n note: 'note',\n aiprompt: 'AI prompt',\n aicontext: 'AI context',\n instructionfile: 'instruction file',\n tunnel: 'tunnel',\n action: 'action',\n file: 'file',\n folder: 'folder',\n conversation: 'conversation',\n catalog: 'catalog',\n component: 'component',\n template: 'template',\n docs: 'docs site',\n};\n\nexport function resourceTypeLabel(resourceType: string): string {\n return RESOURCE_TYPE_LABELS[resourceType] ?? resourceType;\n}\n\nconst ROLE_LABELS: Record<ShareRole, string> = {\n [ShareRole.VIEWER]: 'Viewer',\n [ShareRole.COMMENTER]: 'Commenter',\n [ShareRole.EDITOR]: 'Editor',\n [ShareRole.MANAGER]: 'Manager',\n};\n\nexport function roleLabel(role: ShareRole): string {\n return ROLE_LABELS[role];\n}\n\n/** Build the variable bag the `resource-shared` template renders. */\nexport function buildShareEmailVariables(args: SendShareEmailArgs): Record<string, unknown> {\n return {\n sharerName: args.sharerName ?? 'A teammate',\n resourceType: resourceTypeLabel(args.resourceType),\n resourceName: args.resourceName,\n roleLabel: roleLabel(args.role),\n acceptUrl: args.acceptUrl,\n message: args.message ?? '',\n };\n}\n\n/**\n * Minimal structural view of a notifications module that can send a templated\n * email. `sdk.tenantNotifications` satisfies this. platform defaults to EMAIL\n * inside the module, so it isn't part of this contract.\n */\nexport interface ShareEmailNotifier {\n sendWithTemplate(input: {\n templateSlug: string;\n variables: Record<string, unknown>;\n recipient: { email?: string; userId?: string; name?: string };\n }): Promise<string>;\n}\n\n/**\n * Build a `ShareServiceDeps.sendShareEmail` implementation backed by a\n * notifications module. Skips (no-throw) when there's no addressable recipient.\n */\nexport function makeSendShareEmail(notifier: ShareEmailNotifier): (args: SendShareEmailArgs) => Promise<void> {\n return async (args: SendShareEmailArgs): Promise<void> => {\n const recipient: { email?: string; userId?: string } = {};\n if (args.recipientEmail) recipient.email = args.recipientEmail;\n if (args.recipientUserId) recipient.userId = args.recipientUserId;\n if (!recipient.email && !recipient.userId) {\n logger.warn('[ShareEmail] no addressable recipient; skipping', { idempotencyKey: args.idempotencyKey });\n return;\n }\n logger.info('[ShareEmail] Sending resource-shared', {\n templateSlug: SHARE_EMAIL_TEMPLATE_SLUG,\n resourceType: args.resourceType,\n idempotencyKey: args.idempotencyKey,\n });\n await notifier.sendWithTemplate({\n templateSlug: SHARE_EMAIL_TEMPLATE_SLUG,\n variables: buildShareEmailVariables(args),\n recipient,\n });\n };\n}\n","/**\n * Reusable GraphQL SDL for the generic sharing feature.\n *\n * {@link SHARE_GRANT_SDL} carries the shared types/enums/inputs + the uniform\n * token/self fields and is declared ONCE per subgraph (in a `shared` module).\n * {@link buildPerEntityShareSdl} generates the thin per-entity wrappers that\n * each carry a STATIC `@rbac` directive (the gateway requires a literal\n * action/resource per field — a single generic `shareResource` field cannot be\n * RBAC-protected correctly).\n *\n * Both reference `@rbac` / `@key`, which the host subgraph already declares via\n * its federation/`@link` setup. DateTime is assumed available (be-sdk graphql).\n */\n\nexport const SHARE_GRANT_SDL = /* GraphQL */ `\n enum ShareRole {\n VIEWER\n COMMENTER\n EDITOR\n MANAGER\n }\n\n enum ShareGrantVisibility {\n PRIVATE\n SHARED_WITH_USERS\n SHARED_WITH_VIBE\n PUBLIC_LINK\n }\n\n enum ShareGrantStatus {\n PENDING\n ACCEPTED\n REVOKED\n EXPIRED\n }\n\n type ShareCapabilities {\n canView: Boolean!\n canComment: Boolean!\n canEdit: Boolean!\n canManage: Boolean!\n canExecute: Boolean!\n }\n\n type ShareGrant @key(fields: \"id\") {\n id: ID!\n resourceType: String!\n resourceId: ID!\n granteeUserId: ID\n granteeEmail: String\n role: ShareRole!\n visibility: ShareGrantVisibility!\n status: ShareGrantStatus!\n expiresAt: DateTime\n message: String\n createdBy: ID!\n acceptedAt: DateTime\n createdAt: DateTime!\n \"Public accept/link URL (present for invites and public links).\"\n shareUrl: String\n \"Capabilities implied by this grant's role.\"\n capabilities: ShareCapabilities!\n }\n\n type ShareGrantList {\n items: [ShareGrant!]!\n total: Int!\n }\n\n \"Safe, pre-login preview of a share invitation.\"\n type ShareGrantPreview {\n id: ID!\n resourceType: String!\n resourceName: String\n role: ShareRole!\n visibility: ShareGrantVisibility!\n status: ShareGrantStatus!\n sharerName: String\n expiresAt: DateTime\n }\n\n input ShareEntityInput {\n resourceId: ID!\n email: String!\n role: ShareRole!\n message: String\n expiresAt: DateTime\n }\n\n input UpdateShareRoleInput {\n resourceId: ID!\n shareId: ID!\n role: ShareRole!\n }\n\n input RevokeShareInput {\n resourceId: ID!\n shareId: ID!\n }\n\n input CreateShareLinkInput {\n resourceId: ID!\n role: ShareRole!\n expiresAt: DateTime\n }\n\n extend type Query {\n \"Pre-login preview of a share invite by token.\"\n shareGrantByToken(token: String!): ShareGrantPreview @rbac(public: true)\n \"Grants where the current user is the accepted grantee.\"\n sharesSharedWithMe(resourceType: String, pagination: PaginationInput): ShareGrantList! @rbac(scopeType: \"self\")\n }\n\n extend type Mutation {\n \"Accept a share invitation (recipient identified by the opaque token + email/id).\"\n acceptShare(token: String!): ShareGrant! @rbac(public: true)\n \"Decline a share invitation.\"\n declineShare(token: String!): Boolean! @rbac(public: true)\n }\n`;\n\n/**\n * Per-entity wrapper SDL. `entity` is the GraphQL-safe PascalCase name used in\n * the field name (e.g. `Session` → `shareSession`); `rbacResource` is the\n * resource string the gateway checks (e.g. `session`, `ai-prompt`).\n */\nexport function buildPerEntityShareSdl(entity: string, rbacResource: string): string {\n return /* GraphQL */ `\nextend type Mutation {\n share${entity}(input: ShareEntityInput!): ShareGrant!\n @rbac(action: \"share\", resource: \"${rbacResource}\", resourceIdArg: \"input.resourceId\", scopeType: \"wspace\")\n revoke${entity}Share(input: RevokeShareInput!): ShareGrant!\n @rbac(action: \"share\", resource: \"${rbacResource}\", resourceIdArg: \"input.resourceId\", scopeType: \"wspace\")\n update${entity}ShareRole(input: UpdateShareRoleInput!): ShareGrant!\n @rbac(action: \"share\", resource: \"${rbacResource}\", resourceIdArg: \"input.resourceId\", scopeType: \"wspace\")\n create${entity}ShareLink(input: CreateShareLinkInput!): ShareGrant!\n @rbac(action: \"share\", resource: \"${rbacResource}\", resourceIdArg: \"input.resourceId\", scopeType: \"wspace\")\n revoke${entity}ShareLink(input: RevokeShareInput!): ShareGrant!\n @rbac(action: \"share\", resource: \"${rbacResource}\", resourceIdArg: \"input.resourceId\", scopeType: \"wspace\")\n}\n`;\n}\n","/**\n * Canonical `ShareGrant` Prisma model + indexes, shipped as a copy-paste string.\n *\n * Each service pastes {@link SHARE_GRANT_PRISMA} into its own `prisma/schema/`\n * and runs `gendb`. Enum names are deliberately `ShareRole` /\n * `ShareGrantVisibility` / `ShareGrantStatus` so they never collide with the\n * legacy per-service `ShareStatus` / `VibeVisibility` enums. The Prisma FIELD\n * names stay camelCase (what {@link ShareService} reads/writes); `@map` keeps the\n * DB columns snake_case so {@link SHARE_GRANT_PARTIAL_UNIQUE_SQL} reads cleanly.\n */\n\nexport const SHARE_GRANT_PRISMA = `\nenum ShareRole {\n VIEWER\n COMMENTER\n EDITOR\n MANAGER\n}\n\nenum ShareGrantVisibility {\n PRIVATE\n SHARED_WITH_USERS\n SHARED_WITH_VIBE\n PUBLIC_LINK\n}\n\nenum ShareGrantStatus {\n PENDING\n ACCEPTED\n REVOKED\n EXPIRED\n}\n\n/// Generic resource share grant. \\`resourceType\\` discriminates the entity; one\n/// row per (resource, recipient) or per public link. See @burdenoff/be-sdk/sharing.\nmodel ShareGrant {\n id String @id @default(uuid())\n workspaceId String @map(\"workspace_id\") @db.VarChar(255)\n resourceType String @map(\"resource_type\") @db.VarChar(64)\n resourceId String @map(\"resource_id\") @db.VarChar(255)\n granteeUserId String? @map(\"grantee_user_id\") @db.VarChar(255)\n granteeEmail String? @map(\"grantee_email\") @db.VarChar(320)\n role ShareRole @default(VIEWER)\n visibility ShareGrantVisibility @default(SHARED_WITH_USERS)\n status ShareGrantStatus @default(PENDING)\n token String? @unique @db.VarChar(64)\n expiresAt DateTime? @map(\"expires_at\")\n message String? @db.Text\n createdBy String @map(\"created_by\") @db.VarChar(255)\n onBehalfOf String @map(\"on_behalf_of\") @db.VarChar(255)\n acceptedAt DateTime? @map(\"accepted_at\")\n acceptedBy String? @map(\"accepted_by\") @db.VarChar(255)\n revokedAt DateTime? @map(\"revoked_at\")\n revokedBy String? @map(\"revoked_by\") @db.VarChar(255)\n lastAccessAt DateTime? @map(\"last_access_at\")\n accessCount Int @default(0) @map(\"access_count\")\n context Json?\n createdAt DateTime @default(now()) @map(\"created_at\")\n updatedAt DateTime @updatedAt @map(\"updated_at\")\n deletedAt DateTime? @map(\"deleted_at\")\n\n @@index([workspaceId])\n @@index([resourceType, resourceId])\n @@index([granteeUserId])\n @@index([granteeEmail])\n @@index([status])\n @@index([expiresAt])\n @@index([resourceType, resourceId, status])\n @@map(\"share_grants\")\n}\n`;\n\n/**\n * Partial-unique index that Prisma's `@@unique` cannot express (it has no WHERE\n * predicate). Add this as a raw SQL step in the same migration that creates the\n * table. The table is brand new, so a plain (non-CONCURRENT) create is safe and\n * transaction-friendly.\n */\nexport const SHARE_GRANT_PARTIAL_UNIQUE_SQL = `\nCREATE UNIQUE INDEX IF NOT EXISTS share_grants_active_user_uq\n ON share_grants (resource_type, resource_id, grantee_user_id)\n WHERE status IN ('PENDING', 'ACCEPTED') AND deleted_at IS NULL AND grantee_user_id IS NOT NULL;\n`;\n"]}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
declare enum ShareVisibility {
|
|
2
|
+
PRIVATE = "PRIVATE",
|
|
3
|
+
SHARED_WITH_USERS = "SHARED_WITH_USERS",
|
|
4
|
+
SHARED_WITH_VIBE = "SHARED_WITH_VIBE",
|
|
5
|
+
PUBLIC_LINK = "PUBLIC_LINK"
|
|
6
|
+
}
|
|
7
|
+
declare enum ShareRole {
|
|
8
|
+
VIEWER = "VIEWER",
|
|
9
|
+
COMMENTER = "COMMENTER",
|
|
10
|
+
EDITOR = "EDITOR",
|
|
11
|
+
MANAGER = "MANAGER"
|
|
12
|
+
}
|
|
13
|
+
declare enum ShareStatus {
|
|
14
|
+
PENDING = "PENDING",
|
|
15
|
+
ACCEPTED = "ACCEPTED",
|
|
16
|
+
REVOKED = "REVOKED",
|
|
17
|
+
EXPIRED = "EXPIRED"
|
|
18
|
+
}
|
|
19
|
+
declare const ROLE_ORDER: Record<ShareRole, number>;
|
|
20
|
+
declare function roleAtLeast(role: ShareRole, required: ShareRole): boolean;
|
|
21
|
+
declare function maxRole(a: ShareRole, b: ShareRole): ShareRole;
|
|
22
|
+
interface ShareCapabilities {
|
|
23
|
+
canView: boolean;
|
|
24
|
+
canComment: boolean;
|
|
25
|
+
canEdit: boolean;
|
|
26
|
+
canManage: boolean;
|
|
27
|
+
canExecute: boolean;
|
|
28
|
+
}
|
|
29
|
+
declare const ROLE_CAPABILITIES: Record<ShareRole, ShareCapabilities>;
|
|
30
|
+
declare function capabilitiesFor(role: ShareRole): ShareCapabilities;
|
|
31
|
+
declare const RESOURCE_CAPABILITY_MAP: Record<string, Partial<Record<ShareRole, string>>>;
|
|
32
|
+
declare function roleToLegacy(resourceType: string, role: ShareRole): string;
|
|
33
|
+
declare function legacyToRole(resourceType: string, legacy: string): ShareRole;
|
|
34
|
+
declare function normalizeStatus(status: string): ShareStatus;
|
|
35
|
+
interface ShareGrantRecord {
|
|
36
|
+
id: string;
|
|
37
|
+
workspaceId: string;
|
|
38
|
+
resourceType: string;
|
|
39
|
+
resourceId: string;
|
|
40
|
+
granteeUserId: string | null;
|
|
41
|
+
granteeEmail: string | null;
|
|
42
|
+
role: ShareRole;
|
|
43
|
+
visibility: ShareVisibility;
|
|
44
|
+
status: ShareStatus;
|
|
45
|
+
token: string | null;
|
|
46
|
+
expiresAt: Date | null;
|
|
47
|
+
message: string | null;
|
|
48
|
+
createdBy: string;
|
|
49
|
+
onBehalfOf: string;
|
|
50
|
+
acceptedAt: Date | null;
|
|
51
|
+
acceptedBy: string | null;
|
|
52
|
+
revokedAt: Date | null;
|
|
53
|
+
revokedBy: string | null;
|
|
54
|
+
lastAccessAt: Date | null;
|
|
55
|
+
accessCount: number;
|
|
56
|
+
context: unknown;
|
|
57
|
+
createdAt: Date;
|
|
58
|
+
updatedAt: Date;
|
|
59
|
+
deletedAt: Date | null;
|
|
60
|
+
}
|
|
61
|
+
interface ShareGrantDelegate {
|
|
62
|
+
findFirst(args: {
|
|
63
|
+
where: Record<string, unknown>;
|
|
64
|
+
orderBy?: unknown;
|
|
65
|
+
}): Promise<ShareGrantRecord | null>;
|
|
66
|
+
findMany(args: {
|
|
67
|
+
where: Record<string, unknown>;
|
|
68
|
+
orderBy?: unknown;
|
|
69
|
+
take?: number;
|
|
70
|
+
skip?: number;
|
|
71
|
+
}): Promise<ShareGrantRecord[]>;
|
|
72
|
+
create(args: {
|
|
73
|
+
data: Record<string, unknown>;
|
|
74
|
+
}): Promise<ShareGrantRecord>;
|
|
75
|
+
update(args: {
|
|
76
|
+
where: Record<string, unknown>;
|
|
77
|
+
data: Record<string, unknown>;
|
|
78
|
+
}): Promise<ShareGrantRecord>;
|
|
79
|
+
updateMany(args: {
|
|
80
|
+
where: Record<string, unknown>;
|
|
81
|
+
data: Record<string, unknown>;
|
|
82
|
+
}): Promise<{
|
|
83
|
+
count: number;
|
|
84
|
+
}>;
|
|
85
|
+
count(args: {
|
|
86
|
+
where: Record<string, unknown>;
|
|
87
|
+
}): Promise<number>;
|
|
88
|
+
}
|
|
89
|
+
interface ResourceMeta {
|
|
90
|
+
ownerId: string;
|
|
91
|
+
vibeId: string | null;
|
|
92
|
+
visibility: ShareVisibility;
|
|
93
|
+
name: string;
|
|
94
|
+
}
|
|
95
|
+
interface SendShareEmailArgs {
|
|
96
|
+
recipientEmail: string | null;
|
|
97
|
+
recipientUserId: string | null;
|
|
98
|
+
resourceType: string;
|
|
99
|
+
resourceName: string;
|
|
100
|
+
role: ShareRole;
|
|
101
|
+
acceptUrl: string;
|
|
102
|
+
message: string | null;
|
|
103
|
+
sharerName: string | null;
|
|
104
|
+
idempotencyKey: string;
|
|
105
|
+
}
|
|
106
|
+
interface ShareServiceDeps {
|
|
107
|
+
resolveUserByEmail(email: string): Promise<string | null>;
|
|
108
|
+
isWorkspaceMember(userId: string, workspaceId: string): Promise<boolean | null>;
|
|
109
|
+
hasVibeAccess(actorId: string, vibeId: string, workspaceId: string): Promise<boolean>;
|
|
110
|
+
loadResourceMeta(resourceId: string): Promise<ResourceMeta | null>;
|
|
111
|
+
sendShareEmail(args: SendShareEmailArgs): Promise<void>;
|
|
112
|
+
buildAcceptUrl(token: string): string;
|
|
113
|
+
}
|
|
114
|
+
interface ShareServiceOptions {
|
|
115
|
+
sharedWithVibeRole?: ShareRole;
|
|
116
|
+
requireWorkspaceMember?: boolean;
|
|
117
|
+
}
|
|
118
|
+
interface ShareActor {
|
|
119
|
+
id: string;
|
|
120
|
+
email?: string | null;
|
|
121
|
+
name?: string | null;
|
|
122
|
+
}
|
|
123
|
+
interface CreateUserShareInput {
|
|
124
|
+
resourceId: string;
|
|
125
|
+
granteeEmail: string;
|
|
126
|
+
role: ShareRole;
|
|
127
|
+
message?: string | null;
|
|
128
|
+
expiresAt?: Date | null;
|
|
129
|
+
}
|
|
130
|
+
interface CreateLinkShareInput {
|
|
131
|
+
resourceId: string;
|
|
132
|
+
role: ShareRole;
|
|
133
|
+
expiresAt?: Date | null;
|
|
134
|
+
}
|
|
135
|
+
type AccessVia = 'owner' | 'public_link' | 'vibe' | 'user_grant' | 'none';
|
|
136
|
+
interface AccessResult {
|
|
137
|
+
allowed: boolean;
|
|
138
|
+
effectiveRole: ShareRole | null;
|
|
139
|
+
via: AccessVia;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
interface ShareServiceConfig {
|
|
143
|
+
prisma: ShareGrantDelegate;
|
|
144
|
+
resourceType: string;
|
|
145
|
+
workspaceId: string;
|
|
146
|
+
deps: ShareServiceDeps;
|
|
147
|
+
options?: ShareServiceOptions;
|
|
148
|
+
}
|
|
149
|
+
declare class ShareService {
|
|
150
|
+
private readonly prisma;
|
|
151
|
+
private readonly resourceType;
|
|
152
|
+
private readonly workspaceId;
|
|
153
|
+
private readonly deps;
|
|
154
|
+
private readonly sharedWithVibeRole;
|
|
155
|
+
private readonly requireWorkspaceMember;
|
|
156
|
+
constructor(config: ShareServiceConfig);
|
|
157
|
+
resolveAccess(actorId: string, resourceId: string): Promise<AccessResult>;
|
|
158
|
+
private queryActiveAccessGrants;
|
|
159
|
+
canAccess(actorId: string, resourceId: string, requiredRole: ShareRole): Promise<boolean>;
|
|
160
|
+
assertAccess(actorId: string, resourceId: string, requiredRole: ShareRole, mode?: 'read' | 'mutate'): Promise<void>;
|
|
161
|
+
createUserShare(actor: ShareActor, input: CreateUserShareInput): Promise<ShareGrantRecord>;
|
|
162
|
+
createLinkShare(actor: ShareActor, input: CreateLinkShareInput): Promise<ShareGrantRecord>;
|
|
163
|
+
acceptShare(token: string, actor: ShareActor): Promise<ShareGrantRecord>;
|
|
164
|
+
declineShare(token: string, actor: ShareActor): Promise<boolean>;
|
|
165
|
+
shareGrantByToken(token: string): Promise<ShareGrantRecord | null>;
|
|
166
|
+
revoke(grantId: string, actor: ShareActor): Promise<ShareGrantRecord>;
|
|
167
|
+
updateRole(grantId: string, role: ShareRole, actor: ShareActor): Promise<ShareGrantRecord>;
|
|
168
|
+
resourceShares(resourceId: string): Promise<ShareGrantRecord[]>;
|
|
169
|
+
sharesSharedWithMe(actorId: string, opts?: {
|
|
170
|
+
resourceType?: string;
|
|
171
|
+
take?: number;
|
|
172
|
+
skip?: number;
|
|
173
|
+
}): Promise<ShareGrantRecord[]>;
|
|
174
|
+
listAccessibleResourceIds(actorId: string): Promise<string[]>;
|
|
175
|
+
listPublicResourceIds(): Promise<string[]>;
|
|
176
|
+
touchAccess(grantId: string): Promise<void>;
|
|
177
|
+
private findActiveByToken;
|
|
178
|
+
private fireShareEmail;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
declare const SHARE_EMAIL_TEMPLATE_SLUG = "resource-shared";
|
|
182
|
+
declare const RESOURCE_TYPE_LABELS: Record<string, string>;
|
|
183
|
+
declare function resourceTypeLabel(resourceType: string): string;
|
|
184
|
+
declare function roleLabel(role: ShareRole): string;
|
|
185
|
+
declare function buildShareEmailVariables(args: SendShareEmailArgs): Record<string, unknown>;
|
|
186
|
+
interface ShareEmailNotifier {
|
|
187
|
+
sendWithTemplate(input: {
|
|
188
|
+
templateSlug: string;
|
|
189
|
+
variables: Record<string, unknown>;
|
|
190
|
+
recipient: {
|
|
191
|
+
email?: string;
|
|
192
|
+
userId?: string;
|
|
193
|
+
name?: string;
|
|
194
|
+
};
|
|
195
|
+
}): Promise<string>;
|
|
196
|
+
}
|
|
197
|
+
declare function makeSendShareEmail(notifier: ShareEmailNotifier): (args: SendShareEmailArgs) => Promise<void>;
|
|
198
|
+
|
|
199
|
+
declare const SHARE_GRANT_SDL = "\n enum ShareRole {\n VIEWER\n COMMENTER\n EDITOR\n MANAGER\n }\n\n enum ShareGrantVisibility {\n PRIVATE\n SHARED_WITH_USERS\n SHARED_WITH_VIBE\n PUBLIC_LINK\n }\n\n enum ShareGrantStatus {\n PENDING\n ACCEPTED\n REVOKED\n EXPIRED\n }\n\n type ShareCapabilities {\n canView: Boolean!\n canComment: Boolean!\n canEdit: Boolean!\n canManage: Boolean!\n canExecute: Boolean!\n }\n\n type ShareGrant @key(fields: \"id\") {\n id: ID!\n resourceType: String!\n resourceId: ID!\n granteeUserId: ID\n granteeEmail: String\n role: ShareRole!\n visibility: ShareGrantVisibility!\n status: ShareGrantStatus!\n expiresAt: DateTime\n message: String\n createdBy: ID!\n acceptedAt: DateTime\n createdAt: DateTime!\n \"Public accept/link URL (present for invites and public links).\"\n shareUrl: String\n \"Capabilities implied by this grant's role.\"\n capabilities: ShareCapabilities!\n }\n\n type ShareGrantList {\n items: [ShareGrant!]!\n total: Int!\n }\n\n \"Safe, pre-login preview of a share invitation.\"\n type ShareGrantPreview {\n id: ID!\n resourceType: String!\n resourceName: String\n role: ShareRole!\n visibility: ShareGrantVisibility!\n status: ShareGrantStatus!\n sharerName: String\n expiresAt: DateTime\n }\n\n input ShareEntityInput {\n resourceId: ID!\n email: String!\n role: ShareRole!\n message: String\n expiresAt: DateTime\n }\n\n input UpdateShareRoleInput {\n resourceId: ID!\n shareId: ID!\n role: ShareRole!\n }\n\n input RevokeShareInput {\n resourceId: ID!\n shareId: ID!\n }\n\n input CreateShareLinkInput {\n resourceId: ID!\n role: ShareRole!\n expiresAt: DateTime\n }\n\n extend type Query {\n \"Pre-login preview of a share invite by token.\"\n shareGrantByToken(token: String!): ShareGrantPreview @rbac(public: true)\n \"Grants where the current user is the accepted grantee.\"\n sharesSharedWithMe(resourceType: String, pagination: PaginationInput): ShareGrantList! @rbac(scopeType: \"self\")\n }\n\n extend type Mutation {\n \"Accept a share invitation (recipient identified by the opaque token + email/id).\"\n acceptShare(token: String!): ShareGrant! @rbac(public: true)\n \"Decline a share invitation.\"\n declineShare(token: String!): Boolean! @rbac(public: true)\n }\n";
|
|
200
|
+
declare function buildPerEntityShareSdl(entity: string, rbacResource: string): string;
|
|
201
|
+
|
|
202
|
+
declare const SHARE_GRANT_PRISMA = "\nenum ShareRole {\n VIEWER\n COMMENTER\n EDITOR\n MANAGER\n}\n\nenum ShareGrantVisibility {\n PRIVATE\n SHARED_WITH_USERS\n SHARED_WITH_VIBE\n PUBLIC_LINK\n}\n\nenum ShareGrantStatus {\n PENDING\n ACCEPTED\n REVOKED\n EXPIRED\n}\n\n/// Generic resource share grant. `resourceType` discriminates the entity; one\n/// row per (resource, recipient) or per public link. See @burdenoff/be-sdk/sharing.\nmodel ShareGrant {\n id String @id @default(uuid())\n workspaceId String @map(\"workspace_id\") @db.VarChar(255)\n resourceType String @map(\"resource_type\") @db.VarChar(64)\n resourceId String @map(\"resource_id\") @db.VarChar(255)\n granteeUserId String? @map(\"grantee_user_id\") @db.VarChar(255)\n granteeEmail String? @map(\"grantee_email\") @db.VarChar(320)\n role ShareRole @default(VIEWER)\n visibility ShareGrantVisibility @default(SHARED_WITH_USERS)\n status ShareGrantStatus @default(PENDING)\n token String? @unique @db.VarChar(64)\n expiresAt DateTime? @map(\"expires_at\")\n message String? @db.Text\n createdBy String @map(\"created_by\") @db.VarChar(255)\n onBehalfOf String @map(\"on_behalf_of\") @db.VarChar(255)\n acceptedAt DateTime? @map(\"accepted_at\")\n acceptedBy String? @map(\"accepted_by\") @db.VarChar(255)\n revokedAt DateTime? @map(\"revoked_at\")\n revokedBy String? @map(\"revoked_by\") @db.VarChar(255)\n lastAccessAt DateTime? @map(\"last_access_at\")\n accessCount Int @default(0) @map(\"access_count\")\n context Json?\n createdAt DateTime @default(now()) @map(\"created_at\")\n updatedAt DateTime @updatedAt @map(\"updated_at\")\n deletedAt DateTime? @map(\"deleted_at\")\n\n @@index([workspaceId])\n @@index([resourceType, resourceId])\n @@index([granteeUserId])\n @@index([granteeEmail])\n @@index([status])\n @@index([expiresAt])\n @@index([resourceType, resourceId, status])\n @@map(\"share_grants\")\n}\n";
|
|
203
|
+
declare const SHARE_GRANT_PARTIAL_UNIQUE_SQL = "\nCREATE UNIQUE INDEX IF NOT EXISTS share_grants_active_user_uq\n ON share_grants (resource_type, resource_id, grantee_user_id)\n WHERE status IN ('PENDING', 'ACCEPTED') AND deleted_at IS NULL AND grantee_user_id IS NOT NULL;\n";
|
|
204
|
+
|
|
205
|
+
type index_AccessResult = AccessResult;
|
|
206
|
+
type index_AccessVia = AccessVia;
|
|
207
|
+
type index_CreateLinkShareInput = CreateLinkShareInput;
|
|
208
|
+
type index_CreateUserShareInput = CreateUserShareInput;
|
|
209
|
+
declare const index_RESOURCE_CAPABILITY_MAP: typeof RESOURCE_CAPABILITY_MAP;
|
|
210
|
+
declare const index_RESOURCE_TYPE_LABELS: typeof RESOURCE_TYPE_LABELS;
|
|
211
|
+
declare const index_ROLE_CAPABILITIES: typeof ROLE_CAPABILITIES;
|
|
212
|
+
declare const index_ROLE_ORDER: typeof ROLE_ORDER;
|
|
213
|
+
type index_ResourceMeta = ResourceMeta;
|
|
214
|
+
declare const index_SHARE_EMAIL_TEMPLATE_SLUG: typeof SHARE_EMAIL_TEMPLATE_SLUG;
|
|
215
|
+
declare const index_SHARE_GRANT_PARTIAL_UNIQUE_SQL: typeof SHARE_GRANT_PARTIAL_UNIQUE_SQL;
|
|
216
|
+
declare const index_SHARE_GRANT_PRISMA: typeof SHARE_GRANT_PRISMA;
|
|
217
|
+
declare const index_SHARE_GRANT_SDL: typeof SHARE_GRANT_SDL;
|
|
218
|
+
type index_SendShareEmailArgs = SendShareEmailArgs;
|
|
219
|
+
type index_ShareActor = ShareActor;
|
|
220
|
+
type index_ShareCapabilities = ShareCapabilities;
|
|
221
|
+
type index_ShareEmailNotifier = ShareEmailNotifier;
|
|
222
|
+
type index_ShareGrantDelegate = ShareGrantDelegate;
|
|
223
|
+
type index_ShareGrantRecord = ShareGrantRecord;
|
|
224
|
+
type index_ShareRole = ShareRole;
|
|
225
|
+
declare const index_ShareRole: typeof ShareRole;
|
|
226
|
+
type index_ShareService = ShareService;
|
|
227
|
+
declare const index_ShareService: typeof ShareService;
|
|
228
|
+
type index_ShareServiceConfig = ShareServiceConfig;
|
|
229
|
+
type index_ShareServiceDeps = ShareServiceDeps;
|
|
230
|
+
type index_ShareServiceOptions = ShareServiceOptions;
|
|
231
|
+
type index_ShareStatus = ShareStatus;
|
|
232
|
+
declare const index_ShareStatus: typeof ShareStatus;
|
|
233
|
+
type index_ShareVisibility = ShareVisibility;
|
|
234
|
+
declare const index_ShareVisibility: typeof ShareVisibility;
|
|
235
|
+
declare const index_buildPerEntityShareSdl: typeof buildPerEntityShareSdl;
|
|
236
|
+
declare const index_buildShareEmailVariables: typeof buildShareEmailVariables;
|
|
237
|
+
declare const index_capabilitiesFor: typeof capabilitiesFor;
|
|
238
|
+
declare const index_legacyToRole: typeof legacyToRole;
|
|
239
|
+
declare const index_makeSendShareEmail: typeof makeSendShareEmail;
|
|
240
|
+
declare const index_maxRole: typeof maxRole;
|
|
241
|
+
declare const index_normalizeStatus: typeof normalizeStatus;
|
|
242
|
+
declare const index_resourceTypeLabel: typeof resourceTypeLabel;
|
|
243
|
+
declare const index_roleAtLeast: typeof roleAtLeast;
|
|
244
|
+
declare const index_roleLabel: typeof roleLabel;
|
|
245
|
+
declare const index_roleToLegacy: typeof roleToLegacy;
|
|
246
|
+
declare namespace index {
|
|
247
|
+
export { type index_AccessResult as AccessResult, type index_AccessVia as AccessVia, type index_CreateLinkShareInput as CreateLinkShareInput, type index_CreateUserShareInput as CreateUserShareInput, index_RESOURCE_CAPABILITY_MAP as RESOURCE_CAPABILITY_MAP, index_RESOURCE_TYPE_LABELS as RESOURCE_TYPE_LABELS, index_ROLE_CAPABILITIES as ROLE_CAPABILITIES, index_ROLE_ORDER as ROLE_ORDER, type index_ResourceMeta as ResourceMeta, index_SHARE_EMAIL_TEMPLATE_SLUG as SHARE_EMAIL_TEMPLATE_SLUG, index_SHARE_GRANT_PARTIAL_UNIQUE_SQL as SHARE_GRANT_PARTIAL_UNIQUE_SQL, index_SHARE_GRANT_PRISMA as SHARE_GRANT_PRISMA, index_SHARE_GRANT_SDL as SHARE_GRANT_SDL, type index_SendShareEmailArgs as SendShareEmailArgs, type index_ShareActor as ShareActor, type index_ShareCapabilities as ShareCapabilities, type index_ShareEmailNotifier as ShareEmailNotifier, type index_ShareGrantDelegate as ShareGrantDelegate, type index_ShareGrantRecord as ShareGrantRecord, index_ShareRole as ShareRole, index_ShareService as ShareService, type index_ShareServiceConfig as ShareServiceConfig, type index_ShareServiceDeps as ShareServiceDeps, type index_ShareServiceOptions as ShareServiceOptions, index_ShareStatus as ShareStatus, index_ShareVisibility as ShareVisibility, index_buildPerEntityShareSdl as buildPerEntityShareSdl, index_buildShareEmailVariables as buildShareEmailVariables, index_capabilitiesFor as capabilitiesFor, index_legacyToRole as legacyToRole, index_makeSendShareEmail as makeSendShareEmail, index_maxRole as maxRole, index_normalizeStatus as normalizeStatus, index_resourceTypeLabel as resourceTypeLabel, index_roleAtLeast as roleAtLeast, index_roleLabel as roleLabel, index_roleToLegacy as roleToLegacy };
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export { type AccessResult as A, legacyToRole as B, type CreateLinkShareInput as C, makeSendShareEmail as D, maxRole as E, normalizeStatus as F, resourceTypeLabel as G, roleAtLeast as H, roleLabel as I, roleToLegacy as J, RESOURCE_CAPABILITY_MAP as R, SHARE_EMAIL_TEMPLATE_SLUG as S, type AccessVia as a, type CreateUserShareInput as b, RESOURCE_TYPE_LABELS as c, ROLE_CAPABILITIES as d, ROLE_ORDER as e, type ResourceMeta as f, SHARE_GRANT_PARTIAL_UNIQUE_SQL as g, SHARE_GRANT_PRISMA as h, index as i, SHARE_GRANT_SDL as j, type SendShareEmailArgs as k, type ShareActor as l, type ShareCapabilities as m, type ShareEmailNotifier as n, type ShareGrantDelegate as o, type ShareGrantRecord as p, ShareRole as q, ShareService as r, type ShareServiceConfig as s, type ShareServiceDeps as t, type ShareServiceOptions as u, ShareStatus as v, ShareVisibility as w, buildPerEntityShareSdl as x, buildShareEmailVariables as y, capabilitiesFor as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { TemporalModule } from './temporal/index.js';
|
|
|
18
18
|
export { TemporalClient, TemporalClientConfig, TemporalClientFactory, TemporalWorker, TemporalWorkerConfig, TemporalWorkerFactory, TemporalWorkerManager, WorkflowStartOptions } from './temporal/index.js';
|
|
19
19
|
export { createInternalClient, createInternalClientForTenant, createInternalClientForWorkspaces } from './client/internal-client.js';
|
|
20
20
|
export { PlanTier, RESOURCE_CAP_DEFAULTS, ResourceCap, ResourceCapDefaults, ResourceCapExceededError, ResourceCapsConfig, ResourceCapsModule, ResourceName, getResourceCaps } from './resource-caps/index.js';
|
|
21
|
+
export { i as Sharing } from './index-kssw5ziY.js';
|
|
21
22
|
export { i as Cache } from './index-cnFnfIjk.js';
|
|
22
23
|
export { i as Middleware } from './index-DSOpj8DI.js';
|
|
23
24
|
export { i as Observability } from './index-4gKQKZ2B.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { prisma_exports as Prisma } from './chunk-54BMP5OJ.js';
|
|
2
2
|
export { RESOURCE_CAP_DEFAULTS, ResourceCapExceededError, ResourceCapsModule, getResourceCaps } from './chunk-VDDOGIWY.js';
|
|
3
3
|
import './chunk-GTEMQXCA.js';
|
|
4
|
+
export { sharing_exports as Sharing } from './chunk-XD5ZK727.js';
|
|
4
5
|
export { TemporalClient, TemporalClientFactory, TemporalModule, TemporalWorker, TemporalWorkerFactory, TemporalWorkerManager } from './chunk-5SD7DU3L.js';
|
|
5
6
|
import { ActivityModule, UsageModule, TrackerModule } from './chunk-PPIDJP2W.js';
|
|
6
7
|
export { ActivityModule, TrackerModule, UsageModule } from './chunk-PPIDJP2W.js';
|