dataiku-sdk 0.7.0 → 0.9.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.
- package/dist/src/cli.js +1301 -14
- package/dist/src/client.d.ts +46 -0
- package/dist/src/client.js +158 -0
- package/dist/src/index.d.ts +13 -0
- package/dist/src/index.js +13 -0
- package/dist/src/resources/api-deployer.d.ts +66 -0
- package/dist/src/resources/api-deployer.js +79 -0
- package/dist/src/resources/api-services.d.ts +38 -0
- package/dist/src/resources/api-services.js +50 -0
- package/dist/src/resources/applications.d.ts +56 -0
- package/dist/src/resources/applications.js +67 -0
- package/dist/src/resources/bundles.d.ts +53 -0
- package/dist/src/resources/bundles.js +103 -0
- package/dist/src/resources/continuous-activities.d.ts +27 -0
- package/dist/src/resources/continuous-activities.js +22 -0
- package/dist/src/resources/datasets.d.ts +6 -0
- package/dist/src/resources/datasets.js +15 -0
- package/dist/src/resources/discussions.d.ts +26 -0
- package/dist/src/resources/discussions.js +29 -0
- package/dist/src/resources/meanings.d.ts +41 -0
- package/dist/src/resources/meanings.js +33 -0
- package/dist/src/resources/metrics.d.ts +44 -0
- package/dist/src/resources/metrics.js +31 -0
- package/dist/src/resources/project-library.d.ts +38 -0
- package/dist/src/resources/project-library.js +82 -0
- package/dist/src/resources/projects.d.ts +70 -0
- package/dist/src/resources/projects.js +97 -0
- package/dist/src/resources/recipes.js +10 -8
- package/dist/src/resources/scenarios.d.ts +3 -0
- package/dist/src/resources/scenarios.js +8 -1
- package/dist/src/resources/statistics.d.ts +56 -0
- package/dist/src/resources/statistics.js +51 -0
- package/dist/src/resources/streaming-endpoints.d.ts +45 -0
- package/dist/src/resources/streaming-endpoints.js +36 -0
- package/dist/src/resources/webapps.d.ts +27 -0
- package/dist/src/resources/webapps.js +36 -0
- package/dist/src/resources/workspaces.d.ts +59 -0
- package/dist/src/resources/workspaces.js +31 -0
- package/package.json +5 -5
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { BaseResource, } from "./base.js";
|
|
2
|
+
function normalizeLibraryPath(path) {
|
|
3
|
+
const normalized = path.replace(/^\/+/, "");
|
|
4
|
+
if (!normalized)
|
|
5
|
+
throw new Error("Project library path is required");
|
|
6
|
+
return normalized;
|
|
7
|
+
}
|
|
8
|
+
function normalizeLibraryDestinationPath(path) {
|
|
9
|
+
if (path === "/")
|
|
10
|
+
return "/";
|
|
11
|
+
return `/${normalizeLibraryPath(path)}`;
|
|
12
|
+
}
|
|
13
|
+
function encodeLibraryPath(path) {
|
|
14
|
+
const normalized = normalizeLibraryPath(path);
|
|
15
|
+
return normalized
|
|
16
|
+
.split("/")
|
|
17
|
+
.map((segment) => encodeURIComponent(segment))
|
|
18
|
+
.join("/");
|
|
19
|
+
}
|
|
20
|
+
export class ProjectLibraryResource extends BaseResource {
|
|
21
|
+
/** List the full project code-library contents tree. */
|
|
22
|
+
async listContents(projectKey) {
|
|
23
|
+
return this.client.get(`/public/api/projects/${this.enc(projectKey)}/libraries/contents`);
|
|
24
|
+
}
|
|
25
|
+
/** Read a project code-library file as text. */
|
|
26
|
+
async getFile(path, projectKey) {
|
|
27
|
+
const res = await this.client.get(this.contentsPath(path, projectKey));
|
|
28
|
+
return res.data;
|
|
29
|
+
}
|
|
30
|
+
/** Read a project code-library file as bytes. */
|
|
31
|
+
async getFileBytes(path, projectKey) {
|
|
32
|
+
const res = await this.client.get(`${this.contentsPath(path, projectKey)}?dataEncoding=base64`);
|
|
33
|
+
return Buffer.from(res.data, "base64");
|
|
34
|
+
}
|
|
35
|
+
/** Create an empty project code-library file. */
|
|
36
|
+
async addFile(path, projectKey) {
|
|
37
|
+
await this.client.postText(this.contentsPath(path, projectKey));
|
|
38
|
+
}
|
|
39
|
+
/** Create a project code-library folder. */
|
|
40
|
+
async addFolder(path, projectKey) {
|
|
41
|
+
await this.client.postText(`/public/api/projects/${this.enc(projectKey)}/libraries/folders/${encodeLibraryPath(path)}`);
|
|
42
|
+
}
|
|
43
|
+
/** Create or replace a project code-library file with raw text content. */
|
|
44
|
+
async addOrUpdateFile(path, content, projectKey) {
|
|
45
|
+
await this.postRawText(this.contentsPath(path, projectKey), content);
|
|
46
|
+
}
|
|
47
|
+
/** Delete a project code-library file. */
|
|
48
|
+
async deleteFile(path, projectKey) {
|
|
49
|
+
await this.client.del(this.contentsPath(path, projectKey));
|
|
50
|
+
}
|
|
51
|
+
/** Rename a project code-library file or folder within its current parent folder. */
|
|
52
|
+
async rename(path, newName, projectKey) {
|
|
53
|
+
const body = {
|
|
54
|
+
oldPath: `/${normalizeLibraryPath(path)}`,
|
|
55
|
+
newName,
|
|
56
|
+
};
|
|
57
|
+
await this.client.postText(`/public/api/projects/${this.enc(projectKey)}/libraries/contents-actions/rename/`, body);
|
|
58
|
+
}
|
|
59
|
+
/** Move a project code-library file or folder into another library folder. */
|
|
60
|
+
async move(path, destinationFolderPath, projectKey) {
|
|
61
|
+
const body = {
|
|
62
|
+
oldPath: `/${normalizeLibraryPath(path)}`,
|
|
63
|
+
newPath: normalizeLibraryDestinationPath(destinationFolderPath),
|
|
64
|
+
};
|
|
65
|
+
await this.client.postText(`/public/api/projects/${this.enc(projectKey)}/libraries/contents-actions/move`, body);
|
|
66
|
+
}
|
|
67
|
+
contentsPath(path, projectKey) {
|
|
68
|
+
const projectKeyPart = this.enc(projectKey);
|
|
69
|
+
return `/public/api/projects/${projectKeyPart}/libraries/contents/${encodeLibraryPath(path)}`;
|
|
70
|
+
}
|
|
71
|
+
async postRawText(path, content) {
|
|
72
|
+
// DSS library writes use dataikuapi's raw_body; route through the client's
|
|
73
|
+
// transport so auth, retries, TLS options, and DSS error handling stay aligned.
|
|
74
|
+
const rawClient = this.client;
|
|
75
|
+
const res = await rawClient.fetchWithRetry(`${rawClient.baseUrl}${path}`, {
|
|
76
|
+
method: "POST",
|
|
77
|
+
headers: rawClient.getAnyHeaders(),
|
|
78
|
+
body: content,
|
|
79
|
+
});
|
|
80
|
+
await res.text();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -15,7 +15,77 @@ export interface FlowMapResult {
|
|
|
15
15
|
truncation: FlowMapTruncationSummary;
|
|
16
16
|
raw?: unknown;
|
|
17
17
|
}
|
|
18
|
+
export type ProjectLifecycleSettings = Record<string, unknown>;
|
|
19
|
+
export type ProjectDuplicationMode = "MINIMAL" | "SHARING" | "FULL" | "NONE" | (string & {});
|
|
20
|
+
export interface ProjectDuplicateOptions {
|
|
21
|
+
duplicationMode?: ProjectDuplicationMode;
|
|
22
|
+
exportAnalysisModels?: boolean;
|
|
23
|
+
exportSavedModels?: boolean;
|
|
24
|
+
exportGitRepository?: boolean | null;
|
|
25
|
+
exportInsightsData?: boolean;
|
|
26
|
+
remapping?: Record<string, unknown>;
|
|
27
|
+
targetProjectFolderId?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ProjectExportOptions {
|
|
30
|
+
exportUploads?: boolean;
|
|
31
|
+
exportManagedFS?: boolean;
|
|
32
|
+
exportAnalysisModels?: boolean;
|
|
33
|
+
exportSavedModels?: boolean;
|
|
34
|
+
exportModelEvaluationStores?: boolean;
|
|
35
|
+
exportManagedFolders?: boolean;
|
|
36
|
+
exportAllInputDatasets?: boolean;
|
|
37
|
+
exportAllDatasets?: boolean;
|
|
38
|
+
exportAllInputManagedFolders?: boolean;
|
|
39
|
+
exportGitRepository?: boolean;
|
|
40
|
+
exportInsightsData?: boolean;
|
|
41
|
+
exportPromptStudioHistories?: boolean;
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
export interface ProjectPermissionRule {
|
|
45
|
+
group?: string;
|
|
46
|
+
user?: string;
|
|
47
|
+
admin?: boolean;
|
|
48
|
+
readProjectContent?: boolean;
|
|
49
|
+
writeProjectContent?: boolean;
|
|
50
|
+
readDashboards?: boolean;
|
|
51
|
+
writeDashboards?: boolean;
|
|
52
|
+
runScenarios?: boolean;
|
|
53
|
+
manageDashboardAuthorizations?: boolean;
|
|
54
|
+
manageExposedElements?: boolean;
|
|
55
|
+
moderateDashboards?: boolean;
|
|
56
|
+
[key: string]: unknown;
|
|
57
|
+
}
|
|
58
|
+
export interface ProjectPermissions {
|
|
59
|
+
owner?: string;
|
|
60
|
+
permissions?: ProjectPermissionRule[];
|
|
61
|
+
[key: string]: unknown;
|
|
62
|
+
}
|
|
63
|
+
export interface ProjectImportUploadResult {
|
|
64
|
+
id: string;
|
|
65
|
+
[key: string]: unknown;
|
|
66
|
+
}
|
|
18
67
|
export declare class ProjectsResource extends BaseResource {
|
|
68
|
+
private httpInternals;
|
|
69
|
+
private postStream;
|
|
70
|
+
private uploadJson;
|
|
71
|
+
/** Create a new project. */
|
|
72
|
+
createProject(projectKey: string, name: string, ownerLogin?: string, settings?: ProjectLifecycleSettings | null): Promise<string>;
|
|
73
|
+
/** Delete a project using the lifecycle endpoint. */
|
|
74
|
+
deleteProject(projectKey: string, dropData?: boolean): Promise<void>;
|
|
75
|
+
/** Duplicate a project. */
|
|
76
|
+
duplicate(projectKey: string, targetProjectKey: string, targetProjectName: string, options?: ProjectDuplicateOptions): Promise<Record<string, unknown>>;
|
|
77
|
+
/** Export a project archive to a local file. */
|
|
78
|
+
exportArchive(projectKey: string, filePath: string, options?: ProjectExportOptions): Promise<void>;
|
|
79
|
+
/** Upload a project archive and return the temporary import id. */
|
|
80
|
+
importProjectFromArchive(filePath: string): Promise<ProjectImportUploadResult>;
|
|
81
|
+
/** Get project permissions. */
|
|
82
|
+
getPermissions(projectKey?: string): Promise<ProjectPermissions>;
|
|
83
|
+
/** Set project permissions. */
|
|
84
|
+
setPermissions(projectKey: string | undefined, permissions: ProjectPermissions): Promise<void>;
|
|
85
|
+
/** Get project settings. */
|
|
86
|
+
getSettings(projectKey?: string): Promise<ProjectLifecycleSettings>;
|
|
87
|
+
/** Set project settings. */
|
|
88
|
+
setSettings(projectKey: string | undefined, body: ProjectLifecycleSettings): Promise<void>;
|
|
19
89
|
/** List all projects visible to the API key. */
|
|
20
90
|
list(): Promise<ProjectSummary[]>;
|
|
21
91
|
/** Get details for a single project. */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createWriteStream, openAsBlob, } from "node:fs";
|
|
2
|
+
import { Writable, } from "node:stream";
|
|
1
3
|
import { ProjectDetailsSchema, ProjectMetadataSchema, ProjectSummaryArraySchema, } from "../schemas.js";
|
|
2
4
|
import { normalizeFlowGraph, } from "../utils/flow-map.js";
|
|
3
5
|
import { BaseResource, } from "./base.js";
|
|
@@ -99,6 +101,101 @@ const DEFAULT_MAX_NODES = 300;
|
|
|
99
101
|
const DEFAULT_MAX_EDGES = 600;
|
|
100
102
|
const DEFAULT_METADATA_TIMEOUT_MS = 1_500;
|
|
101
103
|
export class ProjectsResource extends BaseResource {
|
|
104
|
+
httpInternals() {
|
|
105
|
+
return this.client;
|
|
106
|
+
}
|
|
107
|
+
async postStream(path, body) {
|
|
108
|
+
const http = this.httpInternals();
|
|
109
|
+
return http.fetchWithRetry(`${http.baseUrl}${path}`, {
|
|
110
|
+
method: "POST",
|
|
111
|
+
headers: {
|
|
112
|
+
Authorization: `Bearer ${http.apiKey}`,
|
|
113
|
+
Accept: "*/*",
|
|
114
|
+
"Content-Type": "application/json",
|
|
115
|
+
},
|
|
116
|
+
body: JSON.stringify(body),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async uploadJson(path, filePath, fileName) {
|
|
120
|
+
const http = this.httpInternals();
|
|
121
|
+
const fileBlob = await openAsBlob(filePath);
|
|
122
|
+
const formData = new FormData();
|
|
123
|
+
formData.append("file", fileBlob, fileName);
|
|
124
|
+
const res = await http.fetchWithRetry(`${http.baseUrl}${path}`, {
|
|
125
|
+
method: "POST",
|
|
126
|
+
headers: { Authorization: `Bearer ${http.apiKey}`, },
|
|
127
|
+
body: formData,
|
|
128
|
+
});
|
|
129
|
+
return res.json();
|
|
130
|
+
}
|
|
131
|
+
/** Create a new project. */
|
|
132
|
+
async createProject(projectKey, name, ownerLogin, settings) {
|
|
133
|
+
return this.client.postText("/public/api/projects/", {
|
|
134
|
+
projectKey,
|
|
135
|
+
name,
|
|
136
|
+
owner: ownerLogin ?? null,
|
|
137
|
+
settings: settings ?? null,
|
|
138
|
+
description: null,
|
|
139
|
+
permissions: [],
|
|
140
|
+
tags: [],
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/** Delete a project using the lifecycle endpoint. */
|
|
144
|
+
async deleteProject(projectKey, dropData = false) {
|
|
145
|
+
const enc = encodeURIComponent(projectKey);
|
|
146
|
+
await this.client.del(`/public/api/projects/${enc}?clearManagedDatasets=${String(dropData)}&clearOutputManagedFolders=false&clearJobAndScenarioLogs=true&wait=true`);
|
|
147
|
+
}
|
|
148
|
+
/** Duplicate a project. */
|
|
149
|
+
async duplicate(projectKey, targetProjectKey, targetProjectName, options) {
|
|
150
|
+
const body = {
|
|
151
|
+
targetProjectName,
|
|
152
|
+
targetProjectKey,
|
|
153
|
+
duplicationMode: options?.duplicationMode ?? "MINIMAL",
|
|
154
|
+
exportAnalysisModels: options?.exportAnalysisModels ?? true,
|
|
155
|
+
exportSavedModels: options?.exportSavedModels ?? true,
|
|
156
|
+
exportGitRepository: options?.exportGitRepository ?? null,
|
|
157
|
+
exportInsightsData: options?.exportInsightsData ?? true,
|
|
158
|
+
remapping: options?.remapping ?? {},
|
|
159
|
+
...(options?.targetProjectFolderId !== undefined
|
|
160
|
+
? { targetProjectFolderId: options.targetProjectFolderId, }
|
|
161
|
+
: {}),
|
|
162
|
+
};
|
|
163
|
+
return this.client.post(`/public/api/projects/${encodeURIComponent(projectKey)}/duplicate/`, body);
|
|
164
|
+
}
|
|
165
|
+
/** Export a project archive to a local file. */
|
|
166
|
+
async exportArchive(projectKey, filePath, options) {
|
|
167
|
+
const res = await this.postStream(`/public/api/projects/${encodeURIComponent(projectKey)}/export`, options ?? {});
|
|
168
|
+
if (!res.body)
|
|
169
|
+
throw new Error("projects.exportArchive response did not include a body");
|
|
170
|
+
const file = createWriteStream(filePath);
|
|
171
|
+
try {
|
|
172
|
+
await res.body.pipeTo(Writable.toWeb(file));
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
file.destroy();
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/** Upload a project archive and return the temporary import id. */
|
|
180
|
+
async importProjectFromArchive(filePath) {
|
|
181
|
+
return this.uploadJson("/public/api/projects/import/upload", filePath, "tmp-import.zip");
|
|
182
|
+
}
|
|
183
|
+
/** Get project permissions. */
|
|
184
|
+
async getPermissions(projectKey) {
|
|
185
|
+
return this.client.get(`/public/api/projects/${this.enc(projectKey)}/permissions`);
|
|
186
|
+
}
|
|
187
|
+
/** Set project permissions. */
|
|
188
|
+
async setPermissions(projectKey, permissions) {
|
|
189
|
+
await this.client.putVoid(`/public/api/projects/${this.enc(projectKey)}/permissions`, permissions);
|
|
190
|
+
}
|
|
191
|
+
/** Get project settings. */
|
|
192
|
+
async getSettings(projectKey) {
|
|
193
|
+
return this.client.get(`/public/api/projects/${this.enc(projectKey)}/settings`);
|
|
194
|
+
}
|
|
195
|
+
/** Set project settings. */
|
|
196
|
+
async setSettings(projectKey, body) {
|
|
197
|
+
await this.client.putVoid(`/public/api/projects/${this.enc(projectKey)}/settings`, body);
|
|
198
|
+
}
|
|
102
199
|
/** List all projects visible to the API key. */
|
|
103
200
|
async list() {
|
|
104
201
|
const raw = await this.client.get("/public/api/projects/");
|
|
@@ -111,16 +111,18 @@ function escapedRegExp(value) {
|
|
|
111
111
|
function isSqlRecipeType(recipeType) {
|
|
112
112
|
return typeof recipeType === "string" && recipeType.toLowerCase().includes("sql");
|
|
113
113
|
}
|
|
114
|
+
function escapeQuotedIdentifier(identifier, quote) {
|
|
115
|
+
if (quote === '"')
|
|
116
|
+
return identifier.replace(/"/g, '""');
|
|
117
|
+
if (quote === "`")
|
|
118
|
+
return identifier.replace(/`/g, "``");
|
|
119
|
+
return identifier;
|
|
120
|
+
}
|
|
121
|
+
function escapeBracketIdentifier(identifier) {
|
|
122
|
+
return identifier.replace(/\]/g, "]]");
|
|
123
|
+
}
|
|
114
124
|
function rewriteSqlTableReferences(payload, rewrites) {
|
|
115
125
|
const bareIdentifierPattern = /^[A-Za-z_][A-Za-z0-9_$]*(?:\.[A-Za-z_][A-Za-z0-9_$]*)*$/;
|
|
116
|
-
const escapeQuotedIdentifier = (identifier, quote) => {
|
|
117
|
-
if (quote === "\"")
|
|
118
|
-
return identifier.replace(/"/g, '""');
|
|
119
|
-
if (quote === "`")
|
|
120
|
-
return identifier.replace(/`/g, "``");
|
|
121
|
-
return identifier;
|
|
122
|
-
};
|
|
123
|
-
const escapeBracketIdentifier = (identifier) => identifier.replace(/\]/g, "]]");
|
|
124
126
|
let next = payload;
|
|
125
127
|
for (const [from, to,] of Object.entries(rewrites)) {
|
|
126
128
|
if (!from)
|
|
@@ -40,6 +40,8 @@ export interface ScenarioScriptRunResult {
|
|
|
40
40
|
pollCount: number;
|
|
41
41
|
output?: string;
|
|
42
42
|
log: string;
|
|
43
|
+
logTruncated: boolean;
|
|
44
|
+
maxLogBytes: number;
|
|
43
45
|
envName?: string;
|
|
44
46
|
}
|
|
45
47
|
export declare function normalizeScenarioUpdateData(data: Record<string, unknown>): {
|
|
@@ -91,5 +93,6 @@ export declare class ScenariosResource extends BaseResource {
|
|
|
91
93
|
timeoutMs?: number;
|
|
92
94
|
pollIntervalMs?: number;
|
|
93
95
|
keepScenario?: boolean;
|
|
96
|
+
maxLogBytes?: number;
|
|
94
97
|
}): Promise<ScenarioScriptRunResult>;
|
|
95
98
|
}
|
|
@@ -12,6 +12,7 @@ export const SCENARIO_CANONICAL_EDITABLE_FIELDS = [
|
|
|
12
12
|
"active",
|
|
13
13
|
"name",
|
|
14
14
|
];
|
|
15
|
+
const DEFAULT_CODE_RUN_MAX_LOG_BYTES = 1_048_576;
|
|
15
16
|
const CODE_RUN_OUTPUT_START = "<<<DSS_CODE_RUN_OUTPUT_b7e3a1>>>";
|
|
16
17
|
const CODE_RUN_OUTPUT_END = "<<<DSS_CODE_RUN_OUTPUT_END_b7e3a1>>>";
|
|
17
18
|
/**
|
|
@@ -349,6 +350,7 @@ export class ScenariosResource extends BaseResource {
|
|
|
349
350
|
const baseIntervalMs = Math.max(1, opts?.pollIntervalMs ?? 2_000);
|
|
350
351
|
const adaptivePolling = opts?.pollIntervalMs === undefined;
|
|
351
352
|
const timeout = Math.max(baseIntervalMs, opts?.timeoutMs ?? 120_000);
|
|
353
|
+
const maxLogBytes = Math.max(0, Math.floor(opts?.maxLogBytes ?? DEFAULT_CODE_RUN_MAX_LOG_BYTES));
|
|
352
354
|
try {
|
|
353
355
|
await this.client.post(`/public/api/projects/${pkEnc}/scenarios/`, {
|
|
354
356
|
id: scenarioId,
|
|
@@ -394,8 +396,11 @@ export class ScenariosResource extends BaseResource {
|
|
|
394
396
|
await new Promise((r) => setTimeout(r, Math.min(nextDelayMs, Math.max(1, timeout - (Date.now() - startedAt)))));
|
|
395
397
|
}
|
|
396
398
|
let log = "";
|
|
399
|
+
let logTruncated = false;
|
|
397
400
|
if (runId && outcome !== "TIMEOUT") {
|
|
398
|
-
|
|
401
|
+
const limitedLog = await this.client.getTextLimited(`${base}/${encodeURIComponent(runId)}/log`, maxLogBytes);
|
|
402
|
+
log = limitedLog.text;
|
|
403
|
+
logTruncated = limitedLog.truncated;
|
|
399
404
|
}
|
|
400
405
|
const output = extractCodeRunOutput(log);
|
|
401
406
|
return {
|
|
@@ -407,6 +412,8 @@ export class ScenariosResource extends BaseResource {
|
|
|
407
412
|
pollCount,
|
|
408
413
|
output,
|
|
409
414
|
log,
|
|
415
|
+
logTruncated,
|
|
416
|
+
maxLogBytes,
|
|
410
417
|
...(opts?.envName ? { envName: opts.envName, } : {}),
|
|
411
418
|
};
|
|
412
419
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { BaseResource } from "./base.js";
|
|
2
|
+
export type StatisticsCardSettings = Record<string, unknown>;
|
|
3
|
+
export type StatisticsComputationSettings = Record<string, unknown>;
|
|
4
|
+
export interface StatisticsDatasetSelection {
|
|
5
|
+
partitionSelectionMethod?: string;
|
|
6
|
+
maxRecords?: number;
|
|
7
|
+
samplingMethod?: string;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
export interface StatisticsWorksheetDataSpec {
|
|
11
|
+
inputDatasetSmartName?: string;
|
|
12
|
+
datasetSelection?: StatisticsDatasetSelection;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface StatisticsWorksheetCreateRequest {
|
|
16
|
+
projectKey?: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
dataSpec?: StatisticsWorksheetDataSpec;
|
|
19
|
+
rootCard?: StatisticsCardSettings;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
export interface StatisticsWorksheetUpdateRequest extends StatisticsWorksheetCreateRequest {
|
|
23
|
+
id?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface StatisticsWorksheet {
|
|
26
|
+
id: string;
|
|
27
|
+
projectKey?: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
dataSpec?: StatisticsWorksheetDataSpec;
|
|
30
|
+
rootCard?: StatisticsCardSettings;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
export interface StatisticsFutureResponse {
|
|
34
|
+
jobId?: string | null;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
export declare class StatisticsResource extends BaseResource {
|
|
38
|
+
/** List statistics worksheets associated with a dataset. */
|
|
39
|
+
listWorksheets(datasetName: string, projectKey?: string): Promise<StatisticsWorksheet[]>;
|
|
40
|
+
/** Get one statistics worksheet definition. */
|
|
41
|
+
getWorksheet(datasetName: string, worksheetId: string, projectKey?: string): Promise<StatisticsWorksheet>;
|
|
42
|
+
/** Create a statistics worksheet for a dataset. */
|
|
43
|
+
createWorksheet(datasetName: string, body: StatisticsWorksheetCreateRequest, projectKey?: string): Promise<StatisticsWorksheet>;
|
|
44
|
+
/** Replace a statistics worksheet definition. */
|
|
45
|
+
updateWorksheet(datasetName: string, worksheetId: string, body: StatisticsWorksheetUpdateRequest, projectKey?: string): Promise<StatisticsWorksheet>;
|
|
46
|
+
/** Delete a statistics worksheet. */
|
|
47
|
+
deleteWorksheet(datasetName: string, worksheetId: string, projectKey?: string): Promise<void>;
|
|
48
|
+
/** Run the root card of a worksheet, returning the DSS future response. */
|
|
49
|
+
runWorksheet(datasetName: string, worksheetId: string, projectKey?: string): Promise<StatisticsFutureResponse>;
|
|
50
|
+
/** Run a card in the context of a worksheet, returning the DSS future response. */
|
|
51
|
+
runCard(datasetName: string, worksheetId: string, card: StatisticsCardSettings, projectKey?: string): Promise<StatisticsFutureResponse>;
|
|
52
|
+
/** Run a computation in the context of a worksheet, returning the DSS future response. */
|
|
53
|
+
runComputation(datasetName: string, worksheetId: string, computation: StatisticsComputationSettings, projectKey?: string): Promise<StatisticsFutureResponse>;
|
|
54
|
+
private worksheetsPath;
|
|
55
|
+
private worksheetPath;
|
|
56
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { BaseResource, } from "./base.js";
|
|
2
|
+
function isRecord(value) {
|
|
3
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
|
+
}
|
|
5
|
+
export class StatisticsResource extends BaseResource {
|
|
6
|
+
/** List statistics worksheets associated with a dataset. */
|
|
7
|
+
async listWorksheets(datasetName, projectKey) {
|
|
8
|
+
return this.client.get(this.worksheetsPath(datasetName, projectKey));
|
|
9
|
+
}
|
|
10
|
+
/** Get one statistics worksheet definition. */
|
|
11
|
+
async getWorksheet(datasetName, worksheetId, projectKey) {
|
|
12
|
+
return this.client.get(this.worksheetPath(datasetName, worksheetId, projectKey));
|
|
13
|
+
}
|
|
14
|
+
/** Create a statistics worksheet for a dataset. */
|
|
15
|
+
async createWorksheet(datasetName, body, projectKey) {
|
|
16
|
+
return this.client.post(this.worksheetsPath(datasetName, projectKey), body);
|
|
17
|
+
}
|
|
18
|
+
/** Replace a statistics worksheet definition. */
|
|
19
|
+
async updateWorksheet(datasetName, worksheetId, body, projectKey) {
|
|
20
|
+
return this.client.put(this.worksheetPath(datasetName, worksheetId, projectKey), body);
|
|
21
|
+
}
|
|
22
|
+
/** Delete a statistics worksheet. */
|
|
23
|
+
async deleteWorksheet(datasetName, worksheetId, projectKey) {
|
|
24
|
+
await this.client.del(this.worksheetPath(datasetName, worksheetId, projectKey));
|
|
25
|
+
}
|
|
26
|
+
/** Run the root card of a worksheet, returning the DSS future response. */
|
|
27
|
+
async runWorksheet(datasetName, worksheetId, projectKey) {
|
|
28
|
+
const worksheet = await this.getWorksheet(datasetName, worksheetId, projectKey);
|
|
29
|
+
if (!isRecord(worksheet.rootCard)) {
|
|
30
|
+
throw new Error("statistics.runWorksheet requires worksheet.rootCard");
|
|
31
|
+
}
|
|
32
|
+
return this.runCard(datasetName, worksheetId, worksheet.rootCard, projectKey);
|
|
33
|
+
}
|
|
34
|
+
/** Run a card in the context of a worksheet, returning the DSS future response. */
|
|
35
|
+
async runCard(datasetName, worksheetId, card, projectKey) {
|
|
36
|
+
return this.client.post(`${this.worksheetPath(datasetName, worksheetId, projectKey)}/actions/run-card`, card);
|
|
37
|
+
}
|
|
38
|
+
/** Run a computation in the context of a worksheet, returning the DSS future response. */
|
|
39
|
+
async runComputation(datasetName, worksheetId, computation, projectKey) {
|
|
40
|
+
return this.client.post(`${this.worksheetPath(datasetName, worksheetId, projectKey)}/actions/run-computation`, computation);
|
|
41
|
+
}
|
|
42
|
+
worksheetsPath(datasetName, projectKey) {
|
|
43
|
+
const project = this.enc(projectKey);
|
|
44
|
+
const dataset = encodeURIComponent(datasetName);
|
|
45
|
+
return `/public/api/projects/${project}/datasets/${dataset}/statistics/worksheets/`;
|
|
46
|
+
}
|
|
47
|
+
worksheetPath(datasetName, worksheetId, projectKey) {
|
|
48
|
+
const worksheet = encodeURIComponent(worksheetId);
|
|
49
|
+
return `${this.worksheetsPath(datasetName, projectKey)}${worksheet}`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BaseResource } from "./base.js";
|
|
2
|
+
export interface StreamingEndpointSchemaColumn {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
length?: number;
|
|
6
|
+
comment?: string;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
export interface StreamingEndpointSchema {
|
|
10
|
+
columns: StreamingEndpointSchemaColumn[];
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
export interface StreamingEndpointListItem {
|
|
14
|
+
id: string;
|
|
15
|
+
projectKey: string;
|
|
16
|
+
type: string;
|
|
17
|
+
schema?: StreamingEndpointSchema;
|
|
18
|
+
params?: Record<string, unknown>;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
export interface StreamingEndpointSettings {
|
|
22
|
+
id: string;
|
|
23
|
+
projectKey?: string;
|
|
24
|
+
type: string;
|
|
25
|
+
params?: Record<string, unknown>;
|
|
26
|
+
schema?: StreamingEndpointSchema;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
export interface StreamingEndpointCreateParams {
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
export declare class StreamingEndpointsResource extends BaseResource {
|
|
33
|
+
/** List all streaming endpoints in a project. */
|
|
34
|
+
list(projectKey?: string): Promise<StreamingEndpointListItem[]>;
|
|
35
|
+
/** Get one streaming endpoint's settings. */
|
|
36
|
+
get(id: string, projectKey?: string): Promise<StreamingEndpointSettings>;
|
|
37
|
+
/** Get one streaming endpoint's settings. */
|
|
38
|
+
getSettings(id: string, projectKey?: string): Promise<StreamingEndpointSettings>;
|
|
39
|
+
/** Create a streaming endpoint with type-specific params. */
|
|
40
|
+
create(id: string, type: string, body: StreamingEndpointCreateParams, projectKey?: string): Promise<StreamingEndpointSettings>;
|
|
41
|
+
/** Update one streaming endpoint's raw settings. */
|
|
42
|
+
updateSettings(id: string, body: Record<string, unknown>, projectKey?: string): Promise<void>;
|
|
43
|
+
/** Delete a streaming endpoint from the flow without deleting underlying streaming data. */
|
|
44
|
+
delete(id: string, projectKey?: string): Promise<void>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BaseResource, } from "./base.js";
|
|
2
|
+
export class StreamingEndpointsResource extends BaseResource {
|
|
3
|
+
/** List all streaming endpoints in a project. */
|
|
4
|
+
async list(projectKey) {
|
|
5
|
+
return this.client.get(`/public/api/projects/${this.enc(projectKey)}/streamingendpoints/`);
|
|
6
|
+
}
|
|
7
|
+
/** Get one streaming endpoint's settings. */
|
|
8
|
+
async get(id, projectKey) {
|
|
9
|
+
return this.getSettings(id, projectKey);
|
|
10
|
+
}
|
|
11
|
+
/** Get one streaming endpoint's settings. */
|
|
12
|
+
async getSettings(id, projectKey) {
|
|
13
|
+
const endpointId = encodeURIComponent(id);
|
|
14
|
+
return this.client.get(`/public/api/projects/${this.enc(projectKey)}/streamingendpoints/${endpointId}`);
|
|
15
|
+
}
|
|
16
|
+
/** Create a streaming endpoint with type-specific params. */
|
|
17
|
+
async create(id, type, body, projectKey) {
|
|
18
|
+
const pk = this.resolveProjectKey(projectKey);
|
|
19
|
+
return this.client.post(`/public/api/projects/${this.enc(pk)}/streamingendpoints/`, {
|
|
20
|
+
id,
|
|
21
|
+
projectKey: pk,
|
|
22
|
+
type,
|
|
23
|
+
params: body,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** Update one streaming endpoint's raw settings. */
|
|
27
|
+
async updateSettings(id, body, projectKey) {
|
|
28
|
+
const endpointId = encodeURIComponent(id);
|
|
29
|
+
await this.client.putVoid(`/public/api/projects/${this.enc(projectKey)}/streamingendpoints/${endpointId}`, body);
|
|
30
|
+
}
|
|
31
|
+
/** Delete a streaming endpoint from the flow without deleting underlying streaming data. */
|
|
32
|
+
async delete(id, projectKey) {
|
|
33
|
+
const endpointId = encodeURIComponent(id);
|
|
34
|
+
await this.client.del(`/public/api/projects/${this.enc(projectKey)}/streamingendpoints/${endpointId}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseResource } from "./base.js";
|
|
2
|
+
export interface WebappListItem {
|
|
3
|
+
id?: string;
|
|
4
|
+
webAppId?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
projectKey?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface WebappCreateResult {
|
|
10
|
+
webAppId: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class WebappsResource extends BaseResource {
|
|
13
|
+
/** List all webapps in a project. */
|
|
14
|
+
list(projectKey?: string): Promise<WebappListItem[]>;
|
|
15
|
+
/** Get one webapp's settings. */
|
|
16
|
+
getSettings(webappId: string, projectKey?: string): Promise<Record<string, unknown>>;
|
|
17
|
+
/** Create a webapp. */
|
|
18
|
+
create(body: Record<string, unknown>, projectKey?: string): Promise<WebappCreateResult>;
|
|
19
|
+
/** Update one webapp's settings. */
|
|
20
|
+
updateSettings(webappId: string, body: Record<string, unknown>, projectKey?: string): Promise<Record<string, unknown>>;
|
|
21
|
+
/** Stop a webapp backend. */
|
|
22
|
+
stopBackend(webappId: string, projectKey?: string): Promise<void>;
|
|
23
|
+
/** Start or restart a webapp backend. */
|
|
24
|
+
startOrRestartBackend(webappId: string, projectKey?: string): Promise<void>;
|
|
25
|
+
/** Get a webapp backend's state. */
|
|
26
|
+
getBackendState(webappId: string, projectKey?: string): Promise<Record<string, unknown>>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BaseResource, } from "./base.js";
|
|
2
|
+
export class WebappsResource extends BaseResource {
|
|
3
|
+
/** List all webapps in a project. */
|
|
4
|
+
async list(projectKey) {
|
|
5
|
+
return this.client.get(`/public/api/projects/${this.enc(projectKey)}/webapps/`);
|
|
6
|
+
}
|
|
7
|
+
/** Get one webapp's settings. */
|
|
8
|
+
async getSettings(webappId, projectKey) {
|
|
9
|
+
const id = encodeURIComponent(webappId);
|
|
10
|
+
return this.client.get(`/public/api/projects/${this.enc(projectKey)}/webapps/${id}`);
|
|
11
|
+
}
|
|
12
|
+
/** Create a webapp. */
|
|
13
|
+
async create(body, projectKey) {
|
|
14
|
+
return this.client.post(`/public/api/projects/${this.enc(projectKey)}/webapps/`, body);
|
|
15
|
+
}
|
|
16
|
+
/** Update one webapp's settings. */
|
|
17
|
+
async updateSettings(webappId, body, projectKey) {
|
|
18
|
+
const id = encodeURIComponent(webappId);
|
|
19
|
+
return this.client.put(`/public/api/projects/${this.enc(projectKey)}/webapps/${id}`, body);
|
|
20
|
+
}
|
|
21
|
+
/** Stop a webapp backend. */
|
|
22
|
+
async stopBackend(webappId, projectKey) {
|
|
23
|
+
const id = encodeURIComponent(webappId);
|
|
24
|
+
await this.client.putVoid(`/public/api/projects/${this.enc(projectKey)}/webapps/${id}/backend/actions/stop`, {});
|
|
25
|
+
}
|
|
26
|
+
/** Start or restart a webapp backend. */
|
|
27
|
+
async startOrRestartBackend(webappId, projectKey) {
|
|
28
|
+
const id = encodeURIComponent(webappId);
|
|
29
|
+
await this.client.putVoid(`/public/api/projects/${this.enc(projectKey)}/webapps/${id}/backend/actions/restart`, {});
|
|
30
|
+
}
|
|
31
|
+
/** Get a webapp backend's state. */
|
|
32
|
+
async getBackendState(webappId, projectKey) {
|
|
33
|
+
const id = encodeURIComponent(webappId);
|
|
34
|
+
return this.client.get(`/public/api/projects/${this.enc(projectKey)}/webapps/${id}/backend/state`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BaseResource } from "./base.js";
|
|
2
|
+
export type WorkspaceObjectReferenceType = "DATASET" | "ARTICLE" | "DASHBOARD" | (string & {});
|
|
3
|
+
export interface WorkspacePermissionItem extends Record<string, unknown> {
|
|
4
|
+
group?: string;
|
|
5
|
+
user?: string;
|
|
6
|
+
admin?: boolean;
|
|
7
|
+
write?: boolean;
|
|
8
|
+
read?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface WorkspaceListItem extends Record<string, unknown> {
|
|
11
|
+
workspaceKey?: string;
|
|
12
|
+
displayName?: string;
|
|
13
|
+
color?: string | null;
|
|
14
|
+
description?: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface WorkspaceSettings extends WorkspaceListItem {
|
|
17
|
+
permissions?: WorkspacePermissionItem[] | null;
|
|
18
|
+
}
|
|
19
|
+
export interface WorkspaceCreateRequest extends Record<string, unknown> {
|
|
20
|
+
workspaceKey: string;
|
|
21
|
+
displayName: string;
|
|
22
|
+
color?: string | null;
|
|
23
|
+
description?: string | null;
|
|
24
|
+
permissions?: WorkspacePermissionItem[] | null;
|
|
25
|
+
}
|
|
26
|
+
export interface WorkspaceObjectReference extends Record<string, unknown> {
|
|
27
|
+
projectKey?: string;
|
|
28
|
+
type?: WorkspaceObjectReferenceType;
|
|
29
|
+
id?: string;
|
|
30
|
+
workspaceKey?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface WorkspaceHtmlLinkObject extends Record<string, unknown> {
|
|
33
|
+
name: string;
|
|
34
|
+
url: string;
|
|
35
|
+
description?: string | null;
|
|
36
|
+
}
|
|
37
|
+
export interface WorkspaceObject extends Record<string, unknown> {
|
|
38
|
+
id?: string;
|
|
39
|
+
reference?: WorkspaceObjectReference;
|
|
40
|
+
appId?: string;
|
|
41
|
+
htmlLink?: WorkspaceHtmlLinkObject;
|
|
42
|
+
}
|
|
43
|
+
export type WorkspaceObjectInput = WorkspaceObject;
|
|
44
|
+
export declare class WorkspacesResource extends BaseResource {
|
|
45
|
+
/** List workspaces visible to the API key. */
|
|
46
|
+
list(): Promise<WorkspaceListItem[]>;
|
|
47
|
+
/** Get workspace settings. */
|
|
48
|
+
get(workspaceKey: string): Promise<WorkspaceSettings>;
|
|
49
|
+
/** Create a workspace. DSS returns a text confirmation. */
|
|
50
|
+
create(body: WorkspaceCreateRequest): Promise<string>;
|
|
51
|
+
/** Replace workspace settings. */
|
|
52
|
+
updateSettings(workspaceKey: string, body: WorkspaceSettings): Promise<void>;
|
|
53
|
+
/** Delete a workspace. */
|
|
54
|
+
delete(workspaceKey: string): Promise<void>;
|
|
55
|
+
/** List objects in a workspace. */
|
|
56
|
+
listObjects(workspaceKey: string): Promise<WorkspaceObject[]>;
|
|
57
|
+
/** Add an object to a workspace. */
|
|
58
|
+
addObject(workspaceKey: string, object: WorkspaceObjectInput): Promise<WorkspaceObject>;
|
|
59
|
+
}
|