@phpsandbox/sdk 0.0.47 → 0.0.49

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 CHANGED
@@ -85,14 +85,19 @@ const persistent = await client.notebook.create('laravel', {
85
85
  persistent: true,
86
86
  });
87
87
 
88
+ const persistentFork = await created.fork({
89
+ persistent: true,
90
+ });
91
+
88
92
  console.log(persistent.data.policy);
93
+ console.log(persistentFork.data.policy);
89
94
  ```
90
95
 
91
96
  Notes:
92
97
 
93
98
  - `create()` and `fork()` initialize automatically.
94
99
  - `open()` and `get()` return a notebook instance; call `await notebook.ready()` before using tools.
95
- - API notebook creates are ephemeral by default. `persistent: true` requires an entitled account.
100
+ - API notebook creates and forks are ephemeral by default. `persistent: true` requires an entitled account.
96
101
 
97
102
  ## Services At A Glance
98
103
 
@@ -207,8 +212,37 @@ await notebook.git.sync(
207
212
 
208
213
  const history = await notebook.git.log('main');
209
214
  console.log(history[0]);
215
+
216
+ const review = await notebook.git.review();
217
+ await notebook.git.stage({ paths: review.files.filter((file) => file.unstaged).map((file) => file.path) });
218
+ await notebook.git.unstage({ path: 'README.md' });
219
+ await notebook.git.revert({ path: 'README.md' });
220
+ await notebook.git.revert({ path: 'staged-file.php', staged: true });
221
+
222
+ const fork = await notebook.fork();
223
+ const forkCredentials = await fork.git.credentials();
224
+ const preview = await notebook.git.diff({
225
+ url: forkCredentials.url,
226
+ token: forkCredentials.token,
227
+ });
228
+
229
+ if (preview.status === 'ready') {
230
+ const result = await notebook.git.merge({
231
+ url: forkCredentials.url,
232
+ token: forkCredentials.token,
233
+ expectedBaseRef: preview.baseRef,
234
+ author: 'PHPSandbox <hi@phpsandbox.io>',
235
+ message: 'Merge fork into base',
236
+ });
237
+
238
+ if (result.status === 'conflict') {
239
+ console.log(result.conflicts);
240
+ }
241
+ }
210
242
  ```
211
243
 
244
+ Fork diff requires the base and fork to share Git history. If they do not, `diff()` returns `status: 'unrelated'`.
245
+
212
246
  ### Mail
213
247
 
214
248
  ```ts
@@ -4036,6 +4036,36 @@ var Git = class {
4036
4036
  log(ref = "main") {
4037
4037
  return this.okra.invoke("git.log", { ref });
4038
4038
  }
4039
+ diff(input) {
4040
+ return this.okra.invoke("git.diff", input);
4041
+ }
4042
+ merge(input) {
4043
+ return this.okra.invoke("git.merge", input);
4044
+ }
4045
+ conflicts() {
4046
+ return this.okra.invoke("git.conflicts", {});
4047
+ }
4048
+ abortMerge() {
4049
+ return this.okra.invoke("git.resolve", { action: "abort" });
4050
+ }
4051
+ continueMerge(author, message) {
4052
+ return this.okra.invoke("git.resolve", { action: "continue", author, message });
4053
+ }
4054
+ review() {
4055
+ return this.okra.invoke("git.review", {});
4056
+ }
4057
+ stage(input = { all: true }) {
4058
+ return this.okra.invoke("git.stage", input);
4059
+ }
4060
+ unstage(input = { all: true }) {
4061
+ return this.okra.invoke("git.unstage", input);
4062
+ }
4063
+ revert(input) {
4064
+ return this.okra.invoke("git.revert", input);
4065
+ }
4066
+ credentials() {
4067
+ return this.okra.gitCredentials();
4068
+ }
4039
4069
  restore(ref) {
4040
4070
  return this.okra.invoke("git.restore", { ref });
4041
4071
  }
@@ -4822,10 +4852,14 @@ var NotebookApi = class {
4822
4852
  async delete(id) {
4823
4853
  await this.client.delete(`/notebook/${id}`);
4824
4854
  }
4825
- async fork(id) {
4826
- const response = await this.client.post(`/notebook/${id}/fork`);
4855
+ async fork(id, input = {}) {
4856
+ const response = await this.client.post(`/notebook/${id}/fork`, input);
4827
4857
  return this.init(new NotebookInstance(response.data, this.client));
4828
4858
  }
4859
+ async gitCredentials(id) {
4860
+ const response = await this.client.post(`/notebook/${id}/git/credentials`);
4861
+ return response.data;
4862
+ }
4829
4863
  async open(id) {
4830
4864
  const response = await this.client.get(`/notebook/${id}`);
4831
4865
  return new NotebookInstance(response.data, this.client);
@@ -5008,8 +5042,11 @@ var NotebookInstance = class {
5008
5042
  };
5009
5043
  return ready();
5010
5044
  }
5011
- fork() {
5012
- return this.client.notebook.fork(this.data.id);
5045
+ fork(input = {}) {
5046
+ return this.client.notebook.fork(this.data.id, input);
5047
+ }
5048
+ gitCredentials() {
5049
+ return this.client.notebook.gitCredentials(this.data.id);
5013
5050
  }
5014
5051
  delete() {
5015
5052
  return this.client.notebook.delete(this.data.id).then(() => {