@astrale-os/sdk 0.5.0-beta.99 → 0.6.0-beta.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/README.md +165 -2
- package/dist/application/action/action.d.ts +7 -4
- package/dist/application/action/authoring.d.ts +2 -1
- package/dist/application/action/context.d.ts +18 -13
- package/dist/application/action/define.d.ts +5 -1
- package/dist/application/action/define.js +6 -1
- package/dist/application/action/index.d.ts +2 -1
- package/dist/application/dependency/index.d.ts +1 -0
- package/dist/application/dependency/invoker.d.ts +26 -0
- package/dist/application/error/error.d.ts +23 -0
- package/dist/application/error/error.js +87 -0
- package/dist/application/error/index.d.ts +2 -0
- package/dist/application/error/index.js +1 -0
- package/dist/application/index.d.ts +2 -2
- package/dist/application/integration/authentication.d.ts +10 -0
- package/dist/application/integration/authentication.typecheck.js +18 -0
- package/dist/application/integration/client.d.ts +2 -0
- package/dist/application/integration/client.js +19 -2
- package/dist/application/integration/index.d.ts +1 -0
- package/dist/application/integration/operation.d.ts +3 -0
- package/dist/application/mutation/authoring/builder.js +2 -2
- package/dist/application/mutation/authoring/endpoint.d.ts +3 -3
- package/dist/application/mutation/authoring/endpoint.js +9 -0
- package/dist/application/mutation/failure.js +13 -7
- package/dist/application/mutation/index.d.ts +1 -0
- package/dist/application/requirements/{profiles.d.ts → core.d.ts} +5 -3
- package/dist/application/requirements/{profiles.js → core.js} +6 -6
- package/dist/application/requirements/index.d.ts +4 -4
- package/dist/application/requirements/index.js +5 -5
- package/dist/application/requirements/requirement.d.ts +3 -2
- package/dist/application/runtime/authoring.d.ts +1 -0
- package/dist/application/runtime/callables.js +2 -2
- package/dist/application/runtime/declarations.d.ts +43 -0
- package/dist/application/runtime/define.d.ts +2 -1
- package/dist/application/view/index.d.ts +1 -1
- package/dist/application/view/route.d.ts +4 -0
- package/dist/application/view/route.js +5 -1
- package/dist/application/workflow/authoring.d.ts +1 -0
- package/dist/application/workflow/context.d.ts +2 -1
- package/dist/application/workflow/define.d.ts +5 -1
- package/dist/application/workflow/define.js +6 -1
- package/dist/application/workflow/index.d.ts +1 -0
- package/dist/application/workflow/runner/runner.d.ts +3 -2
- package/dist/application/workflow/workflow.d.ts +4 -3
- package/dist/deployment/adapter/adapter.d.ts +12 -7
- package/dist/deployment/adapter/define.d.ts +5 -2
- package/dist/deployment/adapter/define.js +15 -17
- package/dist/deployment/adapter/deploy/context.d.ts +6 -0
- package/dist/deployment/adapter/deploy/result.d.ts +2 -0
- package/dist/deployment/adapter/index.d.ts +2 -3
- package/dist/deployment/adapter/index.js +1 -1
- package/dist/deployment/adapter/prepare/context.d.ts +13 -5
- package/dist/deployment/authoring.d.ts +1 -1
- package/dist/deployment/build/compile.js +21 -19
- package/dist/deployment/build/frontend/compilation.d.ts +2 -1
- package/dist/deployment/build/frontend/compilation.js +1 -0
- package/dist/deployment/build/material.js +5 -5
- package/dist/deployment/deploy.d.ts +10 -4
- package/dist/deployment/deploy.js +5 -5
- package/dist/deployment/deployment.d.ts +8 -5
- package/dist/deployment/deployment.js +10 -1
- package/dist/deployment/index.d.ts +5 -4
- package/dist/deployment/index.js +3 -2
- package/dist/deployment/release/addressing.d.ts +6 -2
- package/dist/deployment/release/addressing.js +9 -4
- package/dist/deployment/release/publication/callables.js +1 -1
- package/dist/deployment/release/publication/index.d.ts +1 -1
- package/dist/deployment/release/publication/index.js +1 -1
- package/dist/deployment/release/publication/routes.js +1 -1
- package/dist/deployment/release/publication/seal.d.ts +0 -1
- package/dist/deployment/release/publication/seal.js +4 -5
- package/dist/deployment/release/publication/views.js +2 -1
- package/dist/deployment/verify/preflight/artifact.js +1 -1
- package/dist/deployment/verify/readiness/deployment.js +7 -3
- package/dist/deployment/verify/readiness/identity.js +1 -1
- package/dist/deployment/verify/readiness/publication.js +2 -2
- package/dist/execution/identity/authentication.js +0 -1
- package/dist/execution/identity/exchange.d.ts +1 -0
- package/dist/execution/identity/exchange.js +1 -1
- package/dist/execution/identity/jwks.js +1 -1
- package/dist/execution/invocation/admission/authentication.d.ts +6 -3
- package/dist/execution/invocation/admission/authentication.js +16 -6
- package/dist/execution/invocation/admission/authority.d.ts +2 -2
- package/dist/execution/invocation/dependency/bind.d.ts +5 -0
- package/dist/execution/invocation/dependency/bind.js +68 -0
- package/dist/execution/invocation/dependency/index.d.ts +1 -0
- package/dist/execution/invocation/dependency/index.js +1 -0
- package/dist/execution/invocation/dispatch/action.js +19 -2
- package/dist/execution/invocation/dispatch/context.d.ts +4 -4
- package/dist/execution/invocation/dispatch/context.js +29 -9
- package/dist/execution/invocation/dispatch/workflow.js +17 -4
- package/dist/execution/invocation/integration/authentication.d.ts +5 -0
- package/dist/execution/invocation/integration/authentication.js +53 -0
- package/dist/execution/invocation/integration/call.d.ts +7 -1
- package/dist/execution/invocation/integration/call.js +8 -3
- package/dist/execution/invocation/integration/clients.d.ts +2 -2
- package/dist/execution/invocation/integration/clients.js +2 -2
- package/dist/execution/invocation/lifecycle/active.js +30 -5
- package/dist/execution/invocation/result/errors.d.ts +1 -0
- package/dist/execution/invocation/result/errors.js +15 -10
- package/dist/execution/service/create.js +3 -1
- package/dist/execution/service/service.d.ts +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/platform/auth/index.d.ts +1 -1
- package/dist/platform/auth/index.js +0 -1
- package/dist/platform/graph/alias.d.ts +6 -0
- package/dist/platform/graph/alias.js +6 -0
- package/dist/platform/graph/document/index.d.ts +2 -1
- package/dist/platform/graph/document/index.js +2 -1
- package/dist/platform/graph/index.d.ts +2 -1
- package/dist/platform/graph/index.js +2 -1
- package/dist/platform/schema/class-authoring.d.ts +37 -0
- package/dist/platform/schema/class-authoring.js +20 -0
- package/dist/platform/schema/class-icon.d.ts +15 -0
- package/dist/platform/schema/class-icon.js +46 -0
- package/dist/platform/schema/error.d.ts +11 -0
- package/dist/platform/schema/error.js +34 -0
- package/dist/platform/schema/errors/index.d.ts +3 -0
- package/dist/platform/schema/errors/index.js +2 -0
- package/dist/platform/schema/icons/index.d.ts +2 -0
- package/dist/platform/schema/icons/index.js +2 -0
- package/dist/platform/schema/index.d.ts +20 -13
- package/dist/platform/schema/index.js +9 -4
- package/dist/platform/schema/kernel.d.ts +22 -0
- package/dist/platform/schema/kernel.js +5 -0
- package/dist/platform/schema/node-id.d.ts +3 -0
- package/dist/platform/schema/node-id.js +6 -0
- package/dist/platform/schema/property.d.ts +12 -0
- package/dist/platform/schema/property.js +3 -0
- package/dist/platform/schema/schema-authoring.d.ts +48 -0
- package/dist/platform/schema/schema-authoring.js +3 -0
- package/dist/platform/schema/state-property.d.ts +11 -0
- package/dist/platform/schema/state-property.js +3 -0
- package/dist/project/admit.d.ts +4 -0
- package/dist/project/admit.js +22 -0
- package/dist/project/define.d.ts +12 -0
- package/dist/project/define.js +106 -0
- package/dist/project/index.d.ts +4 -0
- package/dist/project/index.js +2 -0
- package/dist/project/project.d.ts +24 -0
- package/dist/project/project.js +1 -0
- package/dist/testing/dataset/admission.d.ts +13 -0
- package/dist/testing/dataset/admission.js +107 -0
- package/dist/testing/dataset/builder.d.ts +42 -0
- package/dist/testing/dataset/builder.js +127 -0
- package/dist/testing/dataset/codec.d.ts +6 -0
- package/dist/testing/dataset/codec.js +113 -0
- package/dist/testing/dataset/dataset.d.ts +58 -0
- package/dist/testing/dataset/dataset.js +2 -0
- package/dist/testing/dataset/define.d.ts +33 -0
- package/dist/testing/dataset/define.js +105 -0
- package/dist/testing/dataset/index.d.ts +8 -0
- package/dist/testing/dataset/index.js +4 -0
- package/dist/testing/dataset/references.d.ts +14 -0
- package/dist/testing/dataset/references.js +56 -0
- package/dist/testing/index.d.ts +9 -0
- package/dist/testing/index.js +5 -0
- package/dist/testing/load.d.ts +14 -0
- package/dist/testing/load.js +44 -0
- package/dist/testing/reference.d.ts +11 -0
- package/dist/testing/reference.js +19 -0
- package/dist/testing/tests.d.ts +12 -0
- package/dist/testing/tests.js +31 -0
- package/dist/tooling/cli/arguments.d.ts +7 -4
- package/dist/tooling/cli/arguments.js +82 -107
- package/dist/tooling/cli/astrale/authority.d.ts +5 -0
- package/dist/tooling/cli/astrale/authority.js +11 -0
- package/dist/tooling/cli/astrale/executable.d.ts +2 -0
- package/dist/tooling/cli/astrale/executable.js +47 -0
- package/dist/tooling/cli/astrale/failure.d.ts +6 -0
- package/dist/tooling/cli/astrale/failure.js +48 -0
- package/dist/tooling/cli/astrale/instance.d.ts +11 -0
- package/dist/tooling/cli/astrale/instance.js +52 -0
- package/dist/tooling/cli/astrale/process.d.ts +13 -0
- package/dist/tooling/cli/astrale/process.js +94 -0
- package/dist/tooling/cli/astrale/version.d.ts +18 -0
- package/dist/tooling/cli/astrale/version.js +55 -0
- package/dist/tooling/cli/bun.js +1 -1
- package/dist/tooling/cli/credential.d.ts +2 -0
- package/dist/tooling/cli/credential.js +57 -0
- package/dist/tooling/cli/development/candidate.d.ts +25 -0
- package/dist/tooling/cli/development/candidate.js +176 -0
- package/dist/tooling/cli/development/deployment.d.ts +16 -0
- package/dist/tooling/cli/development/deployment.js +39 -0
- package/dist/tooling/cli/development/develop.d.ts +4 -3
- package/dist/tooling/cli/development/develop.js +125 -289
- package/dist/tooling/cli/development/lease.d.ts +18 -0
- package/dist/tooling/cli/development/lease.js +163 -0
- package/dist/tooling/cli/development/lifecycle.js +4 -0
- package/dist/tooling/cli/development/project-imports.d.ts +22 -0
- package/dist/tooling/cli/development/project-imports.js +39 -0
- package/dist/tooling/cli/development/project-lock.d.ts +3 -4
- package/dist/tooling/cli/development/project-lock.js +14 -166
- package/dist/tooling/cli/development/release-evidence.d.ts +4 -0
- package/dist/tooling/cli/development/release-evidence.js +10 -0
- package/dist/tooling/cli/development/report.d.ts +6 -0
- package/dist/tooling/cli/development/report.js +14 -0
- package/dist/tooling/cli/development/source-watch.js +53 -5
- package/dist/tooling/cli/development/sources.d.ts +7 -0
- package/dist/tooling/cli/development/sources.js +48 -0
- package/dist/tooling/cli/development/target-lock.d.ts +16 -0
- package/dist/tooling/cli/development/target-lock.js +68 -0
- package/dist/tooling/cli/development/view.d.ts +28 -0
- package/dist/tooling/cli/development/view.js +151 -0
- package/dist/tooling/cli/environment-release.d.ts +21 -0
- package/dist/tooling/cli/environment-release.js +46 -0
- package/dist/tooling/cli/evidence.d.ts +11 -0
- package/dist/tooling/cli/evidence.js +53 -0
- package/dist/tooling/cli/help.js +78 -34
- package/dist/tooling/cli/index.d.ts +1 -1
- package/dist/tooling/cli/index.js +1 -1
- package/dist/tooling/cli/installation/index.d.ts +2 -0
- package/dist/tooling/cli/installation/index.js +1 -0
- package/dist/tooling/cli/installation/observation.d.ts +10 -0
- package/dist/tooling/cli/installation/observation.js +44 -0
- package/dist/tooling/cli/installation/reconcile.d.ts +32 -0
- package/dist/tooling/cli/installation/reconcile.js +122 -0
- package/dist/tooling/cli/orchestrate.js +84 -44
- package/dist/tooling/cli/project.d.ts +17 -0
- package/dist/tooling/cli/project.js +18 -0
- package/dist/tooling/cli/test.d.ts +12 -0
- package/dist/tooling/cli/test.js +47 -0
- package/dist/tooling/cli/upgrade/index.d.ts +6 -0
- package/dist/tooling/cli/upgrade/index.js +115 -0
- package/dist/tooling/cli/upgrade/manifest.d.ts +18 -0
- package/dist/tooling/cli/upgrade/manifest.js +77 -0
- package/dist/tooling/cli/upgrade/process.d.ts +2 -0
- package/dist/tooling/cli/upgrade/process.js +57 -0
- package/dist/tooling/linter/adapters/typescript/imports.js +2 -0
- package/dist/tooling/linter/adapters/typescript/index.d.ts +1 -0
- package/dist/tooling/linter/adapters/typescript/index.js +1 -0
- package/dist/tooling/linter/adapters/typescript/query-collection-type.js +4 -51
- package/dist/tooling/linter/adapters/typescript/type-analysis.d.ts +9 -0
- package/dist/tooling/linter/adapters/typescript/type-analysis.js +55 -0
- package/dist/tooling/linter/implementations/source/callable-requirements.d.ts +28 -0
- package/dist/tooling/linter/implementations/source/callable-requirements.js +234 -0
- package/dist/tooling/linter/implementations/source/dependencies.d.ts +2 -0
- package/dist/tooling/linter/implementations/source/dependencies.js +219 -0
- package/dist/tooling/linter/implementations/source/global.js +52 -2
- package/dist/tooling/linter/implementations/source/mutations.js +520 -38
- package/dist/tooling/linter/implementations/source/providers.js +19 -164
- package/dist/tooling/linter/implementations/source/schema.js +454 -2
- package/dist/tooling/linter/implementations/source/verifiers.js +2 -0
- package/dist/tooling/linter/implementations/source/workflows.js +8 -35
- package/dist/tooling/linter/policy/generated.js +2 -2
- package/dist/tooling/linter/requirements/registry.js +9 -3
- package/dist/tooling/packaging/declarations/normalize.js +3 -38
- package/dist/tooling/packaging/declarations/paths.d.ts +5 -0
- package/dist/tooling/packaging/declarations/paths.js +38 -0
- package/dist/tooling/packaging/finalize.d.ts +13 -0
- package/dist/tooling/packaging/finalize.js +62 -0
- package/dist/tooling/packaging/index.d.ts +2 -0
- package/dist/tooling/packaging/index.js +1 -0
- package/dist/tooling/packaging/javascript.d.ts +3 -0
- package/dist/tooling/packaging/javascript.js +45 -2
- package/dist/tooling/packaging/packaging.d.ts +2 -5
- package/dist/tooling/packaging/packaging.js +6 -30
- package/package.json +42 -12
- package/CHANGELOG.md +0 -1506
- package/dist/deployment/adapter/development/context.d.ts +0 -18
- package/dist/deployment/adapter/development/index.d.ts +0 -4
- package/dist/deployment/adapter/development/input.d.ts +0 -6
- package/dist/deployment/adapter/development/placement.d.ts +0 -15
- package/dist/deployment/adapter/development/session.d.ts +0 -9
- /package/dist/{deployment/adapter/development → application/dependency}/index.js +0 -0
- /package/dist/{deployment/adapter/development/context.js → application/dependency/invoker.js} +0 -0
- /package/dist/{deployment/adapter/development/input.js → application/integration/authentication.js} +0 -0
- /package/dist/{deployment/adapter/development/placement.js → application/integration/authentication.typecheck.d.ts} +0 -0
- /package/dist/{deployment/adapter/development/session.js → application/runtime/declarations.js} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import {
|
|
2
|
+
import { propertyChain, resolveImportedSymbol, resolveProjectImport, unwrap, visit, } from '../../adapters/typescript/index.js';
|
|
3
|
+
import { applicationFunctionRequirements, callableReference, callableSelector, externalFacade, lexicalConstInitializer, remoteCallableKey, } from './callable-requirements.js';
|
|
3
4
|
import { ambiguity, production, violation } from './shared.js';
|
|
4
5
|
const LOCAL_DOMAIN_LAYERS = new Set([
|
|
5
6
|
'functions',
|
|
@@ -24,7 +25,11 @@ export const providerRules = [
|
|
|
24
25
|
if (providerExecutionInvoke(file, node)) {
|
|
25
26
|
const reference = node.arguments[0];
|
|
26
27
|
const admitted = reference === undefined ? undefined : callableReference(unwrap(reference));
|
|
27
|
-
const referenceExpression = admitted
|
|
28
|
+
const referenceExpression = admitted &&
|
|
29
|
+
ts.isCallExpression(admitted.expression) &&
|
|
30
|
+
ts.isCallExpression(admitted.expression.expression)
|
|
31
|
+
? admitted.expression.expression
|
|
32
|
+
: admitted?.expression;
|
|
28
33
|
const symbol = referenceExpression && ts.isCallExpression(referenceExpression)
|
|
29
34
|
? resolveImportedSymbol(file, referenceExpression.expression)
|
|
30
35
|
: undefined;
|
|
@@ -96,7 +101,7 @@ export const providerRules = [
|
|
|
96
101
|
const chain = propertyChain(node.expression);
|
|
97
102
|
const name = chain?.at(-1);
|
|
98
103
|
if (name && GRAPH_OPERATIONS.has(name) && !providerExecutionInvoke(file, node)) {
|
|
99
|
-
evidence.push(ambiguity(file, node, `Provider call ${chain?.join('.')} resembles a local Domain operation but its
|
|
104
|
+
evidence.push(ambiguity(file, node, `Provider call ${chain?.join('.')} resembles a local Domain operation but its instance is opaque.`));
|
|
100
105
|
}
|
|
101
106
|
});
|
|
102
107
|
}
|
|
@@ -113,7 +118,9 @@ function remoteCallable(file, invoke) {
|
|
|
113
118
|
if (!admitted.resolved) {
|
|
114
119
|
return ambiguity(file, argument, 'Remote Domain Function requirement cannot be proven from an opaque reference.');
|
|
115
120
|
}
|
|
116
|
-
const expression = admitted.expression
|
|
121
|
+
const expression = ts.isCallExpression(admitted.expression) && ts.isCallExpression(admitted.expression.expression)
|
|
122
|
+
? admitted.expression.expression
|
|
123
|
+
: admitted.expression;
|
|
117
124
|
if (!ts.isCallExpression(expression)) {
|
|
118
125
|
return ambiguity(file, expression, 'Remote Domain Function requirement cannot be proven from a computed reference.');
|
|
119
126
|
}
|
|
@@ -123,20 +130,20 @@ function remoteCallable(file, invoke) {
|
|
|
123
130
|
constructor.module !== '@astrale-os/sdk/client/session') {
|
|
124
131
|
return ambiguity(file, expression, 'Remote Domain Function requirement cannot be proven from a non-SDK reference.');
|
|
125
132
|
}
|
|
126
|
-
const
|
|
133
|
+
const domain = expression.arguments[0];
|
|
127
134
|
const callable = expression.arguments[1];
|
|
128
|
-
const
|
|
135
|
+
const domainChain = domain && propertyChain(domain);
|
|
129
136
|
const callableChain = callable && propertyChain(callable);
|
|
130
|
-
if (
|
|
137
|
+
if (domainChain?.length !== 1 ||
|
|
131
138
|
callableChain === undefined ||
|
|
132
|
-
callableChain[0] !==
|
|
139
|
+
callableChain[0] !== domainChain[0] ||
|
|
133
140
|
!callableSelector(callableChain.slice(1))) {
|
|
134
|
-
return ambiguity(file, expression, 'Remote Domain Function requirement cannot be proven from an opaque
|
|
141
|
+
return ambiguity(file, expression, 'Remote Domain Function requirement cannot be proven from an opaque Domain or selector.');
|
|
135
142
|
}
|
|
136
|
-
const
|
|
137
|
-
const module = bindingTypeModule(file,
|
|
143
|
+
const domainName = domainChain[0];
|
|
144
|
+
const module = bindingTypeModule(file, domainName, expression);
|
|
138
145
|
if (module === undefined || !externalFacade(module)) {
|
|
139
|
-
return ambiguity(file,
|
|
146
|
+
return ambiguity(file, domain, 'Remote Domain type cannot be mapped to one public package facade.');
|
|
140
147
|
}
|
|
141
148
|
return {
|
|
142
149
|
file,
|
|
@@ -160,116 +167,6 @@ function bindingTypeModule(file, name, node) {
|
|
|
160
167
|
}
|
|
161
168
|
return undefined;
|
|
162
169
|
}
|
|
163
|
-
function applicationFunctionRequirements(project) {
|
|
164
|
-
const applicationPath = project.policy.rootFiles.find(({ id }) => id === 'application')?.sourcePath;
|
|
165
|
-
const file = applicationPath && project.filesByPath.get(applicationPath);
|
|
166
|
-
if (!file)
|
|
167
|
-
return { keys: new Set(), indeterminate: true };
|
|
168
|
-
const applications = [];
|
|
169
|
-
visit(file.source, (node) => {
|
|
170
|
-
if (!ts.isCallExpression(node))
|
|
171
|
-
return;
|
|
172
|
-
const symbol = resolveImportedSymbol(file, node.expression);
|
|
173
|
-
if (symbol.kind === 'resolved' &&
|
|
174
|
-
symbol.name === 'defineApplication' &&
|
|
175
|
-
(symbol.module === '@astrale-os/sdk' || symbol.module === '@astrale-os/sdk/application')) {
|
|
176
|
-
applications.push(node);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
if (applications.length !== 1)
|
|
180
|
-
return { keys: new Set(), indeterminate: true };
|
|
181
|
-
const input = applications[0].arguments[0];
|
|
182
|
-
if (!input || !ts.isObjectLiteralExpression(unwrap(input))) {
|
|
183
|
-
return { keys: new Set(), indeterminate: true };
|
|
184
|
-
}
|
|
185
|
-
const requirementsProperty = objectProperty(unwrap(input), 'requirements');
|
|
186
|
-
if (requirementsProperty === undefined)
|
|
187
|
-
return { keys: new Set(), indeterminate: false };
|
|
188
|
-
if (!ts.isPropertyAssignment(requirementsProperty)) {
|
|
189
|
-
return { keys: new Set(), indeterminate: true };
|
|
190
|
-
}
|
|
191
|
-
const requirementsCall = unwrap(requirementsProperty.initializer);
|
|
192
|
-
if (!ts.isCallExpression(requirementsCall))
|
|
193
|
-
return { keys: new Set(), indeterminate: true };
|
|
194
|
-
const requirementsSymbol = resolveImportedSymbol(file, requirementsCall.expression);
|
|
195
|
-
if (requirementsSymbol.kind !== 'resolved' ||
|
|
196
|
-
requirementsSymbol.name !== 'requirements' ||
|
|
197
|
-
(requirementsSymbol.module !== '@astrale-os/sdk' &&
|
|
198
|
-
requirementsSymbol.module !== '@astrale-os/sdk/application')) {
|
|
199
|
-
return { keys: new Set(), indeterminate: true };
|
|
200
|
-
}
|
|
201
|
-
const definition = requirementsCall.arguments[0];
|
|
202
|
-
if (definition === undefined)
|
|
203
|
-
return { keys: new Set(), indeterminate: false };
|
|
204
|
-
if (!ts.isObjectLiteralExpression(unwrap(definition))) {
|
|
205
|
-
return { keys: new Set(), indeterminate: true };
|
|
206
|
-
}
|
|
207
|
-
const functions = objectProperty(unwrap(definition), 'functions');
|
|
208
|
-
if (functions === undefined)
|
|
209
|
-
return { keys: new Set(), indeterminate: false };
|
|
210
|
-
if (!ts.isPropertyAssignment(functions))
|
|
211
|
-
return { keys: new Set(), indeterminate: true };
|
|
212
|
-
const values = unwrap(functions.initializer);
|
|
213
|
-
if (!ts.isArrayLiteralExpression(values))
|
|
214
|
-
return { keys: new Set(), indeterminate: true };
|
|
215
|
-
const keys = new Set();
|
|
216
|
-
let indeterminate = false;
|
|
217
|
-
for (const element of values.elements) {
|
|
218
|
-
if (ts.isSpreadElement(element)) {
|
|
219
|
-
indeterminate = true;
|
|
220
|
-
continue;
|
|
221
|
-
}
|
|
222
|
-
const target = requiredCallable(file, element);
|
|
223
|
-
if (target === undefined)
|
|
224
|
-
indeterminate = true;
|
|
225
|
-
else
|
|
226
|
-
keys.add(remoteCallableKey(target));
|
|
227
|
-
}
|
|
228
|
-
return { keys, indeterminate };
|
|
229
|
-
}
|
|
230
|
-
function requiredCallable(file, input) {
|
|
231
|
-
const admitted = callableReference(unwrap(input));
|
|
232
|
-
if (!admitted.resolved)
|
|
233
|
-
return undefined;
|
|
234
|
-
let current = admitted.expression;
|
|
235
|
-
const selector = [];
|
|
236
|
-
while (ts.isPropertyAccessExpression(unwrap(current))) {
|
|
237
|
-
const property = unwrap(current);
|
|
238
|
-
selector.unshift(property.name.text);
|
|
239
|
-
current = unwrap(property.expression);
|
|
240
|
-
}
|
|
241
|
-
if (!callableSelector(selector) || !ts.isCallExpression(current))
|
|
242
|
-
return undefined;
|
|
243
|
-
const resolve = unwrap(current.expression);
|
|
244
|
-
if (!ts.isPropertyAccessExpression(resolve) || resolve.name.text !== 'resolve')
|
|
245
|
-
return undefined;
|
|
246
|
-
const schemaSymbol = resolveImportedSymbol(file, resolve.expression);
|
|
247
|
-
if (schemaSymbol.kind !== 'resolved' ||
|
|
248
|
-
schemaSymbol.name !== 'schema' ||
|
|
249
|
-
schemaSymbol.module !== '@astrale-os/sdk/schema') {
|
|
250
|
-
return undefined;
|
|
251
|
-
}
|
|
252
|
-
const schemaValue = current.arguments[0];
|
|
253
|
-
if (!schemaValue)
|
|
254
|
-
return undefined;
|
|
255
|
-
const facade = resolveImportedSymbol(file, schemaValue);
|
|
256
|
-
if (facade.kind !== 'resolved' || !externalFacade(facade.module))
|
|
257
|
-
return undefined;
|
|
258
|
-
return { module: facade.module, selector: Object.freeze(selector) };
|
|
259
|
-
}
|
|
260
|
-
function callableSelector(selector) {
|
|
261
|
-
return ((selector.length === 2 && selector[0] === 'functions') ||
|
|
262
|
-
(selector.length === 4 && selector[0] === 'classes' && selector[2] === 'methods'));
|
|
263
|
-
}
|
|
264
|
-
function externalFacade(module) {
|
|
265
|
-
return (!module.startsWith('.') &&
|
|
266
|
-
!module.startsWith('#') &&
|
|
267
|
-
!module.startsWith('@astrale-os/sdk') &&
|
|
268
|
-
!module.startsWith('@astrale-os/kernel-'));
|
|
269
|
-
}
|
|
270
|
-
function remoteCallableKey(input) {
|
|
271
|
-
return `${input.module}\0${input.selector.join('\0')}`;
|
|
272
|
-
}
|
|
273
170
|
function providerExecutionInvoke(file, call) {
|
|
274
171
|
const expression = unwrap(call.expression);
|
|
275
172
|
const invoked = ts.isIdentifier(expression) && lexicalConstInitializer(expression) !== undefined
|
|
@@ -295,48 +192,6 @@ function providerExecutionInvoke(file, call) {
|
|
|
295
192
|
(ts.isIdentifier(element.propertyName) && element.propertyName.text === 'invoke'));
|
|
296
193
|
});
|
|
297
194
|
}
|
|
298
|
-
function callableReference(expression) {
|
|
299
|
-
if (!ts.isIdentifier(expression))
|
|
300
|
-
return { expression, resolved: true };
|
|
301
|
-
const initializer = lexicalConstInitializer(expression);
|
|
302
|
-
return initializer === undefined
|
|
303
|
-
? { expression, resolved: false }
|
|
304
|
-
: { expression: unwrap(initializer), resolved: true };
|
|
305
|
-
}
|
|
306
|
-
/** Resolve only one immutable lexical alias; the linter does not emulate program execution. */
|
|
307
|
-
function lexicalConstInitializer(identifier) {
|
|
308
|
-
let child = identifier;
|
|
309
|
-
let current = identifier.parent;
|
|
310
|
-
while (current) {
|
|
311
|
-
if (ts.isFunctionLike(current)) {
|
|
312
|
-
if (current.parameters.some(({ name }) => bindingContains(name, identifier.text))) {
|
|
313
|
-
return undefined;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
if (ts.isBlock(current) || ts.isSourceFile(current) || ts.isModuleBlock(current)) {
|
|
317
|
-
const index = current.statements.findIndex((statement) => statement.pos <= child.pos && statement.end >= child.end);
|
|
318
|
-
const before = index < 0 ? current.statements : current.statements.slice(0, index);
|
|
319
|
-
for (const statement of [...before].reverse()) {
|
|
320
|
-
if (!ts.isVariableStatement(statement))
|
|
321
|
-
continue;
|
|
322
|
-
const declaration = statement.declarationList.declarations.find(({ name }) => ts.isIdentifier(name) && name.text === identifier.text);
|
|
323
|
-
if (!declaration)
|
|
324
|
-
continue;
|
|
325
|
-
return (statement.declarationList.flags & ts.NodeFlags.Const) !== 0
|
|
326
|
-
? declaration.initializer
|
|
327
|
-
: undefined;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
child = current;
|
|
331
|
-
current = current.parent;
|
|
332
|
-
}
|
|
333
|
-
return undefined;
|
|
334
|
-
}
|
|
335
|
-
function bindingContains(binding, name) {
|
|
336
|
-
if (ts.isIdentifier(binding))
|
|
337
|
-
return binding.text === name;
|
|
338
|
-
return binding.elements.some((element) => !ts.isOmittedExpression(element) && bindingContains(element.name, name));
|
|
339
|
-
}
|
|
340
195
|
function providerOperation(file, node) {
|
|
341
196
|
let current = node.parent;
|
|
342
197
|
while (current && !providerFunction(current))
|