Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/context-use/backend/src/models/assets/model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { EntityReference } from '#backend/models/entities/model.ts';
import type { KnowledgePageSummary } from '#backend/models/knowledge-pages/model.ts';
import type { PublicationStatus } from '#backend/models/publications/model.ts';
import type { ResourceArchiveState } from '#backend/models/resource-archiving/model.ts';

const BYTES_PER_KIBIBYTE = 1024;
const KIBIBYTES_PER_MEBIBYTE = 1024;
Expand All @@ -10,7 +11,7 @@ export const MAX_ASSET_NAME_LENGTH = 160;

export type AssetPresentation = 'embed' | 'attachment';

export interface AssetSummary extends PublicationStatus {
export interface AssetSummary extends PublicationStatus, ResourceArchiveState {
id: string;
readableId: string;
name: string;
Expand Down
3 changes: 2 additions & 1 deletion apps/context-use/backend/src/models/entities/model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { AssetSummary } from '#backend/models/assets/model.ts';
import type { KnowledgePageSummary } from '#backend/models/knowledge-pages/model.ts';
import type { PublicationStatus } from '#backend/models/publications/model.ts';
import type { ResourceArchiveState } from '#backend/models/resource-archiving/model.ts';

export const MAX_ENTITY_NAME_LENGTH = 160;
export const MIN_ENTITY_DESCRIPTION_LENGTH = 1;
Expand Down Expand Up @@ -29,7 +30,7 @@ export const ENTITY_TYPE_FILTER_LABELS: Record<EntityTypeFilter, string> = {
export const ENTITY_TYPE_DESCRIPTION =
'Person: a specific individual. Organization: an identifiable collective, including companies, restaurants, institutions, and named teams. Location: a specific geographic referent, such as a building, address, city, or region. Leave untyped when unsupported or uncertain. Assign from contextual evidence, not a name alone. Events are temporal pages mentioning entities. The self entity is always a Person; its type cannot be changed or cleared.';

export interface Entity extends PublicationStatus {
export interface Entity extends PublicationStatus, ResourceArchiveState {
id: string;
readableId: string;
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
import type { TemporalBounds } from '#backend/models/knowledge-pages/temporal-coverage.ts';
import type { PublicationVisibility } from '#backend/models/publications/model.ts';
import type { RecordSourceFilters, RecordSummary } from '#backend/models/records/model.ts';
import type { ResourceStatus } from '#backend/models/resource-archiving/model.ts';

export const HYPERMEDIA_RESOURCE_TYPES = ['entity', 'knowledge_page', 'asset', 'record'] as const;
export const DEFAULT_HYPERMEDIA_SEARCH_LIMIT = 30;
Expand Down Expand Up @@ -45,6 +46,7 @@ export interface HypermediaRetrievalResults {
}

export interface HypermediaRetrievalFilters {
status?: ResourceStatus;
visibility?: PublicationVisibility;
/** When type is present, restrict retrieval to entities with the selected type. */
entity?: { type?: EntityTypeFilter };
Expand Down
3 changes: 2 additions & 1 deletion apps/context-use/backend/src/models/knowledge-pages/model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { AssetPresentation, AssetSummary } from '#backend/models/assets/model.ts';
import type { Entity } from '#backend/models/entities/model.ts';
import type { PagePublicationStatus } from '#backend/models/publications/model.ts';
import type { ResourceArchiveState } from '#backend/models/resource-archiving/model.ts';

export const MAX_KNOWLEDGE_PAGE_BYTES = 1_000_000;
export const MAX_KNOWLEDGE_PAGE_EXCERPT_LENGTH = 280;
Expand All @@ -9,7 +10,7 @@ export const KNOWLEDGE_PAGE_INTERVAL_FILTERS = ['with', 'without'] as const;

export type KnowledgePageIntervalFilter = (typeof KNOWLEDGE_PAGE_INTERVAL_FILTERS)[number];

export interface KnowledgePageSummary extends PagePublicationStatus {
export interface KnowledgePageSummary extends PagePublicationStatus, ResourceArchiveState {
id: string;
readableId: string;
title: string;
Expand Down
18 changes: 18 additions & 0 deletions apps/context-use/backend/src/models/resource-archiving/model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
export const RESOURCE_STATUSES = ['active', 'archived'] as const;
export type ResourceStatus = (typeof RESOURCE_STATUSES)[number];

export interface ResourceArchiveState {
archivedAt: string | null;
}

export type UnarchiveBlocker = {
resourceType: 'entity' | 'page' | 'asset';
readableId: string;
name: string;
};

export type UnarchiveResult =
| { state: 'unarchived' }
| { state: 'not_found' }
| { state: 'dependencies_archived'; blockers: UnarchiveBlocker[] };

export type ArchiveResult<Blocker> =
| { state: 'archived' }
| { state: 'not_found' }
Expand Down
Loading
Loading