@powerhousedao/contributor-billing 0.1.53 → 1.0.0-dev.10

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 (189) hide show
  1. package/dist/document-models/account-transactions/gen/schema/zod.d.ts.map +1 -1
  2. package/dist/document-models/account-transactions/gen/schema/zod.js +3 -3
  3. package/dist/document-models/account-transactions/module.d.ts +1 -1
  4. package/dist/document-models/account-transactions/module.d.ts.map +1 -1
  5. package/dist/document-models/account-transactions/module.js +1 -1
  6. package/dist/document-models/accounts/gen/schema/zod.d.ts.map +1 -1
  7. package/dist/document-models/accounts/module.d.ts +1 -1
  8. package/dist/document-models/accounts/module.d.ts.map +1 -1
  9. package/dist/document-models/accounts/module.js +1 -1
  10. package/dist/document-models/billing-statement/gen/schema/zod.d.ts.map +1 -1
  11. package/dist/document-models/billing-statement/gen/schema/zod.js +4 -4
  12. package/dist/document-models/billing-statement/module.d.ts +1 -1
  13. package/dist/document-models/billing-statement/module.d.ts.map +1 -1
  14. package/dist/document-models/billing-statement/module.js +1 -1
  15. package/dist/document-models/expense-report/gen/schema/zod.d.ts.map +1 -1
  16. package/dist/document-models/expense-report/gen/schema/zod.js +38 -18
  17. package/dist/document-models/expense-report/module.d.ts +1 -1
  18. package/dist/document-models/expense-report/module.d.ts.map +1 -1
  19. package/dist/document-models/expense-report/module.js +1 -1
  20. package/dist/document-models/invoice/gen/document-model.d.ts.map +1 -1
  21. package/dist/document-models/invoice/gen/document-model.js +150 -150
  22. package/dist/document-models/invoice/gen/schema/types.d.ts +3 -6
  23. package/dist/document-models/invoice/gen/schema/types.d.ts.map +1 -1
  24. package/dist/document-models/invoice/gen/schema/zod.d.ts +2 -8
  25. package/dist/document-models/invoice/gen/schema/zod.d.ts.map +1 -1
  26. package/dist/document-models/invoice/gen/schema/zod.js +14 -25
  27. package/dist/document-models/invoice/module.d.ts +1 -1
  28. package/dist/document-models/invoice/module.d.ts.map +1 -1
  29. package/dist/document-models/invoice/module.js +1 -1
  30. package/dist/document-models/invoice/src/reducers/general.d.ts.map +1 -1
  31. package/dist/document-models/invoice/src/reducers/general.js +8 -0
  32. package/dist/document-models/invoice/src/reducers/items.d.ts.map +1 -1
  33. package/dist/document-models/invoice/src/reducers/items.js +2 -1
  34. package/dist/document-models/invoice/src/reducers/parties.d.ts.map +1 -1
  35. package/dist/document-models/invoice/src/reducers/parties.js +6 -2
  36. package/dist/document-models/invoice/src/reducers/transitions.d.ts +0 -5
  37. package/dist/document-models/invoice/src/reducers/transitions.d.ts.map +1 -1
  38. package/dist/document-models/invoice/src/reducers/transitions.js +19 -6
  39. package/dist/document-models/invoice/tests/general.test.js +11 -2
  40. package/dist/document-models/invoice/tests/items.test.js +1 -1
  41. package/dist/document-models/invoice/tests/parties.test.js +1 -1
  42. package/dist/document-models/invoice/tests/transitions.test.js +7 -2
  43. package/dist/document-models/operational-hub-profile/module.d.ts +1 -1
  44. package/dist/document-models/operational-hub-profile/module.d.ts.map +1 -1
  45. package/dist/document-models/operational-hub-profile/module.js +1 -1
  46. package/dist/document-models/snapshot-report/gen/schema/zod.d.ts.map +1 -1
  47. package/dist/document-models/snapshot-report/gen/schema/zod.js +12 -12
  48. package/dist/document-models/snapshot-report/module.d.ts +1 -1
  49. package/dist/document-models/snapshot-report/module.d.ts.map +1 -1
  50. package/dist/document-models/snapshot-report/module.js +1 -1
  51. package/dist/editors/accounts-editor/editor.d.ts.map +1 -1
  52. package/dist/editors/accounts-editor/editor.js +2 -2
  53. package/dist/editors/builder-team-admin/components/DriveExplorer.d.ts.map +1 -1
  54. package/dist/editors/builder-team-admin/components/DriveExplorer.js +64 -4
  55. package/dist/editors/builder-team-admin/module.js +1 -1
  56. package/dist/editors/contributor-billing/components/DashboardHome.d.ts.map +1 -1
  57. package/dist/editors/contributor-billing/components/DashboardHome.js +2 -8
  58. package/dist/editors/contributor-billing/components/DocumentDropZone.d.ts.map +1 -1
  59. package/dist/editors/contributor-billing/components/DocumentDropZone.js +37 -8
  60. package/dist/editors/contributor-billing/components/DriveContents.d.ts.map +1 -1
  61. package/dist/editors/contributor-billing/components/DriveContents.js +4 -1
  62. package/dist/editors/contributor-billing/components/DriveExplorer.d.ts.map +1 -1
  63. package/dist/editors/contributor-billing/components/DriveExplorer.js +54 -3
  64. package/dist/editors/contributor-billing/components/FolderTree.d.ts.map +1 -1
  65. package/dist/editors/contributor-billing/components/FolderTree.js +6 -15
  66. package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts +2 -1
  67. package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +1 -1
  68. package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.js +41 -6
  69. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts +1 -1
  70. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +1 -1
  71. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.js +16 -1
  72. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableContainer.d.ts +3 -1
  73. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableContainer.d.ts.map +1 -1
  74. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableContainer.js +13 -11
  75. package/dist/editors/contributor-billing/components/MonthReportCard.d.ts +11 -4
  76. package/dist/editors/contributor-billing/components/MonthReportCard.d.ts.map +1 -1
  77. package/dist/editors/contributor-billing/components/MonthReportCard.js +55 -6
  78. package/dist/editors/contributor-billing/components/MonthlyReportsOverview.d.ts +1 -1
  79. package/dist/editors/contributor-billing/components/MonthlyReportsOverview.d.ts.map +1 -1
  80. package/dist/editors/contributor-billing/components/MonthlyReportsOverview.js +104 -7
  81. package/dist/editors/contributor-billing/components/ReportingView.d.ts +0 -3
  82. package/dist/editors/contributor-billing/components/ReportingView.d.ts.map +1 -1
  83. package/dist/editors/contributor-billing/components/ReportingView.js +65 -8
  84. package/dist/editors/contributor-billing/components/ToastRenderer.d.ts +2 -0
  85. package/dist/editors/contributor-billing/components/ToastRenderer.d.ts.map +1 -0
  86. package/dist/editors/contributor-billing/components/ToastRenderer.js +14 -0
  87. package/dist/editors/contributor-billing/components/cbToast.d.ts +16 -0
  88. package/dist/editors/contributor-billing/components/cbToast.d.ts.map +1 -0
  89. package/dist/editors/contributor-billing/components/cbToast.js +29 -0
  90. package/dist/editors/contributor-billing/hooks/useDocumentAutoPlacement.d.ts.map +1 -1
  91. package/dist/editors/contributor-billing/hooks/useDocumentAutoPlacement.js +42 -2
  92. package/dist/editors/contributor-billing/hooks/useMonthlyReports.d.ts +4 -0
  93. package/dist/editors/contributor-billing/hooks/useMonthlyReports.d.ts.map +1 -1
  94. package/dist/editors/contributor-billing/hooks/useMonthlyReports.js +4 -0
  95. package/dist/editors/contributor-billing/module.js +1 -1
  96. package/dist/editors/invoice/InvoicePDF.d.ts.map +1 -1
  97. package/dist/editors/invoice/InvoicePDF.js +12 -9
  98. package/dist/editors/invoice/editor.d.ts.map +1 -1
  99. package/dist/editors/invoice/editor.js +6 -10
  100. package/dist/editors/invoice/exportUBL.d.ts.map +1 -1
  101. package/dist/editors/invoice/exportUBL.js +1 -2
  102. package/dist/editors/invoice/ingestPDF.js +1 -1
  103. package/dist/editors/invoice/invoiceToGnosis.d.ts.map +1 -1
  104. package/dist/editors/invoice/invoiceToGnosis.js +25 -22
  105. package/dist/editors/invoice/invoiceToast.d.ts +4 -0
  106. package/dist/editors/invoice/invoiceToast.d.ts.map +1 -0
  107. package/dist/editors/invoice/invoiceToast.js +6 -0
  108. package/dist/editors/invoice/legalEntity/legalEntity.d.ts +2 -1
  109. package/dist/editors/invoice/legalEntity/legalEntity.d.ts.map +1 -1
  110. package/dist/editors/invoice/legalEntity/legalEntity.js +3 -14
  111. package/dist/editors/invoice/legalEntity/walletSection.d.ts +1 -0
  112. package/dist/editors/invoice/legalEntity/walletSection.d.ts.map +1 -1
  113. package/dist/editors/invoice/legalEntity/walletSection.js +2 -2
  114. package/dist/editors/invoice/lineItems.js +1 -1
  115. package/dist/editors/invoice/requestFinance.d.ts +3 -2
  116. package/dist/editors/invoice/requestFinance.d.ts.map +1 -1
  117. package/dist/editors/invoice/requestFinance.js +38 -42
  118. package/dist/editors/invoice/validation/validationHandler.d.ts +1 -1
  119. package/dist/editors/invoice/validation/validationHandler.d.ts.map +1 -1
  120. package/dist/editors/invoice/validation/validationHandler.js +15 -2
  121. package/dist/editors/invoice/validation/validationManager.d.ts +1 -1
  122. package/dist/editors/invoice/validation/validationManager.d.ts.map +1 -1
  123. package/dist/editors/invoice/validation/validationManager.js +2 -1
  124. package/dist/editors/invoice/validation/validationRules.d.ts +1 -0
  125. package/dist/editors/invoice/validation/validationRules.d.ts.map +1 -1
  126. package/dist/editors/invoice/validation/validationRules.js +26 -1
  127. package/dist/editors/snapshot-report-editor/components/DateRangePicker.d.ts +19 -0
  128. package/dist/editors/snapshot-report-editor/components/DateRangePicker.d.ts.map +1 -0
  129. package/dist/editors/snapshot-report-editor/components/DateRangePicker.js +66 -0
  130. package/dist/editors/snapshot-report-editor/editor.d.ts.map +1 -1
  131. package/dist/editors/snapshot-report-editor/editor.js +72 -48
  132. package/dist/scripts/download-all-drive-documents/download-drive-documents.d.ts +33 -0
  133. package/dist/scripts/download-all-drive-documents/download-drive-documents.d.ts.map +1 -0
  134. package/dist/scripts/download-all-drive-documents/download-drive-documents.js +583 -0
  135. package/dist/scripts/invoice/requestFinance.d.ts +18 -1
  136. package/dist/scripts/invoice/requestFinance.d.ts.map +1 -1
  137. package/dist/scripts/invoice/requestFinance.js +17 -5
  138. package/dist/scripts/upload-phd-documents/upload-phd-documents.d.ts +20 -0
  139. package/dist/scripts/upload-phd-documents/upload-phd-documents.d.ts.map +1 -0
  140. package/dist/scripts/upload-phd-documents/upload-phd-documents.js +313 -0
  141. package/dist/style.css +201 -106
  142. package/dist/subgraphs/budget-statements/resolvers.d.ts +38 -0
  143. package/dist/subgraphs/budget-statements/resolvers.d.ts.map +1 -1
  144. package/dist/subgraphs/budget-statements/resolvers.js +192 -62
  145. package/dist/subgraphs/budget-statements/resolvers.test.d.ts +2 -0
  146. package/dist/subgraphs/budget-statements/resolvers.test.d.ts.map +1 -0
  147. package/dist/subgraphs/budget-statements/resolvers.test.js +339 -0
  148. package/dist/subgraphs/budget-statements/schema.d.ts.map +1 -1
  149. package/dist/subgraphs/budget-statements/schema.js +8 -0
  150. package/dist/subgraphs/index.d.ts +0 -1
  151. package/dist/subgraphs/index.d.ts.map +1 -1
  152. package/dist/subgraphs/index.js +0 -1
  153. package/dist/subgraphs/invoice-addon/customResolvers.d.ts +70 -11
  154. package/dist/subgraphs/invoice-addon/customResolvers.d.ts.map +1 -1
  155. package/dist/subgraphs/invoice-addon/customResolvers.js +12 -27
  156. package/package.json +35 -28
  157. package/dist/document-models/invoice/src/tests/document-model.test.d.ts +0 -10
  158. package/dist/document-models/invoice/src/tests/document-model.test.d.ts.map +0 -1
  159. package/dist/document-models/invoice/src/tests/document-model.test.js +0 -104
  160. package/dist/document-models/invoice/src/tests/general.test.d.ts +0 -6
  161. package/dist/document-models/invoice/src/tests/general.test.d.ts.map +0 -1
  162. package/dist/document-models/invoice/src/tests/general.test.js +0 -49
  163. package/dist/document-models/invoice/src/tests/items.test.d.ts +0 -6
  164. package/dist/document-models/invoice/src/tests/items.test.d.ts.map +0 -1
  165. package/dist/document-models/invoice/src/tests/items.test.js +0 -59
  166. package/dist/document-models/invoice/src/tests/parties.test.d.ts +0 -6
  167. package/dist/document-models/invoice/src/tests/parties.test.d.ts.map +0 -1
  168. package/dist/document-models/invoice/src/tests/parties.test.js +0 -69
  169. package/dist/document-models/invoice/src/tests/transitions.test.d.ts +0 -6
  170. package/dist/document-models/invoice/src/tests/transitions.test.d.ts.map +0 -1
  171. package/dist/document-models/invoice/src/tests/transitions.test.js +0 -59
  172. package/dist/document-models/invoice/utils/statusTransitions.d.ts +0 -13
  173. package/dist/document-models/invoice/utils/statusTransitions.d.ts.map +0 -1
  174. package/dist/document-models/invoice/utils/statusTransitions.js +0 -13
  175. package/dist/editors/builder-team-admin/components/overview/SubscriptionsStats.d.ts +0 -15
  176. package/dist/editors/builder-team-admin/components/overview/SubscriptionsStats.d.ts.map +0 -1
  177. package/dist/editors/builder-team-admin/components/overview/SubscriptionsStats.js +0 -61
  178. package/dist/editors/contributor-billing/components/CreateHubProfileModal.d.ts +0 -12
  179. package/dist/editors/contributor-billing/components/CreateHubProfileModal.d.ts.map +0 -1
  180. package/dist/editors/contributor-billing/components/CreateHubProfileModal.js +0 -74
  181. package/dist/subgraphs/resources-services/index.d.ts +0 -11
  182. package/dist/subgraphs/resources-services/index.d.ts.map +0 -1
  183. package/dist/subgraphs/resources-services/index.js +0 -11
  184. package/dist/subgraphs/resources-services/resolvers.d.ts +0 -3
  185. package/dist/subgraphs/resources-services/resolvers.d.ts.map +0 -1
  186. package/dist/subgraphs/resources-services/resolvers.js +0 -462
  187. package/dist/subgraphs/resources-services/schema.d.ts +0 -3
  188. package/dist/subgraphs/resources-services/schema.d.ts.map +0 -1
  189. package/dist/subgraphs/resources-services/schema.js +0 -284
@@ -0,0 +1,66 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useEffect, useCallback } from "react";
3
+ function toDateOnly(value) {
4
+ return value.split("T")[0] || "";
5
+ }
6
+ function toStartOfDayISO(dateStr) {
7
+ const d = new Date(dateStr + "T00:00:00.000Z");
8
+ return isNaN(d.getTime()) ? "" : d.toISOString();
9
+ }
10
+ function toEndOfDayISO(dateStr) {
11
+ const d = new Date(dateStr + "T23:59:59.999Z");
12
+ return isNaN(d.getTime()) ? "" : d.toISOString();
13
+ }
14
+ /**
15
+ * Unified date range picker rendered as a single row with two date inputs
16
+ * joined visually. Enforces from <= to.
17
+ */
18
+ export function DateRangePicker({ fromDate, toDate, onChange, label, className, }) {
19
+ const [localFrom, setLocalFrom] = useState(() => toDateOnly(fromDate));
20
+ const [localTo, setLocalTo] = useState(() => toDateOnly(toDate));
21
+ useEffect(() => {
22
+ const extFrom = toDateOnly(fromDate);
23
+ if (extFrom && extFrom !== localFrom) {
24
+ setLocalFrom(extFrom);
25
+ }
26
+ }, [fromDate]);
27
+ useEffect(() => {
28
+ const extTo = toDateOnly(toDate);
29
+ if (extTo && extTo !== localTo) {
30
+ setLocalTo(extTo);
31
+ }
32
+ }, [toDate]);
33
+ const handleFromChange = useCallback((e) => {
34
+ const dateStr = e.target.value;
35
+ if (!dateStr)
36
+ return;
37
+ let effectiveTo = localTo;
38
+ if (effectiveTo && dateStr > effectiveTo) {
39
+ effectiveTo = dateStr;
40
+ setLocalTo(effectiveTo);
41
+ }
42
+ setLocalFrom(dateStr);
43
+ const fromISO = toStartOfDayISO(dateStr);
44
+ const toISO = toEndOfDayISO(effectiveTo || dateStr);
45
+ if (fromISO && toISO) {
46
+ onChange(fromISO, toISO);
47
+ }
48
+ }, [localTo, onChange]);
49
+ const handleToChange = useCallback((e) => {
50
+ const dateStr = e.target.value;
51
+ if (!dateStr)
52
+ return;
53
+ let effectiveFrom = localFrom;
54
+ if (effectiveFrom && dateStr < effectiveFrom) {
55
+ effectiveFrom = dateStr;
56
+ setLocalFrom(effectiveFrom);
57
+ }
58
+ setLocalTo(dateStr);
59
+ const fromISO = toStartOfDayISO(effectiveFrom || dateStr);
60
+ const toISO = toEndOfDayISO(dateStr);
61
+ if (fromISO && toISO) {
62
+ onChange(fromISO, toISO);
63
+ }
64
+ }, [localFrom, onChange]);
65
+ return (_jsxs("div", { className: className, children: [label && (_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: label })), _jsxs("div", { className: "inline-flex items-center border border-gray-300 rounded-md overflow-hidden focus-within:ring-2 focus-within:ring-blue-500 focus-within:border-blue-500", children: [_jsx("input", { type: "date", value: localFrom, onChange: handleFromChange, className: "px-3 py-2 text-sm border-none outline-none bg-white" }), _jsx("span", { className: "px-2 text-sm text-gray-400 bg-gray-50 self-stretch flex items-center border-x border-gray-300", children: "\u2192" }), _jsx("input", { type: "date", value: localTo, onChange: handleToChange, className: "px-3 py-2 text-sm border-none outline-none bg-white" })] })] }));
66
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/snapshot-report-editor/editor.tsx"],"names":[],"mappings":"AA2EA,MAAM,CAAC,OAAO,UAAU,MAAM,4CAuqC7B"}
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/snapshot-report-editor/editor.tsx"],"names":[],"mappings":"AAwEA,MAAM,CAAC,OAAO,UAAU,MAAM,4CAktC7B"}
@@ -1,10 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { generateId, setName } from "document-model";
3
- import { useState, useMemo, useEffect } from "react";
3
+ import { useState, useMemo, useEffect, useCallback } from "react";
4
4
  import { useDocumentsInSelectedDrive, useParentFolderForSelectedNode, setSelectedNode, dispatchActions, } from "@powerhousedao/reactor-browser";
5
5
  import { DocumentToolbar } from "@powerhousedao/design-system/connect";
6
- import { Button, Select, DatePicker, } from "@powerhousedao/document-engineering";
6
+ import { Button, Select } from "@powerhousedao/document-engineering";
7
7
  import { ChevronDown, ChevronUp, RefreshCw } from "lucide-react";
8
+ import { DateRangePicker } from "./components/DateRangePicker.js";
8
9
  import { useSelectedSnapshotReportDocument } from "../hooks/useSnapshotReportDocument.js";
9
10
  import { setReportConfig, addSnapshotAccount, addTransaction, setPeriodStart, setPeriodEnd, } from "../../document-models/snapshot-report/gen/creators.js";
10
11
  import { SetOwner } from "./components/SetOwner.js";
@@ -93,6 +94,63 @@ export default function Editor() {
93
94
  // Track if we're in editing mode
94
95
  const [isEditingPeriod, setIsEditingPeriod] = useState(!savedPeriod);
95
96
  const isPeriodChanged = selectedPeriod !== savedPeriod;
97
+ // Compute suggested start date from previous month's snapshot endDate
98
+ const suggestedStartDate = useMemo(() => {
99
+ if (!documentsInDrive || !reportPeriodStart)
100
+ return null;
101
+ const currentPeriodStart = new Date(reportPeriodStart);
102
+ if (isNaN(currentPeriodStart.getTime()))
103
+ return null;
104
+ // Find all other snapshot reports in the drive
105
+ const otherSnapshots = documentsInDrive.filter((doc) => doc.header.documentType === "powerhouse/snapshot-report" &&
106
+ doc.header.id !== document.header.id);
107
+ // Find the snapshot whose reportPeriodStart is closest before this one
108
+ let previousSnapshot = null;
109
+ let closestDistance = Infinity;
110
+ for (const snap of otherSnapshots) {
111
+ const state = snap.state;
112
+ const rps = state?.global?.reportPeriodStart;
113
+ if (!rps)
114
+ continue;
115
+ const rpDate = new Date(rps);
116
+ if (isNaN(rpDate.getTime()))
117
+ continue;
118
+ // Must be before current period
119
+ const diff = currentPeriodStart.getTime() - rpDate.getTime();
120
+ if (diff > 0 && diff < closestDistance) {
121
+ closestDistance = diff;
122
+ previousSnapshot = {
123
+ endDate: state?.global?.endDate || null,
124
+ reportPeriodStart: rps,
125
+ };
126
+ }
127
+ }
128
+ if (!previousSnapshot?.endDate)
129
+ return null;
130
+ const prevEnd = new Date(previousSnapshot.endDate);
131
+ if (isNaN(prevEnd.getTime()))
132
+ return null;
133
+ // Suggested start = previous endDate + 1 day
134
+ const suggested = new Date(prevEnd);
135
+ suggested.setUTCDate(suggested.getUTCDate() + 1);
136
+ suggested.setUTCHours(0, 0, 0, 0);
137
+ return suggested;
138
+ }, [documentsInDrive, reportPeriodStart, document.header.id]);
139
+ const handleSnapshotPeriodChange = useCallback((newFromDate, newToDate) => {
140
+ dispatch?.(setReportConfig({
141
+ startDate: newFromDate,
142
+ endDate: newToDate,
143
+ reportName: reportName || undefined,
144
+ accountsDocumentId: accountsDocumentId || undefined,
145
+ }));
146
+ }, [dispatch, reportName, accountsDocumentId]);
147
+ const handleApplySuggestedStartDate = useCallback(() => {
148
+ if (!suggestedStartDate)
149
+ return;
150
+ const fromISO = suggestedStartDate.toISOString();
151
+ const toISO = endDate || "";
152
+ handleSnapshotPeriodChange(fromISO, toISO);
153
+ }, [suggestedStartDate, endDate, handleSnapshotPeriodChange]);
96
154
  // Update selected period when document period changes externally
97
155
  useEffect(() => {
98
156
  if (savedPeriod && savedPeriod !== selectedPeriod) {
@@ -373,51 +431,6 @@ export default function Editor() {
373
431
  setIsAccountPickerOpen(false);
374
432
  setSelectedAccountIds(new Set());
375
433
  };
376
- // Handlers for the legacy startDate/endDate fields (DatePicker approach)
377
- const handleStartDateChange = (e) => {
378
- const dateValue = e.target.value;
379
- if (!dateValue)
380
- return;
381
- // DatePicker may return ISO string or date string - extract just the date part
382
- const dateString = dateValue.split("T")[0]; // Get YYYY-MM-DD part if ISO string
383
- if (!dateString)
384
- return;
385
- // Create date at start of day (00:00:00)
386
- const date = new Date(dateString + "T00:00:00.000Z");
387
- if (isNaN(date.getTime())) {
388
- console.error("Invalid date value:", dateValue);
389
- return;
390
- }
391
- const isoDateTime = date.toISOString();
392
- dispatch?.(setReportConfig({
393
- startDate: isoDateTime,
394
- endDate: endDate || undefined,
395
- reportName: reportName || undefined,
396
- accountsDocumentId: accountsDocumentId || undefined,
397
- }));
398
- };
399
- const handleEndDateChange = (e) => {
400
- const dateValue = e.target.value;
401
- if (!dateValue)
402
- return;
403
- // DatePicker may return ISO string or date string - extract just the date part
404
- const dateString = dateValue.split("T")[0]; // Get YYYY-MM-DD part if ISO string
405
- if (!dateString)
406
- return;
407
- // Create date at end of day (23:59:59.999)
408
- const endOfDay = new Date(dateString + "T23:59:59.999Z");
409
- if (isNaN(endOfDay.getTime())) {
410
- console.error("Invalid date value:", dateValue);
411
- return;
412
- }
413
- const isoDateTime = endOfDay.toISOString();
414
- dispatch?.(setReportConfig({
415
- endDate: isoDateTime,
416
- startDate: startDate || undefined,
417
- reportName: reportName || undefined,
418
- accountsDocumentId: accountsDocumentId || undefined,
419
- }));
420
- };
421
434
  // Get the parent folder node for the currently selected node
422
435
  const parentFolder = useParentFolderForSelectedNode();
423
436
  // Set the selected node to the parent folder node (close the editor)
@@ -431,7 +444,18 @@ export default function Editor() {
431
444
  endDate: endDate || undefined,
432
445
  })), className: "w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500", children: [_jsx("option", { value: "", children: "Select an Accounts document..." }), accountsDocuments.map((doc) => (_jsx("option", { value: doc.header.id, children: doc.header.name ||
433
446
  `Accounts (${doc.header.id.slice(0, 8)}...)` }, doc.header.id)))] }), selectedAccountsDoc && (_jsxs("p", { className: "text-xs text-gray-500 mt-1", children: [selectedAccountsDoc.state.global?.accounts
434
- ?.length || 0, " ", "accounts available"] }))] })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: "Reporting Period" }), isEditingPeriod ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Select, { options: monthOptions, value: selectedPeriod, onChange: (value) => handlePeriodChange(value), className: "min-w-[180px]" }), isPeriodChanged && (_jsx(Button, { variant: "default", onClick: handleConfirmPeriod, className: "text-sm", children: "Set Period" }))] })) : (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-lg font-bold text-gray-900", children: periodDisplayLabel }), _jsx(Button, { variant: "ghost", onClick: handleEditPeriod, className: "text-sm", children: "Change" })] }))] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: "Snapshot Period" }), _jsxs("div", { className: "flex gap-2 items-center", children: [_jsx(DatePicker, { name: "startDate", value: startDate ? startDate.split("T")[0] : "", onChange: handleStartDateChange, dateFormat: "YYYY-MM-DD", className: "flex-1" }), _jsx("span", { className: "self-center", children: "to" }), _jsx(DatePicker, { name: "endDate", value: endDate ? endDate.split("T")[0] : "", onChange: handleEndDateChange, dateFormat: "YYYY-MM-DD", className: "flex-1" })] })] })] })] }), _jsxs("div", { className: "bg-white rounded-lg shadow p-6", children: [_jsxs("div", { className: "flex justify-between items-center mb-4", children: [_jsx("h2", { className: "text-xl font-semibold", children: "Snapshot Accounts" }), _jsxs("div", { className: "flex gap-2", children: [snapshotAccounts.length > 0 && (_jsxs("button", { onClick: handleSyncAll, disabled: isSyncingAll || !startDate || !endDate, className: "px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500 disabled:bg-gray-400 disabled:cursor-not-allowed flex items-center gap-2", children: [_jsx(RefreshCw, { className: `w-4 h-4 ${isSyncingAll ? "animate-spin" : ""}` }), "Sync All"] })), _jsx("button", { onClick: handleOpenAccountPicker, disabled: !accountsDocumentId, className: "px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-400 disabled:cursor-not-allowed", children: "Add Account" })] })] }), snapshotAccounts.length === 0 ? (_jsxs("div", { className: "text-center py-12 text-gray-500", children: [_jsx("p", { children: "No accounts added yet" }), _jsx("p", { className: "text-sm mt-2", children: "Click \"Add Account\" to select accounts for this snapshot" })] })) : (_jsx("div", { className: "space-y-6", children: [
447
+ ?.length || 0, " ", "accounts available"] }))] })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: "Reporting Period" }), isEditingPeriod ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Select, { options: monthOptions, value: selectedPeriod, onChange: (value) => handlePeriodChange(value), className: "min-w-[180px]" }), isPeriodChanged && (_jsx(Button, { variant: "default", onClick: handleConfirmPeriod, className: "text-sm", children: "Set Period" }))] })) : (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-lg font-bold text-gray-900", children: periodDisplayLabel }), _jsx(Button, { variant: "ghost", onClick: handleEditPeriod, className: "text-sm", children: "Change" })] }))] }), _jsxs("div", { children: [_jsx(DateRangePicker, { label: "Snapshot Period", fromDate: startDate || "", toDate: endDate || "", onChange: handleSnapshotPeriodChange }), suggestedStartDate &&
448
+ (!startDate ||
449
+ startDate.split("T")[0] !==
450
+ suggestedStartDate.toISOString().split("T")[0]) && (_jsxs("div", { className: "mt-2 flex items-center gap-2 p-2 bg-indigo-50 border border-indigo-200 rounded-md", children: [_jsxs("span", { className: "text-xs text-indigo-700 flex-1", children: ["Previous snapshot period ends", " ", new Date(suggestedStartDate.getTime() - 86400000).toLocaleDateString("en-US", {
451
+ month: "short",
452
+ day: "numeric",
453
+ timeZone: "UTC",
454
+ }), ". Start from", " ", _jsx("strong", { children: suggestedStartDate.toLocaleDateString("en-US", {
455
+ month: "short",
456
+ day: "numeric",
457
+ timeZone: "UTC",
458
+ }) }), " ", "to avoid gaps."] }), _jsx("button", { onClick: handleApplySuggestedStartDate, className: "px-2 py-1 text-xs font-medium text-indigo-700 bg-indigo-100 hover:bg-indigo-200 rounded transition-colors whitespace-nowrap", children: "Apply" })] }))] })] })] }), _jsxs("div", { className: "bg-white rounded-lg shadow p-6", children: [_jsxs("div", { className: "flex justify-between items-center mb-4", children: [_jsx("h2", { className: "text-xl font-semibold", children: "Snapshot Accounts" }), _jsxs("div", { className: "flex gap-2", children: [snapshotAccounts.length > 0 && (_jsxs("button", { onClick: handleSyncAll, disabled: isSyncingAll || !startDate || !endDate, className: "px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500 disabled:bg-gray-400 disabled:cursor-not-allowed flex items-center gap-2", children: [_jsx(RefreshCw, { className: `w-4 h-4 ${isSyncingAll ? "animate-spin" : ""}` }), "Sync All"] })), _jsx("button", { onClick: handleOpenAccountPicker, disabled: !accountsDocumentId, className: "px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-400 disabled:cursor-not-allowed", children: "Add Account" })] })] }), snapshotAccounts.length === 0 ? (_jsxs("div", { className: "text-center py-12 text-gray-500", children: [_jsx("p", { children: "No accounts added yet" }), _jsx("p", { className: "text-sm mt-2", children: "Click \"Add Account\" to select accounts for this snapshot" })] })) : (_jsx("div", { className: "space-y-6", children: [
435
459
  {
436
460
  type: "Source",
437
461
  label: "Source",
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * Download all documents from a Powerhouse switchboard as .phd files.
4
+ *
5
+ * REQUIRES: Bun runtime (https://bun.sh) — Node.js is NOT supported.
6
+ *
7
+ * Usage:
8
+ * bun scripts/download-drive-documents.ts <switchboard-url> [drive-id]
9
+ *
10
+ * Examples:
11
+ * # Download all documents from all drives
12
+ * bun scripts/download-drive-documents.ts https://switchboard-dev.powerhouse.xyz
13
+ *
14
+ * # Download documents from a specific drive
15
+ * bun scripts/download-drive-documents.ts https://switchboard-dev.powerhouse.xyz layer-resources-drive
16
+ *
17
+ * Output structure:
18
+ * ./downloads/<drive-name>/
19
+ * ├── document-a.phd
20
+ * ├── FolderName/
21
+ * │ └── document-b.phd
22
+ * └── ...
23
+ *
24
+ * The .phd files are ZIP archives containing:
25
+ * - header.json — document metadata (id, type, timestamps)
26
+ * - state.json — initial empty state
27
+ * - current-state.json — current document state
28
+ * - operations.json — operation history (global scope)
29
+ *
30
+ * No external dependencies required — uses only Node.js built-in modules.
31
+ */
32
+ export {};
33
+ //# sourceMappingURL=download-drive-documents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download-drive-documents.d.ts","sourceRoot":"","sources":["../../../scripts/download-all-drive-documents/download-drive-documents.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG"}