@ai-matrx/records 0.92.1 → 0.93.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/CHANGELOG.md +43 -0
- package/README.md +4 -4
- package/dist/{client-Dzd8gtAo.d.ts → client-DsPuWFp0.d.ts} +8 -8
- package/dist/{client-Cn3odIIB.d.cts → client-EyD3rS0T.d.cts} +8 -8
- package/dist/core/index.cjs +101 -32
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +16 -15
- package/dist/core/index.d.ts +16 -15
- package/dist/core/index.js +101 -32
- package/dist/core/index.js.map +1 -1
- package/dist/data/index.cjs +46 -24
- package/dist/data/index.cjs.map +1 -1
- package/dist/data/index.d.cts +11 -11
- package/dist/data/index.d.ts +11 -11
- package/dist/data/index.js +46 -24
- package/dist/data/index.js.map +1 -1
- package/dist/{declareTable-CrL6AZKB.d.cts → declareTable-Bkk_Ewib.d.cts} +4 -4
- package/dist/{declareTable-ZRW5EsTQ.d.ts → declareTable-kL5qZoTe.d.ts} +4 -4
- package/dist/entity/index.cjs +43 -29
- package/dist/entity/index.cjs.map +1 -1
- package/dist/entity/index.d.cts +7 -6
- package/dist/entity/index.d.ts +7 -6
- package/dist/entity/index.js +43 -29
- package/dist/entity/index.js.map +1 -1
- package/dist/entity/react.cjs +43 -29
- package/dist/entity/react.cjs.map +1 -1
- package/dist/entity/react.js +43 -29
- package/dist/entity/react.js.map +1 -1
- package/dist/{field-CCY1rG9l.d.cts → field-6rwt4ejZ.d.cts} +1 -1
- package/dist/{field-enufS5ry.d.ts → field-B-WaVZnS.d.ts} +1 -1
- package/dist/forms/index.d.cts +3 -3
- package/dist/forms/index.d.ts +3 -3
- package/dist/index.cjs +92 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -33
- package/dist/index.d.ts +13 -33
- package/dist/index.js +92 -25
- package/dist/index.js.map +1 -1
- package/dist/memory/index.d.cts +7 -7
- package/dist/memory/index.d.ts +7 -7
- package/dist/objectOrganization-BII_K3Gm.d.ts +45 -0
- package/dist/objectOrganization-DfjDQtDb.d.cts +45 -0
- package/dist/{port-C54ykAOv.d.ts → port--acgmxh5.d.ts} +5 -2
- package/dist/{port-Drioh9al.d.cts → port-Cx76dq-X.d.cts} +5 -2
- package/dist/{portal-DRdmZ-xv.d.cts → portal-9sRr6cpG.d.cts} +1 -1
- package/dist/{portal-or_f7BkT.d.ts → portal-BDAqsGkg.d.ts} +1 -1
- package/dist/{ports-s0D2jvqn.d.cts → ports-9BQ3zo2y.d.cts} +108 -2
- package/dist/{ports-BeOgjwYl.d.ts → ports-DYWE1ENo.d.ts} +108 -2
- package/dist/react/index.cjs +101 -32
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1463 -1363
- package/dist/react/index.d.ts +1463 -1363
- package/dist/react/index.js +101 -32
- package/dist/react/index.js.map +1 -1
- package/dist/realtime/index.cjs +43 -13
- package/dist/realtime/index.cjs.map +1 -1
- package/dist/realtime/index.d.cts +9 -3
- package/dist/realtime/index.d.ts +9 -3
- package/dist/realtime/index.js +43 -13
- package/dist/realtime/index.js.map +1 -1
- package/dist/{record-BwCf9wKW.d.cts → record-DmmeuUrC.d.cts} +1 -1
- package/dist/{record-BwCf9wKW.d.ts → record-DmmeuUrC.d.ts} +1 -1
- package/dist/{relation-eLMgv_dV.d.ts → relation-Op1M67le.d.ts} +2 -2
- package/dist/{relation-8vAWCa67.d.cts → relation-qrb2NbHf.d.cts} +2 -2
- package/dist/{rule-wHI5B0Ka.d.cts → rule-CeHg1sy1.d.cts} +1 -1
- package/dist/{rule-D9yNiorf.d.ts → rule-tN2lxvJ1.d.ts} +1 -1
- package/dist/search/index.d.cts +1 -1
- package/dist/search/index.d.ts +1 -1
- package/dist/setup/index.cjs +117 -42
- package/dist/setup/index.cjs.map +1 -1
- package/dist/setup/index.d.cts +25 -11
- package/dist/setup/index.d.ts +25 -11
- package/dist/setup/index.js +117 -42
- package/dist/setup/index.js.map +1 -1
- package/dist/{subscription-CdoI-UaB.d.cts → subscription-Drbxn-9Z.d.cts} +3 -3
- package/dist/{subscription-BynsG1K6.d.ts → subscription-hdTaRrfK.d.ts} +3 -3
- package/dist/{table-kind-i3lZJa3f.d.ts → table-kind-BZkvzBgc.d.ts} +4 -29
- package/dist/{table-kind-DzctQ7dO.d.cts → table-kind-C-hZxDN7.d.cts} +4 -29
- package/dist/templates/index.d.cts +10 -10
- package/dist/templates/index.d.ts +10 -10
- package/dist/typed-table/index.cjs +46 -24
- package/dist/typed-table/index.cjs.map +1 -1
- package/dist/typed-table/index.d.cts +10 -10
- package/dist/typed-table/index.d.ts +10 -10
- package/dist/typed-table/index.js +46 -24
- package/dist/typed-table/index.js.map +1 -1
- package/dist/{types-BvL_oKFl.d.ts → types-BauAeFW8.d.ts} +2 -2
- package/dist/{types-DAFP6XFe.d.cts → types-CBmUdBT0.d.cts} +2 -2
- package/dist/{types-BKYEeFt4.d.cts → types-Dek9owBe.d.cts} +2 -2
- package/dist/{types-D8qdG3Lg.d.cts → types-DsgXrESm.d.cts} +2 -2
- package/dist/{types-cpKY7Pjb.d.ts → types-HVgWcZDY.d.ts} +2 -2
- package/dist/{types-DYzXhD7j.d.ts → types-hrw-Eff1.d.ts} +2 -2
- package/dist/use-cases/index.d.cts +5 -5
- package/dist/use-cases/index.d.ts +5 -5
- package/dist/{validate-DfNMxjmU.d.cts → validate-B_iUeyh2.d.cts} +1 -1
- package/dist/{validate-DbvAParj.d.ts → validate-w-HGGTf-.d.ts} +1 -1
- package/dist/views/index.cjs +438 -0
- package/dist/views/index.cjs.map +1 -0
- package/dist/views/index.d.cts +401 -0
- package/dist/views/index.d.ts +401 -0
- package/dist/views/index.js +415 -0
- package/dist/views/index.js.map +1 -0
- package/package.json +12 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { F as FieldTypeWord, a as FieldRule } from './field-
|
|
1
|
+
import { T as TableType, b as TableDisplay, S as StorageMode, F as FieldSource, C as ComputeOn, c as FieldSensitivity, d as ContextPolicy, e as RelationFlavor, f as RelationCardinality, O as OnDelete } from './record-DmmeuUrC.js';
|
|
2
|
+
import { F as FieldTypeWord, a as FieldRule } from './field-B-WaVZnS.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Who the data belongs to. A test organization is created under this name — the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { F as FieldTypeWord, a as FieldRule } from './field-
|
|
1
|
+
import { T as TableType, b as TableDisplay, S as StorageMode, F as FieldSource, C as ComputeOn, c as FieldSensitivity, d as ContextPolicy, e as RelationFlavor, f as RelationCardinality, O as OnDelete } from './record-DmmeuUrC.cjs';
|
|
2
|
+
import { F as FieldTypeWord, a as FieldRule } from './field-6rwt4ejZ.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Who the data belongs to. A test organization is created under this name — the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as EntityRefWithWords } from './relation-
|
|
2
|
-
import { U as Uuid, R as RecordsResult } from './record-
|
|
1
|
+
import { E as EntityRefWithWords } from './relation-qrb2NbHf.cjs';
|
|
2
|
+
import { U as Uuid, R as RecordsResult } from './record-DmmeuUrC.cjs';
|
|
3
3
|
|
|
4
4
|
/** §0. A link to any thing: `{token, id, label}`. A custom row's token is `record`. Every link reads as `EntityRef[]`. */
|
|
5
5
|
type EntityRef = EntityRefWithWords;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AggregateOperation, a as AggregateFilter, D as DashboardBlockKind, b as AggregateMeasure, c as AggregateBucket, S as SubscriptionCadence } from './subscription-
|
|
2
|
-
import { U as UseCase, a as UseCaseTable, b as UseCaseField, c as UseCaseRow, d as UseCaseForm, e as UseCaseFormField, f as UseCaseNotificationTrigger, N as NotificationChannel, g as UseCaseProvenance } from './types-
|
|
1
|
+
import { A as AggregateOperation, a as AggregateFilter, D as DashboardBlockKind, b as AggregateMeasure, c as AggregateBucket, S as SubscriptionCadence } from './subscription-Drbxn-9Z.cjs';
|
|
2
|
+
import { U as UseCase, a as UseCaseTable, b as UseCaseField, c as UseCaseRow, d as UseCaseForm, e as UseCaseFormField, f as UseCaseNotificationTrigger, N as NotificationChannel, g as UseCaseProvenance } from './types-CBmUdBT0.cjs';
|
|
3
3
|
|
|
4
4
|
declare const TABLE_KERNEL_ID = "11111111-0000-4000-8000-000000000001";
|
|
5
5
|
type ConfidentialLevel = "viewer" | "commenter" | "editor";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as EntityRefWithWords } from './relation-
|
|
2
|
-
import { U as Uuid, R as RecordsResult } from './record-
|
|
1
|
+
import { E as EntityRefWithWords } from './relation-Op1M67le.js';
|
|
2
|
+
import { U as Uuid, R as RecordsResult } from './record-DmmeuUrC.js';
|
|
3
3
|
|
|
4
4
|
/** §0. A link to any thing: `{token, id, label}`. A custom row's token is `record`. Every link reads as `EntityRef[]`. */
|
|
5
5
|
type EntityRef = EntityRefWithWords;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AggregateOperation, a as AggregateFilter, D as DashboardBlockKind, b as AggregateMeasure, c as AggregateBucket, S as SubscriptionCadence } from './subscription-
|
|
2
|
-
import { U as UseCase, a as UseCaseTable, b as UseCaseField, c as UseCaseRow, d as UseCaseForm, e as UseCaseFormField, f as UseCaseNotificationTrigger, N as NotificationChannel, g as UseCaseProvenance } from './types-
|
|
1
|
+
import { A as AggregateOperation, a as AggregateFilter, D as DashboardBlockKind, b as AggregateMeasure, c as AggregateBucket, S as SubscriptionCadence } from './subscription-hdTaRrfK.js';
|
|
2
|
+
import { U as UseCase, a as UseCaseTable, b as UseCaseField, c as UseCaseRow, d as UseCaseForm, e as UseCaseFormField, f as UseCaseNotificationTrigger, N as NotificationChannel, g as UseCaseProvenance } from './types-BauAeFW8.js';
|
|
3
3
|
|
|
4
4
|
declare const TABLE_KERNEL_ID = "11111111-0000-4000-8000-000000000001";
|
|
5
5
|
type ConfidentialLevel = "viewer" | "commenter" | "editor";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { U as UseCase, h as UseCaseSummary } from '../types-
|
|
2
|
-
export { B as BusinessIdentity, F as FormAudience, N as NotificationChannel, P as PostalAddress, i as UseCaseDashboardQuestion, j as UseCaseDocumentTemplate, b as UseCaseField, d as UseCaseForm, e as UseCaseFormField, k as UseCaseMergeField, l as UseCaseNotificationRule, f as UseCaseNotificationTrigger, m as UseCasePipeline, n as UseCasePipelineStage, g as UseCaseProvenance, o as UseCaseRelationship, c as UseCaseRow, a as UseCaseTable } from '../types-
|
|
3
|
-
export { M as MIN_ROWS_IN_PRIMARY_TABLE, R as RESOLVABLE_FIELD_TYPE_WORDS, U as UseCaseProblem, a as UseCaseVerdict, b as assertUseCase, v as validateUseCase } from '../validate-
|
|
4
|
-
import '../record-
|
|
5
|
-
import '../field-
|
|
1
|
+
import { U as UseCase, h as UseCaseSummary } from '../types-CBmUdBT0.cjs';
|
|
2
|
+
export { B as BusinessIdentity, F as FormAudience, N as NotificationChannel, P as PostalAddress, i as UseCaseDashboardQuestion, j as UseCaseDocumentTemplate, b as UseCaseField, d as UseCaseForm, e as UseCaseFormField, k as UseCaseMergeField, l as UseCaseNotificationRule, f as UseCaseNotificationTrigger, m as UseCasePipeline, n as UseCasePipelineStage, g as UseCaseProvenance, o as UseCaseRelationship, c as UseCaseRow, a as UseCaseTable } from '../types-CBmUdBT0.cjs';
|
|
3
|
+
export { M as MIN_ROWS_IN_PRIMARY_TABLE, R as RESOLVABLE_FIELD_TYPE_WORDS, U as UseCaseProblem, a as UseCaseVerdict, b as assertUseCase, v as validateUseCase } from '../validate-B_iUeyh2.cjs';
|
|
4
|
+
import '../record-DmmeuUrC.cjs';
|
|
5
|
+
import '../field-6rwt4ejZ.cjs';
|
|
6
6
|
|
|
7
7
|
/** One banned pattern, with the reason and what to do instead. */
|
|
8
8
|
interface PlaceholderPattern {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { U as UseCase, h as UseCaseSummary } from '../types-
|
|
2
|
-
export { B as BusinessIdentity, F as FormAudience, N as NotificationChannel, P as PostalAddress, i as UseCaseDashboardQuestion, j as UseCaseDocumentTemplate, b as UseCaseField, d as UseCaseForm, e as UseCaseFormField, k as UseCaseMergeField, l as UseCaseNotificationRule, f as UseCaseNotificationTrigger, m as UseCasePipeline, n as UseCasePipelineStage, g as UseCaseProvenance, o as UseCaseRelationship, c as UseCaseRow, a as UseCaseTable } from '../types-
|
|
3
|
-
export { M as MIN_ROWS_IN_PRIMARY_TABLE, R as RESOLVABLE_FIELD_TYPE_WORDS, U as UseCaseProblem, a as UseCaseVerdict, b as assertUseCase, v as validateUseCase } from '../validate-
|
|
4
|
-
import '../record-
|
|
5
|
-
import '../field-
|
|
1
|
+
import { U as UseCase, h as UseCaseSummary } from '../types-BauAeFW8.js';
|
|
2
|
+
export { B as BusinessIdentity, F as FormAudience, N as NotificationChannel, P as PostalAddress, i as UseCaseDashboardQuestion, j as UseCaseDocumentTemplate, b as UseCaseField, d as UseCaseForm, e as UseCaseFormField, k as UseCaseMergeField, l as UseCaseNotificationRule, f as UseCaseNotificationTrigger, m as UseCasePipeline, n as UseCasePipelineStage, g as UseCaseProvenance, o as UseCaseRelationship, c as UseCaseRow, a as UseCaseTable } from '../types-BauAeFW8.js';
|
|
3
|
+
export { M as MIN_ROWS_IN_PRIMARY_TABLE, R as RESOLVABLE_FIELD_TYPE_WORDS, U as UseCaseProblem, a as UseCaseVerdict, b as assertUseCase, v as validateUseCase } from '../validate-w-HGGTf-.js';
|
|
4
|
+
import '../record-DmmeuUrC.js';
|
|
5
|
+
import '../field-B-WaVZnS.js';
|
|
6
6
|
|
|
7
7
|
/** One banned pattern, with the reason and what to do instead. */
|
|
8
8
|
interface PlaceholderPattern {
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/views/index.ts
|
|
21
|
+
var views_exports = {};
|
|
22
|
+
__export(views_exports, {
|
|
23
|
+
LAYOUT_FIELD_KIND: () => LAYOUT_FIELD_KIND,
|
|
24
|
+
LAYOUT_LABEL: () => LAYOUT_LABEL,
|
|
25
|
+
PAGE_VIEWS: () => PAGE_VIEWS,
|
|
26
|
+
PAGE_VIEW_LABEL: () => PAGE_VIEW_LABEL,
|
|
27
|
+
STORE_KEEPS_TIMELINE: () => STORE_KEEPS_TIMELINE,
|
|
28
|
+
STORE_KEPT_LAYOUTS: () => STORE_KEPT_LAYOUTS,
|
|
29
|
+
VIEW_KEYS: () => VIEW_KEYS,
|
|
30
|
+
VIEW_LAYOUTS: () => VIEW_LAYOUTS,
|
|
31
|
+
VIEW_NEEDS: () => VIEW_NEEDS,
|
|
32
|
+
declareView: () => declareView,
|
|
33
|
+
defaultViewOf: () => defaultViewOf,
|
|
34
|
+
designateView: () => designateView,
|
|
35
|
+
freeColumnName: () => freeColumnName,
|
|
36
|
+
makeDefaultLabel: () => makeDefaultLabel,
|
|
37
|
+
pageViewFromParam: () => pageViewFromParam,
|
|
38
|
+
plainPresentation: () => plainPresentation,
|
|
39
|
+
saveViewPatch: () => saveViewPatch,
|
|
40
|
+
storeKeepsLayout: () => storeKeepsLayout,
|
|
41
|
+
unknownViewLine: () => unknownViewLine,
|
|
42
|
+
viewDocument: () => viewDocument,
|
|
43
|
+
viewFromRow: () => viewFromRow,
|
|
44
|
+
viewKeysFor: () => viewKeysFor,
|
|
45
|
+
viewOrderOf: () => viewOrderOf,
|
|
46
|
+
viewPatchDocument: () => viewPatchDocument,
|
|
47
|
+
viewPatchFor: () => viewPatchFor,
|
|
48
|
+
viewSettings: () => viewSettings,
|
|
49
|
+
viewSettingsFor: () => viewSettingsFor,
|
|
50
|
+
viewSettingsPatch: () => viewSettingsPatch,
|
|
51
|
+
wordsList: () => wordsList
|
|
52
|
+
});
|
|
53
|
+
module.exports = __toCommonJS(views_exports);
|
|
54
|
+
|
|
55
|
+
// src/views/keys.ts
|
|
56
|
+
var plainPresentation = {
|
|
57
|
+
parse: (raw) => raw && typeof raw === "object" && !Array.isArray(raw) ? { ...raw } : {},
|
|
58
|
+
isEmpty: (presentation) => Object.keys(presentation).length === 0,
|
|
59
|
+
toDocument: (presentation) => ({ ...presentation })
|
|
60
|
+
};
|
|
61
|
+
function plainCodec() {
|
|
62
|
+
return plainPresentation;
|
|
63
|
+
}
|
|
64
|
+
var STORE_KEEPS_TIMELINE = true;
|
|
65
|
+
var ALL = ["grid", "kanban", "calendar", "gallery", ...STORE_KEEPS_TIMELINE ? ["timeline"] : [], "list"];
|
|
66
|
+
var HIDES = ["grid", "gallery", "kanban", "calendar", ...STORE_KEEPS_TIMELINE ? ["timeline"] : [], "list"];
|
|
67
|
+
var GRIDS = ["grid"];
|
|
68
|
+
var VIEW_KEYS = [
|
|
69
|
+
{ path: "layout", shape: "kind", layouts: ALL, writer: "caller" },
|
|
70
|
+
{ path: "filters", shape: "filter", layouts: ALL, writer: "caller" },
|
|
71
|
+
{ path: "where", shape: "rule", layouts: ALL, writer: "caller" },
|
|
72
|
+
{ path: "group_field", shape: "field", layouts: ["kanban", ...STORE_KEEPS_TIMELINE ? ["timeline"] : []], writer: "caller" },
|
|
73
|
+
{ path: "swimlane_field", shape: "field:lane", layouts: ["kanban"], writer: "caller" },
|
|
74
|
+
{ path: "collapsed_columns", shape: "values", layouts: ["kanban"], writer: "caller" },
|
|
75
|
+
{ path: "measure", shape: "field:number", layouts: ["kanban"], writer: "caller" },
|
|
76
|
+
{ path: "date_field", shape: "field:date", layouts: ["calendar"], writer: "caller" },
|
|
77
|
+
...STORE_KEEPS_TIMELINE ? [
|
|
78
|
+
{ path: "start_field", shape: "field:date", layouts: ["timeline"], writer: "caller" },
|
|
79
|
+
{ path: "end_field", shape: "field:date", layouts: ["calendar", "timeline"], writer: "caller" }
|
|
80
|
+
] : [],
|
|
81
|
+
{ path: "image_field", shape: "field", layouts: ["gallery"], writer: "caller" },
|
|
82
|
+
{ path: "sorts", shape: "sorts", layouts: ALL, writer: "caller" },
|
|
83
|
+
{ path: "rule_id", shape: "uuid", layouts: ALL, writer: "caller" },
|
|
84
|
+
{ path: "is_default", shape: "boolean", layouts: ALL, writer: "caller" },
|
|
85
|
+
{ path: "presentation", shape: "presentation", layouts: ALL, writer: "caller" },
|
|
86
|
+
{ path: "presentation.style", shape: "style", layouts: ALL, writer: "caller" },
|
|
87
|
+
{ path: "presentation.formats", shape: "object", layouts: GRIDS, writer: "caller" },
|
|
88
|
+
{ path: "presentation.frozen", shape: "fields", layouts: GRIDS, writer: "caller" },
|
|
89
|
+
{ path: "presentation.grouping", shape: "grouping", layouts: ["grid", "gallery", "list"], writer: "caller" },
|
|
90
|
+
{ path: "presentation.widths", shape: "widths", layouts: GRIDS, writer: "caller" },
|
|
91
|
+
{ path: "presentation.rowHeight", shape: "row_height", layouts: GRIDS, writer: "caller" },
|
|
92
|
+
{ path: "presentation.hiddenFields", shape: "fields", layouts: HIDES, writer: "caller" },
|
|
93
|
+
{ path: "presentation.cardHidden", shape: "fields", layouts: ["kanban", "calendar", ...STORE_KEEPS_TIMELINE ? ["timeline"] : [], "list", "gallery"], writer: "caller" },
|
|
94
|
+
{ path: "presentation.columnOrder", shape: "fields", layouts: GRIDS, writer: "caller" },
|
|
95
|
+
{ path: "presentation.gallerySize", shape: "gallery_size", layouts: ["gallery"], writer: "caller" },
|
|
96
|
+
{ path: "presentation.wrap", shape: "boolean", layouts: GRIDS, writer: "caller" },
|
|
97
|
+
{ path: "presentation.wrapColumns", shape: "fields", layouts: GRIDS, writer: "caller" },
|
|
98
|
+
{ path: "presentation.fit", shape: "fit", layouts: GRIDS, writer: "caller" },
|
|
99
|
+
{ path: "presentation.freezeFirst", shape: "boolean", layouts: GRIDS, writer: "caller" },
|
|
100
|
+
{ path: "presentation.footer", shape: "footer", layouts: GRIDS, writer: "caller" },
|
|
101
|
+
{ path: "presentation.summaries", shape: "summaries", layouts: GRIDS, writer: "caller" },
|
|
102
|
+
{ path: "grid", shape: "grid", layouts: GRIDS, writer: "caller" },
|
|
103
|
+
{ path: "hidden_fields", shape: "input", layouts: HIDES, writer: "input" },
|
|
104
|
+
{ path: "table_id", shape: "server", layouts: ALL, writer: "server" },
|
|
105
|
+
{ path: "order", shape: "server", layouts: GRIDS, writer: "server" },
|
|
106
|
+
{ path: "moved_from", shape: "server", layouts: ALL, writer: "server" }
|
|
107
|
+
];
|
|
108
|
+
var STORE_KEPT_LAYOUTS = ["grid", "kanban", "calendar", "gallery", ...STORE_KEEPS_TIMELINE ? ["timeline"] : [], "list"];
|
|
109
|
+
function storeKeepsLayout(layout) {
|
|
110
|
+
return STORE_KEPT_LAYOUTS.includes(layout);
|
|
111
|
+
}
|
|
112
|
+
function viewKeysFor(layout) {
|
|
113
|
+
return VIEW_KEYS.filter((k) => k.layouts.includes(layout)).map((k) => k.path);
|
|
114
|
+
}
|
|
115
|
+
var KINDS = STORE_KEPT_LAYOUTS;
|
|
116
|
+
function viewSettings(definition, rowFilters, codec = plainCodec()) {
|
|
117
|
+
const data = definition ?? {};
|
|
118
|
+
const text = (key) => {
|
|
119
|
+
const v = data[key];
|
|
120
|
+
return typeof v === "string" && v !== "" ? v : null;
|
|
121
|
+
};
|
|
122
|
+
const layout = String(data["layout"] ?? "grid");
|
|
123
|
+
const flat = rowFilters ?? (isObject(data["filters"]) ? data["filters"] : null);
|
|
124
|
+
const moved = data["moved_from"];
|
|
125
|
+
return {
|
|
126
|
+
layout: KINDS.includes(layout) ? layout : "grid",
|
|
127
|
+
filters: flat && Object.keys(flat).length > 0 ? flat : null,
|
|
128
|
+
where: isRule(data["where"]) ? data["where"] : null,
|
|
129
|
+
groupField: text("group_field"),
|
|
130
|
+
swimlaneField: text("swimlane_field"),
|
|
131
|
+
collapsedColumns: Array.isArray(data["collapsed_columns"]) ? data["collapsed_columns"].filter((v) => ["string", "number", "boolean"].includes(typeof v)).map(String) : [],
|
|
132
|
+
measure: text("measure"),
|
|
133
|
+
dateField: text("date_field"),
|
|
134
|
+
startField: text("start_field"),
|
|
135
|
+
endField: text("end_field"),
|
|
136
|
+
imageField: text("image_field"),
|
|
137
|
+
sorts: parseSorts(data["sorts"]),
|
|
138
|
+
ruleId: text("rule_id"),
|
|
139
|
+
isDefault: data["is_default"] === true || data["is_default"] === "true",
|
|
140
|
+
presentation: codec.parse(data["presentation"]),
|
|
141
|
+
movedFrom: isObject(moved) ? moved : null
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function viewSettingsFor(settings, layout) {
|
|
145
|
+
const reads = new Set(viewKeysFor(layout));
|
|
146
|
+
const out = { layout: settings.layout };
|
|
147
|
+
const take = (key, path) => {
|
|
148
|
+
if (reads.has(path)) out[key] = settings[key];
|
|
149
|
+
};
|
|
150
|
+
take("filters", "filters");
|
|
151
|
+
take("where", "where");
|
|
152
|
+
take("groupField", "group_field");
|
|
153
|
+
take("swimlaneField", "swimlane_field");
|
|
154
|
+
take("collapsedColumns", "collapsed_columns");
|
|
155
|
+
take("measure", "measure");
|
|
156
|
+
take("dateField", "date_field");
|
|
157
|
+
take("startField", "start_field");
|
|
158
|
+
take("endField", "end_field");
|
|
159
|
+
take("imageField", "image_field");
|
|
160
|
+
take("sorts", "sorts");
|
|
161
|
+
take("ruleId", "rule_id");
|
|
162
|
+
take("isDefault", "is_default");
|
|
163
|
+
const p = settings.presentation;
|
|
164
|
+
const look = {};
|
|
165
|
+
for (const [key, value] of Object.entries(p)) {
|
|
166
|
+
if (reads.has(`presentation.${key}`)) look[key] = value;
|
|
167
|
+
}
|
|
168
|
+
out.presentation = look;
|
|
169
|
+
return out;
|
|
170
|
+
}
|
|
171
|
+
function viewSettingsPatch(patch, codec = plainCodec()) {
|
|
172
|
+
const out = {};
|
|
173
|
+
const field = (key, path) => {
|
|
174
|
+
if (patch[key] !== void 0) out[path] = patch[key] || null;
|
|
175
|
+
};
|
|
176
|
+
if (patch.layout !== void 0 && storeKeepsLayout(patch.layout)) out["layout"] = patch.layout;
|
|
177
|
+
field("groupField", "group_field");
|
|
178
|
+
field("swimlaneField", "swimlane_field");
|
|
179
|
+
field("measure", "measure");
|
|
180
|
+
field("dateField", "date_field");
|
|
181
|
+
if (STORE_KEEPS_TIMELINE) {
|
|
182
|
+
field("startField", "start_field");
|
|
183
|
+
field("endField", "end_field");
|
|
184
|
+
}
|
|
185
|
+
field("imageField", "image_field");
|
|
186
|
+
field("ruleId", "rule_id");
|
|
187
|
+
if (patch.collapsedColumns !== void 0) out["collapsed_columns"] = patch.collapsedColumns ?? [];
|
|
188
|
+
if (patch.sorts !== void 0) out["sorts"] = patch.sorts ?? [];
|
|
189
|
+
if (patch.where !== void 0) out["where"] = patch.where ?? null;
|
|
190
|
+
if (patch.isDefault !== void 0) out["is_default"] = patch.isDefault === true;
|
|
191
|
+
if (patch.presentation !== void 0) {
|
|
192
|
+
out["presentation"] = !patch.presentation || codec.isEmpty(patch.presentation) ? null : codec.toDocument(patch.presentation);
|
|
193
|
+
}
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
196
|
+
function isObject(raw) {
|
|
197
|
+
return Boolean(raw) && typeof raw === "object" && !Array.isArray(raw);
|
|
198
|
+
}
|
|
199
|
+
function isRule(raw) {
|
|
200
|
+
if (!isObject(raw)) return false;
|
|
201
|
+
const node = raw;
|
|
202
|
+
return typeof node.op === "string" && Array.isArray(node.args);
|
|
203
|
+
}
|
|
204
|
+
function parseSorts(raw) {
|
|
205
|
+
let list = raw;
|
|
206
|
+
if (typeof raw === "string") {
|
|
207
|
+
try {
|
|
208
|
+
list = raw.trim() === "" ? [] : JSON.parse(raw);
|
|
209
|
+
} catch {
|
|
210
|
+
return [];
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (!Array.isArray(list)) return [];
|
|
214
|
+
return list.filter((s) => isObject(s) && typeof s.field === "string").map((s) => ({ field: s.field, direction: s.direction === "desc" ? "desc" : "asc" }));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// src/views/views.ts
|
|
218
|
+
function plainCodec2() {
|
|
219
|
+
return plainPresentation;
|
|
220
|
+
}
|
|
221
|
+
var VIEW_LAYOUTS = ["grid", "kanban", "calendar", "gallery", "timeline", "list"];
|
|
222
|
+
var LAYOUT_LABEL = {
|
|
223
|
+
grid: "Grid",
|
|
224
|
+
kanban: "Kanban",
|
|
225
|
+
calendar: "Calendar",
|
|
226
|
+
gallery: "Gallery",
|
|
227
|
+
timeline: "Timeline",
|
|
228
|
+
list: "List"
|
|
229
|
+
};
|
|
230
|
+
function wordsList(words) {
|
|
231
|
+
const clean = words.map((w) => w.trim()).filter((w) => w !== "");
|
|
232
|
+
if (clean.length <= 1) return clean.join("");
|
|
233
|
+
return `${clean.slice(0, -1).join(", ")} and ${clean[clean.length - 1]}`;
|
|
234
|
+
}
|
|
235
|
+
var VIEW_NEEDS = {
|
|
236
|
+
grid: null,
|
|
237
|
+
// A list reads nothing a table can lack: rows, titled, grouped only when the person chooses.
|
|
238
|
+
list: null,
|
|
239
|
+
kanban: {
|
|
240
|
+
kind: "choice",
|
|
241
|
+
viewKey: "groupField",
|
|
242
|
+
blocking: true,
|
|
243
|
+
starter: { label: "Status", type: "select", options: ["To do", "In progress", "Done"] },
|
|
244
|
+
pick: "Pick the choice column the board's columns come from.",
|
|
245
|
+
missing: "This table has no choice column to make the board's columns from.",
|
|
246
|
+
does: (label) => `Make it work adds a ${label} column with the choices below and groups the board by it.`,
|
|
247
|
+
ask: (label, options) => `Add a choice column called ${label} to this table${options.length > 0 ? ` with the choices ${wordsList(options)}` : ""}, then group the Kanban board by it.`
|
|
248
|
+
},
|
|
249
|
+
calendar: {
|
|
250
|
+
kind: "date",
|
|
251
|
+
viewKey: "dateField",
|
|
252
|
+
blocking: true,
|
|
253
|
+
starter: { label: "Date", type: "datetime" },
|
|
254
|
+
pick: "Pick the date column the calendar places records by.",
|
|
255
|
+
missing: "This table has no date column to place records on.",
|
|
256
|
+
does: (label) => `Make it work adds a ${label} column and lays the calendar out by it.`,
|
|
257
|
+
ask: (label) => `Add a date column called ${label} to this table, then lay the Calendar out by it.`
|
|
258
|
+
},
|
|
259
|
+
gallery: {
|
|
260
|
+
kind: "file",
|
|
261
|
+
viewKey: "imageField",
|
|
262
|
+
blocking: false,
|
|
263
|
+
starter: { label: "Photo", type: "attachment" },
|
|
264
|
+
pick: "Pick the file column each card shows as its picture.",
|
|
265
|
+
missing: "The cards have no picture because this table has no file column.",
|
|
266
|
+
does: (label) => `Make it work adds a ${label} column and shows it on each card.`,
|
|
267
|
+
ask: (label) => `Add a file column called ${label} to this table, then show it as the picture on each Gallery card.`
|
|
268
|
+
},
|
|
269
|
+
timeline: {
|
|
270
|
+
kind: "date",
|
|
271
|
+
viewKey: "dateField",
|
|
272
|
+
blocking: true,
|
|
273
|
+
starter: { label: "Start", type: "datetime" },
|
|
274
|
+
pick: "Pick the date column each bar starts on.",
|
|
275
|
+
missing: "This table has no date column to place records on.",
|
|
276
|
+
does: (label) => `Make it work adds a ${label} column and lays the timeline out by it.`,
|
|
277
|
+
ask: (label) => `Add a date column called ${label} to this table, then lay the Timeline out by it.`
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
function freeColumnName(wanted, taken) {
|
|
281
|
+
const held = new Set(taken.map((t) => t.trim().toLowerCase()));
|
|
282
|
+
const base = wanted.trim() === "" ? "Column" : wanted.trim();
|
|
283
|
+
if (!held.has(base.toLowerCase())) return base;
|
|
284
|
+
for (let n = 2; n < 100; n += 1) {
|
|
285
|
+
const next = `${base} ${n}`;
|
|
286
|
+
if (!held.has(next.toLowerCase())) return next;
|
|
287
|
+
}
|
|
288
|
+
return base;
|
|
289
|
+
}
|
|
290
|
+
function viewOrderOf(definition) {
|
|
291
|
+
const raw = definition?.["order"];
|
|
292
|
+
return raw === "manual" ? "manual" : raw === "sorted" ? "sorted" : null;
|
|
293
|
+
}
|
|
294
|
+
function defaultViewOf(views) {
|
|
295
|
+
return views.find((v) => v.isDefault);
|
|
296
|
+
}
|
|
297
|
+
var LAYOUT_FIELD_KIND = {
|
|
298
|
+
grid: null,
|
|
299
|
+
kanban: "choice",
|
|
300
|
+
calendar: "date",
|
|
301
|
+
gallery: "file",
|
|
302
|
+
timeline: "date",
|
|
303
|
+
list: null
|
|
304
|
+
};
|
|
305
|
+
var PAGE_VIEWS = [...VIEW_LAYOUTS, "dashboards", "archived"];
|
|
306
|
+
var PAGE_VIEW_LABEL = {
|
|
307
|
+
...LAYOUT_LABEL,
|
|
308
|
+
dashboards: "Dashboards",
|
|
309
|
+
archived: "Archived"
|
|
310
|
+
};
|
|
311
|
+
var PAGE_VIEW_SPELLINGS = {
|
|
312
|
+
grid: "grid",
|
|
313
|
+
table: "grid",
|
|
314
|
+
rows: "grid",
|
|
315
|
+
list: "list",
|
|
316
|
+
kanban: "kanban",
|
|
317
|
+
board: "kanban",
|
|
318
|
+
pipeline: "kanban",
|
|
319
|
+
calendar: "calendar",
|
|
320
|
+
month: "calendar",
|
|
321
|
+
schedule: "calendar",
|
|
322
|
+
gallery: "gallery",
|
|
323
|
+
cards: "gallery",
|
|
324
|
+
timeline: "timeline",
|
|
325
|
+
gantt: "timeline",
|
|
326
|
+
dashboards: "dashboards",
|
|
327
|
+
dashboard: "dashboards",
|
|
328
|
+
charts: "dashboards",
|
|
329
|
+
archived: "archived",
|
|
330
|
+
archive: "archived",
|
|
331
|
+
// The grid's row action says "Delete" and the store soft-deletes, so the word
|
|
332
|
+
// a person types is as likely to be the one the button used as the one this
|
|
333
|
+
// view is called. Both land in the same place; neither dies.
|
|
334
|
+
deleted: "archived",
|
|
335
|
+
trash: "archived",
|
|
336
|
+
removed: "archived"
|
|
337
|
+
};
|
|
338
|
+
function pageViewFromParam(raw) {
|
|
339
|
+
if (typeof raw !== "string") return null;
|
|
340
|
+
const token = raw.trim().toLowerCase();
|
|
341
|
+
if (token === "") return null;
|
|
342
|
+
return PAGE_VIEW_SPELLINGS[token] ?? null;
|
|
343
|
+
}
|
|
344
|
+
function unknownViewLine(raw) {
|
|
345
|
+
return `The link asked for a view called \u201C${raw}\u201D, which this table has no view for, so you are looking at ${PAGE_VIEW_LABEL.grid}. The views this table has are ${PAGE_VIEWS.map((v) => PAGE_VIEW_LABEL[v]).join(", ")} \u2014 pick one above and the address follows it.`;
|
|
346
|
+
}
|
|
347
|
+
function viewDocument(spec, codec = plainCodec2()) {
|
|
348
|
+
const out = {
|
|
349
|
+
// A layout the store does not keep yet is not sent: the view is saved as a grid (`STORE_KEPT_LAYOUTS`).
|
|
350
|
+
layout: storeKeepsLayout(spec.layout) ? spec.layout : "grid",
|
|
351
|
+
sorts: spec.sorts ?? [],
|
|
352
|
+
is_default: spec.isDefault === true
|
|
353
|
+
};
|
|
354
|
+
if (spec.groupField) out["group_field"] = spec.groupField;
|
|
355
|
+
if (spec.swimlaneField) out["swimlane_field"] = spec.swimlaneField;
|
|
356
|
+
if (spec.collapsedColumns && spec.collapsedColumns.length > 0) out["collapsed_columns"] = spec.collapsedColumns;
|
|
357
|
+
if (spec.measure) out["measure"] = spec.measure;
|
|
358
|
+
if (spec.dateField) out["date_field"] = spec.dateField;
|
|
359
|
+
if (STORE_KEEPS_TIMELINE && spec.startField) out["start_field"] = spec.startField;
|
|
360
|
+
if (STORE_KEEPS_TIMELINE && spec.endField) out["end_field"] = spec.endField;
|
|
361
|
+
if (spec.imageField) out["image_field"] = spec.imageField;
|
|
362
|
+
if (spec.ruleId) out["rule_id"] = spec.ruleId;
|
|
363
|
+
if (spec.where) out["where"] = spec.where;
|
|
364
|
+
if (spec.presentation && !codec.isEmpty(spec.presentation)) {
|
|
365
|
+
out["presentation"] = codec.toDocument(spec.presentation);
|
|
366
|
+
}
|
|
367
|
+
return out;
|
|
368
|
+
}
|
|
369
|
+
function viewFromRow(row, codec = plainCodec2()) {
|
|
370
|
+
const data = row.definition ?? {};
|
|
371
|
+
const k = viewSettings(data, row.filters && Object.keys(row.filters).length > 0 ? row.filters : null, codec);
|
|
372
|
+
const tableFromDefinition = typeof data["table_id"] === "string" && data["table_id"] !== "" ? data["table_id"] : null;
|
|
373
|
+
return {
|
|
374
|
+
id: row.view_id,
|
|
375
|
+
name: row.name || "Untitled view",
|
|
376
|
+
subject: row.table_id ?? tableFromDefinition ?? "",
|
|
377
|
+
layout: k.layout,
|
|
378
|
+
groupField: k.groupField,
|
|
379
|
+
swimlaneField: k.swimlaneField,
|
|
380
|
+
collapsedColumns: k.collapsedColumns,
|
|
381
|
+
measure: k.measure,
|
|
382
|
+
dateField: k.dateField,
|
|
383
|
+
startField: k.startField,
|
|
384
|
+
endField: k.endField,
|
|
385
|
+
imageField: k.imageField,
|
|
386
|
+
sorts: k.sorts,
|
|
387
|
+
order: viewOrderOf(data),
|
|
388
|
+
ruleId: k.ruleId,
|
|
389
|
+
...k.filters ? { filters: k.filters } : {},
|
|
390
|
+
where: k.where,
|
|
391
|
+
// The older table's own default view, carried in by the mover, IS this table's default —
|
|
392
|
+
// the mover wrote the row's column, which `custom.views` does not return. Read as anything
|
|
393
|
+
// else, the page would seed a second "All records" beside it and open on that.
|
|
394
|
+
isDefault: k.isDefault || k.movedFrom?.["kind"] === "default_view",
|
|
395
|
+
presentation: k.presentation,
|
|
396
|
+
movedFrom: k.movedFrom
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
async function declareView(client, spec, codec = plainCodec2()) {
|
|
400
|
+
return client.viewDeclare({
|
|
401
|
+
table_id: spec.subject,
|
|
402
|
+
spec: {
|
|
403
|
+
name: spec.name,
|
|
404
|
+
...spec.filters ? { filters: spec.filters } : {},
|
|
405
|
+
definition: viewDocument(spec, codec)
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
async function saveViewPatch(client, tableId, viewId, patch, codec = plainCodec2()) {
|
|
410
|
+
const definition = viewPatchDocument(patch, codec);
|
|
411
|
+
const renamed = patch.name !== void 0 && patch.name.trim() !== "";
|
|
412
|
+
const refiltered = patch.filters !== void 0;
|
|
413
|
+
return client.viewDeclare({
|
|
414
|
+
table_id: tableId,
|
|
415
|
+
spec: {
|
|
416
|
+
view_id: viewId,
|
|
417
|
+
...renamed ? { name: patch.name.trim() } : {},
|
|
418
|
+
...refiltered ? { filters: patch.filters ?? null } : {},
|
|
419
|
+
definition
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
function viewPatchDocument(patch, codec = plainCodec2()) {
|
|
424
|
+
const { name: _name, subject: _subject, filters: _filters, ...keys } = patch;
|
|
425
|
+
return viewSettingsPatch(keys, codec);
|
|
426
|
+
}
|
|
427
|
+
function viewPatchFor(view, patch) {
|
|
428
|
+
if (!view.isDefault) return patch;
|
|
429
|
+
const { layout: _layout, isDefault: _isDefault, ...kept } = patch;
|
|
430
|
+
return kept;
|
|
431
|
+
}
|
|
432
|
+
function makeDefaultLabel(layoutLabel) {
|
|
433
|
+
return `Make ${layoutLabel} the default`;
|
|
434
|
+
}
|
|
435
|
+
async function designateView(client, tableId, viewId, layout) {
|
|
436
|
+
return client.viewDesignate({ table_id: tableId, view_id: viewId, layout });
|
|
437
|
+
}
|
|
438
|
+
//# sourceMappingURL=index.cjs.map
|