@notionhq/custom-blocks-dev-shell 0.5.0 → 0.6.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 +17 -9
- package/data/meetings.json +20 -1
- package/data/projects.json +27 -9
- package/data/tasks.json +45 -0
- package/dist/assets/index-BCrnMfUh.js +12 -0
- package/dist/index.html +1 -1
- package/dist-cli/cli/published-cli.js +700 -87
- package/docs/bindings.md +29 -2
- package/docs/data-sources.md +22 -1
- package/package.json +1 -1
- package/dist/assets/index-Dhs3H2Yo.js +0 -12
|
@@ -410,6 +410,96 @@ function custom(check$1, message$1) {
|
|
|
410
410
|
});
|
|
411
411
|
}
|
|
412
412
|
// @__NO_SIDE_EFFECTS__
|
|
413
|
+
function exactOptional(wrapped, default_) {
|
|
414
|
+
return _standardSchema({
|
|
415
|
+
kind: "schema",
|
|
416
|
+
type: "exact_optional",
|
|
417
|
+
reference: exactOptional,
|
|
418
|
+
expects: wrapped.expects,
|
|
419
|
+
async: false,
|
|
420
|
+
wrapped,
|
|
421
|
+
default: default_,
|
|
422
|
+
"~run"(dataset, config$1) {
|
|
423
|
+
return this.wrapped["~run"](dataset, config$1);
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
// @__NO_SIDE_EFFECTS__
|
|
428
|
+
function _merge(value1, value2) {
|
|
429
|
+
if (typeof value1 === typeof value2) {
|
|
430
|
+
if (/* @__PURE__ */ _isSameValueZero(value1, value2) || value1 instanceof Date && value2 instanceof Date && /* @__PURE__ */ _isSameValueZero(+value1, +value2)) return { value: value1 };
|
|
431
|
+
if (value1 && value2 && value1.constructor === Object && value2.constructor === Object) {
|
|
432
|
+
const nextValue = {
|
|
433
|
+
...value1,
|
|
434
|
+
...value2
|
|
435
|
+
};
|
|
436
|
+
for (const key in value2) if (Object.prototype.hasOwnProperty.call(value1, key) && Object.prototype.hasOwnProperty.call(value2, key)) {
|
|
437
|
+
const dataset = /* @__PURE__ */ _merge(value1[key], value2[key]);
|
|
438
|
+
if (dataset.issue) return dataset;
|
|
439
|
+
nextValue[key] = dataset.value;
|
|
440
|
+
}
|
|
441
|
+
return { value: nextValue };
|
|
442
|
+
}
|
|
443
|
+
if (Array.isArray(value1) && Array.isArray(value2)) {
|
|
444
|
+
if (value1.length === value2.length) {
|
|
445
|
+
const nextValue = [...value1];
|
|
446
|
+
for (let index = 0; index < value1.length; index++) {
|
|
447
|
+
const dataset = /* @__PURE__ */ _merge(value1[index], value2[index]);
|
|
448
|
+
if (dataset.issue) return dataset;
|
|
449
|
+
nextValue[index] = dataset.value;
|
|
450
|
+
}
|
|
451
|
+
return { value: nextValue };
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return { issue: true };
|
|
456
|
+
}
|
|
457
|
+
// @__NO_SIDE_EFFECTS__
|
|
458
|
+
function intersect(options, message$1) {
|
|
459
|
+
return _standardSchema({
|
|
460
|
+
kind: "schema",
|
|
461
|
+
type: "intersect",
|
|
462
|
+
reference: intersect,
|
|
463
|
+
expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "&"),
|
|
464
|
+
async: false,
|
|
465
|
+
options,
|
|
466
|
+
message: message$1,
|
|
467
|
+
"~run"(dataset, config$1) {
|
|
468
|
+
if (this.options.length) {
|
|
469
|
+
const input = dataset.value;
|
|
470
|
+
let outputs;
|
|
471
|
+
dataset.typed = true;
|
|
472
|
+
for (const schema of this.options) {
|
|
473
|
+
const optionDataset = schema["~run"]({ value: input }, config$1);
|
|
474
|
+
if (optionDataset.issues) {
|
|
475
|
+
if (dataset.issues) for (const issue of optionDataset.issues) dataset.issues.push(issue);
|
|
476
|
+
else dataset.issues = optionDataset.issues;
|
|
477
|
+
if (config$1.abortEarly) {
|
|
478
|
+
dataset.typed = false;
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (!optionDataset.typed) dataset.typed = false;
|
|
483
|
+
if (dataset.typed) if (outputs) outputs.push(optionDataset.value);
|
|
484
|
+
else outputs = [optionDataset.value];
|
|
485
|
+
}
|
|
486
|
+
if (dataset.typed) {
|
|
487
|
+
dataset.value = outputs[0];
|
|
488
|
+
for (let index = 1; index < outputs.length; index++) {
|
|
489
|
+
const mergeDataset = /* @__PURE__ */ _merge(dataset.value, outputs[index]);
|
|
490
|
+
if (mergeDataset.issue) {
|
|
491
|
+
_addIssue(this, "type", dataset, config$1, { received: "unknown" });
|
|
492
|
+
break;
|
|
493
|
+
}
|
|
494
|
+
dataset.value = mergeDataset.value;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
} else _addIssue(this, "type", dataset, config$1);
|
|
498
|
+
return dataset;
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
// @__NO_SIDE_EFFECTS__
|
|
413
503
|
function literal(literal_, message$1) {
|
|
414
504
|
return _standardSchema({
|
|
415
505
|
kind: "schema",
|
|
@@ -1624,12 +1714,6 @@ var initResultMessageWithCompatibilitySchema = union([
|
|
|
1624
1714
|
protocol3To11InitResultMessageSchema
|
|
1625
1715
|
]);
|
|
1626
1716
|
|
|
1627
|
-
// ../protocol/src/context/messages/contrastModeChanged.ts
|
|
1628
|
-
var contrastModeChangedMessageSchema = object({
|
|
1629
|
-
type: literal("contrastModeChanged"),
|
|
1630
|
-
contrastMode: notionContrastModeSchema
|
|
1631
|
-
});
|
|
1632
|
-
|
|
1633
1717
|
// ../protocol/src/context/containingPage.ts
|
|
1634
1718
|
var containingPageSchema = variant("type", [
|
|
1635
1719
|
/** The viewer cannot access the containing page. Its ID and parent are not exposed. */
|
|
@@ -1660,12 +1744,18 @@ var containingPageContextSchema = variant("type", [
|
|
|
1660
1744
|
})
|
|
1661
1745
|
]);
|
|
1662
1746
|
|
|
1663
|
-
// ../protocol/src/context/messages/
|
|
1664
|
-
var
|
|
1665
|
-
type: literal("
|
|
1747
|
+
// ../protocol/src/context/messages/containingPageChanged.ts
|
|
1748
|
+
var containingPageChangedMessageSchema = object({
|
|
1749
|
+
type: literal("containingPageChanged"),
|
|
1666
1750
|
page: containingPageContextSchema
|
|
1667
1751
|
});
|
|
1668
1752
|
|
|
1753
|
+
// ../protocol/src/context/messages/contrastModeChanged.ts
|
|
1754
|
+
var contrastModeChangedMessageSchema = object({
|
|
1755
|
+
type: literal("contrastModeChanged"),
|
|
1756
|
+
contrastMode: notionContrastModeSchema
|
|
1757
|
+
});
|
|
1758
|
+
|
|
1669
1759
|
// ../protocol/src/context/messages/pageError.ts
|
|
1670
1760
|
var pageErrorMessageSchema = object({
|
|
1671
1761
|
type: literal("pageError"),
|
|
@@ -1777,31 +1867,93 @@ var sourcePropertySchema = pipe(
|
|
|
1777
1867
|
return definition;
|
|
1778
1868
|
})
|
|
1779
1869
|
);
|
|
1780
|
-
var
|
|
1870
|
+
var sourceSnapshotPropertySchema = intersect([
|
|
1871
|
+
object({
|
|
1872
|
+
id: string(),
|
|
1873
|
+
key: optional(string()),
|
|
1874
|
+
restricted: optional(literal(true))
|
|
1875
|
+
}),
|
|
1876
|
+
sourcePropertySchema
|
|
1877
|
+
]);
|
|
1878
|
+
var availableDataSourceSnapshotSchema = object({
|
|
1781
1879
|
type: literal("available"),
|
|
1782
|
-
|
|
1783
|
-
|
|
1880
|
+
/** Columns in the viewer's schema. */
|
|
1881
|
+
properties: array(sourceSnapshotPropertySchema),
|
|
1882
|
+
relationTargetKeysByPropertyId: optional(
|
|
1883
|
+
record(string(), string()),
|
|
1884
|
+
() => ({})
|
|
1885
|
+
),
|
|
1784
1886
|
title: optional(string()),
|
|
1785
1887
|
description: optional(string()),
|
|
1786
1888
|
icon: optional(bridgePageIconSchema)
|
|
1787
1889
|
});
|
|
1788
|
-
var
|
|
1890
|
+
var settledDataSourceSnapshotSchema = union([
|
|
1789
1891
|
availableDataSourceSnapshotSchema,
|
|
1790
1892
|
strictObject({ type: literal("not_bound") }),
|
|
1791
|
-
strictObject({ type: literal("unavailable") })
|
|
1893
|
+
strictObject({ type: literal("unavailable") })
|
|
1894
|
+
]);
|
|
1895
|
+
var dataSourceSnapshotSchema = union([
|
|
1896
|
+
settledDataSourceSnapshotSchema,
|
|
1792
1897
|
strictObject({
|
|
1793
1898
|
type: literal("error"),
|
|
1794
1899
|
error: customBlockErrorInfoSchema
|
|
1795
1900
|
})
|
|
1796
1901
|
]);
|
|
1797
|
-
var
|
|
1798
|
-
type: literal("
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1902
|
+
var dataSourceTargetSchema = strictObject({
|
|
1903
|
+
type: literal("data_source_key"),
|
|
1904
|
+
dataSourceKey: string()
|
|
1905
|
+
});
|
|
1906
|
+
var subscribeToDataSourceMessageSchema = strictObject({
|
|
1907
|
+
type: literal("subscribeToDataSource"),
|
|
1908
|
+
requestId: string(),
|
|
1909
|
+
dataSourceTarget: dataSourceTargetSchema
|
|
1910
|
+
});
|
|
1911
|
+
var unsubscribeFromDataSourceMessageSchema = strictObject({
|
|
1912
|
+
type: literal("unsubscribeFromDataSource"),
|
|
1913
|
+
requestId: string()
|
|
1804
1914
|
});
|
|
1915
|
+
var subscribeToDataSourceResultMessageSchema = variant("status", [
|
|
1916
|
+
strictObject({
|
|
1917
|
+
type: literal("subscribeToDataSourceResult"),
|
|
1918
|
+
requestId: string(),
|
|
1919
|
+
status: literal("success")
|
|
1920
|
+
}),
|
|
1921
|
+
strictObject({
|
|
1922
|
+
type: literal("subscribeToDataSourceResult"),
|
|
1923
|
+
requestId: string(),
|
|
1924
|
+
status: literal("error"),
|
|
1925
|
+
error: customBlockErrorInfoSchema
|
|
1926
|
+
})
|
|
1927
|
+
]);
|
|
1928
|
+
var dataSourceSnapshotChangedMessageSchema = variant("status", [
|
|
1929
|
+
strictObject({
|
|
1930
|
+
type: literal("dataSourceSnapshotChanged"),
|
|
1931
|
+
requestId: string(),
|
|
1932
|
+
status: literal("available"),
|
|
1933
|
+
dataSource: omit(availableDataSourceSnapshotSchema, ["type"])
|
|
1934
|
+
}),
|
|
1935
|
+
strictObject({
|
|
1936
|
+
type: literal("dataSourceSnapshotChanged"),
|
|
1937
|
+
requestId: string(),
|
|
1938
|
+
status: literal("loading")
|
|
1939
|
+
}),
|
|
1940
|
+
strictObject({
|
|
1941
|
+
type: literal("dataSourceSnapshotChanged"),
|
|
1942
|
+
requestId: string(),
|
|
1943
|
+
status: literal("not_bound")
|
|
1944
|
+
}),
|
|
1945
|
+
strictObject({
|
|
1946
|
+
type: literal("dataSourceSnapshotChanged"),
|
|
1947
|
+
requestId: string(),
|
|
1948
|
+
status: literal("unavailable")
|
|
1949
|
+
}),
|
|
1950
|
+
strictObject({
|
|
1951
|
+
type: literal("dataSourceSnapshotChanged"),
|
|
1952
|
+
requestId: string(),
|
|
1953
|
+
status: literal("error"),
|
|
1954
|
+
error: customBlockErrorInfoSchema
|
|
1955
|
+
})
|
|
1956
|
+
]);
|
|
1805
1957
|
|
|
1806
1958
|
// ../protocol/src/utils/recordPointer.ts
|
|
1807
1959
|
var notionRecordPointerSchema = object({
|
|
@@ -2332,6 +2484,29 @@ var bridgePageSchema = object({
|
|
|
2332
2484
|
in_trash: boolean()
|
|
2333
2485
|
});
|
|
2334
2486
|
|
|
2487
|
+
// ../protocol/src/pages/pageSnapshot.ts
|
|
2488
|
+
var unavailablePagePropertySchema = object({
|
|
2489
|
+
id: string(),
|
|
2490
|
+
key: optional(string()),
|
|
2491
|
+
type: literal("unavailable")
|
|
2492
|
+
});
|
|
2493
|
+
var pageSnapshotPropertySchema = union([
|
|
2494
|
+
unavailablePagePropertySchema,
|
|
2495
|
+
intersect([
|
|
2496
|
+
bridgePagePropertyReadValueSchema,
|
|
2497
|
+
object({ key: optional(string()) })
|
|
2498
|
+
])
|
|
2499
|
+
]);
|
|
2500
|
+
var bridgePageSnapshotSchema = object({
|
|
2501
|
+
...bridgePageSchema.entries,
|
|
2502
|
+
id: optional(bridgePageSchema.entries.id),
|
|
2503
|
+
properties: array(pageSnapshotPropertySchema)
|
|
2504
|
+
});
|
|
2505
|
+
var identifiedPageSnapshotSchema = required(
|
|
2506
|
+
bridgePageSnapshotSchema,
|
|
2507
|
+
["id"]
|
|
2508
|
+
);
|
|
2509
|
+
|
|
2335
2510
|
// ../protocol/src/dataSources/bridgeArchiveStatus.ts
|
|
2336
2511
|
var bridgeArchiveStatusSchema = picklist([
|
|
2337
2512
|
"active",
|
|
@@ -2667,6 +2842,52 @@ var queryDataSourceResultMessageSchema = variant("status", [
|
|
|
2667
2842
|
})
|
|
2668
2843
|
]);
|
|
2669
2844
|
|
|
2845
|
+
// ../protocol/src/dataSources/messages/dataSourceQueryResult.ts
|
|
2846
|
+
var queryLoadingSchema = object({
|
|
2847
|
+
type: literal("queryDataSourceResult"),
|
|
2848
|
+
subscriptionId: string(),
|
|
2849
|
+
status: literal("loading")
|
|
2850
|
+
});
|
|
2851
|
+
var dataSourceQueryRecordResultMessageSchema = variant("status", [
|
|
2852
|
+
object({
|
|
2853
|
+
...queryDataSourceResultMessageSchema.options[0].entries,
|
|
2854
|
+
propertyIdsByKey: optional(bridgePropertyIdsByKeySchema)
|
|
2855
|
+
}),
|
|
2856
|
+
queryDataSourceResultMessageSchema.options[1],
|
|
2857
|
+
queryLoadingSchema
|
|
2858
|
+
]);
|
|
2859
|
+
var dataSourceQueryResultMessageSchema = variant("status", [
|
|
2860
|
+
object({
|
|
2861
|
+
...queryDataSourceResultMessageSchema.options[0].entries,
|
|
2862
|
+
items: array(identifiedPageSnapshotSchema),
|
|
2863
|
+
// A query row carries its own keys. Reject the retired sibling mapping.
|
|
2864
|
+
propertyIdsByKey: exactOptional(never())
|
|
2865
|
+
}),
|
|
2866
|
+
queryDataSourceResultMessageSchema.options[1],
|
|
2867
|
+
queryLoadingSchema
|
|
2868
|
+
]);
|
|
2869
|
+
|
|
2870
|
+
// ../protocol/src/dataSources/messages/dataSourceRead.ts
|
|
2871
|
+
var dataSourceReadMessageSchema = strictObject({
|
|
2872
|
+
type: literal("getDataSource"),
|
|
2873
|
+
requestId: string(),
|
|
2874
|
+
target: dataSourceTargetSchema
|
|
2875
|
+
});
|
|
2876
|
+
var dataSourceReadResultMessageSchema = variant("status", [
|
|
2877
|
+
strictObject({
|
|
2878
|
+
type: literal("getDataSourceResult"),
|
|
2879
|
+
requestId: string(),
|
|
2880
|
+
status: literal("success"),
|
|
2881
|
+
dataSource: settledDataSourceSnapshotSchema
|
|
2882
|
+
}),
|
|
2883
|
+
strictObject({
|
|
2884
|
+
type: literal("getDataSourceResult"),
|
|
2885
|
+
requestId: string(),
|
|
2886
|
+
status: literal("error"),
|
|
2887
|
+
error: customBlockErrorInfoSchema
|
|
2888
|
+
})
|
|
2889
|
+
]);
|
|
2890
|
+
|
|
2670
2891
|
// ../protocol/src/handshake/connectResult.ts
|
|
2671
2892
|
var connectResultMessageSchema = variant("status", [
|
|
2672
2893
|
object({
|
|
@@ -2763,6 +2984,47 @@ var addressedGetPageResultMessageSchema = variant("status", [
|
|
|
2763
2984
|
getPageResultMessageSchema.options[1]
|
|
2764
2985
|
]);
|
|
2765
2986
|
|
|
2987
|
+
// ../protocol/src/pages/messages/openPage.ts
|
|
2988
|
+
var openPageModeSchema = picklist(["side_peek", "center_peek"]);
|
|
2989
|
+
var customBlockOpenPageErrorCodeSchema = string();
|
|
2990
|
+
var customBlockOpenPageErrorInfoSchema = object({
|
|
2991
|
+
code: customBlockOpenPageErrorCodeSchema,
|
|
2992
|
+
message: string(),
|
|
2993
|
+
isRetryable: boolean()
|
|
2994
|
+
});
|
|
2995
|
+
var openPageMessageSchema = object({
|
|
2996
|
+
type: literal("openPage"),
|
|
2997
|
+
requestId: string(),
|
|
2998
|
+
pageId: notionPageIdSchema,
|
|
2999
|
+
mode: openPageModeSchema
|
|
3000
|
+
});
|
|
3001
|
+
var openPageResultMessageSchema = variant("status", [
|
|
3002
|
+
object({
|
|
3003
|
+
type: literal("openPageResult"),
|
|
3004
|
+
requestId: string(),
|
|
3005
|
+
status: literal("success"),
|
|
3006
|
+
pageId: notionPageIdSchema
|
|
3007
|
+
}),
|
|
3008
|
+
object({
|
|
3009
|
+
type: literal("openPageResult"),
|
|
3010
|
+
requestId: string(),
|
|
3011
|
+
status: literal("error"),
|
|
3012
|
+
error: customBlockOpenPageErrorInfoSchema
|
|
3013
|
+
})
|
|
3014
|
+
]);
|
|
3015
|
+
var addressedOpenPageMessageSchema = strictObject({
|
|
3016
|
+
type: literal("openPage"),
|
|
3017
|
+
requestId: string(),
|
|
3018
|
+
target: pageAddressSchema,
|
|
3019
|
+
mode: openPageModeSchema
|
|
3020
|
+
});
|
|
3021
|
+
var addressedOpenPageResultMessageSchema = variant("status", [
|
|
3022
|
+
strictObject(
|
|
3023
|
+
omit(openPageResultMessageSchema.options[0], ["pageId"]).entries
|
|
3024
|
+
),
|
|
3025
|
+
openPageResultMessageSchema.options[1]
|
|
3026
|
+
]);
|
|
3027
|
+
|
|
2766
3028
|
// ../protocol/src/pages/messages/createPage.ts
|
|
2767
3029
|
var customBlockCreatePageErrorCodeSchema = string();
|
|
2768
3030
|
var customBlockCreatePageErrorInfoSchema = object({
|
|
@@ -2853,47 +3115,6 @@ var keyedCreatePageMessageSchema = variant("type", [
|
|
|
2853
3115
|
})
|
|
2854
3116
|
]);
|
|
2855
3117
|
|
|
2856
|
-
// ../protocol/src/pages/messages/openPage.ts
|
|
2857
|
-
var openPageModeSchema = picklist(["side_peek", "center_peek"]);
|
|
2858
|
-
var customBlockOpenPageErrorCodeSchema = string();
|
|
2859
|
-
var customBlockOpenPageErrorInfoSchema = object({
|
|
2860
|
-
code: customBlockOpenPageErrorCodeSchema,
|
|
2861
|
-
message: string(),
|
|
2862
|
-
isRetryable: boolean()
|
|
2863
|
-
});
|
|
2864
|
-
var openPageMessageSchema = object({
|
|
2865
|
-
type: literal("openPage"),
|
|
2866
|
-
requestId: string(),
|
|
2867
|
-
pageId: notionPageIdSchema,
|
|
2868
|
-
mode: openPageModeSchema
|
|
2869
|
-
});
|
|
2870
|
-
var openPageResultMessageSchema = variant("status", [
|
|
2871
|
-
object({
|
|
2872
|
-
type: literal("openPageResult"),
|
|
2873
|
-
requestId: string(),
|
|
2874
|
-
status: literal("success"),
|
|
2875
|
-
pageId: notionPageIdSchema
|
|
2876
|
-
}),
|
|
2877
|
-
object({
|
|
2878
|
-
type: literal("openPageResult"),
|
|
2879
|
-
requestId: string(),
|
|
2880
|
-
status: literal("error"),
|
|
2881
|
-
error: customBlockOpenPageErrorInfoSchema
|
|
2882
|
-
})
|
|
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
|
-
]);
|
|
2896
|
-
|
|
2897
3118
|
// ../protocol/src/pages/messages/updatePage.ts
|
|
2898
3119
|
var customBlockUpdatePageErrorCodeSchema = string();
|
|
2899
3120
|
var customBlockUpdatePageErrorInfoSchema = object({
|
|
@@ -2960,6 +3181,93 @@ var keyedUpdatePageMessageSchema = variant("type", [
|
|
|
2960
3181
|
})
|
|
2961
3182
|
]);
|
|
2962
3183
|
|
|
3184
|
+
// ../protocol/src/pages/messages/pageResults.ts
|
|
3185
|
+
var pageReadResultMessageSchema = variant("status", [
|
|
3186
|
+
object({
|
|
3187
|
+
...omit(getPageResultMessageSchema.options[0], ["propertyIdsByKey"]).entries,
|
|
3188
|
+
propertyIdsByKey: exactOptional(never()),
|
|
3189
|
+
page: bridgePageSnapshotSchema
|
|
3190
|
+
}),
|
|
3191
|
+
getPageResultMessageSchema.options[1]
|
|
3192
|
+
]);
|
|
3193
|
+
var pageCreateResultMessageSchema = variant("status", [
|
|
3194
|
+
object({
|
|
3195
|
+
...omit(createPageResultMessageSchema.options[0], ["propertyIdsByKey"]).entries,
|
|
3196
|
+
propertyIdsByKey: exactOptional(never()),
|
|
3197
|
+
page: identifiedPageSnapshotSchema
|
|
3198
|
+
}),
|
|
3199
|
+
createPageResultMessageSchema.options[1]
|
|
3200
|
+
]);
|
|
3201
|
+
var pageUpdateResultMessageSchema = variant("status", [
|
|
3202
|
+
object({
|
|
3203
|
+
...omit(updatePageResultMessageSchema.options[0], ["propertyIdsByKey"]).entries,
|
|
3204
|
+
propertyIdsByKey: exactOptional(never()),
|
|
3205
|
+
page: bridgePageSnapshotSchema
|
|
3206
|
+
}),
|
|
3207
|
+
updatePageResultMessageSchema.options[1]
|
|
3208
|
+
]);
|
|
3209
|
+
var pageRecordResultMessageSchema = union([
|
|
3210
|
+
dataSourceQueryRecordResultMessageSchema,
|
|
3211
|
+
createPageResultMessageSchema,
|
|
3212
|
+
addressedGetPageResultMessageSchema,
|
|
3213
|
+
addressedUpdatePageResultMessageSchema
|
|
3214
|
+
]);
|
|
3215
|
+
|
|
3216
|
+
// ../protocol/src/pages/messages/pageSnapshots.ts
|
|
3217
|
+
var subscribeToPageMessageSchema = strictObject({
|
|
3218
|
+
type: literal("subscribeToPage"),
|
|
3219
|
+
requestId: string(),
|
|
3220
|
+
pageTarget: pageAddressSchema
|
|
3221
|
+
});
|
|
3222
|
+
var unsubscribeFromPageMessageSchema = strictObject({
|
|
3223
|
+
type: literal("unsubscribeFromPage"),
|
|
3224
|
+
requestId: string()
|
|
3225
|
+
});
|
|
3226
|
+
var subscribeToPageResultMessageSchema = variant("status", [
|
|
3227
|
+
strictObject({
|
|
3228
|
+
type: literal("subscribeToPageResult"),
|
|
3229
|
+
requestId: string(),
|
|
3230
|
+
status: literal("success")
|
|
3231
|
+
}),
|
|
3232
|
+
strictObject({
|
|
3233
|
+
type: literal("subscribeToPageResult"),
|
|
3234
|
+
requestId: string(),
|
|
3235
|
+
status: literal("error"),
|
|
3236
|
+
error: customBlockErrorInfoSchema
|
|
3237
|
+
})
|
|
3238
|
+
]);
|
|
3239
|
+
var pageSnapshotSchema = variant("type", [
|
|
3240
|
+
strictObject({ type: literal("loading") }),
|
|
3241
|
+
strictObject({
|
|
3242
|
+
type: literal("available"),
|
|
3243
|
+
page: partial(bridgePageSchema, ["id"]),
|
|
3244
|
+
propertyIdsByKey: optional(bridgePropertyIdsByKeySchema)
|
|
3245
|
+
}),
|
|
3246
|
+
strictObject({
|
|
3247
|
+
type: literal("error"),
|
|
3248
|
+
error: customBlockErrorInfoSchema
|
|
3249
|
+
})
|
|
3250
|
+
]);
|
|
3251
|
+
var pageSnapshotChangedMessageSchema = variant("status", [
|
|
3252
|
+
strictObject({
|
|
3253
|
+
type: literal("pageSnapshotChanged"),
|
|
3254
|
+
requestId: string(),
|
|
3255
|
+
status: literal("available"),
|
|
3256
|
+
page: bridgePageSnapshotSchema
|
|
3257
|
+
}),
|
|
3258
|
+
strictObject({
|
|
3259
|
+
type: literal("pageSnapshotChanged"),
|
|
3260
|
+
requestId: string(),
|
|
3261
|
+
status: literal("loading")
|
|
3262
|
+
}),
|
|
3263
|
+
strictObject({
|
|
3264
|
+
type: literal("pageSnapshotChanged"),
|
|
3265
|
+
requestId: string(),
|
|
3266
|
+
status: literal("error"),
|
|
3267
|
+
error: customBlockErrorInfoSchema
|
|
3268
|
+
})
|
|
3269
|
+
]);
|
|
3270
|
+
|
|
2963
3271
|
// ../protocol/src/users/bridgeUser.ts
|
|
2964
3272
|
var bridgeUserSchema = object({
|
|
2965
3273
|
object: literal("user"),
|
|
@@ -3020,6 +3328,42 @@ var getUserResultMessageSchema = variant("status", [
|
|
|
3020
3328
|
})
|
|
3021
3329
|
]);
|
|
3022
3330
|
|
|
3331
|
+
// ../protocol/src/users/userSnapshot.ts
|
|
3332
|
+
var userTargetSchema = object({
|
|
3333
|
+
type: literal("user_id"),
|
|
3334
|
+
userId: notionUserIdSchema
|
|
3335
|
+
});
|
|
3336
|
+
var bridgeUserSnapshotSchema = object({
|
|
3337
|
+
id: notionUserIdSchema,
|
|
3338
|
+
name: nullable(string()),
|
|
3339
|
+
avatarUrl: nullable(string()),
|
|
3340
|
+
email: optional(nullable(string()))
|
|
3341
|
+
});
|
|
3342
|
+
|
|
3343
|
+
// ../protocol/src/users/messages/getUserSnapshot.ts
|
|
3344
|
+
var getUserSnapshotMessageSchema = object({
|
|
3345
|
+
type: literal("getUserSnapshot"),
|
|
3346
|
+
requestId: string(),
|
|
3347
|
+
target: userTargetSchema,
|
|
3348
|
+
includeEmail: optional(boolean())
|
|
3349
|
+
});
|
|
3350
|
+
var getUserSnapshotResultMessageSchema = variant("status", [
|
|
3351
|
+
object({
|
|
3352
|
+
type: literal("getUserSnapshotResult"),
|
|
3353
|
+
requestId: string(),
|
|
3354
|
+
email: exactOptional(never()),
|
|
3355
|
+
status: literal("success"),
|
|
3356
|
+
user: bridgeUserSnapshotSchema
|
|
3357
|
+
}),
|
|
3358
|
+
object({
|
|
3359
|
+
type: literal("getUserSnapshotResult"),
|
|
3360
|
+
requestId: string(),
|
|
3361
|
+
email: exactOptional(never()),
|
|
3362
|
+
status: literal("error"),
|
|
3363
|
+
error: customBlockErrorInfoSchema
|
|
3364
|
+
})
|
|
3365
|
+
]);
|
|
3366
|
+
|
|
3023
3367
|
// ../protocol/src/users/viewer.ts
|
|
3024
3368
|
var bridgeViewerSchema = variant("type", [
|
|
3025
3369
|
object({
|
|
@@ -3087,6 +3431,96 @@ var listUsersResultMessageSchema = variant("status", [
|
|
|
3087
3431
|
})
|
|
3088
3432
|
]);
|
|
3089
3433
|
|
|
3434
|
+
// ../protocol/src/users/messages/userField.ts
|
|
3435
|
+
var userFieldSchema = picklist(["name", "avatarUrl", "email"]);
|
|
3436
|
+
var userFieldDataSchema = strictObject({
|
|
3437
|
+
name: optional(nullable(string())),
|
|
3438
|
+
avatarUrl: optional(nullable(string())),
|
|
3439
|
+
email: optional(nullable(string()))
|
|
3440
|
+
});
|
|
3441
|
+
|
|
3442
|
+
// ../protocol/src/users/messages/listUserReferences.ts
|
|
3443
|
+
var listUserReferencesMessageSchema = strictObject({
|
|
3444
|
+
type: literal("listUserReferences"),
|
|
3445
|
+
requestId: string(),
|
|
3446
|
+
startCursor: optional(string()),
|
|
3447
|
+
pageSize: optional(number()),
|
|
3448
|
+
includeEmail: optional(boolean())
|
|
3449
|
+
});
|
|
3450
|
+
var pagination = { nextCursor: nullable(string()), hasMore: boolean() };
|
|
3451
|
+
var pageSchema = strictObject({
|
|
3452
|
+
...pagination,
|
|
3453
|
+
users: array(
|
|
3454
|
+
strictObject({ userId: notionUserIdSchema, fields: userFieldDataSchema })
|
|
3455
|
+
)
|
|
3456
|
+
});
|
|
3457
|
+
var envelope = {
|
|
3458
|
+
type: literal("listUserReferencesResult"),
|
|
3459
|
+
requestId: string()
|
|
3460
|
+
};
|
|
3461
|
+
var listUserReferencesResultMessageSchema = variant("status", [
|
|
3462
|
+
strictObject({
|
|
3463
|
+
...envelope,
|
|
3464
|
+
status: literal("success"),
|
|
3465
|
+
...pagination,
|
|
3466
|
+
users: array(bridgeUserSnapshotSchema)
|
|
3467
|
+
}),
|
|
3468
|
+
strictObject({
|
|
3469
|
+
...envelope,
|
|
3470
|
+
status: literal("error"),
|
|
3471
|
+
error: customBlockListUsersErrorInfoSchema
|
|
3472
|
+
})
|
|
3473
|
+
]);
|
|
3474
|
+
|
|
3475
|
+
// ../protocol/src/users/messages/userSnapshots.ts
|
|
3476
|
+
var subscribeToUserMessageSchema = object({
|
|
3477
|
+
type: literal("subscribeToUser"),
|
|
3478
|
+
requestId: string(),
|
|
3479
|
+
userTarget: userTargetSchema,
|
|
3480
|
+
includeEmail: optional(boolean())
|
|
3481
|
+
});
|
|
3482
|
+
var subscribeToUserResultMessageSchema = variant("status", [
|
|
3483
|
+
object({
|
|
3484
|
+
type: literal("subscribeToUserResult"),
|
|
3485
|
+
requestId: string(),
|
|
3486
|
+
email: exactOptional(never()),
|
|
3487
|
+
status: literal("success")
|
|
3488
|
+
}),
|
|
3489
|
+
object({
|
|
3490
|
+
type: literal("subscribeToUserResult"),
|
|
3491
|
+
requestId: string(),
|
|
3492
|
+
email: exactOptional(never()),
|
|
3493
|
+
status: literal("error"),
|
|
3494
|
+
error: customBlockErrorInfoSchema
|
|
3495
|
+
})
|
|
3496
|
+
]);
|
|
3497
|
+
var userSnapshotChangedMessageSchema = variant("status", [
|
|
3498
|
+
object({
|
|
3499
|
+
type: literal("userSnapshotChanged"),
|
|
3500
|
+
requestId: string(),
|
|
3501
|
+
email: exactOptional(never()),
|
|
3502
|
+
status: literal("available"),
|
|
3503
|
+
user: bridgeUserSnapshotSchema
|
|
3504
|
+
}),
|
|
3505
|
+
object({
|
|
3506
|
+
type: literal("userSnapshotChanged"),
|
|
3507
|
+
requestId: string(),
|
|
3508
|
+
email: exactOptional(never()),
|
|
3509
|
+
status: literal("loading")
|
|
3510
|
+
}),
|
|
3511
|
+
object({
|
|
3512
|
+
type: literal("userSnapshotChanged"),
|
|
3513
|
+
requestId: string(),
|
|
3514
|
+
email: exactOptional(never()),
|
|
3515
|
+
status: literal("error"),
|
|
3516
|
+
error: customBlockErrorInfoSchema
|
|
3517
|
+
})
|
|
3518
|
+
]);
|
|
3519
|
+
var unsubscribeFromUserMessageSchema = object({
|
|
3520
|
+
type: literal("unsubscribeFromUser"),
|
|
3521
|
+
requestId: string()
|
|
3522
|
+
});
|
|
3523
|
+
|
|
3090
3524
|
// ../protocol/src/messages/invalidSandboxMessage.ts
|
|
3091
3525
|
var invalidSandboxMessageSchema = object({
|
|
3092
3526
|
type: literal("invalidSandboxMessage"),
|
|
@@ -3115,18 +3549,44 @@ var commonHostToSandboxSchemas = [
|
|
|
3115
3549
|
openExternalUrlResultMessageSchema,
|
|
3116
3550
|
invalidSandboxMessageSchema
|
|
3117
3551
|
];
|
|
3118
|
-
var
|
|
3552
|
+
var hostToSandboxSchemasWithoutPageResults = [
|
|
3119
3553
|
...commonHostToSandboxSchemas,
|
|
3554
|
+
listUserReferencesResultMessageSchema,
|
|
3555
|
+
getUserSnapshotResultMessageSchema,
|
|
3556
|
+
subscribeToUserResultMessageSchema,
|
|
3557
|
+
userSnapshotChangedMessageSchema,
|
|
3120
3558
|
addressedOpenPageResultMessageSchema,
|
|
3121
|
-
|
|
3559
|
+
containingPageChangedMessageSchema,
|
|
3122
3560
|
parentChangedMessageSchema,
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3561
|
+
dataSourceSnapshotChangedMessageSchema,
|
|
3562
|
+
dataSourceReadResultMessageSchema,
|
|
3563
|
+
subscribeToDataSourceResultMessageSchema,
|
|
3564
|
+
pageSnapshotChangedMessageSchema,
|
|
3565
|
+
subscribeToPageResultMessageSchema
|
|
3566
|
+
];
|
|
3567
|
+
var hostToSandboxMessageSchema = variant("type", [
|
|
3568
|
+
...hostToSandboxSchemasWithoutPageResults,
|
|
3569
|
+
dataSourceQueryResultMessageSchema,
|
|
3570
|
+
pageReadResultMessageSchema,
|
|
3571
|
+
pageCreateResultMessageSchema,
|
|
3572
|
+
pageUpdateResultMessageSchema
|
|
3573
|
+
]);
|
|
3574
|
+
|
|
3575
|
+
// ../protocol/src/pages/messages/pageRecords.ts
|
|
3576
|
+
var pageRecordHostToSandboxMessageSchema = variant("type", [
|
|
3577
|
+
...hostToSandboxSchemasWithoutPageResults,
|
|
3578
|
+
dataSourceQueryRecordResultMessageSchema,
|
|
3126
3579
|
createPageResultMessageSchema,
|
|
3580
|
+
addressedGetPageResultMessageSchema,
|
|
3127
3581
|
addressedUpdatePageResultMessageSchema
|
|
3128
3582
|
]);
|
|
3129
3583
|
|
|
3584
|
+
// ../protocol/src/context/messages/pageChanged.ts
|
|
3585
|
+
var pageChangedMessageSchema = object({
|
|
3586
|
+
type: literal("pageChanged"),
|
|
3587
|
+
page: containingPageContextSchema
|
|
3588
|
+
});
|
|
3589
|
+
|
|
3130
3590
|
// ../protocol/src/compatibility/contextThroughProtocol13.ts
|
|
3131
3591
|
var parentChangedThroughProtocol13Schema = object({
|
|
3132
3592
|
...parentChangedMessageSchema.entries,
|
|
@@ -3542,7 +4002,7 @@ var getDataSourceResultThroughProtocol13 = variant("status", [
|
|
|
3542
4002
|
}),
|
|
3543
4003
|
getDataSourceResultMessageSchema.options[1]
|
|
3544
4004
|
]);
|
|
3545
|
-
function makeHostToSandboxMessageWithPageSchema(
|
|
4005
|
+
function makeHostToSandboxMessageWithPageSchema(pageSchema2) {
|
|
3546
4006
|
return variant("type", [
|
|
3547
4007
|
...commonHostToSandboxSchemas,
|
|
3548
4008
|
openPageResultMessageSchema,
|
|
@@ -3553,28 +4013,28 @@ function makeHostToSandboxMessageWithPageSchema(pageSchema) {
|
|
|
3553
4013
|
variant("status", [
|
|
3554
4014
|
object({
|
|
3555
4015
|
...queryDataSourceResultMessageSchema.options[0].entries,
|
|
3556
|
-
items: array(
|
|
4016
|
+
items: array(pageSchema2)
|
|
3557
4017
|
}),
|
|
3558
4018
|
queryDataSourceResultMessageSchema.options[1]
|
|
3559
4019
|
]),
|
|
3560
4020
|
variant("status", [
|
|
3561
4021
|
object({
|
|
3562
4022
|
...getPageResultMessageSchema.options[0].entries,
|
|
3563
|
-
page:
|
|
4023
|
+
page: pageSchema2
|
|
3564
4024
|
}),
|
|
3565
4025
|
getPageResultMessageSchema.options[1]
|
|
3566
4026
|
]),
|
|
3567
4027
|
variant("status", [
|
|
3568
4028
|
object({
|
|
3569
4029
|
...createPageResultMessageSchema.options[0].entries,
|
|
3570
|
-
page:
|
|
4030
|
+
page: pageSchema2
|
|
3571
4031
|
}),
|
|
3572
4032
|
createPageResultMessageSchema.options[1]
|
|
3573
4033
|
]),
|
|
3574
4034
|
variant("status", [
|
|
3575
4035
|
object({
|
|
3576
4036
|
...updatePageResultMessageSchema.options[0].entries,
|
|
3577
|
-
page:
|
|
4037
|
+
page: pageSchema2
|
|
3578
4038
|
}),
|
|
3579
4039
|
updatePageResultMessageSchema.options[1]
|
|
3580
4040
|
])
|
|
@@ -3606,6 +4066,7 @@ var hostToSandboxMessageForProtocol13Schema = makeHostToSandboxMessageWithPageSc
|
|
|
3606
4066
|
// ../protocol/src/compatibility/hostToSandbox.ts
|
|
3607
4067
|
var hostToSandboxMessageWithCompatibilitySchema = union([
|
|
3608
4068
|
hostToSandboxMessageSchema,
|
|
4069
|
+
pageRecordHostToSandboxMessageSchema,
|
|
3609
4070
|
hostToSandboxMessageForProtocol13Schema,
|
|
3610
4071
|
hostToSandboxMessageForProtocol12Schema,
|
|
3611
4072
|
protocol3To11HostToSandboxMessageSchema
|
|
@@ -3759,12 +4220,21 @@ var sandboxToHostMessageSchema = variant("type", [
|
|
|
3759
4220
|
unsubscribeDataSourceQueryMessageSchema,
|
|
3760
4221
|
keyedCreatePageMessageSchema,
|
|
3761
4222
|
keyedGetPageMessageSchema,
|
|
4223
|
+
subscribeToPageMessageSchema,
|
|
4224
|
+
unsubscribeFromPageMessageSchema,
|
|
3762
4225
|
getUserMessageSchema,
|
|
3763
4226
|
listUsersMessageSchema,
|
|
4227
|
+
listUserReferencesMessageSchema,
|
|
3764
4228
|
addressedOpenPageMessageSchema,
|
|
4229
|
+
getUserSnapshotMessageSchema,
|
|
4230
|
+
subscribeToUserMessageSchema,
|
|
4231
|
+
unsubscribeFromUserMessageSchema,
|
|
3765
4232
|
openExternalUrlMessageSchema,
|
|
3766
4233
|
keyedUpdatePageMessageSchema,
|
|
3767
4234
|
resizeMessageSchema,
|
|
4235
|
+
dataSourceReadMessageSchema,
|
|
4236
|
+
subscribeToDataSourceMessageSchema,
|
|
4237
|
+
unsubscribeFromDataSourceMessageSchema,
|
|
3768
4238
|
invalidHostMessageSchema
|
|
3769
4239
|
]);
|
|
3770
4240
|
|
|
@@ -7867,6 +8337,9 @@ var sampleDataSourceSchema = variant("status", [
|
|
|
7867
8337
|
loadedSampleDataSourceSchema,
|
|
7868
8338
|
sampleDataSourceLoadErrorSchema
|
|
7869
8339
|
]);
|
|
8340
|
+
function getSampleDataSourceId(filename) {
|
|
8341
|
+
return parse(notionDataSourceIdSchema, `ds-${filename}`);
|
|
8342
|
+
}
|
|
7870
8343
|
function selectSampleDataSource({
|
|
7871
8344
|
slotKey,
|
|
7872
8345
|
sources,
|
|
@@ -7895,7 +8368,7 @@ var DEV_SHELL_STATUS_GROUP_NAMES = [
|
|
|
7895
8368
|
"Future"
|
|
7896
8369
|
];
|
|
7897
8370
|
function readDataSources(dataDir) {
|
|
7898
|
-
return
|
|
8371
|
+
return rejectConflictingPageIds(readSampleDataSources(dataDir), void 0).map((source) => {
|
|
7899
8372
|
if (source.status === "failed") {
|
|
7900
8373
|
throw new Error(
|
|
7901
8374
|
`${resolve(dataDir, `${source.filename}.json`)}: ${source.message}`
|
|
@@ -7904,7 +8377,16 @@ function readDataSources(dataDir) {
|
|
|
7904
8377
|
return source;
|
|
7905
8378
|
}).sort((left, right) => left.name.localeCompare(right.name));
|
|
7906
8379
|
}
|
|
7907
|
-
function readSampleDataSourcesSnapshot(
|
|
8380
|
+
function readSampleDataSourcesSnapshot(args) {
|
|
8381
|
+
const { dataDir, containingPageId } = args;
|
|
8382
|
+
return {
|
|
8383
|
+
dataSources: rejectConflictingPageIds(
|
|
8384
|
+
readSampleDataSources(dataDir),
|
|
8385
|
+
containingPageId
|
|
8386
|
+
)
|
|
8387
|
+
};
|
|
8388
|
+
}
|
|
8389
|
+
function readSampleDataSources(dataDir) {
|
|
7908
8390
|
const dataSources = [];
|
|
7909
8391
|
for (const name of listDataSourceFiles(dataDir).sort()) {
|
|
7910
8392
|
const filename = basename(name, ".json");
|
|
@@ -7921,9 +8403,9 @@ function readSampleDataSourcesSnapshot(dataDir) {
|
|
|
7921
8403
|
});
|
|
7922
8404
|
}
|
|
7923
8405
|
}
|
|
7924
|
-
return
|
|
8406
|
+
return dataSources;
|
|
7925
8407
|
}
|
|
7926
|
-
function
|
|
8408
|
+
function rejectConflictingPageIds(sources, containingPageId) {
|
|
7927
8409
|
const filenamesByPageId = /* @__PURE__ */ new Map();
|
|
7928
8410
|
for (const source of sources) {
|
|
7929
8411
|
if (source.status === "failed") {
|
|
@@ -7937,11 +8419,12 @@ function rejectDuplicatePageIds(sources) {
|
|
|
7937
8419
|
}
|
|
7938
8420
|
const errorsByFilename = /* @__PURE__ */ new Map();
|
|
7939
8421
|
for (const [pageId, filenames] of filenamesByPageId) {
|
|
7940
|
-
|
|
8422
|
+
const isContainingPage = pageId === containingPageId;
|
|
8423
|
+
if (!isContainingPage && filenames.length < 2) {
|
|
7941
8424
|
continue;
|
|
7942
8425
|
}
|
|
7943
8426
|
const files = [...new Set(filenames)].map((filename) => `${filename}.json`).join(", ");
|
|
7944
|
-
const message = `Duplicate page ID "${pageId}" in ${files}. Give each row a unique ID across all sample data files.`;
|
|
8427
|
+
const message = isContainingPage ? `Page ID "${pageId}" is reserved for Current page. Give the sample row a different ID.` : `Duplicate page ID "${pageId}" in ${files}. Give each row a unique ID across all sample data files.`;
|
|
7945
8428
|
for (const filename of filenames) {
|
|
7946
8429
|
if (!errorsByFilename.has(filename)) {
|
|
7947
8430
|
errorsByFilename.set(filename, message);
|
|
@@ -7973,7 +8456,13 @@ var sourcePropertySchema2 = object({
|
|
|
7973
8456
|
description: optional(string()),
|
|
7974
8457
|
type: notionPropertyTypeSchema,
|
|
7975
8458
|
options: optional(statusOptionsSchema),
|
|
7976
|
-
groups: optional(statusGroupsSchema)
|
|
8459
|
+
groups: optional(statusGroupsSchema),
|
|
8460
|
+
targetFile: optional(
|
|
8461
|
+
pipe(
|
|
8462
|
+
string(),
|
|
8463
|
+
regex(/^[^/\\]+\.json$/, "Expected a sample .json filename")
|
|
8464
|
+
)
|
|
8465
|
+
)
|
|
7977
8466
|
});
|
|
7978
8467
|
var sourceFileSchema = object({
|
|
7979
8468
|
type: optional(sampleDataSourceTypeSchema, "worker"),
|
|
@@ -8009,6 +8498,11 @@ function readDataSource(file) {
|
|
|
8009
8498
|
`${file}: schema.${propertyKey}: groups require a Status property`
|
|
8010
8499
|
);
|
|
8011
8500
|
}
|
|
8501
|
+
if (property.targetFile !== void 0 && property.type !== "relation") {
|
|
8502
|
+
throw new Error(
|
|
8503
|
+
`${file}: schema.${propertyKey}: targetFile requires a Relation property`
|
|
8504
|
+
);
|
|
8505
|
+
}
|
|
8012
8506
|
const optionIds = new Set((property.options ?? []).map((option) => option.id));
|
|
8013
8507
|
const missingOptionId = (property.groups ?? []).flatMap((group) => group.option_ids).find((optionId) => !optionIds.has(optionId));
|
|
8014
8508
|
if (missingOptionId !== void 0) {
|
|
@@ -8066,7 +8560,12 @@ function toBridgePropertySchema(propertyKey, property) {
|
|
|
8066
8560
|
...property,
|
|
8067
8561
|
name: property.name ?? propertyKey,
|
|
8068
8562
|
options: property.options ?? [],
|
|
8069
|
-
groups: property.groups ?? []
|
|
8563
|
+
groups: property.groups ?? [],
|
|
8564
|
+
...property.targetFile === void 0 ? {} : {
|
|
8565
|
+
data_source_id: getSampleDataSourceId(
|
|
8566
|
+
basename(property.targetFile, ".json")
|
|
8567
|
+
)
|
|
8568
|
+
}
|
|
8070
8569
|
});
|
|
8071
8570
|
}
|
|
8072
8571
|
|
|
@@ -8728,7 +9227,7 @@ var nativeIconMutationSchema = object({
|
|
|
8728
9227
|
var initializedHostMessageSchema = union([
|
|
8729
9228
|
openPageResultMessageSchema,
|
|
8730
9229
|
pageChangedThroughProtocol13Schema,
|
|
8731
|
-
|
|
9230
|
+
pageRecordHostToSandboxMessageSchema,
|
|
8732
9231
|
dataSourcesInvalidatedMessageSchema,
|
|
8733
9232
|
getDataSourceResultMessageSchema
|
|
8734
9233
|
]);
|
|
@@ -8923,6 +9422,26 @@ function parseDataSourceBindingOverride({
|
|
|
8923
9422
|
return { target, filename };
|
|
8924
9423
|
}
|
|
8925
9424
|
|
|
9425
|
+
// cli/bindings/parsePageBindingOverride.ts
|
|
9426
|
+
function parsePageBindingOverride(args) {
|
|
9427
|
+
const { value } = args;
|
|
9428
|
+
let separator = 0;
|
|
9429
|
+
while (separator < value.length && value[separator] !== "=") {
|
|
9430
|
+
const next = value[separator + 1];
|
|
9431
|
+
separator += value[separator] === "\\" && (next === "=" || next === "\\") ? 2 : 1;
|
|
9432
|
+
}
|
|
9433
|
+
const target = value.slice(0, separator).replace(/\\([=\\])/g, "$1");
|
|
9434
|
+
const pageId = value.slice(separator + 1);
|
|
9435
|
+
const dot = target.indexOf(".");
|
|
9436
|
+
if (dot <= 0 || dot === target.length - 1 || pageId.length === 0) {
|
|
9437
|
+
throw new DevShellLauncherBindingError({
|
|
9438
|
+
code: "invalid_page_binding_syntax",
|
|
9439
|
+
message: "--bind-page requires <capabilityKey>.<pageKey>=<pageId>."
|
|
9440
|
+
});
|
|
9441
|
+
}
|
|
9442
|
+
return { target, pageId };
|
|
9443
|
+
}
|
|
9444
|
+
|
|
8926
9445
|
// cli/bindings/parsePropertyBindingOverride.ts
|
|
8927
9446
|
function parsePropertyBindingOverride({
|
|
8928
9447
|
value
|
|
@@ -9139,7 +9658,71 @@ function buildBindingRegistry({
|
|
|
9139
9658
|
return { registryBindings, registryPropertyBindings };
|
|
9140
9659
|
}
|
|
9141
9660
|
|
|
9661
|
+
// cli/bindings/resolvePageBindingOverrides.ts
|
|
9662
|
+
function resolvePageBindingOverrides(args) {
|
|
9663
|
+
const { blocks, sources, overrides } = args;
|
|
9664
|
+
const pageIdsByBlock = /* @__PURE__ */ new Map();
|
|
9665
|
+
if (overrides.length === 0) {
|
|
9666
|
+
return { status: "success", value: pageIdsByBlock };
|
|
9667
|
+
}
|
|
9668
|
+
const slots = blocks.flatMap(
|
|
9669
|
+
(block) => Object.keys(block.config.manifest.pages ?? {}).map((pageKey) => ({
|
|
9670
|
+
blockKey: block.key,
|
|
9671
|
+
pageKey,
|
|
9672
|
+
target: `${block.key}.${pageKey}`
|
|
9673
|
+
}))
|
|
9674
|
+
);
|
|
9675
|
+
const pageIds = getLoadedSamplePageIds(sources);
|
|
9676
|
+
const seenTargets = /* @__PURE__ */ new Set();
|
|
9677
|
+
for (const { target, pageId } of overrides) {
|
|
9678
|
+
const matches = slots.filter((slot) => slot.target === target);
|
|
9679
|
+
if (matches.length === 0) {
|
|
9680
|
+
return bindingFailure(
|
|
9681
|
+
"unknown_page_binding_target",
|
|
9682
|
+
`Unknown page binding target "${target}". Available targets: ${slots.map((slot) => slot.target).join(", ") || "(none)"}.`
|
|
9683
|
+
);
|
|
9684
|
+
}
|
|
9685
|
+
if (matches.length > 1) {
|
|
9686
|
+
return bindingFailure(
|
|
9687
|
+
"ambiguous_page_binding_target",
|
|
9688
|
+
`More than one declared page slot matches "${target}".`
|
|
9689
|
+
);
|
|
9690
|
+
}
|
|
9691
|
+
if (seenTargets.has(target)) {
|
|
9692
|
+
return bindingFailure(
|
|
9693
|
+
"duplicate_page_binding_target",
|
|
9694
|
+
`Duplicate --bind-page target "${target}". Specify each target once.`
|
|
9695
|
+
);
|
|
9696
|
+
}
|
|
9697
|
+
if (!pageIds.has(pageId)) {
|
|
9698
|
+
return bindingFailure(
|
|
9699
|
+
"sample_page_not_found",
|
|
9700
|
+
`Cannot bind ${target}: no loaded sample row has ID "${pageId}".`
|
|
9701
|
+
);
|
|
9702
|
+
}
|
|
9703
|
+
seenTargets.add(target);
|
|
9704
|
+
const { blockKey, pageKey } = matches[0];
|
|
9705
|
+
pageIdsByBlock.set(blockKey, {
|
|
9706
|
+
...pageIdsByBlock.get(blockKey),
|
|
9707
|
+
[pageKey]: pageId
|
|
9708
|
+
});
|
|
9709
|
+
}
|
|
9710
|
+
return { status: "success", value: pageIdsByBlock };
|
|
9711
|
+
}
|
|
9712
|
+
function getLoadedSamplePageIds(sources) {
|
|
9713
|
+
const pageIds = /* @__PURE__ */ new Set();
|
|
9714
|
+
for (const source of sources) {
|
|
9715
|
+
if (source.status === "loaded") {
|
|
9716
|
+
for (const row of source.rows) {
|
|
9717
|
+
pageIds.add(row.id);
|
|
9718
|
+
}
|
|
9719
|
+
}
|
|
9720
|
+
}
|
|
9721
|
+
return pageIds;
|
|
9722
|
+
}
|
|
9723
|
+
|
|
9142
9724
|
// cli/dataSources/createDevShellDataService.ts
|
|
9725
|
+
import { randomUUID } from "node:crypto";
|
|
9143
9726
|
import { existsSync as existsSync3, mkdirSync as mkdirSync2, watch } from "node:fs";
|
|
9144
9727
|
import { basename as basename2, dirname } from "node:path";
|
|
9145
9728
|
|
|
@@ -9169,7 +9752,9 @@ function createDevShellDataService(options) {
|
|
|
9169
9752
|
const { dataDir, prebuiltDir, blocks, log } = options;
|
|
9170
9753
|
mkdirSync2(dataDir, { recursive: true });
|
|
9171
9754
|
const clients = /* @__PURE__ */ new Set();
|
|
9755
|
+
const containingPageId = parse(notionPageIdSchema, randomUUID());
|
|
9172
9756
|
let snapshot = {
|
|
9757
|
+
containingPageId,
|
|
9173
9758
|
blocks,
|
|
9174
9759
|
prebuiltSources: readDataSources(prebuiltDir).map((source) => ({
|
|
9175
9760
|
filename: source.filename,
|
|
@@ -9180,7 +9765,7 @@ function createDevShellDataService(options) {
|
|
|
9180
9765
|
(property) => property.name
|
|
9181
9766
|
)
|
|
9182
9767
|
})),
|
|
9183
|
-
...readSampleDataSourcesSnapshot(dataDir)
|
|
9768
|
+
...readSampleDataSourcesSnapshot({ dataDir, containingPageId })
|
|
9184
9769
|
};
|
|
9185
9770
|
let serialized = JSON.stringify(snapshot);
|
|
9186
9771
|
let timer;
|
|
@@ -9210,7 +9795,10 @@ function createDevShellDataService(options) {
|
|
|
9210
9795
|
return;
|
|
9211
9796
|
}
|
|
9212
9797
|
try {
|
|
9213
|
-
snapshot = {
|
|
9798
|
+
snapshot = {
|
|
9799
|
+
...snapshot,
|
|
9800
|
+
...readSampleDataSourcesSnapshot({ dataDir, containingPageId })
|
|
9801
|
+
};
|
|
9214
9802
|
publish();
|
|
9215
9803
|
} catch (error) {
|
|
9216
9804
|
fail(error);
|
|
@@ -20333,7 +20921,8 @@ function parseWorkerLaunchOptions(options) {
|
|
|
20333
20921
|
strictPort: false,
|
|
20334
20922
|
json: false,
|
|
20335
20923
|
bindings: [],
|
|
20336
|
-
propertyBindings: []
|
|
20924
|
+
propertyBindings: [],
|
|
20925
|
+
pageBindings: []
|
|
20337
20926
|
};
|
|
20338
20927
|
let hasPositionalWorker = false;
|
|
20339
20928
|
const bindDataSource = (value) => {
|
|
@@ -20353,6 +20942,9 @@ function parseWorkerLaunchOptions(options) {
|
|
|
20353
20942
|
"--bind-property": (value) => {
|
|
20354
20943
|
args.propertyBindings.push(parsePropertyBindingOverride({ value }));
|
|
20355
20944
|
},
|
|
20945
|
+
"--bind-page": (value) => {
|
|
20946
|
+
args.pageBindings.push(parsePageBindingOverride({ value }));
|
|
20947
|
+
},
|
|
20356
20948
|
"--worker": (value) => {
|
|
20357
20949
|
if (value.length === 0) {
|
|
20358
20950
|
throw new Error("--worker requires a path to a worker directory.");
|
|
@@ -20371,7 +20963,7 @@ function parseWorkerLaunchOptions(options) {
|
|
|
20371
20963
|
},
|
|
20372
20964
|
onUnknown: (arg) => {
|
|
20373
20965
|
throw new Error(
|
|
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.`
|
|
20966
|
+
`Unknown dev shell option "${arg}". Supported: --worker <dir>, --port <port>, --json, --bind-data-source <capabilityKey>.<dataSourceKey>=<sampleDataFileName>, --bind-property <capabilityKey>.<dataSourceKey>.<propertyKey>=<sourcePropertyKey>, --bind-page <capabilityKey>.<pageKey>=<pageId>. --bind is a deprecated alias for --bind-data-source.`
|
|
20375
20967
|
);
|
|
20376
20968
|
},
|
|
20377
20969
|
onPositional: (arg) => {
|
|
@@ -20432,8 +21024,9 @@ function logWorkerPlan(workerName, plan, snapshot) {
|
|
|
20432
21024
|
);
|
|
20433
21025
|
}
|
|
20434
21026
|
function applyBindingsAndLog(args, plan, workerDir, snapshot) {
|
|
21027
|
+
const blocks = plan.blocks.map((block) => block.capability);
|
|
20435
21028
|
const result = resolveDevShellLauncherBindings({
|
|
20436
|
-
blocks
|
|
21029
|
+
blocks,
|
|
20437
21030
|
dataSourceResults: snapshot.dataSources,
|
|
20438
21031
|
sourceOverrides: args.bindings,
|
|
20439
21032
|
propertyOverrides: args.propertyBindings
|
|
@@ -20441,10 +21034,19 @@ function applyBindingsAndLog(args, plan, workerDir, snapshot) {
|
|
|
20441
21034
|
if (result.status === "error") {
|
|
20442
21035
|
throw result.error;
|
|
20443
21036
|
}
|
|
21037
|
+
const pages = resolvePageBindingOverrides({
|
|
21038
|
+
blocks,
|
|
21039
|
+
sources: snapshot.dataSources,
|
|
21040
|
+
overrides: args.pageBindings
|
|
21041
|
+
});
|
|
21042
|
+
if (pages.status === "error") {
|
|
21043
|
+
throw pages.error;
|
|
21044
|
+
}
|
|
20444
21045
|
const { registryBindings, registryPropertyBindings } = result.value;
|
|
20445
21046
|
for (const entry of plan.registry) {
|
|
20446
21047
|
entry.propertyIdsByDataSource = registryPropertyBindings.get(entry.key) ?? {};
|
|
20447
21048
|
entry.sampleFilesByDataSource = registryBindings.get(entry.key) ?? {};
|
|
21049
|
+
entry.initialPageIdsByKey = pages.value.get(entry.key);
|
|
20448
21050
|
}
|
|
20449
21051
|
logWorkerPlan(basename3(workerDir), plan, snapshot);
|
|
20450
21052
|
}
|
|
@@ -20533,6 +21135,7 @@ async function launchDevShell(options) {
|
|
|
20533
21135
|
return;
|
|
20534
21136
|
}
|
|
20535
21137
|
const { dataSources } = dataService.refreshSnapshot();
|
|
21138
|
+
const availablePageIds = args.pageBindings.length > 0 ? getLoadedSamplePageIds(dataSources) : void 0;
|
|
20536
21139
|
writeStartupEvent({
|
|
20537
21140
|
event: "ready",
|
|
20538
21141
|
version: 1,
|
|
@@ -20542,6 +21145,7 @@ async function launchDevShell(options) {
|
|
|
20542
21145
|
workerManifestPath: relative2(workerDir, plan.manifestPath).split(sep).join("/"),
|
|
20543
21146
|
customBlocks: plan.registry.map((block) => {
|
|
20544
21147
|
const pageKeys = Object.keys(block.manifest.pages ?? {});
|
|
21148
|
+
const initialPageIdsByKey = block.initialPageIdsByKey ?? {};
|
|
20545
21149
|
return {
|
|
20546
21150
|
key: block.key,
|
|
20547
21151
|
url: block.url,
|
|
@@ -20551,7 +21155,16 @@ async function launchDevShell(options) {
|
|
|
20551
21155
|
dataSources
|
|
20552
21156
|
),
|
|
20553
21157
|
pages: pageKeys.length === 0 ? void 0 : Object.fromEntries(
|
|
20554
|
-
pageKeys.map((key) =>
|
|
21158
|
+
pageKeys.map((key) => {
|
|
21159
|
+
const selectedPageId = Object.hasOwn(
|
|
21160
|
+
initialPageIdsByKey,
|
|
21161
|
+
key
|
|
21162
|
+
) ? initialPageIdsByKey[key] : void 0;
|
|
21163
|
+
return [
|
|
21164
|
+
key,
|
|
21165
|
+
selectedPageId === void 0 || !availablePageIds?.has(selectedPageId) ? { status: "page_binding_missing" } : { status: "complete", selectedPageId }
|
|
21166
|
+
];
|
|
21167
|
+
})
|
|
20555
21168
|
)
|
|
20556
21169
|
}
|
|
20557
21170
|
};
|