@powerhousedao/shared 6.2.2-dev.9 → 6.2.2-staging.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 (227) hide show
  1. package/dist/clis/args/access-token--9H57y8J.d.mts +18 -0
  2. package/dist/clis/args/access-token--9H57y8J.d.mts.map +1 -0
  3. package/dist/clis/args/access-token-To5LaIfL.mjs +22 -0
  4. package/dist/clis/args/access-token-To5LaIfL.mjs.map +1 -0
  5. package/dist/clis/args/access-token.d.mts +2 -18
  6. package/dist/clis/args/access-token.mjs +1 -21
  7. package/dist/clis/args/{common-dbsvksvf.mjs → common-CcYbXrBx.mjs} +7 -2
  8. package/dist/clis/args/common-CcYbXrBx.mjs.map +1 -0
  9. package/dist/clis/args/{common-Cr8LZG55.d.mts → common-Dsf1vpHV.d.mts} +7 -4
  10. package/dist/clis/args/{common-Cr8LZG55.d.mts.map → common-Dsf1vpHV.d.mts.map} +1 -1
  11. package/dist/clis/args/common.d.mts +2 -2
  12. package/dist/clis/args/common.mjs +2 -2
  13. package/dist/clis/args/connect-BVVvCmL9.mjs +198 -0
  14. package/dist/clis/args/connect-BVVvCmL9.mjs.map +1 -0
  15. package/dist/clis/args/connect-DetTnI8g.d.mts +443 -0
  16. package/dist/clis/args/connect-DetTnI8g.d.mts.map +1 -0
  17. package/dist/clis/args/connect.d.mts +2 -434
  18. package/dist/clis/args/connect.mjs +1 -196
  19. package/dist/clis/args/{generate-Cs5okckF.mjs → generate-CA916Fvj.mjs} +2 -2
  20. package/dist/clis/args/{generate-Cs5okckF.mjs.map → generate-CA916Fvj.mjs.map} +1 -1
  21. package/dist/clis/args/generate-DnV-bfXt.d.mts +87 -0
  22. package/dist/clis/args/generate-DnV-bfXt.d.mts.map +1 -0
  23. package/dist/clis/args/generate.d.mts +2 -87
  24. package/dist/clis/args/generate.mjs +1 -1
  25. package/dist/clis/args/{help-BkF9Cxud.mjs → help-Bqbgbalu.mjs} +15 -15
  26. package/dist/clis/args/{help-BkF9Cxud.mjs.map → help-Bqbgbalu.mjs.map} +1 -1
  27. package/dist/clis/args/{help-CYjFrzIJ.d.mts → help-CjAsudUn.d.mts} +1 -1
  28. package/dist/clis/args/{help-CYjFrzIJ.d.mts.map → help-CjAsudUn.d.mts.map} +1 -1
  29. package/dist/clis/args/help.d.mts +1 -1
  30. package/dist/clis/args/help.mjs +1 -13
  31. package/dist/clis/args/index.d.mts +19 -19
  32. package/dist/clis/args/index.mjs +19 -19
  33. package/dist/clis/args/init-CUXyfquF.d.mts +55 -0
  34. package/dist/clis/args/init-CUXyfquF.d.mts.map +1 -0
  35. package/dist/clis/args/init-rz9Ei7nq.mjs +67 -0
  36. package/dist/clis/args/init-rz9Ei7nq.mjs.map +1 -0
  37. package/dist/clis/args/init.d.mts +2 -55
  38. package/dist/clis/args/init.mjs +1 -66
  39. package/dist/clis/args/inspect-DtZeoA5c.d.mts +15 -0
  40. package/dist/clis/args/inspect-DtZeoA5c.d.mts.map +1 -0
  41. package/dist/clis/args/inspect-tckH8mSw.mjs +15 -0
  42. package/dist/clis/args/inspect-tckH8mSw.mjs.map +1 -0
  43. package/dist/clis/args/inspect.d.mts +2 -15
  44. package/dist/clis/args/inspect.mjs +1 -14
  45. package/dist/clis/args/install-CkP8zcHb.d.mts +40 -0
  46. package/dist/clis/args/install-CkP8zcHb.d.mts.map +1 -0
  47. package/dist/clis/args/install-Sz2DlCHh.mjs +32 -0
  48. package/dist/clis/args/install-Sz2DlCHh.mjs.map +1 -0
  49. package/dist/clis/args/install.d.mts +2 -40
  50. package/dist/clis/args/install.mjs +1 -31
  51. package/dist/clis/args/list-BGf8s_gj.d.mts +12 -0
  52. package/dist/clis/args/list-BGf8s_gj.d.mts.map +1 -0
  53. package/dist/clis/args/list-DM2d6f1m.mjs +7 -0
  54. package/dist/clis/args/list-DM2d6f1m.mjs.map +1 -0
  55. package/dist/clis/args/list.d.mts +2 -12
  56. package/dist/clis/args/list.mjs +1 -6
  57. package/dist/clis/args/login-DNsHwvqk.d.mts +27 -0
  58. package/dist/clis/args/login-DNsHwvqk.d.mts.map +1 -0
  59. package/dist/clis/args/login-DiKT5Jfu.mjs +40 -0
  60. package/dist/clis/args/login-DiKT5Jfu.mjs.map +1 -0
  61. package/dist/clis/args/login.d.mts +2 -27
  62. package/dist/clis/args/login.mjs +1 -39
  63. package/dist/clis/args/magic-string.es-h_0HDQBQ.mjs +1013 -0
  64. package/dist/clis/args/magic-string.es-h_0HDQBQ.mjs.map +1 -0
  65. package/dist/clis/args/migrate-CG_gWc4k.mjs +29 -0
  66. package/dist/clis/args/migrate-CG_gWc4k.mjs.map +1 -0
  67. package/dist/clis/args/migrate-sixkWhxm.d.mts +21 -0
  68. package/dist/clis/args/migrate-sixkWhxm.d.mts.map +1 -0
  69. package/dist/clis/args/migrate.d.mts +2 -21
  70. package/dist/clis/args/migrate.mjs +1 -28
  71. package/dist/clis/args/publish-DDZYsUfV.mjs +19 -0
  72. package/dist/clis/args/publish-DDZYsUfV.mjs.map +1 -0
  73. package/dist/clis/args/publish-Dqe5DUst.d.mts +18 -0
  74. package/dist/clis/args/publish-Dqe5DUst.d.mts.map +1 -0
  75. package/dist/clis/args/publish.d.mts +2 -18
  76. package/dist/clis/args/publish.mjs +1 -18
  77. package/dist/clis/args/registry-C_OVFQmI.mjs +23 -0
  78. package/dist/clis/args/registry-C_OVFQmI.mjs.map +1 -0
  79. package/dist/clis/args/registry-C_RfTsKB.d.mts +19 -0
  80. package/dist/clis/args/registry-C_RfTsKB.d.mts.map +1 -0
  81. package/dist/clis/args/registry.d.mts +2 -19
  82. package/dist/clis/args/registry.mjs +1 -22
  83. package/dist/clis/args/service-CHOOr0Gg.mjs +11 -0
  84. package/dist/clis/args/service-CHOOr0Gg.mjs.map +1 -0
  85. package/dist/clis/args/{service-C88bN_g_.d.mts → service-DhIkf8-O.d.mts} +1 -1
  86. package/dist/clis/args/{service-C88bN_g_.d.mts.map → service-DhIkf8-O.d.mts.map} +1 -1
  87. package/dist/clis/args/service.d.mts +1 -1
  88. package/dist/clis/args/service.mjs +1 -10
  89. package/dist/clis/args/switchboard-BlPaq2at.d.mts +72 -0
  90. package/dist/clis/args/switchboard-BlPaq2at.d.mts.map +1 -0
  91. package/dist/clis/args/switchboard-Dsp7nosi.mjs +85 -0
  92. package/dist/clis/args/switchboard-Dsp7nosi.mjs.map +1 -0
  93. package/dist/clis/args/switchboard.d.mts +2 -72
  94. package/dist/clis/args/switchboard.mjs +1 -84
  95. package/dist/clis/args/uninstall-BpA3YYbw.d.mts +31 -0
  96. package/dist/clis/args/uninstall-BpA3YYbw.d.mts.map +1 -0
  97. package/dist/clis/args/uninstall-CTwTX0u_.mjs +16 -0
  98. package/dist/clis/args/uninstall-CTwTX0u_.mjs.map +1 -0
  99. package/dist/clis/args/uninstall.d.mts +2 -31
  100. package/dist/clis/args/uninstall.mjs +1 -15
  101. package/dist/clis/args/unpublish-BPMkGEg5.mjs +30 -0
  102. package/dist/clis/args/unpublish-BPMkGEg5.mjs.map +1 -0
  103. package/dist/clis/args/unpublish-CvwaIimG.d.mts +24 -0
  104. package/dist/clis/args/unpublish-CvwaIimG.d.mts.map +1 -0
  105. package/dist/clis/args/unpublish.d.mts +2 -24
  106. package/dist/clis/args/unpublish.mjs +1 -29
  107. package/dist/clis/args/vetra-DLQ6lhLl.d.mts +113 -0
  108. package/dist/clis/args/vetra-DLQ6lhLl.d.mts.map +1 -0
  109. package/dist/clis/args/vetra-b4KUu1Ax.mjs +126 -0
  110. package/dist/clis/args/vetra-b4KUu1Ax.mjs.map +1 -0
  111. package/dist/clis/args/vetra-ports.test.d.mts +1 -0
  112. package/dist/clis/args/vetra-ports.test.mjs +13249 -0
  113. package/dist/clis/args/vetra-ports.test.mjs.map +1 -0
  114. package/dist/clis/args/vetra.d.mts +2 -102
  115. package/dist/clis/args/vetra.mjs +2 -75
  116. package/dist/clis/build-config.d.mts +1 -1
  117. package/dist/clis/build-config.d.mts.map +1 -1
  118. package/dist/clis/constants.d.mts +199 -55
  119. package/dist/clis/constants.d.mts.map +1 -1
  120. package/dist/clis/constants.mjs +12 -4
  121. package/dist/clis/constants.mjs.map +1 -1
  122. package/dist/clis/index.d.mts +591 -30
  123. package/dist/clis/index.d.mts.map +1 -1
  124. package/dist/clis/index.mjs +413 -18
  125. package/dist/clis/index.mjs.map +1 -1
  126. package/dist/clis/project-env.d.mts +27 -0
  127. package/dist/clis/project-env.d.mts.map +1 -0
  128. package/dist/clis/project-env.mjs +44 -0
  129. package/dist/clis/project-env.mjs.map +1 -0
  130. package/dist/clis/project-ports.d.mts +40 -0
  131. package/dist/clis/project-ports.d.mts.map +1 -0
  132. package/dist/clis/project-ports.mjs +90 -0
  133. package/dist/clis/project-ports.mjs.map +1 -0
  134. package/dist/{config-loader-19K8n4DO.js → config-loader-B845Hidf.js} +11 -14
  135. package/dist/config-loader-B845Hidf.js.map +1 -0
  136. package/dist/connect/config-loader.d.ts +2 -1
  137. package/dist/connect/config-loader.d.ts.map +1 -1
  138. package/dist/connect/config-loader.js +1 -1
  139. package/dist/connect/index.d.ts +486 -27
  140. package/dist/connect/index.d.ts.map +1 -1
  141. package/dist/connect/index.js +531 -5
  142. package/dist/connect/index.js.map +1 -1
  143. package/dist/connect/json-adapter.d.ts.map +1 -1
  144. package/dist/{constants-C_EQX4DY.d.ts → constants-BP_gjn8g.d.ts} +1 -1
  145. package/dist/constants-BP_gjn8g.d.ts.map +1 -0
  146. package/dist/constants.d.ts +1 -1
  147. package/dist/document-drive/index.d.ts +2 -2
  148. package/dist/document-drive/index.js +3 -3
  149. package/dist/document-drive/index.js.map +1 -1
  150. package/dist/document-model/index.d.ts +4 -5
  151. package/dist/document-model/index.js +1337 -133
  152. package/dist/document-model/index.js.map +1 -1
  153. package/dist/document-model/mock.d.ts +22 -2
  154. package/dist/document-model/mock.d.ts.map +1 -0
  155. package/dist/document-model/mock.js +32 -3
  156. package/dist/document-model/mock.js.map +1 -1
  157. package/dist/document-model/utils.d.ts +1 -2
  158. package/dist/document-model/utils.js +1 -2
  159. package/dist/{index-CQDIrK1k.d.ts → index-C_iVZe7f.d.ts} +1 -1
  160. package/dist/index-C_iVZe7f.d.ts.map +1 -0
  161. package/dist/index-DPuio_se.d.ts +836 -0
  162. package/dist/index-DPuio_se.d.ts.map +1 -0
  163. package/dist/index.d.ts +5 -6
  164. package/dist/processors/index.d.ts +2 -2
  165. package/dist/registry/index.d.ts +5 -4
  166. package/dist/registry/index.d.ts.map +1 -1
  167. package/dist/registry/index.js +9 -8
  168. package/dist/registry/index.js.map +1 -1
  169. package/dist/registry/manifest-slim.d.ts +1 -1
  170. package/dist/registry/urls.d.ts +11 -0
  171. package/dist/registry/urls.d.ts.map +1 -0
  172. package/dist/registry/urls.js +15 -0
  173. package/dist/registry/urls.js.map +1 -0
  174. package/dist/{types-DvWPqxJr.d.ts → types-BBUlASQ7.d.ts} +30 -4
  175. package/dist/types-BBUlASQ7.d.ts.map +1 -0
  176. package/dist/{types-DXsYu6Tq.d.ts → types-BzWRXB7f.d.ts} +507 -16
  177. package/dist/types-BzWRXB7f.d.ts.map +1 -0
  178. package/dist/utils-DP122OSS.d.ts +18 -0
  179. package/dist/utils-DP122OSS.d.ts.map +1 -0
  180. package/dist/{utils-DKOFCM0Q.js → utils-aaTmfxFW.js} +45 -2
  181. package/dist/utils-aaTmfxFW.js.map +1 -0
  182. package/package.json +12 -1
  183. package/dist/clis/args/access-token.d.mts.map +0 -1
  184. package/dist/clis/args/access-token.mjs.map +0 -1
  185. package/dist/clis/args/common-dbsvksvf.mjs.map +0 -1
  186. package/dist/clis/args/connect.d.mts.map +0 -1
  187. package/dist/clis/args/connect.mjs.map +0 -1
  188. package/dist/clis/args/generate.d.mts.map +0 -1
  189. package/dist/clis/args/init.d.mts.map +0 -1
  190. package/dist/clis/args/init.mjs.map +0 -1
  191. package/dist/clis/args/inspect.d.mts.map +0 -1
  192. package/dist/clis/args/inspect.mjs.map +0 -1
  193. package/dist/clis/args/install.d.mts.map +0 -1
  194. package/dist/clis/args/install.mjs.map +0 -1
  195. package/dist/clis/args/list.d.mts.map +0 -1
  196. package/dist/clis/args/list.mjs.map +0 -1
  197. package/dist/clis/args/login.d.mts.map +0 -1
  198. package/dist/clis/args/login.mjs.map +0 -1
  199. package/dist/clis/args/migrate.d.mts.map +0 -1
  200. package/dist/clis/args/migrate.mjs.map +0 -1
  201. package/dist/clis/args/publish.d.mts.map +0 -1
  202. package/dist/clis/args/publish.mjs.map +0 -1
  203. package/dist/clis/args/registry.d.mts.map +0 -1
  204. package/dist/clis/args/registry.mjs.map +0 -1
  205. package/dist/clis/args/service.mjs.map +0 -1
  206. package/dist/clis/args/switchboard.d.mts.map +0 -1
  207. package/dist/clis/args/switchboard.mjs.map +0 -1
  208. package/dist/clis/args/uninstall.d.mts.map +0 -1
  209. package/dist/clis/args/uninstall.mjs.map +0 -1
  210. package/dist/clis/args/unpublish.d.mts.map +0 -1
  211. package/dist/clis/args/unpublish.mjs.map +0 -1
  212. package/dist/clis/args/vetra.d.mts.map +0 -1
  213. package/dist/clis/args/vetra.mjs.map +0 -1
  214. package/dist/config-loader-19K8n4DO.js.map +0 -1
  215. package/dist/constants-C_EQX4DY.d.ts.map +0 -1
  216. package/dist/index-CQDIrK1k.d.ts.map +0 -1
  217. package/dist/index-Dz7JrBXs.d.ts +0 -399
  218. package/dist/index-Dz7JrBXs.d.ts.map +0 -1
  219. package/dist/mock-CBcf78ra.d.ts +0 -7
  220. package/dist/mock-CBcf78ra.d.ts.map +0 -1
  221. package/dist/types-D0NNBVGA.d.ts +0 -167
  222. package/dist/types-D0NNBVGA.d.ts.map +0 -1
  223. package/dist/types-DXsYu6Tq.d.ts.map +0 -1
  224. package/dist/types-DvWPqxJr.d.ts.map +0 -1
  225. package/dist/utils-BEByNOHo.d.ts +0 -9
  226. package/dist/utils-BEByNOHo.d.ts.map +0 -1
  227. package/dist/utils-DKOFCM0Q.js.map +0 -1
@@ -0,0 +1,836 @@
1
+ import { $t as DocumentModelOperationExampleOperations, Aa as SigningParameters, Bn as ModuleSpecification, Bt as DocumentModelGlobalState, Gt as DocumentModelLocalState, H as ActionSignatureContext, Ht as DocumentModelHeaderOperations, Jr as PruneActionInput, Jt as DocumentModelModuleOperations, Lr as OperationErrorSpecification, Ma as SkipHeaderOperations, On as LoadFromInput, Pa as StateReducer, Qa as UpgradeManifest, Rt as DocumentModelDocument, Sn as ISigner, Su as Grant, Ta as SignalDispatch, Tu as PHBaseState, Za as ValidationError, Zt as DocumentModelOperationErrorOperations, _i as ReplayDocumentOptions, bi as SaveToFileHandle, bl as PHDocument, cn as DocumentSpecification, ct as Author, cu as Operation, ei as Reducer, en as DocumentModelOperationOperations, lt as CodeExample, lu as OperationContext, mn as FileInput, oc as Action, on as DocumentModelVersioningOperations, rn as DocumentModelStateOperations, su as DocumentOperations, ti as ReducerOptions, tn as DocumentModelPHState, wu as PHAuthState, xl as PHDocumentHeader, xu as Condition, yu as AuthGroups, zn as MinimalBackupData, zr as OperationSpecification } from "./types-BzWRXB7f.js";
2
+ import { ZodIssue, z } from "zod";
3
+
4
+ //#region document-model/action-transport.d.ts
5
+ /**
6
+ * An action's signer, as the wire declares it: signatures joined into strings,
7
+ * because GraphQL declares them as a list of strings rather than of lists.
8
+ */
9
+ type TransportSigner = {
10
+ user?: {
11
+ address: string;
12
+ networkId: string;
13
+ chainId: number;
14
+ };
15
+ app?: {
16
+ name: string;
17
+ key: string;
18
+ };
19
+ signatures: string[];
20
+ };
21
+ /** An action's context, as the wire declares it. */
22
+ type TransportActionContext = {
23
+ prevOpIndex?: number;
24
+ prevOpHash?: string;
25
+ nonce?: string;
26
+ signer?: TransportSigner;
27
+ };
28
+ /** An action projected onto exactly the fields the wire declares. */
29
+ type TransportAction = {
30
+ id: string;
31
+ type: string;
32
+ timestampUtcMs: string;
33
+ /**
34
+ * Non-nullable, because the wire declares it so. An action's own type says
35
+ * `unknown`, which admits the absent input an action creator called without
36
+ * one produces - {@link toTransportAction} refuses that rather than passing
37
+ * it on.
38
+ */
39
+ input: NonNullable<unknown>;
40
+ scope: string;
41
+ context?: TransportActionContext;
42
+ };
43
+ /**
44
+ * Projects an action onto the fields the GraphQL `ActionInput` declares.
45
+ *
46
+ * A projection rather than a spread, because an input object rejects a field it
47
+ * does not declare, and that refusal takes the whole request with it. An action
48
+ * read back out of storage can carry fields the type no longer has - a legacy
49
+ * `attachments` array, or the operation fields left behind by a signing helper
50
+ * that returns an operation - and any one of them would sink an otherwise valid
51
+ * submission.
52
+ *
53
+ * Only fields the action actually carries are emitted, so an unsigned action
54
+ * sends no context at all rather than a context full of nulls.
55
+ */
56
+ declare function toTransportAction(action: Action): TransportAction;
57
+ //#endregion
58
+ //#region document-model/auth.d.ts
59
+ type InitializeAuthActionInput = {
60
+ version: number;
61
+ grants: Grant[];
62
+ };
63
+ type SetGrantActionInput = {
64
+ grant: Grant;
65
+ };
66
+ type RemoveGrantActionInput = {
67
+ id: string;
68
+ };
69
+ type MoveGrantActionInput = {
70
+ id: string; /** Target index in the grant list; clamped to the valid range. */
71
+ index: number;
72
+ };
73
+ type InitializeAuthAction = Action & {
74
+ type: "INITIALIZE_AUTH";
75
+ input: InitializeAuthActionInput;
76
+ };
77
+ type SetGrantAction = Action & {
78
+ type: "SET_GRANT";
79
+ input: SetGrantActionInput;
80
+ };
81
+ type RemoveGrantAction = Action & {
82
+ type: "REMOVE_GRANT";
83
+ input: RemoveGrantActionInput;
84
+ };
85
+ type MoveGrantAction = Action & {
86
+ type: "MOVE_GRANT";
87
+ input: MoveGrantActionInput;
88
+ };
89
+ type AuthAction = InitializeAuthAction | SetGrantAction | RemoveGrantAction | MoveGrantAction;
90
+ declare const AUTH_ACTION_TYPES: readonly ["INITIALIZE_AUTH", "SET_GRANT", "REMOVE_GRANT", "MOVE_GRANT"];
91
+ declare function isAuthAction(action: Action): action is AuthAction;
92
+ /** Highest known policy version; decide() fails closed above it. */
93
+ declare const MAX_SUPPORTED_AUTH_VERSION = 1;
94
+ declare const InitializeAuthActionInputSchema: () => z.ZodObject<{
95
+ version: z.ZodNumber;
96
+ grants: z.ZodArray<z.ZodCustom<Grant, Grant>>;
97
+ }, z.core.$strip>;
98
+ declare const SetGrantActionInputSchema: () => z.ZodObject<{
99
+ grant: z.ZodCustom<Grant, Grant>;
100
+ }, z.core.$strip>;
101
+ declare const RemoveGrantActionInputSchema: () => z.ZodObject<{
102
+ id: z.ZodString;
103
+ }, z.core.$strip>;
104
+ declare const MoveGrantActionInputSchema: () => z.ZodObject<{
105
+ id: z.ZodString;
106
+ index: z.ZodNumber;
107
+ }, z.core.$strip>;
108
+ declare const initializeAuth: (input: InitializeAuthActionInput) => InitializeAuthAction;
109
+ declare const setGrant: (input: SetGrantActionInput) => SetGrantAction;
110
+ declare const removeGrant: (input: RemoveGrantActionInput) => RemoveGrantAction;
111
+ declare const moveGrant: (input: MoveGrantActionInput) => MoveGrantAction;
112
+ /**
113
+ * True when `signerKey` (an ActionSigner app key, a did:key) identifies the same
114
+ * key recorded as the document creator. Returns false
115
+ * when there is no creator (empty JWK) or no signer key.
116
+ */
117
+ declare function isDocumentCreator(creatorKey: JsonWebKey | undefined, signerKey: string | undefined): boolean;
118
+ /**
119
+ * Sets the initial policy. Valid only while the auth scope is uninitialized
120
+ * (version 0). The input version is the policy language version and must be an
121
+ * integer >= 1; 0 is reserved for the uninitialized state. On a signed-header
122
+ * document it must be signed by the document creator (`header.sig.publicKey`).
123
+ * A creator-less policy must include a grant permitting execute on the auth
124
+ * scope, or it would be born locked out.
125
+ */
126
+ declare function applyInitializeAuthAction<TState extends PHBaseState>(document: PHDocument<TState>, action: InitializeAuthAction): PHDocument<TState>;
127
+ /** Upserts a grant by id: replaces in place if present, otherwise appends. */
128
+ declare function applySetGrantAction<TState extends PHBaseState>(document: PHDocument<TState>, action: SetGrantAction): PHDocument<TState>;
129
+ /**
130
+ * Removes a grant by id; throws if the id is not present or if the removal
131
+ * would leave a creator-less policy with no auth-administration grant.
132
+ */
133
+ declare function applyRemoveGrantAction<TState extends PHBaseState>(document: PHDocument<TState>, action: RemoveGrantAction): PHDocument<TState>;
134
+ /**
135
+ * Moves a grant by id to a new index. Order is load-bearing (the last
136
+ * applicable grant wins), so the relative order of the other grants is kept.
137
+ * The target index is clamped to the valid range; an unknown id throws.
138
+ *
139
+ * Order alone decides which grant wins, so a move can take administration away
140
+ * without changing the list's contents. It carries the same retention rule as
141
+ * the two mutation paths.
142
+ */
143
+ declare function applyMoveGrantAction<TState extends PHBaseState>(document: PHDocument<TState>, action: MoveGrantAction): PHDocument<TState>;
144
+ /**
145
+ * Dispatches an auth-scope action to its handler. This is the auth scope's
146
+ * dedicated reducer: it is applied by the base reducer instead of the model
147
+ * reducer, mirroring the document-scope platform handlers. Unknown types are a
148
+ * no-op, matching the model-reducer default.
149
+ */
150
+ declare function applyAuthAction<TState extends PHBaseState>(document: PHDocument<TState>, action: Action): PHDocument<TState>;
151
+ /**
152
+ * Because only creators can initialize auth scopes, we must verify that either
153
+ * the document has no auth or the version and creator match.
154
+ */
155
+ declare function assertAuthPreservedOnDuplicate(documentId: string, source: PHAuthState | undefined, duplicated: PHAuthState | undefined): void;
156
+ /**
157
+ * The auth scope a state snapshot may install, given the policy already there.
158
+ *
159
+ * `applyAuthAction` is the validated door onto `state.auth`, but a whole-state
160
+ * snapshot (UPGRADE_DOCUMENT's `initialState`, LOAD_STATE's `data`) replaces the
161
+ * scope wholesale and is authorized as a `document`-scope write. Without this,
162
+ * a subject holding `execute` on `document` and no auth grant at all can install
163
+ * a policy of its choosing, name itself `creator` (which exempts the policy from
164
+ * the retention rule for good), or wipe an existing policy by carrying the
165
+ * default uninitialized one.
166
+ *
167
+ * Three cases:
168
+ *
169
+ * - the snapshot carries no policy, or an uninitialized one: the document
170
+ * keeps the policy it has, so a default-state upgrade cannot reset it;
171
+ * - the document is uninitialized and the snapshot carries a policy: the
172
+ * policy is installed after the same validation genesis applies, so it
173
+ * cannot be born locked out;
174
+ * - both carry a policy: they must agree. A duplicate preserves its source's
175
+ * policy (see {@link assertAuthPreservedOnDuplicate}), and anything else is
176
+ * an attempt to replace one policy with another.
177
+ */
178
+ declare function resolveSnapshotAuth(documentId: string, documentType: string, current: PHAuthState | undefined, incoming: PHAuthState | undefined): PHAuthState;
179
+ /** UNDO, REDO and PRUNE are rejected on the auth scope. */
180
+ declare function assertAuthScopeActionAllowed(action: Action): void;
181
+ type AuthVerb = "read" | "execute";
182
+ type AuthRequest = {
183
+ verb: AuthVerb;
184
+ scope: string; /** For execute: the operation (action type) being attempted. Omitted for reads. */
185
+ operation?: string;
186
+ };
187
+ type AuthSubject = {
188
+ /** Verified signer address; undefined for an anonymous subject. */address?: string; /** The signer's app key (a did:key), used to match the document creator. */
189
+ key?: string;
190
+ };
191
+ /**
192
+ * What condition attr paths resolve against, beyond the subject. Supplied
193
+ * only while authConditions enforcement is on: with no context a grant
194
+ * carrying `where` or a { match } principal never applies.
195
+ */
196
+ type ConditionContext = {
197
+ /** The executing scope's own state, for `doc.<scope>.*` paths. */scopeState: unknown; /** The action's input, for `action.input.*` paths. Absent for reads. */
198
+ actionInput?: unknown;
199
+ };
200
+ type AuthDecision = "allow" | "deny";
201
+ /** Why the policy refused a request. */
202
+ type AuthRefusal = "version-unsupported" | "no-applicable-grant" | "denied-by-grant";
203
+ /**
204
+ * A decision together with why it refused. A refusal names which of the
205
+ * policy's rules produced it, so an operation records the reason it was refused
206
+ * rather than one reason standing for every refusal.
207
+ */
208
+ type AuthEvaluation = {
209
+ decision: "allow";
210
+ } | {
211
+ decision: "deny";
212
+ refusal: AuthRefusal;
213
+ grantId?: string;
214
+ };
215
+ /**
216
+ * Evaluates the auth policy for a single request and reports why it refused.
217
+ * Pure and deterministic.
218
+ *
219
+ * An uninitialized policy (version 0, absent auth state, or a legacy `{}`
220
+ * auth scope serialized before PHAuthState had a version) leaves the document
221
+ * open. Once a policy exists the default is deny, and grants stack in order.
222
+ *
223
+ * Group principals match only against a supplied groups map (the groups
224
+ * projection, present when authGroups is on); with no map they never apply.
225
+ * `where` clauses and { match } principals likewise evaluate only against a
226
+ * supplied condition context (present when authConditions is on).
227
+ */
228
+ declare function evaluate(auth: PHAuthState | undefined, subject: AuthSubject, request: AuthRequest, groups?: AuthGroups, conditions?: ConditionContext): AuthEvaluation;
229
+ /**
230
+ * Evaluates the auth policy for a single request. Pure and deterministic. This
231
+ * is {@link evaluate} with the reason dropped.
232
+ */
233
+ declare function decide(auth: PHAuthState | undefined, subject: AuthSubject, request: AuthRequest, groups?: AuthGroups, conditions?: ConditionContext): AuthDecision;
234
+ /**
235
+ * The group document ids a single auth action's input names with `{ group }`
236
+ * principals. INITIALIZE_AUTH contributes the groups named across its grants,
237
+ * SET_GRANT the groups named by its one grant; REMOVE_GRANT and MOVE_GRANT
238
+ * contribute nothing. Total over any input shape, because references are read
239
+ * from the input as it arrived, including inputs later stored as errors.
240
+ */
241
+ declare function mentionedGroupIds(action: Action): string[];
242
+ //#endregion
243
+ //#region document-model/auth-v1.d.ts
244
+ /** Maximum number of grants in a policy. */
245
+ declare const MAX_AUTH_GRANTS = 100;
246
+ /** Maximum nesting depth of a condition tree. */
247
+ declare const MAX_CONDITION_DEPTH = 10;
248
+ /** Maximum node count (conditions plus operands) of a condition tree. */
249
+ declare const MAX_CONDITION_NODES = 100;
250
+ /** Maximum entries in an execute capability's operation list. */
251
+ declare const MAX_CAPABILITY_OPERATIONS = 100;
252
+ /**
253
+ * Thrown when a grant violates the v1 validation rules. The message is stored
254
+ * on error operations, so it must be a pure function of the input.
255
+ */
256
+ declare class InvalidGrantError extends Error {
257
+ readonly grantId: string;
258
+ constructor(grantId: string, problem: string);
259
+ }
260
+ /** Thrown for a `{ group }` principal on a group document: references never chain. */
261
+ declare class GroupPrincipalNotAllowedError extends Error {
262
+ readonly grantId: string;
263
+ constructor(grantId: string);
264
+ }
265
+ /**
266
+ * Thrown when a change would leave a creator-less policy with no grant
267
+ * permitting execute on the auth scope. Without the creator carve-out no
268
+ * subject could ever administer such a policy again.
269
+ */
270
+ declare class AuthAdministrationLockoutError extends Error {
271
+ readonly grantId: string;
272
+ constructor(grantId: string);
273
+ }
274
+ /**
275
+ * Thrown when INITIALIZE_AUTH would create a creator-less policy with no grant
276
+ * permitting execute on the auth scope. Such a policy would be born with no
277
+ * subject able to administer it.
278
+ */
279
+ declare class AuthAdministrationMissingError extends Error {
280
+ constructor();
281
+ }
282
+ declare function isPlainValue(value: unknown): value is Record<string, unknown>;
283
+ /** Returns the first v1-rule violation, or null. Pure, total, deterministic. */
284
+ declare function grantProblem(value: unknown): string | null;
285
+ declare const GrantSchema: () => z.ZodCustom<Grant, Grant>;
286
+ /** V1 shape rules plus the group-document group-principal ban. */
287
+ declare function assertValidGrant(grant: unknown, documentType: string): void;
288
+ /**
289
+ * Validates an initial grant list: the count cap, every grant, and — on a
290
+ * creator-less policy — that some grant keeps the auth scope administrable.
291
+ */
292
+ declare function assertValidInitialGrants(grants: Grant[], documentType: string, creator: string | undefined): void;
293
+ /**
294
+ * Validates a grant upsert: the grant itself, the count cap on append, and
295
+ * administration retention. Retention is checked on an append as well as an
296
+ * in-place replace, because a grant appended after the administration grant can
297
+ * shadow it (evaluation is last-applicable-grant-wins) and so take
298
+ * administration away without removing anything.
299
+ */
300
+ declare function assertValidGrantUpsert(grant: Grant, existing: Grant[], documentType: string, creator: string | undefined): void;
301
+ /**
302
+ * A creator-less policy must always retain a grant permitting execute on the
303
+ * auth scope; on a signed document the creator carve-out keeps administration
304
+ * reachable instead. Rejects a change that takes the last such grant away. A
305
+ * policy already without one is left alone: the change is not what locks it.
306
+ */
307
+ declare function assertAuthAdministrationRetained(creator: string | undefined, previous: Grant[], next: Grant[], grantId: string): void;
308
+ /**
309
+ * Evaluates a version-1 condition. Deterministic, total, and pure: any input
310
+ * shape yields a boolean and never throws, and a malformed condition is
311
+ * false. These are consensus semantics, versioned by `PHAuthState.version`;
312
+ * changing them requires a new version.
313
+ */
314
+ declare function evaluateCondition(condition: Condition, subject: AuthSubject, request: AuthRequest, conditions: ConditionContext): boolean;
315
+ /**
316
+ * The group document ids named by `{ group }` principals in a grant list, in
317
+ * order of first appearance. These are the streams the groups projection reads.
318
+ */
319
+ declare function referencedGroupIds(grants: Grant[]): string[];
320
+ /**
321
+ * Evaluates a v1 grant stack: default deny, last applicable grant wins, and
322
+ * reports which grant decided it. Group principals match only against a
323
+ * supplied groups map, and `where` clauses and { match } principals evaluate
324
+ * only against a supplied condition context; a grant that uses an unsupplied
325
+ * feature never applies.
326
+ */
327
+ declare function evaluateGrantStack(grants: Grant[], subject: AuthSubject, request: AuthRequest, groups?: AuthGroups, conditions?: ConditionContext): AuthEvaluation;
328
+ /**
329
+ * Evaluates a v1 grant stack: default deny, last applicable grant wins. This is
330
+ * {@link evaluateGrantStack} with the reason dropped.
331
+ */
332
+ declare function evaluateGrants(grants: Grant[], subject: AuthSubject, request: AuthRequest, groups?: AuthGroups, conditions?: ConditionContext): AuthDecision;
333
+ //#endregion
334
+ //#region document-model/constants.d.ts
335
+ declare const documentModelFileExtension: "phdm";
336
+ declare const documentModelInitialLocalState: DocumentModelLocalState;
337
+ declare const documentModelInitialGlobalState: DocumentModelGlobalState;
338
+ declare const documentModelGlobalState: DocumentModelGlobalState;
339
+ declare const HASH_ALGORITHM_SHA1 = "sha1";
340
+ declare const HASH_ALGORITHM_SHA256 = "sha256";
341
+ declare const HASH_ALGORITHM_SHA512 = "sha512";
342
+ declare const HASH_ENCODING_BASE64 = "base64";
343
+ declare const HASH_ENCODING_HEX = "hex";
344
+ //#endregion
345
+ //#region document-model/crypto.d.ts
346
+ declare const hashBrowser: (data: string | Uint8Array | ArrayBufferView | DataView, algorithm?: string, encoding?: string, _params?: Record<string, unknown>) => string;
347
+ declare function getUnixTimestamp(date: Date | string): string;
348
+ declare function buildOperationSignatureParams({
349
+ documentId,
350
+ signer,
351
+ action,
352
+ previousStateHash
353
+ }: ActionSignatureContext): [string, string, string, string];
354
+ declare function buildOperationSignatureMessage(params: [string, string, string, string]): Uint8Array;
355
+ declare function ab2hex(ab: ArrayBuffer | ArrayBufferView): string;
356
+ declare function hex2ab(hex: string): Uint8Array<ArrayBuffer>;
357
+ /**
358
+ * Decodes a base58btc (Bitcoin/IPFS alphabet) string to bytes. Returns null on
359
+ * any character outside the alphabet.
360
+ */
361
+ declare function base58Decode(input: string): Uint8Array | null;
362
+ /** Decodes a base64url string to bytes (portable across node, browsers, workers). */
363
+ declare function base64UrlToBytes(input: string): Uint8Array;
364
+ //#endregion
365
+ //#region document-model/denied.d.ts
366
+ /**
367
+ * True iff authorization rejected the action.
368
+ */
369
+ declare function isDenied(operation: Operation): boolean;
370
+ /**
371
+ * The closed set of strings persisted as `deniedReason`. Re-evaluation compares
372
+ * them, so they are consensus data: exact strings that embed no grant id,
373
+ * subject or timestamp. Changing one is history-visible.
374
+ */
375
+ declare const DOCUMENT_DELETED_REASON = "document deleted";
376
+ declare const AUTH_VERSION_UNSUPPORTED_REASON = "auth policy version unsupported";
377
+ declare const AUTH_NO_GRANT_REASON = "no grant permits this operation";
378
+ declare const AUTH_DENIED_BY_GRANT_REASON = "denied by grant";
379
+ //#endregion
380
+ //#region document-model/document-schema.d.ts
381
+ declare const BaseDocumentHeaderSchema: z.ZodObject<{
382
+ id: z.ZodString;
383
+ name: z.ZodString;
384
+ createdAtUtcIso: z.ZodString;
385
+ lastModifiedAtUtcIso: z.ZodString;
386
+ documentType: z.ZodString;
387
+ }, z.core.$strip>;
388
+ declare const BaseDocumentStateSchema: z.ZodObject<{
389
+ global: z.ZodUnknown;
390
+ }, z.core.$strip>;
391
+ /** Schema for validating the header object of a DocumentModel document */
392
+ declare const DocumentModelHeaderSchema: z.ZodObject<{
393
+ id: z.ZodString;
394
+ name: z.ZodString;
395
+ createdAtUtcIso: z.ZodString;
396
+ lastModifiedAtUtcIso: z.ZodString;
397
+ documentType: z.ZodLiteral<"powerhouse/document-model">;
398
+ }, z.core.$strip>;
399
+ /** Schema for validating the state object of a DocumentModel document */
400
+ declare const DocumentModelPHStateSchema: z.ZodObject<{
401
+ global: z.ZodObject<Required<{
402
+ author: z.ZodType<Author, Author, z.core.$ZodTypeInternals<Author, Author>>;
403
+ description: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
404
+ extension: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
405
+ id: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
406
+ name: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
407
+ specifications: z.ZodType<DocumentSpecification[], DocumentSpecification[], z.core.$ZodTypeInternals<DocumentSpecification[], DocumentSpecification[]>>;
408
+ }>, z.core.$strip>;
409
+ }, z.core.$strip>;
410
+ declare const DocumentModelSchema: z.ZodObject<{
411
+ header: z.ZodObject<{
412
+ id: z.ZodString;
413
+ name: z.ZodString;
414
+ createdAtUtcIso: z.ZodString;
415
+ lastModifiedAtUtcIso: z.ZodString;
416
+ documentType: z.ZodLiteral<"powerhouse/document-model">;
417
+ }, z.core.$strip>;
418
+ state: z.ZodObject<{
419
+ global: z.ZodObject<Required<{
420
+ author: z.ZodType<Author, Author, z.core.$ZodTypeInternals<Author, Author>>;
421
+ description: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
422
+ extension: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
423
+ id: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
424
+ name: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
425
+ specifications: z.ZodType<DocumentSpecification[], DocumentSpecification[], z.core.$ZodTypeInternals<DocumentSpecification[], DocumentSpecification[]>>;
426
+ }>, z.core.$strip>;
427
+ }, z.core.$strip>;
428
+ initialState: z.ZodObject<{
429
+ global: z.ZodObject<Required<{
430
+ author: z.ZodType<Author, Author, z.core.$ZodTypeInternals<Author, Author>>;
431
+ description: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
432
+ extension: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
433
+ id: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
434
+ name: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
435
+ specifications: z.ZodType<DocumentSpecification[], DocumentSpecification[], z.core.$ZodTypeInternals<DocumentSpecification[], DocumentSpecification[]>>;
436
+ }>, z.core.$strip>;
437
+ }, z.core.$strip>;
438
+ }, z.core.$strip>;
439
+ /** Simple helper function to check if a state object is a DocumentModel document state object */
440
+ declare function isDocumentModelState(state: unknown): state is DocumentModelPHState;
441
+ /** Simple helper function to assert that a document state object is a DocumentModel document state object */
442
+ declare function assertIsDocumentModelState(state: unknown): asserts state is DocumentModelPHState;
443
+ /** Simple helper function to check if a document is a DocumentModel document */
444
+ declare function isDocumentModelDocument(document: unknown): document is DocumentModelDocument;
445
+ /** Simple helper function to assert that a document is a DocumentModel document */
446
+ declare function assertIsDocumentModelDocument(document: unknown): asserts document is DocumentModelDocument;
447
+ //#endregion
448
+ //#region document-model/document-type.d.ts
449
+ declare const documentModelDocumentType = "powerhouse/document-model";
450
+ declare const groupDocumentType = "powerhouse/reactor-group";
451
+ /**
452
+ * The group-model action types that change membership. The groups projection
453
+ * filters its reads to these, so any other group operation is invisible to a
454
+ * decision. Kept here so the reactor never depends on the group package; a
455
+ * reactor-group test guards against drift.
456
+ */
457
+ declare const groupMembershipActionTypes: readonly ["ADD_MEMBER", "REMOVE_MEMBER"];
458
+ //#endregion
459
+ //#region document-model/errors.d.ts
460
+ declare const FileSystemError: Error;
461
+ declare class InvalidActionInputError extends Error {
462
+ data: unknown;
463
+ constructor(data: unknown);
464
+ }
465
+ declare class InvalidActionInputZodError extends InvalidActionInputError {
466
+ issues: ZodIssue[];
467
+ constructor(issues: ZodIssue[]);
468
+ }
469
+ /**
470
+ * Error thrown when attempting to downgrade a document version.
471
+ */
472
+ declare class DowngradeNotSupportedError extends Error {
473
+ readonly documentType: string;
474
+ readonly fromVersion: number;
475
+ readonly toVersion: number;
476
+ constructor(documentType: string, fromVersion: number, toVersion: number);
477
+ }
478
+ /**
479
+ * Thrown when INITIALIZE_AUTH is applied to an already-initialized auth scope.
480
+ * The genesis action is valid only at auth revision zero.
481
+ */
482
+ declare class AuthAlreadyInitializedError extends Error {
483
+ readonly documentId: string;
484
+ constructor(documentId: string);
485
+ }
486
+ /**
487
+ * Thrown when INITIALIZE_AUTH is not signed by the document creator (its signer
488
+ * does not match `header.sig.publicKey`), so it cannot set the auth policy.
489
+ */
490
+ declare class AuthInitializerNotCreatorError extends Error {
491
+ readonly documentId: string;
492
+ constructor(documentId: string);
493
+ }
494
+ /**
495
+ * Thrown when INITIALIZE_AUTH carries a version below 1. Version 0 is reserved
496
+ * for the uninitialized auth scope.
497
+ */
498
+ declare class InvalidAuthVersionError extends Error {
499
+ readonly documentId: string;
500
+ readonly version: number;
501
+ constructor(documentId: string, version: number);
502
+ }
503
+ /** Thrown when a duplicate would lose the source policy's version or creator binding. */
504
+ declare class AuthPolicyNotPreservedError extends Error {
505
+ readonly documentId: string;
506
+ constructor(documentId: string);
507
+ }
508
+ /**
509
+ * Thrown when a grant referenced by REMOVE_GRANT or MOVE_GRANT does not exist.
510
+ */
511
+ declare class GrantNotFoundError extends Error {
512
+ readonly grantId: string;
513
+ constructor(grantId: string);
514
+ }
515
+ /**
516
+ * Thrown when a disallowed action (UNDO, REDO, PRUNE) targets the auth scope.
517
+ */
518
+ declare class AuthActionNotAllowedError extends Error {
519
+ readonly actionType: string;
520
+ constructor(actionType: string);
521
+ }
522
+ declare class HashMismatchError extends Error {
523
+ protected _scope: string;
524
+ protected _document: PHDocument;
525
+ protected _operation: Operation;
526
+ constructor(scope: string, document: PHDocument, operation: Operation);
527
+ get document(): PHDocument;
528
+ get scope(): string;
529
+ get operation(): Operation;
530
+ }
531
+ /**
532
+ * Thrown when replay or import requires a document model version that is not
533
+ * registered. Carries the data the UI needs to explain the mismatch.
534
+ */
535
+ declare class UnsupportedDocumentModelVersionError extends Error {
536
+ readonly documentType: string;
537
+ readonly requiredVersion: number;
538
+ readonly availableVersions: number[];
539
+ constructor(documentType: string, requiredVersion: number, availableVersions: number[]);
540
+ static isError(error: unknown): error is UnsupportedDocumentModelVersionError;
541
+ }
542
+ //#endregion
543
+ //#region document-model/versioned-replay.d.ts
544
+ type VersionedReducers = Record<number, Reducer<PHBaseState>>;
545
+ type VersionedReplayConfig = {
546
+ reducers: VersionedReducers;
547
+ upgradeManifest?: UpgradeManifest<readonly number[]>;
548
+ };
549
+ /**
550
+ * Version-aware document replay. Replays a versioned document through per-version
551
+ * reducers, applying upgrade transitions at segment boundaries.
552
+ *
553
+ * Algorithm (D5):
554
+ * a. Build spine from operations["document"]. Empty spine or no upgrades → legacy fallback.
555
+ * b. Collect UPGRADE_DOCUMENT ops from the spine.
556
+ * c. Seed state from the creation upgrade (fromVersion===0). Missing seed with validated
557
+ * upgrades throws; otherwise falls back to legacy.
558
+ * d. Identify validated upgrades (fromVersion > 0, version increases). Compute per-scope
559
+ * boundaries using revision snapshot (preferred) or timestamp fallback.
560
+ * e. Loop over version segments, replaying each scope's ops through the matching reducer,
561
+ * then applying the upgrade transition before the next segment.
562
+ * f. Set header.revision["document"], verify per-scope hashes against state at op-time
563
+ * (not post-upgrade state) when checkHashes is false, and map timestamps from input.
564
+ *
565
+ * operations must include ALL scopes (document scope is NOT stripped).
566
+ * reuseOperationResultingState is ignored by this function — zip operations never carry
567
+ * resultingState.
568
+ */
569
+ declare function replayDocumentVersioned<TState extends PHBaseState>(initialState: TState, operations: DocumentOperations, config: VersionedReplayConfig, header: PHDocumentHeader, dispatch?: SignalDispatch, options?: ReplayDocumentOptions): PHDocument<TState>;
570
+ //#endregion
571
+ //#region document-model/files.d.ts
572
+ declare function createZip(document: PHDocument): Promise<Uint8Array>;
573
+ /**
574
+ * Creates a minimal ZIP backup from strand data.
575
+ * Used when the full document is not available (e.g., in onOperations handler).
576
+ * Creates a ZIP with minimal header and empty operations.
577
+ */
578
+ declare function createMinimalZip(data: MinimalBackupData): Promise<Uint8Array>;
579
+ declare function baseSaveToFileHandle(document: PHDocument, input: FileSystemFileHandle): Promise<void>;
580
+ declare function baseLoadFromInput<TState extends PHBaseState>(input: FileInput, reducer: Reducer<TState>, options?: ReplayDocumentOptions): Promise<PHDocument<TState>>;
581
+ declare function baseLoadFromInputVersioned<TState extends PHBaseState>(input: FileInput, config: VersionedReplayConfig, options?: ReplayDocumentOptions): Promise<PHDocument<TState>>;
582
+ type BulkArchiveEntry = {
583
+ /** "/"-separated zip path of a file entry (no trailing slash). */path: string;
584
+ data: Uint8Array;
585
+ };
586
+ /**
587
+ * Whether this zip is a single Powerhouse document: the document's four JSON
588
+ * entries (header/state/current-state/operations) at the archive root. A
589
+ * bulk archive has a folder tree instead. Returns false for any input that
590
+ * is not a readable zip.
591
+ */
592
+ declare function isDocumentZip(data: Uint8Array): Promise<boolean>;
593
+ /**
594
+ * The file entries of a zip (directory entries excluded). Used for bulk
595
+ * archives; throws when the archive holds no files. Note this does NOT
596
+ * validate that the entries are document zips — pair with isDocumentZip.
597
+ */
598
+ declare function parseBulkArchive(data: Uint8Array): Promise<BulkArchiveEntry[]>;
599
+ /**
600
+ * Assemble a zip from raw entries. A key ending in "/" with empty data is a
601
+ * directory entry, so an archive's folder structure survives a round-trip.
602
+ */
603
+ declare function zipEntries(entries: Record<string, Uint8Array>): Promise<Uint8Array>;
604
+ declare const documentModelLoadFromInput: LoadFromInput<DocumentModelPHState>;
605
+ declare const documentModelSaveToFileHandle: SaveToFileHandle;
606
+ declare function writeFileBrowser(path: string, name: string, stream: Uint8Array): Promise<string>;
607
+ declare function readFileBrowser(path: string): void;
608
+ declare function fetchFileBrowser(url: string): Promise<{
609
+ data: Buffer;
610
+ mimeType?: string;
611
+ }>;
612
+ declare const getFileBrowser: (file: string) => Promise<void>;
613
+ //#endregion
614
+ //#region document-model/header.d.ts
615
+ /**
616
+ * Creates a verification-only signer from a public key.
617
+ * This signer can only verify signatures, not sign data.
618
+ *
619
+ * @param pubKey - The public key to use for verification.
620
+ * @returns An ISigner that can only verify signatures.
621
+ */
622
+ declare function createVerificationSigner(pubKey: JsonWebKey): Promise<ISigner>;
623
+ /**
624
+ * Signs a header. Generally, this is not called directly, but rather through
625
+ * {@link createSignedHeader}.
626
+ *
627
+ * @param parameters - The parameters used to sign the header.
628
+ * @param signer - The signer of the document.
629
+ *
630
+ * @returns The signature of the header.
631
+ */
632
+ declare const sign: (parameters: SigningParameters, signer: ISigner) => Promise<string>;
633
+ /**
634
+ * Verifies a header signature. Generally, this is not called directly, but
635
+ * rather through {@link validateHeader}.
636
+ *
637
+ * @param parameters - The parameters used to sign the header.
638
+ * @param signature - The signature to verify.
639
+ * @param signer - The signer of the document.
640
+ */
641
+ declare const verify: (parameters: SigningParameters, signature: string, signer: ISigner) => Promise<void>;
642
+ /**
643
+ * Validates a header signature.
644
+ */
645
+ declare const validateHeader: (header: PHDocumentHeader) => Promise<void>;
646
+ /**
647
+ * Creates a header that has yet to be signed. This header is not valid, but
648
+ * can be input into {@link createSignedHeader} to create a signed header.
649
+ *
650
+ * @returns An unsigned header for a document.
651
+ */
652
+ declare const createPresignedHeader: (id?: string, documentType?: string) => PHDocumentHeader;
653
+ /**
654
+ * Creates a new, signed header for a document. This will replace the id of the
655
+ * document.
656
+ *
657
+ * @param unsignedHeader - The unsigned header to created the signed header from.
658
+ * @param signer - The signer of the document.
659
+ *
660
+ * @returns A new signed header for a document. Some fields are mutable and
661
+ * some are not. See the PHDocumentHeader type for more information.
662
+ */
663
+ declare const createSignedHeader: (unsignedHeader: PHDocumentHeader, documentType: string, signer: ISigner) => Promise<PHDocumentHeader>;
664
+ /**
665
+ * Creates a signed header for a document. The document header requires a signer
666
+ * as the document id is a cryptographic signature.
667
+ *
668
+ * @param documentType - The type of the document.
669
+ * @param signer - The signer of the document.
670
+ *
671
+ * @returns The signed header for a document. Some fields are mutable and
672
+ * some are not. See the PHDocumentHeader type for more information.
673
+ */
674
+ declare const createSignedHeaderForSigner: (documentType: string, signer: ISigner) => Promise<PHDocumentHeader>;
675
+ //#endregion
676
+ //#region document-model/reducer.d.ts
677
+ declare function replayOperations<TState extends PHBaseState = PHBaseState>(initialState: TState, clearedOperations: DocumentOperations, stateReducer: StateReducer<TState>, header: PHDocumentHeader, dispatch?: SignalDispatch, documentReducer?: typeof baseReducer, skipHeaderOperations?: SkipHeaderOperations, options?: ReplayDocumentOptions): PHDocument<TState>;
678
+ /**
679
+ * Updates the document state based on the provided action.
680
+ *
681
+ * @param state The current state of the document.
682
+ * @param action The action being applied to the document.
683
+ * @param skip The number of operations to skip before applying the action.
684
+ * @param reuseLastOperationIndex Whether to reuse the last operation index (used when a an UNDO operation is performed after an existing one).
685
+ * @param context The operation context for deterministic ID generation.
686
+ * @returns The updated document state.
687
+ */
688
+ declare function updateDocument<TDocument extends PHDocument>(document: TDocument, action: Action, reuseLastOperationIndex: boolean, skip: number, context: OperationContext, operation?: Operation, skipIndexValidation?: boolean): TDocument;
689
+ /**
690
+ * Processes an UNDO or REDO action.
691
+ *
692
+ * @param document The current state of the document.
693
+ * @param action The action being applied to the document.
694
+ * @param skip The number of operations to skip before applying the action.
695
+ * @returns The updated document, calculated skip value and transformed action (if applied).
696
+ */
697
+ declare function processUndoRedo<TState extends PHBaseState = PHBaseState>(document: PHDocument<TState>, action: Action, skip: number, protocolVersion?: number): {
698
+ document: PHDocument<TState>;
699
+ action: Action;
700
+ skip: number;
701
+ reuseLastOperationIndex: boolean;
702
+ };
703
+ /**
704
+ * Base document reducer that wraps a custom document reducer and handles
705
+ * document-level actions such as undo, redo, prune, and set name.
706
+ *
707
+ * @template TGlobalState - The type of the state of the custom reducer.
708
+ * @template TAction - The type of the actions of the custom reducer.
709
+ * @param state - The current state of the document.
710
+ * @param action - The action object to apply to the state.
711
+ * @param customReducer - The custom reducer that implements the application logic
712
+ * specific to the document's state.
713
+ * @returns The new state of the document.
714
+ */
715
+ declare function baseReducer<TState extends PHBaseState = PHBaseState>(document: PHDocument<TState>, action: Action, customReducer: StateReducer<TState>, dispatch?: SignalDispatch, options?: ReducerOptions): PHDocument<TState>;
716
+ /**
717
+ * Helper function to create a document model reducer.
718
+ *
719
+ * @remarks
720
+ * This function creates a new reducer that wraps the provided `reducer` with
721
+ * `documentReducer`, adding support for document actions:
722
+ * - `SET_NAME`
723
+ * - `UNDO`
724
+ * - `REDO`
725
+ * - `PRUNE`
726
+ *
727
+ * It also updates the document-related attributes on every operation.
728
+ *
729
+ * @param reducer - The custom reducer to wrap.
730
+ * @param documentReducer - The document reducer to use.
731
+ *
732
+ * @returns The new reducer.
733
+ */
734
+ declare function createReducer<TState extends PHBaseState = PHBaseState>(stateReducer: StateReducer<TState>, documentReducer?: typeof baseReducer): Reducer<TState>;
735
+ declare function pruneOperation<TState extends PHBaseState = PHBaseState>(document: PHDocument<TState>, input: PruneActionInput, wrappedReducer: StateReducer<TState>): PHDocument<TState>;
736
+ //#endregion
737
+ //#region document-model/reducers.d.ts
738
+ declare const documentModelHeaderReducer: DocumentModelHeaderOperations;
739
+ declare const documentModelModuleReducer: DocumentModelModuleOperations;
740
+ declare const documentModelOperationErrorReducer: DocumentModelOperationErrorOperations;
741
+ declare const documentModelOperationExampleReducer: DocumentModelOperationExampleOperations;
742
+ declare const documentModelOperationReducer: DocumentModelOperationOperations;
743
+ declare const documentModelStateSchemaReducer: DocumentModelStateOperations;
744
+ declare const documentModelVersioningReducer: DocumentModelVersioningOperations;
745
+ declare const documentModelStateReducer: StateReducer<DocumentModelPHState>;
746
+ declare const documentModelReducer: Reducer<DocumentModelPHState>;
747
+ //#endregion
748
+ //#region document-model/validation.d.ts
749
+ /**
750
+ * Reserved operation names from base reducer (core/actions.ts).
751
+ * These names cannot be used for custom operations.
752
+ */
753
+ declare const RESERVED_OPERATION_NAMES: readonly ["UNDO", "REDO", "PRUNE", "LOAD_STATE", "SET_NAME", "SET_PREFERRED_EDITOR", "NOOP"];
754
+ type ReservedOperationName = (typeof RESERVED_OPERATION_NAMES)[number];
755
+ /**
756
+ * Operation names become the literal action `type` string at runtime and the
757
+ * key for codegen's action union. They must be SCREAMING_SNAKE_CASE so the
758
+ * generated TypeScript is valid.
759
+ */
760
+ declare const OPERATION_NAME_PATTERN: RegExp;
761
+ declare function isValidOperationNameFormat(name: string): boolean;
762
+ /**
763
+ * Check if name conflicts with base reducer actions (case-insensitive).
764
+ */
765
+ declare function isReservedOperationName(name: string): boolean;
766
+ /**
767
+ * Get all operation names from all modules in the latest specification.
768
+ * Returns names in uppercase for case-insensitive comparison.
769
+ */
770
+ declare function getAllOperationNames(state: DocumentModelGlobalState, excludeOperationId?: string): string[];
771
+ /**
772
+ * Validate operation name is not reserved or duplicate. Throws on failure.
773
+ *
774
+ * @param name - The operation name to validate
775
+ * @param state - The document model global state
776
+ * @param excludeOperationId - Optional operation ID to exclude (for rename validation)
777
+ * @throws Error if the name is reserved or a duplicate
778
+ */
779
+ declare function validateOperationName(name: string, state: DocumentModelGlobalState, excludeOperationId?: string): void;
780
+ declare function validateInitialState(initialState: string, allowEmptyState?: boolean): ValidationError[];
781
+ declare function validateStateSchemaName(schema: string, documentName: string, scope?: string, allowEmptySchema?: boolean): ValidationError[];
782
+ declare function validateModules(modules: ModuleSpecification[]): ValidationError[];
783
+ declare function validateModule(mod: ModuleSpecification): ValidationError[];
784
+ declare function validateModuleOperation(operation: OperationSpecification): ValidationError[];
785
+ /**
786
+ * Find a module in the latest specification by id, or throw. Reducers that
787
+ * mutate-by-id should call this up front so an unknown id fails loudly
788
+ * instead of silently no-opping.
789
+ */
790
+ declare function findModuleOrThrow(state: DocumentModelGlobalState, moduleId: string): ModuleSpecification;
791
+ /**
792
+ * Find an operation in the latest specification by id, or throw. Same
793
+ * rationale as findModuleOrThrow — reducers that target an operation must
794
+ * fail loudly when the operation doesn't exist.
795
+ */
796
+ declare function findOperationOrThrow(state: DocumentModelGlobalState, operationId: string): OperationSpecification;
797
+ /**
798
+ * Find an operation error by id across all operations in the latest
799
+ * specification, or throw. Throws on a duplicate id too: setters act on a
800
+ * single error, so an ambiguous id must fail loudly rather than mutate an
801
+ * arbitrary match.
802
+ */
803
+ declare function findOperationErrorOrThrow(state: DocumentModelGlobalState, errorId: string): OperationErrorSpecification;
804
+ /**
805
+ * Find an operation example (code example) by id across all operations in the
806
+ * latest specification, or throw. Throws on a duplicate id for the same reason
807
+ * as findOperationErrorOrThrow.
808
+ */
809
+ declare function findOperationExampleOrThrow(state: DocumentModelGlobalState, exampleId: string): CodeExample;
810
+ /**
811
+ * Assert no module in the latest specification already uses `id`. Modules are
812
+ * targeted by id by the setter/delete/reorder reducers, so a duplicate id makes
813
+ * those operations ambiguous.
814
+ */
815
+ declare function assertModuleIdUnique(state: DocumentModelGlobalState, id: string): void;
816
+ /**
817
+ * Assert no operation in the latest specification already uses `id`. Operations
818
+ * are targeted by id across all modules, so the id must be unique document-wide.
819
+ */
820
+ declare function assertOperationIdUnique(state: DocumentModelGlobalState, id: string): void;
821
+ /**
822
+ * Assert no operation error in the latest specification already uses `id`.
823
+ * Error ids are targeted document-wide by the setter/delete reducers, so the id
824
+ * must be unique to keep those operations unambiguous.
825
+ */
826
+ declare function assertOperationErrorIdUnique(state: DocumentModelGlobalState, id: string): void;
827
+ /**
828
+ * Assert no operation example in the latest specification already uses `id`.
829
+ * Example ids are targeted document-wide by the update/delete reducers, so the
830
+ * id must be unique to keep those operations unambiguous.
831
+ */
832
+ declare function assertOperationExampleIdUnique(state: DocumentModelGlobalState, id: string): void;
833
+ declare function validateOperations(operations: DocumentOperations): ValidationError[];
834
+ //#endregion
835
+ export { getFileBrowser as $, mentionedGroupIds as $n, documentModelInitialLocalState as $t, documentModelVersioningReducer as A, InitializeAuthActionInputSchema as An, isDocumentModelDocument as At, createVerificationSigner as B, SetGrantActionInputSchema as Bn, buildOperationSignatureMessage as Bt, documentModelModuleReducer as C, AuthRefusal as Cn, BaseDocumentHeaderSchema as Ct, documentModelReducer as D, ConditionContext as Dn, DocumentModelSchema as Dt, documentModelOperationReducer as E, AuthVerb as En, DocumentModelPHStateSchema as Et, replayOperations as F, RemoveGrantAction as Fn, DOCUMENT_DELETED_REASON as Ft, baseLoadFromInput as G, applySetGrantAction as Gn, HASH_ALGORITHM_SHA1 as Gt, validateHeader as H, applyInitializeAuthAction as Hn, getUnixTimestamp as Ht, updateDocument as I, RemoveGrantActionInput as In, isDenied as It, createMinimalZip as J, decide as Jn, HASH_ENCODING_BASE64 as Jt, baseLoadFromInputVersioned as K, assertAuthPreservedOnDuplicate as Kn, HASH_ALGORITHM_SHA256 as Kt, createPresignedHeader as L, RemoveGrantActionInputSchema as Ln, ab2hex as Lt, createReducer as M, MoveGrantAction as Mn, AUTH_DENIED_BY_GRANT_REASON as Mt, processUndoRedo as N, MoveGrantActionInput as Nn, AUTH_NO_GRANT_REASON as Nt, documentModelStateReducer as O, InitializeAuthAction as On, assertIsDocumentModelDocument as Ot, pruneOperation as P, MoveGrantActionInputSchema as Pn, AUTH_VERSION_UNSUPPORTED_REASON as Pt, fetchFileBrowser as Q, isDocumentCreator as Qn, documentModelInitialGlobalState as Qt, createSignedHeader as R, SetGrantAction as Rn, base58Decode as Rt, documentModelHeaderReducer as S, AuthEvaluation as Sn, groupMembershipActionTypes as St, documentModelOperationExampleReducer as T, AuthSubject as Tn, DocumentModelHeaderSchema as Tt, verify as U, applyMoveGrantAction as Un, hashBrowser as Ut, sign as V, applyAuthAction as Vn, buildOperationSignatureParams as Vt, BulkArchiveEntry as W, applyRemoveGrantAction as Wn, hex2ab as Wt, documentModelLoadFromInput as X, initializeAuth as Xn, documentModelFileExtension as Xt, createZip as Y, evaluate as Yn, HASH_ENCODING_HEX as Yt, documentModelSaveToFileHandle as Z, isAuthAction as Zn, documentModelGlobalState as Zt, validateModuleOperation as _, isPlainValue as _n, InvalidActionInputZodError as _t, assertOperationErrorIdUnique as a, MAX_AUTH_GRANTS as an, TransportActionContext as ar, VersionedReducers as at, validateOperations as b, AuthAction as bn, documentModelDocumentType as bt, findModuleOrThrow as c, MAX_CONDITION_NODES as cn, AuthActionNotAllowedError as ct, findOperationOrThrow as d, assertValidGrantUpsert as dn, AuthPolicyNotPreservedError as dt, AuthAdministrationLockoutError as en, moveGrant as er, isDocumentZip as et, getAllOperationNames as f, assertValidInitialGrants as fn, DowngradeNotSupportedError as ft, validateModule as g, grantProblem as gn, InvalidActionInputError as gt, validateInitialState as h, evaluateGrants as hn, HashMismatchError as ht, assertModuleIdUnique as i, InvalidGrantError as in, TransportAction as ir, zipEntries as it, baseReducer as j, MAX_SUPPORTED_AUTH_VERSION as jn, isDocumentModelState as jt, documentModelStateSchemaReducer as k, InitializeAuthActionInput as kn, assertIsDocumentModelState as kt, findOperationErrorOrThrow as l, assertAuthAdministrationRetained as ln, AuthAlreadyInitializedError as lt, isValidOperationNameFormat as m, evaluateGrantStack as mn, GrantNotFoundError as mt, RESERVED_OPERATION_NAMES as n, GrantSchema as nn, resolveSnapshotAuth as nr, readFileBrowser as nt, assertOperationExampleIdUnique as o, MAX_CAPABILITY_OPERATIONS as on, TransportSigner as or, VersionedReplayConfig as ot, isReservedOperationName as p, evaluateCondition as pn, FileSystemError as pt, baseSaveToFileHandle as q, assertAuthScopeActionAllowed as qn, HASH_ALGORITHM_SHA512 as qt, ReservedOperationName as r, GroupPrincipalNotAllowedError as rn, setGrant as rr, writeFileBrowser as rt, assertOperationIdUnique as s, MAX_CONDITION_DEPTH as sn, toTransportAction as sr, replayDocumentVersioned as st, OPERATION_NAME_PATTERN as t, AuthAdministrationMissingError as tn, removeGrant as tr, parseBulkArchive as tt, findOperationExampleOrThrow as u, assertValidGrant as un, AuthInitializerNotCreatorError as ut, validateModules as v, referencedGroupIds as vn, InvalidAuthVersionError as vt, documentModelOperationErrorReducer as w, AuthRequest as wn, BaseDocumentStateSchema as wt, validateStateSchemaName as x, AuthDecision as xn, groupDocumentType as xt, validateOperationName as y, AUTH_ACTION_TYPES as yn, UnsupportedDocumentModelVersionError as yt, createSignedHeaderForSigner as z, SetGrantActionInput as zn, base64UrlToBytes as zt };
836
+ //# sourceMappingURL=index-DPuio_se.d.ts.map