@suss/packs 0.19.0 → 0.20.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/mongoose.js CHANGED
@@ -112,19 +112,9 @@ function collectionOf(_selector, call) {
112
112
  return model.nameAt(2, "nothing") ?? schemaCollectionOf(model) ?? pluralized(modelName);
113
113
  }
114
114
  function modelCallIn(call) {
115
- const receiver = call.receiver();
116
- if (receiver === null) {
117
- return null;
118
- }
119
- return modelFactoryCall(receiver) ?? modelFactoryCall(receiver.callee()) ?? modelFactoryCall(receiver.receiver());
120
- }
121
- function modelFactoryCall(call) {
122
- if (call === null) {
123
- return null;
124
- }
125
- const named = call.method() ?? call.calleeText();
126
- const fromLibrary = call.isFrom(constructedFrom(CLIENT_MODULE));
127
- return named === MODEL_FACTORY && fromLibrary ? call : null;
115
+ return call.anchorCall?.(
116
+ constructedFrom({ from: [CLIENT_MODULE], named: [MODEL_FACTORY] })
117
+ ) ?? null;
128
118
  }
129
119
  function schemaCollectionOf(model) {
130
120
  return model.argument(1)?.propertyAt(1, "collection", "nothing") ?? null;
package/dist/nextjs.js CHANGED
@@ -268423,13 +268423,17 @@ function bodyStartsWithDirective(fn) {
268423
268423
  }
268424
268424
  return leadingDirectives(body.getStatements()).includes(DIRECTIVE);
268425
268425
  }
268426
- function actionUnit(func, name) {
268426
+ function actionUnit(func, name, module) {
268427
268427
  return {
268428
268428
  func,
268429
268429
  kind: "action",
268430
268430
  name,
268431
268431
  terminals: ACTION_TERMINALS,
268432
- inputMapping: { type: "allPositional" }
268432
+ inputMapping: { type: "allPositional" },
268433
+ // The identity intent and the keyed pairing pass refer to the
268434
+ // action by. The path is absolute here and the CLI makes it
268435
+ // project-relative with every other path on the summary.
268436
+ functionCallInfo: { module, exportName: name }
268433
268437
  };
268434
268438
  }
268435
268439
  function inlineName(fn) {
@@ -268450,6 +268454,7 @@ function nextjsServerActions(sourceFile, _ctx) {
268450
268454
  const out = [];
268451
268455
  const claimed = /* @__PURE__ */ new Set();
268452
268456
  const fileLevel = fileIsServerModule(sf);
268457
+ const module = sf.getFilePath();
268453
268458
  for (const fn of sf.getFunctions()) {
268454
268459
  const name = fn.getName();
268455
268460
  if (name === void 0 || fn.getBody() === void 0) {
@@ -268457,7 +268462,7 @@ function nextjsServerActions(sourceFile, _ctx) {
268457
268462
  }
268458
268463
  if (fileLevel && fn.isExported() || bodyStartsWithDirective(fn)) {
268459
268464
  claimed.add(fn);
268460
- out.push(actionUnit(fn, name));
268465
+ out.push(actionUnit(fn, name, module));
268461
268466
  }
268462
268467
  }
268463
268468
  for (const statement of sf.getVariableStatements()) {
@@ -268468,7 +268473,7 @@ function nextjsServerActions(sourceFile, _ctx) {
268468
268473
  const init = decl.getInitializer();
268469
268474
  if (init !== void 0 && (import_ts_morph.Node.isArrowFunction(init) || import_ts_morph.Node.isFunctionExpression(init))) {
268470
268475
  claimed.add(init);
268471
- out.push(actionUnit(init, decl.getName()));
268476
+ out.push(actionUnit(init, decl.getName(), module));
268472
268477
  }
268473
268478
  }
268474
268479
  }
@@ -268484,10 +268489,10 @@ function nextjsServerActions(sourceFile, _ctx) {
268484
268489
  claimed.add(fn);
268485
268490
  const name = inlineName(fn);
268486
268491
  if (name === null) {
268487
- out.push(actionUnit(fn, `serverAction#${inlineIndex}`));
268492
+ out.push(actionUnit(fn, `serverAction#${inlineIndex}`, module));
268488
268493
  inlineIndex += 1;
268489
268494
  } else {
268490
- out.push(actionUnit(fn, name));
268495
+ out.push(actionUnit(fn, name, module));
268491
268496
  }
268492
268497
  }
268493
268498
  return out;
@@ -2,6 +2,7 @@ import "./chunk-3RG5ZIWI.js";
2
2
 
3
3
  // ../framework/react-query/dist/index.js
4
4
  import { Node } from "ts-morph";
5
+ import { importedNamesOf } from "@suss/adapter-typescript";
5
6
  import { functionCallBinding } from "@suss/behavioral-ir";
6
7
  var QUERY_MODULES = ["@tanstack/react-query", "react-query"];
7
8
  var HOOK_CALLBACK_PROPERTY = {
@@ -13,15 +14,9 @@ var HOOK_CALLBACK_PROPERTY = {
13
14
  };
14
15
  function importedHooksOf(sourceFile) {
15
16
  const hooks = /* @__PURE__ */ new Map();
16
- for (const decl of sourceFile.getImportDeclarations()) {
17
- if (!QUERY_MODULES.includes(decl.getModuleSpecifierValue())) {
18
- continue;
19
- }
20
- for (const named of decl.getNamedImports()) {
21
- const name = named.getName();
22
- if (name in HOOK_CALLBACK_PROPERTY) {
23
- hooks.set(named.getAliasNode()?.getText() ?? name, name);
24
- }
17
+ for (const [local, canonical] of importedNamesOf(sourceFile, QUERY_MODULES)) {
18
+ if (canonical in HOOK_CALLBACK_PROPERTY) {
19
+ hooks.set(local, canonical);
25
20
  }
26
21
  }
27
22
  return hooks;
package/dist/react.js CHANGED
@@ -2,6 +2,11 @@ import "./chunk-3RG5ZIWI.js";
2
2
 
3
3
  // ../framework/react/dist/index.js
4
4
  import { Node } from "ts-morph";
5
+ import {
6
+ functionTargetOf,
7
+ importedNamesOf,
8
+ importedRootsOf
9
+ } from "@suss/adapter-typescript";
5
10
  var STORY_FILE_PATTERN = /\.stories\.tsx?$/;
6
11
  var TEST_FILE_PATTERN = /\.(test|spec)\.tsx?$/;
7
12
  function startsWithUppercase(name) {
@@ -41,34 +46,15 @@ var BOOT_CALLEES = ["createRoot", "hydrateRoot"];
41
46
  var BOOT_MODULES = ["react-dom/client", "react-dom"];
42
47
  function importedBootNames(sourceFile) {
43
48
  const names = /* @__PURE__ */ new Set();
44
- for (const decl of sourceFile.getImportDeclarations()) {
45
- if (!BOOT_MODULES.includes(decl.getModuleSpecifierValue())) {
46
- continue;
47
- }
48
- for (const named of decl.getNamedImports()) {
49
- if (BOOT_CALLEES.includes(named.getName())) {
50
- names.add(named.getAliasNode()?.getText() ?? named.getName());
51
- }
49
+ for (const [local, canonical] of importedNamesOf(sourceFile, BOOT_MODULES)) {
50
+ if (BOOT_CALLEES.includes(canonical)) {
51
+ names.add(local);
52
52
  }
53
53
  }
54
54
  return names;
55
55
  }
56
56
  function importedDomNamespaces(sourceFile) {
57
- const names = /* @__PURE__ */ new Set();
58
- for (const decl of sourceFile.getImportDeclarations()) {
59
- if (!BOOT_MODULES.includes(decl.getModuleSpecifierValue())) {
60
- continue;
61
- }
62
- const namespace = decl.getNamespaceImport()?.getText();
63
- if (namespace !== void 0) {
64
- names.add(namespace);
65
- }
66
- const defaultImport = decl.getDefaultImport()?.getText();
67
- if (defaultImport !== void 0) {
68
- names.add(defaultImport);
69
- }
70
- }
71
- return names;
57
+ return importedRootsOf(sourceFile, BOOT_MODULES);
72
58
  }
73
59
  function isBootRender(call, bootNames, domNamespaces) {
74
60
  const callee = call.getExpression();
@@ -101,20 +87,8 @@ function renderedComponentOf(call) {
101
87
  if (tag === null || !/^[A-Z]/.test(tag.getText())) {
102
88
  return null;
103
89
  }
104
- const symbol = tag.getSymbol();
105
- const aliased = symbol?.getAliasedSymbol();
106
- for (const decl of (aliased ?? symbol)?.getDeclarations() ?? []) {
107
- if (Node.isFunctionDeclaration(decl) && decl.getBody() !== void 0) {
108
- return { func: decl, name: decl.getName() ?? tag.getText() };
109
- }
110
- if (Node.isVariableDeclaration(decl)) {
111
- const init = decl.getInitializer();
112
- if (init !== void 0 && (Node.isArrowFunction(init) || Node.isFunctionExpression(init))) {
113
- return { func: init, name: decl.getName() };
114
- }
115
- }
116
- }
117
- return null;
90
+ const target = functionTargetOf(tag);
91
+ return target === null ? null : { func: target.func, name: target.name };
118
92
  }
119
93
  var reactRootComponents = (sourceFile, _ctx) => {
120
94
  const sf = sourceFile;
package/dist/zustand.js CHANGED
@@ -20,12 +20,12 @@ var METHODS = {
20
20
  function storeNameOf(_names, call) {
21
21
  const callee = call.calleeText();
22
22
  const dot = callee.lastIndexOf(".");
23
- return dot > 0 ? callee.slice(0, dot) : null;
23
+ return dot > 0 ? callee.slice(0, dot) : callee;
24
24
  }
25
25
  var STORE_CALLS = storageCalls({
26
26
  system: "client-store",
27
27
  client: constructedFrom("zustand", "zustand/vanilla")
28
- }).methods(METHODS).container(storeNameOf).example("useAppStore.setState({ bears: 5 })");
28
+ }).methods(METHODS).calls({ kind: "read", fields: { selectorParam: 0 } }).container(storeNameOf).example("useAppStore((s) => s.bears)");
29
29
  function zustandFramework() {
30
30
  return pack("zustand", [STORE_CALLS], {
31
31
  languages: ["typescript", "javascript"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suss/packs",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "type": "module",
5
5
  "description": "Every pack suss ships, as one package with a subpath per pack.",
6
6
  "keywords": [
@@ -173,15 +173,15 @@
173
173
  "ts-morph": "^23.0.0"
174
174
  },
175
175
  "dependencies": {
176
- "@suss/adapter-python": "0.19.0",
177
- "@suss/adapter-ruby": "0.19.0",
178
- "@suss/adapter-typescript": "0.19.0",
179
- "@suss/behavioral-ir": "0.19.0",
180
- "@suss/contract-graphql": "0.19.0",
181
- "@suss/extractor": "0.19.0",
182
- "@suss/manifest-aws": "0.19.0",
183
- "@suss/recognize": "0.19.0",
184
- "@suss/sql": "0.19.0"
176
+ "@suss/adapter-python": "0.20.0",
177
+ "@suss/adapter-ruby": "0.20.0",
178
+ "@suss/adapter-typescript": "0.20.0",
179
+ "@suss/behavioral-ir": "0.20.0",
180
+ "@suss/contract-graphql": "0.20.0",
181
+ "@suss/extractor": "0.20.0",
182
+ "@suss/manifest-aws": "0.20.0",
183
+ "@suss/recognize": "0.20.0",
184
+ "@suss/sql": "0.20.0"
185
185
  },
186
186
  "devDependencies": {
187
187
  "@suss/client-apollo": "*",