@ampless/backend 0.2.0-alpha.13 → 0.2.0-alpha.15

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.
@@ -4,10 +4,12 @@ import "../chunk-BYXBJQAS.js";
4
4
  import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
5
5
  import { DynamoDBDocumentClient, GetCommand } from "@aws-sdk/lib-dynamodb";
6
6
  import { createHash } from "crypto";
7
+ import { decodeAwsJson as decodeAwsJson2 } from "ampless";
7
8
 
8
- // ../mcp-server/dist/chunk-KM6F5QJH.js
9
- import { composeSiteIdStatus, composeSiteIdSlug } from "ampless";
10
- import { composeSiteIdStatus as composeSiteIdStatus2, composeSiteIdSlug as composeSiteIdSlug2 } from "ampless";
9
+ // ../mcp-server/dist/chunk-6LH275IC.js
10
+ import { decodeAwsJson } from "ampless";
11
+ import { composeSiteIdStatus, composeSiteIdSlug, encodeAwsJson } from "ampless";
12
+ import { composeSiteIdStatus as composeSiteIdStatus2, composeSiteIdSlug as composeSiteIdSlug2, encodeAwsJson as encodeAwsJson2 } from "ampless";
11
13
  var POST_FIELDS = (
12
14
  /* GraphQL */
13
15
  `
@@ -25,18 +27,6 @@ var POST_FIELDS = (
25
27
  }
26
28
  `
27
29
  );
28
- function decodeBody(value) {
29
- if (typeof value !== "string") return value;
30
- try {
31
- return JSON.parse(value);
32
- } catch {
33
- return value;
34
- }
35
- }
36
- function encodeBody(value) {
37
- if (typeof value === "string") return value;
38
- return JSON.stringify(value ?? null);
39
- }
40
30
  function toCorePost(p) {
41
31
  return {
42
32
  siteId: p.siteId,
@@ -45,7 +35,7 @@ function toCorePost(p) {
45
35
  title: p.title,
46
36
  excerpt: p.excerpt ?? void 0,
47
37
  format: p.format ?? "markdown",
48
- body: decodeBody(p.body),
38
+ body: decodeAwsJson(p.body),
49
39
  status: p.status ?? "draft",
50
40
  publishedAt: p.publishedAt ?? void 0,
51
41
  tags: (p.tags ?? []).filter((t) => typeof t === "string")
@@ -266,7 +256,7 @@ async function createPost(client, defaultSiteId, args) {
266
256
  title: args.title,
267
257
  excerpt: args.excerpt,
268
258
  format: args.format,
269
- body: encodeBody(args.body),
259
+ body: encodeAwsJson(args.body),
270
260
  status,
271
261
  publishedAt,
272
262
  tags: args.tags,
@@ -314,7 +304,7 @@ async function updatePost(client, defaultSiteId, args) {
314
304
  if (args.title !== void 0) input.title = args.title;
315
305
  if (args.excerpt !== void 0) input.excerpt = args.excerpt;
316
306
  if (args.format !== void 0) input.format = args.format;
317
- if (args.body !== void 0) input.body = encodeBody(args.body);
307
+ if (args.body !== void 0) input.body = encodeAwsJson2(args.body);
318
308
  if (args.status !== void 0) input.status = args.status;
319
309
  if (args.publishedAt !== void 0) input.publishedAt = args.publishedAt;
320
310
  if (args.tags !== void 0) input.tags = args.tags;
@@ -637,15 +627,9 @@ async function validateBearer(plaintext) {
637
627
  return meta;
638
628
  }
639
629
  function decodeTokenMeta(value) {
640
- if (typeof value === "object") return value;
641
- if (typeof value === "string") {
642
- try {
643
- return JSON.parse(value);
644
- } catch {
645
- return null;
646
- }
647
- }
648
- return null;
630
+ const parsed = decodeAwsJson2(value);
631
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
632
+ return parsed;
649
633
  }
650
634
  var cachedCtx = null;
651
635
  function makeContext(meta) {
package/dist/index.d.ts CHANGED
@@ -217,6 +217,14 @@ interface AmplessSchemaAuthorizationOpts {
217
217
  * `amplify/data/resource.ts`. When no Lambda function refs are
218
218
  * supplied the function returns `[]`, so the schema stays unaffected.
219
219
  *
220
+ * Return type is `any[]` (matching the rest of this module's
221
+ * intentional looseness around `@aws-amplify/data-schema`'s heavily
222
+ * generic builder types) so callers don't have to wrestle the
223
+ * generic `SchemaAuthorization<…>` parameters that change between
224
+ * minor versions. `amplify/data/resource.ts` strict-type-checks fine
225
+ * downstream because the schema itself still resolves through
226
+ * `ClientSchema<typeof schema>` correctly.
227
+ *
220
228
  * Usage:
221
229
  *
222
230
  * const schema = a.schema({
@@ -226,7 +234,7 @@ interface AmplessSchemaAuthorizationOpts {
226
234
  * mcpHandlerFunction: mcpHandler,
227
235
  * }))
228
236
  */
229
- declare function amplessSchemaAuthorization(allow: any, opts?: AmplessSchemaAuthorizationOpts): unknown[];
237
+ declare function amplessSchemaAuthorization(allow: any, opts?: AmplessSchemaAuthorizationOpts): any[];
230
238
  /**
231
239
  * Standard authorization modes for ampless. `userPool` is the default
232
240
  * (admin/editor access); the API key serves the public read endpoints
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampless/backend",
3
- "version": "0.2.0-alpha.13",
3
+ "version": "0.2.0-alpha.15",
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",
@@ -64,8 +64,8 @@
64
64
  "@aws-sdk/util-dynamodb": "^3.717.0",
65
65
  "@smithy/protocol-http": "^5.3.0",
66
66
  "@smithy/signature-v4": "^5.4.0",
67
- "ampless": "0.2.0-alpha.6",
68
- "@ampless/mcp-server": "0.2.0-alpha.6"
67
+ "ampless": "0.2.0-alpha.7",
68
+ "@ampless/mcp-server": "0.2.0-alpha.7"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@aws-amplify/backend": "^1",