@revisium/client 0.1.0-alpha.1 → 0.2.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/README.md +372 -36
- package/dist/data-operations.d.ts +52 -0
- package/dist/data-operations.d.ts.map +1 -0
- package/dist/generated/client/client.gen.d.ts +3 -0
- package/dist/generated/client/client.gen.d.ts.map +1 -0
- package/dist/generated/client/index.d.ts +9 -0
- package/dist/generated/client/index.d.ts.map +1 -0
- package/dist/generated/client/types.gen.d.ts +69 -0
- package/dist/generated/client/types.gen.d.ts.map +1 -0
- package/dist/generated/client/utils.gen.d.ts +31 -0
- package/dist/generated/client/utils.gen.d.ts.map +1 -0
- package/dist/generated/client.gen.d.ts +5 -0
- package/dist/generated/client.gen.d.ts.map +1 -0
- package/dist/generated/core/auth.gen.d.ts +9 -0
- package/dist/generated/core/auth.gen.d.ts.map +1 -0
- package/dist/generated/core/bodySerializer.gen.d.ts +22 -0
- package/dist/generated/core/bodySerializer.gen.d.ts.map +1 -0
- package/dist/generated/core/params.gen.d.ts +27 -0
- package/dist/generated/core/params.gen.d.ts.map +1 -0
- package/dist/generated/core/pathSerializer.gen.d.ts +31 -0
- package/dist/generated/core/pathSerializer.gen.d.ts.map +1 -0
- package/dist/generated/core/queryKeySerializer.gen.d.ts +7 -0
- package/dist/generated/core/queryKeySerializer.gen.d.ts.map +1 -0
- package/dist/generated/core/serverSentEvents.gen.d.ts +24 -0
- package/dist/generated/core/serverSentEvents.gen.d.ts.map +1 -0
- package/dist/generated/core/types.gen.d.ts +33 -0
- package/dist/generated/core/types.gen.d.ts.map +1 -0
- package/dist/generated/core/utils.gen.d.ts +20 -0
- package/dist/generated/core/utils.gen.d.ts.map +1 -0
- package/dist/generated/index.d.ts +3 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/sdk.gen.d.ts +79 -0
- package/dist/generated/sdk.gen.d.ts.map +1 -0
- package/dist/generated/types.gen.d.ts +2164 -0
- package/dist/generated/types.gen.d.ts.map +1 -0
- package/dist/index.cjs +2270 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +2263 -3
- package/dist/index.mjs.map +1 -1
- package/dist/revisium-client.d.ts +67 -2
- package/dist/revisium-client.d.ts.map +1 -1
- package/dist/revisium-scope.d.ts +76 -0
- package/dist/revisium-scope.d.ts.map +1 -0
- package/package.json +15 -3
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,2279 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) {
|
|
6
|
+
__defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (!no_symbols) {
|
|
12
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/generated/core/bodySerializer.gen.ts
|
|
19
|
+
const serializeFormDataPair = (data, key, value) => {
|
|
20
|
+
if (typeof value === "string" || value instanceof Blob) data.append(key, value);
|
|
21
|
+
else if (value instanceof Date) data.append(key, value.toISOString());
|
|
22
|
+
else data.append(key, JSON.stringify(value));
|
|
23
|
+
};
|
|
24
|
+
const formDataBodySerializer = { bodySerializer: (body) => {
|
|
25
|
+
const data = new FormData();
|
|
26
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
27
|
+
if (value === void 0 || value === null) return;
|
|
28
|
+
if (Array.isArray(value)) value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
29
|
+
else serializeFormDataPair(data, key, value);
|
|
30
|
+
});
|
|
31
|
+
return data;
|
|
32
|
+
} };
|
|
33
|
+
const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/generated/core/params.gen.ts
|
|
37
|
+
const extraPrefixes = Object.entries({
|
|
38
|
+
$body_: "body",
|
|
39
|
+
$headers_: "headers",
|
|
40
|
+
$path_: "path",
|
|
41
|
+
$query_: "query"
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/generated/core/serverSentEvents.gen.ts
|
|
46
|
+
const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
|
|
47
|
+
let lastEventId;
|
|
48
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
49
|
+
const createStream = async function* () {
|
|
50
|
+
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
51
|
+
let attempt = 0;
|
|
52
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
53
|
+
while (true) {
|
|
54
|
+
if (signal.aborted) break;
|
|
55
|
+
attempt++;
|
|
56
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
57
|
+
if (lastEventId !== void 0) headers.set("Last-Event-ID", lastEventId);
|
|
58
|
+
try {
|
|
59
|
+
const requestInit = {
|
|
60
|
+
redirect: "follow",
|
|
61
|
+
...options,
|
|
62
|
+
body: options.serializedBody,
|
|
63
|
+
headers,
|
|
64
|
+
signal
|
|
65
|
+
};
|
|
66
|
+
let request = new Request(url, requestInit);
|
|
67
|
+
if (onRequest) request = await onRequest(url, requestInit);
|
|
68
|
+
const response = await (options.fetch ?? globalThis.fetch)(request);
|
|
69
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
70
|
+
if (!response.body) throw new Error("No body in SSE response");
|
|
71
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
72
|
+
let buffer = "";
|
|
73
|
+
const abortHandler = () => {
|
|
74
|
+
try {
|
|
75
|
+
reader.cancel();
|
|
76
|
+
} catch {}
|
|
77
|
+
};
|
|
78
|
+
signal.addEventListener("abort", abortHandler);
|
|
79
|
+
try {
|
|
80
|
+
while (true) {
|
|
81
|
+
const { done, value } = await reader.read();
|
|
82
|
+
if (done) break;
|
|
83
|
+
buffer += value;
|
|
84
|
+
buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
85
|
+
const chunks = buffer.split("\n\n");
|
|
86
|
+
buffer = chunks.pop() ?? "";
|
|
87
|
+
for (const chunk of chunks) {
|
|
88
|
+
const lines = chunk.split("\n");
|
|
89
|
+
const dataLines = [];
|
|
90
|
+
let eventName;
|
|
91
|
+
for (const line of lines) if (line.startsWith("data:")) dataLines.push(line.replace(/^data:\s*/, ""));
|
|
92
|
+
else if (line.startsWith("event:")) eventName = line.replace(/^event:\s*/, "");
|
|
93
|
+
else if (line.startsWith("id:")) lastEventId = line.replace(/^id:\s*/, "");
|
|
94
|
+
else if (line.startsWith("retry:")) {
|
|
95
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
96
|
+
if (!Number.isNaN(parsed)) retryDelay = parsed;
|
|
97
|
+
}
|
|
98
|
+
let data;
|
|
99
|
+
let parsedJson = false;
|
|
100
|
+
if (dataLines.length) {
|
|
101
|
+
const rawData = dataLines.join("\n");
|
|
102
|
+
try {
|
|
103
|
+
data = JSON.parse(rawData);
|
|
104
|
+
parsedJson = true;
|
|
105
|
+
} catch {
|
|
106
|
+
data = rawData;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (parsedJson) {
|
|
110
|
+
if (responseValidator) await responseValidator(data);
|
|
111
|
+
if (responseTransformer) data = await responseTransformer(data);
|
|
112
|
+
}
|
|
113
|
+
onSseEvent?.({
|
|
114
|
+
data,
|
|
115
|
+
event: eventName,
|
|
116
|
+
id: lastEventId,
|
|
117
|
+
retry: retryDelay
|
|
118
|
+
});
|
|
119
|
+
if (dataLines.length) yield data;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
} finally {
|
|
123
|
+
signal.removeEventListener("abort", abortHandler);
|
|
124
|
+
reader.releaseLock();
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
} catch (error) {
|
|
128
|
+
onSseError?.(error);
|
|
129
|
+
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
|
|
130
|
+
await sleep(Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
return { stream: createStream() };
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/generated/core/pathSerializer.gen.ts
|
|
139
|
+
const separatorArrayExplode = (style) => {
|
|
140
|
+
switch (style) {
|
|
141
|
+
case "label": return ".";
|
|
142
|
+
case "matrix": return ";";
|
|
143
|
+
case "simple": return ",";
|
|
144
|
+
default: return "&";
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const separatorArrayNoExplode = (style) => {
|
|
148
|
+
switch (style) {
|
|
149
|
+
case "form": return ",";
|
|
150
|
+
case "pipeDelimited": return "|";
|
|
151
|
+
case "spaceDelimited": return "%20";
|
|
152
|
+
default: return ",";
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const separatorObjectExplode = (style) => {
|
|
156
|
+
switch (style) {
|
|
157
|
+
case "label": return ".";
|
|
158
|
+
case "matrix": return ";";
|
|
159
|
+
case "simple": return ",";
|
|
160
|
+
default: return "&";
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
|
|
164
|
+
if (!explode) {
|
|
165
|
+
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
166
|
+
switch (style) {
|
|
167
|
+
case "label": return `.${joinedValues}`;
|
|
168
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
169
|
+
case "simple": return joinedValues;
|
|
170
|
+
default: return `${name}=${joinedValues}`;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const separator = separatorArrayExplode(style);
|
|
174
|
+
const joinedValues = value.map((v) => {
|
|
175
|
+
if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v);
|
|
176
|
+
return serializePrimitiveParam({
|
|
177
|
+
allowReserved,
|
|
178
|
+
name,
|
|
179
|
+
value: v
|
|
180
|
+
});
|
|
181
|
+
}).join(separator);
|
|
182
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
183
|
+
};
|
|
184
|
+
const serializePrimitiveParam = ({ allowReserved, name, value }) => {
|
|
185
|
+
if (value === void 0 || value === null) return "";
|
|
186
|
+
if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
187
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
188
|
+
};
|
|
189
|
+
const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
|
|
190
|
+
if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
191
|
+
if (style !== "deepObject" && !explode) {
|
|
192
|
+
let values = [];
|
|
193
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
194
|
+
values = [
|
|
195
|
+
...values,
|
|
196
|
+
key,
|
|
197
|
+
allowReserved ? v : encodeURIComponent(v)
|
|
198
|
+
];
|
|
199
|
+
});
|
|
200
|
+
const joinedValues = values.join(",");
|
|
201
|
+
switch (style) {
|
|
202
|
+
case "form": return `${name}=${joinedValues}`;
|
|
203
|
+
case "label": return `.${joinedValues}`;
|
|
204
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
205
|
+
default: return joinedValues;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const separator = separatorObjectExplode(style);
|
|
209
|
+
const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
|
|
210
|
+
allowReserved,
|
|
211
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
212
|
+
value: v
|
|
213
|
+
})).join(separator);
|
|
214
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
//#endregion
|
|
218
|
+
//#region src/generated/core/utils.gen.ts
|
|
219
|
+
const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
220
|
+
const defaultPathSerializer = ({ path, url: _url }) => {
|
|
221
|
+
let url = _url;
|
|
222
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
223
|
+
if (matches) for (const match of matches) {
|
|
224
|
+
let explode = false;
|
|
225
|
+
let name = match.substring(1, match.length - 1);
|
|
226
|
+
let style = "simple";
|
|
227
|
+
if (name.endsWith("*")) {
|
|
228
|
+
explode = true;
|
|
229
|
+
name = name.substring(0, name.length - 1);
|
|
230
|
+
}
|
|
231
|
+
if (name.startsWith(".")) {
|
|
232
|
+
name = name.substring(1);
|
|
233
|
+
style = "label";
|
|
234
|
+
} else if (name.startsWith(";")) {
|
|
235
|
+
name = name.substring(1);
|
|
236
|
+
style = "matrix";
|
|
237
|
+
}
|
|
238
|
+
const value = path[name];
|
|
239
|
+
if (value === void 0 || value === null) continue;
|
|
240
|
+
if (Array.isArray(value)) {
|
|
241
|
+
url = url.replace(match, serializeArrayParam({
|
|
242
|
+
explode,
|
|
243
|
+
name,
|
|
244
|
+
style,
|
|
245
|
+
value
|
|
246
|
+
}));
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (typeof value === "object") {
|
|
250
|
+
url = url.replace(match, serializeObjectParam({
|
|
251
|
+
explode,
|
|
252
|
+
name,
|
|
253
|
+
style,
|
|
254
|
+
value,
|
|
255
|
+
valueOnly: true
|
|
256
|
+
}));
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
if (style === "matrix") {
|
|
260
|
+
url = url.replace(match, `;${serializePrimitiveParam({
|
|
261
|
+
name,
|
|
262
|
+
value
|
|
263
|
+
})}`);
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
267
|
+
url = url.replace(match, replaceValue);
|
|
268
|
+
}
|
|
269
|
+
return url;
|
|
270
|
+
};
|
|
271
|
+
const getUrl = ({ baseUrl, path, query, querySerializer, url: _url }) => {
|
|
272
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
273
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
274
|
+
if (path) url = defaultPathSerializer({
|
|
275
|
+
path,
|
|
276
|
+
url
|
|
277
|
+
});
|
|
278
|
+
let search = query ? querySerializer(query) : "";
|
|
279
|
+
if (search.startsWith("?")) search = search.substring(1);
|
|
280
|
+
if (search) url += `?${search}`;
|
|
281
|
+
return url;
|
|
282
|
+
};
|
|
283
|
+
function getValidRequestBody(options) {
|
|
284
|
+
const hasBody = options.body !== void 0;
|
|
285
|
+
if (hasBody && options.bodySerializer) {
|
|
286
|
+
if ("serializedBody" in options) return options.serializedBody !== void 0 && options.serializedBody !== "" ? options.serializedBody : null;
|
|
287
|
+
return options.body !== "" ? options.body : null;
|
|
288
|
+
}
|
|
289
|
+
if (hasBody) return options.body;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
//#endregion
|
|
293
|
+
//#region src/generated/core/auth.gen.ts
|
|
294
|
+
const getAuthToken = async (auth, callback) => {
|
|
295
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
296
|
+
if (!token) return;
|
|
297
|
+
if (auth.scheme === "bearer") return `Bearer ${token}`;
|
|
298
|
+
if (auth.scheme === "basic") return `Basic ${btoa(token)}`;
|
|
299
|
+
return token;
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/generated/client/utils.gen.ts
|
|
304
|
+
const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
305
|
+
const querySerializer = (queryParams) => {
|
|
306
|
+
const search = [];
|
|
307
|
+
if (queryParams && typeof queryParams === "object") for (const name in queryParams) {
|
|
308
|
+
const value = queryParams[name];
|
|
309
|
+
if (value === void 0 || value === null) continue;
|
|
310
|
+
const options = parameters[name] || args;
|
|
311
|
+
if (Array.isArray(value)) {
|
|
312
|
+
const serializedArray = serializeArrayParam({
|
|
313
|
+
allowReserved: options.allowReserved,
|
|
314
|
+
explode: true,
|
|
315
|
+
name,
|
|
316
|
+
style: "form",
|
|
317
|
+
value,
|
|
318
|
+
...options.array
|
|
319
|
+
});
|
|
320
|
+
if (serializedArray) search.push(serializedArray);
|
|
321
|
+
} else if (typeof value === "object") {
|
|
322
|
+
const serializedObject = serializeObjectParam({
|
|
323
|
+
allowReserved: options.allowReserved,
|
|
324
|
+
explode: true,
|
|
325
|
+
name,
|
|
326
|
+
style: "deepObject",
|
|
327
|
+
value,
|
|
328
|
+
...options.object
|
|
329
|
+
});
|
|
330
|
+
if (serializedObject) search.push(serializedObject);
|
|
331
|
+
} else {
|
|
332
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
333
|
+
allowReserved: options.allowReserved,
|
|
334
|
+
name,
|
|
335
|
+
value
|
|
336
|
+
});
|
|
337
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return search.join("&");
|
|
341
|
+
};
|
|
342
|
+
return querySerializer;
|
|
343
|
+
};
|
|
344
|
+
/**
|
|
345
|
+
* Infers parseAs value from provided Content-Type header.
|
|
346
|
+
*/
|
|
347
|
+
const getParseAs = (contentType) => {
|
|
348
|
+
if (!contentType) return "stream";
|
|
349
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
350
|
+
if (!cleanContent) return;
|
|
351
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) return "json";
|
|
352
|
+
if (cleanContent === "multipart/form-data") return "formData";
|
|
353
|
+
if ([
|
|
354
|
+
"application/",
|
|
355
|
+
"audio/",
|
|
356
|
+
"image/",
|
|
357
|
+
"video/"
|
|
358
|
+
].some((type) => cleanContent.startsWith(type))) return "blob";
|
|
359
|
+
if (cleanContent.startsWith("text/")) return "text";
|
|
360
|
+
};
|
|
361
|
+
const checkForExistence = (options, name) => {
|
|
362
|
+
if (!name) return false;
|
|
363
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) return true;
|
|
364
|
+
return false;
|
|
365
|
+
};
|
|
366
|
+
const setAuthParams = async ({ security, ...options }) => {
|
|
367
|
+
for (const auth of security) {
|
|
368
|
+
if (checkForExistence(options, auth.name)) continue;
|
|
369
|
+
const token = await getAuthToken(auth, options.auth);
|
|
370
|
+
if (!token) continue;
|
|
371
|
+
const name = auth.name ?? "Authorization";
|
|
372
|
+
switch (auth.in) {
|
|
373
|
+
case "query":
|
|
374
|
+
if (!options.query) options.query = {};
|
|
375
|
+
options.query[name] = token;
|
|
376
|
+
break;
|
|
377
|
+
case "cookie":
|
|
378
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
379
|
+
break;
|
|
380
|
+
default:
|
|
381
|
+
options.headers.set(name, token);
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
const buildUrl = (options) => getUrl({
|
|
387
|
+
baseUrl: options.baseUrl,
|
|
388
|
+
path: options.path,
|
|
389
|
+
query: options.query,
|
|
390
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
391
|
+
url: options.url
|
|
392
|
+
});
|
|
393
|
+
const mergeConfigs = (a, b) => {
|
|
394
|
+
const config = {
|
|
395
|
+
...a,
|
|
396
|
+
...b
|
|
397
|
+
};
|
|
398
|
+
if (config.baseUrl?.endsWith("/")) config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
399
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
400
|
+
return config;
|
|
401
|
+
};
|
|
402
|
+
const headersEntries = (headers) => {
|
|
403
|
+
const entries = [];
|
|
404
|
+
headers.forEach((value, key) => {
|
|
405
|
+
entries.push([key, value]);
|
|
406
|
+
});
|
|
407
|
+
return entries;
|
|
408
|
+
};
|
|
409
|
+
const mergeHeaders = (...headers) => {
|
|
410
|
+
const mergedHeaders = new Headers();
|
|
411
|
+
for (const header of headers) {
|
|
412
|
+
if (!header) continue;
|
|
413
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
414
|
+
for (const [key, value] of iterator) if (value === null) mergedHeaders.delete(key);
|
|
415
|
+
else if (Array.isArray(value)) for (const v of value) mergedHeaders.append(key, v);
|
|
416
|
+
else if (value !== void 0) mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
417
|
+
}
|
|
418
|
+
return mergedHeaders;
|
|
419
|
+
};
|
|
420
|
+
var Interceptors = class {
|
|
421
|
+
fns = [];
|
|
422
|
+
clear() {
|
|
423
|
+
this.fns = [];
|
|
424
|
+
}
|
|
425
|
+
eject(id) {
|
|
426
|
+
const index = this.getInterceptorIndex(id);
|
|
427
|
+
if (this.fns[index]) this.fns[index] = null;
|
|
428
|
+
}
|
|
429
|
+
exists(id) {
|
|
430
|
+
const index = this.getInterceptorIndex(id);
|
|
431
|
+
return Boolean(this.fns[index]);
|
|
432
|
+
}
|
|
433
|
+
getInterceptorIndex(id) {
|
|
434
|
+
if (typeof id === "number") return this.fns[id] ? id : -1;
|
|
435
|
+
return this.fns.indexOf(id);
|
|
436
|
+
}
|
|
437
|
+
update(id, fn) {
|
|
438
|
+
const index = this.getInterceptorIndex(id);
|
|
439
|
+
if (this.fns[index]) {
|
|
440
|
+
this.fns[index] = fn;
|
|
441
|
+
return id;
|
|
442
|
+
}
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
445
|
+
use(fn) {
|
|
446
|
+
this.fns.push(fn);
|
|
447
|
+
return this.fns.length - 1;
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
const createInterceptors = () => ({
|
|
451
|
+
error: new Interceptors(),
|
|
452
|
+
request: new Interceptors(),
|
|
453
|
+
response: new Interceptors()
|
|
454
|
+
});
|
|
455
|
+
const defaultQuerySerializer = createQuerySerializer({
|
|
456
|
+
allowReserved: false,
|
|
457
|
+
array: {
|
|
458
|
+
explode: true,
|
|
459
|
+
style: "form"
|
|
460
|
+
},
|
|
461
|
+
object: {
|
|
462
|
+
explode: true,
|
|
463
|
+
style: "deepObject"
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
const defaultHeaders = { "Content-Type": "application/json" };
|
|
467
|
+
const createConfig = (override = {}) => ({
|
|
468
|
+
...jsonBodySerializer,
|
|
469
|
+
headers: defaultHeaders,
|
|
470
|
+
parseAs: "auto",
|
|
471
|
+
querySerializer: defaultQuerySerializer,
|
|
472
|
+
...override
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region src/generated/client/client.gen.ts
|
|
477
|
+
const createClient = (config = {}) => {
|
|
478
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
479
|
+
const getConfig = () => ({ ..._config });
|
|
480
|
+
const setConfig = (config) => {
|
|
481
|
+
_config = mergeConfigs(_config, config);
|
|
482
|
+
return getConfig();
|
|
483
|
+
};
|
|
484
|
+
const interceptors = createInterceptors();
|
|
485
|
+
const beforeRequest = async (options) => {
|
|
486
|
+
const opts = {
|
|
487
|
+
..._config,
|
|
488
|
+
...options,
|
|
489
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
490
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
491
|
+
serializedBody: void 0
|
|
492
|
+
};
|
|
493
|
+
if (opts.security) await setAuthParams({
|
|
494
|
+
...opts,
|
|
495
|
+
security: opts.security
|
|
496
|
+
});
|
|
497
|
+
if (opts.requestValidator) await opts.requestValidator(opts);
|
|
498
|
+
if (opts.body !== void 0 && opts.bodySerializer) opts.serializedBody = opts.bodySerializer(opts.body);
|
|
499
|
+
if (opts.body === void 0 || opts.serializedBody === "") opts.headers.delete("Content-Type");
|
|
500
|
+
return {
|
|
501
|
+
opts,
|
|
502
|
+
url: buildUrl(opts)
|
|
503
|
+
};
|
|
504
|
+
};
|
|
505
|
+
const request = async (options) => {
|
|
506
|
+
const { opts, url } = await beforeRequest(options);
|
|
507
|
+
const requestInit = {
|
|
508
|
+
redirect: "follow",
|
|
509
|
+
...opts,
|
|
510
|
+
body: getValidRequestBody(opts)
|
|
511
|
+
};
|
|
512
|
+
let request = new Request(url, requestInit);
|
|
513
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
514
|
+
const _fetch = opts.fetch;
|
|
515
|
+
let response;
|
|
516
|
+
try {
|
|
517
|
+
response = await _fetch(request);
|
|
518
|
+
} catch (error) {
|
|
519
|
+
let finalError = error;
|
|
520
|
+
for (const fn of interceptors.error.fns) if (fn) finalError = await fn(error, void 0, request, opts);
|
|
521
|
+
finalError = finalError || {};
|
|
522
|
+
if (opts.throwOnError) throw finalError;
|
|
523
|
+
return opts.responseStyle === "data" ? void 0 : {
|
|
524
|
+
error: finalError,
|
|
525
|
+
request,
|
|
526
|
+
response: void 0
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request, opts);
|
|
530
|
+
const result = {
|
|
531
|
+
request,
|
|
532
|
+
response
|
|
533
|
+
};
|
|
534
|
+
if (response.ok) {
|
|
535
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
536
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
537
|
+
let emptyData;
|
|
538
|
+
switch (parseAs) {
|
|
539
|
+
case "arrayBuffer":
|
|
540
|
+
case "blob":
|
|
541
|
+
case "text":
|
|
542
|
+
emptyData = await response[parseAs]();
|
|
543
|
+
break;
|
|
544
|
+
case "formData":
|
|
545
|
+
emptyData = new FormData();
|
|
546
|
+
break;
|
|
547
|
+
case "stream":
|
|
548
|
+
emptyData = response.body;
|
|
549
|
+
break;
|
|
550
|
+
default:
|
|
551
|
+
emptyData = {};
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
555
|
+
data: emptyData,
|
|
556
|
+
...result
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
let data;
|
|
560
|
+
switch (parseAs) {
|
|
561
|
+
case "arrayBuffer":
|
|
562
|
+
case "blob":
|
|
563
|
+
case "formData":
|
|
564
|
+
case "text":
|
|
565
|
+
data = await response[parseAs]();
|
|
566
|
+
break;
|
|
567
|
+
case "json": {
|
|
568
|
+
const text = await response.text();
|
|
569
|
+
data = text ? JSON.parse(text) : {};
|
|
570
|
+
break;
|
|
571
|
+
}
|
|
572
|
+
case "stream": return opts.responseStyle === "data" ? response.body : {
|
|
573
|
+
data: response.body,
|
|
574
|
+
...result
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
if (parseAs === "json") {
|
|
578
|
+
if (opts.responseValidator) await opts.responseValidator(data);
|
|
579
|
+
if (opts.responseTransformer) data = await opts.responseTransformer(data);
|
|
580
|
+
}
|
|
581
|
+
return opts.responseStyle === "data" ? data : {
|
|
582
|
+
data,
|
|
583
|
+
...result
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
const textError = await response.text();
|
|
587
|
+
let jsonError;
|
|
588
|
+
try {
|
|
589
|
+
jsonError = JSON.parse(textError);
|
|
590
|
+
} catch {}
|
|
591
|
+
const error = jsonError ?? textError;
|
|
592
|
+
let finalError = error;
|
|
593
|
+
for (const fn of interceptors.error.fns) if (fn) finalError = await fn(error, response, request, opts);
|
|
594
|
+
finalError = finalError || {};
|
|
595
|
+
if (opts.throwOnError) throw finalError;
|
|
596
|
+
return opts.responseStyle === "data" ? void 0 : {
|
|
597
|
+
error: finalError,
|
|
598
|
+
...result
|
|
599
|
+
};
|
|
600
|
+
};
|
|
601
|
+
const makeMethodFn = (method) => (options) => request({
|
|
602
|
+
...options,
|
|
603
|
+
method
|
|
604
|
+
});
|
|
605
|
+
const makeSseFn = (method) => async (options) => {
|
|
606
|
+
const { opts, url } = await beforeRequest(options);
|
|
607
|
+
return createSseClient({
|
|
608
|
+
...opts,
|
|
609
|
+
body: opts.body,
|
|
610
|
+
headers: opts.headers,
|
|
611
|
+
method,
|
|
612
|
+
onRequest: async (url, init) => {
|
|
613
|
+
let request = new Request(url, init);
|
|
614
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
615
|
+
return request;
|
|
616
|
+
},
|
|
617
|
+
serializedBody: getValidRequestBody(opts),
|
|
618
|
+
url
|
|
619
|
+
});
|
|
620
|
+
};
|
|
621
|
+
return {
|
|
622
|
+
buildUrl,
|
|
623
|
+
connect: makeMethodFn("CONNECT"),
|
|
624
|
+
delete: makeMethodFn("DELETE"),
|
|
625
|
+
get: makeMethodFn("GET"),
|
|
626
|
+
getConfig,
|
|
627
|
+
head: makeMethodFn("HEAD"),
|
|
628
|
+
interceptors,
|
|
629
|
+
options: makeMethodFn("OPTIONS"),
|
|
630
|
+
patch: makeMethodFn("PATCH"),
|
|
631
|
+
post: makeMethodFn("POST"),
|
|
632
|
+
put: makeMethodFn("PUT"),
|
|
633
|
+
request,
|
|
634
|
+
setConfig,
|
|
635
|
+
sse: {
|
|
636
|
+
connect: makeSseFn("CONNECT"),
|
|
637
|
+
delete: makeSseFn("DELETE"),
|
|
638
|
+
get: makeSseFn("GET"),
|
|
639
|
+
head: makeSseFn("HEAD"),
|
|
640
|
+
options: makeSseFn("OPTIONS"),
|
|
641
|
+
patch: makeSseFn("PATCH"),
|
|
642
|
+
post: makeSseFn("POST"),
|
|
643
|
+
put: makeSseFn("PUT"),
|
|
644
|
+
trace: makeSseFn("TRACE")
|
|
645
|
+
},
|
|
646
|
+
trace: makeMethodFn("TRACE")
|
|
647
|
+
};
|
|
648
|
+
};
|
|
649
|
+
|
|
650
|
+
//#endregion
|
|
651
|
+
//#region src/generated/client.gen.ts
|
|
652
|
+
const client = createClient(createConfig());
|
|
653
|
+
|
|
654
|
+
//#endregion
|
|
655
|
+
//#region src/generated/sdk.gen.ts
|
|
656
|
+
var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
657
|
+
addUserToOrganization: () => addUserToOrganization,
|
|
658
|
+
addUserToProject: () => addUserToProject,
|
|
659
|
+
applyMigrations: () => applyMigrations,
|
|
660
|
+
branch: () => branch,
|
|
661
|
+
branchTouched: () => branchTouched,
|
|
662
|
+
branches: () => branches,
|
|
663
|
+
childBranches: () => childBranches,
|
|
664
|
+
childRevision: () => childRevision,
|
|
665
|
+
createBranch: () => createBranch,
|
|
666
|
+
createEndpoint: () => createEndpoint,
|
|
667
|
+
createProject: () => createProject,
|
|
668
|
+
createRevision: () => createRevision,
|
|
669
|
+
createRow: () => createRow$1,
|
|
670
|
+
createRows: () => createRows$1,
|
|
671
|
+
createTable: () => createTable$1,
|
|
672
|
+
createUser: () => createUser,
|
|
673
|
+
deleteBranch: () => deleteBranch,
|
|
674
|
+
deleteEndpoint: () => deleteEndpoint,
|
|
675
|
+
deleteProject: () => deleteProject,
|
|
676
|
+
deleteRow: () => deleteRow$1,
|
|
677
|
+
deleteRows: () => deleteRows$1,
|
|
678
|
+
deleteTable: () => deleteTable$1,
|
|
679
|
+
draftRevision: () => draftRevision,
|
|
680
|
+
endpointRelatives: () => endpointRelatives,
|
|
681
|
+
endpoints: () => endpoints,
|
|
682
|
+
getConfiguration: () => getConfiguration,
|
|
683
|
+
headRevision: () => headRevision,
|
|
684
|
+
liveness: () => liveness,
|
|
685
|
+
login: () => login,
|
|
686
|
+
me: () => me,
|
|
687
|
+
migrations: () => migrations,
|
|
688
|
+
parentBranch: () => parentBranch,
|
|
689
|
+
parentRevision: () => parentRevision,
|
|
690
|
+
patchRow: () => patchRow$1,
|
|
691
|
+
patchRows: () => patchRows,
|
|
692
|
+
project: () => project,
|
|
693
|
+
projects: () => projects,
|
|
694
|
+
readiness: () => readiness,
|
|
695
|
+
removeUserFromOrganization: () => removeUserFromOrganization,
|
|
696
|
+
removeUserFromProject: () => removeUserFromProject,
|
|
697
|
+
renameRow: () => renameRow$1,
|
|
698
|
+
renameTable: () => renameTable$1,
|
|
699
|
+
revertChanges: () => revertChanges$1,
|
|
700
|
+
revision: () => revision,
|
|
701
|
+
revisionChanges: () => revisionChanges,
|
|
702
|
+
revisions: () => revisions,
|
|
703
|
+
rootBranch: () => rootBranch,
|
|
704
|
+
row: () => row,
|
|
705
|
+
rowChanges: () => rowChanges,
|
|
706
|
+
rowCountForeignKeysBy: () => rowCountForeignKeysBy,
|
|
707
|
+
rowCountForeignKeysTo: () => rowCountForeignKeysTo,
|
|
708
|
+
rowForeignKeysBy: () => rowForeignKeysBy,
|
|
709
|
+
rowForeignKeysTo: () => rowForeignKeysTo,
|
|
710
|
+
rows: () => rows,
|
|
711
|
+
startRevision: () => startRevision,
|
|
712
|
+
table: () => table,
|
|
713
|
+
tableChanges: () => tableChanges,
|
|
714
|
+
tableCountForeignKeysBy: () => tableCountForeignKeysBy,
|
|
715
|
+
tableCountForeignKeysTo: () => tableCountForeignKeysTo,
|
|
716
|
+
tableCountRows: () => tableCountRows,
|
|
717
|
+
tableForeignKeysBy: () => tableForeignKeysBy,
|
|
718
|
+
tableForeignKeysTo: () => tableForeignKeysTo,
|
|
719
|
+
tableSchema: () => tableSchema,
|
|
720
|
+
tables: () => tables,
|
|
721
|
+
updatePassword: () => updatePassword,
|
|
722
|
+
updateProject: () => updateProject,
|
|
723
|
+
updateRow: () => updateRow$1,
|
|
724
|
+
updateRows: () => updateRows$1,
|
|
725
|
+
updateTable: () => updateTable$1,
|
|
726
|
+
uploadFile: () => uploadFile,
|
|
727
|
+
usersOrganization: () => usersOrganization,
|
|
728
|
+
usersProject: () => usersProject
|
|
729
|
+
});
|
|
730
|
+
/**
|
|
731
|
+
* Authenticate and get access token
|
|
732
|
+
*/
|
|
733
|
+
const login = (options) => (options.client ?? client).post({
|
|
734
|
+
security: [{
|
|
735
|
+
scheme: "bearer",
|
|
736
|
+
type: "http"
|
|
737
|
+
}],
|
|
738
|
+
url: "/api/auth/login",
|
|
739
|
+
...options,
|
|
740
|
+
headers: {
|
|
741
|
+
"Content-Type": "application/json",
|
|
742
|
+
...options.headers
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
/**
|
|
746
|
+
* Create a new user (admin only)
|
|
747
|
+
*/
|
|
748
|
+
const createUser = (options) => (options.client ?? client).post({
|
|
749
|
+
security: [{
|
|
750
|
+
scheme: "bearer",
|
|
751
|
+
type: "http"
|
|
752
|
+
}],
|
|
753
|
+
url: "/api/auth/user",
|
|
754
|
+
...options,
|
|
755
|
+
headers: {
|
|
756
|
+
"Content-Type": "application/json",
|
|
757
|
+
...options.headers
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
/**
|
|
761
|
+
* Update your password
|
|
762
|
+
*/
|
|
763
|
+
const updatePassword = (options) => (options.client ?? client).put({
|
|
764
|
+
security: [{
|
|
765
|
+
scheme: "bearer",
|
|
766
|
+
type: "http"
|
|
767
|
+
}],
|
|
768
|
+
url: "/api/auth/password",
|
|
769
|
+
...options,
|
|
770
|
+
headers: {
|
|
771
|
+
"Content-Type": "application/json",
|
|
772
|
+
...options.headers
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
/**
|
|
776
|
+
* Get current authenticated user
|
|
777
|
+
*/
|
|
778
|
+
const me = (options) => (options?.client ?? client).get({
|
|
779
|
+
security: [{
|
|
780
|
+
scheme: "bearer",
|
|
781
|
+
type: "http"
|
|
782
|
+
}],
|
|
783
|
+
url: "/api/user/me",
|
|
784
|
+
...options
|
|
785
|
+
});
|
|
786
|
+
/**
|
|
787
|
+
* List projects in organization
|
|
788
|
+
*/
|
|
789
|
+
const projects = (options) => (options.client ?? client).get({
|
|
790
|
+
security: [{
|
|
791
|
+
scheme: "bearer",
|
|
792
|
+
type: "http"
|
|
793
|
+
}],
|
|
794
|
+
url: "/api/organization/{organizationId}/projects",
|
|
795
|
+
...options
|
|
796
|
+
});
|
|
797
|
+
/**
|
|
798
|
+
* Create a new project
|
|
799
|
+
*/
|
|
800
|
+
const createProject = (options) => (options.client ?? client).post({
|
|
801
|
+
security: [{
|
|
802
|
+
scheme: "bearer",
|
|
803
|
+
type: "http"
|
|
804
|
+
}],
|
|
805
|
+
url: "/api/organization/{organizationId}/projects",
|
|
806
|
+
...options,
|
|
807
|
+
headers: {
|
|
808
|
+
"Content-Type": "application/json",
|
|
809
|
+
...options.headers
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
/**
|
|
813
|
+
* Remove a user from the organization
|
|
814
|
+
*/
|
|
815
|
+
const removeUserFromOrganization = (options) => (options.client ?? client).delete({
|
|
816
|
+
security: [{
|
|
817
|
+
scheme: "bearer",
|
|
818
|
+
type: "http"
|
|
819
|
+
}],
|
|
820
|
+
url: "/api/organization/{organizationId}/users",
|
|
821
|
+
...options,
|
|
822
|
+
headers: {
|
|
823
|
+
"Content-Type": "application/json",
|
|
824
|
+
...options.headers
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
/**
|
|
828
|
+
* List users in organization
|
|
829
|
+
*/
|
|
830
|
+
const usersOrganization = (options) => (options.client ?? client).get({
|
|
831
|
+
security: [{
|
|
832
|
+
scheme: "bearer",
|
|
833
|
+
type: "http"
|
|
834
|
+
}],
|
|
835
|
+
url: "/api/organization/{organizationId}/users",
|
|
836
|
+
...options
|
|
837
|
+
});
|
|
838
|
+
/**
|
|
839
|
+
* Add a user to the organization
|
|
840
|
+
*/
|
|
841
|
+
const addUserToOrganization = (options) => (options.client ?? client).post({
|
|
842
|
+
security: [{
|
|
843
|
+
scheme: "bearer",
|
|
844
|
+
type: "http"
|
|
845
|
+
}],
|
|
846
|
+
url: "/api/organization/{organizationId}/users",
|
|
847
|
+
...options,
|
|
848
|
+
headers: {
|
|
849
|
+
"Content-Type": "application/json",
|
|
850
|
+
...options.headers
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
/**
|
|
854
|
+
* Delete a project
|
|
855
|
+
*/
|
|
856
|
+
const deleteProject = (options) => (options.client ?? client).delete({
|
|
857
|
+
security: [{
|
|
858
|
+
scheme: "bearer",
|
|
859
|
+
type: "http"
|
|
860
|
+
}],
|
|
861
|
+
url: "/api/organization/{organizationId}/projects/{projectName}",
|
|
862
|
+
...options
|
|
863
|
+
});
|
|
864
|
+
/**
|
|
865
|
+
* Get project by name
|
|
866
|
+
*/
|
|
867
|
+
const project = (options) => (options.client ?? client).get({
|
|
868
|
+
security: [{
|
|
869
|
+
scheme: "bearer",
|
|
870
|
+
type: "http"
|
|
871
|
+
}],
|
|
872
|
+
url: "/api/organization/{organizationId}/projects/{projectName}",
|
|
873
|
+
...options
|
|
874
|
+
});
|
|
875
|
+
/**
|
|
876
|
+
* Update project settings
|
|
877
|
+
*/
|
|
878
|
+
const updateProject = (options) => (options.client ?? client).put({
|
|
879
|
+
security: [{
|
|
880
|
+
scheme: "bearer",
|
|
881
|
+
type: "http"
|
|
882
|
+
}],
|
|
883
|
+
url: "/api/organization/{organizationId}/projects/{projectName}",
|
|
884
|
+
...options,
|
|
885
|
+
headers: {
|
|
886
|
+
"Content-Type": "application/json",
|
|
887
|
+
...options.headers
|
|
888
|
+
}
|
|
889
|
+
});
|
|
890
|
+
/**
|
|
891
|
+
* Get root branch of the project
|
|
892
|
+
*/
|
|
893
|
+
const rootBranch = (options) => (options.client ?? client).get({
|
|
894
|
+
security: [{
|
|
895
|
+
scheme: "bearer",
|
|
896
|
+
type: "http"
|
|
897
|
+
}],
|
|
898
|
+
url: "/api/organization/{organizationId}/projects/{projectName}/root-branch",
|
|
899
|
+
...options
|
|
900
|
+
});
|
|
901
|
+
/**
|
|
902
|
+
* List all branches in the project
|
|
903
|
+
*/
|
|
904
|
+
const branches = (options) => (options.client ?? client).get({
|
|
905
|
+
security: [{
|
|
906
|
+
scheme: "bearer",
|
|
907
|
+
type: "http"
|
|
908
|
+
}],
|
|
909
|
+
url: "/api/organization/{organizationId}/projects/{projectName}/branches",
|
|
910
|
+
...options
|
|
911
|
+
});
|
|
912
|
+
/**
|
|
913
|
+
* List users with access to the project
|
|
914
|
+
*/
|
|
915
|
+
const usersProject = (options) => (options.client ?? client).get({
|
|
916
|
+
security: [{
|
|
917
|
+
scheme: "bearer",
|
|
918
|
+
type: "http"
|
|
919
|
+
}],
|
|
920
|
+
url: "/api/organization/{organizationId}/projects/{projectName}/users",
|
|
921
|
+
...options
|
|
922
|
+
});
|
|
923
|
+
/**
|
|
924
|
+
* Add a user to the project
|
|
925
|
+
*/
|
|
926
|
+
const addUserToProject = (options) => (options.client ?? client).post({
|
|
927
|
+
security: [{
|
|
928
|
+
scheme: "bearer",
|
|
929
|
+
type: "http"
|
|
930
|
+
}],
|
|
931
|
+
url: "/api/organization/{organizationId}/projects/{projectName}/users",
|
|
932
|
+
...options,
|
|
933
|
+
headers: {
|
|
934
|
+
"Content-Type": "application/json",
|
|
935
|
+
...options.headers
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
/**
|
|
939
|
+
* Remove a user from the project
|
|
940
|
+
*/
|
|
941
|
+
const removeUserFromProject = (options) => (options.client ?? client).delete({
|
|
942
|
+
security: [{
|
|
943
|
+
scheme: "bearer",
|
|
944
|
+
type: "http"
|
|
945
|
+
}],
|
|
946
|
+
url: "/api/organization/{organizationId}/projects/{projectName}/users/{userId}",
|
|
947
|
+
...options
|
|
948
|
+
});
|
|
949
|
+
/**
|
|
950
|
+
* Delete a non-root branch
|
|
951
|
+
*/
|
|
952
|
+
const deleteBranch = (options) => (options.client ?? client).delete({
|
|
953
|
+
security: [{
|
|
954
|
+
scheme: "bearer",
|
|
955
|
+
type: "http"
|
|
956
|
+
}],
|
|
957
|
+
url: "/api/organization/{organizationId}/projects/{projectName}/branches/{branchName}",
|
|
958
|
+
...options
|
|
959
|
+
});
|
|
960
|
+
/**
|
|
961
|
+
* Get branch by name
|
|
962
|
+
*/
|
|
963
|
+
const branch = (options) => (options.client ?? client).get({
|
|
964
|
+
security: [{
|
|
965
|
+
scheme: "bearer",
|
|
966
|
+
type: "http"
|
|
967
|
+
}],
|
|
968
|
+
url: "/api/organization/{organizationId}/projects/{projectName}/branches/{branchName}",
|
|
969
|
+
...options
|
|
970
|
+
});
|
|
971
|
+
/**
|
|
972
|
+
* Check if branch has uncommitted changes
|
|
973
|
+
*/
|
|
974
|
+
const branchTouched = (options) => (options.client ?? client).get({
|
|
975
|
+
security: [{
|
|
976
|
+
scheme: "bearer",
|
|
977
|
+
type: "http"
|
|
978
|
+
}],
|
|
979
|
+
url: "/api/organization/{organizationId}/projects/{projectName}/branches/{branchName}/touched",
|
|
980
|
+
...options
|
|
981
|
+
});
|
|
982
|
+
/**
|
|
983
|
+
* Get parent branch (if created from another branch)
|
|
984
|
+
*/
|
|
985
|
+
const parentBranch = (options) => (options.client ?? client).get({
|
|
986
|
+
security: [{
|
|
987
|
+
scheme: "bearer",
|
|
988
|
+
type: "http"
|
|
989
|
+
}],
|
|
990
|
+
url: "/api/organization/{organizationId}/projects/{projectName}/branches/{branchName}/parent-branch",
|
|
991
|
+
...options
|
|
992
|
+
});
|
|
993
|
+
/**
|
|
994
|
+
* Get the first revision of the branch
|
|
995
|
+
*/
|
|
996
|
+
const startRevision = (options) => (options.client ?? client).get({
|
|
997
|
+
security: [{
|
|
998
|
+
scheme: "bearer",
|
|
999
|
+
type: "http"
|
|
1000
|
+
}],
|
|
1001
|
+
url: "/api/organization/{organizationId}/projects/{projectName}/branches/{branchName}/start-revision",
|
|
1002
|
+
...options
|
|
1003
|
+
});
|
|
1004
|
+
/**
|
|
1005
|
+
* Get the latest committed revision
|
|
1006
|
+
*/
|
|
1007
|
+
const headRevision = (options) => (options.client ?? client).get({
|
|
1008
|
+
security: [{
|
|
1009
|
+
scheme: "bearer",
|
|
1010
|
+
type: "http"
|
|
1011
|
+
}],
|
|
1012
|
+
url: "/api/organization/{organizationId}/projects/{projectName}/branches/{branchName}/head-revision",
|
|
1013
|
+
...options
|
|
1014
|
+
});
|
|
1015
|
+
/**
|
|
1016
|
+
* Get the draft (working) revision for modifications
|
|
1017
|
+
*/
|
|
1018
|
+
const draftRevision = (options) => (options.client ?? client).get({
|
|
1019
|
+
security: [{
|
|
1020
|
+
scheme: "bearer",
|
|
1021
|
+
type: "http"
|
|
1022
|
+
}],
|
|
1023
|
+
url: "/api/organization/{organizationId}/projects/{projectName}/branches/{branchName}/draft-revision",
|
|
1024
|
+
...options
|
|
1025
|
+
});
|
|
1026
|
+
/**
|
|
1027
|
+
* List all revisions in the branch
|
|
1028
|
+
*/
|
|
1029
|
+
const revisions = (options) => (options.client ?? client).get({
|
|
1030
|
+
security: [{
|
|
1031
|
+
scheme: "bearer",
|
|
1032
|
+
type: "http"
|
|
1033
|
+
}],
|
|
1034
|
+
url: "/api/organization/{organizationId}/projects/{projectName}/branches/{branchName}/revisions",
|
|
1035
|
+
...options
|
|
1036
|
+
});
|
|
1037
|
+
/**
|
|
1038
|
+
* Commit changes and create a new revision
|
|
1039
|
+
*/
|
|
1040
|
+
const createRevision = (options) => (options.client ?? client).post({
|
|
1041
|
+
security: [{
|
|
1042
|
+
scheme: "bearer",
|
|
1043
|
+
type: "http"
|
|
1044
|
+
}],
|
|
1045
|
+
url: "/api/organization/{organizationId}/projects/{projectName}/branches/{branchName}/create-revision",
|
|
1046
|
+
...options,
|
|
1047
|
+
headers: {
|
|
1048
|
+
"Content-Type": "application/json",
|
|
1049
|
+
...options.headers
|
|
1050
|
+
}
|
|
1051
|
+
});
|
|
1052
|
+
/**
|
|
1053
|
+
* Discard all uncommitted changes
|
|
1054
|
+
*/
|
|
1055
|
+
const revertChanges$1 = (options) => (options.client ?? client).post({
|
|
1056
|
+
security: [{
|
|
1057
|
+
scheme: "bearer",
|
|
1058
|
+
type: "http"
|
|
1059
|
+
}],
|
|
1060
|
+
url: "/api/organization/{organizationId}/projects/{projectName}/branches/{branchName}/revert-changes",
|
|
1061
|
+
...options
|
|
1062
|
+
});
|
|
1063
|
+
/**
|
|
1064
|
+
* Get revision by ID
|
|
1065
|
+
*/
|
|
1066
|
+
const revision = (options) => (options.client ?? client).get({
|
|
1067
|
+
security: [{
|
|
1068
|
+
scheme: "bearer",
|
|
1069
|
+
type: "http"
|
|
1070
|
+
}],
|
|
1071
|
+
url: "/api/revision/{revisionId}",
|
|
1072
|
+
...options
|
|
1073
|
+
});
|
|
1074
|
+
/**
|
|
1075
|
+
* Get parent revision
|
|
1076
|
+
*/
|
|
1077
|
+
const parentRevision = (options) => (options.client ?? client).get({
|
|
1078
|
+
security: [{
|
|
1079
|
+
scheme: "bearer",
|
|
1080
|
+
type: "http"
|
|
1081
|
+
}],
|
|
1082
|
+
url: "/api/revision/{revisionId}/parent-revision",
|
|
1083
|
+
...options
|
|
1084
|
+
});
|
|
1085
|
+
/**
|
|
1086
|
+
* Get child revision
|
|
1087
|
+
*/
|
|
1088
|
+
const childRevision = (options) => (options.client ?? client).get({
|
|
1089
|
+
security: [{
|
|
1090
|
+
scheme: "bearer",
|
|
1091
|
+
type: "http"
|
|
1092
|
+
}],
|
|
1093
|
+
url: "/api/revision/{revisionId}/child-revision",
|
|
1094
|
+
...options
|
|
1095
|
+
});
|
|
1096
|
+
/**
|
|
1097
|
+
* List branches created from this revision
|
|
1098
|
+
*/
|
|
1099
|
+
const childBranches = (options) => (options.client ?? client).get({
|
|
1100
|
+
security: [{
|
|
1101
|
+
scheme: "bearer",
|
|
1102
|
+
type: "http"
|
|
1103
|
+
}],
|
|
1104
|
+
url: "/api/revision/{revisionId}/child-branches",
|
|
1105
|
+
...options
|
|
1106
|
+
});
|
|
1107
|
+
/**
|
|
1108
|
+
* Create a new branch from this revision
|
|
1109
|
+
*/
|
|
1110
|
+
const createBranch = (options) => (options.client ?? client).post({
|
|
1111
|
+
security: [{
|
|
1112
|
+
scheme: "bearer",
|
|
1113
|
+
type: "http"
|
|
1114
|
+
}],
|
|
1115
|
+
url: "/api/revision/{revisionId}/child-branches",
|
|
1116
|
+
...options,
|
|
1117
|
+
headers: {
|
|
1118
|
+
"Content-Type": "application/json",
|
|
1119
|
+
...options.headers
|
|
1120
|
+
}
|
|
1121
|
+
});
|
|
1122
|
+
/**
|
|
1123
|
+
* List tables in revision
|
|
1124
|
+
*/
|
|
1125
|
+
const tables = (options) => (options.client ?? client).get({
|
|
1126
|
+
security: [{
|
|
1127
|
+
scheme: "bearer",
|
|
1128
|
+
type: "http"
|
|
1129
|
+
}],
|
|
1130
|
+
url: "/api/revision/{revisionId}/tables",
|
|
1131
|
+
...options
|
|
1132
|
+
});
|
|
1133
|
+
/**
|
|
1134
|
+
* Create a new table
|
|
1135
|
+
*/
|
|
1136
|
+
const createTable$1 = (options) => (options.client ?? client).post({
|
|
1137
|
+
security: [{
|
|
1138
|
+
scheme: "bearer",
|
|
1139
|
+
type: "http"
|
|
1140
|
+
}],
|
|
1141
|
+
url: "/api/revision/{revisionId}/tables",
|
|
1142
|
+
...options,
|
|
1143
|
+
headers: {
|
|
1144
|
+
"Content-Type": "application/json",
|
|
1145
|
+
...options.headers
|
|
1146
|
+
}
|
|
1147
|
+
});
|
|
1148
|
+
/**
|
|
1149
|
+
* List API endpoints for this revision
|
|
1150
|
+
*/
|
|
1151
|
+
const endpoints = (options) => (options.client ?? client).get({
|
|
1152
|
+
security: [{
|
|
1153
|
+
scheme: "bearer",
|
|
1154
|
+
type: "http"
|
|
1155
|
+
}],
|
|
1156
|
+
url: "/api/revision/{revisionId}/endpoints",
|
|
1157
|
+
...options
|
|
1158
|
+
});
|
|
1159
|
+
/**
|
|
1160
|
+
* Create an API endpoint for this revision
|
|
1161
|
+
*/
|
|
1162
|
+
const createEndpoint = (options) => (options.client ?? client).post({
|
|
1163
|
+
security: [{
|
|
1164
|
+
scheme: "bearer",
|
|
1165
|
+
type: "http"
|
|
1166
|
+
}],
|
|
1167
|
+
url: "/api/revision/{revisionId}/endpoints",
|
|
1168
|
+
...options,
|
|
1169
|
+
headers: {
|
|
1170
|
+
"Content-Type": "application/json",
|
|
1171
|
+
...options.headers
|
|
1172
|
+
}
|
|
1173
|
+
});
|
|
1174
|
+
/**
|
|
1175
|
+
* Get schema migrations from this revision
|
|
1176
|
+
*/
|
|
1177
|
+
const migrations = (options) => (options.client ?? client).get({
|
|
1178
|
+
security: [{
|
|
1179
|
+
scheme: "bearer",
|
|
1180
|
+
type: "http"
|
|
1181
|
+
}],
|
|
1182
|
+
url: "/api/revision/{revisionId}/migrations",
|
|
1183
|
+
...options
|
|
1184
|
+
});
|
|
1185
|
+
/**
|
|
1186
|
+
* Get revision changes summary
|
|
1187
|
+
*/
|
|
1188
|
+
const revisionChanges = (options) => (options.client ?? client).get({
|
|
1189
|
+
security: [{
|
|
1190
|
+
scheme: "bearer",
|
|
1191
|
+
type: "http"
|
|
1192
|
+
}],
|
|
1193
|
+
url: "/api/revision/{revisionId}/changes",
|
|
1194
|
+
...options
|
|
1195
|
+
});
|
|
1196
|
+
/**
|
|
1197
|
+
* Get paginated table changes for a revision
|
|
1198
|
+
*/
|
|
1199
|
+
const tableChanges = (options) => (options.client ?? client).get({
|
|
1200
|
+
security: [{
|
|
1201
|
+
scheme: "bearer",
|
|
1202
|
+
type: "http"
|
|
1203
|
+
}],
|
|
1204
|
+
url: "/api/revision/{revisionId}/table-changes",
|
|
1205
|
+
...options
|
|
1206
|
+
});
|
|
1207
|
+
/**
|
|
1208
|
+
* Get paginated row changes for a revision
|
|
1209
|
+
*/
|
|
1210
|
+
const rowChanges = (options) => (options.client ?? client).get({
|
|
1211
|
+
security: [{
|
|
1212
|
+
scheme: "bearer",
|
|
1213
|
+
type: "http"
|
|
1214
|
+
}],
|
|
1215
|
+
url: "/api/revision/{revisionId}/row-changes",
|
|
1216
|
+
...options
|
|
1217
|
+
});
|
|
1218
|
+
/**
|
|
1219
|
+
* Apply schema migrations to this revision
|
|
1220
|
+
*/
|
|
1221
|
+
const applyMigrations = (options) => (options.client ?? client).post({
|
|
1222
|
+
security: [{
|
|
1223
|
+
scheme: "bearer",
|
|
1224
|
+
type: "http"
|
|
1225
|
+
}],
|
|
1226
|
+
url: "/api/revision/{revisionId}/apply-migrations",
|
|
1227
|
+
...options,
|
|
1228
|
+
headers: {
|
|
1229
|
+
"Content-Type": "application/json",
|
|
1230
|
+
...options.headers
|
|
1231
|
+
}
|
|
1232
|
+
});
|
|
1233
|
+
/**
|
|
1234
|
+
* Delete a table
|
|
1235
|
+
*/
|
|
1236
|
+
const deleteTable$1 = (options) => (options.client ?? client).delete({
|
|
1237
|
+
security: [{
|
|
1238
|
+
scheme: "bearer",
|
|
1239
|
+
type: "http"
|
|
1240
|
+
}],
|
|
1241
|
+
url: "/api/revision/{revisionId}/tables/{tableId}",
|
|
1242
|
+
...options
|
|
1243
|
+
});
|
|
1244
|
+
/**
|
|
1245
|
+
* Get table by ID
|
|
1246
|
+
*/
|
|
1247
|
+
const table = (options) => (options.client ?? client).get({
|
|
1248
|
+
security: [{
|
|
1249
|
+
scheme: "bearer",
|
|
1250
|
+
type: "http"
|
|
1251
|
+
}],
|
|
1252
|
+
url: "/api/revision/{revisionId}/tables/{tableId}",
|
|
1253
|
+
...options
|
|
1254
|
+
});
|
|
1255
|
+
/**
|
|
1256
|
+
* Update table schema using JSON Patch
|
|
1257
|
+
*/
|
|
1258
|
+
const updateTable$1 = (options) => (options.client ?? client).patch({
|
|
1259
|
+
security: [{
|
|
1260
|
+
scheme: "bearer",
|
|
1261
|
+
type: "http"
|
|
1262
|
+
}],
|
|
1263
|
+
url: "/api/revision/{revisionId}/tables/{tableId}",
|
|
1264
|
+
...options,
|
|
1265
|
+
headers: {
|
|
1266
|
+
"Content-Type": "application/json",
|
|
1267
|
+
...options.headers
|
|
1268
|
+
}
|
|
1269
|
+
});
|
|
1270
|
+
/**
|
|
1271
|
+
* Get row count in table
|
|
1272
|
+
*/
|
|
1273
|
+
const tableCountRows = (options) => (options.client ?? client).get({
|
|
1274
|
+
security: [{
|
|
1275
|
+
scheme: "bearer",
|
|
1276
|
+
type: "http"
|
|
1277
|
+
}],
|
|
1278
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/count-rows",
|
|
1279
|
+
...options
|
|
1280
|
+
});
|
|
1281
|
+
/**
|
|
1282
|
+
* Delete multiple rows
|
|
1283
|
+
*/
|
|
1284
|
+
const deleteRows$1 = (options) => (options.client ?? client).delete({
|
|
1285
|
+
security: [{
|
|
1286
|
+
scheme: "bearer",
|
|
1287
|
+
type: "http"
|
|
1288
|
+
}],
|
|
1289
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/rows",
|
|
1290
|
+
...options,
|
|
1291
|
+
headers: {
|
|
1292
|
+
"Content-Type": "application/json",
|
|
1293
|
+
...options.headers
|
|
1294
|
+
}
|
|
1295
|
+
});
|
|
1296
|
+
/**
|
|
1297
|
+
* List rows in table with filtering and sorting
|
|
1298
|
+
*/
|
|
1299
|
+
const rows = (options) => (options.client ?? client).post({
|
|
1300
|
+
security: [{
|
|
1301
|
+
scheme: "bearer",
|
|
1302
|
+
type: "http"
|
|
1303
|
+
}],
|
|
1304
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/rows",
|
|
1305
|
+
...options,
|
|
1306
|
+
headers: {
|
|
1307
|
+
"Content-Type": "application/json",
|
|
1308
|
+
...options.headers
|
|
1309
|
+
}
|
|
1310
|
+
});
|
|
1311
|
+
/**
|
|
1312
|
+
* Create a new row
|
|
1313
|
+
*/
|
|
1314
|
+
const createRow$1 = (options) => (options.client ?? client).post({
|
|
1315
|
+
security: [{
|
|
1316
|
+
scheme: "bearer",
|
|
1317
|
+
type: "http"
|
|
1318
|
+
}],
|
|
1319
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/create-row",
|
|
1320
|
+
...options,
|
|
1321
|
+
headers: {
|
|
1322
|
+
"Content-Type": "application/json",
|
|
1323
|
+
...options.headers
|
|
1324
|
+
}
|
|
1325
|
+
});
|
|
1326
|
+
/**
|
|
1327
|
+
* Create multiple rows
|
|
1328
|
+
*/
|
|
1329
|
+
const createRows$1 = (options) => (options.client ?? client).post({
|
|
1330
|
+
security: [{
|
|
1331
|
+
scheme: "bearer",
|
|
1332
|
+
type: "http"
|
|
1333
|
+
}],
|
|
1334
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/create-rows",
|
|
1335
|
+
...options,
|
|
1336
|
+
headers: {
|
|
1337
|
+
"Content-Type": "application/json",
|
|
1338
|
+
...options.headers
|
|
1339
|
+
}
|
|
1340
|
+
});
|
|
1341
|
+
/**
|
|
1342
|
+
* Replace data for multiple rows
|
|
1343
|
+
*/
|
|
1344
|
+
const updateRows$1 = (options) => (options.client ?? client).put({
|
|
1345
|
+
security: [{
|
|
1346
|
+
scheme: "bearer",
|
|
1347
|
+
type: "http"
|
|
1348
|
+
}],
|
|
1349
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/update-rows",
|
|
1350
|
+
...options,
|
|
1351
|
+
headers: {
|
|
1352
|
+
"Content-Type": "application/json",
|
|
1353
|
+
...options.headers
|
|
1354
|
+
}
|
|
1355
|
+
});
|
|
1356
|
+
/**
|
|
1357
|
+
* Patch multiple rows using JSON Patch
|
|
1358
|
+
*/
|
|
1359
|
+
const patchRows = (options) => (options.client ?? client).patch({
|
|
1360
|
+
security: [{
|
|
1361
|
+
scheme: "bearer",
|
|
1362
|
+
type: "http"
|
|
1363
|
+
}],
|
|
1364
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/patch-rows",
|
|
1365
|
+
...options,
|
|
1366
|
+
headers: {
|
|
1367
|
+
"Content-Type": "application/json",
|
|
1368
|
+
...options.headers
|
|
1369
|
+
}
|
|
1370
|
+
});
|
|
1371
|
+
/**
|
|
1372
|
+
* Get table JSON Schema
|
|
1373
|
+
*/
|
|
1374
|
+
const tableSchema = (options) => (options.client ?? client).get({
|
|
1375
|
+
security: [{
|
|
1376
|
+
scheme: "bearer",
|
|
1377
|
+
type: "http"
|
|
1378
|
+
}],
|
|
1379
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/schema",
|
|
1380
|
+
...options
|
|
1381
|
+
});
|
|
1382
|
+
/**
|
|
1383
|
+
* Count tables that reference this table
|
|
1384
|
+
*/
|
|
1385
|
+
const tableCountForeignKeysBy = (options) => (options.client ?? client).get({
|
|
1386
|
+
security: [{
|
|
1387
|
+
scheme: "bearer",
|
|
1388
|
+
type: "http"
|
|
1389
|
+
}],
|
|
1390
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/count-foreign-keys-by",
|
|
1391
|
+
...options
|
|
1392
|
+
});
|
|
1393
|
+
/**
|
|
1394
|
+
* List tables that reference this table
|
|
1395
|
+
*/
|
|
1396
|
+
const tableForeignKeysBy = (options) => (options.client ?? client).get({
|
|
1397
|
+
security: [{
|
|
1398
|
+
scheme: "bearer",
|
|
1399
|
+
type: "http"
|
|
1400
|
+
}],
|
|
1401
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/foreign-keys-by",
|
|
1402
|
+
...options
|
|
1403
|
+
});
|
|
1404
|
+
/**
|
|
1405
|
+
* Count tables this table references
|
|
1406
|
+
*/
|
|
1407
|
+
const tableCountForeignKeysTo = (options) => (options.client ?? client).get({
|
|
1408
|
+
security: [{
|
|
1409
|
+
scheme: "bearer",
|
|
1410
|
+
type: "http"
|
|
1411
|
+
}],
|
|
1412
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/count-foreign-keys-to",
|
|
1413
|
+
...options
|
|
1414
|
+
});
|
|
1415
|
+
/**
|
|
1416
|
+
* List tables this table references
|
|
1417
|
+
*/
|
|
1418
|
+
const tableForeignKeysTo = (options) => (options.client ?? client).get({
|
|
1419
|
+
security: [{
|
|
1420
|
+
scheme: "bearer",
|
|
1421
|
+
type: "http"
|
|
1422
|
+
}],
|
|
1423
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/foreign-keys-to",
|
|
1424
|
+
...options
|
|
1425
|
+
});
|
|
1426
|
+
/**
|
|
1427
|
+
* Rename a table
|
|
1428
|
+
*/
|
|
1429
|
+
const renameTable$1 = (options) => (options.client ?? client).patch({
|
|
1430
|
+
security: [{
|
|
1431
|
+
scheme: "bearer",
|
|
1432
|
+
type: "http"
|
|
1433
|
+
}],
|
|
1434
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/rename",
|
|
1435
|
+
...options,
|
|
1436
|
+
headers: {
|
|
1437
|
+
"Content-Type": "application/json",
|
|
1438
|
+
...options.headers
|
|
1439
|
+
}
|
|
1440
|
+
});
|
|
1441
|
+
/**
|
|
1442
|
+
* Delete a row
|
|
1443
|
+
*/
|
|
1444
|
+
const deleteRow$1 = (options) => (options.client ?? client).delete({
|
|
1445
|
+
security: [{
|
|
1446
|
+
scheme: "bearer",
|
|
1447
|
+
type: "http"
|
|
1448
|
+
}],
|
|
1449
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/rows/{rowId}",
|
|
1450
|
+
...options
|
|
1451
|
+
});
|
|
1452
|
+
/**
|
|
1453
|
+
* Get row by ID
|
|
1454
|
+
*/
|
|
1455
|
+
const row = (options) => (options.client ?? client).get({
|
|
1456
|
+
security: [{
|
|
1457
|
+
scheme: "bearer",
|
|
1458
|
+
type: "http"
|
|
1459
|
+
}],
|
|
1460
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/rows/{rowId}",
|
|
1461
|
+
...options
|
|
1462
|
+
});
|
|
1463
|
+
/**
|
|
1464
|
+
* Patch row data using JSON Patch
|
|
1465
|
+
*/
|
|
1466
|
+
const patchRow$1 = (options) => (options.client ?? client).patch({
|
|
1467
|
+
security: [{
|
|
1468
|
+
scheme: "bearer",
|
|
1469
|
+
type: "http"
|
|
1470
|
+
}],
|
|
1471
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/rows/{rowId}",
|
|
1472
|
+
...options,
|
|
1473
|
+
headers: {
|
|
1474
|
+
"Content-Type": "application/json",
|
|
1475
|
+
...options.headers
|
|
1476
|
+
}
|
|
1477
|
+
});
|
|
1478
|
+
/**
|
|
1479
|
+
* Replace row data
|
|
1480
|
+
*/
|
|
1481
|
+
const updateRow$1 = (options) => (options.client ?? client).put({
|
|
1482
|
+
security: [{
|
|
1483
|
+
scheme: "bearer",
|
|
1484
|
+
type: "http"
|
|
1485
|
+
}],
|
|
1486
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/rows/{rowId}",
|
|
1487
|
+
...options,
|
|
1488
|
+
headers: {
|
|
1489
|
+
"Content-Type": "application/json",
|
|
1490
|
+
...options.headers
|
|
1491
|
+
}
|
|
1492
|
+
});
|
|
1493
|
+
/**
|
|
1494
|
+
* Count rows that reference this row
|
|
1495
|
+
*/
|
|
1496
|
+
const rowCountForeignKeysBy = (options) => (options.client ?? client).get({
|
|
1497
|
+
security: [{
|
|
1498
|
+
scheme: "bearer",
|
|
1499
|
+
type: "http"
|
|
1500
|
+
}],
|
|
1501
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/rows/{rowId}/count-foreign-keys-by",
|
|
1502
|
+
...options
|
|
1503
|
+
});
|
|
1504
|
+
/**
|
|
1505
|
+
* List rows that reference this row
|
|
1506
|
+
*/
|
|
1507
|
+
const rowForeignKeysBy = (options) => (options.client ?? client).get({
|
|
1508
|
+
security: [{
|
|
1509
|
+
scheme: "bearer",
|
|
1510
|
+
type: "http"
|
|
1511
|
+
}],
|
|
1512
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/rows/{rowId}/foreign-keys-by",
|
|
1513
|
+
...options
|
|
1514
|
+
});
|
|
1515
|
+
/**
|
|
1516
|
+
* Count rows this row references
|
|
1517
|
+
*/
|
|
1518
|
+
const rowCountForeignKeysTo = (options) => (options.client ?? client).get({
|
|
1519
|
+
security: [{
|
|
1520
|
+
scheme: "bearer",
|
|
1521
|
+
type: "http"
|
|
1522
|
+
}],
|
|
1523
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/rows/{rowId}/count-foreign-keys-to",
|
|
1524
|
+
...options
|
|
1525
|
+
});
|
|
1526
|
+
/**
|
|
1527
|
+
* List rows this row references
|
|
1528
|
+
*/
|
|
1529
|
+
const rowForeignKeysTo = (options) => (options.client ?? client).get({
|
|
1530
|
+
security: [{
|
|
1531
|
+
scheme: "bearer",
|
|
1532
|
+
type: "http"
|
|
1533
|
+
}],
|
|
1534
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/rows/{rowId}/foreign-keys-to",
|
|
1535
|
+
...options
|
|
1536
|
+
});
|
|
1537
|
+
/**
|
|
1538
|
+
* Rename a row
|
|
1539
|
+
*/
|
|
1540
|
+
const renameRow$1 = (options) => (options.client ?? client).patch({
|
|
1541
|
+
security: [{
|
|
1542
|
+
scheme: "bearer",
|
|
1543
|
+
type: "http"
|
|
1544
|
+
}],
|
|
1545
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/rows/{rowId}/rename",
|
|
1546
|
+
...options,
|
|
1547
|
+
headers: {
|
|
1548
|
+
"Content-Type": "application/json",
|
|
1549
|
+
...options.headers
|
|
1550
|
+
}
|
|
1551
|
+
});
|
|
1552
|
+
/**
|
|
1553
|
+
* Upload a file to a row field
|
|
1554
|
+
*/
|
|
1555
|
+
const uploadFile = (options) => (options.client ?? client).post({
|
|
1556
|
+
...formDataBodySerializer,
|
|
1557
|
+
security: [{
|
|
1558
|
+
scheme: "bearer",
|
|
1559
|
+
type: "http"
|
|
1560
|
+
}],
|
|
1561
|
+
url: "/api/revision/{revisionId}/tables/{tableId}/rows/{rowId}/upload/{fileId}",
|
|
1562
|
+
...options,
|
|
1563
|
+
headers: {
|
|
1564
|
+
"Content-Type": null,
|
|
1565
|
+
...options.headers
|
|
1566
|
+
}
|
|
1567
|
+
});
|
|
1568
|
+
/**
|
|
1569
|
+
* Get endpoint with all related entities
|
|
1570
|
+
*/
|
|
1571
|
+
const endpointRelatives = (options) => (options.client ?? client).get({
|
|
1572
|
+
security: [{
|
|
1573
|
+
scheme: "bearer",
|
|
1574
|
+
type: "http"
|
|
1575
|
+
}],
|
|
1576
|
+
url: "/api/endpoints/{endpointId}/relatives",
|
|
1577
|
+
...options
|
|
1578
|
+
});
|
|
1579
|
+
/**
|
|
1580
|
+
* Delete an endpoint
|
|
1581
|
+
*/
|
|
1582
|
+
const deleteEndpoint = (options) => (options.client ?? client).delete({
|
|
1583
|
+
security: [{
|
|
1584
|
+
scheme: "bearer",
|
|
1585
|
+
type: "http"
|
|
1586
|
+
}],
|
|
1587
|
+
url: "/api/endpoints/{endpointId}",
|
|
1588
|
+
...options
|
|
1589
|
+
});
|
|
1590
|
+
/**
|
|
1591
|
+
* Get system configuration
|
|
1592
|
+
*/
|
|
1593
|
+
const getConfiguration = (options) => (options?.client ?? client).get({
|
|
1594
|
+
url: "/api/configuration",
|
|
1595
|
+
...options
|
|
1596
|
+
});
|
|
1597
|
+
const readiness = (options) => (options?.client ?? client).get({
|
|
1598
|
+
url: "/health/readiness",
|
|
1599
|
+
...options
|
|
1600
|
+
});
|
|
1601
|
+
const liveness = (options) => (options?.client ?? client).get({
|
|
1602
|
+
url: "/health/liveness",
|
|
1603
|
+
...options
|
|
1604
|
+
});
|
|
1605
|
+
|
|
1606
|
+
//#endregion
|
|
1607
|
+
//#region src/data-operations.ts
|
|
1608
|
+
function unwrap(result) {
|
|
1609
|
+
if (result.error) {
|
|
1610
|
+
const err = result.error;
|
|
1611
|
+
throw new Error(err.message ?? `API error: ${JSON.stringify(result.error)}`);
|
|
1612
|
+
}
|
|
1613
|
+
return result.data;
|
|
1614
|
+
}
|
|
1615
|
+
function assertDraft(ctx) {
|
|
1616
|
+
assertContext(ctx);
|
|
1617
|
+
if (!ctx.isDraft) throw new Error("Mutations are only allowed in draft revision. Use setContext({ revision: \"draft\" }).");
|
|
1618
|
+
}
|
|
1619
|
+
function assertContext(ctx) {
|
|
1620
|
+
if (!ctx.branch.organizationId) throw new Error("Context not set. Call setContext() first.");
|
|
1621
|
+
}
|
|
1622
|
+
async function getTables(ctx, options) {
|
|
1623
|
+
const revisionId = await ctx.getRevisionId();
|
|
1624
|
+
return unwrap(await tables({
|
|
1625
|
+
client: ctx.client,
|
|
1626
|
+
path: { revisionId },
|
|
1627
|
+
query: {
|
|
1628
|
+
first: options?.first ?? 100,
|
|
1629
|
+
after: options?.after
|
|
1630
|
+
}
|
|
1631
|
+
}));
|
|
1632
|
+
}
|
|
1633
|
+
async function getTable(ctx, tableId) {
|
|
1634
|
+
const revisionId = await ctx.getRevisionId();
|
|
1635
|
+
return unwrap(await table({
|
|
1636
|
+
client: ctx.client,
|
|
1637
|
+
path: {
|
|
1638
|
+
revisionId,
|
|
1639
|
+
tableId
|
|
1640
|
+
}
|
|
1641
|
+
}));
|
|
1642
|
+
}
|
|
1643
|
+
async function getTableSchema(ctx, tableId) {
|
|
1644
|
+
const revisionId = await ctx.getRevisionId();
|
|
1645
|
+
return unwrap(await tableSchema({
|
|
1646
|
+
client: ctx.client,
|
|
1647
|
+
path: {
|
|
1648
|
+
revisionId,
|
|
1649
|
+
tableId
|
|
1650
|
+
}
|
|
1651
|
+
}));
|
|
1652
|
+
}
|
|
1653
|
+
async function getRows(ctx, tableId, options) {
|
|
1654
|
+
const revisionId = await ctx.getRevisionId();
|
|
1655
|
+
return unwrap(await rows({
|
|
1656
|
+
client: ctx.client,
|
|
1657
|
+
path: {
|
|
1658
|
+
revisionId,
|
|
1659
|
+
tableId
|
|
1660
|
+
},
|
|
1661
|
+
body: options ?? { first: 100 }
|
|
1662
|
+
}));
|
|
1663
|
+
}
|
|
1664
|
+
async function getRow(ctx, tableId, rowId) {
|
|
1665
|
+
const revisionId = await ctx.getRevisionId();
|
|
1666
|
+
return unwrap(await row({
|
|
1667
|
+
client: ctx.client,
|
|
1668
|
+
path: {
|
|
1669
|
+
revisionId,
|
|
1670
|
+
tableId,
|
|
1671
|
+
rowId
|
|
1672
|
+
}
|
|
1673
|
+
}));
|
|
1674
|
+
}
|
|
1675
|
+
async function getChanges(ctx) {
|
|
1676
|
+
const revisionId = await ctx.getRevisionId();
|
|
1677
|
+
return unwrap(await revisionChanges({
|
|
1678
|
+
client: ctx.client,
|
|
1679
|
+
path: { revisionId }
|
|
1680
|
+
}));
|
|
1681
|
+
}
|
|
1682
|
+
async function createTable(ctx, tableId, schema) {
|
|
1683
|
+
assertDraft(ctx);
|
|
1684
|
+
const revisionId = await ctx.getRevisionId();
|
|
1685
|
+
return unwrap(await createTable$1({
|
|
1686
|
+
client: ctx.client,
|
|
1687
|
+
path: { revisionId },
|
|
1688
|
+
body: {
|
|
1689
|
+
tableId,
|
|
1690
|
+
schema
|
|
1691
|
+
}
|
|
1692
|
+
}));
|
|
1693
|
+
}
|
|
1694
|
+
async function updateTable(ctx, tableId, patches) {
|
|
1695
|
+
assertDraft(ctx);
|
|
1696
|
+
const revisionId = await ctx.getRevisionId();
|
|
1697
|
+
return unwrap(await updateTable$1({
|
|
1698
|
+
client: ctx.client,
|
|
1699
|
+
path: {
|
|
1700
|
+
revisionId,
|
|
1701
|
+
tableId
|
|
1702
|
+
},
|
|
1703
|
+
body: { patches }
|
|
1704
|
+
}));
|
|
1705
|
+
}
|
|
1706
|
+
async function deleteTable(ctx, tableId) {
|
|
1707
|
+
assertDraft(ctx);
|
|
1708
|
+
const revisionId = await ctx.getRevisionId();
|
|
1709
|
+
unwrap(await deleteTable$1({
|
|
1710
|
+
client: ctx.client,
|
|
1711
|
+
path: {
|
|
1712
|
+
revisionId,
|
|
1713
|
+
tableId
|
|
1714
|
+
}
|
|
1715
|
+
}));
|
|
1716
|
+
}
|
|
1717
|
+
async function renameTable(ctx, tableId, nextTableId) {
|
|
1718
|
+
assertDraft(ctx);
|
|
1719
|
+
const revisionId = await ctx.getRevisionId();
|
|
1720
|
+
return unwrap(await renameTable$1({
|
|
1721
|
+
client: ctx.client,
|
|
1722
|
+
path: {
|
|
1723
|
+
revisionId,
|
|
1724
|
+
tableId
|
|
1725
|
+
},
|
|
1726
|
+
body: { nextTableId }
|
|
1727
|
+
}));
|
|
1728
|
+
}
|
|
1729
|
+
async function createRow(ctx, tableId, rowId, data) {
|
|
1730
|
+
assertDraft(ctx);
|
|
1731
|
+
const revisionId = await ctx.getRevisionId();
|
|
1732
|
+
return unwrap(await createRow$1({
|
|
1733
|
+
client: ctx.client,
|
|
1734
|
+
path: {
|
|
1735
|
+
revisionId,
|
|
1736
|
+
tableId
|
|
1737
|
+
},
|
|
1738
|
+
body: {
|
|
1739
|
+
rowId,
|
|
1740
|
+
data
|
|
1741
|
+
}
|
|
1742
|
+
}));
|
|
1743
|
+
}
|
|
1744
|
+
async function createRows(ctx, tableId, rows) {
|
|
1745
|
+
assertDraft(ctx);
|
|
1746
|
+
const revisionId = await ctx.getRevisionId();
|
|
1747
|
+
return unwrap(await createRows$1({
|
|
1748
|
+
client: ctx.client,
|
|
1749
|
+
path: {
|
|
1750
|
+
revisionId,
|
|
1751
|
+
tableId
|
|
1752
|
+
},
|
|
1753
|
+
body: { rows: rows.map((r) => ({
|
|
1754
|
+
rowId: r.rowId,
|
|
1755
|
+
data: r.data
|
|
1756
|
+
})) }
|
|
1757
|
+
}));
|
|
1758
|
+
}
|
|
1759
|
+
async function updateRow(ctx, tableId, rowId, data) {
|
|
1760
|
+
assertDraft(ctx);
|
|
1761
|
+
const revisionId = await ctx.getRevisionId();
|
|
1762
|
+
return unwrap(await updateRow$1({
|
|
1763
|
+
client: ctx.client,
|
|
1764
|
+
path: {
|
|
1765
|
+
revisionId,
|
|
1766
|
+
tableId,
|
|
1767
|
+
rowId
|
|
1768
|
+
},
|
|
1769
|
+
body: { data }
|
|
1770
|
+
}));
|
|
1771
|
+
}
|
|
1772
|
+
async function updateRows(ctx, tableId, rows) {
|
|
1773
|
+
assertDraft(ctx);
|
|
1774
|
+
const revisionId = await ctx.getRevisionId();
|
|
1775
|
+
return unwrap(await updateRows$1({
|
|
1776
|
+
client: ctx.client,
|
|
1777
|
+
path: {
|
|
1778
|
+
revisionId,
|
|
1779
|
+
tableId
|
|
1780
|
+
},
|
|
1781
|
+
body: { rows: rows.map((r) => ({
|
|
1782
|
+
rowId: r.rowId,
|
|
1783
|
+
data: r.data
|
|
1784
|
+
})) }
|
|
1785
|
+
}));
|
|
1786
|
+
}
|
|
1787
|
+
async function patchRow(ctx, tableId, rowId, patches) {
|
|
1788
|
+
assertDraft(ctx);
|
|
1789
|
+
const revisionId = await ctx.getRevisionId();
|
|
1790
|
+
return unwrap(await patchRow$1({
|
|
1791
|
+
client: ctx.client,
|
|
1792
|
+
path: {
|
|
1793
|
+
revisionId,
|
|
1794
|
+
tableId,
|
|
1795
|
+
rowId
|
|
1796
|
+
},
|
|
1797
|
+
body: { patches }
|
|
1798
|
+
}));
|
|
1799
|
+
}
|
|
1800
|
+
async function deleteRow(ctx, tableId, rowId) {
|
|
1801
|
+
assertDraft(ctx);
|
|
1802
|
+
const revisionId = await ctx.getRevisionId();
|
|
1803
|
+
unwrap(await deleteRow$1({
|
|
1804
|
+
client: ctx.client,
|
|
1805
|
+
path: {
|
|
1806
|
+
revisionId,
|
|
1807
|
+
tableId,
|
|
1808
|
+
rowId
|
|
1809
|
+
}
|
|
1810
|
+
}));
|
|
1811
|
+
}
|
|
1812
|
+
async function deleteRows(ctx, tableId, rowIds) {
|
|
1813
|
+
assertDraft(ctx);
|
|
1814
|
+
const revisionId = await ctx.getRevisionId();
|
|
1815
|
+
unwrap(await deleteRows$1({
|
|
1816
|
+
client: ctx.client,
|
|
1817
|
+
path: {
|
|
1818
|
+
revisionId,
|
|
1819
|
+
tableId
|
|
1820
|
+
},
|
|
1821
|
+
body: { rowIds }
|
|
1822
|
+
}));
|
|
1823
|
+
}
|
|
1824
|
+
async function renameRow(ctx, tableId, rowId, nextRowId) {
|
|
1825
|
+
assertDraft(ctx);
|
|
1826
|
+
const revisionId = await ctx.getRevisionId();
|
|
1827
|
+
return unwrap(await renameRow$1({
|
|
1828
|
+
client: ctx.client,
|
|
1829
|
+
path: {
|
|
1830
|
+
revisionId,
|
|
1831
|
+
tableId,
|
|
1832
|
+
rowId
|
|
1833
|
+
},
|
|
1834
|
+
body: { nextRowId }
|
|
1835
|
+
}));
|
|
1836
|
+
}
|
|
1837
|
+
async function commit(ctx, comment) {
|
|
1838
|
+
assertDraft(ctx);
|
|
1839
|
+
return unwrap(await createRevision({
|
|
1840
|
+
client: ctx.client,
|
|
1841
|
+
path: {
|
|
1842
|
+
organizationId: ctx.branch.organizationId,
|
|
1843
|
+
projectName: ctx.branch.projectName,
|
|
1844
|
+
branchName: ctx.branch.branchName
|
|
1845
|
+
},
|
|
1846
|
+
body: { comment }
|
|
1847
|
+
}));
|
|
1848
|
+
}
|
|
1849
|
+
async function revertChanges(ctx) {
|
|
1850
|
+
assertDraft(ctx);
|
|
1851
|
+
unwrap(await revertChanges$1({
|
|
1852
|
+
client: ctx.client,
|
|
1853
|
+
path: {
|
|
1854
|
+
organizationId: ctx.branch.organizationId,
|
|
1855
|
+
projectName: ctx.branch.projectName,
|
|
1856
|
+
branchName: ctx.branch.branchName
|
|
1857
|
+
}
|
|
1858
|
+
}));
|
|
1859
|
+
}
|
|
1860
|
+
async function fetchDraftRevisionId(client, branch) {
|
|
1861
|
+
return unwrap(await draftRevision({
|
|
1862
|
+
client,
|
|
1863
|
+
path: {
|
|
1864
|
+
organizationId: branch.organizationId,
|
|
1865
|
+
projectName: branch.projectName,
|
|
1866
|
+
branchName: branch.branchName
|
|
1867
|
+
}
|
|
1868
|
+
})).id;
|
|
1869
|
+
}
|
|
1870
|
+
async function fetchHeadRevisionId(client, branch) {
|
|
1871
|
+
return unwrap(await headRevision({
|
|
1872
|
+
client,
|
|
1873
|
+
path: {
|
|
1874
|
+
organizationId: branch.organizationId,
|
|
1875
|
+
projectName: branch.projectName,
|
|
1876
|
+
branchName: branch.branchName
|
|
1877
|
+
}
|
|
1878
|
+
})).id;
|
|
1879
|
+
}
|
|
1880
|
+
async function validateRevisionId(client, revisionId) {
|
|
1881
|
+
unwrap(await revision({
|
|
1882
|
+
client,
|
|
1883
|
+
path: { revisionId }
|
|
1884
|
+
}));
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
//#endregion
|
|
1888
|
+
//#region src/revisium-scope.ts
|
|
1889
|
+
var RevisiumScope = class {
|
|
1890
|
+
_client;
|
|
1891
|
+
_branch;
|
|
1892
|
+
_revisionMode;
|
|
1893
|
+
_owner;
|
|
1894
|
+
_revisionId;
|
|
1895
|
+
_isDraft;
|
|
1896
|
+
_stale = false;
|
|
1897
|
+
_disposed = false;
|
|
1898
|
+
_refreshPromise = null;
|
|
1899
|
+
constructor(init) {
|
|
1900
|
+
this._client = init.client;
|
|
1901
|
+
this._branch = init.branch;
|
|
1902
|
+
this._revisionId = init.revisionId;
|
|
1903
|
+
this._isDraft = init.isDraft;
|
|
1904
|
+
this._revisionMode = init.revisionMode;
|
|
1905
|
+
this._owner = init.owner;
|
|
1906
|
+
}
|
|
1907
|
+
get organizationId() {
|
|
1908
|
+
return this._branch.organizationId;
|
|
1909
|
+
}
|
|
1910
|
+
get projectName() {
|
|
1911
|
+
return this._branch.projectName;
|
|
1912
|
+
}
|
|
1913
|
+
get branchName() {
|
|
1914
|
+
return this._branch.branchName;
|
|
1915
|
+
}
|
|
1916
|
+
get revisionId() {
|
|
1917
|
+
return this._revisionId;
|
|
1918
|
+
}
|
|
1919
|
+
get isDraft() {
|
|
1920
|
+
return this._isDraft;
|
|
1921
|
+
}
|
|
1922
|
+
get isStale() {
|
|
1923
|
+
return this._stale;
|
|
1924
|
+
}
|
|
1925
|
+
get isDisposed() {
|
|
1926
|
+
return this._disposed;
|
|
1927
|
+
}
|
|
1928
|
+
get client() {
|
|
1929
|
+
return this._client;
|
|
1930
|
+
}
|
|
1931
|
+
markStale() {
|
|
1932
|
+
if (this._revisionMode === "explicit") return;
|
|
1933
|
+
this._stale = true;
|
|
1934
|
+
}
|
|
1935
|
+
async refresh() {
|
|
1936
|
+
this.assertNotDisposed();
|
|
1937
|
+
if (this._revisionMode === "explicit") return;
|
|
1938
|
+
this._revisionId = await this.fetchRevisionId();
|
|
1939
|
+
this._stale = false;
|
|
1940
|
+
}
|
|
1941
|
+
dispose() {
|
|
1942
|
+
if (this._disposed) return;
|
|
1943
|
+
this._disposed = true;
|
|
1944
|
+
this._owner.unregisterScope(this);
|
|
1945
|
+
}
|
|
1946
|
+
assertNotDisposed() {
|
|
1947
|
+
if (this._disposed) throw new Error("Scope has been disposed.");
|
|
1948
|
+
}
|
|
1949
|
+
get _branchKey() {
|
|
1950
|
+
return `${this._branch.organizationId}/${this._branch.projectName}/${this._branch.branchName}`;
|
|
1951
|
+
}
|
|
1952
|
+
async fetchRevisionId() {
|
|
1953
|
+
if (this._revisionMode === "draft") return fetchDraftRevisionId(this._client, this._branch);
|
|
1954
|
+
return fetchHeadRevisionId(this._client, this._branch);
|
|
1955
|
+
}
|
|
1956
|
+
async getRevisionId() {
|
|
1957
|
+
this.assertNotDisposed();
|
|
1958
|
+
if (this._stale) {
|
|
1959
|
+
this._refreshPromise ??= this.fetchRevisionId().then((id) => {
|
|
1960
|
+
this._revisionId = id;
|
|
1961
|
+
this._stale = false;
|
|
1962
|
+
this._refreshPromise = null;
|
|
1963
|
+
return id;
|
|
1964
|
+
}, (err) => {
|
|
1965
|
+
this._refreshPromise = null;
|
|
1966
|
+
throw err;
|
|
1967
|
+
});
|
|
1968
|
+
return this._refreshPromise;
|
|
1969
|
+
}
|
|
1970
|
+
return this._revisionId;
|
|
1971
|
+
}
|
|
1972
|
+
get _scopeContext() {
|
|
1973
|
+
return {
|
|
1974
|
+
client: this._client,
|
|
1975
|
+
branch: this._branch,
|
|
1976
|
+
isDraft: this._isDraft,
|
|
1977
|
+
getRevisionId: () => this.getRevisionId()
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1980
|
+
async getTables(options) {
|
|
1981
|
+
return getTables(this._scopeContext, options);
|
|
1982
|
+
}
|
|
1983
|
+
async getTable(tableId) {
|
|
1984
|
+
return getTable(this._scopeContext, tableId);
|
|
1985
|
+
}
|
|
1986
|
+
async getTableSchema(tableId) {
|
|
1987
|
+
return getTableSchema(this._scopeContext, tableId);
|
|
1988
|
+
}
|
|
1989
|
+
async getRows(tableId, options) {
|
|
1990
|
+
return getRows(this._scopeContext, tableId, options);
|
|
1991
|
+
}
|
|
1992
|
+
async getRow(tableId, rowId) {
|
|
1993
|
+
return getRow(this._scopeContext, tableId, rowId);
|
|
1994
|
+
}
|
|
1995
|
+
async getChanges() {
|
|
1996
|
+
return getChanges(this._scopeContext);
|
|
1997
|
+
}
|
|
1998
|
+
async createTable(tableId, schema) {
|
|
1999
|
+
return createTable(this._scopeContext, tableId, schema);
|
|
2000
|
+
}
|
|
2001
|
+
async updateTable(tableId, patches) {
|
|
2002
|
+
return updateTable(this._scopeContext, tableId, patches);
|
|
2003
|
+
}
|
|
2004
|
+
async deleteTable(tableId) {
|
|
2005
|
+
return deleteTable(this._scopeContext, tableId);
|
|
2006
|
+
}
|
|
2007
|
+
async renameTable(tableId, nextTableId) {
|
|
2008
|
+
return renameTable(this._scopeContext, tableId, nextTableId);
|
|
2009
|
+
}
|
|
2010
|
+
async createRow(tableId, rowId, data) {
|
|
2011
|
+
return createRow(this._scopeContext, tableId, rowId, data);
|
|
2012
|
+
}
|
|
2013
|
+
async createRows(tableId, rows) {
|
|
2014
|
+
return createRows(this._scopeContext, tableId, rows);
|
|
2015
|
+
}
|
|
2016
|
+
async updateRow(tableId, rowId, data) {
|
|
2017
|
+
return updateRow(this._scopeContext, tableId, rowId, data);
|
|
2018
|
+
}
|
|
2019
|
+
async updateRows(tableId, rows) {
|
|
2020
|
+
return updateRows(this._scopeContext, tableId, rows);
|
|
2021
|
+
}
|
|
2022
|
+
async patchRow(tableId, rowId, patches) {
|
|
2023
|
+
return patchRow(this._scopeContext, tableId, rowId, patches);
|
|
2024
|
+
}
|
|
2025
|
+
async deleteRow(tableId, rowId) {
|
|
2026
|
+
return deleteRow(this._scopeContext, tableId, rowId);
|
|
2027
|
+
}
|
|
2028
|
+
async deleteRows(tableId, rowIds) {
|
|
2029
|
+
return deleteRows(this._scopeContext, tableId, rowIds);
|
|
2030
|
+
}
|
|
2031
|
+
async renameRow(tableId, rowId, nextRowId) {
|
|
2032
|
+
return renameRow(this._scopeContext, tableId, rowId, nextRowId);
|
|
2033
|
+
}
|
|
2034
|
+
async commit(comment) {
|
|
2035
|
+
this.assertNotDisposed();
|
|
2036
|
+
const data = await commit(this._scopeContext, comment);
|
|
2037
|
+
this._revisionId = await fetchDraftRevisionId(this._client, this._branch);
|
|
2038
|
+
this._stale = false;
|
|
2039
|
+
this._owner.notifyBranchChanged(this._branchKey, this);
|
|
2040
|
+
return data;
|
|
2041
|
+
}
|
|
2042
|
+
async revertChanges() {
|
|
2043
|
+
this.assertNotDisposed();
|
|
2044
|
+
await revertChanges(this._scopeContext);
|
|
2045
|
+
this._revisionId = await fetchDraftRevisionId(this._client, this._branch);
|
|
2046
|
+
this._stale = false;
|
|
2047
|
+
this._owner.notifyBranchChanged(this._branchKey, this);
|
|
2048
|
+
}
|
|
2049
|
+
};
|
|
2050
|
+
|
|
2051
|
+
//#endregion
|
|
1
2052
|
//#region src/revisium-client.ts
|
|
2
2053
|
var RevisiumClient = class {
|
|
2054
|
+
_client;
|
|
3
2055
|
_baseUrl;
|
|
4
|
-
|
|
2056
|
+
_organizationId = null;
|
|
2057
|
+
_projectName = null;
|
|
2058
|
+
_branchName = null;
|
|
2059
|
+
_revisionId = null;
|
|
2060
|
+
_isDraft = false;
|
|
2061
|
+
_isAuthenticated = false;
|
|
2062
|
+
_scopes = /* @__PURE__ */ new Map();
|
|
5
2063
|
constructor(options) {
|
|
6
2064
|
const url = options.baseUrl;
|
|
7
2065
|
this._baseUrl = url.endsWith("/") ? url.slice(0, -1) : url;
|
|
2066
|
+
this._client = createClient(createConfig({ baseUrl: this._baseUrl }));
|
|
8
2067
|
}
|
|
9
2068
|
get baseUrl() {
|
|
10
2069
|
return this._baseUrl;
|
|
11
2070
|
}
|
|
2071
|
+
get organizationId() {
|
|
2072
|
+
return this._organizationId;
|
|
2073
|
+
}
|
|
2074
|
+
get projectName() {
|
|
2075
|
+
return this._projectName;
|
|
2076
|
+
}
|
|
2077
|
+
get branchName() {
|
|
2078
|
+
return this._branchName;
|
|
2079
|
+
}
|
|
2080
|
+
get revisionId() {
|
|
2081
|
+
return this._revisionId;
|
|
2082
|
+
}
|
|
2083
|
+
get isDraft() {
|
|
2084
|
+
return this._isDraft;
|
|
2085
|
+
}
|
|
2086
|
+
get client() {
|
|
2087
|
+
return this._client;
|
|
2088
|
+
}
|
|
12
2089
|
isAuthenticated() {
|
|
13
|
-
return this.
|
|
2090
|
+
return this._isAuthenticated;
|
|
2091
|
+
}
|
|
2092
|
+
async login(username, password) {
|
|
2093
|
+
const result = await login({
|
|
2094
|
+
client: this._client,
|
|
2095
|
+
body: {
|
|
2096
|
+
emailOrUsername: username,
|
|
2097
|
+
password
|
|
2098
|
+
}
|
|
2099
|
+
});
|
|
2100
|
+
const data = unwrap(result);
|
|
2101
|
+
this._client.setConfig({ auth: data.accessToken });
|
|
2102
|
+
this._isAuthenticated = true;
|
|
2103
|
+
}
|
|
2104
|
+
loginWithToken(token) {
|
|
2105
|
+
this._client.setConfig({ auth: token });
|
|
2106
|
+
this._isAuthenticated = true;
|
|
2107
|
+
}
|
|
2108
|
+
async setContext(options) {
|
|
2109
|
+
const { organizationId, projectName, branchName = "master", revision = "draft" } = options;
|
|
2110
|
+
this._organizationId = organizationId;
|
|
2111
|
+
this._projectName = projectName;
|
|
2112
|
+
this._branchName = branchName;
|
|
2113
|
+
const branch = {
|
|
2114
|
+
organizationId,
|
|
2115
|
+
projectName,
|
|
2116
|
+
branchName
|
|
2117
|
+
};
|
|
2118
|
+
if (revision === "draft") {
|
|
2119
|
+
this._revisionId = await fetchDraftRevisionId(this._client, branch);
|
|
2120
|
+
this._isDraft = true;
|
|
2121
|
+
} else if (revision === "head") {
|
|
2122
|
+
this._revisionId = await fetchHeadRevisionId(this._client, branch);
|
|
2123
|
+
this._isDraft = false;
|
|
2124
|
+
} else {
|
|
2125
|
+
await validateRevisionId(this._client, revision);
|
|
2126
|
+
this._revisionId = revision;
|
|
2127
|
+
this._isDraft = false;
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
async withContext(options) {
|
|
2131
|
+
const { organizationId, projectName, branchName = "master", revision = "draft" } = options;
|
|
2132
|
+
const branch = {
|
|
2133
|
+
organizationId,
|
|
2134
|
+
projectName,
|
|
2135
|
+
branchName
|
|
2136
|
+
};
|
|
2137
|
+
let revisionId;
|
|
2138
|
+
let isDraft;
|
|
2139
|
+
let revisionMode;
|
|
2140
|
+
if (revision === "draft") {
|
|
2141
|
+
revisionId = await fetchDraftRevisionId(this._client, branch);
|
|
2142
|
+
isDraft = true;
|
|
2143
|
+
revisionMode = "draft";
|
|
2144
|
+
} else if (revision === "head") {
|
|
2145
|
+
revisionId = await fetchHeadRevisionId(this._client, branch);
|
|
2146
|
+
isDraft = false;
|
|
2147
|
+
revisionMode = "head";
|
|
2148
|
+
} else {
|
|
2149
|
+
await validateRevisionId(this._client, revision);
|
|
2150
|
+
revisionId = revision;
|
|
2151
|
+
isDraft = false;
|
|
2152
|
+
revisionMode = "explicit";
|
|
2153
|
+
}
|
|
2154
|
+
const scope = new RevisiumScope({
|
|
2155
|
+
client: this._client,
|
|
2156
|
+
branch,
|
|
2157
|
+
revisionId,
|
|
2158
|
+
isDraft,
|
|
2159
|
+
revisionMode,
|
|
2160
|
+
owner: this
|
|
2161
|
+
});
|
|
2162
|
+
const branchKey = `${organizationId}/${projectName}/${branchName}`;
|
|
2163
|
+
let scopeSet = this._scopes.get(branchKey);
|
|
2164
|
+
if (!scopeSet) {
|
|
2165
|
+
scopeSet = /* @__PURE__ */ new Set();
|
|
2166
|
+
this._scopes.set(branchKey, scopeSet);
|
|
2167
|
+
}
|
|
2168
|
+
scopeSet.add(scope);
|
|
2169
|
+
return scope;
|
|
2170
|
+
}
|
|
2171
|
+
notifyBranchChanged(branchKey, excludeScope) {
|
|
2172
|
+
const scopeSet = this._scopes.get(branchKey);
|
|
2173
|
+
if (!scopeSet) return;
|
|
2174
|
+
for (const scope of scopeSet) if (scope !== excludeScope) scope.markStale();
|
|
2175
|
+
}
|
|
2176
|
+
unregisterScope(scope) {
|
|
2177
|
+
for (const [key, scopeSet] of this._scopes) {
|
|
2178
|
+
scopeSet.delete(scope);
|
|
2179
|
+
if (scopeSet.size === 0) this._scopes.delete(key);
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
get _scopeContext() {
|
|
2183
|
+
return {
|
|
2184
|
+
client: this._client,
|
|
2185
|
+
branch: {
|
|
2186
|
+
organizationId: this._organizationId ?? "",
|
|
2187
|
+
projectName: this._projectName ?? "",
|
|
2188
|
+
branchName: this._branchName ?? ""
|
|
2189
|
+
},
|
|
2190
|
+
isDraft: this._isDraft,
|
|
2191
|
+
getRevisionId: () => {
|
|
2192
|
+
if (this._revisionId === null) return Promise.reject(/* @__PURE__ */ new Error("Context not set. Call setContext() first."));
|
|
2193
|
+
return Promise.resolve(this._revisionId);
|
|
2194
|
+
}
|
|
2195
|
+
};
|
|
2196
|
+
}
|
|
2197
|
+
async getTables(options) {
|
|
2198
|
+
return getTables(this._scopeContext, options);
|
|
2199
|
+
}
|
|
2200
|
+
async getTable(tableId) {
|
|
2201
|
+
return getTable(this._scopeContext, tableId);
|
|
2202
|
+
}
|
|
2203
|
+
async getTableSchema(tableId) {
|
|
2204
|
+
return getTableSchema(this._scopeContext, tableId);
|
|
2205
|
+
}
|
|
2206
|
+
async getRows(tableId, options) {
|
|
2207
|
+
return getRows(this._scopeContext, tableId, options);
|
|
2208
|
+
}
|
|
2209
|
+
async getRow(tableId, rowId) {
|
|
2210
|
+
return getRow(this._scopeContext, tableId, rowId);
|
|
2211
|
+
}
|
|
2212
|
+
async getChanges() {
|
|
2213
|
+
return getChanges(this._scopeContext);
|
|
2214
|
+
}
|
|
2215
|
+
async createTable(tableId, schema) {
|
|
2216
|
+
return createTable(this._scopeContext, tableId, schema);
|
|
2217
|
+
}
|
|
2218
|
+
async updateTable(tableId, patches) {
|
|
2219
|
+
return updateTable(this._scopeContext, tableId, patches);
|
|
2220
|
+
}
|
|
2221
|
+
async deleteTable(tableId) {
|
|
2222
|
+
return deleteTable(this._scopeContext, tableId);
|
|
2223
|
+
}
|
|
2224
|
+
async renameTable(tableId, nextTableId) {
|
|
2225
|
+
return renameTable(this._scopeContext, tableId, nextTableId);
|
|
2226
|
+
}
|
|
2227
|
+
async createRow(tableId, rowId, data) {
|
|
2228
|
+
return createRow(this._scopeContext, tableId, rowId, data);
|
|
2229
|
+
}
|
|
2230
|
+
async createRows(tableId, rows) {
|
|
2231
|
+
return createRows(this._scopeContext, tableId, rows);
|
|
2232
|
+
}
|
|
2233
|
+
async updateRow(tableId, rowId, data) {
|
|
2234
|
+
return updateRow(this._scopeContext, tableId, rowId, data);
|
|
2235
|
+
}
|
|
2236
|
+
async updateRows(tableId, rows) {
|
|
2237
|
+
return updateRows(this._scopeContext, tableId, rows);
|
|
2238
|
+
}
|
|
2239
|
+
async patchRow(tableId, rowId, patches) {
|
|
2240
|
+
return patchRow(this._scopeContext, tableId, rowId, patches);
|
|
2241
|
+
}
|
|
2242
|
+
async deleteRow(tableId, rowId) {
|
|
2243
|
+
return deleteRow(this._scopeContext, tableId, rowId);
|
|
2244
|
+
}
|
|
2245
|
+
async deleteRows(tableId, rowIds) {
|
|
2246
|
+
return deleteRows(this._scopeContext, tableId, rowIds);
|
|
2247
|
+
}
|
|
2248
|
+
async renameRow(tableId, rowId, nextRowId) {
|
|
2249
|
+
return renameRow(this._scopeContext, tableId, rowId, nextRowId);
|
|
2250
|
+
}
|
|
2251
|
+
async commit(comment) {
|
|
2252
|
+
const data = await commit(this._scopeContext, comment);
|
|
2253
|
+
await this.refreshDraftRevisionId();
|
|
2254
|
+
this.notifyScopesOnCurrentBranch();
|
|
2255
|
+
return data;
|
|
2256
|
+
}
|
|
2257
|
+
async revertChanges() {
|
|
2258
|
+
await revertChanges(this._scopeContext);
|
|
2259
|
+
await this.refreshDraftRevisionId();
|
|
2260
|
+
this.notifyScopesOnCurrentBranch();
|
|
2261
|
+
}
|
|
2262
|
+
async refreshDraftRevisionId() {
|
|
2263
|
+
this._revisionId = await fetchDraftRevisionId(this._client, {
|
|
2264
|
+
organizationId: this._organizationId,
|
|
2265
|
+
projectName: this._projectName,
|
|
2266
|
+
branchName: this._branchName
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
notifyScopesOnCurrentBranch() {
|
|
2270
|
+
if (this._organizationId && this._projectName && this._branchName) {
|
|
2271
|
+
const branchKey = `${this._organizationId}/${this._projectName}/${this._branchName}`;
|
|
2272
|
+
this.notifyBranchChanged(branchKey);
|
|
2273
|
+
}
|
|
14
2274
|
}
|
|
15
2275
|
};
|
|
16
2276
|
|
|
17
2277
|
//#endregion
|
|
18
|
-
export { RevisiumClient };
|
|
2278
|
+
export { RevisiumClient, RevisiumScope, client, sdk_gen_exports as sdk };
|
|
19
2279
|
//# sourceMappingURL=index.mjs.map
|