@lightdash-tools/common 0.1.2 → 0.2.4
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/README.md +15 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/safety.d.ts +33 -0
- package/dist/safety.js +60 -0
- package/dist/safety.test.d.ts +1 -0
- package/dist/safety.test.js +27 -0
- package/dist/types/lightdash-api.d.ts +24 -333
- package/dist/types/lightdash-api.js +7 -5
- package/dist/types/{ai-agents.d.ts → v1/ai-agents.d.ts} +1 -1
- package/dist/types/{charts.d.ts → v1/charts.d.ts} +1 -1
- package/dist/types/{dashboards.d.ts → v1/dashboards.d.ts} +1 -1
- package/dist/types/{explores.d.ts → v1/explores.d.ts} +3 -1
- package/dist/types/{groups.d.ts → v1/groups.d.ts} +1 -1
- package/dist/types/v1/index.d.ts +11 -11
- package/dist/types/v1/lightdash-api.d.ts +211 -0
- package/dist/types/v1/lightdash-api.js +23 -0
- package/dist/types/v1/metrics.d.ts +6 -0
- package/dist/types/v1/metrics.js +2 -0
- package/dist/types/{organizations.d.ts → v1/organizations.d.ts} +1 -1
- package/dist/types/{project-access.d.ts → v1/project-access.d.ts} +1 -1
- package/dist/types/{projects.d.ts → v1/projects.d.ts} +1 -1
- package/dist/types/{queries.d.ts → v1/queries.d.ts} +1 -1
- package/dist/types/v1/schedulers.d.ts +7 -0
- package/dist/types/v1/schedulers.js +2 -0
- package/dist/types/{space-access.d.ts → v1/space-access.d.ts} +1 -1
- package/dist/types/{spaces.d.ts → v1/spaces.d.ts} +1 -1
- package/dist/types/v1/tags.d.ts +9 -0
- package/dist/types/v1/tags.js +2 -0
- package/dist/types/{users.d.ts → v1/users.d.ts} +1 -1
- package/dist/types/v1/validation.d.ts +7 -0
- package/dist/types/v1/validation.js +2 -0
- package/dist/types/v2/content.d.ts +6 -0
- package/dist/types/v2/content.js +2 -0
- package/dist/types/v2/index.d.ts +15 -11
- package/package.json +2 -1
- package/src/index.ts +3 -0
- package/src/safety.test.ts +36 -0
- package/src/safety.ts +71 -0
- package/src/types/lightdash-api.ts +73 -432
- package/src/types/{ai-agents.ts → v1/ai-agents.ts} +1 -1
- package/src/types/{charts.ts → v1/charts.ts} +1 -1
- package/src/types/{dashboards.ts → v1/dashboards.ts} +1 -1
- package/src/types/{explores.ts → v1/explores.ts} +3 -1
- package/src/types/{groups.ts → v1/groups.ts} +1 -1
- package/src/types/v1/index.ts +11 -11
- package/src/types/v1/lightdash-api.ts +287 -0
- package/src/types/v1/metrics.ts +7 -0
- package/src/types/{organizations.ts → v1/organizations.ts} +1 -1
- package/src/types/{project-access.ts → v1/project-access.ts} +1 -1
- package/src/types/{projects.ts → v1/projects.ts} +1 -1
- package/src/types/{queries.ts → v1/queries.ts} +1 -1
- package/src/types/v1/schedulers.ts +9 -0
- package/src/types/{space-access.ts → v1/space-access.ts} +1 -1
- package/src/types/{spaces.ts → v1/spaces.ts} +1 -1
- package/src/types/v1/tags.ts +11 -0
- package/src/types/{users.ts → v1/users.ts} +1 -1
- package/src/types/v1/validation.ts +8 -0
- package/src/types/v2/content.ts +7 -0
- package/src/types/v2/index.ts +16 -11
- package/tsconfig.json +3 -2
- /package/dist/types/{ai-agents.js → v1/ai-agents.js} +0 -0
- /package/dist/types/{charts.js → v1/charts.js} +0 -0
- /package/dist/types/{dashboards.js → v1/dashboards.js} +0 -0
- /package/dist/types/{explores.js → v1/explores.js} +0 -0
- /package/dist/types/{groups.js → v1/groups.js} +0 -0
- /package/dist/types/{organizations.js → v1/organizations.js} +0 -0
- /package/dist/types/{project-access.js → v1/project-access.js} +0 -0
- /package/dist/types/{projects.js → v1/projects.js} +0 -0
- /package/dist/types/{queries.js → v1/queries.js} +0 -0
- /package/dist/types/{space-access.js → v1/space-access.js} +0 -0
- /package/dist/types/{spaces.js → v1/spaces.js} +0 -0
- /package/dist/types/{users.js → v1/users.js} +0 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightdash API models extracted from OpenAPI specification.
|
|
3
|
+
* These models are organized by domain for better discoverability and reuse across packages.
|
|
4
|
+
*
|
|
5
|
+
* Models are type aliases to generated OpenAPI types, ensuring they remain aligned with the spec.
|
|
6
|
+
* Models are split into domain-specific files for better maintainability.
|
|
7
|
+
*/
|
|
8
|
+
import type { Projects } from './projects';
|
|
9
|
+
import type { Organizations } from './organizations';
|
|
10
|
+
import type { Queries } from './queries';
|
|
11
|
+
import type { Charts } from './charts';
|
|
12
|
+
import type { Dashboards } from './dashboards';
|
|
13
|
+
import type { Spaces } from './spaces';
|
|
14
|
+
import type { SpaceAccess } from './space-access';
|
|
15
|
+
import type { Users } from './users';
|
|
16
|
+
import type { Groups } from './groups';
|
|
17
|
+
import type { AiAgents } from './ai-agents';
|
|
18
|
+
import type { ProjectAccess } from './project-access';
|
|
19
|
+
import type { Explores } from './explores';
|
|
20
|
+
import type { Validation } from './validation';
|
|
21
|
+
import type { Metrics } from './metrics';
|
|
22
|
+
import type { Schedulers } from './schedulers';
|
|
23
|
+
import type { Tags } from './tags';
|
|
24
|
+
import type { Content } from '../v2/content';
|
|
25
|
+
export type { Projects, Organizations, Queries, Charts, Dashboards, Spaces, SpaceAccess, Users, Groups, AiAgents, ProjectAccess, Explores, Validation, Metrics, Schedulers, Tags, Content, };
|
|
26
|
+
import type { components } from '../generated/openapi-types';
|
|
27
|
+
import { V1 as V1Namespace } from './index';
|
|
28
|
+
import { V2 as V2Namespace } from '../v2/index';
|
|
29
|
+
/**
|
|
30
|
+
* Main namespace for all Lightdash API models.
|
|
31
|
+
* Provides organized access to all domain models.
|
|
32
|
+
*
|
|
33
|
+
* Usage:
|
|
34
|
+
* ```typescript
|
|
35
|
+
* import type { LightdashApi } from '@lightdash-tools/common';
|
|
36
|
+
* const project: LightdashApi.Projects.Project = ...;
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare namespace LightdashApi {
|
|
40
|
+
namespace Projects {
|
|
41
|
+
type Project = components['schemas']['Project'];
|
|
42
|
+
type OrganizationProject = components['schemas']['OrganizationProject'];
|
|
43
|
+
}
|
|
44
|
+
namespace Organizations {
|
|
45
|
+
type Organization = components['schemas']['Organization'];
|
|
46
|
+
}
|
|
47
|
+
namespace Queries {
|
|
48
|
+
namespace Requests {
|
|
49
|
+
type MetricQuery = components['schemas']['MetricQueryRequest'];
|
|
50
|
+
type CompileQuery = components['schemas']['MetricQuery'] & {
|
|
51
|
+
pivotConfiguration?: components['schemas']['PivotConfiguration'];
|
|
52
|
+
parameters?: components['schemas']['ParametersValuesMap'];
|
|
53
|
+
};
|
|
54
|
+
type ExecuteAsyncMetricQuery = components['schemas']['ExecuteAsyncMetricQueryRequestParams'];
|
|
55
|
+
type ExecuteAsyncSqlQuery = components['schemas']['ExecuteAsyncSqlQueryRequestParams'];
|
|
56
|
+
type ExecuteAsyncSavedChart = components['schemas']['ExecuteAsyncSavedChartRequestParams'];
|
|
57
|
+
type ExecuteAsyncDashboardChart = components['schemas']['ExecuteAsyncDashboardChartRequestParams'];
|
|
58
|
+
type ExecuteAsyncUnderlyingData = components['schemas']['ExecuteAsyncUnderlyingDataRequestParams'];
|
|
59
|
+
}
|
|
60
|
+
namespace Responses {
|
|
61
|
+
type RunQueryResults = components['schemas']['ApiRunQueryResponse']['results'];
|
|
62
|
+
type CompiledQueryResults = components['schemas']['ApiCompiledQueryResults'];
|
|
63
|
+
type ExecuteAsyncMetricQueryResults = components['schemas']['ApiExecuteAsyncMetricQueryResults'];
|
|
64
|
+
type ExecuteAsyncDashboardChartResults = components['schemas']['ApiExecuteAsyncDashboardChartQueryResults'];
|
|
65
|
+
type ExecuteAsyncSqlQueryResults = components['schemas']['ApiExecuteAsyncSqlQueryResults'];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
namespace Charts {
|
|
69
|
+
type SpaceQuery = components['schemas']['SpaceQuery'];
|
|
70
|
+
type ChartAsCodeListResults = components['schemas']['ApiChartAsCodeListResponse']['results'];
|
|
71
|
+
type ChartAsCodeUpsertResults = components['schemas']['ApiChartAsCodeUpsertResponse']['results'];
|
|
72
|
+
type UpsertChartAsCodeBody = components['schemas']['Omit_ChartAsCode.chartConfig-or-description_'] & {
|
|
73
|
+
description?: string | null;
|
|
74
|
+
chartConfig: components['schemas']['AnyType'];
|
|
75
|
+
publicSpaceCreate?: boolean;
|
|
76
|
+
skipSpaceCreate?: boolean;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
namespace Dashboards {
|
|
80
|
+
type DashboardBasicDetailsWithTileTypes = components['schemas']['DashboardBasicDetailsWithTileTypes'];
|
|
81
|
+
}
|
|
82
|
+
namespace Spaces {
|
|
83
|
+
type SpaceSummary = components['schemas']['SpaceSummary'];
|
|
84
|
+
type Space = components['schemas']['Space'];
|
|
85
|
+
type CreateSpace = components['schemas']['CreateSpace'];
|
|
86
|
+
type UpdateSpace = components['schemas']['UpdateSpace'];
|
|
87
|
+
}
|
|
88
|
+
namespace SpaceAccess {
|
|
89
|
+
type AddSpaceUserAccess = components['schemas']['AddSpaceUserAccess'];
|
|
90
|
+
type AddSpaceGroupAccess = components['schemas']['AddSpaceGroupAccess'];
|
|
91
|
+
type SpaceMemberRole = components['schemas']['SpaceMemberRole'];
|
|
92
|
+
}
|
|
93
|
+
namespace ProjectAccess {
|
|
94
|
+
type ProjectMemberProfile = components['schemas']['ProjectMemberProfile'];
|
|
95
|
+
type ProjectMemberRole = components['schemas']['ProjectMemberRole'];
|
|
96
|
+
type CreateProjectMember = components['schemas']['CreateProjectMember'];
|
|
97
|
+
type UpdateProjectMember = components['schemas']['UpdateProjectMember'];
|
|
98
|
+
type ProjectGroupAccess = components['schemas']['ProjectGroupAccess'];
|
|
99
|
+
type CreateProjectGroupAccessBody = components['schemas']['Pick_CreateProjectGroupAccess.role_'];
|
|
100
|
+
type UpdateProjectGroupAccess = components['schemas']['UpdateDBProjectGroupAccess'];
|
|
101
|
+
}
|
|
102
|
+
namespace Users {
|
|
103
|
+
type OrganizationMemberProfile = components['schemas']['OrganizationMemberProfile'];
|
|
104
|
+
type OrganizationMemberProfilesResult = components['schemas']['KnexPaginatedData_OrganizationMemberProfile-Array_'];
|
|
105
|
+
type ApiOrganizationMemberProfile = components['schemas']['ApiOrganizationMemberProfile'];
|
|
106
|
+
type ApiOrganizationMemberProfiles = components['schemas']['ApiOrganizationMemberProfiles'];
|
|
107
|
+
type OrganizationMemberProfileUpdate = components['schemas']['OrganizationMemberProfileUpdate'];
|
|
108
|
+
}
|
|
109
|
+
namespace Groups {
|
|
110
|
+
type Group = components['schemas']['Group'];
|
|
111
|
+
type GroupWithMembers = components['schemas']['GroupWithMembers'];
|
|
112
|
+
type CreateGroup = components['schemas']['CreateGroup'];
|
|
113
|
+
type UpdateGroupWithMembers = components['schemas']['UpdateGroupWithMembers'];
|
|
114
|
+
type GroupListResult = components['schemas']['KnexPaginatedData_Group-Array-or-GroupWithMembers-Array_'];
|
|
115
|
+
type ApiGroupResponse = components['schemas']['ApiGroupResponse'];
|
|
116
|
+
type ApiGroupListResponse = components['schemas']['ApiGroupListResponse'];
|
|
117
|
+
type ApiCreateGroupResponse = components['schemas']['ApiCreateGroupResponse'];
|
|
118
|
+
type ApiGroupMembersResponse = components['schemas']['ApiGroupMembersResponse'];
|
|
119
|
+
type GroupMember = components['schemas']['GroupMember'];
|
|
120
|
+
}
|
|
121
|
+
namespace AiAgents {
|
|
122
|
+
type AiAgentSummary = components['schemas']['AiAgentSummary'];
|
|
123
|
+
type AiAgentAdminSortField = components['schemas']['AiAgentAdminSortField'];
|
|
124
|
+
type AdminThreadsResult = components['schemas']['ApiAiAgentAdminConversationsResponse']['results'];
|
|
125
|
+
type GetAiOrganizationSettingsResult = components['schemas']['ApiAiOrganizationSettingsResponse']['results'];
|
|
126
|
+
type UpdateAiOrganizationSettings = components['schemas']['UpdateAiOrganizationSettings'];
|
|
127
|
+
type UpdateAiOrganizationSettingsResult = components['schemas']['ApiUpdateAiOrganizationSettingsResponse']['results'];
|
|
128
|
+
}
|
|
129
|
+
namespace Explores {
|
|
130
|
+
type ApiExploresResults = components['schemas']['ApiExploresResults'];
|
|
131
|
+
type ApiExploreResults = components['schemas']['ApiExploreResults'];
|
|
132
|
+
type CompiledTable = components['schemas']['CompiledTable'];
|
|
133
|
+
}
|
|
134
|
+
namespace Validation {
|
|
135
|
+
type ApiValidateResponse = components['schemas']['ApiValidateResponse'];
|
|
136
|
+
type ApiJobScheduledResponse = components['schemas']['ApiJobScheduledResponse'];
|
|
137
|
+
type ValidationTarget = components['schemas']['ValidationTarget'];
|
|
138
|
+
}
|
|
139
|
+
namespace Metrics {
|
|
140
|
+
type ApiMetricsCatalog = components['schemas']['ApiMetricsCatalog'];
|
|
141
|
+
type ApiGetMetricResponse = components['schemas']['ApiGetMetricPeek'];
|
|
142
|
+
}
|
|
143
|
+
namespace Schedulers {
|
|
144
|
+
type ApiSchedulersResponse = components['schemas']['ApiSchedulersResponse'];
|
|
145
|
+
type ApiSchedulerAndTargetsResponse = components['schemas']['ApiSchedulerAndTargetsResponse'];
|
|
146
|
+
type ListSchedulersParams = {
|
|
147
|
+
pageSize?: number;
|
|
148
|
+
page?: number;
|
|
149
|
+
searchQuery?: string;
|
|
150
|
+
sortBy?: 'name' | 'createdAt';
|
|
151
|
+
sortDirection?: 'asc' | 'desc';
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
namespace Tags {
|
|
155
|
+
type ApiGetTagsResponse = components['schemas']['ApiGetTagsResponse'];
|
|
156
|
+
type ApiGetTagResponse = {
|
|
157
|
+
results: components['schemas']['Tag'];
|
|
158
|
+
status: 'ok';
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
namespace Content {
|
|
162
|
+
type ApiContentResponse = components['schemas']['ApiContentResponse'];
|
|
163
|
+
}
|
|
164
|
+
/** Types for Lightdash API v1 endpoints (ADR-0008). */
|
|
165
|
+
export import V1 = V1Namespace;
|
|
166
|
+
/** Types for Lightdash API v2 endpoints (ADR-0008). */
|
|
167
|
+
export import V2 = V2Namespace;
|
|
168
|
+
}
|
|
169
|
+
export type Project = Projects.Project;
|
|
170
|
+
export type OrganizationProject = Projects.OrganizationProject;
|
|
171
|
+
export type Organization = Organizations.Organization;
|
|
172
|
+
export type SpaceQuery = Charts.SpaceQuery;
|
|
173
|
+
export type ChartAsCodeListResults = Charts.ChartAsCodeListResults;
|
|
174
|
+
export type ChartAsCodeUpsertResults = Charts.ChartAsCodeUpsertResults;
|
|
175
|
+
export type UpsertChartAsCodeBody = Charts.UpsertChartAsCodeBody;
|
|
176
|
+
export type DashboardBasicDetailsWithTileTypes = Dashboards.DashboardBasicDetailsWithTileTypes;
|
|
177
|
+
export type SpaceSummary = Spaces.SpaceSummary;
|
|
178
|
+
export type Space = Spaces.Space;
|
|
179
|
+
export type CreateSpace = Spaces.CreateSpace;
|
|
180
|
+
export type UpdateSpace = Spaces.UpdateSpace;
|
|
181
|
+
export type AddSpaceUserAccess = SpaceAccess.AddSpaceUserAccess;
|
|
182
|
+
export type AddSpaceGroupAccess = SpaceAccess.AddSpaceGroupAccess;
|
|
183
|
+
export type SpaceMemberRole = SpaceAccess.SpaceMemberRole;
|
|
184
|
+
export type ProjectMemberProfile = ProjectAccess.ProjectMemberProfile;
|
|
185
|
+
export type ProjectMemberRole = ProjectAccess.ProjectMemberRole;
|
|
186
|
+
export type CreateProjectMember = ProjectAccess.CreateProjectMember;
|
|
187
|
+
export type UpdateProjectMember = ProjectAccess.UpdateProjectMember;
|
|
188
|
+
export type ProjectGroupAccess = ProjectAccess.ProjectGroupAccess;
|
|
189
|
+
export type CreateProjectGroupAccessBody = ProjectAccess.CreateProjectGroupAccessBody;
|
|
190
|
+
export type UpdateProjectGroupAccess = ProjectAccess.UpdateProjectGroupAccess;
|
|
191
|
+
export type MetricQueryRequest = Queries.Requests.MetricQuery;
|
|
192
|
+
export type CompileQueryRequest = Queries.Requests.CompileQuery;
|
|
193
|
+
export type ExecuteAsyncMetricQueryRequestParams = Queries.Requests.ExecuteAsyncMetricQuery;
|
|
194
|
+
export type ExecuteAsyncSqlQueryRequestParams = Queries.Requests.ExecuteAsyncSqlQuery;
|
|
195
|
+
export type ExecuteAsyncSavedChartRequestParams = Queries.Requests.ExecuteAsyncSavedChart;
|
|
196
|
+
export type ExecuteAsyncDashboardChartRequestParams = Queries.Requests.ExecuteAsyncDashboardChart;
|
|
197
|
+
export type ExecuteAsyncUnderlyingDataRequestParams = Queries.Requests.ExecuteAsyncUnderlyingData;
|
|
198
|
+
export type RunQueryResults = Queries.Responses.RunQueryResults;
|
|
199
|
+
export type CompiledQueryResults = Queries.Responses.CompiledQueryResults;
|
|
200
|
+
export type ExecuteAsyncMetricQueryResults = Queries.Responses.ExecuteAsyncMetricQueryResults;
|
|
201
|
+
export type ExecuteAsyncDashboardChartResults = Queries.Responses.ExecuteAsyncDashboardChartResults;
|
|
202
|
+
export type ExecuteAsyncSqlQueryResults = Queries.Responses.ExecuteAsyncSqlQueryResults;
|
|
203
|
+
export type AiAgentSummary = AiAgents.AiAgentSummary;
|
|
204
|
+
export type AiAgentAdminSortField = AiAgents.AiAgentAdminSortField;
|
|
205
|
+
export type AiAgentsAdminThreadsResult = AiAgents.AdminThreadsResult;
|
|
206
|
+
export type GetAiOrganizationSettingsResult = AiAgents.GetAiOrganizationSettingsResult;
|
|
207
|
+
export type UpdateAiOrganizationSettings = AiAgents.UpdateAiOrganizationSettings;
|
|
208
|
+
export type UpdateAiOrganizationSettingsResult = AiAgents.UpdateAiOrganizationSettingsResult;
|
|
209
|
+
export type GetAdminThreadsParams = AiAgents.GetAdminThreadsParams;
|
|
210
|
+
export type ApiExploresResults = Explores.ApiExploresResults;
|
|
211
|
+
export type ApiExploreResults = Explores.ApiExploreResults;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Lightdash API models extracted from OpenAPI specification.
|
|
4
|
+
* These models are organized by domain for better discoverability and reuse across packages.
|
|
5
|
+
*
|
|
6
|
+
* Models are type aliases to generated OpenAPI types, ensuring they remain aligned with the spec.
|
|
7
|
+
* Models are split into domain-specific files for better maintainability.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.LightdashApi = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* Main namespace for all Lightdash API models.
|
|
13
|
+
* Provides organized access to all domain models.
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import type { LightdashApi } from '@lightdash-tools/common';
|
|
18
|
+
* const project: LightdashApi.Projects.Project = ...;
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
var LightdashApi;
|
|
22
|
+
(function (LightdashApi) {
|
|
23
|
+
})(LightdashApi || (exports.LightdashApi = LightdashApi = {}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { components } from '../generated/openapi-types';
|
|
2
|
+
export declare namespace Metrics {
|
|
3
|
+
type ApiMetricsCatalog = components['schemas']['ApiMetricsCatalog'];
|
|
4
|
+
type ApiGetMetricResponse = components['schemas']['ApiGetMetricPeek'];
|
|
5
|
+
type CompiledMetric = components['schemas']['CompiledMetric'];
|
|
6
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Organizations domain models.
|
|
3
3
|
* Extracted from OpenAPI specification for better maintainability.
|
|
4
4
|
*/
|
|
5
|
-
import type { components } from '
|
|
5
|
+
import type { components } from '../generated/openapi-types';
|
|
6
6
|
export declare namespace Organizations {
|
|
7
7
|
/** Organization entity. */
|
|
8
8
|
type Organization = components['schemas']['Organization'];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Project access domain models (project-level user and group access).
|
|
3
3
|
* Extracted from OpenAPI specification for better maintainability.
|
|
4
4
|
*/
|
|
5
|
-
import type { components } from '
|
|
5
|
+
import type { components } from '../generated/openapi-types';
|
|
6
6
|
export declare namespace ProjectAccess {
|
|
7
7
|
/** Profile of a project member. */
|
|
8
8
|
type ProjectMemberProfile = components['schemas']['ProjectMemberProfile'];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Projects domain models.
|
|
3
3
|
* Extracted from OpenAPI specification for better maintainability.
|
|
4
4
|
*/
|
|
5
|
-
import type { components } from '
|
|
5
|
+
import type { components } from '../generated/openapi-types';
|
|
6
6
|
export declare namespace Projects {
|
|
7
7
|
/** Project entity. */
|
|
8
8
|
type Project = components['schemas']['Project'];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Queries domain models.
|
|
3
3
|
* Extracted from OpenAPI specification for better maintainability.
|
|
4
4
|
*/
|
|
5
|
-
import type { components } from '
|
|
5
|
+
import type { components } from '../generated/openapi-types';
|
|
6
6
|
export declare namespace Queries {
|
|
7
7
|
/**
|
|
8
8
|
* Query request types.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { components } from '../generated/openapi-types';
|
|
2
|
+
export declare namespace Schedulers {
|
|
3
|
+
type ApiSchedulersResponse = components['schemas']['ApiSchedulersResponse'];
|
|
4
|
+
type ApiSchedulerAndTargetsResponse = components['schemas']['ApiSchedulerAndTargetsResponse'];
|
|
5
|
+
type SchedulerAndTargets = components['schemas']['SchedulerAndTargets'];
|
|
6
|
+
type SchedulerLog = components['schemas']['SchedulerLog'];
|
|
7
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Space access domain models (space-level user and group sharing).
|
|
3
3
|
* Extracted from OpenAPI specification for better maintainability.
|
|
4
4
|
*/
|
|
5
|
-
import type { components } from '
|
|
5
|
+
import type { components } from '../generated/openapi-types';
|
|
6
6
|
export declare namespace SpaceAccess {
|
|
7
7
|
/** Payload to grant a user access to a space. */
|
|
8
8
|
type AddSpaceUserAccess = components['schemas']['AddSpaceUserAccess'];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Spaces domain models (core entity and CRUD payloads).
|
|
3
3
|
* Space access types (AddSpaceUserAccess, AddSpaceGroupAccess, SpaceMemberRole) live in space-access.ts.
|
|
4
4
|
*/
|
|
5
|
-
import type { components } from '
|
|
5
|
+
import type { components } from '../generated/openapi-types';
|
|
6
6
|
export declare namespace Spaces {
|
|
7
7
|
/** Space summary. */
|
|
8
8
|
type SpaceSummary = components['schemas']['SpaceSummary'];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { components } from '../generated/openapi-types';
|
|
2
|
+
export declare namespace Tags {
|
|
3
|
+
type ApiGetTagsResponse = components['schemas']['ApiGetTagsResponse'];
|
|
4
|
+
type ApiGetTagResponse = {
|
|
5
|
+
results: components['schemas']['Tag'];
|
|
6
|
+
status: 'ok';
|
|
7
|
+
};
|
|
8
|
+
type Tag = components['schemas']['Tag'];
|
|
9
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Users (organization members) domain models.
|
|
3
3
|
* Extracted from OpenAPI specification for better maintainability.
|
|
4
4
|
*/
|
|
5
|
-
import type { components } from '
|
|
5
|
+
import type { components } from '../generated/openapi-types';
|
|
6
6
|
export declare namespace Users {
|
|
7
7
|
/** Organization member profile. */
|
|
8
8
|
type OrganizationMemberProfile = components['schemas']['OrganizationMemberProfile'];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { components } from '../generated/openapi-types';
|
|
2
|
+
export declare namespace Validation {
|
|
3
|
+
type ValidationTarget = components['schemas']['ValidationTarget'];
|
|
4
|
+
type ApiValidateResponse = components['schemas']['ApiValidateResponse'];
|
|
5
|
+
type ApiJobScheduledResponse = components['schemas']['ApiJobScheduledResponse'];
|
|
6
|
+
type ApiValidationDismissResponse = components['schemas']['ApiValidationDismissResponse'];
|
|
7
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { components } from '../generated/openapi-types';
|
|
2
|
+
export declare namespace Content {
|
|
3
|
+
type ApiContentResponse = components['schemas']['ApiContentResponse'];
|
|
4
|
+
type ContentType = components['schemas']['ContentType'];
|
|
5
|
+
type ContentSortByColumns = components['schemas']['ContentSortByColumns'];
|
|
6
|
+
}
|
package/dist/types/v2/index.d.ts
CHANGED
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
* V2 API type barrel. Re-exports the same surface as LightdashApi.V2.
|
|
3
3
|
* Domain files remain at types/*.ts; see ADR-0008 (file layout follow-up).
|
|
4
4
|
*/
|
|
5
|
-
import type { Projects as P } from '../projects';
|
|
6
|
-
import type { Organizations as O } from '../organizations';
|
|
7
|
-
import type { Queries as Q } from '../queries';
|
|
8
|
-
import type { Charts as C } from '../charts';
|
|
9
|
-
import type { Dashboards as D } from '../dashboards';
|
|
10
|
-
import type { Spaces as S } from '../spaces';
|
|
11
|
-
import type { SpaceAccess as SA } from '../space-access';
|
|
12
|
-
import type { ProjectAccess as PA } from '../project-access';
|
|
13
|
-
import type { Users as U } from '../users';
|
|
14
|
-
import type { Groups as G } from '../groups';
|
|
15
|
-
import type { AiAgents as A } from '../ai-agents';
|
|
5
|
+
import type { Projects as P } from '../v1/projects';
|
|
6
|
+
import type { Organizations as O } from '../v1/organizations';
|
|
7
|
+
import type { Queries as Q } from '../v1/queries';
|
|
8
|
+
import type { Charts as C } from '../v1/charts';
|
|
9
|
+
import type { Dashboards as D } from '../v1/dashboards';
|
|
10
|
+
import type { Spaces as S } from '../v1/spaces';
|
|
11
|
+
import type { SpaceAccess as SA } from '../v1/space-access';
|
|
12
|
+
import type { ProjectAccess as PA } from '../v1/project-access';
|
|
13
|
+
import type { Users as U } from '../v1/users';
|
|
14
|
+
import type { Groups as G } from '../v1/groups';
|
|
15
|
+
import type { AiAgents as A } from '../v1/ai-agents';
|
|
16
|
+
import type { Content as Con } from './content';
|
|
16
17
|
export declare namespace V2 {
|
|
18
|
+
namespace Content {
|
|
19
|
+
type ApiContentResponse = Con.ApiContentResponse;
|
|
20
|
+
}
|
|
17
21
|
namespace Projects {
|
|
18
22
|
type Project = P.Project;
|
|
19
23
|
type OrganizationProject = P.OrganizationProject;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash-tools/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Shared utilities and types for Lightdash AI.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
10
10
|
"devDependencies": {
|
|
11
|
+
"@types/node": "^25.2.3",
|
|
11
12
|
"openapi-typescript": "^7.13.0"
|
|
12
13
|
},
|
|
13
14
|
"scripts": {
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,9 @@ export function greet(name: string): string {
|
|
|
2
2
|
return `Hello, ${name}!`;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
+
// Export safety logic
|
|
6
|
+
export * from './safety';
|
|
7
|
+
|
|
5
8
|
// Export Lightdash API models
|
|
6
9
|
export * from './types/lightdash-api';
|
|
7
10
|
export type { LightdashApi } from './types/lightdash-api';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
SafetyMode,
|
|
4
|
+
isAllowed,
|
|
5
|
+
READ_ONLY_DEFAULT,
|
|
6
|
+
WRITE_IDEMPOTENT,
|
|
7
|
+
WRITE_DESTRUCTIVE,
|
|
8
|
+
} from './safety';
|
|
9
|
+
|
|
10
|
+
describe('Safety Logic', () => {
|
|
11
|
+
describe('isAllowed', () => {
|
|
12
|
+
it('should allow read-only operations in read-only mode', () => {
|
|
13
|
+
expect(isAllowed(SafetyMode.READ_ONLY, READ_ONLY_DEFAULT)).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should forbid non-read-only operations in read-only mode', () => {
|
|
17
|
+
expect(isAllowed(SafetyMode.READ_ONLY, WRITE_IDEMPOTENT)).toBe(false);
|
|
18
|
+
expect(isAllowed(SafetyMode.READ_ONLY, WRITE_DESTRUCTIVE)).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should allow read-only and idempotent-write in write-idempotent mode', () => {
|
|
22
|
+
expect(isAllowed(SafetyMode.WRITE_IDEMPOTENT, READ_ONLY_DEFAULT)).toBe(true);
|
|
23
|
+
expect(isAllowed(SafetyMode.WRITE_IDEMPOTENT, WRITE_IDEMPOTENT)).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should forbid destructive operations in write-idempotent mode', () => {
|
|
27
|
+
expect(isAllowed(SafetyMode.WRITE_IDEMPOTENT, WRITE_DESTRUCTIVE)).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should allow all operations in write-destructive mode', () => {
|
|
31
|
+
expect(isAllowed(SafetyMode.WRITE_DESTRUCTIVE, READ_ONLY_DEFAULT)).toBe(true);
|
|
32
|
+
expect(isAllowed(SafetyMode.WRITE_DESTRUCTIVE, WRITE_IDEMPOTENT)).toBe(true);
|
|
33
|
+
expect(isAllowed(SafetyMode.WRITE_DESTRUCTIVE, WRITE_DESTRUCTIVE)).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
package/src/safety.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hierarchical safety modes for Lightdash AI tools and CLI.
|
|
3
|
+
*/
|
|
4
|
+
export enum SafetyMode {
|
|
5
|
+
READ_ONLY = 'read-only',
|
|
6
|
+
WRITE_IDEMPOTENT = 'write-idempotent',
|
|
7
|
+
WRITE_DESTRUCTIVE = 'write-destructive',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* MCP tool annotations (hints for client display and approval).
|
|
12
|
+
* See MCP spec Tool annotations.
|
|
13
|
+
*/
|
|
14
|
+
export type ToolAnnotations = {
|
|
15
|
+
title?: string;
|
|
16
|
+
readOnlyHint?: boolean;
|
|
17
|
+
destructiveHint?: boolean;
|
|
18
|
+
idempotentHint?: boolean;
|
|
19
|
+
openWorldHint?: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Preset: read-only, non-destructive, idempotent, closed-world. Use for list/get/compile tools. */
|
|
23
|
+
export const READ_ONLY_DEFAULT: ToolAnnotations = {
|
|
24
|
+
readOnlyHint: true,
|
|
25
|
+
openWorldHint: false,
|
|
26
|
+
destructiveHint: false,
|
|
27
|
+
idempotentHint: true,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** Preset: write, non-destructive, idempotent (e.g. upsert by slug). Use for create/update tools. */
|
|
31
|
+
export const WRITE_IDEMPOTENT: ToolAnnotations = {
|
|
32
|
+
readOnlyHint: false,
|
|
33
|
+
openWorldHint: false,
|
|
34
|
+
destructiveHint: false,
|
|
35
|
+
idempotentHint: true,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** Preset: write, destructive, non-idempotent. Use for delete/remove tools. */
|
|
39
|
+
export const WRITE_DESTRUCTIVE: ToolAnnotations = {
|
|
40
|
+
readOnlyHint: false,
|
|
41
|
+
openWorldHint: false,
|
|
42
|
+
destructiveHint: true,
|
|
43
|
+
idempotentHint: false,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Validates if an operation is allowed in the current safety mode.
|
|
48
|
+
*/
|
|
49
|
+
export function isAllowed(mode: SafetyMode | string, annotations: ToolAnnotations): boolean {
|
|
50
|
+
switch (mode) {
|
|
51
|
+
case SafetyMode.READ_ONLY:
|
|
52
|
+
return !!annotations.readOnlyHint;
|
|
53
|
+
case SafetyMode.WRITE_IDEMPOTENT:
|
|
54
|
+
return !!annotations.readOnlyHint || !annotations.destructiveHint;
|
|
55
|
+
case SafetyMode.WRITE_DESTRUCTIVE:
|
|
56
|
+
return true;
|
|
57
|
+
default:
|
|
58
|
+
return true; // Default to most permissive if mode is unknown
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Resolves safety mode from environment variable.
|
|
64
|
+
*/
|
|
65
|
+
export function getSafetyModeFromEnv(): SafetyMode {
|
|
66
|
+
const mode = process.env.LIGHTDASH_TOOL_SAFETY_MODE;
|
|
67
|
+
if (Object.values(SafetyMode).includes(mode as SafetyMode)) {
|
|
68
|
+
return mode as SafetyMode;
|
|
69
|
+
}
|
|
70
|
+
return SafetyMode.WRITE_DESTRUCTIVE;
|
|
71
|
+
}
|