@xnetjs/data 2.5.0 → 3.0.0

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.
Files changed (41) hide show
  1. package/README.md +5 -0
  2. package/dist/auth/index.d.ts +4 -4
  3. package/dist/chunk-GJAOMEQO.js +114 -0
  4. package/dist/chunk-KY62NUOI.js +67 -0
  5. package/dist/chunk-N37U6ZPI.js +789 -0
  6. package/dist/chunk-NFPEFD2I.js +42 -0
  7. package/dist/{chunk-ODOPVGUX.js → chunk-QKVIKVAL.js} +65 -26
  8. package/dist/{chunk-CY6EJUNV.js → chunk-S7SEN4LH.js} +5 -1
  9. package/dist/{chunk-4HJZJMPI.js → chunk-TN7LGV66.js} +1 -1
  10. package/dist/{chunk-YRFCXKJC.js → chunk-UQ2VFHU3.js} +2 -2
  11. package/dist/chunk-VZSEZNYA.js +83 -0
  12. package/dist/{chunk-JF4VCZER.js → chunk-WSINZHSR.js} +27 -1
  13. package/dist/{chunk-MAB662PR.js → chunk-YCBJDT23.js} +62 -48
  14. package/dist/{clone-VRVODkBn.d.ts → clone-ywzFVkID.d.ts} +4 -4
  15. package/dist/course-C5DXOIVO.js +24 -0
  16. package/dist/database/index.d.ts +5 -5
  17. package/dist/database/index.js +8 -8
  18. package/dist/event-VW3FBN4F.js +20 -0
  19. package/dist/{form-types-Dkqm9UO2.d.ts → form-types-BrHYdpi0.d.ts} +1 -1
  20. package/dist/{game-NEQP7OFX.js → game-7AXW7XKS.js} +1 -1
  21. package/dist/{grant-expiration-cleaner-CTsW0hvU.d.ts → grant-expiration-cleaner-CRS9OyhV.d.ts} +3 -3
  22. package/dist/index.d.ts +10 -320
  23. package/dist/index.js +292 -867
  24. package/dist/{moderation-HRMMBFVH.js → moderation-5Z4LKOKN.js} +5 -3
  25. package/dist/{page-MADZ5OHM.js → page-W4G6433H.js} +1 -1
  26. package/dist/portability/index.d.ts +330 -0
  27. package/dist/portability/index.js +34 -0
  28. package/dist/post-7IOO64MD.js +14 -0
  29. package/dist/{profile-5H6XWCK4.js → profile-KLHCAQY2.js} +1 -1
  30. package/dist/publication-3MN3WWKP.js +10 -0
  31. package/dist/{query-ast-h31svZnG.d.ts → query-ast-DQJO7yRV.d.ts} +1 -1
  32. package/dist/{registry-Dh4Kr3fo.d.ts → registry-C9IRLLeR.d.ts} +1 -1
  33. package/dist/schema/index.d.ts +366 -26
  34. package/dist/schema/index.js +195 -149
  35. package/dist/space-GBTEHZOK.js +1 -1
  36. package/dist/store/index.d.ts +4 -4
  37. package/dist/store/index.js +2 -2
  38. package/dist/{store-jukJYsvr.d.ts → store-D1oiFQuF.d.ts} +19 -2
  39. package/dist/{types-Z9dUzbDF.d.ts → types-gws1tSf-.d.ts} +1 -1
  40. package/package.json +27 -25
  41. package/dist/{chunk-TW5XJHNF.js → chunk-ANMAR3KY.js} +14 -14
package/dist/index.js CHANGED
@@ -222,73 +222,23 @@ import {
222
222
  validateJsonData,
223
223
  validateRollupConfig,
224
224
  visibleFormQuestions
225
- } from "./chunk-TW5XJHNF.js";
225
+ } from "./chunk-ANMAR3KY.js";
226
226
  import {
227
- MemoryNodeStorageAdapter,
228
- NodeStore,
229
- PermissionError,
230
- QUERY_AST_VERSION,
231
- SQLiteNodeStorageAdapter,
232
- TEMP_ID_PREFIX,
233
- and,
234
- avg,
235
- between,
236
- contains,
237
- count,
238
- countDistinct,
239
- createNodeStorageAdapter,
240
- createSchemaLookup,
241
- dashboardQuerySet,
242
- defineNodeQueryAST,
243
- defineQuerySetAST,
244
- defineSavedViewDescriptor,
245
- eq,
246
- evaluateQueryASTPlannerGate,
247
- executeQueryASTLoadedAggregates,
248
- filterQueryASTLoadedRows,
249
- follow,
250
- from,
251
- getQueryASTRelationIndexRequirements,
252
- groupBy,
253
- gt,
254
- gte,
255
- having,
256
- includesAny,
257
- isNotNull,
258
- isNull,
259
- isTempId,
260
- lt,
261
- lte,
262
- matchesQueryASTLoadedRow,
263
- max,
264
- min,
265
- neq,
266
- not,
267
- or,
268
- planQueryASTAggregates,
269
- queryOperators,
270
- querySetCount,
271
- resolveTempIds,
272
- startsWith,
273
- sum,
274
- validateQueryAST,
275
- validateSavedViewDescriptor
276
- } from "./chunk-ODOPVGUX.js";
277
- import {
278
- applyNodeQueryDescriptor,
279
- createNodeQueryDescriptor,
280
- decodeNodeQueryCursor,
281
- encodeNodeQueryCursor,
282
- filterNodeQueryResults,
283
- getNodeQuerySearchTokens,
284
- matchesNodeQueryDescriptor,
285
- nodeQueryDescriptorNeedsBoundedReload,
286
- nodeQueryDescriptorToOptions,
287
- serializeNodeQueryDescriptor,
288
- sortNodeQueryResults,
289
- withoutNodeQueryMaterializedView,
290
- withoutNodeQueryPagination
291
- } from "./chunk-WOEFYS7Y.js";
227
+ BUNDLE_ENTRY,
228
+ BundleImportError,
229
+ MemoryBundleSink,
230
+ MemoryBundleSource,
231
+ XNETPACK_FORMAT_VERSION,
232
+ applyBundle,
233
+ blobEntryPath,
234
+ canonicalManifestBytes,
235
+ createStoreYjsPort,
236
+ fromPortableChangeRecord,
237
+ readBundleManifest,
238
+ toPortableChangeRecord,
239
+ verifyBundle,
240
+ writeBundle
241
+ } from "./chunk-N37U6ZPI.js";
292
242
  import {
293
243
  LensRegistry,
294
244
  MAX_LINK_PREVIEWS_PER_MESSAGE,
@@ -357,7 +307,46 @@ import {
357
307
  taskBranchName,
358
308
  transform,
359
309
  when
360
- } from "./chunk-MAB662PR.js";
310
+ } from "./chunk-YCBJDT23.js";
311
+ import {
312
+ AGENT_ACTION_SCHEMA_IRI,
313
+ AGENT_ACTION_STATUSES,
314
+ AGENT_APPROVAL_DECISIONS,
315
+ AGENT_APPROVAL_SCHEMA_IRI,
316
+ AGENT_APPROVAL_SURFACES,
317
+ AGENT_CHANNELS,
318
+ AGENT_NOTIFICATION_KINDS,
319
+ AGENT_NOTIFICATION_SCHEMA_IRI,
320
+ AGENT_NOTIFICATION_STATUSES,
321
+ AGENT_PASSPORT_SCHEMA_IRI,
322
+ AGENT_REVERSIBILITIES,
323
+ AGENT_RISKS,
324
+ AGENT_RUNTIMES,
325
+ AGENT_SESSION_SCHEMA_IRI,
326
+ AgentActionSchema,
327
+ AgentApprovalSchema,
328
+ AgentNotificationSchema,
329
+ AgentPassportSchema,
330
+ AgentSessionSchema,
331
+ agentActionId,
332
+ agentApprovalId,
333
+ agentNotificationId,
334
+ agentPassportId,
335
+ agentSessionId,
336
+ redactInstruction
337
+ } from "./chunk-2K6BLSNC.js";
338
+ import {
339
+ SavedViewSchema
340
+ } from "./chunk-IVCHWQY7.js";
341
+ import {
342
+ WorkspaceSchema
343
+ } from "./chunk-JUTPAFDP.js";
344
+ import {
345
+ UserWidgetSchema
346
+ } from "./chunk-WQRBUG65.js";
347
+ import {
348
+ DashboardSchema
349
+ } from "./chunk-EUJR5QQC.js";
361
350
  import {
362
351
  AbuseReportSchema,
363
352
  AppealSchema,
@@ -370,8 +359,9 @@ import {
370
359
  PolicySubscriptionSchema,
371
360
  PublicInteractionPolicySchema,
372
361
  QualitySignalSchema,
373
- ReviewTaskSchema
374
- } from "./chunk-CY6EJUNV.js";
362
+ ReviewTaskSchema,
363
+ publicInteractionPolicyId
364
+ } from "./chunk-S7SEN4LH.js";
375
365
  import {
376
366
  ACHIEVEMENT_SCHEMA_IRI,
377
367
  AchievementSchema,
@@ -394,39 +384,32 @@ import {
394
384
  PLAYER_IDENTITY_SCHEMA_IRI,
395
385
  PlayerIdentitySchema,
396
386
  gameSchemas
397
- } from "./chunk-YRFCXKJC.js";
387
+ } from "./chunk-UQ2VFHU3.js";
398
388
  import {
399
389
  MEMORY_ITEM_SCHEMA_IRI,
400
390
  MEMORY_KINDS,
401
391
  MemoryItemSchema
402
392
  } from "./chunk-2DAVPHDV.js";
403
393
  import {
404
- AGENT_ACTION_SCHEMA_IRI,
405
- AGENT_ACTION_STATUSES,
406
- AGENT_APPROVAL_DECISIONS,
407
- AGENT_APPROVAL_SCHEMA_IRI,
408
- AGENT_APPROVAL_SURFACES,
409
- AGENT_CHANNELS,
410
- AGENT_NOTIFICATION_KINDS,
411
- AGENT_NOTIFICATION_SCHEMA_IRI,
412
- AGENT_NOTIFICATION_STATUSES,
413
- AGENT_PASSPORT_SCHEMA_IRI,
414
- AGENT_REVERSIBILITIES,
415
- AGENT_RISKS,
416
- AGENT_RUNTIMES,
417
- AGENT_SESSION_SCHEMA_IRI,
418
- AgentActionSchema,
419
- AgentApprovalSchema,
420
- AgentNotificationSchema,
421
- AgentPassportSchema,
422
- AgentSessionSchema,
423
- agentActionId,
424
- agentApprovalId,
425
- agentNotificationId,
426
- agentPassportId,
427
- agentSessionId,
428
- redactInstruction
429
- } from "./chunk-2K6BLSNC.js";
394
+ CHANNEL_KINDS,
395
+ ChannelSchema
396
+ } from "./chunk-7MSSPUMC.js";
397
+ import {
398
+ ChatMessageSchema
399
+ } from "./chunk-57AT2DT2.js";
400
+ import {
401
+ FEED_SCHEMA_IRI,
402
+ FeedSchema
403
+ } from "./chunk-EA2PZ3EU.js";
404
+ import {
405
+ FEED_ITEM_SCHEMA_IRI,
406
+ FeedItemSchema
407
+ } from "./chunk-QH7RZEHT.js";
408
+ import {
409
+ EXTERNAL_ITEM_SCHEMA_IRI,
410
+ EXTERNAL_ITEM_SOURCES,
411
+ ExternalItemSchema
412
+ } from "./chunk-FTKHARBY.js";
430
413
  import {
431
414
  DEFAULT_CHANNEL_TIER,
432
415
  InboxStateSchema,
@@ -436,17 +419,22 @@ import {
436
419
  GrantSchema
437
420
  } from "./chunk-TH2BJPDZ.js";
438
421
  import {
439
- SavedViewSchema
440
- } from "./chunk-IVCHWQY7.js";
422
+ CanvasSchema
423
+ } from "./chunk-O34JPX6Q.js";
441
424
  import {
442
- WorkspaceSchema
443
- } from "./chunk-JUTPAFDP.js";
425
+ MapSchema
426
+ } from "./chunk-HSCGVBQN.js";
444
427
  import {
445
- UserWidgetSchema
446
- } from "./chunk-WQRBUG65.js";
428
+ CommentSchema
429
+ } from "./chunk-ICBC5VLZ.js";
447
430
  import {
448
- DashboardSchema
449
- } from "./chunk-EUJR5QQC.js";
431
+ CHECKPOINT_SCHEMA_IRI,
432
+ CheckpointSchema
433
+ } from "./chunk-TOQ2LBAN.js";
434
+ import {
435
+ DRAFT_SCHEMA_IRI,
436
+ DraftSchema
437
+ } from "./chunk-6AKAZHVZ.js";
450
438
  import {
451
439
  ReactionSchema
452
440
  } from "./chunk-RAJNAD64.js";
@@ -457,27 +445,40 @@ import {
457
445
  ProfileSchema,
458
446
  didFromProfileNodeId,
459
447
  profileNodeId
460
- } from "./chunk-4HJZJMPI.js";
448
+ } from "./chunk-TN7LGV66.js";
461
449
  import {
462
- CHANNEL_KINDS,
463
- ChannelSchema
464
- } from "./chunk-7MSSPUMC.js";
450
+ POSTING_SCHEMA_IRI,
451
+ PostingSchema
452
+ } from "./chunk-F6ICOU6R.js";
465
453
  import {
466
- ChatMessageSchema
467
- } from "./chunk-57AT2DT2.js";
454
+ BUDGET_SCHEMA_IRI,
455
+ BudgetSchema
456
+ } from "./chunk-KHLOVRMQ.js";
468
457
  import {
469
- FEED_SCHEMA_IRI,
470
- FeedSchema
471
- } from "./chunk-EA2PZ3EU.js";
458
+ IMPORT_BATCH_SCHEMA_IRI,
459
+ ImportBatchSchema
460
+ } from "./chunk-M6STMJ2V.js";
472
461
  import {
473
- FEED_ITEM_SCHEMA_IRI,
474
- FeedItemSchema
475
- } from "./chunk-QH7RZEHT.js";
462
+ NODE_VISIBILITY,
463
+ SPACE_KINDS,
464
+ SPACE_ROLES,
465
+ SPACE_SCHEMA_IRI,
466
+ SPACE_VISIBILITY,
467
+ SpaceSchema,
468
+ buildSpaceTree,
469
+ canManageSpace,
470
+ compareSpaceRoles,
471
+ effectiveSpaceRole,
472
+ flattenSpaceTree,
473
+ spaceAncestorIds,
474
+ spacePathIds,
475
+ spaceRoleGrantActions,
476
+ spaceRoleToShareRole,
477
+ wouldCreateSpaceCycle
478
+ } from "./chunk-RRIRY7FP.js";
476
479
  import {
477
- EXTERNAL_ITEM_SCHEMA_IRI,
478
- EXTERNAL_ITEM_SOURCES,
479
- ExternalItemSchema
480
- } from "./chunk-FTKHARBY.js";
480
+ ExternalReferenceSchema
481
+ } from "./chunk-XFOUIAJF.js";
481
482
  import {
482
483
  MediaAssetSchema
483
484
  } from "./chunk-LDKJDNSW.js";
@@ -494,22 +495,21 @@ import {
494
495
  MeetingTranscriptSchema
495
496
  } from "./chunk-QOTR4SGT.js";
496
497
  import {
497
- CanvasSchema
498
- } from "./chunk-O34JPX6Q.js";
498
+ ProjectSchema
499
+ } from "./chunk-3FWYS6AW.js";
499
500
  import {
500
- MapSchema
501
- } from "./chunk-HSCGVBQN.js";
501
+ MetricSchema
502
+ } from "./chunk-QVGTYLL3.js";
502
503
  import {
503
- CommentSchema
504
- } from "./chunk-ICBC5VLZ.js";
504
+ ObservationSchema
505
+ } from "./chunk-ZEMCCIIO.js";
505
506
  import {
506
- CHECKPOINT_SCHEMA_IRI,
507
- CheckpointSchema
508
- } from "./chunk-TOQ2LBAN.js";
507
+ ExperimentSchema
508
+ } from "./chunk-EZJ3OD5A.js";
509
509
  import {
510
- DRAFT_SCHEMA_IRI,
511
- DraftSchema
512
- } from "./chunk-6AKAZHVZ.js";
510
+ MILESTONE_SCHEMA_IRI,
511
+ MilestoneSchema
512
+ } from "./chunk-R2AZXT3D.js";
513
513
  import {
514
514
  ACTIVITY_KINDS,
515
515
  ACTIVITY_SCHEMA_IRI,
@@ -551,38 +551,8 @@ import {
551
551
  TransactionSchema
552
552
  } from "./chunk-PKLHOQSO.js";
553
553
  import {
554
- POSTING_SCHEMA_IRI,
555
- PostingSchema
556
- } from "./chunk-F6ICOU6R.js";
557
- import {
558
- BUDGET_SCHEMA_IRI,
559
- BudgetSchema
560
- } from "./chunk-KHLOVRMQ.js";
561
- import {
562
- IMPORT_BATCH_SCHEMA_IRI,
563
- ImportBatchSchema
564
- } from "./chunk-M6STMJ2V.js";
565
- import {
566
- NODE_VISIBILITY,
567
- SPACE_KINDS,
568
- SPACE_ROLES,
569
- SPACE_SCHEMA_IRI,
570
- SPACE_VISIBILITY,
571
- SpaceSchema,
572
- buildSpaceTree,
573
- canManageSpace,
574
- compareSpaceRoles,
575
- effectiveSpaceRole,
576
- flattenSpaceTree,
577
- spaceAncestorIds,
578
- spacePathIds,
579
- spaceRoleGrantActions,
580
- spaceRoleToShareRole,
581
- wouldCreateSpaceCycle
582
- } from "./chunk-RRIRY7FP.js";
583
- import {
584
- ExternalReferenceSchema
585
- } from "./chunk-XFOUIAJF.js";
554
+ DatabaseSchema
555
+ } from "./chunk-JB6BPIVP.js";
586
556
  import {
587
557
  TASK_STATUS_CATEGORIES,
588
558
  TaskSchema,
@@ -592,25 +562,35 @@ import {
592
562
  import {
593
563
  TaskViewSchema
594
564
  } from "./chunk-4SIMTLCC.js";
595
- import {
596
- ProjectSchema
597
- } from "./chunk-3FWYS6AW.js";
598
- import {
599
- MetricSchema
600
- } from "./chunk-QVGTYLL3.js";
601
- import {
602
- ObservationSchema
603
- } from "./chunk-ZEMCCIIO.js";
604
- import {
605
- ExperimentSchema
606
- } from "./chunk-EZJ3OD5A.js";
607
- import {
608
- MILESTONE_SCHEMA_IRI,
609
- MilestoneSchema
610
- } from "./chunk-R2AZXT3D.js";
611
565
  import {
612
566
  PageSchema
613
- } from "./chunk-JF4VCZER.js";
567
+ } from "./chunk-WSINZHSR.js";
568
+ import {
569
+ POST_SCHEMA_IRI,
570
+ PostSchema,
571
+ comparePostsForFeed
572
+ } from "./chunk-KY62NUOI.js";
573
+ import {
574
+ COURSE_SCHEMA_IRI,
575
+ CourseSchema,
576
+ LESSON_PROGRESS_SCHEMA_IRI,
577
+ LESSON_SCHEMA_IRI,
578
+ LessonProgressSchema,
579
+ LessonSchema,
580
+ courseCompletion,
581
+ lessonProgressId
582
+ } from "./chunk-GJAOMEQO.js";
583
+ import {
584
+ EVENT_SCHEMA_IRI,
585
+ EventSchema,
586
+ RSVP_SCHEMA_IRI,
587
+ RsvpSchema,
588
+ rsvpId,
589
+ upcomingEvents
590
+ } from "./chunk-VZSEZNYA.js";
591
+ import {
592
+ PublicationSchema
593
+ } from "./chunk-NFPEFD2I.js";
614
594
  import {
615
595
  FOLDER_SCHEMA_IRI,
616
596
  FolderSchema,
@@ -627,15 +607,24 @@ import {
627
607
  isValidTagName,
628
608
  normalizeTagName
629
609
  } from "./chunk-YFLL3CME.js";
630
- import {
631
- DatabaseSchema
632
- } from "./chunk-JB6BPIVP.js";
633
610
  import {
634
611
  EXT_PREFIX,
635
612
  extKey,
636
613
  isExtKey,
637
614
  parseExtKey
638
615
  } from "./chunk-PMUQACPY.js";
616
+ import {
617
+ DatabaseRowSchema
618
+ } from "./chunk-AKKBG7HW.js";
619
+ import {
620
+ DatabaseFieldSchema
621
+ } from "./chunk-IKREWSCX.js";
622
+ import {
623
+ DatabaseSelectOptionSchema
624
+ } from "./chunk-XP3VSSXD.js";
625
+ import {
626
+ DatabaseViewSchema
627
+ } from "./chunk-UFV5QWCL.js";
639
628
  import {
640
629
  EXTENSION_FIELD_SCHEMA_IRI,
641
630
  ExtensionFieldSchema,
@@ -643,6 +632,13 @@ import {
643
632
  SchemaExtensionSchema,
644
633
  schemaExtensionId
645
634
  } from "./chunk-2JROE7ML.js";
635
+ import "./chunk-RLRAWZJE.js";
636
+ import {
637
+ SPACE_MEMBERSHIP_SCHEMA_IRI,
638
+ SpaceMembershipSchema,
639
+ isSpaceRole,
640
+ spaceMembershipId
641
+ } from "./chunk-GSLOK5KV.js";
646
642
  import {
647
643
  MAX_KEY_LENGTH,
648
644
  compareSortKeys,
@@ -653,42 +649,77 @@ import {
653
649
  rebalanceSortKeys
654
650
  } from "./chunk-QWFTRZQT.js";
655
651
  import {
656
- DatabaseRowSchema
657
- } from "./chunk-AKKBG7HW.js";
658
- import {
659
- DatabaseFieldSchema
660
- } from "./chunk-IKREWSCX.js";
661
- import {
662
- DatabaseSelectOptionSchema
663
- } from "./chunk-XP3VSSXD.js";
652
+ MemoryNodeStorageAdapter,
653
+ NodeStore,
654
+ PermissionError,
655
+ QUERY_AST_VERSION,
656
+ SQLiteNodeStorageAdapter,
657
+ TEMP_ID_PREFIX,
658
+ and,
659
+ avg,
660
+ between,
661
+ contains,
662
+ count,
663
+ countDistinct,
664
+ createNodeStorageAdapter,
665
+ createSchemaLookup,
666
+ dashboardQuerySet,
667
+ defineNodeQueryAST,
668
+ defineQuerySetAST,
669
+ defineSavedViewDescriptor,
670
+ eq,
671
+ evaluateQueryASTPlannerGate,
672
+ executeQueryASTLoadedAggregates,
673
+ filterQueryASTLoadedRows,
674
+ follow,
675
+ from,
676
+ getQueryASTRelationIndexRequirements,
677
+ groupBy,
678
+ gt,
679
+ gte,
680
+ having,
681
+ includesAny,
682
+ isNotNull,
683
+ isNull,
684
+ isTempId,
685
+ lt,
686
+ lte,
687
+ matchesQueryASTLoadedRow,
688
+ max,
689
+ min,
690
+ neq,
691
+ not,
692
+ or,
693
+ planQueryASTAggregates,
694
+ queryOperators,
695
+ querySetCount,
696
+ resolveTempIds,
697
+ startsWith,
698
+ sum,
699
+ validateQueryAST,
700
+ validateSavedViewDescriptor
701
+ } from "./chunk-QKVIKVAL.js";
664
702
  import {
665
- DatabaseViewSchema
666
- } from "./chunk-UFV5QWCL.js";
667
- import "./chunk-RLRAWZJE.js";
703
+ applyNodeQueryDescriptor,
704
+ createNodeQueryDescriptor,
705
+ decodeNodeQueryCursor,
706
+ encodeNodeQueryCursor,
707
+ filterNodeQueryResults,
708
+ getNodeQuerySearchTokens,
709
+ matchesNodeQueryDescriptor,
710
+ nodeQueryDescriptorNeedsBoundedReload,
711
+ nodeQueryDescriptorToOptions,
712
+ serializeNodeQueryDescriptor,
713
+ sortNodeQueryResults,
714
+ withoutNodeQueryMaterializedView,
715
+ withoutNodeQueryPagination
716
+ } from "./chunk-WOEFYS7Y.js";
668
717
  import {
669
718
  evaluateLedgerWrite,
670
719
  foldAccountRecord,
671
720
  ledgerAccountId,
672
721
  ledgerWriteKind
673
722
  } from "./chunk-3UOUVEZW.js";
674
- import {
675
- ACCOUNT_RECORD_SCHEMA_IRI,
676
- AccountRecordSchema,
677
- DEVICE_RECORD_SCHEMA_IRI,
678
- DeviceRecordSchema,
679
- RECOVERY_RECORD_SCHEMA_IRI,
680
- REVOCATION_RECORD_SCHEMA_IRI,
681
- RecoveryRecordSchema,
682
- RevocationRecordSchema,
683
- accountRecordId,
684
- deviceRecipientExpander,
685
- deviceRecordId,
686
- isDeviceAuthorized,
687
- recoveryRecordId,
688
- resolveActiveDevices,
689
- revocationRecordId,
690
- revokedSubjects
691
- } from "./chunk-5ECIKN6Z.js";
692
723
  import {
693
724
  PresenceSummarySchema,
694
725
  SYSTEM_NAMESPACE_KINDS,
@@ -708,21 +739,23 @@ import {
708
739
  validateSchemaDefinitionNode
709
740
  } from "./chunk-ZNHLH7SC.js";
710
741
  import {
711
- clearLocalPresence,
712
- createAwareness,
713
- generateUserColor,
714
- getAllPresences,
715
- getLocalClientId,
716
- getRemotePresences,
717
- onPresenceChange,
718
- setLocalPresence
719
- } from "./chunk-7PDRDSFH.js";
720
- import {
721
- SPACE_MEMBERSHIP_SCHEMA_IRI,
722
- SpaceMembershipSchema,
723
- isSpaceRole,
724
- spaceMembershipId
725
- } from "./chunk-GSLOK5KV.js";
742
+ ACCOUNT_RECORD_SCHEMA_IRI,
743
+ AccountRecordSchema,
744
+ DEVICE_RECORD_SCHEMA_IRI,
745
+ DeviceRecordSchema,
746
+ RECOVERY_RECORD_SCHEMA_IRI,
747
+ REVOCATION_RECORD_SCHEMA_IRI,
748
+ RecoveryRecordSchema,
749
+ RevocationRecordSchema,
750
+ accountRecordId,
751
+ deviceRecipientExpander,
752
+ deviceRecordId,
753
+ isDeviceAuthorized,
754
+ recoveryRecordId,
755
+ resolveActiveDevices,
756
+ revocationRecordId,
757
+ revokedSubjects
758
+ } from "./chunk-5ECIKN6Z.js";
726
759
  import {
727
760
  checkbox,
728
761
  createNodeId,
@@ -768,6 +801,16 @@ import {
768
801
  mergeOfflinePolicy,
769
802
  schemaToHubPolicy
770
803
  } from "./chunk-D4LUUZYD.js";
804
+ import {
805
+ clearLocalPresence,
806
+ createAwareness,
807
+ generateUserColor,
808
+ getAllPresences,
809
+ getLocalClientId,
810
+ getRemotePresences,
811
+ onPresenceChange,
812
+ setLocalPresence
813
+ } from "./chunk-7PDRDSFH.js";
771
814
 
772
815
  // src/external-references.ts
773
816
  var EMBED_PROVIDERS = [
@@ -2049,646 +2092,9 @@ var BlobService = class {
2049
2092
  }
2050
2093
  };
2051
2094
 
2052
- // src/portability/types.ts
2053
- var XNETPACK_FORMAT_VERSION = "xnetpack/1";
2054
- var BUNDLE_ENTRY = {
2055
- manifest: "manifest.json",
2056
- changes: "changes.ndjson",
2057
- blobIndex: "blobs.ndjson",
2058
- yjsDocs: "yjs/docs.ndjson"
2059
- };
2060
- var FRONTIER_HEADS_CAP = 32;
2061
-
2062
- // src/portability/serialize.ts
2063
- import { bytesToBase64, base64ToBytes, hash, hashHex } from "@xnetjs/crypto";
2064
- var textEncoder = new TextEncoder();
2065
- var textDecoder = new TextDecoder();
2066
- function toPortableChangeRecord(change) {
2067
- const record = {
2068
- id: change.id,
2069
- type: change.type,
2070
- hash: change.hash,
2071
- nodeId: change.payload.nodeId,
2072
- schemaId: change.payload.schemaId,
2073
- lamportTime: change.lamport,
2074
- authorDid: change.authorDID,
2075
- wallTime: change.wallTime,
2076
- parentHash: change.parentHash,
2077
- payload: change.payload,
2078
- signatureB64: bytesToBase64(change.signature),
2079
- // protocolVersion is part of the hashed fields — dropping it makes the
2080
- // record fail verifyChangeHash on the importing side.
2081
- protocolVersion: change.protocolVersion,
2082
- batchId: change.batchId,
2083
- batchIndex: change.batchIndex,
2084
- batchSize: change.batchSize
2085
- };
2086
- return record;
2087
- }
2088
- function fromPortableChangeRecord(record) {
2089
- const payload = record.payload && !record.payload.schemaId && record.schemaId ? { ...record.payload, schemaId: record.schemaId } : record.payload;
2090
- return {
2091
- id: record.id,
2092
- type: record.type,
2093
- hash: record.hash,
2094
- parentHash: record.parentHash,
2095
- authorDID: record.authorDid,
2096
- signature: base64ToBytes(record.signatureB64),
2097
- wallTime: record.wallTime,
2098
- lamport: record.lamportTime,
2099
- payload,
2100
- protocolVersion: record.protocolVersion,
2101
- batchId: record.batchId,
2102
- batchIndex: record.batchIndex,
2103
- batchSize: record.batchSize
2104
- };
2105
- }
2106
- function sortObjectKeys(obj) {
2107
- if (obj === null || typeof obj !== "object") return obj;
2108
- if (Array.isArray(obj)) return obj.map(sortObjectKeys);
2109
- const sorted = {};
2110
- for (const key of Object.keys(obj).sort()) {
2111
- sorted[key] = sortObjectKeys(obj[key]);
2112
- }
2113
- return sorted;
2114
- }
2115
- function canonicalManifestBytes(manifest) {
2116
- const unsigned = { ...manifest };
2117
- delete unsigned.signatureB64;
2118
- return textEncoder.encode(JSON.stringify(sortObjectKeys(unsigned)));
2119
- }
2120
- function createNdjsonDigest() {
2121
- const lineDigests = [];
2122
- return {
2123
- addLine(line) {
2124
- lineDigests.push(hash(textEncoder.encode(line)));
2125
- },
2126
- finish() {
2127
- const concat = new Uint8Array(lineDigests.length * 32);
2128
- lineDigests.forEach((d, i) => concat.set(d, i * 32));
2129
- return hashHex(concat);
2130
- },
2131
- lineCount() {
2132
- return lineDigests.length;
2133
- }
2134
- };
2135
- }
2136
- function digestEntryBytes(bytes) {
2137
- return hashHex(bytes);
2138
- }
2139
- function combineEntryDigests(entries) {
2140
- const lines = [...entries.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([path, digest]) => `${path}
2141
- ${digest}
2142
- `);
2143
- return hashHex(textEncoder.encode(lines.join("")));
2144
- }
2145
- function encodeNdjsonLine(value) {
2146
- return JSON.stringify(value);
2147
- }
2148
- function decodeUtf8(bytes) {
2149
- return textDecoder.decode(bytes);
2150
- }
2151
- function encodeUtf8(text2) {
2152
- return textEncoder.encode(text2);
2153
- }
2154
-
2155
- // src/portability/write.ts
2156
- import { compareChangeApplicationOrder } from "@xnetjs/core";
2157
- import { CURRENT_PROTOCOL_VERSION } from "@xnetjs/sync";
2158
- import { bytesToBase64 as bytesToBase642 } from "@xnetjs/crypto";
2159
- function blobEntryPath(cid) {
2160
- const match = /^cid:([a-z0-9-]+):([0-9a-f]+)$/i.exec(cid);
2161
- if (match) return `blobs/${match[1]}/${match[2]}`;
2162
- return `blobs/raw/${encodeURIComponent(cid)}`;
2163
- }
2164
- function frontierOf(changes) {
2165
- let lamport = 0;
2166
- for (const change of changes) if (change.lamport > lamport) lamport = change.lamport;
2167
- const heads = changes.filter((c) => c.lamport === lamport).slice(0, FRONTIER_HEADS_CAP).map((c) => c.hash);
2168
- return { lamport, heads, changeCount: changes.length };
2169
- }
2170
- function spaceOf(properties) {
2171
- return properties["space"];
2172
- }
2173
- async function collectScopedNodeIds(store, scope) {
2174
- if (scope.kind === "nodes") return [...scope.nodeIds];
2175
- if (scope.kind === "schemas") {
2176
- const ids2 = [];
2177
- for (const schemaId of scope.schemaIds) {
2178
- const nodes = await store.list({ schemaId, includeDeleted: true });
2179
- for (const node of nodes) ids2.push(node.id);
2180
- }
2181
- return ids2;
2182
- }
2183
- if (scope.kind !== "space") return [];
2184
- const all = await store.list({ includeDeleted: true });
2185
- const ids = [];
2186
- for (const node of all) {
2187
- if (node.id === scope.spaceId) {
2188
- ids.push(node.id);
2189
- continue;
2190
- }
2191
- const space = spaceOf(node.properties);
2192
- if (space === scope.spaceId) ids.push(node.id);
2193
- else if (Array.isArray(space) && space.includes(scope.spaceId)) ids.push(node.id);
2194
- }
2195
- return ids;
2196
- }
2197
- async function collectChanges(store, scope, since) {
2198
- let changes;
2199
- if (scope.kind === "full") {
2200
- changes = since ? await store.getChangesSince(since.lamport) : await store.getAllChanges();
2201
- } else {
2202
- const nodeIds = await collectScopedNodeIds(store, scope);
2203
- const byHash = /* @__PURE__ */ new Map();
2204
- for (const nodeId of nodeIds) {
2205
- for (const change of await store.getChanges(nodeId)) {
2206
- if (!since || change.lamport > since.lamport) byHash.set(change.hash, change);
2207
- }
2208
- }
2209
- changes = [...byHash.values()];
2210
- }
2211
- return changes.sort(
2212
- (a, b) => compareChangeApplicationOrder(
2213
- { lamport: a.lamport, author: a.authorDID },
2214
- { lamport: b.lamport, author: b.authorDID }
2215
- )
2216
- );
2217
- }
2218
- async function writeBundle(store, scope, sink, options) {
2219
- const entryDigests = /* @__PURE__ */ new Map();
2220
- const changes = await collectChanges(store, scope, options.since);
2221
- const changesDigest = createNdjsonDigest();
2222
- const changeLines = [];
2223
- for (const change of changes) {
2224
- const line = encodeNdjsonLine(toPortableChangeRecord(change));
2225
- changesDigest.addLine(line);
2226
- changeLines.push(line);
2227
- }
2228
- await sink.writeEntry(
2229
- BUNDLE_ENTRY.changes,
2230
- encodeUtf8(changeLines.join("\n") + (changeLines.length ? "\n" : ""))
2231
- );
2232
- entryDigests.set(BUNDLE_ENTRY.changes, changesDigest.finish());
2233
- let blobCount = 0;
2234
- const blobIndexDigest = createNdjsonDigest();
2235
- const blobIndexLines = [];
2236
- if (options.blobPort) {
2237
- for await (const blob of options.blobPort.list()) {
2238
- const path = blobEntryPath(blob.cid);
2239
- await sink.writeEntry(path, blob.bytes);
2240
- entryDigests.set(path, digestEntryBytes(blob.bytes));
2241
- const record = {
2242
- cid: blob.cid,
2243
- path,
2244
- size: blob.bytes.byteLength,
2245
- mimeType: blob.mimeType
2246
- };
2247
- const line = encodeNdjsonLine(record);
2248
- blobIndexDigest.addLine(line);
2249
- blobIndexLines.push(line);
2250
- blobCount++;
2251
- }
2252
- }
2253
- await sink.writeEntry(
2254
- BUNDLE_ENTRY.blobIndex,
2255
- encodeUtf8(blobIndexLines.join("\n") + (blobIndexLines.length ? "\n" : ""))
2256
- );
2257
- entryDigests.set(BUNDLE_ENTRY.blobIndex, blobIndexDigest.finish());
2258
- let yjsCount = 0;
2259
- const yjsDigest = createNdjsonDigest();
2260
- const yjsLines = [];
2261
- if (options.yjsPort) {
2262
- for await (const doc of options.yjsPort.list()) {
2263
- const line = encodeNdjsonLine({ nodeId: doc.nodeId, updateB64: bytesToBase642(doc.update) });
2264
- yjsDigest.addLine(line);
2265
- yjsLines.push(line);
2266
- yjsCount++;
2267
- }
2268
- }
2269
- await sink.writeEntry(
2270
- BUNDLE_ENTRY.yjsDocs,
2271
- encodeUtf8(yjsLines.join("\n") + (yjsLines.length ? "\n" : ""))
2272
- );
2273
- entryDigests.set(BUNDLE_ENTRY.yjsDocs, yjsDigest.finish());
2274
- const manifest = {
2275
- formatVersion: XNETPACK_FORMAT_VERSION,
2276
- protocolVersion: { change: CURRENT_PROTOCOL_VERSION },
2277
- ownerDid: options.ownerDid,
2278
- scope,
2279
- createdAt: Date.now(),
2280
- frontier: frontierOf(changes),
2281
- prerequisites: options.since,
2282
- counts: { changes: changes.length, blobs: blobCount, yjsDocs: yjsCount },
2283
- contentDigest: combineEntryDigests(entryDigests)
2284
- };
2285
- if (options.manifestSigner) {
2286
- const signature = await options.manifestSigner(canonicalManifestBytes(manifest));
2287
- manifest.signatureB64 = bytesToBase642(signature);
2288
- }
2289
- await sink.writeEntry(BUNDLE_ENTRY.manifest, encodeUtf8(JSON.stringify(manifest, null, 2)));
2290
- return manifest;
2291
- }
2292
-
2293
- // src/portability/verify.ts
2294
- import { verifyChange, verifyChangeHash, CURRENT_PROTOCOL_VERSION as CURRENT_PROTOCOL_VERSION2 } from "@xnetjs/sync";
2295
- import { base64ToBytes as base64ToBytes2, verify as verifySignature } from "@xnetjs/crypto";
2296
- import { parseDID } from "@xnetjs/identity";
2297
- function parseCidHex(path) {
2298
- const match = /^blobs\/([a-z0-9-]+)\/([0-9a-f]+)$/i.exec(path);
2299
- if (!match || match[1] === "raw") return null;
2300
- return { algo: match[1], hex: match[2] };
2301
- }
2302
- async function verifyBundle(source, options = {}) {
2303
- const verifyChangeSignatures = options.verifyChangeSignatures ?? true;
2304
- const issues = [];
2305
- const error = (code, detail, subject) => issues.push({ severity: "error", code, detail, subject });
2306
- const warning = (code, detail, subject) => issues.push({ severity: "warning", code, detail, subject });
2307
- const manifestBytes = await source.readEntry(BUNDLE_ENTRY.manifest);
2308
- if (!manifestBytes) {
2309
- error("unknown-format", "bundle has no manifest.json");
2310
- return { ok: false, manifest: null, issues, danglingParents: 0 };
2311
- }
2312
- let manifest;
2313
- try {
2314
- manifest = JSON.parse(decodeUtf8(manifestBytes));
2315
- } catch (err) {
2316
- error("unknown-format", `manifest.json is not valid JSON: ${err.message}`);
2317
- return { ok: false, manifest: null, issues, danglingParents: 0 };
2318
- }
2319
- if (manifest.formatVersion !== XNETPACK_FORMAT_VERSION) {
2320
- error("unknown-format", `unsupported formatVersion "${manifest.formatVersion}"`);
2321
- return { ok: false, manifest, issues, danglingParents: 0 };
2322
- }
2323
- if ((manifest.protocolVersion?.change ?? 0) > CURRENT_PROTOCOL_VERSION2) {
2324
- error(
2325
- "future-protocol",
2326
- `bundle uses change protocol v${manifest.protocolVersion.change}, this build supports v${CURRENT_PROTOCOL_VERSION2}`
2327
- );
2328
- }
2329
- if (!manifest.signatureB64) {
2330
- warning("manifest-unsigned", "manifest carries no signature");
2331
- } else {
2332
- try {
2333
- const publicKey = parseDID(manifest.ownerDid);
2334
- const signature = base64ToBytes2(manifest.signatureB64);
2335
- if (!verifySignature(canonicalManifestBytes(manifest), signature, publicKey)) {
2336
- error(
2337
- "manifest-signature-invalid",
2338
- `manifest signature does not verify against ${manifest.ownerDid}`
2339
- );
2340
- }
2341
- } catch (err) {
2342
- error(
2343
- "manifest-signature-invalid",
2344
- `cannot verify manifest signature: ${err.message}`
2345
- );
2346
- }
2347
- }
2348
- const entryDigests = /* @__PURE__ */ new Map();
2349
- const changesDigest = createNdjsonDigest();
2350
- const presentHashes = /* @__PURE__ */ new Set();
2351
- const parentHashes = [];
2352
- let lineNumber = 0;
2353
- for await (const line of source.readLines(BUNDLE_ENTRY.changes)) {
2354
- lineNumber++;
2355
- changesDigest.addLine(line);
2356
- let record;
2357
- try {
2358
- record = JSON.parse(line);
2359
- } catch {
2360
- error(
2361
- "change-unparseable",
2362
- `changes.ndjson line ${lineNumber} is not valid JSON`,
2363
- `line:${lineNumber}`
2364
- );
2365
- continue;
2366
- }
2367
- let change;
2368
- try {
2369
- change = fromPortableChangeRecord(record);
2370
- } catch (err) {
2371
- error("change-unparseable", `line ${lineNumber}: ${err.message}`, record.hash);
2372
- continue;
2373
- }
2374
- if (verifyChangeSignatures) {
2375
- if (!verifyChangeHash(change)) {
2376
- error(
2377
- "change-hash-invalid",
2378
- `change ${change.id} fails hash re-computation (tampered?)`,
2379
- record.hash
2380
- );
2381
- continue;
2382
- }
2383
- try {
2384
- const publicKey = parseDID(change.authorDID);
2385
- if (!verifyChange(change, publicKey)) {
2386
- error(
2387
- "change-signature-invalid",
2388
- `change ${change.id} signature does not match ${change.authorDID}`,
2389
- record.hash
2390
- );
2391
- continue;
2392
- }
2393
- } catch (err) {
2394
- error(
2395
- "change-signature-invalid",
2396
- `change ${change.id}: ${err.message}`,
2397
- record.hash
2398
- );
2399
- continue;
2400
- }
2401
- }
2402
- presentHashes.add(change.hash);
2403
- parentHashes.push(change.parentHash);
2404
- }
2405
- entryDigests.set(BUNDLE_ENTRY.changes, changesDigest.finish());
2406
- if (changesDigest.lineCount() !== manifest.counts.changes) {
2407
- error(
2408
- "count-mismatch",
2409
- `manifest declares ${manifest.counts.changes} changes, bundle has ${changesDigest.lineCount()}`
2410
- );
2411
- }
2412
- const prerequisiteHeads = new Set(manifest.prerequisites?.heads ?? []);
2413
- let danglingParents = 0;
2414
- for (const parent of parentHashes) {
2415
- if (parent !== null && !presentHashes.has(parent) && !prerequisiteHeads.has(parent)) {
2416
- danglingParents++;
2417
- }
2418
- }
2419
- if (danglingParents > 0) {
2420
- warning(
2421
- "dangling-parent",
2422
- `${danglingParents} change(s) reference parents outside the bundle (expected for scoped/incremental exports)`
2423
- );
2424
- }
2425
- const blobIndexDigest = createNdjsonDigest();
2426
- const indexedPaths = /* @__PURE__ */ new Set();
2427
- for await (const line of source.readLines(BUNDLE_ENTRY.blobIndex)) {
2428
- blobIndexDigest.addLine(line);
2429
- try {
2430
- const record = JSON.parse(line);
2431
- indexedPaths.add(record.path);
2432
- } catch {
2433
- error("change-unparseable", "blobs.ndjson contains an unparseable line");
2434
- }
2435
- }
2436
- entryDigests.set(BUNDLE_ENTRY.blobIndex, blobIndexDigest.finish());
2437
- if (blobIndexDigest.lineCount() !== manifest.counts.blobs) {
2438
- error(
2439
- "count-mismatch",
2440
- `manifest declares ${manifest.counts.blobs} blobs, index has ${blobIndexDigest.lineCount()}`
2441
- );
2442
- }
2443
- for (const path of await source.listEntries("blobs/")) {
2444
- if (path === BUNDLE_ENTRY.blobIndex) continue;
2445
- const bytes = await source.readEntry(path);
2446
- if (!bytes) continue;
2447
- entryDigests.set(path, digestEntryBytes(bytes));
2448
- const cid = parseCidHex(path);
2449
- if (cid && cid.algo === "blake3" && digestEntryBytes(bytes) !== cid.hex.toLowerCase()) {
2450
- error("blob-digest-mismatch", `blob ${path} bytes do not hash to their filename`, path);
2451
- }
2452
- if (!indexedPaths.has(path)) {
2453
- warning("count-mismatch", `blob entry ${path} is not listed in blobs.ndjson`, path);
2454
- }
2455
- }
2456
- const yjsDigest = createNdjsonDigest();
2457
- for await (const line of source.readLines(BUNDLE_ENTRY.yjsDocs)) {
2458
- yjsDigest.addLine(line);
2459
- }
2460
- entryDigests.set(BUNDLE_ENTRY.yjsDocs, yjsDigest.finish());
2461
- if (yjsDigest.lineCount() !== manifest.counts.yjsDocs) {
2462
- error(
2463
- "count-mismatch",
2464
- `manifest declares ${manifest.counts.yjsDocs} yjs docs, bundle has ${yjsDigest.lineCount()}`
2465
- );
2466
- }
2467
- if (combineEntryDigests(entryDigests) !== manifest.contentDigest) {
2468
- error("content-digest-mismatch", "entry digests do not match manifest.contentDigest");
2469
- }
2470
- return {
2471
- ok: !issues.some((i) => i.severity === "error"),
2472
- manifest,
2473
- issues,
2474
- danglingParents
2475
- };
2476
- }
2477
-
2478
- // src/portability/apply.ts
2479
- import { compareChangeApplicationOrder as compareChangeApplicationOrder2 } from "@xnetjs/core";
2480
- import { base64ToBytes as base64ToBytes3 } from "@xnetjs/crypto";
2481
- var BundleImportError = class extends Error {
2482
- constructor(message, code) {
2483
- super(message);
2484
- this.code = code;
2485
- this.name = "BundleImportError";
2486
- }
2487
- };
2488
- var APPLY_BATCH_SIZE = 500;
2489
- async function applyBundle(store, source, options) {
2490
- const verifyReport = await verifyBundle(source, { verifyChangeSignatures: false });
2491
- if (!verifyReport.ok || !verifyReport.manifest) {
2492
- const details = verifyReport.issues.filter((i) => i.severity === "error").map((i) => i.detail).join("; ");
2493
- throw new BundleImportError(`bundle failed verification: ${details}`, "verify-failed");
2494
- }
2495
- const manifest = verifyReport.manifest;
2496
- if (!manifest.signatureB64 && !options.allowUnsigned) {
2497
- throw new BundleImportError(
2498
- "bundle manifest is unsigned \u2014 pass allowUnsigned to import anyway",
2499
- "unsigned-manifest"
2500
- );
2501
- }
2502
- if (manifest.ownerDid !== options.importerDid && !options.allowForeignOwner) {
2503
- throw new BundleImportError(
2504
- `bundle is owned by ${manifest.ownerDid} but the importer is ${options.importerDid} \u2014 pass allowForeignOwner to import a bundle from another identity`,
2505
- "foreign-owner"
2506
- );
2507
- }
2508
- const missingPrerequisites = [];
2509
- if (manifest.prerequisites) {
2510
- for (const head of manifest.prerequisites.heads) {
2511
- if (!await store.hasChange(head)) missingPrerequisites.push(head);
2512
- }
2513
- if (missingPrerequisites.length > 0 && !options.ignoreMissingPrerequisites) {
2514
- throw new BundleImportError(
2515
- `store is missing ${missingPrerequisites.length} prerequisite head(s) \u2014 this incremental bundle needs its base bundle imported first (or pass ignoreMissingPrerequisites)`,
2516
- "missing-prerequisites"
2517
- );
2518
- }
2519
- }
2520
- const quarantined = [];
2521
- const quarantine = (record) => {
2522
- quarantined.push(record);
2523
- options.onQuarantine?.(record);
2524
- };
2525
- const changes = [];
2526
- for await (const line of source.readLines(BUNDLE_ENTRY.changes)) {
2527
- try {
2528
- changes.push(fromPortableChangeRecord(JSON.parse(line)));
2529
- } catch (err) {
2530
- quarantine({ kind: "change", subject: line.slice(0, 80), reason: err.message });
2531
- }
2532
- }
2533
- changes.sort(
2534
- (a, b) => compareChangeApplicationOrder2(
2535
- { lamport: a.lamport, author: a.authorDID },
2536
- { lamport: b.lamport, author: b.authorDID }
2537
- )
2538
- );
2539
- let applied = 0;
2540
- let duplicates = 0;
2541
- for (let i = 0; i < changes.length; i += APPLY_BATCH_SIZE) {
2542
- for (const change of changes.slice(i, i + APPLY_BATCH_SIZE)) {
2543
- try {
2544
- if (await store.hasChange(change.hash)) {
2545
- duplicates++;
2546
- continue;
2547
- }
2548
- await store.applyRemoteChange(change);
2549
- applied++;
2550
- } catch (err) {
2551
- quarantine({
2552
- kind: "change",
2553
- subject: change.hash,
2554
- reason: err instanceof Error ? err.message : String(err)
2555
- });
2556
- }
2557
- }
2558
- }
2559
- let blobsInstalled = 0;
2560
- if (options.blobPort) {
2561
- for await (const line of source.readLines(BUNDLE_ENTRY.blobIndex)) {
2562
- let record;
2563
- try {
2564
- record = JSON.parse(line);
2565
- } catch (err) {
2566
- quarantine({ kind: "blob", subject: line.slice(0, 80), reason: err.message });
2567
- continue;
2568
- }
2569
- try {
2570
- if (await options.blobPort.has(record.cid)) continue;
2571
- const bytes = await source.readEntry(record.path);
2572
- if (!bytes) {
2573
- quarantine({
2574
- kind: "blob",
2575
- subject: record.cid,
2576
- reason: `bundle entry ${record.path} missing`
2577
- });
2578
- continue;
2579
- }
2580
- await options.blobPort.put(bytes, { cid: record.cid, mimeType: record.mimeType });
2581
- blobsInstalled++;
2582
- } catch (err) {
2583
- quarantine({ kind: "blob", subject: record.cid, reason: err.message });
2584
- }
2585
- }
2586
- }
2587
- let yjsDocsApplied = 0;
2588
- if (options.yjsPort) {
2589
- for await (const line of source.readLines(BUNDLE_ENTRY.yjsDocs)) {
2590
- let record;
2591
- try {
2592
- record = JSON.parse(line);
2593
- } catch (err) {
2594
- quarantine({ kind: "yjs-doc", subject: line.slice(0, 80), reason: err.message });
2595
- continue;
2596
- }
2597
- try {
2598
- await options.yjsPort.apply(record.nodeId, base64ToBytes3(record.updateB64));
2599
- yjsDocsApplied++;
2600
- } catch (err) {
2601
- quarantine({ kind: "yjs-doc", subject: record.nodeId, reason: err.message });
2602
- }
2603
- }
2604
- }
2605
- return { applied, duplicates, quarantined, blobsInstalled, yjsDocsApplied, missingPrerequisites };
2606
- }
2607
- async function readBundleManifest(source) {
2608
- const bytes = await source.readEntry(BUNDLE_ENTRY.manifest);
2609
- if (!bytes) return null;
2610
- try {
2611
- return JSON.parse(decodeUtf8(bytes));
2612
- } catch {
2613
- return null;
2614
- }
2615
- }
2616
-
2617
- // src/portability/memory-bundle.ts
2618
- var MemoryBundleSink = class {
2619
- entries = /* @__PURE__ */ new Map();
2620
- writeEntry(path, data) {
2621
- this.entries.set(path, data);
2622
- }
2623
- toSource() {
2624
- return new MemoryBundleSource(this.entries);
2625
- }
2626
- };
2627
- var MemoryBundleSource = class {
2628
- constructor(entries) {
2629
- this.entries = entries;
2630
- }
2631
- async readEntry(path) {
2632
- return this.entries.get(path) ?? null;
2633
- }
2634
- async *readLines(path) {
2635
- const bytes = this.entries.get(path);
2636
- if (!bytes) return;
2637
- let start = 0;
2638
- const text2 = decodeUtf8(bytes);
2639
- while (start < text2.length) {
2640
- let end = text2.indexOf("\n", start);
2641
- if (end === -1) end = text2.length;
2642
- const line = text2.slice(start, end);
2643
- if (line.length > 0) yield line;
2644
- start = end + 1;
2645
- }
2646
- }
2647
- async listEntries(prefix) {
2648
- return [...this.entries.keys()].filter((p) => p.startsWith(prefix)).sort();
2649
- }
2650
- };
2651
-
2652
- // src/portability/store-yjs-port.ts
2653
- import * as Y2 from "yjs";
2654
- function createStoreYjsPort(store) {
2655
- return {
2656
- async *list() {
2657
- const nodes = await store.list({ includeDeleted: true });
2658
- for (const node of nodes) {
2659
- const content = await store.getDocumentContent(node.id);
2660
- if (content && content.byteLength > 0) {
2661
- yield { nodeId: node.id, update: content };
2662
- }
2663
- }
2664
- },
2665
- async apply(nodeId, update) {
2666
- const existing = await store.getDocumentContent(nodeId);
2667
- if (!existing || existing.byteLength === 0) {
2668
- await store.setDocumentContent(nodeId, update);
2669
- return;
2670
- }
2671
- let merged;
2672
- const doc = new Y2.Doc();
2673
- try {
2674
- Y2.applyUpdate(doc, existing);
2675
- Y2.applyUpdate(doc, update);
2676
- merged = Y2.encodeStateAsUpdate(doc);
2677
- } catch (err) {
2678
- throw new Error(
2679
- `document content for ${nodeId} is not a mergeable Yjs update (${err.message}); left the existing content untouched`
2680
- );
2681
- } finally {
2682
- doc.destroy();
2683
- }
2684
- await store.setDocumentContent(nodeId, merged);
2685
- }
2686
- };
2687
- }
2688
-
2689
2095
  // src/index.ts
2690
2096
  import {
2691
- Doc as Doc2,
2097
+ Doc,
2692
2098
  Map as Map3,
2693
2099
  Array as Array2,
2694
2100
  Text,
@@ -2738,6 +2144,7 @@ export {
2738
2144
  CHECKPOINT_SCHEMA_IRI,
2739
2145
  CONTACT_LIFECYCLE,
2740
2146
  CONTACT_SCHEMA_IRI,
2147
+ COURSE_SCHEMA_IRI,
2741
2148
  CRM_NAMESPACE,
2742
2149
  CanvasSchema,
2743
2150
  ChannelSchema,
@@ -2747,6 +2154,7 @@ export {
2747
2154
  CommunityNoteSchema,
2748
2155
  ContactSchema,
2749
2156
  ContentProvenanceSchema,
2157
+ CourseSchema,
2750
2158
  DATABASE_SCHEMA_NAMESPACE,
2751
2159
  DATABASE_SCHEMA_PREFIX,
2752
2160
  DEAL_CONTACT_ROLES,
@@ -2775,10 +2183,12 @@ export {
2775
2183
  DeviceRecordSchema,
2776
2184
  DraftSchema,
2777
2185
  EMBED_PROVIDERS,
2186
+ EVENT_SCHEMA_IRI,
2778
2187
  EXTENSION_FIELD_SCHEMA_IRI,
2779
2188
  EXTERNAL_ITEM_SCHEMA_IRI,
2780
2189
  EXTERNAL_ITEM_SOURCES,
2781
2190
  EXT_PREFIX,
2191
+ EventSchema,
2782
2192
  ExperimentSchema,
2783
2193
  ExtensionFieldSchema,
2784
2194
  ExternalItemSchema,
@@ -2813,8 +2223,12 @@ export {
2813
2223
  ImportBatchSchema,
2814
2224
  InboxStateSchema,
2815
2225
  InventorySchema,
2226
+ LESSON_PROGRESS_SCHEMA_IRI,
2227
+ LESSON_SCHEMA_IRI,
2816
2228
  LINE_ITEM_SCHEMA_IRI,
2817
2229
  LensRegistry,
2230
+ LessonProgressSchema,
2231
+ LessonSchema,
2818
2232
  LineItemSchema,
2819
2233
  MATCH_RESULTS,
2820
2234
  MATCH_SESSION_SCHEMA_IRI,
@@ -2856,6 +2270,7 @@ export {
2856
2270
  PIPELINE_SCHEMA_IRI,
2857
2271
  PLAYER_IDENTITY_SCHEMA_IRI,
2858
2272
  POSTING_SCHEMA_IRI,
2273
+ POST_SCHEMA_IRI,
2859
2274
  PRODUCT_KINDS,
2860
2275
  PRODUCT_SCHEMA_IRI,
2861
2276
  PUBLIC_SAFE_FORM_FIELD_TYPES,
@@ -2865,6 +2280,7 @@ export {
2865
2280
  PlayerIdentitySchema,
2866
2281
  PolicyListSchema,
2867
2282
  PolicySubscriptionSchema,
2283
+ PostSchema,
2868
2284
  PostingSchema,
2869
2285
  PresenceAggregator,
2870
2286
  PresenceSummarySchema,
@@ -2872,6 +2288,7 @@ export {
2872
2288
  ProfileSchema,
2873
2289
  ProjectSchema,
2874
2290
  PublicInteractionPolicySchema,
2291
+ PublicationSchema,
2875
2292
  QUERY_AST_VERSION,
2876
2293
  QualitySignalSchema,
2877
2294
  RECOVERY_RECORD_SCHEMA_IRI,
@@ -2881,11 +2298,13 @@ export {
2881
2298
  RICHTEXT_PREFIX,
2882
2299
  ROW_HEIGHTS,
2883
2300
  ROW_HEIGHT_PX,
2301
+ RSVP_SCHEMA_IRI,
2884
2302
  ReactionSchema,
2885
2303
  RecoveryRecordSchema,
2886
2304
  RelationshipSchema,
2887
2305
  ReviewTaskSchema,
2888
2306
  RevocationRecordSchema,
2307
+ RsvpSchema,
2889
2308
  SCHEMA_EXTENSION_SCHEMA_IRI,
2890
2309
  SELECT_COLORS,
2891
2310
  SIDECAR_PREFIX,
@@ -2927,7 +2346,7 @@ export {
2927
2346
  WorkspaceSchema,
2928
2347
  XNETPACK_FORMAT_VERSION,
2929
2348
  Array2 as YArray,
2930
- Doc2 as YDoc,
2349
+ Doc as YDoc,
2931
2350
  Map3 as YMap,
2932
2351
  Text as YText,
2933
2352
  XmlElement as YXmlElement,
@@ -2989,6 +2408,7 @@ export {
2989
2408
  columnIdFromKey,
2990
2409
  combineFiltersAnd,
2991
2410
  combineFiltersOr,
2411
+ comparePostsForFeed,
2992
2412
  compareSortKeys,
2993
2413
  compareSpaceRoles,
2994
2414
  composeLens,
@@ -3001,6 +2421,7 @@ export {
3001
2421
  copy,
3002
2422
  count,
3003
2423
  countDistinct,
2424
+ courseCompletion,
3004
2425
  createAccountRecord,
3005
2426
  createAnyOfFilter,
3006
2427
  createAwareness,
@@ -3219,6 +2640,7 @@ export {
3219
2640
  ledgerAccountId,
3220
2641
  ledgerWriteKind,
3221
2642
  lensRegistry,
2643
+ lessonProgressId,
3222
2644
  loadExtensionFields,
3223
2645
  lockedPropertyKeys,
3224
2646
  lt,
@@ -3270,6 +2692,7 @@ export {
3270
2692
  profileNodeId,
3271
2693
  promoteOverlay,
3272
2694
  pruneVersionHistory,
2695
+ publicInteractionPolicyId,
3273
2696
  queryOperators,
3274
2697
  queryRows,
3275
2698
  querySetCount,
@@ -3300,6 +2723,7 @@ export {
3300
2723
  revokeSubjectRecord,
3301
2724
  revokedSubjects,
3302
2725
  rowHeightLabel,
2726
+ rsvpId,
3303
2727
  sanitizeLinkPreviews,
3304
2728
  schemaExtensionId,
3305
2729
  schemaRegistry,
@@ -3352,6 +2776,7 @@ export {
3352
2776
  toggleSortDirection,
3353
2777
  toggleViewGroupCollapsed,
3354
2778
  transform,
2779
+ upcomingEvents,
3355
2780
  updateCell,
3356
2781
  updateCells,
3357
2782
  updateColumn,