Memco

Class NetworkOperations

Memory networks, their members and their identity-provider groups, reached as client.networks.

await using client = await new Memco({ clientId, clientSecret }).connect()
const root = (await client.networks.list({ parentId: 'root', domain: 'coding' }))
.networks[0]
const acme = await client.networks.create({
name: 'Acme',
parentIds: [root.id],
scope: 'customer'
})
Index
  • List one page of your organization's memory networks, narrowed by the filters given.

    Parameters

    Returns Promise<NetworkList>

    The page of networks, and how many match in all.

    MemcoInvalidRequestError If ids is a single string rather than a collection of them.

    const page = await client.networks.list({ parentId: 'root', domain: 'coding' })
    console.log(page.networks.map(network => network.name))
  • Create a memory network.

    Parameters

    Returns Promise<Network>

    The network as created.

    MemcoAlreadyExistsError If the name is already taken.

    const acme = await client.networks.create({
    name: 'Acme',
    parentIds: [root.id],
    scope: 'customer'
    })
  • Create a memory network, or return the one already holding its name.

    Safe when two callers race to create one network: the loser is handed the winner's. The existing network is returned only if it has the owner asked for (no owner matches a network without one) and, when a domain or a scope is given, that domain and scope; a network that merely shares the name is never adopted. Names are matched exactly, case included.

    Parameters

    • options: CreateNetworkOptions

      The network's name, where it goes, and a deadline for each call made.

    Returns Promise<Network>

    The network as created, or as it already was.

    MemcoAlreadyExistsError If the name is held by a network with another owner, domain or scope, or by one that cannot be listed.

    const acme = await client.networks.createOrGet({
    name: 'acme',
    domain: 'knowledge',
    scope: 'customer',
    owner: 'acme'
    })
  • Change a network's name, parent, scope, owner or description.

    Parameters

    • networkId: string

      The network to change.

    • options: UpdateNetworkOptions = {}

      What to change, and a deadline. A field left out stays as it is; an empty string clears it.

    Returns Promise<Network>

    The network as it now is.

    MemcoInvalidRequestError If networkId is blank.

    await client.networks.update('network-a', { name: 'Acme Corp', description: '' })
    
  • Delete a network, and everything that hangs off it.

    Cannot be undone. The result reports what the deletion removed with the network, so its cost can be seen.

    Parameters

    • networkId: string

      The network to delete.

    • options: TimeoutOptions = {}

      Per-call deadline.

    Returns Promise<DeletedNetwork>

    The network deleted, and how many rows the cascade removed from each table.

    MemcoInvalidRequestError If networkId is blank.

    const deleted = await client.networks.delete('network-a')
    console.log(deleted.removed) // { memories: 3, network_members: 1 }
  • List one page of the users placed in a network.

    Parameters

    • networkId: string

      The network whose members to list.

    • options: ListMembersOptions = {}

      A search, the page, and a deadline.

    Returns Promise<MemberList>

    The page of members, and how many match in all.

    MemcoInvalidRequestError If networkId is blank.

    const { members } = await client.networks.listMembers('network-a')
    
  • Place a user in a network.

    A user holds one network per memory domain. One already placed in another network of the same domain is refused with MemcoUserAlreadyAssignedNetworkError, naming that network, unless force is set, which moves them. An external user can be placed only in a customer network; any other is refused with MemcoExternalUserNeedsCustomerNetworkError.

    Parameters

    • networkId: string

      The network to place the user in.

    • options: AddMemberOptions

      The user, whether to move them, and a deadline.

    Returns Promise<MemberPlacement>

    Where the user was placed, and the network they were moved out of, if any.

    MemcoInvalidRequestError If networkId or userId is blank.

    MemcoUserAlreadyAssignedNetworkError If the user is in another network of the domain and force is not set.

    MemcoExternalUserNeedsCustomerNetworkError If an external user is placed in a network that is not a customer one.

    const placed = await client.networks.addMember(acme.id, {
    userId: user.id,
    force: true
    })
    console.log(placed.movedFrom) // the network they left, if any
  • Take a user out of a network.

    Parameters

    • networkId: string

      The network to take the user out of.

    • options: RemoveMemberOptions

      The user, and a deadline.

    Returns Promise<void>

    MemcoInvalidRequestError If networkId or userId is blank.

    await client.networks.removeMember('network-a', { userId: 'user-a' })
    
  • List one page of your organization's identity-provider groups.

    Groups are how an enterprise organization places its people in networks, and are available to enterprise organizations only; the service refuses this call for any other with MemcoPermissionError.

    Parameters

    Returns Promise<GroupList>

    The page of groups, and how many match in all.

    MemcoInvalidRequestError If ids is a single string rather than a collection of them.

    const { groups } = await client.networks.listGroups({ name: 'Support' })
    
  • List the users in an identity-provider group.

    The identity provider manages who is in a group; this only reads it. Available to enterprise organizations only.

    Parameters

    • groupId: string

      The group whose members to list.

    • options: TimeoutOptions = {}

      Per-call deadline.

    Returns Promise<readonly Member[]>

    The group's members.

    MemcoInvalidRequestError If groupId is blank.

    const members = await client.networks.listGroupMembers('group-a')
    
  • Assign an identity-provider group to a network, placing its members there.

    A group holds one network per memory domain, so this replaces the group's network in this network's domain. A group limited to moderation instead keeps its others, and may be bound to several networks in one domain. Available to enterprise organizations only.

    Parameters

    • networkId: string

      The network to assign the group to.

    • options: AddGroupOptions

      The group, the roles it is limited to, and a deadline.

    Returns Promise<void>

    MemcoInvalidRequestError If networkId or groupId is blank, or limitAssignableRoles is a single string.

    await client.networks.addGroup('network-support', { groupId: 'group-a' })
    await client.networks.addGroup('network-review', {
    groupId: 'group-moderators',
    limitAssignableRoles: ['content_moderator']
    })
  • Take an identity-provider group out of a network.

    The group's networks in other memory domains are unaffected. Available to enterprise organizations only.

    Parameters

    • networkId: string

      The network to take the group out of.

    • options: NetworkGroupOptions

      The group, and a deadline.

    Returns Promise<void>

    MemcoInvalidRequestError If networkId or groupId is blank.

    await client.networks.removeGroup('network-support', { groupId: 'group-a' })
    

On this page