upsertEntity
is used to create or update an entity. You can also publish the entity, in one atomic operation, by setting options to { publish: true }
.
interface DossierClient {
upsertEntity(
entity: Readonly<EntityUpsert>,
options?: EntityMutationOptions,
): PromiseResult<
EntityUpsertPayload,
"BadRequest" | "NotAuthorized" | "Generic"
>;
}
interface EntityUpsert {
id: string;
info: {
name?: string;
type: string;
authKey?: string | null;
};
fields: Record<string, unknown>;
}
interface EntityMutationOptions {
publish?: boolean;
}
interface EntityUpsertPayload {
effect:
| "created"
| "createdAndPublished"
| "updated"
| "updatedAndPublished"
| "published"
| "none";
entity: Entity;
}
If a new entity is created, a createEntity
or createAndPublishEntity
event is generated. If an existing entity is update, an updateEntity
or updateAndPublishEntity
event. If there are no changes to the entity, but it's published, a publishEntities
event is generated.