@aglyn/plugins-marketplace 1.0.0-beta.143
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/LICENSE +201 -0
- package/README.md +7 -0
- package/package.json +51 -0
- package/src/index.d.ts +19 -0
- package/src/index.js +20 -0
- package/src/index.js.map +1 -0
- package/src/lib/components/artifact-update-dialog.component.d.ts +27 -0
- package/src/lib/components/artifact-update-dialog.component.js +244 -0
- package/src/lib/components/artifact-update-dialog.component.js.map +1 -0
- package/src/lib/components/host-plugins-card.component.d.ts +23 -0
- package/src/lib/components/host-plugins-card.component.js +566 -0
- package/src/lib/components/host-plugins-card.component.js.map +1 -0
- package/src/lib/components/listing-content.component.d.ts +57 -0
- package/src/lib/components/listing-content.component.js +1880 -0
- package/src/lib/components/listing-content.component.js.map +1 -0
- package/src/lib/components/listing-image.component.d.ts +46 -0
- package/src/lib/components/listing-image.component.js +38 -0
- package/src/lib/components/listing-image.component.js.map +1 -0
- package/src/lib/components/listing-reviews.component.d.ts +22 -0
- package/src/lib/components/listing-reviews.component.js +419 -0
- package/src/lib/components/listing-reviews.component.js.map +1 -0
- package/src/lib/components/marketplace-browse.component.d.ts +38 -0
- package/src/lib/components/marketplace-browse.component.js +802 -0
- package/src/lib/components/marketplace-browse.component.js.map +1 -0
- package/src/lib/components/plugin-site-set-panel.component.d.ts +24 -0
- package/src/lib/components/plugin-site-set-panel.component.js +137 -0
- package/src/lib/components/plugin-site-set-panel.component.js.map +1 -0
- package/src/lib/components/plugin-site-set.component.d.ts +43 -0
- package/src/lib/components/plugin-site-set.component.js +425 -0
- package/src/lib/components/plugin-site-set.component.js.map +1 -0
- package/src/lib/components/rating-input.component.d.ts +3 -0
- package/src/lib/components/rating-input.component.js +47 -0
- package/src/lib/components/rating-input.component.js.map +1 -0
- package/src/lib/components/report-target.component.d.ts +36 -0
- package/src/lib/components/report-target.component.js +181 -0
- package/src/lib/components/report-target.component.js.map +1 -0
- package/src/lib/components/uninstall-impact-dialog.component.d.ts +40 -0
- package/src/lib/components/uninstall-impact-dialog.component.js +244 -0
- package/src/lib/components/uninstall-impact-dialog.component.js.map +1 -0
- package/src/lib/constants/bundle-common.d.ts +8 -0
- package/src/lib/constants/bundle-common.js +9 -0
- package/src/lib/constants/bundle-common.js.map +1 -0
- package/src/lib/hooks/use-artifact-update.d.ts +41 -0
- package/src/lib/hooks/use-artifact-update.js +169 -0
- package/src/lib/hooks/use-artifact-update.js.map +1 -0
- package/src/lib/hooks/use-marketplace-actions.d.ts +37 -0
- package/src/lib/hooks/use-marketplace-actions.js +523 -0
- package/src/lib/hooks/use-marketplace-actions.js.map +1 -0
- package/src/lib/model/artifact-merge.d.ts +154 -0
- package/src/lib/model/artifact-merge.js +228 -0
- package/src/lib/model/artifact-merge.js.map +1 -0
- package/src/lib/model/index.d.ts +43 -0
- package/src/lib/model/index.js +41 -0
- package/src/lib/model/index.js.map +1 -0
- package/src/lib/model/marketplace-props.d.ts +57 -0
- package/src/lib/model/marketplace-props.js +441 -0
- package/src/lib/model/marketplace-props.js.map +1 -0
- package/src/lib/model/marketplace.d.ts +833 -0
- package/src/lib/model/marketplace.js +929 -0
- package/src/lib/model/marketplace.js.map +1 -0
- package/src/lib/model/rating-field.d.ts +24 -0
- package/src/lib/model/rating-field.js +33 -0
- package/src/lib/model/rating-field.js.map +1 -0
- package/src/lib/plugin.d.ts +33 -0
- package/src/lib/plugin.js +86 -0
- package/src/lib/plugin.js.map +1 -0
- package/src/lib/server/billing-webhook.d.ts +25 -0
- package/src/lib/server/billing-webhook.js +1062 -0
- package/src/lib/server/billing-webhook.js.map +1 -0
- package/src/lib/server/checkout.d.ts +76 -0
- package/src/lib/server/checkout.js +477 -0
- package/src/lib/server/checkout.js.map +1 -0
- package/src/lib/server/connect.d.ts +24 -0
- package/src/lib/server/connect.js +205 -0
- package/src/lib/server/connect.js.map +1 -0
- package/src/lib/server/install-dataset-schema.d.ts +32 -0
- package/src/lib/server/install-dataset-schema.js +255 -0
- package/src/lib/server/install-dataset-schema.js.map +1 -0
- package/src/lib/server/install-email-starter.d.ts +65 -0
- package/src/lib/server/install-email-starter.js +279 -0
- package/src/lib/server/install-email-starter.js.map +1 -0
- package/src/lib/server/install-email-template.d.ts +34 -0
- package/src/lib/server/install-email-template.js +252 -0
- package/src/lib/server/install-email-template.js.map +1 -0
- package/src/lib/server/install-layout.d.ts +29 -0
- package/src/lib/server/install-layout.js +323 -0
- package/src/lib/server/install-layout.js.map +1 -0
- package/src/lib/server/install-pin-counts.d.ts +173 -0
- package/src/lib/server/install-pin-counts.js +248 -0
- package/src/lib/server/install-pin-counts.js.map +1 -0
- package/src/lib/server/install-plugin.d.ts +18 -0
- package/src/lib/server/install-plugin.js +405 -0
- package/src/lib/server/install-plugin.js.map +1 -0
- package/src/lib/server/install-template.d.ts +37 -0
- package/src/lib/server/install-template.js +348 -0
- package/src/lib/server/install-template.js.map +1 -0
- package/src/lib/server/install-theme.d.ts +42 -0
- package/src/lib/server/install-theme.js +313 -0
- package/src/lib/server/install-theme.js.map +1 -0
- package/src/lib/server/install.d.ts +27 -0
- package/src/lib/server/install.js +276 -0
- package/src/lib/server/install.js.map +1 -0
- package/src/lib/server/listing-versions.d.ts +26 -0
- package/src/lib/server/listing-versions.js +378 -0
- package/src/lib/server/listing-versions.js.map +1 -0
- package/src/lib/server/preview-image.d.ts +37 -0
- package/src/lib/server/preview-image.js +216 -0
- package/src/lib/server/preview-image.js.map +1 -0
- package/src/lib/server/provenance.d.ts +100 -0
- package/src/lib/server/provenance.js +118 -0
- package/src/lib/server/provenance.js.map +1 -0
- package/src/lib/server/publish-dataset-schema.d.ts +31 -0
- package/src/lib/server/publish-dataset-schema.js +202 -0
- package/src/lib/server/publish-dataset-schema.js.map +1 -0
- package/src/lib/server/publish-email-starter.d.ts +44 -0
- package/src/lib/server/publish-email-starter.js +231 -0
- package/src/lib/server/publish-email-starter.js.map +1 -0
- package/src/lib/server/publish-email-template.d.ts +33 -0
- package/src/lib/server/publish-email-template.js +211 -0
- package/src/lib/server/publish-email-template.js.map +1 -0
- package/src/lib/server/publish-layout.d.ts +33 -0
- package/src/lib/server/publish-layout.js +243 -0
- package/src/lib/server/publish-layout.js.map +1 -0
- package/src/lib/server/publish-plugin.d.ts +18 -0
- package/src/lib/server/publish-plugin.js +485 -0
- package/src/lib/server/publish-plugin.js.map +1 -0
- package/src/lib/server/publish-preconditions.d.ts +86 -0
- package/src/lib/server/publish-preconditions.js +160 -0
- package/src/lib/server/publish-preconditions.js.map +1 -0
- package/src/lib/server/publish-template.d.ts +27 -0
- package/src/lib/server/publish-template.js +215 -0
- package/src/lib/server/publish-template.js.map +1 -0
- package/src/lib/server/publish-theme.d.ts +38 -0
- package/src/lib/server/publish-theme.js +186 -0
- package/src/lib/server/publish-theme.js.map +1 -0
- package/src/lib/server/publish.d.ts +26 -0
- package/src/lib/server/publish.js +204 -0
- package/src/lib/server/publish.js.map +1 -0
- package/src/lib/server/publisher-profile-save.d.ts +30 -0
- package/src/lib/server/publisher-profile-save.js +226 -0
- package/src/lib/server/publisher-profile-save.js.map +1 -0
- package/src/lib/server/publisher-profile.d.ts +86 -0
- package/src/lib/server/publisher-profile.js +116 -0
- package/src/lib/server/publisher-profile.js.map +1 -0
- package/src/lib/server/purchase-entitlement.d.ts +83 -0
- package/src/lib/server/purchase-entitlement.js +118 -0
- package/src/lib/server/purchase-entitlement.js.map +1 -0
- package/src/lib/server/report.d.ts +32 -0
- package/src/lib/server/report.js +101 -0
- package/src/lib/server/report.js.map +1 -0
- package/src/lib/server/reviews.d.ts +41 -0
- package/src/lib/server/reviews.js +240 -0
- package/src/lib/server/reviews.js.map +1 -0
- package/src/lib/server/update-artifact.d.ts +19 -0
- package/src/lib/server/update-artifact.js +569 -0
- package/src/lib/server/update-artifact.js.map +1 -0
- package/src/lib/server/verification-request.d.ts +31 -0
- package/src/lib/server/verification-request.js +173 -0
- package/src/lib/server/verification-request.js.map +1 -0
- package/src/lib/server/version-stats.d.ts +202 -0
- package/src/lib/server/version-stats.js +305 -0
- package/src/lib/server/version-stats.js.map +1 -0
- package/src/lib/server.d.ts +30 -0
- package/src/lib/server.js +95 -0
- package/src/lib/server.js.map +1 -0
|
@@ -0,0 +1,169 @@
|
|
|
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
|
+
*/ 'use client';
|
|
17
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
+
import { lockdownRefusalText, parseLockdownRefusal } from "@aglyn/aglyn";
|
|
19
|
+
import { useLoading } from "@aglyn/shared-ui-jsx";
|
|
20
|
+
import { useSnackbar } from "@aglyn/shared-ui-snackstack";
|
|
21
|
+
import { useCallback, useState } from "react";
|
|
22
|
+
import { useUser } from "@aglyn/tenant-feature-instance";
|
|
23
|
+
import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
|
|
24
|
+
/**
|
|
25
|
+
* Preview-then-apply for a copied artifact (AGL-1018).
|
|
26
|
+
*
|
|
27
|
+
* Deliberately separate from `useMarketplaceActions`: install writes the
|
|
28
|
+
* publisher's version, and an update reconciles it with a copy that has
|
|
29
|
+
* diverged. Sharing one call would put the destructive path one forgotten
|
|
30
|
+
* argument away from the safe one.
|
|
31
|
+
*/ export function useArtifactUpdate(hostId) {
|
|
32
|
+
const { data: user } = useUser();
|
|
33
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
34
|
+
const { queueLoading } = useLoading();
|
|
35
|
+
const [preview, setPreview] = useState(null);
|
|
36
|
+
const [loading, setLoading] = useState(false);
|
|
37
|
+
const post = useCallback(async (listingId, body)=>{
|
|
38
|
+
const response = await authorizedFetch(user, '/api/marketplace/update-artifact', {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
headers: {
|
|
41
|
+
'Content-Type': 'application/json'
|
|
42
|
+
},
|
|
43
|
+
body: JSON.stringify(_extends({
|
|
44
|
+
listingId,
|
|
45
|
+
hostId
|
|
46
|
+
}, body))
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
response,
|
|
50
|
+
payload: await response.json().catch(()=>({}))
|
|
51
|
+
};
|
|
52
|
+
}, [
|
|
53
|
+
user,
|
|
54
|
+
hostId
|
|
55
|
+
]);
|
|
56
|
+
/** Ask what an update would do. Writes nothing. */ const loadPreview = useCallback(async (listingId)=>{
|
|
57
|
+
setLoading(true);
|
|
58
|
+
setPreview(null);
|
|
59
|
+
try {
|
|
60
|
+
const { response, payload } = await post(listingId, {
|
|
61
|
+
action: 'preview'
|
|
62
|
+
});
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
var _ref;
|
|
65
|
+
// `update-artifact` is an install by another name, so an installs
|
|
66
|
+
// lock refuses it (AGL-1510/1532) — say "paused", not "could not
|
|
67
|
+
// read this update", which reads as a corrupt listing.
|
|
68
|
+
const locked = parseLockdownRefusal(response.status, payload);
|
|
69
|
+
if (locked) {
|
|
70
|
+
enqueueSnackbar(lockdownRefusalText(locked), {
|
|
71
|
+
variant: 'warning',
|
|
72
|
+
persist: true
|
|
73
|
+
});
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
enqueueSnackbar((_ref = payload == null ? void 0 : payload.error) != null ? _ref : 'Could not read this update', {
|
|
77
|
+
variant: 'error',
|
|
78
|
+
allowDuplicate: true
|
|
79
|
+
});
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
setPreview(payload.preview);
|
|
83
|
+
return payload.preview;
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error(error);
|
|
86
|
+
enqueueSnackbar('An error has occurred', {
|
|
87
|
+
variant: 'error',
|
|
88
|
+
allowDuplicate: true
|
|
89
|
+
});
|
|
90
|
+
return null;
|
|
91
|
+
} finally{
|
|
92
|
+
setLoading(false);
|
|
93
|
+
}
|
|
94
|
+
}, [
|
|
95
|
+
post,
|
|
96
|
+
enqueueSnackbar
|
|
97
|
+
]);
|
|
98
|
+
/**
|
|
99
|
+
* Write the update. `mode: 'merge'` takes the safe changes plus whatever
|
|
100
|
+
* conflicts were explicitly picked; `mode: 'copy'` installs the new version
|
|
101
|
+
* fresh and detaches the customised one.
|
|
102
|
+
*/ const applyUpdate = useCallback(async (listingId, options)=>{
|
|
103
|
+
const dequeue = queueLoading();
|
|
104
|
+
try {
|
|
105
|
+
const { response, payload } = await post(listingId, _extends({
|
|
106
|
+
action: 'apply'
|
|
107
|
+
}, options));
|
|
108
|
+
if (!response.ok) {
|
|
109
|
+
var _ref;
|
|
110
|
+
const locked = parseLockdownRefusal(response.status, payload);
|
|
111
|
+
if (locked) {
|
|
112
|
+
enqueueSnackbar(lockdownRefusalText(locked), {
|
|
113
|
+
variant: 'warning',
|
|
114
|
+
persist: true
|
|
115
|
+
});
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
enqueueSnackbar((_ref = payload == null ? void 0 : payload.error) != null ? _ref : 'Update failed', {
|
|
119
|
+
variant: (payload == null ? void 0 : payload.needsConfirmation) ? 'warning' : 'error',
|
|
120
|
+
allowDuplicate: true
|
|
121
|
+
});
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
if (options.mode === 'copy') {
|
|
125
|
+
enqueueSnackbar(`Installed v${payload.version} as a new copy — your customized ` + 'version is kept, no longer linked to the listing.', {
|
|
126
|
+
variant: 'success',
|
|
127
|
+
persist: false
|
|
128
|
+
});
|
|
129
|
+
} else {
|
|
130
|
+
var _ref1;
|
|
131
|
+
var _payload_skipped;
|
|
132
|
+
// The summary is the point of the whole flow: it says what moved and,
|
|
133
|
+
// just as importantly, what was left alone.
|
|
134
|
+
const skipped = (_ref1 = (_payload_skipped = payload.skipped) == null ? void 0 : _payload_skipped.length) != null ? _ref1 : 0;
|
|
135
|
+
enqueueSnackbar(// A version bump carrying no content change (AGL-1035). "0 changes
|
|
136
|
+
// applied" would read as a failure; what happened is that the
|
|
137
|
+
// version moved, which is the whole point of taking it.
|
|
138
|
+
!payload.applied && !payload.keptLocal && !skipped ? `Now on v${payload.version} — this version changes nothing in your copy.` : `Updated to v${payload.version} — ${payload.applied} change(s) ` + `applied, ${payload.keptLocal} of yours kept` + (skipped ? `, ${skipped} conflict(s) left as yours` : '') + '.', {
|
|
139
|
+
variant: 'success',
|
|
140
|
+
persist: false
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return true;
|
|
144
|
+
} catch (error) {
|
|
145
|
+
console.error(error);
|
|
146
|
+
enqueueSnackbar('An error has occurred', {
|
|
147
|
+
variant: 'error',
|
|
148
|
+
allowDuplicate: true
|
|
149
|
+
});
|
|
150
|
+
return false;
|
|
151
|
+
} finally{
|
|
152
|
+
dequeue();
|
|
153
|
+
}
|
|
154
|
+
}, [
|
|
155
|
+
post,
|
|
156
|
+
queueLoading,
|
|
157
|
+
enqueueSnackbar
|
|
158
|
+
]);
|
|
159
|
+
return {
|
|
160
|
+
preview,
|
|
161
|
+
loading,
|
|
162
|
+
loadPreview,
|
|
163
|
+
applyUpdate,
|
|
164
|
+
setPreview
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
export default useArtifactUpdate;
|
|
168
|
+
|
|
169
|
+
//# sourceMappingURL=use-artifact-update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/hooks/use-artifact-update.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'use client'\n\nimport { lockdownRefusalText, parseLockdownRefusal } from '@aglyn/aglyn'\nimport { useLoading } from '@aglyn/shared-ui-jsx'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useCallback, useState } from 'react'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport type { ArtifactChange } from '../model'\n\n/** The server's answer to \"what would this update do to my copy?\" (AGL-1018). */\nexport interface ArtifactUpdatePreview {\n artifactType: string\n installedVersion: string | null\n availableVersion: string | null\n mergeable: boolean\n reason?: string\n safe: ArtifactChange[]\n kept: ArtifactChange[]\n conflicts: ArtifactChange[]\n unchanged: number\n identical: boolean\n schema?: {\n added: string[]\n removed: string[]\n retyped: string[]\n additiveOnly: boolean\n recordCount: number\n }\n}\n\n/**\n * Preview-then-apply for a copied artifact (AGL-1018).\n *\n * Deliberately separate from `useMarketplaceActions`: install writes the\n * publisher's version, and an update reconciles it with a copy that has\n * diverged. Sharing one call would put the destructive path one forgotten\n * argument away from the safe one.\n */\nexport function useArtifactUpdate(hostId: string) {\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { queueLoading } = useLoading()\n const [preview, setPreview] = useState<ArtifactUpdatePreview | null>(null)\n const [loading, setLoading] = useState(false)\n\n const post = useCallback(\n async (listingId: string, body: Record<string, unknown>) => {\n const response = await authorizedFetch(\n user,\n '/api/marketplace/update-artifact',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ listingId, hostId, ...body }),\n },\n )\n return { response, payload: await response.json().catch(() => ({})) }\n },\n [user, hostId],\n )\n\n /** Ask what an update would do. Writes nothing. */\n const loadPreview = useCallback(\n async (listingId: string) => {\n setLoading(true)\n setPreview(null)\n try {\n const { response, payload } = await post(listingId, {\n action: 'preview',\n })\n if (!response.ok) {\n // `update-artifact` is an install by another name, so an installs\n // lock refuses it (AGL-1510/1532) — say \"paused\", not \"could not\n // read this update\", which reads as a corrupt listing.\n const locked = parseLockdownRefusal(response.status, payload)\n if (locked) {\n enqueueSnackbar(lockdownRefusalText(locked), {\n variant: 'warning',\n persist: true,\n })\n return null\n }\n enqueueSnackbar(payload?.error ?? 'Could not read this update', {\n variant: 'error',\n allowDuplicate: true,\n })\n return null\n }\n setPreview(payload.preview)\n return payload.preview as ArtifactUpdatePreview\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n return null\n } finally {\n setLoading(false)\n }\n },\n [post, enqueueSnackbar],\n )\n\n /**\n * Write the update. `mode: 'merge'` takes the safe changes plus whatever\n * conflicts were explicitly picked; `mode: 'copy'` installs the new version\n * fresh and detaches the customised one.\n */\n const applyUpdate = useCallback(\n async (\n listingId: string,\n options: {\n mode: 'merge' | 'copy'\n takePaths?: string[]\n confirmDestructive?: boolean\n },\n ): Promise<boolean> => {\n const dequeue = queueLoading()\n try {\n const { response, payload } = await post(listingId, {\n action: 'apply',\n ...options,\n })\n if (!response.ok) {\n const locked = parseLockdownRefusal(response.status, payload)\n if (locked) {\n enqueueSnackbar(lockdownRefusalText(locked), {\n variant: 'warning',\n persist: true,\n })\n return false\n }\n enqueueSnackbar(payload?.error ?? 'Update failed', {\n variant: payload?.needsConfirmation ? 'warning' : 'error',\n allowDuplicate: true,\n })\n return false\n }\n if (options.mode === 'copy') {\n enqueueSnackbar(\n `Installed v${payload.version} as a new copy — your customized ` +\n 'version is kept, no longer linked to the listing.',\n { variant: 'success', persist: false },\n )\n } else {\n // The summary is the point of the whole flow: it says what moved and,\n // just as importantly, what was left alone.\n const skipped = payload.skipped?.length ?? 0\n enqueueSnackbar(\n // A version bump carrying no content change (AGL-1035). \"0 changes\n // applied\" would read as a failure; what happened is that the\n // version moved, which is the whole point of taking it.\n !payload.applied && !payload.keptLocal && !skipped\n ? `Now on v${payload.version} — this version changes nothing in your copy.`\n : `Updated to v${payload.version} — ${payload.applied} change(s) ` +\n `applied, ${payload.keptLocal} of yours kept` +\n (skipped ? `, ${skipped} conflict(s) left as yours` : '') +\n '.',\n { variant: 'success', persist: false },\n )\n }\n return true\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n return false\n } finally {\n dequeue()\n }\n },\n [post, queueLoading, enqueueSnackbar],\n )\n\n return { preview, loading, loadPreview, applyUpdate, setPreview }\n}\n\nexport default useArtifactUpdate\n"],"names":["lockdownRefusalText","parseLockdownRefusal","useLoading","useSnackbar","useCallback","useState","useUser","authorizedFetch","useArtifactUpdate","hostId","data","user","enqueueSnackbar","queueLoading","preview","setPreview","loading","setLoading","post","listingId","body","response","method","headers","JSON","stringify","payload","json","catch","loadPreview","action","ok","locked","status","variant","persist","error","allowDuplicate","console","applyUpdate","options","dequeue","needsConfirmation","mode","version","skipped","length","applied","keptLocal"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,mBAAmB,EAAEC,oBAAoB,QAAQ,eAAc;AACxE,SAASC,UAAU,QAAQ,uBAAsB;AACjD,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,WAAW,EAAEC,QAAQ,QAAQ,QAAO;AAC7C,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SAASC,eAAe,QAAQ,2CAA0C;AAwB1E;;;;;;;CAOC,GACD,OAAO,SAASC,kBAAkBC,MAAc;IAC9C,MAAM,EAAEC,MAAMC,IAAI,EAAE,GAAGL;IACvB,MAAM,EAAEM,eAAe,EAAE,GAAGT;IAC5B,MAAM,EAAEU,YAAY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,KACJ;oBAAEX,SAAS;oBAAWC,SAAS;gBAAM;YAEzC;YACA,OAAO;QACT,EAAE,OAAOC,OAAO;YACdE,QAAQF,KAAK,CAACA;YACdxB,gBAAgB,yBAAyB;gBACvCsB,SAAS;gBACTG,gBAAgB;YAClB;YACA,OAAO;QACT,SAAU;YACRI;QACF;IACF,GACA;QAACvB;QAAML;QAAcD;KAAgB;IAGvC,OAAO;QAAEE;QAASE;QAASa;QAAaU;QAAaxB;IAAW;AAClE;AAEA,eAAeP,kBAAiB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type InstallPlanStep } from '../model/marketplace';
|
|
2
|
+
/**
|
|
3
|
+
* Shared install/buy handlers for marketplace listings (AGL-95): used by the
|
|
4
|
+
* browse grid and the listing detail page. Install copies the pinned
|
|
5
|
+
* version snapshot server-side (/api/marketplace/install); buy opens a
|
|
6
|
+
* Stripe checkout (/api/marketplace/checkout) when configured.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useMarketplaceActions(hostId: string, orgId?: string | null): {
|
|
9
|
+
install: (listing: any, scope?: "org" | "host", options?: {
|
|
10
|
+
/**
|
|
11
|
+
* Called instead of an error toast when the install route refuses
|
|
12
|
+
* because the workspace's copy has been EDITED since it was installed
|
|
13
|
+
* (AGL-1018's 409, AGL-1034).
|
|
14
|
+
*
|
|
15
|
+
* The refusal is correct — that install would have destroyed their
|
|
16
|
+
* work — but "review the update" is only useful advice if something
|
|
17
|
+
* offers the review. Handling it here rather than at each call site
|
|
18
|
+
* means every surface that installs a copied artifact gets the
|
|
19
|
+
* recovery, including ones written later.
|
|
20
|
+
*/
|
|
21
|
+
onDiverged?: () => void;
|
|
22
|
+
}) => Promise<any>;
|
|
23
|
+
installPlan: (listing: any, steps: readonly InstallPlanStep[], options?: {
|
|
24
|
+
/**
|
|
25
|
+
* Re-pinning something already installed (AGL-1017). Only the wording
|
|
26
|
+
* changes — the route is the same, because moving a pin forward IS
|
|
27
|
+
* installing — but "Installed on 1 site" is the wrong sentence to read
|
|
28
|
+
* after pressing Update.
|
|
29
|
+
*/
|
|
30
|
+
intent?: "install" | "update";
|
|
31
|
+
/** The version being moved to, for the update summary. */
|
|
32
|
+
version?: string | number | null;
|
|
33
|
+
}) => Promise<void>;
|
|
34
|
+
buy: (listing: any) => Promise<any>;
|
|
35
|
+
uninstall: (listing: any, scope?: "org" | "host", targetHostId?: string) => Promise<any>;
|
|
36
|
+
};
|
|
37
|
+
export default useMarketplaceActions;
|