@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,1413 @@
|
|
|
1
|
+
import {
|
|
2
|
+
associateDestroyableChild,
|
|
3
|
+
registerDestructor,
|
|
4
|
+
} from '@ember/destroyable';
|
|
5
|
+
import type Owner from '@ember/owner';
|
|
6
|
+
import { setOwner, getOwner } from '@ember/owner';
|
|
7
|
+
import Service, { service } from '@ember/service';
|
|
8
|
+
import { buildWaiter, waitForPromise } from '@ember/test-waiters';
|
|
9
|
+
|
|
10
|
+
import { isTesting } from '@embroider/macros';
|
|
11
|
+
|
|
12
|
+
import { tracked, cached } from '@glimmer/tracking';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
didCancel,
|
|
16
|
+
dropTask,
|
|
17
|
+
task,
|
|
18
|
+
restartableTask,
|
|
19
|
+
rawTimeout,
|
|
20
|
+
} from 'ember-concurrency';
|
|
21
|
+
import window from 'ember-window-mock';
|
|
22
|
+
|
|
23
|
+
import { TrackedSet, TrackedObject, TrackedArray } from 'tracked-built-ins';
|
|
24
|
+
|
|
25
|
+
import type {
|
|
26
|
+
Permissions,
|
|
27
|
+
JWTPayload,
|
|
28
|
+
RealmIdentifier,
|
|
29
|
+
RealmPermissions,
|
|
30
|
+
RealmResourceIdentifier,
|
|
31
|
+
} from '@cardstack/runtime-common';
|
|
32
|
+
import {
|
|
33
|
+
Deferred,
|
|
34
|
+
ensureTrailingSlash,
|
|
35
|
+
isRegisteredPrefix,
|
|
36
|
+
cardIdToURL,
|
|
37
|
+
logger,
|
|
38
|
+
ri,
|
|
39
|
+
rri,
|
|
40
|
+
SupportedMimeType,
|
|
41
|
+
type RealmInfo,
|
|
42
|
+
RealmPaths,
|
|
43
|
+
} from '@cardstack/runtime-common';
|
|
44
|
+
|
|
45
|
+
import ENV from '@cardstack/host/config/environment';
|
|
46
|
+
|
|
47
|
+
import { assertNever } from '@cardstack/host/utils/assert-never';
|
|
48
|
+
|
|
49
|
+
import type {
|
|
50
|
+
IndexRealmEventContent,
|
|
51
|
+
RealmEventContent,
|
|
52
|
+
} from 'https://cardstack.com/base/matrix-event';
|
|
53
|
+
|
|
54
|
+
import {
|
|
55
|
+
syncTokenToServiceWorker,
|
|
56
|
+
syncAllTokensToServiceWorker,
|
|
57
|
+
clearServiceWorkerTokens,
|
|
58
|
+
} from '../utils/auth-service-worker-registration';
|
|
59
|
+
import { SessionLocalStorageKey } from '../utils/local-storage-keys';
|
|
60
|
+
|
|
61
|
+
import type MatrixService from './matrix-service';
|
|
62
|
+
import type MessageService from './message-service';
|
|
63
|
+
import type NetworkService from './network';
|
|
64
|
+
import type RealmServerService from './realm-server';
|
|
65
|
+
import type ResetService from './reset';
|
|
66
|
+
|
|
67
|
+
const log = logger('service:realm');
|
|
68
|
+
|
|
69
|
+
// Reports "pending" while a realm has incremental indexing in flight (between
|
|
70
|
+
// the incremental-index-initiation Matrix event and the matching incremental/
|
|
71
|
+
// full/copy completion event). Lets `await settled()` automatically wait for
|
|
72
|
+
// indexing to finish in tests, which is the primary leverage point for
|
|
73
|
+
// fixing the test surface that pre-CS-11003 relied on the synchronous-
|
|
74
|
+
// indexing semantic of the +source POST.
|
|
75
|
+
const indexingWaiter = buildWaiter('realm:incremental-indexing');
|
|
76
|
+
|
|
77
|
+
// The name returned by `RealmService#info()` when the corresponding realm
|
|
78
|
+
// resource hasn't yet resolved its `_info` document. Exported so consumers
|
|
79
|
+
// (e.g. SearchResultSection's render-race diagnostic) can detect the
|
|
80
|
+
// placeholder without duplicating the literal string.
|
|
81
|
+
export const UNKNOWN_REALM_NAME = 'Unknown Workspace';
|
|
82
|
+
|
|
83
|
+
export type EnhancedRealmInfo = RealmInfo & {
|
|
84
|
+
isIndexing: boolean;
|
|
85
|
+
isPublic: boolean;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export interface PrivateDependencyReference {
|
|
89
|
+
dependency: string;
|
|
90
|
+
realmURL: string;
|
|
91
|
+
via?: string[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type PublishabilityWarningType =
|
|
95
|
+
| 'has-private-dependencies'
|
|
96
|
+
| 'has-error-card-documents';
|
|
97
|
+
|
|
98
|
+
export type PublishabilityViolation =
|
|
99
|
+
| PrivateDependencyViolation
|
|
100
|
+
| ErrorDocumentViolation;
|
|
101
|
+
|
|
102
|
+
export interface BasePublishabilityViolation {
|
|
103
|
+
resource: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface PrivateDependencyViolation extends BasePublishabilityViolation {
|
|
107
|
+
kind: 'private-dependency';
|
|
108
|
+
externalDependencies: PrivateDependencyReference[];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface ErrorDocumentViolation extends BasePublishabilityViolation {
|
|
112
|
+
kind: 'error-document';
|
|
113
|
+
errorDocUrl?: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface RealmPrivateDependencyReport {
|
|
117
|
+
publishable: boolean;
|
|
118
|
+
realmURL: string;
|
|
119
|
+
violations: PublishabilityViolation[];
|
|
120
|
+
warningTypes?: PublishabilityWarningType[];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
type RealmInfoProperty =
|
|
124
|
+
| 'backgroundURL'
|
|
125
|
+
| 'iconURL'
|
|
126
|
+
| 'interactHome'
|
|
127
|
+
| 'hostHome';
|
|
128
|
+
|
|
129
|
+
type AuthStatus =
|
|
130
|
+
| { type: 'logged-in'; token: string; claims: JWTPayload }
|
|
131
|
+
| { type: 'anonymous' };
|
|
132
|
+
|
|
133
|
+
class RealmResource {
|
|
134
|
+
@service declare private matrixService: MatrixService;
|
|
135
|
+
@service declare private network: NetworkService;
|
|
136
|
+
@service declare private messageService: MessageService;
|
|
137
|
+
@service declare private realmServer: RealmServerService;
|
|
138
|
+
|
|
139
|
+
@tracked info: EnhancedRealmInfo | undefined;
|
|
140
|
+
@tracked private realmPermissions: RealmPermissions | null | undefined;
|
|
141
|
+
|
|
142
|
+
// When realm-side indexing is in flight (incremental-index-initiation
|
|
143
|
+
// received but matching incremental/full/copy event hasn't arrived yet),
|
|
144
|
+
// hold a test-waiter token so `await settled()` and other Ember test
|
|
145
|
+
// helpers wait for the index event before proceeding. This is the
|
|
146
|
+
// primary semaphore for tests that, before CS-11003, relied on the
|
|
147
|
+
// synchronous-indexing semantic of the +source POST and now would
|
|
148
|
+
// race against the deferred indexing chain. No-op outside tests.
|
|
149
|
+
private indexingWaiterToken: unknown | null = null;
|
|
150
|
+
|
|
151
|
+
@tracked
|
|
152
|
+
private auth: AuthStatus = { type: 'anonymous' };
|
|
153
|
+
private subscription: { unsubscribe: () => void } | undefined;
|
|
154
|
+
|
|
155
|
+
@tracked private _isPublishing = false;
|
|
156
|
+
private _publishingRealms = new TrackedArray<string>();
|
|
157
|
+
private _unPublishingRealms = new TrackedArray<string>();
|
|
158
|
+
|
|
159
|
+
// Hassan: in general i'm questioning the usefulness of using Tasks in this
|
|
160
|
+
// class. We seem to be following the pattern of await-ing all the tasks on
|
|
161
|
+
// the outside of the Task.perform(). When we do this it actually casts the
|
|
162
|
+
// Task.perform() into a normal non-cancellable promise. Probably we can get
|
|
163
|
+
// rid of all these tasks and just use normal promises as I don't think the
|
|
164
|
+
// tasks are buying us anything.
|
|
165
|
+
|
|
166
|
+
constructor(
|
|
167
|
+
private realmURL: string,
|
|
168
|
+
token: string | undefined,
|
|
169
|
+
private realmService: RealmService,
|
|
170
|
+
) {
|
|
171
|
+
this.token = token;
|
|
172
|
+
registerDestructor(this, () => {
|
|
173
|
+
if (this.subscription) {
|
|
174
|
+
this.subscription.unsubscribe();
|
|
175
|
+
}
|
|
176
|
+
// Release any held test-waiter token so we don't leak pending state
|
|
177
|
+
// across tests when the resource is torn down with indexing in flight.
|
|
178
|
+
if (this.indexingWaiterToken) {
|
|
179
|
+
indexingWaiter.endAsync(this.indexingWaiterToken);
|
|
180
|
+
this.indexingWaiterToken = null;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
get isLoggedIn() {
|
|
186
|
+
return this.auth.type === 'logged-in';
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
get url(): string {
|
|
190
|
+
return this.realmURL;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
get token(): string | undefined {
|
|
194
|
+
if (this.auth.type === 'logged-in') {
|
|
195
|
+
return this.auth.token;
|
|
196
|
+
}
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
set token(value: string | undefined) {
|
|
201
|
+
if (value) {
|
|
202
|
+
this.auth = {
|
|
203
|
+
type: 'logged-in',
|
|
204
|
+
token: value,
|
|
205
|
+
claims: claimsFromRawToken(value),
|
|
206
|
+
};
|
|
207
|
+
} else {
|
|
208
|
+
this.auth = { type: 'anonymous' };
|
|
209
|
+
}
|
|
210
|
+
SessionStorage.persist(this.realmURL, value);
|
|
211
|
+
this.tokenRefresher.perform();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
get isPublic() {
|
|
215
|
+
return this.info?.isPublic;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
get claims(): JWTPayload | undefined {
|
|
219
|
+
if (this.auth.type === 'logged-in') {
|
|
220
|
+
return this.auth.claims;
|
|
221
|
+
}
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
get canRead() {
|
|
226
|
+
return !!this.isPublic || !!this.claims?.permissions?.includes('read');
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
get canWrite() {
|
|
230
|
+
return !!this.claims?.permissions?.includes('write');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
get isRealmOwner() {
|
|
234
|
+
return !!this.claims?.permissions?.includes('realm-owner');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
private loggingIn: Promise<void> | undefined;
|
|
238
|
+
|
|
239
|
+
async login(): Promise<void> {
|
|
240
|
+
if (this.auth.type === 'logged-in') {
|
|
241
|
+
await this.subscribe();
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (!this.loggingIn) {
|
|
245
|
+
this.loggingIn = this.loginTask.perform();
|
|
246
|
+
}
|
|
247
|
+
await this.loggingIn;
|
|
248
|
+
await this.subscribe();
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
private async subscribe() {
|
|
252
|
+
if (this.subscription) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Avoid deadlocks during reauthentication triggered by a 401 when fetching realm info.
|
|
257
|
+
// If the info is already being fetched, we don't need to call fetchInfo again,
|
|
258
|
+
// since the purpose of await this.fetchInfo() here is only to ensure that the realm has the info loaded.
|
|
259
|
+
if (!this.fetchingInfo) {
|
|
260
|
+
await this.fetchInfo();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
this.subscription = {
|
|
264
|
+
unsubscribe: this.messageService.subscribe(
|
|
265
|
+
this.realmURL,
|
|
266
|
+
(event: RealmEventContent) => {
|
|
267
|
+
if (!this.info) {
|
|
268
|
+
console.warn(
|
|
269
|
+
`No realm info exists for ${this.realmURL} when trying to set indexing status`,
|
|
270
|
+
);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (event.eventName !== 'index') {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
let data = event as IndexRealmEventContent;
|
|
277
|
+
switch (data.indexType) {
|
|
278
|
+
case 'incremental-index-initiation':
|
|
279
|
+
this.info.isIndexing = true;
|
|
280
|
+
if (!this.indexingWaiterToken) {
|
|
281
|
+
this.indexingWaiterToken = indexingWaiter.beginAsync();
|
|
282
|
+
}
|
|
283
|
+
break;
|
|
284
|
+
case 'full':
|
|
285
|
+
case 'copy':
|
|
286
|
+
case 'incremental':
|
|
287
|
+
this.info.isIndexing = false;
|
|
288
|
+
if (this.indexingWaiterToken) {
|
|
289
|
+
indexingWaiter.endAsync(this.indexingWaiterToken);
|
|
290
|
+
this.indexingWaiterToken = null;
|
|
291
|
+
}
|
|
292
|
+
break;
|
|
293
|
+
default:
|
|
294
|
+
throw assertNever(data);
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
),
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
private loginTask = task(async () => {
|
|
302
|
+
try {
|
|
303
|
+
let token = await this.matrixService.createRealmSession(
|
|
304
|
+
new URL(this.realmURL),
|
|
305
|
+
);
|
|
306
|
+
this.token = token;
|
|
307
|
+
} catch (e: any) {
|
|
308
|
+
console.error(`RealmService - Failed to login to realm: ${e.message}`, e);
|
|
309
|
+
this.token = undefined;
|
|
310
|
+
const event = new CustomEvent('boxel-auth-error', { detail: e });
|
|
311
|
+
globalThis.dispatchEvent(event);
|
|
312
|
+
} finally {
|
|
313
|
+
this.loggingIn = undefined;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
logout(): void {
|
|
318
|
+
this.clearRealmSession();
|
|
319
|
+
window.localStorage.removeItem(SessionLocalStorageKey);
|
|
320
|
+
syncTokenToServiceWorker(this.realmURL, undefined);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
clearRealmSession(): void {
|
|
324
|
+
this.auth = { type: 'anonymous' };
|
|
325
|
+
SessionStorage.remove(this.realmURL);
|
|
326
|
+
syncTokenToServiceWorker(this.realmURL, undefined);
|
|
327
|
+
this.loginTask.cancelAll();
|
|
328
|
+
this.tokenRefresher.cancelAll();
|
|
329
|
+
this.loggingIn = undefined;
|
|
330
|
+
this.fetchInfoTask.cancelAll();
|
|
331
|
+
this.fetchingInfo = undefined;
|
|
332
|
+
this.fetchRealmPermissionsTask.cancelAll();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
private fetchingInfo: Promise<void> | undefined;
|
|
336
|
+
|
|
337
|
+
async fetchInfo(): Promise<void> {
|
|
338
|
+
if (!this.fetchingInfo) {
|
|
339
|
+
// share the work if there are multiple requests to get the info for a realm
|
|
340
|
+
this.fetchingInfo = this.fetchInfoTask.perform();
|
|
341
|
+
}
|
|
342
|
+
try {
|
|
343
|
+
await this.fetchingInfo;
|
|
344
|
+
} catch (error) {
|
|
345
|
+
// Realm info loading is best-effort during teardown. When the app/test is
|
|
346
|
+
// already being destroyed, callers cannot do anything useful with a
|
|
347
|
+
// cancellation, and surfacing it as a global failure makes normal
|
|
348
|
+
// component unmounts look like test regressions.
|
|
349
|
+
if (!didCancel(error)) {
|
|
350
|
+
throw error;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
private fetchInfoTask = dropTask(async () => {
|
|
356
|
+
try {
|
|
357
|
+
if (this.info) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
await this.realmService.waitForBulkInfoIfNeeded();
|
|
361
|
+
if (this.info) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
let headers: Record<string, string> = {
|
|
365
|
+
Accept: SupportedMimeType.RealmInfo,
|
|
366
|
+
...(this.auth.type === 'logged-in'
|
|
367
|
+
? { Authorization: `Bearer ${this.token}` }
|
|
368
|
+
: {}),
|
|
369
|
+
};
|
|
370
|
+
let response: Response;
|
|
371
|
+
try {
|
|
372
|
+
response = await this.network.authedFetch(`${this.realmURL}_info`, {
|
|
373
|
+
method: 'QUERY',
|
|
374
|
+
headers: {
|
|
375
|
+
...headers,
|
|
376
|
+
'Content-Type': 'application/json',
|
|
377
|
+
},
|
|
378
|
+
body: JSON.stringify({ realms: [this.realmURL] }),
|
|
379
|
+
});
|
|
380
|
+
} catch (error) {
|
|
381
|
+
if (isTesting()) {
|
|
382
|
+
console.warn(
|
|
383
|
+
`[realm-service] realm info fetch failed ${JSON.stringify({
|
|
384
|
+
realmURL: this.realmURL,
|
|
385
|
+
error: String(error),
|
|
386
|
+
})}`,
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
throw error;
|
|
390
|
+
}
|
|
391
|
+
if (response.status !== 200) {
|
|
392
|
+
let responseText = await response.text();
|
|
393
|
+
if (isTesting()) {
|
|
394
|
+
console.warn(
|
|
395
|
+
`[realm-service] realm info fetch bad status ${JSON.stringify({
|
|
396
|
+
realmURL: this.realmURL,
|
|
397
|
+
status: response.status,
|
|
398
|
+
responseText,
|
|
399
|
+
})}`,
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
throw new Error(
|
|
403
|
+
`Failed to fetch realm info for ${this.realmURL}: ${response.status}`,
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
let json = await waitForPromise(response.json());
|
|
407
|
+
let realmData = Array.isArray(json.data) ? json.data[0] : json.data;
|
|
408
|
+
let info: RealmInfo = {
|
|
409
|
+
url: realmData.id,
|
|
410
|
+
...realmData.attributes,
|
|
411
|
+
};
|
|
412
|
+
let isPublic = Boolean(
|
|
413
|
+
response.headers.get('x-boxel-realm-public-readable') ||
|
|
414
|
+
response.headers.get('x-boxel-realms-public-readable'),
|
|
415
|
+
);
|
|
416
|
+
this.info = new TrackedObject({ ...info, isIndexing: false, isPublic });
|
|
417
|
+
} finally {
|
|
418
|
+
this.fetchingInfo = undefined;
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
async setRealmInfoProperty(
|
|
423
|
+
property: RealmInfoProperty,
|
|
424
|
+
value: string | null,
|
|
425
|
+
): Promise<void> {
|
|
426
|
+
await this.loginTask.perform();
|
|
427
|
+
let headers: Record<string, string> = {
|
|
428
|
+
Accept: SupportedMimeType.JSON,
|
|
429
|
+
Authorization: `Bearer ${this.token}`,
|
|
430
|
+
};
|
|
431
|
+
let response = await this.network.authedFetch(`${this.realmURL}_config`, {
|
|
432
|
+
method: 'PATCH',
|
|
433
|
+
headers,
|
|
434
|
+
body: JSON.stringify({
|
|
435
|
+
data: {
|
|
436
|
+
type: 'realm-config',
|
|
437
|
+
id: this.url,
|
|
438
|
+
attributes: { [property]: value },
|
|
439
|
+
},
|
|
440
|
+
}),
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
if (response.status !== 200) {
|
|
444
|
+
throw new Error(
|
|
445
|
+
`Failed to set realm config property '${property}' for realm ${this.url}: ${response.status}`,
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
let json = await waitForPromise(response.json());
|
|
449
|
+
let isPublic = Boolean(
|
|
450
|
+
response.headers.get('x-boxel-realm-public-readable'),
|
|
451
|
+
);
|
|
452
|
+
let updatedInfo = new TrackedObject({
|
|
453
|
+
url: json.data.id,
|
|
454
|
+
...json.data.attributes,
|
|
455
|
+
isIndexing: this.info?.isIndexing ?? false,
|
|
456
|
+
isPublic,
|
|
457
|
+
}) as EnhancedRealmInfo;
|
|
458
|
+
this.info = updatedInfo;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
async setHostHome(hostHome: string | null): Promise<void> {
|
|
462
|
+
return await this.setRealmInfoProperty('hostHome', hostHome);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
async fetchRealmPermissions() {
|
|
466
|
+
return await this.fetchRealmPermissionsTask.perform();
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
private fetchRealmPermissionsTask = dropTask(async () => {
|
|
470
|
+
if (this.realmPermissions !== undefined) {
|
|
471
|
+
return this.realmPermissions;
|
|
472
|
+
}
|
|
473
|
+
await this.loginTask.perform();
|
|
474
|
+
let headers: Record<string, string> = {
|
|
475
|
+
Accept: SupportedMimeType.Permissions,
|
|
476
|
+
Authorization: `Bearer ${this.token}`,
|
|
477
|
+
};
|
|
478
|
+
let response = await this.network.authedFetch(
|
|
479
|
+
`${this.realmURL}_permissions`,
|
|
480
|
+
{
|
|
481
|
+
headers,
|
|
482
|
+
},
|
|
483
|
+
);
|
|
484
|
+
|
|
485
|
+
if (response.status === 403) {
|
|
486
|
+
// the user is not an owner of this realm which is a legit scenario
|
|
487
|
+
this.realmPermissions = null;
|
|
488
|
+
return;
|
|
489
|
+
} else if (response.status !== 200) {
|
|
490
|
+
throw new Error(
|
|
491
|
+
`Failed to fetch realm permissions for ${this.realmURL}: ${response.status}`,
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
let json = await waitForPromise(response.json());
|
|
495
|
+
this.realmPermissions = json.data.attributes.permissions;
|
|
496
|
+
return this.realmPermissions;
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
async fetchPrivateDependencyReport(): Promise<RealmPrivateDependencyReport> {
|
|
500
|
+
await this.loginTask.perform();
|
|
501
|
+
let headers: Record<string, string> = {
|
|
502
|
+
Accept: SupportedMimeType.JSONAPI,
|
|
503
|
+
Authorization: `Bearer ${this.token}`,
|
|
504
|
+
};
|
|
505
|
+
let response = await this.network.authedFetch(
|
|
506
|
+
`${this.realmURL}_publishability`,
|
|
507
|
+
{
|
|
508
|
+
headers,
|
|
509
|
+
},
|
|
510
|
+
);
|
|
511
|
+
|
|
512
|
+
if (response.status !== 200) {
|
|
513
|
+
throw new Error(
|
|
514
|
+
`Failed to check private dependencies for ${this.realmURL}: ${response.status}`,
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
let json = (await waitForPromise(response.json())) as {
|
|
519
|
+
data: {
|
|
520
|
+
attributes: {
|
|
521
|
+
publishable: boolean;
|
|
522
|
+
realmURL: string;
|
|
523
|
+
violations: PublishabilityViolation[];
|
|
524
|
+
warningTypes?: PublishabilityWarningType[];
|
|
525
|
+
};
|
|
526
|
+
};
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
let attributes = json.data.attributes;
|
|
530
|
+
|
|
531
|
+
return {
|
|
532
|
+
publishable: attributes.publishable,
|
|
533
|
+
realmURL: attributes.realmURL,
|
|
534
|
+
violations: attributes.violations ?? [],
|
|
535
|
+
warningTypes: attributes.warningTypes ?? [],
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
async setRealmPermission(
|
|
540
|
+
userId: string,
|
|
541
|
+
permissions: ('read' | 'write')[] | null,
|
|
542
|
+
): Promise<void> {
|
|
543
|
+
return await this.setRealmPermissionTask.perform(userId, permissions);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
private setRealmPermissionTask = restartableTask(
|
|
547
|
+
async (userId: string, permissions: ('read' | 'write')[] | null) => {
|
|
548
|
+
await this.loginTask.perform();
|
|
549
|
+
let headers: Record<string, string> = {
|
|
550
|
+
Accept: SupportedMimeType.Permissions,
|
|
551
|
+
Authorization: `Bearer ${this.token}`,
|
|
552
|
+
};
|
|
553
|
+
let response = await this.network.authedFetch(
|
|
554
|
+
`${this.realmURL}_permissions`,
|
|
555
|
+
{
|
|
556
|
+
method: 'PATCH',
|
|
557
|
+
headers,
|
|
558
|
+
body: JSON.stringify({
|
|
559
|
+
data: {
|
|
560
|
+
type: 'permissions',
|
|
561
|
+
id: this.url,
|
|
562
|
+
attributes: {
|
|
563
|
+
permissions: {
|
|
564
|
+
[userId]: permissions,
|
|
565
|
+
} as RealmPermissions,
|
|
566
|
+
},
|
|
567
|
+
},
|
|
568
|
+
}),
|
|
569
|
+
},
|
|
570
|
+
);
|
|
571
|
+
|
|
572
|
+
if (response.status !== 200) {
|
|
573
|
+
throw new Error(
|
|
574
|
+
`Failed to set realm permissions for '${userId}:${
|
|
575
|
+
permissions ? permissions.join() : 'null'
|
|
576
|
+
}' in realm ${this.url}: ${response.status}`,
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
let json = await waitForPromise(response.json());
|
|
580
|
+
this.realmPermissions = json.data.attributes.permissions;
|
|
581
|
+
},
|
|
582
|
+
);
|
|
583
|
+
|
|
584
|
+
private tokenRefresher = restartableTask(async () => {
|
|
585
|
+
if ((globalThis as any).__boxelRenderContext || !this.claims) {
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
let refreshMs = 0;
|
|
590
|
+
|
|
591
|
+
if (this.claims.sessionRoom) {
|
|
592
|
+
// token expiration is unix time (seconds)
|
|
593
|
+
let expirationMs = this.claims.exp * 1000;
|
|
594
|
+
|
|
595
|
+
refreshMs = Math.max(
|
|
596
|
+
expirationMs - Date.now() - tokenRefreshPeriodSec * 1000,
|
|
597
|
+
0,
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
await rawTimeout(refreshMs);
|
|
602
|
+
|
|
603
|
+
if (!this.loggingIn) {
|
|
604
|
+
this.loggingIn = this.loginTask.perform();
|
|
605
|
+
await this.loggingIn;
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
async publish(urls: string[]) {
|
|
610
|
+
if (this._isPublishing) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
try {
|
|
615
|
+
this._isPublishing = true;
|
|
616
|
+
const publishPromises = urls.map(async (url) => {
|
|
617
|
+
if (this._publishingRealms.includes(url)) {
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
// Set publishing state
|
|
621
|
+
this._publishingRealms.push(url);
|
|
622
|
+
|
|
623
|
+
try {
|
|
624
|
+
const result = await this.realmServer.publishRealm(this.url, url);
|
|
625
|
+
return result;
|
|
626
|
+
} catch (error) {
|
|
627
|
+
console.error(`Error publishing to URL ${url}:`, error);
|
|
628
|
+
throw error; // Re-throw so Promise.allSettled can capture it as rejected
|
|
629
|
+
} finally {
|
|
630
|
+
this._publishingRealms.splice(this._publishingRealms.indexOf(url), 1);
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
const results = await Promise.allSettled(publishPromises);
|
|
635
|
+
if (this.info) {
|
|
636
|
+
let lastPublishedAt = results.reduce(
|
|
637
|
+
(acc, result) => {
|
|
638
|
+
if (result.status === 'fulfilled' && result.value) {
|
|
639
|
+
acc[result.value.data.attributes.publishedRealmURL] =
|
|
640
|
+
result.value.data.attributes.lastPublishedAt;
|
|
641
|
+
}
|
|
642
|
+
return acc;
|
|
643
|
+
},
|
|
644
|
+
{} as Record<string, any>,
|
|
645
|
+
);
|
|
646
|
+
this.info = {
|
|
647
|
+
...this.info,
|
|
648
|
+
lastPublishedAt: {
|
|
649
|
+
...(this.info.lastPublishedAt &&
|
|
650
|
+
typeof this.info.lastPublishedAt === 'object'
|
|
651
|
+
? this.info.lastPublishedAt
|
|
652
|
+
: {}),
|
|
653
|
+
...lastPublishedAt,
|
|
654
|
+
},
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
return results;
|
|
659
|
+
} catch (error) {
|
|
660
|
+
console.error(`Error publishing to URLs ${urls}:`, error);
|
|
661
|
+
return;
|
|
662
|
+
} finally {
|
|
663
|
+
this._isPublishing = false;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
get isPublishing() {
|
|
668
|
+
return this._isPublishing;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
get isPublishingToAnyRealms(): boolean {
|
|
672
|
+
return this._publishingRealms.length > 0;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
get publishingRealms(): string[] {
|
|
676
|
+
return this._publishingRealms;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
async unpublish(url: string) {
|
|
680
|
+
if (this._unPublishingRealms.includes(url)) {
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
try {
|
|
685
|
+
this._unPublishingRealms.push(url);
|
|
686
|
+
await this.realmServer.unpublishRealm(url);
|
|
687
|
+
if (
|
|
688
|
+
this.info &&
|
|
689
|
+
this.info.lastPublishedAt &&
|
|
690
|
+
typeof this.info.lastPublishedAt === 'object'
|
|
691
|
+
) {
|
|
692
|
+
delete this.info.lastPublishedAt[url];
|
|
693
|
+
this.info = {
|
|
694
|
+
...this.info,
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
} catch (error) {
|
|
698
|
+
console.error(`Error unpublishing from URL ${url}:`, error);
|
|
699
|
+
return;
|
|
700
|
+
} finally {
|
|
701
|
+
this._unPublishingRealms.splice(this._unPublishingRealms.indexOf(url), 1);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
isUnpublishingAnyRealms = (): boolean => {
|
|
706
|
+
return this._unPublishingRealms.length > 0;
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
isUnpublishingRealm = (publishedRealmURL: string): boolean => {
|
|
710
|
+
return this._unPublishingRealms.includes(publishedRealmURL);
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
export default class RealmService extends Service {
|
|
715
|
+
@service declare private realmServer: RealmServerService;
|
|
716
|
+
@service declare private matrixService: MatrixService;
|
|
717
|
+
@service declare private network: NetworkService;
|
|
718
|
+
@service declare private reset: ResetService;
|
|
719
|
+
|
|
720
|
+
// This is not a TrackedMap, it's a regular Map. Conceptually, we want it to
|
|
721
|
+
// be tracked, but we're using it as a read-through cache and glimmer/tracking
|
|
722
|
+
// treats that case as a read-then-write assertion failure. So instead we do
|
|
723
|
+
// untracked reads from `realms` and pair them, at the right times, with
|
|
724
|
+
// tracked reads from `currentKnownRealms` to establish dependencies.
|
|
725
|
+
private _realms: Map<string, RealmResource> = this.restoreSessions();
|
|
726
|
+
private currentKnownRealms = new TrackedSet<string>();
|
|
727
|
+
private reauthentications = new Map<string, Promise<string | undefined>>();
|
|
728
|
+
private bulkInfoPromise: Promise<void> | undefined;
|
|
729
|
+
|
|
730
|
+
@tracked private identifyRealmTracker = 0;
|
|
731
|
+
|
|
732
|
+
constructor(owner: Owner) {
|
|
733
|
+
super(owner);
|
|
734
|
+
this.reset.register(this);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
get realms(): ReadonlyMap<string, RealmResource> {
|
|
738
|
+
return this._realms;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
resetState() {
|
|
742
|
+
this.logout();
|
|
743
|
+
this._realms = new Map();
|
|
744
|
+
this.currentKnownRealms = new TrackedSet();
|
|
745
|
+
this.reauthentications.clear();
|
|
746
|
+
this.bulkInfoPromise = undefined;
|
|
747
|
+
this.identifyRealmTracker++;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
async waitForBulkInfoIfNeeded(): Promise<void> {
|
|
751
|
+
if (this.bulkInfoPromise) {
|
|
752
|
+
await this.bulkInfoPromise;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
async ensureRealmMeta(realmURL: string): Promise<void> {
|
|
757
|
+
let resource = this.getOrCreateRealmResource(realmURL);
|
|
758
|
+
await resource.fetchInfo();
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
async login(realmURL: string): Promise<void> {
|
|
762
|
+
let resource = this.getOrCreateRealmResource(realmURL);
|
|
763
|
+
await resource.login();
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
async prefetchRealmInfos(realmUrls: string[]): Promise<void> {
|
|
767
|
+
let uniqueRealmUrls = Array.from(new Set(realmUrls));
|
|
768
|
+
if (uniqueRealmUrls.length === 0) {
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
if (this.bulkInfoPromise) {
|
|
773
|
+
await this.bulkInfoPromise;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
let missingRealmUrls = uniqueRealmUrls.filter((realmURL) => {
|
|
777
|
+
return !this.knownRealm(realmURL, { tracked: false })?.info;
|
|
778
|
+
});
|
|
779
|
+
if (missingRealmUrls.length === 0) {
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
let bulkPromise = (async () => {
|
|
784
|
+
try {
|
|
785
|
+
let { data, publicReadableRealms } =
|
|
786
|
+
await this.realmServer.fetchRealmInfos(missingRealmUrls);
|
|
787
|
+
let publicReadableSet = new Set(
|
|
788
|
+
Array.from(publicReadableRealms).map((realmURL) =>
|
|
789
|
+
ensureTrailingSlash(realmURL),
|
|
790
|
+
),
|
|
791
|
+
);
|
|
792
|
+
for (let entry of data) {
|
|
793
|
+
let realmURL = ensureTrailingSlash(entry.id);
|
|
794
|
+
this.applyRealmInfo(
|
|
795
|
+
entry.id,
|
|
796
|
+
entry.attributes,
|
|
797
|
+
publicReadableSet.has(realmURL),
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
} catch (error) {
|
|
801
|
+
log.warn(`Failed to prefetch realm info: ${error}`);
|
|
802
|
+
}
|
|
803
|
+
})();
|
|
804
|
+
|
|
805
|
+
this.bulkInfoPromise = bulkPromise;
|
|
806
|
+
try {
|
|
807
|
+
await bulkPromise;
|
|
808
|
+
} finally {
|
|
809
|
+
if (this.bulkInfoPromise === bulkPromise) {
|
|
810
|
+
this.bulkInfoPromise = undefined;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
private applyRealmInfo(realmURL: string, info: RealmInfo, isPublic: boolean) {
|
|
816
|
+
let resource = this.getOrCreateRealmResource(realmURL);
|
|
817
|
+
let isIndexing = resource.info?.isIndexing ?? false;
|
|
818
|
+
resource.info = new TrackedObject({
|
|
819
|
+
url: realmURL,
|
|
820
|
+
...info,
|
|
821
|
+
isIndexing,
|
|
822
|
+
isPublic,
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
restoreSessionsFromStorage(): void {
|
|
827
|
+
let tokens = SessionStorage.getAll();
|
|
828
|
+
if (!tokens) {
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
for (let [realmURL, token] of Object.entries(tokens)) {
|
|
832
|
+
let resource = this.getOrCreateRealmResource(realmURL, token);
|
|
833
|
+
if (token && resource.token !== token) {
|
|
834
|
+
resource.token = token;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
info = (url: string): EnhancedRealmInfo => {
|
|
840
|
+
if (isRegisteredPrefix(url)) {
|
|
841
|
+
url = cardIdToURL(url).href;
|
|
842
|
+
}
|
|
843
|
+
let resource = this.knownRealm(url, { tracked: false });
|
|
844
|
+
if (!resource) {
|
|
845
|
+
this.identifyRealm.perform(url);
|
|
846
|
+
|
|
847
|
+
this.identifyRealmTracker;
|
|
848
|
+
|
|
849
|
+
return {
|
|
850
|
+
name: UNKNOWN_REALM_NAME,
|
|
851
|
+
backgroundURL: null,
|
|
852
|
+
iconURL: null,
|
|
853
|
+
showAsCatalog: null,
|
|
854
|
+
visibility: 'private',
|
|
855
|
+
publishable: null,
|
|
856
|
+
isIndexing: false,
|
|
857
|
+
isPublic: false,
|
|
858
|
+
lastPublishedAt: null,
|
|
859
|
+
interactHome: null,
|
|
860
|
+
hostHome: null,
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
if (!resource.info) {
|
|
865
|
+
resource.fetchInfo();
|
|
866
|
+
return {
|
|
867
|
+
name: UNKNOWN_REALM_NAME,
|
|
868
|
+
backgroundURL: null,
|
|
869
|
+
iconURL: null,
|
|
870
|
+
showAsCatalog: null,
|
|
871
|
+
visibility: 'private',
|
|
872
|
+
publishable: null,
|
|
873
|
+
isIndexing: false,
|
|
874
|
+
isPublic: false,
|
|
875
|
+
lastPublishedAt: null,
|
|
876
|
+
interactHome: null,
|
|
877
|
+
hostHome: null,
|
|
878
|
+
};
|
|
879
|
+
} else {
|
|
880
|
+
return resource.info;
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
|
|
884
|
+
async allUsersPermissions(url: string) {
|
|
885
|
+
if (isRegisteredPrefix(url)) {
|
|
886
|
+
url = cardIdToURL(url).href;
|
|
887
|
+
}
|
|
888
|
+
let resource = this.knownRealm(url);
|
|
889
|
+
if (!resource) {
|
|
890
|
+
await this.identifyRealm.perform(url);
|
|
891
|
+
}
|
|
892
|
+
return await resource?.fetchRealmPermissions();
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
async setPermissions(
|
|
896
|
+
url: string,
|
|
897
|
+
userId: string,
|
|
898
|
+
permissions: ('read' | 'write')[],
|
|
899
|
+
) {
|
|
900
|
+
await this.knownRealm(url)?.setRealmPermission(userId, permissions);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
async setHostHome(url: string, hostHome: string | null): Promise<void> {
|
|
904
|
+
await this.knownRealm(url)?.setHostHome(hostHome);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
removeRealm(url: string) {
|
|
908
|
+
let resource = this._realms.get(url);
|
|
909
|
+
if (resource) {
|
|
910
|
+
resource.clearRealmSession();
|
|
911
|
+
} else {
|
|
912
|
+
SessionStorage.remove(url);
|
|
913
|
+
syncTokenToServiceWorker(url, undefined);
|
|
914
|
+
}
|
|
915
|
+
this._realms.delete(url);
|
|
916
|
+
this.currentKnownRealms.delete(url);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
isPublic = (url: string): boolean => {
|
|
920
|
+
return this.knownRealm(url)?.isPublic ?? false;
|
|
921
|
+
};
|
|
922
|
+
|
|
923
|
+
canRead = (url: string): boolean => {
|
|
924
|
+
return this.knownRealm(url)?.canRead ?? false;
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
canWrite = (url: string): boolean => {
|
|
928
|
+
return this.knownRealm(url)?.canWrite ?? false;
|
|
929
|
+
};
|
|
930
|
+
|
|
931
|
+
isRealmOwner = (url: string): boolean => {
|
|
932
|
+
return this.knownRealm(url)?.isRealmOwner ?? false;
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
url = (url: string): string | undefined => {
|
|
936
|
+
return this.knownRealm(url)?.url;
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
permissions = (url: string): Permissions => {
|
|
940
|
+
let self = this;
|
|
941
|
+
return {
|
|
942
|
+
get canRead() {
|
|
943
|
+
return self.canRead(url);
|
|
944
|
+
},
|
|
945
|
+
get canWrite() {
|
|
946
|
+
return self.canWrite(url);
|
|
947
|
+
},
|
|
948
|
+
};
|
|
949
|
+
};
|
|
950
|
+
|
|
951
|
+
meta = (url: string) => {
|
|
952
|
+
let self = this;
|
|
953
|
+
return {
|
|
954
|
+
get info() {
|
|
955
|
+
return self.info(url);
|
|
956
|
+
},
|
|
957
|
+
get canWrite() {
|
|
958
|
+
return self.canWrite(url);
|
|
959
|
+
},
|
|
960
|
+
};
|
|
961
|
+
};
|
|
962
|
+
|
|
963
|
+
get allRealmsInfo() {
|
|
964
|
+
const realmsMeta: Record<
|
|
965
|
+
string,
|
|
966
|
+
{ info: EnhancedRealmInfo; canWrite: boolean }
|
|
967
|
+
> = Object.create(null);
|
|
968
|
+
for (const [url, _resource] of this.realms.entries()) {
|
|
969
|
+
realmsMeta[url] = this.meta(url);
|
|
970
|
+
}
|
|
971
|
+
return realmsMeta;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
realmOf(input: RealmResourceIdentifier | URL): RealmIdentifier | undefined {
|
|
975
|
+
let id = input instanceof URL ? rri(input.href) : input;
|
|
976
|
+
for (const realm of this.realms.keys()) {
|
|
977
|
+
if (new RealmPaths(new URL(realm)).inRealm(id)) {
|
|
978
|
+
return ri(realm);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
return undefined;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
realmForSessionRoomId(sessionRoomId: string) {
|
|
985
|
+
return Array.from(this.realms.values()).find(
|
|
986
|
+
(r) => r.claims?.sessionRoom === sessionRoomId,
|
|
987
|
+
);
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
@cached
|
|
991
|
+
get defaultWritableRealm(): { path: string; info: RealmInfo } | null {
|
|
992
|
+
let maybePersonalRealm = `${this.realmServer.url.href}${this.matrixService.userName}/personal/`;
|
|
993
|
+
if (Object.keys(this.allRealmsInfo).find((r) => r === maybePersonalRealm)) {
|
|
994
|
+
return {
|
|
995
|
+
path: maybePersonalRealm,
|
|
996
|
+
info: this.allRealmsInfo[maybePersonalRealm].info,
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
let writeableRealms = Object.entries(this.allRealmsInfo)
|
|
1000
|
+
.filter(([, i]) => i.canWrite)
|
|
1001
|
+
.sort(([, i], [, j]) => i.info.name.localeCompare(j.info.name));
|
|
1002
|
+
|
|
1003
|
+
let first = writeableRealms[0];
|
|
1004
|
+
|
|
1005
|
+
if (!first) {
|
|
1006
|
+
log.debug(
|
|
1007
|
+
`No writable realms found, known realms and writability: ${Object.keys(
|
|
1008
|
+
this.allRealmsInfo,
|
|
1009
|
+
)
|
|
1010
|
+
.map(
|
|
1011
|
+
(realmUrl) =>
|
|
1012
|
+
`${realmUrl}: ${this.allRealmsInfo[realmUrl].canWrite}`,
|
|
1013
|
+
)
|
|
1014
|
+
.join(', ')}`,
|
|
1015
|
+
);
|
|
1016
|
+
|
|
1017
|
+
return null;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
return { path: first[0], info: first[1].info };
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
@cached
|
|
1024
|
+
get defaultReadableRealm(): { path: string; info: RealmInfo } {
|
|
1025
|
+
if (this.defaultWritableRealm) {
|
|
1026
|
+
return this.defaultWritableRealm;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
let allRealmsInfoEntries = Object.entries(this.allRealmsInfo);
|
|
1030
|
+
|
|
1031
|
+
if (allRealmsInfoEntries.length > 0) {
|
|
1032
|
+
let firstMeta = allRealmsInfoEntries[0];
|
|
1033
|
+
return { path: firstMeta[0], info: firstMeta[1].info };
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
return {
|
|
1037
|
+
path: ENV.resolvedBaseRealmURL,
|
|
1038
|
+
info: this.info(ENV.resolvedBaseRealmURL),
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
token = (url: string): string | undefined => {
|
|
1043
|
+
let resource = this.knownRealm(url, { tracked: false });
|
|
1044
|
+
if (!resource && (globalThis as any).__boxelRenderContext && !isTesting()) {
|
|
1045
|
+
// prerender contexts should always reflect localStorage session state
|
|
1046
|
+
this.restoreSessionsFromStorage();
|
|
1047
|
+
resource = this.knownRealm(url, { tracked: false });
|
|
1048
|
+
}
|
|
1049
|
+
return resource?.token;
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
logout() {
|
|
1053
|
+
for (let realm of this.realms.values()) {
|
|
1054
|
+
realm.logout();
|
|
1055
|
+
}
|
|
1056
|
+
this.bulkInfoPromise = undefined;
|
|
1057
|
+
clearServiceWorkerTokens();
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
async publish(realmURL: string, publishedRealmURLs: string[]) {
|
|
1061
|
+
let resource = this.getOrCreateRealmResource(realmURL);
|
|
1062
|
+
return await resource.publish(publishedRealmURLs);
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
async fetchPrivateDependencyReport(
|
|
1066
|
+
realmURL: string,
|
|
1067
|
+
): Promise<RealmPrivateDependencyReport> {
|
|
1068
|
+
let resource = this.getOrCreateRealmResource(realmURL);
|
|
1069
|
+
return await resource.fetchPrivateDependencyReport();
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
async unpublish(realmURL: string, publishedRealmURL: string) {
|
|
1073
|
+
let resource = this.getOrCreateRealmResource(realmURL);
|
|
1074
|
+
return await resource.unpublish(publishedRealmURL);
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
async cancelIndexingJob(realmURL: string): Promise<void> {
|
|
1078
|
+
let normalizedRealmURL = ensureTrailingSlash(realmURL);
|
|
1079
|
+
let resource = this.getOrCreateRealmResource(normalizedRealmURL);
|
|
1080
|
+
await resource.login();
|
|
1081
|
+
|
|
1082
|
+
let headers = new Headers({
|
|
1083
|
+
Accept: SupportedMimeType.JSON,
|
|
1084
|
+
});
|
|
1085
|
+
if (resource.token) {
|
|
1086
|
+
headers.set('Authorization', `Bearer ${resource.token}`);
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
let response = await this.network.fetch(
|
|
1090
|
+
`${normalizedRealmURL}_cancel-indexing-job`,
|
|
1091
|
+
{
|
|
1092
|
+
method: 'POST',
|
|
1093
|
+
headers,
|
|
1094
|
+
},
|
|
1095
|
+
);
|
|
1096
|
+
|
|
1097
|
+
if (response.status === 204) {
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
let errorText = await response.text();
|
|
1102
|
+
throw new Error(
|
|
1103
|
+
`Cancel indexing job failed: ${response.status} - ${errorText}`,
|
|
1104
|
+
);
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
private beginIndexingAnimation(resource: RealmResource): boolean {
|
|
1108
|
+
let wasIndexing = resource.info?.isIndexing ?? false;
|
|
1109
|
+
if (resource.info) {
|
|
1110
|
+
resource.info.isIndexing = true;
|
|
1111
|
+
}
|
|
1112
|
+
return wasIndexing;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
private restoreIndexingAnimation(
|
|
1116
|
+
resource: RealmResource,
|
|
1117
|
+
wasIndexing: boolean,
|
|
1118
|
+
) {
|
|
1119
|
+
if (resource.info) {
|
|
1120
|
+
resource.info.isIndexing = wasIndexing;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
async reindex(realmURL: string): Promise<void> {
|
|
1125
|
+
let normalizedRealmURL = ensureTrailingSlash(realmURL);
|
|
1126
|
+
let resource = this.getOrCreateRealmResource(normalizedRealmURL);
|
|
1127
|
+
await resource.login();
|
|
1128
|
+
await resource.fetchInfo();
|
|
1129
|
+
let wasIndexing = this.beginIndexingAnimation(resource);
|
|
1130
|
+
|
|
1131
|
+
try {
|
|
1132
|
+
let headers = new Headers({
|
|
1133
|
+
Accept: SupportedMimeType.JSON,
|
|
1134
|
+
});
|
|
1135
|
+
if (resource.token) {
|
|
1136
|
+
headers.set('Authorization', `Bearer ${resource.token}`);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
let response = await this.network.fetch(`${normalizedRealmURL}_reindex`, {
|
|
1140
|
+
method: 'POST',
|
|
1141
|
+
headers,
|
|
1142
|
+
});
|
|
1143
|
+
|
|
1144
|
+
if (response.status === 204) {
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
let errorText = await response.text();
|
|
1149
|
+
throw new Error(
|
|
1150
|
+
`Reindex realm failed: ${response.status} - ${errorText}`,
|
|
1151
|
+
);
|
|
1152
|
+
} catch (error) {
|
|
1153
|
+
this.restoreIndexingAnimation(resource, wasIndexing);
|
|
1154
|
+
throw error;
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
async fullReindex(realmURL: string): Promise<void> {
|
|
1159
|
+
let normalizedRealmURL = ensureTrailingSlash(realmURL);
|
|
1160
|
+
let resource = this.getOrCreateRealmResource(normalizedRealmURL);
|
|
1161
|
+
await resource.login();
|
|
1162
|
+
await resource.fetchInfo();
|
|
1163
|
+
let wasIndexing = this.beginIndexingAnimation(resource);
|
|
1164
|
+
|
|
1165
|
+
try {
|
|
1166
|
+
let headers = new Headers({
|
|
1167
|
+
Accept: SupportedMimeType.JSON,
|
|
1168
|
+
});
|
|
1169
|
+
if (resource.token) {
|
|
1170
|
+
headers.set('Authorization', `Bearer ${resource.token}`);
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
let response = await this.network.fetch(
|
|
1174
|
+
`${normalizedRealmURL}_full-reindex`,
|
|
1175
|
+
{
|
|
1176
|
+
method: 'POST',
|
|
1177
|
+
headers,
|
|
1178
|
+
},
|
|
1179
|
+
);
|
|
1180
|
+
|
|
1181
|
+
if (response.status === 204) {
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
let errorText = await response.text();
|
|
1186
|
+
throw new Error(
|
|
1187
|
+
`Full reindex realm failed: ${response.status} - ${errorText}`,
|
|
1188
|
+
);
|
|
1189
|
+
} catch (error) {
|
|
1190
|
+
this.restoreIndexingAnimation(resource, wasIndexing);
|
|
1191
|
+
throw error;
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
async invalidateUrls(realmURL: string, urls: string[]): Promise<void> {
|
|
1196
|
+
let normalizedRealmURL = ensureTrailingSlash(realmURL);
|
|
1197
|
+
let resource = this.getOrCreateRealmResource(normalizedRealmURL);
|
|
1198
|
+
await resource.login();
|
|
1199
|
+
|
|
1200
|
+
let headers = new Headers({
|
|
1201
|
+
Accept: SupportedMimeType.JSONAPI,
|
|
1202
|
+
'Content-Type': SupportedMimeType.JSONAPI,
|
|
1203
|
+
});
|
|
1204
|
+
if (resource.token) {
|
|
1205
|
+
headers.set('Authorization', `Bearer ${resource.token}`);
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
let dedupedUrls = [...new Set(urls)];
|
|
1209
|
+
let response = await this.network.fetch(
|
|
1210
|
+
`${normalizedRealmURL}_invalidate`,
|
|
1211
|
+
{
|
|
1212
|
+
method: 'POST',
|
|
1213
|
+
headers,
|
|
1214
|
+
body: JSON.stringify({
|
|
1215
|
+
data: {
|
|
1216
|
+
type: 'invalidation-request',
|
|
1217
|
+
attributes: {
|
|
1218
|
+
urls: dedupedUrls,
|
|
1219
|
+
},
|
|
1220
|
+
},
|
|
1221
|
+
}),
|
|
1222
|
+
},
|
|
1223
|
+
);
|
|
1224
|
+
|
|
1225
|
+
if (response.status === 204) {
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
let errorText = await response.text();
|
|
1230
|
+
throw new Error(
|
|
1231
|
+
`Invalidate urls failed: ${response.status} - ${errorText}`,
|
|
1232
|
+
);
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
isUnpublishingAnyRealms = (realmURL: string): boolean => {
|
|
1236
|
+
let resource = this.getOrCreateRealmResource(realmURL);
|
|
1237
|
+
return resource.isUnpublishingAnyRealms();
|
|
1238
|
+
};
|
|
1239
|
+
|
|
1240
|
+
isUnpublishingRealm = (
|
|
1241
|
+
realmURL: string,
|
|
1242
|
+
publishedRealmURL: string,
|
|
1243
|
+
): boolean => {
|
|
1244
|
+
let resource = this.getOrCreateRealmResource(realmURL);
|
|
1245
|
+
return resource.isUnpublishingRealm(publishedRealmURL);
|
|
1246
|
+
};
|
|
1247
|
+
|
|
1248
|
+
isPublishing = (realmURL: string): boolean => {
|
|
1249
|
+
let resource = this.getOrCreateRealmResource(realmURL);
|
|
1250
|
+
return resource.isPublishing;
|
|
1251
|
+
};
|
|
1252
|
+
|
|
1253
|
+
publishingRealms = (realmURL: string): string[] => {
|
|
1254
|
+
let resource = this.getOrCreateRealmResource(realmURL);
|
|
1255
|
+
return resource.publishingRealms;
|
|
1256
|
+
};
|
|
1257
|
+
|
|
1258
|
+
// By default, this does a tracked read from currentKnownRealms so that your
|
|
1259
|
+
// answer can be invalidated if a new realm is discovered. Internally, we also
|
|
1260
|
+
// use it untracked to implement the read-through cache.
|
|
1261
|
+
private knownRealm(
|
|
1262
|
+
url: string | undefined,
|
|
1263
|
+
{ tracked = true }: { tracked?: boolean } = {},
|
|
1264
|
+
): RealmResource | undefined {
|
|
1265
|
+
if (!url) {
|
|
1266
|
+
if (tracked) {
|
|
1267
|
+
// consume a tracked property to allow invalidation when realms change
|
|
1268
|
+
void this.currentKnownRealms.size;
|
|
1269
|
+
}
|
|
1270
|
+
return undefined;
|
|
1271
|
+
}
|
|
1272
|
+
for (let [key, value] of this.realms) {
|
|
1273
|
+
if (url.startsWith(key)) {
|
|
1274
|
+
return value;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
if (tracked) {
|
|
1278
|
+
this.currentKnownRealms.has(url);
|
|
1279
|
+
}
|
|
1280
|
+
return undefined;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
async reauthenticate(realmURL: string): Promise<string | undefined> {
|
|
1284
|
+
let inProgressAuthentication = this.reauthentications.get(realmURL);
|
|
1285
|
+
if (inProgressAuthentication) {
|
|
1286
|
+
return inProgressAuthentication;
|
|
1287
|
+
}
|
|
1288
|
+
let deferred = new Deferred<string | undefined>();
|
|
1289
|
+
this.reauthentications.set(realmURL, deferred.promise);
|
|
1290
|
+
|
|
1291
|
+
let resource = this.getOrCreateRealmResource(realmURL);
|
|
1292
|
+
resource.logout();
|
|
1293
|
+
await resource.login();
|
|
1294
|
+
let result = resource.token;
|
|
1295
|
+
deferred.fulfill(result);
|
|
1296
|
+
try {
|
|
1297
|
+
return result;
|
|
1298
|
+
} finally {
|
|
1299
|
+
this.reauthentications.delete(realmURL);
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
private createRealmResource(
|
|
1304
|
+
realmURL: string,
|
|
1305
|
+
token: string | undefined,
|
|
1306
|
+
): RealmResource {
|
|
1307
|
+
let resource = new RealmResource(realmURL, token, this);
|
|
1308
|
+
setOwner(resource, getOwner(this)!);
|
|
1309
|
+
associateDestroyableChild(this, resource);
|
|
1310
|
+
return resource;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
getOrCreateRealmResource(
|
|
1314
|
+
realmURL: string,
|
|
1315
|
+
token: string | undefined = undefined,
|
|
1316
|
+
): RealmResource {
|
|
1317
|
+
// this should be the only place we do the untracked read. It needs to be
|
|
1318
|
+
// untracked so our `this._realms.set` below will not be an assertion.
|
|
1319
|
+
let resource = this.knownRealm(realmURL, { tracked: false });
|
|
1320
|
+
|
|
1321
|
+
if (resource && !resource?.token && token) {
|
|
1322
|
+
resource.token = token;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
if (!resource) {
|
|
1326
|
+
resource = this.createRealmResource(realmURL, token);
|
|
1327
|
+
this._realms.set(realmURL, resource);
|
|
1328
|
+
// only after the set has happened can we safely do the tracked read to
|
|
1329
|
+
// establish our depenency.
|
|
1330
|
+
this.currentKnownRealms.add(realmURL);
|
|
1331
|
+
}
|
|
1332
|
+
return resource;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
private identifyRealm = task(
|
|
1336
|
+
{ maxConcurrency: 1, enqueue: true },
|
|
1337
|
+
async (url: string): Promise<void> => {
|
|
1338
|
+
if (this.knownRealm(url, { tracked: false })) {
|
|
1339
|
+
// could have already been discovered while we were queued
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
let response = await this.network.authedFetch(url, {
|
|
1343
|
+
method: 'HEAD',
|
|
1344
|
+
});
|
|
1345
|
+
let realmURL = response.headers.get('x-boxel-realm-url');
|
|
1346
|
+
if (realmURL) {
|
|
1347
|
+
this.getOrCreateRealmResource(realmURL);
|
|
1348
|
+
this.identifyRealmTracker = 0;
|
|
1349
|
+
}
|
|
1350
|
+
},
|
|
1351
|
+
);
|
|
1352
|
+
|
|
1353
|
+
private restoreSessions(): Map<string, RealmResource> {
|
|
1354
|
+
let sessions: Map<string, RealmResource> = new Map();
|
|
1355
|
+
let tokens = SessionStorage.getAll();
|
|
1356
|
+
if (tokens) {
|
|
1357
|
+
syncAllTokensToServiceWorker(tokens);
|
|
1358
|
+
for (let [realmURL, token] of Object.entries(tokens)) {
|
|
1359
|
+
let resource = this.createRealmResource(realmURL, token);
|
|
1360
|
+
sessions.set(realmURL, resource);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
return sessions;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
export const tokenRefreshPeriodSec = 5 * 60; // 5 minutes
|
|
1368
|
+
|
|
1369
|
+
export function claimsFromRawToken(rawToken: string): JWTPayload {
|
|
1370
|
+
let [_header, payload] = rawToken.split('.');
|
|
1371
|
+
return JSON.parse(atob(payload)) as JWTPayload;
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
let SessionStorage = {
|
|
1375
|
+
getAll(): Record<string, string> | undefined {
|
|
1376
|
+
let sessionsString = window.localStorage.getItem(SessionLocalStorageKey);
|
|
1377
|
+
if (sessionsString) {
|
|
1378
|
+
return JSON.parse(sessionsString);
|
|
1379
|
+
}
|
|
1380
|
+
return undefined;
|
|
1381
|
+
},
|
|
1382
|
+
persist(realmURL: string, token: string | undefined) {
|
|
1383
|
+
let sessionStr =
|
|
1384
|
+
window.localStorage.getItem(SessionLocalStorageKey) ?? '{}';
|
|
1385
|
+
let session = JSON.parse(sessionStr);
|
|
1386
|
+
if (session[realmURL] !== token) {
|
|
1387
|
+
session[realmURL] = token;
|
|
1388
|
+
window.localStorage.setItem(
|
|
1389
|
+
SessionLocalStorageKey,
|
|
1390
|
+
JSON.stringify(session),
|
|
1391
|
+
);
|
|
1392
|
+
}
|
|
1393
|
+
syncTokenToServiceWorker(realmURL, token);
|
|
1394
|
+
},
|
|
1395
|
+
remove(realmURL: string) {
|
|
1396
|
+
let sessionStr =
|
|
1397
|
+
window.localStorage.getItem(SessionLocalStorageKey) ?? '{}';
|
|
1398
|
+
let session = JSON.parse(sessionStr);
|
|
1399
|
+
if (realmURL in session) {
|
|
1400
|
+
delete session[realmURL];
|
|
1401
|
+
window.localStorage.setItem(
|
|
1402
|
+
SessionLocalStorageKey,
|
|
1403
|
+
JSON.stringify(session),
|
|
1404
|
+
);
|
|
1405
|
+
}
|
|
1406
|
+
},
|
|
1407
|
+
};
|
|
1408
|
+
|
|
1409
|
+
declare module '@ember/service' {
|
|
1410
|
+
interface Registry {
|
|
1411
|
+
realm: RealmService;
|
|
1412
|
+
}
|
|
1413
|
+
}
|