@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.
- package/README.md +39 -28
- 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
|
|
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
|
|
373
|
+
### Publishing apps
|
|
374
374
|
|
|
375
|
-
|
|
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
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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.
|