@qrvey/cd-package-registry 1.0.18-1190 → 1.0.20-1201
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 +0 -202
- package/dist/cjs/index.js +6 -2
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/index.mjs +5331 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/types/index.d.ts +1145 -0
- package/package.json +6 -3
- package/CHANGELOG.md +0 -18
package/README.md
CHANGED
|
@@ -1,203 +1 @@
|
|
|
1
|
-
# @qrvey/cd-package-registry
|
|
2
1
|
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-
|
|
6
|
-
**@qrvey/cd-package-registry** is a package that validates assets and their dependencies.
|
|
7
|
-
|
|
8
|
-
## Installation
|
|
9
|
-
|
|
10
|
-
You can install the **@qrvey/cd-package-registry** package via npm. Run the following command in your terminal:
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
npm install @qrvey/cd-package-registry
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## API Documentation
|
|
17
|
-
|
|
18
|
-
### Available assets in the library to validate
|
|
19
|
-
|
|
20
|
-
- `Application`
|
|
21
|
-
- `Automation`
|
|
22
|
-
- `Connection`
|
|
23
|
-
- `Formula`
|
|
24
|
-
- `Page Flow`
|
|
25
|
-
- `Dashboard Asset`
|
|
26
|
-
- `Global Preference`
|
|
27
|
-
- `Page Tab`
|
|
28
|
-
- `Bucket`
|
|
29
|
-
- `Dashboard Content Element`
|
|
30
|
-
- `Dashboard Content`
|
|
31
|
-
- `Metric`
|
|
32
|
-
- `Report Section`
|
|
33
|
-
- `Report`
|
|
34
|
-
- `Chart Theme`
|
|
35
|
-
- `Chart`
|
|
36
|
-
- `Dataset`
|
|
37
|
-
- `Builder Configuration`
|
|
38
|
-
- `Tokens`
|
|
39
|
-
|
|
40
|
-
## Example Usage
|
|
41
|
-
|
|
42
|
-
```ts
|
|
43
|
-
import { ApplicationValidatorService, ChartValidatorService } from '@qrvey/cd-package-registry';
|
|
44
|
-
|
|
45
|
-
const applicationValidationService = new ApplicationValidatorService();
|
|
46
|
-
const applicationPayload = {
|
|
47
|
-
appid: '123456',
|
|
48
|
-
name: 'app name',
|
|
49
|
-
userid: '123456'
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const applicationValidationResult = applicationValidationService.validate(applicationPayload)
|
|
53
|
-
const applicationBatchValidationResult = applicationValidationService.batchValidate([applicationPayload])
|
|
54
|
-
|
|
55
|
-
// Validation with dependencies
|
|
56
|
-
|
|
57
|
-
const chartPayload = {
|
|
58
|
-
chartId: '123456'
|
|
59
|
-
appid: '123456',
|
|
60
|
-
title: 'chart title',
|
|
61
|
-
userid: '123456'
|
|
62
|
-
}
|
|
63
|
-
const options = {
|
|
64
|
-
domain: 'http://example.com'
|
|
65
|
-
apiKey: '123456'
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const chartValidatorService = new ChartValidatorService({ userId: userid, appId: appid }, options)
|
|
69
|
-
|
|
70
|
-
const chartValidationResults = chartValidatorService.validate(chartPayload)
|
|
71
|
-
const chartBatchValidationResults = chartValidatorService.batchValidate([chartPayload])
|
|
72
|
-
```
|
|
73
|
-
## Extend functionality
|
|
74
|
-
|
|
75
|
-
You can create your custom validators extending from the library functionality. You need to create your DTOs using class-validator. Example of a custom validator without dependencies
|
|
76
|
-
|
|
77
|
-
```ts
|
|
78
|
-
class CustomAssetDto {
|
|
79
|
-
@IsString()
|
|
80
|
-
@IsDefined()
|
|
81
|
-
id: string;
|
|
82
|
-
|
|
83
|
-
@IsString()
|
|
84
|
-
@IsDefined()
|
|
85
|
-
name: string;
|
|
86
|
-
|
|
87
|
-
@IsString()
|
|
88
|
-
@IsDefined()
|
|
89
|
-
lastName: string;
|
|
90
|
-
|
|
91
|
-
@IsNumber()
|
|
92
|
-
@IsOptional()
|
|
93
|
-
age: number;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
class CustomValidatorWithoutDependencies extends BaseAssetService<CustomAssetDto> {
|
|
97
|
-
private static readonly _logger = new LoggerService(CustomValidatorWithoutDependencies.name)
|
|
98
|
-
protected get idKey(): keyof CustomAssetDto {
|
|
99
|
-
return 'id';
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
protected getAssetType(): new () => object {
|
|
103
|
-
return CustomAssetDto;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
protected get logger(): LoggerService {
|
|
107
|
-
return CustomValidatorWithoutDependencies._logger;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
Example of a custom validator with dependencies
|
|
113
|
-
|
|
114
|
-
```ts
|
|
115
|
-
class CustomAssetDto {
|
|
116
|
-
@IsString()
|
|
117
|
-
@IsDefined()
|
|
118
|
-
id: string;
|
|
119
|
-
|
|
120
|
-
@IsString()
|
|
121
|
-
@IsDefined()
|
|
122
|
-
name: string;
|
|
123
|
-
|
|
124
|
-
@IsString()
|
|
125
|
-
@IsDefined()
|
|
126
|
-
lastName: string;
|
|
127
|
-
|
|
128
|
-
@IsNumber()
|
|
129
|
-
@IsOptional()
|
|
130
|
-
age: number;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
class CustomValidatorWithDependencies extends BaseAssetWithDependenciesService<CustomAssetDto> {
|
|
134
|
-
protected get idKey(): keyof CustomAssetDto {
|
|
135
|
-
return 'id';
|
|
136
|
-
}
|
|
137
|
-
protected dependencyValidator: IAssetDependencyValidatorService<CustomAssetDto>;
|
|
138
|
-
private static readonly _logger: LoggerService = new LoggerService(
|
|
139
|
-
CustomValidatorWithDependencies.name,
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
constructor(params: { userId: string; appId: string }, options?: Options) {
|
|
143
|
-
super();
|
|
144
|
-
this.dependencyValidator = new CustomDependencyValidator(
|
|
145
|
-
params,
|
|
146
|
-
options,
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
protected getAssetType(): new () => object {
|
|
151
|
-
return CustomAssetDto;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
protected get logger(): LoggerService {
|
|
155
|
-
return CustomValidatorWithoutDependencies._logger;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
class CustomDependencyValidator
|
|
160
|
-
implements IAssetDependencyValidatorService<CustomAssetDto>
|
|
161
|
-
{
|
|
162
|
-
constructor(private readonly params: any, private readonly options: Option)
|
|
163
|
-
{}
|
|
164
|
-
getDependencyKeys(input: Partial<CustomAssetDto>): {
|
|
165
|
-
keys: Record<string, any>[];
|
|
166
|
-
} {
|
|
167
|
-
return {
|
|
168
|
-
keys: [{ qrveyId: input.qrveyid! }],
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
async fetchDependencies(
|
|
172
|
-
keys: Record<string, any>[],
|
|
173
|
-
): Promise<DependencyContext> {
|
|
174
|
-
const args = uniqueBy(keys ?? [], 'id');
|
|
175
|
-
|
|
176
|
-
const dependencies = await fetchDependencies(args);
|
|
177
|
-
|
|
178
|
-
const dependenciesMap = new Map(dependencies.map((d) => [d.id, d]));
|
|
179
|
-
|
|
180
|
-
return {
|
|
181
|
-
dependencies: dependenciesMap,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
validateWithContext(
|
|
185
|
-
input: Partial<ChartAssetDto>,
|
|
186
|
-
context: DependencyContext,
|
|
187
|
-
): ValidationError[] {
|
|
188
|
-
const errors: ValidationError[] = [];
|
|
189
|
-
|
|
190
|
-
const dependency = context.dependencies.get(input.id);
|
|
191
|
-
|
|
192
|
-
if (!dependency) {
|
|
193
|
-
errors.push({
|
|
194
|
-
field: 'id',
|
|
195
|
-
message: `Custom error message`,
|
|
196
|
-
value: input,
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return errors;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
```
|
package/dist/cjs/index.js
CHANGED
|
@@ -4352,6 +4352,10 @@ var _DatasetFetchClient = class _DatasetFetchClient extends BaseFetchClient {
|
|
|
4352
4352
|
const fetchOptions = _DatasetFetchClient.fetchOptions(options);
|
|
4353
4353
|
return fetch.FetchService.get(`/devapi/v4/user/${args.userId}/app/${args.appId}/qollect/dataset/version/latest/connection/${args.connectionId}`, fetchOptions);
|
|
4354
4354
|
}
|
|
4355
|
+
static getById(args, options) {
|
|
4356
|
+
const fetchOptions = _DatasetFetchClient.fetchOptions(options);
|
|
4357
|
+
return fetch.FetchService.get(`/devapi/v4/user/${args.userId}/app/${args.appId}/qollect/dataset/${args.datasetId}`, fetchOptions);
|
|
4358
|
+
}
|
|
4355
4359
|
};
|
|
4356
4360
|
__name(_DatasetFetchClient, "DatasetFetchClient");
|
|
4357
4361
|
var DatasetFetchClient = _DatasetFetchClient;
|
|
@@ -4827,10 +4831,10 @@ Parent Dataset ID: ${input.publicParentId}`
|
|
|
4827
4831
|
return result.filter((res) => res.status === "fulfilled").map((res) => res.value);
|
|
4828
4832
|
}
|
|
4829
4833
|
async fetchDatasetsByIds(args) {
|
|
4830
|
-
const result = await Promise.allSettled(args.map(({ parentDatasetId }) =>
|
|
4834
|
+
const result = await Promise.allSettled(args.map(({ parentDatasetId }) => DatasetFetchClient.getById({
|
|
4831
4835
|
userId: this.params.userId,
|
|
4832
4836
|
appId: this.params.appId,
|
|
4833
|
-
|
|
4837
|
+
datasetId: parentDatasetId
|
|
4834
4838
|
}, this.options)));
|
|
4835
4839
|
return result.filter((res) => res.status === "fulfilled").map((res) => res.value);
|
|
4836
4840
|
}
|