Skip to content

basalt / tenancy/src / MemoryTenantSource

Class: MemoryTenantSource ​

Defined in: tenancy/src/tenant.ts:174

In-memory source — tests, dev and small single-node setups.

Implements ​

Constructors ​

Constructor ​

> new MemoryTenantSource(options?): MemoryTenantSource

Defined in: tenancy/src/tenant.ts:183

validateTenantId — the id grammar create()/save() enforce. Default isValidTenantId; pass the same function you give tenancyPlugin if you widen or narrow it there.

Parameters ​

options? ​
validateTenantId? ​

(id) => boolean

Returns ​

MemoryTenantSource

Methods ​

add() ​

> add(tenant): this

Defined in: tenancy/src/tenant.ts:187

Parameters ​

tenant ​

Tenant

Returns ​

this


create() ​

> create(tenant): Promise<Tenant>

Defined in: tenancy/src/tenant.ts:213

Refuses an id that is already present. The check and the write happen in one synchronous step, so concurrent creates of the same id cannot both succeed — the same guarantee the durable sources get from a primary key.

Parameters ​

tenant ​

Tenant

Returns ​

Promise<Tenant>

Implementation of ​

TenantSource.create


delete() ​

> delete(id): Promise<void>

Defined in: tenancy/src/tenant.ts:232

Removes the record. Optional, because not every source can: a read-only directory or a config file has nothing to delete from.

tenancy.destroy() refuses rather than reporting a success it did not perform — a tenant that looks removed and still resolves is worse than one that never left.

Parameters ​

id ​

string

Returns ​

Promise<void>

Implementation of ​

TenantSource.delete


find() ​

> find(id): Promise<Tenant | null>

Defined in: tenancy/src/tenant.ts:192

Parameters ​

id ​

string

Returns ​

Promise<Tenant | null>

Implementation of ​

TenantSource.find


findByDomain() ​

> findByDomain(domain): Promise<Tenant | null>

Defined in: tenancy/src/tenant.ts:196

Required by the domain resolver (custom domains).

Parameters ​

domain ​

string

Returns ​

Promise<Tenant | null>

Implementation of ​

TenantSource.findByDomain


list() ​

> list(): Promise<Tenant[]>

Defined in: tenancy/src/tenant.ts:204

Required by tenancy.forEach() and basalt tenant:list.

Returns ​

Promise<Tenant[]>

Implementation of ​

TenantSource.list


save() ​

> save(tenant): Promise<Tenant>

Defined in: tenancy/src/tenant.ts:226

Upsert. Present so status transitions work here too — tenancy.create() writes provisioning, then ready, and needs a second write for that.

Parameters ​

tenant ​

Tenant

Returns ​

Promise<Tenant>

Implementation of ​

TenantSource.save

Released under the MIT License.