@ampless/backend 1.0.0-alpha.33 → 1.0.0-alpha.34
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.
|
@@ -25,7 +25,7 @@ interface CreateProcessorTrustedHandlerOpts {
|
|
|
25
25
|
* SQS-driven trusted plugin executor. Trusted plugins get a runtime
|
|
26
26
|
* context with `listPublishedPosts` (one Query against the byStatus
|
|
27
27
|
* GSI) and `writePublicAsset` (S3 PutObject under
|
|
28
|
-
* `public/plugins/{name}/{key}`).
|
|
28
|
+
* `public/plugins/{instanceId ?? name}/{key}`).
|
|
29
29
|
*
|
|
30
30
|
* Built-in: rebuilds the site-settings JSON cache at
|
|
31
31
|
* `public/site-settings.json` whenever a `site.settings.updated`
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
QueryCommand
|
|
9
9
|
} from "@aws-sdk/lib-dynamodb";
|
|
10
10
|
import {
|
|
11
|
-
formatPublicAssetUrl
|
|
11
|
+
formatPublicAssetUrl,
|
|
12
|
+
validatePublicAssetKey
|
|
12
13
|
} from "ampless";
|
|
13
14
|
|
|
14
15
|
// src/events/posttag-sync.ts
|
|
@@ -57,6 +58,17 @@ function createProcessorTrustedHandler(opts) {
|
|
|
57
58
|
const trustedPlugins = (opts.plugins ?? []).filter(
|
|
58
59
|
(p) => typeof p === "object" && p.trust_level === "trusted"
|
|
59
60
|
);
|
|
61
|
+
const seenNamespaces = /* @__PURE__ */ new Set();
|
|
62
|
+
for (const plugin of trustedPlugins) {
|
|
63
|
+
const ns = plugin.instanceId ?? plugin.name;
|
|
64
|
+
if (seenNamespaces.has(ns)) {
|
|
65
|
+
console.warn(
|
|
66
|
+
`[trusted-processor] duplicate plugin namespace "${ns}" detected in trusted plugins. Set distinct \`instanceId\` on each instance to disambiguate writePublicAsset output.`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
seenNamespaces.add(ns);
|
|
70
|
+
}
|
|
71
|
+
const warnedWritePublicAssetCapability = /* @__PURE__ */ new Set();
|
|
60
72
|
const s3 = new S3Client({});
|
|
61
73
|
const ddb = DynamoDBDocumentClient.from(new DynamoDBClient({}));
|
|
62
74
|
const BUCKET = requireEnv("AMPLESS_BUCKET_NAME");
|
|
@@ -97,11 +109,23 @@ function createProcessorTrustedHandler(opts) {
|
|
|
97
109
|
return items;
|
|
98
110
|
}
|
|
99
111
|
function makeContext(plugin) {
|
|
112
|
+
const namespace = plugin.instanceId ?? plugin.name;
|
|
113
|
+
const label = plugin.instanceId ? `${plugin.name}#${plugin.instanceId}` : plugin.name;
|
|
100
114
|
return {
|
|
101
115
|
site: opts.site,
|
|
102
116
|
listPublishedPosts: () => listPublished(),
|
|
103
117
|
async writePublicAsset(key, body, contentType) {
|
|
104
|
-
const
|
|
118
|
+
const keyError = validatePublicAssetKey(key);
|
|
119
|
+
if (keyError) {
|
|
120
|
+
throw new Error(`[${plugin.name}] writePublicAsset: ${keyError}`);
|
|
121
|
+
}
|
|
122
|
+
if (plugin.capabilities && !plugin.capabilities.includes("writePublicAsset") && !warnedWritePublicAssetCapability.has(label)) {
|
|
123
|
+
console.warn(
|
|
124
|
+
`[trusted-processor] ${label}: called ctx.writePublicAsset() but "writePublicAsset" is not in declared capabilities. Add it so admin UI / capability gates see the surface.`
|
|
125
|
+
);
|
|
126
|
+
warnedWritePublicAssetCapability.add(label);
|
|
127
|
+
}
|
|
128
|
+
const objectKey = `public/plugins/${namespace}/${key}`;
|
|
105
129
|
await s3.send(
|
|
106
130
|
new PutObjectCommand({
|
|
107
131
|
Bucket: BUCKET,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ampless/backend",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.34",
|
|
4
4
|
"description": "Amplify Gen 2 backend factories for ampless: auth, data, storage, event processors, API key renewer",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"@smithy/protocol-http": "^5.4.4",
|
|
66
66
|
"@smithy/signature-v4": "^5.4.4",
|
|
67
67
|
"fflate": "^0.8.3",
|
|
68
|
-
"ampless": "1.0.0-alpha.
|
|
69
|
-
"@ampless/mcp-server": "1.0.0-alpha.
|
|
68
|
+
"ampless": "1.0.0-alpha.19",
|
|
69
|
+
"@ampless/mcp-server": "1.0.0-alpha.23"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"@aws-amplify/backend": "^1",
|