@lightdash/query-sdk 1.34.0 → 1.36.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.
@@ -4,7 +4,7 @@
4
4
  * filters, period pickers) rather than a static module-scope manifest.
5
5
  */
6
6
  import { QueryBuilder } from './query';
7
- import { type SavedChartQuery } from './savedChart';
7
+ import type { SavedChartQuery } from './savedChart';
8
8
  import type { InternalFilterDefinition, ParametersValuesMap, QueryDefinition } from './types';
9
9
  /**
10
10
  * A query declared for scheduled delivery. `label` is the tab/file name in the
@@ -23,30 +23,11 @@ export type DeliveryQuery = {
23
23
  filters?: InternalFilterDefinition[];
24
24
  };
25
25
  export declare function toDeliveryQuery(query: QueryBuilder | SavedChartQuery, name?: string): DeliveryQuery | null;
26
- export declare const DELIVERY_AVAILABLE_MESSAGE_TYPE = "lightdash:delivery:available";
27
- export type DeliveryAvailableMessage = {
28
- type: typeof DELIVERY_AVAILABLE_MESSAGE_TYPE;
29
- queries: DeliveryQuery[];
30
- };
31
- export declare function registerDeliveryQuery(id: string, declaration: DeliveryQuery): void;
32
- export declare function unregisterDeliveryQuery(id: string): void;
33
- export declare function getDeliveryQueries(): DeliveryQuery[];
34
- /** Test-only: clears module state between cases. */
35
- export declare function resetDeliveryRegistry(): void;
36
- /**
37
- * Announce the declared set to the host. Silent while the registry is empty —
38
- * an unconditional announce would unlock a data delivery format for an app
39
- * that declares nothing, which is the lineage failure mode (see lineage.ts).
40
- *
41
- * The registry is read when the timer fires, not when it is scheduled, so a
42
- * declaration registered and removed within one tick never reaches the host.
43
- */
44
- export declare function publishDeliveryQueries(target: Window): void;
45
- export declare function nextDeliveryId(): string;
46
26
  /**
47
- * Declare that this query's results belong in the app's scheduled deliveries.
48
- * Call it alongside the `useLightdash(q)` that renders the same query.
27
+ * @deprecated Inert since the v2 delivery design: scheduled deliveries now
28
+ * capture the app's executed queries host-side, so no declaration is needed.
29
+ * Kept exported so apps generated while this API was advertised don't crash.
49
30
  */
50
- export declare function useDelivery(query: QueryBuilder | SavedChartQuery, options?: {
31
+ export declare function useDelivery(_query: QueryBuilder | SavedChartQuery, _options?: {
51
32
  name?: string;
52
33
  }): void;
package/dist/delivery.js CHANGED
@@ -3,9 +3,7 @@
3
3
  * delivery. Declared during render, so they reflect live app state (global
4
4
  * filters, period pickers) rather than a static module-scope manifest.
5
5
  */
6
- import { useEffect, useMemo, useRef } from 'react';
7
6
  import { QueryBuilder } from './query';
8
- import { savedChartQueryKey } from './savedChart';
9
7
  export function toDeliveryQuery(query, name) {
10
8
  if (query instanceof QueryBuilder) {
11
9
  const built = query.build();
@@ -31,94 +29,11 @@ export function toDeliveryQuery(query, name) {
31
29
  console.warn('[lightdash] useDelivery expects a query() or savedChart() — skipping this declaration.');
32
30
  return null;
33
31
  }
34
- export const DELIVERY_AVAILABLE_MESSAGE_TYPE = 'lightdash:delivery:available';
35
- // Insertion-ordered: Map preserves it, and that order becomes the tab/file
36
- // order in the delivery.
37
- const registry = new Map();
38
- // Every mounted useDelivery publishes on mount, so a page with N declared
39
- // queries would post N times with a growing set. Coalescing collapses that to
40
- // one message carrying the settled set.
41
- const PUBLISH_COALESCE_MS = 0;
42
- let publishTimer = null;
43
- export function registerDeliveryQuery(id, declaration) {
44
- registry.set(id, declaration);
45
- }
46
- export function unregisterDeliveryQuery(id) {
47
- registry.delete(id);
48
- }
49
- export function getDeliveryQueries() {
50
- return [...registry.values()];
51
- }
52
- /** Test-only: clears module state between cases. */
53
- export function resetDeliveryRegistry() {
54
- registry.clear();
55
- if (publishTimer !== null) {
56
- clearTimeout(publishTimer);
57
- publishTimer = null;
58
- }
59
- }
60
32
  /**
61
- * Announce the declared set to the host. Silent while the registry is empty —
62
- * an unconditional announce would unlock a data delivery format for an app
63
- * that declares nothing, which is the lineage failure mode (see lineage.ts).
64
- *
65
- * The registry is read when the timer fires, not when it is scheduled, so a
66
- * declaration registered and removed within one tick never reaches the host.
33
+ * @deprecated Inert since the v2 delivery design: scheduled deliveries now
34
+ * capture the app's executed queries host-side, so no declaration is needed.
35
+ * Kept exported so apps generated while this API was advertised don't crash.
67
36
  */
68
- export function publishDeliveryQueries(target) {
69
- if (typeof window === 'undefined')
70
- return;
71
- if (publishTimer !== null)
72
- return;
73
- publishTimer = setTimeout(() => {
74
- publishTimer = null;
75
- const queries = getDeliveryQueries();
76
- if (queries.length === 0)
77
- return;
78
- // Bundles are served from the host page's own origin, and
79
- // location.origin is URL-derived so it survives the sandboxed
80
- // (opaque-origin) iframe.
81
- const { origin } = window.location;
82
- const targetOrigin = origin && origin !== 'null' ? origin : '*';
83
- const message = {
84
- type: DELIVERY_AVAILABLE_MESSAGE_TYPE,
85
- queries,
86
- };
87
- target.postMessage(message, targetOrigin);
88
- }, PUBLISH_COALESCE_MS);
89
- }
90
- let idCounter = 0;
91
- export function nextDeliveryId() {
92
- idCounter += 1;
93
- return `delivery-${idCounter}`;
94
- }
95
- /**
96
- * Declare that this query's results belong in the app's scheduled deliveries.
97
- * Call it alongside the `useLightdash(q)` that renders the same query.
98
- */
99
- export function useDelivery(query, options) {
100
- const idRef = useRef(null);
101
- if (idRef.current === null)
102
- idRef.current = nextDeliveryId();
103
- const id = idRef.current;
104
- const name = options?.name;
105
- const queryKey = useMemo(() => query instanceof QueryBuilder
106
- ? JSON.stringify(query.build())
107
- : savedChartQueryKey(query), [query]);
108
- useEffect(() => {
109
- const declaration = toDeliveryQuery(query, name);
110
- if (declaration) {
111
- registerDeliveryQuery(id, declaration);
112
- }
113
- else {
114
- unregisterDeliveryQuery(id);
115
- }
116
- if (typeof window !== 'undefined' && window.parent !== window) {
117
- publishDeliveryQueries(window.parent);
118
- }
119
- return () => {
120
- unregisterDeliveryQuery(id);
121
- };
122
- // queryKey tracks query identity. query is intentionally omitted.
123
- }, [id, queryKey, name]); // eslint-disable-line
37
+ export function useDelivery(_query, _options) {
38
+ // no-op
124
39
  }
package/dist/features.js CHANGED
@@ -65,12 +65,6 @@ export const SDK_FEATURES = [
65
65
  description: "Let viewers adjust the visualization from the Lightdash config panel — toggles, dropdowns, numbers, text and colours — and take series colours from the chart's palette, without regenerating the app.",
66
66
  wiring: 'Declare configOptions (and colorPalette, if the viz colours series) in the viz schema, then read options[name] and colorPalette from useVizContext().',
67
67
  },
68
- {
69
- key: 'delivery',
70
- label: 'Data in scheduled deliveries',
71
- description: "Include the app's query results as .csv/.xlsx in scheduled deliveries, instead of only a screenshot. Offer it when an app is used for reporting.",
72
- wiring: 'Call useDelivery(q) alongside each useLightdash(q) whose data should be delivered; without it the delivery format stays image-only.',
73
- },
74
68
  ];
75
69
  export const SDK_FEATURE_KEYS = SDK_FEATURES.map((f) => f.key);
76
70
  export const SDK_MANIFEST_MESSAGE_TYPE = 'lightdash:sdk:manifest';
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.34.0";
1
+ export declare const SDK_VERSION = "1.36.0";
@@ -1,2 +1,2 @@
1
1
  // Generated by scripts/generateSdkVersion.mjs (prebuild) — do not edit.
2
- export const SDK_VERSION = '1.34.0';
2
+ export const SDK_VERSION = '1.36.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/query-sdk",
3
- "version": "1.34.0",
3
+ "version": "1.36.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "SDK for building custom data apps against the Lightdash semantic layer",
@@ -34,7 +34,7 @@
34
34
  "jsdom": "26.1.0",
35
35
  "typescript": "7.0.2",
36
36
  "vitest": "4.1.6",
37
- "@lightdash/common": "1.34.0"
37
+ "@lightdash/common": "1.36.0"
38
38
  },
39
39
  "scripts": {
40
40
  "prebuild": "node ./scripts/generateSdkVersion.mjs",