@carlonicora/nextjs-jsonapi 6.13.1 → 6.14.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/dist/{BlockNoteEditor-VXMDSQAA.mjs → BlockNoteEditor-I3J6YYXK.mjs} +10 -10
- package/dist/{BlockNoteEditor-UBVEUFNR.js → BlockNoteEditor-UIAX72XW.js} +25 -25
- package/dist/{BlockNoteEditor-UBVEUFNR.js.map → BlockNoteEditor-UIAX72XW.js.map} +1 -1
- package/dist/{BlockNoteViewer-2XYASA5Y.js → BlockNoteViewer-APBOPT4B.js} +8 -8
- package/dist/{BlockNoteViewer-2XYASA5Y.js.map → BlockNoteViewer-APBOPT4B.js.map} +1 -1
- package/dist/{BlockNoteViewer-NBW2H6LC.mjs → BlockNoteViewer-HIUAJQRI.mjs} +7 -7
- package/dist/JsonApiRequest-G4J2WTSU.js +26 -0
- package/dist/{JsonApiRequest-WISJZSDE.js.map → JsonApiRequest-G4J2WTSU.js.map} +1 -1
- package/dist/{JsonApiRequest-F6TMJ42G.mjs → JsonApiRequest-IKKHWCPB.mjs} +2 -2
- package/dist/billing/index.js +497 -497
- package/dist/billing/index.mjs +9 -9
- package/dist/{chunk-7DBJTNSU.mjs → chunk-4RPGFQBA.mjs} +2 -2
- package/dist/{chunk-BZ5J2FIV.js → chunk-4XLDBOSE.js} +11 -11
- package/dist/{chunk-BZ5J2FIV.js.map → chunk-4XLDBOSE.js.map} +1 -1
- package/dist/{chunk-27LQDGNP.mjs → chunk-4ZJIUTIV.mjs} +6 -1
- package/dist/chunk-4ZJIUTIV.mjs.map +1 -0
- package/dist/{chunk-PXDUJ47N.js → chunk-6RCZ64BQ.js} +18 -18
- package/dist/{chunk-PXDUJ47N.js.map → chunk-6RCZ64BQ.js.map} +1 -1
- package/dist/{chunk-7JZHPMGW.mjs → chunk-A3RB47X4.mjs} +44 -20
- package/dist/chunk-A3RB47X4.mjs.map +1 -0
- package/dist/{chunk-DOCIFE6A.mjs → chunk-AUD6ZLBB.mjs} +3 -3
- package/dist/{chunk-GB6DBFYY.js → chunk-DGN3PR2F.js} +3 -3
- package/dist/{chunk-GB6DBFYY.js.map → chunk-DGN3PR2F.js.map} +1 -1
- package/dist/{chunk-7ZHTPFFT.js → chunk-DJXSCARG.js} +15 -15
- package/dist/{chunk-7ZHTPFFT.js.map → chunk-DJXSCARG.js.map} +1 -1
- package/dist/{chunk-QKNGZDSQ.js → chunk-GM4VZTWL.js} +2 -2
- package/dist/{chunk-QKNGZDSQ.js.map → chunk-GM4VZTWL.js.map} +1 -1
- package/dist/{chunk-47BBY5KA.mjs → chunk-HAW5PNJG.mjs} +4 -4
- package/dist/{chunk-YRKIFYOE.mjs → chunk-KTGKW72G.mjs} +27 -8
- package/dist/chunk-KTGKW72G.mjs.map +1 -0
- package/dist/{chunk-PV4Z5W6V.js → chunk-KV4N7DEG.js} +19 -19
- package/dist/{chunk-PV4Z5W6V.js.map → chunk-KV4N7DEG.js.map} +1 -1
- package/dist/{chunk-ZLTOUZN2.mjs → chunk-M3N7LPHX.mjs} +4 -4
- package/dist/{chunk-DGWOVYEC.mjs → chunk-MQ7TXALH.mjs} +2 -2
- package/dist/{chunk-W62MHDWM.js → chunk-N5ZE2Z6I.js} +58 -34
- package/dist/chunk-N5ZE2Z6I.js.map +1 -0
- package/dist/{chunk-2SV4SS6N.js → chunk-OQQ7CZWT.js} +12 -12
- package/dist/{chunk-2SV4SS6N.js.map → chunk-OQQ7CZWT.js.map} +1 -1
- package/dist/{chunk-JJMMT24D.mjs → chunk-OUEYZOLB.mjs} +2 -2
- package/dist/{chunk-XXP3TQHF.mjs → chunk-OY65RYD3.mjs} +2 -2
- package/dist/{chunk-MOGEGWXW.js → chunk-PMESKNKL.js} +868 -868
- package/dist/{chunk-MOGEGWXW.js.map → chunk-PMESKNKL.js.map} +1 -1
- package/dist/{chunk-B6JGKDP2.js → chunk-QGVVF77L.js} +48 -29
- package/dist/chunk-QGVVF77L.js.map +1 -0
- package/dist/{chunk-BH6JWIKI.mjs → chunk-QIEF7HIL.mjs} +2 -2
- package/dist/{chunk-P445QGOC.mjs → chunk-RFKSJIQB.mjs} +7 -7
- package/dist/{chunk-PYRZCKC2.js → chunk-RT7XFGIN.js} +1141 -1137
- package/dist/chunk-RT7XFGIN.js.map +1 -0
- package/dist/{chunk-N4RZZKL5.mjs → chunk-RYY7USSW.mjs} +19 -15
- package/dist/chunk-RYY7USSW.mjs.map +1 -0
- package/dist/{chunk-6JUCIWDC.mjs → chunk-UOTHRJD2.mjs} +2 -2
- package/dist/{chunk-KMW7UNL2.js → chunk-WCEYT3GG.js} +8 -8
- package/dist/{chunk-KMW7UNL2.js.map → chunk-WCEYT3GG.js.map} +1 -1
- package/dist/{chunk-MHB36MYE.js → chunk-WUNSG3IN.js} +7 -2
- package/dist/chunk-WUNSG3IN.js.map +1 -0
- package/dist/{chunk-Z4POQWFG.js → chunk-ZYSNJKOP.js} +4 -4
- package/dist/{chunk-Z4POQWFG.js.map → chunk-ZYSNJKOP.js.map} +1 -1
- package/dist/client/index.js +10 -10
- package/dist/client/index.mjs +9 -9
- package/dist/components/index.js +10 -10
- package/dist/components/index.mjs +9 -9
- package/dist/contexts/index.js +10 -10
- package/dist/contexts/index.mjs +9 -9
- package/dist/core/index.js +7 -7
- package/dist/core/index.mjs +6 -6
- package/dist/email-automations/index.js +99 -99
- package/dist/email-automations/index.mjs +9 -9
- package/dist/features/analytics/index.js +126 -126
- package/dist/features/analytics/index.mjs +9 -9
- package/dist/features/analytics/server.js +10 -10
- package/dist/features/analytics/server.mjs +8 -8
- package/dist/features/blog/index.js +156 -156
- package/dist/features/blog/index.mjs +9 -9
- package/dist/features/blog/server.js +28 -28
- package/dist/features/blog/server.mjs +7 -7
- package/dist/features/help/index.js +43 -43
- package/dist/features/help/index.mjs +9 -9
- package/dist/features/tokenusage/index.js +132 -132
- package/dist/features/tokenusage/index.mjs +9 -9
- package/dist/index.js +8 -8
- package/dist/index.mjs +7 -7
- package/dist/{lifecycle-LKGPRBS7.mjs → lifecycle-KI3PCJSE.mjs} +3 -3
- package/dist/lifecycle-TO65I7TO.js +23 -0
- package/dist/{lifecycle-4GUOTB46.js.map → lifecycle-TO65I7TO.js.map} +1 -1
- package/dist/local-transport-4YDJ6FQG.js +15 -0
- package/dist/{local-transport-7H3SPZSA.js.map → local-transport-4YDJ6FQG.js.map} +1 -1
- package/dist/local-transport-C7YTA4I7.mjs +15 -0
- package/dist/offline/index.d.mts +160 -4
- package/dist/offline/index.d.ts +160 -4
- package/dist/offline/index.js +210 -163
- package/dist/offline/index.js.map +1 -1
- package/dist/offline/index.mjs +76 -29
- package/dist/offline/index.mjs.map +1 -1
- package/dist/request-66FGJIHB.mjs +10 -0
- package/dist/request-6W6UGKJV.js +10 -0
- package/dist/{request-KTBV6HHH.js.map → request-6W6UGKJV.js.map} +1 -1
- package/dist/server/index.js +9 -9
- package/dist/server/index.mjs +8 -8
- package/dist/write-through-BAPS24GL.js +15 -0
- package/dist/{write-through-FDQ7N4YI.js.map → write-through-BAPS24GL.js.map} +1 -1
- package/dist/write-through-IWQKXYHE.mjs +15 -0
- package/package.json +1 -1
- package/src/hooks/__tests__/usePageTracker.spec.tsx +61 -0
- package/src/hooks/usePageTracker.ts +17 -7
- package/src/offline/__tests__/generic-answers.spec.ts +146 -3
- package/src/offline/__tests__/local-transport.spec.ts +15 -1
- package/src/offline/__tests__/offline-fixtures.ts +29 -2
- package/src/offline/__tests__/write-through.spec.ts +27 -1
- package/src/offline/config.ts +9 -0
- package/src/offline/generic-answers.ts +44 -17
- package/src/offline/index.ts +2 -0
- package/src/offline/local-transport.ts +5 -3
- package/src/offline/sync/__tests__/runtime.spec.ts +30 -1
- package/src/offline/sync/__tests__/sync-fixtures.ts +22 -0
- package/src/offline/sync/__tests__/sync-root.spec.ts +184 -1
- package/src/offline/sync/known-roots.ts +29 -7
- package/src/offline/sync/runtime.ts +3 -2
- package/src/offline/sync/sync-root.ts +70 -19
- package/src/offline/types.ts +39 -1
- package/src/offline/write-through.ts +6 -3
- package/dist/JsonApiRequest-WISJZSDE.js +0 -26
- package/dist/chunk-27LQDGNP.mjs.map +0 -1
- package/dist/chunk-7JZHPMGW.mjs.map +0 -1
- package/dist/chunk-B6JGKDP2.js.map +0 -1
- package/dist/chunk-MHB36MYE.js.map +0 -1
- package/dist/chunk-N4RZZKL5.mjs.map +0 -1
- package/dist/chunk-PYRZCKC2.js.map +0 -1
- package/dist/chunk-W62MHDWM.js.map +0 -1
- package/dist/chunk-YRKIFYOE.mjs.map +0 -1
- package/dist/lifecycle-4GUOTB46.js +0 -23
- package/dist/local-transport-7H3SPZSA.js +0 -15
- package/dist/local-transport-QYFKA6AN.mjs +0 -15
- package/dist/request-KTBV6HHH.js +0 -10
- package/dist/request-SQOUNWZ4.mjs +0 -10
- package/dist/write-through-FDQ7N4YI.js +0 -15
- package/dist/write-through-R25VQMH6.mjs +0 -15
- /package/dist/{BlockNoteEditor-VXMDSQAA.mjs.map → BlockNoteEditor-I3J6YYXK.mjs.map} +0 -0
- /package/dist/{BlockNoteViewer-NBW2H6LC.mjs.map → BlockNoteViewer-HIUAJQRI.mjs.map} +0 -0
- /package/dist/{JsonApiRequest-F6TMJ42G.mjs.map → JsonApiRequest-IKKHWCPB.mjs.map} +0 -0
- /package/dist/{chunk-7DBJTNSU.mjs.map → chunk-4RPGFQBA.mjs.map} +0 -0
- /package/dist/{chunk-DOCIFE6A.mjs.map → chunk-AUD6ZLBB.mjs.map} +0 -0
- /package/dist/{chunk-47BBY5KA.mjs.map → chunk-HAW5PNJG.mjs.map} +0 -0
- /package/dist/{chunk-ZLTOUZN2.mjs.map → chunk-M3N7LPHX.mjs.map} +0 -0
- /package/dist/{chunk-DGWOVYEC.mjs.map → chunk-MQ7TXALH.mjs.map} +0 -0
- /package/dist/{chunk-JJMMT24D.mjs.map → chunk-OUEYZOLB.mjs.map} +0 -0
- /package/dist/{chunk-XXP3TQHF.mjs.map → chunk-OY65RYD3.mjs.map} +0 -0
- /package/dist/{chunk-BH6JWIKI.mjs.map → chunk-QIEF7HIL.mjs.map} +0 -0
- /package/dist/{chunk-P445QGOC.mjs.map → chunk-RFKSJIQB.mjs.map} +0 -0
- /package/dist/{chunk-6JUCIWDC.mjs.map → chunk-UOTHRJD2.mjs.map} +0 -0
- /package/dist/{lifecycle-LKGPRBS7.mjs.map → lifecycle-KI3PCJSE.mjs.map} +0 -0
- /package/dist/{local-transport-QYFKA6AN.mjs.map → local-transport-C7YTA4I7.mjs.map} +0 -0
- /package/dist/{request-SQOUNWZ4.mjs.map → request-66FGJIHB.mjs.map} +0 -0
- /package/dist/{write-through-R25VQMH6.mjs.map → write-through-IWQKXYHE.mjs.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/offline/sync/known-roots.ts","../src/offline/sync/waiting.ts","../src/offline/write-through.ts"],"sourcesContent":["import { getOfflineConfig, getOfflineStore, rootKinds } from \"../config\";\nimport { setOfflineState } from \"../state\";\nimport type { DeviceStore } from \"../store/DeviceStore\";\nimport { isRootLocked } from \"../store/lifecycle\";\n\nlet _lastSyncRoots: string[] = [];\nlet _lastExtraSyncRoots: string[] = [];\n\n/**\n * Remembers the root records the last online sync listed: `ids` of every kind, `extraIds` those\n * of the `extraRootKinds` among them.\n */\nexport function rememberSyncRoots(ids: string[], extraIds: string[] = []): void {\n _lastSyncRoots = [...ids];\n _lastExtraSyncRoots = [...extraIds];\n}\n\n/**\n * Every root record the device knows of, of every kind: its stored root records, the root records\n * with waiting changes, and the last sync roots (a locked root record is never downloaded, so it\n * may have no stored record).\n */\nexport async function knownRootIds(store: DeviceStore): Promise<string[]> {\n const config = getOfflineConfig();\n const ids = new Set<string>(_lastSyncRoots);\n for (const kind of rootKinds(config)) {\n for (const record of await store.listRecords({ type: kind.module.name })) ids.add(record.id);\n }\n for (const entry of await store.queue()) ids.add(entry.rootId);\n return [...ids].sort();\n}\n\n/** The known root records of the `extraRootKinds`: stored, or listed by the last sync. */\nasync function extraRootIds(store: DeviceStore): Promise<Set<string>> {\n const ids = new Set<string>(_lastExtraSyncRoots);\n for (const kind of getOfflineConfig().extraRootKinds ?? []) {\n for (const record of await store.listRecords({ type: kind.module.name })) ids.add(record.id);\n }\n return ids;\n}\n\n/** `knownRootIds` without the root records of the `extraRootKinds` (the primary kind only). */\nexport async function knownPrimaryRootIds(store: DeviceStore): Promise<string[]> {\n const extra = await extraRootIds(store);\n return (await knownRootIds(store)).filter((id) => !extra.has(id));\n}\n\n/** Recomputes `lockedRootIds` from the stored sync states, now. */\nexport async function refreshLockedRoots(): Promise<void> {\n const config = getOfflineConfig();\n if (!config.getUserId()) return;\n const store = await getOfflineStore();\n const now = new Date();\n const locked: string[] = [];\n for (const id of await knownRootIds(store)) {\n if (isRootLocked(await store.getSyncState(id), now)) locked.push(id);\n }\n setOfflineState({ lockedRootIds: locked });\n}\n","import type { QueueEntry } from \"../store/DeviceStore\";\n\nexport const recordKeyOf = (type: string, id: string) => `${type}:${id}`;\n\n/**\n * The records a queue entry targets: its `recordType`/`recordId`, the `data.type`/`data.id` of\n * its body (a record created on this device), and the `<type>/<id>` of its path (the last\n * segment naming a synced type, when an id follows it: `npcs/n1`, `npcs/n1/merge`; a collection\n * path such as `roots/C/npcs` targets no record).\n */\nexport function recordKeysOfEntry(entry: QueueEntry, typeNames: Set<string>): string[] {\n const keys: string[] = [];\n if (entry.recordType && entry.recordId) keys.push(recordKeyOf(entry.recordType, entry.recordId));\n\n const data = entry.body?.data;\n if (data && !Array.isArray(data) && typeof data.type === \"string\" && typeof data.id === \"string\") {\n keys.push(recordKeyOf(data.type, data.id));\n }\n\n const segments = String(entry.path ?? \"\")\n .split(\"?\")[0]\n .split(\"/\")\n .filter(Boolean);\n for (let index = segments.length - 1; index >= 0; index--) {\n if (!typeNames.has(segments[index])) continue;\n if (index + 1 < segments.length) keys.push(recordKeyOf(segments[index], segments[index + 1]));\n break;\n }\n return keys;\n}\n\n/**\n * Every record with a waiting change: targeted by a queue entry that is pending, sending, in\n * conflict or failed. Such a record is never overwritten or deleted by a sync or a write-through.\n */\nexport function waitingRecordKeys(queue: QueueEntry[], typeNames: Set<string>): Set<string> {\n const keys = new Set<string>();\n for (const entry of queue) for (const key of recordKeysOfEntry(entry, typeNames)) keys.add(key);\n return keys;\n}\n","import type { ApiData } from \"../core/interfaces/ApiData\";\nimport { getOfflineConfig, getOfflineStore, OfflineUnavailableError, rootKinds } from \"./config\";\nimport { rootIdForResource, linkKindFor, linkKindsOf, linksOfKind } from \"./generic-answers\";\nimport { splitApiUrl } from \"./local-transport\";\nimport { matchPattern } from \"./router\";\nimport type { DeviceStore, StoredLink } from \"./store/DeviceStore\";\nimport type { OfflineTypeConfig } from \"./types\";\nimport { cacheArtworkImage, imageUrlOf } from \"./sync/artwork-cache\";\nimport { knownRootIds } from \"./sync/known-roots\";\nimport { recordKeyOf, waitingRecordKeys } from \"./sync/waiting\";\n\nexport type WriteThroughRequest = { method: string; url: string };\n\nfunction updatedAtOf(resource: any): Date | null {\n const value = resource?.attributes?.updatedAt;\n if (!value) return null;\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n}\n\ntype Identifier = { type: string; id: string };\n\nfunction identifiersOf(relationship: any): Identifier[] {\n const data = relationship?.data;\n if (!data) return [];\n return (Array.isArray(data) ? data : [data]).filter((item: any) => item && item.type && item.id);\n}\n\n/**\n * Brings the stored links of the written record in line with the relationships the answer\n * carries (only those whose `data` it holds), as the local answers do: a link of the\n * relationship (its name or mapped Neo4j type; any kind when the type is not mapped, for an\n * identifier the record held before) to an identifier no longer there is removed, and a new\n * identifier gets a link of `linkKindFor` the relationship.\n */\nasync function updateLinks(\n store: DeviceStore,\n typeConfig: OfflineTypeConfig | undefined,\n record: Identifier,\n before: any,\n after: any,\n): Promise<void> {\n const otherEnd = (link: StoredLink) => (link.fromId === record.id ? link.toId : link.fromId);\n const allLinks = async (): Promise<StoredLink[]> => [\n ...(await store.linksFrom(record.id)),\n ...(await store.linksTo(record.id)),\n ];\n\n for (const [name, relationship] of Object.entries<any>(after ?? {})) {\n if (!relationship || !(\"data\" in relationship)) continue;\n const next = new Map(identifiersOf(relationship).map((identifier) => [identifier.id, identifier]));\n const previous = new Set(identifiersOf(before?.[name]).map((identifier) => identifier.id));\n const kinds = linkKindsOf(typeConfig, name) ?? [name];\n const ofRelationship = await linksOfKind(store, record.id, kinds, \"both\");\n const mapped = linkKindsOf(typeConfig, name) !== undefined;\n\n const stale = [\n ...ofRelationship.filter((link) => !next.has(otherEnd(link))),\n // Unmapped: the link to an identifier the record held before may carry any kind.\n ...(mapped ? [] : (await allLinks()).filter((link) => previous.has(otherEnd(link)) && !next.has(otherEnd(link)))),\n ];\n for (const link of stale) await store.deleteLink({ fromId: link.fromId, toId: link.toId, kind: link.kind });\n\n const linked = new Set(\n (mapped ? await linksOfKind(store, record.id, kinds, \"both\") : await allLinks()).map(otherEnd),\n );\n for (const [id, identifier] of next) {\n if (linked.has(id)) continue;\n await store.putLink({\n fromType: record.type,\n fromId: record.id,\n toType: identifier.type,\n toId: id,\n kind: linkKindFor(typeConfig, name),\n props: {},\n });\n }\n }\n}\n\ntype ImageChange = { url: string; previousUrl?: string };\n\nasync function storeResource(\n store: DeviceStore,\n resource: any,\n pathRootId: string | undefined,\n waiting: Set<string>,\n kept: Set<string>,\n primary: boolean,\n images: ImageChange[],\n): Promise<void> {\n const config = getOfflineConfig();\n if (!resource?.type || !resource?.id) return;\n if (!config.types.some((typeConfig) => typeConfig.module.name === resource.type)) return;\n // A record with unsent local changes keeps them: the next sync, once they are sent, brings\n // the server's version.\n if (waiting.has(recordKeyOf(resource.type, resource.id))) return;\n\n const existing = await store.getRecord(resource.type, resource.id);\n if (existing && existing.base !== null) return;\n const rootId = existing?.rootId ?? (await rootIdForResource(store, config, resource)) ?? pathRootId;\n // A record that belongs to no root record on this device waits for the next sync.\n if (!rootId) return;\n // Only the root records the device keeps are written through (never a player's root record).\n if (!kept.has(rootId)) return;\n\n // An answer can carry a sparse resource (fields limited): it is merged onto what is stored.\n const before = existing?.resource ?? {};\n const merged = {\n ...before,\n ...resource,\n attributes: { ...(before.attributes ?? {}), ...(resource.attributes ?? {}) },\n relationships: { ...(before.relationships ?? {}), ...(resource.relationships ?? {}) },\n };\n\n await store.putRecord({\n type: resource.type,\n id: resource.id,\n rootId,\n resource: merged,\n updatedAt: updatedAtOf(resource) ?? existing?.updatedAt ?? null,\n base: null,\n localOnly: false,\n });\n if (primary) {\n const typeConfig = config.types.find((candidate) => candidate.module.name === resource.type);\n await updateLinks(store, typeConfig, resource, before.relationships, resource.relationships);\n }\n\n const url = imageUrlOf(merged);\n const previousUrl = imageUrlOf(existing?.resource);\n if (url && url !== previousUrl) images.push({ url, previousUrl });\n}\n\n/**\n * After a successful online write, copies the answer into the device copy so it is never behind\n * the GM's own work: the resource and its `included` for POST/PUT/PATCH, the record removed for a\n * DELETE. It never fails the request: a problem is logged and the next sync repairs the copy.\n */\nexport async function writeThrough(request: WriteThroughRequest, response: ApiData): Promise<void> {\n const method = request.method.toUpperCase();\n if (method === \"GET\" || !response.ok) return;\n\n try {\n const config = getOfflineConfig();\n if (!config.getUserId()) return;\n const { path } = splitApiUrl(request.url);\n const store = await getOfflineStore();\n\n if (method === \"DELETE\") {\n for (const typeConfig of config.types) {\n const params = matchPattern([typeConfig.module, \":id\"], path);\n if (params) {\n await store.deleteRecord(typeConfig.module.name, params.id);\n return;\n }\n }\n return;\n }\n\n // A path under a root record of any kind (`<root module>/:rootId/...`).\n const rootSegments = path.split(\"/\").slice(0, 2).join(\"/\");\n const pathRootId = rootKinds(config)\n .map((kind) => matchPattern([kind.module, \":rootId\"], rootSegments)?.rootId)\n .find((rootId) => rootId !== undefined);\n\n const document = response.data;\n const primary = Array.isArray(document?.data) ? document.data : document?.data ? [document.data] : [];\n const waiting = waitingRecordKeys(\n await store.queue(),\n new Set(config.types.map((typeConfig) => typeConfig.module.name)),\n );\n // The root records this device keeps for the signed-in user (stored roots, waiting changes, last\n // sync roots): a write in any other root record (a player's) stores nothing.\n const kept = new Set(await knownRootIds(store));\n const images: ImageChange[] = [];\n await store.transaction(async (transactionStore) => {\n for (const resource of primary) {\n await storeResource(transactionStore, resource, pathRootId, waiting, kept, true, images);\n }\n for (const resource of document?.included ?? []) {\n await storeResource(transactionStore, resource, pathRootId, waiting, kept, false, images);\n }\n });\n // A new image URL of an artwork: downloaded, the old cached image removed (as the sync does).\n for (const image of images) await cacheArtworkImage(image.url, image.previousUrl);\n } catch (error) {\n // A browser that cannot keep the device copy was already warned about once.\n if (error instanceof OfflineUnavailableError) return;\n console.warn(\"[offline] could not copy the answer to the device\", error);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAI,iBAA2B,CAAC;AAChC,IAAI,sBAAgC,CAAC;AAM9B,SAAS,kBAAkB,KAAe,WAAqB,CAAC,GAAS;AAC9E,mBAAiB,CAAC,GAAG,GAAG;AACxB,wBAAsB,CAAC,GAAG,QAAQ;AACpC;AAHgB;AAUhB,eAAsB,aAAa,OAAuC;AACxE,QAAM,SAAS,iBAAiB;AAChC,QAAM,MAAM,IAAI,IAAY,cAAc;AAC1C,aAAW,QAAQ,UAAU,MAAM,GAAG;AACpC,eAAW,UAAU,MAAM,MAAM,YAAY,EAAE,MAAM,KAAK,OAAO,KAAK,CAAC,EAAG,KAAI,IAAI,OAAO,EAAE;AAAA,EAC7F;AACA,aAAW,SAAS,MAAM,MAAM,MAAM,EAAG,KAAI,IAAI,MAAM,MAAM;AAC7D,SAAO,CAAC,GAAG,GAAG,EAAE,KAAK;AACvB;AARsB;AAWtB,eAAe,aAAa,OAA0C;AACpE,QAAM,MAAM,IAAI,IAAY,mBAAmB;AAC/C,aAAW,QAAQ,iBAAiB,EAAE,kBAAkB,CAAC,GAAG;AAC1D,eAAW,UAAU,MAAM,MAAM,YAAY,EAAE,MAAM,KAAK,OAAO,KAAK,CAAC,EAAG,KAAI,IAAI,OAAO,EAAE;AAAA,EAC7F;AACA,SAA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,OAAM,kBAAkB,MAAM,KAAK,MAAM,WAAW;AAAA,EAClF,SAAS,OAAO;AAEd,QAAI,iBAAiB,wBAAyB;AAC9C,YAAQ,KAAK,qDAAqD,KAAK;AAAA,EACzE;AACF;AApDsB;","names":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkWCEYT3GGjs = require('./chunk-WCEYT3GG.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkGM4VZTWLjs = require('./chunk-GM4VZTWL.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _chunkLXKSUWAVjs = require('./chunk-LXKSUWAV.js');
|
|
@@ -22,7 +22,7 @@ var _clientConfig = null;
|
|
|
22
22
|
function configureClientJsonApi(config) {
|
|
23
23
|
_clientConfig = config;
|
|
24
24
|
if (config.bootstrapper) {
|
|
25
|
-
|
|
25
|
+
_chunkGM4VZTWLjs.setBootstrapper.call(void 0, config.bootstrapper);
|
|
26
26
|
config.bootstrapper();
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -31,7 +31,7 @@ function getClientApiUrl() {
|
|
|
31
31
|
if (_optionalChain([_clientConfig, 'optionalAccess', _ => _.apiUrl])) {
|
|
32
32
|
return _clientConfig.apiUrl;
|
|
33
33
|
}
|
|
34
|
-
const envUrl =
|
|
34
|
+
const envUrl = _chunkGM4VZTWLjs.ENV.API_URL;
|
|
35
35
|
if (!envUrl) {
|
|
36
36
|
throw new Error(
|
|
37
37
|
"API URL not configured. Use configureClientJsonApi() or set NEXT_PUBLIC_API_URL environment variable."
|
|
@@ -44,7 +44,7 @@ function getClientAppUrl() {
|
|
|
44
44
|
if (_optionalChain([_clientConfig, 'optionalAccess', _2 => _2.appUrl])) {
|
|
45
45
|
return _clientConfig.appUrl;
|
|
46
46
|
}
|
|
47
|
-
const envUrl =
|
|
47
|
+
const envUrl = _chunkGM4VZTWLjs.ENV.APP_URL;
|
|
48
48
|
if (!envUrl) {
|
|
49
49
|
throw new Error(
|
|
50
50
|
"App URL not configured. Use configureClientJsonApi({ appUrl }) or set NEXT_PUBLIC_ADDRESS environment variable."
|
|
@@ -72,7 +72,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, buildClientUrl, "buildClientUrl");
|
|
|
72
72
|
async function ClientJsonApiGet(params) {
|
|
73
73
|
runClientBootstrapper();
|
|
74
74
|
const token = await _chunkLXKSUWAVjs.getClientToken.call(void 0, );
|
|
75
|
-
const apiResponse = await
|
|
75
|
+
const apiResponse = await _chunkWCEYT3GGjs.directFetch.call(void 0, {
|
|
76
76
|
method: "GET",
|
|
77
77
|
url: buildClientUrl(params.endpoint, params.baseUrl),
|
|
78
78
|
token,
|
|
@@ -80,7 +80,7 @@ async function ClientJsonApiGet(params) {
|
|
|
80
80
|
language: params.language,
|
|
81
81
|
additionalHeaders: _optionalChain([_clientConfig, 'optionalAccess', _5 => _5.additionalHeaders])
|
|
82
82
|
});
|
|
83
|
-
return
|
|
83
|
+
return _chunkGM4VZTWLjs.translateResponse.call(void 0, {
|
|
84
84
|
classKey: params.classKey,
|
|
85
85
|
apiResponse,
|
|
86
86
|
companyId: params.companyId,
|
|
@@ -102,9 +102,9 @@ async function ClientJsonApiPost(params) {
|
|
|
102
102
|
if (!body) {
|
|
103
103
|
body = {};
|
|
104
104
|
} else if (params.overridesJsonApiCreation !== true) {
|
|
105
|
-
body =
|
|
105
|
+
body = _chunkGM4VZTWLjs.JsonApiDataFactory.create(params.classKey, body);
|
|
106
106
|
}
|
|
107
|
-
const apiResponse = await
|
|
107
|
+
const apiResponse = await _chunkWCEYT3GGjs.directFetch.call(void 0, {
|
|
108
108
|
method: "POST",
|
|
109
109
|
url: buildClientUrl(params.endpoint, params.baseUrl),
|
|
110
110
|
token,
|
|
@@ -114,7 +114,7 @@ async function ClientJsonApiPost(params) {
|
|
|
114
114
|
language: params.language,
|
|
115
115
|
additionalHeaders: _optionalChain([_clientConfig, 'optionalAccess', _6 => _6.additionalHeaders])
|
|
116
116
|
});
|
|
117
|
-
return
|
|
117
|
+
return _chunkGM4VZTWLjs.translateResponse.call(void 0, {
|
|
118
118
|
classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
|
|
119
119
|
apiResponse,
|
|
120
120
|
companyId: params.companyId,
|
|
@@ -129,9 +129,9 @@ async function ClientJsonApiPut(params) {
|
|
|
129
129
|
if (!body) {
|
|
130
130
|
body = {};
|
|
131
131
|
} else {
|
|
132
|
-
body =
|
|
132
|
+
body = _chunkGM4VZTWLjs.JsonApiDataFactory.create(params.classKey, body);
|
|
133
133
|
}
|
|
134
|
-
const apiResponse = await
|
|
134
|
+
const apiResponse = await _chunkWCEYT3GGjs.directFetch.call(void 0, {
|
|
135
135
|
method: "PUT",
|
|
136
136
|
url: buildClientUrl(params.endpoint, params.baseUrl),
|
|
137
137
|
token,
|
|
@@ -141,7 +141,7 @@ async function ClientJsonApiPut(params) {
|
|
|
141
141
|
language: params.language,
|
|
142
142
|
additionalHeaders: _optionalChain([_clientConfig, 'optionalAccess', _7 => _7.additionalHeaders])
|
|
143
143
|
});
|
|
144
|
-
return
|
|
144
|
+
return _chunkGM4VZTWLjs.translateResponse.call(void 0, {
|
|
145
145
|
classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
|
|
146
146
|
apiResponse,
|
|
147
147
|
companyId: params.companyId,
|
|
@@ -156,9 +156,9 @@ async function ClientJsonApiPatch(params) {
|
|
|
156
156
|
if (!body) {
|
|
157
157
|
body = {};
|
|
158
158
|
} else if (params.overridesJsonApiCreation !== true) {
|
|
159
|
-
body =
|
|
159
|
+
body = _chunkGM4VZTWLjs.JsonApiDataFactory.create(params.classKey, body);
|
|
160
160
|
}
|
|
161
|
-
const apiResponse = await
|
|
161
|
+
const apiResponse = await _chunkWCEYT3GGjs.directFetch.call(void 0, {
|
|
162
162
|
method: "PATCH",
|
|
163
163
|
url: buildClientUrl(params.endpoint, params.baseUrl),
|
|
164
164
|
token,
|
|
@@ -168,7 +168,7 @@ async function ClientJsonApiPatch(params) {
|
|
|
168
168
|
language: params.language,
|
|
169
169
|
additionalHeaders: _optionalChain([_clientConfig, 'optionalAccess', _8 => _8.additionalHeaders])
|
|
170
170
|
});
|
|
171
|
-
return
|
|
171
|
+
return _chunkGM4VZTWLjs.translateResponse.call(void 0, {
|
|
172
172
|
classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
|
|
173
173
|
apiResponse,
|
|
174
174
|
companyId: params.companyId,
|
|
@@ -179,7 +179,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, ClientJsonApiPatch, "ClientJsonApiPatch");
|
|
|
179
179
|
async function ClientJsonApiDelete(params) {
|
|
180
180
|
runClientBootstrapper();
|
|
181
181
|
const token = await _chunkLXKSUWAVjs.getClientToken.call(void 0, );
|
|
182
|
-
const apiResponse = await
|
|
182
|
+
const apiResponse = await _chunkWCEYT3GGjs.directFetch.call(void 0, {
|
|
183
183
|
method: "DELETE",
|
|
184
184
|
url: buildClientUrl(params.endpoint, params.baseUrl),
|
|
185
185
|
token,
|
|
@@ -187,7 +187,7 @@ async function ClientJsonApiDelete(params) {
|
|
|
187
187
|
language: params.language,
|
|
188
188
|
additionalHeaders: _optionalChain([_clientConfig, 'optionalAccess', _9 => _9.additionalHeaders])
|
|
189
189
|
});
|
|
190
|
-
return
|
|
190
|
+
return _chunkGM4VZTWLjs.translateResponse.call(void 0, {
|
|
191
191
|
classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
|
|
192
192
|
apiResponse,
|
|
193
193
|
companyId: params.companyId,
|
|
@@ -209,4 +209,4 @@ _chunk7QVYU63Ejs.__name.call(void 0, ClientJsonApiDelete, "ClientJsonApiDelete")
|
|
|
209
209
|
|
|
210
210
|
|
|
211
211
|
exports.CURRENT_USER_STORAGE_KEY = CURRENT_USER_STORAGE_KEY; exports.configureClientJsonApi = configureClientJsonApi; exports.getClientApiUrl = getClientApiUrl; exports.getClientAppUrl = getClientAppUrl; exports.getClientTrackablePages = getClientTrackablePages; exports.buildClientUrl = buildClientUrl; exports.ClientJsonApiGet = ClientJsonApiGet; exports.ClientJsonApiPost = ClientJsonApiPost; exports.ClientJsonApiPut = ClientJsonApiPut; exports.ClientJsonApiPatch = ClientJsonApiPatch; exports.ClientJsonApiDelete = ClientJsonApiDelete;
|
|
212
|
-
//# sourceMappingURL=chunk-
|
|
212
|
+
//# sourceMappingURL=chunk-KV4N7DEG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-PV4Z5W6V.js","../src/features/user/data/user.storage.ts","../src/client/JsonApiClient.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACRO,IAAM,yBAAA,EAA2B,MAAA;ADUxC;AACA;AENA,IAAI,cAAA,EAMO,IAAA;AAMJ,SAAS,sBAAA,CAAuB,MAAA,EAM9B;AACP,EAAA,cAAA,EAAgB,MAAA;AAChB,EAAA,GAAA,CAAI,MAAA,CAAO,YAAA,EAAc;AACvB,IAAA,8CAAA,MAAgB,CAAO,YAAY,CAAA;AACnC,IAAA,MAAA,CAAO,YA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A;AACD,EAAA;AAEM,EAAA;AACL,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACD,EAAA;AACH;AAtCsB;AAwCtB;AAQE,EAAA;AACM,EAAA;AAEA,EAAA;AACJ,IAAA;AACK,IAAA;AACL,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACD,EAAA;AAEM,EAAA;AACL,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACD,EAAA;AACH;AA1BsB;AF9CZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-PV4Z5W6V.js","sourcesContent":[null,"/**\n * localStorage key backing the `CurrentUserProvider` atom.\n *\n * Owned by this library, not by the apps that consume it: `<Logout />` clears\n * it on every sign-out. Kept in its own module so both the provider that writes\n * it and the component that clears it can reference the same constant without\n * importing each other.\n */\nexport const CURRENT_USER_STORAGE_KEY = \"user\";\n","\"use client\";\n\nimport { ENV } from \"../core/env\";\nimport { JsonApiDataFactory } from \"../core/factories/JsonApiDataFactory\";\nimport { ApiRequestDataTypeInterface } from \"../core/interfaces/ApiRequestDataTypeInterface\";\nimport { ApiResponseInterface } from \"../core/interfaces/ApiResponseInterface\";\nimport { setBootstrapper } from \"../core/registry/bootstrapStore\";\nimport { translateResponse } from \"../core/utils/translateResponse\";\nimport { ModuleWithPermissions } from \"../permissions/types\";\nimport { directFetch } from \"./request\";\nimport { getClientToken } from \"./token\";\n\n// Config storage for client contexts\nlet _clientConfig: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n bootstrapper?: () => void;\n additionalHeaders?: Record<string, string>;\n} | null = null;\n\n/**\n * Configure the JSON:API client for browser contexts.\n * Call this in your client-side initialization or use JsonApiProvider.\n */\nexport function configureClientJsonApi(config: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n bootstrapper?: () => void;\n additionalHeaders?: Record<string, string>;\n}): void {\n _clientConfig = config;\n if (config.bootstrapper) {\n setBootstrapper(config.bootstrapper);\n config.bootstrapper();\n }\n}\n\nexport function getClientApiUrl(): string {\n if (_clientConfig?.apiUrl) {\n return _clientConfig.apiUrl;\n }\n const envUrl = ENV.API_URL;\n if (!envUrl) {\n throw new Error(\n \"API URL not configured. Use configureClientJsonApi() or set NEXT_PUBLIC_API_URL environment variable.\",\n );\n }\n return envUrl;\n}\n\nexport function getClientAppUrl(): string {\n if (_clientConfig?.appUrl) {\n return _clientConfig.appUrl;\n }\n const envUrl = ENV.APP_URL;\n if (!envUrl) {\n throw new Error(\n \"App URL not configured. Use configureClientJsonApi({ appUrl }) or set NEXT_PUBLIC_ADDRESS environment variable.\",\n );\n }\n return envUrl.trim().replace(/\\/+$/, \"\");\n}\n\nexport function getClientTrackablePages(): ModuleWithPermissions[] {\n return _clientConfig?.trackablePages ?? [];\n}\n\nfunction runClientBootstrapper(): void {\n if (_clientConfig?.bootstrapper) {\n _clientConfig.bootstrapper();\n }\n}\n\n/**\n * Resolve the final request URL for an endpoint (client-side variant of `buildUrl`\n * in `unified/JsonApiRequest.ts` — kept in lockstep with it).\n *\n * - `endpoint` starting with \"http\" is always passed through unchanged (existing behaviour).\n * - Otherwise, an explicit `baseUrl` (per-call override) takes precedence over the global\n * `getClientApiUrl()` resolution. Omitting `baseUrl` preserves today's behaviour exactly.\n */\nexport function buildClientUrl(endpoint: string, baseUrl?: string): string {\n if (endpoint.startsWith(\"http\")) return endpoint;\n const apiUrl = baseUrl ?? getClientApiUrl();\n return `${apiUrl}${endpoint}`;\n}\n\nexport async function ClientJsonApiGet(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n language: string;\n baseUrl?: string;\n}): Promise<ApiResponseInterface> {\n runClientBootstrapper();\n const token = await getClientToken();\n\n const apiResponse = await directFetch({\n method: \"GET\",\n url: buildClientUrl(params.endpoint, params.baseUrl),\n token,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _clientConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n paginationHandler: async (endpoint: string) =>\n ClientJsonApiGet({\n classKey: params.classKey,\n endpoint,\n companyId: params.companyId,\n language: params.language,\n baseUrl: params.baseUrl,\n }),\n });\n}\n\nexport async function ClientJsonApiPost(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n body?: any;\n overridesJsonApiCreation?: boolean;\n files?: { [key: string]: File | Blob } | File | Blob;\n language: string;\n responseType?: ApiRequestDataTypeInterface;\n baseUrl?: string;\n}): Promise<ApiResponseInterface> {\n runClientBootstrapper();\n const token = await getClientToken();\n\n let body = params.body;\n if (!body) {\n body = {};\n } else if (params.overridesJsonApiCreation !== true) {\n body = JsonApiDataFactory.create(params.classKey, body);\n }\n\n const apiResponse = await directFetch({\n method: \"POST\",\n url: buildClientUrl(params.endpoint, params.baseUrl),\n token,\n body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _clientConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n\nexport async function ClientJsonApiPut(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n body?: any;\n files?: { [key: string]: File | Blob } | File | Blob;\n language: string;\n responseType?: ApiRequestDataTypeInterface;\n baseUrl?: string;\n}): Promise<ApiResponseInterface> {\n runClientBootstrapper();\n const token = await getClientToken();\n\n let body = params.body;\n if (!body) {\n body = {};\n } else {\n body = JsonApiDataFactory.create(params.classKey, body);\n }\n\n const apiResponse = await directFetch({\n method: \"PUT\",\n url: buildClientUrl(params.endpoint, params.baseUrl),\n token,\n body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _clientConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n\nexport async function ClientJsonApiPatch(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n body?: any;\n files?: { [key: string]: File | Blob } | File | Blob;\n overridesJsonApiCreation?: boolean;\n responseType?: ApiRequestDataTypeInterface;\n language: string;\n baseUrl?: string;\n}): Promise<ApiResponseInterface> {\n runClientBootstrapper();\n const token = await getClientToken();\n\n let body = params.body;\n if (!body) {\n body = {};\n } else if (params.overridesJsonApiCreation !== true) {\n body = JsonApiDataFactory.create(params.classKey, body);\n }\n\n const apiResponse = await directFetch({\n method: \"PATCH\",\n url: buildClientUrl(params.endpoint, params.baseUrl),\n token,\n body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _clientConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n\nexport async function ClientJsonApiDelete(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n language: string;\n responseType?: ApiRequestDataTypeInterface;\n baseUrl?: string;\n}): Promise<ApiResponseInterface> {\n runClientBootstrapper();\n const token = await getClientToken();\n\n const apiResponse = await directFetch({\n method: \"DELETE\",\n url: buildClientUrl(params.endpoint, params.baseUrl),\n token,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _clientConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-KV4N7DEG.js","../src/features/user/data/user.storage.ts","../src/client/JsonApiClient.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5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EM,EAAA;AACL,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACD,EAAA;AACH;AArCsB;AAuCtB;AAWE,EAAA;AACM,EAAA;AAEF,EAAA;AACC,EAAA;AACH,IAAA;AACF,EAAA;AACE,IAAA;AACF,EAAA;AAEM,EAAA;AACJ,IAAA;AACK,IAAA;AACL,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACD,EAAA;AAEM,EAAA;AACL,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACD,EAAA;AACH;AAtCsB;AAwCtB;AAQE,EAAA;AACM,EAAA;AAEA,EAAA;AACJ,IAAA;AACK,IAAA;AACL,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACD,EAAA;AAEM,EAAA;AACL,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACD,EAAA;AACH;AA1BsB;AF9CZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-KV4N7DEG.js","sourcesContent":[null,"/**\n * localStorage key backing the `CurrentUserProvider` atom.\n *\n * Owned by this library, not by the apps that consume it: `<Logout />` clears\n * it on every sign-out. Kept in its own module so both the provider that writes\n * it and the component that clears it can reference the same constant without\n * importing each other.\n */\nexport const CURRENT_USER_STORAGE_KEY = \"user\";\n","\"use client\";\n\nimport { ENV } from \"../core/env\";\nimport { JsonApiDataFactory } from \"../core/factories/JsonApiDataFactory\";\nimport { ApiRequestDataTypeInterface } from \"../core/interfaces/ApiRequestDataTypeInterface\";\nimport { ApiResponseInterface } from \"../core/interfaces/ApiResponseInterface\";\nimport { setBootstrapper } from \"../core/registry/bootstrapStore\";\nimport { translateResponse } from \"../core/utils/translateResponse\";\nimport { ModuleWithPermissions } from \"../permissions/types\";\nimport { directFetch } from \"./request\";\nimport { getClientToken } from \"./token\";\n\n// Config storage for client contexts\nlet _clientConfig: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n bootstrapper?: () => void;\n additionalHeaders?: Record<string, string>;\n} | null = null;\n\n/**\n * Configure the JSON:API client for browser contexts.\n * Call this in your client-side initialization or use JsonApiProvider.\n */\nexport function configureClientJsonApi(config: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n bootstrapper?: () => void;\n additionalHeaders?: Record<string, string>;\n}): void {\n _clientConfig = config;\n if (config.bootstrapper) {\n setBootstrapper(config.bootstrapper);\n config.bootstrapper();\n }\n}\n\nexport function getClientApiUrl(): string {\n if (_clientConfig?.apiUrl) {\n return _clientConfig.apiUrl;\n }\n const envUrl = ENV.API_URL;\n if (!envUrl) {\n throw new Error(\n \"API URL not configured. Use configureClientJsonApi() or set NEXT_PUBLIC_API_URL environment variable.\",\n );\n }\n return envUrl;\n}\n\nexport function getClientAppUrl(): string {\n if (_clientConfig?.appUrl) {\n return _clientConfig.appUrl;\n }\n const envUrl = ENV.APP_URL;\n if (!envUrl) {\n throw new Error(\n \"App URL not configured. Use configureClientJsonApi({ appUrl }) or set NEXT_PUBLIC_ADDRESS environment variable.\",\n );\n }\n return envUrl.trim().replace(/\\/+$/, \"\");\n}\n\nexport function getClientTrackablePages(): ModuleWithPermissions[] {\n return _clientConfig?.trackablePages ?? [];\n}\n\nfunction runClientBootstrapper(): void {\n if (_clientConfig?.bootstrapper) {\n _clientConfig.bootstrapper();\n }\n}\n\n/**\n * Resolve the final request URL for an endpoint (client-side variant of `buildUrl`\n * in `unified/JsonApiRequest.ts` — kept in lockstep with it).\n *\n * - `endpoint` starting with \"http\" is always passed through unchanged (existing behaviour).\n * - Otherwise, an explicit `baseUrl` (per-call override) takes precedence over the global\n * `getClientApiUrl()` resolution. Omitting `baseUrl` preserves today's behaviour exactly.\n */\nexport function buildClientUrl(endpoint: string, baseUrl?: string): string {\n if (endpoint.startsWith(\"http\")) return endpoint;\n const apiUrl = baseUrl ?? getClientApiUrl();\n return `${apiUrl}${endpoint}`;\n}\n\nexport async function ClientJsonApiGet(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n language: string;\n baseUrl?: string;\n}): Promise<ApiResponseInterface> {\n runClientBootstrapper();\n const token = await getClientToken();\n\n const apiResponse = await directFetch({\n method: \"GET\",\n url: buildClientUrl(params.endpoint, params.baseUrl),\n token,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _clientConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n paginationHandler: async (endpoint: string) =>\n ClientJsonApiGet({\n classKey: params.classKey,\n endpoint,\n companyId: params.companyId,\n language: params.language,\n baseUrl: params.baseUrl,\n }),\n });\n}\n\nexport async function ClientJsonApiPost(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n body?: any;\n overridesJsonApiCreation?: boolean;\n files?: { [key: string]: File | Blob } | File | Blob;\n language: string;\n responseType?: ApiRequestDataTypeInterface;\n baseUrl?: string;\n}): Promise<ApiResponseInterface> {\n runClientBootstrapper();\n const token = await getClientToken();\n\n let body = params.body;\n if (!body) {\n body = {};\n } else if (params.overridesJsonApiCreation !== true) {\n body = JsonApiDataFactory.create(params.classKey, body);\n }\n\n const apiResponse = await directFetch({\n method: \"POST\",\n url: buildClientUrl(params.endpoint, params.baseUrl),\n token,\n body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _clientConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n\nexport async function ClientJsonApiPut(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n body?: any;\n files?: { [key: string]: File | Blob } | File | Blob;\n language: string;\n responseType?: ApiRequestDataTypeInterface;\n baseUrl?: string;\n}): Promise<ApiResponseInterface> {\n runClientBootstrapper();\n const token = await getClientToken();\n\n let body = params.body;\n if (!body) {\n body = {};\n } else {\n body = JsonApiDataFactory.create(params.classKey, body);\n }\n\n const apiResponse = await directFetch({\n method: \"PUT\",\n url: buildClientUrl(params.endpoint, params.baseUrl),\n token,\n body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _clientConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n\nexport async function ClientJsonApiPatch(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n body?: any;\n files?: { [key: string]: File | Blob } | File | Blob;\n overridesJsonApiCreation?: boolean;\n responseType?: ApiRequestDataTypeInterface;\n language: string;\n baseUrl?: string;\n}): Promise<ApiResponseInterface> {\n runClientBootstrapper();\n const token = await getClientToken();\n\n let body = params.body;\n if (!body) {\n body = {};\n } else if (params.overridesJsonApiCreation !== true) {\n body = JsonApiDataFactory.create(params.classKey, body);\n }\n\n const apiResponse = await directFetch({\n method: \"PATCH\",\n url: buildClientUrl(params.endpoint, params.baseUrl),\n token,\n body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _clientConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n\nexport async function ClientJsonApiDelete(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n language: string;\n responseType?: ApiRequestDataTypeInterface;\n baseUrl?: string;\n}): Promise<ApiResponseInterface> {\n runClientBootstrapper();\n const token = await getClientToken();\n\n const apiResponse = await directFetch({\n method: \"DELETE\",\n url: buildClientUrl(params.endpoint, params.baseUrl),\n token,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _clientConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
isOfflineConfigured,
|
|
5
5
|
reachesNetworkWhileOffline,
|
|
6
6
|
setOfflineState
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-4ZJIUTIV.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
10
|
} from "./chunk-PAWJFY3S.mjs";
|
|
@@ -21,7 +21,7 @@ async function directFetch(params) {
|
|
|
21
21
|
return answerLocally(params);
|
|
22
22
|
}
|
|
23
23
|
if (offline && response.ok && params.method.toUpperCase() !== "GET") {
|
|
24
|
-
const { writeThrough } = await import("./write-through-
|
|
24
|
+
const { writeThrough } = await import("./write-through-IWQKXYHE.mjs");
|
|
25
25
|
await writeThrough({ method: params.method, url: params.url }, response);
|
|
26
26
|
}
|
|
27
27
|
return response;
|
|
@@ -33,7 +33,7 @@ function hasReplayHeader(headers) {
|
|
|
33
33
|
}
|
|
34
34
|
__name(hasReplayHeader, "hasReplayHeader");
|
|
35
35
|
async function answerLocally(params) {
|
|
36
|
-
const { localTransport } = await import("./local-transport-
|
|
36
|
+
const { localTransport } = await import("./local-transport-C7YTA4I7.mjs");
|
|
37
37
|
return localTransport({ method: params.method, url: params.url, body: params.body, files: params.files });
|
|
38
38
|
}
|
|
39
39
|
__name(answerLocally, "answerLocally");
|
|
@@ -110,4 +110,4 @@ __name(fetchFromApi, "fetchFromApi");
|
|
|
110
110
|
export {
|
|
111
111
|
directFetch
|
|
112
112
|
};
|
|
113
|
-
//# sourceMappingURL=chunk-
|
|
113
|
+
//# sourceMappingURL=chunk-M3N7LPHX.mjs.map
|
|
@@ -292,7 +292,7 @@ __name(getToken, "getToken");
|
|
|
292
292
|
async function makeRequest(params) {
|
|
293
293
|
if (typeof window !== "undefined") {
|
|
294
294
|
if (!_directFetch) {
|
|
295
|
-
const clientModule = await import("./request-
|
|
295
|
+
const clientModule = await import("./request-66FGJIHB.mjs");
|
|
296
296
|
_directFetch = clientModule.directFetch;
|
|
297
297
|
}
|
|
298
298
|
return _directFetch({
|
|
@@ -516,4 +516,4 @@ export {
|
|
|
516
516
|
JsonApiPatch,
|
|
517
517
|
JsonApiDelete
|
|
518
518
|
};
|
|
519
|
-
//# sourceMappingURL=chunk-
|
|
519
|
+
//# sourceMappingURL=chunk-MQ7TXALH.mjs.map
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkKV4N7DEGjs = require('./chunk-KV4N7DEG.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var _chunkMHB36MYEjs = require('./chunk-MHB36MYE.js');
|
|
12
11
|
|
|
12
|
+
var _chunkWUNSG3INjs = require('./chunk-WUNSG3IN.js');
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
var _chunkGM4VZTWLjs = require('./chunk-GM4VZTWL.js');
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
var _chunk7QVYU63Ejs = require('./chunk-7QVYU63E.js');
|
|
@@ -38,7 +39,7 @@ async function singleAnswer(store, record, status = 200) {
|
|
|
38
39
|
}
|
|
39
40
|
_chunk7QVYU63Ejs.__name.call(void 0, singleAnswer, "singleAnswer");
|
|
40
41
|
function isRootWriteLocked(rootId) {
|
|
41
|
-
return !!rootId &&
|
|
42
|
+
return !!rootId && _chunkWUNSG3INjs.getOfflineState.call(void 0, ).lockedRootIds.includes(rootId);
|
|
42
43
|
}
|
|
43
44
|
_chunk7QVYU63Ejs.__name.call(void 0, isRootWriteLocked, "isRootWriteLocked");
|
|
44
45
|
function identifiersOf(relationship) {
|
|
@@ -90,8 +91,8 @@ async function includedFor(store, records) {
|
|
|
90
91
|
_chunk7QVYU63Ejs.__name.call(void 0, includedFor, "includedFor");
|
|
91
92
|
function signedInUserResource(target) {
|
|
92
93
|
try {
|
|
93
|
-
if (target.id !==
|
|
94
|
-
const stored = JSON.parse(_nullishCoalesce(window.localStorage.getItem(
|
|
94
|
+
if (target.id !== _chunkWUNSG3INjs.getOfflineConfig.call(void 0, ).getUserId()) return void 0;
|
|
95
|
+
const stored = JSON.parse(_nullishCoalesce(window.localStorage.getItem(_chunkKV4N7DEGjs.CURRENT_USER_STORAGE_KEY), () => ( "null")));
|
|
95
96
|
const user = _optionalChain([stored, 'optionalAccess', _7 => _7.jsonApi]);
|
|
96
97
|
if (_optionalChain([user, 'optionalAccess', _8 => _8.type]) !== target.type || _optionalChain([user, 'optionalAccess', _9 => _9.id]) !== target.id) return void 0;
|
|
97
98
|
return { type: user.type, id: user.id, attributes: _nullishCoalesce(user.attributes, () => ( {})), meta: user.meta };
|
|
@@ -277,8 +278,8 @@ async function getOne(ctx, type) {
|
|
|
277
278
|
return singleAnswer(ctx.store, record);
|
|
278
279
|
}
|
|
279
280
|
_chunk7QVYU63Ejs.__name.call(void 0, getOne, "getOne");
|
|
280
|
-
async function rootList(ctx,
|
|
281
|
-
const rootType =
|
|
281
|
+
async function rootList(ctx, kind, typeConfig) {
|
|
282
|
+
const rootType = kind.module.name;
|
|
282
283
|
const rootId = ctx.params.rootId;
|
|
283
284
|
if (!await ctx.store.getRecord(rootType, rootId)) return notOnDeviceAnswer(rootType, rootId);
|
|
284
285
|
const records = await ctx.store.listRecords({ type: typeConfig.module.name, rootId });
|
|
@@ -320,10 +321,10 @@ async function relatedList(ctx, config, typeConfig) {
|
|
|
320
321
|
}
|
|
321
322
|
_chunk7QVYU63Ejs.__name.call(void 0, relatedList, "relatedList");
|
|
322
323
|
async function rootIdForResource(store, config, resource) {
|
|
323
|
-
const
|
|
324
|
-
if (_optionalChain([resource, 'optionalAccess', _30 => _30.type])
|
|
324
|
+
const rootTypes = new Set(_chunkWUNSG3INjs.rootKinds.call(void 0, config).map((kind) => kind.module.name));
|
|
325
|
+
if (rootTypes.has(_optionalChain([resource, 'optionalAccess', _30 => _30.type])) && resource.id) return resource.id;
|
|
325
326
|
const identifiers = Object.values(_nullishCoalesce(_optionalChain([resource, 'optionalAccess', _31 => _31.relationships]), () => ( {}))).flatMap(identifiersOf);
|
|
326
|
-
const root = identifiers.find((identifier) => identifier.type
|
|
327
|
+
const root = identifiers.find((identifier) => rootTypes.has(identifier.type));
|
|
327
328
|
if (root) return root.id;
|
|
328
329
|
for (const identifier of identifiers) {
|
|
329
330
|
const stored = await store.getRecord(identifier.type, identifier.id);
|
|
@@ -405,6 +406,16 @@ async function create(ctx, config, type) {
|
|
|
405
406
|
body: ctx.request.body,
|
|
406
407
|
base: null
|
|
407
408
|
});
|
|
409
|
+
if (_optionalChain([typeConfig, 'optionalAccess', _41 => _41.afterLocalWrite])) {
|
|
410
|
+
await typeConfig.afterLocalWrite({
|
|
411
|
+
store,
|
|
412
|
+
module: typeConfig.module,
|
|
413
|
+
id,
|
|
414
|
+
method: "POST",
|
|
415
|
+
resource,
|
|
416
|
+
previous: null
|
|
417
|
+
});
|
|
418
|
+
}
|
|
408
419
|
});
|
|
409
420
|
return singleAnswer(ctx.store, record, 201);
|
|
410
421
|
}
|
|
@@ -414,20 +425,16 @@ async function update(ctx, config, type) {
|
|
|
414
425
|
const existing = await ctx.store.getRecord(type, id);
|
|
415
426
|
if (!existing) return notOnDeviceAnswer(type, id);
|
|
416
427
|
if (isRootWriteLocked(existing.rootId)) return needsConnectionAnswer("The root record is locked");
|
|
417
|
-
const data = _nullishCoalesce(_optionalChain([ctx, 'access',
|
|
428
|
+
const data = _nullishCoalesce(_optionalChain([ctx, 'access', _42 => _42.request, 'access', _43 => _43.body, 'optionalAccess', _44 => _44.data]), () => ( {}));
|
|
418
429
|
const before = _nullishCoalesce(existing.resource, () => ( { type, id }));
|
|
419
430
|
const resource = mergeResource(before, { type, id }, data);
|
|
420
431
|
const base = existing.localOnly ? null : _nullishCoalesce(existing.base, () => ( before));
|
|
432
|
+
const typeConfig = typeConfigOf(config, type);
|
|
433
|
+
const method = ctx.request.method === "PATCH" ? "PATCH" : "PUT";
|
|
421
434
|
const record = { ...existing, resource, base, localOnly: existing.localOnly };
|
|
422
435
|
await ctx.store.transaction(async (store) => {
|
|
423
436
|
await store.putRecord(record);
|
|
424
|
-
await linkRelationships(
|
|
425
|
-
store,
|
|
426
|
-
typeConfigOf(config, type),
|
|
427
|
-
{ type, id },
|
|
428
|
-
_nullishCoalesce(before.relationships, () => ( {})),
|
|
429
|
-
_nullishCoalesce(data.relationships, () => ( {}))
|
|
430
|
-
);
|
|
437
|
+
await linkRelationships(store, typeConfig, { type, id }, _nullishCoalesce(before.relationships, () => ( {})), _nullishCoalesce(data.relationships, () => ( {})));
|
|
431
438
|
await store.enqueue({
|
|
432
439
|
rootId: existing.rootId,
|
|
433
440
|
method: ctx.request.method,
|
|
@@ -437,11 +444,14 @@ async function update(ctx, config, type) {
|
|
|
437
444
|
recordId: id,
|
|
438
445
|
base
|
|
439
446
|
});
|
|
447
|
+
if (_optionalChain([typeConfig, 'optionalAccess', _45 => _45.afterLocalWrite])) {
|
|
448
|
+
await typeConfig.afterLocalWrite({ store, module: typeConfig.module, id, method, resource, previous: before });
|
|
449
|
+
}
|
|
440
450
|
});
|
|
441
451
|
return singleAnswer(ctx.store, record);
|
|
442
452
|
}
|
|
443
453
|
_chunk7QVYU63Ejs.__name.call(void 0, update, "update");
|
|
444
|
-
async function remove(ctx, type) {
|
|
454
|
+
async function remove(ctx, config, type) {
|
|
445
455
|
const id = ctx.params.id;
|
|
446
456
|
const existing = await ctx.store.getRecord(type, id);
|
|
447
457
|
if (!existing) return notOnDeviceAnswer(type, id);
|
|
@@ -459,6 +469,17 @@ async function remove(ctx, type) {
|
|
|
459
469
|
recordId: id,
|
|
460
470
|
base
|
|
461
471
|
});
|
|
472
|
+
const typeConfig = typeConfigOf(config, type);
|
|
473
|
+
if (_optionalChain([typeConfig, 'optionalAccess', _46 => _46.afterLocalWrite])) {
|
|
474
|
+
await typeConfig.afterLocalWrite({
|
|
475
|
+
store,
|
|
476
|
+
module: typeConfig.module,
|
|
477
|
+
id,
|
|
478
|
+
method: "DELETE",
|
|
479
|
+
resource: null,
|
|
480
|
+
previous: existing.resource
|
|
481
|
+
});
|
|
482
|
+
}
|
|
462
483
|
});
|
|
463
484
|
return { status: 204, body: void 0 };
|
|
464
485
|
}
|
|
@@ -478,7 +499,9 @@ function buildGenericRoutes(config) {
|
|
|
478
499
|
for (const typeConfig of config.types) {
|
|
479
500
|
const type = typeConfig.module.name;
|
|
480
501
|
route("GET", [typeConfig.module, ":id"], (ctx) => getOne(ctx, type));
|
|
481
|
-
|
|
502
|
+
for (const kind of _chunkWUNSG3INjs.rootKinds.call(void 0, config)) {
|
|
503
|
+
route("GET", [kind.module, ":rootId", typeConfig.module], (ctx) => rootList(ctx, kind, typeConfig));
|
|
504
|
+
}
|
|
482
505
|
route(
|
|
483
506
|
"POST",
|
|
484
507
|
[typeConfig.module],
|
|
@@ -497,7 +520,7 @@ function buildGenericRoutes(config) {
|
|
|
497
520
|
route(
|
|
498
521
|
"DELETE",
|
|
499
522
|
[typeConfig.module, ":id"],
|
|
500
|
-
readOnlyGuard(typeConfig, (ctx) => remove(ctx, type))
|
|
523
|
+
readOnlyGuard(typeConfig, (ctx) => remove(ctx, config, type))
|
|
501
524
|
);
|
|
502
525
|
}
|
|
503
526
|
for (const typeConfig of config.types) {
|
|
@@ -548,7 +571,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, matchRoute, "matchRoute");
|
|
|
548
571
|
var METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
549
572
|
function apiBases() {
|
|
550
573
|
const bases = [];
|
|
551
|
-
for (const read of [
|
|
574
|
+
for (const read of [_chunkGM4VZTWLjs.getApiUrl, _chunkKV4N7DEGjs.getClientApiUrl]) {
|
|
552
575
|
try {
|
|
553
576
|
const base = read();
|
|
554
577
|
if (base) bases.push(base);
|
|
@@ -592,20 +615,20 @@ function toApiData(answer) {
|
|
|
592
615
|
}
|
|
593
616
|
_chunk7QVYU63Ejs.__name.call(void 0, toApiData, "toApiData");
|
|
594
617
|
async function rootIdForCustomWrite(store, pattern, params, rootSegmentParam) {
|
|
595
|
-
const config =
|
|
618
|
+
const config = _chunkWUNSG3INjs.getOfflineConfig.call(void 0, );
|
|
596
619
|
if (rootSegmentParam && params[rootSegmentParam]) return params[rootSegmentParam];
|
|
597
620
|
for (const value of Object.values(params)) {
|
|
598
621
|
for (const typeConfig of config.types) {
|
|
599
622
|
const stored = await store.getRecord(typeConfig.module.name, value);
|
|
600
|
-
if (_optionalChain([stored, 'optionalAccess',
|
|
623
|
+
if (_optionalChain([stored, 'optionalAccess', _47 => _47.rootId])) return stored.rootId;
|
|
601
624
|
}
|
|
602
625
|
}
|
|
603
|
-
return rootIdForResource(store, config, _optionalChain([pattern, 'access',
|
|
626
|
+
return rootIdForResource(store, config, _optionalChain([pattern, 'access', _48 => _48.body, 'optionalAccess', _49 => _49.data]));
|
|
604
627
|
}
|
|
605
628
|
_chunk7QVYU63Ejs.__name.call(void 0, rootIdForCustomWrite, "rootIdForCustomWrite");
|
|
606
629
|
async function refreshPendingCount(store) {
|
|
607
630
|
const entries = await store.queue();
|
|
608
|
-
|
|
631
|
+
_chunkWUNSG3INjs.setOfflineState.call(void 0, { pending: entries.filter((entry) => entry.status !== "conflict").length });
|
|
609
632
|
}
|
|
610
633
|
_chunk7QVYU63Ejs.__name.call(void 0, refreshPendingCount, "refreshPendingCount");
|
|
611
634
|
async function localTransport(request) {
|
|
@@ -613,7 +636,7 @@ async function localTransport(request) {
|
|
|
613
636
|
const method = request.method.toUpperCase();
|
|
614
637
|
if (!METHODS.includes(method)) return toApiData(needsConnectionAnswer());
|
|
615
638
|
if (request.files) return toApiData(needsConnectionAnswer("Uploading files needs a connection"));
|
|
616
|
-
const config =
|
|
639
|
+
const config = _chunkWUNSG3INjs.getOfflineConfig.call(void 0, );
|
|
617
640
|
const { path, query } = splitApiUrl(request.url);
|
|
618
641
|
const offlineRequest = { method, path, query, body: request.body, url: request.url };
|
|
619
642
|
const custom = matchRoute(config.routes, method, path);
|
|
@@ -621,16 +644,17 @@ async function localTransport(request) {
|
|
|
621
644
|
if (!match) return toApiData(needsConnectionAnswer(`${method} ${path} has no offline answer`));
|
|
622
645
|
let store;
|
|
623
646
|
try {
|
|
624
|
-
store = await
|
|
647
|
+
store = await _chunkWUNSG3INjs.getOfflineStore.call(void 0, );
|
|
625
648
|
} catch (error) {
|
|
626
|
-
if (error instanceof
|
|
649
|
+
if (error instanceof _chunkWUNSG3INjs.NeedsConnectionError) return toApiData(needsConnectionAnswer(error.message));
|
|
627
650
|
console.warn("[offline] the device copy could not be opened", error);
|
|
628
651
|
return toApiData(needsConnectionAnswer("The device copy is not available in this tab"));
|
|
629
652
|
}
|
|
630
653
|
const ctx = { request: offlineRequest, params: match.params, store };
|
|
654
|
+
const rootTypes = new Set(_chunkWUNSG3INjs.rootKinds.call(void 0, config).map((kind) => kind.module.name));
|
|
631
655
|
const customRootId = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async (route) => {
|
|
632
656
|
const rootIndex = route.pattern.findIndex(
|
|
633
|
-
(segment) => typeof segment !== "string" && segment.name
|
|
657
|
+
(segment) => typeof segment !== "string" && rootTypes.has(segment.name)
|
|
634
658
|
);
|
|
635
659
|
const next = rootIndex >= 0 ? route.pattern[rootIndex + 1] : void 0;
|
|
636
660
|
const rootParam = typeof next === "string" && next.startsWith(":") ? next.slice(1) : void 0;
|
|
@@ -666,12 +690,12 @@ async function localTransport(request) {
|
|
|
666
690
|
await refreshPendingCount(store);
|
|
667
691
|
return toApiData(answer);
|
|
668
692
|
} catch (error) {
|
|
669
|
-
if (error instanceof
|
|
693
|
+
if (error instanceof _chunkWUNSG3INjs.NeedsConnectionError) return toApiData(needsConnectionAnswer(error.message));
|
|
670
694
|
console.error("[offline] local answer failed", error);
|
|
671
695
|
return toApiData({
|
|
672
696
|
status: 500,
|
|
673
697
|
body: {
|
|
674
|
-
errors: [{ status: "500", title: "Offline answer failed", detail: String(_nullishCoalesce(_optionalChain([error, 'optionalAccess',
|
|
698
|
+
errors: [{ status: "500", title: "Offline answer failed", detail: String(_nullishCoalesce(_optionalChain([error, 'optionalAccess', _50 => _50.message]), () => ( error))) }]
|
|
675
699
|
}
|
|
676
700
|
});
|
|
677
701
|
}
|
|
@@ -701,4 +725,4 @@ _chunk7QVYU63Ejs.__name.call(void 0, localTransport, "localTransport");
|
|
|
701
725
|
|
|
702
726
|
|
|
703
727
|
exports.errorAnswer = errorAnswer; exports.needsConnectionAnswer = needsConnectionAnswer; exports.notFoundAnswer = notFoundAnswer; exports.singleAnswer = singleAnswer; exports.includedFor = includedFor; exports.SERVER_DEFAULT_ORDER_BY = SERVER_DEFAULT_ORDER_BY; exports.searchRecords = searchRecords; exports.orderRecords = orderRecords; exports.listAnswer = listAnswer; exports.orderedListAnswer = orderedListAnswer; exports.resourceListAnswer = resourceListAnswer; exports.linkKindFor = linkKindFor; exports.linkKindsOf = linkKindsOf; exports.linksOfKind = linksOfKind; exports.rootIdForResource = rootIdForResource; exports.resourceFromDocument = resourceFromDocument; exports.mergeResource = mergeResource; exports.matchPattern = matchPattern; exports.matchRoute = matchRoute; exports.splitApiUrl = splitApiUrl; exports.localTransport = localTransport;
|
|
704
|
-
//# sourceMappingURL=chunk-
|
|
728
|
+
//# sourceMappingURL=chunk-N5ZE2Z6I.js.map
|