@malloy-publisher/sdk 0.2.7 → 0.3.1

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 (221) hide show
  1. package/README.md +180 -204
  2. package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +134 -0
  3. package/dist/DocumentStorageProvider-tGvodI8f.es.js +24268 -0
  4. package/dist/RenderedResult-CPi6uQWq.cjs.js +115 -0
  5. package/dist/RenderedResult-mDE-4u8S.es.js +542 -0
  6. package/dist/{ServerProvider-xXW1HJOJ.cjs.js → ServerProvider-CH71GsoL.cjs.js} +1 -1
  7. package/dist/{ServerProvider-ksC5Su_x.es.js → ServerProvider-X2Ma0HRs.es.js} +324 -359
  8. package/dist/builder/index.cjs.js +105 -0
  9. package/dist/builder/index.d.ts +2 -0
  10. package/dist/builder/index.es.js +9561 -0
  11. package/dist/builder-entry.d.ts +8 -0
  12. package/dist/client/api.d.ts +13 -1
  13. package/dist/client/index.cjs.js +1 -1
  14. package/dist/client/index.es.js +1 -1
  15. package/dist/components/ApiErrorDisplay.d.ts +1 -2
  16. package/dist/components/Dashboard/Dashboard.d.ts +23 -16
  17. package/dist/components/Dashboard/DashboardGrid.d.ts +67 -0
  18. package/dist/components/Dashboard/DashboardTile.d.ts +6 -1
  19. package/dist/components/Dashboard/ExploreDialog.d.ts +18 -0
  20. package/dist/components/Dashboard/RowsDialog.d.ts +47 -0
  21. package/dist/components/Dashboard/TileCard.d.ts +44 -0
  22. package/dist/components/Dashboard/index.d.ts +2 -0
  23. package/dist/components/Dashboard/promoteMeasureRow.d.ts +40 -0
  24. package/dist/components/Dashboard/telemetry.d.ts +43 -0
  25. package/dist/components/DashboardBuilder/AddTileDialog.d.ts +35 -0
  26. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +29 -0
  27. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +112 -0
  28. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +32 -0
  29. package/dist/components/DashboardBuilder/DiffDialog.d.ts +15 -0
  30. package/dist/components/DashboardBuilder/DrillDialog.d.ts +15 -0
  31. package/dist/components/DashboardBuilder/FilterDialog.d.ts +54 -0
  32. package/dist/components/DashboardBuilder/FilterStrip.d.ts +17 -0
  33. package/dist/components/DashboardBuilder/SettingsPopover.d.ts +20 -0
  34. package/dist/components/DashboardBuilder/TileFrame.d.ts +42 -0
  35. package/dist/components/DashboardBuilder/TileMenu.d.ts +24 -0
  36. package/dist/components/DashboardBuilder/catalog.d.ts +62 -0
  37. package/dist/components/DashboardBuilder/controls.d.ts +157 -0
  38. package/dist/components/DashboardBuilder/diff.d.ts +35 -0
  39. package/dist/components/DashboardBuilder/document.d.ts +218 -0
  40. package/dist/components/DashboardBuilder/layout.d.ts +71 -0
  41. package/dist/components/DashboardBuilder/malloyText.d.ts +45 -0
  42. package/dist/components/DashboardBuilder/preview.d.ts +60 -0
  43. package/dist/components/DashboardBuilder/readDocument.d.ts +106 -0
  44. package/dist/components/DashboardBuilder/sortable.d.ts +51 -0
  45. package/dist/components/DashboardBuilder/spliceDocument.d.ts +44 -0
  46. package/dist/components/DashboardBuilder/testing/fixtures.d.ts +10 -0
  47. package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +22 -0
  48. package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +63 -0
  49. package/dist/components/DashboardBuilder/useDraft.d.ts +13 -0
  50. package/dist/components/DashboardBuilder/useFilterForm.d.ts +65 -0
  51. package/dist/components/DashboardBuilder/useTileReorder.d.ts +22 -0
  52. package/dist/components/DashboardBuilder/useTileResize.d.ts +29 -0
  53. package/dist/components/DocumentStorage/BrowserDocumentStorage.d.ts +14 -0
  54. package/dist/components/DocumentStorage/DocumentStorage.d.ts +58 -0
  55. package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +25 -0
  56. package/dist/components/DocumentStorage/index.d.ts +3 -0
  57. package/dist/components/FloatingIconButton.d.ts +16 -0
  58. package/dist/components/Model/index.d.ts +0 -1
  59. package/dist/components/Prose.d.ts +46 -0
  60. package/dist/components/RenderedResult/RenderedResult.d.ts +12 -0
  61. package/dist/components/RenderedResult/ResultContainer.d.ts +7 -1
  62. package/dist/components/RenderedResult/ResultPanel.d.ts +30 -0
  63. package/dist/components/RenderedResult/index.d.ts +2 -0
  64. package/dist/components/RenderedResult/resultSizing.d.ts +183 -0
  65. package/dist/components/drill/index.d.ts +2 -1
  66. package/dist/components/drill/resolveDrill.d.ts +22 -0
  67. package/dist/components/drill/useDrill.d.ts +11 -2
  68. package/dist/components/drill/useDrillSelf.d.ts +46 -0
  69. package/dist/components/given/filterValue.d.ts +63 -0
  70. package/dist/components/given/index.d.ts +1 -0
  71. package/dist/components/given/useGivenUrlParams.d.ts +39 -0
  72. package/dist/components/index.d.ts +3 -3
  73. package/dist/components/styles.d.ts +3 -7
  74. package/dist/core-8NVBCLZh.cjs.js +148 -0
  75. package/dist/{core-BY7vB5gN.es.js → core-B8oMW4sm.es.js} +3540 -2335
  76. package/dist/hooks/index.d.ts +3 -1
  77. package/dist/hooks/useDocumentControls.d.ts +70 -0
  78. package/dist/hooks/useQueryResult.d.ts +40 -0
  79. package/dist/hooks/useSuggestOptions.d.ts +28 -12
  80. package/dist/index.cjs.js +34 -1
  81. package/dist/index.es.js +21487 -79
  82. package/dist/sdk.css +1 -1
  83. package/dist/styles.css +0 -1
  84. package/dist/utils/malloyLiteral.d.ts +11 -0
  85. package/package.json +25 -14
  86. package/src/builder-entry.ts +55 -0
  87. package/src/components/ApiErrorDisplay.tsx +1 -1
  88. package/src/components/Connections/EditConnectionDialog.tsx +96 -86
  89. package/src/components/Dashboard/Dashboard.spec.tsx +7 -10
  90. package/src/components/Dashboard/Dashboard.tsx +184 -229
  91. package/src/components/Dashboard/DashboardGrid.tsx +124 -0
  92. package/src/components/Dashboard/DashboardTile.spec.tsx +30 -6
  93. package/src/components/Dashboard/DashboardTile.tsx +67 -101
  94. package/src/components/Dashboard/ExploreDialog.tsx +84 -0
  95. package/src/components/Dashboard/RowsDialog.spec.ts +42 -0
  96. package/src/components/Dashboard/RowsDialog.tsx +234 -0
  97. package/src/components/Dashboard/TileCard.tsx +120 -0
  98. package/src/components/Dashboard/index.ts +2 -0
  99. package/src/components/Dashboard/promoteMeasureRow.spec.ts +207 -0
  100. package/src/components/Dashboard/promoteMeasureRow.ts +160 -0
  101. package/src/components/Dashboard/telemetry.ts +44 -0
  102. package/src/components/Dashboard/tileGridColumn.spec.ts +1 -1
  103. package/src/components/DashboardBuilder/AddTileDialog.tsx +249 -0
  104. package/src/components/DashboardBuilder/BuilderToolbar.tsx +270 -0
  105. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +858 -0
  106. package/src/components/DashboardBuilder/DashboardBuilder.tsx +653 -0
  107. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +211 -0
  108. package/src/components/DashboardBuilder/DashboardEditor.tsx +493 -0
  109. package/src/components/DashboardBuilder/DiffDialog.tsx +129 -0
  110. package/src/components/DashboardBuilder/DrillDialog.tsx +281 -0
  111. package/src/components/DashboardBuilder/FilterDialog.tsx +581 -0
  112. package/src/components/DashboardBuilder/FilterStrip.tsx +125 -0
  113. package/src/components/DashboardBuilder/SettingsPopover.tsx +168 -0
  114. package/src/components/DashboardBuilder/TileFrame.tsx +380 -0
  115. package/src/components/DashboardBuilder/TileMenu.tsx +188 -0
  116. package/src/components/DashboardBuilder/catalog.spec.ts +215 -0
  117. package/src/components/DashboardBuilder/catalog.ts +225 -0
  118. package/src/components/DashboardBuilder/controls.spec.ts +243 -0
  119. package/src/components/DashboardBuilder/controls.ts +398 -0
  120. package/src/components/DashboardBuilder/diff.spec.ts +44 -0
  121. package/src/components/DashboardBuilder/diff.ts +93 -0
  122. package/src/components/DashboardBuilder/document.ts +209 -0
  123. package/src/components/DashboardBuilder/keepRowStructure.spec.ts +84 -0
  124. package/src/components/DashboardBuilder/layout.ts +143 -0
  125. package/src/components/DashboardBuilder/malloyText.spec.ts +84 -0
  126. package/src/components/DashboardBuilder/malloyText.ts +151 -0
  127. package/src/components/DashboardBuilder/moveIntoGap.spec.ts +90 -0
  128. package/src/components/DashboardBuilder/preview.spec.ts +149 -0
  129. package/src/components/DashboardBuilder/preview.ts +172 -0
  130. package/src/components/DashboardBuilder/readDocument.spec.ts +375 -0
  131. package/src/components/DashboardBuilder/readDocument.ts +467 -0
  132. package/src/components/DashboardBuilder/sortable.tsx +151 -0
  133. package/src/components/DashboardBuilder/spliceDocument.spec.ts +1108 -0
  134. package/src/components/DashboardBuilder/spliceDocument.ts +1098 -0
  135. package/src/components/DashboardBuilder/testing/fixtures.ts +48 -0
  136. package/src/components/DashboardBuilder/useBuilderShortcuts.ts +88 -0
  137. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +255 -0
  138. package/src/components/DashboardBuilder/useDashboardEditor.ts +193 -0
  139. package/src/components/DashboardBuilder/useDraft.ts +43 -0
  140. package/src/components/DashboardBuilder/useFilterForm.spec.tsx +144 -0
  141. package/src/components/DashboardBuilder/useFilterForm.ts +352 -0
  142. package/src/components/DashboardBuilder/useTileReorder.spec.tsx +97 -0
  143. package/src/components/DashboardBuilder/useTileReorder.ts +115 -0
  144. package/src/components/DashboardBuilder/useTileResize.spec.tsx +121 -0
  145. package/src/components/DashboardBuilder/useTileResize.ts +110 -0
  146. package/src/components/DashboardBuilder/withGaps.spec.ts +96 -0
  147. package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +81 -0
  148. package/src/components/DocumentStorage/BrowserDocumentStorage.ts +105 -0
  149. package/src/components/DocumentStorage/DocumentStorage.ts +73 -0
  150. package/src/components/DocumentStorage/DocumentStorageProvider.tsx +58 -0
  151. package/src/components/DocumentStorage/index.ts +16 -0
  152. package/src/components/Environment/About.tsx +4 -36
  153. package/src/components/FloatingIconButton.tsx +41 -0
  154. package/src/components/Model/Model.tsx +6 -23
  155. package/src/components/Model/ModelCell.tsx +34 -72
  156. package/src/components/Model/index.ts +0 -1
  157. package/src/components/Notebook/Notebook.tsx +27 -156
  158. package/src/components/Notebook/NotebookCell.tsx +37 -191
  159. package/src/components/Prose.spec.tsx +85 -0
  160. package/src/components/Prose.tsx +179 -0
  161. package/src/components/QueryResult/QueryResult.tsx +15 -43
  162. package/src/components/RenderedResult/RenderedResult.tsx +86 -76
  163. package/src/components/RenderedResult/ResultContainer.tsx +25 -36
  164. package/src/components/RenderedResult/ResultPanel.spec.tsx +49 -0
  165. package/src/components/RenderedResult/ResultPanel.tsx +73 -0
  166. package/src/components/RenderedResult/index.ts +16 -0
  167. package/src/components/RenderedResult/resultSizing.spec.ts +249 -0
  168. package/src/components/RenderedResult/resultSizing.ts +308 -0
  169. package/src/components/ResultsDialog.tsx +2 -1
  170. package/src/components/drill/index.ts +6 -0
  171. package/src/components/drill/resolveDrill.ts +22 -1
  172. package/src/components/drill/useDrill.spec.tsx +94 -0
  173. package/src/components/drill/useDrill.tsx +52 -12
  174. package/src/components/drill/useDrillSelf.spec.tsx +64 -0
  175. package/src/components/drill/useDrillSelf.ts +110 -0
  176. package/src/components/given/GivenInput.spec.tsx +196 -2
  177. package/src/components/given/GivenInput.tsx +300 -25
  178. package/src/components/given/GivensPanel.tsx +1 -1
  179. package/src/components/given/filterValue.spec.ts +112 -0
  180. package/src/components/given/filterValue.ts +188 -0
  181. package/src/components/given/index.ts +4 -0
  182. package/src/components/given/useGivenUrlParams.spec.tsx +74 -0
  183. package/src/components/given/useGivenUrlParams.ts +87 -0
  184. package/src/components/index.ts +11 -3
  185. package/src/components/styles.ts +0 -37
  186. package/src/hooks/index.ts +13 -1
  187. package/src/hooks/useDocumentControls.ts +170 -0
  188. package/src/hooks/useGivensState.spec.ts +158 -0
  189. package/src/hooks/useGivensState.ts +114 -23
  190. package/src/hooks/useQueryResult.ts +82 -0
  191. package/src/hooks/useSuggestOptions.dom.spec.ts +60 -1
  192. package/src/hooks/useSuggestOptions.ts +94 -51
  193. package/src/utils/malloyLiteral.spec.ts +43 -0
  194. package/src/utils/malloyLiteral.ts +76 -0
  195. package/vite.config.ts +5 -1
  196. package/dist/components/AnalyzePackageButton.d.ts +0 -6
  197. package/dist/components/Workbook/BrowserWorkbookStorage.d.ts +0 -9
  198. package/dist/components/Workbook/EditableMalloyCell.d.ts +0 -11
  199. package/dist/components/Workbook/ModelPicker.d.ts +0 -11
  200. package/dist/components/Workbook/MutableCell.d.ts +0 -17
  201. package/dist/components/Workbook/Workbook.d.ts +0 -7
  202. package/dist/components/Workbook/WorkbookList.d.ts +0 -7
  203. package/dist/components/Workbook/WorkbookManager.d.ts +0 -84
  204. package/dist/components/Workbook/WorkbookStorage.d.ts +0 -17
  205. package/dist/components/Workbook/WorkbookStorageProvider.d.ts +0 -12
  206. package/dist/components/Workbook/index.d.ts +0 -7
  207. package/dist/core-CWKmWEg2.cjs.js +0 -148
  208. package/dist/index-B0WyZAUA.es.js +0 -66412
  209. package/dist/index-kxVD1RjY.cjs.js +0 -356
  210. package/dist/markdown-editor.css +0 -341
  211. package/src/components/AnalyzePackageButton.tsx +0 -319
  212. package/src/components/Workbook/BrowserWorkbookStorage.ts +0 -64
  213. package/src/components/Workbook/EditableMalloyCell.tsx +0 -49
  214. package/src/components/Workbook/ModelPicker.tsx +0 -134
  215. package/src/components/Workbook/MutableCell.tsx +0 -458
  216. package/src/components/Workbook/Workbook.tsx +0 -501
  217. package/src/components/Workbook/WorkbookList.tsx +0 -110
  218. package/src/components/Workbook/WorkbookManager.ts +0 -214
  219. package/src/components/Workbook/WorkbookStorage.ts +0 -35
  220. package/src/components/Workbook/WorkbookStorageProvider.tsx +0 -40
  221. package/src/components/Workbook/index.ts +0 -10
@@ -1,214 +0,0 @@
1
- // Copyright (c) Credible Data Inc.
2
- // SPDX-License-Identifier: MIT
3
-
4
- import type { WorkbookLocator, WorkbookStorage } from "./WorkbookStorage";
5
-
6
- /**
7
- * Interface representing the data structure of a Mutable Workbook
8
- * @interface WorkbookData
9
- * @property {string[]} models - Array of model paths used in the workbook
10
- * @property {WorkbookCellValue[]} cells - Array of cells in the workbook
11
- * @property {WorkbookLocator} workbookPath - Path to the workbook file (relative to project/package)
12
- */
13
- export interface WorkbookData {
14
- models: string[];
15
- cells: WorkbookCellValue[];
16
- workbookPath: WorkbookLocator;
17
- }
18
-
19
- /**
20
- * Interface representing a cell in the workbook
21
- * @interface WorkbookCellValue
22
- * @property {boolean} isMarkdown - Whether the cell is a markdown cell
23
- * @property {string} [value] - The content of the cell
24
- * @property {string} [result] - The result of executing the cell
25
- * @property {string} [modelPath] - modelPath associated with the query in the cell
26
- * @property {string} [sourceName] - Name of the source associated with the cell
27
- * @property {string} [queryInfo] - Information about the query in the cell
28
- */
29
- export interface WorkbookCellValue {
30
- isMarkdown: boolean;
31
- value?: string;
32
- result?: string;
33
- modelPath?: string;
34
- sourceName?: string;
35
- queryInfo?: string;
36
- }
37
-
38
- /**
39
- * Class for managing workbook operations
40
- * @class WorkbookManager
41
- */
42
- export class WorkbookManager {
43
- private isSaved: boolean;
44
- private workbookStorage: WorkbookStorage;
45
-
46
- /**
47
- * Creates a new WorkbookManager instance
48
- * @param {WorkbookStorage} workbookStorage - Storage implementation
49
- * @param {WorkbookData} workbookData - Initial workbook data
50
- */
51
- constructor(
52
- workbookStorage: WorkbookStorage,
53
- private workbookData: WorkbookData,
54
- ) {
55
- this.workbookStorage = workbookStorage;
56
- if (this.workbookData) {
57
- this.isSaved = true;
58
- } else {
59
- this.workbookData = {
60
- models: [],
61
- cells: [],
62
- workbookPath: undefined,
63
- };
64
- this.isSaved = false;
65
- }
66
- }
67
-
68
- /**
69
- * Gets the current workbook data
70
- * @returns {WorkbookData} The current workbook data
71
- */
72
- getWorkbookData(): WorkbookData {
73
- return this.workbookData;
74
- }
75
-
76
- /**
77
- * Gets the current workbook path
78
- * @returns {string} The path to the workbook
79
- */
80
- getWorkbookPath(): WorkbookLocator {
81
- return this.workbookData.workbookPath;
82
- }
83
-
84
- /**
85
- * Renames the workbook and updates storage
86
- * @param {string} workbookPath - New path for the workbook
87
- * @returns {WorkbookManager} The updated WorkbookManager instance
88
- */
89
- async renameWorkbook(workbookPath: string): Promise<WorkbookManager> {
90
- if (this.workbookData.workbookPath.path !== workbookPath) {
91
- try {
92
- await this.workbookStorage.moveWorkbook(
93
- this.workbookData.workbookPath,
94
- {
95
- path: workbookPath,
96
- workspace: this.workbookData.workbookPath.workspace,
97
- },
98
- );
99
- } catch {
100
- // ignore if not found
101
- }
102
- }
103
- this.workbookData.workbookPath.path = workbookPath;
104
- this.isSaved = false;
105
- return await this.saveWorkbook();
106
- }
107
-
108
- getCells(): WorkbookCellValue[] {
109
- return this.workbookData.cells;
110
- }
111
- deleteCell(index: number): WorkbookManager {
112
- this.workbookData.cells = [
113
- ...this.workbookData.cells.slice(0, index),
114
- ...this.workbookData.cells.slice(index + 1),
115
- ];
116
- this.isSaved = false;
117
- return this;
118
- }
119
- insertCell(index: number, cell: WorkbookCellValue): WorkbookManager {
120
- this.workbookData.cells = [
121
- ...this.workbookData.cells.slice(0, index),
122
- cell,
123
- ...this.workbookData.cells.slice(index),
124
- ];
125
- this.isSaved = false;
126
- return this;
127
- }
128
- setCell(index: number, cell: WorkbookCellValue): WorkbookManager {
129
- this.workbookData.cells[index] = cell;
130
- this.isSaved = false;
131
- return this;
132
- }
133
- setModels(models: string[]): WorkbookManager {
134
- this.workbookData.models = models;
135
- this.isSaved = false;
136
- return this;
137
- }
138
- getModels(): string[] {
139
- return this.workbookData.models;
140
- }
141
-
142
- updateWorkbookData(workbookData: WorkbookData): WorkbookManager {
143
- this.workbookData = workbookData;
144
- this.isSaved = false;
145
- return this;
146
- }
147
-
148
- async saveWorkbook(): Promise<WorkbookManager> {
149
- if (!this.isSaved) {
150
- if (!this.workbookData.workbookPath) {
151
- throw new Error("Workbook path is not set");
152
- }
153
- await this.workbookStorage.saveWorkbook(
154
- this.workbookData.workbookPath,
155
- JSON.stringify(this.workbookData),
156
- );
157
- this.isSaved = true;
158
- }
159
- return new WorkbookManager(this.workbookStorage, this.workbookData);
160
- }
161
-
162
- /**
163
- * Converts the workbook data to a Malloy workbook string.
164
- * @returns {string} The Malloy workbook string
165
- */
166
- toMalloyWorkbook(): string {
167
- return this.workbookData.cells
168
- .map((cell) => {
169
- if (cell.isMarkdown) {
170
- return ">>>markdown\n" + cell.value;
171
- } else {
172
- return (
173
- ">>>malloy\n" +
174
- `import {${cell.sourceName}}" from '${cell.modelPath}'"\n` +
175
- cell.value +
176
- "\n"
177
- );
178
- }
179
- })
180
- .join("\n");
181
- }
182
-
183
- static newWorkbook(workbookStorage: WorkbookStorage): WorkbookManager {
184
- return new WorkbookManager(workbookStorage, undefined);
185
- }
186
-
187
- /**
188
- * Creates a new workbook manager by loading from local storage.
189
- * Returns an empty instance if the workbook is not found.
190
- * @param workbookStorage - The storage implementation
191
- * @param userContext - The user context for storage
192
- * @param workbookPath - The path to the workbook file (relative to project/package)
193
- */
194
- static async loadWorkbook(
195
- workbookStorage: WorkbookStorage,
196
- workbookPath: WorkbookLocator,
197
- ): Promise<WorkbookManager> {
198
- let workbookData: WorkbookData | undefined = undefined;
199
- try {
200
- const saved = await workbookStorage.getWorkbook(workbookPath);
201
- if (saved) {
202
- workbookData = JSON.parse(saved);
203
- }
204
- } catch {
205
- // Not found, create a new workbook
206
- workbookData = {
207
- models: [],
208
- cells: [],
209
- workbookPath: workbookPath,
210
- };
211
- }
212
- return new WorkbookManager(workbookStorage, workbookData);
213
- }
214
- }
@@ -1,35 +0,0 @@
1
- // Copyright (c) Credible Data Inc.
2
- // SPDX-License-Identifier: MIT
3
-
4
- export interface Workspace {
5
- name: string;
6
- writeable: boolean;
7
- description: string;
8
- }
9
-
10
- export interface WorkbookLocator {
11
- path: string;
12
- workspace: string;
13
- }
14
-
15
- export interface WorkbookStorage {
16
- // Lists all available workspaces for the context.
17
- listWorkspaces(writeableOnly: boolean): Promise<Workspace[]>;
18
-
19
- // Lists all available workbooks for the context.
20
- // Workbooks names are like S3 paths- / denote hierarchical
21
- // folders, but otherwise folders are not "real" objects
22
- listWorkbooks(workspace: Workspace): Promise<WorkbookLocator[]>;
23
-
24
- // Returns the workbook at the specific path, throws an exception if no such workbook exists (or cannot be accessed)
25
- getWorkbook(path: WorkbookLocator): Promise<string>;
26
-
27
- // Deletes the workbook at the specified path, or throws an
28
- // Exception on failure
29
- deleteWorkbook(path: WorkbookLocator): Promise<void>;
30
-
31
- saveWorkbook(path: WorkbookLocator, workbook: string): Promise<void>;
32
-
33
- // Moves workbook from the "from" path to the "to" path
34
- moveWorkbook(from: WorkbookLocator, to: WorkbookLocator): Promise<void>;
35
- }
@@ -1,40 +0,0 @@
1
- // Copyright (c) Credible Data Inc.
2
- // SPDX-License-Identifier: MIT
3
-
4
- import React, { createContext, useContext, useMemo } from "react";
5
- import type { WorkbookStorage } from "./WorkbookStorage";
6
-
7
- export interface WorkbookStorageProviderProps {
8
- children: React.ReactNode;
9
- workbookStorage: WorkbookStorage;
10
- }
11
-
12
- interface WorkbookStorageContextValue {
13
- workbookStorage: WorkbookStorage;
14
- }
15
-
16
- const WorkbookStorageContext = createContext<
17
- WorkbookStorageContextValue | undefined
18
- >(undefined);
19
-
20
- export function WorkbookStorageProvider({
21
- children,
22
- workbookStorage,
23
- }: WorkbookStorageProviderProps) {
24
- const value = useMemo(() => ({ workbookStorage }), [workbookStorage]);
25
- return (
26
- <WorkbookStorageContext.Provider value={value}>
27
- {children}
28
- </WorkbookStorageContext.Provider>
29
- );
30
- }
31
-
32
- export function useWorkbookStorage() {
33
- const context = useContext(WorkbookStorageContext);
34
- if (!context) {
35
- throw new Error(
36
- "useWorkbookStorage must be used within a WorkbookStorageProvider",
37
- );
38
- }
39
- return context;
40
- }
@@ -1,10 +0,0 @@
1
- // Copyright (c) Credible Data Inc.
2
- // SPDX-License-Identifier: MIT
3
-
4
- export type { WorkbookStorage } from "./WorkbookStorage";
5
- export { default as Workbook } from "./Workbook";
6
- export { WorkbookList } from "./WorkbookList";
7
- export { WorkbookStorageProvider } from "./WorkbookStorageProvider";
8
- export type { WorkbookLocator, Workspace } from "./WorkbookStorage";
9
- export { BrowserWorkbookStorage } from "./BrowserWorkbookStorage";
10
- export { WorkbookManager } from "./WorkbookManager";