@objectstack/objectql 9.0.0 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +85 -1
- package/dist/index.d.ts +85 -1
- package/dist/index.js +195 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +194 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -358,6 +358,81 @@ declare class SchemaRegistry {
|
|
|
358
358
|
reset(): void;
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
+
/** One runtime-verification finding (ADR-0038 BuildIssue, layer 'runtime'). */
|
|
362
|
+
interface RuntimeBuildIssue {
|
|
363
|
+
layer: 'runtime';
|
|
364
|
+
severity: 'error' | 'warning';
|
|
365
|
+
/** The artifact whose runtime behaviour is broken. */
|
|
366
|
+
artifact: {
|
|
367
|
+
type: string;
|
|
368
|
+
name: string;
|
|
369
|
+
};
|
|
370
|
+
/** What it exercised, when narrower than the artifact (e.g. a widget). */
|
|
371
|
+
ref?: {
|
|
372
|
+
type: string;
|
|
373
|
+
name: string;
|
|
374
|
+
member?: string;
|
|
375
|
+
};
|
|
376
|
+
/** 'seed_not_applied' | 'view_read_failed' | 'empty_query' | 'widget_query_failed' | 'probes_unavailable' */
|
|
377
|
+
code: string;
|
|
378
|
+
message: string;
|
|
379
|
+
fix?: string;
|
|
380
|
+
}
|
|
381
|
+
/** Aggregate result of one post-publish probe pass. */
|
|
382
|
+
interface BuildProbeReport {
|
|
383
|
+
/** Findings, empty when every probe passed. */
|
|
384
|
+
issues: RuntimeBuildIssue[];
|
|
385
|
+
/** How many probes actually ran, per plane (0s mean nothing to probe). */
|
|
386
|
+
checked: {
|
|
387
|
+
seeds: number;
|
|
388
|
+
views: number;
|
|
389
|
+
widgets: number;
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
/** The single read the probes need from the data engine. */
|
|
393
|
+
interface ProbeEngine {
|
|
394
|
+
find(objectName: string, query: unknown): Promise<Array<Record<string, unknown>>>;
|
|
395
|
+
}
|
|
396
|
+
/** Optional analytics surface — when absent, widget probes degrade to a warning. */
|
|
397
|
+
interface ProbeAnalytics {
|
|
398
|
+
queryDataset(dataset: unknown, selection: unknown, context?: unknown): Promise<unknown>;
|
|
399
|
+
}
|
|
400
|
+
interface RunBuildProbesOptions {
|
|
401
|
+
engine: ProbeEngine;
|
|
402
|
+
/** Read an ACTIVE (published) item body by type+name; undefined when absent. */
|
|
403
|
+
getItem: (type: string, name: string) => Promise<unknown | undefined>;
|
|
404
|
+
/** The just-published artifact set (publishPackageDrafts' `published`). */
|
|
405
|
+
published: Array<{
|
|
406
|
+
type: string;
|
|
407
|
+
name: string;
|
|
408
|
+
}>;
|
|
409
|
+
/**
|
|
410
|
+
* The kernel's analytics service, when one is mounted. Widget probes run
|
|
411
|
+
* the SAME `queryDataset` path the dashboard renderer hits — absent
|
|
412
|
+
* service means widgets can't be probed (one aggregate warning, not
|
|
413
|
+
* per-widget noise).
|
|
414
|
+
*/
|
|
415
|
+
analytics?: ProbeAnalytics;
|
|
416
|
+
/** Threaded into engine/analytics reads (tenant scoping). */
|
|
417
|
+
organizationId?: string | null;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Run the L3 runtime probes over a just-published artifact set:
|
|
421
|
+
*
|
|
422
|
+
* • per published `seed` — its target object must have rows now
|
|
423
|
+
* (`seed_not_applied`: the rows were promised but never materialized);
|
|
424
|
+
* • per published `view` — a limit-1 read through the same engine the
|
|
425
|
+
* renderer uses must not throw (`view_read_failed`);
|
|
426
|
+
* • per published `dashboard` widget — its real dataset selection must
|
|
427
|
+
* execute (`widget_query_failed`) and must not return empty on an object
|
|
428
|
+
* that HAS rows (`empty_query` — the four-layer staging incident class).
|
|
429
|
+
*
|
|
430
|
+
* All probes are reads (limit-1 / single aggregate); a probe crash is
|
|
431
|
+
* reported, never thrown — verification must not break the publish it
|
|
432
|
+
* verifies.
|
|
433
|
+
*/
|
|
434
|
+
declare function runBuildProbes(opts: RunBuildProbesOptions): Promise<BuildProbeReport>;
|
|
435
|
+
|
|
361
436
|
/**
|
|
362
437
|
* Re-export the canonical validation-result type so callers in this
|
|
363
438
|
* package don't need to dual-import from `@objectstack/spec/kernel`.
|
|
@@ -1340,6 +1415,15 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
1340
1415
|
error?: string;
|
|
1341
1416
|
errors?: unknown[];
|
|
1342
1417
|
};
|
|
1418
|
+
/**
|
|
1419
|
+
* ADR-0038 L3 — post-publish runtime probe report (absent when nothing
|
|
1420
|
+
* was publishable). One real read per published artifact: seeded
|
|
1421
|
+
* objects must have rows, views must be readable, dashboard widgets'
|
|
1422
|
+
* dataset selections must execute and return data. `issues` carries
|
|
1423
|
+
* BuildIssue-shaped findings (layer 'runtime') for the agent / chat
|
|
1424
|
+
* health surfaces; probes never fail the publish itself.
|
|
1425
|
+
*/
|
|
1426
|
+
probes?: BuildProbeReport;
|
|
1343
1427
|
}>;
|
|
1344
1428
|
/**
|
|
1345
1429
|
* Discard every pending DRAFT bound to a package — the NON-destructive
|
|
@@ -3195,4 +3279,4 @@ declare class SeedLoaderService implements ISeedLoaderService {
|
|
|
3195
3279
|
private buildResult;
|
|
3196
3280
|
}
|
|
3197
3281
|
|
|
3198
|
-
export { type BindHooksOptions, type BindHooksResult, DEFAULT_EXTENDER_PRIORITY, DEFAULT_OWNER_PRIORITY, type EngineMiddleware, type EvaluateRulesOptions, type FieldValidationError, type HookEntry, type HookHandler, type HookMetricLabel, type HookMetricOutcome, type HookMetricsRecorder, type HookSkipReason, InMemoryHookMetricsRecorder, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, MetadataFacade, type ObjectContributor, ObjectQL, type ObjectQLHostContext, type ObjectQLKernelOptions, ObjectQLPlugin, ObjectRepository, ObjectStackProtocolImplementation, type OperationContext, RESERVED_NAMESPACES, SECRET_MASK, SECRET_REF_PREFIX, SchemaRegistry, type SchemaRegistryOptions, ScopedContext, SeedLoaderService, type SysMetadataEngine, SysMetadataRepository, type SysMetadataRepositoryOptions, ValidationError, type WrapDeclarativeOptions, applyInMemoryAggregation, applySystemFields, bindHooksToEngine, bucketDateValue, collectSecretFields, computeFQN, convertIntrospectedSchemaToObjects, createObjectQLKernel, evaluateValidationRules, isSecretRef, legalNextStates, makeSecretRef, needsPriorRecord, noopHookMetricsRecorder, parseFQN, parseSecretRef, toTitleCase, validateRecord, wrapDeclarativeHook };
|
|
3282
|
+
export { type BindHooksOptions, type BindHooksResult, type BuildProbeReport, DEFAULT_EXTENDER_PRIORITY, DEFAULT_OWNER_PRIORITY, type EngineMiddleware, type EvaluateRulesOptions, type FieldValidationError, type HookEntry, type HookHandler, type HookMetricLabel, type HookMetricOutcome, type HookMetricsRecorder, type HookSkipReason, InMemoryHookMetricsRecorder, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, MetadataFacade, type ObjectContributor, ObjectQL, type ObjectQLHostContext, type ObjectQLKernelOptions, ObjectQLPlugin, ObjectRepository, ObjectStackProtocolImplementation, type OperationContext, RESERVED_NAMESPACES, type RunBuildProbesOptions, type RuntimeBuildIssue, SECRET_MASK, SECRET_REF_PREFIX, SchemaRegistry, type SchemaRegistryOptions, ScopedContext, SeedLoaderService, type SysMetadataEngine, SysMetadataRepository, type SysMetadataRepositoryOptions, ValidationError, type WrapDeclarativeOptions, applyInMemoryAggregation, applySystemFields, bindHooksToEngine, bucketDateValue, collectSecretFields, computeFQN, convertIntrospectedSchemaToObjects, createObjectQLKernel, evaluateValidationRules, isSecretRef, legalNextStates, makeSecretRef, needsPriorRecord, noopHookMetricsRecorder, parseFQN, parseSecretRef, runBuildProbes, toTitleCase, validateRecord, wrapDeclarativeHook };
|
package/dist/index.d.ts
CHANGED
|
@@ -358,6 +358,81 @@ declare class SchemaRegistry {
|
|
|
358
358
|
reset(): void;
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
+
/** One runtime-verification finding (ADR-0038 BuildIssue, layer 'runtime'). */
|
|
362
|
+
interface RuntimeBuildIssue {
|
|
363
|
+
layer: 'runtime';
|
|
364
|
+
severity: 'error' | 'warning';
|
|
365
|
+
/** The artifact whose runtime behaviour is broken. */
|
|
366
|
+
artifact: {
|
|
367
|
+
type: string;
|
|
368
|
+
name: string;
|
|
369
|
+
};
|
|
370
|
+
/** What it exercised, when narrower than the artifact (e.g. a widget). */
|
|
371
|
+
ref?: {
|
|
372
|
+
type: string;
|
|
373
|
+
name: string;
|
|
374
|
+
member?: string;
|
|
375
|
+
};
|
|
376
|
+
/** 'seed_not_applied' | 'view_read_failed' | 'empty_query' | 'widget_query_failed' | 'probes_unavailable' */
|
|
377
|
+
code: string;
|
|
378
|
+
message: string;
|
|
379
|
+
fix?: string;
|
|
380
|
+
}
|
|
381
|
+
/** Aggregate result of one post-publish probe pass. */
|
|
382
|
+
interface BuildProbeReport {
|
|
383
|
+
/** Findings, empty when every probe passed. */
|
|
384
|
+
issues: RuntimeBuildIssue[];
|
|
385
|
+
/** How many probes actually ran, per plane (0s mean nothing to probe). */
|
|
386
|
+
checked: {
|
|
387
|
+
seeds: number;
|
|
388
|
+
views: number;
|
|
389
|
+
widgets: number;
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
/** The single read the probes need from the data engine. */
|
|
393
|
+
interface ProbeEngine {
|
|
394
|
+
find(objectName: string, query: unknown): Promise<Array<Record<string, unknown>>>;
|
|
395
|
+
}
|
|
396
|
+
/** Optional analytics surface — when absent, widget probes degrade to a warning. */
|
|
397
|
+
interface ProbeAnalytics {
|
|
398
|
+
queryDataset(dataset: unknown, selection: unknown, context?: unknown): Promise<unknown>;
|
|
399
|
+
}
|
|
400
|
+
interface RunBuildProbesOptions {
|
|
401
|
+
engine: ProbeEngine;
|
|
402
|
+
/** Read an ACTIVE (published) item body by type+name; undefined when absent. */
|
|
403
|
+
getItem: (type: string, name: string) => Promise<unknown | undefined>;
|
|
404
|
+
/** The just-published artifact set (publishPackageDrafts' `published`). */
|
|
405
|
+
published: Array<{
|
|
406
|
+
type: string;
|
|
407
|
+
name: string;
|
|
408
|
+
}>;
|
|
409
|
+
/**
|
|
410
|
+
* The kernel's analytics service, when one is mounted. Widget probes run
|
|
411
|
+
* the SAME `queryDataset` path the dashboard renderer hits — absent
|
|
412
|
+
* service means widgets can't be probed (one aggregate warning, not
|
|
413
|
+
* per-widget noise).
|
|
414
|
+
*/
|
|
415
|
+
analytics?: ProbeAnalytics;
|
|
416
|
+
/** Threaded into engine/analytics reads (tenant scoping). */
|
|
417
|
+
organizationId?: string | null;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Run the L3 runtime probes over a just-published artifact set:
|
|
421
|
+
*
|
|
422
|
+
* • per published `seed` — its target object must have rows now
|
|
423
|
+
* (`seed_not_applied`: the rows were promised but never materialized);
|
|
424
|
+
* • per published `view` — a limit-1 read through the same engine the
|
|
425
|
+
* renderer uses must not throw (`view_read_failed`);
|
|
426
|
+
* • per published `dashboard` widget — its real dataset selection must
|
|
427
|
+
* execute (`widget_query_failed`) and must not return empty on an object
|
|
428
|
+
* that HAS rows (`empty_query` — the four-layer staging incident class).
|
|
429
|
+
*
|
|
430
|
+
* All probes are reads (limit-1 / single aggregate); a probe crash is
|
|
431
|
+
* reported, never thrown — verification must not break the publish it
|
|
432
|
+
* verifies.
|
|
433
|
+
*/
|
|
434
|
+
declare function runBuildProbes(opts: RunBuildProbesOptions): Promise<BuildProbeReport>;
|
|
435
|
+
|
|
361
436
|
/**
|
|
362
437
|
* Re-export the canonical validation-result type so callers in this
|
|
363
438
|
* package don't need to dual-import from `@objectstack/spec/kernel`.
|
|
@@ -1340,6 +1415,15 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
|
1340
1415
|
error?: string;
|
|
1341
1416
|
errors?: unknown[];
|
|
1342
1417
|
};
|
|
1418
|
+
/**
|
|
1419
|
+
* ADR-0038 L3 — post-publish runtime probe report (absent when nothing
|
|
1420
|
+
* was publishable). One real read per published artifact: seeded
|
|
1421
|
+
* objects must have rows, views must be readable, dashboard widgets'
|
|
1422
|
+
* dataset selections must execute and return data. `issues` carries
|
|
1423
|
+
* BuildIssue-shaped findings (layer 'runtime') for the agent / chat
|
|
1424
|
+
* health surfaces; probes never fail the publish itself.
|
|
1425
|
+
*/
|
|
1426
|
+
probes?: BuildProbeReport;
|
|
1343
1427
|
}>;
|
|
1344
1428
|
/**
|
|
1345
1429
|
* Discard every pending DRAFT bound to a package — the NON-destructive
|
|
@@ -3195,4 +3279,4 @@ declare class SeedLoaderService implements ISeedLoaderService {
|
|
|
3195
3279
|
private buildResult;
|
|
3196
3280
|
}
|
|
3197
3281
|
|
|
3198
|
-
export { type BindHooksOptions, type BindHooksResult, DEFAULT_EXTENDER_PRIORITY, DEFAULT_OWNER_PRIORITY, type EngineMiddleware, type EvaluateRulesOptions, type FieldValidationError, type HookEntry, type HookHandler, type HookMetricLabel, type HookMetricOutcome, type HookMetricsRecorder, type HookSkipReason, InMemoryHookMetricsRecorder, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, MetadataFacade, type ObjectContributor, ObjectQL, type ObjectQLHostContext, type ObjectQLKernelOptions, ObjectQLPlugin, ObjectRepository, ObjectStackProtocolImplementation, type OperationContext, RESERVED_NAMESPACES, SECRET_MASK, SECRET_REF_PREFIX, SchemaRegistry, type SchemaRegistryOptions, ScopedContext, SeedLoaderService, type SysMetadataEngine, SysMetadataRepository, type SysMetadataRepositoryOptions, ValidationError, type WrapDeclarativeOptions, applyInMemoryAggregation, applySystemFields, bindHooksToEngine, bucketDateValue, collectSecretFields, computeFQN, convertIntrospectedSchemaToObjects, createObjectQLKernel, evaluateValidationRules, isSecretRef, legalNextStates, makeSecretRef, needsPriorRecord, noopHookMetricsRecorder, parseFQN, parseSecretRef, toTitleCase, validateRecord, wrapDeclarativeHook };
|
|
3282
|
+
export { type BindHooksOptions, type BindHooksResult, type BuildProbeReport, DEFAULT_EXTENDER_PRIORITY, DEFAULT_OWNER_PRIORITY, type EngineMiddleware, type EvaluateRulesOptions, type FieldValidationError, type HookEntry, type HookHandler, type HookMetricLabel, type HookMetricOutcome, type HookMetricsRecorder, type HookSkipReason, InMemoryHookMetricsRecorder, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, MetadataFacade, type ObjectContributor, ObjectQL, type ObjectQLHostContext, type ObjectQLKernelOptions, ObjectQLPlugin, ObjectRepository, ObjectStackProtocolImplementation, type OperationContext, RESERVED_NAMESPACES, type RunBuildProbesOptions, type RuntimeBuildIssue, SECRET_MASK, SECRET_REF_PREFIX, SchemaRegistry, type SchemaRegistryOptions, ScopedContext, SeedLoaderService, type SysMetadataEngine, SysMetadataRepository, type SysMetadataRepositoryOptions, ValidationError, type WrapDeclarativeOptions, applyInMemoryAggregation, applySystemFields, bindHooksToEngine, bucketDateValue, collectSecretFields, computeFQN, convertIntrospectedSchemaToObjects, createObjectQLKernel, evaluateValidationRules, isSecretRef, legalNextStates, makeSecretRef, needsPriorRecord, noopHookMetricsRecorder, parseFQN, parseSecretRef, runBuildProbes, toTitleCase, validateRecord, wrapDeclarativeHook };
|
package/dist/index.js
CHANGED
|
@@ -633,6 +633,172 @@ var init_seed_loader = __esm({
|
|
|
633
633
|
}
|
|
634
634
|
});
|
|
635
635
|
|
|
636
|
+
// src/build-probes.ts
|
|
637
|
+
var build_probes_exports = {};
|
|
638
|
+
__export(build_probes_exports, {
|
|
639
|
+
runBuildProbes: () => runBuildProbes
|
|
640
|
+
});
|
|
641
|
+
function asRec(v) {
|
|
642
|
+
return v && typeof v === "object" && !Array.isArray(v) ? v : void 0;
|
|
643
|
+
}
|
|
644
|
+
function asArr(v) {
|
|
645
|
+
return Array.isArray(v) ? v : [];
|
|
646
|
+
}
|
|
647
|
+
function resultRows(result) {
|
|
648
|
+
if (Array.isArray(result)) return result;
|
|
649
|
+
const r = asRec(result);
|
|
650
|
+
if (!r) return [];
|
|
651
|
+
if (Array.isArray(r.rows)) return r.rows;
|
|
652
|
+
if (Array.isArray(r.data)) return r.data;
|
|
653
|
+
return [];
|
|
654
|
+
}
|
|
655
|
+
async function hasRows(engine, objectName, organizationId) {
|
|
656
|
+
const rows = await engine.find(objectName, {
|
|
657
|
+
fields: ["id"],
|
|
658
|
+
limit: 1,
|
|
659
|
+
...organizationId ? { where: { organization_id: organizationId } } : {},
|
|
660
|
+
context: { isSystem: true }
|
|
661
|
+
});
|
|
662
|
+
return Array.isArray(rows) && rows.length > 0;
|
|
663
|
+
}
|
|
664
|
+
async function runBuildProbes(opts) {
|
|
665
|
+
const issues = [];
|
|
666
|
+
const checked = { seeds: 0, views: 0, widgets: 0 };
|
|
667
|
+
const { engine, getItem, published, analytics, organizationId } = opts;
|
|
668
|
+
const itemCache = /* @__PURE__ */ new Map();
|
|
669
|
+
const readItem = async (type, name) => {
|
|
670
|
+
const key = `${type} ${name}`;
|
|
671
|
+
if (itemCache.has(key)) return itemCache.get(key);
|
|
672
|
+
let item;
|
|
673
|
+
try {
|
|
674
|
+
item = await getItem(type, name);
|
|
675
|
+
} catch {
|
|
676
|
+
item = void 0;
|
|
677
|
+
}
|
|
678
|
+
itemCache.set(key, item);
|
|
679
|
+
return item;
|
|
680
|
+
};
|
|
681
|
+
for (const p of published.filter((x) => x.type === "seed")) {
|
|
682
|
+
const body = asRec(await readItem("seed", p.name));
|
|
683
|
+
const objectName = typeof body?.object === "string" ? body.object : void 0;
|
|
684
|
+
if (!objectName) continue;
|
|
685
|
+
checked.seeds += 1;
|
|
686
|
+
try {
|
|
687
|
+
if (!await hasRows(engine, objectName, organizationId)) {
|
|
688
|
+
issues.push({
|
|
689
|
+
layer: "runtime",
|
|
690
|
+
severity: "error",
|
|
691
|
+
artifact: { type: "seed", name: p.name },
|
|
692
|
+
ref: { type: "object", name: objectName },
|
|
693
|
+
code: "seed_not_applied",
|
|
694
|
+
message: `Seed "${p.name}" was published but object "${objectName}" has no rows \u2014 the sample data never materialized.`,
|
|
695
|
+
fix: `Check the publish response's seedApplied for the load error, fix the seed rows (field names/types), and republish the seed.`
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
} catch (e) {
|
|
699
|
+
issues.push({
|
|
700
|
+
layer: "runtime",
|
|
701
|
+
severity: "error",
|
|
702
|
+
artifact: { type: "seed", name: p.name },
|
|
703
|
+
ref: { type: "object", name: objectName },
|
|
704
|
+
code: "seed_not_applied",
|
|
705
|
+
message: `Seed "${p.name}" probe could not read object "${objectName}": ${String(e?.message ?? e)}`
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
for (const p of published.filter((x) => x.type === "view")) {
|
|
710
|
+
const body = asRec(await readItem("view", p.name));
|
|
711
|
+
const config = asRec(body?.config);
|
|
712
|
+
const dataObj = asRec(config?.data)?.object;
|
|
713
|
+
const objectName = typeof body?.object === "string" ? body.object : typeof dataObj === "string" ? dataObj : void 0;
|
|
714
|
+
if (!objectName) continue;
|
|
715
|
+
checked.views += 1;
|
|
716
|
+
try {
|
|
717
|
+
await engine.find(objectName, {
|
|
718
|
+
fields: ["id"],
|
|
719
|
+
limit: 1,
|
|
720
|
+
...organizationId ? { where: { organization_id: organizationId } } : {},
|
|
721
|
+
context: { isSystem: true }
|
|
722
|
+
});
|
|
723
|
+
} catch (e) {
|
|
724
|
+
issues.push({
|
|
725
|
+
layer: "runtime",
|
|
726
|
+
severity: "error",
|
|
727
|
+
artifact: { type: "view", name: p.name },
|
|
728
|
+
ref: { type: "object", name: objectName },
|
|
729
|
+
code: "view_read_failed",
|
|
730
|
+
message: `View "${p.name}" cannot read object "${objectName}": ${String(e?.message ?? e)} \u2014 it will render as an error for every user.`,
|
|
731
|
+
fix: `Verify object "${objectName}" published successfully (its table must exist) and that the view's binding is correct.`
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
const dashboards = published.filter((x) => x.type === "dashboard");
|
|
736
|
+
let widgetsToProbe = 0;
|
|
737
|
+
for (const p of dashboards) {
|
|
738
|
+
const body = asRec(await readItem("dashboard", p.name));
|
|
739
|
+
const widgets = asArr(body?.widgets).map(asRec).filter((w) => !!w);
|
|
740
|
+
const datasetBound = widgets.filter((w) => typeof w.dataset === "string" && w.dataset);
|
|
741
|
+
widgetsToProbe += datasetBound.length;
|
|
742
|
+
if (!analytics || typeof analytics.queryDataset !== "function") continue;
|
|
743
|
+
for (const w of datasetBound) {
|
|
744
|
+
const widgetId = String(w.id ?? w.title ?? "?");
|
|
745
|
+
const dsName = w.dataset;
|
|
746
|
+
const dataset = asRec(await readItem("dataset", dsName));
|
|
747
|
+
if (!dataset) continue;
|
|
748
|
+
checked.widgets += 1;
|
|
749
|
+
const measures = asArr(w.values).filter((v) => typeof v === "string" && v.length > 0);
|
|
750
|
+
const firstMeasure = asRec(asArr(dataset.measures)[0])?.name;
|
|
751
|
+
const selection = {
|
|
752
|
+
measures: measures.length ? measures : typeof firstMeasure === "string" ? [firstMeasure] : [],
|
|
753
|
+
dimensions: [],
|
|
754
|
+
limit: 1
|
|
755
|
+
};
|
|
756
|
+
if (selection.measures.length === 0) continue;
|
|
757
|
+
const objectName = typeof dataset.object === "string" ? dataset.object : void 0;
|
|
758
|
+
try {
|
|
759
|
+
const result = await analytics.queryDataset(dataset, selection, void 0);
|
|
760
|
+
const rows = resultRows(result);
|
|
761
|
+
if (rows.length === 0 && objectName && await hasRows(engine, objectName, organizationId)) {
|
|
762
|
+
issues.push({
|
|
763
|
+
layer: "runtime",
|
|
764
|
+
severity: "error",
|
|
765
|
+
artifact: { type: "dashboard", name: p.name },
|
|
766
|
+
ref: { type: "dataset", name: dsName, member: widgetId },
|
|
767
|
+
code: "empty_query",
|
|
768
|
+
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.`,
|
|
769
|
+
fix: `Run the dataset query directly to see the compiled strategy/SQL; check the dataset's measure/dimension field bindings against object "${objectName}".`
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
} catch (e) {
|
|
773
|
+
issues.push({
|
|
774
|
+
layer: "runtime",
|
|
775
|
+
severity: "error",
|
|
776
|
+
artifact: { type: "dashboard", name: p.name },
|
|
777
|
+
ref: { type: "dataset", name: dsName, member: widgetId },
|
|
778
|
+
code: "widget_query_failed",
|
|
779
|
+
message: `Dashboard "${p.name}" widget "${widgetId}" query against dataset "${dsName}" failed: ${String(e?.message ?? e)}`,
|
|
780
|
+
fix: `Fix the dataset definition (or the widget's values/dimensions) so the query compiles, then republish.`
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
if (widgetsToProbe > 0 && (!analytics || typeof analytics.queryDataset !== "function")) {
|
|
786
|
+
issues.push({
|
|
787
|
+
layer: "runtime",
|
|
788
|
+
severity: "warning",
|
|
789
|
+
artifact: { type: "dashboard", name: dashboards.map((d) => d.name).join(", ") },
|
|
790
|
+
code: "probes_unavailable",
|
|
791
|
+
message: `${widgetsToProbe} dashboard widget(s) could not be probed: no analytics service is mounted on this kernel.`
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
return { issues, checked };
|
|
795
|
+
}
|
|
796
|
+
var init_build_probes = __esm({
|
|
797
|
+
"src/build-probes.ts"() {
|
|
798
|
+
"use strict";
|
|
799
|
+
}
|
|
800
|
+
});
|
|
801
|
+
|
|
636
802
|
// src/index.ts
|
|
637
803
|
var index_exports = {};
|
|
638
804
|
__export(index_exports, {
|
|
@@ -668,6 +834,7 @@ __export(index_exports, {
|
|
|
668
834
|
noopHookMetricsRecorder: () => noopHookMetricsRecorder,
|
|
669
835
|
parseFQN: () => parseFQN,
|
|
670
836
|
parseSecretRef: () => parseSecretRef,
|
|
837
|
+
runBuildProbes: () => runBuildProbes,
|
|
671
838
|
toTitleCase: () => toTitleCase,
|
|
672
839
|
validateRecord: () => validateRecord,
|
|
673
840
|
wrapDeclarativeHook: () => wrapDeclarativeHook
|
|
@@ -5025,13 +5192,38 @@ var _ObjectStackProtocolImplementation = class _ObjectStackProtocolImplementatio
|
|
|
5025
5192
|
});
|
|
5026
5193
|
}
|
|
5027
5194
|
}
|
|
5195
|
+
const seedApplied = seedBodies.length > 0 ? await this.applySeedBodies(seedBodies, orgId) : void 0;
|
|
5196
|
+
let probes;
|
|
5197
|
+
if (published.length > 0) {
|
|
5198
|
+
try {
|
|
5199
|
+
const { runBuildProbes: runBuildProbes2 } = await Promise.resolve().then(() => (init_build_probes(), build_probes_exports));
|
|
5200
|
+
const analytics = this.getServicesRegistry?.().get("analytics");
|
|
5201
|
+
probes = await runBuildProbes2({
|
|
5202
|
+
engine: this.engine,
|
|
5203
|
+
getItem: async (type, name) => {
|
|
5204
|
+
const wrapper = await this.getMetaItem({
|
|
5205
|
+
type,
|
|
5206
|
+
name,
|
|
5207
|
+
...orgId ? { organizationId: orgId } : {}
|
|
5208
|
+
});
|
|
5209
|
+
return wrapper?.item ?? wrapper ?? void 0;
|
|
5210
|
+
},
|
|
5211
|
+
published,
|
|
5212
|
+
...analytics && typeof analytics.queryDataset === "function" ? { analytics } : {},
|
|
5213
|
+
organizationId: orgId
|
|
5214
|
+
});
|
|
5215
|
+
} catch {
|
|
5216
|
+
probes = void 0;
|
|
5217
|
+
}
|
|
5218
|
+
}
|
|
5028
5219
|
return {
|
|
5029
5220
|
success: failed.length === 0 && published.length > 0,
|
|
5030
5221
|
publishedCount: published.length,
|
|
5031
5222
|
failedCount: failed.length,
|
|
5032
5223
|
published,
|
|
5033
5224
|
failed,
|
|
5034
|
-
...
|
|
5225
|
+
...seedApplied ? { seedApplied } : {},
|
|
5226
|
+
...probes ? { probes } : {}
|
|
5035
5227
|
};
|
|
5036
5228
|
}
|
|
5037
5229
|
/**
|
|
@@ -9893,6 +10085,7 @@ function convertIntrospectedSchemaToObjects(introspectedSchema, options) {
|
|
|
9893
10085
|
|
|
9894
10086
|
// src/index.ts
|
|
9895
10087
|
init_seed_loader();
|
|
10088
|
+
init_build_probes();
|
|
9896
10089
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9897
10090
|
0 && (module.exports = {
|
|
9898
10091
|
DEFAULT_EXTENDER_PRIORITY,
|
|
@@ -9927,6 +10120,7 @@ init_seed_loader();
|
|
|
9927
10120
|
noopHookMetricsRecorder,
|
|
9928
10121
|
parseFQN,
|
|
9929
10122
|
parseSecretRef,
|
|
10123
|
+
runBuildProbes,
|
|
9930
10124
|
toTitleCase,
|
|
9931
10125
|
validateRecord,
|
|
9932
10126
|
wrapDeclarativeHook
|