d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
72 lines
2.3 KiB
TypeScript
72 lines
2.3 KiB
TypeScript
/**
|
|
* Clamp a Notion `page_size` value to the API's supported 1-100 range. Returns
|
|
* undefined when the input isn't a finite number so callers can omit the param.
|
|
*/
|
|
export function clampNotionPageSize(value: unknown): number | undefined {
|
|
if (value == null || value === '') return undefined
|
|
const parsed = Number(value)
|
|
if (!Number.isFinite(parsed)) return undefined
|
|
return Math.min(Math.max(Math.trunc(parsed), 1), 100)
|
|
}
|
|
|
|
export function formatPropertyValue(property: any): string {
|
|
switch (property.type) {
|
|
case 'title':
|
|
return property.title?.map((t: any) => t.plain_text || '').join('') || ''
|
|
case 'rich_text':
|
|
return property.rich_text?.map((t: any) => t.plain_text || '').join('') || ''
|
|
case 'number':
|
|
return String(property.number || '')
|
|
case 'select':
|
|
return property.select?.name || ''
|
|
case 'multi_select':
|
|
return property.multi_select?.map((s: any) => s.name).join(', ') || ''
|
|
case 'date':
|
|
return property.date?.start || ''
|
|
case 'checkbox':
|
|
return property.checkbox ? 'Yes' : 'No'
|
|
case 'url':
|
|
return property.url || ''
|
|
case 'email':
|
|
return property.email || ''
|
|
case 'phone_number':
|
|
return property.phone_number || ''
|
|
default:
|
|
return JSON.stringify(property)
|
|
}
|
|
}
|
|
|
|
export function extractTitle(properties: Record<string, any>): string {
|
|
for (const [, value] of Object.entries(properties)) {
|
|
if (
|
|
value.type === 'title' &&
|
|
value.title &&
|
|
Array.isArray(value.title) &&
|
|
value.title.length > 0
|
|
) {
|
|
return value.title.map((t: any) => t.plain_text || '').join('')
|
|
}
|
|
}
|
|
return ''
|
|
}
|
|
|
|
export function extractTitleFromItem(item: any): string {
|
|
if (item.object === 'page') {
|
|
// For pages, check properties first
|
|
if (item.properties?.title?.title && Array.isArray(item.properties.title.title)) {
|
|
const title = item.properties.title.title.map((t: any) => t.plain_text || '').join('')
|
|
if (title) return title
|
|
}
|
|
// Fallback to page title
|
|
return item.title || 'Untitled Page'
|
|
}
|
|
if (item.object === 'database') {
|
|
// For databases, get title from title array
|
|
if (item.title && Array.isArray(item.title)) {
|
|
return item.title.map((t: any) => t.plain_text || '').join('') || 'Untitled Database'
|
|
}
|
|
return 'Untitled Database'
|
|
}
|
|
return 'Untitled'
|
|
}
|