@aglyn/plugins-data 1.14.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 +4 -1
- 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 +29 -47
- 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 +651 -220
- package/src/lib/components/host-datasets-card.component.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/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-drafts.js +2 -0
- package/src/lib/server/dataset-drafts.js.map +1 -1
- package/src/lib/server/datasets-route.js +2 -1
- package/src/lib/server/datasets-route.js.map +1 -1
- package/src/lib/site-bundle/datasets-site-bundle.server.js +8 -1
- package/src/lib/site-bundle/datasets-site-bundle.server.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-data",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,21 +25,23 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.
|
|
29
|
-
"@aglyn/shared-data-mdi": "1.
|
|
30
|
-
"@aglyn/shared-ui-jsx": "1.
|
|
31
|
-
"@aglyn/shared-ui-
|
|
32
|
-
"@aglyn/shared-
|
|
33
|
-
"@aglyn/shared-util-
|
|
34
|
-
"@aglyn/
|
|
35
|
-
"@aglyn/tenant-
|
|
36
|
-
"@aglyn/tenant-
|
|
28
|
+
"@aglyn/aglyn": "1.15.0",
|
|
29
|
+
"@aglyn/shared-data-mdi": "1.15.0",
|
|
30
|
+
"@aglyn/shared-ui-jsx": "1.15.0",
|
|
31
|
+
"@aglyn/shared-ui-next": "1.15.0",
|
|
32
|
+
"@aglyn/shared-ui-snackstack": "1.15.0",
|
|
33
|
+
"@aglyn/shared-util-http": "1.15.0",
|
|
34
|
+
"@aglyn/shared-util-timestamp": "1.15.0",
|
|
35
|
+
"@aglyn/tenant-data-admin": "1.15.0",
|
|
36
|
+
"@aglyn/tenant-feature-instance": "1.15.0",
|
|
37
|
+
"@aglyn/tenant-runtime": "1.15.0",
|
|
37
38
|
"@swc/helpers": "0.5.23"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"@mui/material": "^9.3.1",
|
|
41
42
|
"firebase": "^13.0.0",
|
|
42
43
|
"firebase-admin": "^14.3.0",
|
|
44
|
+
"next": "^16.3.3",
|
|
43
45
|
"react": "^19.2.8"
|
|
44
46
|
},
|
|
45
47
|
"sideEffects": false,
|
|
@@ -18,6 +18,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
18
18
|
import { sharingCovers } from "@aglyn/aglyn/app-utils/scope-tokens";
|
|
19
19
|
import { firebaseAdmin } from "@aglyn/tenant-data-admin";
|
|
20
20
|
import { resolveInstalledDatasetSchema, sanitizeDatasetSchema, summarizeSchemaChange } from "./dataset-schema.js";
|
|
21
|
+
import { datasetNameLower } from "../model/datasets.js";
|
|
21
22
|
/**
|
|
22
23
|
* A dataset's schema as an installable artifact (AGL-657), answered by the
|
|
23
24
|
* plugin that keeps datasets (AGL-3080).
|
|
@@ -203,8 +204,10 @@ const overDatasetQuota = (limit)=>refuse(403, `Dataset limit reached (${limit})
|
|
|
203
204
|
const live = (await tx.get(datasetsRef.count())).data().count;
|
|
204
205
|
const authoritative = checkDatasetQuota(org, live);
|
|
205
206
|
if (!authoritative.allowed) return overDatasetQuota(authoritative.limit);
|
|
207
|
+
const displayName = String((_listing_displayName = listing.displayName) != null ? _listing_displayName : 'Dataset').slice(0, 120);
|
|
206
208
|
tx.create(datasetsRef.doc(datasetId), _extends({
|
|
207
|
-
displayName
|
|
209
|
+
displayName,
|
|
210
|
+
nameLower: datasetNameLower(displayName)
|
|
208
211
|
}, listing.description ? {
|
|
209
212
|
description: listing.description
|
|
210
213
|
} : {}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/data/src/lib/artifact/dataset-schema-artifact.server.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 {\n checkDatasetQuota,\n checkEntitlement,\n createResourceUid,\n defaultScopeForNewResource,\n newResourceScopeFields,\n} from '@aglyn/aglyn/server'\nimport { sharingCovers } from '@aglyn/aglyn/app-utils/scope-tokens'\nimport type {\n ArtifactInstallRequest,\n ArtifactLocateRequest,\n ArtifactRefusal,\n ArtifactSnapshot,\n ArtifactSnapshotRequest,\n ArtifactWorkspace,\n InstalledArtifactCopy,\n PluginArtifactOwner,\n PreparedArtifactInstall,\n} from '@aglyn/aglyn/plugin-manager/plugin-artifact-types'\nimport { firebaseAdmin } from '@aglyn/tenant-data-admin'\nimport {\n resolveInstalledDatasetSchema,\n sanitizeDatasetSchema,\n summarizeSchemaChange,\n type PublishedDatasetSchema,\n} from './dataset-schema'\n\n/**\n * A dataset's schema as an installable artifact (AGL-657), answered by the\n * plugin that keeps datasets (AGL-3080).\n *\n * The installer (the marketplace) owns the listing, who may act on it, the\n * purchase, the provenance stamp and the tally, and asks these four answers\n * for everything that touches `orgs/{orgId}/datasets`, which it never reads.\n * Registered from `declarations.console-server.ts` and loaded with the first\n * publish, install or update.\n */\n\nconst refuse = (status: number, error: string): ArtifactRefusal => ({\n ok: false,\n status,\n error,\n})\n\nconst datasetsOf = (orgId: string) =>\n firebaseAdmin.app().firestore().collection('orgs').doc(orgId).collection('datasets')\n\nconst overDatasetQuota = (limit: number): ArtifactRefusal =>\n refuse(403, `Dataset limit reached (${limit}) — see Billing to upgrade.`)\n\n/**\n * PUBLISHING: an org dataset's SCHEMA, reduced to what travels.\n *\n * Datasets live at `orgs/{orgId}/datasets/{id}` and are org-shared (AGL-237),\n * so the source is named by the publishing org and the dataset's id.\n *\n * Records NEVER travel: `sanitizeDatasetSchema` reads the model, and nothing\n * here touches the `records` subcollection. A dataset's rows are the org's\n * customer data; only the shape is publishable.\n */\nexport async function snapshotDatasetSchema(\n request: ArtifactSnapshotRequest,\n): Promise<ArtifactSnapshot | ArtifactRefusal> {\n const datasets = datasetsOf(request.orgId)\n const datasetSnapshot = await datasets.doc(request.sourceId).get()\n const dataset = datasetSnapshot.data() as any\n if (!datasetSnapshot.exists || dataset?.deletedAt) {\n return refuse(404, 'Unknown dataset')\n }\n // v1 datasets carry a flat `fields: string[]` with no model; publish the\n // derived shape so unmigrated datasets are publishable too (AGL-102 shim,\n // inlined rather than importing core's deriveModelFromFields to keep the\n // sanitizer's input one plain shape).\n const model = dataset?.model?.fields\n ? dataset.model\n : {\n fields: Object.fromEntries(\n (Array.isArray(dataset?.fields) ? dataset.fields : []).map(\n (name: unknown) => [String(name), { name: String(name), type: 'text' }],\n ),\n ),\n order: (Array.isArray(dataset?.fields) ? dataset.fields : []).map(String),\n }\n\n const sanitized = sanitizeDatasetSchema(model)\n if (sanitized.ok === false) return refuse(422, sanitized.error)\n\n // Reference fields name a dataset id that means nothing outside this org,\n // so resolve each target's display name now: the installer relinks by that\n // label (see resolveInstalledDatasetSchema).\n const referenced = new Set(\n Object.values(sanitized.schema.fields)\n .map((field) => field.reference?.datasetId)\n .filter((id): id is string => Boolean(id)),\n )\n if (referenced.size) {\n const labels = new Map<string, string>()\n await Promise.all(\n [...referenced].map(async (id) => {\n const snapshot = await datasets.doc(id).get()\n const label = snapshot.get('displayName')\n if (label) labels.set(id, String(label))\n }),\n )\n for (const field of Object.values(sanitized.schema.fields)) {\n const target = field.reference?.datasetId\n if (target && labels.has(target)) {\n field.reference = {\n ...field.reference,\n datasetLabel: labels.get(target),\n }\n }\n }\n }\n return {\n ok: true,\n content: sanitized.schema,\n facts: { fieldCount: sanitized.schema.order.length },\n }\n}\n\n/** INSTALLING, before the listing is read: datasets are a plan feature. */\nexport async function admitsDatasetSchema(\n workspace: ArtifactWorkspace,\n): Promise<ArtifactRefusal | null> {\n if (!checkEntitlement(workspace.org as any, 'dataStore')) {\n return refuse(403, 'Datasets require a Starter plan or higher')\n }\n return null\n}\n\n/**\n * INSTALLING: a NEW, EMPTY dataset made from the published model.\n *\n * Installing never merges into an existing dataset, because a schema change\n * on a dataset that already holds rows would silently reinterpret live data.\n * Re-installing makes another dataset rather than replacing one, for the same\n * reason.\n *\n * Nothing is written until `commit`, which the installer calls once it has\n * recorded the provenance of exactly the content prepared here.\n */\nexport async function prepareDatasetSchemaInstall(\n request: ArtifactInstallRequest,\n): Promise<PreparedArtifactInstall | ArtifactRefusal> {\n const published = request.published as PublishedDatasetSchema | undefined\n if (!published?.order?.length) {\n return refuse(500, 'Dataset schema version missing')\n }\n const org = request.org as any\n const datasetsRef = datasetsOf(request.orgId)\n\n // Creating a dataset consumes org quota exactly like the console's own\n // create path (AGL-473): installing must not be a way around it.\n // Deliberately counts EVERY dataset the org owns, not the visible ones\n // (AGL-1046). Scoping decides who can see a dataset, never who pays for\n // it: the org owns all of them. Counting per scope would also make a\n // collaborator's remaining quota disagree with the admin's.\n //\n // This is the early answer, so a workspace already at its cap is refused\n // before the installer records any provenance. The one that holds is in\n // `commit`, below.\n const datasets = await datasetsRef.get()\n const quota = checkDatasetQuota(org, datasets.size)\n if (!quota.allowed) return overDatasetQuota(quota.limit)\n\n /**\n * Who the new dataset is shared with. Decided before relinking, because\n * it also decides what a reference field may point at.\n *\n * A dataset schema installs at ORGANIZATION scope and nowhere else\n * (`INSTALL_TARGETS.datasetSchema`), from the organization Marketplace, the\n * one surface that installs anything. The site that surface acts THROUGH\n * only finds the org: the org's first site, not a site anyone is working\n * in, and it never reaches here. So no site is in context, and the dataset\n * starts where a create on an organization page starts: All sites, whatever\n * the org's Default sharing says. Honoring the acting site instead would\n * hide the dataset from every other site, under an install dialog that\n * says it lands on \"the whole organization — every site\" (AGL-2891).\n */\n const visibleTo = defaultScopeForNewResource({\n defaultResourceScope: org?.defaultResourceScope,\n hostId: null,\n })\n\n // Relink reference fields onto this org's datasets by display name; what\n // can't be relinked degrades to text and is reported to the installer.\n // A candidate has to be visible everywhere the new dataset is, which is\n // the rule every reference answers to (`sharingCovers`, AGL-1044): one\n // pointing at a dataset some of those sites cannot see resolves to nothing\n // there, and nothing says why. That is also what keeps an install from\n // binding its reference fields to an agency's internal dataset of the same\n // name (AGL-1046): the display-name collision AGL-1039 fixed on the render\n // path, arriving here instead.\n const byLabel: Record<string, string> = {}\n for (const entry of datasets.docs) {\n if (!sharingCovers(entry.data(), { visibleTo })) continue\n const label = String(entry.get('displayName') ?? '').toLowerCase()\n if (label && !byLabel[label]) byLabel[label] = entry.id\n }\n const { schema, degradedFieldIds } = resolveInstalledDatasetSchema(\n published,\n byLabel,\n )\n const datasetId = createResourceUid()\n const { listing } = request\n\n return {\n ok: true,\n // The RELINKED schema, not the published one, is what the base snapshot\n // records (AGL-1015): relinking rewrites reference fields onto this org's\n // datasets, so a base holding the publisher's ids would report every\n // relinked field as a user edit the moment anything is diffed.\n content: schema,\n /**\n * THE ENFORCEMENT POINT (AGL-3454, the AGL-2371 treatment): the count,\n * the decision and the create in ONE transaction.\n *\n * The count above is taken before the installer awaits the provenance\n * write, and every await is a yield: N installs in flight each read the\n * same pre-count, each find room, and each land, and nothing re-counts\n * afterwards. `tx.get` on the aggregate takes a pessimistic lock on the\n * documents the query matched, so the loser of a race retries, re-reads\n * the higher count and is refused, having written nothing.\n *\n * The org document is read outside, as the console's create path reads\n * it: the plan and the purchased add-ons are not client-writable, so\n * locking it would buy contention rather than correctness.\n */\n commit: async (stamp) => {\n const refused = await firebaseAdmin\n .app()\n .firestore()\n .runTransaction<ArtifactRefusal | null>(async (tx) => {\n const live = (await tx.get(datasetsRef.count())).data().count\n const authoritative = checkDatasetQuota(org, live)\n if (!authoritative.allowed) return overDatasetQuota(authoritative.limit)\n tx.create(datasetsRef.doc(datasetId), {\n displayName: String(listing.displayName ?? 'Dataset').slice(0, 120),\n ...(listing.description ? { description: listing.description } : {}),\n // `fields` is the v1 flat list the older editor still reads; keep it\n // in step with the model so both readers agree (AGL-102).\n fields: schema.order,\n model: schema,\n source: stamp.source,\n installedFrom: stamp.installedFrom,\n // The scope decided above. Stamping it is not optional: a dataset\n // with no `visibleTo` matches no scoped read and would render on no\n // site at all.\n //\n // Through the AGL-1478 gate since AGL-1484, so \"every other dataset\n // creator\" is a fact about the type rather than about four object\n // literals that happen to agree today.\n ...newResourceScopeFields(visibleTo),\n createdAt: firebaseAdmin.firestore.FieldValue.serverTimestamp(),\n })\n return null\n })\n if (refused) return refused\n return {\n ok: true,\n report: { datasetId, fields: schema.order.length, degradedFieldIds },\n }\n },\n }\n}\n\n/**\n * UPDATING: the dataset a listing installed in the site's organization, and\n * what taking the version on offer would do to its records (AGL-1018).\n *\n * The incoming schema is relinked onto THIS org's datasets exactly as install\n * does. The base holds the relinked shape, so diffing the published one would\n * report every reference field as a user edit.\n *\n * A dataset's update is a merge or nothing. Its \"new copy\" would be a whole\n * new dataset, which consumes org quota and lands empty: exactly what the\n * install already does, with the quota check an update does not have.\n */\nexport async function locateInstalledDatasetSchema(\n request: ArtifactLocateRequest,\n): Promise<InstalledArtifactCopy | ArtifactRefusal> {\n if (!request.orgId) return refuse(404, 'Site has no owning organization')\n const datasets = await datasetsOf(request.orgId).get()\n const doc = datasets.docs.find(\n (entry) =>\n entry.get('source.listingId') === request.listingId && !entry.get('deletedAt'),\n )\n if (!doc) return refuse(404, 'Not installed in this organization')\n const byLabel: Record<string, string> = {}\n for (const entry of datasets.docs) {\n const label = String(entry.get('displayName') ?? '').toLowerCase()\n if (label && !byLabel[label]) byLabel[label] = entry.id\n }\n const { schema } = resolveInstalledDatasetSchema(\n request.published as PublishedDatasetSchema,\n byLabel,\n )\n const current = doc.get('model') ?? { order: doc.get('fields') ?? [], fields: {} }\n const summary = summarizeSchemaChange(current as any, schema as any)\n // The count is read for the preview, not estimated: \"3 fields will be\n // removed\" means nothing without \"from 1,240 records\".\n const records = await doc.ref\n .collection('records')\n .count()\n .get()\n .catch(() => null)\n const recordCount = records?.data().count ?? 0\n return {\n ok: true,\n current,\n incoming: schema,\n installedVersion:\n String(doc.get('installedFrom.version') ?? doc.get('source.version') ?? '') || null,\n baseSha: doc.get('installedFrom.sha256') ?? null,\n // A schema change that removes or retypes a field reinterprets rows that\n // already exist. It is applicable, but never without the caller having\n // been told the count and said yes to it specifically.\n impact: {\n preview: {\n schema: {\n added: summary.added,\n removed: summary.removed,\n retyped: summary.retyped,\n additiveOnly: summary.additiveOnly,\n recordCount,\n },\n },\n destructive: !summary.additiveOnly,\n refusal:\n `This update removes or retypes ${\n summary.removed.length + summary.retyped.length\n } field(s) on a dataset holding ${recordCount} record(s).`,\n },\n apply: async ({ content, stamp }) => {\n await doc.ref.set(\n {\n model: content,\n // The v1 flat list the older editor still reads, kept in step.\n fields: (content as PublishedDatasetSchema | undefined)?.order ?? [],\n installedFrom: stamp.installedFrom,\n source: stamp.source,\n updatedAt: firebaseAdmin.firestore.FieldValue.serverTimestamp(),\n },\n { merge: true },\n )\n },\n }\n}\n\n/** The four answers, as the owner registers them. */\nexport const datasetSchemaArtifactOwner: PluginArtifactOwner = {\n snapshot: snapshotDatasetSchema,\n admits: admitsDatasetSchema,\n prepare: prepareDatasetSchemaInstall,\n locate: locateInstalledDatasetSchema,\n}\n"],"names":["checkDatasetQuota","checkEntitlement","createResourceUid","defaultScopeForNewResource","newResourceScopeFields","sharingCovers","firebaseAdmin","resolveInstalledDatasetSchema","sanitizeDatasetSchema","summarizeSchemaChange","refuse","status","error","ok","datasetsOf","orgId","app","firestore","collection","doc","overDatasetQuota","limit","snapshotDatasetSchema","request","dataset","datasets","datasetSnapshot","sourceId","get","data","exists","deletedAt","model","fields","Object","fromEntries","Array","isArray","map","name","String","type","order","sanitized","referenced","Set","values","schema","field","reference","datasetId","filter","id","Boolean","size","labels","Map","Promise","all","snapshot","label","set","target","has","datasetLabel","content","facts","fieldCount","length","admitsDatasetSchema","workspace","org","prepareDatasetSchemaInstall","published","datasetsRef","quota","allowed","visibleTo","defaultResourceScope","hostId","byLabel","entry","docs","toLowerCase","degradedFieldIds","listing","commit","stamp","refused","runTransaction","tx","live","count","authoritative","create","displayName","slice","description","source","installedFrom","createdAt","FieldValue","serverTimestamp","report","locateInstalledDatasetSchema","find","listingId","current","summary","records","ref","catch","recordCount","incoming","installedVersion","baseSha","impact","preview","added","removed","retyped","additiveOnly","destructive","refusal","apply","updatedAt","merge","datasetSchemaArtifactOwner","admits","prepare","locate"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,iBAAiB,EACjBC,gBAAgB,EAChBC,iBAAiB,EACjBC,0BAA0B,EAC1BC,sBAAsB,QACjB,sBAAqB;AAC5B,SAASC,aAAa,QAAQ,sCAAqC;AAYnE,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SACEC,6BAA6B,EAC7BC,qBAAqB,EACrBC,qBAAqB,QAEhB,sBAAkB;AAEzB;;;;;;;;;CASC,GAED,MAAMC,SAAS,CAACC,QAAgBC,QAAoC,CAAA;QAClEC,IAAI;QACJF;QACAC;IACF,CAAA;AAEA,MAAME,aAAa,CAACC,QAClBT,cAAcU,GAAG,GAAGC,SAAS,GAAGC,UAAU,CAAC,QAAQC,GAAG,CAACJ,OAAOG,UAAU,CAAC;AAE3E,MAAME,mBAAmB,CAACC,QACxBX,OAAO,KAAK,CAAC,uBAAuB,EAAEW,MAAM,2BAA2B,CAAC;AAE1E;;;;;;;;;CASC,GACD,OAAO,eAAeC,sBACpBC,OAAgC;QAYlBC;IAVd,MAAMC,WAAWX,WAAWS,QAAQR,KAAK;IACzC,MAAMW,kBAAkB,MAAMD,SAASN,GAAG,CAACI,QAAQI,QAAQ,EAAEC,GAAG;IAChE,MAAMJ,UAAUE,gBAAgBG,IAAI;IACpC,IAAI,CAACH,gBAAgBI,MAAM,KAAIN,2BAAAA,QAASO,SAAS,GAAE;QACjD,OAAOrB,OAAO,KAAK;IACrB;IACA,yEAAyE;IAC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D,AAACA,QAAgDvB,KAAK,mBAAI,EAAE;gBACpEyD,eAAeZ,MAAMY,aAAa;gBAClCD,QAAQX,MAAMW,MAAM;gBACpB2B,WAAWvH,cAAcW,SAAS,CAACoF,UAAU,CAACC,eAAe;YAC/D,GACA;gBAAEwB,OAAO;YAAK;QAElB;IACF;AACF;AAEA,mDAAmD,GACnD,OAAO,MAAMC,6BAAkD;IAC7DpE,UAAUrC;IACV0G,QAAQ3D;IACR4D,SAASzD;IACT0D,QAAQ1B;AACV,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/data/src/lib/artifact/dataset-schema-artifact.server.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 {\n checkDatasetQuota,\n checkEntitlement,\n createResourceUid,\n defaultScopeForNewResource,\n newResourceScopeFields,\n} from '@aglyn/aglyn/server'\nimport { sharingCovers } from '@aglyn/aglyn/app-utils/scope-tokens'\nimport type {\n ArtifactInstallRequest,\n ArtifactLocateRequest,\n ArtifactRefusal,\n ArtifactSnapshot,\n ArtifactSnapshotRequest,\n ArtifactWorkspace,\n InstalledArtifactCopy,\n PluginArtifactOwner,\n PreparedArtifactInstall,\n} from '@aglyn/aglyn/plugin-manager/plugin-artifact-types'\nimport { firebaseAdmin } from '@aglyn/tenant-data-admin'\nimport {\n resolveInstalledDatasetSchema,\n sanitizeDatasetSchema,\n summarizeSchemaChange,\n type PublishedDatasetSchema,\n} from './dataset-schema'\nimport { datasetNameLower } from '../model/datasets'\n\n/**\n * A dataset's schema as an installable artifact (AGL-657), answered by the\n * plugin that keeps datasets (AGL-3080).\n *\n * The installer (the marketplace) owns the listing, who may act on it, the\n * purchase, the provenance stamp and the tally, and asks these four answers\n * for everything that touches `orgs/{orgId}/datasets`, which it never reads.\n * Registered from `declarations.console-server.ts` and loaded with the first\n * publish, install or update.\n */\n\nconst refuse = (status: number, error: string): ArtifactRefusal => ({\n ok: false,\n status,\n error,\n})\n\nconst datasetsOf = (orgId: string) =>\n firebaseAdmin.app().firestore().collection('orgs').doc(orgId).collection('datasets')\n\nconst overDatasetQuota = (limit: number): ArtifactRefusal =>\n refuse(403, `Dataset limit reached (${limit}) — see Billing to upgrade.`)\n\n/**\n * PUBLISHING: an org dataset's SCHEMA, reduced to what travels.\n *\n * Datasets live at `orgs/{orgId}/datasets/{id}` and are org-shared (AGL-237),\n * so the source is named by the publishing org and the dataset's id.\n *\n * Records NEVER travel: `sanitizeDatasetSchema` reads the model, and nothing\n * here touches the `records` subcollection. A dataset's rows are the org's\n * customer data; only the shape is publishable.\n */\nexport async function snapshotDatasetSchema(\n request: ArtifactSnapshotRequest,\n): Promise<ArtifactSnapshot | ArtifactRefusal> {\n const datasets = datasetsOf(request.orgId)\n const datasetSnapshot = await datasets.doc(request.sourceId).get()\n const dataset = datasetSnapshot.data() as any\n if (!datasetSnapshot.exists || dataset?.deletedAt) {\n return refuse(404, 'Unknown dataset')\n }\n // v1 datasets carry a flat `fields: string[]` with no model; publish the\n // derived shape so unmigrated datasets are publishable too (AGL-102 shim,\n // inlined rather than importing core's deriveModelFromFields to keep the\n // sanitizer's input one plain shape).\n const model = dataset?.model?.fields\n ? dataset.model\n : {\n fields: Object.fromEntries(\n (Array.isArray(dataset?.fields) ? dataset.fields : []).map(\n (name: unknown) => [String(name), { name: String(name), type: 'text' }],\n ),\n ),\n order: (Array.isArray(dataset?.fields) ? dataset.fields : []).map(String),\n }\n\n const sanitized = sanitizeDatasetSchema(model)\n if (sanitized.ok === false) return refuse(422, sanitized.error)\n\n // Reference fields name a dataset id that means nothing outside this org,\n // so resolve each target's display name now: the installer relinks by that\n // label (see resolveInstalledDatasetSchema).\n const referenced = new Set(\n Object.values(sanitized.schema.fields)\n .map((field) => field.reference?.datasetId)\n .filter((id): id is string => Boolean(id)),\n )\n if (referenced.size) {\n const labels = new Map<string, string>()\n await Promise.all(\n [...referenced].map(async (id) => {\n const snapshot = await datasets.doc(id).get()\n const label = snapshot.get('displayName')\n if (label) labels.set(id, String(label))\n }),\n )\n for (const field of Object.values(sanitized.schema.fields)) {\n const target = field.reference?.datasetId\n if (target && labels.has(target)) {\n field.reference = {\n ...field.reference,\n datasetLabel: labels.get(target),\n }\n }\n }\n }\n return {\n ok: true,\n content: sanitized.schema,\n facts: { fieldCount: sanitized.schema.order.length },\n }\n}\n\n/** INSTALLING, before the listing is read: datasets are a plan feature. */\nexport async function admitsDatasetSchema(\n workspace: ArtifactWorkspace,\n): Promise<ArtifactRefusal | null> {\n if (!checkEntitlement(workspace.org as any, 'dataStore')) {\n return refuse(403, 'Datasets require a Starter plan or higher')\n }\n return null\n}\n\n/**\n * INSTALLING: a NEW, EMPTY dataset made from the published model.\n *\n * Installing never merges into an existing dataset, because a schema change\n * on a dataset that already holds rows would silently reinterpret live data.\n * Re-installing makes another dataset rather than replacing one, for the same\n * reason.\n *\n * Nothing is written until `commit`, which the installer calls once it has\n * recorded the provenance of exactly the content prepared here.\n */\nexport async function prepareDatasetSchemaInstall(\n request: ArtifactInstallRequest,\n): Promise<PreparedArtifactInstall | ArtifactRefusal> {\n const published = request.published as PublishedDatasetSchema | undefined\n if (!published?.order?.length) {\n return refuse(500, 'Dataset schema version missing')\n }\n const org = request.org as any\n const datasetsRef = datasetsOf(request.orgId)\n\n // Creating a dataset consumes org quota exactly like the console's own\n // create path (AGL-473): installing must not be a way around it.\n // Deliberately counts EVERY dataset the org owns, not the visible ones\n // (AGL-1046). Scoping decides who can see a dataset, never who pays for\n // it: the org owns all of them. Counting per scope would also make a\n // collaborator's remaining quota disagree with the admin's.\n //\n // This is the early answer, so a workspace already at its cap is refused\n // before the installer records any provenance. The one that holds is in\n // `commit`, below.\n const datasets = await datasetsRef.get()\n const quota = checkDatasetQuota(org, datasets.size)\n if (!quota.allowed) return overDatasetQuota(quota.limit)\n\n /**\n * Who the new dataset is shared with. Decided before relinking, because\n * it also decides what a reference field may point at.\n *\n * A dataset schema installs at ORGANIZATION scope and nowhere else\n * (`INSTALL_TARGETS.datasetSchema`), from the organization Marketplace, the\n * one surface that installs anything. The site that surface acts THROUGH\n * only finds the org: the org's first site, not a site anyone is working\n * in, and it never reaches here. So no site is in context, and the dataset\n * starts where a create on an organization page starts: All sites, whatever\n * the org's Default sharing says. Honoring the acting site instead would\n * hide the dataset from every other site, under an install dialog that\n * says it lands on \"the whole organization — every site\" (AGL-2891).\n */\n const visibleTo = defaultScopeForNewResource({\n defaultResourceScope: org?.defaultResourceScope,\n hostId: null,\n })\n\n // Relink reference fields onto this org's datasets by display name; what\n // can't be relinked degrades to text and is reported to the installer.\n // A candidate has to be visible everywhere the new dataset is, which is\n // the rule every reference answers to (`sharingCovers`, AGL-1044): one\n // pointing at a dataset some of those sites cannot see resolves to nothing\n // there, and nothing says why. That is also what keeps an install from\n // binding its reference fields to an agency's internal dataset of the same\n // name (AGL-1046): the display-name collision AGL-1039 fixed on the render\n // path, arriving here instead.\n const byLabel: Record<string, string> = {}\n for (const entry of datasets.docs) {\n if (!sharingCovers(entry.data(), { visibleTo })) continue\n const label = String(entry.get('displayName') ?? '').toLowerCase()\n if (label && !byLabel[label]) byLabel[label] = entry.id\n }\n const { schema, degradedFieldIds } = resolveInstalledDatasetSchema(\n published,\n byLabel,\n )\n const datasetId = createResourceUid()\n const { listing } = request\n\n return {\n ok: true,\n // The RELINKED schema, not the published one, is what the base snapshot\n // records (AGL-1015): relinking rewrites reference fields onto this org's\n // datasets, so a base holding the publisher's ids would report every\n // relinked field as a user edit the moment anything is diffed.\n content: schema,\n /**\n * THE ENFORCEMENT POINT (AGL-3454, the AGL-2371 treatment): the count,\n * the decision and the create in ONE transaction.\n *\n * The count above is taken before the installer awaits the provenance\n * write, and every await is a yield: N installs in flight each read the\n * same pre-count, each find room, and each land, and nothing re-counts\n * afterwards. `tx.get` on the aggregate takes a pessimistic lock on the\n * documents the query matched, so the loser of a race retries, re-reads\n * the higher count and is refused, having written nothing.\n *\n * The org document is read outside, as the console's create path reads\n * it: the plan and the purchased add-ons are not client-writable, so\n * locking it would buy contention rather than correctness.\n */\n commit: async (stamp) => {\n const refused = await firebaseAdmin\n .app()\n .firestore()\n .runTransaction<ArtifactRefusal | null>(async (tx) => {\n const live = (await tx.get(datasetsRef.count())).data().count\n const authoritative = checkDatasetQuota(org, live)\n if (!authoritative.allowed) return overDatasetQuota(authoritative.limit)\n const displayName = String(listing.displayName ?? 'Dataset').slice(0, 120)\n tx.create(datasetsRef.doc(datasetId), {\n displayName,\n nameLower: datasetNameLower(displayName),\n ...(listing.description ? { description: listing.description } : {}),\n // `fields` is the v1 flat list the older editor still reads; keep it\n // in step with the model so both readers agree (AGL-102).\n fields: schema.order,\n model: schema,\n source: stamp.source,\n installedFrom: stamp.installedFrom,\n // The scope decided above. Stamping it is not optional: a dataset\n // with no `visibleTo` matches no scoped read and would render on no\n // site at all.\n //\n // Through the AGL-1478 gate since AGL-1484, so \"every other dataset\n // creator\" is a fact about the type rather than about four object\n // literals that happen to agree today.\n ...newResourceScopeFields(visibleTo),\n createdAt: firebaseAdmin.firestore.FieldValue.serverTimestamp(),\n })\n return null\n })\n if (refused) return refused\n return {\n ok: true,\n report: { datasetId, fields: schema.order.length, degradedFieldIds },\n }\n },\n }\n}\n\n/**\n * UPDATING: the dataset a listing installed in the site's organization, and\n * what taking the version on offer would do to its records (AGL-1018).\n *\n * The incoming schema is relinked onto THIS org's datasets exactly as install\n * does. The base holds the relinked shape, so diffing the published one would\n * report every reference field as a user edit.\n *\n * A dataset's update is a merge or nothing. Its \"new copy\" would be a whole\n * new dataset, which consumes org quota and lands empty: exactly what the\n * install already does, with the quota check an update does not have.\n */\nexport async function locateInstalledDatasetSchema(\n request: ArtifactLocateRequest,\n): Promise<InstalledArtifactCopy | ArtifactRefusal> {\n if (!request.orgId) return refuse(404, 'Site has no owning organization')\n const datasets = await datasetsOf(request.orgId).get()\n const doc = datasets.docs.find(\n (entry) =>\n entry.get('source.listingId') === request.listingId && !entry.get('deletedAt'),\n )\n if (!doc) return refuse(404, 'Not installed in this organization')\n const byLabel: Record<string, string> = {}\n for (const entry of datasets.docs) {\n const label = String(entry.get('displayName') ?? '').toLowerCase()\n if (label && !byLabel[label]) byLabel[label] = entry.id\n }\n const { schema } = resolveInstalledDatasetSchema(\n request.published as PublishedDatasetSchema,\n byLabel,\n )\n const current = doc.get('model') ?? { order: doc.get('fields') ?? [], fields: {} }\n const summary = summarizeSchemaChange(current as any, schema as any)\n // The count is read for the preview, not estimated: \"3 fields will be\n // removed\" means nothing without \"from 1,240 records\".\n const records = await doc.ref\n .collection('records')\n .count()\n .get()\n .catch(() => null)\n const recordCount = records?.data().count ?? 0\n return {\n ok: true,\n current,\n incoming: schema,\n installedVersion:\n String(doc.get('installedFrom.version') ?? doc.get('source.version') ?? '') || null,\n baseSha: doc.get('installedFrom.sha256') ?? null,\n // A schema change that removes or retypes a field reinterprets rows that\n // already exist. It is applicable, but never without the caller having\n // been told the count and said yes to it specifically.\n impact: {\n preview: {\n schema: {\n added: summary.added,\n removed: summary.removed,\n retyped: summary.retyped,\n additiveOnly: summary.additiveOnly,\n recordCount,\n },\n },\n destructive: !summary.additiveOnly,\n refusal:\n `This update removes or retypes ${\n summary.removed.length + summary.retyped.length\n } field(s) on a dataset holding ${recordCount} record(s).`,\n },\n apply: async ({ content, stamp }) => {\n await doc.ref.set(\n {\n model: content,\n // The v1 flat list the older editor still reads, kept in step.\n fields: (content as PublishedDatasetSchema | undefined)?.order ?? [],\n installedFrom: stamp.installedFrom,\n source: stamp.source,\n updatedAt: firebaseAdmin.firestore.FieldValue.serverTimestamp(),\n },\n { merge: true },\n )\n },\n }\n}\n\n/** The four answers, as the owner registers them. */\nexport const datasetSchemaArtifactOwner: PluginArtifactOwner = {\n snapshot: snapshotDatasetSchema,\n admits: admitsDatasetSchema,\n prepare: prepareDatasetSchemaInstall,\n locate: locateInstalledDatasetSchema,\n}\n"],"names":["checkDatasetQuota","checkEntitlement","createResourceUid","defaultScopeForNewResource","newResourceScopeFields","sharingCovers","firebaseAdmin","resolveInstalledDatasetSchema","sanitizeDatasetSchema","summarizeSchemaChange","datasetNameLower","refuse","status","error","ok","datasetsOf","orgId","app","firestore","collection","doc","overDatasetQuota","limit","snapshotDatasetSchema","request","dataset","datasets","datasetSnapshot","sourceId","get","data","exists","deletedAt","model","fields","Object","fromEntries","Array","isArray","map","name","String","type","order","sanitized","referenced","Set","values","schema","field","reference","datasetId","filter","id","Boolean","size","labels","Map","Promise","all","snapshot","label","set","target","has","datasetLabel","content","facts","fieldCount","length","admitsDatasetSchema","workspace","org","prepareDatasetSchemaInstall","published","datasetsRef","quota","allowed","visibleTo","defaultResourceScope","hostId","byLabel","entry","docs","toLowerCase","degradedFieldIds","listing","commit","stamp","refused","runTransaction","tx","live","count","authoritative","displayName","slice","create","nameLower","description","source","installedFrom","createdAt","FieldValue","serverTimestamp","report","locateInstalledDatasetSchema","find","listingId","current","summary","records","ref","catch","recordCount","incoming","installedVersion","baseSha","impact","preview","added","removed","retyped","additiveOnly","destructive","refusal","apply","updatedAt","merge","datasetSchemaArtifactOwner","admits","prepare","locate"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,iBAAiB,EACjBC,gBAAgB,EAChBC,iBAAiB,EACjBC,0BAA0B,EAC1BC,sBAAsB,QACjB,sBAAqB;AAC5B,SAASC,aAAa,QAAQ,sCAAqC;AAYnE,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SACEC,6BAA6B,EAC7BC,qBAAqB,EACrBC,qBAAqB,QAEhB,sBAAkB;AACzB,SAASC,gBAAgB,QAAQ,uBAAmB;AAEpD;;;;;;;;;CASC,GA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AG,CAAC,6BAA5CT,QAAiE,OAAO;QACjFiG,OAAO,GAAEjG,YAAAA,IAAIS,GAAG,CAAC,mCAART,YAAmC;QAC5C,yEAAyE;QACzE,uEAAuE;QACvE,uDAAuD;QACvDkG,QAAQ;YACNC,SAAS;gBACPvE,QAAQ;oBACNwE,OAAOV,QAAQU,KAAK;oBACpBC,SAASX,QAAQW,OAAO;oBACxBC,SAASZ,QAAQY,OAAO;oBACxBC,cAAcb,QAAQa,YAAY;oBAClCT;gBACF;YACF;YACAU,aAAa,CAACd,QAAQa,YAAY;YAClCE,SACE,CAAC,+BAA+B,EAC9Bf,QAAQW,OAAO,CAACpD,MAAM,GAAGyC,QAAQY,OAAO,CAACrD,MAAM,CAChD,+BAA+B,EAAE6C,YAAY,WAAW,CAAC;QAC9D;QACAY,OAAO,OAAO,EAAE5D,OAAO,EAAEsB,KAAK,EAAE;;YAC9B,MAAMpE,IAAI4F,GAAG,CAAClD,GAAG,CACf;gBACE7B,OAAOiC;gBACP,+DAA+D;gBAC/DhC,MAAM,UAAGgC,2BAAD,AAACA,QAAgDvB,KAAK,mBAAI,EAAE;gBACpE0D,eAAeb,MAAMa,aAAa;gBAClCD,QAAQZ,MAAMY,MAAM;gBACpB2B,WAAWzH,cAAcY,SAAS,CAACqF,UAAU,CAACC,eAAe;YAC/D,GACA;gBAAEwB,OAAO;YAAK;QAElB;IACF;AACF;AAEA,mDAAmD,GACnD,OAAO,MAAMC,6BAAkD;IAC7DrE,UAAUrC;IACV2G,QAAQ5D;IACR6D,SAAS1D;IACT2D,QAAQ1B;AACV,EAAC"}
|
|
@@ -27,7 +27,7 @@ import HostDatasetsCard, { newDatasetSharingNote } from "./host-datasets-card.co
|
|
|
27
27
|
* org Data page for the org-wide view. The org doc (resolved by the
|
|
28
28
|
* shell) flows into the card for its entitlement/quota checks.
|
|
29
29
|
*/ export function DataConsolePage(props) {
|
|
30
|
-
const { hostId, org } = props;
|
|
30
|
+
const { hostId, org, basePath, segments } = props;
|
|
31
31
|
// The org Data page is `/[orgSlug]/data` (AGL-621). This used to hardcode
|
|
32
32
|
// `/org/data`, which stopped being a route at that migration and had been
|
|
33
33
|
// a dead link ever since (AGL-685); the slug is not a prop, so resolve it
|
|
@@ -78,7 +78,9 @@ import HostDatasetsCard, { newDatasetSharingNote } from "./host-datasets-card.co
|
|
|
78
78
|
}),
|
|
79
79
|
/*#__PURE__*/ _jsx(HostDatasetsCard, {
|
|
80
80
|
hostId: hostId,
|
|
81
|
-
org: org
|
|
81
|
+
org: org,
|
|
82
|
+
basePath: basePath,
|
|
83
|
+
segments: segments
|
|
82
84
|
})
|
|
83
85
|
]
|
|
84
86
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/data/src/lib/components/data-console-page.tsx"],"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'use client'\n\nimport { buildRoute, type ConsolePluginPageProps, Route } from '@aglyn/aglyn'\nimport { useConsoleHostRoute } from '@aglyn/tenant-feature-instance'\nimport { AppLink } from '@aglyn/shared-ui-jsx'\nimport { Alert, Stack } from '@mui/material'\nimport HostDatasetsCard, {\n newDatasetSharingNote,\n} from './host-datasets-card.component'\n\n/**\n * Data page (AGL-239 → AGL-395): the host-scoped view of the org's shared\n * datasets, owned by the data plugin and rendered by the shell's generic\n * plugin route. Datasets live at org scope, so the card links out to the\n * org Data page for the org-wide view. The org doc (resolved by the\n * shell) flows into the card for its entitlement/quota checks.\n */\nexport function DataConsolePage(props: ConsolePluginPageProps) {\n const { hostId, org } = props\n // The org Data page is `/[orgSlug]/data` (AGL-621). This used to hardcode\n // `/org/data`, which stopped being a route at that migration and had been\n // a dead link ever since (AGL-685); the slug is not a prop, so resolve it\n // from the host.\n const { orgSlug } = useConsoleHostRoute(hostId)\n return (\n <Stack spacing={2}>\n <Alert\n severity=\"info\"\n // On a phone the action drops below the message instead of squeezing\n // it; from sm up these are MUI's own action offsets.\n sx={{\n flexWrap: { xs: 'wrap', sm: 'nowrap' },\n '& .MuiAlert-action': {\n width: { xs: '100%', sm: 'auto' },\n ml: { xs: 0, sm: 'auto' },\n pl: { xs: 4.25, sm: 2 },\n pt: { xs: 0, sm: 0.5 },\n },\n }}\n action={\n // Rendered only once the slug resolves — no link beats a dead one.\n orgSlug ? (\n <AppLink\n componentVariant=\"button\"\n color=\"inherit\"\n size=\"small\"\n href={buildRoute(Route.ORG_DATA, { orgSlug })}\n >\n {'Open organization data'}\n </AppLink>\n ) : undefined\n }\n >\n {/* Always a site page, so the org's Default sharing decides. */}\n {newDatasetSharingNote(\n (org as { defaultResourceScope?: 'org' | 'host' } | undefined)\n ?.defaultResourceScope === 'host',\n )}\n </Alert>\n <HostDatasetsCard hostId={hostId} org={org} />\n </Stack>\n )\n}\nDataConsolePage.displayName = 'DataConsolePage'\n\nexport default DataConsolePage\n"],"names":["buildRoute","Route","useConsoleHostRoute","AppLink","Alert","Stack","HostDatasetsCard","newDatasetSharingNote","DataConsolePage","props","hostId","org","orgSlug","spacing","severity","sx","flexWrap","xs","sm","width","ml","pl","pt","action","componentVariant","color","size","href","ORG_DATA","undefined","defaultResourceScope","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,UAAU,EAA+BC,KAAK,QAAQ,eAAc;AAC7E,SAASC,mBAAmB,QAAQ,iCAAgC;AACpE,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SAASC,KAAK,EAAEC,KAAK,QAAQ,gBAAe;AAC5C,OAAOC,oBACLC,qBAAqB,QAChB,oCAAgC;AAEvC;;;;;;CAMC,GACD,OAAO,SAASC,gBAAgBC,KAA6B;IAC3D,MAAM,EAAEC,MAAM,EAAEC,GAAG,EAAE,
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/data/src/lib/components/data-console-page.tsx"],"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'use client'\n\nimport { buildRoute, type ConsolePluginPageProps, Route } from '@aglyn/aglyn'\nimport { useConsoleHostRoute } from '@aglyn/tenant-feature-instance'\nimport { AppLink } from '@aglyn/shared-ui-jsx'\nimport { Alert, Stack } from '@mui/material'\nimport HostDatasetsCard, {\n newDatasetSharingNote,\n} from './host-datasets-card.component'\n\n/**\n * Data page (AGL-239 → AGL-395): the host-scoped view of the org's shared\n * datasets, owned by the data plugin and rendered by the shell's generic\n * plugin route. Datasets live at org scope, so the card links out to the\n * org Data page for the org-wide view. The org doc (resolved by the\n * shell) flows into the card for its entitlement/quota checks.\n */\nexport function DataConsolePage(props: ConsolePluginPageProps) {\n const { hostId, org, basePath, segments } = props\n // The org Data page is `/[orgSlug]/data` (AGL-621). This used to hardcode\n // `/org/data`, which stopped being a route at that migration and had been\n // a dead link ever since (AGL-685); the slug is not a prop, so resolve it\n // from the host.\n const { orgSlug } = useConsoleHostRoute(hostId)\n return (\n <Stack spacing={2}>\n <Alert\n severity=\"info\"\n // On a phone the action drops below the message instead of squeezing\n // it; from sm up these are MUI's own action offsets.\n sx={{\n flexWrap: { xs: 'wrap', sm: 'nowrap' },\n '& .MuiAlert-action': {\n width: { xs: '100%', sm: 'auto' },\n ml: { xs: 0, sm: 'auto' },\n pl: { xs: 4.25, sm: 2 },\n pt: { xs: 0, sm: 0.5 },\n },\n }}\n action={\n // Rendered only once the slug resolves — no link beats a dead one.\n orgSlug ? (\n <AppLink\n componentVariant=\"button\"\n color=\"inherit\"\n size=\"small\"\n href={buildRoute(Route.ORG_DATA, { orgSlug })}\n >\n {'Open organization data'}\n </AppLink>\n ) : undefined\n }\n >\n {/* Always a site page, so the org's Default sharing decides. */}\n {newDatasetSharingNote(\n (org as { defaultResourceScope?: 'org' | 'host' } | undefined)\n ?.defaultResourceScope === 'host',\n )}\n </Alert>\n {/* Each dataset is a tab, at `<basePath>/<datasetId>` (AGL-4047). */}\n <HostDatasetsCard hostId={hostId} org={org} basePath={basePath} segments={segments} />\n </Stack>\n )\n}\nDataConsolePage.displayName = 'DataConsolePage'\n\nexport default DataConsolePage\n"],"names":["buildRoute","Route","useConsoleHostRoute","AppLink","Alert","Stack","HostDatasetsCard","newDatasetSharingNote","DataConsolePage","props","hostId","org","basePath","segments","orgSlug","spacing","severity","sx","flexWrap","xs","sm","width","ml","pl","pt","action","componentVariant","color","size","href","ORG_DATA","undefined","defaultResourceScope","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,UAAU,EAA+BC,KAAK,QAAQ,eAAc;AAC7E,SAASC,mBAAmB,QAAQ,iCAAgC;AACpE,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SAASC,KAAK,EAAEC,KAAK,QAAQ,gBAAe;AAC5C,OAAOC,oBACLC,qBAAqB,QAChB,oCAAgC;AAEvC;;;;;;CAMC,GACD,OAAO,SAASC,gBAAgBC,KAA6B;IAC3D,MAAM,EAAEC,MAAM,EAAEC,GAAG,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGJ;IAC5C,0EAA0E;IAC1E,0EAA0E;IAC1E,0EAA0E;IAC1E,iBAAiB;IACjB,MAAM,EAAEK,OAAO,EAAE,GAAGZ,oBAAoBQ;IACxC,qBACE,MAACL;QAAMU,SAAS;;0BACd,KAACX;gBACCY,UAAS;gBACT,qEAAqE;gBACrE,qDAAqD;gBACrDC,IAAI;oBACFC,UAAU;wBAAEC,IAAI;wBAAQC,IAAI;oBAAS;oBACrC,sBAAsB;wBACpBC,OAAO;4BAAEF,IAAI;4BAAQC,IAAI;wBAAO;wBAChCE,IAAI;4BAAEH,IAAI;4BAAGC,IAAI;wBAAO;wBACxBG,IAAI;4BAAEJ,IAAI;4BAAMC,IAAI;wBAAE;wBACtBI,IAAI;4BAAEL,IAAI;4BAAGC,IAAI;wBAAI;oBACvB;gBACF;gBACAK,QACE,mEAAmE;gBACnEX,wBACE,KAACX;oBACCuB,kBAAiB;oBACjBC,OAAM;oBACNC,MAAK;oBACLC,MAAM7B,WAAWC,MAAM6B,QAAQ,EAAE;wBAAEhB;oBAAQ;8BAE1C;qBAEDiB;0BAILxB,sBACC,CAACI,uBAAD,AAACA,IACGqB,oBAAoB,MAAK;;0BAIjC,KAAC1B;gBAAiBI,QAAQA;gBAAQC,KAAKA;gBAAKC,UAAUA;gBAAUC,UAAUA;;;;AAGhF;AACAL,gBAAgByB,WAAW,GAAG;AAE9B,eAAezB,gBAAe"}
|
|
@@ -45,6 +45,28 @@ export interface DatasetRecordDialogProps {
|
|
|
45
45
|
*/
|
|
46
46
|
onEdit?: () => void;
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* A record's fields, read-only: each field's label, its value, what the model
|
|
50
|
+
* says is wrong with it, and its description (AGL-4047). Shared by the View
|
|
51
|
+
* record dialog and a record's own page on the Data page, so the two read a
|
|
52
|
+
* record alike. Reads nothing: every value is a prop.
|
|
53
|
+
*/
|
|
54
|
+
export declare function DatasetRecordFieldList(props: {
|
|
55
|
+
record: {
|
|
56
|
+
$id: string;
|
|
57
|
+
values?: Record<string, unknown>;
|
|
58
|
+
} | null;
|
|
59
|
+
model: DatasetModel;
|
|
60
|
+
resolveReference?: DatasetReferenceResolver;
|
|
61
|
+
/**
|
|
62
|
+
* Drawn as a page draws it: a caption over each value and a divider between
|
|
63
|
+
* fields. The dialog draws overline labels with no dividers.
|
|
64
|
+
*/
|
|
65
|
+
divided?: boolean;
|
|
66
|
+
}): import("react").JSX.Element;
|
|
67
|
+
export declare namespace DatasetRecordFieldList {
|
|
68
|
+
var displayName: string;
|
|
69
|
+
}
|
|
48
70
|
export declare function DatasetRecordDialog(props: DatasetRecordDialogProps): import("react").JSX.Element;
|
|
49
71
|
export declare namespace DatasetRecordDialog {
|
|
50
72
|
var displayName: string;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/ 'use client';
|
|
17
17
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
19
|
import { datasetRecordFields } from "../model/dataset-record-view.js";
|
|
20
20
|
import { Alert, Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, Stack, Tooltip, Typography } from "@mui/material";
|
|
21
21
|
import { useMemo } from "react";
|
|
@@ -122,9 +122,13 @@ import { validateDocument } from "../model/dataset-models.js";
|
|
|
122
122
|
}));
|
|
123
123
|
}
|
|
124
124
|
RecordFieldValue.displayName = 'RecordFieldValue';
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
/**
|
|
126
|
+
* A record's fields, read-only: each field's label, its value, what the model
|
|
127
|
+
* says is wrong with it, and its description (AGL-4047). Shared by the View
|
|
128
|
+
* record dialog and a record's own page on the Data page, so the two read a
|
|
129
|
+
* record alike. Reads nothing: every value is a prop.
|
|
130
|
+
*/ export function DatasetRecordFieldList(props) {
|
|
131
|
+
const { record, model, resolveReference, divided = false } = props;
|
|
128
132
|
const values = record == null ? void 0 : record.values;
|
|
129
133
|
const fields = useMemo(()=>record ? datasetRecordFields(model, values, resolveReference) : [], [
|
|
130
134
|
record,
|
|
@@ -142,6 +146,70 @@ export function DatasetRecordDialog(props) {
|
|
|
142
146
|
model,
|
|
143
147
|
values
|
|
144
148
|
]);
|
|
149
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
150
|
+
children: [
|
|
151
|
+
fields.map((field)=>/*#__PURE__*/ _jsxs(Box, {
|
|
152
|
+
sx: divided ? {
|
|
153
|
+
pb: 1.5,
|
|
154
|
+
borderBottom: 1,
|
|
155
|
+
borderColor: 'divider'
|
|
156
|
+
} : undefined,
|
|
157
|
+
children: [
|
|
158
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
159
|
+
useFlexGap: true,
|
|
160
|
+
direction: "row",
|
|
161
|
+
spacing: 1,
|
|
162
|
+
sx: {
|
|
163
|
+
alignItems: 'baseline',
|
|
164
|
+
flexWrap: 'wrap'
|
|
165
|
+
},
|
|
166
|
+
children: [
|
|
167
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
168
|
+
variant: divided ? 'caption' : 'overline',
|
|
169
|
+
color: "text.secondary",
|
|
170
|
+
component: "div",
|
|
171
|
+
children: field.label
|
|
172
|
+
}),
|
|
173
|
+
field.source === 'extra' ? /*#__PURE__*/ _jsx(Tooltip, {
|
|
174
|
+
title: 'Stored on this record with no field in the ' + 'collection’s schema. The table cannot show it, and ' + 'the next save through the editor removes it.',
|
|
175
|
+
children: /*#__PURE__*/ _jsx(Typography, {
|
|
176
|
+
variant: "caption",
|
|
177
|
+
color: "warning.main",
|
|
178
|
+
sx: {
|
|
179
|
+
cursor: 'help'
|
|
180
|
+
},
|
|
181
|
+
children: 'not in schema'
|
|
182
|
+
})
|
|
183
|
+
}) : null
|
|
184
|
+
]
|
|
185
|
+
}),
|
|
186
|
+
/*#__PURE__*/ _jsx(RecordFieldValue, {
|
|
187
|
+
field: field
|
|
188
|
+
}),
|
|
189
|
+
mismatches[field.fieldId] ? /*#__PURE__*/ _jsx(Typography, {
|
|
190
|
+
variant: "caption",
|
|
191
|
+
color: "warning.main",
|
|
192
|
+
children: mismatches[field.fieldId]
|
|
193
|
+
}) : null,
|
|
194
|
+
field.description ? /*#__PURE__*/ _jsx(Typography, {
|
|
195
|
+
variant: "caption",
|
|
196
|
+
color: "text.secondary",
|
|
197
|
+
component: "div",
|
|
198
|
+
children: field.description
|
|
199
|
+
}) : null
|
|
200
|
+
]
|
|
201
|
+
}, field.fieldId)),
|
|
202
|
+
record && fields.length === 0 ? /*#__PURE__*/ _jsx(Alert, {
|
|
203
|
+
severity: "info",
|
|
204
|
+
children: 'This record holds no fields.'
|
|
205
|
+
}) : null
|
|
206
|
+
]
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
DatasetRecordFieldList.displayName = 'DatasetRecordFieldList';
|
|
210
|
+
export function DatasetRecordDialog(props) {
|
|
211
|
+
var _ref;
|
|
212
|
+
const { record, model, resolveReference, onClose, onEdit } = props;
|
|
145
213
|
return /*#__PURE__*/ _jsxs(Dialog, {
|
|
146
214
|
open: Boolean(record),
|
|
147
215
|
onClose: onClose,
|
|
@@ -175,56 +243,11 @@ export function DatasetRecordDialog(props) {
|
|
|
175
243
|
})
|
|
176
244
|
]
|
|
177
245
|
}),
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
spacing: 1,
|
|
184
|
-
sx: {
|
|
185
|
-
alignItems: 'baseline',
|
|
186
|
-
flexWrap: 'wrap'
|
|
187
|
-
},
|
|
188
|
-
children: [
|
|
189
|
-
/*#__PURE__*/ _jsx(Typography, {
|
|
190
|
-
variant: "overline",
|
|
191
|
-
color: "text.secondary",
|
|
192
|
-
component: "div",
|
|
193
|
-
children: field.label
|
|
194
|
-
}),
|
|
195
|
-
field.source === 'extra' ? /*#__PURE__*/ _jsx(Tooltip, {
|
|
196
|
-
title: 'Stored on this record with no field in the ' + 'collection’s schema. The table cannot show it, and ' + 'the next save through the editor removes it.',
|
|
197
|
-
children: /*#__PURE__*/ _jsx(Typography, {
|
|
198
|
-
variant: "caption",
|
|
199
|
-
color: "warning.main",
|
|
200
|
-
sx: {
|
|
201
|
-
cursor: 'help'
|
|
202
|
-
},
|
|
203
|
-
children: 'not in schema'
|
|
204
|
-
})
|
|
205
|
-
}) : null
|
|
206
|
-
]
|
|
207
|
-
}),
|
|
208
|
-
/*#__PURE__*/ _jsx(RecordFieldValue, {
|
|
209
|
-
field: field
|
|
210
|
-
}),
|
|
211
|
-
mismatches[field.fieldId] ? /*#__PURE__*/ _jsx(Typography, {
|
|
212
|
-
variant: "caption",
|
|
213
|
-
color: "warning.main",
|
|
214
|
-
children: mismatches[field.fieldId]
|
|
215
|
-
}) : null,
|
|
216
|
-
field.description ? /*#__PURE__*/ _jsx(Typography, {
|
|
217
|
-
variant: "caption",
|
|
218
|
-
color: "text.secondary",
|
|
219
|
-
component: "div",
|
|
220
|
-
children: field.description
|
|
221
|
-
}) : null
|
|
222
|
-
]
|
|
223
|
-
}, field.fieldId)),
|
|
224
|
-
fields.length === 0 ? /*#__PURE__*/ _jsx(Alert, {
|
|
225
|
-
severity: "info",
|
|
226
|
-
children: 'This record holds no fields.'
|
|
227
|
-
}) : null
|
|
246
|
+
/*#__PURE__*/ _jsx(DatasetRecordFieldList, {
|
|
247
|
+
record: record,
|
|
248
|
+
model: model,
|
|
249
|
+
resolveReference: resolveReference
|
|
250
|
+
})
|
|
228
251
|
]
|
|
229
252
|
})
|
|
230
253
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/data/src/lib/components/dataset-record-dialog.component.tsx"],"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'use client'\n\nimport {\n type DatasetRecordField,\n type DatasetReferenceResolver,\n datasetRecordFields,\n} from '../model/dataset-record-view'\nimport {\n Alert,\n Box,\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Stack,\n Tooltip,\n Typography,\n} from '@mui/material'\nimport { useMemo } from 'react'\nimport { type DatasetModel, validateDocument } from '../model/dataset-models'\n\n/**\n * Looking at a record, as its own gesture.\n *\n * The records table has room for the model's columns and one line per value,\n * so the only way to see what a record actually holds was to open it in the\n * EDITOR — which made reading a record and changing one the same click, on a\n * dialog whose primary button writes. This is the other half: the whole\n * record, nothing writable.\n *\n * ## It reads nothing\n *\n * Every value on screen arrives as a prop, out of the page the table already\n * listens to. There is no query, no `getDoc`, and no effect — opening a record\n * costs zero documents, and rendering the table does not open one dialog per\n * row to find out. That is not an optimization detail: a viewer that fetched\n * the record it was handed would bill a read per glance, and one that mounted\n * per row would bill the whole page on arrival.\n *\n * ## Read-only means read-only\n *\n * Nothing here takes input and nothing here writes. `Edit record` is a\n * separate, explicitly labelled action that closes this and opens the editor —\n * the dialog that has always owned writing — so the two gestures stay\n * distinct rather than one being a slip away from the other.\n */\nexport interface DatasetRecordDialogProps {\n /**\n * The record row itself, straight from the table's page. `null` closes the\n * dialog — including when the row leaves the page under it, which is the\n * honest response to a record this reader can no longer see.\n */\n record: { $id: string; values?: Record<string, unknown> } | null\n model: DatasetModel\n /** Reference target ID → label, or `null` when it resolves to nothing. */\n resolveReference?: DatasetReferenceResolver\n onClose: () => void\n /**\n * Opens the record in the editor. Omitted for a reader who cannot write, so\n * the control is absent rather than present-and-refusing.\n */\n onEdit?: () => void\n}\n\n/** What each \"no value\" state is called on screen. */\nconst PLACEHOLDER: Record<string, string> = {\n absent: 'Not set',\n null: 'Null',\n 'empty-text': 'Empty text',\n 'empty-list': 'Empty list',\n 'empty-map': 'Empty map',\n}\n\n/**\n * One field's value.\n *\n * The four empty states get four different words, deliberately. A table cell\n * prints `--` for all of them because it has one line to work with; here there\n * is room to say which, and the difference decides what a reader does next —\n * a field that was never written and a field holding a real empty string are\n * not the same finding.\n */\nfunction RecordFieldValue(props: { field: DatasetRecordField }) {\n const { value } = props.field\n if (value.kind === 'opaque') {\n return (\n <Typography\n variant=\"body2\"\n color=\"text.secondary\"\n sx={{ fontStyle: 'italic' }}\n >\n {value.text}\n </Typography>\n )\n }\n if (value.kind !== 'value') {\n return (\n <Typography\n variant=\"body2\"\n color=\"text.disabled\"\n sx={{ fontStyle: 'italic' }}\n >\n {PLACEHOLDER[value.kind] ?? 'Not set'}\n </Typography>\n )\n }\n if (value.references) {\n return (\n <Stack useFlexGap direction=\"row\" spacing={1} sx={{ flexWrap: 'wrap', rowGap: 0.5 }}>\n {value.references.map((reference) => (\n <Typography\n key={reference.id}\n variant=\"body2\"\n // An unresolved target is a fact about the data, not a rendering\n // failure to paper over: the ID is shown either way, and only the\n // resolved one is allowed to look like a working link.\n color={reference.label ? 'text.primary' : 'warning.main'}\n sx={{ overflowWrap: 'anywhere' }}\n >\n {reference.label ?? `${reference.id} · unresolved`}\n </Typography>\n ))}\n </Stack>\n )\n }\n if (value.items) {\n return (\n // One line per item. The comma-joined form a cell shows cannot say\n // whether `a, b` is one item or two; a list of lines can.\n <Stack component=\"ul\" spacing={0.25} sx={{ m: 0, pl: 2.5 }}>\n {value.items.map((item, index) => (\n <Typography\n // Items are values, not identities — two equal strings are two\n // real entries and the position is what tells them apart.\n key={`${index}:${item}`}\n component=\"li\"\n variant=\"body2\"\n sx={{ overflowWrap: 'anywhere' }}\n >\n {item}\n </Typography>\n ))}\n </Stack>\n )\n }\n return (\n <Typography\n variant=\"body2\"\n // Pretty-printed JSON is only readable where its whitespace survives.\n {...(value.block\n ? {\n component: 'pre',\n sx: {\n m: 0,\n fontFamily: 'monospace',\n whiteSpace: 'pre-wrap',\n overflowWrap: 'anywhere',\n },\n }\n : { sx: { overflowWrap: 'anywhere' } })}\n >\n {value.text}\n </Typography>\n )\n}\nRecordFieldValue.displayName = 'RecordFieldValue'\n\nexport function DatasetRecordDialog(props: DatasetRecordDialogProps) {\n const { record, model, resolveReference, onClose, onEdit } = props\n const values = record?.values\n const fields = useMemo(\n () => (record ? datasetRecordFields(model, values, resolveReference) : []),\n [record, model, values, resolveReference],\n )\n /**\n * The same mismatch report the editor shows, for the same reason: a type\n * change never rewrites stored documents, so a record may legitimately hold\n * a value its model no longer describes. Reporting it beside the value is\n * what stops the view claiming the record conforms.\n */\n const mismatches = useMemo(\n () => (record ? validateDocument(model, values ?? {}) : {}),\n [record, model, values],\n )\n\n return (\n <Dialog\n open={Boolean(record)}\n onClose={onClose}\n maxWidth=\"sm\"\n fullWidth\n aria-labelledby=\"dataset-record-view-title\"\n >\n <DialogTitle id=\"dataset-record-view-title\">{'View record'}</DialogTitle>\n <DialogContent dividers>\n <Stack spacing={2}>\n <Box>\n <Typography\n variant=\"overline\"\n color=\"text.secondary\"\n component=\"div\"\n >\n {'Record ID'}\n </Typography>\n <Typography variant=\"body2\" sx={{ overflowWrap: 'anywhere' }}>\n {record?.$id ?? ''}\n </Typography>\n </Box>\n {fields.map((field) => (\n <Box key={field.fieldId}>\n <Stack\n useFlexGap\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'baseline', flexWrap: 'wrap' }}\n >\n <Typography\n variant=\"overline\"\n color=\"text.secondary\"\n component=\"div\"\n >\n {field.label}\n </Typography>\n {field.source === 'extra' ? (\n <Tooltip\n title={\n 'Stored on this record with no field in the ' +\n 'collection’s schema. The table cannot show it, and ' +\n 'the next save through the editor removes it.'\n }\n >\n <Typography\n variant=\"caption\"\n color=\"warning.main\"\n sx={{ cursor: 'help' }}\n >\n {'not in schema'}\n </Typography>\n </Tooltip>\n ) : null}\n </Stack>\n <RecordFieldValue field={field} />\n {mismatches[field.fieldId] ? (\n <Typography variant=\"caption\" color=\"warning.main\">\n {mismatches[field.fieldId]}\n </Typography>\n ) : null}\n {field.description ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n component=\"div\"\n >\n {field.description}\n </Typography>\n ) : null}\n </Box>\n ))}\n {fields.length === 0 ? (\n <Alert severity=\"info\">{'This record holds no fields.'}</Alert>\n ) : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n {onEdit ? <Button onClick={onEdit}>{'Edit record'}</Button> : null}\n <Button variant=\"contained\" color=\"primary\" onClick={onClose}>\n {'Close'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\nDatasetRecordDialog.displayName = 'DatasetRecordDialog'\n\nexport default DatasetRecordDialog\n"],"names":["datasetRecordFields","Alert","Box","Button","Dialog","DialogActions","DialogContent","DialogTitle","Stack","Tooltip","Typography","useMemo","validateDocument","PLACEHOLDER","absent","null","RecordFieldValue","props","value","field","kind","variant","color","sx","fontStyle","text","references","useFlexGap","direction","spacing","flexWrap","rowGap","map","reference","label","overflowWrap","id","items","component","m","pl","item","index","block","fontFamily","whiteSpace","displayName","DatasetRecordDialog","record","model","resolveReference","onClose","onEdit","values","fields","mismatches","open","Boolean","maxWidth","fullWidth","aria-labelledby","dividers","$id","alignItems","source","title","cursor","fieldId","description","length","severity","onClick"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAGEA,mBAAmB,QACd,kCAA8B;AACrC,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,KAAK,EACLC,OAAO,EACPC,UAAU,QACL,gBAAe;AACtB,SAASC,OAAO,QAAQ,QAAO;AAC/B,SAA4BC,gBAAgB,QAAQ,6BAAyB;AA6C7E,oDAAoD,GACpD,MAAMC,cAAsC;IAC1CC,QAAQ;IACRC,MAAM;IACN,cAAc;IACd,cAAc;IACd,aAAa;AACf;AAEA;;;;;;;;CAQC,GACD,SAASC,iBAAiBC,KAAoC;IAC5D,MAAM,EAAEC,KAAK,EAAE,GAAGD,MAAME,KAAK;IAC7B,IAAID,MAAME,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;;4CAEbf,MAAM6C,MAAM,KAAK,wBAChB,KAACvD;gDACCwD,OACE,gDACA,wDACA;0DAGF,cAAA,KAACvD;oDACCW,SAAQ;oDACRC,OAAM;oDACNC,IAAI;wDAAE2C,QAAQ;oDAAO;8DAEpB;;iDAGH;;;kDAEN,KAAClD;wCAAiBG,OAAOA;;oCACxBoC,UAAU,CAACpC,MAAMgD,OAAO,CAAC,iBACxB,KAACzD;wCAAWW,SAAQ;wCAAUC,OAAM;kDACjCiC,UAAU,CAACpC,MAAMgD,OAAO,CAAC;yCAE1B;oCACHhD,MAAMiD,WAAW,iBAChB,KAAC1D;wCACCW,SAAQ;wCACRC,OAAM;wCACNgB,WAAU;kDAETnB,MAAMiD,WAAW;yCAElB;;+BA9CIjD,MAAMgD,OAAO;wBAiDxBb,OAAOe,MAAM,KAAK,kBACjB,KAACpE;4BAAMqE,UAAS;sCAAQ;6BACtB;;;;0BAGR,MAACjE;;oBACE+C,uBAAS,KAACjD;wBAAOoE,SAASnB;kCAAS;yBAA0B;kCAC9D,KAACjD;wBAAOkB,SAAQ;wBAAYC,OAAM;wBAAUiD,SAASpB;kCAClD;;;;;;AAKX;AACAJ,oBAAoBD,WAAW,GAAG;AAElC,eAAeC,oBAAmB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/data/src/lib/components/dataset-record-dialog.component.tsx"],"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'use client'\n\nimport {\n type DatasetRecordField,\n type DatasetReferenceResolver,\n datasetRecordFields,\n} from '../model/dataset-record-view'\nimport {\n Alert,\n Box,\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Stack,\n Tooltip,\n Typography,\n} from '@mui/material'\nimport { useMemo } from 'react'\nimport { type DatasetModel, validateDocument } from '../model/dataset-models'\n\n/**\n * Looking at a record, as its own gesture.\n *\n * The records table has room for the model's columns and one line per value,\n * so the only way to see what a record actually holds was to open it in the\n * EDITOR — which made reading a record and changing one the same click, on a\n * dialog whose primary button writes. This is the other half: the whole\n * record, nothing writable.\n *\n * ## It reads nothing\n *\n * Every value on screen arrives as a prop, out of the page the table already\n * listens to. There is no query, no `getDoc`, and no effect — opening a record\n * costs zero documents, and rendering the table does not open one dialog per\n * row to find out. That is not an optimization detail: a viewer that fetched\n * the record it was handed would bill a read per glance, and one that mounted\n * per row would bill the whole page on arrival.\n *\n * ## Read-only means read-only\n *\n * Nothing here takes input and nothing here writes. `Edit record` is a\n * separate, explicitly labelled action that closes this and opens the editor —\n * the dialog that has always owned writing — so the two gestures stay\n * distinct rather than one being a slip away from the other.\n */\nexport interface DatasetRecordDialogProps {\n /**\n * The record row itself, straight from the table's page. `null` closes the\n * dialog — including when the row leaves the page under it, which is the\n * honest response to a record this reader can no longer see.\n */\n record: { $id: string; values?: Record<string, unknown> } | null\n model: DatasetModel\n /** Reference target ID → label, or `null` when it resolves to nothing. */\n resolveReference?: DatasetReferenceResolver\n onClose: () => void\n /**\n * Opens the record in the editor. Omitted for a reader who cannot write, so\n * the control is absent rather than present-and-refusing.\n */\n onEdit?: () => void\n}\n\n/** What each \"no value\" state is called on screen. */\nconst PLACEHOLDER: Record<string, string> = {\n absent: 'Not set',\n null: 'Null',\n 'empty-text': 'Empty text',\n 'empty-list': 'Empty list',\n 'empty-map': 'Empty map',\n}\n\n/**\n * One field's value.\n *\n * The four empty states get four different words, deliberately. A table cell\n * prints `--` for all of them because it has one line to work with; here there\n * is room to say which, and the difference decides what a reader does next —\n * a field that was never written and a field holding a real empty string are\n * not the same finding.\n */\nfunction RecordFieldValue(props: { field: DatasetRecordField }) {\n const { value } = props.field\n if (value.kind === 'opaque') {\n return (\n <Typography\n variant=\"body2\"\n color=\"text.secondary\"\n sx={{ fontStyle: 'italic' }}\n >\n {value.text}\n </Typography>\n )\n }\n if (value.kind !== 'value') {\n return (\n <Typography\n variant=\"body2\"\n color=\"text.disabled\"\n sx={{ fontStyle: 'italic' }}\n >\n {PLACEHOLDER[value.kind] ?? 'Not set'}\n </Typography>\n )\n }\n if (value.references) {\n return (\n <Stack useFlexGap direction=\"row\" spacing={1} sx={{ flexWrap: 'wrap', rowGap: 0.5 }}>\n {value.references.map((reference) => (\n <Typography\n key={reference.id}\n variant=\"body2\"\n // An unresolved target is a fact about the data, not a rendering\n // failure to paper over: the ID is shown either way, and only the\n // resolved one is allowed to look like a working link.\n color={reference.label ? 'text.primary' : 'warning.main'}\n sx={{ overflowWrap: 'anywhere' }}\n >\n {reference.label ?? `${reference.id} · unresolved`}\n </Typography>\n ))}\n </Stack>\n )\n }\n if (value.items) {\n return (\n // One line per item. The comma-joined form a cell shows cannot say\n // whether `a, b` is one item or two; a list of lines can.\n <Stack component=\"ul\" spacing={0.25} sx={{ m: 0, pl: 2.5 }}>\n {value.items.map((item, index) => (\n <Typography\n // Items are values, not identities — two equal strings are two\n // real entries and the position is what tells them apart.\n key={`${index}:${item}`}\n component=\"li\"\n variant=\"body2\"\n sx={{ overflowWrap: 'anywhere' }}\n >\n {item}\n </Typography>\n ))}\n </Stack>\n )\n }\n return (\n <Typography\n variant=\"body2\"\n // Pretty-printed JSON is only readable where its whitespace survives.\n {...(value.block\n ? {\n component: 'pre',\n sx: {\n m: 0,\n fontFamily: 'monospace',\n whiteSpace: 'pre-wrap',\n overflowWrap: 'anywhere',\n },\n }\n : { sx: { overflowWrap: 'anywhere' } })}\n >\n {value.text}\n </Typography>\n )\n}\nRecordFieldValue.displayName = 'RecordFieldValue'\n\n/**\n * A record's fields, read-only: each field's label, its value, what the model\n * says is wrong with it, and its description (AGL-4047). Shared by the View\n * record dialog and a record's own page on the Data page, so the two read a\n * record alike. Reads nothing: every value is a prop.\n */\nexport function DatasetRecordFieldList(props: {\n record: { $id: string; values?: Record<string, unknown> } | null\n model: DatasetModel\n resolveReference?: DatasetReferenceResolver\n /**\n * Drawn as a page draws it: a caption over each value and a divider between\n * fields. The dialog draws overline labels with no dividers.\n */\n divided?: boolean\n}) {\n const { record, model, resolveReference, divided = false } = props\n const values = record?.values\n const fields = useMemo(\n () => (record ? datasetRecordFields(model, values, resolveReference) : []),\n [record, model, values, resolveReference],\n )\n /**\n * The same mismatch report the editor shows, for the same reason: a type\n * change never rewrites stored documents, so a record may legitimately hold\n * a value its model no longer describes. Reporting it beside the value is\n * what stops the view claiming the record conforms.\n */\n const mismatches = useMemo(\n () => (record ? validateDocument(model, values ?? {}) : {}),\n [record, model, values],\n )\n return (\n <>\n {fields.map((field) => (\n <Box\n key={field.fieldId}\n sx={divided ? { pb: 1.5, borderBottom: 1, borderColor: 'divider' } : undefined}\n >\n <Stack\n useFlexGap\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'baseline', flexWrap: 'wrap' }}\n >\n <Typography\n variant={divided ? 'caption' : 'overline'}\n color=\"text.secondary\"\n component=\"div\"\n >\n {field.label}\n </Typography>\n {field.source === 'extra' ? (\n <Tooltip\n title={\n 'Stored on this record with no field in the ' +\n 'collection’s schema. The table cannot show it, and ' +\n 'the next save through the editor removes it.'\n }\n >\n <Typography\n variant=\"caption\"\n color=\"warning.main\"\n sx={{ cursor: 'help' }}\n >\n {'not in schema'}\n </Typography>\n </Tooltip>\n ) : null}\n </Stack>\n <RecordFieldValue field={field} />\n {mismatches[field.fieldId] ? (\n <Typography variant=\"caption\" color=\"warning.main\">\n {mismatches[field.fieldId]}\n </Typography>\n ) : null}\n {field.description ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n component=\"div\"\n >\n {field.description}\n </Typography>\n ) : null}\n </Box>\n ))}\n {record && fields.length === 0 ? (\n <Alert severity=\"info\">{'This record holds no fields.'}</Alert>\n ) : null}\n </>\n )\n}\nDatasetRecordFieldList.displayName = 'DatasetRecordFieldList'\n\nexport function DatasetRecordDialog(props: DatasetRecordDialogProps) {\n const { record, model, resolveReference, onClose, onEdit } = props\n\n return (\n <Dialog\n open={Boolean(record)}\n onClose={onClose}\n maxWidth=\"sm\"\n fullWidth\n aria-labelledby=\"dataset-record-view-title\"\n >\n <DialogTitle id=\"dataset-record-view-title\">{'View record'}</DialogTitle>\n <DialogContent dividers>\n <Stack spacing={2}>\n <Box>\n <Typography\n variant=\"overline\"\n color=\"text.secondary\"\n component=\"div\"\n >\n {'Record ID'}\n </Typography>\n <Typography variant=\"body2\" sx={{ overflowWrap: 'anywhere' }}>\n {record?.$id ?? ''}\n </Typography>\n </Box>\n <DatasetRecordFieldList record={record} model={model} resolveReference={resolveReference} />\n </Stack>\n </DialogContent>\n <DialogActions>\n {onEdit ? <Button onClick={onEdit}>{'Edit record'}</Button> : null}\n <Button variant=\"contained\" color=\"primary\" onClick={onClose}>\n {'Close'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\nDatasetRecordDialog.displayName = 'DatasetRecordDialog'\n\nexport default DatasetRecordDialog\n"],"names":["datasetRecordFields","Alert","Box","Button","Dialog","DialogActions","DialogContent","DialogTitle","Stack","Tooltip","Typography","useMemo","validateDocument","PLACEHOLDER","absent","null","RecordFieldValue","props","value","field","kind","variant","color","sx","fontStyle","text","references","useFlexGap","direction","spacing","flexWrap","rowGap","map","reference","label","overflowWrap","id","items","component","m","pl","item","index","block","fontFamily","whiteSpace","displayName","DatasetRecordFieldList","record","model","resolveReference","divided","values","fields","mismatches","pb","borderBottom","borderColor","undefined","alignItems","source","title","cursor","fieldId","description","length","severity","DatasetRecordDialog","onClose","onEdit","open","Boolean","maxWidth","fullWidth","aria-labelledby","dividers","$id","onClick"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAGEA,mBAAmB,QACd,kCAA8B;AACrC,SACEC,KAAK,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