@xnetjs/data 2.2.0 → 2.4.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 (151) hide show
  1. package/dist/{account-ZD3HMRY6.js → account-LYZ3VDC4.js} +4 -4
  2. package/dist/{account-ledger-ZHBNVREV.js → account-ledger-7VF5SHTT.js} +2 -2
  3. package/dist/{agent-OFQJQMNB.js → agent-IJLOS2LA.js} +4 -4
  4. package/dist/auth/index.d.ts +4 -4
  5. package/dist/{budget-FTGZEXX6.js → budget-WXX7PAWQ.js} +4 -4
  6. package/dist/canvas-64KGRYXI.js +10 -0
  7. package/dist/channel-DXLP6PEJ.js +12 -0
  8. package/dist/chat-message-EZW77LY3.js +10 -0
  9. package/dist/{checkpoint-MZHJ7PCZ.js → checkpoint-SAKNGDI3.js} +4 -4
  10. package/dist/{chunk-ZKMWJNDQ.js → chunk-2DAVPHDV.js} +1 -1
  11. package/dist/{chunk-KTPSQJ5L.js → chunk-2JROE7ML.js} +2 -2
  12. package/dist/{chunk-JWGS7JMA.js → chunk-2K6BLSNC.js} +2 -2
  13. package/dist/{chunk-IKGUBSZP.js → chunk-37PXEMYQ.js} +1 -1
  14. package/dist/{chunk-M4KGY2PC.js → chunk-3FWYS6AW.js} +2 -2
  15. package/dist/chunk-3UOUVEZW.js +122 -0
  16. package/dist/{chunk-EYRZ6ZUB.js → chunk-4HJZJMPI.js} +14 -1
  17. package/dist/{chunk-T45PWXNA.js → chunk-4SIMTLCC.js} +2 -2
  18. package/dist/{chunk-II7WS264.js → chunk-56EXPOJ4.js} +47 -6
  19. package/dist/{chunk-5UJMY3AH.js → chunk-57AT2DT2.js} +2 -2
  20. package/dist/{chunk-4KJ4NAMC.js → chunk-5ECIKN6Z.js} +1 -1
  21. package/dist/{chunk-MEAIGK3W.js → chunk-6AKAZHVZ.js} +1 -1
  22. package/dist/{chunk-UUQVNDBG.js → chunk-7MSSPUMC.js} +2 -2
  23. package/dist/{chunk-OF6455OV.js → chunk-AKKBG7HW.js} +2 -2
  24. package/dist/{chunk-FWCM2TKJ.js → chunk-CM57A2GS.js} +2 -2
  25. package/dist/{chunk-OD2JYCVG.js → chunk-CNGEXCIH.js} +192 -189
  26. package/dist/{chunk-HPUXHSKR.js → chunk-CTQALHJM.js} +2 -2
  27. package/dist/{chunk-WC7EDJHC.js → chunk-CY6EJUNV.js} +1 -1
  28. package/dist/{chunk-JLUFPUIL.js → chunk-EA2PZ3EU.js} +2 -2
  29. package/dist/{chunk-4S73XDWH.js → chunk-EGGRKSRH.js} +93 -8
  30. package/dist/{chunk-NSMSOIEW.js → chunk-EUJR5QQC.js} +2 -2
  31. package/dist/{chunk-RXBLWQQI.js → chunk-EZJ3OD5A.js} +2 -2
  32. package/dist/{chunk-SOXXBQ4P.js → chunk-F6ICOU6R.js} +2 -2
  33. package/dist/{chunk-D4EVJN2P.js → chunk-FTKHARBY.js} +2 -2
  34. package/dist/{chunk-LK5ZIAIE.js → chunk-GSLOK5KV.js} +8 -1
  35. package/dist/{chunk-EZTBWWMS.js → chunk-HSCGVBQN.js} +2 -2
  36. package/dist/{chunk-Z5I2T75Z.js → chunk-HXIEK5L6.js} +6 -2
  37. package/dist/{chunk-I7JMGCV6.js → chunk-ICBC5VLZ.js} +2 -2
  38. package/dist/{chunk-C4CQH7UD.js → chunk-IJZ5YPYT.js} +1 -1
  39. package/dist/{chunk-WWQO7QKV.js → chunk-IKREWSCX.js} +2 -2
  40. package/dist/{chunk-XQDXQ7WG.js → chunk-IVCHWQY7.js} +2 -2
  41. package/dist/{chunk-ZKJXGQCR.js → chunk-JB6BPIVP.js} +2 -2
  42. package/dist/{chunk-3PV6QTKF.js → chunk-JUTPAFDP.js} +1 -1
  43. package/dist/{chunk-HTZTBXKL.js → chunk-KHLOVRMQ.js} +2 -2
  44. package/dist/{chunk-IKI5FBNO.js → chunk-L6DF76E2.js} +2 -2
  45. package/dist/{chunk-7PCMTV6J.js → chunk-LDKJDNSW.js} +1 -1
  46. package/dist/{chunk-22FKOLMX.js → chunk-M6STMJ2V.js} +2 -2
  47. package/dist/{chunk-RRXJNZX5.js → chunk-NH6OLO3X.js} +46 -0
  48. package/dist/{chunk-26HTTVJN.js → chunk-O34JPX6Q.js} +2 -2
  49. package/dist/{chunk-YD2ZPFT7.js → chunk-PKLHOQSO.js} +2 -2
  50. package/dist/{chunk-DPJ4T2LQ.js → chunk-QH7RZEHT.js} +2 -2
  51. package/dist/{chunk-S6JWYPVW.js → chunk-QOTR4SGT.js} +2 -2
  52. package/dist/{chunk-52DR23IW.js → chunk-QVGTYLL3.js} +2 -2
  53. package/dist/{chunk-IA23CLGV.js → chunk-R2AZXT3D.js} +2 -2
  54. package/dist/{chunk-YSD4NSCE.js → chunk-RAJNAD64.js} +2 -2
  55. package/dist/{chunk-JA56EQJO.js → chunk-RLRAWZJE.js} +1 -1
  56. package/dist/{chunk-ZKVRGKLM.js → chunk-RRIRY7FP.js} +3 -3
  57. package/dist/{chunk-GCTONBF6.js → chunk-TH2BJPDZ.js} +1 -1
  58. package/dist/{chunk-6ZUJID52.js → chunk-TOQ2LBAN.js} +2 -2
  59. package/dist/{chunk-SMYZILJ6.js → chunk-UFV5QWCL.js} +3 -3
  60. package/dist/{chunk-QDLWTOII.js → chunk-WOBZDEKQ.js} +2 -2
  61. package/dist/{chunk-S5RP5RKY.js → chunk-WOEFYS7Y.js} +16 -1
  62. package/dist/{chunk-W3QOEPUN.js → chunk-WQRBUG65.js} +1 -1
  63. package/dist/{chunk-57UZYV3L.js → chunk-XFOUIAJF.js} +1 -1
  64. package/dist/{chunk-OIWW5TG3.js → chunk-XP3VSSXD.js} +2 -2
  65. package/dist/{chunk-YHO7GNZK.js → chunk-Y2XWK7AA.js} +2 -2
  66. package/dist/{chunk-Q6VTTPG4.js → chunk-YFLL3CME.js} +1 -1
  67. package/dist/{chunk-EN6XTVLZ.js → chunk-YRFCXKJC.js} +2 -2
  68. package/dist/{chunk-DP4Q2HMO.js → chunk-ZEMCCIIO.js} +2 -2
  69. package/dist/{chunk-XJBDESCX.js → chunk-ZNHLH7SC.js} +1 -1
  70. package/dist/{clone-CU6rTzC0.d.ts → clone-BsoRt89i.d.ts} +4 -4
  71. package/dist/comment-2AS6EGH3.js +10 -0
  72. package/dist/{crm-AFJSSPHK.js → crm-VIJIXKFO.js} +4 -4
  73. package/dist/dashboard-BDKJKEGQ.js +10 -0
  74. package/dist/database/index.d.ts +5 -5
  75. package/dist/database/index.js +12 -10
  76. package/dist/database-VJSYCFXH.js +10 -0
  77. package/dist/database-field-JTTDAN4A.js +10 -0
  78. package/dist/database-row-NFINK37Z.js +10 -0
  79. package/dist/database-select-option-TYDAHMXK.js +10 -0
  80. package/dist/database-view-3OHCI5YK.js +10 -0
  81. package/dist/debug-report-JFSUVHHJ.js +10 -0
  82. package/dist/{draft-KGHITKX2.js → draft-T5KDLPC4.js} +2 -2
  83. package/dist/experiment-ZEUCF3B7.js +10 -0
  84. package/dist/{external-item-ZVD33IXV.js → external-item-K7MZNXKZ.js} +4 -4
  85. package/dist/{external-reference-LGFNVEKC.js → external-reference-NWFUYRF3.js} +2 -2
  86. package/dist/feed-WR4A7XUF.js +12 -0
  87. package/dist/{feed-item-QXRIE6FU.js → feed-item-S7XTCRWW.js} +4 -4
  88. package/dist/{folder-NU5TJFOT.js → folder-D4IL7UHP.js} +2 -2
  89. package/dist/{form-types-xc7NdHaW.d.ts → form-types-Dkqm9UO2.d.ts} +18 -3
  90. package/dist/{game-7WW2JX6O.js → game-NEQP7OFX.js} +4 -4
  91. package/dist/{grant-W772T6FE.js → grant-LNTRVBUG.js} +2 -2
  92. package/dist/{grant-expiration-cleaner-B_Q2pncC.d.ts → grant-expiration-cleaner-BwdmRFua.d.ts} +3 -3
  93. package/dist/{import-batch-ZRU4FY6Y.js → import-batch-4AI3Q2HT.js} +4 -4
  94. package/dist/{inbox-state-IO5C7HVE.js → inbox-state-4XQSSHUQ.js} +2 -2
  95. package/dist/index.d.ts +320 -9
  96. package/dist/index.js +1038 -371
  97. package/dist/map-TDNNBSMU.js +10 -0
  98. package/dist/{media-asset-VHFL65HI.js → media-asset-BQOGFRJZ.js} +2 -2
  99. package/dist/{meeting-PVNKBGTI.js → meeting-XQWTQK7J.js} +4 -4
  100. package/dist/{memory-5PD3XCKB.js → memory-PAPUIKWD.js} +2 -2
  101. package/dist/metric-ZZ3C6T2W.js +10 -0
  102. package/dist/{milestone-MZAZCWGR.js → milestone-HACU5NDB.js} +4 -4
  103. package/dist/{moderation-CXQB77CP.js → moderation-HRMMBFVH.js} +2 -2
  104. package/dist/observation-MVIQQNYJ.js +10 -0
  105. package/dist/page-RUS2BKMX.js +10 -0
  106. package/dist/{posting-5VZZMOKS.js → posting-ZQRTWYSE.js} +4 -4
  107. package/dist/{profile-USKJ6PN7.js → profile-5H6XWCK4.js} +2 -2
  108. package/dist/project-PBEJY4LU.js +10 -0
  109. package/dist/{query-ast-Bn3-oRUo.d.ts → query-ast-DYGcKxoa.d.ts} +1 -1
  110. package/dist/reaction-MRZHOGPW.js +10 -0
  111. package/dist/{registry-Wk8Rt0kh.d.ts → registry-D_3b1Lg6.d.ts} +1 -1
  112. package/dist/saved-view-NQ7QS2YM.js +10 -0
  113. package/dist/schema/index.d.ts +144 -13
  114. package/dist/schema/index.js +104 -90
  115. package/dist/{schema-extension-DV5D7JCQ.js → schema-extension-3AYLTMFL.js} +4 -4
  116. package/dist/{space-THD2MWHR.js → space-GBTEHZOK.js} +5 -5
  117. package/dist/{space-membership-M3QFMONE.js → space-membership-PS2O5TEQ.js} +2 -2
  118. package/dist/store/index.d.ts +4 -4
  119. package/dist/store/index.js +6 -4
  120. package/dist/{store-CyGU48TX.d.ts → store-BMnhBWzM.d.ts} +17 -1
  121. package/dist/{system-LFIMY3QQ.js → system-X2F6HN3K.js} +2 -2
  122. package/dist/{tag-W7ZYPXHK.js → tag-LHP2J53R.js} +2 -2
  123. package/dist/{task-DHTPD66H.js → task-YLRF5NBH.js} +4 -4
  124. package/dist/task-view-YUGGCX7N.js +10 -0
  125. package/dist/{transaction-ANNDXCJM.js → transaction-XVDTENOA.js} +4 -4
  126. package/dist/{transcription-DFTQ4FQ4.js → transcription-H5COCUFG.js} +4 -4
  127. package/dist/{types-BFnYlC8Z.d.ts → types-cycApzib.d.ts} +2 -2
  128. package/dist/{user-widget-5IRVORF3.js → user-widget-Q4A2BKRN.js} +2 -2
  129. package/dist/{workspace-RC4V4IF3.js → workspace-CGRCQCJN.js} +2 -2
  130. package/package.json +11 -7
  131. package/dist/canvas-NQBTRNLS.js +0 -10
  132. package/dist/channel-474QAZGP.js +0 -12
  133. package/dist/chat-message-LGLCITLE.js +0 -10
  134. package/dist/comment-IAZJHG6G.js +0 -10
  135. package/dist/dashboard-2DLFZM2J.js +0 -10
  136. package/dist/database-5M7ZA33U.js +0 -10
  137. package/dist/database-field-IFUWOK7X.js +0 -10
  138. package/dist/database-row-C52KCOPB.js +0 -10
  139. package/dist/database-select-option-AEAPKXEE.js +0 -10
  140. package/dist/database-view-NMG3AGXK.js +0 -10
  141. package/dist/debug-report-BTNZAKX3.js +0 -10
  142. package/dist/experiment-JXHENWXV.js +0 -10
  143. package/dist/feed-CLEHVA6Q.js +0 -12
  144. package/dist/map-BZAVGCR6.js +0 -10
  145. package/dist/metric-6IGGFJMB.js +0 -10
  146. package/dist/observation-O3DLKVIH.js +0 -10
  147. package/dist/page-UE5NPYEF.js +0 -10
  148. package/dist/project-UHGGEFLP.js +0 -10
  149. package/dist/reaction-KD3G75UH.js +0 -10
  150. package/dist/saved-view-AZTUINZA.js +0 -10
  151. package/dist/task-view-J2WRE62C.js +0 -10
package/dist/index.js CHANGED
@@ -6,222 +6,6 @@ import {
6
6
  signUpdate,
7
7
  verifyUpdate
8
8
  } from "./chunk-XHEA5UER.js";
9
- import {
10
- CELL_PREFIX,
11
- DATABASE_SCHEMA_NAMESPACE,
12
- DATABASE_SCHEMA_PREFIX,
13
- DEFAULT_DATABASE_SCHEMA_VERSION,
14
- DEFAULT_ROW_HEIGHT,
15
- FIELD_TYPES,
16
- FormulaService,
17
- MAX_VERSION_HISTORY,
18
- OPERATORS_BY_TYPE,
19
- OPERATOR_LABELS,
20
- PUBLIC_SAFE_FORM_FIELD_TYPES,
21
- RICHTEXT_PREFIX,
22
- ROW_HEIGHTS,
23
- ROW_HEIGHT_PX,
24
- SELECT_COLORS,
25
- SUMMARY_FUNCTIONS_BY_TYPE,
26
- addDefaultTableView,
27
- addDefaultTitleColumn,
28
- addOrToggleSort,
29
- addViewSort,
30
- aggregate,
31
- asRowHeight,
32
- autoColor,
33
- batchComputeRollups,
34
- buildDatabaseSchema,
35
- buildPublicFormDefinition,
36
- buildSchemaFromFields,
37
- buildSchemaIRI,
38
- bumpSchemaVersion,
39
- cellKey,
40
- cellValueToText,
41
- checkNeedsRebalancing,
42
- clearViewFilters,
43
- clearViewSorts,
44
- cloneColumns,
45
- cloneSampleRows,
46
- cloneSchema,
47
- collapseAllGroups,
48
- columnIdFromKey,
49
- combineFiltersAnd,
50
- combineFiltersOr,
51
- computeColumnSummary,
52
- computeRollup,
53
- convertCellValue,
54
- createAnyOfFilter,
55
- createColumn,
56
- createCsvBlob,
57
- createDatabaseSchemaResolver,
58
- createEqualsFilter,
59
- createExtensionField,
60
- createField,
61
- createFilterQuery,
62
- createFormulaService,
63
- createInitialSchemaMetadata,
64
- createJsonBlob,
65
- createNodeDatabaseSchemaResolver,
66
- createPaginatedQuery,
67
- createRow,
68
- createSelectOption,
69
- createSort,
70
- createSortQuery,
71
- createVersionEntry,
72
- createView,
73
- createView2,
74
- deleteColumn,
75
- deleteExtensionField,
76
- deleteField,
77
- deleteMeta,
78
- deleteRichTextCell,
79
- deleteRow,
80
- deleteSelectOption,
81
- deleteView,
82
- deleteView2,
83
- downloadCsv,
84
- downloadJson,
85
- duplicateColumn,
86
- duplicateField,
87
- duplicateView,
88
- duplicateView2,
89
- effectiveFieldSortKey,
90
- ensureSchemaExtension,
91
- escapeCSV,
92
- executeQuery,
93
- expandAllGroups,
94
- exportToCsv,
95
- exportToJson,
96
- exportToJsonArray,
97
- exportToNdjson,
98
- extractSchemaFromDoc,
99
- fieldsToStoredColumns,
100
- filterRows,
101
- flattenGroups,
102
- formatValue,
103
- fromCellProperties,
104
- generateColumnIdMap,
105
- getColumn,
106
- getColumnIndex,
107
- getColumns,
108
- getDatabaseDocumentModel,
109
- getDatabaseSchemaIRI,
110
- getDatabaseSelectOptions,
111
- getField,
112
- getFields,
113
- getMeta,
114
- getOperatorLabel,
115
- getOperatorsForType,
116
- getRichTextCell,
117
- getRichTextColumnIds,
118
- getRichTextPlainText,
119
- getRow,
120
- getSchemaIRIFromDoc,
121
- getSelectOptions,
122
- getTitleColumn,
123
- getTitleField,
124
- getTotalFromGroups,
125
- getVersionBumpType,
126
- getView,
127
- getView2,
128
- getViewByType,
129
- getViews,
130
- getViews2,
131
- groupRows,
132
- guessColumnType,
133
- hasRichTextColumns,
134
- hasRichTextContent,
135
- hideColumn,
136
- inferColumnTypes,
137
- inferColumnsFromRows,
138
- inferTypeFromValues,
139
- initializeDatabaseDoc,
140
- isAutoColumnType,
141
- isAutoFieldType,
142
- isCellKey,
143
- isCellValue,
144
- isComputedColumnType,
145
- isComputedFieldType,
146
- isDatabaseDocInitialized,
147
- isDatabaseSchemaIRI,
148
- isDateRange,
149
- isFieldType,
150
- isFileRef,
151
- isFilledValue,
152
- isFilterCondition,
153
- isFilterGroup,
154
- isFormFieldTypeAllowed,
155
- isFormQuestionVisible,
156
- isNodeStoreColumnType,
157
- isNodeStoreFieldType,
158
- isSelectColor,
159
- isValidOperator,
160
- isYDocColumnType,
161
- isYDocFieldType,
162
- moveField,
163
- moveRow,
164
- moveSelectOption,
165
- moveView,
166
- operatorRequiresValue,
167
- parseCSV,
168
- parseCSVLine,
169
- parseDatabaseSchemaIRI,
170
- parseJSON,
171
- parseRow,
172
- parseValue,
173
- parseVersion,
174
- pruneVersionHistory,
175
- queryRows,
176
- rebalanceDatabase,
177
- remapViewColumnIds,
178
- removeSort,
179
- removeViewSort,
180
- renameExtensionField,
181
- reorderColumn,
182
- reorderViewColumns,
183
- requiresDateColumn,
184
- resolveRowHeightPx,
185
- rowHeightLabel,
186
- setColumnWidth,
187
- setFieldHidden,
188
- setMeta,
189
- setViewFieldOrder,
190
- setViewFieldWidth,
191
- setViewFilters,
192
- setViewFilters2,
193
- setViewGroupBy,
194
- setViewGroupBy2,
195
- setViewSorts,
196
- setViewSorts2,
197
- setVisibleColumns,
198
- setupDatabase,
199
- setupNewDatabase,
200
- showColumn,
201
- sortRows,
202
- submissionRowId,
203
- summaryFunctionLabel,
204
- supportsGrouping,
205
- toCellProperties,
206
- toColumnDefinitions,
207
- toFieldNode,
208
- toSelectOptionNode,
209
- toggleGroupCollapsed,
210
- toggleGroupCollapsed2,
211
- toggleSortDirection,
212
- toggleViewGroupCollapsed,
213
- updateCell,
214
- updateCells,
215
- updateColumn,
216
- updateField,
217
- updateSelectOption,
218
- updateView,
219
- updateView2,
220
- validateFormSubmission,
221
- validateJsonData,
222
- validateRollupConfig,
223
- visibleFormQuestions
224
- } from "./chunk-II7WS264.js";
225
9
  import {
226
10
  LensRegistry,
227
11
  MAX_LINK_PREVIEWS_PER_MESSAGE,
@@ -290,7 +74,7 @@ import {
290
74
  taskBranchName,
291
75
  transform,
292
76
  when
293
- } from "./chunk-OD2JYCVG.js";
77
+ } from "./chunk-CNGEXCIH.js";
294
78
  import {
295
79
  AbuseReportSchema,
296
80
  AppealSchema,
@@ -304,7 +88,7 @@ import {
304
88
  PublicInteractionPolicySchema,
305
89
  QualitySignalSchema,
306
90
  ReviewTaskSchema
307
- } from "./chunk-WC7EDJHC.js";
91
+ } from "./chunk-CY6EJUNV.js";
308
92
  import {
309
93
  ACHIEVEMENT_SCHEMA_IRI,
310
94
  AchievementSchema,
@@ -327,12 +111,12 @@ import {
327
111
  PLAYER_IDENTITY_SCHEMA_IRI,
328
112
  PlayerIdentitySchema,
329
113
  gameSchemas
330
- } from "./chunk-EN6XTVLZ.js";
114
+ } from "./chunk-YRFCXKJC.js";
331
115
  import {
332
116
  MEMORY_ITEM_SCHEMA_IRI,
333
117
  MEMORY_KINDS,
334
118
  MemoryItemSchema
335
- } from "./chunk-ZKMWJNDQ.js";
119
+ } from "./chunk-2DAVPHDV.js";
336
120
  import {
337
121
  AGENT_ACTION_SCHEMA_IRI,
338
122
  AGENT_ACTION_STATUSES,
@@ -359,83 +143,65 @@ import {
359
143
  agentPassportId,
360
144
  agentSessionId,
361
145
  redactInstruction
362
- } from "./chunk-JWGS7JMA.js";
146
+ } from "./chunk-2K6BLSNC.js";
363
147
  import {
364
148
  DEFAULT_CHANNEL_TIER,
365
149
  InboxStateSchema,
366
150
  inboxStateNodeId
367
- } from "./chunk-IKGUBSZP.js";
151
+ } from "./chunk-37PXEMYQ.js";
368
152
  import {
369
153
  GrantSchema
370
- } from "./chunk-GCTONBF6.js";
371
- import {
372
- ACCOUNT_RECORD_SCHEMA_IRI,
373
- AccountRecordSchema,
374
- DEVICE_RECORD_SCHEMA_IRI,
375
- DeviceRecordSchema,
376
- RECOVERY_RECORD_SCHEMA_IRI,
377
- REVOCATION_RECORD_SCHEMA_IRI,
378
- RecoveryRecordSchema,
379
- RevocationRecordSchema,
380
- accountRecordId,
381
- deviceRecipientExpander,
382
- deviceRecordId,
383
- isDeviceAuthorized,
384
- recoveryRecordId,
385
- resolveActiveDevices,
386
- revocationRecordId,
387
- revokedSubjects
388
- } from "./chunk-4KJ4NAMC.js";
154
+ } from "./chunk-TH2BJPDZ.js";
389
155
  import {
390
156
  SavedViewSchema
391
- } from "./chunk-XQDXQ7WG.js";
157
+ } from "./chunk-IVCHWQY7.js";
392
158
  import {
393
159
  WorkspaceSchema
394
- } from "./chunk-3PV6QTKF.js";
160
+ } from "./chunk-JUTPAFDP.js";
395
161
  import {
396
162
  UserWidgetSchema
397
- } from "./chunk-W3QOEPUN.js";
163
+ } from "./chunk-WQRBUG65.js";
398
164
  import {
399
165
  DashboardSchema
400
- } from "./chunk-NSMSOIEW.js";
166
+ } from "./chunk-EUJR5QQC.js";
401
167
  import {
402
168
  ReactionSchema
403
- } from "./chunk-YSD4NSCE.js";
169
+ } from "./chunk-RAJNAD64.js";
404
170
  import {
405
171
  DebugReportSchema
406
- } from "./chunk-Z5I2T75Z.js";
172
+ } from "./chunk-HXIEK5L6.js";
407
173
  import {
408
174
  ProfileSchema,
409
175
  didFromProfileNodeId,
410
176
  profileNodeId
411
- } from "./chunk-EYRZ6ZUB.js";
177
+ } from "./chunk-4HJZJMPI.js";
412
178
  import {
413
179
  CHANNEL_KINDS,
414
180
  ChannelSchema
415
- } from "./chunk-UUQVNDBG.js";
181
+ } from "./chunk-7MSSPUMC.js";
416
182
  import {
417
183
  ChatMessageSchema
418
- } from "./chunk-5UJMY3AH.js";
184
+ } from "./chunk-57AT2DT2.js";
419
185
  import {
420
186
  FEED_SCHEMA_IRI,
421
187
  FeedSchema
422
- } from "./chunk-JLUFPUIL.js";
188
+ } from "./chunk-EA2PZ3EU.js";
423
189
  import {
424
190
  FEED_ITEM_SCHEMA_IRI,
425
191
  FeedItemSchema
426
- } from "./chunk-DPJ4T2LQ.js";
192
+ } from "./chunk-QH7RZEHT.js";
427
193
  import {
428
194
  EXTERNAL_ITEM_SCHEMA_IRI,
429
195
  EXTERNAL_ITEM_SOURCES,
430
196
  ExternalItemSchema
431
- } from "./chunk-D4EVJN2P.js";
197
+ } from "./chunk-FTKHARBY.js";
432
198
  import {
433
199
  MediaAssetSchema
434
- } from "./chunk-7PCMTV6J.js";
200
+ } from "./chunk-LDKJDNSW.js";
435
201
  import {
436
202
  TRANSCRIPTION_SCHEMA_IRI,
437
203
  TranscriptionSchema
438
- } from "./chunk-HPUXHSKR.js";
204
+ } from "./chunk-CTQALHJM.js";
439
205
  import {
440
206
  MEETING_CHANNELS,
441
207
  MEETING_SCHEMA_IRI,
@@ -443,24 +209,24 @@ import {
443
209
  MEETING_TRANSCRIPT_SCHEMA_IRI,
444
210
  MeetingSchema,
445
211
  MeetingTranscriptSchema
446
- } from "./chunk-S6JWYPVW.js";
212
+ } from "./chunk-QOTR4SGT.js";
447
213
  import {
448
214
  CanvasSchema
449
- } from "./chunk-26HTTVJN.js";
215
+ } from "./chunk-O34JPX6Q.js";
450
216
  import {
451
217
  MapSchema
452
- } from "./chunk-EZTBWWMS.js";
218
+ } from "./chunk-HSCGVBQN.js";
453
219
  import {
454
220
  CommentSchema
455
- } from "./chunk-I7JMGCV6.js";
221
+ } from "./chunk-ICBC5VLZ.js";
456
222
  import {
457
223
  CHECKPOINT_SCHEMA_IRI,
458
224
  CheckpointSchema
459
- } from "./chunk-6ZUJID52.js";
225
+ } from "./chunk-TOQ2LBAN.js";
460
226
  import {
461
227
  DRAFT_SCHEMA_IRI,
462
228
  DraftSchema
463
- } from "./chunk-MEAIGK3W.js";
229
+ } from "./chunk-6AKAZHVZ.js";
464
230
  import {
465
231
  ACTIVITY_KINDS,
466
232
  ACTIVITY_SCHEMA_IRI,
@@ -492,27 +258,27 @@ import {
492
258
  STAGE_SCHEMA_IRI,
493
259
  StageSchema,
494
260
  crmSchemas
495
- } from "./chunk-QDLWTOII.js";
261
+ } from "./chunk-WOBZDEKQ.js";
496
262
  import {
497
263
  ACCOUNT_SCHEMA_IRI,
498
264
  AccountSchema
499
- } from "./chunk-IKI5FBNO.js";
265
+ } from "./chunk-L6DF76E2.js";
500
266
  import {
501
267
  TRANSACTION_SCHEMA_IRI,
502
268
  TransactionSchema
503
- } from "./chunk-YD2ZPFT7.js";
269
+ } from "./chunk-PKLHOQSO.js";
504
270
  import {
505
271
  POSTING_SCHEMA_IRI,
506
272
  PostingSchema
507
- } from "./chunk-SOXXBQ4P.js";
273
+ } from "./chunk-F6ICOU6R.js";
508
274
  import {
509
275
  BUDGET_SCHEMA_IRI,
510
276
  BudgetSchema
511
- } from "./chunk-HTZTBXKL.js";
277
+ } from "./chunk-KHLOVRMQ.js";
512
278
  import {
513
279
  IMPORT_BATCH_SCHEMA_IRI,
514
280
  ImportBatchSchema
515
- } from "./chunk-22FKOLMX.js";
281
+ } from "./chunk-M6STMJ2V.js";
516
282
  import {
517
283
  NODE_VISIBILITY,
518
284
  SPACE_KINDS,
@@ -530,38 +296,38 @@ import {
530
296
  spaceRoleGrantActions,
531
297
  spaceRoleToShareRole,
532
298
  wouldCreateSpaceCycle
533
- } from "./chunk-ZKVRGKLM.js";
299
+ } from "./chunk-RRIRY7FP.js";
534
300
  import {
535
301
  ExternalReferenceSchema
536
- } from "./chunk-57UZYV3L.js";
302
+ } from "./chunk-XFOUIAJF.js";
537
303
  import {
538
304
  TASK_STATUS_CATEGORIES,
539
305
  TaskSchema,
540
306
  getTaskStatusCategory,
541
307
  isCompletedTaskStatus
542
- } from "./chunk-FWCM2TKJ.js";
308
+ } from "./chunk-CM57A2GS.js";
543
309
  import {
544
310
  TaskViewSchema
545
- } from "./chunk-T45PWXNA.js";
311
+ } from "./chunk-4SIMTLCC.js";
546
312
  import {
547
313
  ProjectSchema
548
- } from "./chunk-M4KGY2PC.js";
314
+ } from "./chunk-3FWYS6AW.js";
549
315
  import {
550
316
  MetricSchema
551
- } from "./chunk-52DR23IW.js";
317
+ } from "./chunk-QVGTYLL3.js";
552
318
  import {
553
319
  ObservationSchema
554
- } from "./chunk-DP4Q2HMO.js";
320
+ } from "./chunk-ZEMCCIIO.js";
555
321
  import {
556
322
  ExperimentSchema
557
- } from "./chunk-RXBLWQQI.js";
323
+ } from "./chunk-EZJ3OD5A.js";
558
324
  import {
559
325
  MILESTONE_SCHEMA_IRI,
560
326
  MilestoneSchema
561
- } from "./chunk-IA23CLGV.js";
327
+ } from "./chunk-R2AZXT3D.js";
562
328
  import {
563
329
  PageSchema
564
- } from "./chunk-YHO7GNZK.js";
330
+ } from "./chunk-Y2XWK7AA.js";
565
331
  import {
566
332
  FOLDER_SCHEMA_IRI,
567
333
  FolderSchema,
@@ -570,17 +336,337 @@ import {
570
336
  folderAncestorIds,
571
337
  folderPathIds,
572
338
  wouldCreateFolderCycle
573
- } from "./chunk-C4CQH7UD.js";
339
+ } from "./chunk-IJZ5YPYT.js";
574
340
  import {
575
341
  MAX_TAG_NAME_LENGTH,
576
342
  TAG_SCHEMA_IRI,
577
343
  TagSchema,
578
344
  isValidTagName,
579
345
  normalizeTagName
580
- } from "./chunk-Q6VTTPG4.js";
346
+ } from "./chunk-YFLL3CME.js";
581
347
  import {
582
348
  DatabaseSchema
583
- } from "./chunk-ZKJXGQCR.js";
349
+ } from "./chunk-JB6BPIVP.js";
350
+ import {
351
+ MemoryNodeStorageAdapter,
352
+ NodeStore,
353
+ PermissionError,
354
+ QUERY_AST_VERSION,
355
+ SQLiteNodeStorageAdapter,
356
+ TEMP_ID_PREFIX,
357
+ and,
358
+ avg,
359
+ between,
360
+ contains,
361
+ count,
362
+ countDistinct,
363
+ createNodeStorageAdapter,
364
+ createSchemaLookup,
365
+ dashboardQuerySet,
366
+ defineNodeQueryAST,
367
+ defineQuerySetAST,
368
+ defineSavedViewDescriptor,
369
+ eq,
370
+ evaluateQueryASTPlannerGate,
371
+ executeQueryASTLoadedAggregates,
372
+ filterQueryASTLoadedRows,
373
+ follow,
374
+ from,
375
+ getQueryASTRelationIndexRequirements,
376
+ groupBy,
377
+ gt,
378
+ gte,
379
+ having,
380
+ includesAny,
381
+ isNotNull,
382
+ isNull,
383
+ isTempId,
384
+ lt,
385
+ lte,
386
+ matchesQueryASTLoadedRow,
387
+ max,
388
+ min,
389
+ neq,
390
+ not,
391
+ or,
392
+ planQueryASTAggregates,
393
+ queryOperators,
394
+ querySetCount,
395
+ resolveTempIds,
396
+ startsWith,
397
+ sum,
398
+ validateQueryAST,
399
+ validateSavedViewDescriptor
400
+ } from "./chunk-EGGRKSRH.js";
401
+ import {
402
+ evaluateLedgerWrite,
403
+ foldAccountRecord,
404
+ ledgerAccountId,
405
+ ledgerWriteKind
406
+ } from "./chunk-3UOUVEZW.js";
407
+ import {
408
+ ACCOUNT_RECORD_SCHEMA_IRI,
409
+ AccountRecordSchema,
410
+ DEVICE_RECORD_SCHEMA_IRI,
411
+ DeviceRecordSchema,
412
+ RECOVERY_RECORD_SCHEMA_IRI,
413
+ REVOCATION_RECORD_SCHEMA_IRI,
414
+ RecoveryRecordSchema,
415
+ RevocationRecordSchema,
416
+ accountRecordId,
417
+ deviceRecipientExpander,
418
+ deviceRecordId,
419
+ isDeviceAuthorized,
420
+ recoveryRecordId,
421
+ resolveActiveDevices,
422
+ revocationRecordId,
423
+ revokedSubjects
424
+ } from "./chunk-5ECIKN6Z.js";
425
+ import {
426
+ PresenceSummarySchema,
427
+ SYSTEM_NAMESPACE_KINDS,
428
+ SYSTEM_SCHEMA_BASE_IRIS,
429
+ SYSTEM_SCHEMA_IRIS,
430
+ SchemaCompatibilitySchema,
431
+ SchemaDefinitionSchema,
432
+ SyncPolicySchema,
433
+ buildSystemNamespace,
434
+ buildSystemNodeId,
435
+ computeSchemaDefinitionContentHash,
436
+ createSchemaDefinitionSigningPayload,
437
+ isSystemNamespaceResource,
438
+ isSystemSchemaIri,
439
+ parseSystemNamespaceResource,
440
+ resolveSchemaAuthority,
441
+ validateSchemaDefinitionNode
442
+ } from "./chunk-ZNHLH7SC.js";
443
+ import {
444
+ clearLocalPresence,
445
+ createAwareness,
446
+ generateUserColor,
447
+ getAllPresences,
448
+ getLocalClientId,
449
+ getRemotePresences,
450
+ onPresenceChange,
451
+ setLocalPresence
452
+ } from "./chunk-7PDRDSFH.js";
453
+ import {
454
+ CELL_PREFIX,
455
+ DATABASE_SCHEMA_NAMESPACE,
456
+ DATABASE_SCHEMA_PREFIX,
457
+ DEFAULT_DATABASE_SCHEMA_VERSION,
458
+ DEFAULT_ROW_HEIGHT,
459
+ FIELD_TYPES,
460
+ FormulaService,
461
+ MAX_VERSION_HISTORY,
462
+ OPERATORS_BY_TYPE,
463
+ OPERATOR_LABELS,
464
+ PUBLIC_SAFE_FORM_FIELD_TYPES,
465
+ RICHTEXT_PREFIX,
466
+ ROW_HEIGHTS,
467
+ ROW_HEIGHT_PX,
468
+ SELECT_COLORS,
469
+ SUMMARY_FUNCTIONS_BY_TYPE,
470
+ addDefaultTableView,
471
+ addDefaultTitleColumn,
472
+ addOrToggleSort,
473
+ addViewSort,
474
+ aggregate,
475
+ asRowHeight,
476
+ autoColor,
477
+ batchComputeRollups,
478
+ buildDatabaseSchema,
479
+ buildPublicFormDefinition,
480
+ buildSchemaFromFields,
481
+ buildSchemaIRI,
482
+ bumpSchemaVersion,
483
+ cellKey,
484
+ cellValueToText,
485
+ checkNeedsRebalancing,
486
+ clearViewFilters,
487
+ clearViewSorts,
488
+ cloneColumns,
489
+ cloneSampleRows,
490
+ cloneSchema,
491
+ collapseAllGroups,
492
+ columnIdFromKey,
493
+ combineFiltersAnd,
494
+ combineFiltersOr,
495
+ computeColumnSummary,
496
+ computeRollup,
497
+ convertCellValue,
498
+ createAnyOfFilter,
499
+ createColumn,
500
+ createCsvBlob,
501
+ createDatabaseSchemaResolver,
502
+ createEqualsFilter,
503
+ createExtensionField,
504
+ createField,
505
+ createFilterQuery,
506
+ createFormulaService,
507
+ createInitialSchemaMetadata,
508
+ createJsonBlob,
509
+ createNodeDatabaseSchemaResolver,
510
+ createPaginatedQuery,
511
+ createRow,
512
+ createSelectOption,
513
+ createSort,
514
+ createSortQuery,
515
+ createVersionEntry,
516
+ createView,
517
+ createView2,
518
+ deleteColumn,
519
+ deleteExtensionField,
520
+ deleteField,
521
+ deleteMeta,
522
+ deleteRichTextCell,
523
+ deleteRow,
524
+ deleteSelectOption,
525
+ deleteView,
526
+ deleteView2,
527
+ downloadCsv,
528
+ downloadJson,
529
+ duplicateColumn,
530
+ duplicateField,
531
+ duplicateView,
532
+ duplicateView2,
533
+ effectiveFieldSortKey,
534
+ ensureSchemaExtension,
535
+ escapeCSV,
536
+ executeQuery,
537
+ expandAllGroups,
538
+ exportToCsv,
539
+ exportToJson,
540
+ exportToJsonArray,
541
+ exportToNdjson,
542
+ extractSchemaFromDoc,
543
+ fieldsToStoredColumns,
544
+ filterRows,
545
+ flattenGroups,
546
+ formatValue,
547
+ fromCellProperties,
548
+ generateColumnIdMap,
549
+ getColumn,
550
+ getColumnIndex,
551
+ getColumns,
552
+ getDatabaseDocumentModel,
553
+ getDatabaseSchemaIRI,
554
+ getDatabaseSelectOptions,
555
+ getField,
556
+ getFields,
557
+ getMeta,
558
+ getOperatorLabel,
559
+ getOperatorsForType,
560
+ getRichTextCell,
561
+ getRichTextColumnIds,
562
+ getRichTextPlainText,
563
+ getRow,
564
+ getSchemaIRIFromDoc,
565
+ getSelectOptions,
566
+ getTitleColumn,
567
+ getTitleField,
568
+ getTotalFromGroups,
569
+ getVersionBumpType,
570
+ getView,
571
+ getView2,
572
+ getViewByType,
573
+ getViews,
574
+ getViews2,
575
+ groupRows,
576
+ guessColumnType,
577
+ hasRichTextColumns,
578
+ hasRichTextContent,
579
+ hideColumn,
580
+ inferColumnTypes,
581
+ inferColumnsFromRows,
582
+ inferTypeFromValues,
583
+ initializeDatabaseDoc,
584
+ isAutoColumnType,
585
+ isAutoFieldType,
586
+ isCellKey,
587
+ isCellValue,
588
+ isComputedColumnType,
589
+ isComputedFieldType,
590
+ isDatabaseDocInitialized,
591
+ isDatabaseSchemaIRI,
592
+ isDateRange,
593
+ isFieldType,
594
+ isFileRef,
595
+ isFilledValue,
596
+ isFilterCondition,
597
+ isFilterGroup,
598
+ isFormFieldTypeAllowed,
599
+ isFormQuestionVisible,
600
+ isGeoPoint as isGeoPoint2,
601
+ isNodeStoreColumnType,
602
+ isNodeStoreFieldType,
603
+ isSelectColor,
604
+ isValidOperator,
605
+ isYDocColumnType,
606
+ isYDocFieldType,
607
+ moveField,
608
+ moveRow,
609
+ moveSelectOption,
610
+ moveView,
611
+ operatorRequiresValue,
612
+ parseCSV,
613
+ parseCSVLine,
614
+ parseDatabaseSchemaIRI,
615
+ parseJSON,
616
+ parseRow,
617
+ parseValue,
618
+ parseVersion,
619
+ pruneVersionHistory,
620
+ queryRows,
621
+ rebalanceDatabase,
622
+ remapViewColumnIds,
623
+ removeSort,
624
+ removeViewSort,
625
+ renameExtensionField,
626
+ reorderColumn,
627
+ reorderViewColumns,
628
+ requiresDateColumn,
629
+ resolveRowHeightPx,
630
+ rowHeightLabel,
631
+ setColumnWidth,
632
+ setFieldHidden,
633
+ setMeta,
634
+ setViewFieldOrder,
635
+ setViewFieldWidth,
636
+ setViewFilters,
637
+ setViewFilters2,
638
+ setViewGroupBy,
639
+ setViewGroupBy2,
640
+ setViewSorts,
641
+ setViewSorts2,
642
+ setVisibleColumns,
643
+ setupDatabase,
644
+ setupNewDatabase,
645
+ showColumn,
646
+ sortRows,
647
+ submissionRowId,
648
+ summaryFunctionLabel,
649
+ supportsGrouping,
650
+ toCellProperties,
651
+ toColumnDefinitions,
652
+ toFieldNode,
653
+ toSelectOptionNode,
654
+ toggleGroupCollapsed,
655
+ toggleGroupCollapsed2,
656
+ toggleSortDirection,
657
+ toggleViewGroupCollapsed,
658
+ updateCell,
659
+ updateCells,
660
+ updateColumn,
661
+ updateField,
662
+ updateSelectOption,
663
+ updateView,
664
+ updateView2,
665
+ validateFormSubmission,
666
+ validateJsonData,
667
+ validateRollupConfig,
668
+ visibleFormQuestions
669
+ } from "./chunk-56EXPOJ4.js";
584
670
  import {
585
671
  EXT_PREFIX,
586
672
  extKey,
@@ -593,7 +679,7 @@ import {
593
679
  SCHEMA_EXTENSION_SCHEMA_IRI,
594
680
  SchemaExtensionSchema,
595
681
  schemaExtensionId
596
- } from "./chunk-KTPSQJ5L.js";
682
+ } from "./chunk-2JROE7ML.js";
597
683
  import {
598
684
  MAX_KEY_LENGTH,
599
685
  compareSortKeys,
@@ -605,68 +691,17 @@ import {
605
691
  } from "./chunk-QWFTRZQT.js";
606
692
  import {
607
693
  DatabaseRowSchema
608
- } from "./chunk-OF6455OV.js";
694
+ } from "./chunk-AKKBG7HW.js";
609
695
  import {
610
696
  DatabaseFieldSchema
611
- } from "./chunk-WWQO7QKV.js";
697
+ } from "./chunk-IKREWSCX.js";
612
698
  import {
613
699
  DatabaseSelectOptionSchema
614
- } from "./chunk-OIWW5TG3.js";
700
+ } from "./chunk-XP3VSSXD.js";
615
701
  import {
616
702
  DatabaseViewSchema
617
- } from "./chunk-SMYZILJ6.js";
618
- import "./chunk-JA56EQJO.js";
619
- import {
620
- MemoryNodeStorageAdapter,
621
- NodeStore,
622
- PermissionError,
623
- QUERY_AST_VERSION,
624
- SQLiteNodeStorageAdapter,
625
- TEMP_ID_PREFIX,
626
- and,
627
- avg,
628
- between,
629
- contains,
630
- count,
631
- countDistinct,
632
- createNodeStorageAdapter,
633
- createSchemaLookup,
634
- dashboardQuerySet,
635
- defineNodeQueryAST,
636
- defineQuerySetAST,
637
- defineSavedViewDescriptor,
638
- eq,
639
- evaluateQueryASTPlannerGate,
640
- executeQueryASTLoadedAggregates,
641
- filterQueryASTLoadedRows,
642
- follow,
643
- from,
644
- getQueryASTRelationIndexRequirements,
645
- groupBy,
646
- gt,
647
- gte,
648
- having,
649
- includesAny,
650
- isNotNull,
651
- isNull,
652
- isTempId,
653
- lt,
654
- lte,
655
- matchesQueryASTLoadedRow,
656
- max,
657
- min,
658
- neq,
659
- not,
660
- or,
661
- planQueryASTAggregates,
662
- queryOperators,
663
- querySetCount,
664
- resolveTempIds,
665
- startsWith,
666
- sum,
667
- validateQueryAST,
668
- validateSavedViewDescriptor
669
- } from "./chunk-4S73XDWH.js";
703
+ } from "./chunk-UFV5QWCL.js";
704
+ import "./chunk-RLRAWZJE.js";
670
705
  import {
671
706
  applyNodeQueryDescriptor,
672
707
  createNodeQueryDescriptor,
@@ -681,41 +716,13 @@ import {
681
716
  sortNodeQueryResults,
682
717
  withoutNodeQueryMaterializedView,
683
718
  withoutNodeQueryPagination
684
- } from "./chunk-S5RP5RKY.js";
685
- import {
686
- PresenceSummarySchema,
687
- SYSTEM_NAMESPACE_KINDS,
688
- SYSTEM_SCHEMA_BASE_IRIS,
689
- SYSTEM_SCHEMA_IRIS,
690
- SchemaCompatibilitySchema,
691
- SchemaDefinitionSchema,
692
- SyncPolicySchema,
693
- buildSystemNamespace,
694
- buildSystemNodeId,
695
- computeSchemaDefinitionContentHash,
696
- createSchemaDefinitionSigningPayload,
697
- isSystemNamespaceResource,
698
- isSystemSchemaIri,
699
- parseSystemNamespaceResource,
700
- resolveSchemaAuthority,
701
- validateSchemaDefinitionNode
702
- } from "./chunk-XJBDESCX.js";
703
- import {
704
- clearLocalPresence,
705
- createAwareness,
706
- generateUserColor,
707
- getAllPresences,
708
- getLocalClientId,
709
- getRemotePresences,
710
- onPresenceChange,
711
- setLocalPresence
712
- } from "./chunk-7PDRDSFH.js";
719
+ } from "./chunk-WOEFYS7Y.js";
713
720
  import {
714
721
  SPACE_MEMBERSHIP_SCHEMA_IRI,
715
722
  SpaceMembershipSchema,
716
723
  isSpaceRole,
717
724
  spaceMembershipId
718
- } from "./chunk-LK5ZIAIE.js";
725
+ } from "./chunk-GSLOK5KV.js";
719
726
  import {
720
727
  checkbox,
721
728
  createNodeId,
@@ -726,6 +733,8 @@ import {
726
733
  defineSchema,
727
734
  email,
728
735
  file,
736
+ geo,
737
+ isGeoPoint,
729
738
  isMoneyValue,
730
739
  isNode,
731
740
  json,
@@ -739,7 +748,7 @@ import {
739
748
  text,
740
749
  updated,
741
750
  url
742
- } from "./chunk-RRXJNZX5.js";
751
+ } from "./chunk-NH6OLO3X.js";
743
752
  import {
744
753
  AUTH_ACTIONS,
745
754
  DEFAULT_OFFLINE_POLICY,
@@ -2040,9 +2049,646 @@ var BlobService = class {
2040
2049
  }
2041
2050
  };
2042
2051
 
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
+
2043
2689
  // src/index.ts
2044
2690
  import {
2045
- Doc,
2691
+ Doc as Doc2,
2046
2692
  Map as Map3,
2047
2693
  Array as Array2,
2048
2694
  Text,
@@ -2083,8 +2729,10 @@ export {
2083
2729
  AgentSessionSchema,
2084
2730
  AppealSchema,
2085
2731
  BUDGET_SCHEMA_IRI,
2732
+ BUNDLE_ENTRY,
2086
2733
  BlobService,
2087
2734
  BudgetSchema,
2735
+ BundleImportError,
2088
2736
  CELL_PREFIX,
2089
2737
  CHANNEL_KINDS,
2090
2738
  CHECKPOINT_SCHEMA_IRI,
@@ -2187,6 +2835,8 @@ export {
2187
2835
  MediaAssetSchema,
2188
2836
  MeetingSchema,
2189
2837
  MeetingTranscriptSchema,
2838
+ MemoryBundleSink,
2839
+ MemoryBundleSource,
2190
2840
  MemoryItemSchema,
2191
2841
  MemoryNodeStorageAdapter,
2192
2842
  MessageRequestSchema,
@@ -2275,8 +2925,9 @@ export {
2275
2925
  TranscriptionSchema,
2276
2926
  UserWidgetSchema,
2277
2927
  WorkspaceSchema,
2928
+ XNETPACK_FORMAT_VERSION,
2278
2929
  Array2 as YArray,
2279
- Doc as YDoc,
2930
+ Doc2 as YDoc,
2280
2931
  Map3 as YMap,
2281
2932
  Text as YText,
2282
2933
  XmlElement as YXmlElement,
@@ -2297,6 +2948,7 @@ export {
2297
2948
  agentSessionId,
2298
2949
  aggregate,
2299
2950
  and,
2951
+ applyBundle,
2300
2952
  applyNodeQueryDescriptor,
2301
2953
  applySignedUpdate,
2302
2954
  asRowHeight,
@@ -2304,6 +2956,7 @@ export {
2304
2956
  avg,
2305
2957
  batchComputeRollups,
2306
2958
  between,
2959
+ blobEntryPath,
2307
2960
  bucketPresenceCount,
2308
2961
  buildDatabaseSchema,
2309
2962
  buildEffectiveSchema,
@@ -2319,6 +2972,7 @@ export {
2319
2972
  bumpSchemaVersion,
2320
2973
  canManageSpace,
2321
2974
  canModifyColumn,
2975
+ canonicalManifestBytes,
2322
2976
  captureUpdate,
2323
2977
  cellKey,
2324
2978
  cellValueToText,
@@ -2374,6 +3028,7 @@ export {
2374
3028
  createSelectOption,
2375
3029
  createSort,
2376
3030
  createSortQuery,
3031
+ createStoreYjsPort,
2377
3032
  createVersionEntry,
2378
3033
  createView2 as createView,
2379
3034
  createView as createViewNode,
@@ -2419,6 +3074,7 @@ export {
2419
3074
  escapeCSV,
2420
3075
  evaluateEmbedRegistryPolicy,
2421
3076
  evaluateExternalReferenceEmbedPolicy,
3077
+ evaluateLedgerWrite,
2422
3078
  evaluateQueryASTPlannerGate,
2423
3079
  executeQuery,
2424
3080
  executeQueryASTLoadedAggregates,
@@ -2440,6 +3096,7 @@ export {
2440
3096
  flattenFolderTree,
2441
3097
  flattenGroups,
2442
3098
  flattenSpaceTree,
3099
+ foldAccountRecord,
2443
3100
  folderAncestorIds,
2444
3101
  folderPathIds,
2445
3102
  follow,
@@ -2447,11 +3104,13 @@ export {
2447
3104
  formatValue,
2448
3105
  from,
2449
3106
  fromCellProperties,
3107
+ fromPortableChangeRecord,
2450
3108
  gameSchemas,
2451
3109
  generateColumnIdMap,
2452
3110
  generateSortKey,
2453
3111
  generateSortKeyWithJitter,
2454
3112
  generateUserColor,
3113
+ geo,
2455
3114
  getAllPresences,
2456
3115
  getColumn,
2457
3116
  getColumnIndex,
@@ -2515,6 +3174,7 @@ export {
2515
3174
  isCellAnchor,
2516
3175
  isDateRange as isCellDateRange,
2517
3176
  isFileRef as isCellFileRef,
3177
+ isGeoPoint2 as isCellGeoPoint,
2518
3178
  isCellKey,
2519
3179
  isCellValue,
2520
3180
  isColumnAnchor,
@@ -2531,6 +3191,7 @@ export {
2531
3191
  isFilterGroup,
2532
3192
  isFormFieldTypeAllowed,
2533
3193
  isFormQuestionVisible,
3194
+ isGeoPoint,
2534
3195
  isGrantActive,
2535
3196
  isMessageLinkPreview,
2536
3197
  isMoneyValue,
@@ -2555,6 +3216,8 @@ export {
2555
3216
  isYDocColumnType,
2556
3217
  isYDocFieldType,
2557
3218
  json,
3219
+ ledgerAccountId,
3220
+ ledgerWriteKind,
2558
3221
  lensRegistry,
2559
3222
  loadExtensionFields,
2560
3223
  lockedPropertyKeys,
@@ -2610,6 +3273,7 @@ export {
2610
3273
  queryOperators,
2611
3274
  queryRows,
2612
3275
  querySetCount,
3276
+ readBundleManifest,
2613
3277
  rebalanceDatabase,
2614
3278
  rebalanceSortKeys,
2615
3279
  recoveryRecordId,
@@ -2681,6 +3345,7 @@ export {
2681
3345
  toCellProperties,
2682
3346
  toColumnDefinitions,
2683
3347
  toFieldNode,
3348
+ toPortableChangeRecord,
2684
3349
  toSelectOptionNode,
2685
3350
  toggleGroupCollapsed,
2686
3351
  toggleGroupCollapsed2 as toggleGroupCollapsedState,
@@ -2703,11 +3368,13 @@ export {
2703
3368
  validateRollupConfig,
2704
3369
  validateSavedViewDescriptor,
2705
3370
  validateSchemaDefinitionNode,
3371
+ verifyBundle,
2706
3372
  verifyUpdate,
2707
3373
  visibleFormQuestions,
2708
3374
  when,
2709
3375
  withoutNodeQueryMaterializedView,
2710
3376
  withoutNodeQueryPagination,
2711
3377
  wouldCreateFolderCycle,
2712
- wouldCreateSpaceCycle
3378
+ wouldCreateSpaceCycle,
3379
+ writeBundle
2713
3380
  };