@phpsandbox/sdk 0.6.0-canary.6 → 0.6.0-canary.7
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 +44 -37
- package/dist/browser/phpsandbox-sdk.esm.js +4420 -4422
- package/dist/browser/phpsandbox-sdk.esm.min.js +8 -8
- package/dist/browser/phpsandbox-sdk.iife.js +4420 -4422
- package/dist/browser/phpsandbox-sdk.iife.min.js +8 -8
- package/dist/customers.d.ts +5 -4
- package/dist/customers.js +7 -7
- package/dist/feedback.d.ts +0 -1
- package/dist/feedback.js +0 -3
- package/dist/index.d.ts +2 -6
- package/dist/index.js +2 -6
- package/dist/payments.d.ts +9 -9
- package/dist/payments.js +10 -10
- package/dist/publication/index.d.ts +1 -1
- package/dist/publication/index.js +1 -1
- package/dist/publication/instance.d.ts +2 -0
- package/dist/publication/instance.js +4 -0
- package/dist/publication/{notebook.d.ts → project.d.ts} +3 -3
- package/dist/publication/{notebook.js → project.js} +6 -6
- package/dist/schemas/publications.d.ts +30 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -172,7 +172,6 @@ Each `NotebookInstance` exposes service clients:
|
|
|
172
172
|
- `notebook.auth` (`Auth`)
|
|
173
173
|
- `notebook.services` (`Services`)
|
|
174
174
|
- `notebook.mail` (`NotebookMail`)
|
|
175
|
-
- `notebook.feedback` (`Feedback`)
|
|
176
175
|
|
|
177
176
|
Notes:
|
|
178
177
|
|
|
@@ -401,27 +400,39 @@ await notebook.mail.delete(mail.hash);
|
|
|
401
400
|
await notebook.mail.disable();
|
|
402
401
|
```
|
|
403
402
|
|
|
403
|
+
### Product features
|
|
404
|
+
|
|
405
|
+
Projects own the product lifecycle. Address Customers, Payments, feedback, and publishing with an existing project ID; creating a standalone compute sandbox does not create a project.
|
|
406
|
+
|
|
407
|
+
This replaces `notebook.feedback`, `notebook.payments`, `notebook.publication`, and the `forNotebook` helpers. Use a project ID explicitly; sandbox IDs are not aliases for projects.
|
|
408
|
+
|
|
409
|
+
```ts
|
|
410
|
+
const customers = client.customers.forProject('PROJECT_ID');
|
|
411
|
+
const payments = client.payments.forProject('PROJECT_ID');
|
|
412
|
+
const publishing = client.publications.forProject('PROJECT_ID');
|
|
413
|
+
```
|
|
414
|
+
|
|
404
415
|
### Feedback
|
|
405
416
|
|
|
406
417
|
```ts
|
|
407
418
|
// Feedback uses the same API token as the rest of the SDK.
|
|
408
|
-
//
|
|
409
|
-
|
|
410
|
-
await
|
|
419
|
+
// Product features require an existing project ID, not a sandbox ID.
|
|
420
|
+
const projectFeedback = client.feedback.forProject('PROJECT_ID');
|
|
421
|
+
await projectFeedback.configure({
|
|
411
422
|
widget: {
|
|
412
423
|
targets: ['preview', 'publication'],
|
|
413
424
|
types: ['bug', 'suggestion', 'question'],
|
|
414
425
|
},
|
|
415
426
|
});
|
|
416
427
|
|
|
417
|
-
const feedback = await
|
|
428
|
+
const feedback = await projectFeedback.submit({
|
|
418
429
|
type: 'bug',
|
|
419
430
|
message: 'Saving the profile failed.',
|
|
420
431
|
author: { externalId: 'customer-42', email: 'ada@example.com' },
|
|
421
432
|
context: { url: 'https://app.example.com/profile', path: '/profile' },
|
|
422
433
|
});
|
|
423
434
|
|
|
424
|
-
await
|
|
435
|
+
await projectFeedback.update(feedback.id, { status: 'resolved' });
|
|
425
436
|
```
|
|
426
437
|
|
|
427
438
|
The server-side SDK uses the same PHPSandbox API token as the rest of the sandbox. Set `widget: null` to remove the optional popout without disabling API ingestion.
|
|
@@ -479,42 +490,38 @@ MIT
|
|
|
479
490
|
|
|
480
491
|
### Publishing apps
|
|
481
492
|
|
|
482
|
-
Save your app configuration, prepare a proposal for the apps you want to publish, and submit that proposal after explicit confirmation. Use `notebook.secrets` for production secrets and `
|
|
493
|
+
Save your app configuration, prepare a proposal for the apps you want to publish, and submit that proposal after explicit confirmation. Use `notebook.secrets` for production secrets and `client.publications.forProject(projectId).catalog` to discover destinations and available resources.
|
|
483
494
|
|
|
484
495
|
```ts
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
496
|
+
const publisher = client.publications.forProject('PROJECT_ID');
|
|
497
|
+
const configuration = await publisher.updateConfiguration({
|
|
498
|
+
expectedRevision: 0,
|
|
499
|
+
operations: [{ op: 'add-app', app: {
|
|
500
|
+
name: 'Backend', kind: 'http', root: '.',
|
|
501
|
+
build: { mode: 'dockerfile', context: '.', dockerfile: { source: 'project', path: 'Dockerfile' } },
|
|
502
|
+
runtime: { mode: 'container', port: 3333, healthCheck: { path: '/' } },
|
|
503
|
+
destination: { provider: 'ssh-server', serverId: 'OWNED_SERVER_ID' },
|
|
504
|
+
routing: { mode: 'managed' }, resourceIds: [],
|
|
505
|
+
} }],
|
|
506
|
+
});
|
|
507
|
+
const appIds = [configuration.apps[0].id];
|
|
508
|
+
const plan = await publisher.prepare({
|
|
509
|
+
expectedRevision: configuration.revision, appIds,
|
|
510
|
+
});
|
|
511
|
+
if (!plan.review.ready) {
|
|
512
|
+
console.log(plan.review.blockers);
|
|
513
|
+
} else {
|
|
514
|
+
// Show this proposal to the user and wait for their confirmation.
|
|
515
|
+
const result = await publisher.publish({
|
|
516
|
+
reviewId: plan.review.id, proposal: plan.review.proposal, appIds,
|
|
500
517
|
});
|
|
501
|
-
if (
|
|
502
|
-
|
|
518
|
+
if ('confirmationRequired' in result) {
|
|
519
|
+
// Show the changes and updated proposal; obtain a new confirmation.
|
|
520
|
+
console.log(result.changes, result.plan);
|
|
503
521
|
} else {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
reviewId: plan.review.id, proposal: plan.review.proposal, appIds,
|
|
507
|
-
});
|
|
508
|
-
if ('confirmationRequired' in result) {
|
|
509
|
-
// Show the changes and updated proposal; obtain a new confirmation.
|
|
510
|
-
console.log(result.changes, result.plan);
|
|
511
|
-
} else {
|
|
512
|
-
const current = await notebook.publication.application(result.id);
|
|
513
|
-
console.log(current.status); // publishing, healthy, partial, failed, or deleted
|
|
514
|
-
}
|
|
522
|
+
const current = await publisher.application(result.id);
|
|
523
|
+
console.log(current.status); // publishing, healthy, partial, failed, or deleted
|
|
515
524
|
}
|
|
516
|
-
} finally {
|
|
517
|
-
notebook.dispose();
|
|
518
525
|
}
|
|
519
526
|
```
|
|
520
527
|
|