@columnus/shared 0.1.49 → 0.1.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clipboardTransfer.js.map +1 -1
- package/dist/csv.js +26 -1
- package/dist/csv.js.map +1 -1
- package/dist/dateValues.d.ts +3 -0
- package/dist/dateValues.js +23 -1
- package/dist/dateValues.js.map +1 -1
- package/dist/displayLabel.js +26 -1
- package/dist/displayLabel.js.map +1 -1
- package/dist/importMatch.js +26 -1
- package/dist/importMatch.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +221 -43
- package/dist/index.js.map +1 -1
- package/dist/recordTableColumns.d.ts +3 -1
- package/dist/recordTableColumns.js +202 -2
- package/dist/recordTableColumns.js.map +1 -1
- package/dist/recordTablePreload.d.ts +19 -0
- package/dist/recordTablePreload.js +4330 -0
- package/dist/recordTablePreload.js.map +1 -0
- package/dist/refDisplayRequests.js.map +1 -1
- package/dist/richDoc.d.ts +10 -0
- package/dist/richDoc.js +65 -2
- package/dist/richDoc.js.map +1 -1
- package/dist/schemaTypes.js.map +1 -1
- package/dist/shareProposal.js.map +1 -1
- package/dist/spaceBundle.js.map +1 -1
- package/dist/storageFieldValues.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Field, type Table } from "./schemaTypes.ts";
|
|
1
|
+
import { type Field, type FieldType, type Table } from "./schemaTypes.ts";
|
|
2
2
|
import type { Query } from "./queryTypes.ts";
|
|
3
3
|
export type RecordTableDisplayValueMap = Map<string, {
|
|
4
4
|
id?: string;
|
|
@@ -19,3 +19,5 @@ export declare function collectQueryRefIds(table: Table, query: Query | null): M
|
|
|
19
19
|
export declare function collectFilterRefIds(table: Table, query: Query | null): Map<string, Set<string>>;
|
|
20
20
|
export declare function formatFilterEqDisplayValue(field: Field | undefined, value: unknown, displayByTable: Map<string, RecordTableDisplayValueMap>): string;
|
|
21
21
|
export declare function formatRecordTableQuerySummary(table: Table, query: Query | null, displayByTable: Map<string, RecordTableDisplayValueMap>): string;
|
|
22
|
+
/** Public record-table cell text: unwrap BlockNote, format dates, never dump JSON/epochs. */
|
|
23
|
+
export declare function formatRecordTableCellText(value: unknown, type: FieldType, locale?: string): string;
|
|
@@ -4,6 +4,30 @@ var __export = (target, all) => {
|
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
+
// packages/@columnus/shared/src/dateValues.ts
|
|
8
|
+
function formatNumericDate(ms, locale, preset = "date") {
|
|
9
|
+
if (preset === "time") {
|
|
10
|
+
return new Intl.DateTimeFormat(locale, {
|
|
11
|
+
hour: "2-digit",
|
|
12
|
+
minute: "2-digit"
|
|
13
|
+
}).format(new Date(ms));
|
|
14
|
+
}
|
|
15
|
+
if (preset === "datetime") {
|
|
16
|
+
return new Intl.DateTimeFormat(locale, {
|
|
17
|
+
day: "2-digit",
|
|
18
|
+
month: "2-digit",
|
|
19
|
+
year: "numeric",
|
|
20
|
+
hour: "2-digit",
|
|
21
|
+
minute: "2-digit"
|
|
22
|
+
}).format(new Date(ms));
|
|
23
|
+
}
|
|
24
|
+
return new Intl.DateTimeFormat(locale, {
|
|
25
|
+
day: "2-digit",
|
|
26
|
+
month: "2-digit",
|
|
27
|
+
year: "numeric"
|
|
28
|
+
}).format(new Date(ms));
|
|
29
|
+
}
|
|
30
|
+
|
|
7
31
|
// node_modules/zod/v3/external.js
|
|
8
32
|
var external_exports = {};
|
|
9
33
|
__export(external_exports, {
|
|
@@ -4119,7 +4143,7 @@ var querySearchSchema = external_exports.object({
|
|
|
4119
4143
|
index: external_exports.string().min(1),
|
|
4120
4144
|
query: external_exports.string()
|
|
4121
4145
|
});
|
|
4122
|
-
external_exports.object({
|
|
4146
|
+
var querySchema = external_exports.object({
|
|
4123
4147
|
predicates: external_exports.array(predicateSchema).optional(),
|
|
4124
4148
|
order: queryOrderSchema.optional(),
|
|
4125
4149
|
search: querySearchSchema.optional(),
|
|
@@ -4146,6 +4170,33 @@ external_exports.object({
|
|
|
4146
4170
|
scanned: external_exports.number().int().nonnegative().optional(),
|
|
4147
4171
|
truncated: external_exports.boolean().optional()
|
|
4148
4172
|
});
|
|
4173
|
+
function parseQuery(input) {
|
|
4174
|
+
const parsed = querySchema.safeParse(input);
|
|
4175
|
+
if (!parsed.success) {
|
|
4176
|
+
return {
|
|
4177
|
+
ok: false,
|
|
4178
|
+
error: {
|
|
4179
|
+
code: "query_invalid",
|
|
4180
|
+
message: parsed.error.issues.map((i) => i.message).join("; ") || "Invalid query"
|
|
4181
|
+
}
|
|
4182
|
+
};
|
|
4183
|
+
}
|
|
4184
|
+
return { ok: true, query: parsed.data };
|
|
4185
|
+
}
|
|
4186
|
+
function parseQueryJson(raw) {
|
|
4187
|
+
try {
|
|
4188
|
+
const parsed = parseQuery(JSON.parse(raw));
|
|
4189
|
+
return parsed.ok ? parsed.query : null;
|
|
4190
|
+
} catch {
|
|
4191
|
+
return null;
|
|
4192
|
+
}
|
|
4193
|
+
}
|
|
4194
|
+
|
|
4195
|
+
// packages/@columnus/shared/src/queryStudio.ts
|
|
4196
|
+
function isEmptyQuery(query) {
|
|
4197
|
+
if (!query) return true;
|
|
4198
|
+
return (query.predicates?.length ?? 0) === 0 && !query.order && !query.search && !query.indexHint && query.maxScan === void 0 && query.vector === void 0;
|
|
4199
|
+
}
|
|
4149
4200
|
|
|
4150
4201
|
// packages/@columnus/shared/src/richDoc.ts
|
|
4151
4202
|
var RICH_DOC_FORMAT = "blocknote";
|
|
@@ -4164,11 +4215,110 @@ function emptyParagraphBlock() {
|
|
|
4164
4215
|
children: []
|
|
4165
4216
|
};
|
|
4166
4217
|
}
|
|
4218
|
+
function parseRecordTableQueryJson(filterJson) {
|
|
4219
|
+
if (!filterJson.trim()) return null;
|
|
4220
|
+
try {
|
|
4221
|
+
const query = parseQueryJson(filterJson);
|
|
4222
|
+
return !query || isEmptyQuery(query) ? null : query;
|
|
4223
|
+
} catch {
|
|
4224
|
+
return null;
|
|
4225
|
+
}
|
|
4226
|
+
}
|
|
4227
|
+
function isBlockNoteEnvelope(parsed) {
|
|
4228
|
+
const p = parsed;
|
|
4229
|
+
return parsed !== null && typeof parsed === "object" && p.format === RICH_DOC_FORMAT && p.version === RICH_DOC_VERSION && Array.isArray(p.blocks);
|
|
4230
|
+
}
|
|
4167
4231
|
JSON.stringify({
|
|
4168
4232
|
format: RICH_DOC_FORMAT,
|
|
4169
4233
|
version: RICH_DOC_VERSION,
|
|
4170
4234
|
blocks: [emptyParagraphBlock()]
|
|
4171
4235
|
});
|
|
4236
|
+
function parseRichDocBlocks(value) {
|
|
4237
|
+
if (typeof value !== "string" || value === "") {
|
|
4238
|
+
return [emptyParagraphBlock()];
|
|
4239
|
+
}
|
|
4240
|
+
try {
|
|
4241
|
+
const parsed = JSON.parse(value);
|
|
4242
|
+
if (isBlockNoteEnvelope(parsed)) {
|
|
4243
|
+
return parsed.blocks.length > 0 ? parsed.blocks : [emptyParagraphBlock()];
|
|
4244
|
+
}
|
|
4245
|
+
} catch {
|
|
4246
|
+
}
|
|
4247
|
+
return [emptyParagraphBlock()];
|
|
4248
|
+
}
|
|
4249
|
+
function visitInlineContent(content, visit) {
|
|
4250
|
+
for (const item of content) {
|
|
4251
|
+
if (!item || typeof item !== "object") continue;
|
|
4252
|
+
const node = item;
|
|
4253
|
+
if (node.type === "text" && typeof node.text === "string") {
|
|
4254
|
+
visit.text?.(node.text);
|
|
4255
|
+
} else if (node.type === "recordLink") {
|
|
4256
|
+
const props = node.props;
|
|
4257
|
+
if (props) visit.recordLink?.(props);
|
|
4258
|
+
} else if (node.type === "link" && Array.isArray(node.content)) {
|
|
4259
|
+
visit.link?.(node.content);
|
|
4260
|
+
}
|
|
4261
|
+
}
|
|
4262
|
+
}
|
|
4263
|
+
function walkInlineContent(content, parts) {
|
|
4264
|
+
visitInlineContent(content, {
|
|
4265
|
+
text: (t) => parts.push(t),
|
|
4266
|
+
recordLink: (props) => parts.push(props.table ? `[${props.table}]` : "[Record]"),
|
|
4267
|
+
link: (nested) => walkInlineContent(nested, parts)
|
|
4268
|
+
});
|
|
4269
|
+
}
|
|
4270
|
+
function walkTableCell(cell, parts) {
|
|
4271
|
+
if (Array.isArray(cell)) {
|
|
4272
|
+
walkInlineContent(cell, parts);
|
|
4273
|
+
return;
|
|
4274
|
+
}
|
|
4275
|
+
if (cell && typeof cell === "object") {
|
|
4276
|
+
const node = cell;
|
|
4277
|
+
if (node.type === "tableCell" && Array.isArray(node.content)) {
|
|
4278
|
+
walkInlineContent(node.content, parts);
|
|
4279
|
+
}
|
|
4280
|
+
}
|
|
4281
|
+
}
|
|
4282
|
+
function walkTableContent(content, parts) {
|
|
4283
|
+
if (!content || typeof content !== "object" || Array.isArray(content)) return;
|
|
4284
|
+
const rows = content.rows ?? [];
|
|
4285
|
+
for (const row of rows) {
|
|
4286
|
+
for (const cell of row.cells ?? []) {
|
|
4287
|
+
const before = parts.length;
|
|
4288
|
+
walkTableCell(cell, parts);
|
|
4289
|
+
if (parts.length > before) parts.push(" ");
|
|
4290
|
+
}
|
|
4291
|
+
}
|
|
4292
|
+
}
|
|
4293
|
+
function walkBlocks(blocks, parts) {
|
|
4294
|
+
for (const block of blocks) {
|
|
4295
|
+
if (block.type === "recordTable") {
|
|
4296
|
+
const props = block.props ?? {};
|
|
4297
|
+
const table = String(props.table ?? "");
|
|
4298
|
+
const filter = parseRecordTableQueryJson(String(props.filterJson ?? ""));
|
|
4299
|
+
if (table) {
|
|
4300
|
+
const suffix = filter ? " (filtered)" : "";
|
|
4301
|
+
parts.push(`[${table} table${suffix}]`);
|
|
4302
|
+
} else {
|
|
4303
|
+
parts.push("[data table]");
|
|
4304
|
+
}
|
|
4305
|
+
parts.push(" ");
|
|
4306
|
+
} else if (block.type === "table") {
|
|
4307
|
+
walkTableContent(block.content, parts);
|
|
4308
|
+
} else if (Array.isArray(block.content)) {
|
|
4309
|
+
walkInlineContent(block.content, parts);
|
|
4310
|
+
parts.push(" ");
|
|
4311
|
+
}
|
|
4312
|
+
if (block.children?.length) walkBlocks(block.children, parts);
|
|
4313
|
+
}
|
|
4314
|
+
}
|
|
4315
|
+
function extractPlainText(value, maxLength) {
|
|
4316
|
+
const blocks = parseRichDocBlocks(value);
|
|
4317
|
+
const parts = [];
|
|
4318
|
+
walkBlocks(blocks, parts);
|
|
4319
|
+
const text = parts.join("").replace(/\s+/g, " ").trim();
|
|
4320
|
+
return text;
|
|
4321
|
+
}
|
|
4172
4322
|
|
|
4173
4323
|
// packages/@columnus/shared/src/displayLabel.ts
|
|
4174
4324
|
function formatIdShort(id, n = 6) {
|
|
@@ -4463,7 +4613,57 @@ function formatRecordTableQuerySummary(table, query, displayByTable) {
|
|
|
4463
4613
|
}
|
|
4464
4614
|
return parts.join(" \xB7 ") || "All records";
|
|
4465
4615
|
}
|
|
4616
|
+
function plainCellText(value) {
|
|
4617
|
+
if (typeof value !== "string") return String(value);
|
|
4618
|
+
return extractPlainText(value) || value;
|
|
4619
|
+
}
|
|
4620
|
+
function formatRecordTableCellText(value, type, locale) {
|
|
4621
|
+
if (value === void 0 || value === null || value === "") return "";
|
|
4622
|
+
switch (type.kind) {
|
|
4623
|
+
case "boolean":
|
|
4624
|
+
return value ? "true" : "false";
|
|
4625
|
+
case "number":
|
|
4626
|
+
case "bigint":
|
|
4627
|
+
return String(value);
|
|
4628
|
+
case "string":
|
|
4629
|
+
case "markdown":
|
|
4630
|
+
case "literal":
|
|
4631
|
+
return plainCellText(value);
|
|
4632
|
+
case "date": {
|
|
4633
|
+
const ms = typeof value === "number" ? value : Number(value);
|
|
4634
|
+
if (!Number.isFinite(ms)) return String(value);
|
|
4635
|
+
return formatNumericDate(ms, locale, "date");
|
|
4636
|
+
}
|
|
4637
|
+
case "datetime": {
|
|
4638
|
+
const ms = typeof value === "number" ? value : Number(value);
|
|
4639
|
+
if (!Number.isFinite(ms)) return String(value);
|
|
4640
|
+
return formatNumericDate(ms, locale, "datetime");
|
|
4641
|
+
}
|
|
4642
|
+
case "id":
|
|
4643
|
+
return typeof value === "string" ? value : String(value);
|
|
4644
|
+
case "array":
|
|
4645
|
+
return Array.isArray(value) ? `[${value.length}]` : String(value);
|
|
4646
|
+
case "null":
|
|
4647
|
+
return "";
|
|
4648
|
+
case "object":
|
|
4649
|
+
case "file":
|
|
4650
|
+
case "image":
|
|
4651
|
+
case "bytes":
|
|
4652
|
+
case "any":
|
|
4653
|
+
case "union":
|
|
4654
|
+
if (typeof value === "string") return plainCellText(value);
|
|
4655
|
+
try {
|
|
4656
|
+
return JSON.stringify(value);
|
|
4657
|
+
} catch {
|
|
4658
|
+
return String(value);
|
|
4659
|
+
}
|
|
4660
|
+
default: {
|
|
4661
|
+
const _exhaustive = type;
|
|
4662
|
+
return _exhaustive;
|
|
4663
|
+
}
|
|
4664
|
+
}
|
|
4665
|
+
}
|
|
4466
4666
|
|
|
4467
|
-
export { RECORD_TABLE_DEFAULT_FIELD_COUNT, collectFilterRefIds, collectQueryRefIds, defaultRecordTableFieldNames, discretionaryRecordTableFieldNames, formatFilterEqDisplayValue, formatRecordTableQuerySummary, parseRecordTableFieldsJson, queryPredicateFieldNames, resolveRecordTableVisibleFields, stringifyRecordTableFields };
|
|
4667
|
+
export { RECORD_TABLE_DEFAULT_FIELD_COUNT, collectFilterRefIds, collectQueryRefIds, defaultRecordTableFieldNames, discretionaryRecordTableFieldNames, formatFilterEqDisplayValue, formatRecordTableCellText, formatRecordTableQuerySummary, parseRecordTableFieldsJson, queryPredicateFieldNames, resolveRecordTableVisibleFields, stringifyRecordTableFields };
|
|
4468
4668
|
//# sourceMappingURL=recordTableColumns.js.map
|
|
4469
4669
|
//# sourceMappingURL=recordTableColumns.js.map
|