@phpsandbox/sdk 0.1.1 → 0.1.2

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.
@@ -155,12 +155,12 @@ async function main(): Promise<void> {
155
155
  }, false);
156
156
 
157
157
  await recordStep(steps, 'container.opened-ports', options.stepTimeoutMs, async () => {
158
- const ports = await notebook!.container.openedPorts();
159
- return describePorts(assertPortInfoList(ports, 'container.openedPorts'));
158
+ const ports = await notebook!.ports.list();
159
+ return describePorts(assertPortInfoList(ports, 'ports.list'));
160
160
  }, false);
161
161
 
162
162
  const rootSnapshot = await recordStep(steps, 'filesystem.root', options.stepTimeoutMs, async () => {
163
- const rootEntries = await notebook!.file.readDirectory('/');
163
+ const rootEntries = await notebook!.files.list('/');
164
164
 
165
165
  const preferred = ['composer.json', 'index.php', 'artisan'];
166
166
  const rootNames = new Set(rootEntries.map(([name]) => name));
@@ -174,7 +174,7 @@ async function main(): Promise<void> {
174
174
  const treePath = rootSnapshot.candidate === 'artisan' ? 'routes' : undefined;
175
175
  if (treePath) {
176
176
  await recordStep(steps, 'filesystem.tree', options.stepTimeoutMs, async () => {
177
- const tree = await notebook!.file.tree(treePath);
177
+ const tree = await notebook!.files.tree(treePath);
178
178
  return `path=${treePath} bytes=${tree.length}`;
179
179
  }, false);
180
180
  } else {
@@ -183,8 +183,8 @@ async function main(): Promise<void> {
183
183
 
184
184
  const findSnapshot = await recordStep(steps, 'filesystem.find', options.stepTimeoutMs, async () => {
185
185
  const [composerFiles, indexFiles] = await Promise.all([
186
- notebook!.file.find('composer.json', { maxResults: 10 }),
187
- notebook!.file.find('index.php', { maxResults: 10 }),
186
+ notebook!.files.find('composer.json', { maxResults: 10 }),
187
+ notebook!.files.find('index.php', { maxResults: 10 }),
188
188
  ]);
189
189
  const candidate = [...composerFiles, ...indexFiles].find((file) => typeof file.path === 'string')?.path;
190
190
  return {
@@ -197,15 +197,13 @@ async function main(): Promise<void> {
197
197
 
198
198
  if (candidate) {
199
199
  await recordStep(steps, 'filesystem.read-candidate', options.stepTimeoutMs, async () => {
200
- const [info, stat, content, tail] = await Promise.all([
201
- notebook!.file.info(candidate),
202
- notebook!.file.stat(candidate),
203
- notebook!.file.readFile(candidate),
204
- notebook!.file.tail(candidate, 10),
200
+ const [stat, content, tail] = await Promise.all([
201
+ notebook!.files.stat(candidate),
202
+ notebook!.files.read(candidate),
203
+ notebook!.files.tail(candidate, { lines: 10 }),
205
204
  ]);
206
205
 
207
- const bytes = content instanceof Uint8Array ? content : new TextEncoder().encode(JSON.stringify(content));
208
- return `path=${candidate} size=${stat.size} binary=${info.binary} sha256=${sha256(bytes)} tailBytes=${tail.length}`;
206
+ return `path=${candidate} size=${stat.size} sha256=${sha256(content)} tailBytes=${tail.length}`;
209
207
  }, false);
210
208
  } else {
211
209
  recordSkippedStep(steps, 'filesystem.read-candidate', 'No readable candidate file found.');
@@ -214,7 +212,10 @@ async function main(): Promise<void> {
214
212
  if (options.includeDownload) {
215
213
  if (candidate) {
216
214
  await recordStep(steps, 'filesystem.download', options.stepTimeoutMs, async () => {
217
- const archive = await notebook!.file.download(undefined, ['vendor/**', 'node_modules/**'], [candidate]);
215
+ const archive = await notebook!.files.download({
216
+ exclude: ['vendor/**', 'node_modules/**'],
217
+ include: [candidate],
218
+ });
218
219
  if (archive.size === 0) {
219
220
  throw new Error('file.download() returned an empty blob.');
220
221
  }
@@ -228,7 +229,7 @@ async function main(): Promise<void> {
228
229
  }
229
230
 
230
231
  await recordStep(steps, 'filesystem.search', options.stepTimeoutMs, async () => {
231
- const [hasMore, matches] = await notebook!.file.search({
232
+ const [hasMore, matches] = await notebook!.files.search({
232
233
  pattern: 'php',
233
234
  isRegExp: false,
234
235
  isCaseSensitive: false,
@@ -260,7 +261,7 @@ async function main(): Promise<void> {
260
261
  await runExecutionChecks(notebook, steps, options);
261
262
  } else {
262
263
  recordSkippedStep(steps, 'shell.run', 'Enable with --include-exec.');
263
- recordSkippedStep(steps, 'terminal.spawn', 'Enable with --include-exec.');
264
+ recordSkippedStep(steps, 'terminals.create', 'Enable with --include-exec.');
264
265
  recordSkippedStep(steps, 'terminal.interactive', 'Enable with --include-exec.');
265
266
  recordSkippedStep(steps, 'terminal.osc', 'Enable with --include-exec.');
266
267
  recordSkippedStep(steps, 'repl.eval', 'Enable with --include-exec.');
@@ -332,26 +333,25 @@ async function runExecutionChecks(notebook: NotebookInstance, steps: StepArtifac
332
333
  return `exit=${result.exitCode}`;
333
334
  }, false);
334
335
 
335
- await recordStep(steps, 'terminal.spawn', options.stepTimeoutMs, async () => {
336
- const process = await notebook.terminal.spawn('php', ['-r', 'echo "sdk-smoke";'], { output: true });
336
+ await recordStep(steps, 'terminals.create', options.stepTimeoutMs, async () => {
337
+ const process = await notebook.terminals.create({ command: 'php', args: ['-r', 'echo "sdk-smoke";'] });
337
338
  const [exitCode, output] = await Promise.all([
338
339
  withTimeout(process.wait(), options.stepTimeoutMs, 'waiting for terminal process exit'),
339
340
  readStreamToString(process.output, options.streamTimeoutMs, options.maxStreamChars),
340
341
  ]);
341
342
 
342
343
  if (exitCode !== 0 || !output.includes('sdk-smoke')) {
343
- throw new Error(`terminal.spawn failed: exit=${exitCode} output=${trimDetail(output)}`);
344
+ throw new Error(`terminals.create failed: exit=${exitCode} output=${trimDetail(output)}`);
344
345
  }
345
346
 
346
347
  return `exit=${exitCode}`;
347
348
  }, false);
348
349
 
349
350
  await recordStep(steps, 'terminal.interactive', options.stepTimeoutMs, async () => {
350
- const process = await notebook.terminal.spawn(
351
- 'bash',
352
- ['-lc', 'IFS= read -r line; printf "sdk-input:%s\\n" "$line"'],
353
- { output: true }
354
- );
351
+ const process = await notebook.terminals.create({
352
+ command: 'bash',
353
+ args: ['-lc', 'IFS= read -r line; printf "sdk-input:%s\\n" "$line"'],
354
+ });
355
355
 
356
356
  try {
357
357
  const writer = process.input.getWriter();
@@ -374,15 +374,12 @@ async function runExecutionChecks(notebook: NotebookInstance, steps: StepArtifac
374
374
  }, false);
375
375
 
376
376
  await recordStep(steps, 'terminal.osc', options.stepTimeoutMs, async () => {
377
- const process = await notebook.terminal.spawn(
378
- 'bash',
379
- ['-lc', 'printf "sdk-prompt$"'],
380
- {
381
- output: true,
382
- osc: true,
383
- terminal: { cols: 80, rows: 15 },
384
- }
385
- );
377
+ const process = await notebook.terminals.create({
378
+ command: 'bash',
379
+ args: ['-lc', 'printf "sdk-prompt$"'],
380
+ osc: true,
381
+ size: [80, 15],
382
+ });
386
383
 
387
384
  try {
388
385
  const [exitCode, output] = await Promise.all([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phpsandbox/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "A comprehensive TypeScript SDK for interacting with cloud-based PHP development environments",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",