@astrale-os/sdk 0.6.0-beta.42 → 0.6.0-beta.44
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 +7 -7
- package/dist/application/action/authoring.d.ts +1 -1
- package/dist/application/action/context.d.ts +9 -8
- package/dist/application/error/error.d.ts +7 -7
- package/dist/application/error/error.js +12 -12
- package/dist/application/error/index.d.ts +1 -1
- package/dist/application/error/index.js +1 -1
- package/dist/application/mutation/authoring/builder.d.ts +12 -12
- package/dist/application/mutation/authoring/builder.js +3 -3
- package/dist/application/mutation/authoring/guard.d.ts +2 -2
- package/dist/application/mutation/authoring/index.d.ts +1 -1
- package/dist/application/mutation/define.d.ts +8 -8
- package/dist/application/mutation/define.js +12 -12
- package/dist/application/mutation/execution/execute.d.ts +2 -2
- package/dist/application/mutation/execution/execute.js +10 -10
- package/dist/application/mutation/execution/executor.d.ts +2 -2
- package/dist/application/mutation/execution/executor.js +2 -2
- package/dist/application/mutation/index.d.ts +2 -2
- package/dist/application/mutation/legacy/v6/define.d.ts +1 -1
- package/dist/application/mutation/legacy/v6/mutation.d.ts +1 -1
- package/dist/application/mutation/mutation.d.ts +12 -12
- package/dist/application/query/composite/builder.js +1 -1
- package/dist/application/query/define.d.ts +1 -1
- package/dist/application/query/define.js +3 -3
- package/dist/application/query/defined/define.d.ts +45 -0
- package/dist/application/query/defined/define.js +96 -0
- package/dist/application/query/defined/query.d.ts +135 -0
- package/dist/application/query/definition.d.ts +5 -5
- package/dist/application/query/definition.js +4 -4
- package/dist/application/query/execution/bounds.d.ts +7 -5
- package/dist/application/query/execution/bounds.js +4 -2
- package/dist/application/query/execution/client.d.ts +20 -0
- package/dist/application/query/execution/client.js +1 -0
- package/dist/application/query/execution/crossings.d.ts +3 -3
- package/dist/application/query/execution/crossings.js +55 -32
- package/dist/application/query/execution/error.d.ts +8 -8
- package/dist/application/query/execution/error.js +5 -5
- package/dist/application/query/execution/execute.d.ts +4 -4
- package/dist/application/query/execution/executor.d.ts +2 -2
- package/dist/application/query/execution/rows.d.ts +5 -5
- package/dist/application/query/execution/rows.js +42 -30
- package/dist/application/query/execution/run.d.ts +75 -0
- package/dist/application/query/execution/{recipe.js → run.js} +116 -68
- package/dist/application/query/execution/split.d.ts +3 -3
- package/dist/application/query/execution/split.js +1 -1
- package/dist/application/query/handles/build.d.ts +1 -1
- package/dist/application/query/handles/domain.d.ts +1 -1
- package/dist/application/query/handles/handles.d.ts +14 -12
- package/dist/application/query/handles/plan.d.ts +10 -9
- package/dist/application/query/handles/plan.js +1 -1
- package/dist/application/query/handles/reads.js +7 -7
- package/dist/application/query/handles/rows.d.ts +1 -1
- package/dist/application/query/handles/terms.d.ts +9 -1
- package/dist/application/query/handles/terms.js +20 -3
- package/dist/application/query/index.d.ts +8 -5
- package/dist/application/query/index.js +3 -3
- package/dist/application/query/language/index.d.ts +1 -1
- package/dist/application/query/language/query.d.ts +5 -5
- package/dist/application/query/legacy/v6/collection/union.d.ts +1 -1
- package/dist/application/query/legacy/v6/collection/union.js +3 -3
- package/dist/application/query/legacy/v6/define.d.ts +1 -1
- package/dist/application/query/legacy/v6/define.js +3 -3
- package/dist/application/query/legacy/v6/execution/execute.d.ts +6 -4
- package/dist/application/query/legacy/v6/index.d.ts +1 -1
- package/dist/application/query/legacy/v6/index.js +1 -1
- package/dist/application/query/query.d.ts +3 -3
- package/dist/application/routes/admission.d.ts +1 -1
- package/dist/application/routes/admission.js +2 -2
- package/dist/application/routes/index.d.ts +3 -2
- package/dist/application/routes/route.d.ts +1 -1
- package/dist/application/runtime/declarations.d.ts +6 -6
- package/dist/application/runtime/define.d.ts +5 -5
- package/dist/application/workflow/durable.d.ts +9 -9
- package/dist/deployment/build/build.d.ts +8 -1
- package/dist/deployment/build/material.js +3 -0
- package/dist/execution/invocation/capabilities/bind.d.ts +1 -1
- package/dist/execution/invocation/capabilities/bind.js +8 -8
- package/dist/execution/invocation/dispatch/action.js +2 -2
- package/dist/execution/invocation/dispatch/workflow.js +2 -2
- package/dist/execution/invocation/result/index.d.ts +1 -1
- package/dist/execution/invocation/result/index.js +1 -1
- package/dist/execution/invocation/result/undeclared.d.ts +7 -0
- package/dist/execution/invocation/result/undeclared.js +18 -0
- package/dist/execution/workflows/failure.d.ts +7 -7
- package/dist/execution/workflows/failure.js +19 -18
- package/dist/execution/workflows/receiver.d.ts +1 -1
- package/dist/execution/workflows/run.js +2 -2
- package/dist/execution/workflows/steps.d.ts +1 -1
- package/dist/platform/schema/class-authoring.d.ts +2 -8
- package/dist/platform/schema/index.d.ts +1 -1
- package/dist/platform/schema/kernel-compiled.d.ts +1 -1
- package/dist/platform/schema/kernel-compiled.js +2 -2
- package/dist/platform/schema/kernel.d.ts +4 -2
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +1 -1
- package/dist/testing/{recipe.d.ts → query.d.ts} +6 -6
- package/dist/testing/{recipe.js → query.js} +16 -11
- package/dist/tooling/cli/orchestrate.js +7 -6
- package/dist/tooling/linter/adapters/typescript/{recipe-definitions.d.ts → definition-calls.d.ts} +10 -10
- package/dist/tooling/linter/adapters/typescript/{recipe-definitions.js → definition-calls.js} +10 -10
- package/dist/tooling/linter/adapters/typescript/index.d.ts +1 -1
- package/dist/tooling/linter/adapters/typescript/index.js +1 -1
- package/dist/tooling/linter/adapters/typescript/query-observation.js +6 -6
- package/dist/tooling/linter/implementations/source/definitions.d.ts +2 -0
- package/dist/tooling/linter/implementations/source/{recipes.js → definitions.js} +60 -44
- package/dist/tooling/linter/implementations/source/global.js +8 -6
- package/dist/tooling/linter/implementations/source/mutations.js +5 -5
- package/dist/tooling/linter/implementations/source/shared.d.ts +2 -2
- package/dist/tooling/linter/implementations/source/shared.js +7 -7
- package/dist/tooling/linter/implementations/source/verifiers.js +2 -2
- package/dist/tooling/linter/policy/generated.js +3 -3
- package/dist/tooling/linter/requirements/registry.js +4 -4
- package/docs/durable-workflows.md +8 -8
- package/docs/handler-dependencies.md +1 -1
- package/docs/legacy/query-v6.md +7 -7
- package/docs/queries.md +60 -56
- package/package.json +6 -6
- package/dist/application/query/execution/recipe.d.ts +0 -70
- package/dist/application/query/recipe/define.d.ts +0 -45
- package/dist/application/query/recipe/define.js +0 -102
- package/dist/application/query/recipe/recipe.d.ts +0 -134
- package/dist/execution/invocation/result/recipe.d.ts +0 -6
- package/dist/execution/invocation/result/recipe.js +0 -17
- package/dist/tooling/linter/implementations/source/recipes.d.ts +0 -2
- /package/dist/application/query/{recipe/recipe.js → defined/query.js} +0 -0
|
@@ -239,7 +239,19 @@ export class CoreNode {
|
|
|
239
239
|
Object.freeze(this);
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
/**
|
|
242
|
+
/**
|
|
243
|
+
* Whether text is written as a NodePath: it starts with `/` (a Domain anchor) or `@` (a Node's id
|
|
244
|
+
* as its anchor). A NodeId holds neither, so the two never meet.
|
|
245
|
+
*/
|
|
246
|
+
export function isPathText(value) {
|
|
247
|
+
return typeof value === 'string' && (value.startsWith('/') || value.startsWith('@'));
|
|
248
|
+
}
|
|
249
|
+
/** A NodePath that is a Node's id and no step: `@<id>`, a NodeId being 1 to 255 of `A-Za-z0-9._-`. */
|
|
250
|
+
const ID_PATH = /^@([A-Za-z0-9._-]{1,255})$/;
|
|
251
|
+
/**
|
|
252
|
+
* The condition a list of targets gives: ids by `id`, an `@<id>` path by its id, so a long list
|
|
253
|
+
* splits as ids do; any other path, and a Core node, by `path`.
|
|
254
|
+
*/
|
|
243
255
|
export function targetCondition(context, targets) {
|
|
244
256
|
if (targets.length === 0)
|
|
245
257
|
return foldedTo(Condition.NEVER, atom(context, { op: 'id', ids: [] }));
|
|
@@ -248,8 +260,13 @@ export function targetCondition(context, targets) {
|
|
|
248
260
|
for (const target of targets) {
|
|
249
261
|
if (target instanceof CoreNode)
|
|
250
262
|
paths.push(target.path);
|
|
251
|
-
else if (
|
|
252
|
-
|
|
263
|
+
else if (isPathText(target)) {
|
|
264
|
+
const id = ID_PATH.exec(target)?.[1];
|
|
265
|
+
if (id === undefined)
|
|
266
|
+
paths.push(target);
|
|
267
|
+
else
|
|
268
|
+
ids.push(id);
|
|
269
|
+
}
|
|
253
270
|
else if (typeof target === 'string' && target.length > 0)
|
|
254
271
|
ids.push(target);
|
|
255
272
|
else
|
|
@@ -3,11 +3,14 @@ export { executeQuery, type QueryClient, type QueryExecutor } from './execution/
|
|
|
3
3
|
export { QueryPaginationError, QueryValueMismatchError, type QueryFailure, type QueryPaginationErrorCode, } from './failure.js';
|
|
4
4
|
export type { CompositeQueryDefinition, QueryDefinition, QueryInputOf, QueryOutputOf, QueryPagination, } from './query.js';
|
|
5
5
|
export type { CompositeQuery, ProjectedCompositeQuery, QueryComposition, QueryPlan, QueryPlanInput, QueryPlanOutput, QueryPlanValue, RawCompositeQuery, } from './composite/index.js';
|
|
6
|
-
export { defineQuery } from './
|
|
7
|
-
export { edgeKey, type Count, type EdgeKey, type EdgeRow, type Page, type Ref, type Row, } from './handles/rows.js';
|
|
8
|
-
export type { Handles } from './handles/handles.js';
|
|
9
|
-
export type {
|
|
6
|
+
export { defineQuery } from './defined/define.js';
|
|
7
|
+
export { edgeKey, type Count, type EdgeKey, type EdgeRow, type Page, type EdgeRootRef, type EdgeRootRow, type Ref, type Row, type WithheldEdgeRow, type WithheldRow, } from './handles/rows.js';
|
|
8
|
+
export type { CoreNodeHandle, DocumentRead, EdgeHandle, EdgeRootHandle, EdgeSet, Handles, IdProp, NodeHandle, NodeMethods, NodeSet, PageRead, PathProp, Read, RelationRead, RelSet, } from './handles/handles.js';
|
|
9
|
+
export type { BooleanProp, Cond, EnumProp, IsCond, JsonProp, NumberProp, OpenProp, OrderKey, PropsOf, SetProp, TextProp, Unordered, } from './handles/conditions.js';
|
|
10
|
+
export type { DefinedQuery, InputOf, OutputOf, Stepped, Steps } from './defined/query.js';
|
|
11
|
+
export type { QueryDocument } from './language/query.js';
|
|
12
|
+
export type { QueryRequestOptions } from './execution/client.js';
|
|
10
13
|
export { isQueryError, QueryError, type QueryErrorCode, type QueryErrorDetails, } from './execution/error.js';
|
|
11
|
-
export {
|
|
14
|
+
export { runQuery, type QueryOptions, type QueryPageOptions } from './execution/run.js';
|
|
12
15
|
export { defineCollectionQuery, queryResult, type CollectionQueryDefinition, type CollectionQuerySpec, type CollectionValue, type CompleteQueryProjectionContext, type PaginatedQuery, type ProjectedQuery, type QueryAstOf, type QueryPages, type QueryProjectionContext, type RawQuery, type SingleQuery, type SingleQueryDefinition, } from './legacy/v6/index.js';
|
|
13
16
|
export * from './legacy/v6/kernel.js';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { defineCompositeQuery, realizeQuery } from './define.js';
|
|
2
2
|
export { executeQuery } from './execution/index.js';
|
|
3
3
|
export { QueryPaginationError, QueryValueMismatchError, } from './failure.js';
|
|
4
|
-
// Query v7
|
|
5
|
-
export { defineQuery } from './
|
|
4
|
+
// Query v7. `defineQuery` defines a Query v7 from a string id, and a V6 Query from a function.
|
|
5
|
+
export { defineQuery } from './defined/define.js';
|
|
6
6
|
export { edgeKey, } from './handles/rows.js';
|
|
7
7
|
export { isQueryError, QueryError, } from './execution/error.js';
|
|
8
|
-
export {
|
|
8
|
+
export { runQuery } from './execution/run.js';
|
|
9
9
|
// Query V6.
|
|
10
10
|
export { defineCollectionQuery, queryResult, } from './legacy/v6/index.js';
|
|
11
11
|
export * from './legacy/v6/kernel.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The Query v7 language: the static type of a Query's canonical JSON, over one Domain. */
|
|
2
|
-
export { QUERY, type
|
|
2
|
+
export { QUERY, type QueryDocument, type Query, type QueryBounds, type QueryBranch, type QueryClassKey, type QueryCondition, type QueryDomainOf, type QueryEdgeClassKey, type QueryNodeClassKey, type QueryOperatorOf, type QueryOrderKey, type QueryPropertyKey, type QueryPropertyValue, type QueryPropertyValues, type QueryRange, type QueryRendering, type QueryRoot, type QueryTraversal, type Refused, type SizedList, type SizedQuery, type TraversalDirection, type UnsizedList, } from './query.js';
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* `Query<Schema>` is the static type of the canonical JSON (`"query": "astrale.query/7"`). Every
|
|
6
6
|
* name is a key of the Domain (its own Classes, its direct dependencies' and the Kernel's), every
|
|
7
|
-
* condition one its key's value kind admits, every value of its key's type. A
|
|
8
|
-
* to it; an LLM, a tool or a person writes it; tsc checks it at the leaf that is wrong.
|
|
7
|
+
* condition one its key's value kind admits, every value of its key's type. A defined Query's reads
|
|
8
|
+
* lower to it; an LLM, a tool or a person writes it; tsc checks it at the leaf that is wrong.
|
|
9
9
|
*
|
|
10
10
|
* It neither wraps nor re-exports the Kernel's builders (`where`, `key`, `property`, `ref`): the
|
|
11
11
|
* SDK owns its language surface; the Kernel's wire decoder is the one judge of a document.
|
|
@@ -77,7 +77,7 @@ export type QueryPropertyValues<Source> = QueryDomainOf<Source> extends infer D
|
|
|
77
77
|
* `text` or an `instant` (an annotation of its schema), an array a `set` or a `json` (its
|
|
78
78
|
* `uniqueItems`), the portable `Value` any kind. tsc admits what any of them admits, so it never
|
|
79
79
|
* refuses a condition the Kernel answers; the Kernel's decoder refuses the rest (law L4). A value
|
|
80
|
-
* of unknown type (a Query over any Domain, `
|
|
80
|
+
* of unknown type (a Query over any Domain, `QueryDocument`) admits every kind.
|
|
81
81
|
*/
|
|
82
82
|
type KindsOf<V> = unknown extends V ? keyof Admits : V extends boolean ? 'boolean' : V extends number ? 'number' : V extends string ? string extends V ? 'text' | 'instant' : 'enum' : V extends readonly unknown[] ? 'set' | 'json' : V extends null ? never : 'json';
|
|
83
83
|
/** The operators each value kind admits; `key` orders a list (page § Atoms et value kinds). */
|
|
@@ -309,7 +309,7 @@ type QueryOver<D extends Domain, L extends Size> = D extends Domain ? {
|
|
|
309
309
|
} : never;
|
|
310
310
|
/** A Query of the Domain, as its canonical JSON: the root fold names its family. */
|
|
311
311
|
export type Query<Source> = QueryOver<QueryDomainOf<Source>, UnsizedList>;
|
|
312
|
-
/** A Query whose every list is sized by `limit`: the
|
|
312
|
+
/** A Query whose every list is sized by `limit`: the document a defined Query reads (W1). */
|
|
313
313
|
export type SizedQuery<Source> = QueryOver<QueryDomainOf<Source>, SizedList>;
|
|
314
314
|
/** The parts of a Query, for authors who build one piece by piece. */
|
|
315
315
|
export type QueryCondition<Source> = Where<QueryDomainOf<Source>>;
|
|
@@ -319,5 +319,5 @@ export type QueryBranch<Source> = Branch<QueryDomainOf<Source>, UnsizedList>;
|
|
|
319
319
|
export type QueryRoot<Source> = Root<QueryDomainOf<Source>, UnsizedList>;
|
|
320
320
|
export type QueryRange<Source> = Range<QueryDomainOf<Source>>;
|
|
321
321
|
/** Any v7 Query, of any Domain: what code that does not know the Domain handles. */
|
|
322
|
-
export type
|
|
322
|
+
export type QueryDocument = Query<Domain>;
|
|
323
323
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { QueryAST } from '@astrale-os/kernel-core/graph/query';
|
|
2
1
|
import type { AnyResolvedClass } from '@astrale-os/kernel-dsl/v1';
|
|
2
|
+
import { QueryAST } from '@astrale-os/kernel-core/graph/query';
|
|
3
3
|
import type { Edge } from '../../../../../platform/graph/edge/index.js';
|
|
4
4
|
import type { Node } from '../../../../../platform/graph/node/index.js';
|
|
5
5
|
import type { Domain } from '../../../../../platform/schema/index.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { definedClass } from '@astrale-os/kernel-client/graph';
|
|
2
|
-
import { Query, QueryAST
|
|
2
|
+
import { Query, QueryAST } from '@astrale-os/kernel-core/graph/query';
|
|
3
3
|
import { QueryCompositionError } from '../../../composite/errors.js';
|
|
4
4
|
import { collectionIdentityOf } from './identity.js';
|
|
5
5
|
import { COLLECTION_QUERY_LIMITS } from './limits.js';
|
|
@@ -31,8 +31,8 @@ export function compileCollectionUnion(domain, definitions, outputPath) {
|
|
|
31
31
|
name,
|
|
32
32
|
specification: realizeMember(definition, domain, outputPath, name),
|
|
33
33
|
}));
|
|
34
|
-
if (realized.length >
|
|
35
|
-
limit(`${pathOf(outputPath)} has ${realized.length} collection members; maximum is ${
|
|
34
|
+
if (realized.length > QueryAST.limits.sourceTerms) {
|
|
35
|
+
limit(`${pathOf(outputPath)} has ${realized.length} collection members; maximum is ${QueryAST.limits.sourceTerms}.`);
|
|
36
36
|
}
|
|
37
37
|
const ids = new Map();
|
|
38
38
|
const classes = new Map();
|
|
@@ -28,7 +28,7 @@ export interface SingleQueryProjector<Schema extends schema.DomainSchema> {
|
|
|
28
28
|
export interface CollectionQueryProjector<Schema extends schema.DomainSchema> {
|
|
29
29
|
<Class extends AnyResolvedClass>(project: (domain: ResolvedDomainOf<Schema>) => CollectionQuerySpec<Class>): CollectionQueryDefinition<ResolvedDomainOf<Schema>, Class>;
|
|
30
30
|
}
|
|
31
|
-
/** Define one inert single Query
|
|
31
|
+
/** Define one inert single Query projected from its exact loaded Domain. */
|
|
32
32
|
export declare function defineQuery<Schema extends schema.DomainSchema>(): SingleQueryProjector<Schema>;
|
|
33
33
|
/** Define one reusable complete polymorphic Class-extent Query. */
|
|
34
34
|
export declare function defineCollectionQuery<Schema extends schema.DomainSchema>(): CollectionQueryProjector<Schema>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Query } from '@astrale-os/kernel-core/graph/query';
|
|
2
|
-
import { definitionBase,
|
|
2
|
+
import { definitionBase, inertQuery } from '../../definition.js';
|
|
3
3
|
import { requireUniqueCollectionValues } from './collection/identity.js';
|
|
4
4
|
import { COLLECTION_QUERY_LIMITS } from './collection/limits.js';
|
|
5
5
|
import { realizeCollectionQuery, registerCollectionQuery, } from './collection/metadata.js';
|
|
@@ -7,9 +7,9 @@ import { definedValues } from './conformance.js';
|
|
|
7
7
|
import { queryResult } from './single/index.js';
|
|
8
8
|
const DEFAULT_PAGE_SIZE = 256;
|
|
9
9
|
const MAXIMUM_PAGES = 1_024;
|
|
10
|
-
/** Define one inert single Query
|
|
10
|
+
/** Define one inert single Query projected from its exact loaded Domain. */
|
|
11
11
|
export function defineQuery() {
|
|
12
|
-
return ((project) =>
|
|
12
|
+
return ((project) => inertQuery('query', project));
|
|
13
13
|
}
|
|
14
14
|
/** Define one reusable complete polymorphic Class-extent Query. */
|
|
15
15
|
export function defineCollectionQuery() {
|
|
@@ -4,13 +4,15 @@ import type { Domain } from '../../../../../platform/schema/index.js';
|
|
|
4
4
|
import type { QueryDefinition } from '../../../query.js';
|
|
5
5
|
import type { CollectionDefinitionRecord } from '../collection/union.js';
|
|
6
6
|
import type { SingleQuery } from '../single/index.js';
|
|
7
|
-
|
|
7
|
+
import type { QueryPageExecutor } from '../single/pagination.js';
|
|
8
|
+
/** The client a V6 Query reads through, page by page. Every `QueryClient` serves it. */
|
|
9
|
+
export interface QueryV6Client {
|
|
8
10
|
query<Ast extends QueryAST>(ast: Ast, options: {
|
|
9
11
|
readonly page: QueryPageRequest;
|
|
10
12
|
}): Promise<QueryResponse<QueryResultFor<Ast>>>;
|
|
11
13
|
}
|
|
12
14
|
/** The client's V6 reads, each value checked against this client's Domain. */
|
|
13
|
-
export declare function conformingClient(client:
|
|
14
|
-
export declare function runCollectionUnion(execute:
|
|
15
|
+
export declare function conformingClient(client: QueryV6Client, domain: Domain): QueryPageExecutor;
|
|
16
|
+
export declare function runCollectionUnion(execute: QueryPageExecutor, domain: Domain, definitions: CollectionDefinitionRecord, outputPath: readonly string[]): Promise<Readonly<Record<string, readonly unknown[]>>>;
|
|
15
17
|
export declare function realizeSingle<DomainValue extends Domain>(definition: QueryDefinition<Domain, unknown, unknown>, domain: DomainValue): SingleQuery<unknown, unknown>;
|
|
16
|
-
export declare function runSingle(execute:
|
|
18
|
+
export declare function runSingle(execute: QueryPageExecutor, definition: SingleQuery<unknown, unknown>, input: unknown): Promise<unknown>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Query V6: the names `@astrale-os/sdk/query` exports for V6
|
|
1
|
+
/** Query V6: the names `@astrale-os/sdk/query` exports for V6 Queries and their results. */
|
|
2
2
|
export { defineCollectionQuery, defineQuery } from './define.js';
|
|
3
3
|
export type { CollectionQuerySpec } from './collection/metadata.js';
|
|
4
4
|
export type { CollectionQueryDefinition, CollectionValue, QueryAstOf, SingleQueryDefinition, } from '../../query.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/** Query V6: the names `@astrale-os/sdk/query` exports for V6
|
|
1
|
+
/** Query V6: the names `@astrale-os/sdk/query` exports for V6 Queries and their results. */
|
|
2
2
|
export { defineCollectionQuery, defineQuery } from './define.js';
|
|
3
3
|
export { queryResult } from './single/index.js';
|
|
@@ -24,7 +24,7 @@ export interface QueryLifecycle<Input, Output> {
|
|
|
24
24
|
export interface QueryPagination {
|
|
25
25
|
readonly maximumPages: number;
|
|
26
26
|
}
|
|
27
|
-
/** Inert Domain-bound Query
|
|
27
|
+
/** Inert Domain-bound Query definition. Its projector is retained privately by the SDK. */
|
|
28
28
|
export interface QueryDefinition<DomainValue extends Domain = Domain, Input = unknown, Output = QueryResult> {
|
|
29
29
|
readonly kind: 'query' | 'composite-query';
|
|
30
30
|
readonly [QUERY_DOMAIN]: (domain: DomainValue) => DomainValue;
|
|
@@ -35,14 +35,14 @@ export interface SingleQueryDefinition<DomainValue extends Domain = Domain, Inpu
|
|
|
35
35
|
readonly kind: 'query';
|
|
36
36
|
}
|
|
37
37
|
export type CollectionValue<Class extends AnyResolvedClass> = Class extends ResolvedClass<'node'> ? Node : Class extends ResolvedClass<'edge'> ? Edge : never;
|
|
38
|
-
/** Closed complete-Class Query
|
|
38
|
+
/** Closed complete-Class Query definition admitted for explicit physical union planning. */
|
|
39
39
|
export interface CollectionQueryDefinition<DomainValue extends Domain = Domain, Class extends AnyResolvedClass = AnyResolvedClass> extends SingleQueryDefinition<DomainValue, void, readonly CollectionValue<Class>[]> {
|
|
40
40
|
readonly [COLLECTION_QUERY_CLASS]: Class;
|
|
41
41
|
}
|
|
42
42
|
export interface CompositeQueryDefinition<DomainValue extends Domain = Domain, Input = unknown, Output = unknown> extends QueryDefinition<DomainValue, Input, Output> {
|
|
43
43
|
readonly kind: 'composite-query';
|
|
44
44
|
}
|
|
45
|
-
/** Canonical admitted operation produced by realizing one Query
|
|
45
|
+
/** Canonical admitted operation produced by realizing one Query definition. */
|
|
46
46
|
export type RealizedQuery<Input, Output = QueryResult, Ast extends QueryAST = QueryAST> = SingleQuery<Input, Output, Ast> | CompositeQuery<Input, unknown, Output, Domain>;
|
|
47
47
|
export type QueryInputOf<Value> = Value extends QueryDefinition<infer _Domain, infer Input, infer _Output> ? Input : Value extends QueryLifecycle<infer Input, infer _Output> ? Input : never;
|
|
48
48
|
export type QueryOutputOf<Value> = Value extends QueryDefinition<infer _Domain, infer _Input, infer Output> ? Output : Value extends QueryLifecycle<infer _Input, infer Output> ? Output : never;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { release } from '@astrale-os/kernel-protocol';
|
|
2
2
|
import type { RuntimeRegistry } from '../runtime/index.js';
|
|
3
3
|
import type { Routes } from './collection.js';
|
|
4
|
-
/** Lower
|
|
4
|
+
/** Lower definition identities to canonical callable keys after Runtime admission. */
|
|
5
5
|
export declare function admit(input: Routes | undefined, registry: RuntimeRegistry): readonly release.HttpRouteDeclaration[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isRoutes } from './collection.js';
|
|
2
|
-
/** Lower
|
|
2
|
+
/** Lower definition identities to canonical callable keys after Runtime admission. */
|
|
3
3
|
export function admit(input, registry) {
|
|
4
4
|
if (input === undefined)
|
|
5
5
|
return Object.freeze([]);
|
|
@@ -8,7 +8,7 @@ export function admit(input, registry) {
|
|
|
8
8
|
return Object.freeze(input.entries.map(({ target, ...declaration }) => {
|
|
9
9
|
const implementation = registry.implementations.find(({ definition }) => definition === target);
|
|
10
10
|
if (implementation === undefined) {
|
|
11
|
-
throw new TypeError(`Route ${declaration.name} targets a
|
|
11
|
+
throw new TypeError(`Route ${declaration.name} targets a definition outside the Runtime.`);
|
|
12
12
|
}
|
|
13
13
|
return Object.freeze({ ...declaration, callable: implementation.callable.key });
|
|
14
14
|
}));
|
|
@@ -2,8 +2,9 @@ import type { Route, RouteInput, RouteTarget } from './route.js';
|
|
|
2
2
|
export { admit } from './admission.js';
|
|
3
3
|
export { isRoute, isRoutes, routes, type Routes } from './collection.js';
|
|
4
4
|
export type { Route, RouteInput, RouteTarget } from './route.js';
|
|
5
|
-
|
|
5
|
+
/** An Action or Workflow definition: what a route targets. */
|
|
6
|
+
type Callable = RouteTarget & {
|
|
6
7
|
readonly run: (...input: never[]) => unknown;
|
|
7
8
|
};
|
|
8
9
|
/** Define one HTTP route without exposing DSL Function or Method topology. */
|
|
9
|
-
export declare function route<const Target extends
|
|
10
|
+
export declare function route<const Target extends Callable>(target: Target, input: RouteInput): Route<Target>;
|
|
@@ -4,7 +4,7 @@ export interface RouteTarget {
|
|
|
4
4
|
readonly address: string;
|
|
5
5
|
}
|
|
6
6
|
export type RouteInput = Omit<release.HttpRouteDeclaration, 'callable'>;
|
|
7
|
-
/** One provider-neutral HTTP route targeting an admitted Action or Workflow
|
|
7
|
+
/** One provider-neutral HTTP route targeting an admitted Action or Workflow definition. */
|
|
8
8
|
export interface Route<Target extends RouteTarget = RouteTarget> extends RouteInput {
|
|
9
9
|
readonly target: Target;
|
|
10
10
|
}
|
|
@@ -6,22 +6,22 @@ import type { WorkflowAddress, WorkflowDefinition } from '../workflow/index.js';
|
|
|
6
6
|
import type { RuntimeInitialization, RuntimeInitializer } from './initialize.js';
|
|
7
7
|
import type { RuntimeIntegrations } from './integrations.js';
|
|
8
8
|
import type { Runtime } from './runtime.js';
|
|
9
|
-
/** Retain each
|
|
10
|
-
type RuntimeFunctionSignature<
|
|
9
|
+
/** Retain each Function's exact contract without repeating the owning Schema in every tuple slot. */
|
|
10
|
+
type RuntimeFunctionSignature<Callable> = Callable extends ActionDefinition<infer Schema, infer Address, infer Definitions, infer Errors> ? readonly [
|
|
11
11
|
'action',
|
|
12
12
|
Address,
|
|
13
13
|
Definitions,
|
|
14
14
|
Errors,
|
|
15
15
|
{
|
|
16
|
-
[Key in keyof
|
|
16
|
+
[Key in keyof Callable as Exclude<Key, keyof ActionDefinition<Schema, Address, Definitions, Errors>>]: Callable[Key];
|
|
17
17
|
}
|
|
18
|
-
] :
|
|
18
|
+
] : Callable extends WorkflowDefinition<infer Schema, infer Address, infer Definitions, infer Errors> ? readonly [
|
|
19
19
|
'workflow',
|
|
20
20
|
Address,
|
|
21
21
|
Definitions,
|
|
22
22
|
Errors,
|
|
23
23
|
{
|
|
24
|
-
[Key in keyof
|
|
24
|
+
[Key in keyof Callable as Exclude<Key, keyof WorkflowDefinition<Schema, Address, Definitions, Errors>>]: Callable[Key];
|
|
25
25
|
}
|
|
26
26
|
] : never;
|
|
27
27
|
export type RuntimeFunctionSignatures<Functions extends readonly unknown[]> = {
|
|
@@ -37,7 +37,7 @@ type RuntimeFunction<Schema extends schema.DomainSchema, Signature> = Signature
|
|
|
37
37
|
type RuntimeFunctions<Schema extends schema.DomainSchema, Signatures extends readonly unknown[]> = {
|
|
38
38
|
[Index in keyof Signatures]: RuntimeFunction<Schema, Signatures[Index]>;
|
|
39
39
|
};
|
|
40
|
-
/** A portable inferred Runtime keeps its Schema once while retaining the exact
|
|
40
|
+
/** A portable inferred Runtime keeps its Schema once while retaining the exact Function tuple. */
|
|
41
41
|
export interface AuthoredRuntime<Schema extends schema.DomainSchema, Integrations extends RuntimeIntegrations, Initialize extends RuntimeInitializer<never, RuntimeInitialization, Schema>, Signatures extends readonly unknown[]> extends Runtime<Schema, Integrations, Initialize, RuntimeFunctions<Schema, Signatures>> {
|
|
42
42
|
}
|
|
43
43
|
export {};
|
|
@@ -11,11 +11,11 @@ type AnyRuntimeInitializer<Schema extends schema.DomainSchema> = RuntimeInitiali
|
|
|
11
11
|
type Same<Left, Right> = [Left] extends [Right] ? ([Right] extends [Left] ? true : false) : false;
|
|
12
12
|
type ActionSchema<Value> = Value extends ActionDefinition<infer Schema, infer _Address, infer _Services> ? Schema : never;
|
|
13
13
|
type WorkflowSchema<Value> = Value extends WorkflowDefinition<infer Schema, infer _Address, infer _Services> ? Schema : never;
|
|
14
|
-
type
|
|
15
|
-
type
|
|
14
|
+
type FunctionIntegrations<Value> = Value extends ActionDefinition<infer _Schema, infer _Address, infer Definitions> ? Definitions : Value extends WorkflowDefinition<infer _Schema, infer _Address, infer Definitions> ? Definitions : never;
|
|
15
|
+
type AdmitsFunctionSchema<Schema extends schema.DomainSchema, Functions extends readonly unknown[]> = [Functions[number]] extends [never] ? unknown : Same<ActionSchema<Functions[number]> | WorkflowSchema<Functions[number]>, Schema> extends true ? unknown : never;
|
|
16
16
|
type InitializationOf<Initialize extends RuntimeInitializerValue> = Awaited<ReturnType<Initialize>>;
|
|
17
|
-
type
|
|
18
|
-
type AdmitsIntegrations<Definitions extends RuntimeIntegrations, Functions extends readonly unknown[]> = [Functions[number]] extends [never] ? unknown : false extends
|
|
17
|
+
type AdmitsFunctionIntegrations<Definitions extends RuntimeIntegrations, Callable> = FunctionIntegrations<Callable> extends infer Required extends RuntimeIntegrations ? Exclude<keyof Required, keyof Definitions> extends never ? Required extends Pick<Definitions, Extract<keyof Required, keyof Definitions>> ? true : false : false : false;
|
|
18
|
+
type AdmitsIntegrations<Definitions extends RuntimeIntegrations, Functions extends readonly unknown[]> = [Functions[number]] extends [never] ? unknown : false extends AdmitsFunctionIntegrations<Definitions, Functions[number]> ? never : unknown;
|
|
19
19
|
type AdmitsProviders<Integrations extends RuntimeIntegrations, Initialize extends RuntimeInitializerValue> = Same<InitializationOf<Initialize>['providers'], Providers<Integrations>> extends true ? unknown : never;
|
|
20
20
|
export interface RuntimeInput<Integrations extends RuntimeIntegrations, Initialize extends RuntimeInitializerValue, Functions extends readonly unknown[]> {
|
|
21
21
|
readonly integrations: Integrations;
|
|
@@ -23,6 +23,6 @@ export interface RuntimeInput<Integrations extends RuntimeIntegrations, Initiali
|
|
|
23
23
|
readonly functions: Functions;
|
|
24
24
|
}
|
|
25
25
|
/** Define one inert Runtime declaration; realization requires an exact loaded DSL Domain. */
|
|
26
|
-
export declare function defineRuntime<Schema extends schema.DomainSchema>(): <const Integrations extends RuntimeIntegrations, Initialize extends AnyRuntimeInitializer<Schema>, const Functions extends readonly unknown[]>(input: RuntimeInput<Integrations, Initialize, Functions> &
|
|
26
|
+
export declare function defineRuntime<Schema extends schema.DomainSchema>(): <const Integrations extends RuntimeIntegrations, Initialize extends AnyRuntimeInitializer<Schema>, const Functions extends readonly unknown[]>(input: RuntimeInput<Integrations, Initialize, Functions> & AdmitsFunctionSchema<Schema, Functions> & AdmitsIntegrations<Integrations, Functions> & AdmitsProviders<Integrations, Initialize>) => AuthoredRuntime<Schema, Integrations, Initialize, RuntimeFunctionSignatures<Functions>>;
|
|
27
27
|
export declare function isRuntime(input: unknown): input is Runtime;
|
|
28
28
|
export {};
|
|
@@ -6,8 +6,8 @@ import type { DomainCapabilities, DomainKernelSessions, DomainMutate } from '../
|
|
|
6
6
|
import type { HandlerDependencies } from '../dependency/index.js';
|
|
7
7
|
import type { DeclaredErrorFactory, DeclaredErrors, NoDeclaredErrors } from '../error/index.js';
|
|
8
8
|
import type { Integrations, ReplayableIntegrationClients } from '../integration/index.js';
|
|
9
|
-
import type { Mutation, MutationInputOf, MutationOutputOf,
|
|
10
|
-
import type { InputOf, OutputOf, QueryDefinition,
|
|
9
|
+
import type { Mutation, MutationInputOf, MutationOutputOf, DefinedMutation } from '../mutation/index.js';
|
|
10
|
+
import type { InputOf, OutputOf, QueryDefinition, DefinedQuery, QueryOptions } from '../query/index.js';
|
|
11
11
|
/** A callable whose Schema declares `execution: { durable: true }`. */
|
|
12
12
|
export interface DurableCallable {
|
|
13
13
|
readonly execution: {
|
|
@@ -99,8 +99,8 @@ export interface DurableStepDeclaration {
|
|
|
99
99
|
/**
|
|
100
100
|
* A Step's id alone, under the deployment's retry budget and Step timeout, or a declaration of its
|
|
101
101
|
* own. A Step that spends its budget, or that the Kernel refuses for good, throws an error
|
|
102
|
-
* `exhausted` recognizes. A Step whose
|
|
103
|
-
* unless the Kernel refused the read; a
|
|
102
|
+
* `exhausted` recognizes. A Step whose Query read fails throws its `QueryError`, not retried
|
|
103
|
+
* unless the Kernel refused the read; a Query that crosses a dependency's Class its Domain does
|
|
104
104
|
* not require throws its `TypeError`, not retried. Uncaught, each ends the Execution `failed`
|
|
105
105
|
* with code `STEP_EXHAUSTED`.
|
|
106
106
|
*/
|
|
@@ -114,19 +114,19 @@ export interface DurableStep<DomainValue extends Domain = Domain, Definitions ex
|
|
|
114
114
|
run<Output>(step: DurableStepId, execute: (authority: DurableStepAuthority<DomainValue, Definitions>) => Output | Promise<Output>): Promise<Output>;
|
|
115
115
|
/**
|
|
116
116
|
* One journaled Query. A replay returns the result of its first run, so a later Step that depends
|
|
117
|
-
* on it resends the same request whenever it is retried. A
|
|
117
|
+
* on it resends the same request whenever it is retried. A Query v7 reads as the executor; its
|
|
118
118
|
* `QueryError`, or the `TypeError` of a dependency's Class its Domain does not require, is
|
|
119
119
|
* journaled as the Step's failure, is not retried, and a replay throws it again. A read the
|
|
120
120
|
* Kernel refused is a failed attempt instead, as any Kernel refusal.
|
|
121
121
|
*/
|
|
122
|
-
query<R extends
|
|
122
|
+
query<R extends DefinedQuery>(step: DurableStepId, query: R, input: InputOf<R>, options: QueryOptions<R, 'executor'>): Promise<OutputOf<R>>;
|
|
123
123
|
query<Output>(step: DurableStepId, query: QueryDefinition<DomainValue, void, Output>): Promise<Output>;
|
|
124
124
|
query<Input, Output>(step: DurableStepId, query: QueryDefinition<DomainValue, Input, Output>, input: Input): Promise<Output>;
|
|
125
125
|
/**
|
|
126
126
|
* One journaled Mutation, as the executor. A Step replayed after its commit receives the result
|
|
127
127
|
* of that commit from the Kernel's receipt instead of writing again.
|
|
128
128
|
*/
|
|
129
|
-
mutate<M extends
|
|
129
|
+
mutate<M extends DefinedMutation>(step: DurableStepId, mutation: M, input: MutationInputOf<M>, options: {
|
|
130
130
|
readonly as: 'executor';
|
|
131
131
|
}): Promise<MutationOutputOf<M>>;
|
|
132
132
|
mutate<Input, Output>(step: DurableStepId, mutation: Mutation<DomainValue, Input, Output>, input: Input): Promise<Output>;
|
|
@@ -147,10 +147,10 @@ export interface DurableParallelStep<out Output> {
|
|
|
147
147
|
/** The Steps one `step.parallel` declares, with the arguments of `step.run`, `query` and `mutate`. */
|
|
148
148
|
export interface DurableParallelSteps<DomainValue extends Domain = Domain, Definitions extends Integrations = Readonly<Record<never, never>>> {
|
|
149
149
|
run<Output>(step: DurableStepId, execute: (authority: DurableStepAuthority<DomainValue, Definitions>) => Output | Promise<Output>): DurableParallelStep<Output>;
|
|
150
|
-
query<R extends
|
|
150
|
+
query<R extends DefinedQuery>(step: DurableStepId, query: R, input: InputOf<R>, options: QueryOptions<R, 'executor'>): DurableParallelStep<OutputOf<R>>;
|
|
151
151
|
query<Output>(step: DurableStepId, query: QueryDefinition<DomainValue, void, Output>): DurableParallelStep<Output>;
|
|
152
152
|
query<Input, Output>(step: DurableStepId, query: QueryDefinition<DomainValue, Input, Output>, input: Input): DurableParallelStep<Output>;
|
|
153
|
-
mutate<M extends
|
|
153
|
+
mutate<M extends DefinedMutation>(step: DurableStepId, mutation: M, input: MutationInputOf<M>, options: {
|
|
154
154
|
readonly as: 'executor';
|
|
155
155
|
}): DurableParallelStep<MutationOutputOf<M>>;
|
|
156
156
|
mutate<Input, Output>(step: DurableStepId, mutation: Mutation<DomainValue, Input, Output>, input: Input): DurableParallelStep<Output>;
|
|
@@ -7,12 +7,19 @@ export interface Build<Schema extends schema.DomainSchema = schema.DomainSchema,
|
|
|
7
7
|
readonly schema: BuildSchema<Schema>;
|
|
8
8
|
readonly runtime: RuntimeValue;
|
|
9
9
|
readonly callables: readonly Key.Callable[];
|
|
10
|
-
readonly requirements:
|
|
10
|
+
readonly requirements: BuildRequirements;
|
|
11
11
|
readonly routes: routes.Plan;
|
|
12
12
|
readonly frontend?: FrontendCompilation;
|
|
13
13
|
/** What the release manifest shows of the application: its icon. */
|
|
14
14
|
readonly presentation?: BuildPresentation;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* What a build requires of the Instance. The SDK declares capabilities in the legacy shape only
|
|
18
|
+
* (`functions`, `classes`, `authority`, `core`), never roles or scopes.
|
|
19
|
+
*/
|
|
20
|
+
export interface BuildRequirements extends release.Requirements {
|
|
21
|
+
readonly capabilities: release.LegacyCapabilityRequirements;
|
|
22
|
+
}
|
|
16
23
|
export interface BuildPresentation {
|
|
17
24
|
/** One self-contained inline SVG. */
|
|
18
25
|
readonly icon?: string;
|
|
@@ -58,6 +58,9 @@ export function restoreBuild(input, runtime) {
|
|
|
58
58
|
}
|
|
59
59
|
const registry = bindRuntime(domain, runtime, input.callables);
|
|
60
60
|
const requirements = admitRequirements(input.requirements);
|
|
61
|
+
// A build declares its capabilities in the legacy shape only: never roles or scopes.
|
|
62
|
+
if ('roles' in requirements.capabilities || 'scopes' in requirements.capabilities)
|
|
63
|
+
invalid();
|
|
61
64
|
validateRequirements(decoded.root, decoded.closure, requirements);
|
|
62
65
|
const plan = admitRoutePlan(input.routes, domain);
|
|
63
66
|
const compiled = deepFreeze(input.schema.compiled);
|
|
@@ -5,7 +5,7 @@ import type { Domain } from '../../../platform/schema/index.js';
|
|
|
5
5
|
import type { InvocationSessions } from '../admission/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* Bind what code acting under `sessions` holds: self-default Kernel and graph, and dependency
|
|
8
|
-
* invokers per authority. An Action and a durable Step receive these same capabilities. A
|
|
8
|
+
* invokers per authority. An Action and a durable Step receive these same capabilities. A Query's
|
|
9
9
|
* reads are checked against the Class requirements the Domain's build `declared` (S12).
|
|
10
10
|
*/
|
|
11
11
|
export declare function bindCapabilities(domain: Domain, sessions: Readonly<Record<'caller' | 'self', BoundClientSession>>, declared?: readonly DeclaredClass[]): DomainCapabilities;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mutationSpecOf } from '../../../application/mutation/define.js';
|
|
2
2
|
import { executeMutation } from '../../../application/mutation/execution/execute.js';
|
|
3
3
|
import { bindMutation } from '../../../application/mutation/execution/executor.js';
|
|
4
|
+
import { querySpecOf } from '../../../application/query/defined/define.js';
|
|
4
5
|
import { bindQuery } from '../../../application/query/execution/executor.js';
|
|
5
|
-
import {
|
|
6
|
-
import { recipeSpecOf } from '../../../application/query/recipe/define.js';
|
|
6
|
+
import { runQuery } from '../../../application/query/execution/run.js';
|
|
7
7
|
import { bindDependencies } from '../dependency/index.js';
|
|
8
8
|
export function bindCapabilities(domain, sessions, declared) {
|
|
9
9
|
const graph = bindGraph(sessions, domain);
|
|
@@ -13,17 +13,17 @@ export function bindCapabilities(domain, sessions, declared) {
|
|
|
13
13
|
dependencies: bindDependencies(domain, sessions),
|
|
14
14
|
graph,
|
|
15
15
|
query: async (definition, input, options) => {
|
|
16
|
-
if (
|
|
16
|
+
if (mutationSpecOf(definition) !== undefined)
|
|
17
17
|
throw new TypeError(`Mutation ${definition.id} writes: call it with mutate, not query.`);
|
|
18
|
-
if (
|
|
18
|
+
if (querySpecOf(definition) === undefined)
|
|
19
19
|
return graphUnder(options).query(definition, input);
|
|
20
20
|
if (options === undefined)
|
|
21
|
-
throw new TypeError(`
|
|
21
|
+
throw new TypeError(`Query ${definition.id} is called with { as: 'executor' | 'caller' }.`);
|
|
22
22
|
const { size, after } = options;
|
|
23
|
-
return
|
|
23
|
+
return runQuery(sessions[authorityOf(sessions, options)], domain, definition, input, { ...(size === undefined ? {} : { size }), ...(after === undefined ? {} : { after }) }, declared);
|
|
24
24
|
},
|
|
25
25
|
mutate: async (definition, input, options) => {
|
|
26
|
-
if (
|
|
26
|
+
if (mutationSpecOf(definition) === undefined)
|
|
27
27
|
return graphUnder(options).mutate(definition, input);
|
|
28
28
|
if (options === undefined)
|
|
29
29
|
throw new TypeError(`Mutation ${definition.id} is called with { as: 'executor' | 'caller' }.`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { declaredErrorFactory, declaredErrorOf } from '../../../application/error/index.js';
|
|
2
|
-
import { protocolError,
|
|
2
|
+
import { protocolError, reportUndeclaredDefinedError } from '../result/index.js';
|
|
3
3
|
export async function action(selected, context) {
|
|
4
4
|
const complete = Object.freeze({
|
|
5
5
|
...context,
|
|
@@ -11,7 +11,7 @@ export async function action(selected, context) {
|
|
|
11
11
|
catch (cause) {
|
|
12
12
|
const declared = declaredErrorOf(cause, selected.definition);
|
|
13
13
|
if (declared === undefined) {
|
|
14
|
-
|
|
14
|
+
reportUndeclaredDefinedError(cause, selected.address);
|
|
15
15
|
throw cause;
|
|
16
16
|
}
|
|
17
17
|
throw protocolError(declared.family, declared.message, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { declaredErrorFactory, declaredErrorOf } from '../../../application/error/index.js';
|
|
2
|
-
import { protocolError,
|
|
2
|
+
import { protocolError, reportUndeclaredDefinedError } from '../result/index.js';
|
|
3
3
|
export async function workflow(selected, context, runner) {
|
|
4
4
|
const complete = Object.freeze({
|
|
5
5
|
...context,
|
|
@@ -11,7 +11,7 @@ export async function workflow(selected, context, runner) {
|
|
|
11
11
|
catch (cause) {
|
|
12
12
|
const declared = declaredErrorOf(cause, selected.definition);
|
|
13
13
|
if (declared === undefined) {
|
|
14
|
-
|
|
14
|
+
reportUndeclaredDefinedError(cause, selected.address);
|
|
15
15
|
throw cause;
|
|
16
16
|
}
|
|
17
17
|
throw protocolError(declared.family, declared.message, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { inputError, InvocationDefect, projectError, protocolError } from './errors.js';
|
|
2
2
|
export type { InvocationDefectCode } from './errors.js';
|
|
3
3
|
export { project } from './project.js';
|
|
4
|
-
export {
|
|
4
|
+
export { reportUndeclaredDefinedError } from './undeclared.js';
|
|
5
5
|
export { validateInput, validateOutput } from './validate.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { inputError, InvocationDefect, projectError, protocolError } from './errors.js';
|
|
2
2
|
export { project } from './project.js';
|
|
3
|
-
export {
|
|
3
|
+
export { reportUndeclaredDefinedError } from './undeclared.js';
|
|
4
4
|
export { validateInput, validateOutput } from './validate.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log a Query or Mutation's declared error that reaches a Function which does not re-declare it,
|
|
3
|
+
* before the Server redacts it as an internal error: its code, the id of the Query or Mutation and
|
|
4
|
+
* the Function, never its details, which a read as the executor may fill with what the caller may
|
|
5
|
+
* not read.
|
|
6
|
+
*/
|
|
7
|
+
export declare function reportUndeclaredDefinedError(cause: unknown, address: string): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { definedErrorOf } from '../../../application/error/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Log a Query or Mutation's declared error that reaches a Function which does not re-declare it,
|
|
4
|
+
* before the Server redacts it as an internal error: its code, the id of the Query or Mutation and
|
|
5
|
+
* the Function, never its details, which a read as the executor may fill with what the caller may
|
|
6
|
+
* not read.
|
|
7
|
+
*/
|
|
8
|
+
export function reportUndeclaredDefinedError(cause, address) {
|
|
9
|
+
const raised = definedErrorOf(cause);
|
|
10
|
+
if (raised === undefined)
|
|
11
|
+
return;
|
|
12
|
+
// oxlint-disable-next-line no-console
|
|
13
|
+
console.error('[sdk] Query or Mutation error not re-declared by its Function', {
|
|
14
|
+
code: raised.code,
|
|
15
|
+
id: raised.id,
|
|
16
|
+
function: address,
|
|
17
|
+
});
|
|
18
|
+
}
|