@objectstack/metadata-protocol 11.1.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/LICENSE +202 -0
- package/README.md +7 -0
- package/dist/build-probes-I3227FYL.cjs +7 -0
- package/dist/build-probes-I3227FYL.cjs.map +1 -0
- package/dist/build-probes-TLWDII7Z.js +7 -0
- package/dist/build-probes-TLWDII7Z.js.map +1 -0
- package/dist/chunk-7LOFAEHA.cjs +161 -0
- package/dist/chunk-7LOFAEHA.cjs.map +1 -0
- package/dist/chunk-HJVPAKGD.js +639 -0
- package/dist/chunk-HJVPAKGD.js.map +1 -0
- package/dist/chunk-JRNTUZG6.cjs +639 -0
- package/dist/chunk-JRNTUZG6.cjs.map +1 -0
- package/dist/chunk-KJGVCNUC.js +161 -0
- package/dist/chunk-KJGVCNUC.js.map +1 -0
- package/dist/index.cjs +4855 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1893 -0
- package/dist/index.d.ts +1893 -0
- package/dist/index.js +4855 -0
- package/dist/index.js.map +1 -0
- package/dist/seed-loader-IFRY33L4.cjs +7 -0
- package/dist/seed-loader-IFRY33L4.cjs.map +1 -0
- package/dist/seed-loader-KNXGLL2V.js +7 -0
- package/dist/seed-loader-KNXGLL2V.js.map +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute
|
|
108
|
+
must include a readable copy of the attribution notices
|
|
109
|
+
contained within such NOTICE file, excluding those notices
|
|
110
|
+
that do not pertain to any part of the Derivative Works,
|
|
111
|
+
in at least one of the following places: within a NOTICE
|
|
112
|
+
text file distributed as part of the Derivative Works; within
|
|
113
|
+
the Source form or documentation, if provided along with
|
|
114
|
+
the Derivative Works; or, within a display generated by the
|
|
115
|
+
Derivative Works, if and wherever such third-party notices
|
|
116
|
+
normally appear. The contents of the NOTICE file are for
|
|
117
|
+
informational purposes only and do not modify the License.
|
|
118
|
+
You may add Your own attribution notices within Derivative
|
|
119
|
+
Works that You distribute, alongside or as an addendum to
|
|
120
|
+
the NOTICE text from the Work, provided that such additional
|
|
121
|
+
attribution notices cannot be construed as modifying the
|
|
122
|
+
License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 ObjectStack
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @objectstack/metadata-protocol
|
|
2
|
+
|
|
3
|
+
The ObjectStack metadata-management protocol, extracted from `@objectstack/objectql` per [ADR-0076](../../docs/adr/0076-objectql-core-tiering.md).
|
|
4
|
+
|
|
5
|
+
Implements `ObjectStackProtocol`: `sys_metadata` CRUD, draft/publish lifecycle, write locks, package ownership/installation, metadata diagnostics, seed application, and build probes.
|
|
6
|
+
|
|
7
|
+
It uses a data engine purely as storage + schema registry, injected at runtime via the `MetadataHostEngine` interface — so this package does **not** depend on `@objectstack/objectql`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/framework/framework/packages/metadata-protocol/dist/build-probes-I3227FYL.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,0DAAC","file":"/home/runner/work/framework/framework/packages/metadata-protocol/dist/build-probes-I3227FYL.cjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/build-probes.ts
|
|
2
|
+
function asRec(v) {
|
|
3
|
+
return v && typeof v === "object" && !Array.isArray(v) ? v : void 0;
|
|
4
|
+
}
|
|
5
|
+
function asArr(v) {
|
|
6
|
+
return Array.isArray(v) ? v : [];
|
|
7
|
+
}
|
|
8
|
+
function resultRows(result) {
|
|
9
|
+
if (Array.isArray(result)) return result;
|
|
10
|
+
const r = asRec(result);
|
|
11
|
+
if (!r) return [];
|
|
12
|
+
if (Array.isArray(r.rows)) return r.rows;
|
|
13
|
+
if (Array.isArray(r.data)) return r.data;
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
async function hasRows(engine, objectName, organizationId) {
|
|
17
|
+
const rows = await engine.find(objectName, {
|
|
18
|
+
fields: ["id"],
|
|
19
|
+
limit: 1,
|
|
20
|
+
...organizationId ? { where: { organization_id: organizationId } } : {},
|
|
21
|
+
context: { isSystem: true }
|
|
22
|
+
});
|
|
23
|
+
return Array.isArray(rows) && rows.length > 0;
|
|
24
|
+
}
|
|
25
|
+
async function runBuildProbes(opts) {
|
|
26
|
+
const issues = [];
|
|
27
|
+
const checked = { seeds: 0, views: 0, widgets: 0 };
|
|
28
|
+
const { engine, getItem, published, analytics, organizationId } = opts;
|
|
29
|
+
const itemCache = /* @__PURE__ */ new Map();
|
|
30
|
+
const readItem = async (type, name) => {
|
|
31
|
+
const key = `${type} ${name}`;
|
|
32
|
+
if (itemCache.has(key)) return itemCache.get(key);
|
|
33
|
+
let item;
|
|
34
|
+
try {
|
|
35
|
+
item = await getItem(type, name);
|
|
36
|
+
} catch (e2) {
|
|
37
|
+
item = void 0;
|
|
38
|
+
}
|
|
39
|
+
itemCache.set(key, item);
|
|
40
|
+
return item;
|
|
41
|
+
};
|
|
42
|
+
for (const p of published.filter((x) => x.type === "seed")) {
|
|
43
|
+
const body = asRec(await readItem("seed", p.name));
|
|
44
|
+
const objectName = typeof _optionalChain([body, 'optionalAccess', _ => _.object]) === "string" ? body.object : void 0;
|
|
45
|
+
if (!objectName) continue;
|
|
46
|
+
checked.seeds += 1;
|
|
47
|
+
try {
|
|
48
|
+
if (!await hasRows(engine, objectName, organizationId)) {
|
|
49
|
+
issues.push({
|
|
50
|
+
layer: "runtime",
|
|
51
|
+
severity: "error",
|
|
52
|
+
artifact: { type: "seed", name: p.name },
|
|
53
|
+
ref: { type: "object", name: objectName },
|
|
54
|
+
code: "seed_not_applied",
|
|
55
|
+
message: `Seed "${p.name}" was published but object "${objectName}" has no rows \u2014 the sample data never materialized.`,
|
|
56
|
+
fix: `Check the publish response's seedApplied for the load error, fix the seed rows (field names/types), and republish the seed.`
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
} catch (e) {
|
|
60
|
+
issues.push({
|
|
61
|
+
layer: "runtime",
|
|
62
|
+
severity: "error",
|
|
63
|
+
artifact: { type: "seed", name: p.name },
|
|
64
|
+
ref: { type: "object", name: objectName },
|
|
65
|
+
code: "seed_not_applied",
|
|
66
|
+
message: `Seed "${p.name}" probe could not read object "${objectName}": ${String(_nullishCoalesce(_optionalChain([e, 'optionalAccess', _2 => _2.message]), () => ( e)))}`
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (const p of published.filter((x) => x.type === "view")) {
|
|
71
|
+
const body = asRec(await readItem("view", p.name));
|
|
72
|
+
const config = asRec(_optionalChain([body, 'optionalAccess', _3 => _3.config]));
|
|
73
|
+
const dataObj = _optionalChain([asRec, 'call', _4 => _4(_optionalChain([config, 'optionalAccess', _5 => _5.data])), 'optionalAccess', _6 => _6.object]);
|
|
74
|
+
const objectName = typeof _optionalChain([body, 'optionalAccess', _7 => _7.object]) === "string" ? body.object : typeof dataObj === "string" ? dataObj : void 0;
|
|
75
|
+
if (!objectName) continue;
|
|
76
|
+
checked.views += 1;
|
|
77
|
+
try {
|
|
78
|
+
await engine.find(objectName, {
|
|
79
|
+
fields: ["id"],
|
|
80
|
+
limit: 1,
|
|
81
|
+
...organizationId ? { where: { organization_id: organizationId } } : {},
|
|
82
|
+
context: { isSystem: true }
|
|
83
|
+
});
|
|
84
|
+
} catch (e) {
|
|
85
|
+
issues.push({
|
|
86
|
+
layer: "runtime",
|
|
87
|
+
severity: "error",
|
|
88
|
+
artifact: { type: "view", name: p.name },
|
|
89
|
+
ref: { type: "object", name: objectName },
|
|
90
|
+
code: "view_read_failed",
|
|
91
|
+
message: `View "${p.name}" cannot read object "${objectName}": ${String(_nullishCoalesce(_optionalChain([e, 'optionalAccess', _8 => _8.message]), () => ( e)))} \u2014 it will render as an error for every user.`,
|
|
92
|
+
fix: `Verify object "${objectName}" published successfully (its table must exist) and that the view's binding is correct.`
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const dashboards = published.filter((x) => x.type === "dashboard");
|
|
97
|
+
let widgetsToProbe = 0;
|
|
98
|
+
for (const p of dashboards) {
|
|
99
|
+
const body = asRec(await readItem("dashboard", p.name));
|
|
100
|
+
const widgets = asArr(_optionalChain([body, 'optionalAccess', _9 => _9.widgets])).map(asRec).filter((w) => !!w);
|
|
101
|
+
const datasetBound = widgets.filter((w) => typeof w.dataset === "string" && w.dataset);
|
|
102
|
+
widgetsToProbe += datasetBound.length;
|
|
103
|
+
if (!analytics || typeof analytics.queryDataset !== "function") continue;
|
|
104
|
+
for (const w of datasetBound) {
|
|
105
|
+
const widgetId = String(_nullishCoalesce(_nullishCoalesce(w.id, () => ( w.title)), () => ( "?")));
|
|
106
|
+
const dsName = w.dataset;
|
|
107
|
+
const dataset = asRec(await readItem("dataset", dsName));
|
|
108
|
+
if (!dataset) continue;
|
|
109
|
+
checked.widgets += 1;
|
|
110
|
+
const measures = asArr(w.values).filter((v) => typeof v === "string" && v.length > 0);
|
|
111
|
+
const firstMeasure = _optionalChain([asRec, 'call', _10 => _10(asArr(dataset.measures)[0]), 'optionalAccess', _11 => _11.name]);
|
|
112
|
+
const selection = {
|
|
113
|
+
measures: measures.length ? measures : typeof firstMeasure === "string" ? [firstMeasure] : [],
|
|
114
|
+
dimensions: [],
|
|
115
|
+
limit: 1
|
|
116
|
+
};
|
|
117
|
+
if (selection.measures.length === 0) continue;
|
|
118
|
+
const objectName = typeof dataset.object === "string" ? dataset.object : void 0;
|
|
119
|
+
try {
|
|
120
|
+
const result = await analytics.queryDataset(dataset, selection, void 0);
|
|
121
|
+
const rows = resultRows(result);
|
|
122
|
+
if (rows.length === 0 && objectName && await hasRows(engine, objectName, organizationId)) {
|
|
123
|
+
issues.push({
|
|
124
|
+
layer: "runtime",
|
|
125
|
+
severity: "error",
|
|
126
|
+
artifact: { type: "dashboard", name: p.name },
|
|
127
|
+
ref: { type: "dataset", name: dsName, member: widgetId },
|
|
128
|
+
code: "empty_query",
|
|
129
|
+
message: `Dashboard "${p.name}" widget "${widgetId}" returns NO data from dataset "${dsName}" although object "${objectName}" has rows \u2014 the widget will render empty for every user.`,
|
|
130
|
+
fix: `Run the dataset query directly to see the compiled strategy/SQL; check the dataset's measure/dimension field bindings against object "${objectName}".`
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
} catch (e) {
|
|
134
|
+
issues.push({
|
|
135
|
+
layer: "runtime",
|
|
136
|
+
severity: "error",
|
|
137
|
+
artifact: { type: "dashboard", name: p.name },
|
|
138
|
+
ref: { type: "dataset", name: dsName, member: widgetId },
|
|
139
|
+
code: "widget_query_failed",
|
|
140
|
+
message: `Dashboard "${p.name}" widget "${widgetId}" query against dataset "${dsName}" failed: ${String(_nullishCoalesce(_optionalChain([e, 'optionalAccess', _12 => _12.message]), () => ( e)))}`,
|
|
141
|
+
fix: `Fix the dataset definition (or the widget's values/dimensions) so the query compiles, then republish.`
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (widgetsToProbe > 0 && (!analytics || typeof analytics.queryDataset !== "function")) {
|
|
147
|
+
issues.push({
|
|
148
|
+
layer: "runtime",
|
|
149
|
+
severity: "warning",
|
|
150
|
+
artifact: { type: "dashboard", name: dashboards.map((d) => d.name).join(", ") },
|
|
151
|
+
code: "probes_unavailable",
|
|
152
|
+
message: `${widgetsToProbe} dashboard widget(s) could not be probed: no analytics service is mounted on this kernel.`
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return { issues, checked };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
exports.runBuildProbes = runBuildProbes;
|
|
161
|
+
//# sourceMappingURL=chunk-7LOFAEHA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/framework/framework/packages/metadata-protocol/dist/chunk-7LOFAEHA.cjs","../src/build-probes.ts"],"names":[],"mappings":"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","file":"/home/runner/work/framework/framework/packages/metadata-protocol/dist/chunk-7LOFAEHA.cjs","sourcesContent":[null,"// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n//\n// ADR-0038 L3 — runtime probes: after a publish, exercise the published app\n// the way a user would (one real read per artifact) and report what is\n// actually broken AT RUNTIME. Schema-valid ≠ renders ≠ returns data: the\n// 2026-06-10/11 incident set shipped seeds that never materialized, dataset\n// queries that returned 0 on populated objects, and \"Published!\" states the\n// runtime couldn't read back — all invisible until something actually\n// queried. These probes are that something, run by the build pipeline (not\n// the user), generalizing the `seedApplied` pattern to the whole artifact\n// graph.\n//\n// Every finding is a BuildIssue (the ADR-0038 verification contract — same\n// shape the cloud L1 graph lint emits) with `layer: 'runtime'`, so agents,\n// chat surfaces, and eval harnesses consume one stream regardless of which\n// verification plane found the problem.\n\n/** One runtime-verification finding (ADR-0038 BuildIssue, layer 'runtime'). */\nexport interface RuntimeBuildIssue {\n layer: 'runtime';\n severity: 'error' | 'warning';\n /** The artifact whose runtime behaviour is broken. */\n artifact: { type: string; name: string };\n /** What it exercised, when narrower than the artifact (e.g. a widget). */\n ref?: { type: string; name: string; member?: string };\n /** 'seed_not_applied' | 'view_read_failed' | 'empty_query' | 'widget_query_failed' | 'probes_unavailable' */\n code: string;\n message: string;\n fix?: string;\n}\n\n/** Aggregate result of one post-publish probe pass. */\nexport interface BuildProbeReport {\n /** Findings, empty when every probe passed. */\n issues: RuntimeBuildIssue[];\n /** How many probes actually ran, per plane (0s mean nothing to probe). */\n checked: { seeds: number; views: number; widgets: number };\n}\n\n/** The single read the probes need from the data engine. */\nexport interface ProbeEngine {\n find(objectName: string, query: unknown): Promise<Array<Record<string, unknown>>>;\n}\n\n/** Optional analytics surface — when absent, widget probes degrade to a warning. */\nexport interface ProbeAnalytics {\n queryDataset(dataset: unknown, selection: unknown, context?: unknown): Promise<unknown>;\n}\n\nexport interface RunBuildProbesOptions {\n engine: ProbeEngine;\n /** Read an ACTIVE (published) item body by type+name; undefined when absent. */\n getItem: (type: string, name: string) => Promise<unknown | undefined>;\n /** The just-published artifact set (publishPackageDrafts' `published`). */\n published: Array<{ type: string; name: string }>;\n /**\n * The kernel's analytics service, when one is mounted. Widget probes run\n * the SAME `queryDataset` path the dashboard renderer hits — absent\n * service means widgets can't be probed (one aggregate warning, not\n * per-widget noise).\n */\n analytics?: ProbeAnalytics;\n /** Threaded into engine/analytics reads (tenant scoping). */\n organizationId?: string | null;\n}\n\ntype Rec = Record<string, unknown>;\n\nfunction asRec(v: unknown): Rec | undefined {\n return v && typeof v === 'object' && !Array.isArray(v) ? (v as Rec) : undefined;\n}\n\nfunction asArr(v: unknown): unknown[] {\n return Array.isArray(v) ? v : [];\n}\n\n/** Result rows of a queryDataset call, tolerant of {rows}/{data}/array shapes. */\nfunction resultRows(result: unknown): unknown[] {\n if (Array.isArray(result)) return result;\n const r = asRec(result);\n if (!r) return [];\n if (Array.isArray(r.rows)) return r.rows;\n if (Array.isArray(r.data)) return r.data;\n return [];\n}\n\n/** True when the object has at least one row (probe read, isSystem). */\nasync function hasRows(\n engine: ProbeEngine,\n objectName: string,\n organizationId?: string | null,\n): Promise<boolean> {\n const rows = await engine.find(objectName, {\n fields: ['id'],\n limit: 1,\n ...(organizationId ? { where: { organization_id: organizationId } } : {}),\n context: { isSystem: true },\n });\n return Array.isArray(rows) && rows.length > 0;\n}\n\n/**\n * Run the L3 runtime probes over a just-published artifact set:\n *\n * • per published `seed` — its target object must have rows now\n * (`seed_not_applied`: the rows were promised but never materialized);\n * • per published `view` — a limit-1 read through the same engine the\n * renderer uses must not throw (`view_read_failed`);\n * • per published `dashboard` widget — its real dataset selection must\n * execute (`widget_query_failed`) and must not return empty on an object\n * that HAS rows (`empty_query` — the four-layer staging incident class).\n *\n * All probes are reads (limit-1 / single aggregate); a probe crash is\n * reported, never thrown — verification must not break the publish it\n * verifies.\n */\nexport async function runBuildProbes(opts: RunBuildProbesOptions): Promise<BuildProbeReport> {\n const issues: RuntimeBuildIssue[] = [];\n const checked = { seeds: 0, views: 0, widgets: 0 };\n const { engine, getItem, published, analytics, organizationId } = opts;\n\n // Memoized active-item reads (a dashboard and its widgets share datasets).\n const itemCache = new Map<string, unknown | undefined>();\n const readItem = async (type: string, name: string): Promise<unknown | undefined> => {\n const key = `${type} ${name}`;\n if (itemCache.has(key)) return itemCache.get(key);\n let item: unknown | undefined;\n try {\n item = await getItem(type, name);\n } catch {\n item = undefined;\n }\n itemCache.set(key, item);\n return item;\n };\n\n // ── Seeds: rows must exist after publish ────────────────────────────────\n for (const p of published.filter((x) => x.type === 'seed')) {\n const body = asRec(await readItem('seed', p.name));\n const objectName = typeof body?.object === 'string' ? body.object : undefined;\n if (!objectName) continue;\n checked.seeds += 1;\n try {\n if (!(await hasRows(engine, objectName, organizationId))) {\n issues.push({\n layer: 'runtime',\n severity: 'error',\n artifact: { type: 'seed', name: p.name },\n ref: { type: 'object', name: objectName },\n code: 'seed_not_applied',\n message: `Seed \"${p.name}\" was published but object \"${objectName}\" has no rows — the sample data never materialized.`,\n fix: `Check the publish response's seedApplied for the load error, fix the seed rows (field names/types), and republish the seed.`,\n });\n }\n } catch (e) {\n issues.push({\n layer: 'runtime',\n severity: 'error',\n artifact: { type: 'seed', name: p.name },\n ref: { type: 'object', name: objectName },\n code: 'seed_not_applied',\n message: `Seed \"${p.name}\" probe could not read object \"${objectName}\": ${String((e as Error)?.message ?? e)}`,\n });\n }\n }\n\n // ── Views: the renderer's read path must not throw ──────────────────────\n for (const p of published.filter((x) => x.type === 'view')) {\n const body = asRec(await readItem('view', p.name));\n const config = asRec(body?.config);\n const dataObj = asRec(config?.data)?.object;\n const objectName =\n typeof body?.object === 'string' ? body.object\n : typeof dataObj === 'string' ? dataObj\n : undefined;\n if (!objectName) continue;\n checked.views += 1;\n try {\n await engine.find(objectName, {\n fields: ['id'],\n limit: 1,\n ...(organizationId ? { where: { organization_id: organizationId } } : {}),\n context: { isSystem: true },\n });\n } catch (e) {\n issues.push({\n layer: 'runtime',\n severity: 'error',\n artifact: { type: 'view', name: p.name },\n ref: { type: 'object', name: objectName },\n code: 'view_read_failed',\n message: `View \"${p.name}\" cannot read object \"${objectName}\": ${String((e as Error)?.message ?? e)} — it will render as an error for every user.`,\n fix: `Verify object \"${objectName}\" published successfully (its table must exist) and that the view's binding is correct.`,\n });\n }\n }\n\n // ── Dashboard widgets: the real dataset selection must return data ──────\n const dashboards = published.filter((x) => x.type === 'dashboard');\n let widgetsToProbe = 0;\n for (const p of dashboards) {\n const body = asRec(await readItem('dashboard', p.name));\n const widgets = asArr(body?.widgets).map(asRec).filter((w): w is Rec => !!w);\n const datasetBound = widgets.filter((w) => typeof w.dataset === 'string' && w.dataset);\n widgetsToProbe += datasetBound.length;\n if (!analytics || typeof analytics.queryDataset !== 'function') continue;\n\n for (const w of datasetBound) {\n const widgetId = String(w.id ?? w.title ?? '?');\n const dsName = w.dataset as string;\n const dataset = asRec(await readItem('dataset', dsName));\n if (!dataset) continue; // dangling dataset is an L1 (graph) finding, not a runtime one\n checked.widgets += 1;\n\n // The widget's own selection when present, else the dataset's\n // first measure — the same default the renderer falls back to.\n const measures = asArr(w.values).filter((v): v is string => typeof v === 'string' && v.length > 0);\n const firstMeasure = asRec(asArr(dataset.measures)[0])?.name;\n const selection = {\n measures: measures.length ? measures : typeof firstMeasure === 'string' ? [firstMeasure] : [],\n dimensions: [],\n limit: 1,\n };\n if (selection.measures.length === 0) continue; // nothing selectable — schema/graph problem\n\n const objectName = typeof dataset.object === 'string' ? dataset.object : undefined;\n try {\n const result = await analytics.queryDataset(dataset, selection, undefined);\n const rows = resultRows(result);\n if (rows.length === 0 && objectName && (await hasRows(engine, objectName, organizationId))) {\n issues.push({\n layer: 'runtime',\n severity: 'error',\n artifact: { type: 'dashboard', name: p.name },\n ref: { type: 'dataset', name: dsName, member: widgetId },\n code: 'empty_query',\n message: `Dashboard \"${p.name}\" widget \"${widgetId}\" returns NO data from dataset \"${dsName}\" although object \"${objectName}\" has rows — the widget will render empty for every user.`,\n fix: `Run the dataset query directly to see the compiled strategy/SQL; check the dataset's measure/dimension field bindings against object \"${objectName}\".`,\n });\n }\n } catch (e) {\n issues.push({\n layer: 'runtime',\n severity: 'error',\n artifact: { type: 'dashboard', name: p.name },\n ref: { type: 'dataset', name: dsName, member: widgetId },\n code: 'widget_query_failed',\n message: `Dashboard \"${p.name}\" widget \"${widgetId}\" query against dataset \"${dsName}\" failed: ${String((e as Error)?.message ?? e)}`,\n fix: `Fix the dataset definition (or the widget's values/dimensions) so the query compiles, then republish.`,\n });\n }\n }\n }\n\n // Widgets existed but no analytics service was mounted — say so ONCE\n // (silence would read as \"probed and passed\", which it was not).\n if (widgetsToProbe > 0 && (!analytics || typeof analytics.queryDataset !== 'function')) {\n issues.push({\n layer: 'runtime',\n severity: 'warning',\n artifact: { type: 'dashboard', name: dashboards.map((d) => d.name).join(', ') },\n code: 'probes_unavailable',\n message: `${widgetsToProbe} dashboard widget(s) could not be probed: no analytics service is mounted on this kernel.`,\n });\n }\n\n return { issues, checked };\n}\n"]}
|