@suss/contract-serverless 0.34.0 → 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
@@ -44,6 +44,7 @@ __export(index_exports, {
44
44
  module.exports = __toCommonJS(index_exports);
45
45
  var import_node_path2 = __toESM(require("path"), 1);
46
46
  var import_behavioral_ir = require("@suss/behavioral-ir");
47
+ var import_files = require("@suss/behavioral-ir/files");
47
48
  var import_contract_cloudformation = require("@suss/contract-cloudformation");
48
49
 
49
50
  // src/document.ts
@@ -598,10 +599,12 @@ function serverlessFileToSummaries(servicePath, options = {}) {
598
599
  return [];
599
600
  }
600
601
  const document = loadServerlessDocument(located.file);
602
+ const { projectRoot, ...readOptions } = options;
603
+ const workspace = (0, import_files.projectNameOf)(import_node_path2.default.dirname(located.file));
601
604
  return serverlessToSummaries(document, {
602
- ...options,
603
- source: options.source ?? (0, import_contract_cloudformation.documentSourceLabel)("serverless", located.file)
604
- });
605
+ ...readOptions,
606
+ source: options.source ?? (0, import_files.documentSourceLabel)("serverless", located.file, projectRoot)
607
+ }).map((summary) => (0, import_behavioral_ir.withCodeScopeWorkspace)(summary, workspace));
605
608
  }
606
609
  function reportUnread(wiring) {
607
610
  const where = wiring.functionName === null ? wiring.kind : `${wiring.functionName}.${wiring.kind}`;
package/dist/index.d.cts CHANGED
@@ -195,11 +195,15 @@ interface ServerlessToSummariesOptions {
195
195
  */
196
196
  onUnread?: (wiring: UnreadWiring) => void;
197
197
  }
198
+ interface ServerlessFileToSummariesOptions extends ServerlessToSummariesOptions {
199
+ /** Absolute. The directory the service file's label is measured from. */
200
+ projectRoot?: string;
201
+ }
198
202
  declare function serverlessToSummaries(document: ServerlessDocument, options?: ServerlessToSummariesOptions): BehavioralSummary[];
199
203
  /**
200
204
  * Reads a service file and returns its summaries. The path may be the
201
205
  * service file itself or the directory it is in.
202
206
  */
203
- declare function serverlessFileToSummaries(servicePath: string, options?: ServerlessToSummariesOptions): BehavioralSummary[];
207
+ declare function serverlessFileToSummaries(servicePath: string, options?: ServerlessFileToSummariesOptions): BehavioralSummary[];
204
208
 
205
- export { EVENT_TRANSLATIONS, PROGRAM_SERVICE_FILE_NAMES, type ResolvedString, type ResolvedValue, SERVICE_FILE_NAMES, type ServerlessDocument, type ServerlessEvent, type ServerlessFunctionDefinition, type ServerlessToSummariesOptions, type ServiceLocation, type TranslatedService, type UnreadWiring, type VariableResolver, createVariableResolver, findServiceFile, loadServerlessDocument, locateServiceFile, serverlessFileToSummaries, serverlessToSummaries, translateService };
209
+ export { EVENT_TRANSLATIONS, PROGRAM_SERVICE_FILE_NAMES, type ResolvedString, type ResolvedValue, SERVICE_FILE_NAMES, type ServerlessDocument, type ServerlessEvent, type ServerlessFileToSummariesOptions, type ServerlessFunctionDefinition, type ServerlessToSummariesOptions, type ServiceLocation, type TranslatedService, type UnreadWiring, type VariableResolver, createVariableResolver, findServiceFile, loadServerlessDocument, locateServiceFile, serverlessFileToSummaries, serverlessToSummaries, translateService };
package/dist/index.d.ts CHANGED
@@ -195,11 +195,15 @@ interface ServerlessToSummariesOptions {
195
195
  */
196
196
  onUnread?: (wiring: UnreadWiring) => void;
197
197
  }
198
+ interface ServerlessFileToSummariesOptions extends ServerlessToSummariesOptions {
199
+ /** Absolute. The directory the service file's label is measured from. */
200
+ projectRoot?: string;
201
+ }
198
202
  declare function serverlessToSummaries(document: ServerlessDocument, options?: ServerlessToSummariesOptions): BehavioralSummary[];
199
203
  /**
200
204
  * Reads a service file and returns its summaries. The path may be the
201
205
  * service file itself or the directory it is in.
202
206
  */
203
- declare function serverlessFileToSummaries(servicePath: string, options?: ServerlessToSummariesOptions): BehavioralSummary[];
207
+ declare function serverlessFileToSummaries(servicePath: string, options?: ServerlessFileToSummariesOptions): BehavioralSummary[];
204
208
 
205
- export { EVENT_TRANSLATIONS, PROGRAM_SERVICE_FILE_NAMES, type ResolvedString, type ResolvedValue, SERVICE_FILE_NAMES, type ServerlessDocument, type ServerlessEvent, type ServerlessFunctionDefinition, type ServerlessToSummariesOptions, type ServiceLocation, type TranslatedService, type UnreadWiring, type VariableResolver, createVariableResolver, findServiceFile, loadServerlessDocument, locateServiceFile, serverlessFileToSummaries, serverlessToSummaries, translateService };
209
+ export { EVENT_TRANSLATIONS, PROGRAM_SERVICE_FILE_NAMES, type ResolvedString, type ResolvedValue, SERVICE_FILE_NAMES, type ServerlessDocument, type ServerlessEvent, type ServerlessFileToSummariesOptions, type ServerlessFunctionDefinition, type ServerlessToSummariesOptions, type ServiceLocation, type TranslatedService, type UnreadWiring, type VariableResolver, createVariableResolver, findServiceFile, loadServerlessDocument, locateServiceFile, serverlessFileToSummaries, serverlessToSummaries, translateService };
package/dist/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  // src/index.ts
2
2
  import path2 from "path";
3
- import { nestedDocumentLabel } from "@suss/behavioral-ir";
4
3
  import {
5
- cloudFormationToSummaries,
6
- documentSourceLabel
7
- } from "@suss/contract-cloudformation";
4
+ nestedDocumentLabel,
5
+ withCodeScopeWorkspace
6
+ } from "@suss/behavioral-ir";
7
+ import { documentSourceLabel, projectNameOf } from "@suss/behavioral-ir/files";
8
+ import { cloudFormationToSummaries } from "@suss/contract-cloudformation";
8
9
 
9
10
  // src/document.ts
10
11
  import fs from "fs";
@@ -558,10 +559,12 @@ function serverlessFileToSummaries(servicePath, options = {}) {
558
559
  return [];
559
560
  }
560
561
  const document = loadServerlessDocument(located.file);
562
+ const { projectRoot, ...readOptions } = options;
563
+ const workspace = projectNameOf(path2.dirname(located.file));
561
564
  return serverlessToSummaries(document, {
562
- ...options,
563
- source: options.source ?? documentSourceLabel("serverless", located.file)
564
- });
565
+ ...readOptions,
566
+ source: options.source ?? documentSourceLabel("serverless", located.file, projectRoot)
567
+ }).map((summary) => withCodeScopeWorkspace(summary, workspace));
565
568
  }
566
569
  function reportUnread(wiring) {
567
570
  const where = wiring.functionName === null ? wiring.kind : `${wiring.functionName}.${wiring.kind}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suss/contract-serverless",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "type": "module",
5
5
  "description": "Turn a Serverless Framework serverless.yml into a suss contract and check it against the Lambda handlers and clients behind it.",
6
6
  "keywords": [
@@ -48,11 +48,11 @@
48
48
  "typecheck": "tsc --noEmit"
49
49
  },
50
50
  "dependencies": {
51
- "@suss/behavioral-ir": "0.34.0",
52
- "@suss/contract-aws-apigateway": "0.34.0",
53
- "@suss/contract-cloudformation": "0.34.0",
54
- "@suss/ir-core": "0.34.0",
55
- "@suss/manifest-aws": "0.34.0",
51
+ "@suss/behavioral-ir": "0.35.0",
52
+ "@suss/contract-aws-apigateway": "0.35.0",
53
+ "@suss/contract-cloudformation": "0.35.0",
54
+ "@suss/ir-core": "0.35.0",
55
+ "@suss/manifest-aws": "0.35.0",
56
56
  "yaml": "^2.4.0"
57
57
  },
58
58
  "devDependencies": {