@phpsandbox/sdk 0.3.0 → 0.3.1

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.
Files changed (2) hide show
  1. package/README.md +39 -28
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -81,7 +81,7 @@ console.log(persistentFork.data.policy);
81
81
 
82
82
  Notes:
83
83
 
84
- - Runtime actions wait for the sandbox to become ready before Okra handles them.
84
+ - Runtime actions wait for the sandbox to become ready before the runtime handles them.
85
85
  - Call `ready()` explicitly only when you need provisioning results such as the preview URL or opened ports.
86
86
  - API notebook creates and forks are ephemeral by default. `persistent: true` requires an entitled account.
87
87
  - Use `NotebookData.runtimeUrl`, `runtimeUrlProvider`, and `PublicationData.eventStreamUrl` for runtime access.
@@ -370,40 +370,51 @@ try {
370
370
 
371
371
  MIT
372
372
 
373
- ### Publishing without Helfer
373
+ ### Publishing apps
374
374
 
375
- Publishing is a platform capability. An API-key client can assign production settings with `notebook.secrets`, discover destinations and owned resources through `notebook.publication.catalog`, and submit its application choices through `prepare`.
375
+ 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 `notebook.publication.catalog` to discover destinations and available resources.
376
376
 
377
377
  ```ts
378
378
  const notebook = await client.notebook.get('SANDBOX_ID');
379
- const configuration = await notebook.publication.updateConfiguration({
380
- expectedRevision: 0,
381
- operations: [{ op: 'add-app', app: {
382
- name: 'Backend', kind: 'http', root: '.',
383
- build: { mode: 'dockerfile', context: '.', dockerfile: { source: 'project', path: 'Dockerfile' } },
384
- runtime: { mode: 'container', port: 3333, healthCheck: { path: '/' } },
385
- destination: { provider: 'ssh-server', serverId: 'OWNED_SERVER_ID' },
386
- routing: { mode: 'managed' }, resourceIds: [],
387
- } }],
388
- });
389
- const review = await notebook.publication.prepare({
390
- expectedRevision: configuration.revision, appIds: [configuration.apps[0].id],
391
- });
392
- if (!review.review.ready) {
393
- console.log(review.review.blockers);
394
- } else {
395
- // Present this exact review and obtain confirmation before executing.
396
- const application = await notebook.publication.publish({ reviewId: review.review.id });
397
- const current = await notebook.publication.application(application.id);
398
- console.log(current.status); // publishing, healthy, partial, failed, or deleted
379
+ try {
380
+ const configuration = await notebook.publication.updateConfiguration({
381
+ expectedRevision: 0,
382
+ operations: [{ op: 'add-app', app: {
383
+ name: 'Backend', kind: 'http', root: '.',
384
+ build: { mode: 'dockerfile', context: '.', dockerfile: { source: 'project', path: 'Dockerfile' } },
385
+ runtime: { mode: 'container', port: 3333, healthCheck: { path: '/' } },
386
+ destination: { provider: 'ssh-server', serverId: 'OWNED_SERVER_ID' },
387
+ routing: { mode: 'managed' }, resourceIds: [],
388
+ } }],
389
+ });
390
+ const appIds = [configuration.apps[0].id];
391
+ const plan = await notebook.publication.prepare({
392
+ expectedRevision: configuration.revision, appIds,
393
+ });
394
+ if (!plan.review.ready) {
395
+ console.log(plan.review.blockers);
396
+ } else {
397
+ // Show this proposal to the user and wait for their confirmation.
398
+ const result = await notebook.publication.publish({
399
+ reviewId: plan.review.id, proposal: plan.review.proposal, appIds,
400
+ });
401
+ if ('confirmationRequired' in result) {
402
+ // Show the changes and updated proposal; obtain a new confirmation.
403
+ console.log(result.changes, result.plan);
404
+ } else {
405
+ const current = await notebook.publication.application(result.id);
406
+ console.log(current.status); // publishing, healthy, partial, failed, or deleted
407
+ }
408
+ }
409
+ } finally {
410
+ notebook.dispose();
399
411
  }
400
- notebook.dispose();
401
412
  ```
402
413
 
403
- Core owns validation, source snapshots, review expiry, identity, resource ownership, execution and recovery. The confirmation reference binds the resolved review; another client does not copy source revisions or recreate provider logic. Repeated confirmation of an executed reference returns its existing application. A corrected review retains the publication and address. `retryApplication(id)` asks the platform to revalidate and retry failed apps; inspect current state and logs when an outcome is uncertain. `destroyApplication(id)` unpublishes, and resource deletion requires the explicit `deleteResources` option.
414
+ `configuration()` returns saved apps and actual deployment inventory. Configuration edits require `expectedRevision`; omitted apps remain unchanged, and removing an app from configuration does not unpublish it. An existing deployment is adopted explicitly using its exact publication ID.
404
415
 
405
- Helfer presents choices, recommendations and explanations, and resumes its own conversation from platform outcomes. Its chat monitor does not own builds or publication state. The CLI exposes the same operations as `application plan`, `application publish`, `application status`, `application retry`, and `application delete`; JSON input is available for multi-component plans.
416
+ Preparing or viewing a proposal does not start publishing. Confirmation sends the signed `proposal` unchanged along with its `reviewId` and app selection. Current source is captured when that confirmation is submitted. If material settings changed, `publish()` returns `confirmationRequired` without starting a deployment. Show those changes and obtain confirmation of the updated proposal before trying again. Repeating an already executed confirmation returns its existing operation.
406
417
 
407
- `configuration()` is the authoritative saved App configuration and deployment inventory. Changes use explicit revision-checked operations; adding an app preserves omitted apps. Review and confirm use `prepare({ expectedRevision, appIds? })` and `publish({ reviewId })`. The provider-input publishing contract and `PublicationInstance.publish()` have been removed. Inspect per-app reviewed source and route state; a workspace digest includes uncommitted changes, while a native Git destination commits and pushes that workspace before building. The commit reported at review is the last synced commit, not a promise of the final prepared build commit.
418
+ Inspect deployment, runtime and routing outcomes for each selected app; a partial outcome is not full success. `retryApplication(id)` retries failed apps after revalidation. If an outcome is uncertain, inspect status and logs before retrying. `destroyApplication(id)` unpublishes; deleting managed resources additionally requires `deleteResources: true`.
408
419
 
409
- Shared managed-resource creation currently starts with one app. After creation, update the resource definition to `reuse` with its actual catalog inventory ID, then attach further apps. Simultaneous first-time shared-resource provisioning is not supported. Historical deployments require explicit adoption by their exact publication ID; new publishing always creates a saved App.
420
+ Shared managed-resource creation currently starts with one app. After creation, update the resource definition to `reuse` with the catalog resource ID before attaching other apps. Simultaneous first-time shared-resource creation is unsupported.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phpsandbox/sdk",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "The TypeScript SDK for PHPSandbox cloud development environments",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",