@supernova-studio/client 0.6.0 → 0.7.0

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/dist/index.js CHANGED
@@ -876,7 +876,8 @@ var PageBlockImageType = _zod.z.enum(["Upload", "Asset", "FigmaFrame"]);
876
876
  var PageBlockImageAlignment = _zod.z.enum(["Left", "Center", "Stretch"]);
877
877
  var PageBlockTableCellAlignment = _zod.z.enum(["Left", "Center", "Right"]);
878
878
  var PageBlockAppearanceV2 = _zod.z.object({
879
- itemBackgroundColor: ColorValue
879
+ itemBackgroundColor: ColorValue.optional(),
880
+ numberOfColumns: _zod.z.number().optional()
880
881
  });
881
882
  var PageBlockItemUntypedValue = _zod.z.object({
882
883
  value: _zod.z.any()
@@ -2068,6 +2069,14 @@ var WorkspaceMembership = _zod.z.object({
2068
2069
  workspaceId: _zod.z.string(),
2069
2070
  workspaceRole: _zod.z.nativeEnum(WorkspaceRole)
2070
2071
  });
2072
+ var UpdateMembershipRolesInput = _zod.z.object({
2073
+ members: _zod.z.array(
2074
+ _zod.z.object({
2075
+ userId: _zod.z.string(),
2076
+ role: _zod.z.nativeEnum(WorkspaceRole)
2077
+ })
2078
+ )
2079
+ });
2071
2080
  var WorkspaceIpWhitelistEntry = _zod.z.object({
2072
2081
  isEnabled: _zod.z.boolean(),
2073
2082
  name: _zod.z.string(),
@@ -4426,7 +4435,8 @@ function serializeAsCustomBlock(block, definition) {
4426
4435
  id: block.id,
4427
4436
  definitionId: block.data.packageId,
4428
4437
  variantId: block.data.variantId,
4429
- items: JSON.stringify(items)
4438
+ items: JSON.stringify(items),
4439
+ appearance: JSON.stringify(block.data.appearance)
4430
4440
  }
4431
4441
  };
4432
4442
  }
@@ -5811,7 +5821,7 @@ function prosemirrorDocToPage(prosemirrorDoc, definitions) {
5811
5821
  const definitionsById = mapByUnique(definitions, (d) => d.id);
5812
5822
  return {
5813
5823
  blocks: (_nullishCoalesce(prosemirrorDoc.content, () => ( []))).map((prosemirrorNode) => {
5814
- const definitionId = _optionalChain([prosemirrorNode, 'access', _10 => _10.attrs, 'optionalAccess', _11 => _11.definitionId]);
5824
+ const definitionId = parseProsemirrorBlockAttribute(prosemirrorNode, "definitionId");
5815
5825
  if (!definitionId)
5816
5826
  throw new Error(`Node is missing defintion id`);
5817
5827
  if (typeof definitionId !== "string")
@@ -5847,7 +5857,10 @@ function prosemirrorNodeToBlock(prosemirrorNode, definition) {
5847
5857
  }
5848
5858
  function parseAsRichText(prosemirrorNode, definition, property) {
5849
5859
  const id = parseProsemirrorBlockAttribute(prosemirrorNode, "id");
5850
- const variantId = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
5860
+ if (typeof id !== "string")
5861
+ return null;
5862
+ const variantIdRaw = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
5863
+ const variantId = typeof variantIdRaw === "string" ? variantIdRaw : void 0;
5851
5864
  const calloutType = parseCalloutType(parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "type"));
5852
5865
  return {
5853
5866
  // TODO Artem: indent
@@ -5888,7 +5901,10 @@ function parseCalloutType(prosemirrorCalloutType) {
5888
5901
  }
5889
5902
  function parseAsMultiRichText(prosemirrorNode, definition, property) {
5890
5903
  const id = parseProsemirrorBlockAttribute(prosemirrorNode, "id");
5891
- const variantId = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
5904
+ if (typeof id !== "string")
5905
+ return null;
5906
+ const variantIdRaw = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
5907
+ const variantId = typeof variantIdRaw === "string" ? variantIdRaw : void 0;
5892
5908
  return {
5893
5909
  // TODO Artem: indent
5894
5910
  id,
@@ -5905,7 +5921,7 @@ function parseAsMultiRichText(prosemirrorNode, definition, property) {
5905
5921
  value: (_nullishCoalesce(prosemirrorNode.content, () => ( []))).map((listItem) => {
5906
5922
  if (listItem.type !== "listitem")
5907
5923
  return null;
5908
- if (!_optionalChain([listItem, 'access', _12 => _12.content, 'optionalAccess', _13 => _13.length]))
5924
+ if (!_optionalChain([listItem, 'access', _10 => _10.content, 'optionalAccess', _11 => _11.length]))
5909
5925
  return parseRichText([]);
5910
5926
  const paragraph = listItem.content[0];
5911
5927
  if (paragraph.type !== "paragraph")
@@ -5944,11 +5960,13 @@ function parseRichTextAttribute(mark) {
5944
5960
  case "code":
5945
5961
  return { type: "Code" };
5946
5962
  case "link":
5947
- const itemId = _optionalChain([mark, 'access', _14 => _14.attrs, 'optionalAccess', _15 => _15.itemId]);
5948
- const href = _optionalChain([mark, 'access', _16 => _16.attrs, 'optionalAccess', _17 => _17.href]);
5963
+ const itemIdRaw = parseProsemirrorBlockAttribute(mark, "itemId");
5964
+ const itemId = typeof itemIdRaw === "string" ? itemIdRaw : void 0;
5965
+ const hrefRaw = parseProsemirrorBlockAttribute(mark, "href");
5966
+ const href = typeof hrefRaw === "string" ? hrefRaw : void 0;
5949
5967
  return {
5950
5968
  type: "Link",
5951
- openInNewWindow: _optionalChain([mark, 'access', _18 => _18.attrs, 'optionalAccess', _19 => _19.target]) !== "_self",
5969
+ openInNewWindow: _optionalChain([mark, 'access', _12 => _12.attrs, 'optionalAccess', _13 => _13.target]) !== "_self",
5952
5970
  documentationItemId: itemId,
5953
5971
  link: href
5954
5972
  };
@@ -5957,19 +5975,22 @@ function parseRichTextAttribute(mark) {
5957
5975
  }
5958
5976
  function parseAsTable(prosemirrorNode, definition, property) {
5959
5977
  const id = parseProsemirrorBlockAttribute(prosemirrorNode, "id");
5960
- const variantId = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
5978
+ if (typeof id !== "string")
5979
+ return null;
5980
+ const variantIdRaw = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
5981
+ const variantId = typeof variantIdRaw === "string" ? variantIdRaw : void 0;
5961
5982
  const hasBorder = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "hasBorder") !== false;
5962
- const tableChild = _optionalChain([prosemirrorNode, 'access', _20 => _20.content, 'optionalAccess', _21 => _21.find, 'call', _22 => _22((c) => c.type === "table")]);
5983
+ const tableChild = _optionalChain([prosemirrorNode, 'access', _14 => _14.content, 'optionalAccess', _15 => _15.find, 'call', _16 => _16((c) => c.type === "table")]);
5963
5984
  if (!tableChild) {
5964
5985
  return emptyTable(id, variantId, 0);
5965
5986
  }
5966
- const rows = _nullishCoalesce(_optionalChain([tableChild, 'access', _23 => _23.content, 'optionalAccess', _24 => _24.filter, 'call', _25 => _25((c) => c.type === "tableRow" && !!_optionalChain([c, 'access', _26 => _26.content, 'optionalAccess', _27 => _27.length]))]), () => ( []));
5987
+ const rows = _nullishCoalesce(_optionalChain([tableChild, 'access', _17 => _17.content, 'optionalAccess', _18 => _18.filter, 'call', _19 => _19((c) => c.type === "tableRow" && !!_optionalChain([c, 'access', _20 => _20.content, 'optionalAccess', _21 => _21.length]))]), () => ( []));
5967
5988
  if (!rows.length) {
5968
5989
  return emptyTable(id, variantId, 0);
5969
5990
  }
5970
- const rowHeaderCells = _nullishCoalesce(_optionalChain([rows, 'access', _28 => _28[0], 'access', _29 => _29.content, 'optionalAccess', _30 => _30.filter, 'call', _31 => _31((c) => c.type === "tableHeader"), 'access', _32 => _32.length]), () => ( 0));
5971
- const columnHeaderCells = rows.filter((r) => _optionalChain([r, 'access', _33 => _33.content, 'optionalAccess', _34 => _34[0], 'optionalAccess', _35 => _35.type]) === "tableHeader").length;
5972
- const hasHeaderRow = _optionalChain([rows, 'access', _36 => _36[0], 'access', _37 => _37.content, 'optionalAccess', _38 => _38.length]) === rowHeaderCells;
5991
+ const rowHeaderCells = _nullishCoalesce(_optionalChain([rows, 'access', _22 => _22[0], 'access', _23 => _23.content, 'optionalAccess', _24 => _24.filter, 'call', _25 => _25((c) => c.type === "tableHeader"), 'access', _26 => _26.length]), () => ( 0));
5992
+ const columnHeaderCells = rows.filter((r) => _optionalChain([r, 'access', _27 => _27.content, 'optionalAccess', _28 => _28[0], 'optionalAccess', _29 => _29.type]) === "tableHeader").length;
5993
+ const hasHeaderRow = _optionalChain([rows, 'access', _30 => _30[0], 'access', _31 => _31.content, 'optionalAccess', _32 => _32.length]) === rowHeaderCells;
5973
5994
  const hasHeaderColumn = rows.length === columnHeaderCells;
5974
5995
  const tableValue = {
5975
5996
  showBorder: hasBorder,
@@ -5979,7 +6000,7 @@ function parseAsTable(prosemirrorNode, definition, property) {
5979
6000
  };
5980
6001
  tableValue.value = rows.map((row) => {
5981
6002
  return {
5982
- cells: (_nullishCoalesce(row.content, () => ( []))).map(parseAsTableCell)
6003
+ cells: (_nullishCoalesce(row.content, () => ( []))).map(parseAsTableCell).filter(nonNullFilter2)
5983
6004
  };
5984
6005
  });
5985
6006
  return {
@@ -6001,6 +6022,8 @@ function parseAsTable(prosemirrorNode, definition, property) {
6001
6022
  }
6002
6023
  function parseAsTableCell(prosemirrorNode) {
6003
6024
  const id = parseProsemirrorBlockAttribute(prosemirrorNode, "id");
6025
+ if (typeof id !== "string")
6026
+ return null;
6004
6027
  const textAlign = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "textAlign");
6005
6028
  let columnWidth;
6006
6029
  const columnWidthArray = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "colwidth");
@@ -6097,7 +6120,10 @@ function emptyTableCellContent() {
6097
6120
  }
6098
6121
  function parseAsEmbed(prosemirrorNode, definition, property) {
6099
6122
  const id = parseProsemirrorBlockAttribute(prosemirrorNode, "id");
6100
- const variantId = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
6123
+ if (typeof id !== "string")
6124
+ return null;
6125
+ const variantIdRaw = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
6126
+ const variantId = typeof variantIdRaw === "string" ? variantIdRaw : void 0;
6101
6127
  const url = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "url");
6102
6128
  const caption = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "caption");
6103
6129
  const height = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "height");
@@ -6124,7 +6150,10 @@ function parseAsEmbed(prosemirrorNode, definition, property) {
6124
6150
  }
6125
6151
  function parseAsDivider(prosemirrorNode, definition) {
6126
6152
  const id = parseProsemirrorBlockAttribute(prosemirrorNode, "id");
6127
- const variantId = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
6153
+ if (typeof id !== "string")
6154
+ return null;
6155
+ const variantIdRaw = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
6156
+ const variantId = typeof variantIdRaw === "string" ? variantIdRaw : void 0;
6128
6157
  return {
6129
6158
  id,
6130
6159
  data: {
@@ -6137,24 +6166,51 @@ function parseAsDivider(prosemirrorNode, definition) {
6137
6166
  }
6138
6167
  function parseAsCustomBlock(prosemirrorNode, definition) {
6139
6168
  const id = parseProsemirrorBlockAttribute(prosemirrorNode, "id");
6140
- const variantId = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
6141
- const itemsString = parseProsemirrorBlockAttribute(prosemirrorNode, "items");
6142
- const itemsJson = JSON.parse(itemsString);
6143
- if (!Array.isArray(itemsJson)) {
6144
- console.error("Block `items` property must be a json array");
6169
+ if (typeof id !== "string")
6170
+ return null;
6171
+ const variantIdRaw = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
6172
+ const variantId = typeof variantIdRaw === "string" ? variantIdRaw : void 0;
6173
+ const appearance = parseAppearance(prosemirrorNode);
6174
+ const parsedItems = parseBlockItems(prosemirrorNode, definition);
6175
+ if (!parsedItems)
6145
6176
  return null;
6146
- }
6147
- const parsedItems = itemsJson.map((i) => parseItem(i, definition)).filter(nonNullFilter2);
6148
6177
  return {
6149
6178
  id,
6150
6179
  data: {
6151
6180
  packageId: definition.id,
6152
6181
  indentLevel: 0,
6153
6182
  ...variantId && { variantId },
6183
+ appearance,
6154
6184
  items: parsedItems
6155
6185
  }
6156
6186
  };
6157
6187
  }
6188
+ function parseBlockItems(prosemirrorNode, definition) {
6189
+ const itemsString = parseProsemirrorBlockAttribute(prosemirrorNode, "items");
6190
+ if (typeof itemsString !== "string")
6191
+ return null;
6192
+ const itemsJson = JSON.parse(itemsString);
6193
+ if (!Array.isArray(itemsJson)) {
6194
+ console.error("Block `items` property must be a json array");
6195
+ return null;
6196
+ }
6197
+ return itemsJson.map((i) => parseItem(i, definition)).filter(nonNullFilter2);
6198
+ }
6199
+ function parseAppearance(prosemirrorNode) {
6200
+ const appearance = {};
6201
+ const columns = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "columns");
6202
+ if (typeof columns === "number") {
6203
+ appearance.numberOfColumns = columns;
6204
+ }
6205
+ const backgroundColor = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "backgroundColor");
6206
+ if (typeof backgroundColor === "string") {
6207
+ const parsedColor = ColorValue.safeParse(JSON.parse(backgroundColor));
6208
+ if (parsedColor.success) {
6209
+ appearance.itemBackgroundColor = parsedColor.data;
6210
+ }
6211
+ }
6212
+ return appearance;
6213
+ }
6158
6214
  function parseItem(rawItem, definition) {
6159
6215
  const parsedItem = PageBlockItemV2.safeParse(rawItem);
6160
6216
  if (!parsedItem.success) {
@@ -6240,7 +6296,7 @@ function parseProsemirrorBlockAttribute(prosemirrorNode, attributeName) {
6240
6296
  return attributeValue;
6241
6297
  }
6242
6298
  function parseProsemirrorOptionalBlockAttribute(prosemirrorNode, attributeName) {
6243
- return _nullishCoalesce(_optionalChain([prosemirrorNode, 'access', _39 => _39.attrs, 'optionalAccess', _40 => _40[attributeName]]), () => ( void 0));
6299
+ return _nullishCoalesce(_optionalChain([prosemirrorNode, 'access', _33 => _33.attrs, 'optionalAccess', _34 => _34[attributeName]]), () => ( void 0));
6244
6300
  }
6245
6301
  function nonNullFilter2(item) {
6246
6302
  return item !== null;