@phpsandbox/sdk 0.3.3 → 0.3.5

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.
@@ -51,137 +51,6 @@ var PHPSandbox = (() => {
51
51
  readPublicationStream: () => readPublicationStream
52
52
  });
53
53
 
54
- // src/errors/index.ts
55
- var remoteErrorCodes = [
56
- "ActionNotFound",
57
- "AuthenticationRequired",
58
- "BadGateway",
59
- "BadRequest",
60
- "Conflict",
61
- "FileAlreadyExists",
62
- "FileIsDirectory",
63
- "FileNotDirectory",
64
- "FileNotFound",
65
- "FilesystemUnavailable",
66
- "InternalError",
67
- "InvalidArgument",
68
- "InvalidConfiguration",
69
- "InvalidRequest",
70
- "InvalidResponse",
71
- "InvalidServiceCommand",
72
- "MethodNotAllowed",
73
- "NotebookInitializationFailed",
74
- "NotebookUnavailable",
75
- "NotFound",
76
- "PayloadTooLarge",
77
- "PermissionDenied",
78
- "RateLimited",
79
- "RequestFailed",
80
- "RuntimeOperationFailed",
81
- "ServiceNotFound",
82
- "ServiceUnavailable",
83
- "UnprocessableEntity",
84
- "ValidationFailed",
85
- "WorkspaceUnavailable"
86
- ];
87
- var PHPSandboxError = class extends Error {
88
- constructor(message, cause) {
89
- super(message);
90
- this.name = new.target.name;
91
- this.cause = cause;
92
- }
93
- };
94
- var RemoteError = class _RemoteError extends PHPSandboxError {
95
- constructor(message, options) {
96
- super(message, options.cause);
97
- this.source = options.source;
98
- this.status = options.status;
99
- this.code = options.code;
100
- this.details = options.details;
101
- }
102
- static is(error51, code) {
103
- return error51 instanceof _RemoteError && (code === void 0 || error51.code === code);
104
- }
105
- static isValidation(error51) {
106
- return _RemoteError.is(error51, "ValidationFailed") && validationDetails(error51.details) !== void 0;
107
- }
108
- is(code) {
109
- return this.code === code;
110
- }
111
- };
112
- var TransportError = class _TransportError extends PHPSandboxError {
113
- constructor(message, code, cause, response) {
114
- super(message, cause);
115
- this.code = code;
116
- this.response = response;
117
- }
118
- static is(error51, code) {
119
- return error51 instanceof _TransportError && (code === void 0 || error51.code === code);
120
- }
121
- is(code) {
122
- return this.code === code;
123
- }
124
- };
125
- function remoteError(source, payload, cause) {
126
- const error51 = record(payload);
127
- const status = positiveInteger(error51?.status);
128
- const code = nonEmptyString(error51?.code);
129
- const message = nonEmptyString(error51?.message);
130
- if (status === void 0 || !isRemoteErrorCode(code) || message === void 0) {
131
- throw new TransportError("PHPSandbox returned an invalid error response.", "InvalidResponse", cause ?? payload);
132
- }
133
- return new RemoteError(message, {
134
- source,
135
- status,
136
- code,
137
- details: error51?.details,
138
- cause
139
- });
140
- }
141
- function isRemoteErrorCode(value) {
142
- return typeof value === "string" && remoteErrorCodes.includes(value);
143
- }
144
- function positiveInteger(value) {
145
- return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : void 0;
146
- }
147
- function nonEmptyString(value) {
148
- return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
149
- }
150
- function record(value) {
151
- return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
152
- }
153
- function stringArrayRecord(value) {
154
- const candidate = record(value);
155
- if (candidate === void 0) {
156
- return void 0;
157
- }
158
- const entries = Object.entries(candidate);
159
- if (!entries.every(([, messages]) => Array.isArray(messages) && messages.every((message) => typeof message === "string"))) {
160
- return void 0;
161
- }
162
- return Object.fromEntries(entries);
163
- }
164
- function validationDetails(value) {
165
- const details = record(value);
166
- const errors = stringArrayRecord(details?.errors);
167
- return errors === void 0 ? void 0 : { errors };
168
- }
169
- var PromiseTimeoutError = class extends Error {
170
- constructor(message, time3) {
171
- super(message);
172
- this.time = time3;
173
- }
174
- };
175
- var SendTimeoutError = class _SendTimeoutError extends TransportError {
176
- constructor(message, time3, cause) {
177
- super(message, "SendTimeout", cause);
178
- this.time = time3;
179
- }
180
- static fromPromiseTimeoutError(error51) {
181
- return new _SendTimeoutError(error51.message, error51.time, error51);
182
- }
183
- };
184
-
185
54
  // node_modules/zod/v4/classic/external.js
186
55
  var external_exports = {};
187
56
  __export(external_exports, {
@@ -376,7 +245,7 @@ var PHPSandbox = (() => {
376
245
  promise: () => promise,
377
246
  property: () => _property,
378
247
  readonly: () => readonly,
379
- record: () => record2,
248
+ record: () => record,
380
249
  refine: () => refine,
381
250
  regex: () => _regex,
382
251
  regexes: () => regexes_exports,
@@ -12714,7 +12583,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
12714
12583
  preprocess: () => preprocess,
12715
12584
  promise: () => promise,
12716
12585
  readonly: () => readonly,
12717
- record: () => record2,
12586
+ record: () => record,
12718
12587
  refine: () => refine,
12719
12588
  set: () => set,
12720
12589
  strictObject: () => strictObject,
@@ -13683,7 +13552,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13683
13552
  inst.keyType = def.keyType;
13684
13553
  inst.valueType = def.valueType;
13685
13554
  });
13686
- function record2(keyType, valueType, params) {
13555
+ function record(keyType, valueType, params) {
13687
13556
  if (!valueType || !valueType._zod) {
13688
13557
  return new ZodRecord({
13689
13558
  type: "record",
@@ -14150,7 +14019,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14150
14019
  }, ...args);
14151
14020
  function json(params) {
14152
14021
  const jsonSchema = lazy(() => {
14153
- return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record2(string2(), jsonSchema)]);
14022
+ return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record(string2(), jsonSchema)]);
14154
14023
  });
14155
14024
  return jsonSchema;
14156
14025
  }
@@ -14696,12 +14565,146 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14696
14565
  // node_modules/zod/v4/classic/external.js
14697
14566
  config(en_default());
14698
14567
 
14568
+ // src/identity.ts
14569
+ var identitySchema = external_exports.object({
14570
+ user: external_exports.object({ id: external_exports.string(), name: external_exports.string() }).nullable(),
14571
+ organization: external_exports.object({ id: external_exports.string(), name: external_exports.string() }),
14572
+ permissions: external_exports.array(external_exports.string())
14573
+ });
14574
+
14575
+ // src/errors/index.ts
14576
+ var remoteErrorCodes = [
14577
+ "ActionNotFound",
14578
+ "AuthenticationRequired",
14579
+ "BadGateway",
14580
+ "BadRequest",
14581
+ "Conflict",
14582
+ "FileAlreadyExists",
14583
+ "FileIsDirectory",
14584
+ "FileNotDirectory",
14585
+ "FileNotFound",
14586
+ "FilesystemUnavailable",
14587
+ "InternalError",
14588
+ "InvalidArgument",
14589
+ "InvalidConfiguration",
14590
+ "InvalidRequest",
14591
+ "InvalidResponse",
14592
+ "InvalidServiceCommand",
14593
+ "MethodNotAllowed",
14594
+ "NotebookInitializationFailed",
14595
+ "NotebookUnavailable",
14596
+ "NotFound",
14597
+ "PayloadTooLarge",
14598
+ "PermissionDenied",
14599
+ "RateLimited",
14600
+ "RequestFailed",
14601
+ "RuntimeOperationFailed",
14602
+ "ServiceNotFound",
14603
+ "ServiceUnavailable",
14604
+ "UnprocessableEntity",
14605
+ "ValidationFailed",
14606
+ "WorkspaceUnavailable"
14607
+ ];
14608
+ var PHPSandboxError = class extends Error {
14609
+ constructor(message, cause) {
14610
+ super(message);
14611
+ this.name = new.target.name;
14612
+ this.cause = cause;
14613
+ }
14614
+ };
14615
+ var RemoteError = class _RemoteError extends PHPSandboxError {
14616
+ constructor(message, options) {
14617
+ super(message, options.cause);
14618
+ this.source = options.source;
14619
+ this.status = options.status;
14620
+ this.code = options.code;
14621
+ this.details = options.details;
14622
+ }
14623
+ static is(error51, code) {
14624
+ return error51 instanceof _RemoteError && (code === void 0 || error51.code === code);
14625
+ }
14626
+ static isValidation(error51) {
14627
+ return _RemoteError.is(error51, "ValidationFailed") && validationDetails(error51.details) !== void 0;
14628
+ }
14629
+ is(code) {
14630
+ return this.code === code;
14631
+ }
14632
+ };
14633
+ var TransportError = class _TransportError extends PHPSandboxError {
14634
+ constructor(message, code, cause, response) {
14635
+ super(message, cause);
14636
+ this.code = code;
14637
+ this.response = response;
14638
+ }
14639
+ static is(error51, code) {
14640
+ return error51 instanceof _TransportError && (code === void 0 || error51.code === code);
14641
+ }
14642
+ is(code) {
14643
+ return this.code === code;
14644
+ }
14645
+ };
14646
+ function remoteError(source, payload, cause) {
14647
+ const error51 = record2(payload);
14648
+ const status = positiveInteger(error51?.status);
14649
+ const code = nonEmptyString(error51?.code);
14650
+ const message = nonEmptyString(error51?.message);
14651
+ if (status === void 0 || !isRemoteErrorCode(code) || message === void 0) {
14652
+ throw new TransportError("PHPSandbox returned an invalid error response.", "InvalidResponse", cause ?? payload);
14653
+ }
14654
+ return new RemoteError(message, {
14655
+ source,
14656
+ status,
14657
+ code,
14658
+ details: error51?.details,
14659
+ cause
14660
+ });
14661
+ }
14662
+ function isRemoteErrorCode(value) {
14663
+ return typeof value === "string" && remoteErrorCodes.includes(value);
14664
+ }
14665
+ function positiveInteger(value) {
14666
+ return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : void 0;
14667
+ }
14668
+ function nonEmptyString(value) {
14669
+ return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
14670
+ }
14671
+ function record2(value) {
14672
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
14673
+ }
14674
+ function stringArrayRecord(value) {
14675
+ const candidate = record2(value);
14676
+ if (candidate === void 0) {
14677
+ return void 0;
14678
+ }
14679
+ const entries = Object.entries(candidate);
14680
+ if (!entries.every(([, messages]) => Array.isArray(messages) && messages.every((message) => typeof message === "string"))) {
14681
+ return void 0;
14682
+ }
14683
+ return Object.fromEntries(entries);
14684
+ }
14685
+ function validationDetails(value) {
14686
+ const details = record2(value);
14687
+ const errors = stringArrayRecord(details?.errors);
14688
+ return errors === void 0 ? void 0 : { errors };
14689
+ }
14690
+ var PromiseTimeoutError = class extends Error {
14691
+ constructor(message, time3) {
14692
+ super(message);
14693
+ this.time = time3;
14694
+ }
14695
+ };
14696
+ var SendTimeoutError = class _SendTimeoutError extends TransportError {
14697
+ constructor(message, time3, cause) {
14698
+ super(message, "SendTimeout", cause);
14699
+ this.time = time3;
14700
+ }
14701
+ static fromPromiseTimeoutError(error51) {
14702
+ return new _SendTimeoutError(error51.message, error51.time, error51);
14703
+ }
14704
+ };
14705
+
14699
14706
  // src/schemas/publications.ts
14700
- var PublicationProviderNameSchema = external_exports.enum([
14701
- "cloudflare-containers",
14702
- "ssh-server",
14703
- "laravel-cloud"
14704
- ]);
14707
+ var PublicationProviderNameSchema = external_exports.enum(["cloudflare-containers", "ssh-server", "laravel-cloud"]);
14705
14708
  var PublicationStatusSchema = external_exports.enum([
14706
14709
  "pending",
14707
14710
  "queued",
@@ -14714,36 +14717,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14714
14717
  "deleted",
14715
14718
  "delete_failed"
14716
14719
  ]);
14717
- var PublicationBuildStatusSchema = external_exports.enum([
14718
- "pending",
14719
- "queued",
14720
- "running",
14721
- "succeeded",
14722
- "failed",
14723
- "cancelled"
14724
- ]);
14720
+ var PublicationBuildStatusSchema = external_exports.enum(["pending", "queued", "running", "succeeded", "failed", "cancelled"]);
14725
14721
  var PublicationReleaseStatusSchema = external_exports.enum(["created", "ready", "deleted"]);
14726
- var PublicationSizeSchema = external_exports.enum([
14727
- "nano",
14728
- "small",
14729
- "medium",
14730
- "large",
14731
- "lite",
14732
- "basic",
14733
- "standard-1",
14734
- "standard-2"
14735
- ]);
14736
- var PublicationRegionSchema = external_exports.enum([
14737
- "ENAM",
14738
- "WNAM",
14739
- "EEUR",
14740
- "WEUR",
14741
- "APAC",
14742
- "SAM",
14743
- "ME",
14744
- "OC",
14745
- "AFR"
14746
- ]);
14722
+ var PublicationSizeSchema = external_exports.enum(["nano", "small", "medium", "large", "lite", "basic", "standard-1", "standard-2"]);
14723
+ var PublicationRegionSchema = external_exports.enum(["ENAM", "WNAM", "EEUR", "WEUR", "APAC", "SAM", "ME", "OC", "AFR"]);
14747
14724
  var PublicationJurisdictionSchema = external_exports.enum(["eu", "fedramp"]);
14748
14725
  var PublicationProtectionModeSchema = external_exports.enum(["none", "password"]);
14749
14726
  var PublicationLogStreamSchema = external_exports.enum(["build", "runtime"]);
@@ -14853,7 +14830,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14853
14830
  const lines = data;
14854
14831
  eventName = "message";
14855
14832
  data = [];
14856
- if (!lines.length || !PublishStreamSseEventNameSchema.safeParse(name).success) return null;
14833
+ if (!lines.length || !PublishStreamSseEventNameSchema.safeParse(name).success) {
14834
+ return null;
14835
+ }
14857
14836
  const raw = lines.join("\n");
14858
14837
  let payload;
14859
14838
  try {
@@ -14862,18 +14841,30 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14862
14841
  payload = raw;
14863
14842
  }
14864
14843
  const event = PublishStreamSseEventSchema.parse({ event: name, data: payload });
14865
- if (event.type === "result") receivedResult = true;
14844
+ if (event.type === "result") {
14845
+ receivedResult = true;
14846
+ }
14866
14847
  return event;
14867
14848
  }
14868
14849
  function line(value) {
14869
- if (value === "") return dispatch();
14870
- if (value.startsWith(":")) return null;
14850
+ if (value === "") {
14851
+ return dispatch();
14852
+ }
14853
+ if (value.startsWith(":")) {
14854
+ return null;
14855
+ }
14871
14856
  const colon = value.indexOf(":");
14872
14857
  const field = colon < 0 ? value : value.slice(0, colon);
14873
14858
  let content = colon < 0 ? "" : value.slice(colon + 1);
14874
- if (content.startsWith(" ")) content = content.slice(1);
14875
- if (field === "event") eventName = content;
14876
- if (field === "data") data.push(content);
14859
+ if (content.startsWith(" ")) {
14860
+ content = content.slice(1);
14861
+ }
14862
+ if (field === "event") {
14863
+ eventName = content;
14864
+ }
14865
+ if (field === "data") {
14866
+ data.push(content);
14867
+ }
14877
14868
  return null;
14878
14869
  }
14879
14870
  try {
@@ -14882,19 +14873,27 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14882
14873
  buffer += done ? decoder.decode() : decoder.decode(value, { stream: true });
14883
14874
  let match;
14884
14875
  while (match = /\r\n|\r|\n/.exec(buffer)) {
14885
- if (!done && match[0] === "\r" && match.index === buffer.length - 1) break;
14876
+ if (!done && match[0] === "\r" && match.index === buffer.length - 1) {
14877
+ break;
14878
+ }
14886
14879
  const event = line(buffer.slice(0, match.index));
14887
14880
  buffer = buffer.slice(match.index + match[0].length);
14888
- if (event) yield event;
14881
+ if (event) {
14882
+ yield event;
14883
+ }
14889
14884
  }
14890
14885
  if (done) {
14891
14886
  ended = true;
14892
14887
  if (buffer) {
14893
14888
  const event2 = line(buffer);
14894
- if (event2) yield event2;
14889
+ if (event2) {
14890
+ yield event2;
14891
+ }
14895
14892
  }
14896
14893
  const event = dispatch();
14897
- if (event) yield event;
14894
+ if (event) {
14895
+ yield event;
14896
+ }
14898
14897
  if (options.requireResult !== false && !receivedResult) {
14899
14898
  throw new PHPSandboxError("Publish stream ended without result");
14900
14899
  }
@@ -14902,7 +14901,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14902
14901
  }
14903
14902
  }
14904
14903
  } finally {
14905
- if (!ended) await reader.cancel().catch(() => void 0);
14904
+ if (!ended) {
14905
+ await reader.cancel().catch(() => void 0);
14906
+ }
14906
14907
  reader.releaseLock();
14907
14908
  }
14908
14909
  }
@@ -14913,7 +14914,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14913
14914
  let cancellation;
14914
14915
  let abort;
14915
14916
  async function dispose() {
14916
- if (disposed) return;
14917
+ if (disposed) {
14918
+ return;
14919
+ }
14917
14920
  disposed = true;
14918
14921
  options.signal?.removeEventListener("abort", abort);
14919
14922
  reader.releaseLock();
@@ -14929,43 +14932,56 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14929
14932
  }
14930
14933
  })());
14931
14934
  }
14932
- return new Response(new ReadableStream({
14933
- start(controller) {
14934
- abort = () => {
14935
- controller.error(options.signal.reason);
14936
- void cancel(options.signal.reason).catch(() => void 0);
14937
- };
14938
- if (options.signal?.aborted) abort();
14939
- else options.signal?.addEventListener("abort", abort, { once: true });
14940
- },
14941
- async pull(controller) {
14942
- try {
14943
- const { done, value } = await reader.read();
14944
- if (finished) return;
14945
- if (done) {
14946
- finished = true;
14947
- await dispose();
14948
- controller.close();
14949
- } else {
14950
- controller.enqueue(value);
14951
- }
14952
- } catch (error51) {
14953
- if (finished && cancellation) return;
14954
- try {
14955
- await cancel(error51);
14956
- } finally {
14957
- controller.error(error51);
14958
- }
14935
+ return new Response(
14936
+ new ReadableStream(
14937
+ {
14938
+ start(controller) {
14939
+ abort = () => {
14940
+ controller.error(options.signal.reason);
14941
+ void cancel(options.signal.reason).catch(() => void 0);
14942
+ };
14943
+ if (options.signal?.aborted) {
14944
+ abort();
14945
+ } else {
14946
+ options.signal?.addEventListener("abort", abort, { once: true });
14947
+ }
14948
+ },
14949
+ async pull(controller) {
14950
+ try {
14951
+ const { done, value } = await reader.read();
14952
+ if (finished) {
14953
+ return;
14954
+ }
14955
+ if (done) {
14956
+ finished = true;
14957
+ await dispose();
14958
+ controller.close();
14959
+ } else {
14960
+ controller.enqueue(value);
14961
+ }
14962
+ } catch (error51) {
14963
+ if (finished && cancellation) {
14964
+ return;
14965
+ }
14966
+ try {
14967
+ await cancel(error51);
14968
+ } finally {
14969
+ controller.error(error51);
14970
+ }
14971
+ }
14972
+ },
14973
+ cancel
14974
+ },
14975
+ { highWaterMark: 0 }
14976
+ ),
14977
+ {
14978
+ headers: {
14979
+ "Content-Type": "text/event-stream",
14980
+ "Cache-Control": "no-cache, no-transform",
14981
+ "X-Accel-Buffering": "no"
14959
14982
  }
14960
- },
14961
- cancel
14962
- }, { highWaterMark: 0 }), {
14963
- headers: {
14964
- "Content-Type": "text/event-stream",
14965
- "Cache-Control": "no-cache, no-transform",
14966
- "X-Accel-Buffering": "no"
14967
14983
  }
14968
- });
14984
+ );
14969
14985
  }
14970
14986
 
14971
14987
  // src/publication/run.ts
@@ -15286,7 +15302,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15286
15302
  }
15287
15303
  async logSnapshot(stream, limit = 50) {
15288
15304
  const query = new URLSearchParams({ stream, limit: String(limit) });
15289
- return (await this.client.get(`/publications/${encodeURIComponent(this.data.id)}/logs?${query}`)).data;
15305
+ return (await this.client.get(
15306
+ `/publications/${encodeURIComponent(this.data.id)}/logs?${query}`
15307
+ )).data;
15290
15308
  }
15291
15309
  async logs() {
15292
15310
  return parseNdjsonStream(
@@ -15395,11 +15413,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15395
15413
  /** Publish the exact app selection in a server-owned review. */
15396
15414
  async publish(input) {
15397
15415
  const application = (await this.client.post(`${this.path}/publication`, input)).data;
15398
- if (!("confirmationRequired" in application)) this.startApplicationRuns(application);
15416
+ if (!("confirmationRequired" in application)) {
15417
+ this.startApplicationRuns(application);
15418
+ }
15399
15419
  return application;
15400
15420
  }
15401
15421
  async application(applicationId) {
15402
- return (await this.client.get(`${this.path}/publication/application/${encodeURIComponent(applicationId)}`)).data;
15422
+ return (await this.client.get(
15423
+ `${this.path}/publication/application/${encodeURIComponent(applicationId)}`
15424
+ )).data;
15403
15425
  }
15404
15426
  /** Retry failed apps and pending route attachments while preserving running releases. */
15405
15427
  async retryApplication(applicationId) {
@@ -15416,12 +15438,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15416
15438
  }
15417
15439
  startApplicationRuns(application) {
15418
15440
  for (const app of application.apps) {
15419
- if (!(application.selectedAppIds ?? []).includes(app.appId)) continue;
15420
- if (!["pending", "queued", "building", "deploying"].includes(app.publication.status)) continue;
15421
- new PublicationRun(
15422
- new PublicationInstance(app.publication, this.client, this.notebookId),
15423
- this.client
15424
- ).start();
15441
+ if (!(application.selectedAppIds ?? []).includes(app.appId)) {
15442
+ continue;
15443
+ }
15444
+ if (!["pending", "queued", "building", "deploying"].includes(app.publication.status)) {
15445
+ continue;
15446
+ }
15447
+ new PublicationRun(new PublicationInstance(app.publication, this.client, this.notebookId), this.client).start();
15425
15448
  }
15426
15449
  }
15427
15450
  async catalog(provider, serverId) {
@@ -16036,7 +16059,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16036
16059
  return this.okra.invoke("terminal.close", { id });
16037
16060
  });
16038
16061
  const resize = (dimensions) => {
16039
- this.okra.invoke("terminal.resize", { id, width: dimensions.cols, height: dimensions.rows });
16062
+ return this.okra.invoke("terminal.resize", { id, width: dimensions.cols, height: dimensions.rows });
16040
16063
  };
16041
16064
  if (abortSignal && !abortSignal.aborted) {
16042
16065
  abortHandler = () => {
@@ -16057,20 +16080,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16057
16080
  }
16058
16081
  };
16059
16082
 
16060
- // src/auth.ts
16061
- var Auth = class {
16062
- constructor(okra) {
16063
- this.okra = okra;
16064
- }
16065
- login(runtimeUrl) {
16066
- const runtimeTicket = new URL(runtimeUrl).searchParams.get("ticket");
16067
- if (runtimeTicket === null || runtimeTicket === "") {
16068
- throw new TypeError("The notebook connection does not contain a runtime ticket.");
16069
- }
16070
- return this.okra.invoke("auth.login", { runtimeTicket });
16071
- }
16072
- };
16073
-
16074
16083
  // src/lsp.ts
16075
16084
  var Lsp = class {
16076
16085
  constructor(okra) {
@@ -16125,10 +16134,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16125
16134
  return this.lsp.onClose(this.id, cb);
16126
16135
  }
16127
16136
  dispose() {
16128
- this.lsp.close(this.id);
16137
+ return this.lsp.close(this.id);
16129
16138
  }
16130
16139
  start() {
16131
- this.lsp.start(this.id);
16140
+ return this.lsp.start(this.id);
16132
16141
  }
16133
16142
  onClientDisconnect(cb) {
16134
16143
  return this.lsp.onClientDisconnect(cb);
@@ -16231,11 +16240,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16231
16240
  stderr.fail(error51);
16232
16241
  };
16233
16242
  const { abortSignal, ...payloadOpts } = opts;
16234
- this.completion = this.okra.invoke(
16235
- "shell.exec",
16236
- { command, opts: { ...payloadOpts, id: this.id } },
16237
- { abortSignal }
16238
- ).then((result) => {
16243
+ this.completion = this.okra.invoke("shell.exec", { command, opts: { ...payloadOpts, id: this.id } }, { abortSignal }).then((result) => {
16239
16244
  finish();
16240
16245
  return result;
16241
16246
  }).catch((error51) => {
@@ -16268,15 +16273,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16268
16273
  this.notebookId = notebookId;
16269
16274
  }
16270
16275
  async set(input) {
16271
- const response = await this.client.put(
16272
- `/notebook/${this.notebookId}/composer/credentials`,
16273
- input
16274
- );
16276
+ const response = await this.client.put(`/notebook/${this.notebookId}/composer/credentials`, input);
16275
16277
  return response.data;
16276
16278
  }
16277
16279
  async remove(type, url2) {
16278
16280
  const params = new URLSearchParams({ type });
16279
- if (url2) params.set("url", url2);
16281
+ if (url2) {
16282
+ params.set("url", url2);
16283
+ }
16280
16284
  await this.client.delete(`/notebook/${this.notebookId}/composer/credentials?${params.toString()}`);
16281
16285
  }
16282
16286
  };
@@ -16461,11 +16465,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16461
16465
  this.telemetry = telemetry;
16462
16466
  }
16463
16467
  follow(options = {}) {
16464
- return watchRuntimeTelemetry(this.okra, this.telemetry, "logs", "notebook.log", (message) => ({
16465
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
16466
- source: "runtime",
16467
- message
16468
- }), options);
16468
+ return watchRuntimeTelemetry(
16469
+ this.okra,
16470
+ this.telemetry,
16471
+ "logs",
16472
+ "notebook.log",
16473
+ (message) => ({
16474
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
16475
+ source: "runtime",
16476
+ message
16477
+ }),
16478
+ options
16479
+ );
16469
16480
  }
16470
16481
  };
16471
16482
 
@@ -18925,7 +18936,7 @@ ${JSON.stringify(metadata, null, 2)}` : "";
18925
18936
  id() {
18926
18937
  return this.clientId;
18927
18938
  }
18928
- async registerWatchers() {
18939
+ registerWatchers() {
18929
18940
  const onMessage = (ev) => {
18930
18941
  this.incomingMessageChain = this.incomingMessageChain.catch(() => void 0).then(() => this.processIncomingMessage(ev)).catch((error51) => {
18931
18942
  this.log("error", "Failed to process queued WebSocket frame", {
@@ -19091,7 +19102,9 @@ ${JSON.stringify(metadata, null, 2)}` : "";
19091
19102
  this.eventEmitter.emit(event, this.clientId);
19092
19103
  return;
19093
19104
  }
19094
- event && this.eventEmitter.emit(as || event, data);
19105
+ if (event) {
19106
+ this.eventEmitter.emit(as || event, data);
19107
+ }
19095
19108
  }
19096
19109
  listen(event, listener, _context) {
19097
19110
  return this.eventEmitter.listen(event, listener);
@@ -19187,12 +19200,14 @@ ${JSON.stringify(metadata, null, 2)}` : "";
19187
19200
  });
19188
19201
  closeHandler = (_ev) => {
19189
19202
  if (_ev.code === 1008 && (_ev.reason || "").includes("rate limit")) {
19190
- reject(new RemoteError(_ev.reason || "Rate limit exceeded", {
19191
- source: "runtime",
19192
- status: 429,
19193
- code: "RateLimited",
19194
- cause: _ev
19195
- }));
19203
+ reject(
19204
+ new RemoteError(_ev.reason || "Rate limit exceeded", {
19205
+ source: "runtime",
19206
+ status: 429,
19207
+ code: "RateLimited",
19208
+ cause: _ev
19209
+ })
19210
+ );
19196
19211
  return;
19197
19212
  }
19198
19213
  const detail = describeWebSocketEvent(_ev);
@@ -19700,6 +19715,15 @@ ${JSON.stringify(metadata, null, 2)}` : "";
19700
19715
  constructor(client) {
19701
19716
  this.client = client;
19702
19717
  }
19718
+ async inspectInvitation(id, token) {
19719
+ return (await this.client.post(`/platform/server-invitations/${encodeURIComponent(id)}/inspect`, { token })).data;
19720
+ }
19721
+ async acceptInvitation(id, token) {
19722
+ return (await this.client.post(`/platform/server-invitations/${encodeURIComponent(id)}/accept`, { token })).data;
19723
+ }
19724
+ async declineInvitation(id, token) {
19725
+ return (await this.client.post(`/platform/server-invitations/${encodeURIComponent(id)}/decline`, { token })).data;
19726
+ }
19703
19727
  async list(options = {}) {
19704
19728
  const query = options.page === void 0 ? "" : `?${new URLSearchParams({ page: String(options.page) }).toString()}`;
19705
19729
  return this.client.get(`/servers${query}`);
@@ -19725,11 +19749,39 @@ ${JSON.stringify(metadata, null, 2)}` : "";
19725
19749
  const query = options.page === void 0 ? "" : `?${new URLSearchParams({ page: String(options.page) }).toString()}`;
19726
19750
  return this.client.get(`/servers/${encodeURIComponent(this.data.id)}/members${query}`);
19727
19751
  }
19728
- async share(email3) {
19729
- return (await this.client.post(`/servers/${encodeURIComponent(this.data.id)}/members`, { email: email3 })).data;
19752
+ async share(target) {
19753
+ if (target.email !== void 0) {
19754
+ return (await this.client.post(`/platform/servers/${encodeURIComponent(this.data.id)}/invitations`, {
19755
+ email: target.email,
19756
+ requestId: target.requestId ?? crypto.randomUUID()
19757
+ })).data;
19758
+ }
19759
+ const body = { organizationId: target.organizationId, requestId: target.requestId };
19760
+ return (await this.client.post(`/servers/${encodeURIComponent(this.data.id)}/members`, body)).data;
19730
19761
  }
19731
19762
  async revokeAccess(memberId) {
19732
- await this.client.delete(`/servers/${encodeURIComponent(this.data.id)}/members/${encodeURIComponent(String(memberId))}`);
19763
+ await this.client.delete(
19764
+ `/servers/${encodeURIComponent(this.data.id)}/members/${encodeURIComponent(String(memberId))}`
19765
+ );
19766
+ }
19767
+ async invitations(options = {}) {
19768
+ const query = options.page === void 0 ? "" : `?${new URLSearchParams({ page: String(options.page) }).toString()}`;
19769
+ return this.client.get(`/platform/servers/${encodeURIComponent(this.data.id)}/invitations${query}`);
19770
+ }
19771
+ async cancelInvitation(id) {
19772
+ const response = await this.client.delete(
19773
+ `/platform/servers/${encodeURIComponent(this.data.id)}/invitations/${encodeURIComponent(id)}`
19774
+ );
19775
+ if (response.data === void 0) {
19776
+ throw new PHPSandboxError("Missing invitation cancellation response.");
19777
+ }
19778
+ return response.data;
19779
+ }
19780
+ async resendInvitation(id) {
19781
+ return (await this.client.post(
19782
+ `/platform/servers/${encodeURIComponent(this.data.id)}/invitations/${encodeURIComponent(id)}/resend`,
19783
+ {}
19784
+ )).data;
19733
19785
  }
19734
19786
  refresh() {
19735
19787
  return this.client.servers.get(this.data.id);
@@ -19953,9 +20005,7 @@ ${JSON.stringify(metadata, null, 2)}` : "";
19953
20005
  throw new TypeError("Runtime file contents must be binary data.");
19954
20006
  }
19955
20007
  headers["Content-Type"] = "application/octet-stream";
19956
- return Uint8Array.from(
19957
- new Uint8Array(payload.contents.buffer, payload.contents.byteOffset, payload.contents.byteLength)
19958
- ).buffer;
20008
+ return Uint8Array.from(new Uint8Array(payload.contents.buffer, payload.contents.byteOffset, payload.contents.byteLength)).buffer;
19959
20009
  }
19960
20010
  headers["Content-Type"] = "application/json";
19961
20011
  return JSON.stringify(data);
@@ -20017,11 +20067,11 @@ ${JSON.stringify(metadata, null, 2)}` : "";
20017
20067
  async list(options = {}) {
20018
20068
  const query = new URLSearchParams();
20019
20069
  for (const [name, value] of Object.entries(options)) {
20020
- if (value !== void 0) query.set(name, String(value));
20070
+ if (value !== void 0) {
20071
+ query.set(name, String(value));
20072
+ }
20021
20073
  }
20022
- return this.client.get(
20023
- `${this.path()}${query.size === 0 ? "" : `?${query.toString()}`}`
20024
- );
20074
+ return this.client.get(`${this.path()}${query.size === 0 ? "" : `?${query.toString()}`}`);
20025
20075
  }
20026
20076
  async get(id) {
20027
20077
  const response = await this.client.get(this.path(`/${encodeURIComponent(id)}`));
@@ -20069,10 +20119,7 @@ ${JSON.stringify(metadata, null, 2)}` : "";
20069
20119
  return this.data.label;
20070
20120
  }
20071
20121
  async update(input) {
20072
- const response = await this.client.patch(
20073
- `/integrations/${encodeURIComponent(this.id)}`,
20074
- input
20075
- );
20122
+ const response = await this.client.patch(`/integrations/${encodeURIComponent(this.id)}`, input);
20076
20123
  return new _Integration(response.data, this.client);
20077
20124
  }
20078
20125
  async unlink() {
@@ -20274,7 +20321,7 @@ ${JSON.stringify(metadata, null, 2)}` : "";
20274
20321
  })
20275
20322
  );
20276
20323
  if (!response.ok) {
20277
- throw await responseError(response);
20324
+ throw await responseError(response, path.startsWith("/platform/") ? "platform" : "core");
20278
20325
  }
20279
20326
  if (response.status === 204) {
20280
20327
  return { data: void 0 };
@@ -20307,10 +20354,10 @@ ${JSON.stringify(metadata, null, 2)}` : "";
20307
20354
  }
20308
20355
  }
20309
20356
  };
20310
- async function responseError(response) {
20357
+ async function responseError(response, source = "core") {
20311
20358
  const body = await response.text();
20312
20359
  try {
20313
- return remoteError("core", errorPayload(body === "" ? void 0 : JSON.parse(body)), response);
20360
+ return remoteError(source, errorPayload(body === "" ? void 0 : JSON.parse(body)), response);
20314
20361
  } catch {
20315
20362
  return new TransportError(
20316
20363
  `PHPSandbox API returned an invalid error response (HTTP ${response.status}).`,
@@ -20335,6 +20382,14 @@ ${JSON.stringify(metadata, null, 2)}` : "";
20335
20382
  this.servers = client.servers;
20336
20383
  this.integrations = client.integrations;
20337
20384
  }
20385
+ async whoami() {
20386
+ const { data } = await this.client.get("/auth/whoami");
20387
+ const result = identitySchema.safeParse(data);
20388
+ if (!result.success) {
20389
+ throw new PHPSandboxError("Invalid identity response.");
20390
+ }
20391
+ return result.data;
20392
+ }
20338
20393
  get runtimeTransport() {
20339
20394
  return this.client.runtimeTransport;
20340
20395
  }
@@ -20382,7 +20437,6 @@ ${JSON.stringify(metadata, null, 2)}` : "";
20382
20437
  }
20383
20438
  this.files = new Filesystem(this, this.socket === null ? null : (handler) => this.onDidConnect(handler));
20384
20439
  this.terminals = new Terminals(this);
20385
- this.auth = new Auth(this);
20386
20440
  this.lsp = new Lsp(this);
20387
20441
  this.composer = new Composer(this, client);
20388
20442
  this.runtime = new Runtime(this);
@@ -20583,7 +20637,7 @@ ${JSON.stringify(metadata, null, 2)}` : "";
20583
20637
  socket.reconnect();
20584
20638
  this.initialized = false;
20585
20639
  await whenConnected;
20586
- __privateMethod(this, _NotebookInstance_instances, init_fn).call(this);
20640
+ __privateSet(this, _initPromise, __privateMethod(this, _NotebookInstance_instances, init_fn).call(this));
20587
20641
  return this.ready().then(() => this);
20588
20642
  }
20589
20643
  realtimeSocket() {
@@ -20632,7 +20686,9 @@ ${JSON.stringify(metadata, null, 2)}` : "";
20632
20686
  }
20633
20687
  async list(options) {
20634
20688
  const params = new URLSearchParams();
20635
- if (options?.environment) params.set("environment", options.environment);
20689
+ if (options?.environment) {
20690
+ params.set("environment", options.environment);
20691
+ }
20636
20692
  const query = params.toString();
20637
20693
  const response = await this.client.get(
20638
20694
  `/notebook/${this.notebookId}/secrets${query ? `?${query}` : ""}`
@@ -20652,7 +20708,9 @@ ${JSON.stringify(metadata, null, 2)}` : "";
20652
20708
  }
20653
20709
  async delete(name, options) {
20654
20710
  const params = new URLSearchParams();
20655
- if (options?.environment) params.set("environment", options.environment);
20711
+ if (options?.environment) {
20712
+ params.set("environment", options.environment);
20713
+ }
20656
20714
  const query = params.toString();
20657
20715
  await this.client.delete(`/notebook/${this.notebookId}/secrets/${encodeURIComponent(name)}${query ? `?${query}` : ""}`);
20658
20716
  }