@notionhq/custom-blocks-dev-shell 0.4.3 → 0.5.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/README.md +83 -23
- package/data/customers.json +10 -20
- package/data/meetings.json +51 -102
- package/data/projects.json +64 -45
- package/data/tasks.json +33 -66
- package/dist/assets/index-Dhs3H2Yo.js +12 -0
- package/dist/index.html +1 -1
- package/dist-cli/cli/published-cli.js +1879 -612
- package/docs/bindings.md +25 -24
- package/docs/data-sources.md +65 -19
- package/package.json +1 -1
- package/dist/assets/index-BlifLoaB.js +0 -12
|
@@ -492,6 +492,22 @@ function looseObject(entries$1, message$1) {
|
|
|
492
492
|
});
|
|
493
493
|
}
|
|
494
494
|
// @__NO_SIDE_EFFECTS__
|
|
495
|
+
function nan(message$1) {
|
|
496
|
+
return _standardSchema({
|
|
497
|
+
kind: "schema",
|
|
498
|
+
type: "nan",
|
|
499
|
+
reference: nan,
|
|
500
|
+
expects: "NaN",
|
|
501
|
+
async: false,
|
|
502
|
+
message: message$1,
|
|
503
|
+
"~run"(dataset, config$1) {
|
|
504
|
+
if (Number.isNaN(dataset.value)) dataset.typed = true;
|
|
505
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
506
|
+
return dataset;
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
// @__NO_SIDE_EFFECTS__
|
|
495
511
|
function never(message$1) {
|
|
496
512
|
return _standardSchema({
|
|
497
513
|
kind: "schema",
|
|
@@ -524,6 +540,22 @@ function nonOptional(wrapped, message$1) {
|
|
|
524
540
|
});
|
|
525
541
|
}
|
|
526
542
|
// @__NO_SIDE_EFFECTS__
|
|
543
|
+
function null_(message$1) {
|
|
544
|
+
return _standardSchema({
|
|
545
|
+
kind: "schema",
|
|
546
|
+
type: "null",
|
|
547
|
+
reference: null_,
|
|
548
|
+
expects: "null",
|
|
549
|
+
async: false,
|
|
550
|
+
message: message$1,
|
|
551
|
+
"~run"(dataset, config$1) {
|
|
552
|
+
if (dataset.value === null) dataset.typed = true;
|
|
553
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
554
|
+
return dataset;
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
// @__NO_SIDE_EFFECTS__
|
|
527
559
|
function nullable(wrapped, default_) {
|
|
528
560
|
return _standardSchema({
|
|
529
561
|
kind: "schema",
|
|
@@ -960,6 +992,15 @@ function parse(schema, input, config$1) {
|
|
|
960
992
|
return dataset.value;
|
|
961
993
|
}
|
|
962
994
|
// @__NO_SIDE_EFFECTS__
|
|
995
|
+
function partial(schema, keys) {
|
|
996
|
+
const entries$1 = {};
|
|
997
|
+
for (const key in schema.entries) entries$1[key] = !keys || keys.includes(key) ? /* @__PURE__ */ optional(schema.entries[key]) : schema.entries[key];
|
|
998
|
+
return _standardSchema({
|
|
999
|
+
...schema,
|
|
1000
|
+
entries: entries$1
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
// @__NO_SIDE_EFFECTS__
|
|
963
1004
|
function pipe(...pipe$1) {
|
|
964
1005
|
return _standardSchema({
|
|
965
1006
|
...pipe$1[0],
|
|
@@ -998,6 +1039,17 @@ function safeParse(schema, input, config$1) {
|
|
|
998
1039
|
};
|
|
999
1040
|
}
|
|
1000
1041
|
|
|
1042
|
+
// ../protocol/src/utils/unknownPropertyTypeSchema.ts
|
|
1043
|
+
var unknownPropertyTypeSchema = pipe(
|
|
1044
|
+
string(),
|
|
1045
|
+
minLength(1),
|
|
1046
|
+
check(
|
|
1047
|
+
(type) => type !== "unknown" && // Reserved for the placeholder's `type`. `originalType` carries the source type.
|
|
1048
|
+
// These values exist in Notion but are unsupported in custom blocks.
|
|
1049
|
+
type !== "last_visited_time" && type !== "location"
|
|
1050
|
+
)
|
|
1051
|
+
);
|
|
1052
|
+
|
|
1001
1053
|
// ../protocol/src/dataSources/properties/propertySchema.ts
|
|
1002
1054
|
var knownNotionPropertyColorSchema = picklist([
|
|
1003
1055
|
"default",
|
|
@@ -1028,13 +1080,13 @@ var notionPropertyOptionSchema = object({
|
|
|
1028
1080
|
color: optional(notionPropertyColorSchema),
|
|
1029
1081
|
description: optional(string())
|
|
1030
1082
|
});
|
|
1031
|
-
var
|
|
1083
|
+
var bridgeStatusGroupSchema = object({
|
|
1032
1084
|
id: string(),
|
|
1033
1085
|
name: string(),
|
|
1034
1086
|
color: optional(notionPropertyColorSchema),
|
|
1035
1087
|
option_ids: array(string())
|
|
1036
1088
|
});
|
|
1037
|
-
var
|
|
1089
|
+
var bridgeDualPropertySchema = object({
|
|
1038
1090
|
synced_property_id: string(),
|
|
1039
1091
|
synced_property_name: string()
|
|
1040
1092
|
});
|
|
@@ -1069,7 +1121,22 @@ var NOTION_PROPERTY_TYPES = [
|
|
|
1069
1121
|
"last_edited_by"
|
|
1070
1122
|
];
|
|
1071
1123
|
var notionPropertyTypeSchema = picklist(NOTION_PROPERTY_TYPES);
|
|
1072
|
-
var
|
|
1124
|
+
var CUSTOM_BLOCK_DATA_SOURCE_SORTABLE_PROPERTY_TYPES = [
|
|
1125
|
+
"title",
|
|
1126
|
+
"rich_text",
|
|
1127
|
+
"number",
|
|
1128
|
+
"checkbox",
|
|
1129
|
+
"url",
|
|
1130
|
+
"email",
|
|
1131
|
+
"phone_number",
|
|
1132
|
+
"date",
|
|
1133
|
+
"created_time",
|
|
1134
|
+
"last_edited_time",
|
|
1135
|
+
"people",
|
|
1136
|
+
"created_by",
|
|
1137
|
+
"last_edited_by"
|
|
1138
|
+
];
|
|
1139
|
+
var knownBridgePropertySchema = variant("type", [
|
|
1073
1140
|
object({ ...baseProp.entries, type: literal("title") }),
|
|
1074
1141
|
object({ ...baseProp.entries, type: literal("rich_text") }),
|
|
1075
1142
|
object({ ...baseProp.entries, type: literal("number") }),
|
|
@@ -1091,7 +1158,7 @@ var notionPropertySchemaSchema = variant("type", [
|
|
|
1091
1158
|
...baseProp.entries,
|
|
1092
1159
|
type: literal("status"),
|
|
1093
1160
|
options: array(notionPropertyOptionSchema),
|
|
1094
|
-
groups: array(
|
|
1161
|
+
groups: array(bridgeStatusGroupSchema)
|
|
1095
1162
|
}),
|
|
1096
1163
|
object({ ...baseProp.entries, type: literal("date") }),
|
|
1097
1164
|
object({ ...baseProp.entries, type: literal("people") }),
|
|
@@ -1101,7 +1168,7 @@ var notionPropertySchemaSchema = variant("type", [
|
|
|
1101
1168
|
...baseProp.entries,
|
|
1102
1169
|
type: literal("relation"),
|
|
1103
1170
|
data_source_id: optional(string()),
|
|
1104
|
-
dual_property: optional(
|
|
1171
|
+
dual_property: optional(bridgeDualPropertySchema)
|
|
1105
1172
|
}),
|
|
1106
1173
|
object({ ...baseProp.entries, type: literal("place") }),
|
|
1107
1174
|
object({ ...baseProp.entries, type: literal("formula") }),
|
|
@@ -1115,6 +1182,28 @@ var notionPropertySchemaSchema = variant("type", [
|
|
|
1115
1182
|
object({ ...baseProp.entries, type: literal("created_by") }),
|
|
1116
1183
|
object({ ...baseProp.entries, type: literal("last_edited_by") })
|
|
1117
1184
|
]);
|
|
1185
|
+
var bridgeUnknownPropertySchema = object({
|
|
1186
|
+
...baseProp.entries,
|
|
1187
|
+
type: literal("unknown"),
|
|
1188
|
+
originalType: unknownPropertyTypeSchema
|
|
1189
|
+
});
|
|
1190
|
+
var futurePropertySchema = pipe(
|
|
1191
|
+
object({ ...baseProp.entries, type: unknownPropertyTypeSchema }),
|
|
1192
|
+
check(({ type }) => !is(notionPropertyTypeSchema, type)),
|
|
1193
|
+
transform(
|
|
1194
|
+
({ name, description, type }) => ({
|
|
1195
|
+
name,
|
|
1196
|
+
description,
|
|
1197
|
+
type: "unknown",
|
|
1198
|
+
originalType: type
|
|
1199
|
+
})
|
|
1200
|
+
)
|
|
1201
|
+
);
|
|
1202
|
+
var bridgePropertySchema = union([
|
|
1203
|
+
knownBridgePropertySchema,
|
|
1204
|
+
bridgeUnknownPropertySchema,
|
|
1205
|
+
futurePropertySchema
|
|
1206
|
+
]);
|
|
1118
1207
|
|
|
1119
1208
|
// ../protocol/src/manifest/grants.ts
|
|
1120
1209
|
var customBlockGrantSchema = object({
|
|
@@ -1305,10 +1394,24 @@ var pageParentSchema = object({
|
|
|
1305
1394
|
type: literal("page_id"),
|
|
1306
1395
|
page_id: notionPageIdSchema
|
|
1307
1396
|
});
|
|
1397
|
+
var pageKeyParentSchema = strictObject({
|
|
1398
|
+
type: literal("page_key"),
|
|
1399
|
+
pageKey: string()
|
|
1400
|
+
});
|
|
1401
|
+
var pageKindParentSchema = strictObject({
|
|
1402
|
+
type: literal("page")
|
|
1403
|
+
});
|
|
1308
1404
|
var dataSourceParentSchema = object({
|
|
1309
1405
|
type: literal("data_source_id"),
|
|
1310
1406
|
data_source_id: notionDataSourceIdSchema
|
|
1311
1407
|
});
|
|
1408
|
+
var dataSourceKeyParentSchema = strictObject({
|
|
1409
|
+
type: literal("data_source_key"),
|
|
1410
|
+
key: string()
|
|
1411
|
+
});
|
|
1412
|
+
var dataSourceKindParentSchema = strictObject({
|
|
1413
|
+
type: literal("data_source")
|
|
1414
|
+
});
|
|
1312
1415
|
var workspaceParentSchema = object({
|
|
1313
1416
|
type: literal("workspace"),
|
|
1314
1417
|
workspace: literal(true)
|
|
@@ -1326,7 +1429,7 @@ var appInstallationParentSchema = object({
|
|
|
1326
1429
|
app_installation_id: notionAppInstallationIdSchema
|
|
1327
1430
|
});
|
|
1328
1431
|
var unavailableParentSchema = object({ type: literal("unavailable") });
|
|
1329
|
-
var
|
|
1432
|
+
var parentThroughProtocol13Schema = variant("type", [
|
|
1330
1433
|
pageParentSchema,
|
|
1331
1434
|
dataSourceParentSchema,
|
|
1332
1435
|
workspaceParentSchema,
|
|
@@ -1335,6 +1438,13 @@ var notionParentSchema = variant("type", [
|
|
|
1335
1438
|
appInstallationParentSchema,
|
|
1336
1439
|
unavailableParentSchema
|
|
1337
1440
|
]);
|
|
1441
|
+
var notionParentSchema = variant("type", [
|
|
1442
|
+
...parentThroughProtocol13Schema.options,
|
|
1443
|
+
pageKeyParentSchema,
|
|
1444
|
+
pageKindParentSchema,
|
|
1445
|
+
dataSourceKindParentSchema,
|
|
1446
|
+
dataSourceKeyParentSchema
|
|
1447
|
+
]);
|
|
1338
1448
|
|
|
1339
1449
|
// ../protocol/src/dataSources/dataSourcePointer.ts
|
|
1340
1450
|
var dataSourcePointerValidator = object({
|
|
@@ -1344,15 +1454,18 @@ var dataSourcePointerValidator = object({
|
|
|
1344
1454
|
});
|
|
1345
1455
|
|
|
1346
1456
|
// ../protocol/src/dataSources/dataSourceSchema.ts
|
|
1347
|
-
var
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1457
|
+
var bridgeDataSourceSchemaValidator = makeNotionDataSourceSchemaValidator(bridgePropertySchema);
|
|
1458
|
+
function makeNotionDataSourceSchemaValidator(propertySchema) {
|
|
1459
|
+
return object({
|
|
1460
|
+
id: optional(notionDataSourceIdSchema),
|
|
1461
|
+
/**
|
|
1462
|
+
* Describes actual database properties in protocol 5. Protocol 3/4 payloads can also include
|
|
1463
|
+
* synthetic metadata for compatibility. Use this map to resolve property bindings. Use this map
|
|
1464
|
+
* to validate filter and sort references.
|
|
1465
|
+
*/
|
|
1466
|
+
propertiesById: record(string(), propertySchema)
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1356
1469
|
|
|
1357
1470
|
// ../protocol/src/dataSources/bridgeDataSourceBinding.ts
|
|
1358
1471
|
var bridgeDataSourceBindingSchema = object({
|
|
@@ -1362,7 +1475,7 @@ var bridgeDataSourceBindingSchema = object({
|
|
|
1362
1475
|
* schema to validate filter and sort references. Undefined when the host does not provide a
|
|
1363
1476
|
* database schema.
|
|
1364
1477
|
*/
|
|
1365
|
-
dataSourceSchema: optional(
|
|
1478
|
+
dataSourceSchema: optional(bridgeDataSourceSchemaValidator),
|
|
1366
1479
|
/**
|
|
1367
1480
|
* Maps user-defined property keys to database property IDs. Use this map to resolve a key
|
|
1368
1481
|
* such as `name` to its database property ID. A value of `undefined` marks a declared
|
|
@@ -1442,7 +1555,7 @@ var protocol3To11ContainingPageSchema = variant("type", [
|
|
|
1442
1555
|
object({
|
|
1443
1556
|
type: literal("page"),
|
|
1444
1557
|
id: notionPageIdSchema,
|
|
1445
|
-
parent:
|
|
1558
|
+
parent: parentThroughProtocol13Schema
|
|
1446
1559
|
})
|
|
1447
1560
|
]);
|
|
1448
1561
|
var protocol3To11PageChangedMessageSchema = object({
|
|
@@ -1458,7 +1571,7 @@ var protocol3To11InitSuccessMessageSchema = object({
|
|
|
1458
1571
|
theme: notionThemeSchema,
|
|
1459
1572
|
contrastMode: notionContrastModeSchema,
|
|
1460
1573
|
blockId: notionBlockIdSchema,
|
|
1461
|
-
parent:
|
|
1574
|
+
parent: parentThroughProtocol13Schema,
|
|
1462
1575
|
page: protocol3To11ContainingPageSchema,
|
|
1463
1576
|
manifest: manifestSchema,
|
|
1464
1577
|
dataSources: object({
|
|
@@ -1518,7 +1631,7 @@ var contrastModeChangedMessageSchema = object({
|
|
|
1518
1631
|
});
|
|
1519
1632
|
|
|
1520
1633
|
// ../protocol/src/context/containingPage.ts
|
|
1521
|
-
var
|
|
1634
|
+
var containingPageSchema = variant("type", [
|
|
1522
1635
|
/** The viewer cannot access the containing page. Its ID and parent are not exposed. */
|
|
1523
1636
|
object({ type: literal("unavailable") }),
|
|
1524
1637
|
/** The accessible containing page, with its ID and parent location. */
|
|
@@ -1538,11 +1651,19 @@ var customBlockPageSchema = variant("type", [
|
|
|
1538
1651
|
)
|
|
1539
1652
|
})
|
|
1540
1653
|
]);
|
|
1654
|
+
var containingPageContextSchema = variant("type", [
|
|
1655
|
+
strictObject({ type: literal("unavailable") }),
|
|
1656
|
+
strictObject({
|
|
1657
|
+
type: literal("page"),
|
|
1658
|
+
parent: notionParentSchema,
|
|
1659
|
+
displayMode: containingPageSchema.options[1].entries.displayMode
|
|
1660
|
+
})
|
|
1661
|
+
]);
|
|
1541
1662
|
|
|
1542
1663
|
// ../protocol/src/context/messages/pageChanged.ts
|
|
1543
1664
|
var pageChangedMessageSchema = object({
|
|
1544
1665
|
type: literal("pageChanged"),
|
|
1545
|
-
page:
|
|
1666
|
+
page: containingPageContextSchema
|
|
1546
1667
|
});
|
|
1547
1668
|
|
|
1548
1669
|
// ../protocol/src/context/messages/pageError.ts
|
|
@@ -1569,32 +1690,6 @@ var themeChangedMessageSchema = object({
|
|
|
1569
1690
|
theme: notionThemeSchema
|
|
1570
1691
|
});
|
|
1571
1692
|
|
|
1572
|
-
// ../protocol/src/dataSources/messages/getDataSource.ts
|
|
1573
|
-
var getDataSourceMessageSchema = object({
|
|
1574
|
-
type: literal("getDataSource"),
|
|
1575
|
-
requestId: string(),
|
|
1576
|
-
key: string()
|
|
1577
|
-
});
|
|
1578
|
-
var getDataSourceResultMessageSchema = variant("status", [
|
|
1579
|
-
object({
|
|
1580
|
-
type: literal("getDataSourceResult"),
|
|
1581
|
-
requestId: string(),
|
|
1582
|
-
status: literal("success"),
|
|
1583
|
-
binding: required(
|
|
1584
|
-
omit(bridgeDataSourceBindingSchema, ["inaccessible"])
|
|
1585
|
-
)
|
|
1586
|
-
}),
|
|
1587
|
-
object({
|
|
1588
|
-
type: literal("getDataSourceResult"),
|
|
1589
|
-
requestId: string(),
|
|
1590
|
-
status: literal("error"),
|
|
1591
|
-
error: customBlockErrorInfoSchema
|
|
1592
|
-
})
|
|
1593
|
-
]);
|
|
1594
|
-
var dataSourcesInvalidatedMessageSchema = object({
|
|
1595
|
-
type: literal("dataSourcesInvalidated")
|
|
1596
|
-
});
|
|
1597
|
-
|
|
1598
1693
|
// ../protocol/src/files.ts
|
|
1599
1694
|
var bridgeExternalFileSchema = object({
|
|
1600
1695
|
type: literal("external"),
|
|
@@ -1671,10 +1766,86 @@ var bridgePageCoverSchema = variant("type", [
|
|
|
1671
1766
|
bridgeNotionHostedFileSchema
|
|
1672
1767
|
]);
|
|
1673
1768
|
|
|
1769
|
+
// ../protocol/src/dataSources/messages/dataSourceChanged.ts
|
|
1770
|
+
var sourcePropertySchema = pipe(
|
|
1771
|
+
bridgePropertySchema,
|
|
1772
|
+
transform((property) => {
|
|
1773
|
+
if (property.type !== "relation") {
|
|
1774
|
+
return property;
|
|
1775
|
+
}
|
|
1776
|
+
const { data_source_id: _dataSourceId2, ...definition } = property;
|
|
1777
|
+
return definition;
|
|
1778
|
+
})
|
|
1779
|
+
);
|
|
1780
|
+
var availableDataSourceSnapshotSchema = strictObject({
|
|
1781
|
+
type: literal("available"),
|
|
1782
|
+
propertiesById: record(string(), sourcePropertySchema),
|
|
1783
|
+
propertyIdsByKey: record(string(), optional(string())),
|
|
1784
|
+
title: optional(string()),
|
|
1785
|
+
description: optional(string()),
|
|
1786
|
+
icon: optional(bridgePageIconSchema)
|
|
1787
|
+
});
|
|
1788
|
+
var dataSourceSnapshotSchema = union([
|
|
1789
|
+
availableDataSourceSnapshotSchema,
|
|
1790
|
+
strictObject({ type: literal("not_bound") }),
|
|
1791
|
+
strictObject({ type: literal("unavailable") }),
|
|
1792
|
+
strictObject({
|
|
1793
|
+
type: literal("error"),
|
|
1794
|
+
error: customBlockErrorInfoSchema
|
|
1795
|
+
})
|
|
1796
|
+
]);
|
|
1797
|
+
var dataSourceChangedMessageSchema = object({
|
|
1798
|
+
type: literal("dataSourceChanged"),
|
|
1799
|
+
key: string(),
|
|
1800
|
+
snapshot: union([
|
|
1801
|
+
dataSourceSnapshotSchema,
|
|
1802
|
+
strictObject({ type: literal("loading") })
|
|
1803
|
+
])
|
|
1804
|
+
});
|
|
1805
|
+
|
|
1806
|
+
// ../protocol/src/utils/recordPointer.ts
|
|
1807
|
+
var notionRecordPointerSchema = object({
|
|
1808
|
+
id: string(),
|
|
1809
|
+
table: string()
|
|
1810
|
+
});
|
|
1811
|
+
|
|
1812
|
+
// ../protocol/src/pages/properties/actor.ts
|
|
1813
|
+
var bridgeActorSchema = object({
|
|
1814
|
+
...notionRecordPointerSchema.entries,
|
|
1815
|
+
spaceId: optional(string())
|
|
1816
|
+
});
|
|
1817
|
+
|
|
1818
|
+
// ../protocol/src/compatibility/pageTextPropertySchemas.ts
|
|
1819
|
+
var textUniqueIdPropertySchema = object({
|
|
1820
|
+
id: string(),
|
|
1821
|
+
type: literal("unique_id"),
|
|
1822
|
+
unique_id: string()
|
|
1823
|
+
});
|
|
1824
|
+
var textVerificationPropertySchema = object({
|
|
1825
|
+
id: string(),
|
|
1826
|
+
type: literal("verification"),
|
|
1827
|
+
verification: string()
|
|
1828
|
+
});
|
|
1829
|
+
|
|
1674
1830
|
// ../protocol/src/utils/nullableStringSchema.ts
|
|
1675
1831
|
var nullableStringSchema = nullable(string());
|
|
1676
1832
|
|
|
1677
|
-
// ../protocol/src/
|
|
1833
|
+
// ../protocol/src/pages/pageAddress.ts
|
|
1834
|
+
var pageReadTargetSchema = variant("type", [
|
|
1835
|
+
strictObject({ type: literal("page_key"), pageKey: string() }),
|
|
1836
|
+
strictObject({
|
|
1837
|
+
type: literal("data_source_descendant"),
|
|
1838
|
+
dataSourceKey: string(),
|
|
1839
|
+
pageId: notionPageIdSchema
|
|
1840
|
+
}),
|
|
1841
|
+
strictObject({ type: literal("containing_page") })
|
|
1842
|
+
]);
|
|
1843
|
+
var pageAddressSchema = variant("type", [
|
|
1844
|
+
...pageReadTargetSchema.options,
|
|
1845
|
+
strictObject({ type: literal("page_id"), pageId: notionPageIdSchema })
|
|
1846
|
+
]);
|
|
1847
|
+
|
|
1848
|
+
// ../protocol/src/dataSources/properties/dateReminders.ts
|
|
1678
1849
|
var notionDateReminderSchema = object({
|
|
1679
1850
|
unit: picklist(["year", "month", "week", "day"]),
|
|
1680
1851
|
value: number(),
|
|
@@ -1692,48 +1863,9 @@ var notionDateTimeReminderSchema = union([
|
|
|
1692
1863
|
notionDateReminderSchema,
|
|
1693
1864
|
notionTimeReminderSchema
|
|
1694
1865
|
]);
|
|
1695
|
-
var dateOrDisabledReminder = optional(
|
|
1696
|
-
union([notionDateReminderSchema, notionDisabledReminderSchema])
|
|
1697
|
-
);
|
|
1698
|
-
var dateTimeOrDisabledReminder = optional(
|
|
1699
|
-
union([notionDateTimeReminderSchema, notionDisabledReminderSchema])
|
|
1700
|
-
);
|
|
1701
|
-
var notionDateSchema = object({
|
|
1702
|
-
type: literal("date"),
|
|
1703
|
-
start_date: string(),
|
|
1704
|
-
reminder: dateOrDisabledReminder
|
|
1705
|
-
});
|
|
1706
|
-
var notionDateRangeSchema = object({
|
|
1707
|
-
type: literal("daterange"),
|
|
1708
|
-
start_date: string(),
|
|
1709
|
-
end_date: string(),
|
|
1710
|
-
reminder: dateOrDisabledReminder
|
|
1711
|
-
});
|
|
1712
|
-
var notionDateTimeSchema = object({
|
|
1713
|
-
type: literal("datetime"),
|
|
1714
|
-
start_date: string(),
|
|
1715
|
-
start_time: string(),
|
|
1716
|
-
time_zone: optional(string()),
|
|
1717
|
-
reminder: dateTimeOrDisabledReminder
|
|
1718
|
-
});
|
|
1719
|
-
var notionDateTimeRangeSchema = object({
|
|
1720
|
-
type: literal("datetimerange"),
|
|
1721
|
-
start_date: string(),
|
|
1722
|
-
start_time: string(),
|
|
1723
|
-
end_date: string(),
|
|
1724
|
-
end_time: string(),
|
|
1725
|
-
time_zone: optional(string()),
|
|
1726
|
-
reminder: dateTimeOrDisabledReminder
|
|
1727
|
-
});
|
|
1728
|
-
var notionDateValueSchema = variant("type", [
|
|
1729
|
-
notionDateSchema,
|
|
1730
|
-
notionDateRangeSchema,
|
|
1731
|
-
notionDateTimeSchema,
|
|
1732
|
-
notionDateTimeRangeSchema
|
|
1733
|
-
]);
|
|
1734
1866
|
|
|
1735
|
-
// ../protocol/src/pages/properties/
|
|
1736
|
-
var
|
|
1867
|
+
// ../protocol/src/pages/properties/date.ts
|
|
1868
|
+
var dateEntries = {
|
|
1737
1869
|
start: string(),
|
|
1738
1870
|
end: optional(nullableStringSchema),
|
|
1739
1871
|
time_zone: optional(nullableStringSchema),
|
|
@@ -1741,39 +1873,38 @@ var dateInputEntries = {
|
|
|
1741
1873
|
union([notionDateTimeReminderSchema, notionDisabledReminderSchema])
|
|
1742
1874
|
)
|
|
1743
1875
|
};
|
|
1744
|
-
var
|
|
1876
|
+
var bridgeDateSchema = union([
|
|
1745
1877
|
object({
|
|
1746
|
-
...
|
|
1878
|
+
...dateEntries,
|
|
1747
1879
|
start: pipe(string(), includes("T"))
|
|
1748
1880
|
}),
|
|
1749
1881
|
object({
|
|
1750
|
-
...
|
|
1882
|
+
...dateEntries,
|
|
1751
1883
|
time_zone: string()
|
|
1752
1884
|
}),
|
|
1753
1885
|
object({
|
|
1754
|
-
...
|
|
1886
|
+
...dateEntries,
|
|
1755
1887
|
reminder: optional(
|
|
1756
1888
|
union([notionDateReminderSchema, notionDisabledReminderSchema])
|
|
1757
1889
|
)
|
|
1758
1890
|
})
|
|
1759
1891
|
]);
|
|
1760
1892
|
|
|
1761
|
-
// ../protocol/src/
|
|
1762
|
-
var
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
// ../protocol/src/pages/properties/metadataActor.ts
|
|
1768
|
-
var metadataActorSchema = nullable(
|
|
1893
|
+
// ../protocol/src/pages/properties/personItem.ts
|
|
1894
|
+
var bridgePersonItemSchema = union([
|
|
1895
|
+
object({
|
|
1896
|
+
object: optional(literal("user")),
|
|
1897
|
+
id: string()
|
|
1898
|
+
}),
|
|
1769
1899
|
object({
|
|
1770
|
-
|
|
1771
|
-
|
|
1900
|
+
object: literal("group"),
|
|
1901
|
+
id: string(),
|
|
1902
|
+
name: optional(nullableStringSchema)
|
|
1772
1903
|
})
|
|
1773
|
-
);
|
|
1904
|
+
]);
|
|
1774
1905
|
|
|
1775
|
-
// ../protocol/src/pages/properties/
|
|
1776
|
-
var
|
|
1906
|
+
// ../protocol/src/pages/properties/place.ts
|
|
1907
|
+
var bridgePlaceSchema = object({
|
|
1777
1908
|
lat: number(),
|
|
1778
1909
|
lon: number(),
|
|
1779
1910
|
name: optional(nullableStringSchema),
|
|
@@ -1782,14 +1913,14 @@ var notionPlaceInputSchema = object({
|
|
|
1782
1913
|
google_place_id: optional(nullableStringSchema)
|
|
1783
1914
|
});
|
|
1784
1915
|
|
|
1785
|
-
// ../protocol/src/pages/properties/
|
|
1786
|
-
var
|
|
1916
|
+
// ../protocol/src/pages/properties/relationItem.ts
|
|
1917
|
+
var bridgeRelationItemSchema = object({ id: string() });
|
|
1787
1918
|
|
|
1788
1919
|
// ../protocol/src/pages/properties/richText.ts
|
|
1789
|
-
var
|
|
1920
|
+
var bridgeRichTextItemSchema = record(string(), unknown());
|
|
1790
1921
|
|
|
1791
1922
|
// ../protocol/src/pages/properties/selectOption.ts
|
|
1792
|
-
var
|
|
1923
|
+
var bridgeSelectOptionSchema = union([
|
|
1793
1924
|
object({
|
|
1794
1925
|
id: string(),
|
|
1795
1926
|
name: optional(string()),
|
|
@@ -1804,31 +1935,22 @@ var notionSelectOptionInputSchema = union([
|
|
|
1804
1935
|
})
|
|
1805
1936
|
]);
|
|
1806
1937
|
|
|
1807
|
-
// ../protocol/src/pages/properties/userInput.ts
|
|
1808
|
-
var notionUserInputSchema = union([
|
|
1809
|
-
object({
|
|
1810
|
-
object: optional(literal("user")),
|
|
1811
|
-
id: string()
|
|
1812
|
-
}),
|
|
1813
|
-
object({
|
|
1814
|
-
object: literal("group"),
|
|
1815
|
-
id: string(),
|
|
1816
|
-
name: optional(nullableStringSchema)
|
|
1817
|
-
})
|
|
1818
|
-
]);
|
|
1819
|
-
|
|
1820
1938
|
// ../protocol/src/pages/properties/bridgePagePropertyValue.ts
|
|
1821
|
-
var pagePropertyBaseSchema = {
|
|
1822
|
-
|
|
1939
|
+
var pagePropertyBaseSchema = {
|
|
1940
|
+
id: string(),
|
|
1941
|
+
/** Readable values omit `restricted`. Only restricted values set it, to `true`. */
|
|
1942
|
+
restricted: optional(literal(false))
|
|
1943
|
+
};
|
|
1944
|
+
var commonPagePropertySchemas = [
|
|
1823
1945
|
object({
|
|
1824
1946
|
...pagePropertyBaseSchema,
|
|
1825
1947
|
type: literal("title"),
|
|
1826
|
-
title: array(
|
|
1948
|
+
title: array(bridgeRichTextItemSchema)
|
|
1827
1949
|
}),
|
|
1828
1950
|
object({
|
|
1829
1951
|
...pagePropertyBaseSchema,
|
|
1830
1952
|
type: literal("rich_text"),
|
|
1831
|
-
rich_text: array(
|
|
1953
|
+
rich_text: array(bridgeRichTextItemSchema)
|
|
1832
1954
|
}),
|
|
1833
1955
|
object({
|
|
1834
1956
|
...pagePropertyBaseSchema,
|
|
@@ -1858,38 +1980,38 @@ var basePropertySchemas = [
|
|
|
1858
1980
|
object({
|
|
1859
1981
|
...pagePropertyBaseSchema,
|
|
1860
1982
|
type: literal("select"),
|
|
1861
|
-
select: nullable(
|
|
1983
|
+
select: nullable(bridgeSelectOptionSchema)
|
|
1862
1984
|
}),
|
|
1863
1985
|
object({
|
|
1864
1986
|
...pagePropertyBaseSchema,
|
|
1865
1987
|
type: literal("status"),
|
|
1866
|
-
status: nullable(
|
|
1988
|
+
status: nullable(bridgeSelectOptionSchema)
|
|
1867
1989
|
}),
|
|
1868
1990
|
object({
|
|
1869
1991
|
...pagePropertyBaseSchema,
|
|
1870
1992
|
type: literal("multi_select"),
|
|
1871
|
-
multi_select: array(
|
|
1993
|
+
multi_select: array(bridgeSelectOptionSchema)
|
|
1872
1994
|
}),
|
|
1873
1995
|
object({
|
|
1874
1996
|
...pagePropertyBaseSchema,
|
|
1875
1997
|
type: literal("date"),
|
|
1876
|
-
date: nullable(
|
|
1998
|
+
date: nullable(bridgeDateSchema)
|
|
1877
1999
|
}),
|
|
1878
2000
|
object({
|
|
1879
2001
|
...pagePropertyBaseSchema,
|
|
1880
2002
|
type: literal("people"),
|
|
1881
|
-
people: array(
|
|
2003
|
+
people: array(bridgePersonItemSchema)
|
|
1882
2004
|
}),
|
|
1883
2005
|
object({
|
|
1884
2006
|
...pagePropertyBaseSchema,
|
|
1885
2007
|
type: literal("relation"),
|
|
1886
2008
|
has_more: optional(boolean()),
|
|
1887
|
-
relation: array(
|
|
2009
|
+
relation: array(bridgeRelationItemSchema)
|
|
1888
2010
|
}),
|
|
1889
2011
|
object({
|
|
1890
2012
|
...pagePropertyBaseSchema,
|
|
1891
2013
|
type: literal("place"),
|
|
1892
|
-
place: nullable(
|
|
2014
|
+
place: nullable(bridgePlaceSchema)
|
|
1893
2015
|
}),
|
|
1894
2016
|
object({
|
|
1895
2017
|
...pagePropertyBaseSchema,
|
|
@@ -1904,17 +2026,12 @@ var basePropertySchemas = [
|
|
|
1904
2026
|
object({
|
|
1905
2027
|
...pagePropertyBaseSchema,
|
|
1906
2028
|
type: literal("created_by"),
|
|
1907
|
-
created_by:
|
|
2029
|
+
created_by: nullable(bridgeActorSchema)
|
|
1908
2030
|
}),
|
|
1909
2031
|
object({
|
|
1910
2032
|
...pagePropertyBaseSchema,
|
|
1911
2033
|
type: literal("last_edited_by"),
|
|
1912
|
-
last_edited_by:
|
|
1913
|
-
}),
|
|
1914
|
-
object({
|
|
1915
|
-
...pagePropertyBaseSchema,
|
|
1916
|
-
type: literal("unique_id"),
|
|
1917
|
-
unique_id: string()
|
|
2034
|
+
last_edited_by: nullable(bridgeActorSchema)
|
|
1918
2035
|
}),
|
|
1919
2036
|
object({
|
|
1920
2037
|
...pagePropertyBaseSchema,
|
|
@@ -1930,76 +2047,295 @@ var basePropertySchemas = [
|
|
|
1930
2047
|
...pagePropertyBaseSchema,
|
|
1931
2048
|
type: literal("rollup"),
|
|
1932
2049
|
rollup: string()
|
|
1933
|
-
}),
|
|
1934
|
-
object({
|
|
1935
|
-
...pagePropertyBaseSchema,
|
|
1936
|
-
type: literal("verification"),
|
|
1937
|
-
verification: string()
|
|
1938
2050
|
})
|
|
1939
2051
|
];
|
|
2052
|
+
var bridgeFilesPropertyWriteValueSchema = object({
|
|
2053
|
+
...pagePropertyBaseSchema,
|
|
2054
|
+
type: literal("files"),
|
|
2055
|
+
files: array(bridgeFilePropertyItemSchema)
|
|
2056
|
+
});
|
|
1940
2057
|
var bridgePagePropertyWriteValueSchema = variant("type", [
|
|
1941
|
-
...
|
|
2058
|
+
...commonPagePropertySchemas,
|
|
1942
2059
|
object({
|
|
1943
|
-
...
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
})
|
|
1947
|
-
]);
|
|
1948
|
-
var bridgePagePropertyReadValueSchema = variant("type", [
|
|
1949
|
-
...basePropertySchemas,
|
|
2060
|
+
...textUniqueIdPropertySchema.entries,
|
|
2061
|
+
restricted: optional(literal(false))
|
|
2062
|
+
}),
|
|
1950
2063
|
object({
|
|
1951
|
-
...
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
2064
|
+
...textVerificationPropertySchema.entries,
|
|
2065
|
+
restricted: optional(literal(false))
|
|
2066
|
+
}),
|
|
2067
|
+
bridgeFilesPropertyWriteValueSchema
|
|
1955
2068
|
]);
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
nullable(bridgePagePropertyReadValueSchema)
|
|
1965
|
-
);
|
|
1966
|
-
|
|
1967
|
-
// ../protocol/src/pages/bridgePage.ts
|
|
1968
|
-
var pageIconReadSchema = union([
|
|
1969
|
-
bridgePageIconSchema,
|
|
1970
|
-
pipe(
|
|
1971
|
-
object({ type: string() }),
|
|
1972
|
-
check(
|
|
1973
|
-
(icon) => !bridgePageIconSchema.options.some(
|
|
1974
|
-
(option) => option.entries.type.literal === icon.type
|
|
1975
|
-
)
|
|
1976
|
-
),
|
|
1977
|
-
transform(() => null)
|
|
1978
|
-
)
|
|
2069
|
+
var addressedRelationEntries = {
|
|
2070
|
+
type: literal("relation"),
|
|
2071
|
+
has_more: optional(boolean()),
|
|
2072
|
+
relation: array(union([bridgeRelationItemSchema, pageAddressSchema]))
|
|
2073
|
+
};
|
|
2074
|
+
var bridgePageAddressedPropertyWriteValueSchema = union([
|
|
2075
|
+
bridgePagePropertyWriteValueSchema,
|
|
2076
|
+
object({ ...pagePropertyBaseSchema, ...addressedRelationEntries })
|
|
1979
2077
|
]);
|
|
1980
|
-
var
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
/** Whether the page or an ancestor is archived. */
|
|
1994
|
-
is_archived: boolean(),
|
|
1995
|
-
/** Whether the page or an ancestor is in Trash. */
|
|
1996
|
-
in_trash: boolean()
|
|
2078
|
+
var bridgePageKeyedPropertyWriteValueSchema = union([
|
|
2079
|
+
variant(
|
|
2080
|
+
"type",
|
|
2081
|
+
bridgePagePropertyWriteValueSchema.options.map(
|
|
2082
|
+
(schema) => object({ ...schema.entries, id: optional(string()) })
|
|
2083
|
+
)
|
|
2084
|
+
),
|
|
2085
|
+
object({ ...addressedRelationEntries, id: optional(string()) })
|
|
2086
|
+
]);
|
|
2087
|
+
var bridgeFilesPropertyReadValueSchema = object({
|
|
2088
|
+
...pagePropertyBaseSchema,
|
|
2089
|
+
type: literal("files"),
|
|
2090
|
+
files: array(bridgeFilePropertyReadItemSchema)
|
|
1997
2091
|
});
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2092
|
+
var knownBridgePagePropertyReadValueSchema = variant("type", [
|
|
2093
|
+
...commonPagePropertySchemas,
|
|
2094
|
+
object({
|
|
2095
|
+
...textUniqueIdPropertySchema.entries,
|
|
2096
|
+
restricted: optional(literal(false))
|
|
2097
|
+
}),
|
|
2098
|
+
object({
|
|
2099
|
+
...textVerificationPropertySchema.entries,
|
|
2100
|
+
restricted: optional(literal(false))
|
|
2101
|
+
}),
|
|
2102
|
+
bridgeFilesPropertyReadValueSchema
|
|
2103
|
+
]);
|
|
2104
|
+
var bridgeRestrictedPagePropertyValueSchema = variant("type", [
|
|
2105
|
+
object({
|
|
2106
|
+
id: string(),
|
|
2107
|
+
type: literal("title"),
|
|
2108
|
+
title: null_(),
|
|
2109
|
+
restricted: literal(true)
|
|
2110
|
+
}),
|
|
2111
|
+
object({
|
|
2112
|
+
id: string(),
|
|
2113
|
+
type: literal("rich_text"),
|
|
2114
|
+
rich_text: null_(),
|
|
2115
|
+
restricted: literal(true)
|
|
2116
|
+
}),
|
|
2117
|
+
object({
|
|
2118
|
+
id: string(),
|
|
2119
|
+
type: literal("number"),
|
|
2120
|
+
number: null_(),
|
|
2121
|
+
restricted: literal(true)
|
|
2122
|
+
}),
|
|
2123
|
+
object({
|
|
2124
|
+
id: string(),
|
|
2125
|
+
type: literal("url"),
|
|
2126
|
+
url: null_(),
|
|
2127
|
+
restricted: literal(true)
|
|
2128
|
+
}),
|
|
2129
|
+
object({
|
|
2130
|
+
id: string(),
|
|
2131
|
+
type: literal("email"),
|
|
2132
|
+
email: null_(),
|
|
2133
|
+
restricted: literal(true)
|
|
2134
|
+
}),
|
|
2135
|
+
object({
|
|
2136
|
+
id: string(),
|
|
2137
|
+
type: literal("phone_number"),
|
|
2138
|
+
phone_number: null_(),
|
|
2139
|
+
restricted: literal(true)
|
|
2140
|
+
}),
|
|
2141
|
+
object({
|
|
2142
|
+
id: string(),
|
|
2143
|
+
type: literal("checkbox"),
|
|
2144
|
+
checkbox: null_(),
|
|
2145
|
+
restricted: literal(true)
|
|
2146
|
+
}),
|
|
2147
|
+
object({
|
|
2148
|
+
id: string(),
|
|
2149
|
+
type: literal("select"),
|
|
2150
|
+
select: null_(),
|
|
2151
|
+
restricted: literal(true)
|
|
2152
|
+
}),
|
|
2153
|
+
object({
|
|
2154
|
+
id: string(),
|
|
2155
|
+
type: literal("status"),
|
|
2156
|
+
status: null_(),
|
|
2157
|
+
restricted: literal(true)
|
|
2158
|
+
}),
|
|
2159
|
+
object({
|
|
2160
|
+
id: string(),
|
|
2161
|
+
type: literal("multi_select"),
|
|
2162
|
+
multi_select: null_(),
|
|
2163
|
+
restricted: literal(true)
|
|
2164
|
+
}),
|
|
2165
|
+
object({
|
|
2166
|
+
id: string(),
|
|
2167
|
+
type: literal("date"),
|
|
2168
|
+
date: null_(),
|
|
2169
|
+
restricted: literal(true)
|
|
2170
|
+
}),
|
|
2171
|
+
object({
|
|
2172
|
+
id: string(),
|
|
2173
|
+
type: literal("people"),
|
|
2174
|
+
people: null_(),
|
|
2175
|
+
restricted: literal(true)
|
|
2176
|
+
}),
|
|
2177
|
+
object({
|
|
2178
|
+
id: string(),
|
|
2179
|
+
type: literal("relation"),
|
|
2180
|
+
relation: null_(),
|
|
2181
|
+
restricted: literal(true)
|
|
2182
|
+
}),
|
|
2183
|
+
object({
|
|
2184
|
+
id: string(),
|
|
2185
|
+
type: literal("files"),
|
|
2186
|
+
files: null_(),
|
|
2187
|
+
restricted: literal(true)
|
|
2188
|
+
}),
|
|
2189
|
+
object({
|
|
2190
|
+
id: string(),
|
|
2191
|
+
type: literal("place"),
|
|
2192
|
+
place: null_(),
|
|
2193
|
+
restricted: literal(true)
|
|
2194
|
+
}),
|
|
2195
|
+
object({
|
|
2196
|
+
id: string(),
|
|
2197
|
+
type: literal("created_time"),
|
|
2198
|
+
created_time: null_(),
|
|
2199
|
+
restricted: literal(true)
|
|
2200
|
+
}),
|
|
2201
|
+
object({
|
|
2202
|
+
id: string(),
|
|
2203
|
+
type: literal("last_edited_time"),
|
|
2204
|
+
last_edited_time: null_(),
|
|
2205
|
+
restricted: literal(true)
|
|
2206
|
+
}),
|
|
2207
|
+
object({
|
|
2208
|
+
id: string(),
|
|
2209
|
+
type: literal("created_by"),
|
|
2210
|
+
created_by: null_(),
|
|
2211
|
+
restricted: literal(true)
|
|
2212
|
+
}),
|
|
2213
|
+
object({
|
|
2214
|
+
id: string(),
|
|
2215
|
+
type: literal("last_edited_by"),
|
|
2216
|
+
last_edited_by: null_(),
|
|
2217
|
+
restricted: literal(true)
|
|
2218
|
+
}),
|
|
2219
|
+
object({
|
|
2220
|
+
id: string(),
|
|
2221
|
+
type: literal("unique_id"),
|
|
2222
|
+
unique_id: null_(),
|
|
2223
|
+
restricted: literal(true)
|
|
2224
|
+
}),
|
|
2225
|
+
object({
|
|
2226
|
+
id: string(),
|
|
2227
|
+
type: literal("button"),
|
|
2228
|
+
button: null_(),
|
|
2229
|
+
restricted: literal(true)
|
|
2230
|
+
}),
|
|
2231
|
+
object({
|
|
2232
|
+
id: string(),
|
|
2233
|
+
type: literal("formula"),
|
|
2234
|
+
formula: null_(),
|
|
2235
|
+
restricted: literal(true)
|
|
2236
|
+
}),
|
|
2237
|
+
object({
|
|
2238
|
+
id: string(),
|
|
2239
|
+
type: literal("rollup"),
|
|
2240
|
+
rollup: null_(),
|
|
2241
|
+
restricted: literal(true)
|
|
2242
|
+
}),
|
|
2243
|
+
object({
|
|
2244
|
+
id: string(),
|
|
2245
|
+
type: literal("verification"),
|
|
2246
|
+
verification: null_(),
|
|
2247
|
+
restricted: literal(true)
|
|
2248
|
+
})
|
|
2249
|
+
]);
|
|
2250
|
+
var bridgeUnknownPagePropertyReadValueSchema = object({
|
|
2251
|
+
...pagePropertyBaseSchema,
|
|
2252
|
+
type: literal("unknown"),
|
|
2253
|
+
originalType: unknownPropertyTypeSchema
|
|
2254
|
+
});
|
|
2255
|
+
var futurePagePropertyReadValueSchema = pipe(
|
|
2256
|
+
object({
|
|
2257
|
+
id: string(),
|
|
2258
|
+
type: unknownPropertyTypeSchema,
|
|
2259
|
+
restricted: optional(boolean())
|
|
2260
|
+
}),
|
|
2261
|
+
check(
|
|
2262
|
+
({ type }) => !knownBridgePagePropertyReadValueSchema.options.some(
|
|
2263
|
+
(schema) => schema.entries.type.literal === type
|
|
2264
|
+
)
|
|
2265
|
+
),
|
|
2266
|
+
transform(
|
|
2267
|
+
({ id, type }) => ({
|
|
2268
|
+
id,
|
|
2269
|
+
type: "unknown",
|
|
2270
|
+
originalType: type
|
|
2271
|
+
})
|
|
2272
|
+
)
|
|
2273
|
+
);
|
|
2274
|
+
var bridgePagePropertyReadValueSchema = union([
|
|
2275
|
+
bridgeRestrictedPagePropertyValueSchema,
|
|
2276
|
+
knownBridgePagePropertyReadValueSchema,
|
|
2277
|
+
bridgeUnknownPagePropertyReadValueSchema,
|
|
2278
|
+
futurePagePropertyReadValueSchema
|
|
2279
|
+
]);
|
|
2280
|
+
|
|
2281
|
+
// ../protocol/src/pages/properties/bridgePagePropertyMaps.ts
|
|
2282
|
+
var bridgePagePropertyWriteMapSchema = record(
|
|
2283
|
+
string(),
|
|
2284
|
+
bridgePagePropertyWriteValueSchema
|
|
2285
|
+
);
|
|
2286
|
+
var bridgePageAddressedPropertyWriteMapSchema = record(
|
|
2287
|
+
string(),
|
|
2288
|
+
bridgePageAddressedPropertyWriteValueSchema
|
|
2289
|
+
);
|
|
2290
|
+
var bridgePageKeyedPropertyWriteMapSchema = record(
|
|
2291
|
+
string(),
|
|
2292
|
+
bridgePageKeyedPropertyWriteValueSchema
|
|
2293
|
+
);
|
|
2294
|
+
var bridgePropertyIdsByKeySchema = record(
|
|
2295
|
+
string(),
|
|
2296
|
+
optional(string())
|
|
2297
|
+
);
|
|
2298
|
+
var bridgePagePropertyReadMapSchema = record(
|
|
2299
|
+
string(),
|
|
2300
|
+
nullable(bridgePagePropertyReadValueSchema)
|
|
2301
|
+
);
|
|
2302
|
+
|
|
2303
|
+
// ../protocol/src/pages/bridgePage.ts
|
|
2304
|
+
var pageIconReadSchema = union([
|
|
2305
|
+
bridgePageIconSchema,
|
|
2306
|
+
pipe(
|
|
2307
|
+
object({ type: string() }),
|
|
2308
|
+
check(
|
|
2309
|
+
(icon) => !bridgePageIconSchema.options.some(
|
|
2310
|
+
(option) => option.entries.type.literal === icon.type
|
|
2311
|
+
)
|
|
2312
|
+
),
|
|
2313
|
+
transform(() => null)
|
|
2314
|
+
)
|
|
2315
|
+
]);
|
|
2316
|
+
var bridgePageSchema = object({
|
|
2317
|
+
object: literal("page"),
|
|
2318
|
+
id: notionPageIdSchema,
|
|
2319
|
+
parent: notionParentSchema,
|
|
2320
|
+
properties: bridgePagePropertyReadMapSchema,
|
|
2321
|
+
created_by: optional(nullable(bridgeActorSchema), null),
|
|
2322
|
+
last_edited_by: optional(nullable(bridgeActorSchema), null),
|
|
2323
|
+
created_time: optional(nullable(string()), null),
|
|
2324
|
+
last_edited_time: optional(nullable(string()), null),
|
|
2325
|
+
icon: optional(nullable(pageIconReadSchema), null),
|
|
2326
|
+
cover: optional(nullable(bridgePageCoverSchema), null),
|
|
2327
|
+
url: optional(nullable(string()), null),
|
|
2328
|
+
public_url: optional(nullable(string()), null),
|
|
2329
|
+
/** Whether the page or an ancestor is archived. */
|
|
2330
|
+
is_archived: boolean(),
|
|
2331
|
+
/** Whether the page or an ancestor is in Trash. */
|
|
2332
|
+
in_trash: boolean()
|
|
2333
|
+
});
|
|
2334
|
+
|
|
2335
|
+
// ../protocol/src/dataSources/bridgeArchiveStatus.ts
|
|
2336
|
+
var bridgeArchiveStatusSchema = picklist([
|
|
2337
|
+
"active",
|
|
2338
|
+
"archived",
|
|
2003
2339
|
"all"
|
|
2004
2340
|
]);
|
|
2005
2341
|
|
|
@@ -2374,6 +2710,59 @@ var openExternalUrlResultMessageSchema = variant("status", [
|
|
|
2374
2710
|
})
|
|
2375
2711
|
]);
|
|
2376
2712
|
|
|
2713
|
+
// ../protocol/src/pages/messages/getPage.ts
|
|
2714
|
+
var customBlockGetPageErrorCodeSchema = string();
|
|
2715
|
+
var customBlockGetPageErrorInfoSchema = object({
|
|
2716
|
+
code: customBlockGetPageErrorCodeSchema,
|
|
2717
|
+
message: string(),
|
|
2718
|
+
isRetryable: boolean(),
|
|
2719
|
+
details: fallback(optional(customBlockErrorDetailsSchema), void 0)
|
|
2720
|
+
});
|
|
2721
|
+
var getPageMessageSchema = object({
|
|
2722
|
+
type: literal("getPage"),
|
|
2723
|
+
requestId: string(),
|
|
2724
|
+
pageId: notionPageIdSchema,
|
|
2725
|
+
dataSourceId: optional(notionDataSourceIdSchema)
|
|
2726
|
+
});
|
|
2727
|
+
var keyedGetPageMessageSchema = variant("type", [
|
|
2728
|
+
strictObject({
|
|
2729
|
+
type: literal("getPage"),
|
|
2730
|
+
requestId: string(),
|
|
2731
|
+
target: pageReadTargetSchema
|
|
2732
|
+
}),
|
|
2733
|
+
// The host checks bare IDs against current bindings or pages created on the connection.
|
|
2734
|
+
strictObject({
|
|
2735
|
+
type: literal("getPage"),
|
|
2736
|
+
requestId: string(),
|
|
2737
|
+
pageId: notionPageIdSchema
|
|
2738
|
+
})
|
|
2739
|
+
]);
|
|
2740
|
+
var getPageResultMessageSchema = variant("status", [
|
|
2741
|
+
object({
|
|
2742
|
+
type: literal("getPageResult"),
|
|
2743
|
+
requestId: string(),
|
|
2744
|
+
status: literal("success"),
|
|
2745
|
+
page: bridgePageSchema,
|
|
2746
|
+
propertyIdsByKey: optional(bridgePropertyIdsByKeySchema)
|
|
2747
|
+
}),
|
|
2748
|
+
object({
|
|
2749
|
+
type: literal("getPageResult"),
|
|
2750
|
+
requestId: string(),
|
|
2751
|
+
status: literal("error"),
|
|
2752
|
+
error: customBlockGetPageErrorInfoSchema
|
|
2753
|
+
})
|
|
2754
|
+
]);
|
|
2755
|
+
var addressedGetPageResultMessageSchema = variant("status", [
|
|
2756
|
+
object({
|
|
2757
|
+
...getPageResultMessageSchema.options[0].entries,
|
|
2758
|
+
page: object({
|
|
2759
|
+
...bridgePageSchema.entries,
|
|
2760
|
+
id: optional(notionPageIdSchema)
|
|
2761
|
+
})
|
|
2762
|
+
}),
|
|
2763
|
+
getPageResultMessageSchema.options[1]
|
|
2764
|
+
]);
|
|
2765
|
+
|
|
2377
2766
|
// ../protocol/src/pages/messages/createPage.ts
|
|
2378
2767
|
var customBlockCreatePageErrorCodeSchema = string();
|
|
2379
2768
|
var customBlockCreatePageErrorInfoSchema = object({
|
|
@@ -2387,7 +2776,8 @@ var createPageResultMessageSchema = variant("status", [
|
|
|
2387
2776
|
requestId: string(),
|
|
2388
2777
|
status: literal("success"),
|
|
2389
2778
|
/** The newly created page. */
|
|
2390
|
-
page: bridgePageSchema
|
|
2779
|
+
page: bridgePageSchema,
|
|
2780
|
+
propertyIdsByKey: optional(bridgePropertyIdsByKeySchema)
|
|
2391
2781
|
}),
|
|
2392
2782
|
object({
|
|
2393
2783
|
type: literal("createPageResult"),
|
|
@@ -2406,17 +2796,18 @@ var createPageParentSchema = variant("type", [
|
|
|
2406
2796
|
pageParentSchema,
|
|
2407
2797
|
dataSourceParentSchema
|
|
2408
2798
|
]);
|
|
2799
|
+
var createPageAppearanceEntries = {
|
|
2800
|
+
icon: optional(bridgePageIconSchema),
|
|
2801
|
+
cover: optional(bridgePageCoverSchema)
|
|
2802
|
+
};
|
|
2409
2803
|
var createPageBaseEntries = {
|
|
2804
|
+
...createPageAppearanceEntries,
|
|
2410
2805
|
/**
|
|
2411
2806
|
* Property values, keyed by raw property IDs from Notion.
|
|
2412
2807
|
*
|
|
2413
2808
|
* Each value must carry the same raw property ID in its `id` field.
|
|
2414
|
-
* To create a page with manifest-defined property keys, call `pages.create`. The SDK resolves
|
|
2415
|
-
* those keys before it sends this message.
|
|
2416
2809
|
*/
|
|
2417
|
-
properties: bridgePagePropertyWriteMapSchema
|
|
2418
|
-
icon: optional(bridgePageIconSchema),
|
|
2419
|
-
cover: optional(bridgePageCoverSchema)
|
|
2810
|
+
properties: bridgePagePropertyWriteMapSchema
|
|
2420
2811
|
};
|
|
2421
2812
|
var createPageUnderPageArgsSchema = object({
|
|
2422
2813
|
...createPageBaseEntries,
|
|
@@ -2446,33 +2837,19 @@ var createPageMessageSchema = variant("type", [
|
|
|
2446
2837
|
...createPageUnderDataSourceArgsSchema.entries
|
|
2447
2838
|
})
|
|
2448
2839
|
]);
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
isRetryable: boolean(),
|
|
2456
|
-
details: fallback(optional(customBlockErrorDetailsSchema), void 0)
|
|
2457
|
-
});
|
|
2458
|
-
var getPageMessageSchema = object({
|
|
2459
|
-
type: literal("getPage"),
|
|
2460
|
-
requestId: string(),
|
|
2461
|
-
pageId: notionPageIdSchema,
|
|
2462
|
-
dataSourceId: optional(notionDataSourceIdSchema)
|
|
2463
|
-
});
|
|
2464
|
-
var getPageResultMessageSchema = variant("status", [
|
|
2465
|
-
object({
|
|
2466
|
-
type: literal("getPageResult"),
|
|
2467
|
-
requestId: string(),
|
|
2468
|
-
status: literal("success"),
|
|
2469
|
-
page: bridgePageSchema
|
|
2840
|
+
var keyedCreatePageMessageSchema = variant("type", [
|
|
2841
|
+
strictObject({
|
|
2842
|
+
...createPageMessageEntries,
|
|
2843
|
+
...createPageUnderPageArgsSchema.entries,
|
|
2844
|
+
parent: pageAddressSchema,
|
|
2845
|
+
properties: bridgePageAddressedPropertyWriteMapSchema
|
|
2470
2846
|
}),
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2847
|
+
strictObject({
|
|
2848
|
+
...createPageMessageEntries,
|
|
2849
|
+
...createPageAppearanceEntries,
|
|
2850
|
+
parent: dataSourceKeyParentSchema,
|
|
2851
|
+
propertiesByKey: bridgePageKeyedPropertyWriteMapSchema,
|
|
2852
|
+
position: optional(never())
|
|
2476
2853
|
})
|
|
2477
2854
|
]);
|
|
2478
2855
|
|
|
@@ -2504,6 +2881,18 @@ var openPageResultMessageSchema = variant("status", [
|
|
|
2504
2881
|
error: customBlockOpenPageErrorInfoSchema
|
|
2505
2882
|
})
|
|
2506
2883
|
]);
|
|
2884
|
+
var addressedOpenPageMessageSchema = strictObject({
|
|
2885
|
+
type: literal("openPage"),
|
|
2886
|
+
requestId: string(),
|
|
2887
|
+
target: pageAddressSchema,
|
|
2888
|
+
mode: openPageModeSchema
|
|
2889
|
+
});
|
|
2890
|
+
var addressedOpenPageResultMessageSchema = variant("status", [
|
|
2891
|
+
strictObject(
|
|
2892
|
+
omit(openPageResultMessageSchema.options[0], ["pageId"]).entries
|
|
2893
|
+
),
|
|
2894
|
+
openPageResultMessageSchema.options[1]
|
|
2895
|
+
]);
|
|
2507
2896
|
|
|
2508
2897
|
// ../protocol/src/pages/messages/updatePage.ts
|
|
2509
2898
|
var customBlockUpdatePageErrorCodeSchema = string();
|
|
@@ -2517,7 +2906,8 @@ var updatePageResultMessageSchema = variant("status", [
|
|
|
2517
2906
|
type: literal("updatePageResult"),
|
|
2518
2907
|
requestId: string(),
|
|
2519
2908
|
status: literal("success"),
|
|
2520
|
-
page: bridgePageSchema
|
|
2909
|
+
page: bridgePageSchema,
|
|
2910
|
+
propertyIdsByKey: optional(bridgePropertyIdsByKeySchema)
|
|
2521
2911
|
}),
|
|
2522
2912
|
object({
|
|
2523
2913
|
type: literal("updatePageResult"),
|
|
@@ -2526,6 +2916,13 @@ var updatePageResultMessageSchema = variant("status", [
|
|
|
2526
2916
|
error: customBlockUpdatePageErrorInfoSchema
|
|
2527
2917
|
})
|
|
2528
2918
|
]);
|
|
2919
|
+
var addressedUpdatePageResultMessageSchema = variant("status", [
|
|
2920
|
+
object({
|
|
2921
|
+
...updatePageResultMessageSchema.options[0].entries,
|
|
2922
|
+
page: partial(bridgePageSchema, ["id"])
|
|
2923
|
+
}),
|
|
2924
|
+
updatePageResultMessageSchema.options[1]
|
|
2925
|
+
]);
|
|
2529
2926
|
var updatePageMessageSchema = object({
|
|
2530
2927
|
type: literal("updatePage"),
|
|
2531
2928
|
requestId: string(),
|
|
@@ -2535,14 +2932,33 @@ var updatePageMessageSchema = object({
|
|
|
2535
2932
|
* Property values, keyed by raw property IDs from Notion.
|
|
2536
2933
|
*
|
|
2537
2934
|
* Each value must carry the same raw property ID in its `id` field.
|
|
2538
|
-
* To update a page with manifest-defined property keys, call `row.updateByKey()` on a row returned
|
|
2539
|
-
* by `useDataSource()`. The SDK resolves those keys before it sends this message.
|
|
2540
2935
|
*/
|
|
2541
2936
|
properties: optional(bridgePagePropertyWriteMapSchema),
|
|
2542
2937
|
icon: optional(bridgePageIconSchema),
|
|
2543
2938
|
cover: optional(bridgePageCoverSchema),
|
|
2544
2939
|
archived: optional(boolean())
|
|
2545
2940
|
});
|
|
2941
|
+
var {
|
|
2942
|
+
dataSourceId: _dataSourceId,
|
|
2943
|
+
pageId: _pageId,
|
|
2944
|
+
properties: _properties,
|
|
2945
|
+
...updatePageFields
|
|
2946
|
+
} = updatePageMessageSchema.entries;
|
|
2947
|
+
var keyedUpdatePageMessageSchema = variant("type", [
|
|
2948
|
+
strictObject({
|
|
2949
|
+
...updatePageFields,
|
|
2950
|
+
target: pageAddressSchema,
|
|
2951
|
+
dataSourceKey: optional(string()),
|
|
2952
|
+
properties: optional(bridgePageAddressedPropertyWriteMapSchema)
|
|
2953
|
+
}),
|
|
2954
|
+
strictObject({
|
|
2955
|
+
...updatePageFields,
|
|
2956
|
+
target: pageAddressSchema,
|
|
2957
|
+
// Supply a mapping for targets that do not already identify a data source.
|
|
2958
|
+
dataSourceKey: optional(string()),
|
|
2959
|
+
propertiesByKey: bridgePageKeyedPropertyWriteMapSchema
|
|
2960
|
+
})
|
|
2961
|
+
]);
|
|
2546
2962
|
|
|
2547
2963
|
// ../protocol/src/users/bridgeUser.ts
|
|
2548
2964
|
var bridgeUserSchema = object({
|
|
@@ -2688,36 +3104,179 @@ var invalidSandboxMessageSchema = object({
|
|
|
2688
3104
|
var commonHostToSandboxSchemas = [
|
|
2689
3105
|
connectResultMessageSchema,
|
|
2690
3106
|
setupInitMessageSchema,
|
|
2691
|
-
getDataSourceResultMessageSchema,
|
|
2692
3107
|
getCurrentUserResultMessageSchema,
|
|
2693
3108
|
getViewerResultMessageSchema,
|
|
2694
|
-
dataSourcesInvalidatedMessageSchema,
|
|
2695
3109
|
themeChangedMessageSchema,
|
|
2696
3110
|
contrastModeChangedMessageSchema,
|
|
2697
|
-
parentChangedMessageSchema,
|
|
2698
|
-
pageChangedMessageSchema,
|
|
2699
3111
|
pageErrorMessageSchema,
|
|
2700
3112
|
parentErrorMessageSchema,
|
|
2701
3113
|
getUserResultMessageSchema,
|
|
2702
3114
|
listUsersResultMessageSchema,
|
|
2703
|
-
openPageResultMessageSchema,
|
|
2704
3115
|
openExternalUrlResultMessageSchema,
|
|
2705
3116
|
invalidSandboxMessageSchema
|
|
2706
3117
|
];
|
|
2707
3118
|
var hostToSandboxMessageSchema = variant("type", [
|
|
2708
3119
|
...commonHostToSandboxSchemas,
|
|
3120
|
+
addressedOpenPageResultMessageSchema,
|
|
3121
|
+
pageChangedMessageSchema,
|
|
3122
|
+
parentChangedMessageSchema,
|
|
3123
|
+
dataSourceChangedMessageSchema,
|
|
2709
3124
|
queryDataSourceResultMessageSchema,
|
|
2710
|
-
|
|
3125
|
+
addressedGetPageResultMessageSchema,
|
|
2711
3126
|
createPageResultMessageSchema,
|
|
2712
|
-
|
|
3127
|
+
addressedUpdatePageResultMessageSchema
|
|
2713
3128
|
]);
|
|
2714
3129
|
|
|
3130
|
+
// ../protocol/src/compatibility/contextThroughProtocol13.ts
|
|
3131
|
+
var parentChangedThroughProtocol13Schema = object({
|
|
3132
|
+
...parentChangedMessageSchema.entries,
|
|
3133
|
+
parent: parentThroughProtocol13Schema
|
|
3134
|
+
});
|
|
3135
|
+
var pageChangedThroughProtocol13Schema = object({
|
|
3136
|
+
...pageChangedMessageSchema.entries,
|
|
3137
|
+
page: variant("type", [
|
|
3138
|
+
containingPageSchema.options[0],
|
|
3139
|
+
object({
|
|
3140
|
+
...containingPageSchema.options[1].entries,
|
|
3141
|
+
parent: parentThroughProtocol13Schema
|
|
3142
|
+
})
|
|
3143
|
+
])
|
|
3144
|
+
});
|
|
3145
|
+
|
|
3146
|
+
// ../protocol/src/compatibility/protocol13/pagePropertyValues.ts
|
|
3147
|
+
var pagePropertyBaseSchema2 = { id: string() };
|
|
3148
|
+
var commonPagePropertySchemas2 = [
|
|
3149
|
+
object({
|
|
3150
|
+
...pagePropertyBaseSchema2,
|
|
3151
|
+
type: literal("title"),
|
|
3152
|
+
title: array(bridgeRichTextItemSchema)
|
|
3153
|
+
}),
|
|
3154
|
+
object({
|
|
3155
|
+
...pagePropertyBaseSchema2,
|
|
3156
|
+
type: literal("rich_text"),
|
|
3157
|
+
rich_text: array(bridgeRichTextItemSchema)
|
|
3158
|
+
}),
|
|
3159
|
+
object({
|
|
3160
|
+
...pagePropertyBaseSchema2,
|
|
3161
|
+
type: literal("number"),
|
|
3162
|
+
number: nullable(number())
|
|
3163
|
+
}),
|
|
3164
|
+
object({
|
|
3165
|
+
...pagePropertyBaseSchema2,
|
|
3166
|
+
type: literal("url"),
|
|
3167
|
+
url: nullableStringSchema
|
|
3168
|
+
}),
|
|
3169
|
+
object({
|
|
3170
|
+
...pagePropertyBaseSchema2,
|
|
3171
|
+
type: literal("email"),
|
|
3172
|
+
email: nullableStringSchema
|
|
3173
|
+
}),
|
|
3174
|
+
object({
|
|
3175
|
+
...pagePropertyBaseSchema2,
|
|
3176
|
+
type: literal("phone_number"),
|
|
3177
|
+
phone_number: nullableStringSchema
|
|
3178
|
+
}),
|
|
3179
|
+
object({
|
|
3180
|
+
...pagePropertyBaseSchema2,
|
|
3181
|
+
type: literal("checkbox"),
|
|
3182
|
+
checkbox: boolean()
|
|
3183
|
+
}),
|
|
3184
|
+
object({
|
|
3185
|
+
...pagePropertyBaseSchema2,
|
|
3186
|
+
type: literal("select"),
|
|
3187
|
+
select: nullable(bridgeSelectOptionSchema)
|
|
3188
|
+
}),
|
|
3189
|
+
object({
|
|
3190
|
+
...pagePropertyBaseSchema2,
|
|
3191
|
+
type: literal("status"),
|
|
3192
|
+
status: nullable(bridgeSelectOptionSchema)
|
|
3193
|
+
}),
|
|
3194
|
+
object({
|
|
3195
|
+
...pagePropertyBaseSchema2,
|
|
3196
|
+
type: literal("multi_select"),
|
|
3197
|
+
multi_select: array(bridgeSelectOptionSchema)
|
|
3198
|
+
}),
|
|
3199
|
+
object({
|
|
3200
|
+
...pagePropertyBaseSchema2,
|
|
3201
|
+
type: literal("date"),
|
|
3202
|
+
date: nullable(bridgeDateSchema)
|
|
3203
|
+
}),
|
|
3204
|
+
object({
|
|
3205
|
+
...pagePropertyBaseSchema2,
|
|
3206
|
+
type: literal("people"),
|
|
3207
|
+
people: array(bridgePersonItemSchema)
|
|
3208
|
+
}),
|
|
3209
|
+
object({
|
|
3210
|
+
...pagePropertyBaseSchema2,
|
|
3211
|
+
type: literal("relation"),
|
|
3212
|
+
has_more: optional(boolean()),
|
|
3213
|
+
relation: array(bridgeRelationItemSchema)
|
|
3214
|
+
}),
|
|
3215
|
+
object({
|
|
3216
|
+
...pagePropertyBaseSchema2,
|
|
3217
|
+
type: literal("place"),
|
|
3218
|
+
place: nullable(bridgePlaceSchema)
|
|
3219
|
+
}),
|
|
3220
|
+
object({
|
|
3221
|
+
...pagePropertyBaseSchema2,
|
|
3222
|
+
type: literal("created_time"),
|
|
3223
|
+
created_time: nullableStringSchema
|
|
3224
|
+
}),
|
|
3225
|
+
object({
|
|
3226
|
+
...pagePropertyBaseSchema2,
|
|
3227
|
+
type: literal("last_edited_time"),
|
|
3228
|
+
last_edited_time: nullableStringSchema
|
|
3229
|
+
}),
|
|
3230
|
+
object({
|
|
3231
|
+
...pagePropertyBaseSchema2,
|
|
3232
|
+
type: literal("created_by"),
|
|
3233
|
+
created_by: nullable(bridgeActorSchema)
|
|
3234
|
+
}),
|
|
3235
|
+
object({
|
|
3236
|
+
...pagePropertyBaseSchema2,
|
|
3237
|
+
type: literal("last_edited_by"),
|
|
3238
|
+
last_edited_by: nullable(bridgeActorSchema)
|
|
3239
|
+
}),
|
|
3240
|
+
object({
|
|
3241
|
+
...pagePropertyBaseSchema2,
|
|
3242
|
+
type: literal("button"),
|
|
3243
|
+
button: string()
|
|
3244
|
+
}),
|
|
3245
|
+
object({
|
|
3246
|
+
...pagePropertyBaseSchema2,
|
|
3247
|
+
type: literal("formula"),
|
|
3248
|
+
formula: string()
|
|
3249
|
+
}),
|
|
3250
|
+
object({
|
|
3251
|
+
...pagePropertyBaseSchema2,
|
|
3252
|
+
type: literal("rollup"),
|
|
3253
|
+
rollup: string()
|
|
3254
|
+
})
|
|
3255
|
+
];
|
|
3256
|
+
var bridgeFilesPropertyWriteValueSchema2 = object({
|
|
3257
|
+
...pagePropertyBaseSchema2,
|
|
3258
|
+
type: literal("files"),
|
|
3259
|
+
files: array(bridgeFilePropertyItemSchema)
|
|
3260
|
+
});
|
|
3261
|
+
var bridgeFilesPropertyReadValueSchema2 = object({
|
|
3262
|
+
...pagePropertyBaseSchema2,
|
|
3263
|
+
type: literal("files"),
|
|
3264
|
+
files: array(bridgeFilePropertyReadItemSchema)
|
|
3265
|
+
});
|
|
3266
|
+
|
|
2715
3267
|
// ../protocol/src/compatibility/protocol12/page.ts
|
|
3268
|
+
var bridgePagePropertyForProtocol12Schema = variant("type", [
|
|
3269
|
+
...commonPagePropertySchemas2,
|
|
3270
|
+
textUniqueIdPropertySchema,
|
|
3271
|
+
textVerificationPropertySchema,
|
|
3272
|
+
bridgeFilesPropertyWriteValueSchema2
|
|
3273
|
+
]);
|
|
2716
3274
|
var bridgePageForProtocol12Schema = object({
|
|
2717
3275
|
...bridgePageSchema.entries,
|
|
3276
|
+
parent: parentThroughProtocol13Schema,
|
|
2718
3277
|
properties: record(
|
|
2719
3278
|
string(),
|
|
2720
|
-
nullable(
|
|
3279
|
+
nullable(bridgePagePropertyForProtocol12Schema)
|
|
2721
3280
|
)
|
|
2722
3281
|
});
|
|
2723
3282
|
|
|
@@ -2725,8 +3284,8 @@ var bridgePageForProtocol12Schema = object({
|
|
|
2725
3284
|
var bridgePageForProtocol3To5Schema = object({
|
|
2726
3285
|
object: literal("page"),
|
|
2727
3286
|
id: notionPageIdSchema,
|
|
2728
|
-
parent:
|
|
2729
|
-
properties:
|
|
3287
|
+
parent: parentThroughProtocol13Schema,
|
|
3288
|
+
properties: record(string(), bridgePagePropertyForProtocol12Schema),
|
|
2730
3289
|
created_time: optional(string()),
|
|
2731
3290
|
last_edited_time: optional(string()),
|
|
2732
3291
|
icon: optional(bridgePageIconSchema),
|
|
@@ -2739,12 +3298,53 @@ var bridgePageForProtocol3To5Schema = object({
|
|
|
2739
3298
|
in_trash: boolean()
|
|
2740
3299
|
});
|
|
2741
3300
|
|
|
3301
|
+
// ../protocol/src/compatibility/protocol3To5/dateValue.ts
|
|
3302
|
+
var dateOrDisabledReminder = optional(
|
|
3303
|
+
union([notionDateReminderSchema, notionDisabledReminderSchema])
|
|
3304
|
+
);
|
|
3305
|
+
var dateTimeOrDisabledReminder = optional(
|
|
3306
|
+
union([notionDateTimeReminderSchema, notionDisabledReminderSchema])
|
|
3307
|
+
);
|
|
3308
|
+
var protocol3To5DateSchema = object({
|
|
3309
|
+
type: literal("date"),
|
|
3310
|
+
start_date: string(),
|
|
3311
|
+
reminder: dateOrDisabledReminder
|
|
3312
|
+
});
|
|
3313
|
+
var protocol3To5DateRangeSchema = object({
|
|
3314
|
+
type: literal("daterange"),
|
|
3315
|
+
start_date: string(),
|
|
3316
|
+
end_date: string(),
|
|
3317
|
+
reminder: dateOrDisabledReminder
|
|
3318
|
+
});
|
|
3319
|
+
var protocol3To5DateTimeSchema = object({
|
|
3320
|
+
type: literal("datetime"),
|
|
3321
|
+
start_date: string(),
|
|
3322
|
+
start_time: string(),
|
|
3323
|
+
time_zone: optional(string()),
|
|
3324
|
+
reminder: dateTimeOrDisabledReminder
|
|
3325
|
+
});
|
|
3326
|
+
var protocol3To5DateTimeRangeSchema = object({
|
|
3327
|
+
type: literal("datetimerange"),
|
|
3328
|
+
start_date: string(),
|
|
3329
|
+
start_time: string(),
|
|
3330
|
+
end_date: string(),
|
|
3331
|
+
end_time: string(),
|
|
3332
|
+
time_zone: optional(string()),
|
|
3333
|
+
reminder: dateTimeOrDisabledReminder
|
|
3334
|
+
});
|
|
3335
|
+
var protocol3To5DateValueSchema = variant("type", [
|
|
3336
|
+
protocol3To5DateSchema,
|
|
3337
|
+
protocol3To5DateRangeSchema,
|
|
3338
|
+
protocol3To5DateTimeSchema,
|
|
3339
|
+
protocol3To5DateTimeRangeSchema
|
|
3340
|
+
]);
|
|
3341
|
+
|
|
2742
3342
|
// ../protocol/src/compatibility/protocol3To5/dataSourceValue.ts
|
|
2743
3343
|
var notionDataSourceValueSchema = union([
|
|
2744
3344
|
string(),
|
|
2745
3345
|
number(),
|
|
2746
3346
|
boolean(),
|
|
2747
|
-
|
|
3347
|
+
protocol3To5DateValueSchema,
|
|
2748
3348
|
array(string()),
|
|
2749
3349
|
array(notionRecordPointerSchema)
|
|
2750
3350
|
]);
|
|
@@ -2842,29 +3442,172 @@ var dataSourcesChangedMessageSchema = object({
|
|
|
2842
3442
|
})
|
|
2843
3443
|
});
|
|
2844
3444
|
|
|
2845
|
-
// ../protocol/src/compatibility/protocol3To11/hostToSandbox.ts
|
|
2846
|
-
var protocol3To11HostToSandboxMessageSchema = variant("type", [
|
|
2847
|
-
protocol3To11InitMessageSchema,
|
|
2848
|
-
themeChangedMessageSchema,
|
|
2849
|
-
contrastModeChangedMessageSchema,
|
|
2850
|
-
|
|
2851
|
-
protocol3To11PageChangedMessageSchema,
|
|
2852
|
-
currentUserChangedForProtocol3To11Schema,
|
|
2853
|
-
dataSourcesChangedMessageSchema,
|
|
2854
|
-
getUserResultForProtocol3To11Schema,
|
|
2855
|
-
listUsersResultForProtocol3To11Schema,
|
|
2856
|
-
openPageResultMessageSchema,
|
|
2857
|
-
openExternalUrlResultMessageSchema,
|
|
2858
|
-
invalidSandboxMessageSchema,
|
|
2859
|
-
queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema,
|
|
2860
|
-
getPageResultMessageWithProtocol3To5CompatibilitySchema,
|
|
2861
|
-
createPageResultMessageWithProtocol3To5CompatibilitySchema,
|
|
2862
|
-
updatePageResultMessageWithProtocol3To5CompatibilitySchema
|
|
3445
|
+
// ../protocol/src/compatibility/protocol3To11/hostToSandbox.ts
|
|
3446
|
+
var protocol3To11HostToSandboxMessageSchema = variant("type", [
|
|
3447
|
+
protocol3To11InitMessageSchema,
|
|
3448
|
+
themeChangedMessageSchema,
|
|
3449
|
+
contrastModeChangedMessageSchema,
|
|
3450
|
+
parentChangedThroughProtocol13Schema,
|
|
3451
|
+
protocol3To11PageChangedMessageSchema,
|
|
3452
|
+
currentUserChangedForProtocol3To11Schema,
|
|
3453
|
+
dataSourcesChangedMessageSchema,
|
|
3454
|
+
getUserResultForProtocol3To11Schema,
|
|
3455
|
+
listUsersResultForProtocol3To11Schema,
|
|
3456
|
+
openPageResultMessageSchema,
|
|
3457
|
+
openExternalUrlResultMessageSchema,
|
|
3458
|
+
invalidSandboxMessageSchema,
|
|
3459
|
+
queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema,
|
|
3460
|
+
getPageResultMessageWithProtocol3To5CompatibilitySchema,
|
|
3461
|
+
createPageResultMessageWithProtocol3To5CompatibilitySchema,
|
|
3462
|
+
updatePageResultMessageWithProtocol3To5CompatibilitySchema
|
|
3463
|
+
]);
|
|
3464
|
+
|
|
3465
|
+
// ../protocol/src/dataSources/messages/getDataSource.ts
|
|
3466
|
+
var getDataSourceMessageSchema = object({
|
|
3467
|
+
type: literal("getDataSource"),
|
|
3468
|
+
requestId: string(),
|
|
3469
|
+
key: string()
|
|
3470
|
+
});
|
|
3471
|
+
var getDataSourceResultMessageSchema = variant("status", [
|
|
3472
|
+
object({
|
|
3473
|
+
type: literal("getDataSourceResult"),
|
|
3474
|
+
requestId: string(),
|
|
3475
|
+
status: literal("success"),
|
|
3476
|
+
binding: required(
|
|
3477
|
+
omit(bridgeDataSourceBindingSchema, ["inaccessible"])
|
|
3478
|
+
)
|
|
3479
|
+
}),
|
|
3480
|
+
object({
|
|
3481
|
+
type: literal("getDataSourceResult"),
|
|
3482
|
+
requestId: string(),
|
|
3483
|
+
status: literal("error"),
|
|
3484
|
+
error: customBlockErrorInfoSchema
|
|
3485
|
+
})
|
|
3486
|
+
]);
|
|
3487
|
+
var dataSourcesInvalidatedMessageSchema = object({
|
|
3488
|
+
type: literal("dataSourcesInvalidated")
|
|
3489
|
+
});
|
|
3490
|
+
|
|
3491
|
+
// ../protocol/src/compatibility/protocol13/propertyTypes.ts
|
|
3492
|
+
var SUPPORTED_PROTOCOL_13_PROPERTY_TYPES = /* @__PURE__ */ new Set([
|
|
3493
|
+
"title",
|
|
3494
|
+
"rich_text",
|
|
3495
|
+
"number",
|
|
3496
|
+
"checkbox",
|
|
3497
|
+
"url",
|
|
3498
|
+
"email",
|
|
3499
|
+
"phone_number",
|
|
3500
|
+
"select",
|
|
3501
|
+
"multi_select",
|
|
3502
|
+
"status",
|
|
3503
|
+
"date",
|
|
3504
|
+
"people",
|
|
3505
|
+
"files",
|
|
3506
|
+
"unique_id",
|
|
3507
|
+
"relation",
|
|
3508
|
+
"place",
|
|
3509
|
+
"formula",
|
|
3510
|
+
"rollup",
|
|
3511
|
+
"button",
|
|
3512
|
+
"verification",
|
|
3513
|
+
"created_time",
|
|
3514
|
+
"last_edited_time",
|
|
3515
|
+
"created_by",
|
|
3516
|
+
"last_edited_by"
|
|
3517
|
+
]);
|
|
3518
|
+
function supportsPropertyTypeThroughProtocol13(type) {
|
|
3519
|
+
return SUPPORTED_PROTOCOL_13_PROPERTY_TYPES.has(type);
|
|
3520
|
+
}
|
|
3521
|
+
|
|
3522
|
+
// ../protocol/src/compatibility/hostToSandboxWithPageSchema.ts
|
|
3523
|
+
var dataSourceSchemaThroughProtocol13 = makeNotionDataSourceSchemaValidator(
|
|
3524
|
+
pipe(
|
|
3525
|
+
knownBridgePropertySchema,
|
|
3526
|
+
check((property) => supportsPropertyTypeThroughProtocol13(property.type))
|
|
3527
|
+
)
|
|
3528
|
+
);
|
|
3529
|
+
var getDataSourceResultThroughProtocol13 = variant("status", [
|
|
3530
|
+
object({
|
|
3531
|
+
...getDataSourceResultMessageSchema.options[0].entries,
|
|
3532
|
+
binding: required(
|
|
3533
|
+
omit(
|
|
3534
|
+
object({
|
|
3535
|
+
...bridgeDataSourceBindingSchema.entries,
|
|
3536
|
+
dataSourceSchema: optional(dataSourceSchemaThroughProtocol13)
|
|
3537
|
+
}),
|
|
3538
|
+
["inaccessible"]
|
|
3539
|
+
),
|
|
3540
|
+
["dataSourcePointer", "dataSourceSchema", "propertyIdsByKey"]
|
|
3541
|
+
)
|
|
3542
|
+
}),
|
|
3543
|
+
getDataSourceResultMessageSchema.options[1]
|
|
3544
|
+
]);
|
|
3545
|
+
function makeHostToSandboxMessageWithPageSchema(pageSchema) {
|
|
3546
|
+
return variant("type", [
|
|
3547
|
+
...commonHostToSandboxSchemas,
|
|
3548
|
+
openPageResultMessageSchema,
|
|
3549
|
+
parentChangedThroughProtocol13Schema,
|
|
3550
|
+
pageChangedThroughProtocol13Schema,
|
|
3551
|
+
dataSourcesInvalidatedMessageSchema,
|
|
3552
|
+
getDataSourceResultThroughProtocol13,
|
|
3553
|
+
variant("status", [
|
|
3554
|
+
object({
|
|
3555
|
+
...queryDataSourceResultMessageSchema.options[0].entries,
|
|
3556
|
+
items: array(pageSchema)
|
|
3557
|
+
}),
|
|
3558
|
+
queryDataSourceResultMessageSchema.options[1]
|
|
3559
|
+
]),
|
|
3560
|
+
variant("status", [
|
|
3561
|
+
object({
|
|
3562
|
+
...getPageResultMessageSchema.options[0].entries,
|
|
3563
|
+
page: pageSchema
|
|
3564
|
+
}),
|
|
3565
|
+
getPageResultMessageSchema.options[1]
|
|
3566
|
+
]),
|
|
3567
|
+
variant("status", [
|
|
3568
|
+
object({
|
|
3569
|
+
...createPageResultMessageSchema.options[0].entries,
|
|
3570
|
+
page: pageSchema
|
|
3571
|
+
}),
|
|
3572
|
+
createPageResultMessageSchema.options[1]
|
|
3573
|
+
]),
|
|
3574
|
+
variant("status", [
|
|
3575
|
+
object({
|
|
3576
|
+
...updatePageResultMessageSchema.options[0].entries,
|
|
3577
|
+
page: pageSchema
|
|
3578
|
+
}),
|
|
3579
|
+
updatePageResultMessageSchema.options[1]
|
|
3580
|
+
])
|
|
3581
|
+
]);
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3584
|
+
// ../protocol/src/compatibility/protocol12/hostToSandbox.ts
|
|
3585
|
+
var hostToSandboxMessageForProtocol12Schema = makeHostToSandboxMessageWithPageSchema(bridgePageForProtocol12Schema);
|
|
3586
|
+
|
|
3587
|
+
// ../protocol/src/compatibility/protocol13/page.ts
|
|
3588
|
+
var bridgePagePropertyForProtocol13Schema = variant("type", [
|
|
3589
|
+
...commonPagePropertySchemas2,
|
|
3590
|
+
textUniqueIdPropertySchema,
|
|
3591
|
+
textVerificationPropertySchema,
|
|
3592
|
+
bridgeFilesPropertyReadValueSchema2
|
|
2863
3593
|
]);
|
|
3594
|
+
var bridgePageForProtocol13Schema = object({
|
|
3595
|
+
...bridgePageSchema.entries,
|
|
3596
|
+
parent: parentThroughProtocol13Schema,
|
|
3597
|
+
properties: record(
|
|
3598
|
+
string(),
|
|
3599
|
+
nullable(bridgePagePropertyForProtocol13Schema)
|
|
3600
|
+
)
|
|
3601
|
+
});
|
|
3602
|
+
|
|
3603
|
+
// ../protocol/src/compatibility/protocol13/hostToSandbox.ts
|
|
3604
|
+
var hostToSandboxMessageForProtocol13Schema = makeHostToSandboxMessageWithPageSchema(bridgePageForProtocol13Schema);
|
|
2864
3605
|
|
|
2865
3606
|
// ../protocol/src/compatibility/hostToSandbox.ts
|
|
2866
3607
|
var hostToSandboxMessageWithCompatibilitySchema = union([
|
|
2867
3608
|
hostToSandboxMessageSchema,
|
|
3609
|
+
hostToSandboxMessageForProtocol13Schema,
|
|
3610
|
+
hostToSandboxMessageForProtocol12Schema,
|
|
2868
3611
|
protocol3To11HostToSandboxMessageSchema
|
|
2869
3612
|
]);
|
|
2870
3613
|
|
|
@@ -2873,7 +3616,7 @@ var bridgeDataSourceBindingsForProtocol3To10Schema = record(
|
|
|
2873
3616
|
string(),
|
|
2874
3617
|
object({
|
|
2875
3618
|
collectionPointer: optional(dataSourcePointerValidator),
|
|
2876
|
-
collectionSchema: optional(
|
|
3619
|
+
collectionSchema: optional(bridgeDataSourceSchemaValidator),
|
|
2877
3620
|
propertyIdsByKey: optional(record(string(), optional(string()))),
|
|
2878
3621
|
inaccessible: optional(literal(true))
|
|
2879
3622
|
})
|
|
@@ -2940,11 +3683,15 @@ var protocol3To11SandboxToHostMessageSchema = variant("type", [
|
|
|
2940
3683
|
]);
|
|
2941
3684
|
|
|
2942
3685
|
// ../protocol/src/compatibility/protocol11/hostToSandbox.ts
|
|
3686
|
+
var pageWithHistoricalParentSchema = object({
|
|
3687
|
+
...bridgePageSchema.entries,
|
|
3688
|
+
parent: parentThroughProtocol13Schema
|
|
3689
|
+
});
|
|
2943
3690
|
var protocol11HostToSandboxMessageSchema = variant("type", [
|
|
2944
3691
|
protocol3To11InitMessageSchema,
|
|
2945
3692
|
themeChangedMessageSchema,
|
|
2946
3693
|
contrastModeChangedMessageSchema,
|
|
2947
|
-
|
|
3694
|
+
parentChangedThroughProtocol13Schema,
|
|
2948
3695
|
protocol3To11PageChangedMessageSchema,
|
|
2949
3696
|
currentUserChangedForProtocol3To11Schema,
|
|
2950
3697
|
dataSourcesChangedMessageSchema,
|
|
@@ -2953,12 +3700,47 @@ var protocol11HostToSandboxMessageSchema = variant("type", [
|
|
|
2953
3700
|
openPageResultMessageSchema,
|
|
2954
3701
|
openExternalUrlResultMessageSchema,
|
|
2955
3702
|
invalidSandboxMessageSchema,
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
3703
|
+
variant("status", [
|
|
3704
|
+
object({
|
|
3705
|
+
...queryDataSourceResultMessageSchema.options[0].entries,
|
|
3706
|
+
items: array(pageWithHistoricalParentSchema)
|
|
3707
|
+
}),
|
|
3708
|
+
queryDataSourceResultMessageSchema.options[1]
|
|
3709
|
+
]),
|
|
3710
|
+
variant("status", [
|
|
3711
|
+
object({
|
|
3712
|
+
...createPageResultMessageSchema.options[0].entries,
|
|
3713
|
+
page: pageWithHistoricalParentSchema
|
|
3714
|
+
}),
|
|
3715
|
+
createPageResultMessageSchema.options[1]
|
|
3716
|
+
]),
|
|
3717
|
+
variant("status", [
|
|
3718
|
+
object({
|
|
3719
|
+
...getPageResultMessageSchema.options[0].entries,
|
|
3720
|
+
page: pageWithHistoricalParentSchema
|
|
3721
|
+
}),
|
|
3722
|
+
getPageResultMessageSchema.options[1]
|
|
3723
|
+
]),
|
|
3724
|
+
variant("status", [
|
|
3725
|
+
object({
|
|
3726
|
+
...updatePageResultMessageSchema.options[0].entries,
|
|
3727
|
+
page: pageWithHistoricalParentSchema
|
|
3728
|
+
}),
|
|
3729
|
+
updatePageResultMessageSchema.options[1]
|
|
3730
|
+
])
|
|
2960
3731
|
]);
|
|
2961
3732
|
|
|
3733
|
+
// ../protocol/src/dataSources/messages/keyedQueryDataSource.ts
|
|
3734
|
+
var keyedQueryDataSourceMessageSchema = strictObject({
|
|
3735
|
+
type: literal("queryDataSource"),
|
|
3736
|
+
key: string(),
|
|
3737
|
+
subscriptionId: string(),
|
|
3738
|
+
limit: optional(number()),
|
|
3739
|
+
filter: optional(unknown()),
|
|
3740
|
+
sorts: optional(unknown()),
|
|
3741
|
+
archiveStatus: optional(picklist(["active", "archived", "all"]))
|
|
3742
|
+
});
|
|
3743
|
+
|
|
2962
3744
|
// ../protocol/src/handshake/ready.ts
|
|
2963
3745
|
var readyMessageSchema = object({
|
|
2964
3746
|
type: literal("ready"),
|
|
@@ -2968,6 +3750,26 @@ var readyMessageSchema = object({
|
|
|
2968
3750
|
|
|
2969
3751
|
// ../protocol/src/messages/sandboxToHost.ts
|
|
2970
3752
|
var sandboxToHostMessageSchema = variant("type", [
|
|
3753
|
+
connectRequestMessageSchema,
|
|
3754
|
+
getCurrentUserMessageSchema,
|
|
3755
|
+
getViewerMessageSchema,
|
|
3756
|
+
initResultRequestMessageSchema,
|
|
3757
|
+
readyMessageSchema,
|
|
3758
|
+
keyedQueryDataSourceMessageSchema,
|
|
3759
|
+
unsubscribeDataSourceQueryMessageSchema,
|
|
3760
|
+
keyedCreatePageMessageSchema,
|
|
3761
|
+
keyedGetPageMessageSchema,
|
|
3762
|
+
getUserMessageSchema,
|
|
3763
|
+
listUsersMessageSchema,
|
|
3764
|
+
addressedOpenPageMessageSchema,
|
|
3765
|
+
openExternalUrlMessageSchema,
|
|
3766
|
+
keyedUpdatePageMessageSchema,
|
|
3767
|
+
resizeMessageSchema,
|
|
3768
|
+
invalidHostMessageSchema
|
|
3769
|
+
]);
|
|
3770
|
+
|
|
3771
|
+
// ../protocol/src/compatibility/protocol13/sandboxToHost.ts
|
|
3772
|
+
var protocol13SandboxToHostMessageSchema = variant("type", [
|
|
2971
3773
|
connectRequestMessageSchema,
|
|
2972
3774
|
getDataSourceMessageSchema,
|
|
2973
3775
|
getCurrentUserMessageSchema,
|
|
@@ -2990,6 +3792,7 @@ var sandboxToHostMessageSchema = variant("type", [
|
|
|
2990
3792
|
// ../protocol/src/compatibility/sandboxToHost.ts
|
|
2991
3793
|
var sandboxToHostMessageWithCompatibilitySchema = union([
|
|
2992
3794
|
sandboxToHostMessageSchema,
|
|
3795
|
+
protocol13SandboxToHostMessageSchema,
|
|
2993
3796
|
protocol3To11SandboxToHostMessageSchema
|
|
2994
3797
|
]);
|
|
2995
3798
|
|
|
@@ -3006,7 +3809,7 @@ var notionDataSourceSchema = object({
|
|
|
3006
3809
|
* schema to validate filter and sort references. Undefined when the host does not provide a
|
|
3007
3810
|
* database schema.
|
|
3008
3811
|
*/
|
|
3009
|
-
dataSourceSchema: optional(
|
|
3812
|
+
dataSourceSchema: optional(bridgeDataSourceSchemaValidator),
|
|
3010
3813
|
/**
|
|
3011
3814
|
* Maps user-defined property keys to database property IDs. Use this map to resolve a key
|
|
3012
3815
|
* such as `name` to its database property ID. A value of `undefined` marks a declared
|
|
@@ -3024,7 +3827,7 @@ var notionDataSourceSchema = object({
|
|
|
3024
3827
|
* Use `propertiesById` to read a value. Use this map to read the value's schema. Use
|
|
3025
3828
|
* `dataSourceSchema` to validate filter and sort references.
|
|
3026
3829
|
*/
|
|
3027
|
-
propertySchemasById: record(string(),
|
|
3830
|
+
propertySchemasById: record(string(), bridgePropertySchema),
|
|
3028
3831
|
/**
|
|
3029
3832
|
* `true` when the data source is bound but the viewer can't read it. The block still
|
|
3030
3833
|
* initializes. Queries and writes that use this data source fail with
|
|
@@ -3033,121 +3836,45 @@ var notionDataSourceSchema = object({
|
|
|
3033
3836
|
inaccessible: optional(literal(true))
|
|
3034
3837
|
});
|
|
3035
3838
|
|
|
3036
|
-
// ../protocol/src/
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
var bindingValueSchemas = {
|
|
3054
|
-
title: stringValue,
|
|
3055
|
-
rich_text: stringValue,
|
|
3056
|
-
url: stringValue,
|
|
3057
|
-
email: stringValue,
|
|
3058
|
-
phone_number: stringValue,
|
|
3059
|
-
select: stringValue,
|
|
3060
|
-
status: stringValue,
|
|
3061
|
-
number: numberValue,
|
|
3062
|
-
checkbox: booleanValue,
|
|
3063
|
-
multi_select: stringArrayValue,
|
|
3064
|
-
date: notionDateValueSchema,
|
|
3065
|
-
created_time: notionDateValueSchema,
|
|
3066
|
-
last_edited_time: notionDateValueSchema,
|
|
3067
|
-
people: pointerArrayValue,
|
|
3068
|
-
relation: pointerArrayValue,
|
|
3069
|
-
files: stringValue
|
|
3070
|
-
};
|
|
3071
|
-
var convertedValueSchemas = {
|
|
3072
|
-
...bindingValueSchemas,
|
|
3073
|
-
created_by: pointerArrayValue,
|
|
3074
|
-
last_edited_by: pointerArrayValue,
|
|
3075
|
-
unique_id: stringValue,
|
|
3076
|
-
formula: stringValue,
|
|
3077
|
-
rollup: stringValue,
|
|
3078
|
-
verification: stringValue,
|
|
3079
|
-
place: stringValue
|
|
3080
|
-
};
|
|
3081
|
-
function matchesConvertedPropertyType(value, type) {
|
|
3082
|
-
const schema = is(notionPropertyTypeSchema, type) ? convertedValueSchemas[type] : void 0;
|
|
3083
|
-
return is(schema ?? anyLocalValue, value);
|
|
3084
|
-
}
|
|
3085
|
-
function isConvertedDataSourceValue(value) {
|
|
3086
|
-
return is(anyLocalValue, value);
|
|
3087
|
-
}
|
|
3088
|
-
|
|
3089
|
-
// cli/diagnostics/formatUnknownError.ts
|
|
3090
|
-
function formatUnknownError(error) {
|
|
3091
|
-
return error instanceof Error ? error.message : String(error);
|
|
3092
|
-
}
|
|
3093
|
-
|
|
3094
|
-
// cli/utils/claimUniqueKey.ts
|
|
3095
|
-
function claimUniqueKey(base, used) {
|
|
3096
|
-
let key = base;
|
|
3097
|
-
for (let counter = 2; used.has(key); counter++) {
|
|
3098
|
-
key = `${base}_${counter}`;
|
|
3839
|
+
// ../protocol/src/dataSources/resolveDataSourceBinding.ts
|
|
3840
|
+
function resolveDataSourceBinding(args) {
|
|
3841
|
+
const properties = Object.entries(
|
|
3842
|
+
args.manifestDataSource.properties ?? {}
|
|
3843
|
+
).map(([propertyKey, property]) => {
|
|
3844
|
+
const propertyId = args.propertyIdsByKey !== void 0 && Object.hasOwn(args.propertyIdsByKey, propertyKey) ? args.propertyIdsByKey[propertyKey] : void 0;
|
|
3845
|
+
const propertiesById = args.dataSourceSchema?.propertiesById;
|
|
3846
|
+
const mappedSchema = propertyId === void 0 || propertiesById === void 0 || !Object.hasOwn(propertiesById, propertyId) ? void 0 : propertiesById[propertyId];
|
|
3847
|
+
return resolvePropertyBinding(
|
|
3848
|
+
propertyKey,
|
|
3849
|
+
propertyId,
|
|
3850
|
+
mappedSchema?.type,
|
|
3851
|
+
property.type
|
|
3852
|
+
);
|
|
3853
|
+
});
|
|
3854
|
+
if (args.dataSourceSchema === void 0) {
|
|
3855
|
+
return { status: "missing_schema", properties };
|
|
3099
3856
|
}
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
}
|
|
3103
|
-
|
|
3104
|
-
// cli/utils/parseCliArgs.ts
|
|
3105
|
-
function parseCliArgs({
|
|
3106
|
-
argv,
|
|
3107
|
-
handlers,
|
|
3108
|
-
flags = {},
|
|
3109
|
-
onUnknown,
|
|
3110
|
-
onPositional
|
|
3111
|
-
}) {
|
|
3112
|
-
const takeValue = (name, index) => {
|
|
3113
|
-
const value = argv[index];
|
|
3114
|
-
if (value === void 0 || value.startsWith("--")) {
|
|
3115
|
-
throw new Error(`${name} requires a value.`);
|
|
3116
|
-
}
|
|
3117
|
-
return value;
|
|
3118
|
-
};
|
|
3119
|
-
for (let index = 0; index < argv.length; index++) {
|
|
3120
|
-
const arg = argv[index];
|
|
3121
|
-
const flag = flags[arg];
|
|
3122
|
-
if (flag !== void 0) {
|
|
3123
|
-
flag();
|
|
3124
|
-
continue;
|
|
3125
|
-
}
|
|
3126
|
-
const separator = arg.indexOf("=");
|
|
3127
|
-
const name = separator === -1 ? arg : arg.slice(0, separator);
|
|
3128
|
-
const handler = handlers[name];
|
|
3129
|
-
if (handler === void 0) {
|
|
3130
|
-
if (arg.startsWith("-")) {
|
|
3131
|
-
onUnknown(arg);
|
|
3132
|
-
} else {
|
|
3133
|
-
onPositional(arg);
|
|
3134
|
-
}
|
|
3135
|
-
continue;
|
|
3136
|
-
}
|
|
3137
|
-
const value = separator === -1 ? takeValue(name, ++index) : arg.slice(separator + 1);
|
|
3138
|
-
handler(value);
|
|
3857
|
+
if (properties.every((property) => property.status === "mapped")) {
|
|
3858
|
+
return { status: "complete", properties };
|
|
3139
3859
|
}
|
|
3860
|
+
return { status: "incomplete", properties };
|
|
3140
3861
|
}
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3862
|
+
function resolvePropertyBinding(propertyKey, propertyId, actualType, expectedType) {
|
|
3863
|
+
if (propertyId === void 0) {
|
|
3864
|
+
return { status: "missing", propertyKey, propertyId };
|
|
3865
|
+
}
|
|
3866
|
+
if (actualType === void 0) {
|
|
3867
|
+
return { status: "invalid", propertyKey, propertyId };
|
|
3868
|
+
}
|
|
3869
|
+
return {
|
|
3870
|
+
status: actualType === expectedType ? "mapped" : "incompatible",
|
|
3871
|
+
propertyKey,
|
|
3872
|
+
propertyId
|
|
3873
|
+
};
|
|
3146
3874
|
}
|
|
3147
3875
|
|
|
3148
|
-
//
|
|
3149
|
-
|
|
3150
|
-
import { basename, resolve } from "node:path";
|
|
3876
|
+
// ../protocol/src/utils/readRequestId.ts
|
|
3877
|
+
var requestIdentitySchema = object({ requestId: string() });
|
|
3151
3878
|
|
|
3152
3879
|
// ../node_modules/.pnpm/temporal-polyfill@1.0.6/node_modules/temporal-polyfill/chunks/root.js
|
|
3153
3880
|
var NativeTemporal = globalThis.Temporal;
|
|
@@ -6886,42 +7613,70 @@ var Temporal = /* @__PURE__ */ Object.defineProperties({}, {
|
|
|
6886
7613
|
var Temporal2 = NativeTemporal || Temporal;
|
|
6887
7614
|
var toTemporalInstant2 = NativeTemporal ? Date.prototype.toTemporalInstant : toTemporalInstant;
|
|
6888
7615
|
|
|
6889
|
-
// shared/dataSources/
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
7616
|
+
// shared/dataSources/sampleDate.ts
|
|
7617
|
+
var sampleDateSchema = pipe(
|
|
7618
|
+
strictObject({
|
|
7619
|
+
start: string(),
|
|
7620
|
+
end: optional(nullable(string())),
|
|
7621
|
+
timeZone: optional(nullable(string())),
|
|
7622
|
+
reminder: optional(
|
|
7623
|
+
union([notionDateTimeReminderSchema, notionDisabledReminderSchema])
|
|
7624
|
+
)
|
|
7625
|
+
}),
|
|
7626
|
+
check(
|
|
7627
|
+
({ start, reminder }) => start.includes("T") || reminder?.unit !== "hour" && reminder?.unit !== "minute",
|
|
7628
|
+
"Reminders on all-day dates must include a time of day."
|
|
7629
|
+
)
|
|
7630
|
+
);
|
|
7631
|
+
function readSampleDate(value) {
|
|
7632
|
+
if (typeof value !== "string") {
|
|
7633
|
+
const result = safeParse(sampleDateSchema, value);
|
|
7634
|
+
return result.success ? result.output : void 0;
|
|
6893
7635
|
}
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
return {
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
}
|
|
7636
|
+
try {
|
|
7637
|
+
parseDateBoundary({ value, timeZone: void 0 });
|
|
7638
|
+
return { start: value };
|
|
7639
|
+
} catch (error) {
|
|
7640
|
+
if (error instanceof RangeError) {
|
|
7641
|
+
return void 0;
|
|
7642
|
+
}
|
|
7643
|
+
throw error;
|
|
6901
7644
|
}
|
|
6902
|
-
return { start, reminder: value.reminder };
|
|
6903
7645
|
}
|
|
6904
|
-
function
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
const time = useEnd && value.type === "datetimerange" ? value.end_time : value.start_time;
|
|
6913
|
-
return parseDateBoundary({
|
|
6914
|
-
value: `${date}T${time}`,
|
|
6915
|
-
timeZone: value.time_zone
|
|
6916
|
-
});
|
|
7646
|
+
function toBridgeDate({
|
|
7647
|
+
start,
|
|
7648
|
+
end,
|
|
7649
|
+
timeZone,
|
|
7650
|
+
...rest
|
|
7651
|
+
}) {
|
|
7652
|
+
if (timeZone != null) {
|
|
7653
|
+
validateTimeZone(timeZone);
|
|
6917
7654
|
}
|
|
6918
|
-
return
|
|
7655
|
+
return {
|
|
7656
|
+
...rest,
|
|
7657
|
+
start: parseDateBoundary({
|
|
7658
|
+
value: start,
|
|
7659
|
+
timeZone: timeZone ?? void 0
|
|
7660
|
+
}).toString(),
|
|
7661
|
+
...end === void 0 ? {} : {
|
|
7662
|
+
end: end === null ? null : parseDateBoundary({
|
|
7663
|
+
value: end,
|
|
7664
|
+
timeZone: timeZone ?? void 0
|
|
7665
|
+
}).toString()
|
|
7666
|
+
},
|
|
7667
|
+
...timeZone === void 0 ? {} : { time_zone: timeZone }
|
|
7668
|
+
};
|
|
6919
7669
|
}
|
|
6920
7670
|
function parseDateBoundary({
|
|
6921
7671
|
value,
|
|
6922
7672
|
timeZone
|
|
6923
7673
|
}) {
|
|
6924
7674
|
if (!value.includes("T")) {
|
|
7675
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
7676
|
+
throw new RangeError(
|
|
7677
|
+
"Date values must use YYYY-MM-DD or an ISO timestamp."
|
|
7678
|
+
);
|
|
7679
|
+
}
|
|
6925
7680
|
return Temporal2.PlainDate.from(value);
|
|
6926
7681
|
}
|
|
6927
7682
|
if (/(?:Z|[+-]\d{2}:?\d{2})$/i.test(value)) {
|
|
@@ -6935,19 +7690,152 @@ function parseDateBoundary({
|
|
|
6935
7690
|
if (!zonedTime.toPlainDateTime().equals(localTime)) {
|
|
6936
7691
|
throw new RangeError(`Local time "${value}" does not exist in "${zone}".`);
|
|
6937
7692
|
}
|
|
6938
|
-
return zonedTime.toInstant();
|
|
7693
|
+
return zonedTime.toInstant();
|
|
7694
|
+
}
|
|
7695
|
+
function validateTimeZone(timeZone) {
|
|
7696
|
+
try {
|
|
7697
|
+
Temporal2.Instant.fromEpochMilliseconds(0).toZonedDateTimeISO(timeZone);
|
|
7698
|
+
} catch (cause) {
|
|
7699
|
+
if (!(cause instanceof RangeError)) {
|
|
7700
|
+
throw cause;
|
|
7701
|
+
}
|
|
7702
|
+
throw new RangeError(`invalid time zone "${timeZone}"`, { cause });
|
|
7703
|
+
}
|
|
7704
|
+
}
|
|
7705
|
+
|
|
7706
|
+
// shared/dataSources/localPropertyValues.ts
|
|
7707
|
+
var stringValue = string();
|
|
7708
|
+
var numberValue = pipe(number(), finite());
|
|
7709
|
+
var booleanValue = boolean();
|
|
7710
|
+
var stringArrayValue = array(string());
|
|
7711
|
+
var pointerArrayValue = array(notionRecordPointerSchema);
|
|
7712
|
+
var filesValue = array(
|
|
7713
|
+
custom((value) => parseSampleFileItem(value) !== void 0)
|
|
7714
|
+
);
|
|
7715
|
+
var sampleDataSourceValueSchema = union([
|
|
7716
|
+
stringValue,
|
|
7717
|
+
numberValue,
|
|
7718
|
+
booleanValue,
|
|
7719
|
+
sampleDateSchema,
|
|
7720
|
+
stringArrayValue,
|
|
7721
|
+
pointerArrayValue,
|
|
7722
|
+
filesValue
|
|
7723
|
+
]);
|
|
7724
|
+
var bindingValueSchemas = {
|
|
7725
|
+
title: stringValue,
|
|
7726
|
+
rich_text: stringValue,
|
|
7727
|
+
url: stringValue,
|
|
7728
|
+
email: stringValue,
|
|
7729
|
+
phone_number: stringValue,
|
|
7730
|
+
select: stringValue,
|
|
7731
|
+
status: stringValue,
|
|
7732
|
+
number: numberValue,
|
|
7733
|
+
checkbox: booleanValue,
|
|
7734
|
+
multi_select: stringArrayValue,
|
|
7735
|
+
date: sampleDateSchema,
|
|
7736
|
+
created_time: sampleDateSchema,
|
|
7737
|
+
last_edited_time: sampleDateSchema,
|
|
7738
|
+
people: pointerArrayValue,
|
|
7739
|
+
relation: pointerArrayValue,
|
|
7740
|
+
files: union([stringValue, filesValue])
|
|
7741
|
+
};
|
|
7742
|
+
var convertedValueSchemas = {
|
|
7743
|
+
...bindingValueSchemas,
|
|
7744
|
+
created_by: pointerArrayValue,
|
|
7745
|
+
last_edited_by: pointerArrayValue,
|
|
7746
|
+
unique_id: stringValue,
|
|
7747
|
+
formula: stringValue,
|
|
7748
|
+
rollup: stringValue,
|
|
7749
|
+
verification: stringValue,
|
|
7750
|
+
place: stringValue
|
|
7751
|
+
};
|
|
7752
|
+
function matchesBindingPropertyType(value, type) {
|
|
7753
|
+
if (type === "date" || type === "created_time" || type === "last_edited_time") {
|
|
7754
|
+
return readSampleDate(value) !== void 0;
|
|
7755
|
+
}
|
|
7756
|
+
if (type === "created_by" || type === "last_edited_by") {
|
|
7757
|
+
return Array.isArray(value) ? value.every((item) => parseSampleMetadataActor(item) !== void 0) : typeof value === "string" || parseSampleMetadataActor(value) !== void 0;
|
|
7758
|
+
}
|
|
7759
|
+
return is(bindingValueSchemas[type] ?? sampleDataSourceValueSchema, value);
|
|
7760
|
+
}
|
|
7761
|
+
function matchesConvertedPropertyType(value, type) {
|
|
7762
|
+
const schema = is(notionPropertyTypeSchema, type) ? convertedValueSchemas[type] : void 0;
|
|
7763
|
+
return is(schema ?? sampleDataSourceValueSchema, value);
|
|
7764
|
+
}
|
|
7765
|
+
function isSampleDataSourceValue(value) {
|
|
7766
|
+
return is(sampleDataSourceValueSchema, value);
|
|
7767
|
+
}
|
|
7768
|
+
function parseSampleFileItem(value) {
|
|
7769
|
+
const parsed = safeParse(bridgeFilePropertyReadItemSchema, value);
|
|
7770
|
+
return parsed.success && parsed.output.type !== "file" ? parsed.output : void 0;
|
|
7771
|
+
}
|
|
7772
|
+
function parseSampleMetadataActor(value) {
|
|
7773
|
+
return is(bridgePageSchema.entries.created_by, value) && value !== void 0 && value !== null && (value.table === "notion_user" || value.table === "bot" || value.table === "organization_bot") ? value : void 0;
|
|
7774
|
+
}
|
|
7775
|
+
|
|
7776
|
+
// cli/diagnostics/formatUnknownError.ts
|
|
7777
|
+
function formatUnknownError(error) {
|
|
7778
|
+
return error instanceof Error ? error.message : String(error);
|
|
7779
|
+
}
|
|
7780
|
+
|
|
7781
|
+
// cli/utils/claimUniqueKey.ts
|
|
7782
|
+
function claimUniqueKey(base, used) {
|
|
7783
|
+
let key = base;
|
|
7784
|
+
for (let counter = 2; used.has(key); counter++) {
|
|
7785
|
+
key = `${base}_${counter}`;
|
|
7786
|
+
}
|
|
7787
|
+
used.add(key);
|
|
7788
|
+
return key;
|
|
6939
7789
|
}
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
7790
|
+
|
|
7791
|
+
// cli/utils/parseCliArgs.ts
|
|
7792
|
+
function parseCliArgs({
|
|
7793
|
+
argv: argv2,
|
|
7794
|
+
handlers,
|
|
7795
|
+
flags = {},
|
|
7796
|
+
onUnknown,
|
|
7797
|
+
onPositional
|
|
7798
|
+
}) {
|
|
7799
|
+
const takeValue = (name, index) => {
|
|
7800
|
+
const value = argv2[index];
|
|
7801
|
+
if (value === void 0 || value.startsWith("--")) {
|
|
7802
|
+
throw new Error(`${name} requires a value.`);
|
|
6946
7803
|
}
|
|
6947
|
-
|
|
7804
|
+
return value;
|
|
7805
|
+
};
|
|
7806
|
+
for (let index = 0; index < argv2.length; index++) {
|
|
7807
|
+
const arg = argv2[index];
|
|
7808
|
+
const flag = flags[arg];
|
|
7809
|
+
if (flag !== void 0) {
|
|
7810
|
+
flag();
|
|
7811
|
+
continue;
|
|
7812
|
+
}
|
|
7813
|
+
const separator = arg.indexOf("=");
|
|
7814
|
+
const name = separator === -1 ? arg : arg.slice(0, separator);
|
|
7815
|
+
const handler = handlers[name];
|
|
7816
|
+
if (handler === void 0) {
|
|
7817
|
+
if (arg.startsWith("-")) {
|
|
7818
|
+
onUnknown(arg);
|
|
7819
|
+
} else {
|
|
7820
|
+
onPositional(arg);
|
|
7821
|
+
}
|
|
7822
|
+
continue;
|
|
7823
|
+
}
|
|
7824
|
+
const value = separator === -1 ? takeValue(name, ++index) : arg.slice(separator + 1);
|
|
7825
|
+
handler(value);
|
|
6948
7826
|
}
|
|
6949
7827
|
}
|
|
6950
7828
|
|
|
7829
|
+
// cli/utils/slugify.ts
|
|
7830
|
+
function slugify(name) {
|
|
7831
|
+
const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
7832
|
+
return slug.length > 0 ? slug : void 0;
|
|
7833
|
+
}
|
|
7834
|
+
|
|
7835
|
+
// cli/dataSources/readSampleDataSources.ts
|
|
7836
|
+
import { readFileSync } from "node:fs";
|
|
7837
|
+
import { basename, resolve } from "node:path";
|
|
7838
|
+
|
|
6951
7839
|
// shared/dataSources/sampleDataSource.ts
|
|
6952
7840
|
var sampleDataSourceTypeSchema = picklist([
|
|
6953
7841
|
"built-in",
|
|
@@ -6958,7 +7846,7 @@ var sampleDataSourceTypeSchema = picklist([
|
|
|
6958
7846
|
var sampleDataSourceRowSchema = looseObject({ id: string() });
|
|
6959
7847
|
var sampleDataSourcePropertiesSchema = record(
|
|
6960
7848
|
string(),
|
|
6961
|
-
|
|
7849
|
+
knownBridgePropertySchema
|
|
6962
7850
|
);
|
|
6963
7851
|
var loadedSampleDataSourceSchema = object({
|
|
6964
7852
|
status: literal("loaded"),
|
|
@@ -6992,35 +7880,6 @@ function selectSampleDataSource({
|
|
|
6992
7880
|
return sources.find((source) => source.filename === `worker_${slotKey}`) ?? sources.find((source) => source.filename === slotKey);
|
|
6993
7881
|
}
|
|
6994
7882
|
|
|
6995
|
-
// shared/dataSources/toDataSourceDateValue.ts
|
|
6996
|
-
function toDataSourceDateValue(value) {
|
|
6997
|
-
if (is(notionDateValueSchema, value)) {
|
|
6998
|
-
return value;
|
|
6999
|
-
}
|
|
7000
|
-
if (typeof value !== "string") {
|
|
7001
|
-
return void 0;
|
|
7002
|
-
}
|
|
7003
|
-
try {
|
|
7004
|
-
const [date, time] = value.split("T");
|
|
7005
|
-
const { start } = toNotionDateInput({
|
|
7006
|
-
type: "datetime",
|
|
7007
|
-
start_date: date,
|
|
7008
|
-
start_time: time ?? "00:00:00Z"
|
|
7009
|
-
});
|
|
7010
|
-
return {
|
|
7011
|
-
type: "datetime",
|
|
7012
|
-
start_date: start.slice(0, 10),
|
|
7013
|
-
start_time: start.slice(11),
|
|
7014
|
-
time_zone: "UTC"
|
|
7015
|
-
};
|
|
7016
|
-
} catch (error) {
|
|
7017
|
-
if (error instanceof RangeError) {
|
|
7018
|
-
return void 0;
|
|
7019
|
-
}
|
|
7020
|
-
throw error;
|
|
7021
|
-
}
|
|
7022
|
-
}
|
|
7023
|
-
|
|
7024
7883
|
// cli/dataSources/listDataSourceFiles.ts
|
|
7025
7884
|
import { existsSync, readdirSync } from "node:fs";
|
|
7026
7885
|
function listDataSourceFiles(dataDir) {
|
|
@@ -7109,7 +7968,7 @@ var statusGroupsSchema = array(
|
|
|
7109
7968
|
option_ids: array(nonEmptyString)
|
|
7110
7969
|
})
|
|
7111
7970
|
);
|
|
7112
|
-
var
|
|
7971
|
+
var sourcePropertySchema2 = object({
|
|
7113
7972
|
name: optional(string()),
|
|
7114
7973
|
description: optional(string()),
|
|
7115
7974
|
type: notionPropertyTypeSchema,
|
|
@@ -7120,7 +7979,7 @@ var sourceFileSchema = object({
|
|
|
7120
7979
|
type: optional(sampleDataSourceTypeSchema, "worker"),
|
|
7121
7980
|
name: optional(nonEmptyString),
|
|
7122
7981
|
icon: optional(string()),
|
|
7123
|
-
schema: optional(record(string(),
|
|
7982
|
+
schema: optional(record(string(), sourcePropertySchema2), {}),
|
|
7124
7983
|
rows: optional(array(looseObject({ id: nonEmptyString })), [])
|
|
7125
7984
|
});
|
|
7126
7985
|
function readDataSource(file) {
|
|
@@ -7169,7 +8028,7 @@ function readDataSource(file) {
|
|
|
7169
8028
|
schema: Object.fromEntries(
|
|
7170
8029
|
Object.entries(schema).map(([propertyKey, property]) => [
|
|
7171
8030
|
propertyKey,
|
|
7172
|
-
|
|
8031
|
+
toBridgePropertySchema(propertyKey, property)
|
|
7173
8032
|
])
|
|
7174
8033
|
),
|
|
7175
8034
|
rows
|
|
@@ -7188,11 +8047,11 @@ function validateDateValues(file, source) {
|
|
|
7188
8047
|
continue;
|
|
7189
8048
|
}
|
|
7190
8049
|
try {
|
|
7191
|
-
const date =
|
|
8050
|
+
const date = readSampleDate(value);
|
|
7192
8051
|
if (date === void 0) {
|
|
7193
8052
|
throw new Error("Expected a date value or ISO timestamp.");
|
|
7194
8053
|
}
|
|
7195
|
-
|
|
8054
|
+
toBridgeDate(date);
|
|
7196
8055
|
} catch (cause) {
|
|
7197
8056
|
throw new Error(
|
|
7198
8057
|
`${file}: row "${row.id}", property "${propertyId}": ${formatUnknownError(cause)}`,
|
|
@@ -7202,8 +8061,8 @@ function validateDateValues(file, source) {
|
|
|
7202
8061
|
}
|
|
7203
8062
|
}
|
|
7204
8063
|
}
|
|
7205
|
-
function
|
|
7206
|
-
return parse(
|
|
8064
|
+
function toBridgePropertySchema(propertyKey, property) {
|
|
8065
|
+
return parse(knownBridgePropertySchema, {
|
|
7207
8066
|
...property,
|
|
7208
8067
|
name: property.name ?? propertyKey,
|
|
7209
8068
|
options: property.options ?? [],
|
|
@@ -7252,7 +8111,7 @@ function convertPublicApiPropertyValue(publicType, value) {
|
|
|
7252
8111
|
table: "notion_user"
|
|
7253
8112
|
}));
|
|
7254
8113
|
case "files":
|
|
7255
|
-
return
|
|
8114
|
+
return Array.isArray(payload) ? payload.flatMap(toSampleFile) : void 0;
|
|
7256
8115
|
case "relation":
|
|
7257
8116
|
return payload.map((target) => ({
|
|
7258
8117
|
id: target.id,
|
|
@@ -7269,7 +8128,7 @@ function convertPublicApiPropertyValue(publicType, value) {
|
|
|
7269
8128
|
return rollupToText(payload);
|
|
7270
8129
|
case "created_time":
|
|
7271
8130
|
case "last_edited_time":
|
|
7272
|
-
return
|
|
8131
|
+
return { start: payload };
|
|
7273
8132
|
case "created_by":
|
|
7274
8133
|
case "last_edited_by":
|
|
7275
8134
|
return [{ id: payload.id, table: "notion_user" }];
|
|
@@ -7283,8 +8142,20 @@ function convertPublicApiPropertyValue(publicType, value) {
|
|
|
7283
8142
|
return unreachable(publicType);
|
|
7284
8143
|
}
|
|
7285
8144
|
}
|
|
7286
|
-
function
|
|
7287
|
-
|
|
8145
|
+
function toSampleFile(value) {
|
|
8146
|
+
if (typeof value !== "object" || value === null) {
|
|
8147
|
+
return [];
|
|
8148
|
+
}
|
|
8149
|
+
const file = parseSampleFileItem(value);
|
|
8150
|
+
if (file?.type === "external") {
|
|
8151
|
+
return [file];
|
|
8152
|
+
}
|
|
8153
|
+
return [
|
|
8154
|
+
{
|
|
8155
|
+
type: "unavailable",
|
|
8156
|
+
..."name" in value && typeof value.name === "string" ? { name: value.name } : {}
|
|
8157
|
+
}
|
|
8158
|
+
];
|
|
7288
8159
|
}
|
|
7289
8160
|
function formulaToText(formula) {
|
|
7290
8161
|
switch (formula.type) {
|
|
@@ -7315,46 +8186,18 @@ function rollupToText(rollup) {
|
|
|
7315
8186
|
function dateToText(date) {
|
|
7316
8187
|
return date.end ? `${date.start} \u2192 ${date.end}` : date.start;
|
|
7317
8188
|
}
|
|
7318
|
-
function publicDateToLocal(
|
|
7319
|
-
const start = date.start;
|
|
7320
|
-
const end = date.end ?? void 0;
|
|
7321
|
-
const timeZone = date.time_zone ?? void 0;
|
|
7322
|
-
if (!start.includes("T")) {
|
|
7323
|
-
return end === void 0 ? { type: "date", start_date: start.slice(0, 10) } : {
|
|
7324
|
-
type: "daterange",
|
|
7325
|
-
start_date: start.slice(0, 10),
|
|
7326
|
-
end_date: end.slice(0, 10)
|
|
7327
|
-
};
|
|
7328
|
-
}
|
|
7329
|
-
if (end === void 0) {
|
|
7330
|
-
return {
|
|
7331
|
-
type: "datetime",
|
|
7332
|
-
start_date: start.slice(0, 10),
|
|
7333
|
-
start_time: start.slice(11, 16),
|
|
7334
|
-
...timeZone !== void 0 ? { time_zone: timeZone } : {}
|
|
7335
|
-
};
|
|
7336
|
-
}
|
|
8189
|
+
function publicDateToLocal({ start, end, time_zone }) {
|
|
7337
8190
|
return {
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
end_date: end.slice(0, 10),
|
|
7342
|
-
end_time: end.slice(11, 16),
|
|
7343
|
-
...timeZone !== void 0 ? { time_zone: timeZone } : {}
|
|
8191
|
+
start,
|
|
8192
|
+
...end == null ? {} : { end },
|
|
8193
|
+
...time_zone == null ? {} : { timeZone: time_zone }
|
|
7344
8194
|
};
|
|
7345
8195
|
}
|
|
7346
|
-
function timestampToLocal(timestamp) {
|
|
7347
|
-
return timestamp.includes("T") ? {
|
|
7348
|
-
type: "datetime",
|
|
7349
|
-
start_date: timestamp.slice(0, 10),
|
|
7350
|
-
start_time: timestamp.slice(11, 16)
|
|
7351
|
-
} : { type: "date", start_date: timestamp.slice(0, 10) };
|
|
7352
|
-
}
|
|
7353
8196
|
|
|
7354
8197
|
// cli/dataSources/conversion/runConvert.ts
|
|
7355
8198
|
var SUPPORTED_TYPES = new Set(NOTION_PROPERTY_TYPES);
|
|
7356
8199
|
var UNSUPPORTED_TYPE_FALLBACK = "rich_text";
|
|
7357
|
-
function parseConvertArgs(
|
|
8200
|
+
function parseConvertArgs(argv2) {
|
|
7358
8201
|
const args = {
|
|
7359
8202
|
input: void 0,
|
|
7360
8203
|
name: void 0
|
|
@@ -7365,7 +8208,7 @@ function parseConvertArgs(argv) {
|
|
|
7365
8208
|
);
|
|
7366
8209
|
};
|
|
7367
8210
|
parseCliArgs({
|
|
7368
|
-
argv,
|
|
8211
|
+
argv: argv2,
|
|
7369
8212
|
handlers: {
|
|
7370
8213
|
"--in": (value) => {
|
|
7371
8214
|
args.input = value;
|
|
@@ -7509,7 +8352,7 @@ function validateSource(source) {
|
|
|
7509
8352
|
);
|
|
7510
8353
|
continue;
|
|
7511
8354
|
}
|
|
7512
|
-
const matches = declared ? matchesConvertedPropertyType(value, declared.type) :
|
|
8355
|
+
const matches = declared ? matchesConvertedPropertyType(value, declared.type) : isSampleDataSourceValue(value);
|
|
7513
8356
|
if (!matches) {
|
|
7514
8357
|
issues.push(
|
|
7515
8358
|
`row ${JSON.stringify(row.id)}: ${JSON.stringify(key)} does not match ${declared ? `type ${JSON.stringify(declared.type)}` : "any supported value shape"}`
|
|
@@ -7521,8 +8364,8 @@ function validateSource(source) {
|
|
|
7521
8364
|
throw new Error(`Converted rows are invalid: ${issues.join("; ")}`);
|
|
7522
8365
|
}
|
|
7523
8366
|
}
|
|
7524
|
-
async function runConvert(
|
|
7525
|
-
const args = parseConvertArgs(
|
|
8367
|
+
async function runConvert(argv2) {
|
|
8368
|
+
const args = parseConvertArgs(argv2);
|
|
7526
8369
|
let raw;
|
|
7527
8370
|
if (args.input !== void 0) {
|
|
7528
8371
|
try {
|
|
@@ -7559,8 +8402,9 @@ async function runConvert(argv) {
|
|
|
7559
8402
|
// cli/bindings/errors.ts
|
|
7560
8403
|
var DevShellLauncherBindingError = class extends Error {
|
|
7561
8404
|
code;
|
|
7562
|
-
constructor(
|
|
7563
|
-
|
|
8405
|
+
constructor(args) {
|
|
8406
|
+
const { code, message } = args;
|
|
8407
|
+
super(message);
|
|
7564
8408
|
this.name = "DevShellLauncherBindingError";
|
|
7565
8409
|
this.code = code;
|
|
7566
8410
|
}
|
|
@@ -7568,14 +8412,14 @@ var DevShellLauncherBindingError = class extends Error {
|
|
|
7568
8412
|
function bindingFailure(code, message) {
|
|
7569
8413
|
return {
|
|
7570
8414
|
status: "error",
|
|
7571
|
-
error: new DevShellLauncherBindingError(code, message)
|
|
8415
|
+
error: new DevShellLauncherBindingError({ code, message })
|
|
7572
8416
|
};
|
|
7573
8417
|
}
|
|
7574
8418
|
|
|
7575
8419
|
// cli/diagnostics/formatUnknownErrorWithStack.ts
|
|
7576
8420
|
function formatUnknownErrorWithStack(error) {
|
|
7577
8421
|
if (error instanceof DevShellLauncherBindingError) {
|
|
7578
|
-
return error.message
|
|
8422
|
+
return `${error.message} (error code: ${error.code})`;
|
|
7579
8423
|
}
|
|
7580
8424
|
return error instanceof Error ? error.stack ?? error.message : String(error);
|
|
7581
8425
|
}
|
|
@@ -7585,23 +8429,63 @@ import { spawn } from "node:child_process";
|
|
|
7585
8429
|
import { readFileSync as readFileSync3, writeSync } from "node:fs";
|
|
7586
8430
|
import { join } from "node:path";
|
|
7587
8431
|
import { Readable } from "node:stream";
|
|
8432
|
+
|
|
8433
|
+
// cli/diagnostics/DevShellStartupError.ts
|
|
8434
|
+
var DevShellStartupError = class extends Error {
|
|
8435
|
+
code;
|
|
8436
|
+
constructor(args) {
|
|
8437
|
+
const { code, message, options } = args;
|
|
8438
|
+
super(message, options);
|
|
8439
|
+
this.name = "DevShellStartupError";
|
|
8440
|
+
this.code = code;
|
|
8441
|
+
}
|
|
8442
|
+
};
|
|
8443
|
+
|
|
8444
|
+
// cli/diagnostics/startupOutput.ts
|
|
7588
8445
|
var STARTUP_PIPE_ENV = "DEV_SHELL_STARTUP_PIPE";
|
|
7589
|
-
|
|
7590
|
-
|
|
8446
|
+
async function runWithStartupOutput(args) {
|
|
8447
|
+
const { main: main2 } = args;
|
|
7591
8448
|
if (process.env[STARTUP_PIPE_ENV] === "3") {
|
|
7592
8449
|
delete process.env[STARTUP_PIPE_ENV];
|
|
7593
|
-
|
|
7594
|
-
|
|
8450
|
+
const writeStartupEvent = createStartupWriter({ outputFd: 3 });
|
|
8451
|
+
try {
|
|
8452
|
+
await main2({ writeStartupEvent });
|
|
8453
|
+
} catch (error) {
|
|
8454
|
+
writeStartupFailure({ writeStartupEvent, error });
|
|
8455
|
+
throw error;
|
|
8456
|
+
}
|
|
7595
8457
|
return;
|
|
7596
8458
|
}
|
|
7597
|
-
const
|
|
7598
|
-
if (!
|
|
7599
|
-
await main2();
|
|
8459
|
+
const argv2 = process.argv.slice(2);
|
|
8460
|
+
if (!argv2.includes("--json")) {
|
|
8461
|
+
await main2({});
|
|
7600
8462
|
return;
|
|
7601
8463
|
}
|
|
8464
|
+
await relayStartupOutput({ argv: argv2 });
|
|
8465
|
+
}
|
|
8466
|
+
function writeStartupFailure(args) {
|
|
8467
|
+
const { writeStartupEvent, error } = args;
|
|
8468
|
+
writeStartupEvent?.({
|
|
8469
|
+
event: "startup_failed",
|
|
8470
|
+
version: 1,
|
|
8471
|
+
error: {
|
|
8472
|
+
code: error instanceof DevShellLauncherBindingError || error instanceof DevShellStartupError ? error.code : "startup_error",
|
|
8473
|
+
message: formatUnknownError(error)
|
|
8474
|
+
}
|
|
8475
|
+
});
|
|
8476
|
+
}
|
|
8477
|
+
function readDevShellVersion(args) {
|
|
8478
|
+
const { packageDir } = args;
|
|
8479
|
+
const metadata = JSON.parse(
|
|
8480
|
+
readFileSync3(join(packageDir, "package.json"), "utf8")
|
|
8481
|
+
);
|
|
8482
|
+
return parse(object({ version: string() }), metadata).version;
|
|
8483
|
+
}
|
|
8484
|
+
async function relayStartupOutput(args) {
|
|
8485
|
+
const { argv: argv2 } = args;
|
|
7602
8486
|
const child = spawn(
|
|
7603
8487
|
process.execPath,
|
|
7604
|
-
[...process.execArgv, process.argv[1], ...
|
|
8488
|
+
[...process.execArgv, process.argv[1], ...argv2],
|
|
7605
8489
|
{
|
|
7606
8490
|
env: { ...process.env, [STARTUP_PIPE_ENV]: "3" },
|
|
7607
8491
|
stdio: ["inherit", 2, 2, "pipe"]
|
|
@@ -7652,28 +8536,23 @@ async function runWithStartupOutput(main2) {
|
|
|
7652
8536
|
}
|
|
7653
8537
|
}
|
|
7654
8538
|
}
|
|
7655
|
-
function
|
|
7656
|
-
|
|
7657
|
-
return void 0;
|
|
7658
|
-
}
|
|
7659
|
-
const outputFd = startupPipe;
|
|
7660
|
-
const writeStdout = outputFd === void 0 ? process.stdout.write.bind(process.stdout) : (text) => writeSync(outputFd, text);
|
|
8539
|
+
function createStartupWriter(args) {
|
|
8540
|
+
const { outputFd } = args;
|
|
7661
8541
|
process.stdout.write = process.stderr.write.bind(process.stderr);
|
|
8542
|
+
let written = false;
|
|
7662
8543
|
return (event) => {
|
|
7663
|
-
|
|
8544
|
+
if (written) {
|
|
8545
|
+
return;
|
|
8546
|
+
}
|
|
8547
|
+
written = true;
|
|
8548
|
+
writeSync(outputFd, `${JSON.stringify(event)}
|
|
7664
8549
|
`);
|
|
7665
8550
|
};
|
|
7666
8551
|
}
|
|
7667
|
-
function readDevShellVersion(packageDir) {
|
|
7668
|
-
const metadata = JSON.parse(
|
|
7669
|
-
readFileSync3(join(packageDir, "package.json"), "utf8")
|
|
7670
|
-
);
|
|
7671
|
-
return parse(object({ version: string() }), metadata).version;
|
|
7672
|
-
}
|
|
7673
8552
|
|
|
7674
8553
|
// cli/launchDevShell.ts
|
|
7675
8554
|
import { existsSync as existsSync8, mkdirSync as mkdirSync6, mkdtempSync, rmSync } from "node:fs";
|
|
7676
|
-
import { basename as basename3, join as join3, resolve as resolve7 } from "node:path";
|
|
8555
|
+
import { basename as basename3, join as join3, relative as relative2, resolve as resolve7, sep } from "node:path";
|
|
7677
8556
|
|
|
7678
8557
|
// shared/dataSources/sampleDataSourceUpdates.ts
|
|
7679
8558
|
var sampleDataSourcesSnapshotSchema = object({
|
|
@@ -7684,6 +8563,349 @@ function getLoadedDataSources(snapshot) {
|
|
|
7684
8563
|
return snapshot.dataSources.filter((source) => source.status === "loaded").sort((a, b) => a.name.localeCompare(b.name));
|
|
7685
8564
|
}
|
|
7686
8565
|
|
|
8566
|
+
// shared/dataSources/getSampleDataRowIssues.ts
|
|
8567
|
+
function getSampleDataRowIssues(args) {
|
|
8568
|
+
const { source, mappings } = args;
|
|
8569
|
+
const issues = [];
|
|
8570
|
+
const typeCheckedIds = /* @__PURE__ */ new Set();
|
|
8571
|
+
const checkedPairs = /* @__PURE__ */ new Set();
|
|
8572
|
+
for (const { propertyId, expectedType } of mappings) {
|
|
8573
|
+
typeCheckedIds.add(propertyId);
|
|
8574
|
+
const pair = `${propertyId}\0${expectedType}`;
|
|
8575
|
+
if (checkedPairs.has(pair)) {
|
|
8576
|
+
continue;
|
|
8577
|
+
}
|
|
8578
|
+
checkedPairs.add(pair);
|
|
8579
|
+
const rowIds = source.rows.filter((row) => Object.hasOwn(row, propertyId)).filter((row) => !matchesBindingPropertyType(row[propertyId], expectedType)).map((row) => row.id);
|
|
8580
|
+
if (rowIds.length > 0) {
|
|
8581
|
+
issues.push({
|
|
8582
|
+
type: "invalid_property_value",
|
|
8583
|
+
propertyId,
|
|
8584
|
+
expectedType,
|
|
8585
|
+
rowIds
|
|
8586
|
+
});
|
|
8587
|
+
}
|
|
8588
|
+
}
|
|
8589
|
+
return issues.concat(getUnmappedRowIssues({ source, typeCheckedIds }));
|
|
8590
|
+
}
|
|
8591
|
+
function getUnmappedRowIssues(args) {
|
|
8592
|
+
const { source, typeCheckedIds } = args;
|
|
8593
|
+
const issues = [];
|
|
8594
|
+
for (const row of source.rows) {
|
|
8595
|
+
for (const [propertyId, value] of Object.entries(row)) {
|
|
8596
|
+
if (propertyId === "id" || typeCheckedIds.has(propertyId)) {
|
|
8597
|
+
continue;
|
|
8598
|
+
}
|
|
8599
|
+
const type = source.schema[propertyId]?.type;
|
|
8600
|
+
const isSupported = type === "files" || type === "created_by" || type === "last_edited_by" ? matchesBindingPropertyType(value, type) : isSampleDataSourceValue(value);
|
|
8601
|
+
if (!isSupported) {
|
|
8602
|
+
issues.push({
|
|
8603
|
+
type: "unsupported_property_value",
|
|
8604
|
+
propertyId,
|
|
8605
|
+
rowIds: [row.id]
|
|
8606
|
+
});
|
|
8607
|
+
}
|
|
8608
|
+
}
|
|
8609
|
+
}
|
|
8610
|
+
return issues;
|
|
8611
|
+
}
|
|
8612
|
+
|
|
8613
|
+
// ../host/src/bindings.ts
|
|
8614
|
+
var customBlockHostBindingsSchema = object({
|
|
8615
|
+
pages: record(string(), object({ pageId: notionPageIdSchema })),
|
|
8616
|
+
dataSources: record(
|
|
8617
|
+
string(),
|
|
8618
|
+
object({
|
|
8619
|
+
dataSourceId: notionDataSourceIdSchema,
|
|
8620
|
+
propertyIdsByKey: record(string(), optional(string()))
|
|
8621
|
+
})
|
|
8622
|
+
)
|
|
8623
|
+
});
|
|
8624
|
+
var hostDataSourceSchemaValidator = makeNotionDataSourceSchemaValidator(
|
|
8625
|
+
union([knownBridgePropertySchema, bridgeUnknownPropertySchema])
|
|
8626
|
+
);
|
|
8627
|
+
var customBlockHostDataSourceStateSchema = variant("status", [
|
|
8628
|
+
object({ status: literal("unavailable") }),
|
|
8629
|
+
object({
|
|
8630
|
+
status: literal("available"),
|
|
8631
|
+
dataSource: object({
|
|
8632
|
+
dataSourceSchema: hostDataSourceSchemaValidator,
|
|
8633
|
+
title: fallback(optional(string()), void 0),
|
|
8634
|
+
description: fallback(optional(string()), void 0),
|
|
8635
|
+
icon: fallback(optional(bridgePageIconSchema), void 0),
|
|
8636
|
+
capabilities: object({
|
|
8637
|
+
read: boolean(),
|
|
8638
|
+
create: boolean(),
|
|
8639
|
+
update: boolean(),
|
|
8640
|
+
archive: boolean()
|
|
8641
|
+
})
|
|
8642
|
+
})
|
|
8643
|
+
})
|
|
8644
|
+
]);
|
|
8645
|
+
|
|
8646
|
+
// ../host/src/compatibility/protocol3To11/handleInvalidProtocol3To11Handshake.ts
|
|
8647
|
+
var initializationIdentitySchema = object({ initializationId: string() });
|
|
8648
|
+
var protocolVersionSchema = object({
|
|
8649
|
+
// Preserve `NaN` so protocols 3–11 admission reports `invalid_protocol_version`.
|
|
8650
|
+
bridgeProtocolVersion: union([number(), nan()])
|
|
8651
|
+
});
|
|
8652
|
+
|
|
8653
|
+
// ../protocol/src/utils/readSubscriptionId.ts
|
|
8654
|
+
var subscriptionIdentitySchema = object({ subscriptionId: string() });
|
|
8655
|
+
|
|
8656
|
+
// ../protocol/src/dataSources/filters/filterFields.ts
|
|
8657
|
+
var BRIDGE_TO_SDK_FILTER_KEYS = {
|
|
8658
|
+
rich_text: "richText",
|
|
8659
|
+
phone_number: "phoneNumber",
|
|
8660
|
+
multi_select: "multiSelect",
|
|
8661
|
+
created_time: "createdTime",
|
|
8662
|
+
last_edited_time: "lastEditedTime",
|
|
8663
|
+
created_by: "createdBy",
|
|
8664
|
+
last_edited_by: "lastEditedBy",
|
|
8665
|
+
does_not_equal: "doesNotEqual",
|
|
8666
|
+
does_not_contain: "doesNotContain",
|
|
8667
|
+
contains_all: "containsAll",
|
|
8668
|
+
starts_with: "startsWith",
|
|
8669
|
+
ends_with: "endsWith",
|
|
8670
|
+
greater_than: "greaterThan",
|
|
8671
|
+
less_than: "lessThan",
|
|
8672
|
+
greater_than_or_equal_to: "greaterThanOrEqualTo",
|
|
8673
|
+
less_than_or_equal_to: "lessThanOrEqualTo",
|
|
8674
|
+
is_empty: "isEmpty",
|
|
8675
|
+
is_not_empty: "isNotEmpty",
|
|
8676
|
+
group_equals: "groupEquals",
|
|
8677
|
+
group_does_not_equal: "groupDoesNotEqual",
|
|
8678
|
+
on_or_before: "onOrBefore",
|
|
8679
|
+
on_or_after: "onOrAfter",
|
|
8680
|
+
this_week: "thisWeek",
|
|
8681
|
+
past_week: "pastWeek",
|
|
8682
|
+
past_month: "pastMonth",
|
|
8683
|
+
past_year: "pastYear",
|
|
8684
|
+
next_week: "nextWeek",
|
|
8685
|
+
next_month: "nextMonth",
|
|
8686
|
+
next_year: "nextYear"
|
|
8687
|
+
};
|
|
8688
|
+
var BRIDGE_TO_SDK_FILTER_KEY_MAP = new Map(
|
|
8689
|
+
Object.entries(BRIDGE_TO_SDK_FILTER_KEYS)
|
|
8690
|
+
);
|
|
8691
|
+
var SDK_TO_BRIDGE_FILTER_KEY_MAP = new Map(
|
|
8692
|
+
Object.entries(BRIDGE_TO_SDK_FILTER_KEYS).map(([bridgeKey, sdkKey]) => [
|
|
8693
|
+
sdkKey,
|
|
8694
|
+
bridgeKey
|
|
8695
|
+
])
|
|
8696
|
+
);
|
|
8697
|
+
|
|
8698
|
+
// ../protocol/src/dataSources/queries/resolveSorts.ts
|
|
8699
|
+
var supportedDataSourceSortPropertyTypes = new Set(
|
|
8700
|
+
CUSTOM_BLOCK_DATA_SOURCE_SORTABLE_PROPERTY_TYPES
|
|
8701
|
+
);
|
|
8702
|
+
|
|
8703
|
+
// ../host/src/dataSources/validation/validateQueryDataSourceSorts.ts
|
|
8704
|
+
var supportedDataSourceSortPropertyTypes2 = new Set(
|
|
8705
|
+
CUSTOM_BLOCK_DATA_SOURCE_SORTABLE_PROPERTY_TYPES
|
|
8706
|
+
);
|
|
8707
|
+
|
|
8708
|
+
// ../host/src/manifest/types.ts
|
|
8709
|
+
var customBlockHostManifestResultSchema = variant("status", [
|
|
8710
|
+
object({ status: literal("success"), manifest: manifestSchema }),
|
|
8711
|
+
object({
|
|
8712
|
+
status: literal("error"),
|
|
8713
|
+
error: customBlockInitErrorInfoSchema
|
|
8714
|
+
})
|
|
8715
|
+
]);
|
|
8716
|
+
|
|
8717
|
+
// ../host/src/messages/invalidNativeIconColor.ts
|
|
8718
|
+
var nativeIconMutationSchema = object({
|
|
8719
|
+
type: picklist(["updatePage", "createPage"]),
|
|
8720
|
+
requestId: string(),
|
|
8721
|
+
icon: object({
|
|
8722
|
+
type: literal("icon"),
|
|
8723
|
+
icon: object({ color: unknown() })
|
|
8724
|
+
})
|
|
8725
|
+
});
|
|
8726
|
+
|
|
8727
|
+
// ../host/src/createCustomBlockHost.ts
|
|
8728
|
+
var initializedHostMessageSchema = union([
|
|
8729
|
+
openPageResultMessageSchema,
|
|
8730
|
+
pageChangedThroughProtocol13Schema,
|
|
8731
|
+
hostToSandboxMessageSchema,
|
|
8732
|
+
dataSourcesInvalidatedMessageSchema,
|
|
8733
|
+
getDataSourceResultMessageSchema
|
|
8734
|
+
]);
|
|
8735
|
+
|
|
8736
|
+
// ../host/src/dataSources/bindings/resolveAutoPropertyBinding.ts
|
|
8737
|
+
function resolveAutoPropertyBinding(args) {
|
|
8738
|
+
const { propertyKey, manifestProperty, propertySchemasById } = args;
|
|
8739
|
+
const normalizedManifestName = normalizePropertyDisplayName(
|
|
8740
|
+
manifestProperty.name
|
|
8741
|
+
);
|
|
8742
|
+
const compatibleIds = [];
|
|
8743
|
+
const incompatible = [];
|
|
8744
|
+
for (const [propertyId, schema] of Object.entries(propertySchemasById)) {
|
|
8745
|
+
if (propertyId !== propertyKey && normalizePropertyDisplayName(schema.name) !== normalizedManifestName) {
|
|
8746
|
+
continue;
|
|
8747
|
+
}
|
|
8748
|
+
if (schema.type === manifestProperty.type) {
|
|
8749
|
+
compatibleIds.push(propertyId);
|
|
8750
|
+
} else {
|
|
8751
|
+
incompatible.push({ propertyId, actualType: schema.type });
|
|
8752
|
+
}
|
|
8753
|
+
}
|
|
8754
|
+
if (compatibleIds.length === 1) {
|
|
8755
|
+
return { status: "matched", propertyId: compatibleIds[0] };
|
|
8756
|
+
}
|
|
8757
|
+
if (compatibleIds.length > 1) {
|
|
8758
|
+
return { status: "ambiguous_match", candidatePropertyIds: compatibleIds };
|
|
8759
|
+
}
|
|
8760
|
+
return incompatible.length > 0 ? { status: "type_mismatch", candidates: incompatible } : { status: "no_match" };
|
|
8761
|
+
}
|
|
8762
|
+
function normalizePropertyDisplayName(value) {
|
|
8763
|
+
return value.trim().toLowerCase();
|
|
8764
|
+
}
|
|
8765
|
+
|
|
8766
|
+
// shared/dataSources/resolveInitialDataSourceBinding.ts
|
|
8767
|
+
function resolveInitialDataSourceBinding(args) {
|
|
8768
|
+
const { slotKey, slot, sources, sampleFiles, propertyOverrides } = args;
|
|
8769
|
+
const explicitFilename = Object.hasOwn(sampleFiles, slotKey) ? sampleFiles[slotKey] : void 0;
|
|
8770
|
+
const source = selectSampleDataSource({ slotKey, sources, explicitFilename });
|
|
8771
|
+
if (source?.status !== "loaded") {
|
|
8772
|
+
return { source, explicitFilename, properties: [] };
|
|
8773
|
+
}
|
|
8774
|
+
const overrides = Object.hasOwn(propertyOverrides, slotKey) ? propertyOverrides[slotKey] : void 0;
|
|
8775
|
+
const { properties } = resolveDataSourceBinding({
|
|
8776
|
+
manifestDataSource: slot,
|
|
8777
|
+
dataSourceSchema: { propertiesById: source.schema },
|
|
8778
|
+
propertyIdsByKey: overrides
|
|
8779
|
+
});
|
|
8780
|
+
return {
|
|
8781
|
+
source,
|
|
8782
|
+
explicitFilename,
|
|
8783
|
+
properties: properties.map(({ propertyKey, propertyId, status }) => {
|
|
8784
|
+
const manifestProperty = slot.properties[propertyKey];
|
|
8785
|
+
const property = { propertyKey, expectedType: manifestProperty.type };
|
|
8786
|
+
if (overrides === void 0 || !Object.hasOwn(overrides, propertyKey)) {
|
|
8787
|
+
return resolveAutomaticProperty(
|
|
8788
|
+
property,
|
|
8789
|
+
manifestProperty,
|
|
8790
|
+
source.schema
|
|
8791
|
+
);
|
|
8792
|
+
}
|
|
8793
|
+
switch (status) {
|
|
8794
|
+
case "mapped":
|
|
8795
|
+
return { ...property, type: "mapped", propertyId };
|
|
8796
|
+
case "invalid":
|
|
8797
|
+
return {
|
|
8798
|
+
...property,
|
|
8799
|
+
type: "sample_key_not_found",
|
|
8800
|
+
sampleKey: propertyId
|
|
8801
|
+
};
|
|
8802
|
+
case "incompatible":
|
|
8803
|
+
return {
|
|
8804
|
+
...property,
|
|
8805
|
+
type: "property_type_mismatch",
|
|
8806
|
+
bindingMode: "explicit",
|
|
8807
|
+
sampleProperties: [
|
|
8808
|
+
{
|
|
8809
|
+
sampleKey: propertyId,
|
|
8810
|
+
actualType: source.schema[propertyId].type
|
|
8811
|
+
}
|
|
8812
|
+
]
|
|
8813
|
+
};
|
|
8814
|
+
case "missing":
|
|
8815
|
+
return { ...property, type: "property_binding_missing" };
|
|
8816
|
+
default:
|
|
8817
|
+
return unreachable(status);
|
|
8818
|
+
}
|
|
8819
|
+
})
|
|
8820
|
+
};
|
|
8821
|
+
}
|
|
8822
|
+
function resolveAutomaticProperty(property, manifestProperty, schema) {
|
|
8823
|
+
const result = resolveAutoPropertyBinding({
|
|
8824
|
+
propertyKey: property.propertyKey,
|
|
8825
|
+
manifestProperty,
|
|
8826
|
+
propertySchemasById: schema
|
|
8827
|
+
});
|
|
8828
|
+
switch (result.status) {
|
|
8829
|
+
case "matched":
|
|
8830
|
+
return { ...property, type: "mapped", propertyId: result.propertyId };
|
|
8831
|
+
case "no_match":
|
|
8832
|
+
return { ...property, type: "property_binding_missing" };
|
|
8833
|
+
case "ambiguous_match":
|
|
8834
|
+
return {
|
|
8835
|
+
...property,
|
|
8836
|
+
type: "ambiguous_property_binding",
|
|
8837
|
+
candidateSampleKeys: result.candidatePropertyIds
|
|
8838
|
+
};
|
|
8839
|
+
case "type_mismatch":
|
|
8840
|
+
return {
|
|
8841
|
+
...property,
|
|
8842
|
+
type: "property_type_mismatch",
|
|
8843
|
+
bindingMode: "automatic",
|
|
8844
|
+
sampleProperties: result.candidates.map(
|
|
8845
|
+
({ propertyId, actualType }) => ({
|
|
8846
|
+
sampleKey: propertyId,
|
|
8847
|
+
actualType
|
|
8848
|
+
})
|
|
8849
|
+
)
|
|
8850
|
+
};
|
|
8851
|
+
default:
|
|
8852
|
+
return unreachable(result);
|
|
8853
|
+
}
|
|
8854
|
+
}
|
|
8855
|
+
|
|
8856
|
+
// cli/bindings/describeStartupDataSourceBindings.ts
|
|
8857
|
+
function describeStartupDataSourceBindings(block, sources) {
|
|
8858
|
+
return Object.fromEntries(
|
|
8859
|
+
Object.entries(block.manifest.dataSources).map(([slotKey, slot]) => [
|
|
8860
|
+
slotKey,
|
|
8861
|
+
describeBinding(
|
|
8862
|
+
resolveInitialDataSourceBinding({
|
|
8863
|
+
slotKey,
|
|
8864
|
+
slot,
|
|
8865
|
+
sources,
|
|
8866
|
+
sampleFiles: block.sampleFilesByDataSource,
|
|
8867
|
+
propertyOverrides: block.propertyIdsByDataSource
|
|
8868
|
+
})
|
|
8869
|
+
)
|
|
8870
|
+
])
|
|
8871
|
+
);
|
|
8872
|
+
}
|
|
8873
|
+
function describeBinding(binding) {
|
|
8874
|
+
const { source, explicitFilename, properties } = binding;
|
|
8875
|
+
if (source === void 0) {
|
|
8876
|
+
return explicitFilename === void 0 ? { status: "data_source_binding_missing" } : {
|
|
8877
|
+
status: "data_source_load_failed",
|
|
8878
|
+
sampleFile: `data/${explicitFilename}`,
|
|
8879
|
+
message: "The selected sample file disappeared during startup."
|
|
8880
|
+
};
|
|
8881
|
+
}
|
|
8882
|
+
const sampleFile = `data/${source.filename}.json`;
|
|
8883
|
+
if (source.status === "failed") {
|
|
8884
|
+
return {
|
|
8885
|
+
status: "data_source_load_failed",
|
|
8886
|
+
sampleFile,
|
|
8887
|
+
message: source.message
|
|
8888
|
+
};
|
|
8889
|
+
}
|
|
8890
|
+
const mapped = properties.filter((property) => property.type === "mapped");
|
|
8891
|
+
const errors = getSampleDataRowIssues({ source, mappings: mapped });
|
|
8892
|
+
const report = {
|
|
8893
|
+
sampleFile,
|
|
8894
|
+
propertyIdsByKey: Object.fromEntries(
|
|
8895
|
+
mapped.map(({ propertyKey, propertyId }) => [propertyKey, propertyId])
|
|
8896
|
+
),
|
|
8897
|
+
...errors.length > 0 ? { errors } : {}
|
|
8898
|
+
};
|
|
8899
|
+
const [first, ...remaining] = properties.filter(
|
|
8900
|
+
(property) => property.type !== "mapped"
|
|
8901
|
+
);
|
|
8902
|
+
return first === void 0 ? { status: "complete", ...report } : {
|
|
8903
|
+
status: "incomplete_property_bindings",
|
|
8904
|
+
...report,
|
|
8905
|
+
propertyIssues: [first, ...remaining]
|
|
8906
|
+
};
|
|
8907
|
+
}
|
|
8908
|
+
|
|
7687
8909
|
// cli/bindings/parseDataSourceBindingOverride.ts
|
|
7688
8910
|
function parseDataSourceBindingOverride({
|
|
7689
8911
|
value
|
|
@@ -7693,10 +8915,10 @@ function parseDataSourceBindingOverride({
|
|
|
7693
8915
|
const filename = value.slice(separator + 1);
|
|
7694
8916
|
const dot = target.indexOf(".");
|
|
7695
8917
|
if (separator < 0 || dot <= 0 || dot === target.length - 1 || target !== target.trim() || filename !== filename.trim() || !filename.endsWith(".json") || filename === ".json" || /[\\/\0]/.test(filename)) {
|
|
7696
|
-
throw new DevShellLauncherBindingError(
|
|
7697
|
-
"
|
|
7698
|
-
"--bind requires <capabilityKey>.<dataSourceKey>=<sampleDataFileName.json>. Use a filename in data/."
|
|
7699
|
-
);
|
|
8918
|
+
throw new DevShellLauncherBindingError({
|
|
8919
|
+
code: "invalid_data_source_binding_syntax",
|
|
8920
|
+
message: "--bind-data-source requires <capabilityKey>.<dataSourceKey>=<sampleDataFileName.json>. Use a filename in data/."
|
|
8921
|
+
});
|
|
7700
8922
|
}
|
|
7701
8923
|
return { target, filename };
|
|
7702
8924
|
}
|
|
@@ -7710,10 +8932,10 @@ function parsePropertyBindingOverride({
|
|
|
7710
8932
|
const sourcePropertyKey = value.slice(separator + 1);
|
|
7711
8933
|
const parts = target.split(".");
|
|
7712
8934
|
if (separator < 0 || parts.length < 3 || parts.some((part) => part.length === 0) || target !== target.trim() || sourcePropertyKey.length === 0 || sourcePropertyKey !== sourcePropertyKey.trim()) {
|
|
7713
|
-
throw new DevShellLauncherBindingError(
|
|
7714
|
-
"invalid_property_binding_syntax",
|
|
7715
|
-
"--bind-property requires <capabilityKey>.<dataSourceKey>.<propertyKey>=<sourcePropertyKey>."
|
|
7716
|
-
);
|
|
8935
|
+
throw new DevShellLauncherBindingError({
|
|
8936
|
+
code: "invalid_property_binding_syntax",
|
|
8937
|
+
message: "--bind-property requires <capabilityKey>.<dataSourceKey>.<propertyKey>=<sourcePropertyKey>."
|
|
8938
|
+
});
|
|
7717
8939
|
}
|
|
7718
8940
|
return { target, sourcePropertyKey };
|
|
7719
8941
|
}
|
|
@@ -7795,14 +9017,14 @@ function resolveDataSourceBindingSlot({
|
|
|
7795
9017
|
const matches = dataSourceSlots.filter((slot2) => slot2.target === target);
|
|
7796
9018
|
if (matches.length !== 1) {
|
|
7797
9019
|
return bindingFailure(
|
|
7798
|
-
matches.length === 0 ? "
|
|
9020
|
+
matches.length === 0 ? "unknown_data_source_binding_target" : "ambiguous_data_source_binding_target",
|
|
7799
9021
|
`${matches.length === 0 ? "Unknown" : "Ambiguous"} binding target "${target}". Available targets: ${dataSourceSlots.map((slot2) => slot2.target).join(", ") || "(none)"}.`
|
|
7800
9022
|
);
|
|
7801
9023
|
}
|
|
7802
9024
|
if (explicitSlots.has(target)) {
|
|
7803
9025
|
return bindingFailure(
|
|
7804
|
-
"
|
|
7805
|
-
`Duplicate --bind target "${target}". Specify each target once.`
|
|
9026
|
+
"duplicate_data_source_binding_target",
|
|
9027
|
+
`Duplicate --bind-data-source target "${target}". Specify each target once.`
|
|
7806
9028
|
);
|
|
7807
9029
|
}
|
|
7808
9030
|
const slot = matches[0];
|
|
@@ -7845,8 +9067,8 @@ function resolvePropertyBindingSlot({
|
|
|
7845
9067
|
const { dataSourceResult } = slot;
|
|
7846
9068
|
if (dataSourceResult === void 0) {
|
|
7847
9069
|
return bindingFailure(
|
|
7848
|
-
"
|
|
7849
|
-
`Cannot bind ${target}: no sample data source selected. Use --bind ${slot.target}=<sampleDataFileName.json>.`
|
|
9070
|
+
"property_binding_source_missing",
|
|
9071
|
+
`Cannot bind ${target}: no sample data source selected. Use --bind-data-source ${slot.target}=<sampleDataFileName.json>.`
|
|
7850
9072
|
);
|
|
7851
9073
|
}
|
|
7852
9074
|
if (dataSourceResult.status === "failed") {
|
|
@@ -8096,6 +9318,10 @@ function createDevShellDataService(options) {
|
|
|
8096
9318
|
handleUpdatesRequest,
|
|
8097
9319
|
handleAddPrebuiltRequest,
|
|
8098
9320
|
getSnapshot: () => snapshot,
|
|
9321
|
+
refreshSnapshot() {
|
|
9322
|
+
scan();
|
|
9323
|
+
return snapshot;
|
|
9324
|
+
},
|
|
8099
9325
|
close() {
|
|
8100
9326
|
clearImmediate(initialScan);
|
|
8101
9327
|
clearTimeout(timer);
|
|
@@ -8285,15 +9511,15 @@ async function closeResource(resource) {
|
|
|
8285
9511
|
}
|
|
8286
9512
|
|
|
8287
9513
|
// cli/lifecycle/installProcessSignalHandlers.ts
|
|
8288
|
-
function installProcessSignalHandlers(
|
|
9514
|
+
function installProcessSignalHandlers(run2) {
|
|
8289
9515
|
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
|
8290
|
-
process.on(signal, () =>
|
|
9516
|
+
process.on(signal, () => run2.shutdown(signal));
|
|
8291
9517
|
}
|
|
8292
|
-
process.on("exit", () =>
|
|
9518
|
+
process.on("exit", () => run2.shutdown("exit"));
|
|
8293
9519
|
process.on("uncaughtException", (error) => {
|
|
8294
9520
|
console.error(error);
|
|
8295
9521
|
process.exitCode = 1;
|
|
8296
|
-
|
|
9522
|
+
run2.shutdown("SIGTERM");
|
|
8297
9523
|
});
|
|
8298
9524
|
}
|
|
8299
9525
|
|
|
@@ -8351,7 +9577,7 @@ function buildCustomBlockDevShellCsp(args) {
|
|
|
8351
9577
|
// Local hosts replace Notion's production app, relay, and mobile-shell ancestors.
|
|
8352
9578
|
`frame-ancestors 'self' ${shellOrigin} ${allowedFrameAncestors.join(" ")}`,
|
|
8353
9579
|
// Allow WebAssembly compilation without enabling JavaScript string evaluation.
|
|
8354
|
-
"script-src 'self' '
|
|
9580
|
+
"script-src 'self' 'wasm-unsafe-eval'",
|
|
8355
9581
|
`style-src 'self' 'unsafe-inline' https://fonts.googleapis.com ${approved}`
|
|
8356
9582
|
].map((directive) => directive.trim()).join("; ");
|
|
8357
9583
|
}
|
|
@@ -8555,7 +9781,8 @@ var SharedServer = class {
|
|
|
8555
9781
|
// cli/server/waitForPreviewUrls.ts
|
|
8556
9782
|
import { request } from "node:http";
|
|
8557
9783
|
import { setTimeout as delay } from "node:timers/promises";
|
|
8558
|
-
async function waitForPreviewUrls(
|
|
9784
|
+
async function waitForPreviewUrls(args) {
|
|
9785
|
+
const { urls, signal, timeoutMs = 1e4 } = args;
|
|
8559
9786
|
const deadline = new AbortController();
|
|
8560
9787
|
const timer = setTimeout(() => deadline.abort(), timeoutMs);
|
|
8561
9788
|
const bounded = AbortSignal.any([signal, deadline.signal]);
|
|
@@ -8577,9 +9804,10 @@ async function waitForPreviewUrls(urls, signal, timeoutMs = 1e4) {
|
|
|
8577
9804
|
bounded.throwIfAborted();
|
|
8578
9805
|
} catch (error) {
|
|
8579
9806
|
if (deadline.signal.aborted && !signal.aborted) {
|
|
8580
|
-
throw new
|
|
8581
|
-
|
|
8582
|
-
|
|
9807
|
+
throw new DevShellStartupError({
|
|
9808
|
+
code: "preview_readiness_timeout",
|
|
9809
|
+
message: `Preview readiness timed out after ${timeoutMs}ms. No successful HTTP response from: ${[...pending].join(", ")}.`
|
|
9810
|
+
});
|
|
8583
9811
|
}
|
|
8584
9812
|
throw error;
|
|
8585
9813
|
} finally {
|
|
@@ -8691,6 +9919,17 @@ const resolved =
|
|
|
8691
9919
|
|
|
8692
9920
|
const injectBlockBootstrap = {
|
|
8693
9921
|
name: "dev-shell:block-bootstrap",
|
|
9922
|
+
configResolved(config) {
|
|
9923
|
+
// Run React's Fast Refresh preamble before Vite transforms the HTML, so
|
|
9924
|
+
// Vite serves it as a same-origin module that the block CSP allows.
|
|
9925
|
+
const refresh = config.plugins.find(plugin => plugin.name === "vite:react-refresh")
|
|
9926
|
+
if (typeof refresh?.transformIndexHtml === "function") {
|
|
9927
|
+
refresh.transformIndexHtml = {
|
|
9928
|
+
order: "pre",
|
|
9929
|
+
handler: refresh.transformIndexHtml,
|
|
9930
|
+
}
|
|
9931
|
+
}
|
|
9932
|
+
},
|
|
8694
9933
|
transformIndexHtml: {
|
|
8695
9934
|
order: "pre",
|
|
8696
9935
|
handler() {
|
|
@@ -18911,7 +20150,7 @@ import { promisify } from "node:util";
|
|
|
18911
20150
|
var WORKER_MANIFEST_FILENAME = "worker_manifest.json";
|
|
18912
20151
|
async function generateWorkerManifest(workerDir, options = {}) {
|
|
18913
20152
|
const manifest = await extractWorkerManifest(workerDir, options);
|
|
18914
|
-
const dir = resolve6(workerDir, ".dev-shell");
|
|
20153
|
+
const dir = options.outputDir ?? resolve6(workerDir, ".dev-shell");
|
|
18915
20154
|
mkdirSync5(dir, { recursive: true });
|
|
18916
20155
|
const manifestPath = resolve6(dir, WORKER_MANIFEST_FILENAME);
|
|
18917
20156
|
writeFileSync3(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
@@ -18969,7 +20208,7 @@ async function extractWorkerManifest(workerDir, options = {}) {
|
|
|
18969
20208
|
`Built worker at ${entry} exposed no usable manifest (expected .manifest or .capabilities).`
|
|
18970
20209
|
);
|
|
18971
20210
|
}
|
|
18972
|
-
async function buildWorker(workerDir,
|
|
20211
|
+
async function buildWorker(workerDir, run2) {
|
|
18973
20212
|
const child = spawn2("npm run build", {
|
|
18974
20213
|
cwd: workerDir,
|
|
18975
20214
|
shell: true,
|
|
@@ -18981,7 +20220,7 @@ async function buildWorker(workerDir, run) {
|
|
|
18981
20220
|
child.once("error", reject);
|
|
18982
20221
|
child.once("close", (code2) => resolve10(code2));
|
|
18983
20222
|
});
|
|
18984
|
-
|
|
20223
|
+
run2?.addResource(async () => {
|
|
18985
20224
|
const pid = child.pid;
|
|
18986
20225
|
if (pid === void 0 || child.exitCode !== null || child.signalCode !== null) {
|
|
18987
20226
|
return;
|
|
@@ -18996,7 +20235,7 @@ async function buildWorker(workerDir, run) {
|
|
|
18996
20235
|
await finished;
|
|
18997
20236
|
});
|
|
18998
20237
|
const code = await finished;
|
|
18999
|
-
if (
|
|
20238
|
+
if (run2?.closing) {
|
|
19000
20239
|
throw new Error("Worker build cancelled");
|
|
19001
20240
|
}
|
|
19002
20241
|
if (code !== 0) {
|
|
@@ -19028,6 +20267,7 @@ async function prepareWorkerLaunchPlan(workerDir, options = {}) {
|
|
|
19028
20267
|
}
|
|
19029
20268
|
const { manifest, manifestPath } = await generateWorkerManifest(root, {
|
|
19030
20269
|
build: options.build,
|
|
20270
|
+
outputDir: options.configDir,
|
|
19031
20271
|
run: options.run
|
|
19032
20272
|
});
|
|
19033
20273
|
const capabilities = blockCapabilities(manifest);
|
|
@@ -19064,7 +20304,29 @@ async function prepareWorkerLaunchPlan(workerDir, options = {}) {
|
|
|
19064
20304
|
registry
|
|
19065
20305
|
};
|
|
19066
20306
|
}
|
|
19067
|
-
function
|
|
20307
|
+
function warnAboutDeprecatedBind({
|
|
20308
|
+
argv: argv2
|
|
20309
|
+
}) {
|
|
20310
|
+
if (argv2.some((arg) => arg === "--bind" || arg.startsWith("--bind="))) {
|
|
20311
|
+
console.error("--bind is deprecated. Use --bind-data-source instead.");
|
|
20312
|
+
}
|
|
20313
|
+
}
|
|
20314
|
+
function parseWorkerLaunchArgs(args) {
|
|
20315
|
+
try {
|
|
20316
|
+
return parseWorkerLaunchOptions(args);
|
|
20317
|
+
} catch (error) {
|
|
20318
|
+
if (error instanceof DevShellLauncherBindingError) {
|
|
20319
|
+
throw error;
|
|
20320
|
+
}
|
|
20321
|
+
throw new DevShellStartupError({
|
|
20322
|
+
code: "invalid_arguments",
|
|
20323
|
+
message: formatUnknownError(error),
|
|
20324
|
+
options: { cause: error }
|
|
20325
|
+
});
|
|
20326
|
+
}
|
|
20327
|
+
}
|
|
20328
|
+
function parseWorkerLaunchOptions(options) {
|
|
20329
|
+
const { argv: argv2 } = options;
|
|
19068
20330
|
const args = {
|
|
19069
20331
|
worker: void 0,
|
|
19070
20332
|
shellPort: DEFAULT_DEV_SHELL_PORT,
|
|
@@ -19074,17 +20336,20 @@ function parseWorkerLaunchArgs(argv) {
|
|
|
19074
20336
|
propertyBindings: []
|
|
19075
20337
|
};
|
|
19076
20338
|
let hasPositionalWorker = false;
|
|
20339
|
+
const bindDataSource = (value) => {
|
|
20340
|
+
args.bindings.push(parseDataSourceBindingOverride({ value }));
|
|
20341
|
+
};
|
|
19077
20342
|
parseCliArgs({
|
|
19078
|
-
argv,
|
|
20343
|
+
argv: argv2,
|
|
19079
20344
|
flags: {
|
|
19080
20345
|
"--json": () => {
|
|
19081
20346
|
args.json = true;
|
|
19082
20347
|
}
|
|
19083
20348
|
},
|
|
19084
20349
|
handlers: {
|
|
19085
|
-
"--bind":
|
|
19086
|
-
|
|
19087
|
-
|
|
20350
|
+
"--bind-data-source": bindDataSource,
|
|
20351
|
+
/** @deprecated Use `--bind-data-source` instead. */
|
|
20352
|
+
"--bind": bindDataSource,
|
|
19088
20353
|
"--bind-property": (value) => {
|
|
19089
20354
|
args.propertyBindings.push(parsePropertyBindingOverride({ value }));
|
|
19090
20355
|
},
|
|
@@ -19106,7 +20371,7 @@ function parseWorkerLaunchArgs(argv) {
|
|
|
19106
20371
|
},
|
|
19107
20372
|
onUnknown: (arg) => {
|
|
19108
20373
|
throw new Error(
|
|
19109
|
-
`Unknown dev shell option "${arg}". Supported: --worker <dir>, --port <port>, --json, --bind <capabilityKey>.<dataSourceKey>=<sampleDataFileName>, --bind-property <capabilityKey>.<dataSourceKey>.<propertyKey>=<sourcePropertyKey
|
|
20374
|
+
`Unknown dev shell option "${arg}". Supported: --worker <dir>, --port <port>, --json, --bind-data-source <capabilityKey>.<dataSourceKey>=<sampleDataFileName>, --bind-property <capabilityKey>.<dataSourceKey>.<propertyKey>=<sourcePropertyKey>. --bind is a deprecated alias for --bind-data-source.`
|
|
19110
20375
|
);
|
|
19111
20376
|
},
|
|
19112
20377
|
onPositional: (arg) => {
|
|
@@ -19184,34 +20449,33 @@ function applyBindingsAndLog(args, plan, workerDir, snapshot) {
|
|
|
19184
20449
|
logWorkerPlan(basename3(workerDir), plan, snapshot);
|
|
19185
20450
|
}
|
|
19186
20451
|
async function launchDevShell(options) {
|
|
19187
|
-
const { installSignalHandlers = true } = options;
|
|
20452
|
+
const { installSignalHandlers = true, writeStartupEvent } = options;
|
|
19188
20453
|
const shared = new SharedServer();
|
|
19189
20454
|
const beforeCleanup = () => shared.close();
|
|
19190
|
-
const
|
|
20455
|
+
const run2 = options.createRun?.(beforeCleanup) ?? new DevShellRun(beforeCleanup);
|
|
19191
20456
|
if (installSignalHandlers) {
|
|
19192
|
-
installProcessSignalHandlers(
|
|
20457
|
+
installProcessSignalHandlers(run2);
|
|
19193
20458
|
}
|
|
19194
20459
|
const readiness = new AbortController();
|
|
19195
|
-
|
|
20460
|
+
run2.addResource(() => readiness.abort());
|
|
19196
20461
|
try {
|
|
19197
|
-
const
|
|
19198
|
-
const args = parseWorkerLaunchArgs(options.argv);
|
|
20462
|
+
const args = parseWorkerLaunchArgs({ argv: options.argv });
|
|
19199
20463
|
const { workerDir } = resolveWorkerLaunch({ ...options, args });
|
|
19200
20464
|
const originalCwd = process.cwd();
|
|
19201
20465
|
process.chdir(workerDir);
|
|
19202
|
-
|
|
20466
|
+
run2.addResource(() => process.chdir(originalCwd));
|
|
19203
20467
|
args.shellPort = await shared.listen(args.shellPort, args.strictPort);
|
|
19204
20468
|
const tempRoot = join3(workerDir, ".dev-shell");
|
|
19205
20469
|
mkdirSync6(tempRoot, { recursive: true });
|
|
19206
20470
|
const configDir = mkdtempSync(join3(tempRoot, "run-"));
|
|
19207
|
-
|
|
20471
|
+
run2.addResource(() => rmSync(configDir, { recursive: true, force: true }));
|
|
19208
20472
|
logNamed(basename3(workerDir), "Extracting worker manifest...");
|
|
19209
20473
|
const plan = await prepareWorkerLaunchPlan(workerDir, {
|
|
19210
20474
|
shellPort: args.shellPort,
|
|
19211
20475
|
configDir,
|
|
19212
|
-
run
|
|
20476
|
+
run: run2
|
|
19213
20477
|
});
|
|
19214
|
-
if (
|
|
20478
|
+
if (run2.closing) {
|
|
19215
20479
|
return;
|
|
19216
20480
|
}
|
|
19217
20481
|
const dataService = createDevShellDataService({
|
|
@@ -19220,7 +20484,7 @@ async function launchDevShell(options) {
|
|
|
19220
20484
|
blocks: plan.registry,
|
|
19221
20485
|
log: (message) => logNamed(basename3(workerDir), message)
|
|
19222
20486
|
});
|
|
19223
|
-
|
|
20487
|
+
run2.addResource(() => dataService.close());
|
|
19224
20488
|
applyBindingsAndLog(args, plan, workerDir, dataService.getSnapshot());
|
|
19225
20489
|
shared.shellApiRoutes.set(
|
|
19226
20490
|
"/api/dev-shell",
|
|
@@ -19236,10 +20500,10 @@ async function launchDevShell(options) {
|
|
|
19236
20500
|
log: logNamed
|
|
19237
20501
|
});
|
|
19238
20502
|
if (closeShell) {
|
|
19239
|
-
|
|
20503
|
+
run2.addResource(closeShell);
|
|
19240
20504
|
}
|
|
19241
20505
|
for (const block of plan.blocks) {
|
|
19242
|
-
if (
|
|
20506
|
+
if (run2.closing) {
|
|
19243
20507
|
return;
|
|
19244
20508
|
}
|
|
19245
20509
|
const close = await mountVite({
|
|
@@ -19252,36 +20516,51 @@ async function launchDevShell(options) {
|
|
|
19252
20516
|
shared,
|
|
19253
20517
|
config: { configFile: block.configFile, root: block.blockDir }
|
|
19254
20518
|
});
|
|
19255
|
-
|
|
20519
|
+
run2.addResource(close);
|
|
19256
20520
|
}
|
|
19257
|
-
if (
|
|
20521
|
+
if (run2.closing) {
|
|
19258
20522
|
return;
|
|
19259
20523
|
}
|
|
19260
|
-
if (
|
|
19261
|
-
await waitForPreviewUrls(
|
|
19262
|
-
[
|
|
20524
|
+
if (writeStartupEvent) {
|
|
20525
|
+
await waitForPreviewUrls({
|
|
20526
|
+
urls: [
|
|
19263
20527
|
`http://localhost:${args.shellPort}`,
|
|
19264
20528
|
...plan.registry.map((block) => block.url)
|
|
19265
20529
|
],
|
|
19266
|
-
readiness.signal
|
|
19267
|
-
);
|
|
19268
|
-
if (
|
|
20530
|
+
signal: readiness.signal
|
|
20531
|
+
});
|
|
20532
|
+
if (run2.closing) {
|
|
19269
20533
|
return;
|
|
19270
20534
|
}
|
|
19271
|
-
|
|
20535
|
+
const { dataSources } = dataService.refreshSnapshot();
|
|
20536
|
+
writeStartupEvent({
|
|
19272
20537
|
event: "ready",
|
|
20538
|
+
version: 1,
|
|
19273
20539
|
shellUrl: `http://localhost:${args.shellPort}`,
|
|
19274
20540
|
workerDir,
|
|
19275
20541
|
devShellVersion: options.devShellVersion,
|
|
19276
|
-
|
|
19277
|
-
|
|
19278
|
-
|
|
19279
|
-
|
|
20542
|
+
workerManifestPath: relative2(workerDir, plan.manifestPath).split(sep).join("/"),
|
|
20543
|
+
customBlocks: plan.registry.map((block) => {
|
|
20544
|
+
const pageKeys = Object.keys(block.manifest.pages ?? {});
|
|
20545
|
+
return {
|
|
20546
|
+
key: block.key,
|
|
20547
|
+
url: block.url,
|
|
20548
|
+
bindings: {
|
|
20549
|
+
dataSources: describeStartupDataSourceBindings(
|
|
20550
|
+
block,
|
|
20551
|
+
dataSources
|
|
20552
|
+
),
|
|
20553
|
+
pages: pageKeys.length === 0 ? void 0 : Object.fromEntries(
|
|
20554
|
+
pageKeys.map((key) => [key, { status: "unsupported" }])
|
|
20555
|
+
)
|
|
20556
|
+
}
|
|
20557
|
+
};
|
|
20558
|
+
})
|
|
19280
20559
|
});
|
|
19281
20560
|
}
|
|
19282
20561
|
printSummary(args, plan.registry);
|
|
19283
20562
|
} catch (error) {
|
|
19284
|
-
if (
|
|
20563
|
+
if (run2.closing) {
|
|
19285
20564
|
return;
|
|
19286
20565
|
}
|
|
19287
20566
|
console.error(
|
|
@@ -19289,31 +20568,17 @@ async function launchDevShell(options) {
|
|
|
19289
20568
|
${formatUnknownErrorWithStack(error)}`
|
|
19290
20569
|
);
|
|
19291
20570
|
process.exitCode = 1;
|
|
19292
|
-
|
|
19293
|
-
|
|
19294
|
-
}
|
|
19295
|
-
|
|
19296
|
-
return plan.blocks.map(({ capability }, index) => {
|
|
19297
|
-
const block = plan.registry[index];
|
|
19298
|
-
const manifest = capability.config.manifest;
|
|
19299
|
-
const sampleFilesByDataSource = {};
|
|
19300
|
-
for (const slotKey of Object.keys(manifest.dataSources)) {
|
|
19301
|
-
const source = selectSampleDataSource({
|
|
19302
|
-
slotKey,
|
|
19303
|
-
sources,
|
|
19304
|
-
explicitFilename: block.sampleFilesByDataSource[slotKey]
|
|
19305
|
-
});
|
|
19306
|
-
if (source?.filename !== void 0) {
|
|
19307
|
-
sampleFilesByDataSource[slotKey] = `data/${source.filename}.json`;
|
|
19308
|
-
}
|
|
20571
|
+
try {
|
|
20572
|
+
writeStartupFailure({ writeStartupEvent, error });
|
|
20573
|
+
} finally {
|
|
20574
|
+
run2.shutdown("SIGTERM");
|
|
19309
20575
|
}
|
|
19310
|
-
|
|
19311
|
-
});
|
|
20576
|
+
}
|
|
19312
20577
|
}
|
|
19313
20578
|
|
|
19314
20579
|
// cli/server/createUiHandler.ts
|
|
19315
20580
|
import { readFileSync as readFileSync6 } from "node:fs";
|
|
19316
|
-
import { extname, join as join4, normalize, resolve as resolve8, sep } from "node:path";
|
|
20581
|
+
import { extname, join as join4, normalize, resolve as resolve8, sep as sep2 } from "node:path";
|
|
19317
20582
|
var CONTENT_TYPES = {
|
|
19318
20583
|
".html": "text/html; charset=utf-8",
|
|
19319
20584
|
".js": "text/javascript; charset=utf-8",
|
|
@@ -19340,12 +20605,12 @@ function createUiHandler(distDir) {
|
|
|
19340
20605
|
}
|
|
19341
20606
|
const path = normalize(urlPath);
|
|
19342
20607
|
const filePath = join4(dist, path);
|
|
19343
|
-
if (!filePath.startsWith(dist +
|
|
20608
|
+
if (!filePath.startsWith(dist + sep2) && filePath !== dist) {
|
|
19344
20609
|
res.writeHead(403).end();
|
|
19345
20610
|
return;
|
|
19346
20611
|
}
|
|
19347
20612
|
const ext = extname(filePath);
|
|
19348
|
-
if (path === "/" || path === `${
|
|
20613
|
+
if (path === "/" || path === `${sep2}index.html` || ext === "") {
|
|
19349
20614
|
res.writeHead(200, { "Content-Type": CONTENT_TYPES[".html"] }).end(indexHtml);
|
|
19350
20615
|
return;
|
|
19351
20616
|
}
|
|
@@ -19373,22 +20638,24 @@ var createShellLaunch = async ({ shared }) => {
|
|
|
19373
20638
|
handle: createUiHandler(distDir)
|
|
19374
20639
|
});
|
|
19375
20640
|
};
|
|
19376
|
-
|
|
19377
|
-
|
|
19378
|
-
|
|
19379
|
-
|
|
19380
|
-
return;
|
|
19381
|
-
}
|
|
20641
|
+
var argv = process.argv.slice(2);
|
|
20642
|
+
async function main(args) {
|
|
20643
|
+
const { writeStartupEvent } = args;
|
|
20644
|
+
warnAboutDeprecatedBind({ argv });
|
|
19382
20645
|
await launchDevShell({
|
|
19383
|
-
devShellVersion: readDevShellVersion(
|
|
20646
|
+
devShellVersion: readDevShellVersion({
|
|
20647
|
+
packageDir: resolve9(__dirname, "../..")
|
|
20648
|
+
}),
|
|
19384
20649
|
argv,
|
|
19385
20650
|
workerBaseDir: process.cwd(),
|
|
19386
20651
|
detectFromDir: process.cwd(),
|
|
19387
20652
|
createShellLaunch,
|
|
19388
|
-
prebuiltDir: resolve9(__dirname, "../..", "data")
|
|
20653
|
+
prebuiltDir: resolve9(__dirname, "../..", "data"),
|
|
20654
|
+
writeStartupEvent
|
|
19389
20655
|
});
|
|
19390
20656
|
}
|
|
19391
|
-
|
|
20657
|
+
var run = argv[0] === "convert" ? runConvert(argv.slice(1)) : runWithStartupOutput({ main });
|
|
20658
|
+
run.catch((error) => {
|
|
19392
20659
|
console.error(formatUnknownErrorWithStack(error));
|
|
19393
20660
|
process.exitCode = 1;
|
|
19394
20661
|
});
|