@marktiderman/genesis-core 2.10.0 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +164 -1
- package/dist/{chunk-LGTXQTHA.js → chunk-2VJQVAJD.js} +3 -3
- package/dist/{chunk-LGTXQTHA.js.map → chunk-2VJQVAJD.js.map} +1 -1
- package/dist/chunk-2WS4LGYU.js +47 -0
- package/dist/chunk-2WS4LGYU.js.map +1 -0
- package/dist/{chunk-KXVDDDJY.js → chunk-3B5O36DU.js} +105 -13
- package/dist/chunk-3B5O36DU.js.map +1 -0
- package/dist/{chunk-EHFYSJJA.js → chunk-42QPCDQF.js} +3 -3
- package/dist/{chunk-EHFYSJJA.js.map → chunk-42QPCDQF.js.map} +1 -1
- package/dist/{chunk-RK365SO2.js → chunk-AKF2RAGX.js} +8 -5
- package/dist/chunk-AKF2RAGX.js.map +1 -0
- package/dist/{chunk-4ZR7472O.js → chunk-LOJGHR5O.js} +4 -4
- package/dist/{chunk-4ZR7472O.js.map → chunk-LOJGHR5O.js.map} +1 -1
- package/dist/{chunk-ON2V4RXX.js → chunk-OC4OGB2K.js} +19 -11
- package/dist/chunk-OC4OGB2K.js.map +1 -0
- package/dist/{chunk-HQAVDVIH.js → chunk-POMTRNAL.js} +4 -4
- package/dist/{chunk-HQAVDVIH.js.map → chunk-POMTRNAL.js.map} +1 -1
- package/dist/{chunk-VDEW4AOS.js → chunk-PSFKIG27.js} +55 -6
- package/dist/chunk-PSFKIG27.js.map +1 -0
- package/dist/{chunk-37RWGNIO.js → chunk-VFT6QKZW.js} +114 -5
- package/dist/chunk-VFT6QKZW.js.map +1 -0
- package/dist/{chunk-VDS6REM3.js → chunk-VJGU6E4U.js} +5 -5
- package/dist/{chunk-VDS6REM3.js.map → chunk-VJGU6E4U.js.map} +1 -1
- package/dist/{chunk-ZCE3CHPX.js → chunk-XVRIWP7B.js} +3 -3
- package/dist/{chunk-ZCE3CHPX.js.map → chunk-XVRIWP7B.js.map} +1 -1
- package/dist/{chunk-7FVTGKTX.js → chunk-YDMKMNDS.js} +2 -2
- package/dist/{chunk-7FVTGKTX.js.map → chunk-YDMKMNDS.js.map} +1 -1
- package/dist/{chunk-6WV6ST67.js → chunk-YNXLPOAB.js} +97 -10
- package/dist/chunk-YNXLPOAB.js.map +1 -0
- package/dist/{chunk-7GW3QR63.js → chunk-ZHC3MDCS.js} +101 -18
- package/dist/chunk-ZHC3MDCS.js.map +1 -0
- package/dist/conversation/index.d.ts +195 -0
- package/dist/conversation/index.js +110 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/csv.d.ts +1 -1
- package/dist/errors.js +1 -2
- package/dist/form-types.d.ts +1 -1
- package/dist/gallery/index.d.ts +79 -0
- package/dist/gallery/index.js +64 -0
- package/dist/gallery/index.js.map +1 -0
- package/dist/hooks/index.d.ts +5 -4
- package/dist/hooks/index.js +18 -18
- package/dist/hooks/mutation-mode.d.ts +29 -2
- package/dist/hooks/mutation-mode.js +9 -4
- package/dist/hooks/related-keys.d.ts +1 -1
- package/dist/hooks/use-capabilities.d.ts +1 -1
- package/dist/hooks/use-capabilities.js +2 -2
- package/dist/hooks/use-infinite-resource.d.ts +1 -1
- package/dist/hooks/use-infinite-resource.js +4 -4
- package/dist/hooks/use-link-options.d.ts +1 -1
- package/dist/hooks/use-link-options.js +6 -6
- package/dist/hooks/use-live.d.ts +1 -1
- package/dist/hooks/use-live.js +3 -3
- package/dist/hooks/use-one.d.ts +1 -1
- package/dist/hooks/use-one.js +4 -4
- package/dist/hooks/use-relation-label.d.ts +1 -1
- package/dist/hooks/use-relation-label.js +2 -2
- package/dist/hooks/use-resource-form.d.ts +14 -1
- package/dist/hooks/use-resource-form.js +12 -9
- package/dist/hooks/use-resource.d.ts +17 -3
- package/dist/hooks/use-resource.js +12 -8
- package/dist/hooks/use-write.d.ts +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.js +21 -21
- package/dist/offline/index.d.ts +84 -0
- package/dist/offline/index.js +413 -0
- package/dist/offline/index.js.map +1 -0
- package/dist/provider/index.d.ts +60 -7
- package/dist/provider/index.js +3 -3
- package/dist/resource-view/index.d.ts +79 -4
- package/dist/resource-view/index.js +141 -19
- package/dist/resource-view/index.js.map +1 -1
- package/dist/schema/index.d.ts +4 -3
- package/dist/schema/index.js +2 -1
- package/dist/testing/index.d.ts +2 -2
- package/dist/{types-9WnGxZhj.d.ts → types-BzLv8yOm.d.ts} +8 -0
- package/dist/types-CsKSAKqs.d.ts +143 -0
- package/dist/{viewer-scope-bthEYSOB.d.ts → viewer-scope-Dx0N9AYk.d.ts} +3 -2
- package/dist/workspaces.d.ts +1 -1
- package/dist/{write-outcome-ZWlhhzRW.d.ts → write-outcome-DC5hORz-.d.ts} +1 -1
- package/dist/write-state-DVC4Yq9T.d.ts +58 -0
- package/package.json +15 -2
- package/dist/chunk-37RWGNIO.js.map +0 -1
- package/dist/chunk-6WV6ST67.js.map +0 -1
- package/dist/chunk-7GW3QR63.js.map +0 -1
- package/dist/chunk-KXVDDDJY.js.map +0 -1
- package/dist/chunk-ON2V4RXX.js.map +0 -1
- package/dist/chunk-PA6WJE5E.js +0 -115
- package/dist/chunk-PA6WJE5E.js.map +0 -1
- package/dist/chunk-RK365SO2.js.map +0 -1
- package/dist/chunk-VDEW4AOS.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/offline/types.ts","../../src/offline/memory.ts","../../src/offline/indexeddb.ts","../../src/offline/persist.ts"],"names":["fresh","options"],"mappings":";AA6HO,IAAM,UAAA,GAAa,CAAC,IAAA,KAAiB,CAAA,EAAA,EAAK,IAAI,CAAA,CAAA,CAAA;AAG9C,SAAS,YAAY,KAAA,EAAyB;AACnD,EAAA,IAAI,CAAC,YAAA,CAAa,IAAA,CAAK,KAAK,CAAA,EAAG;AAC7B,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,mBAAA,EAAsB,KAAK,CAAA,4EAAA,CAA8E,CAA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AAM,KAAA,CAAM,EAAE,MAAM,CAAA;AAAA,IAC9D,CAAA;AAEA,IAAA,OAAO,EAAE,OAAA,EAAS,SAAA,EAAW,KAAA,EAAM;AAAA,EACrC,CAAA;AACF","file":"index.js","sourcesContent":["// ---------------------------------------------------------------------------\n// The device cache's contract (ADR 0010, slice 1: \"lists open instantly\")\n//\n// A local cache keeps the reads a person already made, per record and per\n// query, so a list or a record opens from the device before the network\n// answers and is then refreshed. It can always be rebuilt from the server:\n// a wipe loses nothing but speed. Every row in it came from a normal read by\n// this person, through the provider and so through RLS.\n// ---------------------------------------------------------------------------\n\n/**\n * Whose cache a write belongs to: always a person's. `u:<userId>|<workspace>`,\n * from `cacheScope`. An adapter refuses a scope without the `u:` prefix, so\n * `clear({ user })` reaches every bucket a person has.\n */\nexport type CacheScope = string;\n\n/** One record as it was read: stored once, whatever lists hold it. */\nexport interface StoredRow {\n readonly resource: string;\n /** `String(row.id)`. */\n readonly id: string;\n /**\n * The row as last read whole (a list or a record read without `select`). A\n * newer read replaces it, so a field the server stops returning is gone; an\n * older one never does.\n */\n readonly row: Readonly<Record<string, unknown>>;\n readonly fetchedAt: number;\n}\n\n/**\n * One cached read (a list, an infinite list or a record), its rows replaced by\n * references (`{ $row: id }`) into the row store.\n */\nexport interface StoredQuery {\n /** The query key as text, the query's identity in the store. */\n readonly key: string;\n readonly queryKey: readonly unknown[];\n readonly resource: string;\n readonly data: unknown;\n readonly fetchedAt: number;\n}\n\n/** One change to the store. A `write` applies all of its ops together, or none. */\nexport type CacheOp =\n | { readonly kind: \"row\"; readonly row: StoredRow }\n | { readonly kind: \"query\"; readonly query: StoredQuery }\n /** Deletes a stored read; with `before`, only if it was fetched before then (a newer save stays). */\n | { readonly kind: \"forget\"; readonly key: string; readonly before?: number }\n /** Deletes one stored row (the record came back empty: deleted, or no longer readable). */\n | { readonly kind: \"drop\"; readonly resource: string; readonly id: string }\n /**\n * Deletes every stored row of `resource` that isn't in `keep` and was fetched before `before`:\n * the rows no kept read refers to, never one saved since the sweep started.\n */\n | { readonly kind: \"prune\"; readonly resource: string; readonly keep: readonly string[]; readonly before: number };\n\n/**\n * The device cache. `memoryLocalCache` (tests), `indexedDbLocalCache` (the\n * web) and genesis-native's `sqliteLocalCache` (the phone) implement it; one\n * contract suite tests every adapter.\n *\n * @stability Beta\n */\nexport interface LocalCache {\n /** Every stored read for `scope`. */\n readQueries(scope: CacheScope): Promise<StoredQuery[]>;\n /** The stored rows of `resource` with these ids; missing ones are left out. */\n readRows(scope: CacheScope, resource: string, ids: readonly string[]): Promise<StoredRow[]>;\n /**\n * Applies `ops` in order, in one transaction. A row op replaces the stored row unless the\n * stored one was fetched later (an older read never overwrites a newer one).\n */\n write(scope: CacheScope, ops: readonly CacheOp[]): Promise<void>;\n /**\n * Deletes one scope's bucket, every bucket of one person, every bucket except one person's\n * (`except`: a device is one person's), or everything.\n */\n clear(target?: { readonly scope: CacheScope } | { readonly user: string } | { readonly except: string }): Promise<void>;\n}\n\n/**\n * Loads saved reads into a QueryClient and saves new ones: what\n * `GenesisNativeApp`'s and `GenesisProvider`'s `persist` take.\n *\n * @stability Beta\n */\nexport interface QueryPersistence {\n /**\n * Load the saved reads for `scope` into the client. Once `signal` aborts (the\n * person signed out, or the scope changed), nothing more is loaded.\n */\n restore(scope: string, signal?: AbortSignal): Promise<void>;\n /**\n * Saves settled reads for `scope` as they arrive; returns the unsubscribe.\n * `restore(\"\")` (nobody signed in) deletes every saved read on the device.\n */\n subscribe(scope: string, options?: SubscribeOptions): () => void;\n /** Delete the saved reads of every person this persistence restored or saved for (else everything). */\n clear(): Promise<void>;\n}\n\n/** Options for `QueryPersistence.subscribe`. */\nexport interface SubscribeOptions {\n /**\n * The reads already made are this scope's: save what each kept query last fetched (never a\n * value the client set since), and the reads still on their way. Only where the client can\n * hold nothing of anyone else's: `GenesisNativeApp`, which empties it whenever the person\n * changes and starts saving only once the session is known.\n *\n * @internal For `GenesisNativeApp`. Elsewhere, use `refresh`: a client that outlived another\n * person's session would have their reads adopted.\n */\n adopt?: boolean;\n /**\n * Nothing already in the client, or on its way, is trusted to be this scope's (the session was\n * still loading, or the client outlived another person's session): every kept read in flight is\n * called off, and the kept queries are fetched again, so everything saved was read once the\n * scope was known. What `GenesisProvider` does when a scope arrives after `undefined`.\n */\n refresh?: boolean;\n}\n\n/** The scope prefix every bucket of `user` starts with. */\nexport const userPrefix = (user: string) => `u:${user}|`;\n\n/** Refuses a scope that doesn't belong to a person. */\nexport function assertScope(scope: CacheScope): void {\n if (!/^u:[^|]+\\|/.test(scope)) {\n throw new Error(`[genesis offline] \"${scope}\" isn't a person's cache scope: build it with cacheScope(userId, workspace).`);\n }\n}\n\n/**\n * A person's cache scope: their user id plus the workspace they're in\n * (`WorkspaceScope`'s `<kind>:<id>`), `all` for a roll-up, or `none` outside\n * any workspace.\n *\n * cacheScope(user.id) // \"u:<id>|none\"\n * cacheScope(user.id, \"org:acme\") // \"u:<id>|org:acme\"\n *\n * @stability Beta\n */\nexport function cacheScope(userId: string, workspace = \"none\"): CacheScope {\n if (!userId) throw new Error(\"[genesis offline] cacheScope needs the signed-in user's id.\");\n return `${userPrefix(userId)}${workspace}`;\n}\n","import { assertScope, userPrefix, type CacheOp, type CacheScope, type LocalCache, type StoredQuery, type StoredRow } from \"./types\";\n\ninterface Bucket {\n rows: Map<string, StoredRow>;\n queries: Map<string, StoredQuery>;\n}\n\nconst rowKey = (resource: string, id: string) => `${resource}\\u0000${id}`;\n\n/** Applies one op to a bucket (shared with the other adapters' tests through behaviour, not code). */\nfunction apply(bucket: Bucket, op: CacheOp): void {\n if (op.kind === \"row\") {\n const k = rowKey(op.row.resource, op.row.id);\n const stored = bucket.rows.get(k);\n if (!stored || stored.fetchedAt <= op.row.fetchedAt) bucket.rows.set(k, op.row);\n } else if (op.kind === \"query\") bucket.queries.set(op.query.key, op.query);\n else if (op.kind === \"forget\") {\n const stored = bucket.queries.get(op.key);\n if (stored && (op.before === undefined || stored.fetchedAt < op.before)) bucket.queries.delete(op.key);\n } else if (op.kind === \"drop\") bucket.rows.delete(rowKey(op.resource, op.id));\n else {\n const keep = new Set(op.keep);\n for (const [k, row] of bucket.rows) if (row.resource === op.resource && !keep.has(row.id) && row.fetchedAt < op.before) bucket.rows.delete(k);\n }\n}\n\n/**\n * A `LocalCache` in memory: for tests, and for a screen that wants the\n * contract without a device store. Nothing survives a reload.\n *\n * @stability Beta\n */\nexport function memoryLocalCache(): LocalCache {\n const buckets = new Map<CacheScope, Bucket>();\n const bucket = (scope: CacheScope) => {\n let b = buckets.get(scope);\n if (!b) buckets.set(scope, (b = { rows: new Map(), queries: new Map() }));\n return b;\n };\n return {\n async readQueries(scope) {\n assertScope(scope);\n return [...(buckets.get(scope)?.queries.values() ?? [])];\n },\n async readRows(scope, resource, ids) {\n assertScope(scope);\n const b = buckets.get(scope);\n if (!b) return [];\n return ids.map((id) => b.rows.get(rowKey(resource, id))).filter((r): r is StoredRow => !!r);\n },\n async write(scope, ops) {\n assertScope(scope);\n // All or nothing: apply to a copy, then swap it in.\n const current = bucket(scope);\n const next: Bucket = { rows: new Map(current.rows), queries: new Map(current.queries) };\n for (const op of ops) apply(next, op);\n buckets.set(scope, next);\n },\n async clear(target) {\n if (!target) {\n buckets.clear();\n return;\n }\n if (\"scope\" in target) {\n buckets.delete(target.scope);\n return;\n }\n // A person's buckets, or (`except`) everyone else's.\n const mine = (scope: CacheScope) => scope.startsWith(userPrefix(\"user\" in target ? target.user : target.except));\n for (const scope of [...buckets.keys()]) if (mine(scope) === (\"user\" in target)) buckets.delete(scope);\n },\n };\n}\n","import { assertScope, userPrefix, type CacheOp, type LocalCache, type StoredQuery, type StoredRow } from \"./types\";\n\n/** Options for {@link indexedDbLocalCache}. */\nexport interface IndexedDbLocalCacheOptions {\n /** The database name. Default `\"genesis-offline\"`. */\n name?: string;\n /** The IndexedDB factory. Default `globalThis.indexedDB`. */\n indexedDB?: IDBFactory;\n /**\n * Ask the browser to keep this origin's storage (`navigator.storage.persist()`).\n * Default false: some browsers ask the person, and kept storage outlives a\n * shared machine's session longer. Without it the browser may evict the\n * cache under pressure; it's rebuilt from the server.\n */\n persist?: boolean;\n}\n\nconst VERSION = 1;\ntype RowRecord = StoredRow & { scope: string };\ntype QueryRecord = StoredQuery & { scope: string };\n\nconst done = <T>(request: IDBRequest<T>) =>\n new Promise<T>((resolve, reject) => {\n request.onsuccess = () => resolve(request.result);\n request.onerror = () => reject(request.error);\n });\n\nconst finished = (tx: IDBTransaction) =>\n new Promise<void>((resolve, reject) => {\n tx.oncomplete = () => resolve();\n tx.onabort = () => reject(tx.error ?? new Error(\"[genesis offline] IndexedDB transaction aborted\"));\n tx.onerror = () => reject(tx.error);\n });\n\n/**\n * A `LocalCache` in IndexedDB, for the web: plain IndexedDB, no dependency.\n * Rows and queries are separate object stores keyed by scope, so one row is\n * stored once whatever lists hold it, and a write is one transaction. A newer\n * version of the database opened in another tab closes this one, which then\n * reopens on its next use, instead of blocking the upgrade.\n *\n * @stability Beta\n */\nexport function indexedDbLocalCache(options: IndexedDbLocalCacheOptions = {}): LocalCache {\n const name = options.name ?? \"genesis-offline\";\n const factory = options.indexedDB ?? (globalThis as { indexedDB?: IDBFactory }).indexedDB;\n let opening: Promise<IDBDatabase> | null = null;\n\n const open = (): Promise<IDBDatabase> => {\n if (opening) return opening;\n if (!factory) return Promise.reject(new Error(\"[genesis offline] IndexedDB isn't available here.\"));\n if (options.persist === true) {\n const storage = (globalThis as { navigator?: { storage?: { persist?: () => Promise<boolean> } } }).navigator?.storage;\n void storage?.persist?.().catch(() => false);\n }\n const request = factory.open(name, VERSION);\n // Another tab holds an older version open: it closes on its versionchange, then this opens.\n request.onblocked = () => undefined;\n request.onupgradeneeded = () => {\n const db = request.result;\n if (!db.objectStoreNames.contains(\"rows\")) {\n db.createObjectStore(\"rows\", { keyPath: [\"scope\", \"resource\", \"id\"] }).createIndex(\"scope\", \"scope\");\n }\n if (!db.objectStoreNames.contains(\"queries\")) {\n db.createObjectStore(\"queries\", { keyPath: [\"scope\", \"key\"] }).createIndex(\"scope\", \"scope\");\n }\n };\n opening = done(request).then((db) => {\n db.onversionchange = () => {\n db.close();\n opening = null;\n };\n return db;\n });\n opening.catch(() => {\n opening = null;\n });\n return opening;\n };\n\n // Every key starts with its scope, so a scope's (or a person's) records are one key range: an\n // array key sorts after any shorter array it starts with, and an array element sorts after a\n // string, so `[scope, []]` is above every `[scope, ...]`.\n const scopeRange = (scope: string) => IDBKeyRange.bound([scope], [scope, []]);\n const personRange = (user: string) => IDBKeyRange.bound([userPrefix(user)], [`${userPrefix(user)}\\uffff`]);\n\n return {\n async readQueries(scope) {\n assertScope(scope);\n const db = await open();\n const records = (await done(db.transaction(\"queries\").objectStore(\"queries\").index(\"scope\").getAll(IDBKeyRange.only(scope)))) as QueryRecord[];\n return records.map(({ scope: _s, ...query }) => query);\n },\n async readRows(scope, resource, ids) {\n assertScope(scope);\n if (ids.length === 0) return [];\n const db = await open();\n const store = db.transaction(\"rows\").objectStore(\"rows\");\n const found = await Promise.all(ids.map((id) => done(store.get([scope, resource, id])) as Promise<RowRecord | undefined>));\n return found.filter((r): r is RowRecord => !!r).map(({ scope: _s, ...row }) => row);\n },\n async write(scope, ops: readonly CacheOp[]) {\n assertScope(scope);\n if (ops.length === 0) return;\n const db = await open();\n const tx = db.transaction([\"rows\", \"queries\"], \"readwrite\");\n const rows = tx.objectStore(\"rows\");\n const queries = tx.objectStore(\"queries\");\n // Requests in one transaction run in the order they're made, so the ops apply in order. A row\n // is written only if the stored one isn't newer: read first, then put (one row op per key, the\n // newest, so two reads of one row in one write can't race).\n const newest = new Map<string, StoredRow>();\n for (const op of ops) {\n if (op.kind !== \"row\") continue;\n const k = JSON.stringify([op.row.resource, op.row.id]);\n const seen = newest.get(k);\n if (!seen || seen.fetchedAt <= op.row.fetchedAt) newest.set(k, op.row);\n }\n const olderThan = (store: IDBObjectStore, key: IDBValidKey, before: number, then: () => void) => {\n const get = store.get(key);\n get.onsuccess = () => {\n const stored = get.result as { fetchedAt: number } | undefined;\n if (stored && stored.fetchedAt < before) then();\n };\n };\n for (const op of ops) {\n if (op.kind === \"row\") {\n const row = newest.get(JSON.stringify([op.row.resource, op.row.id]));\n if (row !== op.row) continue;\n const get = rows.get([scope, row.resource, row.id]);\n get.onsuccess = () => {\n const stored = get.result as RowRecord | undefined;\n if (!stored || stored.fetchedAt <= row.fetchedAt) rows.put({ ...row, scope } satisfies RowRecord);\n };\n } else if (op.kind === \"query\") queries.put({ ...op.query, scope } satisfies QueryRecord);\n else if (op.kind === \"forget\") {\n if (op.before === undefined) queries.delete([scope, op.key]);\n else olderThan(queries, [scope, op.key], op.before, () => queries.delete([scope, op.key]));\n } else if (op.kind === \"drop\") rows.delete([scope, op.resource, op.id]);\n else {\n const keep = new Set(op.keep);\n const cursor = rows.openCursor(IDBKeyRange.bound([scope, op.resource], [scope, op.resource, []]));\n cursor.onsuccess = () => {\n const c = cursor.result;\n if (!c) return;\n const stored = c.value as RowRecord;\n if (!keep.has(stored.id) && stored.fetchedAt < op.before) c.delete();\n c.continue();\n };\n }\n }\n await finished(tx);\n },\n async clear(target) {\n const db = await open();\n const tx = db.transaction([\"rows\", \"queries\"], \"readwrite\");\n for (const store of [tx.objectStore(\"rows\"), tx.objectStore(\"queries\")]) {\n if (!target) store.clear();\n else if (\"scope\" in target) store.delete(scopeRange(target.scope));\n else if (\"user\" in target) store.delete(personRange(target.user));\n else {\n // Everyone else: the keys below this person's range, and those above it.\n store.delete(IDBKeyRange.upperBound([userPrefix(target.except)], true));\n store.delete(IDBKeyRange.lowerBound([`${userPrefix(target.except)}\\uffff`]));\n }\n }\n await finished(tx);\n },\n };\n}\n","import type { Query, QueryCacheNotifyEvent, QueryClient } from \"@tanstack/react-query\";\nimport { userPrefix, type CacheOp, type CacheScope, type LocalCache, type QueryPersistence, type StoredQuery, type StoredRow, type SubscribeOptions } from \"./types\";\n\n/** Options for {@link persistOffline}. */\nexport interface PersistOfflineOptions {\n /** Where reads are kept: `indexedDbLocalCache()` on the web, `sqliteLocalCache({ db })` on the phone. */\n cache: LocalCache;\n /**\n * The resources whose reads are kept on the device: the one opt-in switch.\n * Keeping data on a device is a decision, so nothing else is written. Leave\n * out a resource whose rows shouldn't sit on a phone unencrypted.\n */\n resources: readonly string[];\n /** Your app's version: a different value discards what was kept. */\n buster: string;\n /** How old a kept read may be when restored. Default 7 days. */\n maxAge?: number;\n /** Save at most this often. Default 500 ms. */\n throttleMs?: number;\n /** The most reads kept per person and workspace; the least recently fetched go first. Default 200. */\n maxReads?: number;\n}\n\nconst DAY = 24 * 60 * 60 * 1000;\nconst META = \"__genesis_offline_meta__\";\nconst KINDS = new Set([\"list\", \"detail\", \"infinite\"]);\n\ntype Row = Record<string, unknown>;\ntype Ref = { $row: string };\nconst isRef = (v: unknown): v is Ref => !!v && typeof v === \"object\" && typeof (v as Ref).$row === \"string\" && Object.keys(v).length === 1;\nconst isRow = (v: unknown): v is Row => !!v && typeof v === \"object\" && !Array.isArray(v) && (v as Row).id != null;\n\n/** A query's key as text: its identity in the store. */\nconst keyText = (key: readonly unknown[]) =>\n JSON.stringify(key, (_k, v: unknown) =>\n v && typeof v === \"object\" && !Array.isArray(v)\n ? Object.fromEntries(Object.entries(v as Row).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)))\n : v,\n );\n\n/** A person's scope from what the app shell hands over: a user id, or a scope `cacheScope` built. */\nconst toScope = (scope: string): CacheScope | null =>\n !scope ? null : scope.startsWith(\"u:\") ? (/^u:[^|]+\\|/.test(scope) ? scope : null) : `${userPrefix(scope)}none`;\n\n/**\n * Replaces the rows in a read with references, and collects them. Only a read of whole rows (no\n * `select`) is split, so every stored row has one shape; a projection is kept as it came. Null:\n * not a shape this keeps.\n */\nfunction split(kind: string, select: unknown, data: unknown, rows: Row[]): unknown {\n if (select !== undefined) return kind === \"infinite\" && !(data && typeof data === \"object\" && Array.isArray((data as { pages?: unknown }).pages)) ? null : data;\n const list = (page: unknown) => {\n if (!page || typeof page !== \"object\" || !Array.isArray((page as { data?: unknown }).data)) return page;\n const p = page as { data: unknown[] };\n return { ...p, data: p.data.map((r) => (isRow(r) ? (rows.push(r), { $row: String(r.id) }) : r)) };\n };\n if (kind === \"list\") return list(data);\n if (kind === \"infinite\") {\n if (!data || typeof data !== \"object\" || !Array.isArray((data as { pages?: unknown }).pages)) return null;\n const d = data as { pages: unknown[] };\n return { ...d, pages: d.pages.map(list) };\n }\n // A record read whole is a row.\n if (isRow(data)) {\n rows.push(data);\n return { $row: String(data.id) };\n }\n return data;\n}\n\n/** Collects the ids a stored read refers to. */\nfunction refsIn(value: unknown, out: Set<string>): void {\n if (isRef(value)) out.add(value.$row);\n else if (Array.isArray(value)) for (const v of value) refsIn(v, out);\n else if (value && typeof value === \"object\") for (const v of Object.values(value)) refsIn(v, out);\n}\n\n/** Puts the rows back; undefined when a row it needs is missing. */\nfunction join(value: unknown, rows: Map<string, Row>): unknown {\n if (isRef(value)) return rows.get(value.$row);\n if (Array.isArray(value)) {\n const out = value.map((v) => join(v, rows));\n return out.some((v, i) => v === undefined && value[i] !== undefined) ? undefined : out;\n }\n if (value && typeof value === \"object\") {\n const out: Row = {};\n for (const [k, v] of Object.entries(value)) {\n const joined = join(v, rows);\n if (joined === undefined && v !== undefined) return undefined;\n out[k] = joined;\n }\n return out;\n }\n return value;\n}\n\n/**\n * Keeps the reads of the listed resources on the device, per record, and\n * puts them back into the QueryClient on the next start, so lists and records\n * open at once and then refresh as usual. What `GenesisNativeApp`'s and\n * `GenesisProvider`'s `persist` take.\n *\n * persist={persistOffline({ cache: indexedDbLocalCache(), resources: [\"tasks\", \"people\"], buster: version })}\n *\n * - Only reads that came back from the provider are kept (never an optimistic\n * change that hasn't been saved), in the bucket of the person and workspace\n * they were read in.\n * - A restored read is marked as fetched when it was, so a screen refetches it\n * once it's stale (the client's `staleTime`), as with any cached read. It\n * never replaces a newer read already in the client.\n * - A newer read replaces a stored row, so a field the server stops returning\n * goes; a record that comes back empty is deleted from the device. Each start\n * deletes reads older than `maxAge` and the rows no kept read refers to.\n * - A device is one person's: restoring someone deletes every other person's\n * reads first, and `restore(\"\")` (nobody signed in) deletes them all, so a\n * session that ended outside the app leaves nothing behind.\n * - A sign-out, a change of person or workspace, or `clear()` stops every save\n * and restore still in flight from landing in the new bucket.\n *\n * @stability Beta\n */\nexport function persistOffline(options: PersistOfflineOptions): (queryClient: QueryClient) => QueryPersistence {\n const { cache, buster, maxAge = 7 * DAY, throttleMs = 500, maxReads = 200 } = options;\n const kept = new Set(options.resources);\n\n return (queryClient) => {\n // Generations: a save or a restore started before a newer one (or a clear) is dropped, so\n // nothing lands in another person's or workspace's bucket.\n // Restores and saves count apart, so starting to save doesn't cancel a restore still reading.\n let restores = 0;\n let saves = 0;\n // Each query's last fetched result, recorded from the start whatever the scope: what adopting\n // saves, so a value the client changed since (setQueryData) is never taken for a read.\n const fetched = new WeakMap<Query, { data: unknown; fetchedAt: number }>();\n queryClient.getQueryCache().subscribe((event: QueryCacheNotifyEvent) => {\n if (event.type !== \"updated\") return;\n const action = event.action as { type?: string; manual?: boolean };\n if (action.type !== \"success\" || action.manual) return;\n fetched.set(event.query, { data: event.query.state.data, fetchedAt: event.query.state.dataUpdatedAt });\n });\n // Everyone this persistence restored or saved for: `clear` deletes all of their reads.\n const people = new Set<string>();\n const meta = (): CacheOp => ({ kind: \"query\", query: { key: META, queryKey: [META], resource: META, data: { buster }, fetchedAt: Date.now() } });\n\n const keptQuery = (query: Query) => {\n const [resource, kind] = query.queryKey as readonly unknown[];\n return typeof resource === \"string\" && kept.has(resource) && typeof kind === \"string\" && KINDS.has(kind);\n };\n\n const restore = async (raw: string, signal?: AbortSignal) => {\n if (raw === \"\") {\n // Nobody is signed in: nothing of anyone's stays on the device.\n restores += 1;\n saves += 1;\n people.clear();\n await cache.clear().catch(() => undefined);\n return;\n }\n const scope = toScope(raw);\n if (!scope) return;\n const mine = ++restores;\n const user = scope.slice(2, scope.indexOf(\"|\"));\n people.add(user);\n const stale = () => mine !== restores || signal?.aborted === true;\n // Reads saved from here on are newer than this restore: the sweep below never deletes them.\n const startedAt = Date.now();\n try {\n // A device is one person's: whoever used it before (a session that ended outside the app,\n // by expiry or a sign-out elsewhere) leaves nothing here for this person to sit beside.\n await cache.clear({ except: user });\n const stored = await cache.readQueries(scope);\n if (stale()) return;\n const found = stored.find((q) => q.key === META);\n if (!found || (found.data as { buster?: unknown })?.buster !== buster) {\n // A different app version, or nothing kept yet: start this bucket afresh, deleting what an\n // earlier version kept but never a read saved since this restore started (saving runs\n // alongside it).\n const fresh: CacheOp[] = stored.filter((q) => q.key !== META).map((q) => ({ kind: \"forget\", key: q.key, before: startedAt }));\n for (const resource of new Set([...stored.filter((q) => q.key !== META).map((q) => q.resource), ...kept])) {\n fresh.push({ kind: \"prune\", resource, keep: [], before: startedAt });\n }\n await cache.write(scope, [...fresh, meta()]);\n return;\n }\n const reads = stored.filter((q) => q.key !== META);\n const fresh = reads\n .filter((q) => Date.now() - q.fetchedAt <= maxAge && kept.has(q.resource))\n .sort((a, b) => b.fetchedAt - a.fetchedAt)\n .slice(0, maxReads);\n // The rows each resource's reads refer to, read once per resource.\n const wanted = new Map<string, Set<string>>();\n for (const q of reads) if (!wanted.has(q.resource)) wanted.set(q.resource, new Set());\n for (const q of fresh) refsIn(q.data, wanted.get(q.resource)!);\n const rowsOf = new Map<string, Map<string, Row>>();\n for (const [resource, ids] of wanted) {\n if (ids.size === 0) continue;\n const rows = await cache.readRows(scope, resource, [...ids]);\n rowsOf.set(resource, new Map(rows.map((r) => [r.id, r.row as Row])));\n }\n if (stale()) return;\n for (const q of fresh) {\n const data = join(q.data, rowsOf.get(q.resource) ?? new Map());\n if (data === undefined) continue; // A row it needs is gone: the screen reads it again.\n const existing = queryClient.getQueryState(q.queryKey);\n if (existing?.data !== undefined && existing.dataUpdatedAt >= q.fetchedAt) continue;\n queryClient.setQueryData(q.queryKey, data, { updatedAt: q.fetchedAt });\n }\n // Keep the device to what can still be restored: expired reads, reads past `maxReads`,\n // reads of resources no longer kept, and rows nothing refers to are deleted, unless saved\n // since this restore started.\n const sweep: CacheOp[] = reads.filter((q) => !fresh.includes(q)).map((q) => ({ kind: \"forget\", key: q.key, before: startedAt }));\n for (const [resource, ids] of wanted) sweep.push({ kind: \"prune\", resource, keep: [...ids], before: startedAt });\n if (sweep.length) await cache.write(scope, sweep);\n } catch {\n // An unreadable bucket is no reason to fail the start: the screens read from the server.\n // Dropped, so it doesn't fail every start after this one.\n await cache.clear({ scope }).catch(() => undefined);\n }\n };\n\n const subscribe = (raw: string, options: SubscribeOptions = {}) => {\n const scope = toScope(raw);\n if (!scope) return () => {};\n const mine = ++saves;\n people.add(scope.slice(2, scope.indexOf(\"|\")));\n // What each read was when it came back: saved later, but never what the client changed since.\n const pending = new Map<string, { query: Query; queryKey: readonly unknown[]; data: unknown; fetchedAt: number }>();\n // `refresh`: no kept read already made or on its way is trusted to be this scope's. The ones in\n // flight are called off (so they never come back as a success), and the kept queries are\n // fetched again below, once this subscription is listening.\n if (options.refresh) {\n for (const query of queryClient.getQueryCache().getAll()) {\n if (keptQuery(query) && query.state.fetchStatus === \"fetching\") void query.cancel({ revert: true });\n }\n }\n // Reads already on their way when this started belong to the scope before: never saved here,\n // unless they're this scope's (`adopt`).\n const before = options.adopt\n ? new Set<string>()\n : new Set(queryClient.getQueryCache().getAll().filter((q) => q.state.fetchStatus === \"fetching\").map((q) => q.queryHash));\n let timer: ReturnType<typeof setTimeout> | undefined;\n let first = true;\n\n const flush = () => {\n timer = undefined;\n if (mine !== saves || pending.size === 0) return;\n // The bucket's app version, so the next start keeps what this saves.\n const ops: CacheOp[] = first ? [meta()] : [];\n const newest = new Map<string, StoredRow>();\n first = false;\n for (const read of pending.values()) {\n // A query the client let go of before this save ran (the person changed) isn't saved.\n if (queryClient.getQueryCache().get(read.query.queryHash) !== read.query) continue;\n const [resource, kind, params, detailSelect] = read.queryKey;\n // A record's projection is its key's fourth part; a list's is in its params.\n const select = kind === \"detail\" ? detailSelect : (params as { select?: unknown } | undefined)?.select;\n const key = keyText(read.queryKey);\n if (kind === \"detail\" && read.data == null) {\n // The record came back empty (deleted, or no longer readable): forget it here too.\n const id = read.queryKey[2];\n ops.push({ kind: \"forget\", key });\n if (select === undefined && id != null) ops.push({ kind: \"drop\", resource: resource as string, id: String(id) });\n continue;\n }\n const rows: Row[] = [];\n const data = split(kind as string, select, read.data, rows);\n if (data === null) continue;\n for (const row of rows) {\n // One row per record per save, the most recently fetched (a list, then the record,\n // then the list again leave the newest copy, whatever order they're saved in).\n const k = `${resource as string}\\u0000${String(row.id)}`;\n const seen = newest.get(k);\n if (!seen || seen.fetchedAt <= read.fetchedAt) newest.set(k, { resource: resource as string, id: String(row.id), row, fetchedAt: read.fetchedAt });\n }\n ops.push({ kind: \"query\", query: { key, queryKey: read.queryKey, resource: resource as string, data, fetchedAt: read.fetchedAt } satisfies StoredQuery });\n }\n pending.clear();\n for (const row of newest.values()) ops.push({ kind: \"row\", row });\n if (ops.length) void cache.write(scope, ops).catch(() => undefined);\n };\n\n const unsubscribe = queryClient.getQueryCache().subscribe((event: QueryCacheNotifyEvent) => {\n if (event.type !== \"updated\" || mine !== saves) return;\n const action = event.action as { type?: string; manual?: boolean };\n // A fetch that came back; never a change made in the client (an optimistic patch, a live\n // hint's merge, a restore), which the next fetch confirms or undoes.\n if (action.type !== \"success\" || action.manual) return;\n // A query no longer in the client (cleared when the person changed) finishing its fetch\n // belongs to whoever was signed in before: never saved.\n if (queryClient.getQueryCache().get(event.query.queryHash) !== event.query) return;\n if (before.delete(event.query.queryHash)) return;\n if (!keptQuery(event.query)) return;\n const { data, dataUpdatedAt } = event.query.state;\n pending.set(event.query.queryHash, { query: event.query, queryKey: event.query.queryKey, data, fetchedAt: dataUpdatedAt });\n timer ??= setTimeout(flush, throttleMs);\n });\n if (options.refresh) {\n // Fetched again under this scope: the screens on show read now, the rest when they show.\n // An infinite list is reset (its pages dropped) rather than refetched: a next page fetched\n // onto pages read before the scope (a fetchNextPage that cancels or outlives the refetch)\n // would be saved as this scope's, with the earlier session's pages in it.\n const infinite = (query: Query) => keptQuery(query) && (query.queryKey as readonly unknown[])[1] === \"infinite\";\n void queryClient.resetQueries({ predicate: infinite }).catch(() => undefined);\n void queryClient.invalidateQueries({ predicate: (query) => keptQuery(query) && !infinite(query) }).catch(() => undefined);\n }\n if (options.adopt) {\n // The reads this scope made before saving started: each query's last fetched result, as it\n // came back. A value the client set or changed since (setQueryData) is never adopted.\n for (const query of queryClient.getQueryCache().getAll()) {\n const read = fetched.get(query);\n if (!read || read.data === undefined || !keptQuery(query)) continue;\n pending.set(query.queryHash, { query, queryKey: query.queryKey, data: read.data, fetchedAt: read.fetchedAt });\n }\n if (pending.size) timer ??= setTimeout(flush, throttleMs);\n }\n return () => {\n unsubscribe();\n if (timer) clearTimeout(timer);\n flush();\n };\n };\n\n const clear = async () => {\n restores += 1;\n saves += 1;\n const everyone = [...people];\n people.clear();\n if (everyone.length === 0) await cache.clear();\n else for (const user of everyone) await cache.clear({ user });\n };\n\n return { restore, subscribe, clear };\n };\n}\n"]}
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { D as DataProvider, b as Identifier, B as BaseRecord, I as InvalidationKey, W as WriteEvent, C as CountMode, a as FilterParam } from '../types-
|
|
2
|
-
export { A as ArrayFilter, d as BulkChange, e as BulkResult, f as CreateParams, g as CreateResult, i as DeleteParams, j as DeleteResult, G as GetManyParams, o as GetManyResult, p as GetOneParams, q as GetOneResult, H as HistoryParams, r as ImportParams, L as ListParams, s as ListResult, N as NullFilter, P as PaginationParam, R as RangeFilter, w as ResourceChangeEvent, M as RowFailure, Q as ScalarFilter, S as SortParam, V as SubscribeParams, X as UpdateParams, Y as UpdateResult } from '../types-
|
|
3
|
-
import { D as DataWriteError, W as WriteOutcome } from '../write-outcome-
|
|
4
|
-
export { a as DataWriteErrorOptions, i as isDataWriteError } from '../write-outcome-
|
|
1
|
+
import { D as DataProvider, b as Identifier, B as BaseRecord, I as InvalidationKey, W as WriteEvent, C as CountMode, a as FilterParam } from '../types-BzLv8yOm.js';
|
|
2
|
+
export { A as ArrayFilter, d as BulkChange, e as BulkResult, f as CreateParams, g as CreateResult, i as DeleteParams, j as DeleteResult, G as GetManyParams, o as GetManyResult, p as GetOneParams, q as GetOneResult, H as HistoryParams, r as ImportParams, L as ListParams, s as ListResult, N as NullFilter, P as PaginationParam, R as RangeFilter, w as ResourceChangeEvent, M as RowFailure, Q as ScalarFilter, S as SortParam, V as SubscribeParams, X as UpdateParams, Y as UpdateResult } from '../types-BzLv8yOm.js';
|
|
3
|
+
import { D as DataWriteError, W as WriteOutcome } from '../write-outcome-DC5hORz-.js';
|
|
4
|
+
export { a as DataWriteErrorOptions, i as isDataWriteError } from '../write-outcome-DC5hORz-.js';
|
|
5
5
|
import { D as DataReadError, R as ReadOutcome } from '../read-outcome-BnboMYOV.js';
|
|
6
6
|
export { a as DataReadErrorOptions, i as isDataReadError, r as readFailureMessage } from '../read-outcome-BnboMYOV.js';
|
|
7
7
|
import * as react from 'react';
|
|
8
8
|
import { ReactNode } from 'react';
|
|
9
9
|
import { QueryClient } from '@tanstack/react-query';
|
|
10
10
|
import { S as StorageAdapter } from '../types-DKcxHXxq.js';
|
|
11
|
+
import { Q as QueryPersistence } from '../types-CsKSAKqs.js';
|
|
11
12
|
|
|
12
13
|
interface MockProviderOptions {
|
|
13
14
|
/** Simulated latency in ms (default 0). */
|
|
@@ -125,6 +126,17 @@ interface SupabaseWriteContext {
|
|
|
125
126
|
/** The row's id, for an update. */
|
|
126
127
|
id?: Identifier;
|
|
127
128
|
}
|
|
129
|
+
/** What an `update` override is told besides the row. */
|
|
130
|
+
interface SupabaseUpdateContext {
|
|
131
|
+
/**
|
|
132
|
+
* With a `version` rule and an `expectedVersion` from the caller: the
|
|
133
|
+
* version the row must still be at. The override must apply the change
|
|
134
|
+
* only at that version (e.g. `... where id = $1 and version = $2`) and
|
|
135
|
+
* return nothing when no row matched; the provider then tells a
|
|
136
|
+
* `conflict` from `forbidden` and `gone`.
|
|
137
|
+
*/
|
|
138
|
+
expectedVersion?: string;
|
|
139
|
+
}
|
|
128
140
|
/** Per-resource rules for `createSupabaseProvider`. Every field is optional. */
|
|
129
141
|
interface SupabaseResourceConfig {
|
|
130
142
|
/** Singular noun for failure messages, e.g. "project". Defaults to "record". */
|
|
@@ -174,7 +186,23 @@ interface SupabaseResourceConfig {
|
|
|
174
186
|
* row to say why (`forbidden` or `gone`), exactly as for a plain update,
|
|
175
187
|
* so a function that silently skips a row never reports a save.
|
|
176
188
|
*/
|
|
177
|
-
update?: (id: Identifier, row: Record<string, unknown
|
|
189
|
+
update?: (id: Identifier, row: Record<string, unknown>, context?: SupabaseUpdateContext) => Promise<BaseRecord | Identifier | boolean | null | undefined | void>;
|
|
190
|
+
/**
|
|
191
|
+
* The column every update and delete of this resource is checked against,
|
|
192
|
+
* so an edit made on a stale copy is refused as a `conflict` instead of
|
|
193
|
+
* overwriting someone else's (`UpdateParams.expectedVersion`).
|
|
194
|
+
*
|
|
195
|
+
* The database must advance it on every update, or it detects nothing:
|
|
196
|
+
* `integer` with genesis-supabase's `genesis_version_bump` trigger
|
|
197
|
+
* (migration 0019), or `timestamp` with a trigger that sets it to `now()`
|
|
198
|
+
* on update (`moddatetime`). The provider never writes it: a submitted
|
|
199
|
+
* value is dropped. Writes without an `expectedVersion` are not checked,
|
|
200
|
+
* so turning this on changes nothing for callers that don't send one.
|
|
201
|
+
*/
|
|
202
|
+
version?: {
|
|
203
|
+
field: string;
|
|
204
|
+
kind: "integer" | "timestamp";
|
|
205
|
+
};
|
|
178
206
|
/** Maps a stored row to edit-form values; see `DataProvider.toFormValues`. */
|
|
179
207
|
toFormValues?: (record: Record<string, unknown>) => Record<string, unknown>;
|
|
180
208
|
/**
|
|
@@ -445,6 +473,27 @@ type GenesisProviderProps = {
|
|
|
445
473
|
mock?: never;
|
|
446
474
|
/** Platform-specific storage adapter. Defaults to localStorage (SSR-safe). */
|
|
447
475
|
storage?: StorageAdapter;
|
|
476
|
+
/**
|
|
477
|
+
* Keep reads on the device and restore them on the next start, so lists and records open at
|
|
478
|
+
* once: `persistOffline({ cache: indexedDbLocalCache(), resources, buster })` from
|
|
479
|
+
* `@marktiderman/genesis-core/offline`. Needs `persistScope`. Give it from the first render:
|
|
480
|
+
* the provider keeps the first one it's given.
|
|
481
|
+
*/
|
|
482
|
+
persist?: (client: QueryClient) => QueryPersistence;
|
|
483
|
+
/**
|
|
484
|
+
* Whose cache this is: `cacheScope(user.id, workspaceKey)` once someone is signed in,
|
|
485
|
+
* `null` once nobody is, and `undefined` while that isn't known yet (the session loading).
|
|
486
|
+
* A device is one person's: restoring someone deletes everyone else's kept reads, and
|
|
487
|
+
* `null` deletes them all, so a session that ended outside the app (it expired, or was
|
|
488
|
+
* signed out elsewhere) leaves nothing on the device. Undefined does nothing. A change of
|
|
489
|
+
* scope restores the new one's reads. Clear the QueryClient yourself when the person
|
|
490
|
+
* changes, as a sign-out already does; a `ViewerScope` inside keeps the restored reads for
|
|
491
|
+
* this person. Restoring is client-only: in a server-rendered app, give it after hydration
|
|
492
|
+
* (undefined on the server and the first client render), and the screens restore in the
|
|
493
|
+
* background. Change it only once the provider's session has: a scope must never name a
|
|
494
|
+
* person before the data provider's requests are made as them.
|
|
495
|
+
*/
|
|
496
|
+
persistScope?: string | null;
|
|
448
497
|
/**
|
|
449
498
|
* The TanStack Query client to use. Without it, GenesisProvider creates
|
|
450
499
|
* its OWN client — a second cache beside any the app already has, so app
|
|
@@ -465,6 +514,10 @@ type GenesisProviderProps = {
|
|
|
465
514
|
storage?: StorageAdapter;
|
|
466
515
|
/** See the `provider` variant. */
|
|
467
516
|
queryClient?: QueryClient;
|
|
517
|
+
/** See the `provider` variant. */
|
|
518
|
+
persist?: (client: QueryClient) => QueryPersistence;
|
|
519
|
+
/** See the `provider` variant. */
|
|
520
|
+
persistScope?: string | null;
|
|
468
521
|
};
|
|
469
522
|
/**
|
|
470
523
|
* Convenience root: a `QueryClientProvider`, storage, and a data provider
|
|
@@ -472,6 +525,6 @@ type GenesisProviderProps = {
|
|
|
472
525
|
* unless you pass `queryClient`; an app that already has one should pass it,
|
|
473
526
|
* or mount `DataProviderRoot` inside its existing `QueryClientProvider`.
|
|
474
527
|
*/
|
|
475
|
-
declare function GenesisProvider({ children, provider, mock, storage, queryClient: queryClientProp, }: GenesisProviderProps): react.JSX.Element;
|
|
528
|
+
declare function GenesisProvider({ children, provider, mock, storage, queryClient: queryClientProp, persist, persistScope, }: GenesisProviderProps): react.JSX.Element;
|
|
476
529
|
|
|
477
|
-
export { BaseRecord, type CallRpcOptions, CountMode, type CreateOrAdoptOptions, type CreateOrAdoptResult, DEFAULT_RPC_MESSAGES, DataProvider, DataProviderRoot, type DataProviderRootProps, DataReadError, DataWriteError, FilterParam, GenesisProvider, type GenesisProviderProps, Identifier, InvalidationKey, type MockProviderOptions, type PostgrestFieldErrors, RPC_FAILED, ReadOutcome, type RpcClient, type SupabaseClient, type SupabaseClientInput, type SupabaseProviderOptions, type SupabaseRealtimeChannel, type SupabaseRealtimePayload, type SupabaseResourceConfig, type SupabaseWriteContext, WriteEvent, WriteOutcome, callRpc, createMockProvider, createOrAdopt, createSupabaseProvider, fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, useDataProvider, useStorage, writeOutcomeFromCode };
|
|
530
|
+
export { BaseRecord, type CallRpcOptions, CountMode, type CreateOrAdoptOptions, type CreateOrAdoptResult, DEFAULT_RPC_MESSAGES, DataProvider, DataProviderRoot, type DataProviderRootProps, DataReadError, DataWriteError, FilterParam, GenesisProvider, type GenesisProviderProps, Identifier, InvalidationKey, type MockProviderOptions, type PostgrestFieldErrors, RPC_FAILED, ReadOutcome, type RpcClient, type SupabaseClient, type SupabaseClientInput, type SupabaseProviderOptions, type SupabaseRealtimeChannel, type SupabaseRealtimePayload, type SupabaseResourceConfig, type SupabaseUpdateContext, type SupabaseWriteContext, WriteEvent, WriteOutcome, callRpc, createMockProvider, createOrAdopt, createSupabaseProvider, fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, useDataProvider, useStorage, writeOutcomeFromCode };
|
package/dist/provider/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabaseProvider } from '../chunk-
|
|
2
|
-
export { DataProviderRoot, GenesisProvider, createMockProvider, useDataProvider, useStorage } from '../chunk-
|
|
1
|
+
export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabaseProvider } from '../chunk-ZHC3MDCS.js';
|
|
2
|
+
export { DataProviderRoot, GenesisProvider, createMockProvider, useDataProvider, useStorage } from '../chunk-PSFKIG27.js';
|
|
3
3
|
import '../chunk-ZYJUEJ4Z.js';
|
|
4
|
-
export { fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, writeOutcomeFromCode } from '../chunk-
|
|
4
|
+
export { fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, writeOutcomeFromCode } from '../chunk-VFT6QKZW.js';
|
|
5
5
|
export { DataReadError, isDataReadError, readFailureMessage } from '../chunk-HUNGCTRA.js';
|
|
6
6
|
import '../chunk-RYEXWQFD.js';
|
|
7
7
|
export { DataWriteError, isDataWriteError } from '../chunk-LG6TUBVM.js';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { h as DataRow, x as ResourceContract, O as RowOf, K as RowAction, F as FieldSchema, a as FilterParam, b as Identifier } from '../types-
|
|
1
|
+
import { h as DataRow, x as ResourceContract, O as RowOf, K as RowAction, F as FieldSchema, a as FilterParam, b as Identifier } from '../types-BzLv8yOm.js';
|
|
2
|
+
import { GalleryItem } from '../gallery/index.js';
|
|
2
3
|
import { C as ChipTone, R as Readiness } from '../status-BXRokZD9.js';
|
|
3
|
-
import { V as Viewer, R as ResourceScope } from '../viewer-scope-
|
|
4
|
-
export { G as GenesisViewerRoles, N as NO_VIEWER } from '../viewer-scope-
|
|
4
|
+
import { V as Viewer, R as ResourceScope } from '../viewer-scope-Dx0N9AYk.js';
|
|
5
|
+
export { G as GenesisViewerRoles, N as NO_VIEWER } from '../viewer-scope-Dx0N9AYk.js';
|
|
5
6
|
import 'react';
|
|
6
7
|
import '@tanstack/react-query';
|
|
7
8
|
import '../dates.js';
|
|
@@ -321,6 +322,45 @@ interface ViewCalendar<Name extends string = string> {
|
|
|
321
322
|
/** 0 Sunday or 1 Monday (default). */
|
|
322
323
|
weekStartsOn?: 0 | 1;
|
|
323
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* How the view's rows show as a board: a column per value of one field, a card per row.
|
|
327
|
+
* ResourceView's `mode="board"` draws it, and moving a card between columns writes the field
|
|
328
|
+
* through the provider. Plain values only, so every platform reads the same block.
|
|
329
|
+
*/
|
|
330
|
+
interface ViewBoard<Name extends string = string> {
|
|
331
|
+
/** The field whose value is a card's column: a field with choices (an enum) or a yes/no one. */
|
|
332
|
+
field: Name;
|
|
333
|
+
/**
|
|
334
|
+
* The columns, in order, as values of `field`. Default: its choices in the contract's order,
|
|
335
|
+
* then a "No value" column when it can be empty. Listing them shows only those.
|
|
336
|
+
*/
|
|
337
|
+
columns?: readonly string[];
|
|
338
|
+
/** The fields a card shows under its title, in order. Default none: the title alone. */
|
|
339
|
+
cardFields?: readonly Name[];
|
|
340
|
+
/**
|
|
341
|
+
* The most cards a column should hold, by value (`{ doing: 3 }`): a work-in-progress limit.
|
|
342
|
+
* A column over its limit says so; nothing stops a move into it.
|
|
343
|
+
*/
|
|
344
|
+
limits?: Readonly<Record<string, number>>;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* How the view's rows show as a gallery: ResourceView's `mode="grid"` draws a photo per row in
|
|
348
|
+
* justified rows (the layout `GalleryGrid` uses, from `@marktiderman/genesis-core/gallery`) in
|
|
349
|
+
* place of cards. Plain field names only, so every platform reads the same block.
|
|
350
|
+
*/
|
|
351
|
+
interface ViewGallery<Name extends string = string> {
|
|
352
|
+
/** The field holding the image's URL. */
|
|
353
|
+
image: Name;
|
|
354
|
+
/** The image's width and height in pixels, when the rows store them: rows pack by their ratio, 4:3 without. */
|
|
355
|
+
width?: Name;
|
|
356
|
+
height?: Name;
|
|
357
|
+
/** A short line under the photo in the viewer. Default none. */
|
|
358
|
+
caption?: Name;
|
|
359
|
+
/** The photo's text alternative. Default the row's label (the view's `labelField`). */
|
|
360
|
+
alt?: Name;
|
|
361
|
+
/** The target row height, px on the web and points on a phone. Default 180, as `GalleryGrid`. */
|
|
362
|
+
rowHeight?: number;
|
|
363
|
+
}
|
|
324
364
|
/** What `defineView` accepts. */
|
|
325
365
|
interface ViewDefinition<C extends ResourceContract, Row extends DataRow = RowOf<C>> {
|
|
326
366
|
copy?: ViewCopy;
|
|
@@ -353,6 +393,10 @@ interface ViewDefinition<C extends ResourceContract, Row extends DataRow = RowOf
|
|
|
353
393
|
scope?: readonly FieldNameOf<C>[];
|
|
354
394
|
/** How the rows show as a calendar (`mode="calendar"`). */
|
|
355
395
|
calendar?: ViewCalendar<FieldNameOf<C>>;
|
|
396
|
+
/** How the rows show as a board (`mode="board"`). */
|
|
397
|
+
board?: ViewBoard<FieldNameOf<C>>;
|
|
398
|
+
/** How the rows show as a gallery of photos (`mode="grid"`), in place of cards. */
|
|
399
|
+
gallery?: ViewGallery<FieldNameOf<C>>;
|
|
356
400
|
/** Group rows under headers by this field. */
|
|
357
401
|
groupBy?: FieldNameOf<C>;
|
|
358
402
|
/** Default order; `manual: true` turns on drag to reorder, writing this field. */
|
|
@@ -432,6 +476,11 @@ interface ResourceView<C extends ResourceContract = ResourceContract, Row extend
|
|
|
432
476
|
/** A value in words: the field's `labels`, else title case. For badges, choices and group titles. */
|
|
433
477
|
valueLabel(name: string, value: unknown): string;
|
|
434
478
|
columns(preset?: string): readonly ResolvedColumn<Row>[];
|
|
479
|
+
/**
|
|
480
|
+
* One field as a column, resolved as a preset lists it (a board card's fields, say). Undefined
|
|
481
|
+
* for a name that isn't a field or one the viewer can't read (`permissions.read: false`).
|
|
482
|
+
*/
|
|
483
|
+
column(name: string): ResolvedColumn<Row> | undefined;
|
|
435
484
|
form(mode: "create" | "edit"): readonly ResolvedFormField[];
|
|
436
485
|
/** Fields a writer may send: the form's, never generated, read-only, key or scope fields. */
|
|
437
486
|
writable(mode: "create" | "edit"): readonly string[];
|
|
@@ -449,6 +498,13 @@ interface ResourceView<C extends ResourceContract = ResourceContract, Row extend
|
|
|
449
498
|
*/
|
|
450
499
|
canAction(name: string, row: Row, viewer?: Viewer): Allowed;
|
|
451
500
|
summary(row: Row): RowSummary;
|
|
501
|
+
/**
|
|
502
|
+
* The row as a gallery photo, by the view's `gallery` block and any `override` a screen passes
|
|
503
|
+
* (ResourceView's `gallery`): undefined without a gallery block. Its `id` is the row's key, its
|
|
504
|
+
* `alt` the row's label unless the block names a field; a row without an image has an empty `src`,
|
|
505
|
+
* which GalleryGrid and NativeGalleryGrid draw as a placeholder tile; leave those out of a Lightbox.
|
|
506
|
+
*/
|
|
507
|
+
galleryItem(row: Row, override?: Partial<ViewGallery>): GalleryItem | undefined;
|
|
452
508
|
}
|
|
453
509
|
|
|
454
510
|
/** A view that names a field, preset or section its contract doesn't have. */
|
|
@@ -473,6 +529,25 @@ declare function valueText(labels: Readonly<Record<string, string>> | undefined,
|
|
|
473
529
|
* @stability Beta
|
|
474
530
|
*/
|
|
475
531
|
declare function calendarProblems(fields: readonly Pick<FieldSchema, "name" | "type" | "array">[], calendar: Partial<ViewCalendar>): string[];
|
|
532
|
+
/**
|
|
533
|
+
* The values a board's field can hold, in the contract's order: an enum's choices, or `true`
|
|
534
|
+
* and `false` for a yes/no field. Undefined when the field has no fixed set of values.
|
|
535
|
+
*
|
|
536
|
+
* @stability Beta
|
|
537
|
+
*/
|
|
538
|
+
declare function boardChoices(field: Pick<FieldSchema, "type" | "array" | "enumValues"> | undefined): readonly string[] | undefined;
|
|
539
|
+
/**
|
|
540
|
+
* What's wrong with a gallery block for these fields, one sentence each (empty when it's fine).
|
|
541
|
+
*
|
|
542
|
+
* @stability Beta
|
|
543
|
+
*/
|
|
544
|
+
declare function galleryProblems(fields: readonly Pick<FieldSchema, "name" | "type" | "array">[], gallery: Partial<ViewGallery>): string[];
|
|
545
|
+
/**
|
|
546
|
+
* What's wrong with a board block for these fields, one sentence each (empty when it's fine).
|
|
547
|
+
*
|
|
548
|
+
* @stability Beta
|
|
549
|
+
*/
|
|
550
|
+
declare function boardProblems(fields: readonly Pick<FieldSchema, "name" | "type" | "array" | "enumValues">[], board: Partial<ViewBoard>): string[];
|
|
476
551
|
/**
|
|
477
552
|
* Describe what a resource means to people. The result is frozen and platform-neutral:
|
|
478
553
|
*
|
|
@@ -816,4 +891,4 @@ type WorkspaceSection<Row extends DataRow = DataRow, Name extends string = strin
|
|
|
816
891
|
/** @deprecated Renamed `RecordViewHeaderAction`. */
|
|
817
892
|
type WorkspaceHeaderAction = RecordViewHeaderAction;
|
|
818
893
|
|
|
819
|
-
export { type Allowed, type ComputedColumn, type DisplayHint, type FieldNameOf, type LinkFilter, type LinkOrder, type LinkedView, type RecordView, type RecordViewDefinition, type RecordViewFilter, type RecordViewHeader, type RecordViewHeaderAction, type RecordViewHeaderOptions, type RecordViewListSection, type RecordViewReadinessItem, type RecordViewSection, type RecordViewSettingsSection, type RecordViewSlotSection, type ResolvedColumn, type ResolvedFormField, type ResolvedLink, type ResolvedReadinessItem, type ResolvedRecordViewSection, type ResolvedViewAction, type ResourceTree, type ResourceView, type ResourceWorkspace, type RowImage, RowOf, type RowPicture, type RowSummary, type TimeZoneName, type TreeNode, type TreeOptions, type TreeResult, type ViewAction, type ViewCalendar, type ViewCalendarDurationUnit, type ViewCalendarLayout, type ViewColumn, type ViewCopy, type ViewDefinition, ViewDefinitionError, type ViewField, type ViewFormItem, type ViewGuards, type ViewLink, type ViewPreset, type ViewTimeZone, type ViewTone, Viewer, type WorkspaceDefinition, type WorkspaceHeaderAction, type WorkspaceSection, calendarProblems, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, filterParams, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, sameFormValue, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
|
|
894
|
+
export { type Allowed, type ComputedColumn, type DisplayHint, type FieldNameOf, type LinkFilter, type LinkOrder, type LinkedView, type RecordView, type RecordViewDefinition, type RecordViewFilter, type RecordViewHeader, type RecordViewHeaderAction, type RecordViewHeaderOptions, type RecordViewListSection, type RecordViewReadinessItem, type RecordViewSection, type RecordViewSettingsSection, type RecordViewSlotSection, type ResolvedColumn, type ResolvedFormField, type ResolvedLink, type ResolvedReadinessItem, type ResolvedRecordViewSection, type ResolvedViewAction, type ResourceTree, type ResourceView, type ResourceWorkspace, type RowImage, RowOf, type RowPicture, type RowSummary, type TimeZoneName, type TreeNode, type TreeOptions, type TreeResult, type ViewAction, type ViewBoard, type ViewCalendar, type ViewCalendarDurationUnit, type ViewCalendarLayout, type ViewColumn, type ViewCopy, type ViewDefinition, ViewDefinitionError, type ViewField, type ViewFormItem, type ViewGallery, type ViewGuards, type ViewLink, type ViewPreset, type ViewTimeZone, type ViewTone, Viewer, type WorkspaceDefinition, type WorkspaceHeaderAction, type WorkspaceSection, boardChoices, boardProblems, calendarProblems, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, filterParams, galleryProblems, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, sameFormValue, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
|
|
@@ -3,8 +3,7 @@ import { keyFields, encodeRecordKey } from '../chunk-KV2HW4G4.js';
|
|
|
3
3
|
import { NO_VIEWER } from '../chunk-OZYF55E3.js';
|
|
4
4
|
export { NO_VIEWER } from '../chunk-OZYF55E3.js';
|
|
5
5
|
import { isTimeZone } from '../chunk-WXENWPWP.js';
|
|
6
|
-
import { isDevelopment, reportError } from '../chunk-
|
|
7
|
-
import '../chunk-PA6WJE5E.js';
|
|
6
|
+
import { isDevelopment, reportError } from '../chunk-VFT6QKZW.js';
|
|
8
7
|
import '../chunk-HUNGCTRA.js';
|
|
9
8
|
import { titleCase } from '../chunk-RYEXWQFD.js';
|
|
10
9
|
import '../chunk-LG6TUBVM.js';
|
|
@@ -245,6 +244,62 @@ function calendarProblems(fields, calendar) {
|
|
|
245
244
|
}
|
|
246
245
|
return problems;
|
|
247
246
|
}
|
|
247
|
+
var BOARD_KEYS = ["field", "columns", "cardFields", "limits"];
|
|
248
|
+
function boardChoices(field) {
|
|
249
|
+
if (!field || field.array) return void 0;
|
|
250
|
+
if (field.enumValues?.length) return field.enumValues;
|
|
251
|
+
if (field.type === "boolean") return ["true", "false"];
|
|
252
|
+
return void 0;
|
|
253
|
+
}
|
|
254
|
+
var GALLERY_KEYS = ["image", "width", "height", "caption", "alt", "rowHeight"];
|
|
255
|
+
function galleryProblems(fields, gallery) {
|
|
256
|
+
const problems = [];
|
|
257
|
+
const byName = new Map(fields.map((f) => [f.name, f]));
|
|
258
|
+
const named = (key, type) => {
|
|
259
|
+
const name = gallery[key];
|
|
260
|
+
if (name === void 0) return;
|
|
261
|
+
const field = byName.get(name);
|
|
262
|
+
if (!field) problems.push(`gallery.${key} names "${name}", which isn't a field`);
|
|
263
|
+
else if (type && (field.type !== type || field.array)) problems.push(`gallery.${key} "${name}" is a ${field.array ? "list" : field.type}, not a ${type === "string" ? "text" : "number"} field`);
|
|
264
|
+
};
|
|
265
|
+
named("image", "string");
|
|
266
|
+
named("width", "number");
|
|
267
|
+
named("height", "number");
|
|
268
|
+
named("caption");
|
|
269
|
+
named("alt");
|
|
270
|
+
if (gallery.width === void 0 !== (gallery.height === void 0)) problems.push("gallery.width and gallery.height go together: a ratio needs both");
|
|
271
|
+
const { rowHeight } = gallery;
|
|
272
|
+
if (rowHeight !== void 0 && !(typeof rowHeight === "number" && Number.isFinite(rowHeight) && rowHeight > 0)) problems.push(`gallery.rowHeight is a height above 0, not ${String(rowHeight)}`);
|
|
273
|
+
return problems;
|
|
274
|
+
}
|
|
275
|
+
function boardProblems(fields, board) {
|
|
276
|
+
const problems = [];
|
|
277
|
+
const byName = new Map(fields.map((f) => [f.name, f]));
|
|
278
|
+
const field = board.field === void 0 ? void 0 : byName.get(board.field);
|
|
279
|
+
if (board.field !== void 0 && !field) problems.push(`board.field names "${board.field}", which isn't a field`);
|
|
280
|
+
const choices = boardChoices(field);
|
|
281
|
+
if (field && !choices) problems.push(`board.field "${board.field}" has no fixed values: use an enum or a yes/no field`);
|
|
282
|
+
if (board.columns !== void 0) {
|
|
283
|
+
if (!Array.isArray(board.columns) || board.columns.length === 0) problems.push("board.columns isn't a list of values");
|
|
284
|
+
else {
|
|
285
|
+
const seen = /* @__PURE__ */ new Set();
|
|
286
|
+
for (const value of board.columns) {
|
|
287
|
+
if (choices && !choices.includes(value)) problems.push(`board.columns lists "${String(value)}", which isn't a value of ${board.field}`);
|
|
288
|
+
if (seen.has(value)) problems.push(`board.columns lists "${String(value)}" twice`);
|
|
289
|
+
seen.add(value);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
for (const name of board.cardFields ?? []) {
|
|
294
|
+
if (!byName.has(name)) problems.push(`board.cardFields names "${name}", which isn't a field`);
|
|
295
|
+
}
|
|
296
|
+
for (const [value, limit] of Object.entries(board.limits ?? {})) {
|
|
297
|
+
const columns = board.columns ?? choices;
|
|
298
|
+
if (columns && !columns.includes(value)) problems.push(`board.limits has "${value}", which isn't one of the board's columns`);
|
|
299
|
+
if (!Number.isInteger(limit) || limit < 1) problems.push(`board.limits.${value} is a whole number of cards, 1 or more, not ${String(limit)}`);
|
|
300
|
+
}
|
|
301
|
+
return problems;
|
|
302
|
+
}
|
|
248
303
|
function defineView(contract, definition = {}) {
|
|
249
304
|
const facts = contract;
|
|
250
305
|
const fields = contract.fields;
|
|
@@ -359,6 +414,36 @@ function defineView(contract, definition = {}) {
|
|
|
359
414
|
problems.push(...calendarProblems(fields, calendar));
|
|
360
415
|
}
|
|
361
416
|
}
|
|
417
|
+
const rawBoard = definition.board;
|
|
418
|
+
let board;
|
|
419
|
+
if (rawBoard !== void 0) {
|
|
420
|
+
if (!rawBoard || typeof rawBoard !== "object" || Array.isArray(rawBoard)) {
|
|
421
|
+
problems.push("board isn't an object");
|
|
422
|
+
} else {
|
|
423
|
+
for (const key of Object.keys(rawBoard)) if (!BOARD_KEYS.includes(key)) problems.push(`board.${key} isn't a board setting`);
|
|
424
|
+
if (rawBoard.field === void 0) problems.push("board.field is required");
|
|
425
|
+
const given = rawBoard;
|
|
426
|
+
board = Object.freeze({
|
|
427
|
+
...given,
|
|
428
|
+
...given.columns ? { columns: Object.freeze([...given.columns]) } : {},
|
|
429
|
+
...given.cardFields ? { cardFields: Object.freeze([...given.cardFields]) } : {},
|
|
430
|
+
...given.limits ? { limits: Object.freeze({ ...given.limits }) } : {}
|
|
431
|
+
});
|
|
432
|
+
problems.push(...boardProblems(fields, board));
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
const rawGallery = definition.gallery;
|
|
436
|
+
let gallery;
|
|
437
|
+
if (rawGallery !== void 0) {
|
|
438
|
+
if (!rawGallery || typeof rawGallery !== "object" || Array.isArray(rawGallery)) {
|
|
439
|
+
problems.push("gallery isn't an object");
|
|
440
|
+
} else {
|
|
441
|
+
for (const key of Object.keys(rawGallery)) if (!GALLERY_KEYS.includes(key)) problems.push(`gallery.${key} isn't a gallery setting`);
|
|
442
|
+
if (rawGallery.image === void 0) problems.push("gallery.image is required");
|
|
443
|
+
gallery = Object.freeze({ ...rawGallery });
|
|
444
|
+
problems.push(...galleryProblems(fields, gallery));
|
|
445
|
+
}
|
|
446
|
+
}
|
|
362
447
|
if (definition.orderBy) known(definition.orderBy.field, "orderBy");
|
|
363
448
|
for (const [name, preset] of Object.entries(presets)) {
|
|
364
449
|
if (preset.columns && preset.columns !== "default" && !own(columnLists, preset.columns)) {
|
|
@@ -411,6 +496,27 @@ function defineView(contract, definition = {}) {
|
|
|
411
496
|
const neededLink = (f) => linkEditable(f) && !f.nullable && !f.optional && !f.hasDefault && !scope.has(f.name);
|
|
412
497
|
const defaultColumns = own(columnLists, "default") ?? fields.filter((f) => !quiet(f)).map((f) => f.name);
|
|
413
498
|
const presetNames = Object.freeze(["default", ...Object.keys(columnLists).filter((p) => p !== "default")]);
|
|
499
|
+
const fieldColumns = /* @__PURE__ */ new Map();
|
|
500
|
+
const fieldColumn = (column) => {
|
|
501
|
+
const cached = fieldColumns.get(column);
|
|
502
|
+
if (cached) return cached;
|
|
503
|
+
const v = own(viewFields, column);
|
|
504
|
+
const resolved = Object.freeze({
|
|
505
|
+
key: column,
|
|
506
|
+
label: label(column),
|
|
507
|
+
display: display(column),
|
|
508
|
+
field: byName.get(column),
|
|
509
|
+
value: (row) => row[column],
|
|
510
|
+
...v?.tones ? { tones: v.tones } : {},
|
|
511
|
+
...v?.labels ? { labels: v.labels } : {},
|
|
512
|
+
...v?.labelField ? { labelField: v.labelField } : {},
|
|
513
|
+
...v?.missingLabel ? { missingLabel: v.missingLabel } : {},
|
|
514
|
+
...v?.when ? { when: (row, viewer = NO_VIEWER) => v.when(row, viewer) } : {},
|
|
515
|
+
...v?.timeZone ? { timeZone: v.timeZone } : {}
|
|
516
|
+
});
|
|
517
|
+
fieldColumns.set(column, resolved);
|
|
518
|
+
return resolved;
|
|
519
|
+
};
|
|
414
520
|
const resolvedColumns = /* @__PURE__ */ new Map();
|
|
415
521
|
const columns = (preset = "default") => {
|
|
416
522
|
const cached = resolvedColumns.get(preset);
|
|
@@ -422,20 +528,7 @@ function defineView(contract, definition = {}) {
|
|
|
422
528
|
if (typeof column !== "string") {
|
|
423
529
|
return Object.freeze({ key: column.key, label: column.label, display: column.display ?? "text", value: column.value });
|
|
424
530
|
}
|
|
425
|
-
|
|
426
|
-
return Object.freeze({
|
|
427
|
-
key: column,
|
|
428
|
-
label: label(column),
|
|
429
|
-
display: display(column),
|
|
430
|
-
field: byName.get(column),
|
|
431
|
-
value: (row) => row[column],
|
|
432
|
-
...v?.tones ? { tones: v.tones } : {},
|
|
433
|
-
...v?.labels ? { labels: v.labels } : {},
|
|
434
|
-
...v?.labelField ? { labelField: v.labelField } : {},
|
|
435
|
-
...v?.missingLabel ? { missingLabel: v.missingLabel } : {},
|
|
436
|
-
...v?.when ? { when: (row, viewer = NO_VIEWER) => v.when(row, viewer) } : {},
|
|
437
|
-
...v?.timeZone ? { timeZone: v.timeZone } : {}
|
|
438
|
-
});
|
|
531
|
+
return fieldColumn(column);
|
|
439
532
|
})
|
|
440
533
|
);
|
|
441
534
|
resolvedColumns.set(preset, out);
|
|
@@ -514,6 +607,31 @@ function defineView(contract, definition = {}) {
|
|
|
514
607
|
const value = labelField ? row[labelField] : void 0;
|
|
515
608
|
return { title: value === null || value === void 0 || value === "" ? titleCase(noun) : String(value) };
|
|
516
609
|
};
|
|
610
|
+
const galleryItem = (row, override) => {
|
|
611
|
+
const block = { ...gallery, ...override };
|
|
612
|
+
if (!block.image) return void 0;
|
|
613
|
+
const image = row[block.image];
|
|
614
|
+
const src = typeof image === "string" ? image : "";
|
|
615
|
+
const number = (name) => {
|
|
616
|
+
const value = name ? Number(row[name]) : NaN;
|
|
617
|
+
return Number.isFinite(value) && value > 0 ? value : void 0;
|
|
618
|
+
};
|
|
619
|
+
const text = (name) => {
|
|
620
|
+
const value = name ? row[name] : void 0;
|
|
621
|
+
return value === null || value === void 0 || value === "" ? void 0 : String(value);
|
|
622
|
+
};
|
|
623
|
+
const width = number(block.width);
|
|
624
|
+
const height = number(block.height);
|
|
625
|
+
const caption = text(block.caption);
|
|
626
|
+
const alt = text(block.alt) ?? summary(row).title;
|
|
627
|
+
return {
|
|
628
|
+
id: String(encodeRecordKey(contract, row)),
|
|
629
|
+
src,
|
|
630
|
+
alt,
|
|
631
|
+
...width !== void 0 && height !== void 0 ? { width, height } : {},
|
|
632
|
+
...caption !== void 0 ? { caption } : {}
|
|
633
|
+
};
|
|
634
|
+
};
|
|
517
635
|
return Object.freeze({
|
|
518
636
|
contract,
|
|
519
637
|
definition: Object.freeze({
|
|
@@ -524,7 +642,9 @@ function defineView(contract, definition = {}) {
|
|
|
524
642
|
...definition.form ? { form: formItems } : {},
|
|
525
643
|
...definition.scope ? { scope: Object.freeze([...definition.scope]) } : {},
|
|
526
644
|
...definition.actions ? { actions: actionList } : {},
|
|
527
|
-
...calendar ? { calendar } : {}
|
|
645
|
+
...calendar ? { calendar } : {},
|
|
646
|
+
...board ? { board } : {},
|
|
647
|
+
...gallery ? { gallery } : {}
|
|
528
648
|
}),
|
|
529
649
|
resource: contract.name,
|
|
530
650
|
noun,
|
|
@@ -533,6 +653,7 @@ function defineView(contract, definition = {}) {
|
|
|
533
653
|
labelField,
|
|
534
654
|
presets: presetNames,
|
|
535
655
|
field: (name) => byName.get(name),
|
|
656
|
+
column: (name) => byName.has(name) && readable(name) ? fieldColumn(name) : void 0,
|
|
536
657
|
label,
|
|
537
658
|
display,
|
|
538
659
|
valueLabel,
|
|
@@ -542,7 +663,8 @@ function defineView(contract, definition = {}) {
|
|
|
542
663
|
can,
|
|
543
664
|
actions: () => resolvedActions,
|
|
544
665
|
canAction,
|
|
545
|
-
summary
|
|
666
|
+
summary,
|
|
667
|
+
galleryItem
|
|
546
668
|
});
|
|
547
669
|
}
|
|
548
670
|
|
|
@@ -912,6 +1034,6 @@ function defineRecordView(view, definition) {
|
|
|
912
1034
|
var defineWorkspace = defineRecordView;
|
|
913
1035
|
var isWorkspace = isRecordView;
|
|
914
1036
|
|
|
915
|
-
export { ViewDefinitionError, calendarProblems, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, filterParams, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, sameFormValue, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
|
|
1037
|
+
export { ViewDefinitionError, boardChoices, boardProblems, calendarProblems, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, filterParams, galleryProblems, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, sameFormValue, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
|
|
916
1038
|
//# sourceMappingURL=index.js.map
|
|
917
1039
|
//# sourceMappingURL=index.js.map
|