@constructive-io/sheets 0.13.1 → 0.15.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 +231 -148
- package/dist/advanced.cjs +7220 -4030
- package/dist/advanced.cjs.map +1 -1
- package/dist/advanced.d.cts +2 -2
- package/dist/advanced.d.ts +2 -2
- package/dist/advanced.js +5 -5
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.js +3 -3
- package/dist/chunk-CJ4PRA64.js +312 -0
- package/dist/chunk-CJ4PRA64.js.map +1 -0
- package/dist/chunk-II3MSNRO.js +18 -0
- package/dist/chunk-II3MSNRO.js.map +1 -0
- package/dist/{chunk-MXVNIKES.js → chunk-J7KK4UWI.js} +6 -6
- package/dist/chunk-MBSHDF55.js +839 -0
- package/dist/chunk-MBSHDF55.js.map +1 -0
- package/dist/{chunk-ZKANUG3F.js → chunk-MOFFS5WQ.js} +20 -15
- package/dist/chunk-MOFFS5WQ.js.map +1 -0
- package/dist/chunk-VCBY2AMT.js +8920 -0
- package/dist/chunk-VCBY2AMT.js.map +1 -0
- package/dist/{chunk-H5HR5HUJ.js → chunk-ZOQDSOMO.js} +50 -312
- package/dist/chunk-ZOQDSOMO.js.map +1 -0
- package/dist/date-editor-ORCB43ZM.js +346 -0
- package/dist/date-editor-ORCB43ZM.js.map +1 -0
- package/dist/grid-cell-types-YNIVK4hN.d.cts +346 -0
- package/dist/grid-cell-types-YNIVK4hN.d.ts +346 -0
- package/dist/index.cjs +22910 -12084
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1497 -337
- package/dist/index.d.ts +1497 -337
- package/dist/index.js +12833 -6142
- package/dist/index.js.map +1 -1
- package/dist/sheets-context-Bb7ZoNBg.d.cts +436 -0
- package/dist/sheets-context-CPuf31LS.d.ts +436 -0
- package/dist/testing.cjs +1253 -638
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +80 -11
- package/dist/testing.d.ts +80 -11
- package/dist/testing.js +791 -148
- package/dist/testing.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-4EZ6A23C.js +0 -44
- package/dist/chunk-4EZ6A23C.js.map +0 -1
- package/dist/chunk-5QPNOKMA.js +0 -4397
- package/dist/chunk-5QPNOKMA.js.map +0 -1
- package/dist/chunk-AYMXT3ME.js +0 -540
- package/dist/chunk-AYMXT3ME.js.map +0 -1
- package/dist/chunk-H5HR5HUJ.js.map +0 -1
- package/dist/chunk-PZL2BCWF.js +0 -168
- package/dist/chunk-PZL2BCWF.js.map +0 -1
- package/dist/chunk-X7DHTSOX.js +0 -21
- package/dist/chunk-X7DHTSOX.js.map +0 -1
- package/dist/chunk-ZKANUG3F.js.map +0 -1
- package/dist/date-editor-ZFNDKYBD.js +0 -358
- package/dist/date-editor-ZFNDKYBD.js.map +0 -1
- package/dist/grid-cell-types-Pbe2m2tE.d.cts +0 -253
- package/dist/grid-cell-types-Pbe2m2tE.d.ts +0 -253
- package/dist/map-picker-ZUGGOIZS.js +0 -290
- package/dist/map-picker-ZUGGOIZS.js.map +0 -1
- package/dist/sheets-context-CY1RmDKL.d.cts +0 -244
- package/dist/sheets-context-Cu3Ec_ca.d.ts +0 -244
- /package/dist/{chunk-MXVNIKES.js.map → chunk-J7KK4UWI.js.map} +0 -0
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
-
import { DocumentNode } from 'graphql';
|
|
4
|
-
import { TypedDocumentString, FieldSelection, CleanTable, MetaQuery, MutationOptions } from '@constructive-io/data';
|
|
5
|
-
import { b as CellType, S as SheetsCell, C as CellCreationMetadata, c as CellCategory, E as EditorProps } from './grid-cell-types-Pbe2m2tE.cjs';
|
|
6
|
-
|
|
7
|
-
type ExecutableDocument = TypedDocumentString<any, any> | DocumentNode | string | unknown;
|
|
8
|
-
type SheetsExecuteFn = <T = unknown>(document: ExecutableDocument, variables?: Record<string, unknown>) => Promise<T>;
|
|
9
|
-
/**
|
|
10
|
-
* Result of an upload through the seam. `url` is the only guaranteed field;
|
|
11
|
-
* the REST upload endpoint also returns `{ filename, mime, size }` (and may
|
|
12
|
-
* return server-internal extras). Keeping it open-ended lets callers read the
|
|
13
|
-
* richer metadata while a bare `{ url }` (e.g. the mock) still satisfies it.
|
|
14
|
-
*/
|
|
15
|
-
type SheetsUploadResult = {
|
|
16
|
-
url: string;
|
|
17
|
-
} & Record<string, unknown>;
|
|
18
|
-
/**
|
|
19
|
-
* Optional upload metadata carried through the seam (third arg). Lets an
|
|
20
|
-
* injected `executeUpload` see the destination field/row and report progress.
|
|
21
|
-
* All fields optional, so existing `(file, path?)` callers stay valid.
|
|
22
|
-
*/
|
|
23
|
-
interface SheetsUploadOptions {
|
|
24
|
-
tableName?: string;
|
|
25
|
-
fieldName?: string;
|
|
26
|
-
recordId?: string | number;
|
|
27
|
-
onProgress?: (progress: {
|
|
28
|
-
loaded: number;
|
|
29
|
-
total: number;
|
|
30
|
-
percentage: number;
|
|
31
|
-
}) => void;
|
|
32
|
-
}
|
|
33
|
-
type SheetsUploadFn = (file: File, path?: string, options?: SheetsUploadOptions) => Promise<SheetsUploadResult>;
|
|
34
|
-
declare function createSheetsExecute(config: SheetsConfig, getToken: () => string | null): SheetsExecuteFn;
|
|
35
|
-
/**
|
|
36
|
-
* Presigned-URL cell-upload seam.
|
|
37
|
-
*
|
|
38
|
-
* Replaces the legacy multipart `<endpoint>/upload` POST entirely. The flow:
|
|
39
|
-
* 1. Read + SHA-256 hash the file bytes (Web Crypto)
|
|
40
|
-
* 2. Discover (cached per endpoint) the upload op + downloadUrl-by-id field
|
|
41
|
-
* via GraphQL introspection — the root `upload<Type>File` mutation, matched
|
|
42
|
-
* by FIELD/TYPE SHAPE (LOCKED: no hardcoded names)
|
|
43
|
-
* 3. Call the upload op with input `{ bucketKey, contentHash, contentType,
|
|
44
|
-
* size, filename }` — NO `ownerId` (app-scoped buckets have no owner_id)
|
|
45
|
-
* 4. If `uploadUrl` is non-null, PUT the raw bytes to it with ONLY the signed
|
|
46
|
-
* `Content-Type` header (NO Authorization). Skipped when `deduplicated`.
|
|
47
|
-
* 5. Resolve the stable public `downloadUrl` for the returned fileId.
|
|
48
|
-
*
|
|
49
|
-
* Returns `{ url, filename, mime, size, key, fileId }` where `url` is the stable
|
|
50
|
-
* download URL — the same cell value shape callers/Step-2 already consume.
|
|
51
|
-
*
|
|
52
|
-
* `path` is ignored (content-addressed buckets key on `contentHash`).
|
|
53
|
-
*/
|
|
54
|
-
declare function createSheetsUpload(config: SheetsConfig, getToken: () => string | null): SheetsUploadFn;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Injectable logger seam for @constructive-io/sheets.
|
|
58
|
-
*
|
|
59
|
-
* The host app may provide a custom logger via SheetsConfig.logger. The provider
|
|
60
|
-
* installs it into this module singleton (see sheets-provider.tsx), so any module
|
|
61
|
-
* or hook can log without threading the logger through props/context.
|
|
62
|
-
*
|
|
63
|
-
* Default behaviour matches the prior console.* calls. `debug` is omitted from the
|
|
64
|
-
* default logger (no-op) so verbose diagnostics stay silent unless a host opts in.
|
|
65
|
-
*/
|
|
66
|
-
interface SheetsLogger {
|
|
67
|
-
debug?(msg: string, ctx?: unknown): void;
|
|
68
|
-
warn(msg: string, ctx?: unknown): void;
|
|
69
|
-
error(msg: string, ctx?: unknown): void;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** Smallest render-column descriptor a cell view needs now. Overridable. */
|
|
73
|
-
interface CellColumnDescriptor {
|
|
74
|
-
key: string;
|
|
75
|
-
name: string;
|
|
76
|
-
cellType: CellType;
|
|
77
|
-
}
|
|
78
|
-
/** Props every native cell view receives. Minimal and overridable. */
|
|
79
|
-
interface CellProps {
|
|
80
|
-
cell: SheetsCell;
|
|
81
|
-
value: unknown;
|
|
82
|
-
colKey: string;
|
|
83
|
-
rowId: string;
|
|
84
|
-
rowIndex: number;
|
|
85
|
-
column: CellColumnDescriptor;
|
|
86
|
-
isEditing: boolean;
|
|
87
|
-
onStartEdit: () => void;
|
|
88
|
-
disabled: boolean;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** Schema-only inputs used to DETECT a cell type. Never the runtime value. */
|
|
92
|
-
interface CellTypeMatchInput {
|
|
93
|
-
gqlType: string;
|
|
94
|
-
isArray: boolean;
|
|
95
|
-
pgAlias?: string | null;
|
|
96
|
-
pgType?: string | null;
|
|
97
|
-
subtype?: string | null;
|
|
98
|
-
fieldName?: string;
|
|
99
|
-
}
|
|
100
|
-
/** Context handed to `toSheetsCell` so a definition can build the neutral cell.
|
|
101
|
-
* Geometry uses the built-in fallback, so no `createGeometry` callback is needed. */
|
|
102
|
-
interface SheetsCellRenderContext {
|
|
103
|
-
metadata: CellCreationMetadata;
|
|
104
|
-
}
|
|
105
|
-
interface CellTypeDefinition<TValue = unknown> {
|
|
106
|
-
/** Stable key. A def whose typeKey equals a built-in (e.g. 'relation') overrides it. */
|
|
107
|
-
typeKey: string;
|
|
108
|
-
category?: CellCategory;
|
|
109
|
-
/** Toolbar / type-picker icon. */
|
|
110
|
-
icon?: React.ComponentType<{
|
|
111
|
-
size?: number;
|
|
112
|
-
}>;
|
|
113
|
-
defaultWidth?: number;
|
|
114
|
-
supportsInlineEdit?: boolean;
|
|
115
|
-
/** DETECTION (schema-only). Highest-priority match wins; omit for typeKey-only. */
|
|
116
|
-
match?: (meta: CellTypeMatchInput) => boolean;
|
|
117
|
-
/** Native DISPLAY. Build the neutral SheetsCell. Omit to keep the built-in renderer. */
|
|
118
|
-
toSheetsCell?: (value: TValue, ctx: SheetsCellRenderContext) => SheetsCell;
|
|
119
|
-
/** Native cell COMPONENT override (the slot target). Omit to keep the built-in view. */
|
|
120
|
-
cell?: React.ComponentType<CellProps>;
|
|
121
|
-
/** Native EDITOR override (DOM portal overlay). Omit to keep the built-in native editor. */
|
|
122
|
-
editorComponent?: React.ComponentType<EditorProps>;
|
|
123
|
-
/** Value -> display/copy/export string. */
|
|
124
|
-
format?: (value: TValue) => string;
|
|
125
|
-
defaultValue?: () => TValue;
|
|
126
|
-
}
|
|
127
|
-
/** Identity helper that pins the generic — `defineCellType<number>({ ... })`. */
|
|
128
|
-
declare function defineCellType<T = unknown>(def: CellTypeDefinition<T>): CellTypeDefinition<T>;
|
|
129
|
-
/** A named bundle of cell types, registered via `SheetsConfig.plugins`. */
|
|
130
|
-
interface CellTypePlugin {
|
|
131
|
-
name: string;
|
|
132
|
-
cellTypes: CellTypeDefinition<any>[];
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** The table being operated on, plus all tables (needed for relation-aware AST building). */
|
|
136
|
-
interface AdapterTableContext {
|
|
137
|
-
table: CleanTable;
|
|
138
|
-
allTables: CleanTable[];
|
|
139
|
-
tableName: string;
|
|
140
|
-
}
|
|
141
|
-
/** A normalized list query. `relationFieldMap` is resolved by the hook (it is cache-bound). */
|
|
142
|
-
interface AdapterListQuery {
|
|
143
|
-
where?: unknown;
|
|
144
|
-
orderBy?: Array<{
|
|
145
|
-
field: string;
|
|
146
|
-
direction: 'asc' | 'desc';
|
|
147
|
-
}>;
|
|
148
|
-
limit?: number;
|
|
149
|
-
offset?: number;
|
|
150
|
-
/** Relay cursor for forward pagination (infinite/cursor mode). */
|
|
151
|
-
after?: string;
|
|
152
|
-
fieldSelection?: FieldSelection;
|
|
153
|
-
/** Resolved relation field name map, threaded from the hook's cached resolution. */
|
|
154
|
-
relationFieldMap?: Record<string, string>;
|
|
155
|
-
}
|
|
156
|
-
interface AdapterPageInfo {
|
|
157
|
-
endCursor?: string | null;
|
|
158
|
-
startCursor?: string | null;
|
|
159
|
-
hasNextPage?: boolean;
|
|
160
|
-
hasPreviousPage?: boolean;
|
|
161
|
-
}
|
|
162
|
-
interface AdapterListResult<T = Record<string, unknown>> {
|
|
163
|
-
rows: T[];
|
|
164
|
-
totalCount: number;
|
|
165
|
-
pageInfo?: AdapterPageInfo;
|
|
166
|
-
}
|
|
167
|
-
interface SheetsBackendAdapter {
|
|
168
|
-
/** Introspect the schema. Default adapter validates and runs the July 2026 `_meta` contract. */
|
|
169
|
-
fetchMeta(execute: SheetsExecuteFn): Promise<MetaQuery>;
|
|
170
|
-
/** Read a page of rows, flattening relation connections into arrays. */
|
|
171
|
-
listRows<T = Record<string, unknown>>(ctx: AdapterTableContext, query: AdapterListQuery, execute: SheetsExecuteFn): Promise<AdapterListResult<T>>;
|
|
172
|
-
/** Create a row; resolves to the created row (or null). */
|
|
173
|
-
createRow<T = Record<string, unknown>>(ctx: AdapterTableContext, data: Record<string, unknown>, execute: SheetsExecuteFn, options?: MutationOptions): Promise<T | null>;
|
|
174
|
-
/** Update a row by id (or composite PK object); resolves to the updated row (or null). */
|
|
175
|
-
updateRow<T = Record<string, unknown>>(ctx: AdapterTableContext, id: string | number | Record<string, unknown>, patch: Record<string, unknown>, execute: SheetsExecuteFn, options?: MutationOptions): Promise<T | null>;
|
|
176
|
-
/** Delete a row by id (or composite PK object). */
|
|
177
|
-
deleteRow(ctx: AdapterTableContext, id: string | number | Record<string, unknown>, execute: SheetsExecuteFn, options?: MutationOptions): Promise<void>;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
interface SheetsAuthEmbedded {
|
|
181
|
-
mode: 'embedded';
|
|
182
|
-
getToken: () => string | null;
|
|
183
|
-
/**
|
|
184
|
-
* Stable, non-secret identity used to isolate cached data between users.
|
|
185
|
-
* Hosts should return the authenticated user/session id, never the token.
|
|
186
|
-
* When omitted, the provider uses an opaque key that changes with the token.
|
|
187
|
-
*/
|
|
188
|
-
getIdentityKey?: () => string | null;
|
|
189
|
-
}
|
|
190
|
-
interface SheetsAuthStandalone {
|
|
191
|
-
mode: 'standalone';
|
|
192
|
-
}
|
|
193
|
-
interface SheetsConfig {
|
|
194
|
-
/** Data endpoint (app-public GraphQL) */
|
|
195
|
-
endpoint: string;
|
|
196
|
-
/** Auth endpoint (auth GraphQL) — required for standalone mode */
|
|
197
|
-
authEndpoint?: string;
|
|
198
|
-
/** Database ID for multi-tenant scoping */
|
|
199
|
-
databaseId?: string;
|
|
200
|
-
/** Auth mode */
|
|
201
|
-
auth: SheetsAuthEmbedded | SheetsAuthStandalone;
|
|
202
|
-
/** Field type overrides (replaces schema-builder smart tags) */
|
|
203
|
-
fieldTypeOverrides?: Record<string, string>;
|
|
204
|
-
/** Optional: BCP-47 locale for locale-aware date/number formatting (default 'en-US'). */
|
|
205
|
-
locale?: string;
|
|
206
|
-
/** Optional: inject custom execute function */
|
|
207
|
-
execute?: SheetsExecuteFn;
|
|
208
|
-
/** Optional: inject custom upload function */
|
|
209
|
-
executeUpload?: SheetsUploadFn;
|
|
210
|
-
/** Optional upload settings. `bucketKey` defaults to "public". */
|
|
211
|
-
upload?: {
|
|
212
|
-
bucketKey?: string;
|
|
213
|
-
};
|
|
214
|
-
/** Optional: inject existing QueryClient */
|
|
215
|
-
queryClient?: QueryClient;
|
|
216
|
-
/** Optional: inject a custom backend adapter. Defaults to the PostGraphile adapter. */
|
|
217
|
-
adapter?: SheetsBackendAdapter;
|
|
218
|
-
/** Optional: provider-level cell-type plugins (consumer override layer). */
|
|
219
|
-
plugins?: CellTypePlugin[];
|
|
220
|
-
/** Called on 401/UNAUTHENTICATED before the error is thrown. Host app handles token cleanup. */
|
|
221
|
-
onAuthError?: () => void;
|
|
222
|
-
/** Optional: inject a custom logger. Installed into the module logger singleton by the provider. */
|
|
223
|
-
logger?: SheetsLogger;
|
|
224
|
-
/** Optional: called when a grid/editor/mutation/upload error surfaces. Host app handles reporting. */
|
|
225
|
-
onError?: (error: unknown, ctx?: {
|
|
226
|
-
source?: 'grid' | 'editor' | 'mutation' | 'upload';
|
|
227
|
-
tableName?: string;
|
|
228
|
-
}) => void;
|
|
229
|
-
}
|
|
230
|
-
interface SheetsContextValue {
|
|
231
|
-
config: SheetsConfig;
|
|
232
|
-
execute: SheetsExecuteFn;
|
|
233
|
-
executeUpload: SheetsUploadFn;
|
|
234
|
-
scopeKey: SheetsScopeKey;
|
|
235
|
-
}
|
|
236
|
-
interface SheetsScopeKey {
|
|
237
|
-
databaseId: string | null;
|
|
238
|
-
endpoint: string;
|
|
239
|
-
identityKey: string | null;
|
|
240
|
-
}
|
|
241
|
-
declare const SheetsContext: react.Context<SheetsContextValue | null>;
|
|
242
|
-
declare function useSheetsContext(): SheetsContextValue;
|
|
243
|
-
|
|
244
|
-
export { type AdapterListQuery as A, type CellProps as C, type SheetsExecuteFn as S, type SheetsUploadFn as a, type SheetsConfig as b, type CellTypeDefinition as c, type SheetsCellRenderContext as d, type CellTypeMatchInput as e, type SheetsScopeKey as f, type SheetsBackendAdapter as g, type AdapterListResult as h, type AdapterPageInfo as i, type AdapterTableContext as j, type CellColumnDescriptor as k, type CellTypePlugin as l, type SheetsAuthEmbedded as m, type SheetsAuthStandalone as n, SheetsContext as o, type SheetsContextValue as p, type SheetsLogger as q, createSheetsExecute as r, createSheetsUpload as s, defineCellType as t, useSheetsContext as u };
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
-
import { DocumentNode } from 'graphql';
|
|
4
|
-
import { TypedDocumentString, FieldSelection, CleanTable, MetaQuery, MutationOptions } from '@constructive-io/data';
|
|
5
|
-
import { b as CellType, S as SheetsCell, C as CellCreationMetadata, c as CellCategory, E as EditorProps } from './grid-cell-types-Pbe2m2tE.js';
|
|
6
|
-
|
|
7
|
-
type ExecutableDocument = TypedDocumentString<any, any> | DocumentNode | string | unknown;
|
|
8
|
-
type SheetsExecuteFn = <T = unknown>(document: ExecutableDocument, variables?: Record<string, unknown>) => Promise<T>;
|
|
9
|
-
/**
|
|
10
|
-
* Result of an upload through the seam. `url` is the only guaranteed field;
|
|
11
|
-
* the REST upload endpoint also returns `{ filename, mime, size }` (and may
|
|
12
|
-
* return server-internal extras). Keeping it open-ended lets callers read the
|
|
13
|
-
* richer metadata while a bare `{ url }` (e.g. the mock) still satisfies it.
|
|
14
|
-
*/
|
|
15
|
-
type SheetsUploadResult = {
|
|
16
|
-
url: string;
|
|
17
|
-
} & Record<string, unknown>;
|
|
18
|
-
/**
|
|
19
|
-
* Optional upload metadata carried through the seam (third arg). Lets an
|
|
20
|
-
* injected `executeUpload` see the destination field/row and report progress.
|
|
21
|
-
* All fields optional, so existing `(file, path?)` callers stay valid.
|
|
22
|
-
*/
|
|
23
|
-
interface SheetsUploadOptions {
|
|
24
|
-
tableName?: string;
|
|
25
|
-
fieldName?: string;
|
|
26
|
-
recordId?: string | number;
|
|
27
|
-
onProgress?: (progress: {
|
|
28
|
-
loaded: number;
|
|
29
|
-
total: number;
|
|
30
|
-
percentage: number;
|
|
31
|
-
}) => void;
|
|
32
|
-
}
|
|
33
|
-
type SheetsUploadFn = (file: File, path?: string, options?: SheetsUploadOptions) => Promise<SheetsUploadResult>;
|
|
34
|
-
declare function createSheetsExecute(config: SheetsConfig, getToken: () => string | null): SheetsExecuteFn;
|
|
35
|
-
/**
|
|
36
|
-
* Presigned-URL cell-upload seam.
|
|
37
|
-
*
|
|
38
|
-
* Replaces the legacy multipart `<endpoint>/upload` POST entirely. The flow:
|
|
39
|
-
* 1. Read + SHA-256 hash the file bytes (Web Crypto)
|
|
40
|
-
* 2. Discover (cached per endpoint) the upload op + downloadUrl-by-id field
|
|
41
|
-
* via GraphQL introspection — the root `upload<Type>File` mutation, matched
|
|
42
|
-
* by FIELD/TYPE SHAPE (LOCKED: no hardcoded names)
|
|
43
|
-
* 3. Call the upload op with input `{ bucketKey, contentHash, contentType,
|
|
44
|
-
* size, filename }` — NO `ownerId` (app-scoped buckets have no owner_id)
|
|
45
|
-
* 4. If `uploadUrl` is non-null, PUT the raw bytes to it with ONLY the signed
|
|
46
|
-
* `Content-Type` header (NO Authorization). Skipped when `deduplicated`.
|
|
47
|
-
* 5. Resolve the stable public `downloadUrl` for the returned fileId.
|
|
48
|
-
*
|
|
49
|
-
* Returns `{ url, filename, mime, size, key, fileId }` where `url` is the stable
|
|
50
|
-
* download URL — the same cell value shape callers/Step-2 already consume.
|
|
51
|
-
*
|
|
52
|
-
* `path` is ignored (content-addressed buckets key on `contentHash`).
|
|
53
|
-
*/
|
|
54
|
-
declare function createSheetsUpload(config: SheetsConfig, getToken: () => string | null): SheetsUploadFn;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Injectable logger seam for @constructive-io/sheets.
|
|
58
|
-
*
|
|
59
|
-
* The host app may provide a custom logger via SheetsConfig.logger. The provider
|
|
60
|
-
* installs it into this module singleton (see sheets-provider.tsx), so any module
|
|
61
|
-
* or hook can log without threading the logger through props/context.
|
|
62
|
-
*
|
|
63
|
-
* Default behaviour matches the prior console.* calls. `debug` is omitted from the
|
|
64
|
-
* default logger (no-op) so verbose diagnostics stay silent unless a host opts in.
|
|
65
|
-
*/
|
|
66
|
-
interface SheetsLogger {
|
|
67
|
-
debug?(msg: string, ctx?: unknown): void;
|
|
68
|
-
warn(msg: string, ctx?: unknown): void;
|
|
69
|
-
error(msg: string, ctx?: unknown): void;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** Smallest render-column descriptor a cell view needs now. Overridable. */
|
|
73
|
-
interface CellColumnDescriptor {
|
|
74
|
-
key: string;
|
|
75
|
-
name: string;
|
|
76
|
-
cellType: CellType;
|
|
77
|
-
}
|
|
78
|
-
/** Props every native cell view receives. Minimal and overridable. */
|
|
79
|
-
interface CellProps {
|
|
80
|
-
cell: SheetsCell;
|
|
81
|
-
value: unknown;
|
|
82
|
-
colKey: string;
|
|
83
|
-
rowId: string;
|
|
84
|
-
rowIndex: number;
|
|
85
|
-
column: CellColumnDescriptor;
|
|
86
|
-
isEditing: boolean;
|
|
87
|
-
onStartEdit: () => void;
|
|
88
|
-
disabled: boolean;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** Schema-only inputs used to DETECT a cell type. Never the runtime value. */
|
|
92
|
-
interface CellTypeMatchInput {
|
|
93
|
-
gqlType: string;
|
|
94
|
-
isArray: boolean;
|
|
95
|
-
pgAlias?: string | null;
|
|
96
|
-
pgType?: string | null;
|
|
97
|
-
subtype?: string | null;
|
|
98
|
-
fieldName?: string;
|
|
99
|
-
}
|
|
100
|
-
/** Context handed to `toSheetsCell` so a definition can build the neutral cell.
|
|
101
|
-
* Geometry uses the built-in fallback, so no `createGeometry` callback is needed. */
|
|
102
|
-
interface SheetsCellRenderContext {
|
|
103
|
-
metadata: CellCreationMetadata;
|
|
104
|
-
}
|
|
105
|
-
interface CellTypeDefinition<TValue = unknown> {
|
|
106
|
-
/** Stable key. A def whose typeKey equals a built-in (e.g. 'relation') overrides it. */
|
|
107
|
-
typeKey: string;
|
|
108
|
-
category?: CellCategory;
|
|
109
|
-
/** Toolbar / type-picker icon. */
|
|
110
|
-
icon?: React.ComponentType<{
|
|
111
|
-
size?: number;
|
|
112
|
-
}>;
|
|
113
|
-
defaultWidth?: number;
|
|
114
|
-
supportsInlineEdit?: boolean;
|
|
115
|
-
/** DETECTION (schema-only). Highest-priority match wins; omit for typeKey-only. */
|
|
116
|
-
match?: (meta: CellTypeMatchInput) => boolean;
|
|
117
|
-
/** Native DISPLAY. Build the neutral SheetsCell. Omit to keep the built-in renderer. */
|
|
118
|
-
toSheetsCell?: (value: TValue, ctx: SheetsCellRenderContext) => SheetsCell;
|
|
119
|
-
/** Native cell COMPONENT override (the slot target). Omit to keep the built-in view. */
|
|
120
|
-
cell?: React.ComponentType<CellProps>;
|
|
121
|
-
/** Native EDITOR override (DOM portal overlay). Omit to keep the built-in native editor. */
|
|
122
|
-
editorComponent?: React.ComponentType<EditorProps>;
|
|
123
|
-
/** Value -> display/copy/export string. */
|
|
124
|
-
format?: (value: TValue) => string;
|
|
125
|
-
defaultValue?: () => TValue;
|
|
126
|
-
}
|
|
127
|
-
/** Identity helper that pins the generic — `defineCellType<number>({ ... })`. */
|
|
128
|
-
declare function defineCellType<T = unknown>(def: CellTypeDefinition<T>): CellTypeDefinition<T>;
|
|
129
|
-
/** A named bundle of cell types, registered via `SheetsConfig.plugins`. */
|
|
130
|
-
interface CellTypePlugin {
|
|
131
|
-
name: string;
|
|
132
|
-
cellTypes: CellTypeDefinition<any>[];
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** The table being operated on, plus all tables (needed for relation-aware AST building). */
|
|
136
|
-
interface AdapterTableContext {
|
|
137
|
-
table: CleanTable;
|
|
138
|
-
allTables: CleanTable[];
|
|
139
|
-
tableName: string;
|
|
140
|
-
}
|
|
141
|
-
/** A normalized list query. `relationFieldMap` is resolved by the hook (it is cache-bound). */
|
|
142
|
-
interface AdapterListQuery {
|
|
143
|
-
where?: unknown;
|
|
144
|
-
orderBy?: Array<{
|
|
145
|
-
field: string;
|
|
146
|
-
direction: 'asc' | 'desc';
|
|
147
|
-
}>;
|
|
148
|
-
limit?: number;
|
|
149
|
-
offset?: number;
|
|
150
|
-
/** Relay cursor for forward pagination (infinite/cursor mode). */
|
|
151
|
-
after?: string;
|
|
152
|
-
fieldSelection?: FieldSelection;
|
|
153
|
-
/** Resolved relation field name map, threaded from the hook's cached resolution. */
|
|
154
|
-
relationFieldMap?: Record<string, string>;
|
|
155
|
-
}
|
|
156
|
-
interface AdapterPageInfo {
|
|
157
|
-
endCursor?: string | null;
|
|
158
|
-
startCursor?: string | null;
|
|
159
|
-
hasNextPage?: boolean;
|
|
160
|
-
hasPreviousPage?: boolean;
|
|
161
|
-
}
|
|
162
|
-
interface AdapterListResult<T = Record<string, unknown>> {
|
|
163
|
-
rows: T[];
|
|
164
|
-
totalCount: number;
|
|
165
|
-
pageInfo?: AdapterPageInfo;
|
|
166
|
-
}
|
|
167
|
-
interface SheetsBackendAdapter {
|
|
168
|
-
/** Introspect the schema. Default adapter validates and runs the July 2026 `_meta` contract. */
|
|
169
|
-
fetchMeta(execute: SheetsExecuteFn): Promise<MetaQuery>;
|
|
170
|
-
/** Read a page of rows, flattening relation connections into arrays. */
|
|
171
|
-
listRows<T = Record<string, unknown>>(ctx: AdapterTableContext, query: AdapterListQuery, execute: SheetsExecuteFn): Promise<AdapterListResult<T>>;
|
|
172
|
-
/** Create a row; resolves to the created row (or null). */
|
|
173
|
-
createRow<T = Record<string, unknown>>(ctx: AdapterTableContext, data: Record<string, unknown>, execute: SheetsExecuteFn, options?: MutationOptions): Promise<T | null>;
|
|
174
|
-
/** Update a row by id (or composite PK object); resolves to the updated row (or null). */
|
|
175
|
-
updateRow<T = Record<string, unknown>>(ctx: AdapterTableContext, id: string | number | Record<string, unknown>, patch: Record<string, unknown>, execute: SheetsExecuteFn, options?: MutationOptions): Promise<T | null>;
|
|
176
|
-
/** Delete a row by id (or composite PK object). */
|
|
177
|
-
deleteRow(ctx: AdapterTableContext, id: string | number | Record<string, unknown>, execute: SheetsExecuteFn, options?: MutationOptions): Promise<void>;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
interface SheetsAuthEmbedded {
|
|
181
|
-
mode: 'embedded';
|
|
182
|
-
getToken: () => string | null;
|
|
183
|
-
/**
|
|
184
|
-
* Stable, non-secret identity used to isolate cached data between users.
|
|
185
|
-
* Hosts should return the authenticated user/session id, never the token.
|
|
186
|
-
* When omitted, the provider uses an opaque key that changes with the token.
|
|
187
|
-
*/
|
|
188
|
-
getIdentityKey?: () => string | null;
|
|
189
|
-
}
|
|
190
|
-
interface SheetsAuthStandalone {
|
|
191
|
-
mode: 'standalone';
|
|
192
|
-
}
|
|
193
|
-
interface SheetsConfig {
|
|
194
|
-
/** Data endpoint (app-public GraphQL) */
|
|
195
|
-
endpoint: string;
|
|
196
|
-
/** Auth endpoint (auth GraphQL) — required for standalone mode */
|
|
197
|
-
authEndpoint?: string;
|
|
198
|
-
/** Database ID for multi-tenant scoping */
|
|
199
|
-
databaseId?: string;
|
|
200
|
-
/** Auth mode */
|
|
201
|
-
auth: SheetsAuthEmbedded | SheetsAuthStandalone;
|
|
202
|
-
/** Field type overrides (replaces schema-builder smart tags) */
|
|
203
|
-
fieldTypeOverrides?: Record<string, string>;
|
|
204
|
-
/** Optional: BCP-47 locale for locale-aware date/number formatting (default 'en-US'). */
|
|
205
|
-
locale?: string;
|
|
206
|
-
/** Optional: inject custom execute function */
|
|
207
|
-
execute?: SheetsExecuteFn;
|
|
208
|
-
/** Optional: inject custom upload function */
|
|
209
|
-
executeUpload?: SheetsUploadFn;
|
|
210
|
-
/** Optional upload settings. `bucketKey` defaults to "public". */
|
|
211
|
-
upload?: {
|
|
212
|
-
bucketKey?: string;
|
|
213
|
-
};
|
|
214
|
-
/** Optional: inject existing QueryClient */
|
|
215
|
-
queryClient?: QueryClient;
|
|
216
|
-
/** Optional: inject a custom backend adapter. Defaults to the PostGraphile adapter. */
|
|
217
|
-
adapter?: SheetsBackendAdapter;
|
|
218
|
-
/** Optional: provider-level cell-type plugins (consumer override layer). */
|
|
219
|
-
plugins?: CellTypePlugin[];
|
|
220
|
-
/** Called on 401/UNAUTHENTICATED before the error is thrown. Host app handles token cleanup. */
|
|
221
|
-
onAuthError?: () => void;
|
|
222
|
-
/** Optional: inject a custom logger. Installed into the module logger singleton by the provider. */
|
|
223
|
-
logger?: SheetsLogger;
|
|
224
|
-
/** Optional: called when a grid/editor/mutation/upload error surfaces. Host app handles reporting. */
|
|
225
|
-
onError?: (error: unknown, ctx?: {
|
|
226
|
-
source?: 'grid' | 'editor' | 'mutation' | 'upload';
|
|
227
|
-
tableName?: string;
|
|
228
|
-
}) => void;
|
|
229
|
-
}
|
|
230
|
-
interface SheetsContextValue {
|
|
231
|
-
config: SheetsConfig;
|
|
232
|
-
execute: SheetsExecuteFn;
|
|
233
|
-
executeUpload: SheetsUploadFn;
|
|
234
|
-
scopeKey: SheetsScopeKey;
|
|
235
|
-
}
|
|
236
|
-
interface SheetsScopeKey {
|
|
237
|
-
databaseId: string | null;
|
|
238
|
-
endpoint: string;
|
|
239
|
-
identityKey: string | null;
|
|
240
|
-
}
|
|
241
|
-
declare const SheetsContext: react.Context<SheetsContextValue | null>;
|
|
242
|
-
declare function useSheetsContext(): SheetsContextValue;
|
|
243
|
-
|
|
244
|
-
export { type AdapterListQuery as A, type CellProps as C, type SheetsExecuteFn as S, type SheetsUploadFn as a, type SheetsConfig as b, type CellTypeDefinition as c, type SheetsCellRenderContext as d, type CellTypeMatchInput as e, type SheetsScopeKey as f, type SheetsBackendAdapter as g, type AdapterListResult as h, type AdapterPageInfo as i, type AdapterTableContext as j, type CellColumnDescriptor as k, type CellTypePlugin as l, type SheetsAuthEmbedded as m, type SheetsAuthStandalone as n, SheetsContext as o, type SheetsContextValue as p, type SheetsLogger as q, createSheetsExecute as r, createSheetsUpload as s, defineCellType as t, useSheetsContext as u };
|
|
File without changes
|