@lincyaw/kernel 1.0.0-rc.54 → 1.0.0-rc.56

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.54",
3
+ "version": "1.0.0-rc.56",
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": {
package/src/authoring.ts CHANGED
@@ -28,6 +28,8 @@ export const DOCUMENT_CHANGE_JSON_SCHEMA: Schema = {
28
28
  operation('updateSection', { sectionId: id, title: { type: 'string' }, layout: ref('Layout') }, ['sectionId']),
29
29
  operation('setStepState', { stepId: id, visuals: { type: 'array', items: ref('Visual') }, inherits: id }, ['stepId', 'visuals']),
30
30
  operation('setNarration', { narration: ref('Narration'), stepId: id, index }, ['narration']),
31
+ operation('removeNarration', { stepId: id, narrationId: id }),
32
+ operation('setStepNarrations', { stepId: id, narrationIds: { type: 'array', maxItems: 1000, items: id, uniqueItems: true, description: 'Complete ordered existing narration IDs for this step. Omitted references are removed; entities still used by other steps remain.' } }),
31
33
  operation('setTiming', { stepId: id, sectionId: id, value: ref('StepProduction') }, ['value']),
32
34
  operation('replaceAsset', { asset: ref('Asset') }),
33
35
  ] },
@@ -95,12 +95,14 @@ export interface ClientCommentDraftMetadata {
95
95
  threadId?: string
96
96
  commentId?: string
97
97
  }
98
+ const PRODUCTION_DRAFT_KINDS = ['step-timing', 'caption-timing', 'recording-range', 'voice', 'media-clip'] as const
98
99
  export interface ClientProductionDraftMetadata {
99
100
  draft: string
100
- kind: 'step-timing' | 'caption-timing' | 'recording-range'
101
+ kind: typeof PRODUCTION_DRAFT_KINDS[number]
101
102
  stepId: string
102
103
  field?: 'minimumHoldMs' | 'trailingPauseMs'
103
104
  assetId?: string
105
+ clipId?: string
104
106
  targetAvailable: boolean
105
107
  requiresReview: boolean
106
108
  storage: 'tab' | 'memory'
@@ -228,7 +230,7 @@ const nullableComponentReference: Schema = { oneOf: [componentDraftReference, {
228
230
  const nullableCommentReference: Schema = { oneOf: [draftReference, { type: 'null' }] }
229
231
  const commentRestore = object({ composerId: id, expectedCurrent: nullableCommentReference })
230
232
  const cursor = object({ after: entity, token: digest })
231
- const productionMetadata = object({ draft: digest, kind: { enum: ['step-timing', 'caption-timing', 'recording-range'] }, stepId: entity, field: { enum: ['minimumHoldMs', 'trailingPauseMs'] }, assetId: entity, targetAvailable: bool, requiresReview: bool, storage: { enum: ['tab', 'memory'] }, discardable: bool }, ['draft', 'kind', 'stepId', 'targetAvailable', 'requiresReview', 'storage', 'discardable'])
233
+ const productionMetadata = object({ draft: digest, kind: { enum: [...PRODUCTION_DRAFT_KINDS] }, stepId: entity, field: { enum: ['minimumHoldMs', 'trailingPauseMs'] }, assetId: entity, clipId: entity, targetAvailable: bool, requiresReview: bool, storage: { enum: ['tab', 'memory'] }, discardable: bool }, ['draft', 'kind', 'stepId', 'targetAvailable', 'requiresReview', 'storage', 'discardable'])
232
234
  export const AUTHORING_CLIENT_ACTION_RESULT_SCHEMA: Schema = { oneOf: [
233
235
  object({ type: { const: 'body-drafts.inspect' }, family: { const: 'body' }, coverage: { enum: ['stored-and-session', 'partial'] }, token: digest,
234
236
  drafts: { type: 'array', maxItems: 10, items: bodyMetadata }, next: cursor }, ['type', 'family', 'coverage', 'token', 'drafts']),
@@ -6,7 +6,7 @@ import type { DocumentOutlineAnswer, DocumentOutlineQuery, DocumentPartAnswer, D
6
6
  import type { AppliedDocumentAuthoringAction, DocumentAuthoringActionInspection, DocumentAuthoringActionPlan, DocumentAuthoringActionRead, DocumentAuthoringActionReference, DocumentAuthoringActionRequest, DocumentAuthoringAction, DocumentComponentImpactAnswer, DocumentComponentImpactQuery } from './authoring-actions.ts'
7
7
 
8
8
  export const AUTHORING_API_VERSION = 1 as const
9
- export const DOCUMENT_OPERATION_TYPES = ['insertBlock', 'moveBlock', 'deleteBlock', 'updateText', 'updateSection', 'setStepState', 'setNarration', 'setTiming', 'replaceAsset'] as const satisfies readonly DocumentEditOperation['type'][]
9
+ export const DOCUMENT_OPERATION_TYPES = ['insertBlock', 'moveBlock', 'deleteBlock', 'updateText', 'updateSection', 'setStepState', 'setNarration', 'removeNarration', 'setStepNarrations', 'setTiming', 'replaceAsset'] as const satisfies readonly DocumentEditOperation['type'][]
10
10
 
11
11
  export interface AuthoringCapabilities {
12
12
  apiVersion: typeof AUTHORING_API_VERSION
@@ -249,5 +249,7 @@ export type DocumentEditOperation =
249
249
  | { type: 'updateSection', sectionId: SectionId, title?: string, layout?: Layout }
250
250
  | { type: 'setStepState', stepId: StepId, visuals: VisualState[], inherits?: StepId }
251
251
  | { type: 'setNarration', narration: Narration, stepId?: StepId, index?: number }
252
+ | { type: 'removeNarration', stepId: StepId, narrationId: NarrationId }
253
+ | { type: 'setStepNarrations', stepId: StepId, narrationIds: NarrationId[] }
252
254
  | { type: 'setTiming', stepId?: StepId, sectionId?: SectionId, value: StepProduction }
253
255
  | { type: 'replaceAsset', asset: Asset }
@@ -1,11 +1,12 @@
1
1
  import { isDocumentPlaceAnchor } from './contracts/document.ts'
2
2
  import { degradeDocumentCommentAnchor } from './document-comments.ts'
3
+ import { replaceStepNarrations } from './document-narrations.ts'
3
4
  import type { DocumentBlock, DocumentEditOperation, TeachingDocument } from './contracts/document.ts'
4
5
 
5
6
  /** Operations describe author intent; the caller validates the resulting complete document before committing it. */
6
7
  export function applyDocumentOperations(source: TeachingDocument, operations: readonly DocumentEditOperation[]): TeachingDocument {
7
8
  if (!operations.length || operations.length > 1000) throw new Error('document-operation-count')
8
- const document = structuredClone(source)
9
+ let document = structuredClone(source)
9
10
  const block = (id: string): DocumentBlock => {
10
11
  if (!Object.hasOwn(document.blocks, id)) throw new Error('document-block-missing')
11
12
  return document.blocks[id]!
@@ -129,6 +130,21 @@ export function applyDocumentOperations(source: TeachingDocument, operations: re
129
130
  }
130
131
  break
131
132
  }
133
+ case 'removeNarration': {
134
+ const value = step(operation.stepId)
135
+ if (!value.narrationIds.includes(operation.narrationId)) throw new Error('document-narration-target')
136
+ document = replaceStepNarrations(document, value.id, value.narrationIds.filter(id => id !== operation.narrationId).map(id => document.narrations[id]!))
137
+ break
138
+ }
139
+ case 'setStepNarrations': {
140
+ step(operation.stepId)
141
+ const narrations = operation.narrationIds.map(id => {
142
+ if (!Object.hasOwn(document.narrations, id)) throw new Error('document-narration-target')
143
+ return document.narrations[id]!
144
+ })
145
+ document = replaceStepNarrations(document, operation.stepId, narrations)
146
+ break
147
+ }
132
148
  case 'setTiming':
133
149
  if (operation.stepId && operation.sectionId) throw new Error('document-timing-scope')
134
150
  if (operation.stepId) { step(operation.stepId); put(document.production.stepOverrides, operation.stepId, operation.value) }