@superdoc-dev/cli 0.7.0-next.8 → 0.7.0-next.9

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/dist/index.js +70 -11
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -19530,6 +19530,27 @@ function expectOptionalEnvVarName(value, path) {
19530
19530
  }
19531
19531
  return value;
19532
19532
  }
19533
+ function expectOptionalWebSocketParams(value, path) {
19534
+ if (value == null)
19535
+ return;
19536
+ if (!isRecord3(value)) {
19537
+ throw new CliError("VALIDATION_ERROR", `${path} must be an object of string key-value pairs.`);
19538
+ }
19539
+ const result = {};
19540
+ for (const [key, val] of Object.entries(value)) {
19541
+ if (key.trim().length === 0) {
19542
+ throw new CliError("VALIDATION_ERROR", `${path} keys must be non-empty strings.`);
19543
+ }
19544
+ if (RESERVED_WEBSOCKET_PARAM_KEYS.has(key)) {
19545
+ throw new CliError("VALIDATION_ERROR", `${path}.${key} is reserved; the collaboration token is set automatically from tokenEnv.`);
19546
+ }
19547
+ if (typeof val !== "string") {
19548
+ throw new CliError("VALIDATION_ERROR", `${path}.${key} must be a string.`);
19549
+ }
19550
+ result[key] = val;
19551
+ }
19552
+ return result;
19553
+ }
19533
19554
  function parseOnMissing(value) {
19534
19555
  if (value == null)
19535
19556
  return;
@@ -19562,15 +19583,13 @@ function parseWebSocketInput(raw) {
19562
19583
  if ("token" in raw) {
19563
19584
  throw new CliError("VALIDATION_ERROR", "collaboration.token is not supported in v1; use collaboration.tokenEnv.");
19564
19585
  }
19565
- if ("params" in raw) {
19566
- throw new CliError("VALIDATION_ERROR", "collaboration.params is not supported in v1.");
19567
- }
19568
19586
  const providerType = normalizeProviderType(raw.providerType, "collaboration.providerType");
19569
19587
  return {
19570
19588
  providerType,
19571
19589
  url: expectNonEmptyString(raw.url, "collaboration.url").trim(),
19572
19590
  documentId: raw.documentId != null ? expectNonEmptyString(raw.documentId, "collaboration.documentId") : undefined,
19573
19591
  tokenEnv: expectOptionalEnvVarName(raw.tokenEnv, "collaboration.tokenEnv"),
19592
+ params: expectOptionalWebSocketParams(raw.params, "collaboration.params"),
19574
19593
  ...parseSharedFields(raw)
19575
19594
  };
19576
19595
  }
@@ -19588,7 +19607,7 @@ function parseLiveblocksInput(raw) {
19588
19607
  throw new CliError("VALIDATION_ERROR", "collaboration.token is not supported in v1.");
19589
19608
  }
19590
19609
  if ("params" in raw) {
19591
- throw new CliError("VALIDATION_ERROR", "collaboration.params is not supported in v1.");
19610
+ throw new CliError("VALIDATION_ERROR", "collaboration.params is not supported for Liveblocks.");
19592
19611
  }
19593
19612
  if ("headers" in raw) {
19594
19613
  throw new CliError("VALIDATION_ERROR", "collaboration.headers is not supported; use authHeadersEnv for custom auth headers.");
@@ -19647,7 +19666,7 @@ function buildShorthandCollaborationInput(params) {
19647
19666
  ...params
19648
19667
  });
19649
19668
  }
19650
- var DEFAULT_SHORTHAND_COLLABORATION_PROVIDER_TYPE = "y-websocket", WEBSOCKET_ALLOWED_KEYS, LIVEBLOCKS_ALLOWED_KEYS;
19669
+ var DEFAULT_SHORTHAND_COLLABORATION_PROVIDER_TYPE = "y-websocket", WEBSOCKET_ALLOWED_KEYS, RESERVED_WEBSOCKET_PARAM_KEYS, LIVEBLOCKS_ALLOWED_KEYS;
19651
19670
  var init_parse = __esm(() => {
19652
19671
  init_errors();
19653
19672
  init_guards();
@@ -19657,10 +19676,12 @@ var init_parse = __esm(() => {
19657
19676
  "url",
19658
19677
  "documentId",
19659
19678
  "tokenEnv",
19679
+ "params",
19660
19680
  "syncTimeoutMs",
19661
19681
  "onMissing",
19662
19682
  "bootstrapSettlingMs"
19663
19683
  ]);
19684
+ RESERVED_WEBSOCKET_PARAM_KEYS = new Set(["token"]);
19664
19685
  LIVEBLOCKS_ALLOWED_KEYS = new Set([
19665
19686
  "providerType",
19666
19687
  "roomId",
@@ -19680,6 +19701,7 @@ function resolveWebSocketProfile(input, sessionId) {
19680
19701
  url: input.url,
19681
19702
  documentId: input.documentId?.trim() || sessionId,
19682
19703
  tokenEnv: input.tokenEnv,
19704
+ params: input.params,
19683
19705
  syncTimeoutMs: input.syncTimeoutMs,
19684
19706
  onMissing: input.onMissing,
19685
19707
  bootstrapSettlingMs: input.bootstrapSettlingMs
@@ -41219,9 +41241,13 @@ function createWebSocketRuntime(profile) {
41219
41241
  const syncTimeoutMs = profile.syncTimeoutMs ?? DEFAULT_SYNC_TIMEOUT_MS;
41220
41242
  let provider;
41221
41243
  if (profile.providerType === "y-websocket") {
41222
- const providerOptions = {};
41244
+ const params3 = { ...profile.params ?? {} };
41223
41245
  if (token) {
41224
- providerOptions.params = { token };
41246
+ params3.token = token;
41247
+ }
41248
+ const providerOptions = {};
41249
+ if (Object.keys(params3).length > 0) {
41250
+ providerOptions.params = params3;
41225
41251
  }
41226
41252
  provider = new WebsocketProvider(profile.url, profile.documentId, ydoc, providerOptions);
41227
41253
  } else {
@@ -41230,6 +41256,7 @@ function createWebSocketRuntime(profile) {
41230
41256
  document: ydoc,
41231
41257
  name: profile.documentId,
41232
41258
  token: token ?? "",
41259
+ parameters: profile.params,
41233
41260
  preserveConnection: false
41234
41261
  });
41235
41262
  }
@@ -41356,6 +41383,21 @@ function normalizeSharedFields(record) {
41356
41383
  bootstrapSettlingMs: typeof record.bootstrapSettlingMs === "number" ? record.bootstrapSettlingMs : undefined
41357
41384
  };
41358
41385
  }
41386
+ function normalizeWebSocketParams(value) {
41387
+ if (value == null)
41388
+ return;
41389
+ if (!isRecord3(value))
41390
+ return null;
41391
+ const result = {};
41392
+ for (const [key, val] of Object.entries(value)) {
41393
+ if (typeof key !== "string" || key.length === 0)
41394
+ return null;
41395
+ if (typeof val !== "string")
41396
+ return null;
41397
+ result[key] = val;
41398
+ }
41399
+ return result;
41400
+ }
41359
41401
  function normalizeWebSocketProfile(record) {
41360
41402
  const { providerType, url: url2, documentId, tokenEnv } = record;
41361
41403
  if (typeof url2 !== "string" || url2.length === 0)
@@ -41367,11 +41409,15 @@ function normalizeWebSocketProfile(record) {
41367
41409
  const shared = normalizeSharedFields(record);
41368
41410
  if (!shared)
41369
41411
  return;
41412
+ const params3 = normalizeWebSocketParams(record.params);
41413
+ if (params3 === null)
41414
+ return;
41370
41415
  return {
41371
41416
  providerType,
41372
41417
  url: url2,
41373
41418
  documentId,
41374
41419
  tokenEnv: typeof tokenEnv === "string" ? tokenEnv : undefined,
41420
+ params: params3,
41375
41421
  ...shared
41376
41422
  };
41377
41423
  }
@@ -374039,6 +374085,11 @@ var init_operation_params = __esm(() => {
374039
374085
  description: "Room/document identifier. Defaults to session ID if omitted."
374040
374086
  },
374041
374087
  tokenEnv: { type: "string", description: "Environment variable name containing the auth token." },
374088
+ params: {
374089
+ type: "object",
374090
+ description: "Custom query parameters appended to the WebSocket URL. Values must be strings. Reserved keys: token.",
374091
+ additionalProperties: { type: "string" }
374092
+ },
374042
374093
  syncTimeoutMs: { type: "number", description: "Max time (ms) to wait for initial sync." },
374043
374094
  onMissing: {
374044
374095
  type: "string",
@@ -374915,7 +374966,7 @@ function validateValueAgainstTypeSpec(value2, schema, path2) {
374915
374966
  throw new CliError("VALIDATION_ERROR", `${path2}.${key2} is required.`);
374916
374967
  }
374917
374968
  }
374918
- const propertyEntries = Object.entries(schema.properties);
374969
+ const propertyEntries = schema.properties ? Object.entries(schema.properties) : [];
374919
374970
  const shouldRestrictUnknownKeys = propertyEntries.length > 0 || required.length > 0;
374920
374971
  if (shouldRestrictUnknownKeys) {
374921
374972
  const knownKeys = new Set(propertyEntries.map(([key2]) => key2));
@@ -374988,7 +375039,8 @@ function validateResponseValueAgainstTypeSpec(value2, schema, path2) {
374988
375039
  throw new CliError("VALIDATION_ERROR", `${path2}.${key2} is required.`);
374989
375040
  }
374990
375041
  }
374991
- for (const [key2, propSchema] of Object.entries(schema.properties)) {
375042
+ const properties = schema.properties ?? {};
375043
+ for (const [key2, propSchema] of Object.entries(properties)) {
374992
375044
  if (!Object.prototype.hasOwnProperty.call(value2, key2))
374993
375045
  continue;
374994
375046
  validateResponseValueAgainstTypeSpec(value2[key2], propSchema, `${path2}.${key2}`);
@@ -382733,9 +382785,16 @@ var init_version2 = () => {};
382733
382785
 
382734
382786
  // src/host/session-pool.ts
382735
382787
  import { createHash as createHash4 } from "node:crypto";
382788
+ function stableStringify4(value2) {
382789
+ if (value2 === null || typeof value2 !== "object")
382790
+ return JSON.stringify(value2);
382791
+ if (Array.isArray(value2))
382792
+ return `[${value2.map(stableStringify4).join(",")}]`;
382793
+ const entries3 = Object.keys(value2).sort().map((key2) => `${JSON.stringify(key2)}:${stableStringify4(value2[key2])}`);
382794
+ return `{${entries3.join(",")}}`;
382795
+ }
382736
382796
  function profileToFingerprint(profile) {
382737
- const sortedJson = JSON.stringify(profile, Object.keys(profile).sort());
382738
- return createHash4("sha256").update(sortedJson).digest("hex");
382797
+ return createHash4("sha256").update(stableStringify4(profile)).digest("hex");
382739
382798
  }
382740
382799
  function createSessionLocks() {
382741
382800
  const locks = new Map;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.7.0-next.8",
3
+ "version": "0.7.0-next.9",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -25,20 +25,20 @@
25
25
  "@types/ws": "^8.5.13",
26
26
  "typescript": "^5.9.2",
27
27
  "@superdoc/document-api": "0.0.1",
28
+ "@superdoc/pm-adapter": "0.0.0",
28
29
  "@superdoc/super-editor": "0.0.1",
29
- "superdoc": "1.26.0",
30
- "@superdoc/pm-adapter": "0.0.0"
30
+ "superdoc": "1.26.0"
31
31
  },
32
32
  "module": "src/index.ts",
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@superdoc-dev/cli-darwin-arm64": "0.7.0-next.8",
38
- "@superdoc-dev/cli-darwin-x64": "0.7.0-next.8",
39
- "@superdoc-dev/cli-linux-x64": "0.7.0-next.8",
40
- "@superdoc-dev/cli-windows-x64": "0.7.0-next.8",
41
- "@superdoc-dev/cli-linux-arm64": "0.7.0-next.8"
37
+ "@superdoc-dev/cli-darwin-arm64": "0.7.0-next.9",
38
+ "@superdoc-dev/cli-darwin-x64": "0.7.0-next.9",
39
+ "@superdoc-dev/cli-linux-arm64": "0.7.0-next.9",
40
+ "@superdoc-dev/cli-linux-x64": "0.7.0-next.9",
41
+ "@superdoc-dev/cli-windows-x64": "0.7.0-next.9"
42
42
  },
43
43
  "scripts": {
44
44
  "predev": "node scripts/ensure-superdoc-build.js",