@notionhq/custom-blocks-dev-shell 0.2.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.
@@ -865,6 +865,15 @@ function variant(key, options, message$1) {
865
865
  }
866
866
  });
867
867
  }
868
+ // @__NO_SIDE_EFFECTS__
869
+ function omit(schema, keys) {
870
+ const entries$1 = { ...schema.entries };
871
+ for (const key of keys) delete entries$1[key];
872
+ return _standardSchema({
873
+ ...schema,
874
+ entries: entries$1
875
+ });
876
+ }
868
877
  function parse(schema, input, config$1) {
869
878
  const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
870
879
  if (dataset.issues) throw new ValiError(dataset.issues);
@@ -907,6 +916,10 @@ var notionDataSourceIdSchema = pipe(
907
916
  var notionPageIdSchema = pipe(string(), brand("NotionPageId"));
908
917
  var notionAgentIdSchema = pipe(string(), brand("NotionAgentId"));
909
918
  var notionSpaceIdSchema = pipe(string(), brand("NotionSpaceId"));
919
+ var notionAppInstallationIdSchema = pipe(
920
+ string(),
921
+ brand("NotionAppInstallationId")
922
+ );
910
923
 
911
924
  // ../protocol/src/context/parent.ts
912
925
  var pageParentSchema = object({
@@ -929,6 +942,10 @@ var agentParentSchema = object({
929
942
  type: literal("agent_id"),
930
943
  agent_id: notionAgentIdSchema
931
944
  });
945
+ var appInstallationParentSchema = object({
946
+ type: literal("app_installation_id"),
947
+ app_installation_id: notionAppInstallationIdSchema
948
+ });
932
949
  var unavailableParentSchema = object({ type: literal("unavailable") });
933
950
  var notionParentSchema = variant("type", [
934
951
  pageParentSchema,
@@ -936,12 +953,30 @@ var notionParentSchema = variant("type", [
936
953
  workspaceParentSchema,
937
954
  blockParentSchema,
938
955
  agentParentSchema,
956
+ appInstallationParentSchema,
939
957
  unavailableParentSchema
940
958
  ]);
941
959
 
960
+ // ../protocol/src/files.ts
961
+ var bridgeExternalFileSchema = object({
962
+ type: literal("external"),
963
+ external: object({ url: string() })
964
+ });
965
+ var bridgeNotionHostedFileSchema = object({
966
+ type: literal("file"),
967
+ file: object({
968
+ url: string(),
969
+ expiry_time: optional(string())
970
+ })
971
+ });
972
+ var bridgeFilePropertyItemSchema = union([
973
+ object({ ...bridgeExternalFileSchema.entries, name: string() }),
974
+ object({ ...bridgeNotionHostedFileSchema.entries, name: string() })
975
+ ]);
976
+
942
977
  // ../protocol/src/icons.ts
943
- var notionIconNameSchema = string();
944
- var knownNotionIconColorSchema = picklist([
978
+ var bridgeIconNameSchema = string();
979
+ var knownBridgeIconColorSchema = picklist([
945
980
  "gray",
946
981
  "lightgray",
947
982
  "brown",
@@ -953,24 +988,22 @@ var knownNotionIconColorSchema = picklist([
953
988
  "pink",
954
989
  "red"
955
990
  ]);
956
- var notionIconColorSchema = union([
957
- knownNotionIconColorSchema,
991
+ var bridgeIconColorSchema = union([
992
+ knownBridgeIconColorSchema,
958
993
  string()
959
994
  ]);
960
- var notionNativeIconSchema = looseObject({
995
+ var bridgeIconSchema = looseObject({
961
996
  type: literal("icon"),
962
997
  icon: looseObject({
963
- name: notionIconNameSchema,
964
- color: optional(notionIconColorSchema)
998
+ name: bridgeIconNameSchema,
999
+ color: optional(bridgeIconColorSchema)
965
1000
  })
966
1001
  });
967
-
968
- // ../protocol/src/pages/pageAppearance.ts
969
- var notionEmojiIconSchema = object({
1002
+ var bridgeEmojiSchema = object({
970
1003
  type: literal("emoji"),
971
1004
  emoji: string()
972
1005
  });
973
- var notionCustomEmojiIconSchema = object({
1006
+ var bridgeCustomEmojiSchema = object({
974
1007
  type: literal("custom_emoji"),
975
1008
  custom_emoji: object({
976
1009
  id: string(),
@@ -978,34 +1011,18 @@ var notionCustomEmojiIconSchema = object({
978
1011
  url: optional(string())
979
1012
  })
980
1013
  });
981
- var notionExternalFileSchema = object({
982
- type: literal("external"),
983
- external: object({ url: string() })
984
- });
985
- var notionHostedFileSchema = object({
986
- type: literal("file"),
987
- file: object({
988
- url: string(),
989
- expiry_time: optional(string())
990
- })
991
- });
992
- var notionPageIconSchema = variant("type", [
993
- notionNativeIconSchema,
994
- notionEmojiIconSchema,
995
- notionCustomEmojiIconSchema,
996
- notionExternalFileSchema,
997
- notionHostedFileSchema
998
- ]);
999
- var notionPageCoverSchema = variant("type", [
1000
- notionExternalFileSchema,
1001
- notionHostedFileSchema
1014
+
1015
+ // ../protocol/src/pages/pageAppearance.ts
1016
+ var bridgePageIconSchema = variant("type", [
1017
+ bridgeIconSchema,
1018
+ bridgeEmojiSchema,
1019
+ bridgeCustomEmojiSchema,
1020
+ bridgeExternalFileSchema,
1021
+ bridgeNotionHostedFileSchema
1002
1022
  ]);
1003
- var notionCreatePageIconSchema = variant("type", [
1004
- notionNativeIconSchema,
1005
- notionEmojiIconSchema,
1006
- notionCustomEmojiIconSchema,
1007
- notionExternalFileSchema,
1008
- notionHostedFileSchema
1023
+ var bridgePageCoverSchema = variant("type", [
1024
+ bridgeExternalFileSchema,
1025
+ bridgeNotionHostedFileSchema
1009
1026
  ]);
1010
1027
 
1011
1028
  // ../protocol/src/utils/nullableStringSchema.ts
@@ -1095,23 +1112,6 @@ var notionDateInputSchema = union([
1095
1112
  })
1096
1113
  ]);
1097
1114
 
1098
- // ../protocol/src/pages/properties/fileInput.ts
1099
- var notionFileInputSchema = union([
1100
- object({
1101
- type: literal("external"),
1102
- name: string(),
1103
- external: object({ url: string() })
1104
- }),
1105
- object({
1106
- type: literal("file"),
1107
- name: string(),
1108
- file: object({
1109
- url: string(),
1110
- expiry_time: optional(string())
1111
- })
1112
- })
1113
- ]);
1114
-
1115
1115
  // ../protocol/src/utils/recordPointer.ts
1116
1116
  var notionRecordPointerSchema = object({
1117
1117
  id: string(),
@@ -1244,7 +1244,7 @@ var bridgePagePropertyValueSchema = variant("type", [
1244
1244
  object({
1245
1245
  ...pagePropertyBaseSchema,
1246
1246
  type: literal("files"),
1247
- files: array(notionFileInputSchema)
1247
+ files: array(bridgeFilePropertyItemSchema)
1248
1248
  }),
1249
1249
  object({
1250
1250
  ...pagePropertyBaseSchema,
@@ -1286,11 +1286,6 @@ var bridgePagePropertyValueSchema = variant("type", [
1286
1286
  type: literal("formula"),
1287
1287
  formula: string()
1288
1288
  }),
1289
- object({
1290
- ...pagePropertyBaseSchema,
1291
- type: literal("location"),
1292
- location: string()
1293
- }),
1294
1289
  object({
1295
1290
  ...pagePropertyBaseSchema,
1296
1291
  type: literal("rollup"),
@@ -1321,8 +1316,8 @@ var bridgePageForProtocol3To5Schema = object({
1321
1316
  properties: bridgePagePropertyWriteMapSchema,
1322
1317
  created_time: optional(string()),
1323
1318
  last_edited_time: optional(string()),
1324
- icon: optional(notionPageIconSchema),
1325
- cover: optional(notionPageCoverSchema),
1319
+ icon: optional(bridgePageIconSchema),
1320
+ cover: optional(bridgePageCoverSchema),
1326
1321
  url: optional(string()),
1327
1322
  public_url: optional(string()),
1328
1323
  /** Whether the page or an ancestor is archived. */
@@ -1351,61 +1346,8 @@ var notionDataSourcePageForProtocol3To5Schema = object({
1351
1346
  propertiesById: record(string(), optional(notionDataSourceValueSchema))
1352
1347
  });
1353
1348
 
1354
- // ../protocol/src/context/containingPage.ts
1355
- var customBlockPageSchema = variant("type", [
1356
- /** The viewer cannot access the containing page; its ID and parent are not exposed. */
1357
- object({ type: literal("unavailable") }),
1358
- /** The viewer can access the containing page; includes its ID and parent location. */
1359
- object({
1360
- type: literal("page"),
1361
- id: notionPageIdSchema,
1362
- /**
1363
- * The containing page's own parent. It lets a block distinguish a freestanding page from a
1364
- * database row without a round trip. Not to be confused with the top-level `parent` runtime
1365
- * value, which is the custom block's own parent.
1366
- */
1367
- parent: notionParentSchema
1368
- })
1369
- ]);
1370
-
1371
- // ../protocol/src/context/contrast.ts
1372
- var notionContrastModeSchema = picklist(["standard", "high"]);
1373
-
1374
- // ../protocol/src/context/messages/contrastModeChanged.ts
1375
- var contrastModeChangedMessageSchema = object({
1376
- type: literal("contrastModeChanged"),
1377
- contrastMode: notionContrastModeSchema
1378
- });
1379
-
1380
- // ../protocol/src/context/messages/pageChanged.ts
1381
- var pageChangedMessageSchema = object({
1382
- type: literal("pageChanged"),
1383
- page: customBlockPageSchema
1384
- });
1385
-
1386
- // ../protocol/src/context/messages/parentChanged.ts
1387
- var parentChangedMessageSchema = object({
1388
- type: literal("parentChanged"),
1389
- parent: notionParentSchema
1390
- });
1391
-
1392
- // ../protocol/src/context/messages/resize.ts
1393
- var resizeMessageSchema = object({
1394
- type: literal("resize"),
1395
- height: pipe(number(), finite(), minValue(0))
1396
- });
1397
-
1398
- // ../protocol/src/context/theme.ts
1399
- var notionThemeSchema = picklist(["light", "dark"]);
1400
-
1401
- // ../protocol/src/context/messages/themeChanged.ts
1402
- var themeChangedMessageSchema = object({
1403
- type: literal("themeChanged"),
1404
- theme: notionThemeSchema
1405
- });
1406
-
1407
- // ../protocol/src/dataSources/collectionPointer.ts
1408
- var collectionPointerValidator = object({
1349
+ // ../protocol/src/dataSources/dataSourcePointer.ts
1350
+ var dataSourcePointerValidator = object({
1409
1351
  id: notionDataSourceIdSchema,
1410
1352
  table: string(),
1411
1353
  spaceId: optional(notionSpaceIdSchema)
@@ -1475,7 +1417,6 @@ var NOTION_PROPERTY_TYPES = [
1475
1417
  "rollup",
1476
1418
  "button",
1477
1419
  "verification",
1478
- "location",
1479
1420
  "created_time",
1480
1421
  "last_edited_time",
1481
1422
  "created_by",
@@ -1522,7 +1463,6 @@ var notionPropertySchemaSchema = variant("type", [
1522
1463
  // Internal-only types passed through under their bridge-native names.
1523
1464
  object({ ...baseProp.entries, type: literal("button") }),
1524
1465
  object({ ...baseProp.entries, type: literal("verification") }),
1525
- object({ ...baseProp.entries, type: literal("location") }),
1526
1466
  // Synthetic built-ins. The host always emits one of each per data source.
1527
1467
  object({ ...baseProp.entries, type: literal("created_time") }),
1528
1468
  object({ ...baseProp.entries, type: literal("last_edited_time") }),
@@ -1530,8 +1470,8 @@ var notionPropertySchemaSchema = variant("type", [
1530
1470
  object({ ...baseProp.entries, type: literal("last_edited_by") })
1531
1471
  ]);
1532
1472
 
1533
- // ../protocol/src/dataSources/collectionSchema.ts
1534
- var notionCollectionSchemaValidator = object({
1473
+ // ../protocol/src/dataSources/dataSourceSchema.ts
1474
+ var notionDataSourceSchemaValidator = object({
1535
1475
  id: optional(notionDataSourceIdSchema),
1536
1476
  /**
1537
1477
  * Describes actual database properties in protocol 5. Protocol 3/4 payloads can also include
@@ -1541,15 +1481,38 @@ var notionCollectionSchemaValidator = object({
1541
1481
  propertiesById: record(string(), notionPropertySchemaSchema)
1542
1482
  });
1543
1483
 
1484
+ // ../protocol/src/context/containingPage.ts
1485
+ var customBlockPageSchema = variant("type", [
1486
+ /** The viewer cannot access the containing page; its ID and parent are not exposed. */
1487
+ object({ type: literal("unavailable") }),
1488
+ /** The viewer can access the containing page; includes its ID and parent location. */
1489
+ object({
1490
+ type: literal("page"),
1491
+ id: notionPageIdSchema,
1492
+ /**
1493
+ * The containing page's own parent. It lets a block distinguish a freestanding page from a
1494
+ * database row without a round trip. Not to be confused with the top-level `parent` runtime
1495
+ * value, which is the custom block's own parent.
1496
+ */
1497
+ parent: notionParentSchema
1498
+ })
1499
+ ]);
1500
+
1501
+ // ../protocol/src/context/contrast.ts
1502
+ var notionContrastModeSchema = picklist(["standard", "high"]);
1503
+
1504
+ // ../protocol/src/context/theme.ts
1505
+ var notionThemeSchema = picklist(["light", "dark"]);
1506
+
1544
1507
  // ../protocol/src/dataSources/bridgeDataSourceBinding.ts
1545
1508
  var bridgeDataSourceBindingSchema = object({
1546
- collectionPointer: optional(collectionPointerValidator),
1509
+ dataSourcePointer: optional(dataSourcePointerValidator),
1547
1510
  /**
1548
1511
  * Describes database properties. Use this schema to resolve property bindings. Use this
1549
1512
  * schema to validate filter and sort references. Undefined when the host does not provide a
1550
1513
  * database schema.
1551
1514
  */
1552
- collectionSchema: optional(notionCollectionSchemaValidator),
1515
+ dataSourceSchema: optional(notionDataSourceSchemaValidator),
1553
1516
  /**
1554
1517
  * Maps user-defined property keys to database property IDs. Use this map to resolve a key
1555
1518
  * such as `name` to its database property ID. A value of `undefined` marks a declared
@@ -1559,7 +1522,7 @@ var bridgeDataSourceBindingSchema = object({
1559
1522
  propertyIdsByKey: optional(record(string(), optional(string()))),
1560
1523
  /**
1561
1524
  * `true` when the data source is bound but the viewer can't read it. The host omits
1562
- * `collectionPointer`, `collectionSchema`, and `propertyIdsByKey`, so the binding reveals
1525
+ * `dataSourcePointer`, `dataSourceSchema`, and `propertyIdsByKey`, so the binding reveals
1563
1526
  * nothing about the data source. The block still initializes.
1564
1527
  */
1565
1528
  inaccessible: optional(literal(true))
@@ -1571,6 +1534,172 @@ var bridgeDataSourceBindingsSchema = record(
1571
1534
  bridgeDataSourceBindingSchema
1572
1535
  );
1573
1536
 
1537
+ // ../protocol/src/manifest/grants.ts
1538
+ var customBlockGrantSchema = object({
1539
+ action: string(),
1540
+ resource: union([string(), pipe(array(string()), minLength(1))])
1541
+ });
1542
+
1543
+ // ../protocol/src/manifest/manifest.ts
1544
+ var bridgeManifestIconSchema = variant("type", [
1545
+ object({
1546
+ type: literal("emoji"),
1547
+ emoji: string()
1548
+ }),
1549
+ object({
1550
+ type: literal("external"),
1551
+ url: string()
1552
+ })
1553
+ ]);
1554
+ var bridgeManifestPropertySchema = object({
1555
+ name: string(),
1556
+ description: optional(string()),
1557
+ type: notionPropertyTypeSchema
1558
+ });
1559
+ var manifestPageSchema = object({
1560
+ name: string(),
1561
+ description: optional(string()),
1562
+ icon: optional(bridgeManifestIconSchema)
1563
+ });
1564
+ var bridgeManifestDataSourceSchema = object({
1565
+ name: string(),
1566
+ description: optional(string()),
1567
+ icon: optional(bridgeManifestIconSchema),
1568
+ properties: optional(
1569
+ record(string(), bridgeManifestPropertySchema),
1570
+ {}
1571
+ )
1572
+ });
1573
+ var manifestSchema = object({
1574
+ version: literal(1),
1575
+ name: optional(string()),
1576
+ description: optional(string()),
1577
+ slashCommand: optional(string()),
1578
+ icon: optional(object({ type: literal("emoji"), emoji: string() })),
1579
+ dataSources: optional(
1580
+ record(string(), bridgeManifestDataSourceSchema),
1581
+ {}
1582
+ ),
1583
+ pages: optional(record(string(), manifestPageSchema)),
1584
+ /**
1585
+ * Grants the block needs. Omitted means the block predates viewer
1586
+ * approval, so hosts do not ask the viewer. An empty array declares
1587
+ * nothing.
1588
+ */
1589
+ grants: optional(array(customBlockGrantSchema))
1590
+ });
1591
+
1592
+ // ../protocol/src/users/userId.ts
1593
+ var notionUserIdSchema = pipe(string(), brand("NotionUserId"));
1594
+
1595
+ // ../protocol/src/users/bridgeUser.ts
1596
+ var bridgeUserSchema = object({
1597
+ object: literal("user"),
1598
+ id: notionUserIdSchema,
1599
+ name: optional(string()),
1600
+ avatar_url: nullable(string()),
1601
+ type: literal("person"),
1602
+ person: object({
1603
+ email: string()
1604
+ })
1605
+ });
1606
+
1607
+ // ../protocol/src/handshake/init.ts
1608
+ var customBlockInitErrorCodeSchema = string();
1609
+ var customBlockInitErrorInfoSchema = object({
1610
+ code: customBlockInitErrorCodeSchema,
1611
+ message: string(),
1612
+ isRetryable: boolean()
1613
+ });
1614
+ var initMessageSchema = variant("status", [
1615
+ object({
1616
+ type: literal("init"),
1617
+ initializationId: string(),
1618
+ status: literal("success"),
1619
+ theme: notionThemeSchema,
1620
+ contrastMode: notionContrastModeSchema,
1621
+ blockId: notionBlockIdSchema,
1622
+ parent: notionParentSchema,
1623
+ page: customBlockPageSchema,
1624
+ manifest: manifestSchema,
1625
+ dataSources: object({
1626
+ bindings: bridgeDataSourceBindingsSchema
1627
+ }),
1628
+ currentUser: bridgeUserSchema
1629
+ }),
1630
+ object({
1631
+ type: literal("init"),
1632
+ initializationId: string(),
1633
+ status: literal("error"),
1634
+ error: customBlockInitErrorInfoSchema
1635
+ })
1636
+ ]);
1637
+
1638
+ // ../protocol/src/compatibility/protocol3To10/dataSourceBindings.ts
1639
+ var bridgeDataSourceBindingsForProtocol3To10Schema = record(
1640
+ string(),
1641
+ object({
1642
+ collectionPointer: optional(dataSourcePointerValidator),
1643
+ collectionSchema: optional(notionDataSourceSchemaValidator),
1644
+ propertyIdsByKey: optional(record(string(), optional(string()))),
1645
+ inaccessible: optional(literal(true))
1646
+ })
1647
+ );
1648
+ var dataSourceBindingsMessageForProtocol3To10Schema = variant(
1649
+ "type",
1650
+ [
1651
+ object({
1652
+ ...initMessageSchema.options[0].entries,
1653
+ dataSources: object({
1654
+ bindings: bridgeDataSourceBindingsForProtocol3To10Schema
1655
+ })
1656
+ }),
1657
+ object({
1658
+ type: literal("dataSourcesChanged"),
1659
+ dataSources: object({
1660
+ bindings: bridgeDataSourceBindingsForProtocol3To10Schema
1661
+ })
1662
+ })
1663
+ ]
1664
+ );
1665
+
1666
+ // ../protocol/src/context/messages/contrastModeChanged.ts
1667
+ var contrastModeChangedMessageSchema = object({
1668
+ type: literal("contrastModeChanged"),
1669
+ contrastMode: notionContrastModeSchema
1670
+ });
1671
+
1672
+ // ../protocol/src/context/messages/pageChanged.ts
1673
+ var pageChangedMessageSchema = object({
1674
+ type: literal("pageChanged"),
1675
+ page: customBlockPageSchema
1676
+ });
1677
+
1678
+ // ../protocol/src/context/messages/parentChanged.ts
1679
+ var parentChangedMessageSchema = object({
1680
+ type: literal("parentChanged"),
1681
+ parent: notionParentSchema
1682
+ });
1683
+
1684
+ // ../protocol/src/context/messages/resize.ts
1685
+ var resizeMessageSchema = object({
1686
+ type: literal("resize"),
1687
+ height: pipe(number(), finite(), minValue(0))
1688
+ });
1689
+
1690
+ // ../protocol/src/context/messages/themeChanged.ts
1691
+ var themeChangedMessageSchema = object({
1692
+ type: literal("themeChanged"),
1693
+ theme: notionThemeSchema
1694
+ });
1695
+
1696
+ // ../protocol/src/dataSources/bridgeArchiveStatus.ts
1697
+ var bridgeArchiveStatusSchema = picklist([
1698
+ "active",
1699
+ "archived",
1700
+ "all"
1701
+ ]);
1702
+
1574
1703
  // ../protocol/src/dataSources/errors.ts
1575
1704
  var customBlockDataSourceResolutionErrorCodeSchema = string();
1576
1705
  var customBlockPropertyErrorCodeSchema = string();
@@ -1601,18 +1730,6 @@ var customBlockContainsFilterOperatorSchema = union([
1601
1730
  emptyOperatorSchema
1602
1731
  ]);
1603
1732
 
1604
- // ../protocol/src/dataSources/filters/createdByFilterOperator.ts
1605
- var customBlockCreatorFilterValueSchema = strictObject({
1606
- object: literal("user"),
1607
- id: pipe(string(), minLength(1), maxLength(2e3))
1608
- });
1609
- var customBlockCreatedByFilterOperatorSchema = union([
1610
- strictObject({ contains: customBlockCreatorFilterValueSchema }),
1611
- strictObject({ does_not_contain: customBlockCreatorFilterValueSchema }),
1612
- strictObject({ is_empty: literal(true) }),
1613
- strictObject({ is_not_empty: literal(true) })
1614
- ]);
1615
-
1616
1733
  // ../protocol/src/dataSources/filters/dateFilterOperator.ts
1617
1734
  var dateTargetSchema = picklist(["start_date", "end_date"]);
1618
1735
  var customBlockRelativeDateValueSchema = picklist([
@@ -1708,7 +1825,7 @@ var customBlockOptionFilterOperatorSchema = union([
1708
1825
  // ../protocol/src/dataSources/filters/peopleFilterOperator.ts
1709
1826
  var customBlockPersonFilterValueSchema = strictObject({
1710
1827
  object: picklist(["user", "group"]),
1711
- id: pipe(string(), minLength(1))
1828
+ id: pipe(string(), minLength(1), maxLength(2e3))
1712
1829
  });
1713
1830
  var customBlockPeopleFilterOperatorSchema = union([
1714
1831
  strictObject({ contains: customBlockPersonFilterValueSchema }),
@@ -1771,15 +1888,34 @@ var customBlockTextFilterOperatorSchema = union([
1771
1888
  emptyOperatorSchema
1772
1889
  ]);
1773
1890
 
1891
+ // ../protocol/src/dataSources/filters/timestampFilterOperator.ts
1892
+ var customBlockTimestampFilterOperatorSchema = union(
1893
+ customBlockDateFilterOperatorSchema.options.map(
1894
+ (option) => omit(option, ["target"])
1895
+ )
1896
+ );
1897
+
1774
1898
  // ../protocol/src/dataSources/filters/bridgeDataSourceFilterCondition.ts
1775
1899
  var bridgeDataSourceFilterConditionSchema = union([
1900
+ strictObject({
1901
+ propertyId: string(),
1902
+ last_edited_by: customBlockPeopleFilterOperatorSchema
1903
+ }),
1904
+ strictObject({
1905
+ propertyId: string(),
1906
+ created_time: customBlockTimestampFilterOperatorSchema
1907
+ }),
1908
+ strictObject({
1909
+ propertyId: string(),
1910
+ last_edited_time: customBlockTimestampFilterOperatorSchema
1911
+ }),
1776
1912
  strictObject({
1777
1913
  propertyId: string(),
1778
1914
  relation: customBlockRelationFilterOperatorSchema
1779
1915
  }),
1780
1916
  strictObject({
1781
1917
  propertyId: string(),
1782
- created_by: customBlockCreatedByFilterOperatorSchema
1918
+ created_by: customBlockPeopleFilterOperatorSchema
1783
1919
  }),
1784
1920
  strictObject({
1785
1921
  propertyId: string(),
@@ -1866,8 +2002,8 @@ var bridgePageSchema = object({
1866
2002
  last_edited_by: optional(metadataActorSchema, null),
1867
2003
  created_time: optional(nullable(string()), null),
1868
2004
  last_edited_time: optional(nullable(string()), null),
1869
- icon: optional(nullable(notionPageIconSchema), null),
1870
- cover: optional(nullable(notionPageCoverSchema), null),
2005
+ icon: optional(nullable(bridgePageIconSchema), null),
2006
+ cover: optional(nullable(bridgePageCoverSchema), null),
1871
2007
  url: optional(nullable(string()), null),
1872
2008
  public_url: optional(nullable(string()), null),
1873
2009
  /** Whether the page or an ancestor is archived. */
@@ -1888,7 +2024,8 @@ var queryDataSourceMessageSchema = object({
1888
2024
  /** A sandbox-resolved property filter. */
1889
2025
  filter: optional(bridgeDataSourceFilterSchema),
1890
2026
  /** Sandbox-resolved property sorts, in priority order. */
1891
- sorts: optional(array(bridgeDataSourceSortSchema))
2027
+ sorts: optional(array(bridgeDataSourceSortSchema)),
2028
+ archive_status: optional(bridgeArchiveStatusSchema)
1892
2029
  });
1893
2030
  var customBlockQueryDataSourceErrorCodeSchema = string();
1894
2031
  var customBlockQueryDataSourceErrorInfoSchema = object({
@@ -1939,13 +2076,13 @@ var unsubscribeDataSourceQueryMessageSchema = object({
1939
2076
  // ../protocol/src/dataSources/notionDataSource.ts
1940
2077
  var notionDataSourceSchema = object({
1941
2078
  key: string(),
1942
- collectionPointer: optional(collectionPointerValidator),
2079
+ dataSourcePointer: optional(dataSourcePointerValidator),
1943
2080
  /**
1944
2081
  * Describes database properties. Use this schema to resolve property bindings. Use this
1945
2082
  * schema to validate filter and sort references. Undefined when the host does not provide a
1946
2083
  * database schema.
1947
2084
  */
1948
- collectionSchema: optional(notionCollectionSchemaValidator),
2085
+ dataSourceSchema: optional(notionDataSourceSchemaValidator),
1949
2086
  /**
1950
2087
  * Maps user-defined property keys to database property IDs. Use this map to resolve a key
1951
2088
  * such as `name` to its database property ID. A value of `undefined` marks a declared
@@ -1961,7 +2098,7 @@ var notionDataSourceSchema = object({
1961
2098
  * database properties when the host provides their schema.
1962
2099
  *
1963
2100
  * Use `propertiesById` to read a value. Use this map to read the value's schema. Use
1964
- * `collectionSchema` to validate filter and sort references.
2101
+ * `dataSourceSchema` to validate filter and sort references.
1965
2102
  */
1966
2103
  propertySchemasById: record(string(), notionPropertySchemaSchema),
1967
2104
  /**
@@ -1972,55 +2109,6 @@ var notionDataSourceSchema = object({
1972
2109
  inaccessible: optional(literal(true))
1973
2110
  });
1974
2111
 
1975
- // ../protocol/src/manifest/capabilities.ts
1976
- var customBlockCapabilityDeclarationSchema = object({
1977
- capability: string(),
1978
- resource: union([string(), pipe(array(string()), minLength(1))])
1979
- });
1980
-
1981
- // ../protocol/src/manifest/manifest.ts
1982
- var manifestIconSchema = variant("type", [
1983
- object({
1984
- type: literal("emoji"),
1985
- emoji: string()
1986
- }),
1987
- object({
1988
- type: literal("external"),
1989
- url: string()
1990
- })
1991
- ]);
1992
- var manifestPropertySchema = object({
1993
- name: string(),
1994
- description: optional(string()),
1995
- type: notionPropertyTypeSchema
1996
- });
1997
- var manifestPageSchema = object({
1998
- name: string(),
1999
- description: optional(string()),
2000
- icon: optional(manifestIconSchema)
2001
- });
2002
- var manifestDataSourceSchema = object({
2003
- name: string(),
2004
- description: optional(string()),
2005
- icon: optional(manifestIconSchema),
2006
- properties: optional(record(string(), manifestPropertySchema), {})
2007
- });
2008
- var manifestSchema = object({
2009
- version: literal(1),
2010
- name: optional(string()),
2011
- description: optional(string()),
2012
- slashCommand: optional(string()),
2013
- icon: optional(object({ type: literal("emoji"), emoji: string() })),
2014
- dataSources: optional(record(string(), manifestDataSourceSchema), {}),
2015
- pages: optional(record(string(), manifestPageSchema)),
2016
- /**
2017
- * Capabilities the block needs. Omitted means the block predates capability
2018
- * approval, so hosts do not ask the viewer. An empty array declares no
2019
- * capabilities.
2020
- */
2021
- capabilities: optional(array(customBlockCapabilityDeclarationSchema))
2022
- });
2023
-
2024
2112
  // ../protocol/src/utils/errors.ts
2025
2113
  var customBlockErrorInfoSchema = object({
2026
2114
  code: string(),
@@ -2062,52 +2150,6 @@ var connectMessageSchema = variant("status", [
2062
2150
  })
2063
2151
  ]);
2064
2152
 
2065
- // ../protocol/src/users/userId.ts
2066
- var notionUserIdSchema = pipe(string(), brand("NotionUserId"));
2067
-
2068
- // ../protocol/src/users/bridgeUser.ts
2069
- var bridgeUserSchema = object({
2070
- object: literal("user"),
2071
- id: notionUserIdSchema,
2072
- name: optional(string()),
2073
- avatar_url: nullable(string()),
2074
- type: literal("person"),
2075
- person: object({
2076
- email: string()
2077
- })
2078
- });
2079
-
2080
- // ../protocol/src/handshake/init.ts
2081
- var customBlockInitErrorCodeSchema = string();
2082
- var customBlockInitErrorInfoSchema = object({
2083
- code: customBlockInitErrorCodeSchema,
2084
- message: string(),
2085
- isRetryable: boolean()
2086
- });
2087
- var initMessageSchema = variant("status", [
2088
- object({
2089
- type: literal("init"),
2090
- initializationId: string(),
2091
- status: literal("success"),
2092
- theme: notionThemeSchema,
2093
- contrastMode: notionContrastModeSchema,
2094
- blockId: notionBlockIdSchema,
2095
- parent: notionParentSchema,
2096
- page: customBlockPageSchema,
2097
- manifest: manifestSchema,
2098
- dataSources: object({
2099
- bindings: bridgeDataSourceBindingsSchema
2100
- }),
2101
- currentUser: bridgeUserSchema
2102
- }),
2103
- object({
2104
- type: literal("init"),
2105
- initializationId: string(),
2106
- status: literal("error"),
2107
- error: customBlockInitErrorInfoSchema
2108
- })
2109
- ]);
2110
-
2111
2153
  // ../protocol/src/handshake/initResult.ts
2112
2154
  var customBlockInitResultErrorCodeSchema = string();
2113
2155
  var customBlockInitResultErrorInfoSchema = object({
@@ -2206,9 +2248,7 @@ var createPageParentSchema = variant("type", [
2206
2248
  pageParentSchema,
2207
2249
  dataSourceParentSchema
2208
2250
  ]);
2209
- var createPageMessageBaseSchema = {
2210
- type: literal("createPage"),
2211
- requestId: string(),
2251
+ var createPageBaseEntries = {
2212
2252
  /**
2213
2253
  * Property values, keyed by raw property IDs from Notion.
2214
2254
  *
@@ -2217,19 +2257,35 @@ var createPageMessageBaseSchema = {
2217
2257
  * those keys before it sends this message.
2218
2258
  */
2219
2259
  properties: bridgePagePropertyWriteMapSchema,
2220
- icon: optional(notionCreatePageIconSchema),
2221
- cover: optional(notionPageCoverSchema)
2260
+ icon: optional(bridgePageIconSchema),
2261
+ cover: optional(bridgePageCoverSchema)
2262
+ };
2263
+ var createPageUnderPageArgsSchema = object({
2264
+ ...createPageBaseEntries,
2265
+ parent: pageParentSchema,
2266
+ position: optional(notionCreatePagePositionSchema)
2267
+ });
2268
+ var createPageUnderDataSourceArgsSchema = object({
2269
+ ...createPageBaseEntries,
2270
+ parent: dataSourceParentSchema,
2271
+ position: optional(never())
2272
+ });
2273
+ var createPageArgsSchema = union([
2274
+ createPageUnderPageArgsSchema,
2275
+ createPageUnderDataSourceArgsSchema
2276
+ ]);
2277
+ var createPageMessageEntries = {
2278
+ type: literal("createPage"),
2279
+ requestId: string()
2222
2280
  };
2223
2281
  var createPageMessageSchema = variant("type", [
2224
2282
  object({
2225
- ...createPageMessageBaseSchema,
2226
- parent: pageParentSchema,
2227
- position: optional(notionCreatePagePositionSchema)
2283
+ ...createPageMessageEntries,
2284
+ ...createPageUnderPageArgsSchema.entries
2228
2285
  }),
2229
2286
  object({
2230
- ...createPageMessageBaseSchema,
2231
- parent: dataSourceParentSchema,
2232
- position: optional(never())
2287
+ ...createPageMessageEntries,
2288
+ ...createPageUnderDataSourceArgsSchema.entries
2233
2289
  })
2234
2290
  ]);
2235
2291
 
@@ -2352,8 +2408,8 @@ var updatePageMessageSchema = object({
2352
2408
  * by `useDataSource()`. The SDK resolves those keys before it sends this message.
2353
2409
  */
2354
2410
  properties: optional(bridgePagePropertyWriteMapSchema),
2355
- icon: optional(notionPageIconSchema),
2356
- cover: optional(notionPageCoverSchema),
2411
+ icon: optional(bridgePageIconSchema),
2412
+ cover: optional(bridgePageCoverSchema),
2357
2413
  archived: optional(boolean())
2358
2414
  });
2359
2415
 
@@ -6561,7 +6617,6 @@ function convertPublicApiPropertyValue(publicType, value) {
6561
6617
  case "button":
6562
6618
  return void 0;
6563
6619
  case "place":
6564
- case "location":
6565
6620
  return JSON.stringify(payload);
6566
6621
  default:
6567
6622
  return unreachable(publicType);
@@ -6672,8 +6727,7 @@ var VALUE_SCHEMAS = {
6672
6727
  formula: stringValue,
6673
6728
  rollup: stringValue,
6674
6729
  verification: stringValue,
6675
- place: stringValue,
6676
- location: stringValue
6730
+ place: stringValue
6677
6731
  };
6678
6732
  function matchesPropertyType(value, type) {
6679
6733
  return is(VALUE_SCHEMAS[type] ?? anyLocalValue, value);
@@ -7421,6 +7475,16 @@ function createDevShellDataService(options) {
7421
7475
  import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync } from "node:fs";
7422
7476
  import { resolve as resolve3 } from "node:path";
7423
7477
 
7478
+ // shared/blocks/formatBlockValidationIssues.ts
7479
+ function formatBlockValidationIssues(blockKey, issues, pathPrefix) {
7480
+ const details = issues.map((issue) => {
7481
+ const path = [pathPrefix, getDotPath(issue)].filter(Boolean).join(".");
7482
+ return `${path}: ${issue.message}`;
7483
+ });
7484
+ return `Block "${blockKey}" has an invalid declaration:
7485
+ ${details.join("\n")}`;
7486
+ }
7487
+
7424
7488
  // cli/workers/blockCapabilities.ts
7425
7489
  var workerBlockCapabilitySchema = object({
7426
7490
  _tag: literal("custom_block"),
@@ -7436,7 +7500,16 @@ var workerBlockCapabilitySchema = object({
7436
7500
  })
7437
7501
  });
7438
7502
  function blockCapabilities(manifest) {
7439
- return manifest.capabilities.filter((capability) => capability._tag === "custom_block").map((capability) => parse(workerBlockCapabilitySchema, capability));
7503
+ return manifest.capabilities.filter((capability) => capability._tag === "custom_block").map((capability) => {
7504
+ const parsed = safeParse(workerBlockCapabilitySchema, capability);
7505
+ if (!parsed.success) {
7506
+ const error = new ValiError(parsed.issues);
7507
+ error.message = `${formatBlockValidationIssues(capability.key, parsed.issues, "")}
7508
+ Fix the custom block declaration, then restart the dev shell to rebuild the manifest.`;
7509
+ throw error;
7510
+ }
7511
+ return parsed.output;
7512
+ });
7440
7513
  }
7441
7514
 
7442
7515
  // cli/dataSources/materializeWorkerSchemaDataSources.ts
@@ -8043,6 +8116,7 @@ function buildBlockRegistry(blocks, port = DEFAULT_DEV_SHELL_PORT) {
8043
8116
  }
8044
8117
  used.add(hostname);
8045
8118
  return {
8119
+ status: "ready",
8046
8120
  key: capability.key,
8047
8121
  manifest: capability.config.manifest,
8048
8122
  name: capability.key,