@cloudcannon/sdk 0.0.3 → 0.0.5
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 +1534 -0
- package/dist/index.d.ts +21 -11
- package/dist/index.js +44 -19
- package/dist/src/helpers/query.d.ts +1 -1
- package/dist/src/helpers/query.js +6 -2
- package/dist/src/inbox.d.ts +2 -1
- package/dist/src/inbox.js +1 -1
- package/dist/src/org.d.ts +6 -3
- package/dist/src/org.js +3 -3
- package/dist/src/site.d.ts +7 -3
- package/dist/src/site.js +12 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { components, operations, paths } from './schema.ts';
|
|
2
2
|
import { BackupClient } from './src/backup.ts';
|
|
3
3
|
import { BuildClient } from './src/build.ts';
|
|
4
|
-
import { type CommitEditingSessionOptions, type CommitEditingSessionResponse, EditingSessionClient } from './src/editing-session.ts';
|
|
5
|
-
import { EditingSessionFileClient } from './src/editing-session-file.ts';
|
|
4
|
+
import { type CommitEditingSessionOptions, type CommitEditingSessionResponse, type CreateEditingSessionFileOptions, EditingSessionClient } from './src/editing-session.ts';
|
|
5
|
+
import { type CreateContributionOptions, EditingSessionFileClient, type UnlockOptions } from './src/editing-session-file.ts';
|
|
6
6
|
import { type FilterOptions, type PaginatedResponse, type PaginationOptions, type SortingOptions } from './src/helpers/query.ts';
|
|
7
|
-
import { InboxClient } from './src/inbox.ts';
|
|
8
|
-
import { OrgClient } from './src/org.ts';
|
|
9
|
-
import { type BuildConfiguration, SiteClient } from './src/site.ts';
|
|
10
|
-
import { SiteInboxClient } from './src/site-inbox.ts';
|
|
7
|
+
import { InboxClient, type ListInboxSubmissionsOptions } from './src/inbox.ts';
|
|
8
|
+
import { type ConnectSiteOptions, type CreateDamOptions, type CreateInboxOptions, type ListOrgDamsOptions, type ListOrgInboxesOptions, type ListOrgSitesOptions, OrgClient } from './src/org.ts';
|
|
9
|
+
import { type BuildConfiguration, type ConnectDamOptions, type ConnectInboxOptions, type CopySiteOptions, type CreateBackupOptions, type ListSiteBackupsOptions, type ListSiteBuildsOptions, type ListSiteSyncsOptions, SiteClient, type UpdateSiteOptions, type UploadFileOptions } from './src/site.ts';
|
|
10
|
+
import { SiteInboxClient, type UpdateInboxOptions } from './src/site-inbox.ts';
|
|
11
11
|
import { SyncClient } from './src/sync.ts';
|
|
12
|
-
export type { BuildConfiguration, CommitEditingSessionOptions, CommitEditingSessionResponse, FilterOptions, PaginatedResponse, PaginationOptions, SortingOptions, };
|
|
12
|
+
export type { BuildConfiguration, CommitEditingSessionOptions, CommitEditingSessionResponse, ConnectDamOptions, ConnectInboxOptions, ConnectSiteOptions, CopySiteOptions, CreateBackupOptions, CreateContributionOptions, CreateDamOptions, CreateEditingSessionFileOptions, CreateInboxOptions, FilterOptions, ListInboxSubmissionsOptions, ListOrgDamsOptions, ListOrgInboxesOptions, ListOrgSitesOptions, ListOrgsOptions, ListSiteBackupsOptions, ListSiteBuildsOptions, ListSiteSyncsOptions, PaginatedResponse, PaginationOptions, SortingOptions, UnlockOptions, UpdateInboxOptions, UpdateSiteOptions, UploadFileOptions, };
|
|
13
13
|
export type Provider = operations['Providers_Repositories']['parameters']['path']['provider'];
|
|
14
14
|
export type Site = components['schemas']['SiteBlueprint'];
|
|
15
15
|
export type Backup = components['schemas']['SiteArchiveBlueprint'];
|
|
@@ -31,6 +31,7 @@ export type ProviderDetails = {
|
|
|
31
31
|
repository: string;
|
|
32
32
|
branch: string;
|
|
33
33
|
};
|
|
34
|
+
type ListOrgsOptions = PaginationOptions & SortingOptions<operations['Organizations_Index']> & FilterOptions<operations['Organizations_Index']>;
|
|
34
35
|
type ParamToString<S extends string> = S extends `${infer A}/{${string}}/${infer B}` ? `${A}/${string}/${ParamToString<B>}` : S extends `${infer A}/{${string}}` ? `${A}/${string}` : S;
|
|
35
36
|
type StripPrefix<S extends string> = S extends `/api/v0${infer Rest}` ? Rest : never;
|
|
36
37
|
type StripParams<S extends string> = S extends `${infer Path}?${string}` ? Path : S;
|
|
@@ -71,15 +72,24 @@ type MatchURL<M extends keyof paths[keyof paths], U extends string> = {
|
|
|
71
72
|
type ValidURL<M extends keyof paths[keyof paths], U extends string> = MatchURL<M, U> extends never ? {
|
|
72
73
|
[K in keyof paths]: RequestParams<paths[K][M]> extends never ? never : StripPrefix<K>;
|
|
73
74
|
}[keyof paths] : U;
|
|
74
|
-
|
|
75
|
-
key: string;
|
|
75
|
+
type BaseCloudCannonClientConfig = {
|
|
76
76
|
apiOrigin?: string;
|
|
77
77
|
getCustomAuthHeaders?: () => Record<string, string>;
|
|
78
78
|
};
|
|
79
|
+
export type CloudCannonClientConfig = ({
|
|
80
|
+
key: string;
|
|
81
|
+
} & BaseCloudCannonClientConfig) | ({
|
|
82
|
+
userAccessKey: UserAccessKey;
|
|
83
|
+
} & BaseCloudCannonClientConfig);
|
|
84
|
+
export type UserAccessKey = {
|
|
85
|
+
id: string;
|
|
86
|
+
secret: string;
|
|
87
|
+
};
|
|
79
88
|
export default class CloudCannonClient {
|
|
80
89
|
#private;
|
|
81
90
|
constructor(config: CloudCannonClientConfig);
|
|
82
|
-
getAuthHeaders(): Record<string, string
|
|
91
|
+
getAuthHeaders(url: string, body?: string): Promise<Record<string, string>>;
|
|
92
|
+
signRequest(userAccessKey: UserAccessKey, url: string, body?: string | null): Promise<Record<string, string>>;
|
|
83
93
|
fetch<const U extends string, const M extends Uppercase<keyof paths[keyof paths]> = 'GET'>(url: ValidURL<Lowercase<M>, U>, options?: Omit<RequestInit, keyof RequestMixin<M, MatchURL<Lowercase<M>, U>[Lowercase<M>]>> & RequestMixin<M, MatchURL<Lowercase<M>, U>[Lowercase<M>]>): Promise<APIResponse<MatchURL<Lowercase<M>, U>[Lowercase<M>]>>;
|
|
84
94
|
org(uuid: string): OrgClient;
|
|
85
95
|
site(uuid: string): SiteClient;
|
|
@@ -90,6 +100,6 @@ export default class CloudCannonClient {
|
|
|
90
100
|
build(uuid: string): BuildClient;
|
|
91
101
|
backup(uuid: string): BackupClient;
|
|
92
102
|
sync(uuid: string): SyncClient;
|
|
93
|
-
orgs(options?:
|
|
103
|
+
orgs(options?: ListOrgsOptions): Promise<PaginatedResponse<Org>>;
|
|
94
104
|
getUploadData(): Promise<UploadData>;
|
|
95
105
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,50 +1,75 @@
|
|
|
1
|
+
import { createHmac, randomUUID } from 'node:crypto';
|
|
1
2
|
import { BackupClient } from "./src/backup.js";
|
|
2
3
|
import { BuildClient } from "./src/build.js";
|
|
3
4
|
import { EditingSessionClient, } from "./src/editing-session.js";
|
|
4
|
-
import { EditingSessionFileClient } from "./src/editing-session-file.js";
|
|
5
|
+
import { EditingSessionFileClient, } from "./src/editing-session-file.js";
|
|
5
6
|
import { buildQuery, paginatedResponse, } from "./src/helpers/query.js";
|
|
6
7
|
import { InboxClient } from "./src/inbox.js";
|
|
7
|
-
import { OrgClient } from "./src/org.js";
|
|
8
|
-
import { SiteClient } from "./src/site.js";
|
|
8
|
+
import { OrgClient, } from "./src/org.js";
|
|
9
|
+
import { SiteClient, } from "./src/site.js";
|
|
9
10
|
import { SiteInboxClient } from "./src/site-inbox.js";
|
|
10
11
|
import { SyncClient } from "./src/sync.js";
|
|
11
12
|
export default class CloudCannonClient {
|
|
12
13
|
#apiKey;
|
|
14
|
+
#userAccessKey;
|
|
13
15
|
#appDomain;
|
|
14
16
|
#getCustomAuthHeaders;
|
|
15
17
|
constructor(config) {
|
|
16
|
-
|
|
18
|
+
if ('userAccessKey' in config) {
|
|
19
|
+
this.#userAccessKey = config.userAccessKey;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.#apiKey = config.key;
|
|
23
|
+
}
|
|
17
24
|
this.#appDomain = config.apiOrigin ?? 'app.cloudcannon.com';
|
|
18
25
|
this.#getCustomAuthHeaders = config.getCustomAuthHeaders;
|
|
19
26
|
}
|
|
20
|
-
getAuthHeaders() {
|
|
27
|
+
async getAuthHeaders(url, body) {
|
|
21
28
|
if (this.#getCustomAuthHeaders) {
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
return this.#getCustomAuthHeaders();
|
|
30
|
+
}
|
|
31
|
+
if (this.#userAccessKey) {
|
|
32
|
+
return this.signRequest(this.#userAccessKey, url, body);
|
|
25
33
|
}
|
|
26
34
|
return {
|
|
27
35
|
'X-API-KEY': `${this.#apiKey}`,
|
|
28
36
|
};
|
|
29
37
|
}
|
|
38
|
+
async signRequest(userAccessKey, url, body) {
|
|
39
|
+
const signedAtISO = new Date().toISOString();
|
|
40
|
+
const nonce = randomUUID();
|
|
41
|
+
const key = Buffer.from(userAccessKey.secret, 'base64');
|
|
42
|
+
const message = JSON.stringify({ url, signed_at: signedAtISO, body: body ?? '', nonce });
|
|
43
|
+
const digest = createHmac('sha256', key).update(message).digest('hex');
|
|
44
|
+
return {
|
|
45
|
+
'X-CC-ACCESS-KEY': userAccessKey.id,
|
|
46
|
+
'X-CC-SIGNED-AT': signedAtISO,
|
|
47
|
+
'X-CC-CHECKSUM': digest,
|
|
48
|
+
'X-CC-NONCE': nonce,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
30
51
|
async fetch(url, options) {
|
|
52
|
+
const fullUrl = `https://${this.#appDomain}/api/v0${url}`;
|
|
53
|
+
let body;
|
|
54
|
+
if (options?.body) {
|
|
55
|
+
if (typeof options?.body !== 'string') {
|
|
56
|
+
body = JSON.stringify(options.body);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
body = options.body;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const authHeaders = await this.getAuthHeaders(fullUrl, body);
|
|
31
63
|
const requestInit = {
|
|
32
64
|
...options,
|
|
33
65
|
headers: {
|
|
34
|
-
...
|
|
66
|
+
...authHeaders,
|
|
35
67
|
'Content-Type': 'application/json',
|
|
36
68
|
...options?.headers,
|
|
37
69
|
},
|
|
70
|
+
body,
|
|
38
71
|
};
|
|
39
|
-
|
|
40
|
-
if (typeof options?.body !== 'string') {
|
|
41
|
-
requestInit.body = JSON.stringify(options.body);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
requestInit.body = options.body;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return fetch(`https://${this.#appDomain}/api/v0${url}`, requestInit);
|
|
72
|
+
return fetch(fullUrl, requestInit);
|
|
48
73
|
}
|
|
49
74
|
org(uuid) {
|
|
50
75
|
return new OrgClient(uuid, this);
|
|
@@ -75,7 +100,7 @@ export default class CloudCannonClient {
|
|
|
75
100
|
}
|
|
76
101
|
async orgs(options = {}) {
|
|
77
102
|
const query = buildQuery(options);
|
|
78
|
-
const resp = await this.fetch(`/orgs
|
|
103
|
+
const resp = await this.fetch(`/orgs${query}`);
|
|
79
104
|
if (resp.status === 403) {
|
|
80
105
|
throw new Error('Error fetching orgs. Permission denied');
|
|
81
106
|
}
|
|
@@ -24,5 +24,5 @@ export declare function buildQuery(options?: PaginationOptions & {
|
|
|
24
24
|
sort_attribute?: string;
|
|
25
25
|
sort_direction?: 'ASC' | 'DESC';
|
|
26
26
|
filters?: Record<string, unknown>;
|
|
27
|
-
}): string;
|
|
27
|
+
}): `?${string}` | '';
|
|
28
28
|
export declare function paginatedResponse<T>(items: T[], headers: Headers): PaginatedResponse<T>;
|
|
@@ -3,7 +3,7 @@ export function buildQuery(options = {}) {
|
|
|
3
3
|
if (options.page !== undefined)
|
|
4
4
|
params.set('page', String(options.page));
|
|
5
5
|
if (options.items !== undefined)
|
|
6
|
-
params.set('
|
|
6
|
+
params.set('items', String(options.items));
|
|
7
7
|
if (options.sort_attribute !== undefined)
|
|
8
8
|
params.set('sort_attribute', options.sort_attribute);
|
|
9
9
|
if (options.sort_direction !== undefined)
|
|
@@ -15,7 +15,11 @@ export function buildQuery(options = {}) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
const result = params.toString();
|
|
19
|
+
if (result.length > 0) {
|
|
20
|
+
return `?${result}`;
|
|
21
|
+
}
|
|
22
|
+
return '';
|
|
19
23
|
}
|
|
20
24
|
export function paginatedResponse(items, headers) {
|
|
21
25
|
const parse = (name) => {
|
package/dist/src/inbox.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import type CloudCannonClient from '../index.ts';
|
|
|
2
2
|
import type { FormSubmission } from '../index.ts';
|
|
3
3
|
import type { operations } from '../schema.js';
|
|
4
4
|
import { type FilterOptions, type PaginatedResponse, type PaginationOptions, type SortingOptions } from './helpers/query.ts';
|
|
5
|
+
export type ListInboxSubmissionsOptions = PaginationOptions & SortingOptions<operations['Inbox Form Hooks_Index']> & FilterOptions<operations['Inbox Form Hooks_Index']>;
|
|
5
6
|
export declare class InboxClient {
|
|
6
7
|
#private;
|
|
7
8
|
constructor(uuid: string, client: CloudCannonClient);
|
|
8
|
-
getSubmissions(options?:
|
|
9
|
+
getSubmissions(options?: ListInboxSubmissionsOptions): Promise<PaginatedResponse<FormSubmission>>;
|
|
9
10
|
}
|
package/dist/src/inbox.js
CHANGED
|
@@ -8,7 +8,7 @@ export class InboxClient {
|
|
|
8
8
|
}
|
|
9
9
|
async getSubmissions(options = {}) {
|
|
10
10
|
const query = buildQuery(options);
|
|
11
|
-
const resp = await this.#client.fetch(`/inboxes/${this.#uuid}/form-hooks
|
|
11
|
+
const resp = await this.#client.fetch(`/inboxes/${this.#uuid}/form-hooks${query}`);
|
|
12
12
|
if (resp.status === 401 || resp.status === 403) {
|
|
13
13
|
throw new Error('Error fetching submissions. Permission denied');
|
|
14
14
|
}
|
package/dist/src/org.d.ts
CHANGED
|
@@ -6,18 +6,21 @@ export interface ConnectSiteOptions extends ProviderDetails {
|
|
|
6
6
|
folder?: string;
|
|
7
7
|
}
|
|
8
8
|
export type Repository = operations['Providers_Repositories']['responses']['200']['content']['application/json'][number];
|
|
9
|
+
export type ListOrgSitesOptions = PaginationOptions & SortingOptions<operations['Sites_Index']> & FilterOptions<operations['Sites_Index']>;
|
|
10
|
+
export type ListOrgInboxesOptions = PaginationOptions & SortingOptions<operations['Organization Inboxes_Index']> & FilterOptions<operations['Organization Inboxes_Index']>;
|
|
11
|
+
export type ListOrgDamsOptions = PaginationOptions & SortingOptions<operations['DAMs_Index']> & FilterOptions<operations['DAMs_Index']>;
|
|
9
12
|
export type CreateInboxOptions = operations['Organization Inboxes_Create']['requestBody']['content']['application/json'];
|
|
10
13
|
export type CreateDamOptions = operations['DAMs_Create']['requestBody']['content']['application/json'];
|
|
11
14
|
export declare class OrgClient {
|
|
12
15
|
#private;
|
|
13
16
|
constructor(uuid: string, client: CloudCannonClient);
|
|
14
|
-
sites(options?:
|
|
17
|
+
sites(options?: ListOrgSitesOptions): Promise<PaginatedResponse<Site>>;
|
|
15
18
|
createSite(name: string, stableDomain?: string): Promise<Site>;
|
|
16
19
|
connectSite(name: string, providerDetails: ConnectSiteOptions, stableDomain?: string): Promise<Site>;
|
|
17
20
|
get(): Promise<Org>;
|
|
18
|
-
getInboxes(options?:
|
|
21
|
+
getInboxes(options?: ListOrgInboxesOptions): Promise<PaginatedResponse<Inbox>>;
|
|
19
22
|
createInbox(body: CreateInboxOptions): Promise<Inbox>;
|
|
20
|
-
getDams(options?:
|
|
23
|
+
getDams(options?: ListOrgDamsOptions): Promise<PaginatedResponse<Dam>>;
|
|
21
24
|
createDam(body: CreateDamOptions): Promise<Dam>;
|
|
22
25
|
getRepositories(provider: Provider): Promise<Repository[]>;
|
|
23
26
|
}
|
package/dist/src/org.js
CHANGED
|
@@ -9,7 +9,7 @@ export class OrgClient {
|
|
|
9
9
|
}
|
|
10
10
|
async sites(options = {}) {
|
|
11
11
|
const query = buildQuery(options);
|
|
12
|
-
const resp = await this.#client.fetch(`/orgs/${this.#uuid}/sites
|
|
12
|
+
const resp = await this.#client.fetch(`/orgs/${this.#uuid}/sites${query}`);
|
|
13
13
|
if (resp.status === 401 || resp.status === 403) {
|
|
14
14
|
throw new Error('Error fetching sites. Permission denied');
|
|
15
15
|
}
|
|
@@ -67,7 +67,7 @@ export class OrgClient {
|
|
|
67
67
|
}
|
|
68
68
|
async getInboxes(options = {}) {
|
|
69
69
|
const query = buildQuery(options);
|
|
70
|
-
const resp = await this.#client.fetch(`/orgs/${this.#uuid}/inboxes
|
|
70
|
+
const resp = await this.#client.fetch(`/orgs/${this.#uuid}/inboxes${query}`);
|
|
71
71
|
if (resp.status === 403) {
|
|
72
72
|
throw new Error('Error fetching inboxes. Permission denied');
|
|
73
73
|
}
|
|
@@ -91,7 +91,7 @@ export class OrgClient {
|
|
|
91
91
|
}
|
|
92
92
|
async getDams(options = {}) {
|
|
93
93
|
const query = buildQuery(options);
|
|
94
|
-
const resp = await this.#client.fetch(`/orgs/${this.#uuid}/dams
|
|
94
|
+
const resp = await this.#client.fetch(`/orgs/${this.#uuid}/dams${query}`);
|
|
95
95
|
const dams = await resp.json();
|
|
96
96
|
return paginatedResponse(dams, resp.headers);
|
|
97
97
|
}
|
package/dist/src/site.d.ts
CHANGED
|
@@ -23,6 +23,9 @@ export type BuildConfiguration = Partial<Omit<operations['Sites_UpdateBuild']['r
|
|
|
23
23
|
};
|
|
24
24
|
export type UpdateSiteOptions = operations['Sites_Update']['requestBody']['content']['application/json'];
|
|
25
25
|
export type CopySiteOptions = operations['Sites_Copy']['requestBody']['content']['application/json'];
|
|
26
|
+
export type ListSiteBuildsOptions = PaginationOptions & SortingOptions<operations['Builds_Index']> & FilterOptions<operations['Builds_Index']>;
|
|
27
|
+
export type ListSiteBackupsOptions = PaginationOptions & SortingOptions<operations['Backups_Index']> & FilterOptions<operations['Backups_Index']>;
|
|
28
|
+
export type ListSiteSyncsOptions = PaginationOptions & SortingOptions<operations['Syncs_Index']> & FilterOptions<operations['Syncs_Index']>;
|
|
26
29
|
export type CreateBackupOptions = operations['Backups_Create']['requestBody']['content']['application/json'];
|
|
27
30
|
export type ConnectInboxOptions = operations['Site Inboxes_Create']['requestBody']['content']['application/json'];
|
|
28
31
|
export type ConnectDamOptions = operations['Dams_Create']['requestBody']['content']['application/json'];
|
|
@@ -39,15 +42,15 @@ export declare class SiteClient {
|
|
|
39
42
|
delete(): Promise<void>;
|
|
40
43
|
copy(body: CopySiteOptions): Promise<Site>;
|
|
41
44
|
updateBuildConfig(options: BuildConfiguration): Promise<Site>;
|
|
42
|
-
getBuilds(options?:
|
|
45
|
+
getBuilds(options?: ListSiteBuildsOptions): Promise<PaginatedResponse<Build>>;
|
|
43
46
|
rebuild(): Promise<void>;
|
|
44
|
-
listBackups(options?:
|
|
47
|
+
listBackups(options?: ListSiteBackupsOptions): Promise<PaginatedResponse<Backup>>;
|
|
45
48
|
createBackup(body?: CreateBackupOptions): Promise<{
|
|
46
49
|
socket_message_id?: string;
|
|
47
50
|
}>;
|
|
48
51
|
listFiles(): Promise<FileListing[]>;
|
|
49
52
|
getFile(path: string): Promise<Response>;
|
|
50
|
-
getSyncs(options?:
|
|
53
|
+
getSyncs(options?: ListSiteSyncsOptions): Promise<PaginatedResponse<Sync>>;
|
|
51
54
|
getScan(): Promise<SiteScan>;
|
|
52
55
|
getScreenshotHashes(): Promise<Record<string, string>>;
|
|
53
56
|
getScreenshot(device: 'desktop' | 'mobile', path: string): Promise<Response>;
|
|
@@ -64,4 +67,5 @@ export declare class SiteClient {
|
|
|
64
67
|
createEditingSession(): Promise<EditingSession>;
|
|
65
68
|
getLatestEditingSession(): Promise<EditingSession>;
|
|
66
69
|
uploadFile(path: string, content: BlobPart, options?: UploadFileOptions): Promise<void>;
|
|
70
|
+
triggerPull(): Promise<void>;
|
|
67
71
|
}
|
package/dist/src/site.js
CHANGED
|
@@ -73,7 +73,7 @@ export class SiteClient {
|
|
|
73
73
|
}
|
|
74
74
|
async getBuilds(options = {}) {
|
|
75
75
|
const query = buildQuery(options);
|
|
76
|
-
const resp = await this.#client.fetch(`/sites/${this.#uuid}/builds
|
|
76
|
+
const resp = await this.#client.fetch(`/sites/${this.#uuid}/builds${query}`);
|
|
77
77
|
if (resp.status === 401 || resp.status === 403) {
|
|
78
78
|
throw new Error('Error fetching builds. Permission denied');
|
|
79
79
|
}
|
|
@@ -90,7 +90,7 @@ export class SiteClient {
|
|
|
90
90
|
}
|
|
91
91
|
async listBackups(options = {}) {
|
|
92
92
|
const query = buildQuery(options);
|
|
93
|
-
const resp = await this.#client.fetch(`/sites/${this.#uuid}/archives
|
|
93
|
+
const resp = await this.#client.fetch(`/sites/${this.#uuid}/archives${query}`);
|
|
94
94
|
if (resp.status === 401) {
|
|
95
95
|
throw new Error('Error fetching backups. Permission denied');
|
|
96
96
|
}
|
|
@@ -140,7 +140,7 @@ export class SiteClient {
|
|
|
140
140
|
}
|
|
141
141
|
async getSyncs(options = {}) {
|
|
142
142
|
const query = buildQuery(options);
|
|
143
|
-
const resp = await this.#client.fetch(`/sites/${this.#uuid}/syncs
|
|
143
|
+
const resp = await this.#client.fetch(`/sites/${this.#uuid}/syncs${query}`);
|
|
144
144
|
if (resp.status === 401) {
|
|
145
145
|
throw new Error('Error fetching syncs. Permission denied');
|
|
146
146
|
}
|
|
@@ -369,4 +369,13 @@ export class SiteClient {
|
|
|
369
369
|
previous_content_hash: contentHash,
|
|
370
370
|
});
|
|
371
371
|
}
|
|
372
|
+
async triggerPull() {
|
|
373
|
+
const resp = await this.#client.fetch(`/sites/${this.#uuid}/providers/sync`, {
|
|
374
|
+
method: 'POST',
|
|
375
|
+
});
|
|
376
|
+
if (resp.status === 422) {
|
|
377
|
+
const errorResp = await resp.json();
|
|
378
|
+
throw new ApiError('Error triggering pull on site. Invalid request', errorResp.errors, `/sites/${this.#uuid}/providers/sync`, { method: 'POST' }, resp.status);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
372
381
|
}
|