@suss/contract-appsync 0.34.1 → 0.35.0

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.cjs CHANGED
@@ -35,6 +35,7 @@ __export(index_exports, {
35
35
  });
36
36
  module.exports = __toCommonJS(index_exports);
37
37
  var import_node_path2 = __toESM(require("path"), 1);
38
+ var import_files = require("@suss/behavioral-ir/files");
38
39
  var import_manifest_aws2 = require("@suss/manifest-aws");
39
40
 
40
41
  // src/refs.ts
@@ -745,8 +746,9 @@ function indexSchemas(resolvedByApi) {
745
746
  }
746
747
  function appsyncFileToSummaries(filePath, options = {}) {
747
748
  const template = (0, import_manifest_aws2.loadCloudFormationTemplate)(filePath);
749
+ const root = options.projectRoot ?? (0, import_files.defaultProjectRoot)(filePath);
748
750
  return appsyncToSummaries(template, {
749
- source: options.source ?? import_node_path2.default.relative(process.cwd(), filePath),
751
+ source: options.source ?? (0, import_files.pathInProject)(filePath, root),
750
752
  baseDir: options.baseDir ?? import_node_path2.default.dirname(filePath)
751
753
  });
752
754
  }
package/dist/index.d.cts CHANGED
@@ -35,6 +35,10 @@ interface AppsyncToSummariesOptions {
35
35
  */
36
36
  baseDir?: string;
37
37
  }
38
+ interface AppsyncFileToSummariesOptions extends AppsyncToSummariesOptions {
39
+ /** Absolute. The directory the template's path is measured from. */
40
+ projectRoot?: string;
41
+ }
38
42
  /**
39
43
  * Converts a template already in memory, such as a CDK
40
44
  * `Template.fromStack` result, to AppSync resolver summaries.
@@ -44,6 +48,6 @@ declare function appsyncToSummaries(template: CfnTemplate, options?: AppsyncToSu
44
48
  * Reads a CloudFormation or SAM template, in JSON or YAML, and converts
45
49
  * it. A relative schema path resolves against the template's directory.
46
50
  */
47
- declare function appsyncFileToSummaries(filePath: string, options?: AppsyncToSummariesOptions): BehavioralSummary[];
51
+ declare function appsyncFileToSummaries(filePath: string, options?: AppsyncFileToSummariesOptions): BehavioralSummary[];
48
52
 
49
- export { type AppsyncToSummariesOptions, type CfnTemplate, appsyncFileToSummaries, appsyncToSummaries };
53
+ export { type AppsyncFileToSummariesOptions, type AppsyncToSummariesOptions, type CfnTemplate, appsyncFileToSummaries, appsyncToSummaries };
package/dist/index.d.ts CHANGED
@@ -35,6 +35,10 @@ interface AppsyncToSummariesOptions {
35
35
  */
36
36
  baseDir?: string;
37
37
  }
38
+ interface AppsyncFileToSummariesOptions extends AppsyncToSummariesOptions {
39
+ /** Absolute. The directory the template's path is measured from. */
40
+ projectRoot?: string;
41
+ }
38
42
  /**
39
43
  * Converts a template already in memory, such as a CDK
40
44
  * `Template.fromStack` result, to AppSync resolver summaries.
@@ -44,6 +48,6 @@ declare function appsyncToSummaries(template: CfnTemplate, options?: AppsyncToSu
44
48
  * Reads a CloudFormation or SAM template, in JSON or YAML, and converts
45
49
  * it. A relative schema path resolves against the template's directory.
46
50
  */
47
- declare function appsyncFileToSummaries(filePath: string, options?: AppsyncToSummariesOptions): BehavioralSummary[];
51
+ declare function appsyncFileToSummaries(filePath: string, options?: AppsyncFileToSummariesOptions): BehavioralSummary[];
48
52
 
49
- export { type AppsyncToSummariesOptions, type CfnTemplate, appsyncFileToSummaries, appsyncToSummaries };
53
+ export { type AppsyncFileToSummariesOptions, type AppsyncToSummariesOptions, type CfnTemplate, appsyncFileToSummaries, appsyncToSummaries };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // src/index.ts
2
2
  import path2 from "path";
3
+ import { defaultProjectRoot, pathInProject } from "@suss/behavioral-ir/files";
3
4
  import { loadCloudFormationTemplate } from "@suss/manifest-aws";
4
5
 
5
6
  // src/refs.ts
@@ -718,8 +719,9 @@ function indexSchemas(resolvedByApi) {
718
719
  }
719
720
  function appsyncFileToSummaries(filePath, options = {}) {
720
721
  const template = loadCloudFormationTemplate(filePath);
722
+ const root = options.projectRoot ?? defaultProjectRoot(filePath);
721
723
  return appsyncToSummaries(template, {
722
- source: options.source ?? path2.relative(process.cwd(), filePath),
724
+ source: options.source ?? pathInProject(filePath, root),
723
725
  baseDir: options.baseDir ?? path2.dirname(filePath)
724
726
  });
725
727
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suss/contract-appsync",
3
- "version": "0.34.1",
3
+ "version": "0.35.0",
4
4
  "type": "module",
5
5
  "description": "Turn the AppSync API in a CloudFormation or SAM template into a suss contract and check it against the resolvers and clients on either side of it.",
6
6
  "keywords": [
@@ -48,9 +48,9 @@
48
48
  "typecheck": "tsc --noEmit"
49
49
  },
50
50
  "dependencies": {
51
- "@suss/behavioral-ir": "0.34.1",
52
- "@suss/contract-graphql": "0.34.1",
53
- "@suss/manifest-aws": "0.34.1",
51
+ "@suss/behavioral-ir": "0.35.0",
52
+ "@suss/contract-graphql": "0.35.0",
53
+ "@suss/manifest-aws": "0.35.0",
54
54
  "graphql": "^16.8.0"
55
55
  },
56
56
  "devDependencies": {