@cardstack/boxel-cli 0.2.0-unstable.448 → 0.3.0-unstable.13
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/bundled-types/base/-private.d.ts +1 -0
- package/bundled-types/base/address.d.ts +17 -0
- package/bundled-types/base/ai-app-generator.d.ts +14 -0
- package/bundled-types/base/amount-with-currency.d.ts +10 -0
- package/bundled-types/base/avif-image-def.d.ts +12 -0
- package/bundled-types/base/avif-meta-extractor.d.ts +4 -0
- package/bundled-types/base/base64-image.d.ts +25 -0
- package/bundled-types/base/big-integer.d.ts +12 -0
- package/bundled-types/base/boolean.d.ts +14 -0
- package/bundled-types/base/brand-functional-palette.d.ts +16 -0
- package/bundled-types/base/brand-guide.d.ts +26 -0
- package/bundled-types/base/brand-logo.d.ts +29 -0
- package/bundled-types/base/card-api.d.ts +513 -0
- package/bundled-types/base/card-serialization.d.ts +47 -0
- package/bundled-types/base/cards-grid.d.ts +10 -0
- package/bundled-types/base/code-ref.d.ts +14 -0
- package/bundled-types/base/codemirror-editor.d.ts +135 -0
- package/bundled-types/base/color-field/components/advanced-color-picker.d.ts +66 -0
- package/bundled-types/base/color-field/components/color-picker-field.d.ts +22 -0
- package/bundled-types/base/color-field/components/color-wheel-picker.d.ts +44 -0
- package/bundled-types/base/color-field/components/contrast-checker-addon.d.ts +14 -0
- package/bundled-types/base/color-field/components/recent-colors-addon.d.ts +19 -0
- package/bundled-types/base/color-field/components/slider-picker.d.ts +40 -0
- package/bundled-types/base/color-field/components/swatches-picker.d.ts +5 -0
- package/bundled-types/base/color-field/modifiers/setup-element-modifier.d.ts +10 -0
- package/bundled-types/base/color-field/util/color-field-signature.d.ts +9 -0
- package/bundled-types/base/color-field/util/color-utils.d.ts +96 -0
- package/bundled-types/base/color-field/util/css-color-parsers.d.ts +11 -0
- package/bundled-types/base/color.d.ts +10 -0
- package/bundled-types/base/command.d.ts +593 -0
- package/bundled-types/base/commands/search-card-result.d.ts +36 -0
- package/bundled-types/base/components/age.d.ts +22 -0
- package/bundled-types/base/components/business-days.d.ts +16 -0
- package/bundled-types/base/components/card-list.d.ts +25 -0
- package/bundled-types/base/components/cards-grid-layout.d.ts +58 -0
- package/bundled-types/base/components/countdown.d.ts +31 -0
- package/bundled-types/base/components/expiration-warning.d.ts +24 -0
- package/bundled-types/base/components/time-ago.d.ts +24 -0
- package/bundled-types/base/components/time-slots.d.ts +20 -0
- package/bundled-types/base/components/timeline.d.ts +22 -0
- package/bundled-types/base/contains-many-component.d.ts +7 -0
- package/bundled-types/base/coordinate.d.ts +7 -0
- package/bundled-types/base/country.d.ts +23 -0
- package/bundled-types/base/css-value.d.ts +6 -0
- package/bundled-types/base/csv-file-def.d.ts +29 -0
- package/bundled-types/base/currency.d.ts +16 -0
- package/bundled-types/base/date/day.d.ts +9 -0
- package/bundled-types/base/date/month-day.d.ts +10 -0
- package/bundled-types/base/date/month-year.d.ts +9 -0
- package/bundled-types/base/date/month.d.ts +9 -0
- package/bundled-types/base/date/quarter.d.ts +10 -0
- package/bundled-types/base/date/week.d.ts +9 -0
- package/bundled-types/base/date/year.d.ts +9 -0
- package/bundled-types/base/date-range-field.d.ts +12 -0
- package/bundled-types/base/date.d.ts +12 -0
- package/bundled-types/base/datetime-stamp.d.ts +7 -0
- package/bundled-types/base/datetime.d.ts +12 -0
- package/bundled-types/base/default-templates/atom.d.ts +10 -0
- package/bundled-types/base/default-templates/card-info.d.ts +32 -0
- package/bundled-types/base/default-templates/embedded.d.ts +11 -0
- package/bundled-types/base/default-templates/field-edit.d.ts +10 -0
- package/bundled-types/base/default-templates/file-def-edit.d.ts +8 -0
- package/bundled-types/base/default-templates/fitted.d.ts +12 -0
- package/bundled-types/base/default-templates/head.d.ts +13 -0
- package/bundled-types/base/default-templates/image-def-atom.d.ts +8 -0
- package/bundled-types/base/default-templates/image-def-embedded.d.ts +8 -0
- package/bundled-types/base/default-templates/image-def-fitted.d.ts +8 -0
- package/bundled-types/base/default-templates/image-def-isolated.d.ts +8 -0
- package/bundled-types/base/default-templates/isolated-and-edit.d.ts +15 -0
- package/bundled-types/base/default-templates/markdown-fallback.d.ts +19 -0
- package/bundled-types/base/default-templates/markdown.d.ts +60 -0
- package/bundled-types/base/default-templates/missing-template.d.ts +13 -0
- package/bundled-types/base/default-templates/theme-dashboard.d.ts +126 -0
- package/bundled-types/base/detailed-style-reference.d.ts +48 -0
- package/bundled-types/base/email.d.ts +10 -0
- package/bundled-types/base/enum.d.ts +30 -0
- package/bundled-types/base/ethereum-address.d.ts +13 -0
- package/bundled-types/base/field-component.d.ts +65 -0
- package/bundled-types/base/field-support.d.ts +55 -0
- package/bundled-types/base/file-api.d.ts +2 -0
- package/bundled-types/base/file-menu-items.d.ts +4 -0
- package/bundled-types/base/gif-image-def.d.ts +12 -0
- package/bundled-types/base/gif-meta-extractor.d.ts +4 -0
- package/bundled-types/base/gts-file-def.d.ts +7 -0
- package/bundled-types/base/helpers/country.d.ts +3198 -0
- package/bundled-types/base/helpers/sanitized-html.d.ts +2 -0
- package/bundled-types/base/helpers/set-background-image.d.ts +2 -0
- package/bundled-types/base/image-file-def.d.ts +1 -0
- package/bundled-types/base/image.d.ts +8 -0
- package/bundled-types/base/index.d.ts +1 -0
- package/bundled-types/base/join-the-community.d.ts +14 -0
- package/bundled-types/base/jpg-image-def.d.ts +12 -0
- package/bundled-types/base/jpg-meta-extractor.d.ts +4 -0
- package/bundled-types/base/json-file-def.d.ts +23 -0
- package/bundled-types/base/links-to-editor.d.ts +22 -0
- package/bundled-types/base/links-to-many-component.d.ts +7 -0
- package/bundled-types/base/llm-model.d.ts +6 -0
- package/bundled-types/base/markdown-file-def.d.ts +25 -0
- package/bundled-types/base/markdown-helpers.d.ts +26 -0
- package/bundled-types/base/markdown.d.ts +1 -0
- package/bundled-types/base/matrix-event.d.ts +400 -0
- package/bundled-types/base/menu-items.d.ts +21 -0
- package/bundled-types/base/number/components/badge-counter.d.ts +32 -0
- package/bundled-types/base/number/components/badge-metric.d.ts +34 -0
- package/bundled-types/base/number/components/badge-notification.d.ts +38 -0
- package/bundled-types/base/number/components/gauge.d.ts +45 -0
- package/bundled-types/base/number/components/number-input.d.ts +27 -0
- package/bundled-types/base/number/components/progress-bar.d.ts +44 -0
- package/bundled-types/base/number/components/progress-circle.d.ts +41 -0
- package/bundled-types/base/number/components/score.d.ts +41 -0
- package/bundled-types/base/number/components/stat.d.ts +38 -0
- package/bundled-types/base/number/util/index.d.ts +29 -0
- package/bundled-types/base/number.d.ts +52 -0
- package/bundled-types/base/percentage.d.ts +9 -0
- package/bundled-types/base/phone-number.d.ts +25 -0
- package/bundled-types/base/png-image-def.d.ts +12 -0
- package/bundled-types/base/png-meta-extractor.d.ts +4 -0
- package/bundled-types/base/positioned-card.d.ts +7 -0
- package/bundled-types/base/query-field-support.d.ts +6 -0
- package/bundled-types/base/realm-config.d.ts +16 -0
- package/bundled-types/base/realm.d.ts +7 -0
- package/bundled-types/base/resources/command-data.d.ts +43 -0
- package/bundled-types/base/response-field.d.ts +6 -0
- package/bundled-types/base/rich-markdown.d.ts +30 -0
- package/bundled-types/base/shared-state.d.ts +1 -0
- package/bundled-types/base/skill-plus.d.ts +79 -0
- package/bundled-types/base/skill-reference.d.ts +12 -0
- package/bundled-types/base/skill-set.d.ts +18 -0
- package/bundled-types/base/skill.d.ts +21 -0
- package/bundled-types/base/spec.d.ts +108 -0
- package/bundled-types/base/string.d.ts +2 -0
- package/bundled-types/base/structured-theme-variables.d.ts +85 -0
- package/bundled-types/base/structured-theme.d.ts +32 -0
- package/bundled-types/base/style-reference.d.ts +14 -0
- package/bundled-types/base/svg-image-def.d.ts +12 -0
- package/bundled-types/base/svg-meta-extractor.d.ts +12 -0
- package/bundled-types/base/system-card.d.ts +17 -0
- package/bundled-types/base/tag.d.ts +15 -0
- package/bundled-types/base/text-area.d.ts +2 -0
- package/bundled-types/base/text-file-def.d.ts +23 -0
- package/bundled-types/base/text-input-validator.d.ts +13 -0
- package/bundled-types/base/theme.d.ts +2 -0
- package/bundled-types/base/time/duration.d.ts +14 -0
- package/bundled-types/base/time/relative-time.d.ts +10 -0
- package/bundled-types/base/time/time-range.d.ts +11 -0
- package/bundled-types/base/time.d.ts +9 -0
- package/bundled-types/base/ts-file-def.d.ts +26 -0
- package/bundled-types/base/ts-highlight.d.ts +1 -0
- package/bundled-types/base/types/@cardstack/boxel-host/index.d.ts +5 -0
- package/bundled-types/base/types/ember-css-url/index.d.ts +15 -0
- package/bundled-types/base/typography.d.ts +14 -0
- package/bundled-types/base/url.d.ts +13 -0
- package/bundled-types/base/watched-array.d.ts +7 -0
- package/bundled-types/base/webp-image-def.d.ts +12 -0
- package/bundled-types/base/webp-meta-extractor.d.ts +4 -0
- package/bundled-types/base/website.d.ts +8 -0
- package/bundled-types/base/welcome-to-boxel.d.ts +22 -0
- package/bundled-types/boxel-ui/components/accordion/index.gts +50 -0
- package/bundled-types/boxel-ui/components/accordion/item/index.gts +156 -0
- package/bundled-types/boxel-ui/components/accordion/usage.gts +157 -0
- package/bundled-types/boxel-ui/components/add-button/index.gts +46 -0
- package/bundled-types/boxel-ui/components/add-button/usage.gts +54 -0
- package/bundled-types/boxel-ui/components/alert/index.gts +151 -0
- package/bundled-types/boxel-ui/components/alert/usage.gts +66 -0
- package/bundled-types/boxel-ui/components/avatar/index.gts +79 -0
- package/bundled-types/boxel-ui/components/avatar/usage.gts +96 -0
- package/bundled-types/boxel-ui/components/basic-fitted/index.gts +340 -0
- package/bundled-types/boxel-ui/components/basic-fitted/usage.gts +223 -0
- package/bundled-types/boxel-ui/components/button/index.gts +416 -0
- package/bundled-types/boxel-ui/components/button/usage.gts +334 -0
- package/bundled-types/boxel-ui/components/card-container/index.gts +251 -0
- package/bundled-types/boxel-ui/components/card-container/usage.gts +53 -0
- package/bundled-types/boxel-ui/components/card-header/index.gts +473 -0
- package/bundled-types/boxel-ui/components/card-header/usage.gts +295 -0
- package/bundled-types/boxel-ui/components/circle-spinner/index.gts +42 -0
- package/bundled-types/boxel-ui/components/circle-spinner/usage.gts +48 -0
- package/bundled-types/boxel-ui/components/color-palette/index.gts +134 -0
- package/bundled-types/boxel-ui/components/color-palette/usage.gts +69 -0
- package/bundled-types/boxel-ui/components/color-picker/index.gts +125 -0
- package/bundled-types/boxel-ui/components/color-picker/usage.gts +56 -0
- package/bundled-types/boxel-ui/components/container/index.gts +67 -0
- package/bundled-types/boxel-ui/components/container/usage.gts +59 -0
- package/bundled-types/boxel-ui/components/context-button/index.gts +184 -0
- package/bundled-types/boxel-ui/components/context-button/usage.gts +125 -0
- package/bundled-types/boxel-ui/components/copy-button/index.gts +79 -0
- package/bundled-types/boxel-ui/components/copy-button/usage.gts +25 -0
- package/bundled-types/boxel-ui/components/date-range-picker/index.gts +211 -0
- package/bundled-types/boxel-ui/components/date-range-picker/setup.gts +11 -0
- package/bundled-types/boxel-ui/components/date-range-picker/usage.gts +52 -0
- package/bundled-types/boxel-ui/components/drag-and-drop/index.gts +256 -0
- package/bundled-types/boxel-ui/components/drag-and-drop/usage.gts +142 -0
- package/bundled-types/boxel-ui/components/dropdown/index.gts +478 -0
- package/bundled-types/boxel-ui/components/dropdown/trigger/index.gts +70 -0
- package/bundled-types/boxel-ui/components/dropdown/trigger/usage.gts +54 -0
- package/bundled-types/boxel-ui/components/dropdown/usage.gts +119 -0
- package/bundled-types/boxel-ui/components/email-input/index.gts +111 -0
- package/bundled-types/boxel-ui/components/email-input/usage.gts +75 -0
- package/bundled-types/boxel-ui/components/entity-icon-display/index.gts +144 -0
- package/bundled-types/boxel-ui/components/entity-icon-display/usage.gts +54 -0
- package/bundled-types/boxel-ui/components/entity-thumbnail-display/index.gts +148 -0
- package/bundled-types/boxel-ui/components/entity-thumbnail-display/usage.gts +76 -0
- package/bundled-types/boxel-ui/components/field-container/index.gts +150 -0
- package/bundled-types/boxel-ui/components/field-container/usage.gts +188 -0
- package/bundled-types/boxel-ui/components/filter-list/index.gts +255 -0
- package/bundled-types/boxel-ui/components/filter-list/usage.gts +153 -0
- package/bundled-types/boxel-ui/components/fitted-card-container/index.gts +66 -0
- package/bundled-types/boxel-ui/components/fitted-card-container/usage.gts +81 -0
- package/bundled-types/boxel-ui/components/grid-container/grid-item-container/index.gts +37 -0
- package/bundled-types/boxel-ui/components/grid-container/index.gts +116 -0
- package/bundled-types/boxel-ui/components/grid-container/usage.gts +105 -0
- package/bundled-types/boxel-ui/components/header/index.gts +101 -0
- package/bundled-types/boxel-ui/components/header/usage.gts +116 -0
- package/bundled-types/boxel-ui/components/icon-button/index.gts +148 -0
- package/bundled-types/boxel-ui/components/icon-button/usage.gts +249 -0
- package/bundled-types/boxel-ui/components/input/index.gts +560 -0
- package/bundled-types/boxel-ui/components/input/usage.gts +449 -0
- package/bundled-types/boxel-ui/components/input-group/accessories/index.gts +191 -0
- package/bundled-types/boxel-ui/components/input-group/controls/index.gts +54 -0
- package/bundled-types/boxel-ui/components/input-group/index.gts +347 -0
- package/bundled-types/boxel-ui/components/input-group/usage.gts +437 -0
- package/bundled-types/boxel-ui/components/kanban/card.gts +89 -0
- package/bundled-types/boxel-ui/components/kanban/column-header.gts +151 -0
- package/bundled-types/boxel-ui/components/kanban/drag.gts +1007 -0
- package/bundled-types/boxel-ui/components/kanban/engine.ts +247 -0
- package/bundled-types/boxel-ui/components/kanban/ghost.gts +64 -0
- package/bundled-types/boxel-ui/components/kanban/index.gts +16 -0
- package/bundled-types/boxel-ui/components/kanban/modifiers.gts +42 -0
- package/bundled-types/boxel-ui/components/kanban/plane-inner.gts +525 -0
- package/bundled-types/boxel-ui/components/kanban/plane.gts +163 -0
- package/bundled-types/boxel-ui/components/kanban/usage.gts +392 -0
- package/bundled-types/boxel-ui/components/label/index.gts +64 -0
- package/bundled-types/boxel-ui/components/loading-indicator/index.gts +78 -0
- package/bundled-types/boxel-ui/components/loading-indicator/usage.gts +72 -0
- package/bundled-types/boxel-ui/components/menu/index.gts +267 -0
- package/bundled-types/boxel-ui/components/menu/usage.gts +100 -0
- package/bundled-types/boxel-ui/components/message/index.gts +146 -0
- package/bundled-types/boxel-ui/components/message/usage.gts +263 -0
- package/bundled-types/boxel-ui/components/modal/index.gts +159 -0
- package/bundled-types/boxel-ui/components/modal/usage.gts +206 -0
- package/bundled-types/boxel-ui/components/multi-select/after-options.gts +59 -0
- package/bundled-types/boxel-ui/components/multi-select/index.gts +230 -0
- package/bundled-types/boxel-ui/components/multi-select/selected-item.gts +91 -0
- package/bundled-types/boxel-ui/components/multi-select/trigger.gts +190 -0
- package/bundled-types/boxel-ui/components/multi-select/usage.gts +420 -0
- package/bundled-types/boxel-ui/components/phone-input/index.gts +149 -0
- package/bundled-types/boxel-ui/components/phone-input/usage.gts +73 -0
- package/bundled-types/boxel-ui/components/picker/before-options-with-search.gts +340 -0
- package/bundled-types/boxel-ui/components/picker/index.gts +427 -0
- package/bundled-types/boxel-ui/components/picker/option-row.gts +270 -0
- package/bundled-types/boxel-ui/components/picker/selected-item.gts +171 -0
- package/bundled-types/boxel-ui/components/picker/trigger-labeled.gts +216 -0
- package/bundled-types/boxel-ui/components/picker/usage.gts +179 -0
- package/bundled-types/boxel-ui/components/pill/index.gts +231 -0
- package/bundled-types/boxel-ui/components/pill/usage.gts +230 -0
- package/bundled-types/boxel-ui/components/progress-bar/index.gts +124 -0
- package/bundled-types/boxel-ui/components/progress-bar/usage.gts +131 -0
- package/bundled-types/boxel-ui/components/progress-radial/index.gts +95 -0
- package/bundled-types/boxel-ui/components/progress-radial/usage.gts +79 -0
- package/bundled-types/boxel-ui/components/radio-input/index.gts +143 -0
- package/bundled-types/boxel-ui/components/radio-input/item.gts +210 -0
- package/bundled-types/boxel-ui/components/radio-input/usage.gts +303 -0
- package/bundled-types/boxel-ui/components/realm-icon/index.gts +129 -0
- package/bundled-types/boxel-ui/components/realm-icon/usage.gts +62 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/handle.gts +180 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/index.gts +341 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/panel.gts +86 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/usage.gts +350 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/adjust-layout-by-delta.ts +231 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/assert.ts +10 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/calculate-delta-percentage.ts +41 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/calculate-unsafe-default-layout.ts +53 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/compare-layouts.ts +12 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/const.ts +6 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/determine-pivot-indices.ts +15 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/dom/get-panel-element.ts +10 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/dom/get-panel-elements-for-group.ts +8 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/dom/get-panel-group-element.ts +21 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/dom/get-resize-handle-element-index.ts +14 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/dom/get-resize-handle-element.ts +12 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/dom/get-resize-handle-elements-for-group.ts +10 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/fuzzy-layouts-equal.ts +22 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/fuzzy-numbers.ts +21 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/get-resize-event-coordinates.ts +8 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/get-resize-event-cursor-position.ts +10 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/panel-resize-handle-registry.ts +446 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/resize-panel.ts +35 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/types.ts +23 -0
- package/bundled-types/boxel-ui/components/resizable-panel-group/utils/validate-panel-group-layout.ts +86 -0
- package/bundled-types/boxel-ui/components/select/index.gts +882 -0
- package/bundled-types/boxel-ui/components/select/trigger.gts +132 -0
- package/bundled-types/boxel-ui/components/select/usage.gts +353 -0
- package/bundled-types/boxel-ui/components/skeleton-placeholder/index.gts +89 -0
- package/bundled-types/boxel-ui/components/skeleton-placeholder/usage.gts +102 -0
- package/bundled-types/boxel-ui/components/sort-dropdown/index.gts +91 -0
- package/bundled-types/boxel-ui/components/sort-dropdown/usage.gts +77 -0
- package/bundled-types/boxel-ui/components/swatch/index.gts +81 -0
- package/bundled-types/boxel-ui/components/swatch/usage.gts +57 -0
- package/bundled-types/boxel-ui/components/switch/index.gts +95 -0
- package/bundled-types/boxel-ui/components/switch/usage.gts +79 -0
- package/bundled-types/boxel-ui/components/tabbed-header/index.gts +141 -0
- package/bundled-types/boxel-ui/components/tabbed-header/usage.gts +103 -0
- package/bundled-types/boxel-ui/components/tag/index.gts +50 -0
- package/bundled-types/boxel-ui/components/tag/usage.gts +89 -0
- package/bundled-types/boxel-ui/components/tag-list/index.gts +85 -0
- package/bundled-types/boxel-ui/components/tag-list/usage.gts +129 -0
- package/bundled-types/boxel-ui/components/tooltip/index.gts +306 -0
- package/bundled-types/boxel-ui/components/tooltip/usage.gts +168 -0
- package/bundled-types/boxel-ui/components/view-selector/index.gts +166 -0
- package/bundled-types/boxel-ui/components/view-selector/usage.gts +149 -0
- package/bundled-types/boxel-ui/components.ts +169 -0
- package/bundled-types/boxel-ui/helpers/add-class-to-svg.ts +8 -0
- package/bundled-types/boxel-ui/helpers/clipboard.ts +21 -0
- package/bundled-types/boxel-ui/helpers/cn.ts +12 -0
- package/bundled-types/boxel-ui/helpers/color-tools.ts +331 -0
- package/bundled-types/boxel-ui/helpers/compact.ts +3 -0
- package/bundled-types/boxel-ui/helpers/contrast-color.ts +32 -0
- package/bundled-types/boxel-ui/helpers/css-var.ts +41 -0
- package/bundled-types/boxel-ui/helpers/currency-format.ts +25 -0
- package/bundled-types/boxel-ui/helpers/dayjs-format.ts +27 -0
- package/bundled-types/boxel-ui/helpers/deterministic-color-from-string.ts +45 -0
- package/bundled-types/boxel-ui/helpers/element.ts +16 -0
- package/bundled-types/boxel-ui/helpers/extract-css-variables.ts +126 -0
- package/bundled-types/boxel-ui/helpers/format-age.ts +72 -0
- package/bundled-types/boxel-ui/helpers/format-countdown.ts +110 -0
- package/bundled-types/boxel-ui/helpers/format-currency.ts +95 -0
- package/bundled-types/boxel-ui/helpers/format-date-time.ts +567 -0
- package/bundled-types/boxel-ui/helpers/format-duration.ts +143 -0
- package/bundled-types/boxel-ui/helpers/format-file-size.ts +49 -0
- package/bundled-types/boxel-ui/helpers/format-list.ts +73 -0
- package/bundled-types/boxel-ui/helpers/format-names.ts +103 -0
- package/bundled-types/boxel-ui/helpers/format-number.ts +140 -0
- package/bundled-types/boxel-ui/helpers/format-ordinal.ts +115 -0
- package/bundled-types/boxel-ui/helpers/format-period.ts +188 -0
- package/bundled-types/boxel-ui/helpers/format-relative-time.ts +789 -0
- package/bundled-types/boxel-ui/helpers/generate-css-variables.ts +47 -0
- package/bundled-types/boxel-ui/helpers/markdown-escape.ts +36 -0
- package/bundled-types/boxel-ui/helpers/math-helpers.ts +18 -0
- package/bundled-types/boxel-ui/helpers/menu-divider.ts +15 -0
- package/bundled-types/boxel-ui/helpers/menu-item.ts +76 -0
- package/bundled-types/boxel-ui/helpers/optional.ts +7 -0
- package/bundled-types/boxel-ui/helpers/pick.ts +11 -0
- package/bundled-types/boxel-ui/helpers/sanitize-html.ts +45 -0
- package/bundled-types/boxel-ui/helpers/string.ts +15 -0
- package/bundled-types/boxel-ui/helpers/theme-css.ts +148 -0
- package/bundled-types/boxel-ui/helpers/truth-helpers.ts +48 -0
- package/bundled-types/boxel-ui/helpers/validate-email-format.ts +138 -0
- package/bundled-types/boxel-ui/helpers/validate-phone-format.ts +201 -0
- package/bundled-types/boxel-ui/helpers.ts +134 -0
- package/bundled-types/boxel-ui/icons/ai-bw.gts +22 -0
- package/bundled-types/boxel-ui/icons/arrow-left.gts +25 -0
- package/bundled-types/boxel-ui/icons/arrow-right.gts +28 -0
- package/bundled-types/boxel-ui/icons/arrow-top-left.gts +22 -0
- package/bundled-types/boxel-ui/icons/arrow-up.gts +25 -0
- package/bundled-types/boxel-ui/icons/atom.gts +26 -0
- package/bundled-types/boxel-ui/icons/boxel-icon-with-text.gts +29 -0
- package/bundled-types/boxel-ui/icons/boxel-icon.gts +34 -0
- package/bundled-types/boxel-ui/icons/card-definition.gts +26 -0
- package/bundled-types/boxel-ui/icons/card-instance.gts +26 -0
- package/bundled-types/boxel-ui/icons/card.gts +24 -0
- package/bundled-types/boxel-ui/icons/cardbot-lg.gts +24 -0
- package/bundled-types/boxel-ui/icons/caret-down.gts +23 -0
- package/bundled-types/boxel-ui/icons/caret-up.gts +23 -0
- package/bundled-types/boxel-ui/icons/check-mark.gts +23 -0
- package/bundled-types/boxel-ui/icons/chevron-right.gts +23 -0
- package/bundled-types/boxel-ui/icons/copy.gts +28 -0
- package/bundled-types/boxel-ui/icons/diagonal-arrow-left-up.gts +21 -0
- package/bundled-types/boxel-ui/icons/download.gts +19 -0
- package/bundled-types/boxel-ui/icons/dropdown-arrow-down.gts +20 -0
- package/bundled-types/boxel-ui/icons/dropdown-arrow-filled.gts +19 -0
- package/bundled-types/boxel-ui/icons/dropdown-arrow-up.gts +20 -0
- package/bundled-types/boxel-ui/icons/edit.gts +14 -0
- package/bundled-types/boxel-ui/icons/embedded.gts +34 -0
- package/bundled-types/boxel-ui/icons/exclamation-circle.gts +26 -0
- package/bundled-types/boxel-ui/icons/exclamation.gts +20 -0
- package/bundled-types/boxel-ui/icons/eye.gts +19 -0
- package/bundled-types/boxel-ui/icons/failure-bordered.gts +26 -0
- package/bundled-types/boxel-ui/icons/field.gts +26 -0
- package/bundled-types/boxel-ui/icons/file-alert.gts +28 -0
- package/bundled-types/boxel-ui/icons/file.gts +27 -0
- package/bundled-types/boxel-ui/icons/fitted.gts +42 -0
- package/bundled-types/boxel-ui/icons/folder.gts +26 -0
- package/bundled-types/boxel-ui/icons/form.gts +38 -0
- package/bundled-types/boxel-ui/icons/four-lines.gts +21 -0
- package/bundled-types/boxel-ui/icons/grid-3x3.gts +26 -0
- package/bundled-types/boxel-ui/icons/group.gts +22 -0
- package/bundled-types/boxel-ui/icons/head.gts +28 -0
- package/bundled-types/boxel-ui/icons/highlight-icon.gts +46 -0
- package/bundled-types/boxel-ui/icons/icon-circle-selected.gts +25 -0
- package/bundled-types/boxel-ui/icons/icon-circle.gts +25 -0
- package/bundled-types/boxel-ui/icons/icon-code.gts +22 -0
- package/bundled-types/boxel-ui/icons/icon-funnel.gts +23 -0
- package/bundled-types/boxel-ui/icons/icon-globe.gts +19 -0
- package/bundled-types/boxel-ui/icons/icon-grid.gts +68 -0
- package/bundled-types/boxel-ui/icons/icon-hexagon.gts +22 -0
- package/bundled-types/boxel-ui/icons/icon-inherit.gts +19 -0
- package/bundled-types/boxel-ui/icons/icon-link.gts +20 -0
- package/bundled-types/boxel-ui/icons/icon-list.gts +40 -0
- package/bundled-types/boxel-ui/icons/icon-minus-circle.gts +26 -0
- package/bundled-types/boxel-ui/icons/icon-pencil-crossed-out.gts +33 -0
- package/bundled-types/boxel-ui/icons/icon-pencil-not-crossed-out.gts +21 -0
- package/bundled-types/boxel-ui/icons/icon-pencil.gts +23 -0
- package/bundled-types/boxel-ui/icons/icon-plus-circle.gts +31 -0
- package/bundled-types/boxel-ui/icons/icon-plus-thin.gts +19 -0
- package/bundled-types/boxel-ui/icons/icon-plus.gts +20 -0
- package/bundled-types/boxel-ui/icons/icon-search-thick.gts +27 -0
- package/bundled-types/boxel-ui/icons/icon-search.gts +25 -0
- package/bundled-types/boxel-ui/icons/icon-table.gts +44 -0
- package/bundled-types/boxel-ui/icons/icon-trash.gts +24 -0
- package/bundled-types/boxel-ui/icons/icon-turn-down-right.gts +18 -0
- package/bundled-types/boxel-ui/icons/icon-x.gts +21 -0
- package/bundled-types/boxel-ui/icons/image-placeholder.gts +30 -0
- package/bundled-types/boxel-ui/icons/isolated.gts +20 -0
- package/bundled-types/boxel-ui/icons/loading-indicator.gts +26 -0
- package/bundled-types/boxel-ui/icons/lock.gts +23 -0
- package/bundled-types/boxel-ui/icons/markdown.gts +19 -0
- package/bundled-types/boxel-ui/icons/profile.gts +23 -0
- package/bundled-types/boxel-ui/icons/publish-site-icon.gts +25 -0
- package/bundled-types/boxel-ui/icons/rows-4.gts +26 -0
- package/bundled-types/boxel-ui/icons/select-all.gts +25 -0
- package/bundled-types/boxel-ui/icons/send.gts +21 -0
- package/bundled-types/boxel-ui/icons/sparkle.gts +21 -0
- package/bundled-types/boxel-ui/icons/star-filled.gts +25 -0
- package/bundled-types/boxel-ui/icons/star-half-fill.gts +27 -0
- package/bundled-types/boxel-ui/icons/star.gts +25 -0
- package/bundled-types/boxel-ui/icons/success-bordered.gts +30 -0
- package/bundled-types/boxel-ui/icons/three-dots-horizontal.gts +21 -0
- package/bundled-types/boxel-ui/icons/triangle-left.gts +23 -0
- package/bundled-types/boxel-ui/icons/triangle-right.gts +23 -0
- package/bundled-types/boxel-ui/icons/types.ts +10 -0
- package/bundled-types/boxel-ui/icons/upload.gts +20 -0
- package/bundled-types/boxel-ui/icons/warning.gts +19 -0
- package/bundled-types/boxel-ui/icons.gts +249 -0
- package/bundled-types/boxel-ui/modifiers/auto-focus.ts +7 -0
- package/bundled-types/boxel-ui/modifiers/set-css-var.ts +24 -0
- package/bundled-types/boxel-ui/modifiers.ts +14 -0
- package/bundled-types/boxel-ui/types/@cardstack/boxel-ui/index.d.ts +3 -0
- package/bundled-types/boxel-ui/types/ember-css-url/index.d.ts +15 -0
- package/bundled-types/boxel-ui/types/ember-draggable-modifiers/index.d.ts +109 -0
- package/bundled-types/boxel-ui/types/ember-draggable-modifiers/utils.d.ts +7 -0
- package/bundled-types/boxel-ui/types/ember-focus-trap/index.d.ts +20 -0
- package/bundled-types/boxel-ui/types/ember-power-calendar/components/index.d.ts +9 -0
- package/bundled-types/boxel-ui/types/ember-resize-modifier/index.d.ts +14 -0
- package/bundled-types/boxel-ui/types/ember-set-body-class/index.d.ts +12 -0
- package/bundled-types/boxel-ui/types/ember-sortable/index.d.ts +52 -0
- package/bundled-types/boxel-ui/types/global.d.ts +7 -0
- package/bundled-types/boxel-ui/usage.ts +112 -0
- package/bundled-types/boxel-ui/utils/date-utils.ts +192 -0
- package/bundled-types/boxel-ui/utils/fitted-formats.ts +161 -0
- package/bundled-types/host-app/app.ts +22 -0
- package/bundled-types/host-app/commands/add-field-to-card-definition.ts +74 -0
- package/bundled-types/host-app/commands/ai-assistant.ts +203 -0
- package/bundled-types/host-app/commands/apply-markdown-edit.ts +203 -0
- package/bundled-types/host-app/commands/apply-search-replace-block.ts +225 -0
- package/bundled-types/host-app/commands/ask-ai.ts +66 -0
- package/bundled-types/host-app/commands/authed-fetch.ts +53 -0
- package/bundled-types/host-app/commands/bot-requests/create-listing-pr-request.ts +77 -0
- package/bundled-types/host-app/commands/bot-requests/send-bot-trigger-event.ts +53 -0
- package/bundled-types/host-app/commands/can-read-realm.ts +34 -0
- package/bundled-types/host-app/commands/cancel-indexing-job.ts +29 -0
- package/bundled-types/host-app/commands/check-correctness.ts +309 -0
- package/bundled-types/host-app/commands/copy-and-edit.ts +311 -0
- package/bundled-types/host-app/commands/copy-card-as-markdown.ts +41 -0
- package/bundled-types/host-app/commands/copy-card-to-stack.ts +70 -0
- package/bundled-types/host-app/commands/copy-card.ts +67 -0
- package/bundled-types/host-app/commands/copy-file-to-realm.ts +82 -0
- package/bundled-types/host-app/commands/copy-source.ts +46 -0
- package/bundled-types/host-app/commands/create-ai-assistant-room.ts +144 -0
- package/bundled-types/host-app/commands/create-and-open-submission-workflow-card.ts +30 -0
- package/bundled-types/host-app/commands/create-specs.ts +422 -0
- package/bundled-types/host-app/commands/create-submission-workflow.ts +172 -0
- package/bundled-types/host-app/commands/evaluate-module.ts +119 -0
- package/bundled-types/host-app/commands/execute-atomic-operations.ts +44 -0
- package/bundled-types/host-app/commands/fetch-card-json.ts +33 -0
- package/bundled-types/host-app/commands/full-reindex-realm.ts +30 -0
- package/bundled-types/host-app/commands/generate-example-cards.ts +298 -0
- package/bundled-types/host-app/commands/generate-readme-spec.ts +116 -0
- package/bundled-types/host-app/commands/generate-theme-example.ts +147 -0
- package/bundled-types/host-app/commands/generate-thumbnail.ts +247 -0
- package/bundled-types/host-app/commands/get-all-realm-metas.ts +38 -0
- package/bundled-types/host-app/commands/get-available-realm-identifiers.ts +29 -0
- package/bundled-types/host-app/commands/get-card-type-schema.ts +59 -0
- package/bundled-types/host-app/commands/get-card.ts +34 -0
- package/bundled-types/host-app/commands/get-catalog-realm-identifiers.ts +29 -0
- package/bundled-types/host-app/commands/get-default-writable-realm.ts +28 -0
- package/bundled-types/host-app/commands/get-events-from-room.ts +70 -0
- package/bundled-types/host-app/commands/get-realm-of-resource-identifier.ts +37 -0
- package/bundled-types/host-app/commands/get-user-system-card.ts +38 -0
- package/bundled-types/host-app/commands/index.ts +590 -0
- package/bundled-types/host-app/commands/instantiate-card.ts +185 -0
- package/bundled-types/host-app/commands/invalidate-realm-identifiers.ts +33 -0
- package/bundled-types/host-app/commands/invite-user-to-room.ts +34 -0
- package/bundled-types/host-app/commands/lint-and-fix.ts +60 -0
- package/bundled-types/host-app/commands/listing-action-build.ts +79 -0
- package/bundled-types/host-app/commands/listing-action-init.ts +106 -0
- package/bundled-types/host-app/commands/listing-create.ts +632 -0
- package/bundled-types/host-app/commands/listing-generate-example.ts +83 -0
- package/bundled-types/host-app/commands/listing-install.ts +227 -0
- package/bundled-types/host-app/commands/listing-remix.ts +150 -0
- package/bundled-types/host-app/commands/listing-update-specs.ts +116 -0
- package/bundled-types/host-app/commands/listing-use.ts +97 -0
- package/bundled-types/host-app/commands/one-shot-llm-request.ts +209 -0
- package/bundled-types/host-app/commands/open-ai-assistant-room.ts +38 -0
- package/bundled-types/host-app/commands/open-create-listing-modal.ts +52 -0
- package/bundled-types/host-app/commands/open-in-interact-mode.ts +36 -0
- package/bundled-types/host-app/commands/open-workspace.ts +38 -0
- package/bundled-types/host-app/commands/patch-card-instance.ts +108 -0
- package/bundled-types/host-app/commands/patch-code.ts +243 -0
- package/bundled-types/host-app/commands/patch-fields.ts +304 -0
- package/bundled-types/host-app/commands/patch-theme.ts +52 -0
- package/bundled-types/host-app/commands/persist-module-inspector-view.ts +41 -0
- package/bundled-types/host-app/commands/populate-with-sample-data.ts +84 -0
- package/bundled-types/host-app/commands/preview-format.ts +52 -0
- package/bundled-types/host-app/commands/read-binary-file.ts +62 -0
- package/bundled-types/host-app/commands/read-card-for-ai-assistant.ts +50 -0
- package/bundled-types/host-app/commands/read-file-for-ai-assistant.ts +46 -0
- package/bundled-types/host-app/commands/read-source.ts +46 -0
- package/bundled-types/host-app/commands/read-text-file.ts +44 -0
- package/bundled-types/host-app/commands/register-bot.ts +42 -0
- package/bundled-types/host-app/commands/reindex-realm.ts +30 -0
- package/bundled-types/host-app/commands/retry-submission-workflow.ts +119 -0
- package/bundled-types/host-app/commands/sanitize-module-list.ts +83 -0
- package/bundled-types/host-app/commands/save-card.ts +44 -0
- package/bundled-types/host-app/commands/screenshot-card.ts +148 -0
- package/bundled-types/host-app/commands/search-and-choose.ts +180 -0
- package/bundled-types/host-app/commands/search-cards.ts +102 -0
- package/bundled-types/host-app/commands/search-google-images.ts +100 -0
- package/bundled-types/host-app/commands/send-ai-assistant-message.ts +122 -0
- package/bundled-types/host-app/commands/send-request-via-proxy.ts +70 -0
- package/bundled-types/host-app/commands/serialize-card.ts +45 -0
- package/bundled-types/host-app/commands/set-active-llm.ts +39 -0
- package/bundled-types/host-app/commands/set-user-system-card.ts +29 -0
- package/bundled-types/host-app/commands/show-card.ts +102 -0
- package/bundled-types/host-app/commands/show-file.ts +39 -0
- package/bundled-types/host-app/commands/store-add.ts +37 -0
- package/bundled-types/host-app/commands/summarize-session.ts +82 -0
- package/bundled-types/host-app/commands/switch-submode.ts +112 -0
- package/bundled-types/host-app/commands/sync-openrouter-models.ts +373 -0
- package/bundled-types/host-app/commands/transform-cards.ts +59 -0
- package/bundled-types/host-app/commands/unregister-bot.ts +29 -0
- package/bundled-types/host-app/commands/update-code-path-with-selection.ts +45 -0
- package/bundled-types/host-app/commands/update-playground-selection.ts +37 -0
- package/bundled-types/host-app/commands/update-room-skills.ts +231 -0
- package/bundled-types/host-app/commands/utils.ts +178 -0
- package/bundled-types/host-app/commands/validate-realm.ts +40 -0
- package/bundled-types/host-app/commands/write-binary-file.ts +142 -0
- package/bundled-types/host-app/commands/write-text-file.ts +104 -0
- package/bundled-types/host-app/components/.gitkeep +0 -0
- package/bundled-types/host-app/components/ai-assistant/action-bar.gts +188 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-button-active-bg.webp +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-button-active-bg@2x.webp +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-button-active-bg@3x.webp +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-icon-animated.webp +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-icon-bw.png +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-icon-bw@2x.png +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-icon-bw@3x.png +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-icon.webp +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-icon@2x.webp +0 -0
- package/bundled-types/host-app/components/ai-assistant/ai-assist-icon@3x.webp +0 -0
- package/bundled-types/host-app/components/ai-assistant/apply-button/index.gts +226 -0
- package/bundled-types/host-app/components/ai-assistant/apply-button/usage.gts +81 -0
- package/bundled-types/host-app/components/ai-assistant/attached-file-dropdown-menu.gts +179 -0
- package/bundled-types/host-app/components/ai-assistant/attachment-picker/attach-button.gts +176 -0
- package/bundled-types/host-app/components/ai-assistant/attachment-picker/attached-items.gts +271 -0
- package/bundled-types/host-app/components/ai-assistant/attachment-picker/index.gts +144 -0
- package/bundled-types/host-app/components/ai-assistant/attachment-picker/usage.gts +127 -0
- package/bundled-types/host-app/components/ai-assistant/button.gts +60 -0
- package/bundled-types/host-app/components/ai-assistant/chat-input/index.gts +203 -0
- package/bundled-types/host-app/components/ai-assistant/chat-input/usage.gts +68 -0
- package/bundled-types/host-app/components/ai-assistant/code-block/actions.gts +58 -0
- package/bundled-types/host-app/components/ai-assistant/code-block/apply-code-patch-button.gts +66 -0
- package/bundled-types/host-app/components/ai-assistant/code-block/command-header.gts +115 -0
- package/bundled-types/host-app/components/ai-assistant/code-block/diff-editor-header.gts +209 -0
- package/bundled-types/host-app/components/ai-assistant/code-block/index.gts +228 -0
- package/bundled-types/host-app/components/ai-assistant/code-block/patch-footer.gts +32 -0
- package/bundled-types/host-app/components/ai-assistant/code-block/view-code-button.gts +73 -0
- package/bundled-types/host-app/components/ai-assistant/focus-pill/index.gts +60 -0
- package/bundled-types/host-app/components/ai-assistant/focus-pill/usage.gts +45 -0
- package/bundled-types/host-app/components/ai-assistant/llm-mode-toggle.gts +113 -0
- package/bundled-types/host-app/components/ai-assistant/llm-select.gts +158 -0
- package/bundled-types/host-app/components/ai-assistant/message/aibot-message.gts +374 -0
- package/bundled-types/host-app/components/ai-assistant/message/attachments.gts +153 -0
- package/bundled-types/host-app/components/ai-assistant/message/index.gts +678 -0
- package/bundled-types/host-app/components/ai-assistant/message/meta.gts +66 -0
- package/bundled-types/host-app/components/ai-assistant/message/text-content.gts +32 -0
- package/bundled-types/host-app/components/ai-assistant/message/usage.gts +182 -0
- package/bundled-types/host-app/components/ai-assistant/message/user-message.gts +52 -0
- package/bundled-types/host-app/components/ai-assistant/new-session-button.gts +126 -0
- package/bundled-types/host-app/components/ai-assistant/new-session-settings.gts +180 -0
- package/bundled-types/host-app/components/ai-assistant/new-session.gts +83 -0
- package/bundled-types/host-app/components/ai-assistant/panel-popover.gts +102 -0
- package/bundled-types/host-app/components/ai-assistant/panel.gts +453 -0
- package/bundled-types/host-app/components/ai-assistant/past-session-item.gts +323 -0
- package/bundled-types/host-app/components/ai-assistant/past-sessions.gts +115 -0
- package/bundled-types/host-app/components/ai-assistant/rename-session.gts +144 -0
- package/bundled-types/host-app/components/ai-assistant/restore-file-modal.gts +105 -0
- package/bundled-types/host-app/components/ai-assistant/skill-menu/index.gts +190 -0
- package/bundled-types/host-app/components/ai-assistant/skill-menu/skill-toggle.gts +168 -0
- package/bundled-types/host-app/components/ai-assistant/skill-menu/usage.gts +48 -0
- package/bundled-types/host-app/components/ai-assistant/toast.gts +293 -0
- package/bundled-types/host-app/components/card-catalog/modal.gts +579 -0
- package/bundled-types/host-app/components/card-error.gts +41 -0
- package/bundled-types/host-app/components/card-instance-picker/index.gts +54 -0
- package/bundled-types/host-app/components/card-pill.gts +189 -0
- package/bundled-types/host-app/components/card-prerender.gts +880 -0
- package/bundled-types/host-app/components/card-renderer.gts +84 -0
- package/bundled-types/host-app/components/card-search/constants.ts +76 -0
- package/bundled-types/host-app/components/card-search/item-button.gts +243 -0
- package/bundled-types/host-app/components/card-search/panel.gts +150 -0
- package/bundled-types/host-app/components/card-search/search-bar.gts +218 -0
- package/bundled-types/host-app/components/card-search/search-content.gts +604 -0
- package/bundled-types/host-app/components/card-search/search-result-header.gts +165 -0
- package/bundled-types/host-app/components/card-search/search-result-section.gts +545 -0
- package/bundled-types/host-app/components/card-search/section-header.gts +117 -0
- package/bundled-types/host-app/components/editor/directory.gts +308 -0
- package/bundled-types/host-app/components/editor/file-tree.gts +69 -0
- package/bundled-types/host-app/components/editor/import-module.gts +27 -0
- package/bundled-types/host-app/components/editor/indexed-file-tree.gts +572 -0
- package/bundled-types/host-app/components/editor/recent-files.gts +141 -0
- package/bundled-types/host-app/components/file-pill.gts +206 -0
- package/bundled-types/host-app/components/head-format-preview.gts +781 -0
- package/bundled-types/host-app/components/host-mode/breadcrumb-item.gts +150 -0
- package/bundled-types/host-app/components/host-mode/breadcrumbs.gts +131 -0
- package/bundled-types/host-app/components/host-mode/card.gts +199 -0
- package/bundled-types/host-app/components/host-mode/content.gts +195 -0
- package/bundled-types/host-app/components/host-mode/stack-item.gts +310 -0
- package/bundled-types/host-app/components/host-mode/stack.gts +91 -0
- package/bundled-types/host-app/components/matrix/auth-container.gts +66 -0
- package/bundled-types/host-app/components/matrix/auth.gts +73 -0
- package/bundled-types/host-app/components/matrix/forgot-password.gts +487 -0
- package/bundled-types/host-app/components/matrix/login.gts +241 -0
- package/bundled-types/host-app/components/matrix/register-user.gts +843 -0
- package/bundled-types/host-app/components/matrix/room-message-command.gts +330 -0
- package/bundled-types/host-app/components/matrix/room-message.gts +261 -0
- package/bundled-types/host-app/components/matrix/room.gts +1872 -0
- package/bundled-types/host-app/components/matrix/user-profile.gts +99 -0
- package/bundled-types/host-app/components/modal-container.gts +171 -0
- package/bundled-types/host-app/components/operator-mode/binary-file-info.gts +77 -0
- package/bundled-types/host-app/components/operator-mode/card-adoption-chain.gts +99 -0
- package/bundled-types/host-app/components/operator-mode/card-error-detail.gts +87 -0
- package/bundled-types/host-app/components/operator-mode/card-error.gts +177 -0
- package/bundled-types/host-app/components/operator-mode/card-schema-editor.gts +616 -0
- package/bundled-types/host-app/components/operator-mode/card-url-bar.gts +197 -0
- package/bundled-types/host-app/components/operator-mode/choose-file-modal.gts +562 -0
- package/bundled-types/host-app/components/operator-mode/choose-subscription-plan-modal.gts +517 -0
- package/bundled-types/host-app/components/operator-mode/code-editor.gts +736 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/editor-indicator.gts +128 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/format-chooser.gts +589 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/inner-container.gts +162 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/left-panel-toggle.gts +267 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/module-inspector.gts +836 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/playground/field-chooser-modal.gts +97 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/playground/instance-chooser-dropdown.gts +346 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/playground/playground-background.png +0 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/playground/playground-panel.gts +1274 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/playground/playground-preview.gts +155 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/playground/playground.gts +98 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/playground/spec-search.gts +70 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/schema-editor.gts +205 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/spec-preview-badge.gts +72 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/spec-preview.gts +432 -0
- package/bundled-types/host-app/components/operator-mode/code-submode/toggle-button.gts +72 -0
- package/bundled-types/host-app/components/operator-mode/code-submode.gts +1030 -0
- package/bundled-types/host-app/components/operator-mode/container.gts +270 -0
- package/bundled-types/host-app/components/operator-mode/context-menu-button.gts +95 -0
- package/bundled-types/host-app/components/operator-mode/copy-button.gts +277 -0
- package/bundled-types/host-app/components/operator-mode/create-file-modal.gts +1087 -0
- package/bundled-types/host-app/components/operator-mode/create-listing-modal.gts +513 -0
- package/bundled-types/host-app/components/operator-mode/definition-container/base.gts +222 -0
- package/bundled-types/host-app/components/operator-mode/definition-container/clickable.gts +59 -0
- package/bundled-types/host-app/components/operator-mode/definition-container/divider.gts +48 -0
- package/bundled-types/host-app/components/operator-mode/definition-container/index.gts +108 -0
- package/bundled-types/host-app/components/operator-mode/delete-modal.gts +123 -0
- package/bundled-types/host-app/components/operator-mode/detail-panel-selector.gts +320 -0
- package/bundled-types/host-app/components/operator-mode/detail-panel.gts +834 -0
- package/bundled-types/host-app/components/operator-mode/edit-field-modal.gts +450 -0
- package/bundled-types/host-app/components/operator-mode/error-display.gts +590 -0
- package/bundled-types/host-app/components/operator-mode/host-submode/open-site-popover.gts +127 -0
- package/bundled-types/host-app/components/operator-mode/host-submode/publishing-realm-popover.gts +159 -0
- package/bundled-types/host-app/components/operator-mode/host-submode.gts +373 -0
- package/bundled-types/host-app/components/operator-mode/interact-submode/neighbor-stack-trigger.gts +116 -0
- package/bundled-types/host-app/components/operator-mode/interact-submode.gts +1021 -0
- package/bundled-types/host-app/components/operator-mode/new-file-button.gts +187 -0
- package/bundled-types/host-app/components/operator-mode/operator-mode-overlays.gts +511 -0
- package/bundled-types/host-app/components/operator-mode/overlays.gts +342 -0
- package/bundled-types/host-app/components/operator-mode/preview-panel/fitted-format-gallery.gts +127 -0
- package/bundled-types/host-app/components/operator-mode/preview-panel/index.gts +443 -0
- package/bundled-types/host-app/components/operator-mode/preview-panel/markdown-preview.gts +175 -0
- package/bundled-types/host-app/components/operator-mode/preview-panel/metadata-panel.gts +214 -0
- package/bundled-types/host-app/components/operator-mode/preview-panel/rendered-markdown.gts +718 -0
- package/bundled-types/host-app/components/operator-mode/private-dependency-violation.gts +70 -0
- package/bundled-types/host-app/components/operator-mode/profile/profile-email.gts +686 -0
- package/bundled-types/host-app/components/operator-mode/profile/profile-settings-modal.gts +454 -0
- package/bundled-types/host-app/components/operator-mode/profile/profile-subscription.gts +170 -0
- package/bundled-types/host-app/components/operator-mode/profile-info-popover.gts +263 -0
- package/bundled-types/host-app/components/operator-mode/publish-realm-modal.gts +1529 -0
- package/bundled-types/host-app/components/operator-mode/remove-field-modal.gts +135 -0
- package/bundled-types/host-app/components/operator-mode/send-error-to-ai-assistant.gts +195 -0
- package/bundled-types/host-app/components/operator-mode/stack-item.gts +1341 -0
- package/bundled-types/host-app/components/operator-mode/stack.gts +191 -0
- package/bundled-types/host-app/components/operator-mode/submode-layout.gts +781 -0
- package/bundled-types/host-app/components/operator-mode/syntax-error-display.gts +72 -0
- package/bundled-types/host-app/components/operator-mode/workspace-chooser/add-workspace.gts +282 -0
- package/bundled-types/host-app/components/operator-mode/workspace-chooser/index.gts +299 -0
- package/bundled-types/host-app/components/operator-mode/workspace-chooser/item-container.gts +50 -0
- package/bundled-types/host-app/components/operator-mode/workspace-chooser/workspace-loading-indicator.gts +50 -0
- package/bundled-types/host-app/components/operator-mode/workspace-chooser/workspace.gts +1079 -0
- package/bundled-types/host-app/components/pill-menu/index.gts +281 -0
- package/bundled-types/host-app/components/pill-menu/usage.gts +64 -0
- package/bundled-types/host-app/components/prerendered-card-search.gts +274 -0
- package/bundled-types/host-app/components/realm-dropdown.gts +209 -0
- package/bundled-types/host-app/components/realm-picker/index.gts +142 -0
- package/bundled-types/host-app/components/search-sheet/index.gts +426 -0
- package/bundled-types/host-app/components/search-sheet/usage.gts +99 -0
- package/bundled-types/host-app/components/submode-switcher.gts +260 -0
- package/bundled-types/host-app/components/type-picker/index.gts +111 -0
- package/bundled-types/host-app/components/with-known-realms-loaded.gts +47 -0
- package/bundled-types/host-app/components/with-loaded-realm.gts +39 -0
- package/bundled-types/host-app/components/with-subscription-data.gts +247 -0
- package/bundled-types/host-app/config/environment.ts +66 -0
- package/bundled-types/host-app/deprecation-workflow.js +30 -0
- package/bundled-types/host-app/lib/browser-queue.ts +198 -0
- package/bundled-types/host-app/lib/codemirror-context.ts +1081 -0
- package/bundled-types/host-app/lib/command-definitions.ts +41 -0
- package/bundled-types/host-app/lib/download-realm.ts +9 -0
- package/bundled-types/host-app/lib/example-card-helpers.ts +99 -0
- package/bundled-types/host-app/lib/externals.ts +247 -0
- package/bundled-types/host-app/lib/field-path-parser.ts +520 -0
- package/bundled-types/host-app/lib/file-def-manager.ts +712 -0
- package/bundled-types/host-app/lib/file-upload-state.ts +6 -0
- package/bundled-types/host-app/lib/formatted-message/utils.ts +272 -0
- package/bundled-types/host-app/lib/gc-card-store.ts +1084 -0
- package/bundled-types/host-app/lib/host-base-command.ts +29 -0
- package/bundled-types/host-app/lib/html-component.ts +144 -0
- package/bundled-types/host-app/lib/html-to-markdown.ts +96 -0
- package/bundled-types/host-app/lib/isolated-render.gts +90 -0
- package/bundled-types/host-app/lib/known-file-meta-urls.ts +17 -0
- package/bundled-types/host-app/lib/limited-set.ts +68 -0
- package/bundled-types/host-app/lib/matrix-classes/member.ts +28 -0
- package/bundled-types/host-app/lib/matrix-classes/message-builder.ts +444 -0
- package/bundled-types/host-app/lib/matrix-classes/message-code-patch-result.ts +44 -0
- package/bundled-types/host-app/lib/matrix-classes/message-command.ts +109 -0
- package/bundled-types/host-app/lib/matrix-classes/message.ts +239 -0
- package/bundled-types/host-app/lib/matrix-classes/room.ts +174 -0
- package/bundled-types/host-app/lib/matrix-utils.ts +114 -0
- package/bundled-types/host-app/lib/mutex.ts +62 -0
- package/bundled-types/host-app/lib/prerender-fetch-headers.ts +46 -0
- package/bundled-types/host-app/lib/prerender-util.ts +31 -0
- package/bundled-types/host-app/lib/public-path.ts +1 -0
- package/bundled-types/host-app/lib/random-name.ts +26 -0
- package/bundled-types/host-app/lib/realm-utils.ts +45 -0
- package/bundled-types/host-app/lib/search-cache-key.ts +33 -0
- package/bundled-types/host-app/lib/search-in-flight-key.ts +28 -0
- package/bundled-types/host-app/lib/search-replace-block-parsing.ts +101 -0
- package/bundled-types/host-app/lib/setup-globals.ts +15 -0
- package/bundled-types/host-app/lib/sqlite-adapter.ts +510 -0
- package/bundled-types/host-app/lib/stack-item.ts +164 -0
- package/bundled-types/host-app/lib/utils.ts +84 -0
- package/bundled-types/host-app/lib/window-error-handler.ts +132 -0
- package/bundled-types/host-app/router.ts +31 -0
- package/bundled-types/host-app/services/ai-assistant-panel-service.ts +850 -0
- package/bundled-types/host-app/services/billing-service.ts +208 -0
- package/bundled-types/host-app/services/card-service.ts +373 -0
- package/bundled-types/host-app/services/card-type-service.ts +226 -0
- package/bundled-types/host-app/services/code-semantics-service.ts +297 -0
- package/bundled-types/host-app/services/command-service.ts +975 -0
- package/bundled-types/host-app/services/environment-service.ts +26 -0
- package/bundled-types/host-app/services/error-display.ts +42 -0
- package/bundled-types/host-app/services/file-upload.ts +212 -0
- package/bundled-types/host-app/services/host-mode-service.ts +381 -0
- package/bundled-types/host-app/services/host-mode-state-service.ts +160 -0
- package/bundled-types/host-app/services/loader-service.ts +148 -0
- package/bundled-types/host-app/services/local-indexer.ts +68 -0
- package/bundled-types/host-app/services/local-persistence-service.ts +296 -0
- package/bundled-types/host-app/services/logger-service.ts +13 -0
- package/bundled-types/host-app/services/matrix-sdk-loader.ts +346 -0
- package/bundled-types/host-app/services/matrix-service.ts +2287 -0
- package/bundled-types/host-app/services/message-service.ts +84 -0
- package/bundled-types/host-app/services/module-contents-service.ts +333 -0
- package/bundled-types/host-app/services/monaco-service.ts +333 -0
- package/bundled-types/host-app/services/network.ts +101 -0
- package/bundled-types/host-app/services/operator-mode-state-service.ts +1591 -0
- package/bundled-types/host-app/services/playground-panel-service.ts +236 -0
- package/bundled-types/host-app/services/queue.ts +30 -0
- package/bundled-types/host-app/services/realm-info-service.ts +37 -0
- package/bundled-types/host-app/services/realm-server.ts +1209 -0
- package/bundled-types/host-app/services/realm.ts +1413 -0
- package/bundled-types/host-app/services/recent-cards-service.ts +174 -0
- package/bundled-types/host-app/services/recent-files-service.ts +224 -0
- package/bundled-types/host-app/services/render-error-state.ts +55 -0
- package/bundled-types/host-app/services/render-service.ts +362 -0
- package/bundled-types/host-app/services/render-store.ts +27 -0
- package/bundled-types/host-app/services/reset.ts +19 -0
- package/bundled-types/host-app/services/scroll-position-service.ts +81 -0
- package/bundled-types/host-app/services/spec-panel-service.ts +107 -0
- package/bundled-types/host-app/services/store.ts +2540 -0
- package/bundled-types/host-app/utils/assert-never.ts +3 -0
- package/bundled-types/host-app/utils/auth-error-guard.ts +183 -0
- package/bundled-types/host-app/utils/auth-service-worker-registration.ts +123 -0
- package/bundled-types/host-app/utils/card-search/query-builder.ts +169 -0
- package/bundled-types/host-app/utils/card-search/section-pagination.ts +57 -0
- package/bundled-types/host-app/utils/card-search/sections.ts +240 -0
- package/bundled-types/host-app/utils/card-search/type-filter.ts +124 -0
- package/bundled-types/host-app/utils/card-search/types.ts +11 -0
- package/bundled-types/host-app/utils/card-search/url.ts +23 -0
- package/bundled-types/host-app/utils/clipboard.ts +23 -0
- package/bundled-types/host-app/utils/editor/boxel-formatter.ts +65 -0
- package/bundled-types/host-app/utils/editor/editor-language.ts +88 -0
- package/bundled-types/host-app/utils/editor/monaco-test-waiter.ts +302 -0
- package/bundled-types/host-app/utils/file-def-attributes-extractor.ts +438 -0
- package/bundled-types/host-app/utils/file-name.ts +38 -0
- package/bundled-types/host-app/utils/id-from-card-or-url.ts +11 -0
- package/bundled-types/host-app/utils/lint-formatting.ts +57 -0
- package/bundled-types/host-app/utils/local-storage-keys.ts +28 -0
- package/bundled-types/host-app/utils/normalized-dir-path.ts +3 -0
- package/bundled-types/host-app/utils/prettify-messages.ts +21 -0
- package/bundled-types/host-app/utils/prettify-prompts.ts +21 -0
- package/bundled-types/host-app/utils/realm-index-boilerplate.ts +27 -0
- package/bundled-types/host-app/utils/register-boxel-transition.ts +17 -0
- package/bundled-types/host-app/utils/render-desync-detector.ts +362 -0
- package/bundled-types/host-app/utils/render-error.ts +455 -0
- package/bundled-types/host-app/utils/render-timer-stub.ts +249 -0
- package/bundled-types/host-app/utils/run-while-active.ts +14 -0
- package/bundled-types/host-app/utils/schema-editor.ts +25 -0
- package/bundled-types/host-app/utils/text-suggestion.ts +82 -0
- package/bundled-types/host-app/utils/titleize.ts +10 -0
- package/bundled-types/host-app/utils/uuid.ts +13 -0
- package/bundled-types/host-tests/helpers/adapter.ts +464 -0
- package/bundled-types/host-tests/helpers/base-realm.ts +464 -0
- package/bundled-types/host-tests/helpers/cards/view-card-demo.ts +119 -0
- package/bundled-types/host-tests/helpers/field-test-helpers.gts +54 -0
- package/bundled-types/host-tests/helpers/image-fixture.ts +3 -0
- package/bundled-types/host-tests/helpers/index.gts +2099 -0
- package/bundled-types/host-tests/helpers/indexer.ts +293 -0
- package/bundled-types/host-tests/helpers/interact-submode-setup.gts +551 -0
- package/bundled-types/host-tests/helpers/mock-matrix/_client.ts +1042 -0
- package/bundled-types/host-tests/helpers/mock-matrix/_sdk.ts +71 -0
- package/bundled-types/host-tests/helpers/mock-matrix/_server-state.ts +343 -0
- package/bundled-types/host-tests/helpers/mock-matrix/_sliding-sync.ts +140 -0
- package/bundled-types/host-tests/helpers/mock-matrix/_utils.ts +146 -0
- package/bundled-types/host-tests/helpers/mock-matrix.ts +200 -0
- package/bundled-types/host-tests/helpers/operator-mode-parameters-match.ts +71 -0
- package/bundled-types/host-tests/helpers/operator-mode-state.ts +18 -0
- package/bundled-types/host-tests/helpers/percy-snapshot.ts +228 -0
- package/bundled-types/host-tests/helpers/playground.ts +130 -0
- package/bundled-types/host-tests/helpers/realm-server-mock/index.ts +100 -0
- package/bundled-types/host-tests/helpers/realm-server-mock/routes.ts +617 -0
- package/bundled-types/host-tests/helpers/realm-server-mock/types.ts +24 -0
- package/bundled-types/host-tests/helpers/recent-files-cards.ts +86 -0
- package/bundled-types/host-tests/helpers/render-component.ts +40 -0
- package/bundled-types/host-tests/helpers/setup-qunit.js +164 -0
- package/bundled-types/host-tests/helpers/setup.ts +349 -0
- package/bundled-types/host-tests/helpers/shard-warmup.ts +72 -0
- package/bundled-types/host-tests/helpers/stream.ts +60 -0
- package/bundled-types/host-tests/helpers/test-auth.ts +27 -0
- package/bundled-types/host-tests/helpers/test-realm-registry.ts +23 -0
- package/bundled-types/host-tests/helpers/test-realm-service-worker.ts +92 -0
- package/bundled-types/host-tests/helpers/uncaught-exceptions.ts +16 -0
- package/bundled-types/host-tests/helpers/visit-operator-mode.ts +39 -0
- package/bundled-types/host-types/@cardstack/host/index.d.ts +3 -0
- package/bundled-types/host-types/@joplin/turndown-plugin-gfm/index.d.ts +15 -0
- package/bundled-types/host-types/@sqlite.org/sqlite-wasm/index.d.ts +122 -0
- package/bundled-types/host-types/ember-click-outside/modifiers/on-click-outside.ts +16 -0
- package/bundled-types/host-types/ember-concurrency/helpers/perform.d.ts +3 -0
- package/bundled-types/host-types/ember-css-url/index.d.ts +15 -0
- package/bundled-types/host-types/ember-data/types/registries/model.d.ts +6 -0
- package/bundled-types/host-types/ember-elsewhere/from-elsewhere.d.ts +12 -0
- package/bundled-types/host-types/ember-elsewhere/to-elsewhere.d.ts +16 -0
- package/bundled-types/host-types/ember-focus-trap/index.d.ts +4 -0
- package/bundled-types/host-types/ember-keyboard/modifiers/on-key.d.ts +15 -0
- package/bundled-types/host-types/index.d.ts +6 -0
- package/bundled-types/local-types/eslint-js.d.ts +5 -0
- package/bundled-types/local-types/index.d.ts +115 -0
- package/bundled-types/local-types/marked-gfm-heading-id.d.ts +12 -0
- package/bundled-types/local-types/matrix-js-sdk/index.d.ts +11 -0
- package/bundled-types/local-types/package.json +13 -0
- package/bundled-types/shims/boxel-cli-shims.d.ts +10 -0
- package/dist/index.js +100 -100
- package/package.json +13 -7
- package/src/commands/parse.ts +277 -34
|
@@ -0,0 +1,1209 @@
|
|
|
1
|
+
import type Owner from '@ember/owner';
|
|
2
|
+
import Service from '@ember/service';
|
|
3
|
+
import { service } from '@ember/service';
|
|
4
|
+
|
|
5
|
+
import { isTesting } from '@embroider/macros';
|
|
6
|
+
|
|
7
|
+
import { cached } from '@glimmer/tracking';
|
|
8
|
+
|
|
9
|
+
import { restartableTask, rawTimeout, task } from 'ember-concurrency';
|
|
10
|
+
|
|
11
|
+
import window from 'ember-window-mock';
|
|
12
|
+
|
|
13
|
+
import { TrackedArray } from 'tracked-built-ins';
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
baseRealm,
|
|
17
|
+
ensureTrailingSlash,
|
|
18
|
+
SupportedMimeType,
|
|
19
|
+
Deferred,
|
|
20
|
+
testRealmURL,
|
|
21
|
+
type RealmInfo,
|
|
22
|
+
type JWTPayload,
|
|
23
|
+
} from '@cardstack/runtime-common';
|
|
24
|
+
import {
|
|
25
|
+
joinDMRoom,
|
|
26
|
+
RealmAuthClient,
|
|
27
|
+
} from '@cardstack/runtime-common/realm-auth-client';
|
|
28
|
+
|
|
29
|
+
import ENV from '@cardstack/host/config/environment';
|
|
30
|
+
import { SessionLocalStorageKey } from '@cardstack/host/utils/local-storage-keys';
|
|
31
|
+
|
|
32
|
+
import type { ExtendedClient } from './matrix-sdk-loader';
|
|
33
|
+
import type NetworkService from './network';
|
|
34
|
+
import type RealmService from './realm';
|
|
35
|
+
import type ResetService from './reset';
|
|
36
|
+
import type { IEvent } from 'matrix-js-sdk';
|
|
37
|
+
|
|
38
|
+
const { hostsOwnAssets, resolvedBaseRealmURL } = ENV;
|
|
39
|
+
|
|
40
|
+
export interface RealmServerTokenClaims {
|
|
41
|
+
user: string;
|
|
42
|
+
sessionRoom: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface SubdomainAvailabilityResult {
|
|
46
|
+
available: boolean;
|
|
47
|
+
domain: string;
|
|
48
|
+
error?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface ClaimedDomain {
|
|
52
|
+
id: string;
|
|
53
|
+
hostname: string;
|
|
54
|
+
subdomain: string;
|
|
55
|
+
sourceRealmURL: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface RealmServerEvent {
|
|
59
|
+
eventType: string;
|
|
60
|
+
data: any;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// iat - issued at (seconds since epoch)
|
|
64
|
+
// exp - expires at (seconds since epoch)
|
|
65
|
+
type RealmServerJWTPayload = RealmServerTokenClaims & {
|
|
66
|
+
iat: number;
|
|
67
|
+
exp: number;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
type AuthStatus =
|
|
71
|
+
| { type: 'logged-in'; token: string; claims: RealmServerJWTPayload }
|
|
72
|
+
| { type: 'anonymous' };
|
|
73
|
+
|
|
74
|
+
interface AvailableRealm {
|
|
75
|
+
url: string;
|
|
76
|
+
type: 'base' | 'catalog' | 'user';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
type RealmServerEventSubscriber = (data: any) => Promise<void>;
|
|
80
|
+
|
|
81
|
+
export default class RealmServerService extends Service {
|
|
82
|
+
@service declare private network: NetworkService;
|
|
83
|
+
@service declare private reset: ResetService;
|
|
84
|
+
@service declare private realm: RealmService;
|
|
85
|
+
@service declare private realmServer: RealmServerService;
|
|
86
|
+
private auth: AuthStatus = { type: 'anonymous' };
|
|
87
|
+
private client: ExtendedClient | undefined;
|
|
88
|
+
private availableRealms = new TrackedArray<AvailableRealm>([
|
|
89
|
+
{ type: 'base', url: baseRealm.url },
|
|
90
|
+
]);
|
|
91
|
+
private _ready = new Deferred<void>();
|
|
92
|
+
private eventSubscribers: Map<string, RealmServerEventSubscriber[]> =
|
|
93
|
+
new Map();
|
|
94
|
+
|
|
95
|
+
constructor(owner: Owner) {
|
|
96
|
+
super(owner);
|
|
97
|
+
this.reset.register(this);
|
|
98
|
+
this.fetchCatalogRealms();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
get ready() {
|
|
102
|
+
return this._ready.promise;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
get canFetch(): boolean {
|
|
106
|
+
return this.client !== undefined || this.auth.type === 'logged-in';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
resetState() {
|
|
110
|
+
let catalogRealms = this.availableRealms.filter(
|
|
111
|
+
(realm) => realm.type === 'catalog',
|
|
112
|
+
);
|
|
113
|
+
this.logout();
|
|
114
|
+
this.availableRealms = new TrackedArray([
|
|
115
|
+
{ type: 'base', url: baseRealm.url },
|
|
116
|
+
...catalogRealms,
|
|
117
|
+
]);
|
|
118
|
+
this.eventSubscribers = new Map();
|
|
119
|
+
this._ready = new Deferred<void>();
|
|
120
|
+
this._ready.fulfill();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
setClient(client: ExtendedClient) {
|
|
124
|
+
this.client = client;
|
|
125
|
+
this.token =
|
|
126
|
+
window.localStorage.getItem(sessionLocalStorageKey) ?? undefined;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async createStripeSession(email: string) {
|
|
130
|
+
let url = new URL(`${this.url.href}_stripe-session`);
|
|
131
|
+
url.searchParams.set('email', email);
|
|
132
|
+
|
|
133
|
+
let response = await this.network.fetch(url.href, {
|
|
134
|
+
method: 'POST',
|
|
135
|
+
headers: {
|
|
136
|
+
Accept: SupportedMimeType.JSONAPI,
|
|
137
|
+
'Content-Type': 'application/json',
|
|
138
|
+
Authorization: `Bearer ${this.token}`,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
if (!response.ok) {
|
|
143
|
+
let err = `Could not create Stripe session: ${response.status} - ${await response.text()}`;
|
|
144
|
+
console.error(err);
|
|
145
|
+
throw new Error(err);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return response;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async createRealm(args: {
|
|
152
|
+
endpoint: string;
|
|
153
|
+
name: string;
|
|
154
|
+
iconURL?: string;
|
|
155
|
+
backgroundURL?: string;
|
|
156
|
+
}) {
|
|
157
|
+
await this.login();
|
|
158
|
+
|
|
159
|
+
let response = await this.network.fetch(`${this.url.href}_create-realm`, {
|
|
160
|
+
method: 'POST',
|
|
161
|
+
headers: {
|
|
162
|
+
Accept: SupportedMimeType.JSONAPI,
|
|
163
|
+
'Content-Type': 'application/json',
|
|
164
|
+
Authorization: `Bearer ${this.token}`,
|
|
165
|
+
},
|
|
166
|
+
body: JSON.stringify({
|
|
167
|
+
data: { type: 'realm', attributes: args },
|
|
168
|
+
}),
|
|
169
|
+
});
|
|
170
|
+
if (!response.ok) {
|
|
171
|
+
let err = `Could not create realm with endpoint '${args.endpoint}': ${
|
|
172
|
+
response.status
|
|
173
|
+
} - ${await response.text()}`;
|
|
174
|
+
console.error(err);
|
|
175
|
+
throw new Error(err);
|
|
176
|
+
}
|
|
177
|
+
let {
|
|
178
|
+
data: { id: realmURL },
|
|
179
|
+
} = (await response.json()) as { data: { id: string } };
|
|
180
|
+
return new URL(realmURL);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async deleteRealm(realmURL: string) {
|
|
184
|
+
await this.login();
|
|
185
|
+
|
|
186
|
+
let response = await this.network.fetch(`${this.url.href}_delete-realm`, {
|
|
187
|
+
method: 'DELETE',
|
|
188
|
+
headers: {
|
|
189
|
+
Accept: SupportedMimeType.JSONAPI,
|
|
190
|
+
'Content-Type': 'application/json',
|
|
191
|
+
Authorization: `Bearer ${this.token}`,
|
|
192
|
+
},
|
|
193
|
+
body: JSON.stringify({
|
|
194
|
+
data: {
|
|
195
|
+
type: 'realm',
|
|
196
|
+
id: realmURL,
|
|
197
|
+
},
|
|
198
|
+
}),
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
if (!response.ok) {
|
|
202
|
+
let err = `Could not delete realm '${realmURL}': ${
|
|
203
|
+
response.status
|
|
204
|
+
} - ${await response.text()}`;
|
|
205
|
+
console.error(err);
|
|
206
|
+
throw new Error(err);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
logout(): void {
|
|
211
|
+
this.loginTask.cancelAll();
|
|
212
|
+
this.tokenRefresher.cancelAll();
|
|
213
|
+
this.token = undefined;
|
|
214
|
+
this.client = undefined;
|
|
215
|
+
this.loggingIn = undefined;
|
|
216
|
+
this.auth = { type: 'anonymous' };
|
|
217
|
+
this.availableRealms.splice(0, this.availableRealms.length, {
|
|
218
|
+
type: 'base',
|
|
219
|
+
url: baseRealm.url,
|
|
220
|
+
});
|
|
221
|
+
window.localStorage.removeItem(sessionLocalStorageKey);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async fetchTokensForAccessibleRealms() {
|
|
225
|
+
await this.login();
|
|
226
|
+
let response = await this.network.fetch(`${this.url.href}_realm-auth`, {
|
|
227
|
+
method: 'POST',
|
|
228
|
+
headers: {
|
|
229
|
+
Accept: SupportedMimeType.JSONAPI,
|
|
230
|
+
'Content-Type': 'application/json',
|
|
231
|
+
Authorization: `Bearer ${this.token}`,
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
if (!response.ok) {
|
|
236
|
+
let responseText = await response.text();
|
|
237
|
+
|
|
238
|
+
// Temporary development instruction to help with user setup
|
|
239
|
+
let isDevelopment = ENV.environment === 'development';
|
|
240
|
+
if (isDevelopment && responseText.includes('User in JWT not found')) {
|
|
241
|
+
console.error(
|
|
242
|
+
'\x1b[1m\x1b[31m%s\x1b[0m',
|
|
243
|
+
'Failed to login to realms due to missing entry in the users table. It is likely the user setup is incomplete - run pnpm register-all in matrix package',
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
throw new Error(
|
|
248
|
+
`Failed to fetch tokens for accessible realms: ${response.status} - ${responseText}`,
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return response.json();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
@cached
|
|
256
|
+
get availableRealmURLs() {
|
|
257
|
+
return this.availableRealms.map((r) => r.url);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
assertOwnRealmServer(realmServerURLs: string[]): void {
|
|
261
|
+
let normalizedOwnRealmServerURL = this.normalizeRealmServerURL(
|
|
262
|
+
this.realmServer.url.href,
|
|
263
|
+
);
|
|
264
|
+
let normalizedRealmServerURLs = [
|
|
265
|
+
...new Set(
|
|
266
|
+
realmServerURLs.map((url) => this.normalizeRealmServerURL(url)),
|
|
267
|
+
),
|
|
268
|
+
];
|
|
269
|
+
if (realmServerURLs.length === 0) {
|
|
270
|
+
throw new Error(`Unable to determine realm server to use`);
|
|
271
|
+
}
|
|
272
|
+
if (
|
|
273
|
+
normalizedRealmServerURLs.length > 1 ||
|
|
274
|
+
normalizedRealmServerURLs[0] !== normalizedOwnRealmServerURL
|
|
275
|
+
) {
|
|
276
|
+
throw new Error(
|
|
277
|
+
`Multi-realm server support is not yet implemented: don't know how to provide auth token for different realm servers: ${normalizedRealmServerURLs.join()} (own realm server: ${normalizedOwnRealmServerURL})`,
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
getRealmServersForRealms(realms: string[]) {
|
|
283
|
+
let testRealmOrigin = isTesting()
|
|
284
|
+
? new URL(testRealmURL).origin
|
|
285
|
+
: undefined;
|
|
286
|
+
let sessionTokens: Record<string, string> = {};
|
|
287
|
+
let sessionStr =
|
|
288
|
+
window.localStorage.getItem(SessionLocalStorageKey) ?? '{}';
|
|
289
|
+
|
|
290
|
+
try {
|
|
291
|
+
sessionTokens = JSON.parse(sessionStr) as Record<string, string>;
|
|
292
|
+
} catch {
|
|
293
|
+
sessionTokens = {};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
let realmServerURLs = new Set<string>();
|
|
297
|
+
|
|
298
|
+
for (let realmURL of realms) {
|
|
299
|
+
let normalizedRealmURL = ensureTrailingSlash(realmURL);
|
|
300
|
+
if (
|
|
301
|
+
testRealmOrigin &&
|
|
302
|
+
new URL(normalizedRealmURL).origin === testRealmOrigin
|
|
303
|
+
) {
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
let token = sessionTokens[normalizedRealmURL] ?? sessionTokens[realmURL];
|
|
307
|
+
if (!token) {
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
let claims = realmClaimsFromRawToken(token);
|
|
312
|
+
if (claims?.realmServerURL) {
|
|
313
|
+
realmServerURLs.add(
|
|
314
|
+
this.normalizeRealmServerURL(claims.realmServerURL),
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (realmServerURLs.size === 0) {
|
|
320
|
+
realmServerURLs.add(this.normalizeRealmServerURL(this.url.href));
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return [...realmServerURLs];
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
private normalizeRealmServerURL(url: string): string {
|
|
327
|
+
let normalizedURL = ensureTrailingSlash(url);
|
|
328
|
+
if (isTesting()) {
|
|
329
|
+
let testRealmOrigin = new URL(testRealmURL).origin;
|
|
330
|
+
// In tests, realm URLs are often rooted at the test realm origin but
|
|
331
|
+
// are served by the base realm server; remap to the base origin so
|
|
332
|
+
// federated requests hit the active test server.
|
|
333
|
+
if (new URL(normalizedURL).origin === testRealmOrigin) {
|
|
334
|
+
return ensureTrailingSlash(new URL(resolvedBaseRealmURL).origin);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return normalizedURL;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
@cached
|
|
341
|
+
get userRealmURLs() {
|
|
342
|
+
return this.availableRealms
|
|
343
|
+
.filter((r) => r.type === 'user')
|
|
344
|
+
.map((r) => r.url);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
@cached
|
|
348
|
+
get catalogRealmURLs() {
|
|
349
|
+
return this.availableRealms
|
|
350
|
+
.filter((r) => r.type === 'catalog')
|
|
351
|
+
.map((r) => r.url);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
@cached
|
|
355
|
+
get displayedCatalogRealmURLs() {
|
|
356
|
+
return this.catalogRealmURLs;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
@cached
|
|
360
|
+
get availableRealmIndexCardIds() {
|
|
361
|
+
return this.availableRealmURLs.map((url) => `${url}index`);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
async authenticateToAllAccessibleRealms() {
|
|
365
|
+
let tokens = (await this.fetchTokensForAccessibleRealms()) as {
|
|
366
|
+
[realmURL: string]: string;
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
await this.ensureJoinedSessionRoom(tokens);
|
|
370
|
+
for (let [realmURL, token] of Object.entries(tokens)) {
|
|
371
|
+
this.realm.getOrCreateRealmResource(realmURL, token);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
private async ensureJoinedSessionRoom(tokens: {
|
|
376
|
+
[realmUrl: string]: string;
|
|
377
|
+
}) {
|
|
378
|
+
if (!this.client) {
|
|
379
|
+
throw new Error(`Cannot check joined rooms without matrix client`);
|
|
380
|
+
}
|
|
381
|
+
let { joined_rooms } = await this.client.getJoinedRooms();
|
|
382
|
+
let joinedRoomSet = new Set(joined_rooms ?? []);
|
|
383
|
+
for (let [_realmURL, token] of Object.entries(tokens)) {
|
|
384
|
+
let { sessionRoom } = claimsFromRawToken(token);
|
|
385
|
+
if (!joinedRoomSet.has(sessionRoom)) {
|
|
386
|
+
await joinDMRoom(this.client, sessionRoom);
|
|
387
|
+
joinedRoomSet.add(sessionRoom);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
async setAvailableRealmURLs(userRealmURLs: string[]) {
|
|
393
|
+
await this._ready.promise;
|
|
394
|
+
userRealmURLs.forEach((userRealmURL) => {
|
|
395
|
+
if (!this.availableRealms.find((r) => r.url === userRealmURL)) {
|
|
396
|
+
this.availableRealms.push({
|
|
397
|
+
type: 'user',
|
|
398
|
+
url: userRealmURL,
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
// pluck out any user realms that aren't a part of the userRealmsURLs
|
|
404
|
+
this.availableRealms
|
|
405
|
+
.filter((r) => r.type === 'user')
|
|
406
|
+
.forEach((realm) => {
|
|
407
|
+
if (!userRealmURLs.includes(realm.url)) {
|
|
408
|
+
this.availableRealms.splice(
|
|
409
|
+
this.availableRealms.findIndex((r) => r.url === realm.url),
|
|
410
|
+
1,
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
async fetchCatalogRealms() {
|
|
417
|
+
if (this.catalogRealmURLs.length > 0) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
let response = await this.network.fetch(
|
|
421
|
+
`${this.url.origin}/_catalog-realms`,
|
|
422
|
+
);
|
|
423
|
+
if (response.status !== 200) {
|
|
424
|
+
throw new Error(
|
|
425
|
+
`Failed to fetch public realms for realm server ${this.url.origin}: ${response.status}`,
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
let { data } = await response.json();
|
|
430
|
+
|
|
431
|
+
data.forEach((publicRealm: { id: string }) => {
|
|
432
|
+
if (!this.availableRealms.find((r) => r.url === publicRealm.id)) {
|
|
433
|
+
this.availableRealms.push({
|
|
434
|
+
type: 'catalog',
|
|
435
|
+
url: publicRealm.id,
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
this._ready.fulfill();
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
async fetchRealmInfos(realmUrls: string[]): Promise<{
|
|
444
|
+
data: { id: string; type: 'realm-info'; attributes: RealmInfo }[];
|
|
445
|
+
publicReadableRealms: Set<string>;
|
|
446
|
+
}> {
|
|
447
|
+
if (realmUrls.length === 0) {
|
|
448
|
+
return { data: [], publicReadableRealms: new Set() };
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
let uniqueRealmUrls = Array.from(new Set(realmUrls));
|
|
452
|
+
let realmServerURLs = this.getRealmServersForRealms(uniqueRealmUrls);
|
|
453
|
+
// TODO remove this assertion after multi-realm server/federated identity is supported
|
|
454
|
+
this.assertOwnRealmServer(realmServerURLs);
|
|
455
|
+
let [realmServerURL] = realmServerURLs;
|
|
456
|
+
|
|
457
|
+
await this.login();
|
|
458
|
+
|
|
459
|
+
let infoURL = new URL('_federated-info', realmServerURL);
|
|
460
|
+
|
|
461
|
+
let response = await this.authedFetch(infoURL.href, {
|
|
462
|
+
method: 'QUERY',
|
|
463
|
+
headers: {
|
|
464
|
+
Accept: SupportedMimeType.RealmInfo,
|
|
465
|
+
'Content-Type': 'application/json',
|
|
466
|
+
},
|
|
467
|
+
body: JSON.stringify({ realms: uniqueRealmUrls }),
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
if (!response.ok) {
|
|
471
|
+
let responseText = await response.text();
|
|
472
|
+
throw new Error(
|
|
473
|
+
`Failed to fetch federated realm info: ${response.status} - ${responseText}`,
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
let publicReadableRealms = new Set<string>();
|
|
478
|
+
let publicReadableHeader = response.headers.get(
|
|
479
|
+
'x-boxel-realms-public-readable',
|
|
480
|
+
);
|
|
481
|
+
if (publicReadableHeader) {
|
|
482
|
+
for (let value of publicReadableHeader.split(',')) {
|
|
483
|
+
let trimmed = value.trim();
|
|
484
|
+
if (trimmed) {
|
|
485
|
+
publicReadableRealms.add(ensureTrailingSlash(trimmed));
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
let json = (await response.json()) as {
|
|
491
|
+
data: { id: string; type: 'realm-info'; attributes: RealmInfo }[];
|
|
492
|
+
};
|
|
493
|
+
return { data: json.data ?? [], publicReadableRealms };
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
async fetchCardTypeSummaries(
|
|
497
|
+
realmUrls: string[],
|
|
498
|
+
options?: {
|
|
499
|
+
searchKey?: string;
|
|
500
|
+
page?: { number: number; size: number };
|
|
501
|
+
},
|
|
502
|
+
): Promise<{
|
|
503
|
+
data: {
|
|
504
|
+
id: string;
|
|
505
|
+
type: 'card-type-summary';
|
|
506
|
+
attributes: {
|
|
507
|
+
displayName: string;
|
|
508
|
+
total: number;
|
|
509
|
+
iconHTML: string;
|
|
510
|
+
// The federated `_types` response now stamps `kind` on every
|
|
511
|
+
// entry. Keeping it in the declared return type — not just the
|
|
512
|
+
// local `json` cast — means callers see the discriminator and
|
|
513
|
+
// can partition card vs file summaries instead of conflating
|
|
514
|
+
// them. `?` for back-compat with the still-supported legacy
|
|
515
|
+
// response shape (no kind, treated as 'instance').
|
|
516
|
+
kind?: 'instance' | 'file';
|
|
517
|
+
};
|
|
518
|
+
meta?: { realmURL: string };
|
|
519
|
+
}[];
|
|
520
|
+
meta: { page: { total: number } };
|
|
521
|
+
}> {
|
|
522
|
+
if (realmUrls.length === 0) {
|
|
523
|
+
return { data: [], meta: { page: { total: 0 } } };
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
let uniqueRealmUrls = Array.from(new Set(realmUrls));
|
|
527
|
+
let realmServerURLs = this.getRealmServersForRealms(uniqueRealmUrls);
|
|
528
|
+
// TODO remove this assertion after multi-realm server/federated identity is supported
|
|
529
|
+
this.assertOwnRealmServer(realmServerURLs);
|
|
530
|
+
let [realmServerURL] = realmServerURLs;
|
|
531
|
+
|
|
532
|
+
await this.login();
|
|
533
|
+
|
|
534
|
+
let typesURL = new URL('_federated-types', realmServerURL);
|
|
535
|
+
|
|
536
|
+
let body: Record<string, unknown> = { realms: uniqueRealmUrls };
|
|
537
|
+
if (options?.searchKey) {
|
|
538
|
+
body.searchKey = options.searchKey;
|
|
539
|
+
}
|
|
540
|
+
if (options?.page) {
|
|
541
|
+
body.page = options.page;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
let response = await this.authedFetch(typesURL.href, {
|
|
545
|
+
method: 'QUERY',
|
|
546
|
+
headers: {
|
|
547
|
+
Accept: SupportedMimeType.CardTypeSummary,
|
|
548
|
+
'Content-Type': 'application/json',
|
|
549
|
+
},
|
|
550
|
+
body: JSON.stringify(body),
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
if (!response.ok) {
|
|
554
|
+
let responseText = await response.text();
|
|
555
|
+
throw new Error(
|
|
556
|
+
`Failed to fetch federated card type summaries: ${response.status} - ${responseText}`,
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
let json = (await response.json()) as {
|
|
561
|
+
data: {
|
|
562
|
+
id: string;
|
|
563
|
+
type: 'card-type-summary';
|
|
564
|
+
attributes: {
|
|
565
|
+
displayName: string;
|
|
566
|
+
total: number;
|
|
567
|
+
iconHTML: string;
|
|
568
|
+
kind?: 'instance' | 'file';
|
|
569
|
+
};
|
|
570
|
+
meta?: { realmURL: string };
|
|
571
|
+
}[];
|
|
572
|
+
meta: { page: { total: number } };
|
|
573
|
+
};
|
|
574
|
+
return { data: json.data ?? [], meta: json.meta ?? { page: { total: 0 } } };
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
async handleEvent(event: Partial<IEvent>) {
|
|
578
|
+
let claims = await this.getClaims();
|
|
579
|
+
if (event.room_id !== claims.sessionRoom || !event.content) {
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
let realmServerEvent = JSON.parse(event.content.body) as RealmServerEvent;
|
|
584
|
+
let subscribers = this.eventSubscribers.get(realmServerEvent.eventType);
|
|
585
|
+
subscribers?.forEach(async (subscriber) => {
|
|
586
|
+
await subscriber(realmServerEvent.data);
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
subscribeEvent(eventType: string, subscriber: RealmServerEventSubscriber) {
|
|
591
|
+
if (!this.eventSubscribers.has(eventType)) {
|
|
592
|
+
this.eventSubscribers.set(eventType, []);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
this.eventSubscribers.get(eventType)!.push(subscriber);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
get url() {
|
|
599
|
+
if (isTesting()) {
|
|
600
|
+
return new URL(ENV.realmServerURL);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
let url;
|
|
604
|
+
if (hostsOwnAssets) {
|
|
605
|
+
url = new URL(resolvedBaseRealmURL).origin;
|
|
606
|
+
} else {
|
|
607
|
+
url = globalThis.location.origin;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
return new URL(url);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
private async getClaims() {
|
|
614
|
+
if (!this.claims) {
|
|
615
|
+
await this.login();
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
if (!this.claims) {
|
|
619
|
+
throw new Error('Failed to get realm server token claims');
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
return this.claims;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
private get claims(): RealmServerJWTPayload | undefined {
|
|
626
|
+
if (this.auth.type === 'logged-in') {
|
|
627
|
+
return this.auth.claims;
|
|
628
|
+
}
|
|
629
|
+
return undefined;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
get token(): string | undefined {
|
|
633
|
+
if (this.auth.type === 'logged-in') {
|
|
634
|
+
return this.auth.token;
|
|
635
|
+
}
|
|
636
|
+
return undefined;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
private set token(value: string | undefined) {
|
|
640
|
+
if (value) {
|
|
641
|
+
this.auth = {
|
|
642
|
+
type: 'logged-in',
|
|
643
|
+
token: value,
|
|
644
|
+
claims: claimsFromRawToken(value),
|
|
645
|
+
};
|
|
646
|
+
} else {
|
|
647
|
+
this.auth = { type: 'anonymous' };
|
|
648
|
+
}
|
|
649
|
+
window.localStorage.setItem(sessionLocalStorageKey, value ?? '');
|
|
650
|
+
this.tokenRefresher.perform();
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
private tokenRefresher = restartableTask(async () => {
|
|
654
|
+
if (!this.claims) {
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// token expiration is unix time (seconds)
|
|
659
|
+
let expirationMs = this.claims.exp * 1000;
|
|
660
|
+
|
|
661
|
+
let refreshMs = Math.max(
|
|
662
|
+
expirationMs - Date.now() - tokenRefreshPeriodSec * 1000,
|
|
663
|
+
0,
|
|
664
|
+
);
|
|
665
|
+
|
|
666
|
+
await rawTimeout(refreshMs);
|
|
667
|
+
if (!this.loggingIn) {
|
|
668
|
+
this.loggingIn = this.loginTask.perform();
|
|
669
|
+
await this.loggingIn;
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
private loggingIn: Promise<void> | undefined;
|
|
674
|
+
private pendingRegistrationToken: string | undefined;
|
|
675
|
+
|
|
676
|
+
async login(registrationToken?: string): Promise<void> {
|
|
677
|
+
if (registrationToken) {
|
|
678
|
+
this.pendingRegistrationToken = registrationToken;
|
|
679
|
+
}
|
|
680
|
+
if (this.auth.type === 'logged-in') {
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
if (!this.loggingIn) {
|
|
684
|
+
this.loggingIn = this.loginTask.perform();
|
|
685
|
+
}
|
|
686
|
+
await this.loggingIn;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
private loginTask = task(async () => {
|
|
690
|
+
if (!this.client) {
|
|
691
|
+
throw new Error(`Cannot login to realm server without matrix client`);
|
|
692
|
+
}
|
|
693
|
+
try {
|
|
694
|
+
let realmAuthClient = new RealmAuthClient(
|
|
695
|
+
this.url,
|
|
696
|
+
this.client,
|
|
697
|
+
this.network.authedFetch.bind(this.network),
|
|
698
|
+
{
|
|
699
|
+
authWithRealmServer: true,
|
|
700
|
+
registrationToken: this.pendingRegistrationToken,
|
|
701
|
+
},
|
|
702
|
+
);
|
|
703
|
+
this.pendingRegistrationToken = undefined;
|
|
704
|
+
let token = await realmAuthClient.getJWT();
|
|
705
|
+
this.token = token;
|
|
706
|
+
} catch (e: any) {
|
|
707
|
+
console.error(
|
|
708
|
+
`RealmServerService - failed to login to realm: ${e.message}`,
|
|
709
|
+
e,
|
|
710
|
+
);
|
|
711
|
+
this.token = undefined;
|
|
712
|
+
} finally {
|
|
713
|
+
this.loggingIn = undefined;
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
async authedFetch(url: string, options: RequestInit = {}) {
|
|
718
|
+
const headers = new Headers(options.headers);
|
|
719
|
+
headers.set('Authorization', `Bearer ${await this.getToken()}`);
|
|
720
|
+
|
|
721
|
+
let response = await this.network.fetch(url, {
|
|
722
|
+
...options,
|
|
723
|
+
headers,
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
return response;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
maybeAuthedFetch(url: string, options: RequestInit = {}) {
|
|
730
|
+
const headers = new Headers(options.headers);
|
|
731
|
+
if (this.token) {
|
|
732
|
+
headers.set('Authorization', `Bearer ${this.token}`);
|
|
733
|
+
}
|
|
734
|
+
return this.network.fetch(url, {
|
|
735
|
+
...options,
|
|
736
|
+
headers,
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
maybeAuthedFetchForRealms(
|
|
741
|
+
url: string,
|
|
742
|
+
realms: string[],
|
|
743
|
+
options: RequestInit = {},
|
|
744
|
+
) {
|
|
745
|
+
const headers = new Headers(options.headers);
|
|
746
|
+
if (!headers.has('Authorization')) {
|
|
747
|
+
if (this.token) {
|
|
748
|
+
headers.set('Authorization', `Bearer ${this.token}`);
|
|
749
|
+
} else {
|
|
750
|
+
let realmToken = this.getRealmTokenForRealms(realms);
|
|
751
|
+
if (realmToken) {
|
|
752
|
+
headers.set('Authorization', `Bearer ${realmToken}`);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
return this.network.fetch(url, {
|
|
757
|
+
...options,
|
|
758
|
+
headers,
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// args is of type `RequestForwardBody` in realm-server/handlers/handle-request-forward
|
|
763
|
+
async requestForward(args: {
|
|
764
|
+
url: string;
|
|
765
|
+
method: string;
|
|
766
|
+
requestBody: string;
|
|
767
|
+
headers?: Record<string, string>;
|
|
768
|
+
multipart?: boolean;
|
|
769
|
+
}) {
|
|
770
|
+
await this.login();
|
|
771
|
+
|
|
772
|
+
const response = await this.network.fetch(
|
|
773
|
+
`${this.url.href}_request-forward`,
|
|
774
|
+
{
|
|
775
|
+
method: 'POST',
|
|
776
|
+
headers: {
|
|
777
|
+
Accept: 'application/json',
|
|
778
|
+
'Content-Type': 'application/json',
|
|
779
|
+
Authorization: `Bearer ${this.token}`,
|
|
780
|
+
},
|
|
781
|
+
body: JSON.stringify(args),
|
|
782
|
+
},
|
|
783
|
+
);
|
|
784
|
+
|
|
785
|
+
if (!response.ok) {
|
|
786
|
+
const errorText = await response.text();
|
|
787
|
+
throw new Error(
|
|
788
|
+
`Request forward failed: ${response.status} - ${errorText}`,
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
return response;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
async registerBot(username: string) {
|
|
796
|
+
await this.login();
|
|
797
|
+
|
|
798
|
+
let response = await this.network.fetch(
|
|
799
|
+
`${this.url.href}_bot-registration`,
|
|
800
|
+
{
|
|
801
|
+
method: 'POST',
|
|
802
|
+
headers: {
|
|
803
|
+
Accept: SupportedMimeType.JSONAPI,
|
|
804
|
+
'Content-Type': 'application/vnd.api+json',
|
|
805
|
+
Authorization: `Bearer ${this.token}`,
|
|
806
|
+
},
|
|
807
|
+
body: JSON.stringify({
|
|
808
|
+
data: {
|
|
809
|
+
type: 'bot-registration',
|
|
810
|
+
attributes: {
|
|
811
|
+
username,
|
|
812
|
+
},
|
|
813
|
+
},
|
|
814
|
+
}),
|
|
815
|
+
},
|
|
816
|
+
);
|
|
817
|
+
|
|
818
|
+
if (!response.ok) {
|
|
819
|
+
let err = `Could not register bot: ${response.status} - ${await response.text()}`;
|
|
820
|
+
console.error(err);
|
|
821
|
+
throw new Error(err);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
let body = (await response.json()) as {
|
|
825
|
+
data: {
|
|
826
|
+
id: string;
|
|
827
|
+
attributes: {
|
|
828
|
+
username: string;
|
|
829
|
+
createdAt: string;
|
|
830
|
+
};
|
|
831
|
+
};
|
|
832
|
+
};
|
|
833
|
+
|
|
834
|
+
return {
|
|
835
|
+
botRegistrationId: body.data.id,
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
async unregisterBot(botRegistrationId: string) {
|
|
840
|
+
await this.login();
|
|
841
|
+
|
|
842
|
+
if (!botRegistrationId) {
|
|
843
|
+
throw new Error('botRegistrationId is required');
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
let response = await this.network.fetch(
|
|
847
|
+
`${this.url.href}_bot-registration`,
|
|
848
|
+
{
|
|
849
|
+
method: 'DELETE',
|
|
850
|
+
headers: {
|
|
851
|
+
Accept: SupportedMimeType.JSONAPI,
|
|
852
|
+
'Content-Type': 'application/vnd.api+json',
|
|
853
|
+
Authorization: `Bearer ${this.token}`,
|
|
854
|
+
},
|
|
855
|
+
body: JSON.stringify({
|
|
856
|
+
data: {
|
|
857
|
+
type: 'bot-registration',
|
|
858
|
+
id: botRegistrationId,
|
|
859
|
+
},
|
|
860
|
+
}),
|
|
861
|
+
},
|
|
862
|
+
);
|
|
863
|
+
|
|
864
|
+
if (!response.ok) {
|
|
865
|
+
let err = `Could not unregister bot: ${response.status} - ${await response.text()}`;
|
|
866
|
+
console.error(err);
|
|
867
|
+
throw new Error(err);
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
async getBotRegistrations() {
|
|
874
|
+
await this.login();
|
|
875
|
+
|
|
876
|
+
let response = await this.network.fetch(
|
|
877
|
+
`${this.url.href}_bot-registrations`,
|
|
878
|
+
{
|
|
879
|
+
method: 'GET',
|
|
880
|
+
headers: {
|
|
881
|
+
Accept: SupportedMimeType.JSONAPI,
|
|
882
|
+
Authorization: `Bearer ${this.token}`,
|
|
883
|
+
},
|
|
884
|
+
},
|
|
885
|
+
);
|
|
886
|
+
|
|
887
|
+
if (!response.ok) {
|
|
888
|
+
let err = `Could not fetch bot registrations: ${response.status} - ${await response.text()}`;
|
|
889
|
+
console.error(err);
|
|
890
|
+
throw new Error(err);
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
let body = (await response.json()) as {
|
|
894
|
+
data: Array<{
|
|
895
|
+
id: string;
|
|
896
|
+
attributes: {
|
|
897
|
+
username: string;
|
|
898
|
+
createdAt: string;
|
|
899
|
+
};
|
|
900
|
+
}>;
|
|
901
|
+
};
|
|
902
|
+
|
|
903
|
+
let registrations = body.data.map((entry) => ({
|
|
904
|
+
botRegistrationId: entry.id,
|
|
905
|
+
username: entry.attributes.username,
|
|
906
|
+
createdAt: entry.attributes.createdAt,
|
|
907
|
+
}));
|
|
908
|
+
|
|
909
|
+
return registrations;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
async publishRealm(sourceRealmURL: string, publishedRealmURL: string) {
|
|
913
|
+
await this.login();
|
|
914
|
+
|
|
915
|
+
const response = await this.network.fetch(
|
|
916
|
+
`${this.url.href}_publish-realm`,
|
|
917
|
+
{
|
|
918
|
+
method: 'POST',
|
|
919
|
+
headers: {
|
|
920
|
+
Accept: 'application/json',
|
|
921
|
+
'Content-Type': 'application/json',
|
|
922
|
+
Authorization: `Bearer ${this.token}`,
|
|
923
|
+
},
|
|
924
|
+
body: JSON.stringify({
|
|
925
|
+
sourceRealmURL,
|
|
926
|
+
publishedRealmURL,
|
|
927
|
+
}),
|
|
928
|
+
},
|
|
929
|
+
);
|
|
930
|
+
|
|
931
|
+
if (!response.ok) {
|
|
932
|
+
const errorText = await response.text();
|
|
933
|
+
throw new Error(
|
|
934
|
+
`Publish realm failed: ${response.status} - ${errorText}`,
|
|
935
|
+
);
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
return response.json();
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
async checkDomainAvailability(
|
|
942
|
+
subdomain: string,
|
|
943
|
+
): Promise<SubdomainAvailabilityResult> {
|
|
944
|
+
await this.login();
|
|
945
|
+
|
|
946
|
+
let url = new URL(`${this.url.href}_check-boxel-domain-availability`);
|
|
947
|
+
url.searchParams.set('subdomain', subdomain);
|
|
948
|
+
|
|
949
|
+
let response = await this.realmServer.authedFetch(url.href, {
|
|
950
|
+
method: 'GET',
|
|
951
|
+
headers: {
|
|
952
|
+
Accept: 'application/json',
|
|
953
|
+
},
|
|
954
|
+
});
|
|
955
|
+
|
|
956
|
+
if (!response.ok) {
|
|
957
|
+
let errorText = await response.text();
|
|
958
|
+
throw new Error(
|
|
959
|
+
`Check site name availability failed: ${response.status} - ${errorText}`,
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
return (await response.json()) as SubdomainAvailabilityResult;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
async fetchBoxelClaimedDomain(
|
|
967
|
+
sourceRealmURL: string,
|
|
968
|
+
): Promise<ClaimedDomain | null> {
|
|
969
|
+
await this.login();
|
|
970
|
+
|
|
971
|
+
let url = new URL(`${this.url.href}_boxel-claimed-domains`);
|
|
972
|
+
url.searchParams.set('source_realm_url', sourceRealmURL);
|
|
973
|
+
|
|
974
|
+
let response = await this.authedFetch(url.href, {
|
|
975
|
+
method: 'GET',
|
|
976
|
+
headers: {
|
|
977
|
+
Accept: SupportedMimeType.JSONAPI,
|
|
978
|
+
},
|
|
979
|
+
});
|
|
980
|
+
|
|
981
|
+
if (response.status === 404) {
|
|
982
|
+
return null;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
if (!response.ok) {
|
|
986
|
+
let errorText = await response.text();
|
|
987
|
+
throw new Error(
|
|
988
|
+
`Fetch claimed domain failed: ${response.status} - ${errorText}`,
|
|
989
|
+
);
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
let {
|
|
993
|
+
data: { id, attributes },
|
|
994
|
+
} = (await response.json()) as {
|
|
995
|
+
data: {
|
|
996
|
+
id: string;
|
|
997
|
+
attributes: {
|
|
998
|
+
hostname: string;
|
|
999
|
+
subdomain: string;
|
|
1000
|
+
sourceRealmURL: string;
|
|
1001
|
+
};
|
|
1002
|
+
};
|
|
1003
|
+
};
|
|
1004
|
+
|
|
1005
|
+
return {
|
|
1006
|
+
id,
|
|
1007
|
+
hostname: attributes.hostname,
|
|
1008
|
+
subdomain: attributes.subdomain,
|
|
1009
|
+
sourceRealmURL: attributes.sourceRealmURL,
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
async deleteBoxelClaimedDomain(claimedDomainId: string): Promise<void> {
|
|
1014
|
+
await this.login();
|
|
1015
|
+
|
|
1016
|
+
let response = await this.authedFetch(
|
|
1017
|
+
`${this.url.href}_boxel-claimed-domains/${claimedDomainId}`,
|
|
1018
|
+
{
|
|
1019
|
+
method: 'DELETE',
|
|
1020
|
+
},
|
|
1021
|
+
);
|
|
1022
|
+
|
|
1023
|
+
if (response.status === 204) {
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
if (!response.ok) {
|
|
1028
|
+
let errorText = await response.text();
|
|
1029
|
+
throw new Error(
|
|
1030
|
+
`Delete claimed domain failed: ${response.status} - ${errorText}`,
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
async claimBoxelDomain(sourceRealmURL: string, hostname: string) {
|
|
1036
|
+
const requestBody = {
|
|
1037
|
+
data: {
|
|
1038
|
+
type: 'claimed-domain',
|
|
1039
|
+
attributes: {
|
|
1040
|
+
source_realm_url: sourceRealmURL,
|
|
1041
|
+
hostname,
|
|
1042
|
+
},
|
|
1043
|
+
},
|
|
1044
|
+
};
|
|
1045
|
+
|
|
1046
|
+
const response = await this.realmServer.authedFetch(
|
|
1047
|
+
`${this.url.href}_boxel-claimed-domains`,
|
|
1048
|
+
{
|
|
1049
|
+
method: 'POST',
|
|
1050
|
+
headers: {
|
|
1051
|
+
Accept: SupportedMimeType.JSONAPI,
|
|
1052
|
+
'Content-Type': 'application/json',
|
|
1053
|
+
},
|
|
1054
|
+
body: JSON.stringify(requestBody),
|
|
1055
|
+
},
|
|
1056
|
+
);
|
|
1057
|
+
|
|
1058
|
+
if (!response.ok) {
|
|
1059
|
+
throw new Error(await response.text());
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
return response.json();
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
async unpublishRealm(publishedRealmURL: string) {
|
|
1066
|
+
await this.login();
|
|
1067
|
+
|
|
1068
|
+
const response = await this.network.fetch(
|
|
1069
|
+
`${this.url.href}_unpublish-realm`,
|
|
1070
|
+
{
|
|
1071
|
+
method: 'POST',
|
|
1072
|
+
headers: {
|
|
1073
|
+
Accept: 'application/json',
|
|
1074
|
+
'Content-Type': 'application/json',
|
|
1075
|
+
Authorization: `Bearer ${this.token}`,
|
|
1076
|
+
},
|
|
1077
|
+
body: JSON.stringify({
|
|
1078
|
+
publishedRealmURL,
|
|
1079
|
+
}),
|
|
1080
|
+
},
|
|
1081
|
+
);
|
|
1082
|
+
|
|
1083
|
+
if (!response.ok) {
|
|
1084
|
+
const errorText = await response.text();
|
|
1085
|
+
throw new Error(
|
|
1086
|
+
`Unpublish realm failed: ${response.status} - ${errorText}`,
|
|
1087
|
+
);
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
return response.json();
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
async createGitHubPR(params: {
|
|
1094
|
+
listingName: string;
|
|
1095
|
+
listingId?: string;
|
|
1096
|
+
snapshotId: string;
|
|
1097
|
+
branch: string;
|
|
1098
|
+
baseBranch?: string;
|
|
1099
|
+
files: Array<{ path: string; content: string }>;
|
|
1100
|
+
}): Promise<{
|
|
1101
|
+
prUrl: string;
|
|
1102
|
+
prNumber: number;
|
|
1103
|
+
branch: string;
|
|
1104
|
+
sha: string;
|
|
1105
|
+
status: 'open' | 'merged' | 'closed' | 'failed';
|
|
1106
|
+
}> {
|
|
1107
|
+
await this.login();
|
|
1108
|
+
|
|
1109
|
+
const response = await this.authedFetch(`${this.url.href}_github-pr`, {
|
|
1110
|
+
method: 'POST',
|
|
1111
|
+
headers: {
|
|
1112
|
+
Accept: SupportedMimeType.JSONAPI,
|
|
1113
|
+
'Content-Type': 'application/json',
|
|
1114
|
+
},
|
|
1115
|
+
body: JSON.stringify({
|
|
1116
|
+
data: {
|
|
1117
|
+
type: 'github-pr',
|
|
1118
|
+
attributes: params,
|
|
1119
|
+
},
|
|
1120
|
+
}),
|
|
1121
|
+
});
|
|
1122
|
+
|
|
1123
|
+
if (!response.ok) {
|
|
1124
|
+
const errorText = await response.text();
|
|
1125
|
+
let errorMessage: string;
|
|
1126
|
+
try {
|
|
1127
|
+
const errorJson = JSON.parse(errorText);
|
|
1128
|
+
errorMessage = errorJson.errors?.[0]?.detail || errorText;
|
|
1129
|
+
} catch {
|
|
1130
|
+
errorMessage = errorText;
|
|
1131
|
+
}
|
|
1132
|
+
throw new Error(
|
|
1133
|
+
`GitHub PR creation failed: ${response.status} - ${errorMessage}`,
|
|
1134
|
+
);
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
const { data } = (await response.json()) as {
|
|
1138
|
+
data: {
|
|
1139
|
+
type: string;
|
|
1140
|
+
id: string;
|
|
1141
|
+
attributes: {
|
|
1142
|
+
prUrl: string;
|
|
1143
|
+
prNumber: number;
|
|
1144
|
+
branch: string;
|
|
1145
|
+
sha: string;
|
|
1146
|
+
status: 'open' | 'merged' | 'closed' | 'failed';
|
|
1147
|
+
};
|
|
1148
|
+
};
|
|
1149
|
+
};
|
|
1150
|
+
|
|
1151
|
+
return data.attributes;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
private async getToken() {
|
|
1155
|
+
if (!this.token) {
|
|
1156
|
+
await this.login();
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
if (!this.token) {
|
|
1160
|
+
throw new Error('Failed to get realm server token');
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
return this.token;
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
private getRealmTokenForRealms(realms: string[]): string | undefined {
|
|
1167
|
+
let sessionTokens: Record<string, string> = {};
|
|
1168
|
+
let sessionStr = window.localStorage.getItem(SessionLocalStorageKey);
|
|
1169
|
+
if (!sessionStr) {
|
|
1170
|
+
return undefined;
|
|
1171
|
+
}
|
|
1172
|
+
try {
|
|
1173
|
+
sessionTokens = JSON.parse(sessionStr) as Record<string, string>;
|
|
1174
|
+
} catch {
|
|
1175
|
+
return undefined;
|
|
1176
|
+
}
|
|
1177
|
+
for (let realmURL of realms) {
|
|
1178
|
+
let normalizedRealmURL = ensureTrailingSlash(realmURL);
|
|
1179
|
+
let token = sessionTokens[normalizedRealmURL] ?? sessionTokens[realmURL];
|
|
1180
|
+
if (token) {
|
|
1181
|
+
return token;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
return undefined;
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
const tokenRefreshPeriodSec = 5 * 60; // 5 minutes
|
|
1189
|
+
const sessionLocalStorageKey = 'boxel-realm-server-session';
|
|
1190
|
+
|
|
1191
|
+
function claimsFromRawToken(rawToken: string): RealmServerJWTPayload {
|
|
1192
|
+
let [_header, payload] = rawToken.split('.');
|
|
1193
|
+
return JSON.parse(atob(payload)) as RealmServerJWTPayload;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
function realmClaimsFromRawToken(rawToken: string): JWTPayload | undefined {
|
|
1197
|
+
try {
|
|
1198
|
+
let [_header, payload] = rawToken.split('.');
|
|
1199
|
+
return JSON.parse(atob(payload)) as JWTPayload;
|
|
1200
|
+
} catch {
|
|
1201
|
+
return undefined;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
declare module '@ember/service' {
|
|
1206
|
+
interface Registry {
|
|
1207
|
+
'realm-server': RealmServerService;
|
|
1208
|
+
}
|
|
1209
|
+
}
|