@powerhousedao/shared 6.0.0-dev.47

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 (67) hide show
  1. package/README.md +15 -0
  2. package/dist/document-model/core/actions.d.ts +62 -0
  3. package/dist/document-model/core/actions.d.ts.map +1 -0
  4. package/dist/document-model/core/actions.js +2 -0
  5. package/dist/document-model/core/actions.js.map +1 -0
  6. package/dist/document-model/core/constants.d.ts +6 -0
  7. package/dist/document-model/core/constants.d.ts.map +1 -0
  8. package/dist/document-model/core/constants.js +8 -0
  9. package/dist/document-model/core/constants.js.map +1 -0
  10. package/dist/document-model/core/documents.d.ts +102 -0
  11. package/dist/document-model/core/documents.d.ts.map +1 -0
  12. package/dist/document-model/core/documents.js +2 -0
  13. package/dist/document-model/core/documents.js.map +1 -0
  14. package/dist/document-model/core/operations.d.ts +74 -0
  15. package/dist/document-model/core/operations.d.ts.map +1 -0
  16. package/dist/document-model/core/operations.js +2 -0
  17. package/dist/document-model/core/operations.js.map +1 -0
  18. package/dist/document-model/core/ph-types.d.ts +7 -0
  19. package/dist/document-model/core/ph-types.d.ts.map +1 -0
  20. package/dist/document-model/core/ph-types.js +2 -0
  21. package/dist/document-model/core/ph-types.js.map +1 -0
  22. package/dist/document-model/core/signatures.d.ts +52 -0
  23. package/dist/document-model/core/signatures.d.ts.map +1 -0
  24. package/dist/document-model/core/signatures.js +2 -0
  25. package/dist/document-model/core/signatures.js.map +1 -0
  26. package/dist/document-model/core/state.d.ts +38 -0
  27. package/dist/document-model/core/state.d.ts.map +1 -0
  28. package/dist/document-model/core/state.js +2 -0
  29. package/dist/document-model/core/state.js.map +1 -0
  30. package/dist/document-model/core/types.d.ts +533 -0
  31. package/dist/document-model/core/types.d.ts.map +1 -0
  32. package/dist/document-model/core/types.js +2 -0
  33. package/dist/document-model/core/types.js.map +1 -0
  34. package/dist/document-model/core/upgrades.d.ts +24 -0
  35. package/dist/document-model/core/upgrades.d.ts.map +1 -0
  36. package/dist/document-model/core/upgrades.js +2 -0
  37. package/dist/document-model/core/upgrades.js.map +1 -0
  38. package/dist/document-model/index.d.ts +5 -0
  39. package/dist/document-model/index.d.ts.map +1 -0
  40. package/dist/document-model/index.js +3 -0
  41. package/dist/document-model/index.js.map +1 -0
  42. package/dist/document-model/types.d.ts +97 -0
  43. package/dist/document-model/types.d.ts.map +1 -0
  44. package/dist/document-model/types.js +2 -0
  45. package/dist/document-model/types.js.map +1 -0
  46. package/dist/processors/constants.d.ts +4 -0
  47. package/dist/processors/constants.d.ts.map +1 -0
  48. package/dist/processors/constants.js +4 -0
  49. package/dist/processors/constants.js.map +1 -0
  50. package/dist/processors/index.d.ts +5 -0
  51. package/dist/processors/index.d.ts.map +1 -0
  52. package/dist/processors/index.js +4 -0
  53. package/dist/processors/index.js.map +1 -0
  54. package/dist/processors/relational/types.d.ts +72 -0
  55. package/dist/processors/relational/types.d.ts.map +1 -0
  56. package/dist/processors/relational/types.js +45 -0
  57. package/dist/processors/relational/types.js.map +1 -0
  58. package/dist/processors/relational/utils.d.ts +29 -0
  59. package/dist/processors/relational/utils.d.ts.map +1 -0
  60. package/dist/processors/relational/utils.js +67 -0
  61. package/dist/processors/relational/utils.js.map +1 -0
  62. package/dist/processors/types.d.ts +76 -0
  63. package/dist/processors/types.d.ts.map +1 -0
  64. package/dist/processors/types.js +2 -0
  65. package/dist/processors/types.js.map +1 -0
  66. package/dist/tsconfig.tsbuildinfo +1 -0
  67. package/package.json +37 -0
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # Shared code for the Powerhouse monorepo
2
+
3
+ This directory is an npm package which is intended for sharing code across packages in the monorepo.
4
+
5
+ This package is excluded from the release workflow and is never intended to be published ("private": true) in package.json.
6
+
7
+ It also doesn't define anything in the "files" field of the `package.json` for the same reason.
8
+
9
+ This package should **never depend on any other package in this monorepo**. We want to be able to use the code kept here in any of the other monorepo packages without circular imports.
10
+
11
+ This is a great place to put your:
12
+
13
+ - simple constants you want to be able to use anywhere
14
+ - base types you want to share easily (**not** derived types that require imports from elsewhere)
15
+ - simple utility functions that **do not depend on code from elsewhere in the monorepo**
@@ -0,0 +1,62 @@
1
+ import type { ActionSigner } from "./signatures.js";
2
+ /**
3
+ * The context of an action.
4
+ */
5
+ export type ActionContext = {
6
+ /** The index of the previous operation, showing intended ordering. */
7
+ prevOpIndex?: number;
8
+ /** The hash of the previous operation, showing intended state. */
9
+ prevOpHash?: string;
10
+ /** A nonce, to cover specific signing attacks and to prevent replay attacks from no-ops. */
11
+ nonce?: string;
12
+ /** The signer of the action. */
13
+ signer?: ActionSigner;
14
+ };
15
+ /**
16
+ * Defines the basic structure of an action.
17
+ */
18
+ export type Action = {
19
+ /** The id of the action. This is distinct from the operation id. */
20
+ id: string;
21
+ /** The name of the action. */
22
+ type: string;
23
+ /** The timestamp of the action. */
24
+ timestampUtcMs: string;
25
+ /** The payload of the action. */
26
+ input: unknown;
27
+ /** The scope of the action */
28
+ scope: string;
29
+ /**
30
+ * The attachments included in the action.
31
+ *
32
+ * This will be refactored in a future release.
33
+ */
34
+ attachments?: AttachmentInput[];
35
+ /** The context of the action. */
36
+ context?: ActionContext;
37
+ };
38
+ /**
39
+ * The attributes stored for a file. Namely, attachments of a document.
40
+ */
41
+ export type Attachment = {
42
+ /** The binary data of the attachment in Base64 */
43
+ data: string;
44
+ /** The MIME type of the attachment */
45
+ mimeType: string;
46
+ extension?: string | null;
47
+ fileName?: string | null;
48
+ };
49
+ export type AttachmentInput = Attachment & {
50
+ hash: string;
51
+ };
52
+ export type ActionWithAttachment = Action & {
53
+ attachments: AttachmentInput[];
54
+ };
55
+ /**
56
+ * String type representing an attachment in a Document.
57
+ *
58
+ * @remarks
59
+ * Attachment string is formatted as `attachment://<filename>`.
60
+ */
61
+ export type AttachmentRef = string;
62
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../document-model/core/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,4FAA4F;IAC5F,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,gCAAgC;IAChC,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,oEAAoE;IACpE,EAAE,EAAE,MAAM,CAAC;IAEX,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IAEb,mCAAmC;IACnC,cAAc,EAAE,MAAM,CAAC;IAEvB,iCAAiC;IACjC,KAAK,EAAE,OAAO,CAAC;IAEf,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,WAAW,CAAC,EAAE,eAAe,EAAE,CAAC;IAEhC,iCAAiC;IACjC,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IAEb,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IAGjB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG;IACzC,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG;IAC1C,WAAW,EAAE,eAAe,EAAE,CAAC;CAChC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../document-model/core/actions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export declare const HASH_ALGORITHM_SHA1 = "sha1";
2
+ export declare const HASH_ALGORITHM_SHA256 = "sha256";
3
+ export declare const HASH_ALGORITHM_SHA512 = "sha512";
4
+ export declare const HASH_ENCODING_BASE64 = "base64";
5
+ export declare const HASH_ENCODING_HEX = "hex";
6
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../document-model/core/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAC1C,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAG9C,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,eAAO,MAAM,iBAAiB,QAAQ,CAAC"}
@@ -0,0 +1,8 @@
1
+ // Known hash algorithms (can be extended without breaking changes)
2
+ export const HASH_ALGORITHM_SHA1 = "sha1";
3
+ export const HASH_ALGORITHM_SHA256 = "sha256";
4
+ export const HASH_ALGORITHM_SHA512 = "sha512";
5
+ // Known encodings (can be extended without breaking changes)
6
+ export const HASH_ENCODING_BASE64 = "base64";
7
+ export const HASH_ENCODING_HEX = "hex";
8
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../document-model/core/constants.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAC1C,MAAM,CAAC,MAAM,qBAAqB,GAAG,QAAQ,CAAC;AAC9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,QAAQ,CAAC;AAE9C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AAC7C,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC"}
@@ -0,0 +1,102 @@
1
+ import type { DocumentOperations, Operation } from "./operations.js";
2
+ import type { PHDocumentSignatureInfo } from "./signatures.js";
3
+ import type { PHBaseState } from "./state.js";
4
+ /** Meta information about the document. */
5
+ export type PHDocumentMeta = {
6
+ /** The preferred editor for the document. */
7
+ preferredEditor?: string;
8
+ };
9
+ /**
10
+ * The header of a document.
11
+ */
12
+ export type PHDocumentHeader = {
13
+ /**
14
+ * The id of the document.
15
+ *
16
+ * This is a Ed25519 signature and is immutable.
17
+ **/
18
+ id: string;
19
+ /**
20
+ * Information to verify the document creator.
21
+ *
22
+ * This is immutable.
23
+ **/
24
+ sig: PHDocumentSignatureInfo;
25
+ /**
26
+ * The type of the document.
27
+ *
28
+ * This is used as part of the signature payload and thus, cannot be changed
29
+ * after the document header has been created.
30
+ **/
31
+ documentType: string;
32
+ /**
33
+ * The timestamp of the creation date of the document, in UTC ISO format.
34
+ *
35
+ * This is used as part of the signature payload and thus, cannot be changed
36
+ * after the document header has been created.
37
+ **/
38
+ createdAtUtcIso: string;
39
+ /** The slug of the document. */
40
+ slug: string;
41
+ /** The name of the document. */
42
+ name: string;
43
+ /** The branch of this document. */
44
+ branch: string;
45
+ /**
46
+ * The revision of each scope of the document. This object is updated every
47
+ * time any _other_ scope is updated.
48
+ */
49
+ revision: {
50
+ [scope: string]: number;
51
+ };
52
+ /**
53
+ * The timestamp of the last change in the document, in UTC ISO format.
54
+ **/
55
+ lastModifiedAtUtcIso: string;
56
+ /**
57
+ * This is a map from protocol name to version. A protocol can be any set of
58
+ * rules that are applied to the document.
59
+ *
60
+ * Examples of protocols include:
61
+ *
62
+ * - "base-reducer"
63
+ */
64
+ protocolVersions?: {
65
+ [key: string]: number;
66
+ };
67
+ /** Meta information about the document. */
68
+ meta?: PHDocumentMeta;
69
+ };
70
+ /**
71
+ * The base type of a document model.
72
+ *
73
+ * @remarks
74
+ * This type is extended by all Document models.
75
+ *
76
+ * @typeParam TState - The type of the document state.
77
+ */
78
+ export type PHDocument<TState extends PHBaseState = PHBaseState> = {
79
+ /** The header of the document. */
80
+ header: PHDocumentHeader;
81
+ /** The document model specific state. */
82
+ state: TState;
83
+ /**
84
+ * The initial state of the document, enabling replaying operations.
85
+ *
86
+ * This will be removed in a future release.
87
+ */
88
+ initialState: TState;
89
+ /**
90
+ * The operations history of the document.
91
+ *
92
+ * This will be removed in a future release.
93
+ */
94
+ operations: DocumentOperations;
95
+ /**
96
+ * A list of undone operations
97
+ *
98
+ * This will be removed in a future release.
99
+ */
100
+ clipboard: Operation[];
101
+ };
102
+ //# sourceMappingURL=documents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../../document-model/core/documents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,2CAA2C;AAC3C,MAAM,MAAM,cAAc,GAAG;IAC3B,6CAA6C;IAC7C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;QAII;IACJ,EAAE,EAAE,MAAM,CAAC;IAEX;;;;QAII;IACJ,GAAG,EAAE,uBAAuB,CAAC;IAE7B;;;;;QAKI;IACJ,YAAY,EAAE,MAAM,CAAC;IAErB;;;;;QAKI;IACJ,eAAe,EAAE,MAAM,CAAC;IAExB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IAEb,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IAEb,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,QAAQ,EAAE;QACR,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;KACzB,CAAC;IAEF;;QAEI;IACJ,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAE7C,2CAA2C;IAC3C,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,CAAC,MAAM,SAAS,WAAW,GAAG,WAAW,IAAI;IACjE,kCAAkC;IAClC,MAAM,EAAE,gBAAgB,CAAC;IAEzB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,UAAU,EAAE,kBAAkB,CAAC;IAE/B;;;;OAIG;IACH,SAAS,EAAE,SAAS,EAAE,CAAC;CACxB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=documents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.js","sourceRoot":"","sources":["../../../document-model/core/documents.ts"],"names":[],"mappings":""}
@@ -0,0 +1,74 @@
1
+ import type { Action } from "./actions.js";
2
+ /**
3
+ * An operation that was applied to a {@link BaseDocument}.
4
+ *
5
+ * @remarks
6
+ * Wraps an action with an index, to be added to the operations history of a Document.
7
+ * The `index` field is used to keep all operations in order and enable replaying the
8
+ * document's history from the beginning. Note that indices and skips are relative to
9
+ * a specific reactor. Example below:
10
+ *
11
+ * For (index, skip, ts, action)
12
+ * A - [(0, 0, 1, "A0"), (1, 0, 2, "A1")]
13
+ * B - [(0, 0, 0, "B0"), (1, 0, 3, "B1")]
14
+ * ...
15
+ * B gets A's Operations Scenario:
16
+ * B' - [(0, 0, 0, "B0"), (1, 0, 3, "B1"), (2, 1, 1, "A0"), (3, 0, 2, "A1"), (4, 0, 3, "B1")]
17
+ * Then A needs to end up with:
18
+ * A' - [(0, 0, 1, "A0"), (1, 0, 2, "A1"), (2, 2, 0, "B0"), (3, 0, 1, "A0"), (4, 0, 2, "A1"), (5, 0, 3, "B1")]
19
+ * So that both A and B end up with the stream of actions (action):
20
+ * [("B0"), ("A0"), ("A1"), ("B1")]
21
+ *
22
+ * @typeParam A - The type of the action.
23
+ */
24
+ export type Operation = {
25
+ /**
26
+ * This is a stable id, derived from various document and action properties
27
+ * in deriveOperationId().
28
+ *
29
+ * It _cannot_ be an arbitrary string.
30
+ *
31
+ * It it also not unique per operation, as reshuffled operations will keep'
32
+ * the same id they had before they were reshuffled. This means that the
33
+ * IOperationStore may have multiple operations with the same operation id.
34
+ **/
35
+ id: string;
36
+ /** Position of the operation in the history. This is relative to a specific reactor -- they may not all agree on this value. */
37
+ index: number;
38
+ /** The number of operations skipped with this Operation. This is relative to a specific reactor -- they may not all agree on this value. */
39
+ skip: number;
40
+ /** Timestamp of when the operation was added */
41
+ timestampUtcMs: string;
42
+ /** Hash of the resulting document data after the operation */
43
+ hash: string;
44
+ /** Error message for a failed action */
45
+ error?: string;
46
+ /** The resulting state after the operation */
47
+ resultingState?: string;
48
+ /**
49
+ * The action that was applied to the document to produce this operation.
50
+ */
51
+ action: Action;
52
+ };
53
+ /**
54
+ * The operations history of the document by scope.
55
+ *
56
+ * This will be removed in a future release.
57
+ *
58
+ * TODO: Type should be Partial<Record<string, Operation[]>>,
59
+ * but that is a breaking change for codegen + external doc models.
60
+ */
61
+ export type DocumentOperations = Record<string, Operation[]>;
62
+ export type OperationContext = {
63
+ documentId: string;
64
+ documentType: string;
65
+ scope: string;
66
+ branch: string;
67
+ resultingState?: string;
68
+ ordinal: number;
69
+ };
70
+ export type OperationWithContext = {
71
+ operation: Operation;
72
+ context: OperationContext;
73
+ };
74
+ //# sourceMappingURL=operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../../document-model/core/operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB;;;;;;;;;QASI;IACJ,EAAE,EAAE,MAAM,CAAC;IAEX,gIAAgI;IAChI,KAAK,EAAE,MAAM,CAAC;IAEd,4IAA4I;IAC5I,IAAI,EAAE,MAAM,CAAC;IAEb,gDAAgD;IAChD,cAAc,EAAE,MAAM,CAAC;IAEvB,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IAEb,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;AAE7D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IAGxB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,gBAAgB,CAAC;CAC3B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../../document-model/core/operations.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export type * from "./actions.js";
2
+ export type * from "./documents.js";
3
+ export type * from "./operations.js";
4
+ export type * from "./signatures.js";
5
+ export type * from "./state.js";
6
+ export type * from "./upgrades.js";
7
+ //# sourceMappingURL=ph-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ph-types.d.ts","sourceRoot":"","sources":["../../../document-model/core/ph-types.ts"],"names":[],"mappings":"AAOA,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ph-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ph-types.js","sourceRoot":"","sources":["../../../document-model/core/ph-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * A signature of an action.
3
+ *
4
+ * This will be refactored in a future release.
5
+ */
6
+ export type Signature = [string, string, string, string, string];
7
+ /**
8
+ * A user action signer.
9
+ */
10
+ export type UserActionSigner = {
11
+ address: string;
12
+ networkId: string;
13
+ chainId: number;
14
+ };
15
+ /**
16
+ * An app action signer.
17
+ */
18
+ export type AppActionSigner = {
19
+ name: string;
20
+ key: string;
21
+ };
22
+ /**
23
+ * An action signer.
24
+ */
25
+ export type ActionSigner = {
26
+ user: UserActionSigner;
27
+ app: AppActionSigner;
28
+ signatures: Signature[];
29
+ };
30
+ /**
31
+ * Information to verify the document creator.
32
+ */
33
+ export type PHDocumentSignatureInfo = {
34
+ /**
35
+ * The public key of the document creator.
36
+ **/
37
+ publicKey: JsonWebKey;
38
+ /** The nonce that was appended to the message to create the signature. */
39
+ nonce: string;
40
+ };
41
+ /**
42
+ * Configuration for hashing document state in operations.
43
+ */
44
+ export type HashConfig = {
45
+ /** The hashing algorithm to use (e.g., "sha1", "sha256") */
46
+ algorithm: string;
47
+ /** The encoding format for the hash output (e.g., "base64", "hex") */
48
+ encoding: string;
49
+ /** Optional algorithm-specific parameters */
50
+ params?: Record<string, unknown>;
51
+ };
52
+ //# sourceMappingURL=signatures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signatures.d.ts","sourceRoot":"","sources":["../../../document-model/core/signatures.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,gBAAgB,CAAC;IACvB,GAAG,EAAE,eAAe,CAAC;IACrB,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;QAEI;IACJ,SAAS,EAAE,UAAU,CAAC;IAEtB,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;IAElB,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;IAEjB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=signatures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signatures.js","sourceRoot":"","sources":["../../../document-model/core/signatures.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ import type { HashConfig } from "./signatures.js";
2
+ /**
3
+ * The document state of the document.
4
+ */
5
+ export type PHDocumentState = {
6
+ /**
7
+ * The current document model schema version of the document. This is used
8
+ * with the UPGRADE_DOCUMENT operation to specify the DocumentModelModule
9
+ * version to use for reducer execution.
10
+ */
11
+ version: number;
12
+ /** Hash configuration for operation state verification */
13
+ hash: HashConfig;
14
+ /** True if and only if the document has been deleted */
15
+ isDeleted?: boolean;
16
+ /** The timestamp when the document was deleted, in UTC ISO format */
17
+ deletedAtUtcIso?: string;
18
+ /** Optional: who deleted the document */
19
+ deletedBy?: string;
20
+ /** Optional: reason for deletion */
21
+ deletionReason?: string;
22
+ };
23
+ /**
24
+ * The authentication state of the document.
25
+ *
26
+ * This has yet to be implemented.
27
+ */
28
+ export type PHAuthState = {};
29
+ /**
30
+ * The base state of the document.
31
+ */
32
+ export type PHBaseState = {
33
+ /** Carries authentication information. */
34
+ auth: PHAuthState;
35
+ /** Carries information about the document. */
36
+ document: PHDocumentState;
37
+ };
38
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../document-model/core/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB,0DAA0D;IAC1D,IAAI,EAAE,UAAU,CAAC;IAEjB,wDAAwD;IACxD,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,oCAAoC;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,EAAE,CAAC;AAE7B;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,0CAA0C;IAC1C,IAAI,EAAE,WAAW,CAAC;IAElB,8CAA8C;IAC9C,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../document-model/core/state.ts"],"names":[],"mappings":""}