@aglyn/plugins-data 1.13.0 → 1.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/package.json +12 -10
- package/src/lib/artifact/dataset-schema-artifact.server.js +10 -4
- package/src/lib/artifact/dataset-schema-artifact.server.js.map +1 -1
- package/src/lib/components/data-console-page.js +4 -2
- package/src/lib/components/data-console-page.js.map +1 -1
- package/src/lib/components/dataset-record-dialog.component.d.ts +22 -0
- package/src/lib/components/dataset-record-dialog.component.js +77 -54
- package/src/lib/components/dataset-record-dialog.component.js.map +1 -1
- package/src/lib/components/dataset-schema-dialog.component.js +195 -168
- package/src/lib/components/dataset-schema-dialog.component.js.map +1 -1
- package/src/lib/components/host-datasets-card.component.d.ts +12 -0
- package/src/lib/components/host-datasets-card.component.js +652 -221
- package/src/lib/components/host-datasets-card.component.js.map +1 -1
- package/src/lib/components/use-dataset-writes-blocked.d.ts +5 -4
- package/src/lib/components/use-dataset-writes-blocked.js +11 -12
- package/src/lib/components/use-dataset-writes-blocked.js.map +1 -1
- package/src/lib/components/use-org-sites.d.ts +27 -0
- package/src/lib/components/use-org-sites.js +68 -0
- package/src/lib/components/use-org-sites.js.map +1 -0
- package/src/lib/model/data-record-routes.js +6 -3
- package/src/lib/model/data-record-routes.js.map +1 -1
- package/src/lib/model/dataset-model-core.d.ts +22 -0
- package/src/lib/model/dataset-model-core.js +34 -0
- package/src/lib/model/dataset-model-core.js.map +1 -1
- package/src/lib/model/dataset-rail.d.ts +88 -0
- package/src/lib/model/dataset-rail.js +123 -0
- package/src/lib/model/dataset-rail.js.map +1 -0
- package/src/lib/model/dataset-record-list.js +17 -2
- package/src/lib/model/dataset-record-list.js.map +1 -1
- package/src/lib/model/dataset-record.js +8 -3
- package/src/lib/model/dataset-record.js.map +1 -1
- package/src/lib/model/datasets.d.ts +14 -0
- package/src/lib/model/datasets.js +10 -0
- package/src/lib/model/datasets.js.map +1 -1
- package/src/lib/plugin.d.ts +5 -1
- package/src/lib/plugin.js +8 -3
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/record-pages/record-template-section.component.js +12 -1
- package/src/lib/record-pages/record-template-section.component.js.map +1 -1
- package/src/lib/server/api-v1/datasets.js +6 -1
- package/src/lib/server/api-v1/datasets.js.map +1 -1
- package/src/lib/server/dataset-access.server.d.ts +4 -3
- package/src/lib/server/dataset-access.server.js +7 -5
- package/src/lib/server/dataset-access.server.js.map +1 -1
- package/src/lib/server/dataset-drafts.js +2 -0
- package/src/lib/server/dataset-drafts.js.map +1 -1
- package/src/lib/server/dataset-site-erasure.d.ts +2 -2
- package/src/lib/server/dataset-site-erasure.js +4 -26
- package/src/lib/server/dataset-site-erasure.js.map +1 -1
- package/src/lib/server/datasets-route.d.ts +2 -0
- package/src/lib/server/datasets-route.js +125 -19
- package/src/lib/server/datasets-route.js.map +1 -1
- package/src/lib/site-bundle/datasets-site-bundle.server.d.ts +4 -2
- package/src/lib/site-bundle/datasets-site-bundle.server.js +16 -5
- package/src/lib/site-bundle/datasets-site-bundle.server.js.map +1 -1
- package/src/lib/transfer/dataset-transfer-access.server.js +3 -3
- package/src/lib/transfer/dataset-transfer-access.server.js.map +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { type DatasetModel } from './dataset-models';
|
|
18
|
+
import { type HostDataset } from './datasets';
|
|
19
|
+
/**
|
|
20
|
+
* The Data page's rail of datasets (AGL-4047): one tab per dataset, a second
|
|
21
|
+
* line that tells same-named ones apart, a search over the names, and groups
|
|
22
|
+
* by sharing once there are many. Pure, so the card and its specs read the
|
|
23
|
+
* same answers.
|
|
24
|
+
*/
|
|
25
|
+
/** A dataset as the rail reads it: its document, with the facts it shows. */
|
|
26
|
+
export type DatasetRailEntry = HostDataset & {
|
|
27
|
+
$id: string;
|
|
28
|
+
name?: unknown;
|
|
29
|
+
source?: {
|
|
30
|
+
listingId?: unknown;
|
|
31
|
+
version?: unknown;
|
|
32
|
+
} | null;
|
|
33
|
+
createdAt?: unknown;
|
|
34
|
+
scopeMode?: unknown;
|
|
35
|
+
scopeExcept?: unknown;
|
|
36
|
+
};
|
|
37
|
+
/** Past this many datasets the rail groups them by who they are shared with, and offers the Shared with filter. */
|
|
38
|
+
export declare const DATASET_RAIL_GROUP_AT = 10;
|
|
39
|
+
/** `1 field`, `5 fields`. */
|
|
40
|
+
export declare function datasetFieldCount(dataset: DatasetRailEntry): string;
|
|
41
|
+
/** Who a dataset is shared with, named where `hostNames` has the site: `Bakery only`, `All sites`, `3 sites`. */
|
|
42
|
+
export declare function datasetSharingLabel(dataset: DatasetRailEntry, hostNames: Readonly<Record<string, string>>): string;
|
|
43
|
+
/**
|
|
44
|
+
* The tab's second line. Ungrouped it says who the dataset is shared with and
|
|
45
|
+
* how many fields it has, which is what tells the same name on two sites
|
|
46
|
+
* apart: `Bakery only · 5 fields`. In a group, whose heading already says who
|
|
47
|
+
* it is shared with, it names the first fields instead:
|
|
48
|
+
* `5 fields · Name, Description, Duration`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function datasetRailSecondary(dataset: DatasetRailEntry, options: {
|
|
51
|
+
hostNames: Readonly<Record<string, string>>;
|
|
52
|
+
grouped: boolean;
|
|
53
|
+
}): string;
|
|
54
|
+
/** A dataset's name for the rail and the page: its display name, or a stand-in when it has none. */
|
|
55
|
+
export declare function datasetRailName(dataset: DatasetRailEntry): string;
|
|
56
|
+
/** Datasets in name order, then id, so two of one name keep their places. */
|
|
57
|
+
export declare function sortDatasetsByName<T extends DatasetRailEntry>(datasets: readonly T[]): T[];
|
|
58
|
+
/**
|
|
59
|
+
* Whether a dataset's name starts with what was typed, normalized the way the
|
|
60
|
+
* stored `nameLower` is, so the loaded-list search and the query that replaces
|
|
61
|
+
* it answer alike.
|
|
62
|
+
*/
|
|
63
|
+
export declare function datasetNameMatches(dataset: DatasetRailEntry, typed: string): boolean;
|
|
64
|
+
/** One group of the rail: its heading, with how many it holds, and its datasets in name order. */
|
|
65
|
+
export interface DatasetRailGroup {
|
|
66
|
+
label: string;
|
|
67
|
+
datasets: DatasetRailEntry[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The rail's groups by who each dataset is shared with: `Bakery only (6)`.
|
|
71
|
+
* Groups run in heading order, datasets in name order within each.
|
|
72
|
+
*/
|
|
73
|
+
export declare function groupDatasetsBySharing(datasets: readonly DatasetRailEntry[], hostNames: Readonly<Record<string, string>>): DatasetRailGroup[];
|
|
74
|
+
/** Where a dataset came from: the marketplace listing it was installed from, or `--` for one made here. */
|
|
75
|
+
export declare function datasetSourceLabel(dataset: DatasetRailEntry): string;
|
|
76
|
+
/** When a dataset was created, as a date, or `--` where it was never stamped (a site backup restore stamps none). */
|
|
77
|
+
export declare function datasetCreatedLabel(dataset: DatasetRailEntry, locale?: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* A record's own page's heading (AGL-4047): the first field, in the model's
|
|
80
|
+
* order, that shows a value — a reference names an id, so it is passed over —
|
|
81
|
+
* or a stand-in when none does.
|
|
82
|
+
*/
|
|
83
|
+
export declare function datasetRecordTitle(model: DatasetModel, values: Readonly<Record<string, unknown>> | undefined): string;
|
|
84
|
+
/**
|
|
85
|
+
* The picker labels for a list of datasets (AGL-4047), through the pure
|
|
86
|
+
* `datasetPickerLabels`: the name alone unless it collides in the list.
|
|
87
|
+
*/
|
|
88
|
+
export declare function datasetPickerLabelsOf(datasets: readonly DatasetRailEntry[], hostNames?: Readonly<Record<string, string>>): Record<string, string>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { nameSearchKey } from "@aglyn/aglyn/app-utils/name-search";
|
|
17
|
+
import { describeSharing } from "@aglyn/aglyn/app-utils/scope-tokens";
|
|
18
|
+
import { datasetPickerLabels, effectiveDatasetModel, formatDatasetValue } from "./dataset-models.js";
|
|
19
|
+
import { datasetDisplayName } from "./datasets.js";
|
|
20
|
+
/** Past this many datasets the rail groups them by who they are shared with, and offers the Shared with filter. */ export const DATASET_RAIL_GROUP_AT = 10;
|
|
21
|
+
/** How many field names the second line names, in a grouped rail. */ const RAIL_FIELD_NAMES = 3;
|
|
22
|
+
/** `1 field`, `5 fields`. */ export function datasetFieldCount(dataset) {
|
|
23
|
+
const count = effectiveDatasetModel(dataset).order.length;
|
|
24
|
+
return `${count} ${count === 1 ? 'field' : 'fields'}`;
|
|
25
|
+
}
|
|
26
|
+
/** Who a dataset is shared with, named where `hostNames` has the site: `Bakery only`, `All sites`, `3 sites`. */ export function datasetSharingLabel(dataset, hostNames) {
|
|
27
|
+
return describeSharing(dataset, hostNames);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The tab's second line. Ungrouped it says who the dataset is shared with and
|
|
31
|
+
* how many fields it has, which is what tells the same name on two sites
|
|
32
|
+
* apart: `Bakery only · 5 fields`. In a group, whose heading already says who
|
|
33
|
+
* it is shared with, it names the first fields instead:
|
|
34
|
+
* `5 fields · Name, Description, Duration`.
|
|
35
|
+
*/ export function datasetRailSecondary(dataset, options) {
|
|
36
|
+
const fields = datasetFieldCount(dataset);
|
|
37
|
+
if (!options.grouped) return `${datasetSharingLabel(dataset, options.hostNames)} · ${fields}`;
|
|
38
|
+
const model = effectiveDatasetModel(dataset);
|
|
39
|
+
const names = model.order.slice(0, RAIL_FIELD_NAMES).map((id)=>{
|
|
40
|
+
var _ref;
|
|
41
|
+
var _model_fields_id;
|
|
42
|
+
return (_ref = (_model_fields_id = model.fields[id]) == null ? void 0 : _model_fields_id.name) != null ? _ref : id;
|
|
43
|
+
}).filter(Boolean);
|
|
44
|
+
return names.length ? `${fields} · ${names.join(', ')}` : fields;
|
|
45
|
+
}
|
|
46
|
+
/** A dataset's name for the rail and the page: its display name, or a stand-in when it has none. */ export function datasetRailName(dataset) {
|
|
47
|
+
return datasetDisplayName(dataset) || 'Untitled dataset';
|
|
48
|
+
}
|
|
49
|
+
/** Datasets in name order, then id, so two of one name keep their places. */ export function sortDatasetsByName(datasets) {
|
|
50
|
+
return [
|
|
51
|
+
...datasets
|
|
52
|
+
].sort((a, b)=>nameSearchKey(datasetRailName(a)).localeCompare(nameSearchKey(datasetRailName(b))) || a.$id.localeCompare(b.$id));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Whether a dataset's name starts with what was typed, normalized the way the
|
|
56
|
+
* stored `nameLower` is, so the loaded-list search and the query that replaces
|
|
57
|
+
* it answer alike.
|
|
58
|
+
*/ export function datasetNameMatches(dataset, typed) {
|
|
59
|
+
const key = nameSearchKey(typed);
|
|
60
|
+
return !key || nameSearchKey(datasetDisplayName(dataset)).startsWith(key);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The rail's groups by who each dataset is shared with: `Bakery only (6)`.
|
|
64
|
+
* Groups run in heading order, datasets in name order within each.
|
|
65
|
+
*/ export function groupDatasetsBySharing(datasets, hostNames) {
|
|
66
|
+
const groups = new Map();
|
|
67
|
+
for (const dataset of datasets){
|
|
68
|
+
var _groups_get;
|
|
69
|
+
const label = datasetSharingLabel(dataset, hostNames);
|
|
70
|
+
groups.set(label, [
|
|
71
|
+
...(_groups_get = groups.get(label)) != null ? _groups_get : [],
|
|
72
|
+
dataset
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
return [
|
|
76
|
+
...groups.entries()
|
|
77
|
+
].sort(([a], [b])=>a.localeCompare(b)).map(([label, members])=>({
|
|
78
|
+
label: `${label} (${members.length})`,
|
|
79
|
+
datasets: sortDatasetsByName(members)
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
/** Where a dataset came from: the marketplace listing it was installed from, or `--` for one made here. */ export function datasetSourceLabel(dataset) {
|
|
83
|
+
var _dataset_source;
|
|
84
|
+
if (!((_dataset_source = dataset.source) == null ? void 0 : _dataset_source.listingId)) return '--';
|
|
85
|
+
const version = Number(dataset.source.version);
|
|
86
|
+
return Number.isFinite(version) && version > 0 ? `Marketplace, version ${version}` : 'Marketplace';
|
|
87
|
+
}
|
|
88
|
+
/** When a dataset was created, as a date, or `--` where it was never stamped (a site backup restore stamps none). */ export function datasetCreatedLabel(dataset, locale) {
|
|
89
|
+
const at = dataset.createdAt;
|
|
90
|
+
const date = typeof (at == null ? void 0 : at.toDate) === 'function' ? at.toDate() : typeof (at == null ? void 0 : at.seconds) === 'number' ? new Date(at.seconds * 1000) : null;
|
|
91
|
+
if (!date || Number.isNaN(date.getTime())) return '--';
|
|
92
|
+
return date.toLocaleDateString(locale, {
|
|
93
|
+
month: 'short',
|
|
94
|
+
day: 'numeric',
|
|
95
|
+
year: 'numeric'
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A record's own page's heading (AGL-4047): the first field, in the model's
|
|
100
|
+
* order, that shows a value — a reference names an id, so it is passed over —
|
|
101
|
+
* or a stand-in when none does.
|
|
102
|
+
*/ export function datasetRecordTitle(model, values) {
|
|
103
|
+
for (const fieldId of model.order){
|
|
104
|
+
const field = model.fields[fieldId];
|
|
105
|
+
if (!field || field.type === 'reference') continue;
|
|
106
|
+
const shown = formatDatasetValue(field, values == null ? void 0 : values[fieldId]).trim();
|
|
107
|
+
if (shown) return shown;
|
|
108
|
+
}
|
|
109
|
+
return 'Untitled record';
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The picker labels for a list of datasets (AGL-4047), through the pure
|
|
113
|
+
* `datasetPickerLabels`: the name alone unless it collides in the list.
|
|
114
|
+
*/ export function datasetPickerLabelsOf(datasets, hostNames = {}) {
|
|
115
|
+
return datasetPickerLabels(datasets.map((dataset)=>({
|
|
116
|
+
id: dataset.$id,
|
|
117
|
+
name: datasetRailName(dataset),
|
|
118
|
+
sharing: datasetSharingLabel(dataset, hostNames),
|
|
119
|
+
fields: effectiveDatasetModel(dataset).order.length
|
|
120
|
+
})));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
//# sourceMappingURL=dataset-rail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/data/src/lib/model/dataset-rail.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { nameSearchKey } from '@aglyn/aglyn/app-utils/name-search'\nimport { describeSharing } from '@aglyn/aglyn/app-utils/scope-tokens'\nimport { type DatasetModel, datasetPickerLabels, effectiveDatasetModel, formatDatasetValue } from './dataset-models'\nimport { datasetDisplayName, type HostDataset } from './datasets'\n\n/**\n * The Data page's rail of datasets (AGL-4047): one tab per dataset, a second\n * line that tells same-named ones apart, a search over the names, and groups\n * by sharing once there are many. Pure, so the card and its specs read the\n * same answers.\n */\n\n/** A dataset as the rail reads it: its document, with the facts it shows. */\nexport type DatasetRailEntry = HostDataset & {\n $id: string\n name?: unknown\n source?: { listingId?: unknown; version?: unknown } | null\n createdAt?: unknown\n scopeMode?: unknown\n scopeExcept?: unknown\n}\n\n/** Past this many datasets the rail groups them by who they are shared with, and offers the Shared with filter. */\nexport const DATASET_RAIL_GROUP_AT = 10\n\n/** How many field names the second line names, in a grouped rail. */\nconst RAIL_FIELD_NAMES = 3\n\n/** `1 field`, `5 fields`. */\nexport function datasetFieldCount(dataset: DatasetRailEntry): string {\n const count = effectiveDatasetModel(dataset).order.length\n return `${count} ${count === 1 ? 'field' : 'fields'}`\n}\n\n/** Who a dataset is shared with, named where `hostNames` has the site: `Bakery only`, `All sites`, `3 sites`. */\nexport function datasetSharingLabel(\n dataset: DatasetRailEntry,\n hostNames: Readonly<Record<string, string>>,\n): string {\n return describeSharing(dataset as unknown as Readonly<Record<string, unknown>>, hostNames)\n}\n\n/**\n * The tab's second line. Ungrouped it says who the dataset is shared with and\n * how many fields it has, which is what tells the same name on two sites\n * apart: `Bakery only · 5 fields`. In a group, whose heading already says who\n * it is shared with, it names the first fields instead:\n * `5 fields · Name, Description, Duration`.\n */\nexport function datasetRailSecondary(\n dataset: DatasetRailEntry,\n options: { hostNames: Readonly<Record<string, string>>; grouped: boolean },\n): string {\n const fields = datasetFieldCount(dataset)\n if (!options.grouped) return `${datasetSharingLabel(dataset, options.hostNames)} · ${fields}`\n const model = effectiveDatasetModel(dataset)\n const names = model.order\n .slice(0, RAIL_FIELD_NAMES)\n .map((id) => model.fields[id]?.name ?? id)\n .filter(Boolean)\n return names.length ? `${fields} · ${names.join(', ')}` : fields\n}\n\n/** A dataset's name for the rail and the page: its display name, or a stand-in when it has none. */\nexport function datasetRailName(dataset: DatasetRailEntry): string {\n return datasetDisplayName(dataset) || 'Untitled dataset'\n}\n\n/** Datasets in name order, then id, so two of one name keep their places. */\nexport function sortDatasetsByName<T extends DatasetRailEntry>(datasets: readonly T[]): T[] {\n return [...datasets].sort(\n (a, b) =>\n nameSearchKey(datasetRailName(a)).localeCompare(nameSearchKey(datasetRailName(b))) ||\n a.$id.localeCompare(b.$id),\n )\n}\n\n/**\n * Whether a dataset's name starts with what was typed, normalized the way the\n * stored `nameLower` is, so the loaded-list search and the query that replaces\n * it answer alike.\n */\nexport function datasetNameMatches(dataset: DatasetRailEntry, typed: string): boolean {\n const key = nameSearchKey(typed)\n return !key || nameSearchKey(datasetDisplayName(dataset)).startsWith(key)\n}\n\n/** One group of the rail: its heading, with how many it holds, and its datasets in name order. */\nexport interface DatasetRailGroup {\n label: string\n datasets: DatasetRailEntry[]\n}\n\n/**\n * The rail's groups by who each dataset is shared with: `Bakery only (6)`.\n * Groups run in heading order, datasets in name order within each.\n */\nexport function groupDatasetsBySharing(\n datasets: readonly DatasetRailEntry[],\n hostNames: Readonly<Record<string, string>>,\n): DatasetRailGroup[] {\n const groups = new Map<string, DatasetRailEntry[]>()\n for (const dataset of datasets) {\n const label = datasetSharingLabel(dataset, hostNames)\n groups.set(label, [...(groups.get(label) ?? []), dataset])\n }\n return [...groups.entries()]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([label, members]) => ({ label: `${label} (${members.length})`, datasets: sortDatasetsByName(members) }))\n}\n\n/** Where a dataset came from: the marketplace listing it was installed from, or `--` for one made here. */\nexport function datasetSourceLabel(dataset: DatasetRailEntry): string {\n if (!dataset.source?.listingId) return '--'\n const version = Number(dataset.source.version)\n return Number.isFinite(version) && version > 0 ? `Marketplace, version ${version}` : 'Marketplace'\n}\n\n/** When a dataset was created, as a date, or `--` where it was never stamped (a site backup restore stamps none). */\nexport function datasetCreatedLabel(dataset: DatasetRailEntry, locale?: string): string {\n const at = dataset.createdAt as { toDate?: () => Date; seconds?: number } | null | undefined\n const date =\n typeof at?.toDate === 'function'\n ? at.toDate()\n : typeof at?.seconds === 'number'\n ? new Date(at.seconds * 1000)\n : null\n if (!date || Number.isNaN(date.getTime())) return '--'\n return date.toLocaleDateString(locale, { month: 'short', day: 'numeric', year: 'numeric' })\n}\n\n/**\n * A record's own page's heading (AGL-4047): the first field, in the model's\n * order, that shows a value — a reference names an id, so it is passed over —\n * or a stand-in when none does.\n */\nexport function datasetRecordTitle(model: DatasetModel, values: Readonly<Record<string, unknown>> | undefined): string {\n for (const fieldId of model.order) {\n const field = model.fields[fieldId]\n if (!field || field.type === 'reference') continue\n const shown = formatDatasetValue(field, values?.[fieldId]).trim()\n if (shown) return shown\n }\n return 'Untitled record'\n}\n\n/**\n * The picker labels for a list of datasets (AGL-4047), through the pure\n * `datasetPickerLabels`: the name alone unless it collides in the list.\n */\nexport function datasetPickerLabelsOf(\n datasets: readonly DatasetRailEntry[],\n hostNames: Readonly<Record<string, string>> = {},\n): Record<string, string> {\n return datasetPickerLabels(\n datasets.map((dataset) => ({\n id: dataset.$id,\n name: datasetRailName(dataset),\n sharing: datasetSharingLabel(dataset, hostNames),\n fields: effectiveDatasetModel(dataset).order.length,\n })),\n )\n}\n"],"names":["nameSearchKey","describeSharing","datasetPickerLabels","effectiveDatasetModel","formatDatasetValue","datasetDisplayName","DATASET_RAIL_GROUP_AT","RAIL_FIELD_NAMES","datasetFieldCount","dataset","count","order","length","datasetSharingLabel","hostNames","datasetRailSecondary","options","fields","grouped","model","names","slice","map","id","name","filter","Boolean","join","datasetRailName","sortDatasetsByName","datasets","sort","a","b","localeCompare","$id","datasetNameMatches","typed","key","startsWith","groupDatasetsBySharing","groups","Map","label","set","get","entries","members","datasetSourceLabel","source","listingId","version","Number","isFinite","datasetCreatedLabel","locale","at","createdAt","date","toDate","seconds","Date","isNaN","getTime","toLocaleDateString","month","day","year","datasetRecordTitle","values","fieldId","field","type","shown","trim","datasetPickerLabelsOf","sharing"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,aAAa,QAAQ,qCAAoC;AAClE,SAASC,eAAe,QAAQ,sCAAqC;AACrE,SAA4BC,mBAAmB,EAAEC,qBAAqB,EAAEC,kBAAkB,QAAQ,sBAAkB;AACpH,SAASC,kBAAkB,QAA0B,gBAAY;AAmBjE,iHAAiH,GACjH,OAAO,MAAMC,wBAAwB,GAAE;AAEvC,mEAAmE,GACnE,MAAMC,mBAAmB;AAEzB,2BAA2B,GAC3B,OAAO,SAASC,kBAAkBC,OAAyB;IACzD,MAAMC,QAAQP,sBAAsBM,SAASE,KAAK,CAACC,MAAM;IACzD,OAAO,GAAGF,MAAM,CAAC,EAAEA,UAAU,IAAI,UAAU,UAAU;AACvD;AAEA,+GAA+G,GAC/G,OAAO,SAASG,oBACdJ,OAAyB,EACzBK,SAA2C;IAE3C,OAAOb,gBAAgBQ,SAAyDK;AAClF;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,qBACdN,OAAyB,EACzBO,OAA0E;IAE1E,MAAMC,SAAST,kBAAkBC;IACjC,IAAI,CAACO,QAAQE,OAAO,EAAE,OAAO,GAAGL,oBAAoBJ,SAASO,QAAQF,SAAS,EAAE,GAAG,EAAEG,QAAQ;IAC7F,MAAME,QAAQhB,sBAAsBM;IACpC,MAAMW,QAAQD,MAAMR,KAAK,CACtBU,KAAK,CAAC,GAAGd,kBACTe,GAAG,CAAC,CAACC;;YAAOJ;wBAAAA,mBAAAA,MAAMF,MAAM,CAACM,GAAG,qBAAhBJ,iBAAkBK,IAAI,mBAAID;OACtCE,MAAM,CAACC;IACV,OAAON,MAAMR,MAAM,GAAG,GAAGK,OAAO,GAAG,EAAEG,MAAMO,IAAI,CAAC,OAAO,GAAGV;AAC5D;AAEA,kGAA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ITIONS OF ANY KIND, either express or implied.
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
|
-
*/ import { scopeTokensForHost } from "@aglyn/aglyn/app-utils/scope-tokens";
|
|
16
|
+
*/ import { describeSharing, scopeTokensForHost } from "@aglyn/aglyn/app-utils/scope-tokens";
|
|
17
17
|
import { registerPluginRecordListSource } from "@aglyn/aglyn/plugin-manager/plugin-record-lists";
|
|
18
18
|
import { collection, documentId, limit, orderBy, query, where } from "firebase/firestore";
|
|
19
19
|
import { BUNDLE_ID } from "../constants/bundle-common.js";
|
|
20
20
|
import { datasetIndexedRecord } from "./dataset-record.js";
|
|
21
|
+
import { datasetPickerLabels } from "./dataset-model-core.js";
|
|
21
22
|
/**
|
|
22
23
|
* The `visibleTo` tokens a list of datasets asks for, or `null` for no filter.
|
|
23
24
|
*
|
|
@@ -64,7 +65,21 @@ import { datasetIndexedRecord } from "./dataset-record.js";
|
|
|
64
65
|
])
|
|
65
66
|
] : [], orderBy(documentId()), limit(request.limit));
|
|
66
67
|
},
|
|
67
|
-
record: datasetIndexedRecord
|
|
68
|
+
record: datasetIndexedRecord,
|
|
69
|
+
/**
|
|
70
|
+
* A dataset's name alone, unless another in the list has it too (AGL-4047):
|
|
71
|
+
* then who it is shared with, and where that matches too, its field count.
|
|
72
|
+
*/ pickerLabels (records, context) {
|
|
73
|
+
return datasetPickerLabels(records.map((record)=>{
|
|
74
|
+
var _ref;
|
|
75
|
+
return {
|
|
76
|
+
id: record.id,
|
|
77
|
+
name: record.name,
|
|
78
|
+
sharing: describeSharing(record.facts, (_ref = context == null ? void 0 : context.hostNames) != null ? _ref : {}),
|
|
79
|
+
fields: Array.isArray(record.facts['fields']) ? record.facts['fields'].length : 0
|
|
80
|
+
};
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
68
83
|
};
|
|
69
84
|
/** Called from the console registrar, owner named for a spec that calls it directly. */ export function registerDatasetRecordList() {
|
|
70
85
|
registerPluginRecordListSource('dataset', datasetRecordListSource, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/data/src/lib/model/dataset-record-list.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { scopeTokensForHost } from '@aglyn/aglyn/app-utils/scope-tokens'\nimport {\n registerPluginRecordListSource,\n type PluginRecordListSource,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-lists'\nimport {\n collection,\n documentId,\n limit,\n orderBy,\n query,\n where,\n} from 'firebase/firestore'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { datasetIndexedRecord } from './dataset-record'\n\n/**\n * The `visibleTo` tokens a list of datasets asks for, or `null` for no filter.\n *\n * Narrowed to a site, the site decides, whoever is looking: an owner who\n * reaches every dataset still sees only that site's and the workspace-wide\n * ones on that site's pages. With no site, the member's own reach decides:\n * their scope tokens, or `null` for an organization-wide member, who reads\n * everything.\n *\n * A site's tokens are a subset of those of anyone who can open the site, so\n * the query also satisfies the `canReadScoped` rule for a site collaborator.\n */\nexport function datasetListScope(request: {\n hostId?: string | null\n memberScope?: readonly string[] | null\n}): readonly string[] | null {\n return request.hostId ? scopeTokensForHost(request.hostId) : (request.memberScope ?? null)\n}\n\n/**\n * The workspace's datasets, listed in the console for another plugin's picker\n * or check (AGL-3080) — an automation step choosing the dataset it writes to,\n * a reference check confirming one still exists.\n *\n * Narrowed to a site (`hostId`), the query asks only for the datasets shared\n * with it, by the site's scope tokens: an automation runs on the site, so it\n * may only reach datasets the site can use, and the filter is the one the\n * security rules require of a member scoped to the site. With no site, a\n * member who is not organization-wide (`memberScope`) is asked for the ones\n * shared with any site they reach — the rules refuse them an unfiltered\n * list — and an organization-wide reader lists the organization's own.\n * `installedFrom` keeps the ones installed from that listing, by the\n * `source.listingId` every dataset install stamps.\n *\n * Ordered by document id, which the automatic index serves beside the\n * `visibleTo` filter, and the composite index on (`source.listingId`,\n * `visibleTo`) beside both. Each record is `datasetIndexedRecord`'s, the\n * server index's shape.\n */\nexport const datasetRecordListSource: PluginRecordListSource = {\n query(firestore, request) {\n if (!request.orgId) return null\n const scope = datasetListScope(request)\n return query(\n collection(firestore, 'orgs', request.orgId, 'datasets'),\n ...(request.installedFrom ? [where('source.listingId', '==', request.installedFrom)] : []),\n ...(scope ? [where('visibleTo', 'array-contains-any', [...scope])] : []),\n orderBy(documentId()),\n limit(request.limit),\n )\n },\n record: datasetIndexedRecord,\n}\n\n/** Called from the console registrar, owner named for a spec that calls it directly. */\nexport function registerDatasetRecordList(): void {\n registerPluginRecordListSource('dataset', datasetRecordListSource, { pluginId: BUNDLE_ID })\n}\n"],"names":["scopeTokensForHost","registerPluginRecordListSource","collection","documentId","limit","orderBy","query","where","BUNDLE_ID","datasetIndexedRecord","datasetListScope","request","hostId","memberScope","datasetRecordListSource","firestore","orgId","scope","installedFrom","record","registerDatasetRecordList","pluginId"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,kBAAkB,QAAQ,sCAAqC;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/data/src/lib/model/dataset-record-list.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { describeSharing, scopeTokensForHost } from '@aglyn/aglyn/app-utils/scope-tokens'\nimport {\n registerPluginRecordListSource,\n type PluginRecordListSource,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-lists'\nimport {\n collection,\n documentId,\n limit,\n orderBy,\n query,\n where,\n} from 'firebase/firestore'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { datasetIndexedRecord } from './dataset-record'\nimport { datasetPickerLabels } from './dataset-model-core'\n\n/**\n * The `visibleTo` tokens a list of datasets asks for, or `null` for no filter.\n *\n * Narrowed to a site, the site decides, whoever is looking: an owner who\n * reaches every dataset still sees only that site's and the workspace-wide\n * ones on that site's pages. With no site, the member's own reach decides:\n * their scope tokens, or `null` for an organization-wide member, who reads\n * everything.\n *\n * A site's tokens are a subset of those of anyone who can open the site, so\n * the query also satisfies the `canReadScoped` rule for a site collaborator.\n */\nexport function datasetListScope(request: {\n hostId?: string | null\n memberScope?: readonly string[] | null\n}): readonly string[] | null {\n return request.hostId ? scopeTokensForHost(request.hostId) : (request.memberScope ?? null)\n}\n\n/**\n * The workspace's datasets, listed in the console for another plugin's picker\n * or check (AGL-3080) — an automation step choosing the dataset it writes to,\n * a reference check confirming one still exists.\n *\n * Narrowed to a site (`hostId`), the query asks only for the datasets shared\n * with it, by the site's scope tokens: an automation runs on the site, so it\n * may only reach datasets the site can use, and the filter is the one the\n * security rules require of a member scoped to the site. With no site, a\n * member who is not organization-wide (`memberScope`) is asked for the ones\n * shared with any site they reach — the rules refuse them an unfiltered\n * list — and an organization-wide reader lists the organization's own.\n * `installedFrom` keeps the ones installed from that listing, by the\n * `source.listingId` every dataset install stamps.\n *\n * Ordered by document id, which the automatic index serves beside the\n * `visibleTo` filter, and the composite index on (`source.listingId`,\n * `visibleTo`) beside both. Each record is `datasetIndexedRecord`'s, the\n * server index's shape.\n */\nexport const datasetRecordListSource: PluginRecordListSource = {\n query(firestore, request) {\n if (!request.orgId) return null\n const scope = datasetListScope(request)\n return query(\n collection(firestore, 'orgs', request.orgId, 'datasets'),\n ...(request.installedFrom ? [where('source.listingId', '==', request.installedFrom)] : []),\n ...(scope ? [where('visibleTo', 'array-contains-any', [...scope])] : []),\n orderBy(documentId()),\n limit(request.limit),\n )\n },\n record: datasetIndexedRecord,\n /**\n * A dataset's name alone, unless another in the list has it too (AGL-4047):\n * then who it is shared with, and where that matches too, its field count.\n */\n pickerLabels(records, context) {\n return datasetPickerLabels(\n records.map((record) => ({\n id: record.id,\n name: record.name,\n sharing: describeSharing(record.facts, context?.hostNames ?? {}),\n fields: Array.isArray(record.facts['fields']) ? record.facts['fields'].length : 0,\n })),\n )\n },\n}\n\n/** Called from the console registrar, owner named for a spec that calls it directly. */\nexport function registerDatasetRecordList(): void {\n registerPluginRecordListSource('dataset', datasetRecordListSource, { pluginId: BUNDLE_ID })\n}\n"],"names":["describeSharing","scopeTokensForHost","registerPluginRecordListSource","collection","documentId","limit","orderBy","query","where","BUNDLE_ID","datasetIndexedRecord","datasetPickerLabels","datasetListScope","request","hostId","memberScope","datasetRecordListSource","firestore","orgId","scope","installedFrom","record","pickerLabels","records","context","map","id","name","sharing","facts","hostNames","fields","Array","isArray","length","registerDatasetRecordList","pluginId"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,eAAe,EAAEC,kBAAkB,QAAQ,sCAAqC;AACzF,SACEC,8BAA8B,QAEzB,kDAAiD;AACxD,SACEC,UAAU,EACVC,UAAU,EACVC,KAAK,EACLC,OAAO,EACPC,KAAK,EACLC,KAAK,QACA,qBAAoB;AAC3B,SAASC,SAAS,QAAQ,gCAA4B;AACtD,SAASC,oBAAoB,QAAQ,sBAAkB;AACvD,SAASC,mBAAmB,QAAQ,0BAAsB;AAE1D;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,iBAAiBC,OAGhC;QAC+DA;IAA9D,OAAOA,QAAQC,MAAM,GAAGb,mBAAmBY,QAAQC,MAAM,KAAKD,uBAAAA,QAAQE,WAAW,YAAnBF,uBAAuB;AACvF;AAEA;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMG,0BAAkD;IAC7DT,OAAMU,SAAS,EAAEJ,OAAO;QACtB,IAAI,CAACA,QAAQK,KAAK,EAAE,OAAO;QAC3B,MAAMC,QAAQP,iBAAiBC;QAC/B,OAAON,MACLJ,WAAWc,WAAW,QAAQJ,QAAQK,KAAK,EAAE,gBACzCL,QAAQO,aAAa,GAAG;YAACZ,MAAM,oBAAoB,MAAMK,QAAQO,aAAa;SAAE,GAAG,EAAE,KACrFD,QAAQ;YAACX,MAAM,aAAa,sBAAsB;mBAAIW;aAAM;SAAE,GAAG,EAAE,EACvEb,QAAQF,eACRC,MAAMQ,QAAQR,KAAK;IAEvB;IACAgB,QAAQX;IACR;;;GAGC,GACDY,cAAaC,OAAO,EAAEC,OAAO;QAC3B,OAAOb,oBACLY,QAAQE,GAAG,CAAC,CAACJ;;mBAAY;gBACvBK,IAAIL,OAAOK,EAAE;gBACbC,MAAMN,OAAOM,IAAI;gBACjBC,SAAS5B,gBAAgBqB,OAAOQ,KAAK,UAAEL,2BAAAA,QAASM,SAAS,mBAAI,CAAC;gBAC9DC,QAAQC,MAAMC,OAAO,CAACZ,OAAOQ,KAAK,CAAC,SAAS,IAAIR,OAAOQ,KAAK,CAAC,SAAS,CAACK,MAAM,GAAG;YAClF;;IAEJ;AACF,EAAC;AAED,sFAAsF,GACtF,OAAO,SAASC;IACdjC,+BAA+B,WAAWc,yBAAyB;QAAEoB,UAAU3B;IAAU;AAC3F"}
|
|
@@ -37,7 +37,7 @@ import { datasetDisplayName } from "./datasets.js";
|
|
|
37
37
|
return {
|
|
38
38
|
id,
|
|
39
39
|
name: datasetDisplayName(data) || id,
|
|
40
|
-
facts: {
|
|
40
|
+
facts: _extends({
|
|
41
41
|
fields: model.order.map((fieldId)=>{
|
|
42
42
|
var _ref;
|
|
43
43
|
var _model_fields_fieldId, _model_fields_fieldId1, _model_fields_fieldId2, _model_fields_fieldId3;
|
|
@@ -49,9 +49,14 @@ import { datasetDisplayName } from "./datasets.js";
|
|
|
49
49
|
customType: String((_model_fields_fieldId3 = model.fields[fieldId]) == null ? void 0 : _model_fields_fieldId3.customType)
|
|
50
50
|
} : {});
|
|
51
51
|
}),
|
|
52
|
-
visibleTo: Array.isArray(data['visibleTo']) ? data['visibleTo'] : []
|
|
52
|
+
visibleTo: Array.isArray(data['visibleTo']) ? data['visibleTo'] : []
|
|
53
|
+
}, data['scopeMode'] !== undefined ? {
|
|
54
|
+
scopeMode: data['scopeMode']
|
|
55
|
+
} : {}, data['scopeExcept'] !== undefined ? {
|
|
56
|
+
scopeExcept: data['scopeExcept']
|
|
57
|
+
} : {}, {
|
|
53
58
|
installedFrom: installedFrom(data['source'])
|
|
54
|
-
}
|
|
59
|
+
})
|
|
55
60
|
};
|
|
56
61
|
}
|
|
57
62
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/data/src/lib/model/dataset-record.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PluginIndexedRecord } from '@aglyn/aglyn/plugin-manager/plugin-record-index'\nimport { type DatasetModel, effectiveDatasetModel } from './dataset-models'\nimport { datasetDisplayName } from './datasets'\n\n/**\n * One stored dataset as this plugin shares it with another (AGL-3080) — the\n * one shape its server index (`dataset-record-index.ts`) and its console list\n * source (`dataset-record-list.ts`) both answer, so a reader on either side\n * reads the same record.\n *\n * `null` for a deleted dataset. Otherwise its id, its name as the Data page\n * shows it, and `facts`:\n * `fields` — its fields in the dataset page's order, each\n * `{ id, name, type }`; `visibleTo` — the scope tokens it is shared\n * with, so a reader acting for a member can apply the platform's own\n * visibility rule to them; and `installedFrom` — `{ listingId, version }`\n * for a dataset installed from a listing (`version` as the install\n * stamped it), `null` for one the workspace made. Never a record of it.\n */\nexport function datasetIndexedRecord(\n id: string,\n data: Readonly<Record<string, unknown>> | undefined,\n): PluginIndexedRecord | null {\n if (!data || data['deletedAt'] != null) return null\n const model = effectiveDatasetModel(data as { model?: DatasetModel; fields?: string[] })\n const text = (value: unknown): string => (typeof value === 'string' ? value.trim() : '')\n return {\n id,\n name: datasetDisplayName(data) || id,\n facts: {\n fields: model.order.map((fieldId) => ({\n id: fieldId,\n name: text(model.fields[fieldId]?.name) || fieldId,\n type: String(model.fields[fieldId]?.type ?? 'text'),\n // A named type riding the storage one: a record's photo is `image` (AGL-3616).\n ...(model.fields[fieldId]?.customType ? { customType: String(model.fields[fieldId]?.customType) } : {}),\n })),\n visibleTo: Array.isArray(data['visibleTo']) ? (data['visibleTo'] as string[]) : [],\n installedFrom: installedFrom(data['source']),\n },\n }\n}\n\n/**\n * Where an installed dataset came from. Read from its `source` stamp, which\n * every dataset install has written — the ones from before install\n * provenance (AGL-1015) included, which carry no `installedFrom`.\n */\nfunction installedFrom(source: unknown): { listingId: string; version: unknown } | null {\n const stamp = (source ?? {}) as Record<string, unknown>\n const listingId = typeof stamp['listingId'] === 'string' ? stamp['listingId'] : ''\n return listingId ? { listingId, version: stamp['version'] ?? null } : null\n}\n"],"names":["effectiveDatasetModel","datasetDisplayName","datasetIndexedRecord","id","data","model","text","value","trim","name","facts","fields","order","map","fieldId","type","String","customType","visibleTo","Array","isArray","installedFrom","source","stamp","listingId","version"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAA4BA,qBAAqB,QAAQ,sBAAkB;AAC3E,SAASC,kBAAkB,QAAQ,gBAAY;AAE/C;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASC,qBACdC,EAAU,EACVC,IAAmD;IAEnD,IAAI,CAACA,QAAQA,IAAI,CAAC,YAAY,IAAI,MAAM,OAAO;IAC/C,MAAMC,QAAQL,sBAAsBI;IACpC,MAAME,OAAO,CAACC,QAA4B,OAAOA,UAAU,WAAWA,MAAMC,IAAI,KAAK;IACrF,OAAO;QACLL;QACAM,MAAMR,mBAAmBG,SAASD;QAClCO,OAAO;YACLC,QAAQN,MAAMO,KAAK,CAACC,GAAG,CAAC,CAACC;;oBAEZT,uBACEA,wBAETA,wBAAyDA;uBALzB;oBACpCF,IAAIW;oBACJL,MAAMH,MAAKD,wBAAAA,MAAMM,MAAM,CAACG,QAAQ,qBAArBT,sBAAuBI,IAAI,KAAKK;oBAC3CC,MAAMC,gBAAOX,yBAAAA,MAAMM,MAAM,CAACG,QAAQ,qBAArBT,uBAAuBU,IAAI,mBAAI;mBAExCV,EAAAA,yBAAAA,MAAMM,MAAM,CAACG,QAAQ,qBAArBT,uBAAuBY,UAAU,IAAG;oBAAEA,YAAYD,QAAOX,yBAAAA,MAAMM,MAAM,CAACG,QAAQ,qBAArBT,uBAAuBY,UAAU;gBAAE,IAAI,CAAC;;YAEvGC,WAAWC,MAAMC,OAAO,CAAChB,IAAI,CAAC,YAAY,IAAKA,IAAI,CAAC,YAAY,GAAgB,EAAE;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/data/src/lib/model/dataset-record.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PluginIndexedRecord } from '@aglyn/aglyn/plugin-manager/plugin-record-index'\nimport { type DatasetModel, effectiveDatasetModel } from './dataset-models'\nimport { datasetDisplayName } from './datasets'\n\n/**\n * One stored dataset as this plugin shares it with another (AGL-3080) — the\n * one shape its server index (`dataset-record-index.ts`) and its console list\n * source (`dataset-record-list.ts`) both answer, so a reader on either side\n * reads the same record.\n *\n * `null` for a deleted dataset. Otherwise its id, its name as the Data page\n * shows it, and `facts`:\n * `fields` — its fields in the dataset page's order, each\n * `{ id, name, type }`; `visibleTo` — the scope tokens it is shared\n * with, so a reader acting for a member can apply the platform's own\n * visibility rule to them; and `installedFrom` — `{ listingId, version }`\n * for a dataset installed from a listing (`version` as the install\n * stamped it), `null` for one the workspace made. Never a record of it.\n */\nexport function datasetIndexedRecord(\n id: string,\n data: Readonly<Record<string, unknown>> | undefined,\n): PluginIndexedRecord | null {\n if (!data || data['deletedAt'] != null) return null\n const model = effectiveDatasetModel(data as { model?: DatasetModel; fields?: string[] })\n const text = (value: unknown): string => (typeof value === 'string' ? value.trim() : '')\n return {\n id,\n name: datasetDisplayName(data) || id,\n facts: {\n fields: model.order.map((fieldId) => ({\n id: fieldId,\n name: text(model.fields[fieldId]?.name) || fieldId,\n type: String(model.fields[fieldId]?.type ?? 'text'),\n // A named type riding the storage one: a record's photo is `image` (AGL-3616).\n ...(model.fields[fieldId]?.customType ? { customType: String(model.fields[fieldId]?.customType) } : {}),\n })),\n visibleTo: Array.isArray(data['visibleTo']) ? (data['visibleTo'] as string[]) : [],\n // Shared with all sites except some: what a reader of `visibleTo` needs in\n // order not to take it for a dataset on those sites alone (AGL-4047).\n ...(data['scopeMode'] !== undefined ? { scopeMode: data['scopeMode'] } : {}),\n ...(data['scopeExcept'] !== undefined ? { scopeExcept: data['scopeExcept'] } : {}),\n installedFrom: installedFrom(data['source']),\n },\n }\n}\n\n/**\n * Where an installed dataset came from. Read from its `source` stamp, which\n * every dataset install has written — the ones from before install\n * provenance (AGL-1015) included, which carry no `installedFrom`.\n */\nfunction installedFrom(source: unknown): { listingId: string; version: unknown } | null {\n const stamp = (source ?? {}) as Record<string, unknown>\n const listingId = typeof stamp['listingId'] === 'string' ? stamp['listingId'] : ''\n return listingId ? { listingId, version: stamp['version'] ?? null } : null\n}\n"],"names":["effectiveDatasetModel","datasetDisplayName","datasetIndexedRecord","id","data","model","text","value","trim","name","facts","fields","order","map","fieldId","type","String","customType","visibleTo","Array","isArray","undefined","scopeMode","scopeExcept","installedFrom","source","stamp","listingId","version"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAA4BA,qBAAqB,QAAQ,sBAAkB;AAC3E,SAASC,kBAAkB,QAAQ,gBAAY;AAE/C;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASC,qBACdC,EAAU,EACVC,IAAmD;IAEnD,IAAI,CAACA,QAAQA,IAAI,CAAC,YAAY,IAAI,MAAM,OAAO;IAC/C,MAAMC,QAAQL,sBAAsBI;IACpC,MAAME,OAAO,CAACC,QAA4B,OAAOA,UAAU,WAAWA,MAAMC,IAAI,KAAK;IACrF,OAAO;QACLL;QACAM,MAAMR,mBAAmBG,SAASD;QAClCO,OAAO;YACLC,QAAQN,MAAMO,KAAK,CAACC,GAAG,CAAC,CAACC;;oBAEZT,uBACEA,wBAETA,wBAAyDA;uBALzB;oBACpCF,IAAIW;oBACJL,MAAMH,MAAKD,wBAAAA,MAAMM,MAAM,CAACG,QAAQ,qBAArBT,sBAAuBI,IAAI,KAAKK;oBAC3CC,MAAMC,gBAAOX,yBAAAA,MAAMM,MAAM,CAACG,QAAQ,qBAArBT,uBAAuBU,IAAI,mBAAI;mBAExCV,EAAAA,yBAAAA,MAAMM,MAAM,CAACG,QAAQ,qBAArBT,uBAAuBY,UAAU,IAAG;oBAAEA,YAAYD,QAAOX,yBAAAA,MAAMM,MAAM,CAACG,QAAQ,qBAArBT,uBAAuBY,UAAU;gBAAE,IAAI,CAAC;;YAEvGC,WAAWC,MAAMC,OAAO,CAAChB,IAAI,CAAC,YAAY,IAAKA,IAAI,CAAC,YAAY,GAAgB,EAAE;WAG9EA,IAAI,CAAC,YAAY,KAAKiB,YAAY;YAAEC,WAAWlB,IAAI,CAAC,YAAY;QAAC,IAAI,CAAC,GACtEA,IAAI,CAAC,cAAc,KAAKiB,YAAY;YAAEE,aAAanB,IAAI,CAAC,cAAc;QAAC,IAAI,CAAC;YAChFoB,eAAeA,cAAcpB,IAAI,CAAC,SAAS;;IAE/C;AACF;AAEA;;;;CAIC,GACD,SAASoB,cAAcC,MAAe;QAGKC;IAFzC,MAAMA,QAASD,iBAAAA,SAAU,CAAC;IAC1B,MAAME,YAAY,OAAOD,KAAK,CAAC,YAAY,KAAK,WAAWA,KAAK,CAAC,YAAY,GAAG;IAChF,OAAOC,YAAY;QAAEA;QAAWC,OAAO,GAAEF,iBAAAA,KAAK,CAAC,UAAU,YAAhBA,iBAAoB;IAAK,IAAI;AACxE"}
|
|
@@ -39,7 +39,21 @@ export interface HostDataset {
|
|
|
39
39
|
* the AGL-1040 backfill stamps it. See `app-utils/scope-tokens`.
|
|
40
40
|
*/
|
|
41
41
|
visibleTo?: ScopeToken[];
|
|
42
|
+
/**
|
|
43
|
+
* The name's search key (AGL-4047): `nameSearchKey(displayName)`, written
|
|
44
|
+
* beside the name by every path that writes one, so the Data page can find a
|
|
45
|
+
* dataset by the start of its name and order the list by it. Never shown.
|
|
46
|
+
*/
|
|
47
|
+
nameLower?: string;
|
|
42
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* The search key stored beside a dataset's name (AGL-4047).
|
|
51
|
+
*
|
|
52
|
+
* One function for every writer, so a name saved on the web, through the API,
|
|
53
|
+
* by an AI draft, an install or a restore is found by the same typed prefix.
|
|
54
|
+
* The native apps write the same key through their own `nameSearchKey` port.
|
|
55
|
+
*/
|
|
56
|
+
export declare function datasetNameLower(displayName: string | null | undefined): string;
|
|
43
57
|
export interface HostDatasetRecord {
|
|
44
58
|
$id?: string;
|
|
45
59
|
/**
|
|
@@ -18,12 +18,22 @@
|
|
|
18
18
|
* `records` subcollection, edited in the console Data card and consumed by
|
|
19
19
|
* repeatable components (AGL-103) via `{{item.field}}` bindings.
|
|
20
20
|
*/ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
21
|
+
import { nameSearchKey } from "@aglyn/aglyn/app-utils/name-search";
|
|
21
22
|
import { coerceDocumentValues, effectiveDatasetModel, validateDocument } from "./dataset-models.js";
|
|
22
23
|
import { fillRecordAddresses } from "../record-pages/record-pages.js";
|
|
23
24
|
import { DATASET_FIELD_PATTERN } from "./dataset-model-core.js";
|
|
24
25
|
// The field-id and naming helpers are pure and live with the model's pure
|
|
25
26
|
// half (AGL-3668), which the native apps generate from.
|
|
26
27
|
export { DATASET_FIELD_PATTERN, datasetDisplayName, defaultDatasetFieldId, parseDatasetFieldEntries, slugifyDatasetFieldId, validateDatasetFieldId } from "./dataset-model-core.js";
|
|
28
|
+
/**
|
|
29
|
+
* The search key stored beside a dataset's name (AGL-4047).
|
|
30
|
+
*
|
|
31
|
+
* One function for every writer, so a name saved on the web, through the API,
|
|
32
|
+
* by an AI draft, an install or a restore is found by the same typed prefix.
|
|
33
|
+
* The native apps write the same key through their own `nameSearchKey` port.
|
|
34
|
+
*/ export function datasetNameLower(displayName) {
|
|
35
|
+
return nameSearchKey(displayName);
|
|
36
|
+
}
|
|
27
37
|
/** What Data says beside a sample record (AGL-4065). */ export const DATASET_SAMPLE_RECORD_NOTE = 'A sample row made because your site’s brief gave none. Replace it with your own: saving your changes makes it yours.';
|
|
28
38
|
/** Whether a record is a sample to replace (AGL-4065). */ export function isSampleDatasetRecord(record) {
|
|
29
39
|
return (record == null ? void 0 : record.sample) === true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/data/src/lib/model/datasets.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Datasets (AGL-102): tabular data at `orgs/{orgId}/datasets/{id}` with a\n * `records` subcollection, edited in the console Data card and consumed by\n * repeatable components (AGL-103) via `{{item.field}}` bindings.\n */\n\nimport type { ScopeToken } from '@aglyn/aglyn/foundation/definitions/platform.types'\nimport {\n coerceDocumentValues,\n type DatasetModel,\n effectiveDatasetModel,\n validateDocument,\n} from './dataset-models'\nimport { fillRecordAddresses } from '../record-pages/record-pages'\nimport { DATASET_FIELD_PATTERN } from './dataset-model-core'\n\n// The field-id and naming helpers are pure and live with the model's pure\n// half (AGL-3668), which the native apps generate from.\nexport {\n DATASET_FIELD_PATTERN,\n datasetDisplayName,\n defaultDatasetFieldId,\n parseDatasetFieldEntries,\n slugifyDatasetFieldId,\n validateDatasetFieldId,\n} from './dataset-model-core'\n\nexport interface HostDataset {\n $id?: string\n displayName?: string\n /** Column names, in display order (v1; superseded by `model`). */\n fields?: string[]\n /** Typed model (AGL-177); when absent, derive from `fields`. */\n model?: import('./dataset-models').DatasetModel\n /** dod.ts Schema.Name shape (AGL-178). */\n names?: { singular?: string; plural?: string }\n /**\n * Which sites may see this dataset (AGL-1037). Absent = org-wide, until\n * the AGL-1040 backfill stamps it. See `app-utils/scope-tokens`.\n */\n visibleTo?: ScopeToken[]\n}\n\nexport interface HostDatasetRecord {\n $id?: string\n /**\n * Field → value, in storage form per the field's type (see\n * `dataset-models`). Rows written by a form or an automation step before\n * AGL-2773 hold every value as text; readers accept both.\n */\n values?: Record<string, unknown>\n /** Row position in the editor and in repeated output. */\n order?: number\n /**\n * A sample a site start seeded for the owner to replace (AGL-4065): the\n * brief gave no entries for the list. Beside the values, so no page reads\n * it; saving the record in Data makes it the owner's.\n */\n sample?: boolean\n}\n\n/** What Data says beside a sample record (AGL-4065). */\nexport const DATASET_SAMPLE_RECORD_NOTE =\n 'A sample row made because your site’s brief gave none. Replace it with your own: saving your changes makes it yours.'\n\n/** Whether a record is a sample to replace (AGL-4065). */\nexport function isSampleDatasetRecord(record: Pick<HostDatasetRecord, 'sample'> | null | undefined): boolean {\n return record?.sample === true\n}\n\n/**\n * Parses a comma/newline separated field list into valid unique names;\n * invalid entries are dropped rather than failing the whole set.\n */\nexport function parseDatasetFields(input: string): string[] {\n const seen = new Set<string>()\n const fields: string[] = []\n for (const raw of input.split(/[,\\n]/)) {\n const name = raw.trim()\n if (!DATASET_FIELD_PATTERN.test(name)) continue\n const key = name.toLowerCase()\n if (seen.has(key)) continue\n seen.add(key)\n fields.push(name)\n }\n return fields\n}\n\n/** Record values restricted to the dataset's declared fields. */\nexport function sanitizeRecordValues(\n fields: string[],\n input: Record<string, unknown> | null | undefined,\n): Record<string, string> {\n const values: Record<string, string> = {}\n for (const field of fields) {\n const value = input?.[field]\n if (value == null) continue\n values[field] = String(value)\n }\n return values\n}\n\n/**\n * The submitted values a dataset write would store, picked by field id and\n * left as they arrived (AGL-556). With a `fieldMap` (submitted key → stable\n * model fieldId), mapped values land under the mapped fieldId — so renamed\n * schema fields keep receiving data — and entries whose fieldId isn't in the\n * model are dropped. Submitted keys without a mapping (and calls without a\n * map) fall back to the legacy name-intersection against the model's field\n * ids, matching `sanitizeRecordValues`.\n */\nexport function pickDatasetRecordInput(\n dataset: { model?: DatasetModel; fields?: string[] },\n input: Record<string, unknown> | null | undefined,\n fieldMap?: Record<string, string> | null,\n): Record<string, unknown> {\n const model = effectiveDatasetModel(dataset)\n const map = fieldMap ?? {}\n const values: Record<string, unknown> = {}\n for (const fieldId of model.order) {\n if (!model.fields[fieldId]) continue\n // A submitted key with an explicit mapping never doubles as a\n // name-match — the mapping decides where it lands.\n if (fieldId in map) continue\n const value = input?.[fieldId]\n if (value == null) continue\n values[fieldId] = value\n }\n for (const [submittedKey, fieldId] of Object.entries(map)) {\n if (typeof fieldId !== 'string' || !model.fields[fieldId]) continue\n const value = input?.[submittedKey]\n if (value == null) continue\n values[fieldId] = value\n }\n return values\n}\n\n/** A dataset record write, checked against the dataset's model. */\nexport interface DatasetRecordWrite {\n /**\n * The model fields this write supplied a value for, before coercion. Empty\n * means nothing submitted matched a field of the dataset.\n */\n matched: string[]\n /**\n * The values to store, in storage form (see `dataset-models`): numbers,\n * booleans, epoch millis and so on per the field's type. For a merge, the\n * existing values with this write's laid over them.\n */\n values: Record<string, unknown>\n /** fieldId → the reason it was refused. Empty when the write may land. */\n errors: Record<string, string>\n}\n\n/**\n * A text field takes what an event payload carries as a number or a boolean\n * as the text it reads as, which is what these writes always stored.\n */\nfunction asTextInput(\n model: DatasetModel,\n picked: Record<string, unknown>,\n): Record<string, unknown> {\n const values: Record<string, unknown> = {}\n for (const [fieldId, value] of Object.entries(picked)) {\n const type = model.fields[fieldId]?.type\n values[fieldId] =\n (type === 'text' || type === 'reference') &&\n (typeof value === 'number' || typeof value === 'boolean')\n ? String(value)\n : value\n }\n return values\n}\n\n/**\n * A record write from a form submission or an automation step, coerced and\n * validated against the dataset's model (AGL-2773, option B).\n *\n * These writes used to store `String(value)` for every field and check\n * nothing, so a form could put `abc` in a number column and skip a required\n * one. They now run the same `coerceDocumentValues` + `validateDocument` pair\n * the console and `/v1` do: a value is stored in its field's type, and a\n * record with any refused field is not written at all. The caller decides\n * what a refusal costs — a form keeps the Inbox submission, a run records a\n * failed step.\n *\n * `existing` makes it a merge (update-or-append's update leg): this write's\n * values are laid over the stored ones, and only the fields THIS write\n * supplied are held to the model. A stored row written as text before this\n * change keeps its text values and is not refused for them — the reads have\n * always rendered them, and a merge that touched `email` must not fail over a\n * legacy `price` of `\"12\"` it never sent.\n *\n * Custom field types validate only once registered: call\n * `ensureDeclaredCustomFieldTypes(model)` before this on a server path.\n */\nexport function prepareDatasetRecordWrite(\n dataset: { model?: DatasetModel; fields?: string[] },\n input: Record<string, unknown> | null | undefined,\n options: {\n fieldMap?: Record<string, string> | null\n existing?: Record<string, unknown> | null\n } = {},\n): DatasetRecordWrite {\n const model = effectiveDatasetModel(dataset)\n const picked = pickDatasetRecordInput(dataset, input, options.fieldMap)\n const matched = Object.keys(picked)\n const coerced = coerceDocumentValues(model, asTextInput(model, picked))\n if (!options.existing) {\n // A page address fills in from its source on the record's first write\n // and is normalized on every one (AGL-3475).\n const values = fillRecordAddresses(model, coerced)\n return {\n matched,\n values,\n errors: validateDocument(model, values),\n }\n }\n const values = fillRecordAddresses(model, { ...options.existing, ...coerced })\n const errors: Record<string, string> = {}\n for (const [fieldId, error] of Object.entries(\n validateDocument(model, values),\n )) {\n if (fieldId in coerced) errors[fieldId] = error\n }\n return { matched, values, errors }\n}\n\n/**\n * A refused write's errors as one line, in the model's field order:\n * `Stars must be a whole number; Email is required`.\n */\nexport function describeDatasetRecordErrors(\n errors: Record<string, string>,\n): string {\n return Object.values(errors).join('; ')\n}\n\n/** Records sorted by their editor order (then id for stability). */\nexport function sortDatasetRecords<T extends HostDatasetRecord>(\n records: T[],\n): T[] {\n return [...records].sort(\n (a, b) =>\n (a.order ?? Number.MAX_SAFE_INTEGER) -\n (b.order ?? Number.MAX_SAFE_INTEGER) ||\n String(a.$id ?? '').localeCompare(String(b.$id ?? '')),\n )\n}\n"],"names":["coerceDocumentValues","effectiveDatasetModel","validateDocument","fillRecordAddresses","DATASET_FIELD_PATTERN","datasetDisplayName","defaultDatasetFieldId","parseDatasetFieldEntries","slugifyDatasetFieldId","validateDatasetFieldId","DATASET_SAMPLE_RECORD_NOTE","isSampleDatasetRecord","record","sample","parseDatasetFields","input","seen","Set","fields","raw","split","name","trim","test","key","toLowerCase","has","add","push","sanitizeRecordValues","values","field","value","String","pickDatasetRecordInput","dataset","fieldMap","model","map","fieldId","order","submittedKey","Object","entries","asTextInput","picked","type","prepareDatasetRecordWrite","options","matched","keys","coerced","existing","errors","error","describeDatasetRecordErrors","join","sortDatasetRecords","records","sort","a","b","Number","MAX_SAFE_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SAASpB,OAAOiC,QAAQZ,QAAQ;IACtE,MAAMa,UAAUP,OAAOQ,IAAI,CAACL;IAC5B,MAAMM,UAAUnD,qBAAqBqC,OAAOO,YAAYP,OAAOQ;IAC/D,IAAI,CAACG,QAAQI,QAAQ,EAAE;QACrB,sEAAsE;QACtE,6CAA6C;QAC7C,MAAMtB,SAAS3B,oBAAoBkC,OAAOc;QAC1C,OAAO;YACLF;YACAnB;YACAuB,QAAQnD,iBAAiBmC,OAAOP;QAClC;IACF;IACA,MAAMA,SAAS3B,oBAAoBkC,OAAO,aAAKW,QAAQI,QAAQ,EAAKD;IACpE,MAAME,SAAiC,CAAC;IACxC,KAAK,MAAM,CAACd,SAASe,MAAM,IAAIZ,OAAOC,OAAO,CAC3CzC,iBAAiBmC,OAAOP,SACvB;QACD,IAAIS,WAAWY,SAASE,MAAM,CAACd,QAAQ,GAAGe;IAC5C;IACA,OAAO;QAAEL;QAASnB;QAAQuB;IAAO;AACnC;AAEA;;;CAGC,GACD,OAAO,SAASE,4BACdF,MAA8B;IAE9B,OAAOX,OAAOZ,MAAM,CAACuB,QAAQG,IAAI,CAAC;AACpC;AAEA,kEAAkE,GAClE,OAAO,SAASC,mBACdC,OAAY;IAEZ,OAAO;WAAIA;KAAQ,CAACC,IAAI,CACtB,CAACC,GAAGC;YACDD,UACEC,UACID,QAAkCC;eAFzC,EAACD,WAAAA,EAAEpB,KAAK,YAAPoB,WAAWE,OAAOC,gBAAgB,MAChCF,WAAAA,EAAErB,KAAK,YAAPqB,WAAWC,OAAOC,gBAAgB,KACrC9B,QAAO2B,SAAAA,EAAEI,GAAG,YAALJ,SAAS,IAAIK,aAAa,CAAChC,QAAO4B,SAAAA,EAAEG,GAAG,YAALH,SAAS;;AAExD"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/data/src/lib/model/datasets.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Datasets (AGL-102): tabular data at `orgs/{orgId}/datasets/{id}` with a\n * `records` subcollection, edited in the console Data card and consumed by\n * repeatable components (AGL-103) via `{{item.field}}` bindings.\n */\n\nimport type { ScopeToken } from '@aglyn/aglyn/foundation/definitions/platform.types'\nimport { nameSearchKey } from '@aglyn/aglyn/app-utils/name-search'\nimport {\n coerceDocumentValues,\n type DatasetModel,\n effectiveDatasetModel,\n validateDocument,\n} from './dataset-models'\nimport { fillRecordAddresses } from '../record-pages/record-pages'\nimport { DATASET_FIELD_PATTERN } from './dataset-model-core'\n\n// The field-id and naming helpers are pure and live with the model's pure\n// half (AGL-3668), which the native apps generate from.\nexport {\n DATASET_FIELD_PATTERN,\n datasetDisplayName,\n defaultDatasetFieldId,\n parseDatasetFieldEntries,\n slugifyDatasetFieldId,\n validateDatasetFieldId,\n} from './dataset-model-core'\n\nexport interface HostDataset {\n $id?: string\n displayName?: string\n /** Column names, in display order (v1; superseded by `model`). */\n fields?: string[]\n /** Typed model (AGL-177); when absent, derive from `fields`. */\n model?: import('./dataset-models').DatasetModel\n /** dod.ts Schema.Name shape (AGL-178). */\n names?: { singular?: string; plural?: string }\n /**\n * Which sites may see this dataset (AGL-1037). Absent = org-wide, until\n * the AGL-1040 backfill stamps it. See `app-utils/scope-tokens`.\n */\n visibleTo?: ScopeToken[]\n /**\n * The name's search key (AGL-4047): `nameSearchKey(displayName)`, written\n * beside the name by every path that writes one, so the Data page can find a\n * dataset by the start of its name and order the list by it. Never shown.\n */\n nameLower?: string\n}\n\n/**\n * The search key stored beside a dataset's name (AGL-4047).\n *\n * One function for every writer, so a name saved on the web, through the API,\n * by an AI draft, an install or a restore is found by the same typed prefix.\n * The native apps write the same key through their own `nameSearchKey` port.\n */\nexport function datasetNameLower(displayName: string | null | undefined): string {\n return nameSearchKey(displayName)\n}\n\nexport interface HostDatasetRecord {\n $id?: string\n /**\n * Field → value, in storage form per the field's type (see\n * `dataset-models`). Rows written by a form or an automation step before\n * AGL-2773 hold every value as text; readers accept both.\n */\n values?: Record<string, unknown>\n /** Row position in the editor and in repeated output. */\n order?: number\n /**\n * A sample a site start seeded for the owner to replace (AGL-4065): the\n * brief gave no entries for the list. Beside the values, so no page reads\n * it; saving the record in Data makes it the owner's.\n */\n sample?: boolean\n}\n\n/** What Data says beside a sample record (AGL-4065). */\nexport const DATASET_SAMPLE_RECORD_NOTE =\n 'A sample row made because your site’s brief gave none. Replace it with your own: saving your changes makes it yours.'\n\n/** Whether a record is a sample to replace (AGL-4065). */\nexport function isSampleDatasetRecord(record: Pick<HostDatasetRecord, 'sample'> | null | undefined): boolean {\n return record?.sample === true\n}\n\n/**\n * Parses a comma/newline separated field list into valid unique names;\n * invalid entries are dropped rather than failing the whole set.\n */\nexport function parseDatasetFields(input: string): string[] {\n const seen = new Set<string>()\n const fields: string[] = []\n for (const raw of input.split(/[,\\n]/)) {\n const name = raw.trim()\n if (!DATASET_FIELD_PATTERN.test(name)) continue\n const key = name.toLowerCase()\n if (seen.has(key)) continue\n seen.add(key)\n fields.push(name)\n }\n return fields\n}\n\n/** Record values restricted to the dataset's declared fields. */\nexport function sanitizeRecordValues(\n fields: string[],\n input: Record<string, unknown> | null | undefined,\n): Record<string, string> {\n const values: Record<string, string> = {}\n for (const field of fields) {\n const value = input?.[field]\n if (value == null) continue\n values[field] = String(value)\n }\n return values\n}\n\n/**\n * The submitted values a dataset write would store, picked by field id and\n * left as they arrived (AGL-556). With a `fieldMap` (submitted key → stable\n * model fieldId), mapped values land under the mapped fieldId — so renamed\n * schema fields keep receiving data — and entries whose fieldId isn't in the\n * model are dropped. Submitted keys without a mapping (and calls without a\n * map) fall back to the legacy name-intersection against the model's field\n * ids, matching `sanitizeRecordValues`.\n */\nexport function pickDatasetRecordInput(\n dataset: { model?: DatasetModel; fields?: string[] },\n input: Record<string, unknown> | null | undefined,\n fieldMap?: Record<string, string> | null,\n): Record<string, unknown> {\n const model = effectiveDatasetModel(dataset)\n const map = fieldMap ?? {}\n const values: Record<string, unknown> = {}\n for (const fieldId of model.order) {\n if (!model.fields[fieldId]) continue\n // A submitted key with an explicit mapping never doubles as a\n // name-match — the mapping decides where it lands.\n if (fieldId in map) continue\n const value = input?.[fieldId]\n if (value == null) continue\n values[fieldId] = value\n }\n for (const [submittedKey, fieldId] of Object.entries(map)) {\n if (typeof fieldId !== 'string' || !model.fields[fieldId]) continue\n const value = input?.[submittedKey]\n if (value == null) continue\n values[fieldId] = value\n }\n return values\n}\n\n/** A dataset record write, checked against the dataset's model. */\nexport interface DatasetRecordWrite {\n /**\n * The model fields this write supplied a value for, before coercion. Empty\n * means nothing submitted matched a field of the dataset.\n */\n matched: string[]\n /**\n * The values to store, in storage form (see `dataset-models`): numbers,\n * booleans, epoch millis and so on per the field's type. For a merge, the\n * existing values with this write's laid over them.\n */\n values: Record<string, unknown>\n /** fieldId → the reason it was refused. Empty when the write may land. */\n errors: Record<string, string>\n}\n\n/**\n * A text field takes what an event payload carries as a number or a boolean\n * as the text it reads as, which is what these writes always stored.\n */\nfunction asTextInput(\n model: DatasetModel,\n picked: Record<string, unknown>,\n): Record<string, unknown> {\n const values: Record<string, unknown> = {}\n for (const [fieldId, value] of Object.entries(picked)) {\n const type = model.fields[fieldId]?.type\n values[fieldId] =\n (type === 'text' || type === 'reference') &&\n (typeof value === 'number' || typeof value === 'boolean')\n ? String(value)\n : value\n }\n return values\n}\n\n/**\n * A record write from a form submission or an automation step, coerced and\n * validated against the dataset's model (AGL-2773, option B).\n *\n * These writes used to store `String(value)` for every field and check\n * nothing, so a form could put `abc` in a number column and skip a required\n * one. They now run the same `coerceDocumentValues` + `validateDocument` pair\n * the console and `/v1` do: a value is stored in its field's type, and a\n * record with any refused field is not written at all. The caller decides\n * what a refusal costs — a form keeps the Inbox submission, a run records a\n * failed step.\n *\n * `existing` makes it a merge (update-or-append's update leg): this write's\n * values are laid over the stored ones, and only the fields THIS write\n * supplied are held to the model. A stored row written as text before this\n * change keeps its text values and is not refused for them — the reads have\n * always rendered them, and a merge that touched `email` must not fail over a\n * legacy `price` of `\"12\"` it never sent.\n *\n * Custom field types validate only once registered: call\n * `ensureDeclaredCustomFieldTypes(model)` before this on a server path.\n */\nexport function prepareDatasetRecordWrite(\n dataset: { model?: DatasetModel; fields?: string[] },\n input: Record<string, unknown> | null | undefined,\n options: {\n fieldMap?: Record<string, string> | null\n existing?: Record<string, unknown> | null\n } = {},\n): DatasetRecordWrite {\n const model = effectiveDatasetModel(dataset)\n const picked = pickDatasetRecordInput(dataset, input, options.fieldMap)\n const matched = Object.keys(picked)\n const coerced = coerceDocumentValues(model, asTextInput(model, picked))\n if (!options.existing) {\n // A page address fills in from its source on the record's first write\n // and is normalized on every one (AGL-3475).\n const values = fillRecordAddresses(model, coerced)\n return {\n matched,\n values,\n errors: validateDocument(model, values),\n }\n }\n const values = fillRecordAddresses(model, { ...options.existing, ...coerced })\n const errors: Record<string, string> = {}\n for (const [fieldId, error] of Object.entries(\n validateDocument(model, values),\n )) {\n if (fieldId in coerced) errors[fieldId] = error\n }\n return { matched, values, errors }\n}\n\n/**\n * A refused write's errors as one line, in the model's field order:\n * `Stars must be a whole number; Email is required`.\n */\nexport function describeDatasetRecordErrors(\n errors: Record<string, string>,\n): string {\n return Object.values(errors).join('; ')\n}\n\n/** Records sorted by their editor order (then id for stability). */\nexport function sortDatasetRecords<T extends HostDatasetRecord>(\n records: T[],\n): T[] {\n return [...records].sort(\n (a, b) =>\n (a.order ?? Number.MAX_SAFE_INTEGER) -\n (b.order ?? Number.MAX_SAFE_INTEGER) ||\n String(a.$id ?? '').localeCompare(String(b.$id ?? '')),\n )\n}\n"],"names":["nameSearchKey","coerceDocumentValues","effectiveDatasetModel","validateDocument","fillRecordAddresses","DATASET_FIELD_PATTERN","datasetDisplayName","defaultDatasetFieldId","parseDatasetFieldEntries","slugifyDatasetFieldId","validateDatasetFieldId","datasetNameLower","displayName","DATASET_SAMPLE_RECORD_NOTE","isSampleDatasetRecord","record","sample","parseDatasetFields","input","seen","Set","fields","raw","split","name","trim","test","key","toLowerCase","has","add","push","sanitizeRecordValues","values","field","value","String","pickDatasetRecordInput","dataset","fieldMap","model","map","fieldId","order","submittedKey","Object","entries","asTextInput","picked","type","prepareDatasetRecordWrite","options","matched","keys","coerced","existing","errors","error","describeDatasetRecordErrors","join","sortDatasetRecords","records","sort","a","b","Number","MAX_SAFE_INTEGER","$id","localeCompare"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;CAIC;AAGD,SAASA,aAAa,QAAQ,qCAAoC;AAClE,SACEC,oBAAoB,EAEpBC,qBAAqB,EACrBC,gBAAgB,QACX,sBAAkB;AACzB,SAASC,mBAAmB,QAAQ,kCAA8B;AAClE,SAASC,qBAAqB,QAAQ,0BAAsB;AAE5D,0EAA0E;AAC1E,wDAAwD;AACxD,SACEA,qBAAqB,EACrBC,kBAAkB,EAClBC,qBAAqB,EACrBC,wBAAwB,EACxBC,qBAAqB,EACrBC,sBAAsB,QACjB,0BAAsB;AAwB7B;;;;;;CAMC,GACD,OAAO,SAASC,iBAAiBC,WAAsC;IACrE,OAAOZ,cAAcY;AACvB;AAoBA,sDAAsD,GACtD,OAAO,MAAMC,6BACX,uHAAsH;AAExH,wDAAwD,GACxD,OAAO,SAASC,sBAAsBC,MAA4D;IAChG,OAAOA,CAAAA,0BAAAA,OAAQC,MAAM,MAAK;AAC5B;AAEA;;;CAGC,GACD,OAAO,SAASC,mBAAmBC,KAAa;IAC9C,MAAMC,OAAO,IAAIC;IACjB,MAAMC,SAAmB,EAAE;IAC3B,KAAK,MAAMC,OAAOJ,MAAMK,KAAK,CAAC,SAAU;QACtC,MAAMC,OAAOF,IAAIG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AI,CAAC;AACpC;AAEA,kEAAkE,GAClE,OAAO,SAASC,mBACdC,OAAY;IAEZ,OAAO;WAAIA;KAAQ,CAACC,IAAI,CACtB,CAACC,GAAGC;YACDD,UACEC,UACID,QAAkCC;eAFzC,EAACD,WAAAA,EAAEpB,KAAK,YAAPoB,WAAWE,OAAOC,gBAAgB,MAChCF,WAAAA,EAAErB,KAAK,YAAPqB,WAAWC,OAAOC,gBAAgB,KACrC9B,QAAO2B,SAAAA,EAAEI,GAAG,YAALJ,SAAS,IAAIK,aAAa,CAAChC,QAAO4B,SAAAA,EAAEG,GAAG,YAALH,SAAS;;AAExD"}
|
package/src/lib/plugin.d.ts
CHANGED
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
/**
|
|
18
|
+
* The org datasets card, split the same way: it loads where the `orgData`
|
|
19
|
+
* slot mounts it (or inside the Data page's own chunk), not with the plugin.
|
|
20
|
+
*/
|
|
21
|
+
export declare const HostDatasetsCard: import("react").LazyExoticComponent<typeof import("./components/host-datasets-card.component").HostDatasetsCard>;
|
|
17
22
|
/**
|
|
18
23
|
* Data feature plugin (AGL-395). Console-only — datasets are org-shared
|
|
19
24
|
* document collections consumed by repeatable components at render time
|
|
@@ -35,5 +40,4 @@
|
|
|
35
40
|
* imported only to run one (AGL-3025).
|
|
36
41
|
*/
|
|
37
42
|
export declare function registerDataConsole(): void;
|
|
38
|
-
export { default as HostDatasetsCard } from './components/host-datasets-card.component';
|
|
39
43
|
export type { HostDatasetsCardProps } from './components/host-datasets-card.component';
|
package/src/lib/plugin.js
CHANGED
|
@@ -14,8 +14,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/ import
|
|
18
|
-
import { datasetInstanceImportAccess } from "./components/use-dataset-writes-blocked.js";
|
|
17
|
+
*/ import { datasetInstanceImportAccess } from "./components/use-dataset-writes-blocked.js";
|
|
19
18
|
import * as Aglyn from "@aglyn/aglyn";
|
|
20
19
|
import { registerRepeatSource } from "@aglyn/aglyn/app-utils/repeat-sources";
|
|
21
20
|
import { mdiDatabaseOutline } from "@aglyn/shared-data-mdi";
|
|
@@ -35,6 +34,10 @@ import { registerDataRecordRoutes } from "./model/data-record-routes.js";
|
|
|
35
34
|
import RecordTemplateRowChip from "./record-pages/record-template-row-chip.component.js";
|
|
36
35
|
import RecordTemplateSection from "./record-pages/record-template-section.component.js";
|
|
37
36
|
/** Code-split: the Data console page only loads when opened. */ const DataConsolePage = lazy(()=>import("./components/data-console-page.js"));
|
|
37
|
+
/**
|
|
38
|
+
* The org datasets card, split the same way: it loads where the `orgData`
|
|
39
|
+
* slot mounts it (or inside the Data page's own chunk), not with the plugin.
|
|
40
|
+
*/ export const HostDatasetsCard = lazy(()=>import("./components/host-datasets-card.component.js"));
|
|
38
41
|
/**
|
|
39
42
|
* Data feature plugin (AGL-395). Console-only — datasets are org-shared
|
|
40
43
|
* document collections consumed by repeatable components at render time
|
|
@@ -118,6 +121,9 @@ import RecordTemplateSection from "./record-pages/record-template-section.compon
|
|
|
118
121
|
{
|
|
119
122
|
label: 'Data',
|
|
120
123
|
href: '/data',
|
|
124
|
+
// Each dataset is a tab of the page, at `/data/<datasetId>` (AGL-4047).
|
|
125
|
+
ownsSubtree: true,
|
|
126
|
+
recordTitle: 'Dataset',
|
|
121
127
|
// Reuse the existing release-flag nav-tab so staff-preview gating is
|
|
122
128
|
// unchanged now that the tab comes from the plugin (AGL-395).
|
|
123
129
|
navTabId: 'nav-tab-data',
|
|
@@ -136,6 +142,5 @@ import RecordTemplateSection from "./record-pages/record-template-section.compon
|
|
|
136
142
|
]
|
|
137
143
|
});
|
|
138
144
|
}
|
|
139
|
-
export { default as HostDatasetsCard } from "./components/host-datasets-card.component.js";
|
|
140
145
|
|
|
141
146
|
//# sourceMappingURL=plugin.js.map
|
package/src/lib/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/plugins/data/src/lib/plugin.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/plugins/data/src/lib/plugin.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { datasetInstanceImportAccess } from './components/use-dataset-writes-blocked'\nimport * as Aglyn from '@aglyn/aglyn'\nimport { registerRepeatSource } from '@aglyn/aglyn/app-utils/repeat-sources'\nimport { mdiDatabaseOutline } from '@aglyn/shared-data-mdi'\nimport { lazy } from 'react'\nimport { BUNDLE_ID } from './constants/bundle-common'\nimport { registerDatasetRecordList } from './model/dataset-record-list'\nimport { registerPageRecordSource } from '@aglyn/aglyn/app-utils/page-record-sources'\nimport { registerPluginTransferResourceUi } from '@aglyn/aglyn/plugin-manager/plugin-transfer-resources'\nimport { DATASET_TRANSFER_RESOURCE } from './transfer/dataset-transfer-key'\nimport { DATASET_REPEAT_SOURCE } from './repeat/dataset-repeat-source'\nimport { DATASET_IMAGE_FIELD } from './model/dataset-image-field'\nimport { DATASET_PAGE_FIELD } from './model/dataset-page-field'\nimport { DatasetImageFieldInput, DatasetPageFieldInput } from './components/dataset-field-inputs.component'\nimport { RECORD_PAGE_ADDRESS_FIELD } from './record-pages/record-pages'\nimport { RECORD_PAGE_SOURCE } from './record-pages/record-page-source'\nimport { registerDataRecordRoutes } from './model/data-record-routes'\nimport RecordTemplateRowChip from './record-pages/record-template-row-chip.component'\nimport RecordTemplateSection from './record-pages/record-template-section.component'\n\n/** Code-split: the Data console page only loads when opened. */\nconst DataConsolePage = lazy(() => import('./components/data-console-page'))\n/**\n * The org datasets card, split the same way: it loads where the `orgData`\n * slot mounts it (or inside the Data page's own chunk), not with the plugin.\n */\nexport const HostDatasetsCard = lazy(() => import('./components/host-datasets-card.component'))\n\n/**\n * Data feature plugin (AGL-395). Console-only — datasets are org-shared\n * document collections consumed by repeatable components at render time\n * through binding resolution, not a canvas element of their own, so there\n * is no UI bundle. The console half declares the host Data nav + page\n * through the ConsoleExtension registry, gated by the `dataStore`\n * entitlement. The org Data page (`Route.ORG_DATA`) is an org-scoped app route\n * that imports {@link HostDatasetsCard} directly.\n *\n * Record pages (AGL-3475) add a section to the besigner's Page Properties, a\n * chip to the Pages list's rows, and the page-record source that draws a\n * record template on the canvas for one of its records.\n *\n * It also registers datasets as a repeat source (AGL-3111), which is what puts\n * \"Repeat over dataset\" on every element's Attributes panel and draws a\n * repeat's copies from the real rows on the besigner canvas. Registered here,\n * inside the function the loader calls by name, and never by a module's own\n * load: this package declares no side effects, so a bundler deletes a module\n * imported only to run one (AGL-3025).\n */\nexport function registerDataConsole(): void {\n registerRepeatSource(DATASET_REPEAT_SOURCE)\n // The \"Page address\" field type (AGL-3475), for the schema dialog's type\n // list and the record editor's checks.\n Aglyn.registerCustomFieldType(RECORD_PAGE_ADDRESS_FIELD)\n // A record's photo (AGL-3616), which a page's Image binds, and its page\n // (AGL-3763), which a Button or Link binds — each chosen from a picker in\n // the record editor, never typed.\n Aglyn.registerCustomFieldType({ ...DATASET_IMAGE_FIELD, Input: DatasetImageFieldInput })\n Aglyn.registerCustomFieldType({ ...DATASET_PAGE_FIELD, Input: DatasetPageFieldInput })\n // A record template draws on the canvas for one of its records (AGL-3475).\n registerPageRecordSource(RECORD_PAGE_SOURCE)\n // The workspace's datasets, for another plugin's picker (AGL-3080).\n registerDatasetRecordList()\n // …and where one is read, for a surface that links it (AGL-3616): an AI\n // job's dataset opens on the Data page.\n registerDataRecordRoutes()\n // A dataset's records in the import wizard and the export dialog\n // (AGL-3530); the Data card names the dataset when it opens them.\n registerPluginTransferResourceUi(\n DATASET_TRANSFER_RESOURCE,\n // The Import & export hub lists each dataset from the `dataset` record list (AGL-3535).\n // Its Import there answers as this one's does on the Data page (AGL-4047).\n {\n label: 'Dataset records',\n icon: { path: mdiDatabaseOutline.path },\n instancesFrom: 'dataset',\n instanceImportAccess: datasetInstanceImportAccess,\n },\n { pluginId: BUNDLE_ID },\n )\n Aglyn.registerConsoleExtension({\n // Org datasets card (AGL-419): org/data renders it through the\n // 'orgData' widget slot.\n widgets: [\n {\n slot: 'orgData',\n widgetId: 'data-org-datasets',\n Component: HostDatasetsCard,\n },\n // Record pages (AGL-3475): the template's settings in Page Properties,\n // and its chip in the Pages list.\n {\n slot: 'besignerPageProperties',\n widgetId: 'data-record-template',\n Component: RecordTemplateSection,\n },\n {\n slot: 'hostScreenRow',\n widgetId: 'data-record-template-chip',\n Component: RecordTemplateRowChip,\n },\n ],\n pluginId: BUNDLE_ID,\n displayName: 'Data',\n featureFlag: 'dataStore',\n navItems: [\n {\n label: 'Data',\n href: '/data',\n // Each dataset is a tab of the page, at `/data/<datasetId>` (AGL-4047).\n ownsSubtree: true,\n recordTitle: 'Dataset',\n // Reuse the existing release-flag nav-tab so staff-preview gating is\n // unchanged now that the tab comes from the plugin (AGL-395).\n navTabId: 'nav-tab-data',\n icon: { path: mdiDatabaseOutline.path },\n header: {\n title: 'Data',\n icon: { path: mdiDatabaseOutline.path },\n docsTopic: 'datasets',\n },\n Component: DataConsolePage,\n },\n ],\n })\n}\n\nexport type { HostDatasetsCardProps } from './components/host-datasets-card.component'\n"],"names":["datasetInstanceImportAccess","Aglyn","registerRepeatSource","mdiDatabaseOutline","lazy","BUNDLE_ID","registerDatasetRecordList","registerPageRecordSource","registerPluginTransferResourceUi","DATASET_TRANSFER_RESOURCE","DATASET_REPEAT_SOURCE","DATASET_IMAGE_FIELD","DATASET_PAGE_FIELD","DatasetImageFieldInput","DatasetPageFieldInput","RECORD_PAGE_ADDRESS_FIELD","RECORD_PAGE_SOURCE","registerDataRecordRoutes","RecordTemplateRowChip","RecordTemplateSection","DataConsolePage","HostDatasetsCard","registerDataConsole","registerCustomFieldType","Input","label","icon","path","instancesFrom","instanceImportAccess","pluginId","registerConsoleExtension","widgets","slot","widgetId","Component","displayName","featureFlag","navItems","href","ownsSubtree","recordTitle","navTabId","header","title","docsTopic"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,2BAA2B,QAAQ,6CAAyC;AACrF,YAAYC,WAAW,eAAc;AACrC,SAASC,oBAAoB,QAAQ,wCAAuC;AAC5E,SAASC,kBAAkB,QAAQ,yBAAwB;AAC3D,SAASC,IAAI,QAAQ,QAAO;AAC5B,SAASC,SAAS,QAAQ,+BAA2B;AACrD,SAASC,yBAAyB,QAAQ,iCAA6B;AACvE,SAASC,wBAAwB,QAAQ,6CAA4C;AACrF,SAASC,gCAAgC,QAAQ,wDAAuD;AACxG,SAASC,yBAAyB,QAAQ,qCAAiC;AAC3E,SAASC,qBAAqB,QAAQ,oCAAgC;AACtE,SAASC,mBAAmB,QAAQ,iCAA6B;AACjE,SAASC,kBAAkB,QAAQ,gCAA4B;AAC/D,SAASC,sBAAsB,EAAEC,qBAAqB,QAAQ,iDAA6C;AAC3G,SAASC,yBAAyB,QAAQ,iCAA6B;AACvE,SAASC,kBAA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