@duckcodeailabs/dql-plugin-api 1.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/LICENSE +123 -0
- package/README.md +56 -0
- package/dist/chart.d.ts +47 -0
- package/dist/chart.d.ts.map +1 -0
- package/dist/chart.js +9 -0
- package/dist/chart.js.map +1 -0
- package/dist/connector.d.ts +67 -0
- package/dist/connector.d.ts.map +1 -0
- package/dist/connector.js +8 -0
- package/dist/connector.js.map +1 -0
- package/dist/governance.d.ts +55 -0
- package/dist/governance.d.ts.map +1 -0
- package/dist/governance.js +9 -0
- package/dist/governance.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
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, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and configuration
|
|
27
|
+
files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
31
|
+
generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
|
34
|
+
available under the License, as indicated by a copyright notice that is included
|
|
35
|
+
in or attached to the work.
|
|
36
|
+
|
|
37
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
38
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
39
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
40
|
+
original work of authorship.
|
|
41
|
+
|
|
42
|
+
"Contribution" shall mean any work of authorship, including the original version
|
|
43
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
|
44
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
|
45
|
+
by the copyright owner or by an individual or Legal Entity authorized to submit
|
|
46
|
+
on behalf of the copyright owner.
|
|
47
|
+
|
|
48
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
49
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
50
|
+
incorporated within the Work.
|
|
51
|
+
|
|
52
|
+
2. Grant of Copyright License.
|
|
53
|
+
|
|
54
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
55
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
56
|
+
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
|
57
|
+
publicly display, publicly perform, sublicense, and distribute the Work and such
|
|
58
|
+
Derivative Works in Source or Object form.
|
|
59
|
+
|
|
60
|
+
3. Grant of Patent License.
|
|
61
|
+
|
|
62
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
63
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
64
|
+
irrevocable patent license to make, have made, use, offer to sell, sell, import,
|
|
65
|
+
and otherwise transfer the Work.
|
|
66
|
+
|
|
67
|
+
4. Redistribution.
|
|
68
|
+
|
|
69
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
|
70
|
+
in any medium, with or without modifications, and in Source or Object form,
|
|
71
|
+
provided that You meet the following conditions:
|
|
72
|
+
|
|
73
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of
|
|
74
|
+
this License; and
|
|
75
|
+
|
|
76
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
77
|
+
You changed the files; and
|
|
78
|
+
|
|
79
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
80
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
81
|
+
Source form of the Work, excluding those notices that do not pertain to any part
|
|
82
|
+
of the Derivative Works; and
|
|
83
|
+
|
|
84
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
85
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
86
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
87
|
+
that do not pertain to any part of the Derivative Works.
|
|
88
|
+
|
|
89
|
+
5. Submission of Contributions.
|
|
90
|
+
|
|
91
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
|
92
|
+
for inclusion in the Work by You to the Licensor shall be under the terms and
|
|
93
|
+
conditions of this License, without any additional terms or conditions.
|
|
94
|
+
|
|
95
|
+
6. Trademarks.
|
|
96
|
+
|
|
97
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
98
|
+
service marks, or product names of the Licensor, except as required for
|
|
99
|
+
reasonable and customary use in describing the origin of the Work.
|
|
100
|
+
|
|
101
|
+
7. Disclaimer of Warranty.
|
|
102
|
+
|
|
103
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the
|
|
104
|
+
Work on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
105
|
+
express or implied, including, without limitation, any warranties or conditions
|
|
106
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
|
|
107
|
+
PURPOSE.
|
|
108
|
+
|
|
109
|
+
8. Limitation of Liability.
|
|
110
|
+
|
|
111
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
112
|
+
contract, or otherwise, unless required by applicable law, shall any Contributor
|
|
113
|
+
be liable to You for damages, including any direct, indirect, special,
|
|
114
|
+
incidental, or consequential damages of any character arising as a result of this
|
|
115
|
+
License or out of the use or inability to use the Work.
|
|
116
|
+
|
|
117
|
+
9. Accepting Warranty or Additional Liability.
|
|
118
|
+
|
|
119
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
|
120
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
|
121
|
+
other liability obligations and/or rights consistent with this License.
|
|
122
|
+
|
|
123
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @duckcodeailabs/dql-plugin-api
|
|
2
|
+
|
|
3
|
+
Stable plugin contracts for DQL. **Frozen at v1.0** — breaking changes
|
|
4
|
+
require a major version bump and a 6-month deprecation window.
|
|
5
|
+
|
|
6
|
+
## Exports
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import type { Connector } from '@duckcodeailabs/dql-plugin-api/connector';
|
|
10
|
+
import type { ChartRenderer } from '@duckcodeailabs/dql-plugin-api/chart';
|
|
11
|
+
import type { RulePack } from '@duckcodeailabs/dql-plugin-api/governance';
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Or all at once:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import type { Connector, ChartRenderer, RulePack } from '@duckcodeailabs/dql-plugin-api';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Connector
|
|
21
|
+
|
|
22
|
+
See [`src/connector.ts`](./src/connector.ts). Implement `Connector`,
|
|
23
|
+
publish as a module, register in `cdql.yaml`:
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
plugins:
|
|
27
|
+
connectors:
|
|
28
|
+
- my-company/dql-connector-exasol
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Chart renderer
|
|
32
|
+
|
|
33
|
+
See [`src/chart.ts`](./src/chart.ts). Registered the same way under
|
|
34
|
+
`plugins.charts`.
|
|
35
|
+
|
|
36
|
+
## Governance rule pack
|
|
37
|
+
|
|
38
|
+
See [`src/governance.ts`](./src/governance.ts). Registered under
|
|
39
|
+
`governance.rule_packs`.
|
|
40
|
+
|
|
41
|
+
## Stability guarantee
|
|
42
|
+
|
|
43
|
+
The interfaces in this package are versioned via `PLUGIN_API_VERSION`.
|
|
44
|
+
At v1.0:
|
|
45
|
+
|
|
46
|
+
- Adding optional fields to request/result shapes: **non-breaking**
|
|
47
|
+
- Adding new methods marked optional: **non-breaking**
|
|
48
|
+
- Removing or renaming fields: **breaking, major bump required**
|
|
49
|
+
- Changing method signatures (even "compatible" widening): **breaking**
|
|
50
|
+
|
|
51
|
+
Consumers can assert compatibility at runtime:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { PLUGIN_API_VERSION } from '@duckcodeailabs/dql-plugin-api';
|
|
55
|
+
if (!PLUGIN_API_VERSION.startsWith('1.')) throw new Error('incompatible DQL');
|
|
56
|
+
```
|
package/dist/chart.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chart renderer contract.
|
|
3
|
+
*
|
|
4
|
+
* FROZEN at v1.0. A renderer turns a QueryResult + a config object into
|
|
5
|
+
* either a Vega-Lite spec (for the static compiler) or a React element
|
|
6
|
+
* (for the browser runtime).
|
|
7
|
+
*/
|
|
8
|
+
import type { QueryResult } from './connector.js';
|
|
9
|
+
/** JSON schema describing the config shape this renderer accepts. */
|
|
10
|
+
export type ChartConfigSchema = {
|
|
11
|
+
type: 'object';
|
|
12
|
+
properties: Record<string, unknown>;
|
|
13
|
+
required?: string[];
|
|
14
|
+
};
|
|
15
|
+
export type ChartConfig = Record<string, unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* A renderer may produce either output form; the runtime picks based on
|
|
18
|
+
* target (static HTML dashboards need VegaLite; interactive notebook cells
|
|
19
|
+
* can use React).
|
|
20
|
+
*/
|
|
21
|
+
export type ChartOutput = {
|
|
22
|
+
kind: 'vega-lite';
|
|
23
|
+
spec: Record<string, unknown>;
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'react';
|
|
26
|
+
element: unknown;
|
|
27
|
+
};
|
|
28
|
+
export interface ChartRenderer {
|
|
29
|
+
/** Unique id — what the user writes as `visualization: <id>(…)`. */
|
|
30
|
+
id: string;
|
|
31
|
+
displayName: string;
|
|
32
|
+
configSchema: ChartConfigSchema;
|
|
33
|
+
/**
|
|
34
|
+
* Validate + normalize the user-supplied config. Return a user-friendly
|
|
35
|
+
* message on failure (will surface in Block Studio's lint ribbon).
|
|
36
|
+
*/
|
|
37
|
+
validate(config: ChartConfig): {
|
|
38
|
+
ok: true;
|
|
39
|
+
config: ChartConfig;
|
|
40
|
+
} | {
|
|
41
|
+
ok: false;
|
|
42
|
+
error: string;
|
|
43
|
+
};
|
|
44
|
+
/** Produce the chart output for a given result + validated config. */
|
|
45
|
+
render(result: QueryResult, config: ChartConfig): ChartOutput;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=chart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../src/chart.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,qEAAqE;AACrE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElD;;;;GAIG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAExC,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,iBAAiB,CAAC;IAEhC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAE,GAAG;QAAE,EAAE,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAEhG,sEAAsE;IACtE,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,WAAW,CAAC;CAC/D"}
|
package/dist/chart.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chart renderer contract.
|
|
3
|
+
*
|
|
4
|
+
* FROZEN at v1.0. A renderer turns a QueryResult + a config object into
|
|
5
|
+
* either a Vega-Lite spec (for the static compiler) or a React element
|
|
6
|
+
* (for the browser runtime).
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart.js","sourceRoot":"","sources":["../src/chart.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Warehouse connector contract.
|
|
3
|
+
*
|
|
4
|
+
* FROZEN at v1.0 — any breaking change requires a major version bump and a
|
|
5
|
+
* 6-month deprecation window. See docs.duckcode.ai/architecture/plugin-api.
|
|
6
|
+
*/
|
|
7
|
+
export interface ColumnSchema {
|
|
8
|
+
name: string;
|
|
9
|
+
type: string;
|
|
10
|
+
nullable?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface TableSchema {
|
|
13
|
+
schema: string;
|
|
14
|
+
name: string;
|
|
15
|
+
columns: ColumnSchema[];
|
|
16
|
+
}
|
|
17
|
+
export interface QueryRow {
|
|
18
|
+
[column: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
export interface QueryResult {
|
|
21
|
+
columns: ColumnSchema[];
|
|
22
|
+
rows: QueryRow[];
|
|
23
|
+
rowCount: number;
|
|
24
|
+
executionTimeMs?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface QueryCursor extends AsyncIterable<QueryRow> {
|
|
27
|
+
readonly columns: ColumnSchema[];
|
|
28
|
+
close(): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
/** Per-driver configuration — opaque to the core. */
|
|
31
|
+
export type ConnectorConfig = Record<string, unknown>;
|
|
32
|
+
export interface ConnectorMetadata {
|
|
33
|
+
id: string;
|
|
34
|
+
displayName: string;
|
|
35
|
+
supports: {
|
|
36
|
+
streaming: boolean;
|
|
37
|
+
introspection: boolean;
|
|
38
|
+
transactions: boolean;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Implement this interface and register the module in cdql.yaml under
|
|
43
|
+
* `plugins.connectors`. DQL will instantiate, connect, and close the
|
|
44
|
+
* connector; plugin authors do not need to manage lifecycle.
|
|
45
|
+
*/
|
|
46
|
+
export interface Connector {
|
|
47
|
+
readonly metadata: ConnectorMetadata;
|
|
48
|
+
/** Open a connection. Called once per session. */
|
|
49
|
+
connect(config: ConnectorConfig): Promise<void>;
|
|
50
|
+
/** Close the connection. Must be idempotent. */
|
|
51
|
+
close(): Promise<void>;
|
|
52
|
+
/** Execute a query to completion and return the full result. */
|
|
53
|
+
query(sql: string, params?: unknown[]): Promise<QueryResult>;
|
|
54
|
+
/**
|
|
55
|
+
* Optional: execute a query as a streaming cursor. Required when
|
|
56
|
+
* `metadata.supports.streaming` is true.
|
|
57
|
+
*/
|
|
58
|
+
stream?(sql: string, params?: unknown[]): Promise<QueryCursor>;
|
|
59
|
+
/**
|
|
60
|
+
* Optional: list tables with columns. Required when
|
|
61
|
+
* `metadata.supports.introspection` is true.
|
|
62
|
+
*/
|
|
63
|
+
introspect?(): Promise<TableSchema[]>;
|
|
64
|
+
/** Optional: sanity-check the connection is live. */
|
|
65
|
+
ping?(): Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=connector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,WAAY,SAAQ,aAAa,CAAC,QAAQ,CAAC;IAC1D,QAAQ,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC;IACjC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,qDAAqD;AACrD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE;QACR,SAAS,EAAE,OAAO,CAAC;QACnB,aAAa,EAAE,OAAO,CAAC;QACvB,YAAY,EAAE,OAAO,CAAC;KACvB,CAAC;CACH;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IAErC,kDAAkD;IAClD,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhD,gDAAgD;IAChD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB,gEAAgE;IAChE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAE7D;;;OAGG;IACH,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAE/D;;;OAGG;IACH,UAAU,CAAC,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAEtC,qDAAqD;IACrD,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Governance rule pack contract.
|
|
3
|
+
*
|
|
4
|
+
* FROZEN at v1.0. A rule pack is a named bundle of lint rules that run
|
|
5
|
+
* against block ASTs — in the editor (real-time) and at `dql certify`
|
|
6
|
+
* (gating).
|
|
7
|
+
*/
|
|
8
|
+
export type Severity = 'error' | 'warning' | 'info';
|
|
9
|
+
/** A minimal view of a parsed block passed to rules. Keep this shape stable. */
|
|
10
|
+
export interface BlockView {
|
|
11
|
+
name: string;
|
|
12
|
+
domain?: string;
|
|
13
|
+
owner?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
tags: string[];
|
|
16
|
+
query: string;
|
|
17
|
+
visualization?: string;
|
|
18
|
+
path: string;
|
|
19
|
+
metricRefs: string[];
|
|
20
|
+
dimensionRefs: string[];
|
|
21
|
+
blockRefs: string[];
|
|
22
|
+
tableRefs: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface Diagnostic {
|
|
25
|
+
ruleId: string;
|
|
26
|
+
severity: Severity;
|
|
27
|
+
message: string;
|
|
28
|
+
/** Optional AST span (0-based byte offsets) for editor underlining. */
|
|
29
|
+
span?: {
|
|
30
|
+
start: number;
|
|
31
|
+
end: number;
|
|
32
|
+
};
|
|
33
|
+
/** Optional fix suggestion. */
|
|
34
|
+
fix?: {
|
|
35
|
+
title: string;
|
|
36
|
+
newText: string;
|
|
37
|
+
span: {
|
|
38
|
+
start: number;
|
|
39
|
+
end: number;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface Rule {
|
|
44
|
+
id: string;
|
|
45
|
+
description: string;
|
|
46
|
+
defaultSeverity: Severity;
|
|
47
|
+
check(block: BlockView): Diagnostic[];
|
|
48
|
+
}
|
|
49
|
+
export interface RulePack {
|
|
50
|
+
id: string;
|
|
51
|
+
displayName: string;
|
|
52
|
+
version: string;
|
|
53
|
+
rules: Rule[];
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=governance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.d.ts","sourceRoot":"","sources":["../src/governance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEpD,gFAAgF;AAChF,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,+BAA+B;IAC/B,GAAG,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CAChF;AAED,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,QAAQ,CAAC;IAC1B,KAAK,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,EAAE,CAAC;CACvC;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,IAAI,EAAE,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.js","sourceRoot":"","sources":["../src/governance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAEhC,iEAAiE;AACjE,eAAO,MAAM,kBAAkB,QAAQ,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Public plugin API for DQL. FROZEN at v1.0.
|
|
2
|
+
//
|
|
3
|
+
// These types are the contract between DQL core and third-party extensions.
|
|
4
|
+
// Breaking changes require a major bump and a 6-month deprecation window.
|
|
5
|
+
// Don't import from anywhere else in @duckcodeailabs/* — those internals
|
|
6
|
+
// can change between minor versions.
|
|
7
|
+
export * from './connector.js';
|
|
8
|
+
export * from './chart.js';
|
|
9
|
+
export * from './governance.js';
|
|
10
|
+
/** Marker re-exported so plugin authors can assert stability. */
|
|
11
|
+
export const PLUGIN_API_VERSION = '1.0';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,EAAE;AACF,4EAA4E;AAC5E,0EAA0E;AAC1E,yEAAyE;AACzE,qCAAqC;AAErC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAEhC,iEAAiE;AACjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@duckcodeailabs/dql-plugin-api",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Stable plugin contracts for DQL — connectors, chart renderers, governance rule packs. Frozen at v1.0.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./connector": {
|
|
15
|
+
"types": "./dist/connector.d.ts",
|
|
16
|
+
"import": "./dist/connector.js"
|
|
17
|
+
},
|
|
18
|
+
"./chart": {
|
|
19
|
+
"types": "./dist/chart.d.ts",
|
|
20
|
+
"import": "./dist/chart.js"
|
|
21
|
+
},
|
|
22
|
+
"./governance": {
|
|
23
|
+
"types": "./dist/governance.d.ts",
|
|
24
|
+
"import": "./dist/governance.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^20.11.0",
|
|
33
|
+
"typescript": "^5.4.0",
|
|
34
|
+
"vitest": "^1.6.0"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "rm -rf dist tsconfig.tsbuildinfo && tsc",
|
|
41
|
+
"test": "vitest run"
|
|
42
|
+
}
|
|
43
|
+
}
|