@graphiql/plugin-collections 1.0.0-beta.4 → 1.0.0-rc.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.
- package/README.md +5 -2
- package/dist/components/save-dialog.js +17 -18
- package/dist/components/save-dialog.js.map +1 -1
- package/dist/store.d.ts +9 -4
- package/dist/store.js +100 -7
- package/dist/store.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -104,18 +104,21 @@ const apiStorage: CollectionsStorage = {
|
|
|
104
104
|
return (await res.json()) as Collection[];
|
|
105
105
|
},
|
|
106
106
|
async save(collections) {
|
|
107
|
-
await fetch('/api/collections', {
|
|
107
|
+
const response = await fetch('/api/collections', {
|
|
108
108
|
method: 'PUT',
|
|
109
109
|
headers: { 'content-type': 'application/json' },
|
|
110
110
|
body: JSON.stringify(collections),
|
|
111
111
|
});
|
|
112
|
+
if (!response.ok) {
|
|
113
|
+
throw new Error(`Saving collections failed (${response.status})`);
|
|
114
|
+
}
|
|
112
115
|
},
|
|
113
116
|
};
|
|
114
117
|
|
|
115
118
|
const collections = collectionsPlugin({ storage: apiStorage });
|
|
116
119
|
```
|
|
117
120
|
|
|
118
|
-
`load()` runs once when the panel first mounts. `save()`
|
|
121
|
+
`load()` runs once when the panel first mounts. `save()` receives the full collection list after mutations. For toolbar or keyboard saves, its promise must resolve only after the write commits. A rejection keeps the operation dirty and shows an error in GraphiQL. Other collection editing actions still update the UI immediately.
|
|
119
122
|
|
|
120
123
|
### Team-shared backends and sync
|
|
121
124
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { collectionsStore, useCollectionsStore } from "../store.js";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
|
-
import { Button, Dialog
|
|
3
|
+
import { Button, Dialog } from "@graphiql/react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/save-dialog.tsx
|
|
6
6
|
var NEW_COLLECTION = "__new__";
|
|
@@ -13,7 +13,7 @@ var SaveDialog = () => {
|
|
|
13
13
|
const collections = useCollectionsStore((s) => s.collections);
|
|
14
14
|
const actions = useCollectionsStore((s) => s.actions);
|
|
15
15
|
const { open, name: initialName } = useCollectionsStore((s) => s.saveDialog);
|
|
16
|
-
const
|
|
16
|
+
const [saving, setSaving] = useState(false);
|
|
17
17
|
const [name, setName] = useState(initialName);
|
|
18
18
|
const [description, setDescription] = useState("");
|
|
19
19
|
const [selectedCollectionId, setSelectedCollectionId] = useState(NEW_COLLECTION);
|
|
@@ -25,24 +25,21 @@ var SaveDialog = () => {
|
|
|
25
25
|
setDescription("");
|
|
26
26
|
setSelectedCollectionId(current[0]?.id ?? NEW_COLLECTION);
|
|
27
27
|
setNewCollectionName("New Collection");
|
|
28
|
+
setSaving(false);
|
|
28
29
|
}
|
|
29
30
|
}, [open, initialName]);
|
|
30
|
-
const handleSave = () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (saveDialog.tabId) {
|
|
42
|
-
a.linkTab(saveDialog.tabId, collectionId, item.id);
|
|
43
|
-
markTabSaved(saveDialog.tabId);
|
|
31
|
+
const handleSave = async () => {
|
|
32
|
+
setSaving(true);
|
|
33
|
+
try {
|
|
34
|
+
await collectionsStore.getState().actions.commitSaveDialog({
|
|
35
|
+
name: name || "Unnamed operation",
|
|
36
|
+
description: description || void 0,
|
|
37
|
+
collectionId: selectedCollectionId === NEW_COLLECTION ? void 0 : selectedCollectionId,
|
|
38
|
+
newCollectionName
|
|
39
|
+
});
|
|
40
|
+
} catch {} finally {
|
|
41
|
+
setSaving(false);
|
|
44
42
|
}
|
|
45
|
-
a.closeSaveDialog();
|
|
46
43
|
};
|
|
47
44
|
return /* @__PURE__ */ jsxs(Dialog, {
|
|
48
45
|
open,
|
|
@@ -101,12 +98,14 @@ var SaveDialog = () => {
|
|
|
101
98
|
})
|
|
102
99
|
] }), /* @__PURE__ */ jsxs(Dialog.Footer, { children: [/* @__PURE__ */ jsx(Button, {
|
|
103
100
|
type: "button",
|
|
101
|
+
disabled: saving,
|
|
104
102
|
onClick: () => actions.closeSaveDialog(),
|
|
105
103
|
children: "Cancel"
|
|
106
104
|
}), /* @__PURE__ */ jsx(Button, {
|
|
107
105
|
type: "submit",
|
|
108
106
|
variant: "primary",
|
|
109
|
-
|
|
107
|
+
disabled: saving,
|
|
108
|
+
children: saving ? "Saving…" : "Save"
|
|
110
109
|
})] })]
|
|
111
110
|
})]
|
|
112
111
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save-dialog.js","names":[],"sources":["../../src/components/save-dialog.tsx"],"sourcesContent":["import { FC, useEffect, useState } from 'react';\nimport { Button, Dialog
|
|
1
|
+
{"version":3,"file":"save-dialog.js","names":[],"sources":["../../src/components/save-dialog.tsx"],"sourcesContent":["import { FC, useEffect, useState } from 'react';\nimport { Button, Dialog } from '@graphiql/react';\nimport { useCollectionsStore, collectionsStore } from '../store';\n\nconst NEW_COLLECTION = '__new__';\n\n/**\n * The single \"Save to collection\" dialog. Its open state and the operation\n * being saved live in the collections store, so ⌘S and the save button can open\n * it imperatively via `requestSave`.\n */\nexport const SaveDialog: FC = () => {\n const collections = useCollectionsStore(s => s.collections);\n const actions = useCollectionsStore(s => s.actions);\n const { open, name: initialName } = useCollectionsStore(s => s.saveDialog);\n const [saving, setSaving] = useState(false);\n\n const [name, setName] = useState(initialName);\n const [description, setDescription] = useState('');\n const [selectedCollectionId, setSelectedCollectionId] =\n useState<string>(NEW_COLLECTION);\n const [newCollectionName, setNewCollectionName] = useState('New Collection');\n\n // Reset the form each time the dialog opens with a fresh operation.\n useEffect(() => {\n if (open) {\n const { collections: current } = collectionsStore.getState();\n setName(initialName);\n setDescription('');\n setSelectedCollectionId(current[0]?.id ?? NEW_COLLECTION);\n setNewCollectionName('New Collection');\n setSaving(false);\n }\n }, [open, initialName]);\n\n const handleSave = async () => {\n setSaving(true);\n try {\n await collectionsStore.getState().actions.commitSaveDialog({\n name: name || 'Unnamed operation',\n description: description || undefined,\n collectionId:\n selectedCollectionId === NEW_COLLECTION\n ? undefined\n : selectedCollectionId,\n newCollectionName,\n });\n } catch {\n // The editor displays the rejected save; it retains the dirty state.\n } finally {\n setSaving(false);\n }\n };\n\n return (\n <Dialog open={open} onOpenChange={o => !o && actions.closeSaveDialog()}>\n <Dialog.Header>Save to collection</Dialog.Header>\n <form\n onSubmit={e => {\n e.preventDefault();\n void handleSave();\n }}\n >\n <Dialog.Body>\n <label className=\"graphiql-save-dialog-field\">\n <span>Operation name</span>\n <input\n type=\"text\"\n value={name}\n onChange={e => setName(e.target.value)}\n placeholder=\"Unnamed operation\"\n className=\"graphiql-save-dialog-input\"\n autoFocus\n />\n </label>\n <label className=\"graphiql-save-dialog-field\">\n <span>Description</span>\n <input\n type=\"text\"\n value={description}\n onChange={e => setDescription(e.target.value)}\n placeholder=\"Description (optional)\"\n className=\"graphiql-save-dialog-input\"\n />\n </label>\n <label className=\"graphiql-save-dialog-field\">\n <span>Collection</span>\n <select\n value={selectedCollectionId}\n onChange={e => setSelectedCollectionId(e.target.value)}\n className=\"graphiql-save-dialog-select\"\n >\n <option value={NEW_COLLECTION}>+ New collection</option>\n {collections.map(c => (\n <option key={c.id} value={c.id}>\n {c.name}\n </option>\n ))}\n </select>\n </label>\n {selectedCollectionId === NEW_COLLECTION && (\n <label className=\"graphiql-save-dialog-field\">\n <span>Collection name</span>\n <input\n type=\"text\"\n value={newCollectionName}\n onChange={e => setNewCollectionName(e.target.value)}\n placeholder=\"Collection name\"\n className=\"graphiql-save-dialog-input\"\n />\n </label>\n )}\n </Dialog.Body>\n <Dialog.Footer>\n <Button\n type=\"button\"\n disabled={saving}\n onClick={() => actions.closeSaveDialog()}\n >\n Cancel\n </Button>\n <Button type=\"submit\" variant=\"primary\" disabled={saving}>\n {saving ? 'Saving…' : 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IAAS,SAAQ;IAAU,UAAU;IAC/C,UAAA,SAAS,YAAY;GAChB,CAAA,CACK,EAAA,CAAA,CACX;EACA,CAAA,CAAA;;AAEZ"}
|
package/dist/store.d.ts
CHANGED
|
@@ -58,11 +58,16 @@ type CollectionsActions = {
|
|
|
58
58
|
linkTab(tabId: string, collectionId: string, itemId: string): void;
|
|
59
59
|
/**
|
|
60
60
|
* Save the active operation: update the linked item in place if the tab is
|
|
61
|
-
* already tied to a collection item, otherwise open the save dialog.
|
|
62
|
-
*
|
|
63
|
-
* `false` when it opened the dialog instead.
|
|
61
|
+
* already tied to a collection item, otherwise open the save dialog. The
|
|
62
|
+
* returned promise settles after storage commits or the dialog is cancelled.
|
|
64
63
|
*/
|
|
65
|
-
requestSave(operation: ActiveOperation): boolean
|
|
64
|
+
requestSave(operation: ActiveOperation): Promise<boolean>;
|
|
65
|
+
commitSaveDialog(input: {
|
|
66
|
+
name: string;
|
|
67
|
+
description?: string;
|
|
68
|
+
collectionId?: string;
|
|
69
|
+
newCollectionName?: string;
|
|
70
|
+
}): Promise<void>;
|
|
66
71
|
openSaveDialog(input: Omit<SaveDialogState, 'open'>): void;
|
|
67
72
|
closeSaveDialog(): void;
|
|
68
73
|
};
|
package/dist/store.js
CHANGED
|
@@ -30,8 +30,28 @@ function itemContentEqual(a, b) {
|
|
|
30
30
|
return a.name === b.name && norm(a.query) === norm(b.query) && norm(a.variables) === norm(b.variables) && norm(a.headers) === norm(b.headers);
|
|
31
31
|
}
|
|
32
32
|
var collectionsStore = createStore((set, get) => {
|
|
33
|
+
let pendingDialog;
|
|
34
|
+
let committingDialog = false;
|
|
35
|
+
let lastPersist = Promise.resolve();
|
|
36
|
+
const queueWrite = async (write) => {
|
|
37
|
+
const previous = lastPersist;
|
|
38
|
+
let release;
|
|
39
|
+
lastPersist = new Promise((resolve) => {
|
|
40
|
+
release = resolve;
|
|
41
|
+
});
|
|
42
|
+
await previous;
|
|
43
|
+
try {
|
|
44
|
+
await write();
|
|
45
|
+
} finally {
|
|
46
|
+
release();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
33
49
|
const persist = async () => {
|
|
34
|
-
|
|
50
|
+
try {
|
|
51
|
+
await queueWrite(() => get().storage.save(get().collections));
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error("Failed to persist collections", error);
|
|
54
|
+
}
|
|
35
55
|
};
|
|
36
56
|
return {
|
|
37
57
|
collections: [],
|
|
@@ -331,16 +351,28 @@ var collectionsStore = createStore((set, get) => {
|
|
|
331
351
|
} }));
|
|
332
352
|
saveTabLinks(get().links);
|
|
333
353
|
},
|
|
334
|
-
requestSave(operation) {
|
|
354
|
+
async requestSave(operation) {
|
|
335
355
|
if (get().config.readOnly) return false;
|
|
356
|
+
if (get().saveDialog.open) return false;
|
|
336
357
|
const { links, collections, actions } = get();
|
|
337
358
|
const link = operation.id ? links[operation.id] : void 0;
|
|
338
359
|
if (link) {
|
|
339
360
|
if (collections.find((c) => c.id === link.collectionId)?.items.find((i) => i.id === link.itemId)) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
361
|
+
await queueWrite(async () => {
|
|
362
|
+
if (!get().collections.find((c) => c.id === link.collectionId)?.items.find((i) => i.id === link.itemId)) throw new Error("Saved collection item no longer exists");
|
|
363
|
+
const next = get().collections.map((c) => c.id === link.collectionId ? {
|
|
364
|
+
...c,
|
|
365
|
+
updatedAt: Date.now(),
|
|
366
|
+
items: c.items.map((i) => i.id === link.itemId ? {
|
|
367
|
+
...i,
|
|
368
|
+
query: operation.query ?? "",
|
|
369
|
+
variables: operation.variables ?? "",
|
|
370
|
+
headers: operation.headers ?? "",
|
|
371
|
+
updatedAt: Date.now()
|
|
372
|
+
} : i)
|
|
373
|
+
} : c);
|
|
374
|
+
await get().storage.save(next);
|
|
375
|
+
set({ collections: next });
|
|
344
376
|
});
|
|
345
377
|
return true;
|
|
346
378
|
}
|
|
@@ -352,7 +384,65 @@ var collectionsStore = createStore((set, get) => {
|
|
|
352
384
|
headers: operation.headers ?? "",
|
|
353
385
|
name: deriveOperationName(operation.query ?? "", operation.operationName)
|
|
354
386
|
});
|
|
355
|
-
return
|
|
387
|
+
return new Promise((resolve, reject) => {
|
|
388
|
+
pendingDialog = {
|
|
389
|
+
resolve,
|
|
390
|
+
reject
|
|
391
|
+
};
|
|
392
|
+
});
|
|
393
|
+
},
|
|
394
|
+
async commitSaveDialog(input) {
|
|
395
|
+
const { saveDialog, collections } = get();
|
|
396
|
+
if (!saveDialog.open || committingDialog) return;
|
|
397
|
+
if (input.collectionId && !collections.some((c) => c.id === input.collectionId)) {
|
|
398
|
+
const error = /* @__PURE__ */ new Error("Selected collection no longer exists");
|
|
399
|
+
pendingDialog?.reject(error);
|
|
400
|
+
pendingDialog = void 0;
|
|
401
|
+
get().actions.closeSaveDialog();
|
|
402
|
+
throw error;
|
|
403
|
+
}
|
|
404
|
+
committingDialog = true;
|
|
405
|
+
const now = Date.now();
|
|
406
|
+
const item = {
|
|
407
|
+
id: randomId(),
|
|
408
|
+
name: input.name || "Unnamed operation",
|
|
409
|
+
description: input.description || void 0,
|
|
410
|
+
query: saveDialog.query,
|
|
411
|
+
variables: saveDialog.variables,
|
|
412
|
+
headers: saveDialog.headers,
|
|
413
|
+
createdAt: now,
|
|
414
|
+
updatedAt: now
|
|
415
|
+
};
|
|
416
|
+
const collectionId = input.collectionId ?? randomId();
|
|
417
|
+
try {
|
|
418
|
+
await queueWrite(async () => {
|
|
419
|
+
if (input.collectionId && !get().collections.some((c) => c.id === collectionId)) throw new Error("Selected collection no longer exists");
|
|
420
|
+
const next = input.collectionId ? get().collections.map((c) => c.id === collectionId ? {
|
|
421
|
+
...c,
|
|
422
|
+
items: [...c.items, item],
|
|
423
|
+
updatedAt: now
|
|
424
|
+
} : c) : [...get().collections, {
|
|
425
|
+
id: collectionId,
|
|
426
|
+
name: input.newCollectionName || "New Collection",
|
|
427
|
+
items: [item],
|
|
428
|
+
createdAt: now,
|
|
429
|
+
updatedAt: now
|
|
430
|
+
}];
|
|
431
|
+
await get().storage.save(next);
|
|
432
|
+
set({ collections: next });
|
|
433
|
+
});
|
|
434
|
+
if (saveDialog.tabId) get().actions.linkTab(saveDialog.tabId, collectionId, item.id);
|
|
435
|
+
pendingDialog?.resolve(true);
|
|
436
|
+
pendingDialog = void 0;
|
|
437
|
+
committingDialog = false;
|
|
438
|
+
get().actions.closeSaveDialog();
|
|
439
|
+
} catch (error) {
|
|
440
|
+
pendingDialog?.reject(error);
|
|
441
|
+
pendingDialog = void 0;
|
|
442
|
+
committingDialog = false;
|
|
443
|
+
get().actions.closeSaveDialog();
|
|
444
|
+
throw error;
|
|
445
|
+
}
|
|
356
446
|
},
|
|
357
447
|
openSaveDialog(input) {
|
|
358
448
|
set({ saveDialog: {
|
|
@@ -361,6 +451,9 @@ var collectionsStore = createStore((set, get) => {
|
|
|
361
451
|
} });
|
|
362
452
|
},
|
|
363
453
|
closeSaveDialog() {
|
|
454
|
+
if (committingDialog) return;
|
|
455
|
+
pendingDialog?.resolve(false);
|
|
456
|
+
pendingDialog = void 0;
|
|
364
457
|
set((s) => ({ saveDialog: {
|
|
365
458
|
...s.saveDialog,
|
|
366
459
|
open: false
|
package/dist/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","names":[],"sources":["../src/store.ts"],"sourcesContent":["import { createStore } from 'zustand';\nimport { createBoundedUseStore } from '@graphiql/react';\nimport { z } from 'zod';\nimport { randomId } from './utility/uuid';\nimport type {\n Collection,\n CollectionItem,\n CollectionsConfig,\n CollectionsStorage,\n ImportAnalysis,\n ImportResolution,\n} from './types';\nimport { DEFAULT_COLLECTIONS_CONFIG } from './types';\nimport { localStorageAdapter } from './storage/local-storage';\nimport { loadTabLinks, saveTabLinks, type TabLink } from './storage/tab-links';\n\n/** The active operation being saved, as seen by the save dialog. */\nexport type SaveDialogState = {\n open: boolean;\n /** The tab this save originated from, linked to the item once saved. */\n tabId?: string;\n query: string;\n variables: string;\n headers: string;\n name: string;\n};\n\n/** The current operation handed to `requestSave` from ⌘S or the save button. */\nexport type ActiveOperation = {\n id?: string;\n query: string | null;\n variables?: string | null;\n headers?: string | null;\n operationName?: string | null;\n};\n\ntype CollectionsState = {\n collections: Collection[];\n loaded: boolean;\n storage: CollectionsStorage;\n /** Host-controlled capability flags; set on init from the plugin options. */\n config: CollectionsConfig;\n /** Maps a tab id to the collection item it is linked to. */\n links: Record<string, TabLink>;\n saveDialog: SaveDialogState;\n};\n\ntype CollectionsActions = {\n init(\n storage: CollectionsStorage,\n config?: Partial<CollectionsConfig>,\n ): Promise<void>;\n /**\n * Replace the in-memory collections wholesale without persisting. Use this\n * to reflect state loaded or merged externally — writing it back would be\n * redundant and, for a DB adapter, an unwanted extra write.\n */\n setCollections(collections: Collection[]): void;\n /** Re-read collections from the configured storage — call after an external/remote change to refresh the UI. */\n reload(): Promise<void>;\n createCollection(name: string, description?: string): Collection;\n deleteCollection(id: string): void;\n renameCollection(id: string, name: string): void;\n addItem(\n collectionId: string,\n item: Omit<CollectionItem, 'id' | 'createdAt' | 'updatedAt'>,\n ): CollectionItem;\n updateItem(\n collectionId: string,\n itemId: string,\n updates: Partial<Omit<CollectionItem, 'id' | 'createdAt'>>,\n ): void;\n deleteItem(collectionId: string, itemId: string): void;\n moveItem(\n fromCollectionId: string,\n fromIndex: number,\n toCollectionId: string,\n toIndex: number,\n ): void;\n /** Pure analysis of an import JSON string against current store state. Never mutates. */\n analyzeImport(json: string): ImportAnalysis;\n /** Commit an analysis to the store using the given resolution strategy. */\n applyImport(analysis: ImportAnalysis, resolution: ImportResolution): void;\n exportCollections(): string;\n /** Export a single collection as a (one-collection) export envelope. */\n exportCollection(id: string): string;\n /** Export a single item as a (one-item, one-collection) export envelope. */\n exportItem(itemId: string): string;\n /** Link a tab to a collection item so ⌘S updates it in place. */\n linkTab(tabId: string, collectionId: string, itemId: string): void;\n /**\n * Save the active operation: update the linked item in place if the tab is\n * already tied to a collection item, otherwise open the save dialog. Returns\n * `true` when it saved in place (so the caller can clear the dirty state),\n * `false` when it opened the dialog instead.\n */\n requestSave(operation: ActiveOperation): boolean;\n openSaveDialog(input: Omit<SaveDialogState, 'open'>): void;\n closeSaveDialog(): void;\n};\n\nconst INITIAL_SAVE_DIALOG: SaveDialogState = {\n open: false,\n query: '',\n variables: '',\n headers: '',\n name: '',\n};\n\nexport function deriveOperationName(\n query: string,\n fallback?: string | null,\n): string {\n if (fallback) {\n return fallback;\n }\n const match =\n /(?:query|mutation|subscription)\\s+([A-Za-z_][A-Za-z0-9_]*)/i.exec(query);\n return match?.[1] ?? 'Unnamed operation';\n}\n\ntype StoreShape = CollectionsState & { actions: CollectionsActions };\n\n/** Drop every link that points at one of `itemIds`. */\nfunction pruneLinksForItems(\n links: Record<string, TabLink>,\n itemIds: Set<string>,\n): Record<string, TabLink> {\n const next: Record<string, TabLink> = {};\n for (const [tabId, link] of Object.entries(links)) {\n if (!itemIds.has(link.itemId)) {\n next[tabId] = link;\n }\n }\n return next;\n}\n\n/** Normalize optional string fields so undefined and '' are treated identically. */\nconst norm = (v: string | undefined): string => v ?? '';\n\n/** Compare only the user-visible content fields of two items, ignoring id and timestamps. */\nfunction itemContentEqual(a: CollectionItem, b: CollectionItem): boolean {\n return (\n a.name === b.name &&\n norm(a.query) === norm(b.query) &&\n norm(a.variables) === norm(b.variables) &&\n norm(a.headers) === norm(b.headers)\n );\n}\n\nexport const collectionsStore = createStore<StoreShape>((set, get) => {\n const persist = async () => {\n await get().storage.save(get().collections);\n };\n\n return {\n collections: [],\n loaded: false,\n storage: localStorageAdapter,\n config: DEFAULT_COLLECTIONS_CONFIG,\n links: {},\n saveDialog: INITIAL_SAVE_DIALOG,\n actions: {\n async init(storage, config) {\n const collections = await storage.load();\n set({\n collections,\n loaded: true,\n storage,\n config: { ...DEFAULT_COLLECTIONS_CONFIG, ...config },\n // Restore tab↔item links so ⌘S on a tab reopened from the previous\n // session still updates its saved operation in place.\n links: loadTabLinks(),\n });\n },\n setCollections(collections) {\n set({ collections });\n },\n async reload() {\n const collections = await get().storage.load();\n set({ collections });\n },\n createCollection(name, description) {\n const c: Collection = {\n id: randomId(),\n name,\n description,\n items: [],\n createdAt: Date.now(),\n updatedAt: Date.now(),\n };\n set(s => ({ collections: [...s.collections, c] }));\n void persist();\n return c;\n },\n deleteCollection(id) {\n const removed = get().collections.find(c => c.id === id);\n const removedItemIds = new Set(removed?.items.map(i => i.id) ?? []);\n set(s => ({\n collections: s.collections.filter(c => c.id !== id),\n links: pruneLinksForItems(s.links, removedItemIds),\n }));\n void persist();\n saveTabLinks(get().links);\n },\n renameCollection(id, name) {\n set(s => ({\n collections: s.collections.map(c =>\n c.id === id ? { ...c, name, updatedAt: Date.now() } : c,\n ),\n }));\n void persist();\n },\n addItem(collectionId, item) {\n const newItem: CollectionItem = {\n ...item,\n id: randomId(),\n createdAt: Date.now(),\n updatedAt: Date.now(),\n };\n set(s => ({\n collections: s.collections.map(c =>\n c.id === collectionId\n ? { ...c, items: [...c.items, newItem], updatedAt: Date.now() }\n : c,\n ),\n }));\n void persist();\n return newItem;\n },\n updateItem(collectionId, itemId, updates) {\n set(s => ({\n collections: s.collections.map(c =>\n c.id === collectionId\n ? {\n ...c,\n updatedAt: Date.now(),\n items: c.items.map(i =>\n i.id === itemId\n ? { ...i, ...updates, updatedAt: Date.now() }\n : i,\n ),\n }\n : c,\n ),\n }));\n void persist();\n },\n deleteItem(collectionId, itemId) {\n set(s => ({\n collections: s.collections.map(c =>\n c.id === collectionId\n ? {\n ...c,\n items: c.items.filter(i => i.id !== itemId),\n updatedAt: Date.now(),\n }\n : c,\n ),\n links: pruneLinksForItems(s.links, new Set([itemId])),\n }));\n void persist();\n saveTabLinks(get().links);\n },\n moveItem(fromCollectionId, fromIndex, toCollectionId, toIndex) {\n const { collections } = get();\n const fromCollection = collections.find(c => c.id === fromCollectionId);\n if (\n !fromCollection ||\n fromIndex < 0 ||\n fromIndex >= fromCollection.items.length\n ) {\n return;\n }\n\n const item = fromCollection.items[fromIndex];\n if (!item) {\n return;\n }\n const newCollections = collections.map(c => {\n if (c.id === fromCollectionId && c.id === toCollectionId) {\n const items = [...c.items];\n items.splice(fromIndex, 1);\n items.splice(toIndex, 0, item);\n return { ...c, items, updatedAt: Date.now() };\n }\n if (c.id === fromCollectionId) {\n return {\n ...c,\n items: c.items.filter((_, i) => i !== fromIndex),\n updatedAt: Date.now(),\n };\n }\n if (c.id === toCollectionId) {\n const items = [...c.items];\n items.splice(toIndex, 0, item);\n return { ...c, items, updatedAt: Date.now() };\n }\n return c;\n });\n set({ collections: newCollections });\n void persist();\n },\n analyzeImport(json) {\n const empty: ImportAnalysis = {\n ok: false,\n newCollections: [],\n newItems: [],\n changedItems: [],\n unchangedCount: 0,\n _incoming: [],\n };\n\n // Zod schemas for the import envelope.\n const CollectionItemSchema = z.object({\n id: z.string(),\n name: z.string(),\n query: z.string(),\n variables: z.string().optional(),\n headers: z.string().optional(),\n description: z.string().optional(),\n createdAt: z.number(),\n updatedAt: z.number(),\n });\n\n const CollectionSchema = z.object({\n id: z.string(),\n name: z.string(),\n description: z.string().optional(),\n createdAt: z.number(),\n updatedAt: z.number(),\n items: z.array(CollectionItemSchema),\n });\n\n const EnvelopeSchema = z.union([\n z.object({\n version: z.number().optional(),\n collections: z.array(CollectionSchema),\n }),\n z.array(CollectionSchema),\n ]);\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(json);\n } catch {\n return empty;\n }\n\n const result = EnvelopeSchema.safeParse(parsed);\n if (!result.success) {\n return empty;\n }\n\n const incoming: Collection[] = Array.isArray(result.data)\n ? result.data\n : result.data.collections;\n\n if (incoming.length === 0) {\n return empty;\n }\n\n const localCollections = get().collections;\n\n // Build a flat map: item id → { item, collectionId } for all local items.\n const localItemMap = new Map<\n string,\n { item: CollectionItem; collectionId: string }\n >();\n for (const col of localCollections) {\n for (const item of col.items) {\n localItemMap.set(item.id, { item, collectionId: col.id });\n }\n }\n\n const localCollectionIds = new Set(localCollections.map(c => c.id));\n\n const newCollections: Collection[] = [];\n const newItems: ImportAnalysis['newItems'] = [];\n const changedItems: ImportAnalysis['changedItems'] = [];\n let unchangedCount = 0;\n\n for (const incomingCol of incoming) {\n // Determine which items in this collection are genuinely new locally.\n const genuinelyNewItems = incomingCol.items.filter(\n item => !localItemMap.has(item.id),\n );\n\n // Register a new collection shell only when:\n // - the collection id is absent locally, AND\n // - it is intentionally empty OR it contributes at least one genuinely new item.\n // A new-to-us collection that only re-homes already-known items must NOT be created.\n if (\n !localCollectionIds.has(incomingCol.id) &&\n (incomingCol.items.length === 0 || genuinelyNewItems.length > 0)\n ) {\n newCollections.push({ ...incomingCol, items: [] });\n }\n\n for (const incomingItem of incomingCol.items) {\n const local = localItemMap.get(incomingItem.id);\n if (!local) {\n newItems.push({\n item: incomingItem,\n // Land in the incoming parent; if that parent is new it will be\n // created during apply, otherwise it already exists locally.\n targetCollectionId: incomingCol.id,\n });\n } else if (itemContentEqual(incomingItem, local.item)) {\n unchangedCount++;\n } else {\n changedItems.push({\n incoming: incomingItem,\n current: local.item,\n // Use where the recipient actually keeps it, not the incoming parent.\n currentCollectionId: local.collectionId,\n });\n }\n }\n }\n\n return {\n ok: true,\n newCollections,\n newItems,\n changedItems,\n unchangedCount,\n _incoming: incoming,\n };\n },\n applyImport(analysis, resolution) {\n if (!analysis.ok) {\n return;\n }\n\n if (resolution.mode === 'replace') {\n set({ collections: analysis._incoming });\n void persist();\n return;\n }\n\n // Merge mode.\n const now = Date.now();\n let collections = [...get().collections];\n\n // 1. Create new collection shells.\n for (const shell of analysis.newCollections) {\n collections.push({ ...shell, items: [] });\n }\n\n // 2. Add new items into their target collections.\n for (const { item, targetCollectionId } of analysis.newItems) {\n collections = collections.map(c =>\n c.id === targetCollectionId\n ? { ...c, items: [...c.items, item], updatedAt: now }\n : c,\n );\n }\n\n // 3. Apply changed items per resolution.\n const shouldApply = (itemId: string): boolean => {\n if ('applyChanges' in resolution) {\n return resolution.applyChanges;\n }\n return resolution.changedItemIds.has(itemId);\n };\n\n for (const conflict of analysis.changedItems) {\n if (!shouldApply(conflict.incoming.id)) {\n continue;\n }\n collections = collections.map(c => {\n if (c.id !== conflict.currentCollectionId) {\n return c;\n }\n return {\n ...c,\n updatedAt: now,\n items: c.items.map(i =>\n i.id === conflict.incoming.id\n ? {\n // Replace content fields; keep the local createdAt.\n ...conflict.incoming,\n createdAt: conflict.current.createdAt,\n updatedAt: now,\n }\n : i,\n ),\n };\n });\n }\n\n set({ collections });\n void persist();\n },\n exportCollections() {\n return JSON.stringify(\n { version: 1, collections: get().collections },\n null,\n 2,\n );\n },\n exportCollection(id) {\n const collection = get().collections.find(c => c.id === id);\n return JSON.stringify(\n { version: 1, collections: collection ? [collection] : [] },\n null,\n 2,\n );\n },\n exportItem(itemId) {\n for (const col of get().collections) {\n const item = col.items.find(i => i.id === itemId);\n if (item) {\n const shell: Collection = {\n id: col.id,\n name: col.name,\n description: col.description,\n createdAt: col.createdAt,\n updatedAt: col.updatedAt,\n items: [item],\n };\n return JSON.stringify(\n { version: 1, collections: [shell] },\n null,\n 2,\n );\n }\n }\n return JSON.stringify({ version: 1, collections: [] }, null, 2);\n },\n linkTab(tabId, collectionId, itemId) {\n set(s => ({\n // An item lives in exactly one tab: drop any stale link to it (e.g. a\n // closed tab's) before recording the new one.\n links: {\n ...pruneLinksForItems(s.links, new Set([itemId])),\n [tabId]: { collectionId, itemId },\n },\n }));\n saveTabLinks(get().links);\n },\n requestSave(operation) {\n // Authoritative gate: saving is disabled in read-only mode regardless\n // of how it was triggered (⌘S, save button, etc.).\n if (get().config.readOnly) {\n return false;\n }\n const { links, collections, actions } = get();\n const link = operation.id ? links[operation.id] : undefined;\n if (link) {\n const collection = collections.find(c => c.id === link.collectionId);\n const item = collection?.items.find(i => i.id === link.itemId);\n if (item) {\n actions.updateItem(link.collectionId, link.itemId, {\n query: operation.query ?? '',\n variables: operation.variables ?? '',\n headers: operation.headers ?? '',\n });\n return true;\n }\n }\n actions.openSaveDialog({\n tabId: operation.id,\n query: operation.query ?? '',\n variables: operation.variables ?? '',\n headers: operation.headers ?? '',\n name: deriveOperationName(\n operation.query ?? '',\n operation.operationName,\n ),\n });\n return false;\n },\n openSaveDialog(input) {\n set({ saveDialog: { ...input, open: true } });\n },\n closeSaveDialog() {\n set(s => ({ saveDialog: { ...s.saveDialog, open: false } }));\n },\n },\n };\n});\n\nexport const useCollectionsStore = createBoundedUseStore(collectionsStore);\n"],"mappings":";;;;;;;;AAqGA,IAAM,sBAAuC;CAC3C,MAAM;CACN,OAAO;CACP,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,SAAgB,oBACd,OACA,UACQ;CACR,IAAI,UACF,OAAO;CAIT,OADE,8DAA8D,KAAK,KAC9D,CAAA,GAAQ,MAAM;AACvB;;AAKA,SAAS,mBACP,OACA,SACyB;CACzB,MAAM,OAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,OAAO,SAAS,OAAO,QAAQ,KAAK,GAC9C,IAAI,CAAC,QAAQ,IAAI,KAAK,MAAM,GAC1B,KAAK,SAAS;CAGlB,OAAO;AACT;;AAGA,IAAM,QAAQ,MAAkC,KAAK;;AAGrD,SAAS,iBAAiB,GAAmB,GAA4B;CACvE,OACE,EAAE,SAAS,EAAE,QACb,KAAK,EAAE,KAAK,MAAM,KAAK,EAAE,KAAK,KAC9B,KAAK,EAAE,SAAS,MAAM,KAAK,EAAE,SAAS,KACtC,KAAK,EAAE,OAAO,MAAM,KAAK,EAAE,OAAO;AAEtC;AAEA,IAAa,mBAAmB,aAAyB,KAAK,QAAQ;CACpE,MAAM,UAAU,YAAY;EAC1B,MAAM,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,WAAW;CAC5C;CAEA,OAAO;EACL,aAAa,CAAC;EACd,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,OAAO,CAAC;EACR,YAAY;EACZ,SAAS;GACP,MAAM,KAAK,SAAS,QAAQ;IAE1B,IAAI;KACF,aAAA,MAFwB,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e;KACrB,OAAO,UAAU;KACjB,OAAO,UAAU,SAAS;KAC1B,WAAW,UAAU,aAAa;KAClC,SAAS,UAAU,WAAW;KAC9B,MAAM,oBACJ,UAAU,SAAS,IACnB,UAAU,aACZ;IACF,CAAC;IACD,OAAO;GACT;GACA,eAAe,OAAO;IACpB,IAAI,EAAE,YAAY;KAAE,GAAG;KAAO,MAAM;IAAK,EAAE,CAAC;GAC9C;GACA,kBAAkB;IAChB,KAAI,OAAM,EAAE,YAAY;KAAE,GAAG,EAAE;KAAY,MAAM;IAAM,EAAE,EAAE;GAC7D;EACF;CACF;AACF,CAAC;AAED,IAAa,sBAAsB,sBAAsB,gBAAgB"}
|
|
1
|
+
{"version":3,"file":"store.js","names":[],"sources":["../src/store.ts"],"sourcesContent":["import { createStore } from 'zustand';\nimport { createBoundedUseStore } from '@graphiql/react';\nimport { z } from 'zod';\nimport { randomId } from './utility/uuid';\nimport type {\n Collection,\n CollectionItem,\n CollectionsConfig,\n CollectionsStorage,\n ImportAnalysis,\n ImportResolution,\n} from './types';\nimport { DEFAULT_COLLECTIONS_CONFIG } from './types';\nimport { localStorageAdapter } from './storage/local-storage';\nimport { loadTabLinks, saveTabLinks, type TabLink } from './storage/tab-links';\n\n/** The active operation being saved, as seen by the save dialog. */\nexport type SaveDialogState = {\n open: boolean;\n /** The tab this save originated from, linked to the item once saved. */\n tabId?: string;\n query: string;\n variables: string;\n headers: string;\n name: string;\n};\n\n/** The current operation handed to `requestSave` from ⌘S or the save button. */\nexport type ActiveOperation = {\n id?: string;\n query: string | null;\n variables?: string | null;\n headers?: string | null;\n operationName?: string | null;\n};\n\ntype CollectionsState = {\n collections: Collection[];\n loaded: boolean;\n storage: CollectionsStorage;\n /** Host-controlled capability flags; set on init from the plugin options. */\n config: CollectionsConfig;\n /** Maps a tab id to the collection item it is linked to. */\n links: Record<string, TabLink>;\n saveDialog: SaveDialogState;\n};\n\ntype CollectionsActions = {\n init(\n storage: CollectionsStorage,\n config?: Partial<CollectionsConfig>,\n ): Promise<void>;\n /**\n * Replace the in-memory collections wholesale without persisting. Use this\n * to reflect state loaded or merged externally — writing it back would be\n * redundant and, for a DB adapter, an unwanted extra write.\n */\n setCollections(collections: Collection[]): void;\n /** Re-read collections from the configured storage — call after an external/remote change to refresh the UI. */\n reload(): Promise<void>;\n createCollection(name: string, description?: string): Collection;\n deleteCollection(id: string): void;\n renameCollection(id: string, name: string): void;\n addItem(\n collectionId: string,\n item: Omit<CollectionItem, 'id' | 'createdAt' | 'updatedAt'>,\n ): CollectionItem;\n updateItem(\n collectionId: string,\n itemId: string,\n updates: Partial<Omit<CollectionItem, 'id' | 'createdAt'>>,\n ): void;\n deleteItem(collectionId: string, itemId: string): void;\n moveItem(\n fromCollectionId: string,\n fromIndex: number,\n toCollectionId: string,\n toIndex: number,\n ): void;\n /** Pure analysis of an import JSON string against current store state. Never mutates. */\n analyzeImport(json: string): ImportAnalysis;\n /** Commit an analysis to the store using the given resolution strategy. */\n applyImport(analysis: ImportAnalysis, resolution: ImportResolution): void;\n exportCollections(): string;\n /** Export a single collection as a (one-collection) export envelope. */\n exportCollection(id: string): string;\n /** Export a single item as a (one-item, one-collection) export envelope. */\n exportItem(itemId: string): string;\n /** Link a tab to a collection item so ⌘S updates it in place. */\n linkTab(tabId: string, collectionId: string, itemId: string): void;\n /**\n * Save the active operation: update the linked item in place if the tab is\n * already tied to a collection item, otherwise open the save dialog. The\n * returned promise settles after storage commits or the dialog is cancelled.\n */\n requestSave(operation: ActiveOperation): Promise<boolean>;\n commitSaveDialog(input: {\n name: string;\n description?: string;\n collectionId?: string;\n newCollectionName?: string;\n }): Promise<void>;\n openSaveDialog(input: Omit<SaveDialogState, 'open'>): void;\n closeSaveDialog(): void;\n};\n\nconst INITIAL_SAVE_DIALOG: SaveDialogState = {\n open: false,\n query: '',\n variables: '',\n headers: '',\n name: '',\n};\n\nexport function deriveOperationName(\n query: string,\n fallback?: string | null,\n): string {\n if (fallback) {\n return fallback;\n }\n const match =\n /(?:query|mutation|subscription)\\s+([A-Za-z_][A-Za-z0-9_]*)/i.exec(query);\n return match?.[1] ?? 'Unnamed operation';\n}\n\ntype StoreShape = CollectionsState & { actions: CollectionsActions };\n\n/** Drop every link that points at one of `itemIds`. */\nfunction pruneLinksForItems(\n links: Record<string, TabLink>,\n itemIds: Set<string>,\n): Record<string, TabLink> {\n const next: Record<string, TabLink> = {};\n for (const [tabId, link] of Object.entries(links)) {\n if (!itemIds.has(link.itemId)) {\n next[tabId] = link;\n }\n }\n return next;\n}\n\n/** Normalize optional string fields so undefined and '' are treated identically. */\nconst norm = (v: string | undefined): string => v ?? '';\n\n/** Compare only the user-visible content fields of two items, ignoring id and timestamps. */\nfunction itemContentEqual(a: CollectionItem, b: CollectionItem): boolean {\n return (\n a.name === b.name &&\n norm(a.query) === norm(b.query) &&\n norm(a.variables) === norm(b.variables) &&\n norm(a.headers) === norm(b.headers)\n );\n}\n\nexport const collectionsStore = createStore<StoreShape>((set, get) => {\n let pendingDialog:\n | { resolve: (saved: boolean) => void; reject: (error: unknown) => void }\n | undefined;\n let committingDialog = false;\n let lastPersist: Promise<void> = Promise.resolve();\n const queueWrite = async (write: () => Promise<void>) => {\n const previous = lastPersist;\n let release!: () => void;\n lastPersist = new Promise<void>(resolve => {\n release = resolve;\n });\n await previous;\n try {\n await write();\n } finally {\n release();\n }\n };\n const persist = async () => {\n try {\n await queueWrite(() => get().storage.save(get().collections));\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to persist collections', error);\n }\n };\n\n return {\n collections: [],\n loaded: false,\n storage: localStorageAdapter,\n config: DEFAULT_COLLECTIONS_CONFIG,\n links: {},\n saveDialog: INITIAL_SAVE_DIALOG,\n actions: {\n async init(storage, config) {\n const collections = await storage.load();\n set({\n collections,\n loaded: true,\n storage,\n config: { ...DEFAULT_COLLECTIONS_CONFIG, ...config },\n // Restore tab↔item links so ⌘S on a tab reopened from the previous\n // session still updates its saved operation in place.\n links: loadTabLinks(),\n });\n },\n setCollections(collections) {\n set({ collections });\n },\n async reload() {\n const collections = await get().storage.load();\n set({ collections });\n },\n createCollection(name, description) {\n const c: Collection = {\n id: randomId(),\n name,\n description,\n items: [],\n createdAt: Date.now(),\n updatedAt: Date.now(),\n };\n set(s => ({ collections: [...s.collections, c] }));\n void persist();\n return c;\n },\n deleteCollection(id) {\n const removed = get().collections.find(c => c.id === id);\n const removedItemIds = new Set(removed?.items.map(i => i.id) ?? []);\n set(s => ({\n collections: s.collections.filter(c => c.id !== id),\n links: pruneLinksForItems(s.links, removedItemIds),\n }));\n void persist();\n saveTabLinks(get().links);\n },\n renameCollection(id, name) {\n set(s => ({\n collections: s.collections.map(c =>\n c.id === id ? { ...c, name, updatedAt: Date.now() } : c,\n ),\n }));\n void persist();\n },\n addItem(collectionId, item) {\n const newItem: CollectionItem = {\n ...item,\n id: randomId(),\n createdAt: Date.now(),\n updatedAt: Date.now(),\n };\n set(s => ({\n collections: s.collections.map(c =>\n c.id === collectionId\n ? { ...c, items: [...c.items, newItem], updatedAt: Date.now() }\n : c,\n ),\n }));\n void persist();\n return newItem;\n },\n updateItem(collectionId, itemId, updates) {\n set(s => ({\n collections: s.collections.map(c =>\n c.id === collectionId\n ? {\n ...c,\n updatedAt: Date.now(),\n items: c.items.map(i =>\n i.id === itemId\n ? { ...i, ...updates, updatedAt: Date.now() }\n : i,\n ),\n }\n : c,\n ),\n }));\n void persist();\n },\n deleteItem(collectionId, itemId) {\n set(s => ({\n collections: s.collections.map(c =>\n c.id === collectionId\n ? {\n ...c,\n items: c.items.filter(i => i.id !== itemId),\n updatedAt: Date.now(),\n }\n : c,\n ),\n links: pruneLinksForItems(s.links, new Set([itemId])),\n }));\n void persist();\n saveTabLinks(get().links);\n },\n moveItem(fromCollectionId, fromIndex, toCollectionId, toIndex) {\n const { collections } = get();\n const fromCollection = collections.find(c => c.id === fromCollectionId);\n if (\n !fromCollection ||\n fromIndex < 0 ||\n fromIndex >= fromCollection.items.length\n ) {\n return;\n }\n\n const item = fromCollection.items[fromIndex];\n if (!item) {\n return;\n }\n const newCollections = collections.map(c => {\n if (c.id === fromCollectionId && c.id === toCollectionId) {\n const items = [...c.items];\n items.splice(fromIndex, 1);\n items.splice(toIndex, 0, item);\n return { ...c, items, updatedAt: Date.now() };\n }\n if (c.id === fromCollectionId) {\n return {\n ...c,\n items: c.items.filter((_, i) => i !== fromIndex),\n updatedAt: Date.now(),\n };\n }\n if (c.id === toCollectionId) {\n const items = [...c.items];\n items.splice(toIndex, 0, item);\n return { ...c, items, updatedAt: Date.now() };\n }\n return c;\n });\n set({ collections: newCollections });\n void persist();\n },\n analyzeImport(json) {\n const empty: ImportAnalysis = {\n ok: false,\n newCollections: [],\n newItems: [],\n changedItems: [],\n unchangedCount: 0,\n _incoming: [],\n };\n\n // Zod schemas for the import envelope.\n const CollectionItemSchema = z.object({\n id: z.string(),\n name: z.string(),\n query: z.string(),\n variables: z.string().optional(),\n headers: z.string().optional(),\n description: z.string().optional(),\n createdAt: z.number(),\n updatedAt: z.number(),\n });\n\n const CollectionSchema = z.object({\n id: z.string(),\n name: z.string(),\n description: z.string().optional(),\n createdAt: z.number(),\n updatedAt: z.number(),\n items: z.array(CollectionItemSchema),\n });\n\n const EnvelopeSchema = z.union([\n z.object({\n version: z.number().optional(),\n collections: z.array(CollectionSchema),\n }),\n z.array(CollectionSchema),\n ]);\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(json);\n } catch {\n return empty;\n }\n\n const result = EnvelopeSchema.safeParse(parsed);\n if (!result.success) {\n return empty;\n }\n\n const incoming: Collection[] = Array.isArray(result.data)\n ? result.data\n : result.data.collections;\n\n if (incoming.length === 0) {\n return empty;\n }\n\n const localCollections = get().collections;\n\n // Build a flat map: item id → { item, collectionId } for all local items.\n const localItemMap = new Map<\n string,\n { item: CollectionItem; collectionId: string }\n >();\n for (const col of localCollections) {\n for (const item of col.items) {\n localItemMap.set(item.id, { item, collectionId: col.id });\n }\n }\n\n const localCollectionIds = new Set(localCollections.map(c => c.id));\n\n const newCollections: Collection[] = [];\n const newItems: ImportAnalysis['newItems'] = [];\n const changedItems: ImportAnalysis['changedItems'] = [];\n let unchangedCount = 0;\n\n for (const incomingCol of incoming) {\n // Determine which items in this collection are genuinely new locally.\n const genuinelyNewItems = incomingCol.items.filter(\n item => !localItemMap.has(item.id),\n );\n\n // Register a new collection shell only when:\n // - the collection id is absent locally, AND\n // - it is intentionally empty OR it contributes at least one genuinely new item.\n // A new-to-us collection that only re-homes already-known items must NOT be created.\n if (\n !localCollectionIds.has(incomingCol.id) &&\n (incomingCol.items.length === 0 || genuinelyNewItems.length > 0)\n ) {\n newCollections.push({ ...incomingCol, items: [] });\n }\n\n for (const incomingItem of incomingCol.items) {\n const local = localItemMap.get(incomingItem.id);\n if (!local) {\n newItems.push({\n item: incomingItem,\n // Land in the incoming parent; if that parent is new it will be\n // created during apply, otherwise it already exists locally.\n targetCollectionId: incomingCol.id,\n });\n } else if (itemContentEqual(incomingItem, local.item)) {\n unchangedCount++;\n } else {\n changedItems.push({\n incoming: incomingItem,\n current: local.item,\n // Use where the recipient actually keeps it, not the incoming parent.\n currentCollectionId: local.collectionId,\n });\n }\n }\n }\n\n return {\n ok: true,\n newCollections,\n newItems,\n changedItems,\n unchangedCount,\n _incoming: incoming,\n };\n },\n applyImport(analysis, resolution) {\n if (!analysis.ok) {\n return;\n }\n\n if (resolution.mode === 'replace') {\n set({ collections: analysis._incoming });\n void persist();\n return;\n }\n\n // Merge mode.\n const now = Date.now();\n let collections = [...get().collections];\n\n // 1. Create new collection shells.\n for (const shell of analysis.newCollections) {\n collections.push({ ...shell, items: [] });\n }\n\n // 2. Add new items into their target collections.\n for (const { item, targetCollectionId } of analysis.newItems) {\n collections = collections.map(c =>\n c.id === targetCollectionId\n ? { ...c, items: [...c.items, item], updatedAt: now }\n : c,\n );\n }\n\n // 3. Apply changed items per resolution.\n const shouldApply = (itemId: string): boolean => {\n if ('applyChanges' in resolution) {\n return resolution.applyChanges;\n }\n return resolution.changedItemIds.has(itemId);\n };\n\n for (const conflict of analysis.changedItems) {\n if (!shouldApply(conflict.incoming.id)) {\n continue;\n }\n collections = collections.map(c => {\n if (c.id !== conflict.currentCollectionId) {\n return c;\n }\n return {\n ...c,\n updatedAt: now,\n items: c.items.map(i =>\n i.id === conflict.incoming.id\n ? {\n // Replace content fields; keep the local createdAt.\n ...conflict.incoming,\n createdAt: conflict.current.createdAt,\n updatedAt: now,\n }\n : i,\n ),\n };\n });\n }\n\n set({ collections });\n void persist();\n },\n exportCollections() {\n return JSON.stringify(\n { version: 1, collections: get().collections },\n null,\n 2,\n );\n },\n exportCollection(id) {\n const collection = get().collections.find(c => c.id === id);\n return JSON.stringify(\n { version: 1, collections: collection ? [collection] : [] },\n null,\n 2,\n );\n },\n exportItem(itemId) {\n for (const col of get().collections) {\n const item = col.items.find(i => i.id === itemId);\n if (item) {\n const shell: Collection = {\n id: col.id,\n name: col.name,\n description: col.description,\n createdAt: col.createdAt,\n updatedAt: col.updatedAt,\n items: [item],\n };\n return JSON.stringify(\n { version: 1, collections: [shell] },\n null,\n 2,\n );\n }\n }\n return JSON.stringify({ version: 1, collections: [] }, null, 2);\n },\n linkTab(tabId, collectionId, itemId) {\n set(s => ({\n // An item lives in exactly one tab: drop any stale link to it (e.g. a\n // closed tab's) before recording the new one.\n links: {\n ...pruneLinksForItems(s.links, new Set([itemId])),\n [tabId]: { collectionId, itemId },\n },\n }));\n saveTabLinks(get().links);\n },\n async requestSave(operation) {\n // Authoritative gate: saving is disabled in read-only mode regardless\n // of how it was triggered (⌘S, save button, etc.).\n if (get().config.readOnly) {\n return false;\n }\n if (get().saveDialog.open) {\n return false;\n }\n const { links, collections, actions } = get();\n const link = operation.id ? links[operation.id] : undefined;\n if (link) {\n const collection = collections.find(c => c.id === link.collectionId);\n const item = collection?.items.find(i => i.id === link.itemId);\n if (item) {\n await queueWrite(async () => {\n const target = get()\n .collections.find(c => c.id === link.collectionId)\n ?.items.find(i => i.id === link.itemId);\n if (!target) {\n throw new Error('Saved collection item no longer exists');\n }\n const next = get().collections.map(c =>\n c.id === link.collectionId\n ? {\n ...c,\n updatedAt: Date.now(),\n items: c.items.map(i =>\n i.id === link.itemId\n ? {\n ...i,\n query: operation.query ?? '',\n variables: operation.variables ?? '',\n headers: operation.headers ?? '',\n updatedAt: Date.now(),\n }\n : i,\n ),\n }\n : c,\n );\n await get().storage.save(next);\n set({ collections: next });\n });\n return true;\n }\n }\n actions.openSaveDialog({\n tabId: operation.id,\n query: operation.query ?? '',\n variables: operation.variables ?? '',\n headers: operation.headers ?? '',\n name: deriveOperationName(\n operation.query ?? '',\n operation.operationName,\n ),\n });\n return new Promise<boolean>((resolve, reject) => {\n pendingDialog = { resolve, reject };\n });\n },\n async commitSaveDialog(input) {\n const { saveDialog, collections } = get();\n if (!saveDialog.open || committingDialog) {\n return;\n }\n if (\n input.collectionId &&\n !collections.some(c => c.id === input.collectionId)\n ) {\n const error = new Error('Selected collection no longer exists');\n pendingDialog?.reject(error);\n pendingDialog = undefined;\n get().actions.closeSaveDialog();\n throw error;\n }\n committingDialog = true;\n const now = Date.now();\n const item: CollectionItem = {\n id: randomId(),\n name: input.name || 'Unnamed operation',\n description: input.description || undefined,\n query: saveDialog.query,\n variables: saveDialog.variables,\n headers: saveDialog.headers,\n createdAt: now,\n updatedAt: now,\n };\n const collectionId = input.collectionId ?? randomId();\n try {\n await queueWrite(async () => {\n if (\n input.collectionId &&\n !get().collections.some(c => c.id === collectionId)\n ) {\n throw new Error('Selected collection no longer exists');\n }\n const next = input.collectionId\n ? get().collections.map(c =>\n c.id === collectionId\n ? { ...c, items: [...c.items, item], updatedAt: now }\n : c,\n )\n : [\n ...get().collections,\n {\n id: collectionId,\n name: input.newCollectionName || 'New Collection',\n items: [item],\n createdAt: now,\n updatedAt: now,\n },\n ];\n await get().storage.save(next);\n set({ collections: next });\n });\n if (saveDialog.tabId) {\n get().actions.linkTab(saveDialog.tabId, collectionId, item.id);\n }\n pendingDialog?.resolve(true);\n pendingDialog = undefined;\n committingDialog = false;\n get().actions.closeSaveDialog();\n } catch (error) {\n pendingDialog?.reject(error);\n pendingDialog = undefined;\n committingDialog = false;\n get().actions.closeSaveDialog();\n throw error;\n }\n },\n openSaveDialog(input) {\n set({ saveDialog: { ...input, open: true } });\n },\n closeSaveDialog() {\n if (committingDialog) {\n return;\n }\n pendingDialog?.resolve(false);\n pendingDialog = undefined;\n set(s => ({ saveDialog: { ...s.saveDialog, open: false } }));\n },\n },\n };\n});\n\nexport const useCollectionsStore = createBoundedUseStore(collectionsStore);\n"],"mappings":";;;;;;;;AA0GA,IAAM,sBAAuC;CAC3C,MAAM;CACN,OAAO;CACP,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,SAAgB,oBACd,OACA,UACQ;CACR,IAAI,UACF,OAAO;CAIT,OADE,8DAA8D,KAAK,KAC9D,CAAA,GAAQ,MAAM;AACvB;;AAKA,SAAS,mBACP,OACA,SACyB;CACzB,MAAM,OAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,OAAO,SAAS,OAAO,QAAQ,KAAK,GAC9C,IAAI,CAAC,QAAQ,IAAI,KAAK,MAAM,GAC1B,KAAK,SAAS;CAGlB,OAAO;AACT;;AAGA,IAAM,QAAQ,MAAkC,KAAK;;AAGrD,SAAS,iBAAiB,GAAmB,GAA4B;CACvE,OACE,EAAE,SAAS,EAAE,QACb,KAAK,EAAE,KAAK,MAAM,KAAK,EAAE,KAAK,KAC9B,KAAK,EAAE,SAAS,MAAM,KAAK,EAAE,SAAS,KACtC,KAAK,EAAE,OAAO,MAAM,KAAK,EAAE,OAAO;AAEtC;AAEA,IAAa,mBAAmB,aAAyB,KAAK,QAAQ;CACpE,IAAI;CAGJ,IAAI,mBAAmB;CACvB,IAAI,cAA6B,QAAQ,QAAQ;CACjD,MAAM,aAAa,OAAO,UAA+B;EACvD,MAAM,WAAW;EACjB,IAAI;EACJ,cAAc,IAAI,SAAc,YAAW;GACzC,UAAU;EACZ,CAAC;EACD,MAAM;EACN,IAAI;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,gBAAgB;IAChC,SAAS,OAAO;KACd,eAAe,OAAO,KAAK;KAC3B,gBAAgB,KAAA;KAChB,mBAAmB;KACnB,IAAI,CAAC,CAAC,QAAQ,gBAAgB;KAC9B,MAAM;IACR;GACF;GACA,eAAe,OAAO;IACpB,IAAI,EAAE,YAAY;KAAE,GAAG;KAAO,MAAM;IAAK,EAAE,CAAC;GAC9C;GACA,kBAAkB;IAChB,IAAI,kBACF;IAEF,eAAe,QAAQ,KAAK;IAC5B,gBAAgB,KAAA;IAChB,KAAI,OAAM,EAAE,YAAY;KAAE,GAAG,EAAE;KAAY,MAAM;IAAM,EAAE,EAAE;GAC7D;EACF;CACF;AACF,CAAC;AAED,IAAa,sBAAsB,sBAAsB,gBAAgB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphiql/plugin-collections",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc.1",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"zustand": "^5"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@graphiql/react": "1.0.0-
|
|
39
|
+
"@graphiql/react": "^1.0.0-rc.0",
|
|
40
40
|
"graphql": "^16.11.0 || ^17.0.0",
|
|
41
41
|
"react": "^18 || ^19",
|
|
42
42
|
"react-dom": "^18 || ^19"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@graphiql/react": "1.0.0-
|
|
45
|
+
"@graphiql/react": "^1.0.0-rc.1",
|
|
46
46
|
"@storybook/react-vite": "^10.3.6",
|
|
47
47
|
"@testing-library/dom": "^10.4.0",
|
|
48
48
|
"@testing-library/jest-dom": "^7.0.1",
|