@notionhq/custom-blocks-dev-shell 0.4.2 → 0.4.4
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 +3 -0
- package/data/projects.json +36 -3
- package/dist/assets/index-B1RObNc_.js +12 -0
- package/dist/index.html +1 -1
- package/dist-cli/cli/published-cli.js +270 -164
- package/docs/data-sources.md +25 -1
- package/package.json +1 -1
- package/dist/assets/index-BPt5jNdQ.js +0 -12
package/dist/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Workers local shell</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-B1RObNc_.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-CohEBjwO.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
@@ -310,6 +310,20 @@ function getFallback(schema, dataset, config$1) {
|
|
|
310
310
|
return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
|
|
311
311
|
}
|
|
312
312
|
// @__NO_SIDE_EFFECTS__
|
|
313
|
+
function fallback(schema, fallback$1) {
|
|
314
|
+
return _standardSchema({
|
|
315
|
+
...schema,
|
|
316
|
+
fallback: fallback$1,
|
|
317
|
+
"~run"(dataset, config$1) {
|
|
318
|
+
const outputDataset = schema["~run"](dataset, config$1);
|
|
319
|
+
return outputDataset.issues ? {
|
|
320
|
+
typed: true,
|
|
321
|
+
value: /* @__PURE__ */ getFallback(this, outputDataset, config$1)
|
|
322
|
+
} : outputDataset;
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
// @__NO_SIDE_EFFECTS__
|
|
313
327
|
function getDefault(schema, dataset, config$1) {
|
|
314
328
|
return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
|
|
315
329
|
}
|
|
@@ -379,6 +393,23 @@ function boolean(message$1) {
|
|
|
379
393
|
});
|
|
380
394
|
}
|
|
381
395
|
// @__NO_SIDE_EFFECTS__
|
|
396
|
+
function custom(check$1, message$1) {
|
|
397
|
+
return _standardSchema({
|
|
398
|
+
kind: "schema",
|
|
399
|
+
type: "custom",
|
|
400
|
+
reference: custom,
|
|
401
|
+
expects: "unknown",
|
|
402
|
+
async: false,
|
|
403
|
+
check: check$1,
|
|
404
|
+
message: message$1,
|
|
405
|
+
"~run"(dataset, config$1) {
|
|
406
|
+
if (this.check(dataset.value)) dataset.typed = true;
|
|
407
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
408
|
+
return dataset;
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
// @__NO_SIDE_EFFECTS__
|
|
382
413
|
function literal(literal_, message$1) {
|
|
383
414
|
return _standardSchema({
|
|
384
415
|
kind: "schema",
|
|
@@ -1233,6 +1264,15 @@ var customBlockErrorInfoSchema = object({
|
|
|
1233
1264
|
message: string(),
|
|
1234
1265
|
isRetryable: boolean()
|
|
1235
1266
|
});
|
|
1267
|
+
var customBlockErrorDetailsSchema = custom(
|
|
1268
|
+
(value) => {
|
|
1269
|
+
if (value === null || typeof value !== "object") {
|
|
1270
|
+
return false;
|
|
1271
|
+
}
|
|
1272
|
+
const prototype = Object.getPrototypeOf(value);
|
|
1273
|
+
return prototype === Object.prototype || prototype === null;
|
|
1274
|
+
}
|
|
1275
|
+
);
|
|
1236
1276
|
|
|
1237
1277
|
// ../protocol/src/compatibility/protocol3To11/connect.ts
|
|
1238
1278
|
var connectMessageCommonEntries = {
|
|
@@ -1478,7 +1518,7 @@ var contrastModeChangedMessageSchema = object({
|
|
|
1478
1518
|
});
|
|
1479
1519
|
|
|
1480
1520
|
// ../protocol/src/context/containingPage.ts
|
|
1481
|
-
var
|
|
1521
|
+
var containingPageSchema = variant("type", [
|
|
1482
1522
|
/** The viewer cannot access the containing page. Its ID and parent are not exposed. */
|
|
1483
1523
|
object({ type: literal("unavailable") }),
|
|
1484
1524
|
/** The accessible containing page, with its ID and parent location. */
|
|
@@ -1502,7 +1542,7 @@ var customBlockPageSchema = variant("type", [
|
|
|
1502
1542
|
// ../protocol/src/context/messages/pageChanged.ts
|
|
1503
1543
|
var pageChangedMessageSchema = object({
|
|
1504
1544
|
type: literal("pageChanged"),
|
|
1505
|
-
page:
|
|
1545
|
+
page: containingPageSchema
|
|
1506
1546
|
});
|
|
1507
1547
|
|
|
1508
1548
|
// ../protocol/src/context/messages/pageError.ts
|
|
@@ -1571,6 +1611,14 @@ var bridgeFilePropertyItemSchema = union([
|
|
|
1571
1611
|
object({ ...bridgeExternalFileSchema.entries, name: string() }),
|
|
1572
1612
|
object({ ...bridgeNotionHostedFileSchema.entries, name: string() })
|
|
1573
1613
|
]);
|
|
1614
|
+
var bridgeUnavailableFilePropertyItemSchema = object({
|
|
1615
|
+
type: literal("unavailable"),
|
|
1616
|
+
name: optional(string())
|
|
1617
|
+
});
|
|
1618
|
+
var bridgeFilePropertyReadItemSchema = union([
|
|
1619
|
+
...bridgeFilePropertyItemSchema.options,
|
|
1620
|
+
bridgeUnavailableFilePropertyItemSchema
|
|
1621
|
+
]);
|
|
1574
1622
|
|
|
1575
1623
|
// ../protocol/src/icons.ts
|
|
1576
1624
|
var bridgeIconNameSchema = string();
|
|
@@ -1771,7 +1819,7 @@ var notionUserInputSchema = union([
|
|
|
1771
1819
|
|
|
1772
1820
|
// ../protocol/src/pages/properties/bridgePagePropertyValue.ts
|
|
1773
1821
|
var pagePropertyBaseSchema = { id: string() };
|
|
1774
|
-
var
|
|
1822
|
+
var basePropertySchemas = [
|
|
1775
1823
|
object({
|
|
1776
1824
|
...pagePropertyBaseSchema,
|
|
1777
1825
|
type: literal("title"),
|
|
@@ -1838,11 +1886,6 @@ var bridgePagePropertyValueSchema = variant("type", [
|
|
|
1838
1886
|
has_more: optional(boolean()),
|
|
1839
1887
|
relation: array(notionRelationInputSchema)
|
|
1840
1888
|
}),
|
|
1841
|
-
object({
|
|
1842
|
-
...pagePropertyBaseSchema,
|
|
1843
|
-
type: literal("files"),
|
|
1844
|
-
files: array(bridgeFilePropertyItemSchema)
|
|
1845
|
-
}),
|
|
1846
1889
|
object({
|
|
1847
1890
|
...pagePropertyBaseSchema,
|
|
1848
1891
|
type: literal("place"),
|
|
@@ -1893,16 +1936,33 @@ var bridgePagePropertyValueSchema = variant("type", [
|
|
|
1893
1936
|
type: literal("verification"),
|
|
1894
1937
|
verification: string()
|
|
1895
1938
|
})
|
|
1939
|
+
];
|
|
1940
|
+
var bridgePagePropertyWriteValueSchema = variant("type", [
|
|
1941
|
+
...basePropertySchemas,
|
|
1942
|
+
object({
|
|
1943
|
+
...pagePropertyBaseSchema,
|
|
1944
|
+
type: literal("files"),
|
|
1945
|
+
files: array(bridgeFilePropertyItemSchema)
|
|
1946
|
+
})
|
|
1947
|
+
]);
|
|
1948
|
+
var bridgeFilesPropertyReadValueSchema = object({
|
|
1949
|
+
...pagePropertyBaseSchema,
|
|
1950
|
+
type: literal("files"),
|
|
1951
|
+
files: array(bridgeFilePropertyReadItemSchema)
|
|
1952
|
+
});
|
|
1953
|
+
var bridgePagePropertyReadValueSchema = variant("type", [
|
|
1954
|
+
...basePropertySchemas,
|
|
1955
|
+
bridgeFilesPropertyReadValueSchema
|
|
1896
1956
|
]);
|
|
1897
1957
|
|
|
1898
1958
|
// ../protocol/src/pages/properties/bridgePagePropertyMaps.ts
|
|
1899
1959
|
var bridgePagePropertyWriteMapSchema = record(
|
|
1900
1960
|
string(),
|
|
1901
|
-
|
|
1961
|
+
bridgePagePropertyWriteValueSchema
|
|
1902
1962
|
);
|
|
1903
1963
|
var bridgePagePropertyReadMapSchema = record(
|
|
1904
1964
|
string(),
|
|
1905
|
-
nullable(
|
|
1965
|
+
nullable(bridgePagePropertyReadValueSchema)
|
|
1906
1966
|
);
|
|
1907
1967
|
|
|
1908
1968
|
// ../protocol/src/pages/bridgePage.ts
|
|
@@ -2252,7 +2312,8 @@ var customBlockQueryDataSourceErrorCodeSchema = string();
|
|
|
2252
2312
|
var customBlockQueryDataSourceErrorInfoSchema = object({
|
|
2253
2313
|
code: customBlockQueryDataSourceErrorCodeSchema,
|
|
2254
2314
|
message: string(),
|
|
2255
|
-
isRetryable: boolean()
|
|
2315
|
+
isRetryable: boolean(),
|
|
2316
|
+
details: fallback(optional(customBlockErrorDetailsSchema), void 0)
|
|
2256
2317
|
});
|
|
2257
2318
|
var queryDataSourceResultMessageSchema = variant("status", [
|
|
2258
2319
|
object({
|
|
@@ -2392,7 +2453,8 @@ var customBlockGetPageErrorCodeSchema = string();
|
|
|
2392
2453
|
var customBlockGetPageErrorInfoSchema = object({
|
|
2393
2454
|
code: customBlockGetPageErrorCodeSchema,
|
|
2394
2455
|
message: string(),
|
|
2395
|
-
isRetryable: boolean()
|
|
2456
|
+
isRetryable: boolean(),
|
|
2457
|
+
details: fallback(optional(customBlockErrorDetailsSchema), void 0)
|
|
2396
2458
|
});
|
|
2397
2459
|
var getPageMessageSchema = object({
|
|
2398
2460
|
type: literal("getPage"),
|
|
@@ -2624,7 +2686,7 @@ var invalidSandboxMessageSchema = object({
|
|
|
2624
2686
|
});
|
|
2625
2687
|
|
|
2626
2688
|
// ../protocol/src/messages/hostToSandbox.ts
|
|
2627
|
-
var
|
|
2689
|
+
var commonHostToSandboxSchemas = [
|
|
2628
2690
|
connectResultMessageSchema,
|
|
2629
2691
|
setupInitMessageSchema,
|
|
2630
2692
|
getDataSourceResultMessageSchema,
|
|
@@ -2641,13 +2703,25 @@ var hostToSandboxMessageSchema = variant("type", [
|
|
|
2641
2703
|
listUsersResultMessageSchema,
|
|
2642
2704
|
openPageResultMessageSchema,
|
|
2643
2705
|
openExternalUrlResultMessageSchema,
|
|
2644
|
-
invalidSandboxMessageSchema
|
|
2706
|
+
invalidSandboxMessageSchema
|
|
2707
|
+
];
|
|
2708
|
+
var hostToSandboxMessageSchema = variant("type", [
|
|
2709
|
+
...commonHostToSandboxSchemas,
|
|
2645
2710
|
queryDataSourceResultMessageSchema,
|
|
2646
2711
|
getPageResultMessageSchema,
|
|
2647
2712
|
createPageResultMessageSchema,
|
|
2648
2713
|
updatePageResultMessageSchema
|
|
2649
2714
|
]);
|
|
2650
2715
|
|
|
2716
|
+
// ../protocol/src/compatibility/protocol12/page.ts
|
|
2717
|
+
var bridgePageForProtocol12Schema = object({
|
|
2718
|
+
...bridgePageSchema.entries,
|
|
2719
|
+
properties: record(
|
|
2720
|
+
string(),
|
|
2721
|
+
nullable(bridgePagePropertyWriteValueSchema)
|
|
2722
|
+
)
|
|
2723
|
+
});
|
|
2724
|
+
|
|
2651
2725
|
// ../protocol/src/compatibility/protocol3To5/bridgePage.ts
|
|
2652
2726
|
var bridgePageForProtocol3To5Schema = object({
|
|
2653
2727
|
object: literal("page"),
|
|
@@ -2693,7 +2767,10 @@ var createPageResultMessageWithProtocol3To5CompatibilitySchema = variant("status
|
|
|
2693
2767
|
requestId: string(),
|
|
2694
2768
|
status: literal("success"),
|
|
2695
2769
|
/** The newly created page. */
|
|
2696
|
-
page: union([
|
|
2770
|
+
page: union([
|
|
2771
|
+
bridgePageForProtocol12Schema,
|
|
2772
|
+
bridgePageForProtocol3To5Schema
|
|
2773
|
+
])
|
|
2697
2774
|
}),
|
|
2698
2775
|
object({
|
|
2699
2776
|
type: literal("createPageResult"),
|
|
@@ -2707,7 +2784,10 @@ var getPageResultMessageWithProtocol3To5CompatibilitySchema = variant("status",
|
|
|
2707
2784
|
type: literal("getPageResult"),
|
|
2708
2785
|
requestId: string(),
|
|
2709
2786
|
status: literal("success"),
|
|
2710
|
-
page: union([
|
|
2787
|
+
page: union([
|
|
2788
|
+
bridgePageForProtocol12Schema,
|
|
2789
|
+
bridgePageForProtocol3To5Schema
|
|
2790
|
+
])
|
|
2711
2791
|
}),
|
|
2712
2792
|
object({
|
|
2713
2793
|
type: literal("getPageResult"),
|
|
@@ -2721,7 +2801,10 @@ var updatePageResultMessageWithProtocol3To5CompatibilitySchema = variant("status
|
|
|
2721
2801
|
type: literal("updatePageResult"),
|
|
2722
2802
|
requestId: string(),
|
|
2723
2803
|
status: literal("success"),
|
|
2724
|
-
page: union([
|
|
2804
|
+
page: union([
|
|
2805
|
+
bridgePageForProtocol12Schema,
|
|
2806
|
+
bridgePageForProtocol3To5Schema
|
|
2807
|
+
])
|
|
2725
2808
|
}),
|
|
2726
2809
|
object({
|
|
2727
2810
|
type: literal("updatePageResult"),
|
|
@@ -2736,7 +2819,10 @@ var queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema = variant("s
|
|
|
2736
2819
|
subscriptionId: string(),
|
|
2737
2820
|
status: literal("success"),
|
|
2738
2821
|
items: array(
|
|
2739
|
-
union([
|
|
2822
|
+
union([
|
|
2823
|
+
bridgePageForProtocol12Schema,
|
|
2824
|
+
notionDataSourcePageForProtocol3To5Schema
|
|
2825
|
+
])
|
|
2740
2826
|
),
|
|
2741
2827
|
hasMore: boolean(),
|
|
2742
2828
|
limitClamp: optional(bridgeDataSourceQueryLimitClampSchema)
|
|
@@ -2951,119 +3037,6 @@ var notionDataSourceSchema = object({
|
|
|
2951
3037
|
// ../protocol/src/utils/readRequestId.ts
|
|
2952
3038
|
var requestIdentitySchema = object({ requestId: string() });
|
|
2953
3039
|
|
|
2954
|
-
// shared/dataSources/localPropertyValues.ts
|
|
2955
|
-
var stringValue = string();
|
|
2956
|
-
var numberValue = pipe(number(), finite());
|
|
2957
|
-
var booleanValue = boolean();
|
|
2958
|
-
var stringArrayValue = array(string());
|
|
2959
|
-
var pointerArrayValue = array(notionRecordPointerSchema);
|
|
2960
|
-
var anyLocalValue = union([
|
|
2961
|
-
stringValue,
|
|
2962
|
-
numberValue,
|
|
2963
|
-
booleanValue,
|
|
2964
|
-
notionDateValueSchema,
|
|
2965
|
-
stringArrayValue,
|
|
2966
|
-
pointerArrayValue
|
|
2967
|
-
]);
|
|
2968
|
-
var bindingValueSchemas = {
|
|
2969
|
-
title: stringValue,
|
|
2970
|
-
rich_text: stringValue,
|
|
2971
|
-
url: stringValue,
|
|
2972
|
-
email: stringValue,
|
|
2973
|
-
phone_number: stringValue,
|
|
2974
|
-
select: stringValue,
|
|
2975
|
-
status: stringValue,
|
|
2976
|
-
number: numberValue,
|
|
2977
|
-
checkbox: booleanValue,
|
|
2978
|
-
multi_select: stringArrayValue,
|
|
2979
|
-
date: notionDateValueSchema,
|
|
2980
|
-
created_time: notionDateValueSchema,
|
|
2981
|
-
last_edited_time: notionDateValueSchema,
|
|
2982
|
-
people: pointerArrayValue,
|
|
2983
|
-
relation: pointerArrayValue,
|
|
2984
|
-
files: stringValue
|
|
2985
|
-
};
|
|
2986
|
-
var convertedValueSchemas = {
|
|
2987
|
-
...bindingValueSchemas,
|
|
2988
|
-
created_by: pointerArrayValue,
|
|
2989
|
-
last_edited_by: pointerArrayValue,
|
|
2990
|
-
unique_id: stringValue,
|
|
2991
|
-
formula: stringValue,
|
|
2992
|
-
rollup: stringValue,
|
|
2993
|
-
verification: stringValue,
|
|
2994
|
-
place: stringValue
|
|
2995
|
-
};
|
|
2996
|
-
function matchesConvertedPropertyType(value, type) {
|
|
2997
|
-
const schema = is(notionPropertyTypeSchema, type) ? convertedValueSchemas[type] : void 0;
|
|
2998
|
-
return is(schema ?? anyLocalValue, value);
|
|
2999
|
-
}
|
|
3000
|
-
function isConvertedDataSourceValue(value) {
|
|
3001
|
-
return is(anyLocalValue, value);
|
|
3002
|
-
}
|
|
3003
|
-
|
|
3004
|
-
// cli/diagnostics/formatUnknownError.ts
|
|
3005
|
-
function formatUnknownError(error) {
|
|
3006
|
-
return error instanceof Error ? error.message : String(error);
|
|
3007
|
-
}
|
|
3008
|
-
|
|
3009
|
-
// cli/utils/claimUniqueKey.ts
|
|
3010
|
-
function claimUniqueKey(base, used) {
|
|
3011
|
-
let key = base;
|
|
3012
|
-
for (let counter = 2; used.has(key); counter++) {
|
|
3013
|
-
key = `${base}_${counter}`;
|
|
3014
|
-
}
|
|
3015
|
-
used.add(key);
|
|
3016
|
-
return key;
|
|
3017
|
-
}
|
|
3018
|
-
|
|
3019
|
-
// cli/utils/parseCliArgs.ts
|
|
3020
|
-
function parseCliArgs({
|
|
3021
|
-
argv,
|
|
3022
|
-
handlers,
|
|
3023
|
-
flags = {},
|
|
3024
|
-
onUnknown,
|
|
3025
|
-
onPositional
|
|
3026
|
-
}) {
|
|
3027
|
-
const takeValue = (name, index) => {
|
|
3028
|
-
const value = argv[index];
|
|
3029
|
-
if (value === void 0 || value.startsWith("--")) {
|
|
3030
|
-
throw new Error(`${name} requires a value.`);
|
|
3031
|
-
}
|
|
3032
|
-
return value;
|
|
3033
|
-
};
|
|
3034
|
-
for (let index = 0; index < argv.length; index++) {
|
|
3035
|
-
const arg = argv[index];
|
|
3036
|
-
const flag = flags[arg];
|
|
3037
|
-
if (flag !== void 0) {
|
|
3038
|
-
flag();
|
|
3039
|
-
continue;
|
|
3040
|
-
}
|
|
3041
|
-
const separator = arg.indexOf("=");
|
|
3042
|
-
const name = separator === -1 ? arg : arg.slice(0, separator);
|
|
3043
|
-
const handler = handlers[name];
|
|
3044
|
-
if (handler === void 0) {
|
|
3045
|
-
if (arg.startsWith("-")) {
|
|
3046
|
-
onUnknown(arg);
|
|
3047
|
-
} else {
|
|
3048
|
-
onPositional(arg);
|
|
3049
|
-
}
|
|
3050
|
-
continue;
|
|
3051
|
-
}
|
|
3052
|
-
const value = separator === -1 ? takeValue(name, ++index) : arg.slice(separator + 1);
|
|
3053
|
-
handler(value);
|
|
3054
|
-
}
|
|
3055
|
-
}
|
|
3056
|
-
|
|
3057
|
-
// cli/utils/slugify.ts
|
|
3058
|
-
function slugify(name) {
|
|
3059
|
-
const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
3060
|
-
return slug.length > 0 ? slug : void 0;
|
|
3061
|
-
}
|
|
3062
|
-
|
|
3063
|
-
// cli/dataSources/readSampleDataSources.ts
|
|
3064
|
-
import { readFileSync } from "node:fs";
|
|
3065
|
-
import { basename, resolve } from "node:path";
|
|
3066
|
-
|
|
3067
3040
|
// ../node_modules/.pnpm/temporal-polyfill@1.0.6/node_modules/temporal-polyfill/chunks/root.js
|
|
3068
3041
|
var NativeTemporal = globalThis.Temporal;
|
|
3069
3042
|
|
|
@@ -6863,6 +6836,156 @@ function validateTimeZone(timeZone) {
|
|
|
6863
6836
|
}
|
|
6864
6837
|
}
|
|
6865
6838
|
|
|
6839
|
+
// shared/dataSources/toDataSourceDateValue.ts
|
|
6840
|
+
function toDataSourceDateValue(value) {
|
|
6841
|
+
if (is(notionDateValueSchema, value)) {
|
|
6842
|
+
return value;
|
|
6843
|
+
}
|
|
6844
|
+
if (typeof value !== "string") {
|
|
6845
|
+
return void 0;
|
|
6846
|
+
}
|
|
6847
|
+
try {
|
|
6848
|
+
const [date, time] = value.split("T");
|
|
6849
|
+
const { start } = toNotionDateInput({
|
|
6850
|
+
type: "datetime",
|
|
6851
|
+
start_date: date,
|
|
6852
|
+
start_time: time ?? "00:00:00Z"
|
|
6853
|
+
});
|
|
6854
|
+
return {
|
|
6855
|
+
type: "datetime",
|
|
6856
|
+
start_date: start.slice(0, 10),
|
|
6857
|
+
start_time: start.slice(11),
|
|
6858
|
+
time_zone: "UTC"
|
|
6859
|
+
};
|
|
6860
|
+
} catch (error) {
|
|
6861
|
+
if (error instanceof RangeError) {
|
|
6862
|
+
return void 0;
|
|
6863
|
+
}
|
|
6864
|
+
throw error;
|
|
6865
|
+
}
|
|
6866
|
+
}
|
|
6867
|
+
|
|
6868
|
+
// shared/dataSources/localPropertyValues.ts
|
|
6869
|
+
var stringValue = string();
|
|
6870
|
+
var numberValue = pipe(number(), finite());
|
|
6871
|
+
var booleanValue = boolean();
|
|
6872
|
+
var stringArrayValue = array(string());
|
|
6873
|
+
var pointerArrayValue = array(notionRecordPointerSchema);
|
|
6874
|
+
var filesValue = array(
|
|
6875
|
+
custom((value) => parseSampleFileItem(value) !== void 0)
|
|
6876
|
+
);
|
|
6877
|
+
var sampleDataSourceValueSchema = union([
|
|
6878
|
+
stringValue,
|
|
6879
|
+
numberValue,
|
|
6880
|
+
booleanValue,
|
|
6881
|
+
notionDateValueSchema,
|
|
6882
|
+
stringArrayValue,
|
|
6883
|
+
pointerArrayValue,
|
|
6884
|
+
filesValue
|
|
6885
|
+
]);
|
|
6886
|
+
var bindingValueSchemas = {
|
|
6887
|
+
title: stringValue,
|
|
6888
|
+
rich_text: stringValue,
|
|
6889
|
+
url: stringValue,
|
|
6890
|
+
email: stringValue,
|
|
6891
|
+
phone_number: stringValue,
|
|
6892
|
+
select: stringValue,
|
|
6893
|
+
status: stringValue,
|
|
6894
|
+
number: numberValue,
|
|
6895
|
+
checkbox: booleanValue,
|
|
6896
|
+
multi_select: stringArrayValue,
|
|
6897
|
+
date: notionDateValueSchema,
|
|
6898
|
+
created_time: notionDateValueSchema,
|
|
6899
|
+
last_edited_time: notionDateValueSchema,
|
|
6900
|
+
people: pointerArrayValue,
|
|
6901
|
+
relation: pointerArrayValue,
|
|
6902
|
+
files: union([stringValue, filesValue])
|
|
6903
|
+
};
|
|
6904
|
+
var convertedValueSchemas = {
|
|
6905
|
+
...bindingValueSchemas,
|
|
6906
|
+
created_by: pointerArrayValue,
|
|
6907
|
+
last_edited_by: pointerArrayValue,
|
|
6908
|
+
unique_id: stringValue,
|
|
6909
|
+
formula: stringValue,
|
|
6910
|
+
rollup: stringValue,
|
|
6911
|
+
verification: stringValue,
|
|
6912
|
+
place: stringValue
|
|
6913
|
+
};
|
|
6914
|
+
function matchesConvertedPropertyType(value, type) {
|
|
6915
|
+
const schema = is(notionPropertyTypeSchema, type) ? convertedValueSchemas[type] : void 0;
|
|
6916
|
+
return is(schema ?? sampleDataSourceValueSchema, value);
|
|
6917
|
+
}
|
|
6918
|
+
function isSampleDataSourceValue(value) {
|
|
6919
|
+
return is(sampleDataSourceValueSchema, value);
|
|
6920
|
+
}
|
|
6921
|
+
function parseSampleFileItem(value) {
|
|
6922
|
+
const parsed = safeParse(bridgeFilePropertyReadItemSchema, value);
|
|
6923
|
+
return parsed.success && parsed.output.type !== "file" ? parsed.output : void 0;
|
|
6924
|
+
}
|
|
6925
|
+
|
|
6926
|
+
// cli/diagnostics/formatUnknownError.ts
|
|
6927
|
+
function formatUnknownError(error) {
|
|
6928
|
+
return error instanceof Error ? error.message : String(error);
|
|
6929
|
+
}
|
|
6930
|
+
|
|
6931
|
+
// cli/utils/claimUniqueKey.ts
|
|
6932
|
+
function claimUniqueKey(base, used) {
|
|
6933
|
+
let key = base;
|
|
6934
|
+
for (let counter = 2; used.has(key); counter++) {
|
|
6935
|
+
key = `${base}_${counter}`;
|
|
6936
|
+
}
|
|
6937
|
+
used.add(key);
|
|
6938
|
+
return key;
|
|
6939
|
+
}
|
|
6940
|
+
|
|
6941
|
+
// cli/utils/parseCliArgs.ts
|
|
6942
|
+
function parseCliArgs({
|
|
6943
|
+
argv,
|
|
6944
|
+
handlers,
|
|
6945
|
+
flags = {},
|
|
6946
|
+
onUnknown,
|
|
6947
|
+
onPositional
|
|
6948
|
+
}) {
|
|
6949
|
+
const takeValue = (name, index) => {
|
|
6950
|
+
const value = argv[index];
|
|
6951
|
+
if (value === void 0 || value.startsWith("--")) {
|
|
6952
|
+
throw new Error(`${name} requires a value.`);
|
|
6953
|
+
}
|
|
6954
|
+
return value;
|
|
6955
|
+
};
|
|
6956
|
+
for (let index = 0; index < argv.length; index++) {
|
|
6957
|
+
const arg = argv[index];
|
|
6958
|
+
const flag = flags[arg];
|
|
6959
|
+
if (flag !== void 0) {
|
|
6960
|
+
flag();
|
|
6961
|
+
continue;
|
|
6962
|
+
}
|
|
6963
|
+
const separator = arg.indexOf("=");
|
|
6964
|
+
const name = separator === -1 ? arg : arg.slice(0, separator);
|
|
6965
|
+
const handler = handlers[name];
|
|
6966
|
+
if (handler === void 0) {
|
|
6967
|
+
if (arg.startsWith("-")) {
|
|
6968
|
+
onUnknown(arg);
|
|
6969
|
+
} else {
|
|
6970
|
+
onPositional(arg);
|
|
6971
|
+
}
|
|
6972
|
+
continue;
|
|
6973
|
+
}
|
|
6974
|
+
const value = separator === -1 ? takeValue(name, ++index) : arg.slice(separator + 1);
|
|
6975
|
+
handler(value);
|
|
6976
|
+
}
|
|
6977
|
+
}
|
|
6978
|
+
|
|
6979
|
+
// cli/utils/slugify.ts
|
|
6980
|
+
function slugify(name) {
|
|
6981
|
+
const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
6982
|
+
return slug.length > 0 ? slug : void 0;
|
|
6983
|
+
}
|
|
6984
|
+
|
|
6985
|
+
// cli/dataSources/readSampleDataSources.ts
|
|
6986
|
+
import { readFileSync } from "node:fs";
|
|
6987
|
+
import { basename, resolve } from "node:path";
|
|
6988
|
+
|
|
6866
6989
|
// shared/dataSources/sampleDataSource.ts
|
|
6867
6990
|
var sampleDataSourceTypeSchema = picklist([
|
|
6868
6991
|
"built-in",
|
|
@@ -6907,35 +7030,6 @@ function selectSampleDataSource({
|
|
|
6907
7030
|
return sources.find((source) => source.filename === `worker_${slotKey}`) ?? sources.find((source) => source.filename === slotKey);
|
|
6908
7031
|
}
|
|
6909
7032
|
|
|
6910
|
-
// shared/dataSources/toDataSourceDateValue.ts
|
|
6911
|
-
function toDataSourceDateValue(value) {
|
|
6912
|
-
if (is(notionDateValueSchema, value)) {
|
|
6913
|
-
return value;
|
|
6914
|
-
}
|
|
6915
|
-
if (typeof value !== "string") {
|
|
6916
|
-
return void 0;
|
|
6917
|
-
}
|
|
6918
|
-
try {
|
|
6919
|
-
const [date, time] = value.split("T");
|
|
6920
|
-
const { start } = toNotionDateInput({
|
|
6921
|
-
type: "datetime",
|
|
6922
|
-
start_date: date,
|
|
6923
|
-
start_time: time ?? "00:00:00Z"
|
|
6924
|
-
});
|
|
6925
|
-
return {
|
|
6926
|
-
type: "datetime",
|
|
6927
|
-
start_date: start.slice(0, 10),
|
|
6928
|
-
start_time: start.slice(11),
|
|
6929
|
-
time_zone: "UTC"
|
|
6930
|
-
};
|
|
6931
|
-
} catch (error) {
|
|
6932
|
-
if (error instanceof RangeError) {
|
|
6933
|
-
return void 0;
|
|
6934
|
-
}
|
|
6935
|
-
throw error;
|
|
6936
|
-
}
|
|
6937
|
-
}
|
|
6938
|
-
|
|
6939
7033
|
// cli/dataSources/listDataSourceFiles.ts
|
|
6940
7034
|
import { existsSync, readdirSync } from "node:fs";
|
|
6941
7035
|
function listDataSourceFiles(dataDir) {
|
|
@@ -7167,7 +7261,7 @@ function convertPublicApiPropertyValue(publicType, value) {
|
|
|
7167
7261
|
table: "notion_user"
|
|
7168
7262
|
}));
|
|
7169
7263
|
case "files":
|
|
7170
|
-
return
|
|
7264
|
+
return Array.isArray(payload) ? payload.flatMap(toSampleFile) : void 0;
|
|
7171
7265
|
case "relation":
|
|
7172
7266
|
return payload.map((target) => ({
|
|
7173
7267
|
id: target.id,
|
|
@@ -7198,8 +7292,20 @@ function convertPublicApiPropertyValue(publicType, value) {
|
|
|
7198
7292
|
return unreachable(publicType);
|
|
7199
7293
|
}
|
|
7200
7294
|
}
|
|
7201
|
-
function
|
|
7202
|
-
|
|
7295
|
+
function toSampleFile(value) {
|
|
7296
|
+
if (typeof value !== "object" || value === null) {
|
|
7297
|
+
return [];
|
|
7298
|
+
}
|
|
7299
|
+
const file = parseSampleFileItem(value);
|
|
7300
|
+
if (file?.type === "external") {
|
|
7301
|
+
return [file];
|
|
7302
|
+
}
|
|
7303
|
+
return [
|
|
7304
|
+
{
|
|
7305
|
+
type: "unavailable",
|
|
7306
|
+
..."name" in value && typeof value.name === "string" ? { name: value.name } : {}
|
|
7307
|
+
}
|
|
7308
|
+
];
|
|
7203
7309
|
}
|
|
7204
7310
|
function formulaToText(formula) {
|
|
7205
7311
|
switch (formula.type) {
|
|
@@ -7424,7 +7530,7 @@ function validateSource(source) {
|
|
|
7424
7530
|
);
|
|
7425
7531
|
continue;
|
|
7426
7532
|
}
|
|
7427
|
-
const matches = declared ? matchesConvertedPropertyType(value, declared.type) :
|
|
7533
|
+
const matches = declared ? matchesConvertedPropertyType(value, declared.type) : isSampleDataSourceValue(value);
|
|
7428
7534
|
if (!matches) {
|
|
7429
7535
|
issues.push(
|
|
7430
7536
|
`row ${JSON.stringify(row.id)}: ${JSON.stringify(key)} does not match ${declared ? `type ${JSON.stringify(declared.type)}` : "any supported value shape"}`
|
package/docs/data-sources.md
CHANGED
|
@@ -65,10 +65,30 @@ Value shapes by property type:
|
|
|
65
65
|
| `date` | `{ "type": "date", "start_date": "YYYY-MM-DD" }`. Ranges and datetimes use `"daterange"`, `"datetime"`, or `"datetimerange"` with `end_date`, `start_time`, and `end_time`. |
|
|
66
66
|
| `people` | array of `{ "id": "...", "table": "notion_user" }` pointers |
|
|
67
67
|
| `relation` | array of `{ "id": "...", "table": "block" }` pointers |
|
|
68
|
-
| `files` |
|
|
68
|
+
| `files` | Array of named external links and unavailable placeholders. |
|
|
69
69
|
|
|
70
70
|
People properties use user IDs, not page IDs from a directory data source.
|
|
71
71
|
|
|
72
|
+
To test how a block handles an unavailable attachment, add a placeholder to a Files cell. For a
|
|
73
|
+
schema property named `files`, a row can contain this value:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"files": [
|
|
78
|
+
{
|
|
79
|
+
"type": "external",
|
|
80
|
+
"name": "Analytical Engine reference",
|
|
81
|
+
"external": { "url": "https://en.wikipedia.org/wiki/Analytical_Engine" }
|
|
82
|
+
},
|
|
83
|
+
{ "type": "unavailable", "name": "Engine diagrams.png" }
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Reads preserve entry order. The sample data contains links and labels, so loading a row does not
|
|
89
|
+
fetch the linked content. A placeholder's name is optional. The shell skips malformed entries and
|
|
90
|
+
treats missing cells and older text values as empty arrays.
|
|
91
|
+
|
|
72
92
|
## Validation
|
|
73
93
|
|
|
74
94
|
Files are validated independently at startup and after edits. Errors name the file and problem, for
|
|
@@ -125,6 +145,10 @@ ntn workers customblocks sample <url-or-data-source-id> \
|
|
|
125
145
|
Run the dev shell once to create the generated file, then sample your data. `--row-only` preserves
|
|
126
146
|
the schema and appends rows with new IDs. Add `--overwrite` to replace existing rows.
|
|
127
147
|
|
|
148
|
+
Imported Files cells keep external links in order. Notion-hosted files and pending uploads become
|
|
149
|
+
unavailable placeholders, with a name when supplied. The sample JSON does not store temporary file
|
|
150
|
+
URLs.
|
|
151
|
+
|
|
128
152
|
Sampled property keys must match the generated schema. If they differ, sample into a separate file
|
|
129
153
|
and select it with [`--bind`](bindings.md#choose-sample-data).
|
|
130
154
|
|