@awsless/awsless 0.0.184 → 0.0.186
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/bin.js +37 -4
- package/package.json +7 -7
package/dist/bin.js
CHANGED
|
@@ -2476,7 +2476,7 @@ var functionFeature = defineFeature({
|
|
|
2476
2476
|
import { paramCase as paramCase5 } from "change-case";
|
|
2477
2477
|
import { mergeTypeDefs } from "@graphql-tools/merge";
|
|
2478
2478
|
import { generate } from "@awsless/graphql";
|
|
2479
|
-
import { buildSchema, print } from "graphql";
|
|
2479
|
+
import { buildSchema, isObjectType, print } from "graphql";
|
|
2480
2480
|
import { readFile as readFile5 } from "fs/promises";
|
|
2481
2481
|
import { Asset as Asset2, Node as Node6, aws as aws6 } from "@awsless/formation";
|
|
2482
2482
|
|
|
@@ -2627,6 +2627,7 @@ var buildTypeScriptResolver = async (input, { minify = true } = {}) => {
|
|
|
2627
2627
|
};
|
|
2628
2628
|
|
|
2629
2629
|
// src/feature/graphql/index.ts
|
|
2630
|
+
import { createHash as createHash4 } from "crypto";
|
|
2630
2631
|
var defaultResolver = `
|
|
2631
2632
|
export function request(ctx) {
|
|
2632
2633
|
return {
|
|
@@ -2639,6 +2640,10 @@ export function response(ctx) {
|
|
|
2639
2640
|
return ctx.result
|
|
2640
2641
|
}
|
|
2641
2642
|
`;
|
|
2643
|
+
var baseSchema = `
|
|
2644
|
+
type Query
|
|
2645
|
+
type Mutation
|
|
2646
|
+
`;
|
|
2642
2647
|
var scalarSchema = `
|
|
2643
2648
|
scalar AWSDate
|
|
2644
2649
|
scalar AWSTime
|
|
@@ -2793,9 +2798,37 @@ var graphqlFeature = defineFeature({
|
|
|
2793
2798
|
}
|
|
2794
2799
|
}
|
|
2795
2800
|
});
|
|
2801
|
+
ctx.registerBuild("graphql-schema", id, async (build3) => {
|
|
2802
|
+
const source = await readFile5(props.schema, "utf8");
|
|
2803
|
+
const finger = createHash4("sha1").update(source).digest("hex");
|
|
2804
|
+
return build3(finger, async (write) => {
|
|
2805
|
+
const defs = mergeTypeDefs([scalarSchema, baseSchema, source]);
|
|
2806
|
+
const schema2 = buildSchema(print(defs));
|
|
2807
|
+
const output = generate(schema2);
|
|
2808
|
+
for (const [typeName, fields] of Object.entries(props.resolvers ?? {})) {
|
|
2809
|
+
const type = schema2.getType(typeName);
|
|
2810
|
+
if (!type || !isObjectType(type)) {
|
|
2811
|
+
throw new FileError(props.schema, `GraphQL schema type doesn't exist: ${typeName}`);
|
|
2812
|
+
}
|
|
2813
|
+
const typeFields = type.getFields();
|
|
2814
|
+
for (const fieldName of Object.keys(fields ?? {})) {
|
|
2815
|
+
if (!(fieldName in typeFields)) {
|
|
2816
|
+
throw new FileError(
|
|
2817
|
+
props.schema,
|
|
2818
|
+
`GraphQL schema field doesn't exist: ${typeName}.${fieldName}`
|
|
2819
|
+
);
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
await write("schema.gql", output);
|
|
2824
|
+
return {
|
|
2825
|
+
size: formatByteSize(Buffer.from(source).byteLength)
|
|
2826
|
+
};
|
|
2827
|
+
});
|
|
2828
|
+
});
|
|
2796
2829
|
const schema = new aws6.appsync.GraphQLSchema(group, "schema", {
|
|
2797
2830
|
apiId: api.id,
|
|
2798
|
-
definition: Asset2.fromFile(
|
|
2831
|
+
definition: Asset2.fromFile(getBuildPath("graphql-schema", id, "schema.gql"))
|
|
2799
2832
|
});
|
|
2800
2833
|
const association = new aws6.appsync.SourceApiAssociation(group, "association", {
|
|
2801
2834
|
mergedApiId: ctx.shared.get(`graphql-${id}-id`),
|
|
@@ -3390,9 +3423,9 @@ import { camelCase as camelCase5 } from "change-case";
|
|
|
3390
3423
|
import { relative as relative3 } from "path";
|
|
3391
3424
|
|
|
3392
3425
|
// src/util/id.ts
|
|
3393
|
-
import { createHash as
|
|
3426
|
+
import { createHash as createHash5 } from "crypto";
|
|
3394
3427
|
var shortId = (ns) => {
|
|
3395
|
-
return
|
|
3428
|
+
return createHash5("md5").update(ns).digest("hex").substring(0, 10);
|
|
3396
3429
|
};
|
|
3397
3430
|
|
|
3398
3431
|
// src/feature/http/index.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/awsless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.186",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@awsless/redis": "^0.0.12",
|
|
32
31
|
"@awsless/lambda": "^0.0.18",
|
|
33
|
-
"@awsless/sns": "^0.0.7",
|
|
34
32
|
"@awsless/s3": "^0.0.10",
|
|
33
|
+
"@awsless/sns": "^0.0.7",
|
|
34
|
+
"@awsless/redis": "^0.0.12",
|
|
35
35
|
"@awsless/sqs": "^0.0.7",
|
|
36
|
-
"@awsless/validate": "^0.0.13",
|
|
37
36
|
"@awsless/ssm": "^0.0.7",
|
|
37
|
+
"@awsless/validate": "^0.0.13",
|
|
38
38
|
"@awsless/weak-cache": "^0.0.1"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
@@ -96,11 +96,11 @@
|
|
|
96
96
|
"wrap-ansi": "^8.1.0",
|
|
97
97
|
"zod": "^3.21.4",
|
|
98
98
|
"zod-to-json-schema": "^3.22.3",
|
|
99
|
-
"@awsless/formation": "^0.0.
|
|
100
|
-
"@awsless/
|
|
99
|
+
"@awsless/formation": "^0.0.12",
|
|
100
|
+
"@awsless/duration": "^0.0.1",
|
|
101
101
|
"@awsless/size": "^0.0.1",
|
|
102
102
|
"@awsless/graphql": "^0.0.9",
|
|
103
|
-
"@awsless/
|
|
103
|
+
"@awsless/validate": "^0.0.13",
|
|
104
104
|
"@awsless/code": "^0.0.10"
|
|
105
105
|
},
|
|
106
106
|
"scripts": {
|