logo logo
Design: Database: BID-Data meta

Database BID-Data (BID is randomly generated ulid for a bundle)
Purpose Hold the actual zip file data for a bundle.
Cardinality one BID-Data database per bundle in the engagement
one item whose associated file contains the Zip data for the bundle
Source Code
Items src/ts/dbitems/BID-Data.ts
Zod Models
item BIDDataItem
item.item BIDDataRecord
itemId number of bundle in the Bundles database
item: BIDDataRecord
    kind 'biddata'
    bnum number of bundle in the Bundles database (same as itemId)
    root root from bundle settings


The BID-Data database is created by the host when a new bundle is uploaded. It contains a single BIDDataItem whose associated file holds the Zip data for the bundle.

(see userbase-js/types/index.d.ts)

  export interface Item {              userbase item                  userbase file
    itemId: string                    ╭────────────────────────┐     ┌──────────┐
    item: any ───────────────────────▶│ kind: 'biddata'        │╶╶╶╶ │ zip file │
    createdBy: Attribution            │ bnum: 1                │     └──────────┘
    updatedBy?: Attribution           │ root: '/'              │
    fileId?: string                   ╰────────────────────────┘
    fileName?: string
    fileSize?: number
    fileUploadedBy?: Attribution
    writeAccess?: AccessControl

The database name uses the randomly generated BID (bundle ID) from the corresponding record in the Bundles database as a prefix.

Ownership and Access

The BID-Data database is owned by the host.

It is initially not shared with any members and readable only by the host.

When the host shares bundle with a member the corresponding BID-Data Userbase database is shared in one of two ways depending on whether or not the bundle is restricted or unrestricted and whether or not the member has accepted their invitation.

                bundle is:

                    unrestricted        restricted
  member is:      ╭────────────────┬───────────────────╮
                  │                │                   │
     invited      │     GUEST      │      ESCROW       │
                  │                │                   │
                  │                │                   │
     accepted     │     GUEST      │       GUEST       │
                  │                │                   │
  • If the bundle is unrestricted or the member has accepted the invitation then the host grants read access for the BID-Data database to the member's GUEST user when the bundle is shared.

  • If the bundle is restricted and the member has not accepted the invitation then the host grants read access for the BID-Data database to the member's ESCROW user when the bundle is shared.

    Later when the member accepts the terms, Securepub uses the credentials stored in the ULID-Bundles database to signin as the ESCROW user and reshare the BID-Data database with the GUEST user.

    After the invitation is accepted the temporary ESCROW user is deleted.

Zod models

The following Zod models show how the Userbase items are represented in memory.

Note that in addition to the values specified by the Userbase Item interface the kind and database attributes are added during deserialization.

export type  BIDDataItem = z.infer<typeof BIDDataItem>;
export const BIDDataItem = z.object({
  kind:                 z.literal('biddataitem'),
  fileId:               z.string().optional(),
  itemId:               z.string(),
  item:                 BIDDataRecord,
  updatedBy:            z.custom<Attribution>(),
  fileUploadedBy:       z.custom<Attribution>(),
  database:             z.custom<Database>()
export type  BIDDataRecord = z.infer<typeof BIDDataRecord>;
export const BIDDataRecord = z.object({
  kind:                 z.literal('biddata'),
  bnum:                 z.number(),
  root:                 z.string()