@lincyaw/kernel 1.0.0-rc.59 → 1.0.0-rc.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lincyaw/kernel",
3
- "version": "1.0.0-rc.59",
3
+ "version": "1.0.0-rc.60",
4
4
  "description": "Presmium's shared kernel: the IR and plugin contracts, the service registry, anchors and checks",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -1,3 +1,5 @@
1
+ import { MEDIA_LOCATION_PROPERTIES, MEDIA_LOCATION_CHOICES, mediaFileSchema } from './media-uploads.ts'
2
+ import type { DocumentMediaLocation, DocumentMediaFile } from './media-uploads.ts'
1
3
  import type { CanonicalSource } from '../ir.ts'
2
4
  import type { Finding } from './checks.ts'
3
5
  import type { DocumentIssue, MediaClip, TimeRange } from './document.ts'
@@ -33,18 +35,18 @@ export interface VerifiedDocumentRecordingAdoption extends DocumentChangeAnswer
33
35
  }
34
36
  /** Inspect an existing real snapshot; an expected revision is optional during discovery. */
35
37
  export type DocProductionPlanQuery = ProductionAudioPlanQuery
36
- export interface DocumentWorkspaceAudioInspect { source: CanonicalSource, path: string }
38
+ export type DocumentWorkspaceAudioInspect = { source: CanonicalSource } & DocumentMediaLocation
37
39
  export interface WorkspaceAudioInspectionAnswer {
38
40
  document: string
39
41
  source: CanonicalSource
40
- file: { path: string, sha256: string, byteLength: number }
42
+ file: DocumentMediaFile
41
43
  inspection: Omit<ProductionAssetInspection, 'assetId' | 'mediaId'>
42
44
  }
43
45
  export interface DocumentWorkspaceAudioImport {
44
46
  id: string
45
47
  source: CanonicalSource
46
48
  /** Workspace-relative regular file permitted by the selected document's existing source scope. */
47
- file: { path: string, sha256: string, byteLength: number }
49
+ file: DocumentMediaFile
48
50
  }
49
51
  export interface VerifiedDocumentAudioImport extends DocumentAudioImportAnswer {
50
52
  verification: {
@@ -116,15 +118,15 @@ export const DOCUMENT_AUDIO_WORKSPACE_IMPORT_SCHEMA = {
116
118
  type: 'object', additionalProperties: false,
117
119
  properties: {
118
120
  id: { type: 'string', minLength: 1, maxLength: 200 }, source,
119
- file: { type: 'object', additionalProperties: false, properties: { path: { type: 'string', minLength: 1, maxLength: 1024 }, sha256: { type: 'string', pattern: '^[a-f\\d]{64}$' }, byteLength: { type: 'integer', minimum: 1, maximum: DOCUMENT_AUDIO_MAX_BYTES } }, required: ['path', 'sha256', 'byteLength'] },
121
+ file: mediaFileSchema(DOCUMENT_AUDIO_MAX_BYTES),
120
122
  },
121
123
  required: ['id', 'source', 'file'],
122
124
  } as const
123
125
 
124
126
  export const DOCUMENT_WORKSPACE_AUDIO_INSPECTION_SCHEMA = {
125
127
  type: 'object', additionalProperties: false,
126
- properties: { source, path: { type: 'string', minLength: 1, maxLength: 1024 } },
127
- required: ['source', 'path'],
128
+ properties: { source, ...MEDIA_LOCATION_PROPERTIES },
129
+ required: ['source'], oneOf: MEDIA_LOCATION_CHOICES,
128
130
  } as const
129
131
 
130
132
  const clipId = { type: 'string', minLength: 1, maxLength: 200, pattern: '^[^\\u0000-\\u001f]+$', not: { enum: ['__proto__', 'constructor', 'prototype'] } } as const
@@ -1,13 +1,15 @@
1
+ import { MEDIA_LOCATION_PROPERTIES, MEDIA_LOCATION_CHOICES, mediaFileSchema } from './media-uploads.ts'
2
+ import type { DocumentMediaLocation, DocumentMediaFile } from './media-uploads.ts'
1
3
  import type { CanonicalSource } from '../ir.ts'
2
4
  import type { Member } from './server.ts'
3
5
  import type { DocumentImageImportAnswer } from './workspace.ts'
4
6
  import { DOCUMENT_IMAGE_MAX_BYTES } from './workspace.ts'
5
7
 
6
- export interface DocumentWorkspaceImageInspect { source: CanonicalSource, path: string }
7
- export interface DocumentWorkspaceImageImport { id: string, source: CanonicalSource, file: { path: string, sha256: string, byteLength: number } }
8
+ export type DocumentWorkspaceImageInspect = { source: CanonicalSource } & DocumentMediaLocation
9
+ export interface DocumentWorkspaceImageImport { id: string, source: CanonicalSource, file: DocumentMediaFile }
8
10
  export interface WorkspaceImageInspection {
9
11
  document: string, source: CanonicalSource
10
- file: { path: string, sha256: string, byteLength: number }
12
+ file: DocumentMediaFile
11
13
  image: { mediaType: string, dimensions: { width: number, height: number } }
12
14
  }
13
15
  export interface VerifiedDocumentImageImport extends DocumentImageImportAnswer {
@@ -28,5 +30,5 @@ export interface DocumentImageAuthoring {
28
30
  importWorkspace(document: string, request: DocumentWorkspaceImageImport, member: Member, signal?: AbortSignal): Promise<VerifiedDocumentImageImport>
29
31
  }
30
32
  const source = { type: 'object', additionalProperties: false, properties: { documentId: { type: 'string', minLength: 1, maxLength: 200 }, version: { type: 'string', pattern: '^[a-f\\d]{20}$' }, fingerprint: { type: 'string', pattern: '^[a-f\\d]{16}$' } }, required: ['documentId', 'version', 'fingerprint'] } as const
31
- export const DOCUMENT_WORKSPACE_IMAGE_INSPECTION_SCHEMA = { type: 'object', additionalProperties: false, properties: { source, path: { type: 'string', minLength: 1, maxLength: 1024 } }, required: ['source', 'path'] } as const
32
- export const DOCUMENT_WORKSPACE_IMAGE_IMPORT_SCHEMA = { type: 'object', additionalProperties: false, properties: { id: { type: 'string', minLength: 1, maxLength: 200 }, source, file: { type: 'object', additionalProperties: false, properties: { path: { type: 'string', minLength: 1, maxLength: 1024 }, sha256: { type: 'string', pattern: '^[a-f\\d]{64}$' }, byteLength: { type: 'integer', minimum: 1, maximum: DOCUMENT_IMAGE_MAX_BYTES } }, required: ['path', 'sha256', 'byteLength'] } }, required: ['id', 'source', 'file'] } as const
33
+ export const DOCUMENT_WORKSPACE_IMAGE_INSPECTION_SCHEMA = { type: 'object', additionalProperties: false, properties: { source, ...MEDIA_LOCATION_PROPERTIES }, required: ['source'], oneOf: MEDIA_LOCATION_CHOICES } as const
34
+ export const DOCUMENT_WORKSPACE_IMAGE_IMPORT_SCHEMA = { type: 'object', additionalProperties: false, properties: { id: { type: 'string', minLength: 1, maxLength: 200 }, source, file: mediaFileSchema(DOCUMENT_IMAGE_MAX_BYTES) }, required: ['id', 'source', 'file'] } as const
@@ -0,0 +1,28 @@
1
+ import type { Member } from './server.ts'
2
+
3
+ export const MEDIA_UPLOAD_PATH = '/__presmium/presmium.media-upload'
4
+ export const MEDIA_UPLOAD_KINDS = ['image', 'audio'] as const
5
+ export type MediaUploadKind = typeof MEDIA_UPLOAD_KINDS[number]
6
+ export interface MediaUpload {
7
+ upload: string
8
+ kind: MediaUploadKind
9
+ url: string
10
+ expiresAt: string
11
+ maxBytes: number
12
+ state: 'empty' | 'uploading' | 'ready'
13
+ name?: string
14
+ byteLength?: number
15
+ }
16
+ /** Temporary input only; canonical imports retain their existing authoring permission and transaction. */
17
+ export interface DocumentMediaUploads {
18
+ prepare(document: string, kind: MediaUploadKind, member: Member): Promise<MediaUpload>
19
+ status(document: string, upload: string, member: Member): Promise<MediaUpload>
20
+ }
21
+ export type DocumentMediaLocation = { path: string, upload?: never } | { upload: string, path?: never }
22
+ export type DocumentMediaFile = ({ path: string, upload?: never, name?: never } | { upload: string, name: string, path?: never }) & { sha256: string, byteLength: number }
23
+ export const MEDIA_LOCATION_PROPERTIES = { path: { type: 'string', minLength: 1, maxLength: 1024 }, upload: { type: 'string', pattern: '^[a-f0-9]{64}$' } } as const
24
+ export const MEDIA_LOCATION_CHOICES = [{ required: ['path'], not: { required: ['upload'] } }, { required: ['upload'], not: { required: ['path'] } }] as const
25
+ export const mediaFileSchema = (maxBytes: number) => ({ type: 'object', additionalProperties: false,
26
+ properties: { ...MEDIA_LOCATION_PROPERTIES, name: { type: 'string', minLength: 1, maxLength: 200 }, sha256: { type: 'string', pattern: '^[a-f\\d]{64}$' }, byteLength: { type: 'integer', minimum: 1, maximum: maxBytes } },
27
+ required: ['sha256', 'byteLength'], oneOf: [{ required: ['path'], not: { anyOf: [{ required: ['upload'] }, { required: ['name'] }] } }, { required: ['upload', 'name'], not: { required: ['path'] } }],
28
+ } as const)
package/src/contracts.ts CHANGED
@@ -38,3 +38,4 @@ export * from './contracts/authoring-clients.ts'
38
38
  export * from './contracts/authoring-windows.ts'
39
39
  export * from './contracts/projects.ts'
40
40
  export * from './contracts/document-image.ts'
41
+ export * from './contracts/media-uploads.ts'