@ampless/mcp-server 1.0.0-alpha.38 → 1.0.0-alpha.40
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/dist/index.js +29 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -129,6 +129,17 @@ async function getPost(client, args) {
|
|
|
129
129
|
import {
|
|
130
130
|
encodeAwsJson
|
|
131
131
|
} from "ampless";
|
|
132
|
+
|
|
133
|
+
// src/tools/published-at.ts
|
|
134
|
+
function normalizePublishedAt(value) {
|
|
135
|
+
const d = new Date(value);
|
|
136
|
+
if (Number.isNaN(d.getTime())) {
|
|
137
|
+
throw new Error(`Invalid publishedAt: "${value}" could not be parsed as a date`);
|
|
138
|
+
}
|
|
139
|
+
return d.toISOString();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/tools/create-post.ts
|
|
132
143
|
var MUTATION = (
|
|
133
144
|
/* GraphQL */
|
|
134
145
|
`
|
|
@@ -181,7 +192,7 @@ var createPostSchema = {
|
|
|
181
192
|
async function createPost(client, args) {
|
|
182
193
|
const postId = args.postId ?? `post-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
183
194
|
const status = args.status ?? "draft";
|
|
184
|
-
const publishedAt = args.publishedAt
|
|
195
|
+
const publishedAt = args.publishedAt !== void 0 ? normalizePublishedAt(args.publishedAt) : status === "published" ? (/* @__PURE__ */ new Date()).toISOString() : void 0;
|
|
185
196
|
const data = await client.query(MUTATION, {
|
|
186
197
|
input: {
|
|
187
198
|
postId,
|
|
@@ -258,9 +269,17 @@ async function updatePost(client, args) {
|
|
|
258
269
|
if (args.format !== void 0) input.format = args.format;
|
|
259
270
|
if (args.body !== void 0) input.body = encodeAwsJson2(args.body);
|
|
260
271
|
if (args.status !== void 0) input.status = args.status;
|
|
261
|
-
if (args.publishedAt !== void 0)
|
|
272
|
+
if (args.publishedAt !== void 0) {
|
|
273
|
+
input.publishedAt = normalizePublishedAt(args.publishedAt);
|
|
274
|
+
}
|
|
262
275
|
if (args.tags !== void 0) input.tags = args.tags;
|
|
263
276
|
if (args.metadata !== void 0) input.metadata = encodeAwsJson2(args.metadata);
|
|
277
|
+
if (args.status === "published" && args.publishedAt === void 0) {
|
|
278
|
+
const existing = await getPost(client, { postId: args.postId });
|
|
279
|
+
if (existing && !existing.publishedAt) {
|
|
280
|
+
input.publishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
264
283
|
const data = await client.query(MUTATION2, { input });
|
|
265
284
|
return toCorePost(data.updatePost);
|
|
266
285
|
}
|
|
@@ -1275,11 +1294,17 @@ async function upsertStaticPost(graphql, slug, body, fields) {
|
|
|
1275
1294
|
if (fields.title !== void 0) input2.title = fields.title;
|
|
1276
1295
|
if (fields.excerpt !== void 0) input2.excerpt = fields.excerpt;
|
|
1277
1296
|
if (fields.status !== void 0) input2.status = fields.status;
|
|
1278
|
-
if (fields.publishedAt !== void 0)
|
|
1297
|
+
if (fields.publishedAt !== void 0) {
|
|
1298
|
+
input2.publishedAt = normalizePublishedAt(fields.publishedAt);
|
|
1299
|
+
}
|
|
1279
1300
|
if (fields.tags !== void 0) input2.tags = fields.tags;
|
|
1280
1301
|
if (fields.metadata !== void 0) {
|
|
1281
1302
|
input2.metadata = encodeAwsJson4(fields.metadata);
|
|
1282
1303
|
}
|
|
1304
|
+
const effectiveStatus = fields.status ?? existing.status;
|
|
1305
|
+
if (effectiveStatus === "published" && fields.publishedAt === void 0 && !existing.publishedAt) {
|
|
1306
|
+
input2.publishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1307
|
+
}
|
|
1283
1308
|
const data2 = await graphql.query(UPDATE_MUTATION, { input: input2 });
|
|
1284
1309
|
const updated = toCorePost(data2.updatePost);
|
|
1285
1310
|
return { post: updated, created: false };
|
|
@@ -1290,7 +1315,7 @@ async function upsertStaticPost(graphql, slug, body, fields) {
|
|
|
1290
1315
|
);
|
|
1291
1316
|
}
|
|
1292
1317
|
const status = fields.status ?? "draft";
|
|
1293
|
-
const publishedAt = fields.publishedAt
|
|
1318
|
+
const publishedAt = fields.publishedAt !== void 0 ? normalizePublishedAt(fields.publishedAt) : status === "published" ? (/* @__PURE__ */ new Date()).toISOString() : void 0;
|
|
1294
1319
|
const postId = fields.postId ?? `post-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
1295
1320
|
const input = {
|
|
1296
1321
|
postId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ampless/mcp-server",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.40",
|
|
4
4
|
"description": "MCP tool registry shared by @ampless/backend mcp-handler Lambda. Installed transitively via @ampless/admin / @ampless/backend; no direct install needed.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"bugs": "https://github.com/heavymoons/ampless/issues",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"fflate": "^0.8.3",
|
|
29
|
-
"ampless": "1.0.0-alpha.
|
|
29
|
+
"ampless": "1.0.0-alpha.34"
|
|
30
30
|
},
|
|
31
31
|
"keywords": [
|
|
32
32
|
"ampless",
|