@aglyn/plugins-marketplace 1.0.0-beta.291 → 1.0.0-beta.293

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/package.json +14 -14
  2. package/src/lib/components/listing-detail-editor.component.js +32 -10
  3. package/src/lib/components/listing-detail-editor.component.js.map +1 -1
  4. package/src/lib/components/listing-verification-request.component.js +32 -11
  5. package/src/lib/components/listing-verification-request.component.js.map +1 -1
  6. package/src/lib/components/org-seller-panel.component.js +121 -143
  7. package/src/lib/components/org-seller-panel.component.js.map +1 -1
  8. package/src/lib/components/publish-artifact-dialog.component.js +115 -115
  9. package/src/lib/components/publish-artifact-dialog.component.js.map +1 -1
  10. package/src/lib/components/publish-plugin-form.component.js +32 -36
  11. package/src/lib/components/publish-plugin-form.component.js.map +1 -1
  12. package/src/lib/components/publisher-agreement-checkbox.component.d.ts +56 -0
  13. package/src/lib/components/publisher-agreement-checkbox.component.js +121 -0
  14. package/src/lib/components/publisher-agreement-checkbox.component.js.map +1 -0
  15. package/src/lib/components/publisher-agreement-confirm-dialog.component.d.ts +45 -0
  16. package/src/lib/components/publisher-agreement-confirm-dialog.component.js +109 -0
  17. package/src/lib/components/publisher-agreement-confirm-dialog.component.js.map +1 -0
  18. package/src/lib/components/publisher-agreement-summary.component.d.ts +4 -3
  19. package/src/lib/components/publisher-agreement-summary.component.js +4 -3
  20. package/src/lib/components/publisher-agreement-summary.component.js.map +1 -1
  21. package/src/lib/components/starter-picker-shelf.component.d.ts +29 -0
  22. package/src/lib/components/starter-picker-shelf.component.js +317 -0
  23. package/src/lib/components/starter-picker-shelf.component.js.map +1 -0
  24. package/src/lib/declarations.server.js +2 -1
  25. package/src/lib/declarations.server.js.map +1 -1
  26. package/src/lib/hooks/use-starter-purchase.d.ts +31 -0
  27. package/src/lib/hooks/use-starter-purchase.js +101 -0
  28. package/src/lib/hooks/use-starter-purchase.js.map +1 -0
  29. package/src/lib/hooks/use-starter-search.d.ts +42 -0
  30. package/src/lib/hooks/use-starter-search.js +137 -0
  31. package/src/lib/hooks/use-starter-search.js.map +1 -0
  32. package/src/lib/model/listing-visibility.d.ts +17 -9
  33. package/src/lib/model/listing-visibility.js +18 -32
  34. package/src/lib/model/listing-visibility.js.map +1 -1
  35. package/src/lib/model/publisher-agreement.d.ts +105 -8
  36. package/src/lib/model/publisher-agreement.js +131 -24
  37. package/src/lib/model/publisher-agreement.js.map +1 -1
  38. package/src/lib/model/site-starter-listing.js +4 -1
  39. package/src/lib/model/site-starter-listing.js.map +1 -1
  40. package/src/lib/model/starter-query.d.ts +159 -0
  41. package/src/lib/model/starter-query.js +267 -0
  42. package/src/lib/model/starter-query.js.map +1 -0
  43. package/src/lib/plugin.js +12 -0
  44. package/src/lib/plugin.js.map +1 -1
  45. package/src/lib/server/checkout.js +45 -12
  46. package/src/lib/server/checkout.js.map +1 -1
  47. package/src/lib/server/preview-image.js +38 -8
  48. package/src/lib/server/preview-image.js.map +1 -1
  49. package/src/lib/server/publish-dataset-schema.js +27 -2
  50. package/src/lib/server/publish-dataset-schema.js.map +1 -1
  51. package/src/lib/server/publish-email-starter.js +27 -2
  52. package/src/lib/server/publish-email-starter.js.map +1 -1
  53. package/src/lib/server/publish-email-template.js +27 -2
  54. package/src/lib/server/publish-email-template.js.map +1 -1
  55. package/src/lib/server/publish-layout.js +27 -2
  56. package/src/lib/server/publish-layout.js.map +1 -1
  57. package/src/lib/server/publish-plugin.js +120 -14
  58. package/src/lib/server/publish-plugin.js.map +1 -1
  59. package/src/lib/server/publish-preconditions.d.ts +13 -9
  60. package/src/lib/server/publish-preconditions.js +19 -45
  61. package/src/lib/server/publish-preconditions.js.map +1 -1
  62. package/src/lib/server/publish-starter.js +27 -2
  63. package/src/lib/server/publish-starter.js.map +1 -1
  64. package/src/lib/server/publish-template.js +27 -2
  65. package/src/lib/server/publish-template.js.map +1 -1
  66. package/src/lib/server/publish-theme.js +27 -2
  67. package/src/lib/server/publish-theme.js.map +1 -1
  68. package/src/lib/server/publish.js +27 -2
  69. package/src/lib/server/publish.js.map +1 -1
  70. package/src/lib/server/publisher-agreement-acceptance.d.ts +49 -0
  71. package/src/lib/server/publisher-agreement-acceptance.js +97 -0
  72. package/src/lib/server/publisher-agreement-acceptance.js.map +1 -0
  73. package/src/lib/server/publisher-profile-save.js +46 -97
  74. package/src/lib/server/publisher-profile-save.js.map +1 -1
  75. package/src/lib/server/site-starter-source.js +97 -25
  76. package/src/lib/server/site-starter-source.js.map +1 -1
  77. package/src/lib/server/starters.d.ts +31 -0
  78. package/src/lib/server/starters.js +170 -0
  79. package/src/lib/server/starters.js.map +1 -0
  80. package/src/lib/server/verification-request.js +33 -8
  81. package/src/lib/server/verification-request.js.map +1 -1
  82. package/src/lib/server.js +14 -0
  83. package/src/lib/server.js.map +1 -1
  84. package/src/lib/components/publisher-agreement-client.d.ts +0 -48
  85. package/src/lib/components/publisher-agreement-client.js +0 -93
  86. package/src/lib/components/publisher-agreement-client.js.map +0 -1
  87. package/src/lib/components/publisher-agreement-dialog.component.d.ts +0 -47
  88. package/src/lib/components/publisher-agreement-dialog.component.js +0 -222
  89. package/src/lib/components/publisher-agreement-dialog.component.js.map +0 -1
  90. package/src/lib/components/use-publisher-agreement-gate.d.ts +0 -58
  91. package/src/lib/components/use-publisher-agreement-gate.js +0 -166
  92. package/src/lib/components/use-publisher-agreement-gate.js.map +0 -1
  93. package/src/lib/model/publisher-agreement-refusal.d.ts +0 -46
  94. package/src/lib/model/publisher-agreement-refusal.js +0 -41
  95. package/src/lib/model/publisher-agreement-refusal.js.map +0 -1
@@ -0,0 +1,159 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type { SiteStarterFacets, SiteStarterMode } from '@aglyn/aglyn/app-utils/site-starter';
18
+ import type { SiteStarterSummary } from '@aglyn/aglyn/plugin-manager/plugin-site-starters';
19
+ /**
20
+ * The starter search as a request and an answer (AGL-4049): what "Choose
21
+ * your starter" asks `GET /api/marketplace/starters`, how the route reads the
22
+ * question back, and how a card words what it shows.
23
+ *
24
+ * Pure and dependency-light on purpose, so the native apps mirror it line for
25
+ * line (phase 5's `StarterQuery`): the same parameters in the same order, the
26
+ * same defensive read of the answer, the same "Free" and "$12".
27
+ */
28
+ /** Where the console asks. */
29
+ export declare const STARTER_SEARCH_PATH = "/api/marketplace/starters";
30
+ /** The longest search a request carries; the rest is dropped, not refused. */
31
+ export declare const STARTER_SEARCH_WORD_MAX = 200;
32
+ /** The facets a search may narrow to by query parameter, in the order they are written. */
33
+ export declare const STARTER_FILTER_KEYS: readonly ["kind", "base", "fonts"];
34
+ export type StarterFilterKey = (typeof STARTER_FILTER_KEYS)[number];
35
+ /** The names the cards and the filters show for the ids a starter carries. */
36
+ export interface StarterSearchLabels {
37
+ /** A built-in theme's short name (`material3`) to the name the theme picker shows. */
38
+ base: Record<string, string>;
39
+ /** A font pairing id to its families, as a person reads them. */
40
+ fonts: Record<string, string>;
41
+ }
42
+ /** What the route answers: the starters as summaries, and the names for their ids. */
43
+ export interface StarterSearchAnswer {
44
+ rows: SiteStarterSummary[];
45
+ labels: StarterSearchLabels;
46
+ }
47
+ /** One search, as the console and the native apps build it. */
48
+ export interface StarterQueryInput {
49
+ /** The workspace the site will belong to. */
50
+ orgId: string;
51
+ /** How the site will be filled: its pages as they are, or by the AI site start. */
52
+ mode: SiteStarterMode;
53
+ /** The person's words, as typed. */
54
+ word?: string;
55
+ /** The facets the person narrowed to; an absent one is any. */
56
+ filter?: Partial<SiteStarterFacets>;
57
+ /** At most this many; the route caps it. */
58
+ limit?: number;
59
+ /**
60
+ * A listing the answer must carry whatever the search finds (AGL-4049):
61
+ * the person's own pick, restored on the way back from buying it, which a
62
+ * search for other words or another mode would not list.
63
+ */
64
+ include?: string | null;
65
+ }
66
+ /** One search, as the route reads it back, every part checked. */
67
+ export interface StarterQuery {
68
+ orgId: string;
69
+ mode: SiteStarterMode;
70
+ word: string;
71
+ /** `mode` is always among them, so the source asks for that mode only. */
72
+ filter: Partial<SiteStarterFacets>;
73
+ limit: number;
74
+ /** The listing to carry whatever the search finds, or `null`. */
75
+ include: string | null;
76
+ }
77
+ /**
78
+ * The query string for one search, its parameters always in one order —
79
+ * `orgId`, `mode`, `q`, `kind`, `base`, `fonts`, `limit`, `include` — so the
80
+ * same search is the same URL, and a hook can key a request on it.
81
+ */
82
+ export declare function starterQueryParams(input: StarterQueryInput): URLSearchParams;
83
+ /**
84
+ * The route's reading of a search, or the refusal it answers with a 400.
85
+ *
86
+ * A base theme or a font pairing is checked against the lists a starter may
87
+ * name (`SITE_STARTER_KNOWN_IDS`), and a kind against the styles a person
88
+ * chooses among (core's `SITE_STYLES`, which are the kinds of site), so a
89
+ * mistyped one is named rather than answered with nothing.
90
+ */
91
+ export declare function starterQueryFrom(params: URLSearchParams): StarterQuery | {
92
+ error: string;
93
+ };
94
+ /**
95
+ * One starter as a card shows it, read field by field, or `null` for a row
96
+ * with no listing id.
97
+ *
98
+ * The route answers each row through this, as the console and the apps read
99
+ * it, so what leaves the server is a summary and nothing else: a source that
100
+ * handed back a paid AI starter's answers, or its pages, would have them
101
+ * dropped here. Each field falls back the way a card needs it to: a missing
102
+ * price is free, a missing picture is none, a page count is a whole number
103
+ * from zero, a mode is `base` unless it says `ai`, and `owned` is kept only
104
+ * where the answer gave it as a yes or a no.
105
+ */
106
+ export declare function readStarterSummary(value: unknown): SiteStarterSummary | null;
107
+ /**
108
+ * The route's answer, read defensively: rows that are not starters are
109
+ * dropped, as is a duplicate of a listing already read, and missing labels
110
+ * are empty. Never throws, whatever it is handed.
111
+ */
112
+ export declare function parseStarterSearchAnswer(json: unknown): StarterSearchAnswer;
113
+ /**
114
+ * A starter's price as a card shows it: "Free" at zero, whole dollars as
115
+ * "$12", and cents only where there are some ("$12.50").
116
+ */
117
+ export declare function starterPriceLabel(usd: number): string;
118
+ /** How many pages a starter creates, as a card says it, or `null` when it does not say. */
119
+ export declare function starterPagesLabel(pages: number): string | null;
120
+ /** One fact a starter's card shows as a chip, keyed so a surface can style each kind its own way. */
121
+ export interface StarterCardFact {
122
+ key: 'price' | 'official' | 'ai' | 'kind' | 'pages';
123
+ label: string;
124
+ }
125
+ /**
126
+ * The chips on a starter's card, in the order they are read: the price,
127
+ * every card carrying one ("Free" included, so a missing chip never reads as
128
+ * a forgotten price); the platform's name for its own; "AI" for a starter the
129
+ * AI site start fills; the kind of site in words; and its page count.
130
+ *
131
+ * The kind is the style's own name for the listing's kind of site (core's
132
+ * `SITE_STYLES`), the same words the kind filters show — never the listing's
133
+ * marketplace category, which for a starter that names no kind is a shelf
134
+ * of the marketplace (`design`), not a kind of site.
135
+ */
136
+ export declare function starterCardFacts(row: SiteStarterSummary): StarterCardFact[];
137
+ /** Where a purchase is opened. */
138
+ export declare const STARTER_CHECKOUT_PATH = "/api/marketplace/checkout";
139
+ /**
140
+ * The one place other than the marketplace a purchase may send its buyer
141
+ * back to (AGL-4049): Create site, reopened on the starter they picked. A
142
+ * name the checkout turns into an address itself, never an address the
143
+ * browser hands it.
144
+ */
145
+ export declare const STARTER_CHECKOUT_RETURN = "create-site";
146
+ export type StarterCheckoutReturn = typeof STARTER_CHECKOUT_RETURN;
147
+ /**
148
+ * A checkout body's `return`, read: `create-site`, `null` when it names none
149
+ * (the marketplace, as always), or the refusal a 400 answers with.
150
+ */
151
+ export declare function readStarterCheckoutReturn(value: unknown): StarterCheckoutReturn | null | {
152
+ error: string;
153
+ };
154
+ /** The body "Buy and continue" sends: the starter, the workspace buying it, and the way back. */
155
+ export declare function starterCheckoutBody(input: {
156
+ listingId: string;
157
+ orgId: string;
158
+ gaClientId?: string | null;
159
+ }): Record<string, string>;
@@ -0,0 +1,267 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ /**
3
+ * @license
4
+ * Copyright 2026 Aglyn LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */ import { PLATFORM_BRAND_NAME } from "@aglyn/aglyn/app-utils/platform-brand";
18
+ import { isSiteStyleId, siteStyleOf } from "@aglyn/aglyn/app-utils/site-styles";
19
+ import { SITE_STARTER_KNOWN_IDS, SITE_STARTER_SEARCH_MAX, siteStarterSearchLimit } from "./site-starter-listing.js";
20
+ /**
21
+ * The starter search as a request and an answer (AGL-4049): what "Choose
22
+ * your starter" asks `GET /api/marketplace/starters`, how the route reads the
23
+ * question back, and how a card words what it shows.
24
+ *
25
+ * Pure and dependency-light on purpose, so the native apps mirror it line for
26
+ * line (phase 5's `StarterQuery`): the same parameters in the same order, the
27
+ * same defensive read of the answer, the same "Free" and "$12".
28
+ */ /** Where the console asks. */ export const STARTER_SEARCH_PATH = '/api/marketplace/starters';
29
+ /** The longest search a request carries; the rest is dropped, not refused. */ export const STARTER_SEARCH_WORD_MAX = 200;
30
+ /** The facets a search may narrow to by query parameter, in the order they are written. */ export const STARTER_FILTER_KEYS = [
31
+ 'kind',
32
+ 'base',
33
+ 'fonts'
34
+ ];
35
+ const ORG_ID = /^[A-Za-z0-9_-]{1,128}$/;
36
+ const LISTING_ID = /^[A-Za-z0-9_-]{1,128}$/;
37
+ const FACET_ID = /^[a-z0-9][a-z0-9-]{0,63}$/;
38
+ const trimmed = (value)=>typeof value === 'string' ? value.trim() : '';
39
+ /**
40
+ * The query string for one search, its parameters always in one order —
41
+ * `orgId`, `mode`, `q`, `kind`, `base`, `fonts`, `limit`, `include` — so the
42
+ * same search is the same URL, and a hook can key a request on it.
43
+ */ export function starterQueryParams(input) {
44
+ var _input_limit;
45
+ const params = new URLSearchParams();
46
+ params.set('orgId', trimmed(input.orgId));
47
+ params.set('mode', input.mode === 'ai' ? 'ai' : 'base');
48
+ const word = trimmed(input.word).slice(0, STARTER_SEARCH_WORD_MAX);
49
+ if (word) params.set('q', word);
50
+ for (const key of STARTER_FILTER_KEYS){
51
+ var _input_filter;
52
+ const value = trimmed((_input_filter = input.filter) == null ? void 0 : _input_filter[key]);
53
+ if (value) params.set(key, value);
54
+ }
55
+ params.set('limit', String(siteStarterSearchLimit((_input_limit = input.limit) != null ? _input_limit : SITE_STARTER_SEARCH_MAX) || SITE_STARTER_SEARCH_MAX));
56
+ const include = trimmed(input.include);
57
+ if (LISTING_ID.test(include)) params.set('include', include);
58
+ return params;
59
+ }
60
+ /**
61
+ * The route's reading of a search, or the refusal it answers with a 400.
62
+ *
63
+ * A base theme or a font pairing is checked against the lists a starter may
64
+ * name (`SITE_STARTER_KNOWN_IDS`), and a kind against the styles a person
65
+ * chooses among (core's `SITE_STYLES`, which are the kinds of site), so a
66
+ * mistyped one is named rather than answered with nothing.
67
+ */ export function starterQueryFrom(params) {
68
+ const orgId = trimmed(params.get('orgId'));
69
+ if (!ORG_ID.test(orgId)) return {
70
+ error: 'Missing orgId'
71
+ };
72
+ const askedMode = trimmed(params.get('mode'));
73
+ if (askedMode && askedMode !== 'base' && askedMode !== 'ai') {
74
+ return {
75
+ error: 'Unknown mode'
76
+ };
77
+ }
78
+ const mode = askedMode === 'ai' ? 'ai' : 'base';
79
+ const filter = {
80
+ mode
81
+ };
82
+ const kind = trimmed(params.get('kind'));
83
+ if (kind) {
84
+ if (!FACET_ID.test(kind) || !isSiteStyleId(kind)) return {
85
+ error: 'Unknown kind of site'
86
+ };
87
+ filter.kind = kind;
88
+ }
89
+ const base = trimmed(params.get('base'));
90
+ if (base) {
91
+ var _SITE_STARTER_KNOWN_IDS_bases;
92
+ if (!((_SITE_STARTER_KNOWN_IDS_bases = SITE_STARTER_KNOWN_IDS.bases) == null ? void 0 : _SITE_STARTER_KNOWN_IDS_bases.has(base))) return {
93
+ error: 'Unknown base theme'
94
+ };
95
+ filter.base = base;
96
+ }
97
+ const fonts = trimmed(params.get('fonts'));
98
+ if (fonts) {
99
+ var _SITE_STARTER_KNOWN_IDS_fonts;
100
+ if (!((_SITE_STARTER_KNOWN_IDS_fonts = SITE_STARTER_KNOWN_IDS.fonts) == null ? void 0 : _SITE_STARTER_KNOWN_IDS_fonts.has(fonts))) return {
101
+ error: 'Unknown font pairing'
102
+ };
103
+ filter.fonts = fonts;
104
+ }
105
+ const include = trimmed(params.get('include'));
106
+ if (include && !LISTING_ID.test(include)) return {
107
+ error: 'Unknown starter'
108
+ };
109
+ return {
110
+ orgId,
111
+ mode,
112
+ word: trimmed(params.get('q')).slice(0, STARTER_SEARCH_WORD_MAX),
113
+ filter,
114
+ limit: siteStarterSearchLimit(params.get('limit')) || SITE_STARTER_SEARCH_MAX,
115
+ include: include || null
116
+ };
117
+ }
118
+ const isRecord = (value)=>!!value && typeof value === 'object' && !Array.isArray(value);
119
+ const textOr = (value, fallback)=>typeof value === 'string' ? value : fallback;
120
+ const idOrNull = (value)=>typeof value === 'string' && value.trim() ? value.trim() : null;
121
+ /**
122
+ * One starter as a card shows it, read field by field, or `null` for a row
123
+ * with no listing id.
124
+ *
125
+ * The route answers each row through this, as the console and the apps read
126
+ * it, so what leaves the server is a summary and nothing else: a source that
127
+ * handed back a paid AI starter's answers, or its pages, would have them
128
+ * dropped here. Each field falls back the way a card needs it to: a missing
129
+ * price is free, a missing picture is none, a page count is a whole number
130
+ * from zero, a mode is `base` unless it says `ai`, and `owned` is kept only
131
+ * where the answer gave it as a yes or a no.
132
+ */ export function readStarterSummary(value) {
133
+ if (!isRecord(value)) return null;
134
+ const listingId = idOrNull(value['listingId']);
135
+ if (!listingId) return null;
136
+ const price = Number(value['priceUsd']);
137
+ const facets = isRecord(value['facets']) ? value['facets'] : {};
138
+ const pages = Number(facets['pages']);
139
+ const preview = value['previewImageUrl'];
140
+ return _extends({
141
+ listingId,
142
+ displayName: textOr(value['displayName'], ''),
143
+ description: textOr(value['description'], ''),
144
+ authorName: textOr(value['authorName'], ''),
145
+ official: value['official'] === true,
146
+ priceUsd: Number.isFinite(price) && price > 0 ? price : 0,
147
+ previewImageUrl: typeof preview === 'string' && preview ? preview : null,
148
+ facets: {
149
+ kind: idOrNull(facets['kind']),
150
+ base: idOrNull(facets['base']),
151
+ fonts: idOrNull(facets['fonts']),
152
+ pages: Number.isFinite(pages) && pages > 0 ? Math.floor(pages) : 0,
153
+ mode: facets['mode'] === 'ai' ? 'ai' : 'base'
154
+ },
155
+ category: idOrNull(value['category'])
156
+ }, typeof value['owned'] === 'boolean' ? {
157
+ owned: value['owned']
158
+ } : {});
159
+ }
160
+ /** A map of id to name, keeping only string names under non-empty ids. */ const namesOf = (value)=>{
161
+ if (!isRecord(value)) return {};
162
+ const names = {};
163
+ for (const [id, name] of Object.entries(value)){
164
+ if (id && typeof name === 'string' && name) names[id] = name;
165
+ }
166
+ return names;
167
+ };
168
+ /**
169
+ * The route's answer, read defensively: rows that are not starters are
170
+ * dropped, as is a duplicate of a listing already read, and missing labels
171
+ * are empty. Never throws, whatever it is handed.
172
+ */ export function parseStarterSearchAnswer(json) {
173
+ const body = isRecord(json) ? json : {};
174
+ const seen = new Set();
175
+ const rows = [];
176
+ for (const value of Array.isArray(body['rows']) ? body['rows'] : []){
177
+ const row = readStarterSummary(value);
178
+ if (!row || seen.has(row.listingId)) continue;
179
+ seen.add(row.listingId);
180
+ rows.push(row);
181
+ }
182
+ const labels = isRecord(body['labels']) ? body['labels'] : {};
183
+ return {
184
+ rows,
185
+ labels: {
186
+ base: namesOf(labels['base']),
187
+ fonts: namesOf(labels['fonts'])
188
+ }
189
+ };
190
+ }
191
+ /**
192
+ * A starter's price as a card shows it: "Free" at zero, whole dollars as
193
+ * "$12", and cents only where there are some ("$12.50").
194
+ */ export function starterPriceLabel(usd) {
195
+ if (!Number.isFinite(usd) || usd <= 0) return 'Free';
196
+ return Number.isInteger(usd) ? `$${usd}` : `$${usd.toFixed(2)}`;
197
+ }
198
+ /** How many pages a starter creates, as a card says it, or `null` when it does not say. */ export function starterPagesLabel(pages) {
199
+ if (!Number.isFinite(pages) || pages < 1) return null;
200
+ const whole = Math.floor(pages);
201
+ return whole === 1 ? '1 page' : `${whole} pages`;
202
+ }
203
+ /**
204
+ * The chips on a starter's card, in the order they are read: the price,
205
+ * every card carrying one ("Free" included, so a missing chip never reads as
206
+ * a forgotten price); the platform's name for its own; "AI" for a starter the
207
+ * AI site start fills; the kind of site in words; and its page count.
208
+ *
209
+ * The kind is the style's own name for the listing's kind of site (core's
210
+ * `SITE_STYLES`), the same words the kind filters show — never the listing's
211
+ * marketplace category, which for a starter that names no kind is a shelf
212
+ * of the marketplace (`design`), not a kind of site.
213
+ */ export function starterCardFacts(row) {
214
+ var _siteStyleOf;
215
+ const facts = [
216
+ {
217
+ key: 'price',
218
+ label: starterPriceLabel(row.priceUsd)
219
+ }
220
+ ];
221
+ if (row.official) facts.push({
222
+ key: 'official',
223
+ label: PLATFORM_BRAND_NAME
224
+ });
225
+ if (row.facets.mode === 'ai') facts.push({
226
+ key: 'ai',
227
+ label: 'AI'
228
+ });
229
+ const kind = (_siteStyleOf = siteStyleOf(row.facets.kind)) == null ? void 0 : _siteStyleOf.name;
230
+ if (kind) facts.push({
231
+ key: 'kind',
232
+ label: kind
233
+ });
234
+ const pages = starterPagesLabel(row.facets.pages);
235
+ if (pages) facts.push({
236
+ key: 'pages',
237
+ label: pages
238
+ });
239
+ return facts;
240
+ }
241
+ /** Where a purchase is opened. */ export const STARTER_CHECKOUT_PATH = '/api/marketplace/checkout';
242
+ /**
243
+ * The one place other than the marketplace a purchase may send its buyer
244
+ * back to (AGL-4049): Create site, reopened on the starter they picked. A
245
+ * name the checkout turns into an address itself, never an address the
246
+ * browser hands it.
247
+ */ export const STARTER_CHECKOUT_RETURN = 'create-site';
248
+ /**
249
+ * A checkout body's `return`, read: `create-site`, `null` when it names none
250
+ * (the marketplace, as always), or the refusal a 400 answers with.
251
+ */ export function readStarterCheckoutReturn(value) {
252
+ if (value === undefined || value === null || value === '') return null;
253
+ return value === STARTER_CHECKOUT_RETURN ? STARTER_CHECKOUT_RETURN : {
254
+ error: 'Unknown return'
255
+ };
256
+ }
257
+ /** The body "Buy and continue" sends: the starter, the workspace buying it, and the way back. */ export function starterCheckoutBody(input) {
258
+ return _extends({
259
+ listingId: input.listingId,
260
+ orgId: input.orgId,
261
+ return: STARTER_CHECKOUT_RETURN
262
+ }, input.gaClientId ? {
263
+ gaClientId: input.gaClientId
264
+ } : {});
265
+ }
266
+
267
+ //# sourceMappingURL=starter-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/model/starter-query.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PLATFORM_BRAND_NAME } from '@aglyn/aglyn/app-utils/platform-brand'\nimport { isSiteStyleId, siteStyleOf } from '@aglyn/aglyn/app-utils/site-styles'\nimport type {\n SiteStarterFacets,\n SiteStarterMode,\n} from '@aglyn/aglyn/app-utils/site-starter'\nimport type { SiteStarterSummary } from '@aglyn/aglyn/plugin-manager/plugin-site-starters'\nimport {\n SITE_STARTER_KNOWN_IDS,\n SITE_STARTER_SEARCH_MAX,\n siteStarterSearchLimit,\n} from './site-starter-listing'\n\n/**\n * The starter search as a request and an answer (AGL-4049): what \"Choose\n * your starter\" asks `GET /api/marketplace/starters`, how the route reads the\n * question back, and how a card words what it shows.\n *\n * Pure and dependency-light on purpose, so the native apps mirror it line for\n * line (phase 5's `StarterQuery`): the same parameters in the same order, the\n * same defensive read of the answer, the same \"Free\" and \"$12\".\n */\n\n/** Where the console asks. */\nexport const STARTER_SEARCH_PATH = '/api/marketplace/starters'\n\n/** The longest search a request carries; the rest is dropped, not refused. */\nexport const STARTER_SEARCH_WORD_MAX = 200\n\n/** The facets a search may narrow to by query parameter, in the order they are written. */\nexport const STARTER_FILTER_KEYS = ['kind', 'base', 'fonts'] as const\nexport type StarterFilterKey = (typeof STARTER_FILTER_KEYS)[number]\n\n/** The names the cards and the filters show for the ids a starter carries. */\nexport interface StarterSearchLabels {\n /** A built-in theme's short name (`material3`) to the name the theme picker shows. */\n base: Record<string, string>\n /** A font pairing id to its families, as a person reads them. */\n fonts: Record<string, string>\n}\n\n/** What the route answers: the starters as summaries, and the names for their ids. */\nexport interface StarterSearchAnswer {\n rows: SiteStarterSummary[]\n labels: StarterSearchLabels\n}\n\n/** One search, as the console and the native apps build it. */\nexport interface StarterQueryInput {\n /** The workspace the site will belong to. */\n orgId: string\n /** How the site will be filled: its pages as they are, or by the AI site start. */\n mode: SiteStarterMode\n /** The person's words, as typed. */\n word?: string\n /** The facets the person narrowed to; an absent one is any. */\n filter?: Partial<SiteStarterFacets>\n /** At most this many; the route caps it. */\n limit?: number\n /**\n * A listing the answer must carry whatever the search finds (AGL-4049):\n * the person's own pick, restored on the way back from buying it, which a\n * search for other words or another mode would not list.\n */\n include?: string | null\n}\n\n/** One search, as the route reads it back, every part checked. */\nexport interface StarterQuery {\n orgId: string\n mode: SiteStarterMode\n word: string\n /** `mode` is always among them, so the source asks for that mode only. */\n filter: Partial<SiteStarterFacets>\n limit: number\n /** The listing to carry whatever the search finds, or `null`. */\n include: string | null\n}\n\nconst ORG_ID = /^[A-Za-z0-9_-]{1,128}$/\nconst LISTING_ID = /^[A-Za-z0-9_-]{1,128}$/\nconst FACET_ID = /^[a-z0-9][a-z0-9-]{0,63}$/\n\nconst trimmed = (value: unknown): string =>\n typeof value === 'string' ? value.trim() : ''\n\n/**\n * The query string for one search, its parameters always in one order —\n * `orgId`, `mode`, `q`, `kind`, `base`, `fonts`, `limit`, `include` — so the\n * same search is the same URL, and a hook can key a request on it.\n */\nexport function starterQueryParams(input: StarterQueryInput): URLSearchParams {\n const params = new URLSearchParams()\n params.set('orgId', trimmed(input.orgId))\n params.set('mode', input.mode === 'ai' ? 'ai' : 'base')\n const word = trimmed(input.word).slice(0, STARTER_SEARCH_WORD_MAX)\n if (word) params.set('q', word)\n for (const key of STARTER_FILTER_KEYS) {\n const value = trimmed(input.filter?.[key])\n if (value) params.set(key, value)\n }\n params.set(\n 'limit',\n String(siteStarterSearchLimit(input.limit ?? SITE_STARTER_SEARCH_MAX) || SITE_STARTER_SEARCH_MAX),\n )\n const include = trimmed(input.include)\n if (LISTING_ID.test(include)) params.set('include', include)\n return params\n}\n\n/**\n * The route's reading of a search, or the refusal it answers with a 400.\n *\n * A base theme or a font pairing is checked against the lists a starter may\n * name (`SITE_STARTER_KNOWN_IDS`), and a kind against the styles a person\n * chooses among (core's `SITE_STYLES`, which are the kinds of site), so a\n * mistyped one is named rather than answered with nothing.\n */\nexport function starterQueryFrom(\n params: URLSearchParams,\n): StarterQuery | { error: string } {\n const orgId = trimmed(params.get('orgId'))\n if (!ORG_ID.test(orgId)) return { error: 'Missing orgId' }\n const askedMode = trimmed(params.get('mode'))\n if (askedMode && askedMode !== 'base' && askedMode !== 'ai') {\n return { error: 'Unknown mode' }\n }\n const mode: SiteStarterMode = askedMode === 'ai' ? 'ai' : 'base'\n const filter: Partial<SiteStarterFacets> = { mode }\n const kind = trimmed(params.get('kind'))\n if (kind) {\n if (!FACET_ID.test(kind) || !isSiteStyleId(kind)) return { error: 'Unknown kind of site' }\n filter.kind = kind\n }\n const base = trimmed(params.get('base'))\n if (base) {\n if (!SITE_STARTER_KNOWN_IDS.bases?.has(base)) return { error: 'Unknown base theme' }\n filter.base = base\n }\n const fonts = trimmed(params.get('fonts'))\n if (fonts) {\n if (!SITE_STARTER_KNOWN_IDS.fonts?.has(fonts)) return { error: 'Unknown font pairing' }\n filter.fonts = fonts\n }\n const include = trimmed(params.get('include'))\n if (include && !LISTING_ID.test(include)) return { error: 'Unknown starter' }\n return {\n orgId,\n mode,\n word: trimmed(params.get('q')).slice(0, STARTER_SEARCH_WORD_MAX),\n filter,\n limit: siteStarterSearchLimit(params.get('limit')) || SITE_STARTER_SEARCH_MAX,\n include: include || null,\n }\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n !!value && typeof value === 'object' && !Array.isArray(value)\n\nconst textOr = (value: unknown, fallback: string): string =>\n typeof value === 'string' ? value : fallback\n\nconst idOrNull = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() ? value.trim() : null\n\n/**\n * One starter as a card shows it, read field by field, or `null` for a row\n * with no listing id.\n *\n * The route answers each row through this, as the console and the apps read\n * it, so what leaves the server is a summary and nothing else: a source that\n * handed back a paid AI starter's answers, or its pages, would have them\n * dropped here. Each field falls back the way a card needs it to: a missing\n * price is free, a missing picture is none, a page count is a whole number\n * from zero, a mode is `base` unless it says `ai`, and `owned` is kept only\n * where the answer gave it as a yes or a no.\n */\nexport function readStarterSummary(value: unknown): SiteStarterSummary | null {\n if (!isRecord(value)) return null\n const listingId = idOrNull(value['listingId'])\n if (!listingId) return null\n const price = Number(value['priceUsd'])\n const facets = isRecord(value['facets']) ? value['facets'] : {}\n const pages = Number(facets['pages'])\n const preview = value['previewImageUrl']\n return {\n listingId,\n displayName: textOr(value['displayName'], ''),\n description: textOr(value['description'], ''),\n authorName: textOr(value['authorName'], ''),\n official: value['official'] === true,\n priceUsd: Number.isFinite(price) && price > 0 ? price : 0,\n previewImageUrl: typeof preview === 'string' && preview ? preview : null,\n facets: {\n kind: idOrNull(facets['kind']),\n base: idOrNull(facets['base']),\n fonts: idOrNull(facets['fonts']),\n pages: Number.isFinite(pages) && pages > 0 ? Math.floor(pages) : 0,\n mode: facets['mode'] === 'ai' ? 'ai' : 'base',\n },\n category: idOrNull(value['category']),\n // Only where the answer says: absent is \"the search does not know\".\n ...(typeof value['owned'] === 'boolean' ? { owned: value['owned'] } : {}),\n }\n}\n\n/** A map of id to name, keeping only string names under non-empty ids. */\nconst namesOf = (value: unknown): Record<string, string> => {\n if (!isRecord(value)) return {}\n const names: Record<string, string> = {}\n for (const [id, name] of Object.entries(value)) {\n if (id && typeof name === 'string' && name) names[id] = name\n }\n return names\n}\n\n/**\n * The route's answer, read defensively: rows that are not starters are\n * dropped, as is a duplicate of a listing already read, and missing labels\n * are empty. Never throws, whatever it is handed.\n */\nexport function parseStarterSearchAnswer(json: unknown): StarterSearchAnswer {\n const body = isRecord(json) ? json : {}\n const seen = new Set<string>()\n const rows: SiteStarterSummary[] = []\n for (const value of Array.isArray(body['rows']) ? body['rows'] : []) {\n const row = readStarterSummary(value)\n if (!row || seen.has(row.listingId)) continue\n seen.add(row.listingId)\n rows.push(row)\n }\n const labels = isRecord(body['labels']) ? body['labels'] : {}\n return { rows, labels: { base: namesOf(labels['base']), fonts: namesOf(labels['fonts']) } }\n}\n\n/**\n * A starter's price as a card shows it: \"Free\" at zero, whole dollars as\n * \"$12\", and cents only where there are some (\"$12.50\").\n */\nexport function starterPriceLabel(usd: number): string {\n if (!Number.isFinite(usd) || usd <= 0) return 'Free'\n return Number.isInteger(usd) ? `$${usd}` : `$${usd.toFixed(2)}`\n}\n\n/** How many pages a starter creates, as a card says it, or `null` when it does not say. */\nexport function starterPagesLabel(pages: number): string | null {\n if (!Number.isFinite(pages) || pages < 1) return null\n const whole = Math.floor(pages)\n return whole === 1 ? '1 page' : `${whole} pages`\n}\n\n/** One fact a starter's card shows as a chip, keyed so a surface can style each kind its own way. */\nexport interface StarterCardFact {\n key: 'price' | 'official' | 'ai' | 'kind' | 'pages'\n label: string\n}\n\n/**\n * The chips on a starter's card, in the order they are read: the price,\n * every card carrying one (\"Free\" included, so a missing chip never reads as\n * a forgotten price); the platform's name for its own; \"AI\" for a starter the\n * AI site start fills; the kind of site in words; and its page count.\n *\n * The kind is the style's own name for the listing's kind of site (core's\n * `SITE_STYLES`), the same words the kind filters show — never the listing's\n * marketplace category, which for a starter that names no kind is a shelf\n * of the marketplace (`design`), not a kind of site.\n */\nexport function starterCardFacts(row: SiteStarterSummary): StarterCardFact[] {\n const facts: StarterCardFact[] = [{ key: 'price', label: starterPriceLabel(row.priceUsd) }]\n if (row.official) facts.push({ key: 'official', label: PLATFORM_BRAND_NAME })\n if (row.facets.mode === 'ai') facts.push({ key: 'ai', label: 'AI' })\n const kind = siteStyleOf(row.facets.kind)?.name\n if (kind) facts.push({ key: 'kind', label: kind })\n const pages = starterPagesLabel(row.facets.pages)\n if (pages) facts.push({ key: 'pages', label: pages })\n return facts\n}\n\n/** Where a purchase is opened. */\nexport const STARTER_CHECKOUT_PATH = '/api/marketplace/checkout'\n\n/**\n * The one place other than the marketplace a purchase may send its buyer\n * back to (AGL-4049): Create site, reopened on the starter they picked. A\n * name the checkout turns into an address itself, never an address the\n * browser hands it.\n */\nexport const STARTER_CHECKOUT_RETURN = 'create-site'\nexport type StarterCheckoutReturn = typeof STARTER_CHECKOUT_RETURN\n\n/**\n * A checkout body's `return`, read: `create-site`, `null` when it names none\n * (the marketplace, as always), or the refusal a 400 answers with.\n */\nexport function readStarterCheckoutReturn(value: unknown): StarterCheckoutReturn | null | { error: string } {\n if (value === undefined || value === null || value === '') return null\n return value === STARTER_CHECKOUT_RETURN ? STARTER_CHECKOUT_RETURN : { error: 'Unknown return' }\n}\n\n/** The body \"Buy and continue\" sends: the starter, the workspace buying it, and the way back. */\nexport function starterCheckoutBody(input: {\n listingId: string\n orgId: string\n gaClientId?: string | null\n}): Record<string, string> {\n return {\n listingId: input.listingId,\n orgId: input.orgId,\n return: STARTER_CHECKOUT_RETURN,\n ...(input.gaClientId ? { gaClientId: input.gaClientId } : {}),\n }\n}\n"],"names":["PLATFORM_BRAND_NAME","isSiteStyleId","siteStyleOf","SITE_STARTER_KNOWN_IDS","SITE_STARTER_SEARCH_MAX","siteStarterSearchLimit","STARTER_SEARCH_PATH","STARTER_SEARCH_WORD_MAX","STARTER_FILTER_KEYS","ORG_ID","LISTING_ID","FACET_ID","trimmed","value","trim","starterQueryParams","input","params","URLSearchParams","set","orgId","mode","word","slice","key","filter","String","limit","include","test","starterQueryFrom","get","error","askedMode","kind","base","bases","has","fonts","isRecord","Array","isArray","textOr","fallback","idOrNull","readStarterSummary","listingId","price","Number","facets","pages","preview","displayName","description","authorName","official","priceUsd","isFinite","previewImageUrl","Math","floor","category","owned","namesOf","names","id","name","Object","entries","parseStarterSearchAnswer","json","body","seen","Set","rows","row","add","push","labels","starterPriceLabel","usd","isInteger","toFixed","starterPagesLabel","whole","starterCardFacts","facts","label","STARTER_CHECKOUT_PATH","STARTER_CHECKOUT_RETURN","readStarterCheckoutReturn","undefined","starterCheckoutBody","return","gaClientId"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,aAAa,EAAEC,WAAW,QAAQ,qCAAoC;AAM/E,SACEC,sBAAsB,EACtBC,uBAAuB,EACvBC,sBAAsB,QACjB,4BAAwB;AAE/B;;;;;;;;CAQC,GAED,4BAA4B,GAC5B,OAAO,MAAMC,sBAAsB,4BAA2B;AAE9D,4EAA4E,GAC5E,OAAO,MAAMC,0BAA0B,IAAG;AAE1C,yFAAyF,GACzF,OAAO,MAAMC,sBAAsB;IAAC;IAAQ;IAAQ;CAAQ,CAAS;AAiDrE,MAAMC,SAAS;AACf,MAAMC,aAAa;AACnB,MAAMC,WA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CHANGED
@@ -24,6 +24,7 @@ import PluginSiteSetPanel from "./components/plugin-site-set-panel.component.js"
24
24
  import OrgPluginInstallsCard from "./components/org-plugin-installs-card.component.js";
25
25
  import PluginInstallStatus from "./components/plugin-install-status.component.js";
26
26
  import StaffMarketplaceOverview from "./components/staff-marketplace-overview.component.js";
27
+ import StarterPickerShelf from "./components/starter-picker-shelf.component.js";
27
28
  import TemplateGalleryShelf from "./components/template-gallery-shelf.component.js";
28
29
  import TemplateInstallStatus from "./components/template-install-status.component.js";
29
30
  import PublishArtifactDialog from "./components/publish-artifact-dialog.component.js";
@@ -111,6 +112,17 @@ import RatingInput from "./components/rating-input.component.js";
111
112
  slot: 'templateInstallStatus',
112
113
  widgetId: 'marketplace-template-install-status',
113
114
  Component: TemplateInstallStatus
115
+ },
116
+ // "Choose your starter" in Create site (AGL-4049): the marketplace's
117
+ // site starters, searched and picked before the site exists. It lists
118
+ // and picks; the dialog creates. Searching is the first step of
119
+ // creating a site, so it takes the create's permission, as its route
120
+ // does; the route also answers the release flag.
121
+ {
122
+ slot: 'hostStarterPicker',
123
+ widgetId: 'marketplace-starter-picker',
124
+ permission: 'hosts.create',
125
+ Component: StarterPickerShelf
114
126
  }
115
127
  ],
116
128
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/plugins/marketplace/src/lib/plugin.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { ICON_VARIANT_SYMBOL_FLAG } from '@aglyn/shared-data-enums'\nimport { mdiStorefrontOutline } from '@aglyn/shared-data-mdi'\nimport MarketplaceBrowse from './components/marketplace-browse.component'\nimport MarketplaceHub from './components/marketplace-hub.component'\nimport MarketplaceReportsPage from './components/marketplace-reports-page.component'\nimport PluginReviewsSurface from './components/plugin-reviews-surface.component'\nimport MarketplacePaymentsNotice from './components/marketplace-payments-notice.component'\nimport HostPluginsCard from './components/host-plugins-card.component'\nimport PluginSiteSetPanel from './components/plugin-site-set-panel.component'\nimport OrgPluginInstallsCard from './components/org-plugin-installs-card.component'\nimport PluginInstallStatus from './components/plugin-install-status.component'\nimport StaffMarketplaceOverview from './components/staff-marketplace-overview.component'\nimport TemplateGalleryShelf from './components/template-gallery-shelf.component'\nimport TemplateInstallStatus from './components/template-install-status.component'\nimport PublishArtifactDialog from './components/publish-artifact-dialog.component'\nimport { MarketplaceListingContent } from './components/listing-content.component'\nimport { BUNDLE_ID } from './constants/bundle-common'\nimport { MARKETPLACE_LICENSES_SECTION_ID } from './model/marketplace-section-ids'\nimport { RATING_FIELD } from './model/rating-field'\nimport RatingInput from './components/rating-input.component'\n\n/**\n * Marketplace feature plugin (AGL-395). Console-only — marketplace components\n * install into a host's own components collection and render through the\n * normal compose pipeline, so there is no separate canvas bundle.\n *\n * The marketplace moved to org scope (AGL-772/774): browse + install live at\n * `/[orgSlug]/marketplace`, so this plugin no longer contributes a per-site\n * `Marketplace` nav tab (AGL-775). It exposes its UI purely through widget\n * slots — `orgMarketplace` (browse), `marketplaceListing` (detail) and\n * `orgAddons` (installed) — which the app renders without importing the\n * plugin.\n */\nexport function registerMarketplaceConsole(): void {\n // Custom field type (AGL-434): rating rides int32 with a starred input.\n Aglyn.registerCustomFieldType({ ...RATING_FIELD, Input: RatingInput })\n Aglyn.registerConsoleExtension({\n /*\n * Four widgets fewer since AGL-3080 — the listing body, the capability\n * notice, browse, and installed add-ons. Their zones existed for one\n * reason: a CONSOLE ROUTE had to show them and an app may not import a\n * plugin. The hub is this plugin's own surface now, so those components\n * are plain imports and the four zones are gone from the catalog.\n *\n * What is left is what a console page OTHER than the marketplace draws.\n */\n widgets: [\n // The site set for one installation (AGL-1007): the same control the\n // listing page uses, exposed so the installation detail page can show\n // it without the app importing this plugin.\n {\n slot: 'pluginSiteSet',\n widgetId: 'marketplace-plugin-site-set',\n Component: PluginSiteSetPanel,\n },\n // Publishing something the console holds (AGL-3080). The page that\n // offers it keeps the control that opens it — a menu item is one entry\n // of a list the page builds, not a widget — and hands over what it has\n // in its own vocabulary. Where a layout or a theme GOES, what a listing\n // of it is called and what it may cost at the least are this plugin's.\n {\n slot: 'hostArtifactPublish',\n widgetId: 'marketplace-publish-artifact',\n Component: PublishArtifactDialog,\n },\n // The workspace's Plugins page and an installation's own page\n // (AGL-3080). The shell owns both pages and the built-in half of the\n // inventory; what this plugin installed — its pins, whether a newer\n // version may be installed, whether a kill switch is thrown — is read\n // from this plugin's own collections, so this plugin draws it.\n {\n slot: 'orgPluginInstalls',\n widgetId: 'marketplace-org-plugin-installs',\n Component: OrgPluginInstallsCard,\n },\n {\n slot: 'pluginInstallStatus',\n widgetId: 'marketplace-plugin-install-status',\n Component: PluginInstallStatus,\n },\n // The staff overview (AGL-3080): recent purchases and the\n // refund-reversal recovery queue, from this plugin's own purchases.\n {\n slot: 'staffOverview',\n widgetId: 'marketplace-staff-overview',\n Component: StaffMarketplaceOverview,\n },\n // A site's templates (AGL-3080). The gallery and the library are the\n // shell's; the site templates this plugin lists, the route that\n // installs one, and whether a template it installed has a newer\n // version are read from this plugin's listings, so this plugin draws\n // them: a shelf of the gallery, and a chip on the library's row.\n {\n slot: 'templateGallery',\n widgetId: 'marketplace-template-gallery',\n Component: TemplateGalleryShelf,\n },\n {\n slot: 'templateInstallStatus',\n widgetId: 'marketplace-template-install-status',\n Component: TemplateInstallStatus,\n },\n ],\n /**\n * THE MARKETPLACE HUB, as a declaration (AGL-3080).\n *\n * Seventeen hand-written console routes until now — the eight sections\n * below plus a listing, a publisher storefront and a publish form —\n * whose whole job was assembling chrome around bodies that already\n * belonged to this plugin. The shell's generic org plugin route does\n * that assembly for every other surface from exactly this.\n *\n * `ownsSubtree` is what keeps every URL the same. A segment naming a\n * section below resolves as that section; anything else beneath\n * `/marketplace` is handed to the page as `segments`, which is how\n * `/{org}/marketplace/{listingId}` still opens a listing. The cost is\n * stated where the flag is declared: this surface can no longer tell a\n * typo from an id, so it owns saying \"no such thing\" — which a listing\n * page has to do anyway for one deleted while a link to it was still in\n * someone's inbox.\n */\n orgNavItems: [\n {\n label: 'Marketplace',\n href: '/marketplace',\n navTabId: 'nav-tab-org-marketplace',\n icon: { path: mdiStorefrontOutline.path },\n /*\n * Last of the plugin tabs, so it sits directly before the shell's\n * Plugins tab (AGL-3294): shopping for plugins beside managing the\n * ones the workspace runs, the pair AGL-1011 split into two tabs.\n */\n tabOrder: 100,\n ownsSubtree: true,\n Component: MarketplaceHub,\n header: {\n title: 'Marketplace',\n icon: { path: mdiStorefrontOutline.path },\n docsTopic: 'plugins',\n },\n sections: [\n // \"Browse All\" (AGL-1024): the same grid also renders\n // publisher-filtered views, so the unqualified verb was ambiguous\n // about which you were getting.\n { id: 'browse', label: 'Browse All' },\n { id: 'installed', label: 'Installed' },\n /*\n * What this workspace OWNS (AGL-2331) — an org can hold a licence\n * nobody has installed, and a member can install something they\n * never bought. Buyer-side, so deliberately NOT gated like the\n * seller sections below: the person who needs it is often not a\n * publisher at all.\n *\n * `purchase` lands here: Stripe bakes it into the checkout session\n * and holds the URL, and a buyer coming back wants what they now\n * own.\n */\n {\n id: MARKETPLACE_LICENSES_SECTION_ID,\n label: 'Licenses',\n landsOnQuery: ['purchase'],\n },\n /*\n * The seller half. Each reads the organization's REVENUE or its\n * payout account, so each names the permission rather than relying\n * on a hidden tab — a URL can be typed whether or not a tab was\n * ever offered, and the shell applies this to the rail and to the\n * deep link as one verdict.\n */\n {\n id: 'upload',\n // Covers uploading a bundle as well as publishing an existing\n // artifact (AGL-1024).\n label: 'Upload / Publish',\n permission: 'publishToMarketplace',\n },\n {\n id: 'profile',\n // Whose profile (AGL-1024) — the console also has org and user\n // profiles.\n label: 'Publisher Profile',\n permission: 'publishToMarketplace',\n },\n {\n id: 'listings',\n label: 'Listings',\n permission: 'publishToMarketplace',\n },\n {\n id: 'payouts',\n label: 'Payouts',\n permission: 'publishToMarketplace',\n // Stripe Connect onboarding returns with this, from\n // `server/connect.ts`. A seller coming back wants Payouts.\n landsOnQuery: ['connect'],\n },\n {\n id: 'sales',\n label: 'Sales',\n permission: 'publishToMarketplace',\n },\n ],\n },\n ],\n /**\n * The report queue, in the staff area (AGL-2310, moved by AGL-3080).\n *\n * `marketplaceReports` is a collection only this plugin writes, and the\n * queue that triages it was a console staff route because the staff area\n * had no way for a plugin to own a page. It does (AGL-2939), and the\n * shell serves this at the same `/admin/marketplace-reports` it always\n * had — a staff page's id IS its URL segment.\n */\n staffPages: [\n {\n id: 'marketplace-reports',\n label: 'Marketplace reports',\n header: {\n title: 'Marketplace Reports',\n icon: { path: ICON_VARIANT_SYMBOL_FLAG.path },\n // The abuse queue's topic, for the reason the page's own help\n // gives. The page publishes the `#statuses` anchor itself, which a\n // `staffPages` entry cannot carry.\n docsTopic: 'abuseReports',\n },\n Component: MarketplaceReportsPage,\n },\n /**\n * The review queue (AGL-432, moved by AGL-3080).\n *\n * `ownsSubtree` is what makes the move possible at all: the queue is a\n * list and each row opens one submission at\n * `/admin/plugin-reviews/{listingId}`, and a staff page without it\n * could only ever BE the list. Same URLs as the console routes it\n * replaces — a staff page's id IS its segment under `/admin`.\n *\n * The queue carries no signing authority. Granting realm trust is a\n * separate super-only act on its own route; listing and verifying here\n * never signs anything.\n */\n {\n id: 'plugin-reviews',\n label: 'Plugin reviews',\n ownsSubtree: true,\n header: {\n title: 'Plugin reviews',\n icon: { path: ICON_VARIANT_SYMBOL_FLAG.path },\n docsTopic: 'staffConsole',\n },\n Component: PluginReviewsSurface,\n },\n ],\n pluginId: BUNDLE_ID,\n displayName: 'Marketplace',\n })\n}\n\n// Shared with the listing/publisher detail app-routes.\nexport { default as useMarketplaceActions } from './hooks/use-marketplace-actions'\nexport { default as MarketplaceBrowse } from './components/marketplace-browse.component'\nexport { default as HostPluginsCard } from './components/host-plugins-card.component'\nexport { default as PluginSiteSetPanel } from './components/plugin-site-set-panel.component'\n"],"names":["Aglyn","ICON_VARIANT_SYMBOL_FLAG","mdiStorefrontOutline","MarketplaceHub","MarketplaceReportsPage","PluginReviewsSurface","PluginSiteSetPanel","OrgPluginInstallsCard","PluginInstallStatus","StaffMarketplaceOverview","TemplateGalleryShelf","TemplateInstallStatus","PublishArtifactDialog","BUNDLE_ID","MARKETPLACE_LICENSES_SECTION_ID","RATING_FIELD","RatingInput","registerMarketplaceConsole","registerCustomFieldType","Input","registerConsoleExtension","widgets","slot","widgetId","Component","orgNavItems","label","href","navTabId","icon","path","tabOrder","ownsSubtree","header","title","docsTopic","sections","id","landsOnQuery","permission","staffPages","pluginId","displayName","default","useMarketplaceActions","MarketplaceBrowse","HostPluginsCard"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,wBAAwB,QAAQ,2BAA0B;AACnE,SAASC,oBAAoB,QAAQ,yBAAwB;AAE7D,OAAOC,oBAAoB,4CAAwC;AACnE,OAAOC,4BAA4B,qDAAiD;AACpF,OAAOC,0BAA0B,mDAA+C;AAGhF,OAAOC,wBAAwB,kDAA8C;AAC7E,OAAOC,2BAA2B,qDAAiD;AACnF,OAAOC,yBAAyB,kDAA8C;AAC9E,OAAOC,8BAA8B,uDAAmD;AACxF,OAAOC,0BAA0B,mDAA+C;AAChF,OAAOC,2BAA2B,oDAAgD;AAClF,OAAOC,2BAA2B,oDAAgD;AAElF,SAASC,SAAS,QAAQ,+BAA2B;AACrD,SAASC,+BAA+B,QAAQ,qCAAiC;AACjF,SAASC,YAAY,QAAQ,0BAAsB;AACnD,OAAOC,iBAAiB,yCAAqC;AAE7D;;;;;;;;;;;CAWC,GACD,OAAO,SAASC;IACd,wEAAw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tC;;;;;;;;;;WAUC,GACD;wBACEW,IAAIvB;wBACJY,OAAO;wBACPY,cAAc;4BAAC;yBAAW;oBAC5B;oBACA;;;;;;WAMC,GACD;wBACED,IAAI;wBACJ,8DAA8D;wBAC9D,uBAAuB;wBACvBX,OAAO;wBACPa,YAAY;oBACd;oBACA;wBACEF,IAAI;wBACJ,+DAA+D;wBAC/D,YAAY;wBACZX,OAAO;wBACPa,YAAY;oBACd;oBACA;wBACEF,IAAI;wBACJX,OAAO;wBACPa,YAAY;oBACd;oBACA;wBACEF,IAAI;wBACJX,OAAO;wBACPa,YAAY;wBACZ,oDAAoD;wBACpD,2DAA2D;wBAC3DD,cAAc;4BAAC;yBAAU;oBAC3B;oBACA;wBACED,IAAI;wBACJX,OAAO;wBACPa,YAAY;oBACd;iBACD;YACH;SACD;QACD;;;;;;;;KAQC,GACDC,YAAY;YACV;gBACEH,IAAI;gBACJX,OAAO;gBACPO,QAAQ;oBACNC,OAAO;oBACPL,MAAM;wBAAEC,MAAM7B,yBAAyB6B,IAAI;oBAAC;oBAC5C,8DAA8D;oBAC9D,mEAAmE;oBACnE,mCAAmC;oBACnCK,WAAW;gBACb;gBACAX,WAAWpB;YACb;YACA;;;;;;;;;;;;OAYC,GACD;gBACEiC,IAAI;gBACJX,OAAO;gBACPM,aAAa;gBACbC,QAAQ;oBACNC,OAAO;oBACPL,MAAM;wBAAEC,MAAM7B,yBAAyB6B,IAAI;oBAAC;oBAC5CK,WAAW;gBACb;gBACAX,WAAWnB;YACb;SACD;QACDoC,UAAU5B;QACV6B,aAAa;IACf;AACF;AAEA,uDAAuD;AACvD,SAASC,WAAWC,qBAAqB,QAAQ,qCAAiC;AAClF,SAASD,WAAWE,iBAAiB,QAAQ,+CAA2C;AACxF,SAASF,WAAWG,eAAe,QAAQ,8CAA0C;AACrF,SAASH,WAAWrC,kBAAkB,QAAQ,kDAA8C"}
1
+ {"version":3,"sources":["../../../../../../libs/plugins/marketplace/src/lib/plugin.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { ICON_VARIANT_SYMBOL_FLAG } from '@aglyn/shared-data-enums'\nimport { mdiStorefrontOutline } from '@aglyn/shared-data-mdi'\nimport MarketplaceBrowse from './components/marketplace-browse.component'\nimport MarketplaceHub from './components/marketplace-hub.component'\nimport MarketplaceReportsPage from './components/marketplace-reports-page.component'\nimport PluginReviewsSurface from './components/plugin-reviews-surface.component'\nimport MarketplacePaymentsNotice from './components/marketplace-payments-notice.component'\nimport HostPluginsCard from './components/host-plugins-card.component'\nimport PluginSiteSetPanel from './components/plugin-site-set-panel.component'\nimport OrgPluginInstallsCard from './components/org-plugin-installs-card.component'\nimport PluginInstallStatus from './components/plugin-install-status.component'\nimport StaffMarketplaceOverview from './components/staff-marketplace-overview.component'\nimport StarterPickerShelf from './components/starter-picker-shelf.component'\nimport TemplateGalleryShelf from './components/template-gallery-shelf.component'\nimport TemplateInstallStatus from './components/template-install-status.component'\nimport PublishArtifactDialog from './components/publish-artifact-dialog.component'\nimport { MarketplaceListingContent } from './components/listing-content.component'\nimport { BUNDLE_ID } from './constants/bundle-common'\nimport { MARKETPLACE_LICENSES_SECTION_ID } from './model/marketplace-section-ids'\nimport { RATING_FIELD } from './model/rating-field'\nimport RatingInput from './components/rating-input.component'\n\n/**\n * Marketplace feature plugin (AGL-395). Console-only — marketplace components\n * install into a host's own components collection and render through the\n * normal compose pipeline, so there is no separate canvas bundle.\n *\n * The marketplace moved to org scope (AGL-772/774): browse + install live at\n * `/[orgSlug]/marketplace`, so this plugin no longer contributes a per-site\n * `Marketplace` nav tab (AGL-775). It exposes its UI purely through widget\n * slots — `orgMarketplace` (browse), `marketplaceListing` (detail) and\n * `orgAddons` (installed) — which the app renders without importing the\n * plugin.\n */\nexport function registerMarketplaceConsole(): void {\n // Custom field type (AGL-434): rating rides int32 with a starred input.\n Aglyn.registerCustomFieldType({ ...RATING_FIELD, Input: RatingInput })\n Aglyn.registerConsoleExtension({\n /*\n * Four widgets fewer since AGL-3080 — the listing body, the capability\n * notice, browse, and installed add-ons. Their zones existed for one\n * reason: a CONSOLE ROUTE had to show them and an app may not import a\n * plugin. The hub is this plugin's own surface now, so those components\n * are plain imports and the four zones are gone from the catalog.\n *\n * What is left is what a console page OTHER than the marketplace draws.\n */\n widgets: [\n // The site set for one installation (AGL-1007): the same control the\n // listing page uses, exposed so the installation detail page can show\n // it without the app importing this plugin.\n {\n slot: 'pluginSiteSet',\n widgetId: 'marketplace-plugin-site-set',\n Component: PluginSiteSetPanel,\n },\n // Publishing something the console holds (AGL-3080). The page that\n // offers it keeps the control that opens it — a menu item is one entry\n // of a list the page builds, not a widget — and hands over what it has\n // in its own vocabulary. Where a layout or a theme GOES, what a listing\n // of it is called and what it may cost at the least are this plugin's.\n {\n slot: 'hostArtifactPublish',\n widgetId: 'marketplace-publish-artifact',\n Component: PublishArtifactDialog,\n },\n // The workspace's Plugins page and an installation's own page\n // (AGL-3080). The shell owns both pages and the built-in half of the\n // inventory; what this plugin installed — its pins, whether a newer\n // version may be installed, whether a kill switch is thrown — is read\n // from this plugin's own collections, so this plugin draws it.\n {\n slot: 'orgPluginInstalls',\n widgetId: 'marketplace-org-plugin-installs',\n Component: OrgPluginInstallsCard,\n },\n {\n slot: 'pluginInstallStatus',\n widgetId: 'marketplace-plugin-install-status',\n Component: PluginInstallStatus,\n },\n // The staff overview (AGL-3080): recent purchases and the\n // refund-reversal recovery queue, from this plugin's own purchases.\n {\n slot: 'staffOverview',\n widgetId: 'marketplace-staff-overview',\n Component: StaffMarketplaceOverview,\n },\n // A site's templates (AGL-3080). The gallery and the library are the\n // shell's; the site templates this plugin lists, the route that\n // installs one, and whether a template it installed has a newer\n // version are read from this plugin's listings, so this plugin draws\n // them: a shelf of the gallery, and a chip on the library's row.\n {\n slot: 'templateGallery',\n widgetId: 'marketplace-template-gallery',\n Component: TemplateGalleryShelf,\n },\n {\n slot: 'templateInstallStatus',\n widgetId: 'marketplace-template-install-status',\n Component: TemplateInstallStatus,\n },\n // \"Choose your starter\" in Create site (AGL-4049): the marketplace's\n // site starters, searched and picked before the site exists. It lists\n // and picks; the dialog creates. Searching is the first step of\n // creating a site, so it takes the create's permission, as its route\n // does; the route also answers the release flag.\n {\n slot: 'hostStarterPicker',\n widgetId: 'marketplace-starter-picker',\n permission: 'hosts.create',\n Component: StarterPickerShelf,\n },\n ],\n /**\n * THE MARKETPLACE HUB, as a declaration (AGL-3080).\n *\n * Seventeen hand-written console routes until now — the eight sections\n * below plus a listing, a publisher storefront and a publish form —\n * whose whole job was assembling chrome around bodies that already\n * belonged to this plugin. The shell's generic org plugin route does\n * that assembly for every other surface from exactly this.\n *\n * `ownsSubtree` is what keeps every URL the same. A segment naming a\n * section below resolves as that section; anything else beneath\n * `/marketplace` is handed to the page as `segments`, which is how\n * `/{org}/marketplace/{listingId}` still opens a listing. The cost is\n * stated where the flag is declared: this surface can no longer tell a\n * typo from an id, so it owns saying \"no such thing\" — which a listing\n * page has to do anyway for one deleted while a link to it was still in\n * someone's inbox.\n */\n orgNavItems: [\n {\n label: 'Marketplace',\n href: '/marketplace',\n navTabId: 'nav-tab-org-marketplace',\n icon: { path: mdiStorefrontOutline.path },\n /*\n * Last of the plugin tabs, so it sits directly before the shell's\n * Plugins tab (AGL-3294): shopping for plugins beside managing the\n * ones the workspace runs, the pair AGL-1011 split into two tabs.\n */\n tabOrder: 100,\n ownsSubtree: true,\n Component: MarketplaceHub,\n header: {\n title: 'Marketplace',\n icon: { path: mdiStorefrontOutline.path },\n docsTopic: 'plugins',\n },\n sections: [\n // \"Browse All\" (AGL-1024): the same grid also renders\n // publisher-filtered views, so the unqualified verb was ambiguous\n // about which you were getting.\n { id: 'browse', label: 'Browse All' },\n { id: 'installed', label: 'Installed' },\n /*\n * What this workspace OWNS (AGL-2331) — an org can hold a licence\n * nobody has installed, and a member can install something they\n * never bought. Buyer-side, so deliberately NOT gated like the\n * seller sections below: the person who needs it is often not a\n * publisher at all.\n *\n * `purchase` lands here: Stripe bakes it into the checkout session\n * and holds the URL, and a buyer coming back wants what they now\n * own.\n */\n {\n id: MARKETPLACE_LICENSES_SECTION_ID,\n label: 'Licenses',\n landsOnQuery: ['purchase'],\n },\n /*\n * The seller half. Each reads the organization's REVENUE or its\n * payout account, so each names the permission rather than relying\n * on a hidden tab — a URL can be typed whether or not a tab was\n * ever offered, and the shell applies this to the rail and to the\n * deep link as one verdict.\n */\n {\n id: 'upload',\n // Covers uploading a bundle as well as publishing an existing\n // artifact (AGL-1024).\n label: 'Upload / Publish',\n permission: 'publishToMarketplace',\n },\n {\n id: 'profile',\n // Whose profile (AGL-1024) — the console also has org and user\n // profiles.\n label: 'Publisher Profile',\n permission: 'publishToMarketplace',\n },\n {\n id: 'listings',\n label: 'Listings',\n permission: 'publishToMarketplace',\n },\n {\n id: 'payouts',\n label: 'Payouts',\n permission: 'publishToMarketplace',\n // Stripe Connect onboarding returns with this, from\n // `server/connect.ts`. A seller coming back wants Payouts.\n landsOnQuery: ['connect'],\n },\n {\n id: 'sales',\n label: 'Sales',\n permission: 'publishToMarketplace',\n },\n ],\n },\n ],\n /**\n * The report queue, in the staff area (AGL-2310, moved by AGL-3080).\n *\n * `marketplaceReports` is a collection only this plugin writes, and the\n * queue that triages it was a console staff route because the staff area\n * had no way for a plugin to own a page. It does (AGL-2939), and the\n * shell serves this at the same `/admin/marketplace-reports` it always\n * had — a staff page's id IS its URL segment.\n */\n staffPages: [\n {\n id: 'marketplace-reports',\n label: 'Marketplace reports',\n header: {\n title: 'Marketplace Reports',\n icon: { path: ICON_VARIANT_SYMBOL_FLAG.path },\n // The abuse queue's topic, for the reason the page's own help\n // gives. The page publishes the `#statuses` anchor itself, which a\n // `staffPages` entry cannot carry.\n docsTopic: 'abuseReports',\n },\n Component: MarketplaceReportsPage,\n },\n /**\n * The review queue (AGL-432, moved by AGL-3080).\n *\n * `ownsSubtree` is what makes the move possible at all: the queue is a\n * list and each row opens one submission at\n * `/admin/plugin-reviews/{listingId}`, and a staff page without it\n * could only ever BE the list. Same URLs as the console routes it\n * replaces — a staff page's id IS its segment under `/admin`.\n *\n * The queue carries no signing authority. Granting realm trust is a\n * separate super-only act on its own route; listing and verifying here\n * never signs anything.\n */\n {\n id: 'plugin-reviews',\n label: 'Plugin reviews',\n ownsSubtree: true,\n header: {\n title: 'Plugin reviews',\n icon: { path: ICON_VARIANT_SYMBOL_FLAG.path },\n docsTopic: 'staffConsole',\n },\n Component: PluginReviewsSurface,\n },\n ],\n pluginId: BUNDLE_ID,\n displayName: 'Marketplace',\n })\n}\n\n// Shared with the listing/publisher detail app-routes.\nexport { default as useMarketplaceActions } from './hooks/use-marketplace-actions'\nexport { default as MarketplaceBrowse } from './components/marketplace-browse.component'\nexport { default as HostPluginsCard } from './components/host-plugins-card.component'\nexport { default as PluginSiteSetPanel } from './components/plugin-site-set-panel.component'\n"],"names":["Aglyn","ICON_VARIANT_SYMBOL_FLAG","mdiStorefrontOutline","MarketplaceHub","MarketplaceReportsPage","PluginReviewsSurface","PluginSiteSetPanel","OrgPluginInstallsCard","PluginInstallStatus","StaffMarketplaceOverview","StarterPickerShelf","TemplateGalleryShelf","TemplateInstallStatus","PublishArtifactDialog","BUNDLE_ID","MARKETPLACE_LICENSES_SECTION_ID","RATING_FIELD","RatingInput","registerMarketplaceConsole","registerCustomFieldType","Input","registerConsoleExtension","widgets","slot","widgetId","Component","permission","orgNavItems","label","href","navTabId","icon","path","tabOrder","ownsSubtree","header","title","docsTopic","sections","id","landsOnQuery","staffPages","pluginId","displayName","default","useMarketplaceActions","M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