@notionhq/custom-blocks-dev-shell 0.1.115 → 0.2.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.
Files changed (139) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +92 -13
  3. package/THIRD_PARTY_LICENSES.md +133 -0
  4. package/dist/assets/index-Do-x8yIt.css +2 -0
  5. package/dist/assets/index-n0_PUieY.js +11 -0
  6. package/dist/index.html +2 -2
  7. package/dist-cli/cli/published-cli.js +8572 -51
  8. package/docs/bindings.md +17 -12
  9. package/docs/bridge/changelog.md +94 -0
  10. package/docs/bridge/protocol.md +239 -0
  11. package/docs/bridge/versioning.md +39 -0
  12. package/docs/data-sources.md +49 -36
  13. package/docs/host/README.md +193 -0
  14. package/docs/host/docs/compatibility.md +76 -0
  15. package/docs/host/docs/handlers.md +210 -0
  16. package/docs/host/docs/lifecycle.md +131 -0
  17. package/package.json +5 -3
  18. package/dist/assets/index-DXzPwq_J.js +0 -11
  19. package/dist/assets/index-E1j3FxAu.css +0 -2
  20. package/dist-cli/cli/binding-cli-flags.js +0 -33
  21. package/dist-cli/cli/binding-errors.js +0 -15
  22. package/dist-cli/cli/block-csp.js +0 -84
  23. package/dist-cli/cli/build-block-registry.js +0 -30
  24. package/dist-cli/cli/convert-values.js +0 -222
  25. package/dist-cli/cli/convert.js +0 -210
  26. package/dist-cli/cli/data-source-files.js +0 -6
  27. package/dist-cli/cli/data-sources.js +0 -114
  28. package/dist-cli/cli/dev-shell-launcher.js +0 -239
  29. package/dist-cli/cli/dev-shell-run.js +0 -72
  30. package/dist-cli/cli/errors.js +0 -12
  31. package/dist-cli/cli/launcher-bindings.js +0 -144
  32. package/dist-cli/cli/materialize.js +0 -105
  33. package/dist-cli/cli/ports.js +0 -20
  34. package/dist-cli/cli/prebuilt.js +0 -23
  35. package/dist-cli/cli/runtime-error-client.js +0 -52
  36. package/dist-cli/cli/serve-ui.js +0 -110
  37. package/dist-cli/cli/shared-server.js +0 -70
  38. package/dist-cli/cli/utils.js +0 -52
  39. package/dist-cli/cli/vite-block-server.js +0 -125
  40. package/dist-cli/cli/vite-middleware.js +0 -111
  41. package/dist-cli/cli/worker-manifest.js +0 -158
  42. package/dist-cli/protocol/contrast.d.ts +0 -4
  43. package/dist-cli/protocol/contrast.js +0 -3
  44. package/dist-cli/protocol/dataSources/dataSource.d.ts +0 -786
  45. package/dist-cli/protocol/dataSources/dataSource.js +0 -66
  46. package/dist-cli/protocol/dataSources/dataSourcePage.d.ts +0 -74
  47. package/dist-cli/protocol/dataSources/dataSourcePage.js +0 -15
  48. package/dist-cli/protocol/dataSources/dataSourceValue.d.ts +0 -66
  49. package/dist-cli/protocol/dataSources/dataSourceValue.js +0 -14
  50. package/dist-cli/protocol/dataSources/dateValue.d.ts +0 -157
  51. package/dist-cli/protocol/dataSources/dateValue.js +0 -61
  52. package/dist-cli/protocol/dataSources/errors.d.ts +0 -8
  53. package/dist-cli/protocol/dataSources/errors.js +0 -7
  54. package/dist-cli/protocol/dataSources/propertySchema.d.ts +0 -200
  55. package/dist-cli/protocol/dataSources/propertySchema.js +0 -174
  56. package/dist-cli/protocol/dataSources/recordPointer.d.ts +0 -9
  57. package/dist-cli/protocol/dataSources/recordPointer.js +0 -8
  58. package/dist-cli/protocol/dataSources/sortDirection.d.ts +0 -3
  59. package/dist-cli/protocol/dataSources/sortDirection.js +0 -2
  60. package/dist-cli/protocol/errors.d.ts +0 -12
  61. package/dist-cli/protocol/errors.js +0 -6
  62. package/dist-cli/protocol/ids.d.ts +0 -31
  63. package/dist-cli/protocol/ids.js +0 -26
  64. package/dist-cli/protocol/index.d.ts +0 -53
  65. package/dist-cli/protocol/index.js +0 -53
  66. package/dist-cli/protocol/manifest.d.ts +0 -67
  67. package/dist-cli/protocol/manifest.js +0 -36
  68. package/dist-cli/protocol/messages/connect.d.ts +0 -54
  69. package/dist-cli/protocol/messages/connect.js +0 -39
  70. package/dist-cli/protocol/messages/contrastModeChanged.d.ts +0 -7
  71. package/dist-cli/protocol/messages/contrastModeChanged.js +0 -7
  72. package/dist-cli/protocol/messages/createPage.d.ts +0 -290
  73. package/dist-cli/protocol/messages/createPage.js +0 -51
  74. package/dist-cli/protocol/messages/createPageResult.d.ts +0 -897
  75. package/dist-cli/protocol/messages/createPageResult.js +0 -43
  76. package/dist-cli/protocol/messages/currentUserChanged.d.ts +0 -18
  77. package/dist-cli/protocol/messages/currentUserChanged.js +0 -9
  78. package/dist-cli/protocol/messages/dataSourcesChanged.d.ts +0 -157
  79. package/dist-cli/protocol/messages/dataSourcesChanged.js +0 -13
  80. package/dist-cli/protocol/messages/getPage.d.ts +0 -902
  81. package/dist-cli/protocol/messages/getPage.js +0 -48
  82. package/dist-cli/protocol/messages/getUser.d.ts +0 -44
  83. package/dist-cli/protocol/messages/getUser.js +0 -32
  84. package/dist-cli/protocol/messages/hostToSandbox.d.ts +0 -4385
  85. package/dist-cli/protocol/messages/hostToSandbox.js +0 -48
  86. package/dist-cli/protocol/messages/incomingType.d.ts +0 -9
  87. package/dist-cli/protocol/messages/incomingType.js +0 -17
  88. package/dist-cli/protocol/messages/init.d.ts +0 -273
  89. package/dist-cli/protocol/messages/init.js +0 -57
  90. package/dist-cli/protocol/messages/initResult.d.ts +0 -37
  91. package/dist-cli/protocol/messages/initResult.js +0 -29
  92. package/dist-cli/protocol/messages/invalidHostMessage.d.ts +0 -14
  93. package/dist-cli/protocol/messages/invalidHostMessage.js +0 -13
  94. package/dist-cli/protocol/messages/invalidSandboxMessage.d.ts +0 -14
  95. package/dist-cli/protocol/messages/invalidSandboxMessage.js +0 -13
  96. package/dist-cli/protocol/messages/isInitHandshakeMessage.d.ts +0 -4
  97. package/dist-cli/protocol/messages/isInitHandshakeMessage.js +0 -11
  98. package/dist-cli/protocol/messages/listUsers.d.ts +0 -52
  99. package/dist-cli/protocol/messages/listUsers.js +0 -33
  100. package/dist-cli/protocol/messages/messagePayload.d.ts +0 -19
  101. package/dist-cli/protocol/messages/messagePayload.js +0 -1
  102. package/dist-cli/protocol/messages/openExternalUrl.d.ts +0 -32
  103. package/dist-cli/protocol/messages/openExternalUrl.js +0 -26
  104. package/dist-cli/protocol/messages/openPage.d.ts +0 -38
  105. package/dist-cli/protocol/messages/openPage.js +0 -34
  106. package/dist-cli/protocol/messages/pageChanged.d.ts +0 -32
  107. package/dist-cli/protocol/messages/pageChanged.js +0 -9
  108. package/dist-cli/protocol/messages/parentChanged.d.ts +0 -26
  109. package/dist-cli/protocol/messages/parentChanged.js +0 -9
  110. package/dist-cli/protocol/messages/queryDataSource.d.ts +0 -1446
  111. package/dist-cli/protocol/messages/queryDataSource.js +0 -252
  112. package/dist-cli/protocol/messages/queryDataSourceResult.d.ts +0 -686
  113. package/dist-cli/protocol/messages/queryDataSourceResult.js +0 -44
  114. package/dist-cli/protocol/messages/resize.d.ts +0 -11
  115. package/dist-cli/protocol/messages/resize.js +0 -10
  116. package/dist-cli/protocol/messages/sandboxToHost.d.ts +0 -1091
  117. package/dist-cli/protocol/messages/sandboxToHost.js +0 -33
  118. package/dist-cli/protocol/messages/themeChanged.d.ts +0 -10
  119. package/dist-cli/protocol/messages/themeChanged.js +0 -10
  120. package/dist-cli/protocol/messages/unsubscribeDataSourceQuery.d.ts +0 -10
  121. package/dist-cli/protocol/messages/unsubscribeDataSourceQuery.js +0 -9
  122. package/dist-cli/protocol/messages/updatePage.d.ts +0 -271
  123. package/dist-cli/protocol/messages/updatePage.js +0 -23
  124. package/dist-cli/protocol/messages/updatePageResult.d.ts +0 -895
  125. package/dist-cli/protocol/messages/updatePageResult.js +0 -41
  126. package/dist-cli/protocol/pages/page.d.ts +0 -1422
  127. package/dist-cli/protocol/pages/page.js +0 -318
  128. package/dist-cli/protocol/parent.d.ts +0 -32
  129. package/dist-cli/protocol/parent.js +0 -13
  130. package/dist-cli/protocol/protocolVersion.d.ts +0 -8
  131. package/dist-cli/protocol/protocolVersion.js +0 -11
  132. package/dist-cli/protocol/theme.d.ts +0 -3
  133. package/dist-cli/protocol/theme.js +0 -2
  134. package/dist-cli/protocol/users/user.d.ts +0 -32
  135. package/dist-cli/protocol/users/user.js +0 -20
  136. package/dist-cli/shared/block-registry.js +0 -28
  137. package/dist-cli/shared/data-source.js +0 -22
  138. package/dist-cli/shared/runtime-config.js +0 -10
  139. package/dist-cli/shared/sample-data-source.js +0 -12
@@ -1,2 +0,0 @@
1
- /*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
2
- @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-black:#000;--color-white:#fff;--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--leading-relaxed:1.625;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-ink:#32302c;--color-ink-muted:#6b6b68;--color-ink-faint:#9b9a97;--color-ink-fainter:#b3b3b0;--color-nav-ink:#2c2c2b;--color-paper:#fbfbfa;--color-hairline:#e6e5e3;--color-ui-hover:#3b14000d;--color-panel:#42230308;--color-canvas:#fff;--color-pill:#0000000d;--color-pill-dark:#ffffff0e;--color-dark-ink:#ffffffcf;--color-dark-ink-muted:#ffffff75;--color-sidebar:#f7f7f5;--color-sidebar-active:#00000008;--color-sidebar-ink:#5f5e59;--color-sidebar-ink-strong:#1d1b16;--color-sidebar-ink-muted:#7d7a75;--color-hairline-soft:#f0efed;--color-toggle:#e9e9e7;--color-accent:#2383e2;--color-match:#dcf3e3;--color-match-ink:#1f6d3d;--color-mismatch:#fbe4e4;--color-mismatch-ink:#a33}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}:root{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}body{background:var(--color-paper);color:var(--color-ink);margin:0}[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--color-ink:#ffffffcf;--color-ink-muted:#ffffff94;--color-ink-faint:#ffffff6b;--color-ink-fainter:#ffffff52;--color-nav-ink:#ffffffcf;--color-paper:#202020;--color-hairline:#3a3a3a;--color-ui-hover:#ffffff14;--color-panel:#ffffff0e;--color-canvas:#191919;--color-pill:#ffffff14;--color-sidebar:#191919;--color-sidebar-active:#ffffff14;--color-sidebar-ink:#ffffffb8;--color-sidebar-ink-strong:#ffffffe6;--color-sidebar-ink-muted:#ffffff80;--color-hairline-soft:#2b2b2b;--color-hover:#2a2a2a;--color-toggle:#303030;--color-tooltip:#f7f7f5;--color-match:#46b47838;--color-match-ink:#7bd59d;--color-mismatch:#dc505033;--color-mismatch-ink:#f08b8b}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:0}.top-0{top:0}.top-1\/2{top:50%}.top-full{top:100%}.right-0{right:0}.right-1\.5{right:calc(var(--spacing) * 1.5)}.bottom-full{bottom:100%}.left-0{left:0}.isolate{isolation:isolate}.z-10{z-index:10}.z-50{z-index:50}.row-1{grid-row:1}.row-2{grid-row:2}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.m-0{margin:0}.mx-auto{margin-inline:auto}.mt-1{margin-top:var(--spacing)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mb-1{margin-bottom:var(--spacing)}.ml-auto{margin-left:auto}.block{display:block}.contents{display:contents}.flex{display:flex}.inline{display:inline}.inline-flex{display:inline-flex}.table{display:table}.size-5{width:calc(var(--spacing) * 5);height:calc(var(--spacing) * 5)}.size-6{width:calc(var(--spacing) * 6);height:calc(var(--spacing) * 6)}.size-7{width:calc(var(--spacing) * 7);height:calc(var(--spacing) * 7)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-9{height:calc(var(--spacing) * 9)}.h-100{height:calc(var(--spacing) * 100)}.h-\[30px\]{height:30px}.h-\[38px\]{height:38px}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:calc(var(--spacing) * 32)}.max-h-64{max-height:calc(var(--spacing) * 64)}.max-h-\[85vh\]{max-height:85vh}.max-h-full{max-height:100%}.max-h-none{max-height:none}.min-h-0{min-height:0}.w-70{width:calc(var(--spacing) * 70)}.w-\[172px\]{width:172px}.w-full{width:100%}.max-w-120{max-width:calc(var(--spacing) * 120)}.max-w-160{max-width:calc(var(--spacing) * 160)}.max-w-190{max-width:calc(var(--spacing) * 190)}.max-w-\[560px\]{max-width:560px}.max-w-\[720px\]{max-width:720px}.max-w-\[960px\]{max-width:960px}.max-w-full{max-width:100%}.max-w-none{max-width:none}.min-w-0{min-width:0}.min-w-40{min-width:calc(var(--spacing) * 40)}.flex-1{flex:1}.flex-none{flex:none}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-y-1\/2{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.resize{resize:both}.list-disc{list-style-type:disc}.appearance-none{appearance:none}.flex-col{flex-direction:column}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-6{gap:calc(var(--spacing) * 6)}.gap-px{gap:1px}.self-start{align-self:flex-start}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-\[6px\]{border-radius:6px}.rounded-\[10px\]{border-radius:10px}.rounded-\[12px\]{border-radius:12px}.rounded-full{border-radius:2147483647px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-xl{border-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-hairline{border-color:var(--color-hairline)}.border-hairline-soft{border-color:var(--color-hairline-soft)}.border-mismatch{border-color:var(--color-mismatch)}.bg-accent{background-color:var(--color-accent)}.bg-black\/40{background-color:#0006}@supports (color:color-mix(in lab, red, red)){.bg-black\/40{background-color:color-mix(in oklab, var(--color-black) 40%, transparent)}}.bg-canvas{background-color:var(--color-canvas)}.bg-match{background-color:var(--color-match)}.bg-panel{background-color:var(--color-panel)}.bg-paper{background-color:var(--color-paper)}.bg-pill{background-color:var(--color-pill)}.bg-pill-dark{background-color:var(--color-pill-dark)}.bg-sidebar{background-color:var(--color-sidebar)}.bg-sidebar-active{background-color:var(--color-sidebar-active)}.bg-transparent{background-color:#0000}.bg-ui-hover{background-color:var(--color-ui-hover)}.p-1{padding:var(--spacing)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-5{padding:calc(var(--spacing) * 5)}.p-6{padding:calc(var(--spacing) * 6)}.px-1{padding-inline:var(--spacing)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-6{padding-inline:calc(var(--spacing) * 6)}.px-10{padding-inline:calc(var(--spacing) * 10)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-10{padding-block:calc(var(--spacing) * 10)}.pt-10{padding-top:calc(var(--spacing) * 10)}.pt-24{padding-top:calc(var(--spacing) * 24)}.pr-1{padding-right:var(--spacing)}.pr-1\.5{padding-right:calc(var(--spacing) * 1.5)}.pr-6{padding-right:calc(var(--spacing) * 6)}.pb-1{padding-bottom:var(--spacing)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pb-6{padding-bottom:calc(var(--spacing) * 6)}.pl-0\.5{padding-left:calc(var(--spacing) * .5)}.pl-2{padding-left:calc(var(--spacing) * 2)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-5{padding-left:calc(var(--spacing) * 5)}.text-center{text-align:center}.text-left{text-align:left}.align-top{vertical-align:top}.font-mono{font-family:var(--font-mono)}.text-body{letter-spacing:-.154px;font-size:14px;line-height:20px}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-caption{font-size:12px;line-height:16px}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[11px\]{font-size:11px}.text-\[13px\]{font-size:13px}.text-\[17px\]{font-size:17px}.text-\[32px\]{font-size:32px}.text-\[40px\]{font-size:40px}.leading-4{--tw-leading:calc(var(--spacing) * 4);line-height:calc(var(--spacing) * 4)}.leading-10{--tw-leading:calc(var(--spacing) * 10);line-height:calc(var(--spacing) * 10)}.leading-\[1\.2\]{--tw-leading:1.2;line-height:1.2}.leading-\[20px\]{--tw-leading:20px;line-height:20px}.leading-\[22px\]{--tw-leading:22px;line-height:22px}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[-0\.442px\]{--tw-tracking:-.442px;letter-spacing:-.442px}.tracking-\[-1\.55px\]{--tw-tracking:-1.55px;letter-spacing:-1.55px}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-dark-ink{color:var(--color-dark-ink)}.text-dark-ink-muted{color:var(--color-dark-ink-muted)}.text-ink{color:var(--color-ink)}.text-ink-faint{color:var(--color-ink-faint)}.text-ink-fainter{color:var(--color-ink-fainter)}.text-ink-muted{color:var(--color-ink-muted)}.text-match-ink{color:var(--color-match-ink)}.text-mismatch-ink{color:var(--color-mismatch-ink)}.text-nav-ink{color:var(--color-nav-ink)}.text-sidebar-ink{color:var(--color-sidebar-ink)}.text-sidebar-ink-muted{color:var(--color-sidebar-ink-muted)}.text-sidebar-ink-strong{color:var(--color-sidebar-ink-strong)}.text-white{color:var(--color-white)}.lowercase{text-transform:lowercase}.opacity-0{opacity:0}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-\[0_4px_12px_rgb\(0_0_0\/10\%\)\]{--tw-shadow:0 4px 12px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-\[0_12px_40px_rgb\(0_0_0\/25\%\)\]{--tw-shadow:0 12px 40px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.select-all{-webkit-user-select:all;user-select:all}.select-text{-webkit-user-select:text;user-select:text}@media (hover:hover){.group-hover\:opacity-100:is(:where(.group):hover *){opacity:1}}.backdrop\:bg-black\/40::backdrop{background-color:#0006}@supports (color:color-mix(in lab, red, red)){.backdrop\:bg-black\/40::backdrop{background-color:color-mix(in oklab, var(--color-black) 40%, transparent)}}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.open\:flex:is([open],:popover-open,:open){display:flex}@media (hover:hover){.hover\:bg-sidebar-active:hover{background-color:var(--color-sidebar-active)}.hover\:bg-ui-hover:hover{background-color:var(--color-ui-hover)}.hover\:opacity-90:hover{opacity:.9}}.focus-visible\:opacity-100:focus-visible{opacity:1}.disabled\:cursor-default:disabled{cursor:default}.disabled\:bg-toggle:disabled{background-color:var(--color-toggle)}.disabled\:text-ink-faint:disabled{color:var(--color-ink-faint)}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}
@@ -1,33 +0,0 @@
1
- import { DevShellLauncherBindingError } from "./binding-errors.js";
2
- export function parseDataSourceBindingOverride({ value, }) {
3
- const separator = value.indexOf("=");
4
- const target = value.slice(0, separator);
5
- const filename = value.slice(separator + 1);
6
- const dot = target.indexOf(".");
7
- if (separator < 0 ||
8
- dot <= 0 ||
9
- dot === target.length - 1 ||
10
- target !== target.trim() ||
11
- filename !== filename.trim() ||
12
- !filename.endsWith(".json") ||
13
- filename === ".json" ||
14
- /[\\/\0]/.test(filename)) {
15
- throw new DevShellLauncherBindingError("invalid_binding_syntax", "--bind requires <capabilityKey>.<dataSourceKey>=<sampleDataFileName.json>. Use a filename in data/.");
16
- }
17
- return { target, filename };
18
- }
19
- export function parsePropertyBindingOverride({ value, }) {
20
- const separator = value.indexOf("=");
21
- const target = value.slice(0, separator);
22
- const sourcePropertyKey = value.slice(separator + 1);
23
- const parts = target.split(".");
24
- if (separator < 0 ||
25
- parts.length < 3 ||
26
- parts.some(part => part.length === 0) ||
27
- target !== target.trim() ||
28
- sourcePropertyKey.length === 0 ||
29
- sourcePropertyKey !== sourcePropertyKey.trim()) {
30
- throw new DevShellLauncherBindingError("invalid_property_binding_syntax", "--bind-property requires <capabilityKey>.<dataSourceKey>.<propertyKey>=<sourcePropertyKey>.");
31
- }
32
- return { target, sourcePropertyKey };
33
- }
@@ -1,15 +0,0 @@
1
- /** A binding failure with a stable code for callers and a message for CLI output. */
2
- export class DevShellLauncherBindingError extends Error {
3
- code;
4
- constructor(code, message) {
5
- super(`${message} (error code: ${code})`);
6
- this.name = "DevShellLauncherBindingError";
7
- this.code = code;
8
- }
9
- }
10
- export function bindingFailure(code, message) {
11
- return {
12
- status: "error",
13
- error: new DevShellLauncherBindingError(code, message),
14
- };
15
- }
@@ -1,84 +0,0 @@
1
- /**
2
- * Network response policies for custom blocks served by the dev shell.
3
- * Keep directives, media/font sources, and connection-allowlist semantics in sync with
4
- * notion-next's production policy. Local origins and the HMR exception are documented below.
5
- *
6
- * @see https://github.com/makenotion/notion-next/blob/main/src/shared-customBlocks/customBlockBundleCsp.ts
7
- */
8
- /**
9
- * Keep these paths in sync with getNotionHostedMediaSources and FILE_S3_URLS.production
10
- * in notion-next. Media exceptions do not grant fetch or script access.
11
- */
12
- const notionMediaSources = [
13
- "https://s3-us-west-2.amazonaws.com/public.notion-static.com/",
14
- "https://s3.us-west-2.amazonaws.com/public.notion-static.com/",
15
- "https://prod-files-secure.s3.us-west-2.amazonaws.com/",
16
- "https://prod-files-secure-euc1.s3.eu-central-1.amazonaws.com/",
17
- "https://prod-files-secure-apne1.s3.ap-northeast-1.amazonaws.com/",
18
- "https://prod-files-secure-apne2.s3.ap-northeast-2.amazonaws.com/",
19
- "https://s3-us-west-2.amazonaws.com/temporary.notion-static.com/",
20
- "https://prod-notion-temporary-files-usw2.s3.us-west-2.amazonaws.com/",
21
- "https://prod-notion-temporary-files-euc1.s3.eu-central-1.amazonaws.com/",
22
- "https://prod-notion-temporary-files-apne1.s3.ap-northeast-1.amazonaws.com/",
23
- "https://prod-notion-temporary-files-apne2.s3.ap-northeast-2.amazonaws.com/",
24
- ];
25
- /** Builds the CSP and Connection-Allowlist headers for a local custom block response. */
26
- export function buildCustomBlockDevShellResponseHeaders(args) {
27
- return {
28
- "Content-Security-Policy": buildCustomBlockDevShellCsp(args),
29
- "Connection-Allowlist": buildCustomBlockDevShellConnectionAllowlist(args),
30
- };
31
- }
32
- /**
33
- * Mirrors notion-next's buildCustomBlockBundleCsp with local bundle and embedding origins.
34
- * The extra WebSocket source permits Vite HMR without broadening other connection sources.
35
- */
36
- function buildCustomBlockDevShellCsp(args) {
37
- const { blockOrigin, shellOrigin, allowedNetworkOrigins, allowedFrameAncestors, } = args;
38
- const approved = allowedNetworkOrigins.join(" ");
39
- const media = notionMediaSources.join(" ");
40
- // Production has no HMR connection. Allow only this block's WebSocket host and port
41
- // so Vite can update modules without granting access to sibling blocks or the shell.
42
- const hmr = new URL(blockOrigin);
43
- hmr.protocol = "ws:";
44
- return [
45
- "default-src 'self'",
46
- "worker-src 'none'",
47
- "child-src 'none'",
48
- `frame-src ${approved || "'none'"}`,
49
- "object-src 'none'",
50
- "manifest-src 'none'",
51
- `media-src 'self' ${media} ${approved}`,
52
- // The local HTTP origin replaces production's definition-specific bundle sources.
53
- `connect-src ${blockOrigin} ${hmr.origin} ${approved}`,
54
- `img-src 'self' data: ${media} ${approved}`,
55
- `font-src 'self' data: https://fonts.gstatic.com ${approved}`,
56
- "base-uri 'none'",
57
- "form-action 'none'",
58
- // Local hosts replace Notion's production app, relay, and mobile-shell ancestors.
59
- `frame-ancestors 'self' ${shellOrigin} ${allowedFrameAncestors.join(" ")}`,
60
- "script-src 'self' 'unsafe-inline'",
61
- `style-src 'self' 'unsafe-inline' https://fonts.googleapis.com ${approved}`,
62
- ]
63
- .map(directive => directive.trim())
64
- .join("; ");
65
- }
66
- /**
67
- * Mirrors notion-next's buildCustomBlockBundleConnectionAllowlist, including redirect and
68
- * WebRTC blocking. The local block origin replaces production's bundle sources.
69
- */
70
- function buildCustomBlockDevShellConnectionAllowlist(args) {
71
- const sources = [
72
- // WebSocket matching rewrites ws: to http:, so this also permits Vite HMR.
73
- args.blockOrigin,
74
- ...notionMediaSources,
75
- "https://fonts.googleapis.com",
76
- "https://fonts.gstatic.com",
77
- ...args.allowedNetworkOrigins,
78
- ];
79
- // CSP path prefixes need an explicit wildcard in Connection-Allowlist URLPatterns.
80
- const patterns = sources.map(source => JSON.stringify(source === "*"
81
- ? "*://*:*/*"
82
- : `${source}${source.endsWith("/") ? "" : "/"}*`));
83
- return `(${patterns.join(" ")}); redirects=block; webrtc=block`;
84
- }
@@ -1,30 +0,0 @@
1
- import { DEFAULT_DEV_SHELL_PORT } from "./ports.js";
2
- /** The registry for a worker's blocks, with unique localhost hostnames. */
3
- export function buildBlockRegistry(blocks, port = DEFAULT_DEV_SHELL_PORT) {
4
- const used = new Set();
5
- return blocks.map(capability => {
6
- const stem = capability.key
7
- .toLowerCase()
8
- .replace(/[^a-z0-9-]+/g, "-")
9
- .replace(/^-+|-+$/g, "")
10
- .slice(0, 63)
11
- .replace(/-+$/g, "") || "block";
12
- let hostname = stem;
13
- let suffix = 1;
14
- // Distinct capability keys can normalize to the same hostname.
15
- // Add a suffix to keep hostnames unique within the 63-character label limit.
16
- while (used.has(hostname)) {
17
- const ending = `-${++suffix}`;
18
- hostname = stem.slice(0, 63 - ending.length).replace(/-+$/g, "") + ending;
19
- }
20
- used.add(hostname);
21
- return {
22
- key: capability.key,
23
- manifest: capability.config.manifest,
24
- name: capability.key,
25
- url: `http://${hostname}.localhost:${port}/`,
26
- sampleFilesByDataSource: {},
27
- propertyIdsByDataSource: {},
28
- };
29
- });
30
- }
@@ -1,222 +0,0 @@
1
- import { notionDateValueSchema, } from "../protocol/index.js";
2
- import * as v from "valibot";
3
- import { unreachable } from "./utils.js";
4
- /**
5
- * Convert one public API property value object to a local data source value.
6
- * Returns undefined for empty values (blank cells are normal API output; the
7
- * key is omitted from the row).
8
- */
9
- export function convertPublicApiPropertyValue(publicType, value) {
10
- if (typeof value !== "object" || value === null) {
11
- return undefined;
12
- }
13
- const payload = value[publicType];
14
- if (payload === null || payload === undefined) {
15
- return undefined;
16
- }
17
- switch (publicType) {
18
- case "title":
19
- case "rich_text":
20
- return payload
21
- .map(part => part.plain_text ?? "")
22
- .join("");
23
- case "number":
24
- return payload;
25
- case "checkbox":
26
- return payload;
27
- case "url":
28
- case "email":
29
- case "phone_number":
30
- return payload;
31
- case "select":
32
- case "status":
33
- return payload.name;
34
- case "multi_select":
35
- return payload.map(option => option.name ?? "");
36
- case "date":
37
- return publicDateToLocal(payload);
38
- case "people":
39
- return payload.map(user => ({
40
- id: user.id,
41
- table: "notion_user",
42
- }));
43
- case "files":
44
- return filesToText(payload);
45
- case "relation":
46
- return payload.map(target => ({
47
- id: target.id,
48
- table: "block",
49
- }));
50
- case "unique_id": {
51
- const uniqueId = payload;
52
- return uniqueId.prefix
53
- ? `${uniqueId.prefix}-${uniqueId.number}`
54
- : String(uniqueId.number);
55
- }
56
- // The production host still serializes formula, rollup, and
57
- // last_visited_time as plain text. Match it so fixtures predict what a
58
- // block receives from the real host.
59
- case "formula":
60
- return formulaToText(payload);
61
- case "rollup":
62
- return rollupToText(payload);
63
- case "last_visited_time":
64
- return payload;
65
- case "created_time":
66
- case "last_edited_time":
67
- return timestampToLocal(payload);
68
- case "created_by":
69
- case "last_edited_by":
70
- return [{ id: payload.id, table: "notion_user" }];
71
- case "verification":
72
- return payload.state;
73
- case "button":
74
- // Buttons carry no data; there is nothing to sample.
75
- return undefined;
76
- case "place":
77
- case "location":
78
- // No public API payload converter yet: keep something inspectable.
79
- return JSON.stringify(payload);
80
- default:
81
- return unreachable(publicType);
82
- }
83
- }
84
- function filesToText(files) {
85
- return files
86
- .map(file => file.name ?? "")
87
- .filter(name => name.length > 0)
88
- .join(", ");
89
- }
90
- function formulaToText(formula) {
91
- switch (formula.type) {
92
- case "string":
93
- return formula.string ?? undefined;
94
- case "number":
95
- return formula.number != null ? String(formula.number) : undefined;
96
- case "boolean":
97
- return formula.boolean != null ? String(formula.boolean) : undefined;
98
- case "date":
99
- return formula.date ? dateToText(formula.date) : undefined;
100
- default:
101
- return undefined;
102
- }
103
- }
104
- function rollupToText(rollup) {
105
- switch (rollup.type) {
106
- case "number":
107
- return rollup.number != null ? String(rollup.number) : undefined;
108
- case "date":
109
- return rollup.date ? dateToText(rollup.date) : undefined;
110
- default: {
111
- const raw = rollup.type === undefined
112
- ? undefined
113
- : rollup[rollup.type];
114
- return raw === null || raw === undefined ? undefined : JSON.stringify(raw);
115
- }
116
- }
117
- }
118
- /**
119
- * Best-effort text for a public API date payload: matches production's
120
- * string shape, not its exact date formatting.
121
- */
122
- function dateToText(date) {
123
- return date.end ? `${date.start} → ${date.end}` : date.start;
124
- }
125
- /**
126
- * Public API date value (`{ start, end, time_zone }`, ISO 8601 strings) to
127
- * the local `NotionDateValue` shape. Date-only starts become `date` /
128
- * `daterange`; timestamped starts become `datetime` / `datetimerange`.
129
- */
130
- function publicDateToLocal(date) {
131
- const start = date.start;
132
- const end = date.end ?? undefined;
133
- const timeZone = date.time_zone ?? undefined;
134
- if (!start.includes("T")) {
135
- return end === undefined
136
- ? { type: "date", start_date: start.slice(0, 10) }
137
- : {
138
- type: "daterange",
139
- start_date: start.slice(0, 10),
140
- end_date: end.slice(0, 10),
141
- };
142
- }
143
- if (end === undefined) {
144
- return {
145
- type: "datetime",
146
- start_date: start.slice(0, 10),
147
- start_time: start.slice(11, 16),
148
- ...(timeZone !== undefined ? { time_zone: timeZone } : {}),
149
- };
150
- }
151
- return {
152
- type: "datetimerange",
153
- start_date: start.slice(0, 10),
154
- start_time: start.slice(11, 16),
155
- end_date: end.slice(0, 10),
156
- end_time: end.slice(11, 16),
157
- ...(timeZone !== undefined ? { time_zone: timeZone } : {}),
158
- };
159
- }
160
- function timestampToLocal(timestamp) {
161
- return timestamp.includes("T")
162
- ? {
163
- type: "datetime",
164
- start_date: timestamp.slice(0, 10),
165
- start_time: timestamp.slice(11, 16),
166
- }
167
- : { type: "date", start_date: timestamp.slice(0, 10) };
168
- }
169
- const stringValue = v.string();
170
- const numberValue = v.pipe(v.number(), v.finite());
171
- const booleanValue = v.boolean();
172
- const stringArrayValue = v.array(v.string());
173
- const pointerArrayValue = v.array(v.object({ id: v.string(), table: v.string() }));
174
- const anyLocalValue = v.union([
175
- stringValue,
176
- numberValue,
177
- booleanValue,
178
- notionDateValueSchema,
179
- stringArrayValue,
180
- pointerArrayValue,
181
- ]);
182
- const _valueUnionsMatch = true;
183
- void _valueUnionsMatch;
184
- /**
185
- * The value shape each property type must hold in a local file. Mirrors the
186
- * production host's serialization: the types production still serializes as
187
- * text are pinned to strings here, deliberately stricter than the dev
188
- * shell's binding-time checks.
189
- */
190
- const VALUE_SCHEMAS = {
191
- title: stringValue,
192
- rich_text: stringValue,
193
- url: stringValue,
194
- email: stringValue,
195
- phone_number: stringValue,
196
- select: stringValue,
197
- status: stringValue,
198
- number: numberValue,
199
- checkbox: booleanValue,
200
- multi_select: stringArrayValue,
201
- date: notionDateValueSchema,
202
- created_time: notionDateValueSchema,
203
- last_edited_time: notionDateValueSchema,
204
- people: pointerArrayValue,
205
- relation: pointerArrayValue,
206
- created_by: pointerArrayValue,
207
- last_edited_by: pointerArrayValue,
208
- unique_id: stringValue,
209
- files: stringValue,
210
- formula: stringValue,
211
- rollup: stringValue,
212
- verification: stringValue,
213
- place: stringValue,
214
- location: stringValue,
215
- last_visited_time: stringValue,
216
- };
217
- export function matchesPropertyType(value, type) {
218
- return v.is(VALUE_SCHEMAS[type] ?? anyLocalValue, value);
219
- }
220
- export function isDataSourceValue(value) {
221
- return v.is(anyLocalValue, value);
222
- }
@@ -1,210 +0,0 @@
1
- /**
2
- * `convert` subcommand: translate a sampled Notion data source (public API
3
- * shapes: schema `properties`, query `results`) into the dev shell's local
4
- * JSON data source format, validate the result, and print it to stdout.
5
- * `ntn workers customblocks sample` pipes through this via stdin; it also runs
6
- * standalone: `npx @notionhq/custom-blocks-dev-shell convert --in sample.json`.
7
- */
8
- import { readFileSync } from "node:fs";
9
- import { NOTION_PROPERTY_TYPES, } from "../protocol/index.js";
10
- import * as v from "valibot";
11
- import { convertPublicApiPropertyValue, isDataSourceValue, matchesPropertyType, } from "./convert-values.js";
12
- import { sourceFileSchema } from "./data-sources.js";
13
- import { formatUnknownError } from "./errors.js";
14
- import { claimUniqueKey, parseCliArgs, slugify } from "./utils.js";
15
- const SUPPORTED_TYPES = new Set(NOTION_PROPERTY_TYPES);
16
- /** The spelling of "text" in the local file format. */
17
- const UNSUPPORTED_TYPE_FALLBACK = "rich_text";
18
- export function parseConvertArgs(argv) {
19
- const args = {
20
- input: undefined,
21
- name: undefined,
22
- };
23
- const rejectUnknown = (arg) => {
24
- throw new Error(`Unknown convert option "${arg}". Supported: --in <file>, --name <name>.`);
25
- };
26
- parseCliArgs({
27
- argv,
28
- handlers: {
29
- "--in": value => {
30
- args.input = value;
31
- },
32
- "--name": value => {
33
- args.name = value;
34
- },
35
- },
36
- onUnknown: rejectUnknown,
37
- // This command accepts no positional arguments.
38
- onPositional: rejectUnknown,
39
- });
40
- return args;
41
- }
42
- const sampleInputSchema = v.pipe(v.looseObject({
43
- name: v.optional(v.string()),
44
- properties: v.optional(v.record(v.string(), v.looseObject({ type: v.string() }))),
45
- results: v.optional(v.array(v.looseObject({
46
- id: v.string(),
47
- properties: v.optional(v.record(v.string(), v.unknown())),
48
- }))),
49
- }), v.check(input => input.properties !== undefined || input.results !== undefined, "expected a schema under `properties` and/or sampled pages under `results`"));
50
- /**
51
- * Convert a sampled data source (public API shapes) into a local data source
52
- * object. The input carries the schema under `properties` and/or sampled
53
- * pages under `results` (query output verbatim). The emitted object always
54
- * carries a `schema` — taken from `properties` when present, otherwise
55
- * inferred from the row values — because the shell derives table columns and
56
- * bindings from the schema alone.
57
- */
58
- export function convertSample(input, overrides = {}) {
59
- const parsed = v.safeParse(sampleInputSchema, input);
60
- if (!parsed.success) {
61
- const issue = parsed.issues[0];
62
- const path = v.getDotPath(issue);
63
- throw new Error(`Input is not a sampled data source: ${path ? `${path}: ` : ""}${issue.message}`);
64
- }
65
- const sample = parsed.output;
66
- const warnings = [];
67
- const mappings = buildPropertyMappings(sample.properties, sample.results, warnings);
68
- const name = overrides.name ?? (sample.name || undefined);
69
- const schema = {};
70
- for (const mapping of mappings.values()) {
71
- schema[mapping.key] = { name: mapping.name, type: mapping.type };
72
- }
73
- const source = {
74
- type: "syncedFromProd",
75
- ...(name !== undefined ? { name } : {}),
76
- schema,
77
- rows: (sample.results ?? []).map(row => convertRow(row, mappings)),
78
- };
79
- validateSource(source);
80
- return { source, warnings };
81
- }
82
- /**
83
- * One mapping per public property name. For schema-only and full samples the
84
- * mappings come from `properties`; for rows-only samples they are derived
85
- * from the `type` field each row value carries.
86
- */
87
- function buildPropertyMappings(properties, sampledRows, warnings) {
88
- const mappings = new Map();
89
- // `id` is the row identifier; a property named "ID" must not overwrite it.
90
- const usedKeys = new Set(["id"]);
91
- const add = (propertyName, publicType) => {
92
- if (mappings.has(propertyName)) {
93
- return;
94
- }
95
- const unsupported = !SUPPORTED_TYPES.has(publicType);
96
- if (unsupported) {
97
- warnings.push(`Property ${JSON.stringify(propertyName)}: public API type ` +
98
- `${JSON.stringify(publicType)} is not supported by custom blocks; ` +
99
- `converted to text ("${UNSUPPORTED_TYPE_FALLBACK}") with the ` +
100
- `placeholder value ${JSON.stringify(`unsupported type: ${publicType}`)}.`);
101
- }
102
- mappings.set(propertyName, {
103
- key: claimUniqueKey(slugify(propertyName) ?? "property", usedKeys),
104
- name: propertyName,
105
- type: unsupported ? UNSUPPORTED_TYPE_FALLBACK : publicType,
106
- publicType,
107
- unsupported,
108
- });
109
- };
110
- for (const [propertyName, property] of Object.entries(properties ?? {})) {
111
- add(propertyName, property.type);
112
- }
113
- for (const row of sampledRows ?? []) {
114
- for (const [propertyName, value] of Object.entries(row.properties ?? {})) {
115
- const publicType = value?.type;
116
- if (typeof publicType === "string") {
117
- add(propertyName, publicType);
118
- }
119
- }
120
- }
121
- return mappings;
122
- }
123
- function convertRow(row, mappings) {
124
- const converted = { id: row.id };
125
- for (const [propertyName, value] of Object.entries(row.properties ?? {})) {
126
- const mapping = mappings.get(propertyName);
127
- if (mapping === undefined) {
128
- continue;
129
- }
130
- if (mapping.unsupported) {
131
- converted[mapping.key] = `unsupported type: ${mapping.publicType}`;
132
- continue;
133
- }
134
- const local = convertPublicApiPropertyValue(mapping.publicType, value);
135
- if (local !== undefined) {
136
- converted[mapping.key] = local;
137
- }
138
- }
139
- return converted;
140
- }
141
- /**
142
- * Validate the built source the same way the dev shell will at spin-up, plus
143
- * a row-value pass the loader doesn't do: every emitted value must match its
144
- * declared schema type. Failures here are conversion bugs or malformed input;
145
- * the command must never print a file the shell would reject.
146
- */
147
- export function validateSource(source) {
148
- const hasSchema = source.schema !== undefined;
149
- const result = v.safeParse(sourceFileSchema, source);
150
- if (!result.success) {
151
- const issue = result.issues[0];
152
- const path = v.getDotPath(issue);
153
- throw new Error(`Converted data source is invalid: ${path ? `${path}: ` : ""}${issue.message}`);
154
- }
155
- const { schema, rows } = result.output;
156
- const issues = [];
157
- for (const row of rows) {
158
- for (const [key, value] of Object.entries(row)) {
159
- if (key === "id") {
160
- continue;
161
- }
162
- const declared = hasSchema ? schema[key] : undefined;
163
- if (hasSchema && declared === undefined) {
164
- issues.push(`row ${JSON.stringify(row.id)}: ${JSON.stringify(key)} is not in the schema`);
165
- continue;
166
- }
167
- const matches = declared
168
- ? matchesPropertyType(value, declared.type)
169
- : isDataSourceValue(value);
170
- if (!matches) {
171
- issues.push(`row ${JSON.stringify(row.id)}: ${JSON.stringify(key)} does not match ${declared ? `type ${JSON.stringify(declared.type)}` : "any supported value shape"}`);
172
- }
173
- }
174
- }
175
- if (issues.length > 0) {
176
- throw new Error(`Converted rows are invalid: ${issues.join("; ")}`);
177
- }
178
- }
179
- export async function runConvert(argv) {
180
- const args = parseConvertArgs(argv);
181
- let raw;
182
- if (args.input !== undefined) {
183
- try {
184
- raw = readFileSync(args.input, "utf-8");
185
- }
186
- catch (error) {
187
- throw new Error(`Could not read ${args.input}: ${formatUnknownError(error)}`);
188
- }
189
- }
190
- else {
191
- if (process.stdin.isTTY) {
192
- throw new Error("No input: pipe `ntn workers customblocks sample` output to convert, or pass --in <file>.");
193
- }
194
- raw = readFileSync(0, "utf-8");
195
- }
196
- let parsed;
197
- try {
198
- parsed = JSON.parse(raw);
199
- }
200
- catch (error) {
201
- throw new Error(`Input is not valid JSON — ${formatUnknownError(error)}`);
202
- }
203
- const { source, warnings } = convertSample(parsed, {
204
- ...(args.name !== undefined ? { name: args.name } : {}),
205
- });
206
- for (const warning of warnings) {
207
- console.warn(warning);
208
- }
209
- process.stdout.write(`${JSON.stringify(source, null, "\t")}\n`);
210
- }
@@ -1,6 +0,0 @@
1
- import { existsSync, readdirSync } from "node:fs";
2
- export function listDataSourceFiles(dataDir) {
3
- return existsSync(dataDir)
4
- ? readdirSync(dataDir).filter(name => name.endsWith(".json"))
5
- : [];
6
- }