@constructive-io/sheets 0.4.1 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +19 -24
  2. package/dist/advanced.cjs +250 -405
  3. package/dist/advanced.cjs.map +1 -1
  4. package/dist/advanced.d.cts +9 -10
  5. package/dist/advanced.d.ts +9 -10
  6. package/dist/advanced.js +3 -3
  7. package/dist/auth.cjs +10 -10
  8. package/dist/auth.cjs.map +1 -1
  9. package/dist/auth.d.cts +5 -4
  10. package/dist/auth.d.ts +5 -4
  11. package/dist/auth.js +3 -3
  12. package/dist/{chunk-GLVZSPV2.js → chunk-4EZ6A23C.js} +4 -3
  13. package/dist/chunk-4EZ6A23C.js.map +1 -0
  14. package/dist/{chunk-3BNOZQIJ.js → chunk-KKAWMVEG.js} +11 -11
  15. package/dist/chunk-KKAWMVEG.js.map +1 -0
  16. package/dist/{chunk-FG2LRZP5.js → chunk-KOZAW264.js} +4 -3
  17. package/dist/chunk-KOZAW264.js.map +1 -0
  18. package/dist/{chunk-BWJVRYJT.js → chunk-KVPVEXWB.js} +40 -17
  19. package/dist/chunk-KVPVEXWB.js.map +1 -0
  20. package/dist/{chunk-BWKB52JB.js → chunk-LR64FLWO.js} +231 -379
  21. package/dist/chunk-LR64FLWO.js.map +1 -0
  22. package/dist/{chunk-SDKHWE7G.js → chunk-ZETPUEXH.js} +27 -2
  23. package/dist/chunk-ZETPUEXH.js.map +1 -0
  24. package/dist/{date-editor-CXKKGNL6.js → date-editor-QT47WY5T.js} +5 -3
  25. package/dist/date-editor-QT47WY5T.js.map +1 -0
  26. package/dist/{editor-props-M6Dh0P9f.d.ts → grid-cell-types-C3ARj148.d.cts} +70 -62
  27. package/dist/{editor-props-M6Dh0P9f.d.cts → grid-cell-types-C3ARj148.d.ts} +70 -62
  28. package/dist/index.cjs +564 -493
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +86 -35
  31. package/dist/index.d.ts +86 -35
  32. package/dist/index.js +264 -72
  33. package/dist/index.js.map +1 -1
  34. package/dist/{sheets-context-9u9r7Bs0.d.ts → sheets-context-B03WDhZ9.d.cts} +13 -6
  35. package/dist/{sheets-context-BjGIHocT.d.cts → sheets-context-DmVCOgiX.d.ts} +13 -6
  36. package/dist/styles.css +6 -0
  37. package/dist/testing.cjs +99 -33
  38. package/dist/testing.cjs.map +1 -1
  39. package/dist/testing.d.cts +11 -7
  40. package/dist/testing.d.ts +11 -7
  41. package/dist/testing.js +34 -8
  42. package/dist/testing.js.map +1 -1
  43. package/package.json +15 -16
  44. package/dist/chunk-3BNOZQIJ.js.map +0 -1
  45. package/dist/chunk-BWJVRYJT.js.map +0 -1
  46. package/dist/chunk-BWKB52JB.js.map +0 -1
  47. package/dist/chunk-FG2LRZP5.js.map +0 -1
  48. package/dist/chunk-GLVZSPV2.js.map +0 -1
  49. package/dist/chunk-SDKHWE7G.js.map +0 -1
  50. package/dist/date-editor-CXKKGNL6.js.map +0 -1
@@ -460,10 +460,35 @@ function createSheetsUpload(config, getToken) {
460
460
  };
461
461
  }
462
462
 
463
+ // src/hooks/query-keys.ts
464
+ function isSheetsScopeKey(value) {
465
+ if (!value || typeof value !== "object") return false;
466
+ const candidate = value;
467
+ return "databaseId" in candidate && "endpoint" in candidate && "identityKey" in candidate;
468
+ }
469
+ var sheetsQueryKeys = {
470
+ root: ["sheets"],
471
+ scope: (scope) => ["sheets", scope],
472
+ meta: (scope) => [...sheetsQueryKeys.scope(scope), "meta"],
473
+ typeFields: (scope, typeName) => [...sheetsQueryKeys.scope(scope), "type-fields", typeName],
474
+ enumValues: (scope, typeName) => [...sheetsQueryKeys.scope(scope), "enum-values", typeName],
475
+ relations: (scope, tableName) => [...sheetsQueryKeys.scope(scope), "relations", tableName],
476
+ table: (scope, tableName) => [...sheetsQueryKeys.scope(scope), "table", tableName],
477
+ tableRows: (scope, tableName, options) => [...sheetsQueryKeys.table(scope, tableName), "rows", options],
478
+ tableRow: (scope, tableName, id) => [...sheetsQueryKeys.table(scope, tableName), "row", id],
479
+ tableCount: (scope, tableName, where) => [...sheetsQueryKeys.table(scope, tableName), "count", where],
480
+ infiniteTable: (scope, tableName) => [...sheetsQueryKeys.scope(scope), "infinite-table", tableName],
481
+ infiniteTablePage: (scope, tableName, pageIndex, options) => [...sheetsQueryKeys.infiniteTable(scope, tableName), "page", pageIndex, options],
482
+ infiniteTableTotalCount: (scope, tableName, where) => [...sheetsQueryKeys.infiniteTable(scope, tableName), "totalCount", where],
483
+ cursorTable: (scope, tableName, options) => [...sheetsQueryKeys.scope(scope), "cursor-table", tableName, options]
484
+ };
485
+
463
486
  export {
464
487
  resolveDownloadUrl,
465
488
  createSheetsExecute,
466
489
  createSheetsUpload,
467
- DataError2 as DataError
490
+ DataError2 as DataError,
491
+ isSheetsScopeKey,
492
+ sheetsQueryKeys
468
493
  };
469
- //# sourceMappingURL=chunk-SDKHWE7G.js.map
494
+ //# sourceMappingURL=chunk-ZETPUEXH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context/sheets-upload-presigned.ts","../src/context/sheets-execute.ts","../src/hooks/query-keys.ts"],"sourcesContent":["/**\n * Presigned-URL upload helpers for the sheets cell-upload seam.\n *\n * Replaces the legacy multipart `<endpoint>/upload` POST. The flow is:\n * 1. SHA-256 hash the file bytes (Web Crypto, zero new deps)\n * 2. Call the presigned upload op (discovered via introspection) to get a\n * presigned PUT url + fileId\n * 3. PUT the raw bytes to that url (only Content-Type, NO Authorization)\n * 4. Resolve the stable public `downloadUrl` for the fileId\n *\n * `confirmUpload` is intentionally skipped: the backend plugin creates the file\n * row inside the upload op, so `downloadUrl` resolves immediately.\n *\n * The upload op is discovered via runtime introspection, matched by FIELD/TYPE\n * SHAPE (never a hardcoded name): a root mutation `upload<Type>File(input: {...})`\n * whose input + payload carry the upload shape.\n *\n * The downloadUrl-by-id field is likewise shape-discovered. Three read shapes,\n * preferred in order: the inflected singular `appFile(id:)`; a filtered\n * connection `appFiles(where:{id:{equalTo:$id}}){ nodes { downloadUrl } }`\n * (Relay-disabled backends); and the Relay `node(nodeId:)` fallback.\n */\n\nimport { getIntrospectionQuery } from 'graphql';\n\nimport { createError } from '@constructive-io/data';\n\nimport type { SheetsExecuteFn } from './sheets-execute';\n\n// ============================================================================\n// Capability discovery types\n// ============================================================================\n\nexport interface UploadCapability {\n\t/** Upload mutation field name, discovered by shape, e.g. 'uploadAppFile'. */\n\tuploadFieldName: string;\n\t/** The upload input object type name, e.g. 'UploadAppFileInput'. */\n\tinputTypeName: string;\n\t/** Query field used to resolve the stable downloadUrl by id, e.g. 'appFile' | 'node' | 'appFiles'. */\n\tfileByIdField: string;\n\t/**\n\t * Which downloadUrl-by-id resolution shape was discovered:\n\t * - 'id' inflected singular `appFile(id:)`\n\t * - 'connection' filtered connection `appFiles(where:{id:{equalTo:$id}}){ nodes { downloadUrl } }`\n\t * - 'nodeId' Relay `node(nodeId:)` (last-resort fallback)\n\t */\n\tfileByIdArgName: 'id' | 'nodeId' | 'connection';\n\t/** The file object type name (used to spread `... on <Type>` on the Relay node path). */\n\tfileTypeName: string;\n\t/** The GraphQL scalar type name for the `$id` variable (e.g. 'UUID'), discovered by shape. */\n\tidScalarName?: string;\n\t/** connection kind only — the filter arg name on the connection field, e.g. 'where' | 'filter' | 'condition'. */\n\tconnectionFilterArgName?: string;\n\t/** connection kind only — the id field name inside the filter input, e.g. 'id'. */\n\tconnectionIdField?: string;\n\t/** connection kind only — the equality operator field for style (a), e.g. 'equalTo'. Absent for condition style (b). */\n\tconnectionIdOperator?: string;\n\t/** connection kind only — the field on the connection object holding the file rows, e.g. 'nodes'. */\n\tconnectionNodesField?: string;\n}\n\ninterface UploadPayload {\n\tuploadUrl: string | null;\n\tfileId: string;\n\tkey: string;\n\tdeduplicated: boolean;\n}\n\n// ============================================================================\n// SHA-256 (Web Crypto)\n// ============================================================================\n\n/**\n * SHA-256 hex digest of an already-read ArrayBuffer. Lowercase, 64 chars —\n * matches the server regex `^[a-f0-9]{64}$`. We reuse the same buffer for the\n * PUT body to avoid a second `file.arrayBuffer()` read.\n */\nexport async function sha256HexFromBuffer(buffer: ArrayBuffer): Promise<string> {\n\tif (!globalThis.crypto?.subtle) {\n\t\tthrow createError.badRequest('Web Crypto (crypto.subtle) is unavailable; cannot hash file for upload.');\n\t}\n\tconst digest = await crypto.subtle.digest('SHA-256', buffer);\n\tconst bytes = new Uint8Array(digest);\n\tlet hex = '';\n\tfor (let i = 0; i < bytes.length; i++) {\n\t\thex += bytes[i].toString(16).padStart(2, '0');\n\t}\n\treturn hex;\n}\n\n// ============================================================================\n// Introspection-based capability discovery (cached per endpoint)\n// ============================================================================\n\nconst capabilityCache = new Map<string, Promise<UploadCapability>>();\n\n/** Test-only: clear the per-endpoint capability cache between cases. */\nexport function __resetUploadCapabilityCache(): void {\n\tcapabilityCache.clear();\n}\n\n/**\n * Discover the upload op + downloadUrl-by-id field for an endpoint, by shape.\n * Cached per `endpoint`; concurrent uploads share one in-flight introspection.\n */\nexport function discoverUploadCapability(endpoint: string, execute: SheetsExecuteFn): Promise<UploadCapability> {\n\tconst cached = capabilityCache.get(endpoint);\n\tif (cached) return cached;\n\n\tconst promise = (async () => {\n\t\tconst data = await execute<{ __schema: IntrospectionSchema }>(getIntrospectionQuery());\n\t\tconst schema = data?.__schema;\n\t\tif (!schema) {\n\t\t\tthrow createError.badRequest('Uploads are not enabled for this endpoint.');\n\t\t}\n\t\treturn resolveUploadCapability(schema);\n\t})();\n\n\t// Don't cache a rejected discovery — let the next attempt retry.\n\tpromise.catch(() => capabilityCache.delete(endpoint));\n\tcapabilityCache.set(endpoint, promise);\n\treturn promise;\n}\n\n// --- Minimal introspection shapes (only what discovery reads) ---\n\n// Loose, structural shapes for the slice of introspection that discovery\n// reads. `ofType` recurses with `any` so hand-built fixtures and the real\n// `IntrospectionQuery['__schema']` (from `graphql`) both satisfy these without\n// exact-match friction — discovery validates by runtime shape regardless.\ninterface IntrospectionTypeRef {\n\tkind: string;\n\tname?: string | null;\n\tofType?: any;\n}\n\ninterface IntrospectionInputValue {\n\tname: string;\n\ttype: IntrospectionTypeRef;\n}\n\ninterface IntrospectionField {\n\tname: string;\n\targs: ReadonlyArray<IntrospectionInputValue>;\n\ttype: IntrospectionTypeRef;\n}\n\ninterface IntrospectionType {\n\tkind: string;\n\tname?: string | null;\n\tfields?: ReadonlyArray<IntrospectionField> | null;\n\tinputFields?: ReadonlyArray<IntrospectionInputValue> | null;\n}\n\n/** Loose structural shape of an introspection `__schema` (accepts fixtures + real). */\nexport interface IntrospectionSchema {\n\tqueryType?: { name: string } | null;\n\tmutationType?: { name: string } | null;\n\ttypes: ReadonlyArray<IntrospectionType>;\n}\n\n/** Unwrap NON_NULL / LIST wrappers down to the named type. */\nfunction namedTypeName(ref: IntrospectionTypeRef | null | undefined): string | null {\n\tlet cur = ref;\n\twhile (cur && (cur.kind === 'NON_NULL' || cur.kind === 'LIST')) {\n\t\tcur = cur.ofType ?? null;\n\t}\n\treturn cur?.name ?? null;\n}\n\n/**\n * True if `ref` is a LIST (optionally NON_NULL-wrapped) at the outer level, i.e.\n * the field is plural. Unwraps only leading NON_NULL wrappers (e.g. `[AppFile]!`)\n * before checking for the LIST — distinguishes `nodes: [AppFile]` from a singular\n * `appFile: AppFile`.\n */\nfunction isListTypeRef(ref: IntrospectionTypeRef | null | undefined): boolean {\n\tlet cur = ref;\n\twhile (cur && cur.kind === 'NON_NULL') {\n\t\tcur = cur.ofType ?? null;\n\t}\n\treturn cur?.kind === 'LIST';\n}\n\n/**\n * PostGraphile names the primary-key column `id` on every row type, so the\n * filter input field that selects a single file by primary key is `id`. This is\n * the same convention the singular by-id branch (`appFile(id:)`) relies on.\n */\nconst PK_FIELD_NAME = 'id';\n\n/**\n * Pure resolver over an introspection __schema. Exported for direct unit tests\n * (no fetch). Matches by field/type SHAPE, never by a literal name.\n */\nexport function resolveUploadCapability(schema: IntrospectionSchema): UploadCapability {\n\tconst typeByName = new Map<string, IntrospectionType>();\n\tfor (const t of schema.types) {\n\t\tif (t.name) typeByName.set(t.name, t);\n\t}\n\n\tconst objectHasFields = (typeName: string | null, names: string[]): boolean => {\n\t\tif (!typeName) return false;\n\t\tconst t = typeByName.get(typeName);\n\t\tif (!t?.fields) return false;\n\t\tconst present = new Set(t.fields.map((f) => f.name));\n\t\treturn names.every((n) => present.has(n));\n\t};\n\n\tconst inputHasFields = (typeName: string | null, names: string[]): boolean => {\n\t\tif (!typeName) return false;\n\t\tconst t = typeByName.get(typeName);\n\t\tif (!t?.inputFields) return false;\n\t\tconst present = new Set(t.inputFields.map((f) => f.name));\n\t\treturn names.every((n) => present.has(n));\n\t};\n\n\tconst PAYLOAD_FIELDS = ['uploadUrl', 'fileId', 'deduplicated'];\n\tconst INPUT_FIELDS = ['contentHash', 'bucketKey', 'contentType', 'size'];\n\n\tconst mutationType = schema.mutationType ? typeByName.get(schema.mutationType.name) : null;\n\tconst queryType = schema.queryType ? typeByName.get(schema.queryType.name) : null;\n\n\t// rootUpload discovery: a Mutation field with a single `input` arg whose input\n\t// type carries the upload-input shape and whose payload carries the\n\t// upload-payload shape. (The legacy bucket-centric `requestUploadUrl` shape was\n\t// removed from the backend on 2026-05-08; only the root upload mutation exists.)\n\tlet upload: Pick<UploadCapability, 'uploadFieldName' | 'inputTypeName'> | null = null;\n\n\tfor (const field of mutationType?.fields ?? []) {\n\t\tconst inputArg = field.args.find((a) => a.name === 'input');\n\t\tif (!inputArg) continue;\n\t\tconst inputTypeName = namedTypeName(inputArg.type);\n\t\tconst payloadTypeName = namedTypeName(field.type);\n\t\tif (\n\t\t\tinputHasFields(inputTypeName, INPUT_FIELDS) &&\n\t\t\tobjectHasFields(payloadTypeName, PAYLOAD_FIELDS)\n\t\t) {\n\t\t\tupload = { uploadFieldName: field.name, inputTypeName: inputTypeName as string };\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!upload) {\n\t\tthrow createError.badRequest('Uploads are not enabled for this endpoint.');\n\t}\n\n\t// --- File object type + by-id field for downloadUrl ---\n\tconst downloadById = resolveDownloadByIdField(schema, typeByName, queryType, upload.uploadFieldName);\n\n\treturn {\n\t\t...upload,\n\t\t...downloadById,\n\t};\n}\n\ntype DownloadByIdResult = Omit<UploadCapability, 'uploadFieldName' | 'inputTypeName'>;\n\nfunction resolveDownloadByIdField(\n\tschema: IntrospectionSchema,\n\ttypeByName: Map<string, IntrospectionType>,\n\tqueryType: IntrospectionType | null | undefined,\n\tuploadFieldName: string,\n): DownloadByIdResult {\n\t// The file object type carries a `downloadUrl` field (grounded on\n\t// download-url-field.ts which adds `downloadUrl: String` to @storageFiles).\n\tconst fileTypesWithDownloadUrl = new Set<string>();\n\tfor (const t of schema.types) {\n\t\tif (t.kind === 'OBJECT' && t.name && t.fields?.some((f) => f.name === 'downloadUrl')) {\n\t\t\tfileTypesWithDownloadUrl.add(t.name);\n\t\t}\n\t}\n\n\t// 1. Prefer the inflected by-id form: a Query field whose return type has a\n\t// `downloadUrl` field and that takes a single `id` arg. e.g. appFile(id:).\n\t// The `$id` variable type is the actual scalar of that id arg (NOT a\n\t// hardcoded UUID) — derived by shape.\n\tfor (const field of queryType?.fields ?? []) {\n\t\tconst returnTypeName = namedTypeName(field.type);\n\t\tif (!returnTypeName || !fileTypesWithDownloadUrl.has(returnTypeName)) continue;\n\t\tif (field.args.length === 1 && field.args[0].name === PK_FIELD_NAME) {\n\t\t\treturn {\n\t\t\t\tfileByIdField: field.name,\n\t\t\t\tfileByIdArgName: 'id',\n\t\t\t\tfileTypeName: returnTypeName,\n\t\t\t\tidScalarName: namedTypeName(field.args[0].type) ?? undefined,\n\t\t\t};\n\t\t}\n\t}\n\n\t// 2. Connection fallback (Relay-disabled backends, incl. the live tenant API):\n\t// a Query field returning a connection whose `nodes` element is a\n\t// downloadUrl-bearing file type, filtered by id. e.g.\n\t// appFiles(where: { id: { equalTo: $id } }, first: 1) { nodes { downloadUrl } }\n\t// All names (connection field, filter arg, id field, equality operator,\n\t// nodes field, id scalar) are discovered by SHAPE, never hardcoded.\n\t// Preferred over the Relay node path: it consumes the raw fileId directly,\n\t// so it needs no client-side global-id construction.\n\tconst connection = resolveConnectionDownloadField(typeByName, queryType, fileTypesWithDownloadUrl, uploadFieldName);\n\tif (connection) return connection;\n\n\t// 3. Relay fallback: `node(nodeId: ID!)`. Last resort — only when neither a\n\t// singular `id` accessor nor a filtered connection exists. Caller spreads\n\t// `... on <FileType> { downloadUrl }` and encodes the global id.\n\tconst nodeField = queryType?.fields?.find(\n\t\t(f) => f.name === 'node' && f.args.some((a) => a.name === 'nodeId'),\n\t);\n\tif (nodeField && fileTypesWithDownloadUrl.size > 0) {\n\t\t// Deterministic file type for the inline fragment: prefer the type named\n\t\t// after the upload op (uploadAppFile → AppFile); else the first-declared\n\t\t// downloadUrl-bearing type. (Was alphabetical `.sort()[0]`, which could pick\n\t\t// the wrong type when several expose downloadUrl, e.g. DataRoomFile.)\n\t\tconst preferred = uploadFieldName.replace(/^upload/, '');\n\t\tconst fileTypeName = fileTypesWithDownloadUrl.has(preferred)\n\t\t\t? preferred\n\t\t\t: [...fileTypesWithDownloadUrl][0];\n\t\treturn { fileByIdField: 'node', fileByIdArgName: 'nodeId', fileTypeName };\n\t}\n\n\tthrow createError.badRequest('Uploads are not enabled for this endpoint.');\n}\n\n/**\n * Discover a filtered-connection downloadUrl-by-id path. Returns null if the\n * schema exposes no such connection. Supports two filter input styles:\n * (a) operator filter — `where: { id: { equalTo: $id } }` (connection-filter\n * plugin): the id field's input type carries an equality operator.\n * (b) condition filter — `condition: { id: $id }`: the id field is the scalar\n * directly.\n */\nfunction resolveConnectionDownloadField(\n\ttypeByName: Map<string, IntrospectionType>,\n\tqueryType: IntrospectionType | null | undefined,\n\tfileTypesWithDownloadUrl: Set<string>,\n\tuploadFieldName: string,\n): DownloadByIdResult | null {\n\t// Equality operator names we recognize on a filter-input field, in priority\n\t// order (exact-match equality first).\n\tconst EQUALITY_OPERATORS = ['equalTo', 'eq'];\n\n\t// Collect every matching connection, then pick deterministically — a tenant\n\t// with multiple @storageFiles tables exposes several file connections\n\t// (appFiles, dataRoomFiles, …), all carrying downloadUrl-bearing nodes.\n\tconst candidates: DownloadByIdResult[] = [];\n\n\tfor (const field of queryType?.fields ?? []) {\n\t\tconst connTypeName = namedTypeName(field.type);\n\t\tif (!connTypeName) continue;\n\t\tconst connType = typeByName.get(connTypeName);\n\t\tif (connType?.kind !== 'OBJECT' || !connType.fields) continue;\n\n\t\t// Find the `nodes` field whose element type is a downloadUrl-bearing file.\n\t\t// Require it to be a LIST (plural) so a singular `appFile: AppFile` field on\n\t\t// some object does NOT false-match as a connection (fetchDownloadUrl indexes\n\t\t// [nodesField][0], which only makes sense on an array).\n\t\tconst nodesField = connType.fields.find((f) => {\n\t\t\tif (!isListTypeRef(f.type)) return false;\n\t\t\tconst elem = namedTypeName(f.type);\n\t\t\treturn elem != null && fileTypesWithDownloadUrl.has(elem);\n\t\t});\n\t\tif (!nodesField) continue;\n\t\tconst fileTypeName = namedTypeName(nodesField.type) as string;\n\n\t\t// Find a filter arg whose input type has an `id` field.\n\t\tfor (const arg of field.args) {\n\t\t\tconst filterTypeName = namedTypeName(arg.type);\n\t\t\tconst filterType = filterTypeName ? typeByName.get(filterTypeName) : null;\n\t\t\tif (filterType?.kind !== 'INPUT_OBJECT' || !filterType.inputFields) continue;\n\t\t\tconst idField = filterType.inputFields.find((f) => f.name === PK_FIELD_NAME);\n\t\t\tif (!idField) continue;\n\n\t\t\tconst idFieldTypeName = namedTypeName(idField.type);\n\t\t\tconst idFieldType = idFieldTypeName ? typeByName.get(idFieldTypeName) : null;\n\n\t\t\t// Style (a): the id field is itself an input type carrying an equality\n\t\t\t// operator (e.g. UUIDFilter.equalTo). The `$id` scalar is the operator's\n\t\t\t// type.\n\t\t\tif (idFieldType?.kind === 'INPUT_OBJECT' && idFieldType.inputFields) {\n\t\t\t\tconst opField = EQUALITY_OPERATORS.map((op) =>\n\t\t\t\t\tidFieldType.inputFields!.find((f) => f.name === op),\n\t\t\t\t).find((f) => f != null);\n\t\t\t\tif (opField) {\n\t\t\t\t\tcandidates.push({\n\t\t\t\t\t\tfileByIdField: field.name,\n\t\t\t\t\t\tfileByIdArgName: 'connection',\n\t\t\t\t\t\tfileTypeName,\n\t\t\t\t\t\tidScalarName: namedTypeName(opField.type) ?? undefined,\n\t\t\t\t\t\tconnectionFilterArgName: arg.name,\n\t\t\t\t\t\tconnectionIdField: idField.name,\n\t\t\t\t\t\tconnectionIdOperator: opField.name,\n\t\t\t\t\t\tconnectionNodesField: nodesField.name,\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// id field is an input object but with no recognized equality op — skip.\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Style (b): the id field is a scalar directly (condition style). The\n\t\t\t// `$id` scalar is that field's type.\n\t\t\tif (idFieldType?.kind === 'SCALAR' || (!idFieldType && idFieldTypeName)) {\n\t\t\t\tcandidates.push({\n\t\t\t\t\tfileByIdField: field.name,\n\t\t\t\t\tfileByIdArgName: 'connection',\n\t\t\t\t\tfileTypeName,\n\t\t\t\t\tidScalarName: idFieldTypeName ?? undefined,\n\t\t\t\t\tconnectionFilterArgName: arg.name,\n\t\t\t\t\tconnectionIdField: idField.name,\n\t\t\t\t\tconnectionNodesField: nodesField.name,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (candidates.length === 0) return null;\n\n\t// Deterministic pick: prefer the connection whose file type matches the upload\n\t// op (uploadAppFile → AppFile), else the first-declared. This is the LIVE\n\t// production path — the only downloadUrl shape on a Relay-disabled, unique-\n\t// lookup-disabled tenant API — so resolving the WRONG file connection (e.g.\n\t// reading a DataRoomFile id through appFiles) yields 0 nodes and fails every\n\t// upload. Mirrors the node-branch determinism, where it matters far more.\n\tconst preferred = uploadFieldName.replace(/^upload/, '');\n\treturn candidates.find((c) => c.fileTypeName === preferred) ?? candidates[0];\n}\n\n// ============================================================================\n// Upload op call\n// ============================================================================\n\ninterface UploadOpInput {\n\tbucketKey: string;\n\tcontentHash: string;\n\tcontentType: string;\n\tsize: number;\n\tfilename: string;\n}\n\n/**\n * Invoke the discovered upload op and normalize its payload.\n * App-scoped buckets have NO owner_id column, so `ownerId` is NEVER sent.\n */\nexport async function callUploadOp(\n\texecute: SheetsExecuteFn,\n\tcap: UploadCapability,\n\tinput: UploadOpInput,\n): Promise<UploadPayload> {\n\tconst mutation = `\n\t\tmutation SheetsUpload($input: ${cap.inputTypeName}!) {\n\t\t\t${cap.uploadFieldName}(input: $input) {\n\t\t\t\tuploadUrl\n\t\t\t\tfileId\n\t\t\t\tkey\n\t\t\t\tdeduplicated\n\t\t\t}\n\t\t}\n\t`.trim();\n\tconst data = await execute<Record<string, UploadPayload | null>>(mutation, {\n\t\tinput: {\n\t\t\tbucketKey: input.bucketKey,\n\t\t\tcontentHash: input.contentHash,\n\t\t\tcontentType: input.contentType,\n\t\t\tsize: input.size,\n\t\t\tfilename: input.filename,\n\t\t},\n\t});\n\tconst payload = data?.[cap.uploadFieldName];\n\tif (!payload) {\n\t\tthrow createError.badRequest('Upload failed: no payload returned from upload mutation.');\n\t}\n\treturn payload;\n}\n\n// ============================================================================\n// Presigned PUT\n// ============================================================================\n\n/**\n * PUT the raw bytes to the presigned url. Sends ONLY the signed `Content-Type`\n * header — NO Authorization (the signature lives in the url query string), no\n * cookies, no Accept override. The browser supplies Content-Length from the body.\n *\n * When `onProgress` is provided and XHR is available, uses XHR for byte\n * progress; otherwise a plain fetch PUT.\n */\nexport async function presignedPut(\n\turl: string,\n\tbuffer: ArrayBuffer,\n\tcontentType: string,\n\tonProgress?: (progress: { loaded: number; total: number; percentage: number }) => void,\n): Promise<void> {\n\tconst total = buffer.byteLength;\n\n\tif (onProgress && typeof XMLHttpRequest !== 'undefined') {\n\t\tawait putWithXHR(url, buffer, contentType, total, onProgress);\n\t\treturn;\n\t}\n\n\tlet response: Response;\n\ttry {\n\t\tresponse = await fetch(url, {\n\t\t\tmethod: 'PUT',\n\t\t\theaders: { 'Content-Type': contentType },\n\t\t\tbody: buffer,\n\t\t});\n\t} catch (error) {\n\t\tthrow createError.network(error instanceof Error ? error : undefined);\n\t}\n\n\tif (!response.ok) {\n\t\tconst body = await response.text().catch(() => '');\n\t\tthrow createError.badRequest(`Upload failed: ${response.status} ${response.statusText}${body ? ` — ${body}` : ''}`);\n\t}\n\tonProgress?.({ loaded: total, total, percentage: 100 });\n}\n\nfunction putWithXHR(\n\turl: string,\n\tbuffer: ArrayBuffer,\n\tcontentType: string,\n\ttotal: number,\n\tonProgress: (progress: { loaded: number; total: number; percentage: number }) => void,\n): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst xhr = new XMLHttpRequest();\n\t\txhr.open('PUT', url);\n\t\txhr.setRequestHeader('Content-Type', contentType);\n\n\t\txhr.upload.addEventListener('progress', (event) => {\n\t\t\tif (event.lengthComputable) {\n\t\t\t\tonProgress({\n\t\t\t\t\tloaded: event.loaded,\n\t\t\t\t\ttotal: event.total,\n\t\t\t\t\tpercentage: Math.round((event.loaded / event.total) * 100),\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\txhr.addEventListener('load', () => {\n\t\t\tif (xhr.status >= 200 && xhr.status < 300) {\n\t\t\t\tonProgress({ loaded: total, total, percentage: 100 });\n\t\t\t\tresolve();\n\t\t\t} else {\n\t\t\t\treject(createError.badRequest(`Upload failed: ${xhr.status} ${xhr.statusText}${xhr.responseText ? ` — ${xhr.responseText}` : ''}`));\n\t\t\t}\n\t\t});\n\n\t\txhr.addEventListener('error', () => reject(createError.network()));\n\n\t\txhr.send(buffer);\n\t});\n}\n\n// ============================================================================\n// downloadUrl resolution\n// ============================================================================\n\n/**\n * Encode a PostGraphile global id (Relay `node` id) from a row's primary key,\n * using the default base64JSON codec: `base64(JSON.stringify([typeName, pk]))`.\n */\nfunction toGlobalId(typeName: string, id: string): string {\n\tif (typeof btoa !== 'function') {\n\t\tthrow createError.badRequest('Cannot encode the file node id: btoa is unavailable in this environment.');\n\t}\n\treturn btoa(JSON.stringify([typeName, id]));\n}\n\n/**\n * Resolve the stable public download URL for a file id via the discovered\n * by-id field. For public files the backend returns a permanent public URL\n * (its exact path shape is the backend's concern) — stored opaquely in the cell.\n */\nexport async function fetchDownloadUrl(\n\texecute: SheetsExecuteFn,\n\tcap: UploadCapability,\n\tfileId: string,\n): Promise<string> {\n\tif (cap.fileByIdArgName === 'nodeId') {\n\t\t// The upload payload returns the RAW primary key as `fileId`, but\n\t\t// `node(nodeId:)` expects the opaque PostGraphile global id. Encode it with\n\t\t// the default base64JSON codec (`base64([typeName, pk])`). NOTE: the live\n\t\t// tenant API is Relay-disabled and resolves via the connection branch; this\n\t\t// path is mock-covered only and assumes the default node-id codec.\n\t\tconst nodeId = toGlobalId(cap.fileTypeName, fileId);\n\t\tconst query = `\n\t\t\tquery SheetsDownloadUrl($nodeId: ID!) {\n\t\t\t\t${cap.fileByIdField}(nodeId: $nodeId) {\n\t\t\t\t\t... on ${cap.fileTypeName} {\n\t\t\t\t\t\tdownloadUrl\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t`.trim();\n\t\tconst data = await execute<Record<string, { downloadUrl?: string | null } | null>>(query, { nodeId });\n\t\tconst node = data?.[cap.fileByIdField];\n\t\tconst url = node?.downloadUrl;\n\t\tif (!url) {\n\t\t\tthrow createError.badRequest('Upload succeeded but no downloadUrl was returned for the file.');\n\t\t}\n\t\treturn url;\n\t}\n\n\t// Connection fallback (Relay-disabled): filter the connection by id and read\n\t// the first node's downloadUrl. The filter literal is built per the discovered\n\t// style — operator (`{ id: { equalTo: $id } }`) or condition (`{ id: $id }`).\n\tif (cap.fileByIdArgName === 'connection') {\n\t\tconst idScalar = cap.idScalarName ?? 'ID';\n\t\tconst filterArg = cap.connectionFilterArgName as string;\n\t\tconst idField = cap.connectionIdField as string;\n\t\tconst nodesField = cap.connectionNodesField as string;\n\t\tconst filterLiteral = cap.connectionIdOperator\n\t\t\t? `{ ${idField}: { ${cap.connectionIdOperator}: $id } }`\n\t\t\t: `{ ${idField}: $id }`;\n\t\tconst query = `\n\t\t\tquery SheetsDownloadUrl($id: ${idScalar}!) {\n\t\t\t\t${cap.fileByIdField}(${filterArg}: ${filterLiteral}, first: 1) {\n\t\t\t\t\t${nodesField} {\n\t\t\t\t\t\tdownloadUrl\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t`.trim();\n\t\tconst data = await execute<Record<string, Record<string, Array<{ downloadUrl?: string | null }> | null> | null>>(\n\t\t\tquery,\n\t\t\t{ id: fileId },\n\t\t);\n\t\tconst conn = data?.[cap.fileByIdField];\n\t\tconst url = conn?.[nodesField]?.[0]?.downloadUrl;\n\t\tif (!url) {\n\t\t\tthrow createError.badRequest('Upload succeeded but no downloadUrl was returned for the file.');\n\t\t}\n\t\treturn url;\n\t}\n\n\tconst idScalar = cap.idScalarName ?? 'ID';\n\tconst query = `\n\t\tquery SheetsDownloadUrl($id: ${idScalar}!) {\n\t\t\t${cap.fileByIdField}(id: $id) {\n\t\t\t\tid\n\t\t\t\tdownloadUrl\n\t\t\t}\n\t\t}\n\t`.trim();\n\tconst data = await execute<Record<string, { downloadUrl?: string | null } | null>>(query, { id: fileId });\n\tconst file = data?.[cap.fileByIdField];\n\tconst url = file?.downloadUrl;\n\tif (!url) {\n\t\tthrow createError.badRequest('Upload succeeded but no downloadUrl was returned for the file.');\n\t}\n\treturn url;\n}\n\n/**\n * Resolve a file's signed `downloadUrl` by id — the public entry point for callers\n * OUTSIDE the upload flow (e.g. a storage browser fetching the preview/copy link for\n * an already-uploaded file).\n *\n * `downloadUrl` is a Grafast computed field, so it cannot be selected through the\n * runtime query builder (`buildSelect` intersects the select against pg columns and\n * drops computed fields). This discovers the by-id field once per endpoint (cached)\n * and reads it through the SAME resolver the upload path uses. Returns null on any\n * failure — a missing url is not exceptional for the caller (it just disables\n * copy/download), so the throwing internals are swallowed here.\n */\nexport async function resolveDownloadUrl(\n\texecute: SheetsExecuteFn,\n\tendpoint: string,\n\tfileId: string,\n): Promise<string | null> {\n\ttry {\n\t\tconst cap = await discoverUploadCapability(endpoint, execute);\n\t\treturn await fetchDownloadUrl(execute, cap, fileId);\n\t} catch {\n\t\treturn null;\n\t}\n}\n","import type { DocumentNode } from 'graphql';\nimport { print } from 'graphql';\n\nimport { createError, DataError, TypedDocumentString } from '@constructive-io/data';\n\nimport type { SheetsConfig } from './sheets-context';\nimport {\n\tcallUploadOp,\n\tdiscoverUploadCapability,\n\tfetchDownloadUrl,\n\tpresignedPut,\n\tsha256HexFromBuffer,\n} from './sheets-upload-presigned';\n\n// ============================================================================\n// Types\n// ============================================================================\n\ntype ExecutableDocument = TypedDocumentString<any, any> | DocumentNode | string | unknown;\n\nexport type SheetsExecuteFn = <T = unknown>(\n\tdocument: ExecutableDocument,\n\tvariables?: Record<string, unknown>,\n) => Promise<T>;\n\n/**\n * Result of an upload through the seam. `url` is the only guaranteed field;\n * the REST upload endpoint also returns `{ filename, mime, size }` (and may\n * return server-internal extras). Keeping it open-ended lets callers read the\n * richer metadata while a bare `{ url }` (e.g. the mock) still satisfies it.\n */\nexport type SheetsUploadResult = { url: string } & Record<string, unknown>;\n\n/**\n * Optional upload metadata carried through the seam (third arg). Lets an\n * injected `executeUpload` see the destination field/row and report progress.\n * All fields optional, so existing `(file, path?)` callers stay valid.\n */\nexport interface SheetsUploadOptions {\n\ttableName?: string;\n\tfieldName?: string;\n\trecordId?: string | number;\n\tonProgress?: (progress: { loaded: number; total: number; percentage: number }) => void;\n}\n\nexport type SheetsUploadFn = (\n\tfile: File,\n\tpath?: string,\n\toptions?: SheetsUploadOptions,\n) => Promise<SheetsUploadResult>;\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\nfunction documentToString(document: ExecutableDocument): string {\n\tif (typeof document === 'string') return document;\n\tif (document instanceof String) return document.toString();\n\tif (document && typeof document === 'object' && 'kind' in (document as DocumentNode)) {\n\t\treturn print(document as DocumentNode);\n\t}\n\tif (document === null || document === undefined) {\n\t\tthrow createError.badRequest('Invalid GraphQL document: null or undefined');\n\t}\n\treturn String(document);\n}\n\n// ============================================================================\n// GraphQL Response Parsing\n// ============================================================================\n\ninterface GraphQLResponseError {\n\tmessage: string;\n\textensions?: { code?: string };\n}\n\ninterface GraphQLResponse {\n\tdata?: unknown;\n\terrors?: GraphQLResponseError[];\n}\n\nfunction hasAuthMessage(message: string | undefined): boolean {\n\tconst normalized = String(message ?? '').toLowerCase();\n\treturn (\n\t\tnormalized.includes('unauthenticated') ||\n\t\tnormalized.includes('unauthorized') ||\n\t\tnormalized.includes('authentication')\n\t);\n}\n\nfunction parseGraphQLResponse(response: GraphQLResponse, onAuthError?: () => void): DataError | null {\n\tif (!response.errors?.length) return null;\n\n\tconst error = response.errors[0];\n\tconst code = error.extensions?.code;\n\tconst message = error.message || 'GraphQL query failed';\n\n\tif (code === 'UNAUTHENTICATED' || hasAuthMessage(message)) {\n\t\tonAuthError?.();\n\t\treturn createError.unauthorized('Authentication required. Please log in again.');\n\t}\n\n\tif (code === 'FORBIDDEN') {\n\t\treturn createError.forbidden('You do not have permission to perform this action.');\n\t}\n\n\treturn createError.graphql(message, code);\n}\n\n// ============================================================================\n// Factory\n// ============================================================================\n\nexport function createSheetsExecute(\n\tconfig: SheetsConfig,\n\tgetToken: () => string | null,\n): SheetsExecuteFn {\n\treturn async <T = unknown>(\n\t\tdocument: ExecutableDocument,\n\t\tvariables?: Record<string, unknown>,\n\t): Promise<T> => {\n\t\tconst url = config.endpoint;\n\t\tif (!url) {\n\t\t\tthrow createError.badRequest('No GraphQL endpoint configured.');\n\t\t}\n\n\t\tconst token = getToken();\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Content-Type': 'application/json',\n\t\t\tAccept: 'application/graphql-response+json',\n\t\t};\n\t\tif (token) {\n\t\t\theaders['Authorization'] = `Bearer ${token}`;\n\t\t}\n\n\t\tlet response: Response;\n\t\ttry {\n\t\t\tresponse = await fetch(url, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders,\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\tquery: documentToString(document),\n\t\t\t\t\t...(variables !== undefined && { variables }),\n\t\t\t\t}),\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthrow createError.network(error instanceof Error ? error : undefined);\n\t\t}\n\n\t\tif (!response.ok) {\n\t\t\tconst { status, statusText } = response;\n\t\t\tif (status === 401) {\n\t\t\t\tconfig.onAuthError?.();\n\t\t\t\tthrow createError.unauthorized('Authentication required. Please log in again.');\n\t\t\t}\n\t\t\tif (status === 403) {\n\t\t\t\tthrow createError.forbidden('You do not have permission to perform this action.');\n\t\t\t}\n\t\t\tif (status === 404) {\n\t\t\t\tthrow createError.notFound('The requested endpoint does not exist.');\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst body = await response.json();\n\t\t\t\tif (body.errors?.length) {\n\t\t\t\t\tthrow createError.graphql(body.errors[0].message || `Request failed: ${status}`, body.errors[0].extensions?.code);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tif (e instanceof DataError) throw e;\n\t\t\t}\n\t\t\tthrow createError.badRequest(`Request failed: ${status} ${statusText}`);\n\t\t}\n\n\t\tconst result: GraphQLResponse = await response.json();\n\t\tconst graphqlError = parseGraphQLResponse(result, config.onAuthError);\n\t\tif (graphqlError) {\n\t\t\tthrow graphqlError;\n\t\t}\n\n\t\treturn result.data as T;\n\t};\n}\n\n/**\n * Presigned-URL cell-upload seam.\n *\n * Replaces the legacy multipart `<endpoint>/upload` POST entirely. The flow:\n * 1. Read + SHA-256 hash the file bytes (Web Crypto)\n * 2. Discover (cached per endpoint) the upload op + downloadUrl-by-id field\n * via GraphQL introspection — the root `upload<Type>File` mutation, matched\n * by FIELD/TYPE SHAPE (LOCKED: no hardcoded names)\n * 3. Call the upload op with input `{ bucketKey, contentHash, contentType,\n * size, filename }` — NO `ownerId` (app-scoped buckets have no owner_id)\n * 4. If `uploadUrl` is non-null, PUT the raw bytes to it with ONLY the signed\n * `Content-Type` header (NO Authorization). Skipped when `deduplicated`.\n * 5. Resolve the stable public `downloadUrl` for the returned fileId.\n *\n * Returns `{ url, filename, mime, size, key, fileId }` where `url` is the stable\n * download URL — the same cell value shape callers/Step-2 already consume.\n *\n * `path` is ignored (content-addressed buckets key on `contentHash`).\n */\nexport function createSheetsUpload(config: SheetsConfig, getToken: () => string | null): SheetsUploadFn {\n\t// Reuse the kept GraphQL executor so DataError normalization + onAuthError\n\t// (401/UNAUTHENTICATED) apply to introspection, the upload op, and the\n\t// downloadUrl query alike.\n\tconst execute = config.execute ?? createSheetsExecute(config, getToken);\n\n\treturn async (file: File, _path?: string, options?: SheetsUploadOptions): Promise<SheetsUploadResult> => {\n\t\tif (!config.endpoint) {\n\t\t\tthrow createError.badRequest('No GraphQL endpoint configured.');\n\t\t}\n\n\t\tconst bucketKey = config.upload?.bucketKey ?? 'public';\n\t\tconst contentType = file.type || 'application/octet-stream';\n\n\t\t// Single read of the bytes — reused for both hashing and the PUT body.\n\t\tconst buffer = await file.arrayBuffer();\n\t\tconst contentHash = await sha256HexFromBuffer(buffer);\n\n\t\tconst cap = await discoverUploadCapability(config.endpoint, execute);\n\n\t\tconst payload = await callUploadOp(execute, cap, {\n\t\t\tbucketKey,\n\t\t\tcontentHash,\n\t\t\tcontentType,\n\t\t\tsize: file.size,\n\t\t\tfilename: file.name,\n\t\t});\n\n\t\t// Dedup (deduplicated ⇒ uploadUrl === null) means the row + S3 object already\n\t\t// exist; skip the PUT. A non-deduplicated payload MUST carry an uploadUrl — a\n\t\t// null there is a server-contract violation, so fail loudly rather than\n\t\t// resolving a downloadUrl for an object that was never uploaded.\n\t\tif (!payload.deduplicated) {\n\t\t\tif (!payload.uploadUrl) {\n\t\t\t\tthrow createError.badRequest('Upload failed: server returned no uploadUrl for a non-deduplicated file.');\n\t\t\t}\n\t\t\tawait presignedPut(payload.uploadUrl, buffer, contentType, options?.onProgress);\n\t\t} else {\n\t\t\toptions?.onProgress?.({ loaded: file.size, total: file.size, percentage: 100 });\n\t\t}\n\n\t\tconst url = await fetchDownloadUrl(execute, cap, payload.fileId);\n\n\t\treturn {\n\t\t\turl,\n\t\t\tfilename: file.name,\n\t\t\tmime: file.type,\n\t\t\tsize: file.size,\n\t\t\tkey: payload.key,\n\t\t\tfileId: payload.fileId,\n\t\t};\n\t};\n}\n\nexport { DataError } from '@constructive-io/data';\n","import type { SheetsScopeKey } from '../context/sheets-context';\n\nexport function isSheetsScopeKey(value: unknown): value is SheetsScopeKey {\n\tif (!value || typeof value !== 'object') return false;\n\tconst candidate = value as Record<string, unknown>;\n\treturn 'databaseId' in candidate && 'endpoint' in candidate && 'identityKey' in candidate;\n}\n\nexport const sheetsQueryKeys = {\n\troot: ['sheets'] as const,\n\tscope: (scope: SheetsScopeKey) => ['sheets', scope] as const,\n\tmeta: (scope: SheetsScopeKey) => [...sheetsQueryKeys.scope(scope), 'meta'] as const,\n\ttypeFields: (scope: SheetsScopeKey, typeName: string) =>\n\t\t[...sheetsQueryKeys.scope(scope), 'type-fields', typeName] as const,\n\tenumValues: (scope: SheetsScopeKey, typeName: string) =>\n\t\t[...sheetsQueryKeys.scope(scope), 'enum-values', typeName] as const,\n\trelations: (scope: SheetsScopeKey, tableName: string) =>\n\t\t[...sheetsQueryKeys.scope(scope), 'relations', tableName] as const,\n\ttable: (scope: SheetsScopeKey, tableName: string) => [...sheetsQueryKeys.scope(scope), 'table', tableName] as const,\n\ttableRows: (scope: SheetsScopeKey, tableName: string, options?: unknown) =>\n\t\t[...sheetsQueryKeys.table(scope, tableName), 'rows', options] as const,\n\ttableRow: (scope: SheetsScopeKey, tableName: string, id: unknown) =>\n\t\t[...sheetsQueryKeys.table(scope, tableName), 'row', id] as const,\n\ttableCount: (scope: SheetsScopeKey, tableName: string, where?: Record<string, unknown> | null) =>\n\t\t[...sheetsQueryKeys.table(scope, tableName), 'count', where] as const,\n\tinfiniteTable: (scope: SheetsScopeKey, tableName: string) =>\n\t\t[...sheetsQueryKeys.scope(scope), 'infinite-table', tableName] as const,\n\tinfiniteTablePage: (scope: SheetsScopeKey, tableName: string, pageIndex: number, options: unknown) =>\n\t\t[...sheetsQueryKeys.infiniteTable(scope, tableName), 'page', pageIndex, options] as const,\n\tinfiniteTableTotalCount: (scope: SheetsScopeKey, tableName: string, where?: Record<string, unknown>) =>\n\t\t[...sheetsQueryKeys.infiniteTable(scope, tableName), 'totalCount', where] as const,\n\tcursorTable: (scope: SheetsScopeKey, tableName: string, options?: unknown) =>\n\t\t[...sheetsQueryKeys.scope(scope), 'cursor-table', tableName, options] as const,\n} as const;\n"],"mappings":";;;AAuBA,SAAS,6BAA6B;AAEtC,SAAS,mBAAmB;AAoD5B,eAAsB,oBAAoB,QAAsC;AAC/E,MAAI,CAAC,WAAW,QAAQ,QAAQ;AAC/B,UAAM,YAAY,WAAW,yEAAyE;AAAA,EACvG;AACA,QAAM,SAAS,MAAM,OAAO,OAAO,OAAO,WAAW,MAAM;AAC3D,QAAM,QAAQ,IAAI,WAAW,MAAM;AACnC,MAAI,MAAM;AACV,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACtC,WAAO,MAAM,CAAC,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAAA,EAC7C;AACA,SAAO;AACR;AAMA,IAAM,kBAAkB,oBAAI,IAAuC;AAW5D,SAAS,yBAAyB,UAAkB,SAAqD;AAC/G,QAAM,SAAS,gBAAgB,IAAI,QAAQ;AAC3C,MAAI,OAAQ,QAAO;AAEnB,QAAM,WAAW,YAAY;AAC5B,UAAM,OAAO,MAAM,QAA2C,sBAAsB,CAAC;AACrF,UAAM,SAAS,MAAM;AACrB,QAAI,CAAC,QAAQ;AACZ,YAAM,YAAY,WAAW,4CAA4C;AAAA,IAC1E;AACA,WAAO,wBAAwB,MAAM;AAAA,EACtC,GAAG;AAGH,UAAQ,MAAM,MAAM,gBAAgB,OAAO,QAAQ,CAAC;AACpD,kBAAgB,IAAI,UAAU,OAAO;AAC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value, onFinishedEditing, dateType: forcedDateType }) => {
183
183
  const isDateTimeType = dateType === "datetime" || dateType === "timestamptz";
184
184
  const handleDateSelect = useCallback(
185
185
  (dateValue2) => {
186
- setSelectedDate(dateValue2);
187
- const jsDate = dateValueToDate(dateValue2);
186
+ if (Array.isArray(dateValue2)) return;
187
+ const selectedValue = dateValue2;
188
+ setSelectedDate(selectedValue);
189
+ const jsDate = dateValueToDate(selectedValue);
188
190
  if (jsDate) {
189
191
  if (isDateTimeType && currentDateValue) {
190
192
  const currentDate = new Date(currentDateValue);
@@ -358,4 +360,4 @@ export {
358
360
  resolveDateType,
359
361
  toLocalDateString
360
362
  };
361
- //# sourceMappingURL=date-editor-CXKKGNL6.js.map
363
+ //# sourceMappingURL=date-editor-QT47WY5T.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/grid/editors/date-editor.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { parseDate as parseAriaDate } from '@internationalized/date';\nimport type { DateValue as DateValueType } from 'react-aria-components';\n\nimport { Button } from '@constructive-io/ui/button';\nimport { Calendar } from '@constructive-io/ui/calendar-rac';\n\nimport { DATE_TIME_TYPES } from '../../cell-types/cell-type-groups';\nimport { sheetsLocale } from '../../utils/sheets-i18n';\n\nimport { EditorFocusTrap } from './editor-focus-trap';\nimport { OVERLAY } from './overlay-presets';\n\nconst TIME_RE = /(\\d{1,2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?/;\nconst MAC_UA_RE = /Mac|iPod|iPhone|iPad/;\n\nexport type DateEditorType = 'date' | 'datetime' | 'timestamptz' | 'time';\n\nconst DATE_ONLY_RE = /^\\d{4}-\\d{2}-\\d{2}/;\n\nfunction pad2(value: number): string {\n\treturn String(value).padStart(2, '0');\n}\n\n// Format a Date as a calendar date string using LOCAL getters (never UTC).\n// This is the correct serialization for date-only values: the wall-clock day\n// the user picked is preserved regardless of timezone.\nexport function toLocalDateString(d: Date): string {\n\treturn `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;\n}\n\n// If the value is a string whose literal calendar date is already known\n// (starts with YYYY-MM-DD), return that 10-char slice verbatim. Otherwise null.\n// Date-only strings must never round-trip through a Date object.\nexport function extractDateOnly(v: unknown): string | null {\n\tif (typeof v === 'string' && DATE_ONLY_RE.test(v)) {\n\t\treturn v.slice(0, 10);\n\t}\n\treturn null;\n}\n\nfunction normalizeTimeValue(value: unknown): string {\n\tif (value == null) return '';\n\n\tif (value instanceof Date) {\n\t\tif (isNaN(value.getTime())) return '';\n\t\treturn `${pad2(value.getHours())}:${pad2(value.getMinutes())}:${pad2(value.getSeconds())}`;\n\t}\n\n\tconst asString = String(value).trim();\n\tif (!asString) return '';\n\n\t// Match both time-only values and datetime-like values with a time component.\n\tconst match = asString.match(TIME_RE);\n\tif (!match) return '';\n\n\tconst hours = Number(match[1] ?? 0);\n\tconst minutes = Number(match[2] ?? 0);\n\tconst seconds = Number(match[3] ?? 0);\n\tif (\n\t\t!Number.isFinite(hours) ||\n\t\t!Number.isFinite(minutes) ||\n\t\t!Number.isFinite(seconds) ||\n\t\thours < 0 ||\n\t\thours > 23 ||\n\t\tminutes < 0 ||\n\t\tminutes > 59 ||\n\t\tseconds < 0 ||\n\t\tseconds > 59\n\t) {\n\t\treturn '';\n\t}\n\n\treturn `${pad2(hours)}:${pad2(minutes)}:${pad2(seconds)}`;\n}\n\n// Determine date type from cell data or explicit context\nexport const getDateType = (value: any): DateEditorType => {\n\t// Try to infer from the value format\n\tif (typeof value === 'string') {\n\t\tif (value.includes('T') || value.includes(' ')) {\n\t\t\treturn value.includes('+') || value.includes('Z') ? 'timestamptz' : 'datetime';\n\t\t}\n\t\tif (value.includes(':') && !value.includes('-')) {\n\t\t\treturn 'time';\n\t\t}\n\t}\n\treturn 'date'; // Default fallback\n};\n\nexport function resolveDateType(value: unknown, explicitType?: string): DateEditorType {\n\tif (explicitType && DATE_TIME_TYPES.has(explicitType)) {\n\t\treturn explicitType as DateEditorType;\n\t}\n\treturn getDateType(value);\n}\n\n// Format date for display based on type\nexport const formatDate = (val: unknown, dateType: DateEditorType): string => {\n\tif (!val) return '';\n\n\tif (dateType === 'time') {\n\t\tif (typeof val === 'string') {\n\t\t\treturn val.trim();\n\t\t}\n\t\tconst normalized = normalizeTimeValue(val);\n\t\treturn normalized || String(val);\n\t}\n\n\ttry {\n\t\t// Date-only display must use the literal calendar date, never a UTC\n\t\t// conversion (which shifts the day in any UTC+ zone). Prefer the literal\n\t\t// slice and never round-trip a Date.\n\t\tif (dateType === 'date') {\n\t\t\tconst literal = extractDateOnly(val);\n\t\t\tif (literal) return literal;\n\t\t\tif (val instanceof Date) {\n\t\t\t\treturn isNaN(val.getTime()) ? String(val) : toLocalDateString(val);\n\t\t\t}\n\t\t\treturn String(val);\n\t\t}\n\n\t\tlet date: Date;\n\t\tif (val instanceof Date) {\n\t\t\tdate = val;\n\t\t} else if (typeof val === 'string') {\n\t\t\tdate = new Date(val);\n\t\t} else {\n\t\t\treturn String(val);\n\t\t}\n\n\t\tif (isNaN(date.getTime())) return String(val);\n\n\t\tswitch (dateType) {\n\t\t\tcase 'datetime':\n\t\t\tcase 'timestamptz':\n\t\t\t\treturn date.toLocaleDateString(sheetsLocale(), {\n\t\t\t\t\tyear: 'numeric',\n\t\t\t\t\tmonth: 'short',\n\t\t\t\t\tday: 'numeric',\n\t\t\t\t\thour: '2-digit',\n\t\t\t\t\tminute: '2-digit',\n\t\t\t\t\thour12: false,\n\t\t\t\t});\n\t\t\tdefault: {\n\t\t\t\t// Default branch is treated as date-only semantics.\n\t\t\t\tconst literal = extractDateOnly(val);\n\t\t\t\tif (literal) return literal;\n\t\t\t\treturn toLocalDateString(date);\n\t\t\t}\n\t\t}\n\t} catch {\n\t\treturn String(val);\n\t}\n};\n\n// Format date for input based on type\nexport const formatForInput = (val: unknown, inputType: string): string => {\n\tif (!val) return '';\n\n\tif (inputType === 'time') {\n\t\treturn normalizeTimeValue(val);\n\t}\n\n\t// Date-only input must reflect the literal calendar date, never a UTC shift.\n\tif (inputType === 'date') {\n\t\tconst literal = extractDateOnly(val);\n\t\tif (literal) return literal;\n\t\tif (val instanceof Date) {\n\t\t\treturn isNaN(val.getTime()) ? '' : toLocalDateString(val);\n\t\t}\n\t\treturn '';\n\t}\n\n\ttry {\n\t\tlet date: Date;\n\t\tif (val instanceof Date) {\n\t\t\tdate = val;\n\t\t} else if (typeof val === 'string') {\n\t\t\tdate = new Date(val);\n\t\t} else {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (isNaN(date.getTime())) return '';\n\n\t\tswitch (inputType) {\n\t\t\tcase 'datetime-local':\n\t\t\t\treturn date.toISOString().slice(0, 16);\n\t\t\tdefault:\n\t\t\t\treturn '';\n\t\t}\n\t} catch {\n\t\treturn '';\n\t}\n};\n\n// Convert a date input to a DateValue for the calendar.\n// Date-only strings are parsed by their literal calendar date (no Date round-trip),\n// so the calendar seeds on exactly the stored day in any timezone.\nconst dateToDateValue = (date: Date | string | null): DateValueType | null => {\n\tif (!date) return null;\n\n\ttry {\n\t\tconst literal = extractDateOnly(date);\n\t\tif (literal) {\n\t\t\treturn parseAriaDate(literal);\n\t\t}\n\n\t\tconst jsDate = date instanceof Date ? date : new Date(date);\n\t\tif (isNaN(jsDate.getTime())) return null;\n\n\t\treturn parseAriaDate(toLocalDateString(jsDate));\n\t} catch {\n\t\treturn null;\n\t}\n};\n\n// Convert DateValue to JavaScript Date\nconst dateValueToDate = (dateValue: DateValueType | null): Date | null => {\n\tif (!dateValue) return null;\n\n\ttry {\n\t\treturn new Date(dateValue.year, dateValue.month - 1, dateValue.day);\n\t} catch {\n\t\treturn null;\n\t}\n};\n\n// Derive a date-only string from a calendar value (year/month/day) without any\n// UTC conversion. Pure and DOM-free so the write path is directly testable; it\n// mirrors handleSave's date-only serialization (local-midnight Date → local getters).\nexport function dateOnlyStringFromCalendarValue(dateValue: DateValueType | null): string {\n\tconst date = dateValueToDate(dateValue);\n\treturn date ? toLocalDateString(date) : '';\n}\n\ninterface DateEditorProps {\n\tvalue: unknown;\n\tonFinishedEditing: (next?: unknown) => void;\n\tdateType?: DateEditorType;\n}\n\nexport const DateEditor: React.FC<DateEditorProps> = ({ value, onFinishedEditing, dateType: forcedDateType }) => {\n\t// Extract current date data from the raw value\n\tconst currentDateValue = typeof value === 'string' ? value : '';\n\tconst dateType = resolveDateType(currentDateValue, forcedDateType);\n\n\tconst [dateValue, setDateValue] = useState<string | Date | null>(currentDateValue);\n\tconst [selectedDate, setSelectedDate] = useState<DateValueType | null>(\n\t\tdateToDateValue(currentDateValue || new Date()),\n\t);\n\n\tconst keyContainerRef = useRef<HTMLDivElement>(null);\n\n\tconst isTimeOnly = dateType === 'time';\n\tconst isDateTimeType = dateType === 'datetime' || dateType === 'timestamptz';\n\n\tconst handleDateSelect = useCallback(\n\t\t(dateValue: DateValueType | readonly DateValueType[] | null) => {\n\t\t\t// The shared Calendar also supports multi-select, so its public\n\t\t\t// callback includes arrays. This editor is intentionally single-date.\n\t\t\tif (Array.isArray(dateValue)) return;\n\t\t\tconst selectedValue = dateValue as DateValueType | null;\n\t\t\tsetSelectedDate(selectedValue);\n\t\t\tconst jsDate = dateValueToDate(selectedValue);\n\n\t\t\tif (jsDate) {\n\t\t\t\t// For datetime types, preserve existing time if available\n\t\t\t\tif (isDateTimeType && currentDateValue) {\n\t\t\t\t\tconst currentDate = new Date(currentDateValue);\n\t\t\t\t\tif (!isNaN(currentDate.getTime())) {\n\t\t\t\t\t\tjsDate.setHours(currentDate.getHours(), currentDate.getMinutes(), currentDate.getSeconds());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsetDateValue(jsDate);\n\t\t\t}\n\t\t},\n\t\t[isDateTimeType, currentDateValue],\n\t);\n\n\tconst handleTimeChange = useCallback(\n\t\t(timeValue: string) => {\n\t\t\tif (!timeValue) return;\n\n\t\t\tif (isTimeOnly) {\n\t\t\t\tconst normalizedTime = normalizeTimeValue(timeValue);\n\t\t\t\tsetDateValue(normalizedTime);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst [hours, minutes, seconds = 0] = timeValue.split(':').map(Number);\n\t\t\tconst targetDate: Date = selectedDate\n\t\t\t\t? dateValueToDate(selectedDate) || new Date()\n\t\t\t\t: currentDateValue\n\t\t\t\t\t? new Date(currentDateValue)\n\t\t\t\t\t: new Date();\n\n\t\t\ttargetDate.setHours(hours || 0, minutes || 0, seconds || 0, 0);\n\t\t\tsetDateValue(targetDate);\n\t\t},\n\t\t[isTimeOnly, selectedDate, currentDateValue],\n\t);\n\n\tconst handleSave = useCallback(() => {\n\t\tlet finalValue: string;\n\n\t\tif (!dateValue) {\n\t\t\tfinalValue = '';\n\t\t} else {\n\t\t\tif (dateType === 'time') {\n\t\t\t\tfinalValue = normalizeTimeValue(dateValue);\n\t\t\t\tif (!finalValue) {\n\t\t\t\t\tfinalValue = String(dateValue).trim();\n\t\t\t\t}\n\t\t\t\treturn onFinishedEditing(finalValue);\n\t\t\t}\n\n\t\t\t// Date-only path: serialize the literal calendar date with LOCAL getters.\n\t\t\t// A UTC conversion (toISOString) shifts the day backwards in any UTC+\n\t\t\t// zone — that is the write corruption this guards against.\n\t\t\tif (dateType === 'date') {\n\t\t\t\tconst literal = extractDateOnly(dateValue);\n\t\t\t\tif (literal) {\n\t\t\t\t\tfinalValue = literal;\n\t\t\t\t} else if (dateValue instanceof Date) {\n\t\t\t\t\tfinalValue = isNaN(dateValue.getTime()) ? '' : toLocalDateString(dateValue);\n\t\t\t\t} else {\n\t\t\t\t\tfinalValue = '';\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst date = dateValue instanceof Date ? dateValue : new Date(dateValue);\n\n\t\t\t\tif (isNaN(date.getTime())) {\n\t\t\t\t\tfinalValue = '';\n\t\t\t\t} else {\n\t\t\t\t\tswitch (dateType) {\n\t\t\t\t\t\tcase 'datetime':\n\t\t\t\t\t\t\tfinalValue = date.toISOString().slice(0, 19); // Remove Z\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'timestamptz':\n\t\t\t\t\t\t\tfinalValue = date.toISOString();\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\t// Default branch is treated as date-only semantics.\n\t\t\t\t\t\t\tconst literal = extractDateOnly(dateValue);\n\t\t\t\t\t\t\tfinalValue = literal ?? toLocalDateString(date);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Emit the raw formatted date string\n\t\tonFinishedEditing(finalValue);\n\t}, [dateValue, dateType, onFinishedEditing]);\n\n\tconst handleCancel = useCallback(() => {\n\t\tonFinishedEditing();\n\t}, [onFinishedEditing]);\n\n\t// Refs for native key handler\n\tconst actionsRef = useRef({ handleSave, handleCancel });\n\tactionsRef.current = { handleSave, handleCancel };\n\n\t// Native DOM keydown listener — prevents Glide from intercepting keys in portal context\n\tuseEffect(() => {\n\t\tconst el = keyContainerRef.current;\n\t\tif (!el) return;\n\t\tconst handler = (e: KeyboardEvent) => {\n\t\t\tconst { handleSave, handleCancel } = actionsRef.current;\n\n\t\t\tif (e.key === 'Escape') {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\t\t\t\thandleCancel();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ((e.key === 'Enter' && (e.metaKey || e.ctrlKey)) || (e.key === 's' && (e.metaKey || e.ctrlKey))) {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\t\t\t\thandleSave();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Stop Tab from reaching Glide\n\t\t\tif (e.key === 'Tab') {\n\t\t\t\te.stopPropagation();\n\t\t\t}\n\t\t};\n\t\tel.addEventListener('keydown', handler);\n\t\treturn () => el.removeEventListener('keydown', handler);\n\t}, []);\n\n\tconst displayValue = formatDate(dateValue, dateType);\n\n\tconst isMac = typeof navigator !== 'undefined' && MAC_UA_RE.test(navigator.userAgent);\n\tconst modKey = isMac ? '⌘' : 'Ctrl';\n\n\treturn (\n\t\t<EditorFocusTrap\n\t\t\tonEscape={handleCancel}\n\t\t\tclassName={`bg-popover ${OVERLAY.sm} rounded-lg border p-2.5 shadow-lg`}\n\t\t>\n\t\t\t<div ref={keyContainerRef}>\n\t\t\t\t{isTimeOnly ? (\n\t\t\t\t\t// Time-only: compact input\n\t\t\t\t\t<div className='space-y-2'>\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\ttype='time'\n\t\t\t\t\t\t\tstep='1'\n\t\t\t\t\t\t\tvalue={formatForInput(dateValue, 'time')}\n\t\t\t\t\t\t\tonChange={(e) => handleTimeChange(e.target.value)}\n\t\t\t\t\t\t\tclassName='bg-muted/40 border-border/40 text-foreground w-full rounded-md border px-3 py-2 text-sm outline-none focus:border-primary/60 focus:ring-2 focus:ring-primary/20'\n\t\t\t\t\t\t\tautoFocus\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t// Date / DateTime: calendar + optional time\n\t\t\t\t\t<div>\n\t\t\t\t\t\t{/* Selected date display */}\n\t\t\t\t\t\t<div className='text-muted-foreground mb-1 px-1 text-xs font-medium tabular-nums'>\n\t\t\t\t\t\t\t{displayValue || 'No date selected'}\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t{/* Calendar */}\n\t\t\t\t\t\t<Calendar\n\t\t\t\t\t\t\tvalue={selectedDate}\n\t\t\t\t\t\t\tonChange={handleDateSelect}\n\t\t\t\t\t\t\taria-label='Select date'\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t{/* Time input for datetime types */}\n\t\t\t\t\t\t{isDateTimeType && (\n\t\t\t\t\t\t\t<div className='mt-2 px-1'>\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\ttype='time'\n\t\t\t\t\t\t\t\t\tstep='1'\n\t\t\t\t\t\t\t\t\tvalue={dateValue ? new Date(dateValue).toTimeString().split(' ')[0].slice(0, 8) : ''}\n\t\t\t\t\t\t\t\t\tonChange={(e) => handleTimeChange(e.target.value)}\n\t\t\t\t\t\t\t\t\tclassName='bg-muted/40 border-border/40 text-foreground w-full rounded-md border px-2.5 py-1.5 text-sm outline-none focus:border-primary/60 focus:ring-2 focus:ring-primary/20'\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\n\t\t\t\t{/* Footer — hints + save */}\n\t\t\t\t<div className='mt-3 flex items-center justify-between gap-4 border-t px-1 pt-2.5'>\n\t\t\t\t\t<div className='text-muted-foreground flex items-center gap-3 text-xs'>\n\t\t\t\t\t\t<span className='inline-flex shrink-0 items-center gap-1'>\n\t\t\t\t\t\t\t<kbd className='bg-muted/60 border-border/40 inline-flex min-h-5 min-w-5 items-center justify-center rounded border font-sans text-[11px] leading-tight'>{modKey}</kbd>\n\t\t\t\t\t\t\t<kbd className='bg-muted/60 border-border/40 inline-flex min-h-5 min-w-5 items-center justify-center rounded border font-sans text-[11px] leading-tight'>↵</kbd>\n\t\t\t\t\t\t\t<span>save</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className='inline-flex shrink-0 items-center gap-1'>\n\t\t\t\t\t\t\t<kbd className='bg-muted/60 border-border/40 inline-flex min-h-5 items-center justify-center rounded border px-1.5 font-sans text-[11px] leading-tight'>Esc</kbd>\n\t\t\t\t\t\t\t<span>cancel</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Button onClick={handleSave} size='xs' variant='default' className='shrink-0'>\n\t\t\t\t\t\tSave\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</EditorFocusTrap>\n\t);\n};\n"],"mappings":";;;;;;;;;;;AAAA,SAAgB,aAAa,WAAW,QAAQ,gBAAgB;AAChE,SAAS,aAAa,qBAAqB;AAG3C,SAAS,cAAc;AACvB,SAAS,gBAAgB;AAkZnB,cAW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C,UAAK,WAAU,2CACf;AAAA,kCAAC,SAAI,WAAU,0IAAyI,iBAAG;AAAA,cAC3J,oBAAC,UAAK,oBAAM;AAAA,eACb;AAAA,aACD;AAAA,UACA,oBAAC,UAAO,SAAS,YAAY,MAAK,MAAK,SAAQ,WAAU,WAAU,YAAW,kBAE9E;AAAA,WACD;AAAA,SACD;AAAA;AAAA,EACD;AAEF;","names":["dateValue","handleSave","handleCancel"]}
@@ -1,10 +1,30 @@
1
1
  import { ComponentType } from 'react';
2
2
  import { MetaQuery } from '@constructive-io/data';
3
3
 
4
+ interface FieldMetadata$1 {
5
+ name: string;
6
+ type?: {
7
+ gqlType: string;
8
+ pgType?: string | null;
9
+ pgAlias?: string | null;
10
+ isArray?: boolean;
11
+ subtype?: string | null;
12
+ };
13
+ }
14
+ interface CellTypeResolution {
15
+ cellType: string;
16
+ canEdit: boolean;
17
+ canActivate: boolean;
18
+ activationBehavior: 'single-click' | 'double-click';
19
+ isReadonly: boolean;
20
+ }
21
+ declare function resolveCellType(fieldName: string, fieldMeta?: FieldMetadata$1): CellTypeResolution;
22
+ declare function isImageField(fieldMeta?: FieldMetadata$1, fieldName?: string): boolean;
23
+
4
24
  type CellType = 'text' | 'textarea' | 'email' | 'url' | 'phone' | 'citext' | 'bpchar' | 'number' | 'integer' | 'smallint' | 'decimal' | 'currency' | 'percentage' | 'date' | 'datetime' | 'time' | 'timestamptz' | 'interval' | 'boolean' | 'toggle' | 'bit' | 'json' | 'jsonb' | 'array' | 'text-array' | 'uuid-array' | 'number-array' | 'integer-array' | 'date-array' | 'geometry' | 'geometry-point' | 'geometry-collection' | 'inet' | 'image' | 'file' | 'video' | 'audio' | 'upload' | 'uuid' | 'color' | 'rating' | 'tags' | 'tsvector' | 'origin' | 'relation' | 'unknown';
5
25
  type CellCategory = 'text' | 'numeric' | 'date' | 'boolean' | 'structured' | 'geometric' | 'network' | 'media' | 'special' | 'other';
6
26
  type CellValue = string | number | boolean | Date | null | undefined | Array<any> | Record<string, any>;
7
- interface FieldMetadata$1 {
27
+ interface FieldMetadata {
8
28
  name: string;
9
29
  gqlType: string;
10
30
  isArray: boolean;
@@ -13,6 +33,14 @@ interface FieldMetadata$1 {
13
33
  pgType?: string | null;
14
34
  subtype?: string | null;
15
35
  typmod?: number | null;
36
+ encoding?: {
37
+ kind: string;
38
+ elementType?: string | null;
39
+ dimensions?: number | null;
40
+ geometrySubtype?: string | null;
41
+ srid?: number | null;
42
+ dotPath?: boolean | null;
43
+ } | null;
16
44
  }
17
45
  interface ColumnSchema {
18
46
  id: string;
@@ -114,65 +142,6 @@ interface CellPlugin {
114
142
  uninstall?: () => void;
115
143
  }
116
144
 
117
- interface FieldMetadata {
118
- name: string;
119
- type?: {
120
- gqlType: string;
121
- pgType?: string | null;
122
- pgAlias?: string | null;
123
- isArray?: boolean;
124
- subtype?: string | null;
125
- };
126
- }
127
- interface CellTypeResolution {
128
- cellType: string;
129
- canEdit: boolean;
130
- canActivate: boolean;
131
- activationBehavior: 'single-click' | 'double-click';
132
- isReadonly: boolean;
133
- }
134
- declare function resolveCellType(fieldName: string, fieldMeta?: FieldMetadata): CellTypeResolution;
135
- declare function isImageField(fieldMeta?: FieldMetadata, fieldName?: string): boolean;
136
-
137
- type RelationKind = 'belongsTo' | 'hasOne' | 'hasMany' | 'manyToMany';
138
- interface RelationInfo {
139
- kind: RelationKind;
140
- relatedTable?: string;
141
- displayCandidates: string[];
142
- relationField?: string;
143
- foreignKeyField?: string;
144
- junctionTable?: string;
145
- junctionLeftKeyField?: string;
146
- junctionRightKeyField?: string;
147
- displayName?: string;
148
- }
149
- interface RelationInfoSlice {
150
- relationInfoCache: Record<string, Record<string, RelationInfo>>;
151
- relationInfoMapCache: Record<string, Map<string, RelationInfo>>;
152
- setRelationInfoForTable: (tableName: string, info: Record<string, RelationInfo>) => void;
153
- getRelationInfoForTable: (tableName: string) => Record<string, RelationInfo> | undefined;
154
- getRelationInfoMapForTable: (tableName: string) => Map<string, RelationInfo> | undefined;
155
- rebuildRelationInfo: (tableName: string, meta: MetaQuery | undefined) => void;
156
- ensureRelationInfo: (tableName: string, meta: MetaQuery | undefined) => Record<string, RelationInfo>;
157
- clearRelationInfoCache: () => void;
158
- }
159
- declare function buildRelationInfoFromMeta(tableName: string, meta: MetaQuery | undefined): Record<string, RelationInfo> | null;
160
-
161
- interface RelationCellOptions {
162
- relationChipLimit?: number;
163
- relationLabelMaxLength?: number;
164
- }
165
- interface CellCreationMetadata {
166
- cellType: string;
167
- fieldName: string;
168
- fieldMeta?: FieldMetadata;
169
- relationInfo?: RelationInfo;
170
- relationOptions?: RelationCellOptions;
171
- canEdit: boolean;
172
- isReadonly: boolean;
173
- activationBehavior: 'single-click' | 'double-click';
174
- }
175
-
176
145
  /**
177
146
  * Neutral RENDER kinds — equal to the frozen `DisplayKind` union. `loading` and
178
147
  * `draft-action` originate from grid-internal state, not the `CellType` system.
@@ -206,6 +175,30 @@ interface SheetsCell {
206
175
  };
207
176
  }
208
177
 
178
+ type RelationKind = 'belongsTo' | 'hasOne' | 'hasMany' | 'manyToMany';
179
+ interface RelationInfo {
180
+ kind: RelationKind;
181
+ relatedTable?: string;
182
+ displayCandidates: string[];
183
+ relationField?: string;
184
+ foreignKeyField?: string;
185
+ junctionTable?: string;
186
+ junctionLeftKeyField?: string;
187
+ junctionRightKeyField?: string;
188
+ displayName?: string;
189
+ }
190
+ interface RelationInfoSlice {
191
+ relationInfoCache: Record<string, Record<string, RelationInfo>>;
192
+ relationInfoMapCache: Record<string, Map<string, RelationInfo>>;
193
+ setRelationInfoForTable: (tableName: string, info: Record<string, RelationInfo>) => void;
194
+ getRelationInfoForTable: (tableName: string) => Record<string, RelationInfo> | undefined;
195
+ getRelationInfoMapForTable: (tableName: string) => Map<string, RelationInfo> | undefined;
196
+ rebuildRelationInfo: (tableName: string, meta: MetaQuery | undefined) => void;
197
+ ensureRelationInfo: (tableName: string, meta: MetaQuery | undefined) => Record<string, RelationInfo>;
198
+ clearRelationInfoCache: () => void;
199
+ }
200
+ declare function buildRelationInfoFromMeta(tableName: string, meta: MetaQuery | undefined): Record<string, RelationInfo> | null;
201
+
209
202
  interface EditorProps {
210
203
  value: unknown;
211
204
  cell: SheetsCell;
@@ -213,7 +206,7 @@ interface EditorProps {
213
206
  rowId: string;
214
207
  rowIndex: number;
215
208
  tableName?: string;
216
- fieldMeta?: FieldMetadata;
209
+ fieldMeta?: FieldMetadata$1;
217
210
  relationInfo?: RelationInfo;
218
211
  /**
219
212
  * Type-to-edit seed: when the overlay was opened by typing a printable char on the
@@ -242,4 +235,19 @@ interface EditorProps {
242
235
  };
243
236
  }
244
237
 
245
- export { type BaseCellProps as B, type CellCreationMetadata as C, type EditorProps as E, type FieldMetadata as F, type RelationInfo as R, type SheetsCell as S, type TableSchema as T, type SheetsCellKind as a, type CellType as b, type CellCategory as c, type RelationInfoSlice as d, type CellRegistryEntry as e, type CellRenderer as f, type CellPlugin as g, type ColumnSchema as h, type RelationKind as i, buildRelationInfoFromMeta as j, isImageField as k, type CellValue as l, type FieldMetadata$1 as m, type RowData as n, resolveCellType as r };
238
+ interface RelationCellOptions {
239
+ relationChipLimit?: number;
240
+ relationLabelMaxLength?: number;
241
+ }
242
+ interface CellCreationMetadata {
243
+ cellType: string;
244
+ fieldName: string;
245
+ fieldMeta?: FieldMetadata$1;
246
+ relationInfo?: RelationInfo;
247
+ relationOptions?: RelationCellOptions;
248
+ canEdit: boolean;
249
+ isReadonly: boolean;
250
+ activationBehavior: 'single-click' | 'double-click';
251
+ }
252
+
253
+ export { type BaseCellProps as B, type CellCreationMetadata as C, type EditorProps as E, type FieldMetadata$1 as F, type RelationInfo as R, type SheetsCell as S, type TableSchema as T, type SheetsCellKind as a, type CellType as b, type CellCategory as c, type RelationInfoSlice as d, type CellRegistryEntry as e, type CellRenderer as f, type CellPlugin as g, type ColumnSchema as h, type CellValue as i, type FieldMetadata as j, type RelationKind as k, type RowData as l, buildRelationInfoFromMeta as m, isImageField as n, resolveCellType as r };
@@ -1,10 +1,30 @@
1
1
  import { ComponentType } from 'react';
2
2
  import { MetaQuery } from '@constructive-io/data';
3
3
 
4
+ interface FieldMetadata$1 {
5
+ name: string;
6
+ type?: {
7
+ gqlType: string;
8
+ pgType?: string | null;
9
+ pgAlias?: string | null;
10
+ isArray?: boolean;
11
+ subtype?: string | null;
12
+ };
13
+ }
14
+ interface CellTypeResolution {
15
+ cellType: string;
16
+ canEdit: boolean;
17
+ canActivate: boolean;
18
+ activationBehavior: 'single-click' | 'double-click';
19
+ isReadonly: boolean;
20
+ }
21
+ declare function resolveCellType(fieldName: string, fieldMeta?: FieldMetadata$1): CellTypeResolution;
22
+ declare function isImageField(fieldMeta?: FieldMetadata$1, fieldName?: string): boolean;
23
+
4
24
  type CellType = 'text' | 'textarea' | 'email' | 'url' | 'phone' | 'citext' | 'bpchar' | 'number' | 'integer' | 'smallint' | 'decimal' | 'currency' | 'percentage' | 'date' | 'datetime' | 'time' | 'timestamptz' | 'interval' | 'boolean' | 'toggle' | 'bit' | 'json' | 'jsonb' | 'array' | 'text-array' | 'uuid-array' | 'number-array' | 'integer-array' | 'date-array' | 'geometry' | 'geometry-point' | 'geometry-collection' | 'inet' | 'image' | 'file' | 'video' | 'audio' | 'upload' | 'uuid' | 'color' | 'rating' | 'tags' | 'tsvector' | 'origin' | 'relation' | 'unknown';
5
25
  type CellCategory = 'text' | 'numeric' | 'date' | 'boolean' | 'structured' | 'geometric' | 'network' | 'media' | 'special' | 'other';
6
26
  type CellValue = string | number | boolean | Date | null | undefined | Array<any> | Record<string, any>;
7
- interface FieldMetadata$1 {
27
+ interface FieldMetadata {
8
28
  name: string;
9
29
  gqlType: string;
10
30
  isArray: boolean;
@@ -13,6 +33,14 @@ interface FieldMetadata$1 {
13
33
  pgType?: string | null;
14
34
  subtype?: string | null;
15
35
  typmod?: number | null;
36
+ encoding?: {
37
+ kind: string;
38
+ elementType?: string | null;
39
+ dimensions?: number | null;
40
+ geometrySubtype?: string | null;
41
+ srid?: number | null;
42
+ dotPath?: boolean | null;
43
+ } | null;
16
44
  }
17
45
  interface ColumnSchema {
18
46
  id: string;
@@ -114,65 +142,6 @@ interface CellPlugin {
114
142
  uninstall?: () => void;
115
143
  }
116
144
 
117
- interface FieldMetadata {
118
- name: string;
119
- type?: {
120
- gqlType: string;
121
- pgType?: string | null;
122
- pgAlias?: string | null;
123
- isArray?: boolean;
124
- subtype?: string | null;
125
- };
126
- }
127
- interface CellTypeResolution {
128
- cellType: string;
129
- canEdit: boolean;
130
- canActivate: boolean;
131
- activationBehavior: 'single-click' | 'double-click';
132
- isReadonly: boolean;
133
- }
134
- declare function resolveCellType(fieldName: string, fieldMeta?: FieldMetadata): CellTypeResolution;
135
- declare function isImageField(fieldMeta?: FieldMetadata, fieldName?: string): boolean;
136
-
137
- type RelationKind = 'belongsTo' | 'hasOne' | 'hasMany' | 'manyToMany';
138
- interface RelationInfo {
139
- kind: RelationKind;
140
- relatedTable?: string;
141
- displayCandidates: string[];
142
- relationField?: string;
143
- foreignKeyField?: string;
144
- junctionTable?: string;
145
- junctionLeftKeyField?: string;
146
- junctionRightKeyField?: string;
147
- displayName?: string;
148
- }
149
- interface RelationInfoSlice {
150
- relationInfoCache: Record<string, Record<string, RelationInfo>>;
151
- relationInfoMapCache: Record<string, Map<string, RelationInfo>>;
152
- setRelationInfoForTable: (tableName: string, info: Record<string, RelationInfo>) => void;
153
- getRelationInfoForTable: (tableName: string) => Record<string, RelationInfo> | undefined;
154
- getRelationInfoMapForTable: (tableName: string) => Map<string, RelationInfo> | undefined;
155
- rebuildRelationInfo: (tableName: string, meta: MetaQuery | undefined) => void;
156
- ensureRelationInfo: (tableName: string, meta: MetaQuery | undefined) => Record<string, RelationInfo>;
157
- clearRelationInfoCache: () => void;
158
- }
159
- declare function buildRelationInfoFromMeta(tableName: string, meta: MetaQuery | undefined): Record<string, RelationInfo> | null;
160
-
161
- interface RelationCellOptions {
162
- relationChipLimit?: number;
163
- relationLabelMaxLength?: number;
164
- }
165
- interface CellCreationMetadata {
166
- cellType: string;
167
- fieldName: string;
168
- fieldMeta?: FieldMetadata;
169
- relationInfo?: RelationInfo;
170
- relationOptions?: RelationCellOptions;
171
- canEdit: boolean;
172
- isReadonly: boolean;
173
- activationBehavior: 'single-click' | 'double-click';
174
- }
175
-
176
145
  /**
177
146
  * Neutral RENDER kinds — equal to the frozen `DisplayKind` union. `loading` and
178
147
  * `draft-action` originate from grid-internal state, not the `CellType` system.
@@ -206,6 +175,30 @@ interface SheetsCell {
206
175
  };
207
176
  }
208
177
 
178
+ type RelationKind = 'belongsTo' | 'hasOne' | 'hasMany' | 'manyToMany';
179
+ interface RelationInfo {
180
+ kind: RelationKind;
181
+ relatedTable?: string;
182
+ displayCandidates: string[];
183
+ relationField?: string;
184
+ foreignKeyField?: string;
185
+ junctionTable?: string;
186
+ junctionLeftKeyField?: string;
187
+ junctionRightKeyField?: string;
188
+ displayName?: string;
189
+ }
190
+ interface RelationInfoSlice {
191
+ relationInfoCache: Record<string, Record<string, RelationInfo>>;
192
+ relationInfoMapCache: Record<string, Map<string, RelationInfo>>;
193
+ setRelationInfoForTable: (tableName: string, info: Record<string, RelationInfo>) => void;
194
+ getRelationInfoForTable: (tableName: string) => Record<string, RelationInfo> | undefined;
195
+ getRelationInfoMapForTable: (tableName: string) => Map<string, RelationInfo> | undefined;
196
+ rebuildRelationInfo: (tableName: string, meta: MetaQuery | undefined) => void;
197
+ ensureRelationInfo: (tableName: string, meta: MetaQuery | undefined) => Record<string, RelationInfo>;
198
+ clearRelationInfoCache: () => void;
199
+ }
200
+ declare function buildRelationInfoFromMeta(tableName: string, meta: MetaQuery | undefined): Record<string, RelationInfo> | null;
201
+
209
202
  interface EditorProps {
210
203
  value: unknown;
211
204
  cell: SheetsCell;
@@ -213,7 +206,7 @@ interface EditorProps {
213
206
  rowId: string;
214
207
  rowIndex: number;
215
208
  tableName?: string;
216
- fieldMeta?: FieldMetadata;
209
+ fieldMeta?: FieldMetadata$1;
217
210
  relationInfo?: RelationInfo;
218
211
  /**
219
212
  * Type-to-edit seed: when the overlay was opened by typing a printable char on the
@@ -242,4 +235,19 @@ interface EditorProps {
242
235
  };
243
236
  }
244
237
 
245
- export { type BaseCellProps as B, type CellCreationMetadata as C, type EditorProps as E, type FieldMetadata as F, type RelationInfo as R, type SheetsCell as S, type TableSchema as T, type SheetsCellKind as a, type CellType as b, type CellCategory as c, type RelationInfoSlice as d, type CellRegistryEntry as e, type CellRenderer as f, type CellPlugin as g, type ColumnSchema as h, type RelationKind as i, buildRelationInfoFromMeta as j, isImageField as k, type CellValue as l, type FieldMetadata$1 as m, type RowData as n, resolveCellType as r };
238
+ interface RelationCellOptions {
239
+ relationChipLimit?: number;
240
+ relationLabelMaxLength?: number;
241
+ }
242
+ interface CellCreationMetadata {
243
+ cellType: string;
244
+ fieldName: string;
245
+ fieldMeta?: FieldMetadata$1;
246
+ relationInfo?: RelationInfo;
247
+ relationOptions?: RelationCellOptions;
248
+ canEdit: boolean;
249
+ isReadonly: boolean;
250
+ activationBehavior: 'single-click' | 'double-click';
251
+ }
252
+
253
+ export { type BaseCellProps as B, type CellCreationMetadata as C, type EditorProps as E, type FieldMetadata$1 as F, type RelationInfo as R, type SheetsCell as S, type TableSchema as T, type SheetsCellKind as a, type CellType as b, type CellCategory as c, type RelationInfoSlice as d, type CellRegistryEntry as e, type CellRenderer as f, type CellPlugin as g, type ColumnSchema as h, type CellValue as i, type FieldMetadata as j, type RelationKind as k, type RowData as l, buildRelationInfoFromMeta as m, isImageField as n, resolveCellType as r };