@constructive-io/sheets 0.14.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 -157
- package/dist/advanced.cjs +7192 -3840
- 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-BYAYBXVB.js → chunk-J7KK4UWI.js} +6 -6
- package/dist/chunk-MBSHDF55.js +839 -0
- package/dist/chunk-MBSHDF55.js.map +1 -0
- package/dist/chunk-MOFFS5WQ.js +128 -0
- 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-YJZFHL2D.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-C2-ocDS7.d.cts → grid-cell-types-YNIVK4hN.d.cts} +71 -18
- package/dist/{grid-cell-types-C2-ocDS7.d.ts → grid-cell-types-YNIVK4hN.d.ts} +71 -18
- package/dist/index.cjs +22733 -12052
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1432 -266
- package/dist/index.d.ts +1432 -266
- package/dist/index.js +12688 -6097
- 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 +1170 -589
- 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 +778 -147
- package/dist/testing.js.map +1 -1
- package/package.json +4 -5
- package/dist/chunk-4EZ6A23C.js +0 -44
- package/dist/chunk-4EZ6A23C.js.map +0 -1
- package/dist/chunk-6Y7CZ5VS.js +0 -168
- package/dist/chunk-6Y7CZ5VS.js.map +0 -1
- package/dist/chunk-BGL6EBTE.js +0 -446
- package/dist/chunk-BGL6EBTE.js.map +0 -1
- package/dist/chunk-ER3FIDK7.js +0 -4383
- package/dist/chunk-ER3FIDK7.js.map +0 -1
- package/dist/chunk-GZM2CSTR.js +0 -279
- package/dist/chunk-GZM2CSTR.js.map +0 -1
- package/dist/chunk-X7DHTSOX.js +0 -21
- package/dist/chunk-X7DHTSOX.js.map +0 -1
- package/dist/chunk-YJZFHL2D.js.map +0 -1
- package/dist/date-editor-G26WKILO.js +0 -358
- package/dist/date-editor-G26WKILO.js.map +0 -1
- package/dist/map-picker-ZUGGOIZS.js +0 -290
- package/dist/map-picker-ZUGGOIZS.js.map +0 -1
- package/dist/sheets-context-CHUVJCff.d.ts +0 -245
- package/dist/sheets-context-C_MkTxXm.d.cts +0 -245
- /package/dist/{chunk-BYAYBXVB.js.map → chunk-J7KK4UWI.js.map} +0 -0
|
@@ -1,245 +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-C2-ocDS7.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
|
-
/** Durable file metadata for image and upload columns. */
|
|
10
|
-
interface SheetsFileValue {
|
|
11
|
-
id: string;
|
|
12
|
-
key: string;
|
|
13
|
-
bucket_id: string;
|
|
14
|
-
mime: string;
|
|
15
|
-
size: number;
|
|
16
|
-
filename: string;
|
|
17
|
-
/** Public URL supplied by storage, when available. */
|
|
18
|
-
url?: string;
|
|
19
|
-
}
|
|
20
|
-
interface SheetsUploadResult {
|
|
21
|
-
file: SheetsFileValue;
|
|
22
|
-
/** Optional download URL for immediate use. It can expire. */
|
|
23
|
-
url?: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Optional upload metadata carried through the seam (third arg). Lets an
|
|
27
|
-
* injected `executeUpload` see the destination field/row and report progress.
|
|
28
|
-
* All fields optional, so existing `(file, path?)` callers stay valid.
|
|
29
|
-
*/
|
|
30
|
-
interface SheetsUploadOptions {
|
|
31
|
-
tableName?: string;
|
|
32
|
-
fieldName?: string;
|
|
33
|
-
recordId?: string | number;
|
|
34
|
-
onProgress?: (progress: {
|
|
35
|
-
loaded: number;
|
|
36
|
-
total: number;
|
|
37
|
-
percentage: number;
|
|
38
|
-
}) => void;
|
|
39
|
-
}
|
|
40
|
-
type SheetsUploadFn = (file: File, path?: string, options?: SheetsUploadOptions) => Promise<SheetsUploadResult>;
|
|
41
|
-
declare function createSheetsExecute(config: SheetsConfig, getToken: () => string | null): SheetsExecuteFn;
|
|
42
|
-
/** Creates an uploader for storage. Direct callers may use the supplied endpoint as storage. */
|
|
43
|
-
declare function createSheetsUpload(config: SheetsConfig, getToken: () => string | null): SheetsUploadFn;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Injectable logger seam for @constructive-io/sheets.
|
|
47
|
-
*
|
|
48
|
-
* The host app may provide a custom logger via SheetsConfig.logger. The provider
|
|
49
|
-
* installs it into this module singleton (see sheets-provider.tsx), so any module
|
|
50
|
-
* or hook can log without threading the logger through props/context.
|
|
51
|
-
*
|
|
52
|
-
* Default behaviour matches the prior console.* calls. `debug` is omitted from the
|
|
53
|
-
* default logger (no-op) so verbose diagnostics stay silent unless a host opts in.
|
|
54
|
-
*/
|
|
55
|
-
interface SheetsLogger {
|
|
56
|
-
debug?(msg: string, ctx?: unknown): void;
|
|
57
|
-
warn(msg: string, ctx?: unknown): void;
|
|
58
|
-
error(msg: string, ctx?: unknown): void;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** Smallest render-column descriptor a cell view needs now. Overridable. */
|
|
62
|
-
interface CellColumnDescriptor {
|
|
63
|
-
key: string;
|
|
64
|
-
name: string;
|
|
65
|
-
cellType: CellType;
|
|
66
|
-
}
|
|
67
|
-
/** Props every native cell view receives. Minimal and overridable. */
|
|
68
|
-
interface CellProps {
|
|
69
|
-
cell: SheetsCell;
|
|
70
|
-
value: unknown;
|
|
71
|
-
colKey: string;
|
|
72
|
-
rowId: string;
|
|
73
|
-
rowIndex: number;
|
|
74
|
-
column: CellColumnDescriptor;
|
|
75
|
-
isEditing: boolean;
|
|
76
|
-
onStartEdit: () => void;
|
|
77
|
-
disabled: boolean;
|
|
78
|
-
readOnlyReason?: string;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** Schema-only inputs used to DETECT a cell type. Never the runtime value. */
|
|
82
|
-
interface CellTypeMatchInput {
|
|
83
|
-
gqlType: string;
|
|
84
|
-
isArray: boolean;
|
|
85
|
-
pgAlias?: string | null;
|
|
86
|
-
pgType?: string | null;
|
|
87
|
-
subtype?: string | null;
|
|
88
|
-
fieldName?: string;
|
|
89
|
-
}
|
|
90
|
-
/** Context handed to `toSheetsCell` so a definition can build the neutral cell.
|
|
91
|
-
* Geometry uses the built-in fallback, so no `createGeometry` callback is needed. */
|
|
92
|
-
interface SheetsCellRenderContext {
|
|
93
|
-
metadata: CellCreationMetadata;
|
|
94
|
-
}
|
|
95
|
-
interface CellTypeDefinition<TValue = unknown> {
|
|
96
|
-
/** Stable key. A def whose typeKey equals a built-in (e.g. 'relation') overrides it. */
|
|
97
|
-
typeKey: string;
|
|
98
|
-
category?: CellCategory;
|
|
99
|
-
/** Toolbar / type-picker icon. */
|
|
100
|
-
icon?: React.ComponentType<{
|
|
101
|
-
size?: number;
|
|
102
|
-
}>;
|
|
103
|
-
defaultWidth?: number;
|
|
104
|
-
supportsInlineEdit?: boolean;
|
|
105
|
-
/** DETECTION (schema-only). Highest-priority match wins; omit for typeKey-only. */
|
|
106
|
-
match?: (meta: CellTypeMatchInput) => boolean;
|
|
107
|
-
/** Native DISPLAY. Build the neutral SheetsCell. Omit to keep the built-in renderer. */
|
|
108
|
-
toSheetsCell?: (value: TValue, ctx: SheetsCellRenderContext) => SheetsCell;
|
|
109
|
-
/** Native cell COMPONENT override (the slot target). Omit to keep the built-in view. */
|
|
110
|
-
cell?: React.ComponentType<CellProps>;
|
|
111
|
-
/** Native EDITOR override (DOM portal overlay). Omit to keep the built-in native editor. */
|
|
112
|
-
editorComponent?: React.ComponentType<EditorProps>;
|
|
113
|
-
/** Value -> display/copy/export string. */
|
|
114
|
-
format?: (value: TValue) => string;
|
|
115
|
-
defaultValue?: () => TValue;
|
|
116
|
-
}
|
|
117
|
-
/** Identity helper that pins the generic — `defineCellType<number>({ ... })`. */
|
|
118
|
-
declare function defineCellType<T = unknown>(def: CellTypeDefinition<T>): CellTypeDefinition<T>;
|
|
119
|
-
/** A named bundle of cell types, registered via `SheetsConfig.plugins`. */
|
|
120
|
-
interface CellTypePlugin {
|
|
121
|
-
name: string;
|
|
122
|
-
cellTypes: CellTypeDefinition<any>[];
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/** The table being operated on, plus all tables (needed for relation-aware AST building). */
|
|
126
|
-
interface AdapterTableContext {
|
|
127
|
-
table: CleanTable;
|
|
128
|
-
allTables: CleanTable[];
|
|
129
|
-
tableName: string;
|
|
130
|
-
}
|
|
131
|
-
/** A normalized list query. `relationFieldMap` is resolved by the hook (it is cache-bound). */
|
|
132
|
-
interface AdapterListQuery {
|
|
133
|
-
where?: unknown;
|
|
134
|
-
orderBy?: Array<{
|
|
135
|
-
field: string;
|
|
136
|
-
direction: 'asc' | 'desc';
|
|
137
|
-
}>;
|
|
138
|
-
limit?: number;
|
|
139
|
-
offset?: number;
|
|
140
|
-
/** Relay cursor for forward pagination (infinite/cursor mode). */
|
|
141
|
-
after?: string;
|
|
142
|
-
fieldSelection?: FieldSelection;
|
|
143
|
-
/** Resolved relation field name map, threaded from the hook's cached resolution. */
|
|
144
|
-
relationFieldMap?: Record<string, string>;
|
|
145
|
-
}
|
|
146
|
-
interface AdapterPageInfo {
|
|
147
|
-
endCursor?: string | null;
|
|
148
|
-
startCursor?: string | null;
|
|
149
|
-
hasNextPage?: boolean;
|
|
150
|
-
hasPreviousPage?: boolean;
|
|
151
|
-
}
|
|
152
|
-
interface AdapterListResult<T = Record<string, unknown>> {
|
|
153
|
-
rows: T[];
|
|
154
|
-
totalCount: number;
|
|
155
|
-
pageInfo?: AdapterPageInfo;
|
|
156
|
-
}
|
|
157
|
-
interface SheetsBackendAdapter {
|
|
158
|
-
/** Introspect the schema. Default adapter validates and runs the July 2026 `_meta` contract. */
|
|
159
|
-
fetchMeta(execute: SheetsExecuteFn): Promise<MetaQuery>;
|
|
160
|
-
/** Read a page of rows, flattening relation connections into arrays. */
|
|
161
|
-
listRows<T = Record<string, unknown>>(ctx: AdapterTableContext, query: AdapterListQuery, execute: SheetsExecuteFn): Promise<AdapterListResult<T>>;
|
|
162
|
-
/** Create a row; resolves to the created row (or null). */
|
|
163
|
-
createRow<T = Record<string, unknown>>(ctx: AdapterTableContext, data: Record<string, unknown>, execute: SheetsExecuteFn, options?: MutationOptions): Promise<T | null>;
|
|
164
|
-
/** Update a row by id (or composite PK object); resolves to the updated row (or null). */
|
|
165
|
-
updateRow<T = Record<string, unknown>>(ctx: AdapterTableContext, id: string | number | Record<string, unknown>, patch: Record<string, unknown>, execute: SheetsExecuteFn, options?: MutationOptions): Promise<T | null>;
|
|
166
|
-
/** Delete a row by id (or composite PK object). */
|
|
167
|
-
deleteRow(ctx: AdapterTableContext, id: string | number | Record<string, unknown>, execute: SheetsExecuteFn, options?: MutationOptions): Promise<void>;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
interface SheetsAuthEmbedded {
|
|
171
|
-
mode: 'embedded';
|
|
172
|
-
getToken: () => string | null;
|
|
173
|
-
/**
|
|
174
|
-
* Stable, non-secret identity used to isolate cached data between users.
|
|
175
|
-
* Hosts should return the authenticated user/session id, never the token.
|
|
176
|
-
* When omitted, the provider uses an opaque key that changes with the token.
|
|
177
|
-
*/
|
|
178
|
-
getIdentityKey?: () => string | null;
|
|
179
|
-
}
|
|
180
|
-
interface SheetsAuthStandalone {
|
|
181
|
-
mode: 'standalone';
|
|
182
|
-
}
|
|
183
|
-
interface SheetsStorageTransport {
|
|
184
|
-
endpoint: string;
|
|
185
|
-
execute: SheetsExecuteFn;
|
|
186
|
-
}
|
|
187
|
-
interface SheetsConfig {
|
|
188
|
-
/** Data endpoint (app-public GraphQL) */
|
|
189
|
-
endpoint: string;
|
|
190
|
-
/** Auth endpoint (auth GraphQL) — required for standalone mode */
|
|
191
|
-
authEndpoint?: string;
|
|
192
|
-
/** Database ID for multi-tenant scoping */
|
|
193
|
-
databaseId?: string;
|
|
194
|
-
/** Auth mode */
|
|
195
|
-
auth: SheetsAuthEmbedded | SheetsAuthStandalone;
|
|
196
|
-
/** Field type overrides (replaces schema-builder smart tags) */
|
|
197
|
-
fieldTypeOverrides?: Record<string, string>;
|
|
198
|
-
/** Optional: BCP-47 locale for locale-aware date/number formatting (default 'en-US'). */
|
|
199
|
-
locale?: string;
|
|
200
|
-
/** Optional: inject custom execute function */
|
|
201
|
-
execute?: SheetsExecuteFn;
|
|
202
|
-
/** Optional: inject custom upload function */
|
|
203
|
-
executeUpload?: SheetsUploadFn;
|
|
204
|
-
/** Storage endpoint for media uploads and download URL lookups. */
|
|
205
|
-
storage?: {
|
|
206
|
-
endpoint: string;
|
|
207
|
-
execute?: SheetsExecuteFn;
|
|
208
|
-
};
|
|
209
|
-
/** Explicit bucket override. Omit to use the tenant's public default. */
|
|
210
|
-
upload?: {
|
|
211
|
-
bucketKey?: string;
|
|
212
|
-
};
|
|
213
|
-
/** Optional: inject existing QueryClient */
|
|
214
|
-
queryClient?: QueryClient;
|
|
215
|
-
/** Optional: inject a custom backend adapter. Defaults to the PostGraphile adapter. */
|
|
216
|
-
adapter?: SheetsBackendAdapter;
|
|
217
|
-
/** Optional: provider-level cell-type plugins (consumer override layer). */
|
|
218
|
-
plugins?: CellTypePlugin[];
|
|
219
|
-
/** Called on 401/UNAUTHENTICATED before the error is thrown. Host app handles token cleanup. */
|
|
220
|
-
onAuthError?: () => void;
|
|
221
|
-
/** Optional: inject a custom logger. Installed into the module logger singleton by the provider. */
|
|
222
|
-
logger?: SheetsLogger;
|
|
223
|
-
/** Optional: called when a grid/editor/mutation/upload error surfaces. Host app handles reporting. */
|
|
224
|
-
onError?: (error: unknown, ctx?: {
|
|
225
|
-
source?: 'grid' | 'editor' | 'mutation' | 'upload';
|
|
226
|
-
tableName?: string;
|
|
227
|
-
}) => void;
|
|
228
|
-
}
|
|
229
|
-
interface SheetsContextValue {
|
|
230
|
-
config: SheetsConfig;
|
|
231
|
-
execute: SheetsExecuteFn;
|
|
232
|
-
executeUpload: SheetsUploadFn;
|
|
233
|
-
storage?: SheetsStorageTransport;
|
|
234
|
-
canUpload: boolean;
|
|
235
|
-
scopeKey: SheetsScopeKey;
|
|
236
|
-
}
|
|
237
|
-
interface SheetsScopeKey {
|
|
238
|
-
databaseId: string | null;
|
|
239
|
-
endpoint: string;
|
|
240
|
-
identityKey: string | null;
|
|
241
|
-
}
|
|
242
|
-
declare const SheetsContext: react.Context<SheetsContextValue | null>;
|
|
243
|
-
declare function useSheetsContext(): SheetsContextValue;
|
|
244
|
-
|
|
245
|
-
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 SheetsFileValue as g, type SheetsBackendAdapter as h, type AdapterListResult as i, type AdapterPageInfo as j, type AdapterTableContext as k, type CellColumnDescriptor as l, type CellTypePlugin as m, type SheetsAuthEmbedded as n, type SheetsAuthStandalone as o, SheetsContext as p, type SheetsContextValue as q, type SheetsLogger as r, type SheetsUploadResult as s, createSheetsExecute as t, createSheetsUpload as u, defineCellType as v, useSheetsContext as w };
|
|
File without changes
|