@livechat/developer-studio-api 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +80 -0
- package/dist/index.mjs +80 -0
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -2097,6 +2097,16 @@ declare const api: {
|
|
|
2097
2097
|
createRepositoryBuildHook(repositoryName: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<{
|
|
2098
2098
|
keys: GitHubRepositoryHook[];
|
|
2099
2099
|
} | undefined>;
|
|
2100
|
+
getFile(path: string, repositoryName: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<any>;
|
|
2101
|
+
commitFiles(data: {
|
|
2102
|
+
repositoryName: string;
|
|
2103
|
+
repositoryBranch: string;
|
|
2104
|
+
message: string;
|
|
2105
|
+
files: {
|
|
2106
|
+
path: string;
|
|
2107
|
+
content: string | null;
|
|
2108
|
+
}[];
|
|
2109
|
+
}, authorization?: GithubClientInstanceAuthorization | undefined): Promise<void>;
|
|
2100
2110
|
};
|
|
2101
2111
|
getToken(code: string, clientId: string, clientSecret: string, redirectUrl: string): Promise<string>;
|
|
2102
2112
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -2097,6 +2097,16 @@ declare const api: {
|
|
|
2097
2097
|
createRepositoryBuildHook(repositoryName: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<{
|
|
2098
2098
|
keys: GitHubRepositoryHook[];
|
|
2099
2099
|
} | undefined>;
|
|
2100
|
+
getFile(path: string, repositoryName: string, authorization?: GithubClientInstanceAuthorization | undefined): Promise<any>;
|
|
2101
|
+
commitFiles(data: {
|
|
2102
|
+
repositoryName: string;
|
|
2103
|
+
repositoryBranch: string;
|
|
2104
|
+
message: string;
|
|
2105
|
+
files: {
|
|
2106
|
+
path: string;
|
|
2107
|
+
content: string | null;
|
|
2108
|
+
}[];
|
|
2109
|
+
}, authorization?: GithubClientInstanceAuthorization | undefined): Promise<void>;
|
|
2100
2110
|
};
|
|
2101
2111
|
getToken(code: string, clientId: string, clientSecret: string, redirectUrl: string): Promise<string>;
|
|
2102
2112
|
};
|
package/dist/index.js
CHANGED
|
@@ -547,6 +547,86 @@ var gitHubRepositoryApi = {
|
|
|
547
547
|
} catch (e) {
|
|
548
548
|
}
|
|
549
549
|
});
|
|
550
|
+
},
|
|
551
|
+
getFile(path, repositoryName, authorization) {
|
|
552
|
+
return __async(this, null, function* () {
|
|
553
|
+
var _a;
|
|
554
|
+
const { data } = yield githubClientInstance.get(
|
|
555
|
+
`/repos/${repositoryName}/contents/${path}`,
|
|
556
|
+
getGithubClientRequestConfig({
|
|
557
|
+
token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
|
|
558
|
+
ensureAuthorizationToken: true
|
|
559
|
+
})
|
|
560
|
+
);
|
|
561
|
+
return data;
|
|
562
|
+
});
|
|
563
|
+
},
|
|
564
|
+
commitFiles(data, authorization) {
|
|
565
|
+
return __async(this, null, function* () {
|
|
566
|
+
var _a, _b, _c, _d, _e;
|
|
567
|
+
const MODES = { FILE: "100644", FOLDER: "040000" };
|
|
568
|
+
const TYPE = { BLOB: "blob", TREE: "tree" };
|
|
569
|
+
const {
|
|
570
|
+
data: {
|
|
571
|
+
object: { sha: currentCommitSha }
|
|
572
|
+
}
|
|
573
|
+
} = yield githubClientInstance.get(
|
|
574
|
+
`/repos/${data.repositoryName}/git/refs/heads/${data.repositoryBranch}`,
|
|
575
|
+
getGithubClientRequestConfig({
|
|
576
|
+
token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
|
|
577
|
+
ensureAuthorizationToken: true
|
|
578
|
+
})
|
|
579
|
+
);
|
|
580
|
+
const {
|
|
581
|
+
data: {
|
|
582
|
+
tree: { sha: treeSha }
|
|
583
|
+
}
|
|
584
|
+
} = yield githubClientInstance.get(
|
|
585
|
+
`/repos/${data.repositoryName}/git/commits/${currentCommitSha}`,
|
|
586
|
+
getGithubClientRequestConfig({
|
|
587
|
+
token: (_b = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _b.app,
|
|
588
|
+
ensureAuthorizationToken: true
|
|
589
|
+
})
|
|
590
|
+
);
|
|
591
|
+
const {
|
|
592
|
+
data: { sha: newTreeSha }
|
|
593
|
+
} = yield githubClientInstance.post(
|
|
594
|
+
`/repos/${data.repositoryName}/git/trees`,
|
|
595
|
+
{
|
|
596
|
+
base_tree: treeSha,
|
|
597
|
+
tree: data.files.map(
|
|
598
|
+
({ content, path }) => content ? { path, content, mode: MODES.FILE, type: TYPE.BLOB } : { path, sha: null, mode: MODES.FILE, type: TYPE.BLOB }
|
|
599
|
+
// If sha is null => the file gets deleted
|
|
600
|
+
)
|
|
601
|
+
},
|
|
602
|
+
getGithubClientRequestConfig({
|
|
603
|
+
token: (_c = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _c.app,
|
|
604
|
+
ensureAuthorizationToken: true
|
|
605
|
+
})
|
|
606
|
+
);
|
|
607
|
+
const {
|
|
608
|
+
data: { sha: newCommitSha }
|
|
609
|
+
} = yield githubClientInstance.post(
|
|
610
|
+
`/repos/${data.repositoryName}/git/commits`,
|
|
611
|
+
{
|
|
612
|
+
message: data.message,
|
|
613
|
+
tree: newTreeSha,
|
|
614
|
+
parents: [currentCommitSha]
|
|
615
|
+
},
|
|
616
|
+
getGithubClientRequestConfig({
|
|
617
|
+
token: (_d = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _d.app,
|
|
618
|
+
ensureAuthorizationToken: true
|
|
619
|
+
})
|
|
620
|
+
);
|
|
621
|
+
yield githubClientInstance.post(
|
|
622
|
+
`/repos/${data.repositoryName}/git/refs/heads/${data.repositoryBranch}`,
|
|
623
|
+
{ sha: newCommitSha },
|
|
624
|
+
getGithubClientRequestConfig({
|
|
625
|
+
token: (_e = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _e.app,
|
|
626
|
+
ensureAuthorizationToken: true
|
|
627
|
+
})
|
|
628
|
+
);
|
|
629
|
+
});
|
|
550
630
|
}
|
|
551
631
|
};
|
|
552
632
|
|
package/dist/index.mjs
CHANGED
|
@@ -463,6 +463,86 @@ var gitHubRepositoryApi = {
|
|
|
463
463
|
} catch (e) {
|
|
464
464
|
}
|
|
465
465
|
});
|
|
466
|
+
},
|
|
467
|
+
getFile(path, repositoryName, authorization) {
|
|
468
|
+
return __async(this, null, function* () {
|
|
469
|
+
var _a;
|
|
470
|
+
const { data } = yield githubClientInstance.get(
|
|
471
|
+
`/repos/${repositoryName}/contents/${path}`,
|
|
472
|
+
getGithubClientRequestConfig({
|
|
473
|
+
token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
|
|
474
|
+
ensureAuthorizationToken: true
|
|
475
|
+
})
|
|
476
|
+
);
|
|
477
|
+
return data;
|
|
478
|
+
});
|
|
479
|
+
},
|
|
480
|
+
commitFiles(data, authorization) {
|
|
481
|
+
return __async(this, null, function* () {
|
|
482
|
+
var _a, _b, _c, _d, _e;
|
|
483
|
+
const MODES = { FILE: "100644", FOLDER: "040000" };
|
|
484
|
+
const TYPE = { BLOB: "blob", TREE: "tree" };
|
|
485
|
+
const {
|
|
486
|
+
data: {
|
|
487
|
+
object: { sha: currentCommitSha }
|
|
488
|
+
}
|
|
489
|
+
} = yield githubClientInstance.get(
|
|
490
|
+
`/repos/${data.repositoryName}/git/refs/heads/${data.repositoryBranch}`,
|
|
491
|
+
getGithubClientRequestConfig({
|
|
492
|
+
token: (_a = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _a.app,
|
|
493
|
+
ensureAuthorizationToken: true
|
|
494
|
+
})
|
|
495
|
+
);
|
|
496
|
+
const {
|
|
497
|
+
data: {
|
|
498
|
+
tree: { sha: treeSha }
|
|
499
|
+
}
|
|
500
|
+
} = yield githubClientInstance.get(
|
|
501
|
+
`/repos/${data.repositoryName}/git/commits/${currentCommitSha}`,
|
|
502
|
+
getGithubClientRequestConfig({
|
|
503
|
+
token: (_b = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _b.app,
|
|
504
|
+
ensureAuthorizationToken: true
|
|
505
|
+
})
|
|
506
|
+
);
|
|
507
|
+
const {
|
|
508
|
+
data: { sha: newTreeSha }
|
|
509
|
+
} = yield githubClientInstance.post(
|
|
510
|
+
`/repos/${data.repositoryName}/git/trees`,
|
|
511
|
+
{
|
|
512
|
+
base_tree: treeSha,
|
|
513
|
+
tree: data.files.map(
|
|
514
|
+
({ content, path }) => content ? { path, content, mode: MODES.FILE, type: TYPE.BLOB } : { path, sha: null, mode: MODES.FILE, type: TYPE.BLOB }
|
|
515
|
+
// If sha is null => the file gets deleted
|
|
516
|
+
)
|
|
517
|
+
},
|
|
518
|
+
getGithubClientRequestConfig({
|
|
519
|
+
token: (_c = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _c.app,
|
|
520
|
+
ensureAuthorizationToken: true
|
|
521
|
+
})
|
|
522
|
+
);
|
|
523
|
+
const {
|
|
524
|
+
data: { sha: newCommitSha }
|
|
525
|
+
} = yield githubClientInstance.post(
|
|
526
|
+
`/repos/${data.repositoryName}/git/commits`,
|
|
527
|
+
{
|
|
528
|
+
message: data.message,
|
|
529
|
+
tree: newTreeSha,
|
|
530
|
+
parents: [currentCommitSha]
|
|
531
|
+
},
|
|
532
|
+
getGithubClientRequestConfig({
|
|
533
|
+
token: (_d = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _d.app,
|
|
534
|
+
ensureAuthorizationToken: true
|
|
535
|
+
})
|
|
536
|
+
);
|
|
537
|
+
yield githubClientInstance.post(
|
|
538
|
+
`/repos/${data.repositoryName}/git/refs/heads/${data.repositoryBranch}`,
|
|
539
|
+
{ sha: newCommitSha },
|
|
540
|
+
getGithubClientRequestConfig({
|
|
541
|
+
token: (_e = authorization == null ? void 0 : authorization.tokens) == null ? void 0 : _e.app,
|
|
542
|
+
ensureAuthorizationToken: true
|
|
543
|
+
})
|
|
544
|
+
);
|
|
545
|
+
});
|
|
466
546
|
}
|
|
467
547
|
};
|
|
468
548
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livechat/developer-studio-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "This project is API for LiveChat Developer Studio.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"tsup": "^7.1.0",
|
|
19
19
|
"typescript": "^5.1.6",
|
|
20
20
|
"config": "0.0.0",
|
|
21
|
-
"tsconfig": "0.0.0",
|
|
22
21
|
"eslint-config-custom-lib": "0.0.1",
|
|
22
|
+
"tsconfig": "0.0.0",
|
|
23
23
|
"types": "0.0.1"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|