@pikku/inspector 0.12.75 → 0.12.81
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/CHANGELOG.md +330 -0
- package/dist/add/add-analytics.d.ts +9 -0
- package/dist/add/add-analytics.js +178 -0
- package/dist/add/add-auth.js +0 -54
- package/dist/add/add-feature-flag.d.ts +2 -0
- package/dist/add/add-feature-flag.js +162 -0
- package/dist/add/add-wire-addon.js +1 -0
- package/dist/add/add-wire-remote-addon.js +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/inspector.js +4 -0
- package/dist/surface/collect-surface.d.ts +58 -0
- package/dist/surface/collect-surface.js +613 -0
- package/dist/types.d.ts +20 -11
- package/dist/utils/filter-inspector-state.js +14 -0
- package/dist/utils/post-process.js +15 -0
- package/dist/utils/read-module-specifiers.d.ts +8 -0
- package/dist/utils/read-module-specifiers.js +23 -0
- package/dist/utils/read-tsconfig-out-dir.d.ts +5 -0
- package/dist/utils/read-tsconfig-out-dir.js +12 -0
- package/dist/utils/resolve-deploy-target.d.ts +7 -0
- package/dist/utils/resolve-deploy-target.js +15 -7
- package/dist/utils/serialize-inspector-state.d.ts +5 -0
- package/dist/utils/serialize-inspector-state.js +8 -0
- package/dist/visit.js +4 -0
- package/package.json +16 -6
- package/run-tests.sh +21 -6
- package/src/add/add-addon-bans.ts +0 -85
- package/src/add/add-agent-scorer.test.ts +0 -197
- package/src/add/add-agent-scorer.ts +0 -83
- package/src/add/add-agent.test.ts +0 -87
- package/src/add/add-agent.ts +0 -638
- package/src/add/add-approval-description.ts +0 -76
- package/src/add/add-auth.test.ts +0 -791
- package/src/add/add-auth.ts +0 -424
- package/src/add/add-channel.ts +0 -778
- package/src/add/add-cli-renderers.test.ts +0 -74
- package/src/add/add-cli.ts +0 -1006
- package/src/add/add-credential.ts +0 -186
- package/src/add/add-feature.test.ts +0 -306
- package/src/add/add-feature.ts +0 -253
- package/src/add/add-file-extends-core-type.ts +0 -66
- package/src/add/add-file-with-config.ts +0 -45
- package/src/add/add-file-with-factory.test.ts +0 -134
- package/src/add/add-file-with-factory.ts +0 -288
- package/src/add/add-functions.test.ts +0 -743
- package/src/add/add-functions.ts +0 -1548
- package/src/add/add-gateway.ts +0 -143
- package/src/add/add-http-route-ref.test.ts +0 -149
- package/src/add/add-http-route.ts +0 -530
- package/src/add/add-http-routes.ts +0 -471
- package/src/add/add-keyed-wiring.ts +0 -180
- package/src/add/add-mcp-prompt.ts +0 -157
- package/src/add/add-mcp-resource.ts +0 -175
- package/src/add/add-middleware.test.ts +0 -196
- package/src/add/add-middleware.ts +0 -879
- package/src/add/add-permission-auth.test.ts +0 -59
- package/src/add/add-permission.ts +0 -311
- package/src/add/add-personas.test.ts +0 -406
- package/src/add/add-personas.ts +0 -287
- package/src/add/add-queue-worker.ts +0 -117
- package/src/add/add-rpc-invocations.test.ts +0 -287
- package/src/add/add-rpc-invocations.ts +0 -221
- package/src/add/add-scenario-step.test.ts +0 -509
- package/src/add/add-schedule.ts +0 -120
- package/src/add/add-scope.test.ts +0 -419
- package/src/add/add-scope.ts +0 -221
- package/src/add/add-secret.ts +0 -10
- package/src/add/add-subject-scenario-steps.test.ts +0 -161
- package/src/add/add-system-role.test.ts +0 -297
- package/src/add/add-system-role.ts +0 -162
- package/src/add/add-trigger.ts +0 -165
- package/src/add/add-variable.ts +0 -10
- package/src/add/add-wire-addon.test.ts +0 -185
- package/src/add/add-wire-addon.ts +0 -146
- package/src/add/add-wire-remote-addon.ts +0 -80
- package/src/add/add-workflow-edge-cases.test.ts +0 -201
- package/src/add/add-workflow-fanout.test.ts +0 -166
- package/src/add/add-workflow-graph-foreach.test.ts +0 -174
- package/src/add/add-workflow-graph-input.test.ts +0 -94
- package/src/add/add-workflow-graph-notes.test.ts +0 -74
- package/src/add/add-workflow-graph.ts +0 -644
- package/src/add/add-workflow-on-error.test.ts +0 -118
- package/src/add/add-workflow-return-switch.test.ts +0 -121
- package/src/add/add-workflow-silent-drops.test.ts +0 -261
- package/src/add/add-workflow-sleep-expression.test.ts +0 -96
- package/src/add/add-workflow.test.ts +0 -155
- package/src/add/add-workflow.ts +0 -482
- package/src/add/addon-bans.test.ts +0 -121
- package/src/add/addon-contracts.test.ts +0 -221
- package/src/add/allow-escape-hatches.test.ts +0 -144
- package/src/add/audit-meta.test.ts +0 -75
- package/src/add/classified-sink-check.test.ts +0 -347
- package/src/add/config-value-metadata.test.ts +0 -263
- package/src/add/dynamic-import-check.test.ts +0 -119
- package/src/add/expect-eventually-scenario-only.test.ts +0 -108
- package/src/add/function-body-span.test.ts +0 -96
- package/src/add/inline-wiring-function.test.ts +0 -104
- package/src/add/pii-check.test.ts +0 -258
- package/src/add/rpc-type-cast.test.ts +0 -123
- package/src/add/scenario-instrumentation.test.ts +0 -89
- package/src/add/scenario-instrumentation.ts +0 -42
- package/src/add/scenario-marker.test.ts +0 -89
- package/src/add/scenario-not-extractable.test.ts +0 -159
- package/src/add/scenario-services.test.ts +0 -103
- package/src/add/scenario-skip.test.ts +0 -83
- package/src/add/validate-workflow-graph-addons.test.ts +0 -102
- package/src/add/wire-name-literal.test.ts +0 -117
- package/src/error-codes-emitted.test.ts +0 -76
- package/src/error-codes.ts +0 -145
- package/src/index.ts +0 -66
- package/src/inspector.ts +0 -575
- package/src/schema-generator.ts +0 -1
- package/src/source-file-cache.ts +0 -73
- package/src/tsconfig-paths.test.ts +0 -90
- package/src/types-map.ts +0 -141
- package/src/types.ts +0 -775
- package/src/utils/annotate-http-route-auth.test.ts +0 -161
- package/src/utils/annotate-http-route-auth.ts +0 -53
- package/src/utils/check-classified-sinks.ts +0 -215
- package/src/utils/check-pii-output.ts +0 -120
- package/src/utils/compute-diagnostics.test.ts +0 -106
- package/src/utils/compute-required-schemas.ts +0 -48
- package/src/utils/contract-hashes.test.ts +0 -553
- package/src/utils/contract-hashes.ts +0 -387
- package/src/utils/custom-types-generator.test.ts +0 -124
- package/src/utils/custom-types-generator.ts +0 -150
- package/src/utils/detect-schema-vendor.test.ts +0 -123
- package/src/utils/detect-schema-vendor.ts +0 -120
- package/src/utils/does-type-extend-core-type.ts +0 -53
- package/src/utils/ensure-function-metadata.ts +0 -385
- package/src/utils/extract-function-name.ts +0 -612
- package/src/utils/extract-function-node.ts +0 -70
- package/src/utils/extract-node-value.test.ts +0 -117
- package/src/utils/extract-node-value.ts +0 -172
- package/src/utils/extract-secret-usage.test.ts +0 -81
- package/src/utils/extract-secret-usage.ts +0 -73
- package/src/utils/extract-services.ts +0 -70
- package/src/utils/extract-surface-usage.test.ts +0 -147
- package/src/utils/extract-surface-usage.ts +0 -121
- package/src/utils/filter-inspector-state.test.ts +0 -2232
- package/src/utils/filter-inspector-state.ts +0 -1298
- package/src/utils/filter-utils.test.ts +0 -843
- package/src/utils/filter-utils.ts +0 -161
- package/src/utils/find-root-dir.ts +0 -68
- package/src/utils/find-zod-transform.test.ts +0 -70
- package/src/utils/find-zod-transform.ts +0 -103
- package/src/utils/get-exported-variable-name.ts +0 -48
- package/src/utils/get-files-and-methods.ts +0 -157
- package/src/utils/get-property-value.test.ts +0 -141
- package/src/utils/get-property-value.ts +0 -331
- package/src/utils/hash.ts +0 -26
- package/src/utils/literal-properties.ts +0 -97
- package/src/utils/load-addon-functions-meta.test.ts +0 -157
- package/src/utils/load-addon-functions-meta.ts +0 -508
- package/src/utils/load-addon-scopes.test.ts +0 -138
- package/src/utils/middleware.test.ts +0 -204
- package/src/utils/middleware.ts +0 -303
- package/src/utils/nested-project-filter.test.ts +0 -53
- package/src/utils/nested-project-filter.ts +0 -28
- package/src/utils/permissions-shorthand.test.ts +0 -79
- package/src/utils/permissions.test.ts +0 -125
- package/src/utils/permissions.ts +0 -129
- package/src/utils/post-process.test.ts +0 -1094
- package/src/utils/post-process.ts +0 -1604
- package/src/utils/resolve-addon-package.ts +0 -106
- package/src/utils/resolve-core-type.test.ts +0 -142
- package/src/utils/resolve-core-type.ts +0 -35
- package/src/utils/resolve-deploy-target.test.ts +0 -135
- package/src/utils/resolve-deploy-target.ts +0 -65
- package/src/utils/resolve-function-meta.ts +0 -25
- package/src/utils/resolve-function-types.ts +0 -42
- package/src/utils/resolve-identifier.ts +0 -46
- package/src/utils/resolve-ref-contract.ts +0 -71
- package/src/utils/resolve-versions.test.ts +0 -499
- package/src/utils/resolve-versions.ts +0 -228
- package/src/utils/schema-cache.test.ts +0 -124
- package/src/utils/schema-generator.test.ts +0 -272
- package/src/utils/schema-generator.ts +0 -780
- package/src/utils/secret-alias-services.test.ts +0 -146
- package/src/utils/secret-alias-services.ts +0 -58
- package/src/utils/serialize-inspector-state.ts +0 -742
- package/src/utils/serialize-mcp-json.ts +0 -150
- package/src/utils/serialize-middleware-groups-meta.ts +0 -36
- package/src/utils/serialize-openapi-json.ts +0 -277
- package/src/utils/serialize-permissions-groups-meta.ts +0 -7
- package/src/utils/single-declaration.ts +0 -57
- package/src/utils/type-utils.ts +0 -145
- package/src/utils/validate-auth-sessionless.ts +0 -30
- package/src/utils/validate-exposed-functions-gated.test.ts +0 -230
- package/src/utils/validate-exposed-functions-gated.ts +0 -103
- package/src/utils/validate-tags-resolve-to-middleware.test.ts +0 -108
- package/src/utils/validate-tags-resolve-to-middleware.ts +0 -48
- package/src/utils/workflow/derive-workflow-plan.test.ts +0 -178
- package/src/utils/workflow/derive-workflow-plan.ts +0 -117
- package/src/utils/workflow/dsl/deserialize-dsl-workflow.ts +0 -1465
- package/src/utils/workflow/dsl/deserialize-fanout-body.test.ts +0 -71
- package/src/utils/workflow/dsl/deserialize-fanout-fidelity.test.ts +0 -99
- package/src/utils/workflow/dsl/deserialize-graph-next.test.ts +0 -161
- package/src/utils/workflow/dsl/deserialize-roundtrip-bindings.test.ts +0 -121
- package/src/utils/workflow/dsl/deserialize-roundtrip-values.test.ts +0 -116
- package/src/utils/workflow/dsl/deserialize-roundtrip.test.ts +0 -145
- package/src/utils/workflow/dsl/extract-approval-policy.test.ts +0 -71
- package/src/utils/workflow/dsl/extract-dsl-workflow.ts +0 -2254
- package/src/utils/workflow/dsl/index.ts +0 -11
- package/src/utils/workflow/dsl/patterns.ts +0 -440
- package/src/utils/workflow/dsl/validation.ts +0 -203
- package/src/utils/workflow/graph/convert-dsl-to-graph-skip.test.ts +0 -35
- package/src/utils/workflow/graph/convert-dsl-to-graph.ts +0 -543
- package/src/utils/workflow/graph/fanout-node-identity.test.ts +0 -105
- package/src/utils/workflow/graph/finalize-workflow-wires.ts +0 -310
- package/src/utils/workflow/graph/finalize-workflows.test.ts +0 -50
- package/src/utils/workflow/graph/finalize-workflows.ts +0 -130
- package/src/utils/workflow/graph/index.ts +0 -28
- package/src/utils/workflow/graph/serialize-workflow-graph.ts +0 -240
- package/src/utils/workflow/graph/workflow-graph.types.ts +0 -281
- package/src/visit.ts +0 -181
- package/tsconfig.json +0 -19
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import * as ts from 'typescript'
|
|
2
|
-
import type { PathToNameAndType, InspectorState } from '../types.js'
|
|
3
|
-
import { extractServicesFromFunction } from '../utils/extract-services.js'
|
|
4
|
-
|
|
5
|
-
// Mapping of wrapper function names to their corresponding types
|
|
6
|
-
const wrapperFunctionMap: Record<string, string> = {
|
|
7
|
-
pikkuConfig: 'CreateConfig',
|
|
8
|
-
pikkuAddonConfig: 'CreateConfig',
|
|
9
|
-
pikkuServices: 'CreateSingletonServices',
|
|
10
|
-
pikkuAddonServices: 'CreateSingletonServices',
|
|
11
|
-
pikkuWireServices: 'CreateWireServices',
|
|
12
|
-
pikkuAddonWireServices: 'CreateWireServices',
|
|
13
|
-
pikkuServerLifecycle: 'ServerLifecycle',
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* What an addon's `pikkuAddonServices` factory takes from the parent: the names
|
|
18
|
-
* destructured off its second parameter, either in the parameter list or from a
|
|
19
|
-
* `const { … } = existingServices` in the body.
|
|
20
|
-
*/
|
|
21
|
-
const extractForwardedServices = (
|
|
22
|
-
functionNode: ts.ArrowFunction | ts.FunctionExpression
|
|
23
|
-
): string[] => {
|
|
24
|
-
const forwarded: string[] = []
|
|
25
|
-
const secondParam = functionNode.parameters[1]
|
|
26
|
-
if (!secondParam) return forwarded
|
|
27
|
-
|
|
28
|
-
const collectBinding = (pattern: ts.ObjectBindingPattern) => {
|
|
29
|
-
for (const elem of pattern.elements) {
|
|
30
|
-
if (elem.dotDotDotToken) continue
|
|
31
|
-
const name =
|
|
32
|
-
elem.propertyName && ts.isIdentifier(elem.propertyName)
|
|
33
|
-
? elem.propertyName.text
|
|
34
|
-
: ts.isIdentifier(elem.name)
|
|
35
|
-
? elem.name.text
|
|
36
|
-
: undefined
|
|
37
|
-
if (name) forwarded.push(name)
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (ts.isObjectBindingPattern(secondParam.name)) {
|
|
42
|
-
collectBinding(secondParam.name)
|
|
43
|
-
return forwarded
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (!ts.isIdentifier(secondParam.name)) return forwarded
|
|
47
|
-
const paramName = secondParam.name.text
|
|
48
|
-
const body = functionNode.body
|
|
49
|
-
if (!ts.isBlock(body)) return forwarded
|
|
50
|
-
|
|
51
|
-
const visit = (node: ts.Node) => {
|
|
52
|
-
if (
|
|
53
|
-
ts.isVariableDeclaration(node) &&
|
|
54
|
-
ts.isObjectBindingPattern(node.name) &&
|
|
55
|
-
node.initializer &&
|
|
56
|
-
ts.isIdentifier(node.initializer) &&
|
|
57
|
-
node.initializer.text === paramName
|
|
58
|
-
) {
|
|
59
|
-
collectBinding(node.name)
|
|
60
|
-
}
|
|
61
|
-
ts.forEachChild(node, visit)
|
|
62
|
-
}
|
|
63
|
-
ts.forEachChild(body, visit)
|
|
64
|
-
|
|
65
|
-
return forwarded
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* The service names the factory's returned object literals name. A spread is
|
|
70
|
-
* skipped — it carries the parent's bag through rather than naming anything —
|
|
71
|
-
* and a name the factory took off the parent is a forward, not a creation.
|
|
72
|
-
*/
|
|
73
|
-
const extractReturnedServices = (
|
|
74
|
-
functionNode: ts.ArrowFunction | ts.FunctionExpression
|
|
75
|
-
): string[] => {
|
|
76
|
-
const returned: string[] = []
|
|
77
|
-
|
|
78
|
-
const collect = (expression: ts.Expression) => {
|
|
79
|
-
while (ts.isParenthesizedExpression(expression)) {
|
|
80
|
-
expression = expression.expression
|
|
81
|
-
}
|
|
82
|
-
if (!ts.isObjectLiteralExpression(expression)) return
|
|
83
|
-
for (const property of expression.properties) {
|
|
84
|
-
if (ts.isSpreadAssignment(property)) continue
|
|
85
|
-
const name = property.name
|
|
86
|
-
if (name && (ts.isIdentifier(name) || ts.isStringLiteral(name))) {
|
|
87
|
-
returned.push(name.text)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const body = functionNode.body
|
|
93
|
-
if (!ts.isBlock(body)) {
|
|
94
|
-
collect(body)
|
|
95
|
-
return returned
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const visit = (node: ts.Node) => {
|
|
99
|
-
if (
|
|
100
|
-
ts.isFunctionDeclaration(node) ||
|
|
101
|
-
ts.isFunctionExpression(node) ||
|
|
102
|
-
ts.isArrowFunction(node)
|
|
103
|
-
) {
|
|
104
|
-
return
|
|
105
|
-
}
|
|
106
|
-
if (ts.isReturnStatement(node) && node.expression) {
|
|
107
|
-
collect(node.expression)
|
|
108
|
-
}
|
|
109
|
-
ts.forEachChild(node, visit)
|
|
110
|
-
}
|
|
111
|
-
ts.forEachChild(body, visit)
|
|
112
|
-
|
|
113
|
-
return returned
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export const addFileWithFactory = (
|
|
117
|
-
node: ts.Node,
|
|
118
|
-
checker: ts.TypeChecker,
|
|
119
|
-
methods: PathToNameAndType = new Map(),
|
|
120
|
-
expectedTypeName: string,
|
|
121
|
-
state?: InspectorState
|
|
122
|
-
) => {
|
|
123
|
-
if (ts.isVariableDeclaration(node)) {
|
|
124
|
-
const fileName = node.getSourceFile().fileName
|
|
125
|
-
const variableTypeNode = node.type
|
|
126
|
-
const variableName = node.name.getText()
|
|
127
|
-
|
|
128
|
-
// Check for wrapper function calls FIRST (e.g., pikkuConfig(...), pikkuServices(...))
|
|
129
|
-
// This handles both cases: with and without explicit type annotations
|
|
130
|
-
if (node.initializer && ts.isCallExpression(node.initializer)) {
|
|
131
|
-
const callExpression = node.initializer
|
|
132
|
-
const expression = callExpression.expression
|
|
133
|
-
|
|
134
|
-
if (ts.isIdentifier(expression)) {
|
|
135
|
-
const wrapperFunctionName = expression.text
|
|
136
|
-
const inferredType = wrapperFunctionMap[wrapperFunctionName]
|
|
137
|
-
|
|
138
|
-
if (inferredType === expectedTypeName) {
|
|
139
|
-
// Get the type declaration path from the wrapper function
|
|
140
|
-
const typeSymbol = checker.getSymbolAtLocation(expression)
|
|
141
|
-
let typeDeclarationPath: string | null = null
|
|
142
|
-
|
|
143
|
-
if (
|
|
144
|
-
typeSymbol &&
|
|
145
|
-
typeSymbol.declarations &&
|
|
146
|
-
typeSymbol.declarations[0]
|
|
147
|
-
) {
|
|
148
|
-
const declaration = typeSymbol.declarations[0]
|
|
149
|
-
const sourceFile = declaration.getSourceFile()
|
|
150
|
-
typeDeclarationPath = sourceFile.fileName
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const variables = methods.get(fileName) || []
|
|
154
|
-
variables.push({
|
|
155
|
-
variable: variableName,
|
|
156
|
-
type: inferredType,
|
|
157
|
-
typePath: typeDeclarationPath,
|
|
158
|
-
})
|
|
159
|
-
methods.set(fileName, variables)
|
|
160
|
-
|
|
161
|
-
if (state && callExpression.arguments.length > 0) {
|
|
162
|
-
const firstArg = callExpression.arguments[0]
|
|
163
|
-
let functionNode:
|
|
164
|
-
ts.ArrowFunction | ts.FunctionExpression | undefined
|
|
165
|
-
|
|
166
|
-
if (ts.isArrowFunction(firstArg)) {
|
|
167
|
-
functionNode = firstArg
|
|
168
|
-
} else if (ts.isFunctionExpression(firstArg)) {
|
|
169
|
-
functionNode = firstArg
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Extract singleton services for CreateWireServices factories
|
|
173
|
-
if (expectedTypeName === 'CreateWireServices' && functionNode) {
|
|
174
|
-
const servicesMeta = extractServicesFromFunction(functionNode)
|
|
175
|
-
state.wireServicesMeta.set(variableName, servicesMeta.services)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Extract existing services an addon needs from the parent
|
|
179
|
-
// (second parameter of pikkuAddonServices callback)
|
|
180
|
-
if (wrapperFunctionName === 'pikkuAddonServices' && functionNode) {
|
|
181
|
-
state.addonServicesFactorySeen = true
|
|
182
|
-
const forwarded = new Set(extractForwardedServices(functionNode))
|
|
183
|
-
for (const name of forwarded) {
|
|
184
|
-
state.addonRequiredParentServices.push(name)
|
|
185
|
-
}
|
|
186
|
-
for (const name of extractReturnedServices(functionNode)) {
|
|
187
|
-
if (!forwarded.has(name)) {
|
|
188
|
-
state.addonCreatedServices.push(name)
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return // Early return since we found a match
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (variableTypeNode && ts.isTypeReferenceNode(variableTypeNode)) {
|
|
200
|
-
const typeNameNode = variableTypeNode.typeName || null
|
|
201
|
-
|
|
202
|
-
let typeDeclarationPath: string | null = null
|
|
203
|
-
|
|
204
|
-
// Check if the type name matches the expected type name
|
|
205
|
-
if (
|
|
206
|
-
ts.isIdentifier(typeNameNode) &&
|
|
207
|
-
typeNameNode.text === expectedTypeName
|
|
208
|
-
) {
|
|
209
|
-
const typeSymbol = checker.getSymbolAtLocation(typeNameNode)
|
|
210
|
-
const declaration =
|
|
211
|
-
typeSymbol && typeSymbol.declarations && typeSymbol.declarations[0]
|
|
212
|
-
if (declaration) {
|
|
213
|
-
const sourceFile = declaration.getSourceFile()
|
|
214
|
-
typeDeclarationPath = sourceFile.fileName // Get the path of the file where the type was declared
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
const variables = methods.get(fileName) || []
|
|
218
|
-
variables.push({
|
|
219
|
-
variable: variableName,
|
|
220
|
-
type: typeNameNode.getText(),
|
|
221
|
-
typePath: typeDeclarationPath,
|
|
222
|
-
})
|
|
223
|
-
methods.set(fileName, variables)
|
|
224
|
-
|
|
225
|
-
// Extract singleton services for CreateWireServices factories
|
|
226
|
-
if (
|
|
227
|
-
expectedTypeName === 'CreateWireServices' &&
|
|
228
|
-
state &&
|
|
229
|
-
node.initializer
|
|
230
|
-
) {
|
|
231
|
-
let functionNode: ts.ArrowFunction | ts.FunctionExpression | undefined
|
|
232
|
-
if (ts.isArrowFunction(node.initializer)) {
|
|
233
|
-
functionNode = node.initializer
|
|
234
|
-
} else if (ts.isFunctionExpression(node.initializer)) {
|
|
235
|
-
functionNode = node.initializer
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (functionNode) {
|
|
239
|
-
const servicesMeta = extractServicesFromFunction(functionNode)
|
|
240
|
-
state.wireServicesMeta.set(variableName, servicesMeta.services)
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// Handle qualified type names if necessary
|
|
246
|
-
else if (ts.isQualifiedName(typeNameNode)) {
|
|
247
|
-
const lastName = typeNameNode.right.text
|
|
248
|
-
if (lastName === expectedTypeName) {
|
|
249
|
-
const typeSymbol = checker.getSymbolAtLocation(typeNameNode.right)
|
|
250
|
-
const declaration =
|
|
251
|
-
typeSymbol && typeSymbol.declarations && typeSymbol.declarations[0]
|
|
252
|
-
if (declaration) {
|
|
253
|
-
const sourceFile = declaration.getSourceFile()
|
|
254
|
-
typeDeclarationPath = sourceFile.fileName // Get the path of the file where the type was declared
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const variables = methods.get(fileName) || []
|
|
258
|
-
variables.push({
|
|
259
|
-
variable: variableName,
|
|
260
|
-
type: typeNameNode.getText(),
|
|
261
|
-
typePath: typeDeclarationPath,
|
|
262
|
-
})
|
|
263
|
-
methods.set(fileName, variables)
|
|
264
|
-
|
|
265
|
-
// Extract singleton services for CreateWireServices factories
|
|
266
|
-
if (
|
|
267
|
-
expectedTypeName === 'CreateWireServices' &&
|
|
268
|
-
state &&
|
|
269
|
-
node.initializer
|
|
270
|
-
) {
|
|
271
|
-
let functionNode:
|
|
272
|
-
ts.ArrowFunction | ts.FunctionExpression | undefined
|
|
273
|
-
if (ts.isArrowFunction(node.initializer)) {
|
|
274
|
-
functionNode = node.initializer
|
|
275
|
-
} else if (ts.isFunctionExpression(node.initializer)) {
|
|
276
|
-
functionNode = node.initializer
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if (functionNode) {
|
|
280
|
-
const servicesMeta = extractServicesFromFunction(functionNode)
|
|
281
|
-
state.wireServicesMeta.set(variableName, servicesMeta.services)
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|