@rightkit/social-ui 0.0.0-stage → 0.1.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 (124) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE-APACHE +201 -0
  3. package/LICENSE-MIT +21 -0
  4. package/README.md +40 -2
  5. package/dist/appName.d.ts +2 -0
  6. package/dist/appName.js +8 -0
  7. package/dist/components/ScopeSelect.d.ts +7 -0
  8. package/dist/components/ScopeSelect.js +6 -0
  9. package/dist/components/Shared.d.ts +34 -0
  10. package/dist/components/Shared.js +55 -0
  11. package/dist/data/derive.d.ts +21 -0
  12. package/dist/data/derive.js +47 -0
  13. package/dist/data/draftRules.d.ts +10 -0
  14. package/dist/data/draftRules.js +20 -0
  15. package/dist/data/engine/engineDataSource.d.ts +194 -0
  16. package/dist/data/engine/engineDataSource.js +836 -0
  17. package/dist/data/engine/errors.d.ts +13 -0
  18. package/dist/data/engine/errors.js +21 -0
  19. package/dist/data/engine/mapping.d.ts +172 -0
  20. package/dist/data/engine/mapping.js +1487 -0
  21. package/dist/data/engine/protocol.d.ts +910 -0
  22. package/dist/data/engine/protocol.js +67 -0
  23. package/dist/data/index.d.ts +18 -0
  24. package/dist/data/index.js +23 -0
  25. package/dist/data/mock/devSource.d.ts +7 -0
  26. package/dist/data/mock/devSource.js +10 -0
  27. package/dist/data/mock/fixtures-analytics.d.ts +7 -0
  28. package/dist/data/mock/fixtures-analytics.js +123 -0
  29. package/dist/data/mock/fixtures-briefs.d.ts +4 -0
  30. package/dist/data/mock/fixtures-briefs.js +230 -0
  31. package/dist/data/mock/fixtures-content.d.ts +4 -0
  32. package/dist/data/mock/fixtures-content.js +89 -0
  33. package/dist/data/mock/fixtures-digests.d.ts +3 -0
  34. package/dist/data/mock/fixtures-digests.js +40 -0
  35. package/dist/data/mock/fixtures-drafts.d.ts +2 -0
  36. package/dist/data/mock/fixtures-drafts.js +74 -0
  37. package/dist/data/mock/fixtures-gate.d.ts +3 -0
  38. package/dist/data/mock/fixtures-gate.js +49 -0
  39. package/dist/data/mock/fixtures-hooks.d.ts +2 -0
  40. package/dist/data/mock/fixtures-hooks.js +103 -0
  41. package/dist/data/mock/fixtures-inbox.d.ts +11 -0
  42. package/dist/data/mock/fixtures-inbox.js +213 -0
  43. package/dist/data/mock/fixtures-links.d.ts +5 -0
  44. package/dist/data/mock/fixtures-links.js +89 -0
  45. package/dist/data/mock/fixtures-memory.d.ts +3 -0
  46. package/dist/data/mock/fixtures-memory.js +148 -0
  47. package/dist/data/mock/fixtures-ops.d.ts +15 -0
  48. package/dist/data/mock/fixtures-ops.js +403 -0
  49. package/dist/data/mock/fixtures-optimise.d.ts +18 -0
  50. package/dist/data/mock/fixtures-optimise.js +221 -0
  51. package/dist/data/mock/fixtures-pacing.d.ts +5 -0
  52. package/dist/data/mock/fixtures-pacing.js +285 -0
  53. package/dist/data/mock/fixtures-publish.d.ts +2 -0
  54. package/dist/data/mock/fixtures-publish.js +129 -0
  55. package/dist/data/mock/fixtures-store.d.ts +10 -0
  56. package/dist/data/mock/fixtures-store.js +13 -0
  57. package/dist/data/mock/fixtures-variants.d.ts +5 -0
  58. package/dist/data/mock/fixtures-variants.js +138 -0
  59. package/dist/data/mock/fixtures.d.ts +6 -0
  60. package/dist/data/mock/fixtures.js +420 -0
  61. package/dist/data/mock/mockDataSource.d.ts +98 -0
  62. package/dist/data/mock/mockDataSource.js +903 -0
  63. package/dist/data/money.d.ts +14 -0
  64. package/dist/data/money.js +36 -0
  65. package/dist/data/platforms.d.ts +12 -0
  66. package/dist/data/platforms.js +26 -0
  67. package/dist/data/source.d.ts +196 -0
  68. package/dist/data/source.js +1 -0
  69. package/dist/data/time.d.ts +23 -0
  70. package/dist/data/time.js +86 -0
  71. package/dist/data/types.d.ts +1092 -0
  72. package/dist/data/types.js +3 -0
  73. package/dist/env.d.ts +59 -0
  74. package/dist/hooks/useAsync.d.ts +19 -0
  75. package/dist/hooks/useAsync.js +25 -0
  76. package/dist/index.d.ts +56 -0
  77. package/dist/index.js +58 -0
  78. package/dist/lib/host.d.ts +21 -0
  79. package/dist/lib/host.js +32 -0
  80. package/dist/lib/shell.d.ts +156 -0
  81. package/dist/lib/shell.js +16 -0
  82. package/dist/screens/AccountsScreen.d.ts +8 -0
  83. package/dist/screens/AccountsScreen.js +100 -0
  84. package/dist/screens/AnalyticsScreen.d.ts +7 -0
  85. package/dist/screens/AnalyticsScreen.js +64 -0
  86. package/dist/screens/ApprovalsScreen.d.ts +10 -0
  87. package/dist/screens/ApprovalsScreen.js +144 -0
  88. package/dist/screens/BriefsScreen.d.ts +7 -0
  89. package/dist/screens/BriefsScreen.js +83 -0
  90. package/dist/screens/CalendarScreen.d.ts +10 -0
  91. package/dist/screens/CalendarScreen.js +143 -0
  92. package/dist/screens/CampaignsScreen.d.ts +7 -0
  93. package/dist/screens/CampaignsScreen.js +52 -0
  94. package/dist/screens/ChannelMemoryScreen.d.ts +7 -0
  95. package/dist/screens/ChannelMemoryScreen.js +109 -0
  96. package/dist/screens/ContentScreen.d.ts +7 -0
  97. package/dist/screens/ContentScreen.js +64 -0
  98. package/dist/screens/DigestsScreen.d.ts +7 -0
  99. package/dist/screens/DigestsScreen.js +53 -0
  100. package/dist/screens/DraftsScreen.d.ts +10 -0
  101. package/dist/screens/DraftsScreen.js +108 -0
  102. package/dist/screens/FailuresScreen.d.ts +8 -0
  103. package/dist/screens/FailuresScreen.js +111 -0
  104. package/dist/screens/HookTestsScreen.d.ts +7 -0
  105. package/dist/screens/HookTestsScreen.js +54 -0
  106. package/dist/screens/InboxScreen.d.ts +12 -0
  107. package/dist/screens/InboxScreen.js +76 -0
  108. package/dist/screens/LinksScreen.d.ts +7 -0
  109. package/dist/screens/LinksScreen.js +52 -0
  110. package/dist/screens/PacingScreen.d.ts +7 -0
  111. package/dist/screens/PacingScreen.js +88 -0
  112. package/dist/screens/PublishJobsScreen.d.ts +7 -0
  113. package/dist/screens/PublishJobsScreen.js +66 -0
  114. package/dist/screens/SuggestionsScreen.d.ts +8 -0
  115. package/dist/screens/SuggestionsScreen.js +94 -0
  116. package/dist/screens/TextGateScreen.d.ts +7 -0
  117. package/dist/screens/TextGateScreen.js +111 -0
  118. package/dist/screens/ThreadsScreen.d.ts +8 -0
  119. package/dist/screens/ThreadsScreen.js +113 -0
  120. package/dist/screens/TypedBriefsScreen.d.ts +7 -0
  121. package/dist/screens/TypedBriefsScreen.js +75 -0
  122. package/dist/screens/labels.d.ts +121 -0
  123. package/dist/screens/labels.js +272 -0
  124. package/package.json +56 -3
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A read the engine cannot answer yet, because the method or the field does not exist in the engine.
3
+ * Screens show their load error state for it. The message is kept for logs and tests.
4
+ */
5
+ export declare class EngineUnavailableError extends Error {
6
+ readonly code: "engine_unavailable";
7
+ constructor(message: string);
8
+ }
9
+ /** A read the engine answered with an error, or an engine reply the desktop cannot map. */
10
+ export declare class EngineReadError extends Error {
11
+ readonly code: string;
12
+ constructor(code: string, message: string);
13
+ }
@@ -0,0 +1,21 @@
1
+ // Errors the engine data source throws from reads. Writes never throw: they return a Result.
2
+ /**
3
+ * A read the engine cannot answer yet, because the method or the field does not exist in the engine.
4
+ * Screens show their load error state for it. The message is kept for logs and tests.
5
+ */
6
+ export class EngineUnavailableError extends Error {
7
+ code = "engine_unavailable";
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = "EngineUnavailableError";
11
+ }
12
+ }
13
+ /** A read the engine answered with an error, or an engine reply the desktop cannot map. */
14
+ export class EngineReadError extends Error {
15
+ code;
16
+ constructor(code, message) {
17
+ super(message);
18
+ this.name = "EngineReadError";
19
+ this.code = code;
20
+ }
21
+ }
@@ -0,0 +1,172 @@
1
+ import type { Account, FailureItem, ManualDraft, PublishJob, PublishProgress, PublishJobRecord, RejectReason, HeartbeatStatus, RestoreReceiptList, InboxEvent, InboxRaw, InboxStats, PublishNextView, PublishQuota, UnreadableRow } from "../types.js";
2
+ import type { OptimiseProposal, SpendAllowance, SpendPrice, SpendReport } from "../types.js";
3
+ import type { Campaign, CampaignAttribution, ChannelLink, HookTestSet, TrackedLink, ContentDetail, ContentExperimentSummary, ContentRecord, ContentVariant, DigestApplication, ResearchDigest, BriefSummary, DeliveryEnvelope, DispatchAttempt, GateCheck, GatePolicy, GateRecord, JsonValue, OutgoingBrief, OutgoingBriefDetail, ChannelMemoryDetail, ChannelMemoryRevision, ProofRecord, BriefVariant, TypedBrief, AnalyticsObservation, AnalyticsPost, MetricImport } from "../types.js";
4
+ import { EngineReadError } from "./errors.js";
5
+ import type { EngineAccount, EngineCampaign, EngineDraft, EngineEntry, EngineHookTestSet, EngineLinkAttribution, EngineOptimiseProposal, EnginePublishJob, EngineInboxEvent, EngineInboxGet, EngineInboxStats, EnginePublishNext, EnginePublishQuota, EngineScope, EngineSpendAllowance, EngineSpendPrice, EngineSpendReport, EngineTrackedLink, EngineDigestApplication, EngineDigestRecord, EngineContentExperimentSummary, EngineContentGet, EngineContentRecord, EngineContentVariant, EngineGatePolicy, EngineGateCheck, EngineGateRecord, EngineBriefOut, EngineDeliveryRecord, EngineDispatchAttempt, EngineMemoryGet, EngineMemoryRevisionRow, EngineProofRow, EngineBriefVariant, EngineTypedBrief, EngineAnalyticsObservation, EngineAnalyticsSummary, EngineMetricImportRecord, EngineHeartbeatStatus, EngineRestoreReceiptList } from "./protocol.js";
6
+ /** The desktop's account key: the engine scope (venture, channel, account). */
7
+ export declare function accountKey(scope: EngineScope): string;
8
+ /** The desktop's job id: the account key plus the engine entry id. */
9
+ export declare function jobKey(scope: EngineScope, entryId: string): string;
10
+ /** Reverses jobKey. Null when the id is not one this data source issued. */
11
+ export declare function parseJobKey(id: string): {
12
+ scope: EngineScope;
13
+ entryId: string;
14
+ } | null;
15
+ /**
16
+ * The desktop's account id: the engine scope plus the platform. The engine keys an account by scope
17
+ * and platform. Jobs carry only the scope (`accountKey`), so a job does not name one of its
18
+ * channel's accounts (see "Engine gaps" in the design doc).
19
+ */
20
+ export declare function accountId(scope: EngineScope, platform: string): string;
21
+ /** Reverses accountId. Null when the id is not one this data source issued. */
22
+ export declare function parseAccountId(id: string): {
23
+ scope: EngineScope;
24
+ platform: string;
25
+ } | null;
26
+ /** The desktop's draft id: the engine scope plus the engine draft id. */
27
+ export declare function draftKey(scope: EngineScope, draftId: string): string;
28
+ /** Reverses draftKey. Null when the id is not one this data source issued. */
29
+ export declare function parseDraftKey(id: string): {
30
+ scope: EngineScope;
31
+ draftId: string;
32
+ } | null;
33
+ /** An engine draft as the desktop's ManualDraft. A state or kind the desktop does not show is an engine_mapping error. */
34
+ export declare function draftOf(engine: EngineDraft): ManualDraft;
35
+ /** The engine's instant form: YYYY-MM-DDTHH:MM:SSZ (no milliseconds). */
36
+ export declare function engineInstant(iso: string): string;
37
+ /**
38
+ * FNV-1a over the caption's UTF-16 code units. The engine stores no caption digest, so this is a
39
+ * display fingerprint computed here. It is not the daemon's SHA-256 and cannot be compared with it.
40
+ */
41
+ export declare function captionFingerprint(caption: string): string;
42
+ export declare function encodeRejection(code: RejectReason, note: string): string;
43
+ export declare function parseRejection(text: string): {
44
+ reason: RejectReason;
45
+ note: string | null;
46
+ };
47
+ /**
48
+ * One engine entry as the operator's PublishJob. Fields the engine does not hold are set as the
49
+ * design doc's "Engine gaps" section records: null or empty means "not reported", not "none".
50
+ */
51
+ export declare function entryToJob(entry: EngineEntry): PublishJob;
52
+ /**
53
+ * An engine account the desktop cannot map yet: its platform, or a state it does not show. It is
54
+ * kept with its typed error so the list is not silently shorter than the engine's.
55
+ */
56
+ export interface UnmappedAccount {
57
+ /** The desktop account id the account would have had (accountId). */
58
+ id: string;
59
+ platform: string;
60
+ error: EngineReadError;
61
+ }
62
+ /**
63
+ * One engine account as the operator's Account. `nowUtc` is the caller's clock (the data source
64
+ * passes its own); this function reads no clock. A cooldown reads as active only while it is after
65
+ * `nowUtc`.
66
+ */
67
+ export declare function accountOf(engine: EngineAccount, nowUtc: string): Account;
68
+ /** One engine publish job as the desktop's progress view. Throws on a state the desktop does not show. */
69
+ export declare function publishProgressOf(engine: EnginePublishJob): PublishProgress;
70
+ /**
71
+ * The publish job for one calendar entry at its current revision, or null when there is none. A job
72
+ * for an older revision is not shown: the entry changed after that job was approved.
73
+ */
74
+ export declare function publishProgressFor(jobs: readonly EnginePublishJob[], entry: EngineEntry): PublishProgress | null;
75
+ /**
76
+ * A failure row for a publish job that needs the operator: failed, outcome_unknown, or cancelled with
77
+ * a reason. Queued, running, waiting and published jobs need no failure row (null).
78
+ */
79
+ export declare function publishFailureOf(engine: EnginePublishJob): FailureItem | null;
80
+ /** One engine publish job as the desktop's read-only row. publishProgressOf refuses a state the desktop does not show. */
81
+ export declare function publishJobRecordOf(engine: EnginePublishJob): PublishJobRecord;
82
+ /** The scope a suggestion or spend id names. Null when the id is not one this data source issued. */
83
+ export declare function parseScopeKey(id: string): EngineScope | null;
84
+ /** One optimise proposal as the desktop's OptimiseProposal. Only the remake rule and the three states are shown. */
85
+ export declare function proposalOf(engine: EngineOptimiseProposal): OptimiseProposal;
86
+ export declare function allowanceOf(engine: EngineSpendAllowance): SpendAllowance;
87
+ export declare function spendReportOf(engine: EngineSpendReport): SpendReport;
88
+ export declare function priceOf(engine: EngineSpendPrice): SpendPrice;
89
+ /** One engine campaign as the desktop's Campaign. */
90
+ export declare function campaignOf(engine: EngineCampaign): Campaign;
91
+ /** One engine tracked link as the desktop's TrackedLink. The UTM parts and final URL are shown as stored. */
92
+ export declare function linkOf(engine: EngineTrackedLink): TrackedLink;
93
+ /**
94
+ * The visit counts of one campaign. The engine's total must equal the sum of its rows; a mismatch is
95
+ * refused, not shown.
96
+ */
97
+ export declare function attributionOf(engine: EngineLinkAttribution): CampaignAttribution;
98
+ /**
99
+ * The links of one campaign, each with the campaign's name and its count from the attribution reply of the same
100
+ * campaign. A link the attribution reply does not list has no count (null), never a zero.
101
+ */
102
+ export declare function channelLinksOf(campaignName: string, links: readonly EngineTrackedLink[], attribution: EngineLinkAttribution): ChannelLink[];
103
+ /**
104
+ * One engine hook test set as the desktop's HookTestSet. A decided set must name its winner and its
105
+ * decision instant; a set missing either is a mapping error.
106
+ */
107
+ export declare function hookTestOf(engine: EngineHookTestSet): HookTestSet;
108
+ /** One stored digest as the desktop's ResearchDigest. The id is the engine's digest id, within its scope. */
109
+ export declare function digestOf(engine: EngineDigestRecord): ResearchDigest;
110
+ /** One applied digest entry as the desktop's DigestApplication. The entry's scope comes from the digest.applied reply. */
111
+ export declare function digestApplicationOf(engine: EngineDigestApplication, scope: EngineScope): DigestApplication;
112
+ /** One stored content record as the desktop's ContentRecord. The state is the engine's derived state. */
113
+ export declare function contentRecordOf(engine: EngineContentRecord): ContentRecord;
114
+ /** One content variant as the desktop's ContentVariant. */
115
+ export declare function contentVariantOf(engine: EngineContentVariant): ContentVariant;
116
+ /** The record and variants of one content.get reply, as the desktop's ContentDetail. */
117
+ export declare function contentDetailOf(engine: EngineContentGet): ContentDetail;
118
+ /** The variant comparison of one content.experiment_summary reply. The verdict is checked, never reworded. */
119
+ export declare function experimentSummaryOf(engine: EngineContentExperimentSummary): ContentExperimentSummary;
120
+ /** The latest policy revision as the desktop's GatePolicy. */
121
+ export declare function gatePolicyOf(engine: EngineGatePolicy): GatePolicy;
122
+ /** One gate.check reply as the desktop's GateCheck. The desktop never asks the engine to record, so nothing is stored. */
123
+ export declare function gateCheckOf(engine: EngineGateCheck): GateCheck;
124
+ /** One stored verdict record. The scope is the one the read was made in, because the record carries none. */
125
+ export declare function gateRecordOf(engine: EngineGateRecord, scopeId: string): GateRecord;
126
+ /** The fields of a brief document the desktop shows. Anything the document lacks stays null or empty. */
127
+ export declare function briefSummaryOf(document: JsonValue): BriefSummary;
128
+ /** One outgoing brief as the list shows it. The document is left out of the list. */
129
+ export declare function briefOf(engine: EngineBriefOut): OutgoingBrief;
130
+ /** One outgoing brief with its summary and the document as stored. */
131
+ export declare function briefDetailOf(engine: EngineBriefOut): OutgoingBriefDetail;
132
+ /** One accepted delivery envelope as the desktop's DeliveryEnvelope. */
133
+ export declare function deliveryOf(engine: EngineDeliveryRecord): DeliveryEnvelope;
134
+ /** One dispatch attempt. The message and stderr tail are read from the engine's detail object when present. */
135
+ export declare function dispatchAttemptOf(engine: EngineDispatchAttempt, scopeId: string): DispatchAttempt;
136
+ /** One stored memory revision without its document. The scope is the one the read was made in. */
137
+ export declare function memoryRevisionOf(engine: EngineMemoryRevisionRow, scopeId: string): ChannelMemoryRevision;
138
+ /** The latest memory revision with its document. A document that is not a JSON object is a mapping error. */
139
+ export declare function memoryDetailOf(engine: EngineMemoryGet): ChannelMemoryDetail;
140
+ /** One proof row. The value is kept as the exact decimal text the engine sent; it is never parsed. */
141
+ export declare function proofOf(engine: EngineProofRow): ProofRecord;
142
+ /** One stored typed brief as the desktop's TypedBrief. An explainer with no beats is a mapping error. */
143
+ export declare function typedBriefOf(engine: EngineTypedBrief): TypedBrief;
144
+ /** One platform variant as the desktop's BriefVariant. The link is kept as given; no slot is re-derived. */
145
+ export declare function briefVariantOf(engine: EngineBriefVariant): BriefVariant;
146
+ /**
147
+ * The published posts of one scope, from analytics.summary. The summary names no source: a metric with an
148
+ * import id is a manual row, and one without is an API row.
149
+ */
150
+ export declare function analyticsPostsOf(engine: EngineAnalyticsSummary): AnalyticsPost[];
151
+ /** One stored observation, from analytics.list. The scope is the one the read was made in. */
152
+ export declare function analyticsObservationOf(engine: EngineAnalyticsObservation, scopeId: string): AnalyticsObservation;
153
+ /** One committed manual import. Only the manual_export source is shown; any other source is a mapping error. */
154
+ export declare function metricImportOf(engine: EngineMetricImportRecord): MetricImport;
155
+ /** The heartbeat status as the desktop's HeartbeatStatus: one record, no per-source list. */
156
+ export declare function heartbeatStatusOf(engine: EngineHeartbeatStatus): HeartbeatStatus;
157
+ /** The restore receipts as the desktop's RestoreReceiptList, newest first as the engine sends them. */
158
+ export declare function restoreReceiptListOf(engine: EngineRestoreReceiptList): RestoreReceiptList;
159
+ /** A value as pretty printed JSON text. Used for raw rows and raw event items. */
160
+ export declare function rawTextOf(value: unknown): string;
161
+ /** Maps one row. A row whose mapping throws is kept unread, with the reason and its raw JSON. It is never dropped. */
162
+ export declare function rowOf<T>(raw: unknown, map: () => T): T | UnreadableRow;
163
+ /** One inbox event. An unknown kind or state is a mapping error, so the row is kept unread (see rowOf). */
164
+ export declare function inboxEventOf(engine: EngineInboxEvent): InboxEvent;
165
+ /** The raw item JSON of one event, shown as text. */
166
+ export declare function inboxRawOf(engine: EngineInboxGet): InboxRaw;
167
+ /** The inbox counts as the engine stores them. Each group is kept, even one whose count cannot be read. */
168
+ export declare function inboxStatsOf(engine: EngineInboxStats): InboxStats;
169
+ /** publish.next as the desktop's view. Every row is kept: a row it cannot read is an UnreadableRow. */
170
+ export declare function publishNextOf(engine: EnginePublishNext): PublishNextView;
171
+ /** One account's pacing as stored. The limits are the stored ones, or the host app defaults when opted_in is false. */
172
+ export declare function publishQuotaOf(engine: EnginePublishQuota): PublishQuota;