@endge/core 1.0.0-dev.5 → 1.2.0-dev.15

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.
Files changed (87) hide show
  1. package/README.md +46 -0
  2. package/dist/core.js +60726 -47416
  3. package/dist/features/core/kernel/config/kernel.config.d.ts +1 -1
  4. package/dist/features/core/kernel/config/modules.config.d.ts +7 -7
  5. package/dist/features/core/kernel/endge.d.ts +9 -9
  6. package/dist/features/core/modules/actions/domain/action.types.d.ts +2 -0
  7. package/dist/features/core/modules/auth/EndgeAuth_Module.d.ts +9 -1
  8. package/dist/features/core/modules/auth/domain/types/auth-profile.types.d.ts +17 -0
  9. package/dist/features/core/modules/auth/services/auth-facet-claims.d.ts +5 -0
  10. package/dist/features/core/modules/compiler/EndgeCompiler_Module.d.ts +10 -0
  11. package/dist/features/core/modules/compiler/tools/select-type-context.d.ts +1 -0
  12. package/dist/features/core/modules/computations/model/ComputationResource.d.ts +1 -0
  13. package/dist/features/core/modules/context/domain/context-persistence.types.d.ts +1 -0
  14. package/dist/features/core/modules/document-import/services/parsers/GraphQLDocumentImportParser.d.ts +3 -2
  15. package/dist/features/core/modules/domain/types/component/component-core.types.d.ts +4 -0
  16. package/dist/features/core/modules/domain/types/component/sfc/table-events.types.d.ts +18 -0
  17. package/dist/features/core/modules/program/EndgeProgram_Module.d.ts +4 -0
  18. package/dist/features/core/modules/program/domain/types/execution-bundle.types.d.ts +7 -0
  19. package/dist/features/core/modules/program/domain/types/program.types.d.ts +5 -2
  20. package/dist/features/core/modules/program/tools/execution-bundle.d.ts +2 -1
  21. package/dist/features/core/modules/program/tools/startup-bundle.d.ts +2 -0
  22. package/dist/features/core/modules/runtime/EndgeControllers_Module.d.ts +26 -0
  23. package/dist/features/core/modules/runtime/EndgeRuntime_Module.d.ts +2 -0
  24. package/dist/features/core/modules/runtime/adapters/QueryExecutor_Adapter.d.ts +42 -3
  25. package/dist/features/core/modules/runtime/domain/controllers/controller.types.d.ts +121 -0
  26. package/dist/features/core/modules/runtime/domain/controllers/page-cache.types.d.ts +41 -0
  27. package/dist/features/core/modules/runtime/domain/graphql-query-error.d.ts +73 -0
  28. package/dist/features/core/modules/runtime/domain/query-execution.types.d.ts +25 -1
  29. package/dist/features/core/modules/runtime/domain/runtime-entity-map.types.d.ts +2 -0
  30. package/dist/features/core/modules/runtime/domain/runtime-host.types.d.ts +1 -0
  31. package/dist/features/core/modules/runtime/domain/runtime.types.d.ts +3 -2
  32. package/dist/features/core/modules/runtime/domain/stream-runtime.types.d.ts +8 -1
  33. package/dist/features/core/modules/runtime/execution/endge-data-view.d.ts +1 -1
  34. package/dist/features/core/modules/runtime/execution/endge-query.d.ts +21 -2
  35. package/dist/features/core/modules/runtime/hosts/CompositionRuntimeHost.d.ts +9 -0
  36. package/dist/features/core/modules/runtime/hosts/ControllerRuntimeHost.d.ts +64 -0
  37. package/dist/features/core/modules/runtime/hosts/QueryRuntimeHost.d.ts +9 -1
  38. package/dist/features/core/modules/runtime/hosts/SimulationRuntimeHost.d.ts +1 -0
  39. package/dist/features/core/modules/runtime/hosts/StoreRuntimeHost.d.ts +1 -0
  40. package/dist/features/core/modules/runtime/hosts/StreamRuntimeHost.d.ts +30 -0
  41. package/dist/features/core/modules/runtime/services/controllers/ControllerRegistry.d.ts +16 -0
  42. package/dist/features/core/modules/runtime/services/controllers/builtins/CollectionWindowController.d.ts +56 -0
  43. package/dist/features/core/modules/runtime/services/controllers/builtins/collection-window.definition.d.ts +2 -0
  44. package/dist/features/core/modules/runtime/services/controllers/cache/PageCacheService.d.ts +25 -0
  45. package/dist/features/core/modules/runtime/services/controllers/controller-values.d.ts +3 -0
  46. package/dist/features/core/modules/runtime/services/simulation/prepare-simulation-overrides.d.ts +7 -5
  47. package/dist/features/core/modules/runtime/services/strategies/ControllerRuntimeStrategy.d.ts +11 -0
  48. package/dist/features/core/modules/runtime/services/transports/BrowserGraphQLSseStreamTransportFactory.d.ts +24 -0
  49. package/dist/features/core/modules/runtime/services/transports/BrowserSseStreamTransportFactory.d.ts +13 -1
  50. package/dist/features/core/modules/source/EndgeSource_Module.d.ts +6 -0
  51. package/dist/features/core/modules/source/domain/types/composition-source.types.d.ts +13 -2
  52. package/dist/features/core/modules/source/domain/types/data-view-source.types.d.ts +5 -2
  53. package/dist/features/core/modules/source/domain/types/graphql-fragments.types.d.ts +17 -0
  54. package/dist/features/core/modules/source/domain/types/query-source.types.d.ts +4 -1
  55. package/dist/features/core/modules/source/domain/types/simulation-source.types.d.ts +8 -0
  56. package/dist/features/core/modules/source/domain/types/source-context.types.d.ts +6 -0
  57. package/dist/features/core/modules/source/domain/types/source-engine.types.d.ts +3 -0
  58. package/dist/features/core/modules/source/domain/types/source-expression.types.d.ts +3 -1
  59. package/dist/features/core/modules/source/domain/types/stream-source.types.d.ts +29 -1
  60. package/dist/features/core/modules/source/domain/types/type-source.types.d.ts +11 -6
  61. package/dist/features/core/modules/source/services/SimulationSourceResolver.d.ts +6 -0
  62. package/dist/features/core/modules/source/services/compilers/graphql-operation-compile.d.ts +52 -0
  63. package/dist/features/core/modules/source/services/compilers/source-expression-compile.d.ts +21 -0
  64. package/dist/features/core/modules/source/services/compilers/source-model-reference-compile.d.ts +11 -1
  65. package/dist/features/core/modules/source/services/composition-activation.d.ts +6 -1
  66. package/dist/features/core/modules/source/services/graphql-fragments.d.ts +23 -0
  67. package/dist/features/core/modules/source/services/graphql-schema.d.ts +37 -0
  68. package/dist/features/core/modules/source/services/simulation-response-contract.d.ts +23 -0
  69. package/dist/features/core/modules/source/services/source-context.d.ts +13 -0
  70. package/dist/features/core/modules/source/services/type-extends.d.ts +15 -0
  71. package/dist/features/core/modules/source/services/value-expression-language.d.ts +2 -0
  72. package/dist/features/core/modules/source/services/value-path.d.ts +14 -0
  73. package/dist/features/core/modules/ui/EndgeUIRegistry_Module.d.ts +5 -0
  74. package/dist/features/core/modules/ui/adapters/json/EndgeUIJsonRenderer.d.ts +57 -0
  75. package/dist/features/core/modules/ui/adapters/json/endge-ui-json-adapter.d.ts +16 -0
  76. package/dist/features/core/modules/ui/adapters/json/endge-ui-json-patch.d.ts +3 -0
  77. package/dist/features/core/modules/ui/adapters/json/endge-ui-json.schema.d.ts +371 -0
  78. package/dist/features/core/modules/ui/domain/types/endge-ui-json.types.d.ts +121 -0
  79. package/dist/features/core/modules/ui/registry/UIAdapterRegistry.d.ts +2 -0
  80. package/dist/features/federation/EndgeFederation.d.ts +1 -133
  81. package/dist/features/federation/EndgeModule.d.ts +1 -58
  82. package/dist/features/federation/constants/federation.constants.d.ts +1 -1
  83. package/dist/features/federation/tools/sort-endge-modules.d.ts +1 -9
  84. package/dist/features/federation/types/endge-modules.types.d.ts +1 -28
  85. package/dist/features/federation/types/federation.types.d.ts +1 -112
  86. package/dist/main.d.ts +15 -0
  87. package/package.json +9 -5
@@ -0,0 +1,25 @@
1
+ import { ControllerPageCache, PageCacheOptions } from '../../../domain/controllers/page-cache.types';
2
+ export declare const PAGE_CACHE_DATABASE = "endge-collection-pages";
3
+ export declare function pageCacheJson(value: unknown): string;
4
+ /** Runtime-owned bounded page cache. It never owns a Query or writes Store data. */
5
+ export declare class PageCacheService {
6
+ private readonly _buckets;
7
+ private readonly _queue;
8
+ private _queuedBytes;
9
+ private _database;
10
+ private _timer;
11
+ private _flushing;
12
+ private _activeWrite;
13
+ private readonly _preparing;
14
+ private _preparingBytes;
15
+ private _generation;
16
+ private _lastError;
17
+ create(input: PageCacheOptions, scope: () => unknown): ControllerPageCache;
18
+ flush(): Promise<void>;
19
+ reset(): Promise<void>;
20
+ private _schedule;
21
+ private _finishPreparation;
22
+ private _open;
23
+ private _flush;
24
+ private _rollback;
25
+ }
@@ -0,0 +1,3 @@
1
+ import { SourceFieldDefinition } from '../../../source/domain/types/source-expression.types';
2
+ import { TypeProgramCatalogEntry } from '../../../source/domain/types/type-source.types';
3
+ export declare function validateControllerValue(field: SourceFieldDefinition, value: unknown, catalog: readonly TypeProgramCatalogEntry[]): void;
@@ -1,10 +1,12 @@
1
1
  import { RuntimeArtifactReader } from '../../domain/runtime-host.types';
2
- import { SimulationMockStream, SimulationSourceArtifact } from '../../../source/domain/types/simulation-source.types';
2
+ import { SimulationGraphQLError, SimulationMockStream, SimulationSourceArtifact } from '../../../source/domain/types/simulation-source.types';
3
+ export interface SimulationRequestOverride {
4
+ schema: Record<string, unknown>;
5
+ seed: string;
6
+ errors?: SimulationGraphQLError[];
7
+ }
3
8
  export interface SimulationOverrides {
4
- requests: ReadonlyMap<string, {
5
- schema: Record<string, unknown>;
6
- seed: string;
7
- }>;
9
+ requests: ReadonlyMap<string, SimulationRequestOverride>;
8
10
  streams: ReadonlyMap<string, {
9
11
  schema: Record<string, unknown>;
10
12
  options: SimulationMockStream;
@@ -0,0 +1,11 @@
1
+ import { ControllerModel } from '../../domain/controllers/controller.types';
2
+ import { RuntimeStrategy } from '../../domain/runtime-strategy.types';
3
+ import { ControllerRuntimeHost } from '../../hosts/ControllerRuntimeHost';
4
+ export declare class ControllerRuntimeStrategy implements RuntimeStrategy<ControllerModel, ControllerRuntimeHost> {
5
+ private readonly _createHost;
6
+ readonly id = "runtime:controller";
7
+ readonly entityType: "controller";
8
+ constructor(_createHost: RuntimeStrategy<ControllerModel, ControllerRuntimeHost>['create']);
9
+ supports(model: unknown): model is ControllerModel;
10
+ create: RuntimeStrategy<ControllerModel, ControllerRuntimeHost>['create'];
11
+ }
@@ -0,0 +1,24 @@
1
+ import { StreamTransportConnection, StreamTransportFactory } from '../../domain/stream-runtime.types';
2
+ import { ResolveAuthSession } from './BrowserSseStreamTransportFactory';
3
+ /**
4
+ * HTTP 4xx ответа graphql-sse: подписка остановлена без переподключения.
5
+ */
6
+ export declare class GraphQLSseHttpError extends Error {
7
+ readonly status: number;
8
+ readonly url: string;
9
+ constructor(status: number, url: string, cause?: unknown);
10
+ }
11
+ export declare function readSseHttpStatus(error: unknown): number | null;
12
+ /**
13
+ * GraphQL subscription по протоколу graphql-sse, режим distinct connections:
14
+ * одно fetch-соединение на подписку, события next (ExecutionResult) и complete.
15
+ * Событие next публикует data результата; complete закрывает соединение без переподключения.
16
+ * Обрыв без complete, сетевые ошибки, HTTP 5xx, 408 и 429 переподключаются через reconnectDelayMs.
17
+ * Остальные HTTP 4xx останавливают подписку с ошибкой; 401 при auth — один повтор с обновлённым
18
+ * токеном (счётчик сбрасывается после успешного открытия).
19
+ */
20
+ export declare class BrowserGraphQLSseStreamTransportFactory implements StreamTransportFactory {
21
+ private readonly _resolveAuthSession;
22
+ constructor(_resolveAuthSession: ResolveAuthSession);
23
+ open(artifact: Parameters<StreamTransportFactory['open']>[0], callbacks: Parameters<StreamTransportFactory['open']>[1], request?: Parameters<StreamTransportFactory['open']>[2]): StreamTransportConnection;
24
+ }
@@ -2,10 +2,22 @@ import { AuthRequestPolicy, AuthResolvedSession, AuthResolveOptions } from '../.
2
2
  import { StreamTransportConnection, StreamTransportFactory } from '../../domain/stream-runtime.types';
3
3
  export type ResolveAuthSession = (policy: AuthRequestPolicy, options?: AuthResolveOptions) => Promise<AuthResolvedSession>;
4
4
  /**
5
- * Браузерный адаптер, владеющий нативным EventSource и преобразующий его в транспортный порт Core.
5
+ * Браузерный адаптер SSE: без авторизации владеет нативным EventSource, с авторизацией —
6
+ * fetch-соединением SSEManager с Bearer token; оба сохраняют имена событий.
6
7
  */
7
8
  export declare class BrowserSseStreamTransportFactory implements StreamTransportFactory {
8
9
  private readonly _resolveAuthSession;
9
10
  constructor(_resolveAuthSession: ResolveAuthSession);
10
11
  open(artifact: Parameters<StreamTransportFactory['open']>[0], callbacks: Parameters<StreamTransportFactory['open']>[1]): StreamTransportConnection;
11
12
  }
13
+ /**
14
+ * Получает access token AuthProfile для SSE-запроса; после 401/403 следующий запрос
15
+ * принудительно обновляет сессию.
16
+ */
17
+ export declare function createSseAuthTokenProvider(resolveAuthSession: ResolveAuthSession, transport: {
18
+ authMode: 'inherit' | 'profile' | 'none';
19
+ authProfileIdentity: string | null;
20
+ }): {
21
+ getToken: () => Promise<string>;
22
+ onError: (error: unknown) => void;
23
+ };
@@ -1,3 +1,4 @@
1
+ import { SourceContextValues } from './domain/types/source-context.types';
1
2
  import { SourceDocumentReference, SourceEngineCompileContext, SourceEngineCompileResult, SourceEngineGenerateResult, SourceEngineStrategy, SourceKind, SourceLanguageCompletion, SourceLanguageContext, SourceLanguageInlineHint, SourceLanguageSemanticHighlight, SourceLanguageSignatureHelp, SourceLanguageStrategy, SourceLanguageValidationResult, SourceParseResult, SourcePatchResult, SourcePatchStrategy } from './domain/types/source-engine.types';
2
3
  import { EndgeModule } from '../../../federation/EndgeModule';
3
4
  /**
@@ -75,6 +76,11 @@ export declare class EndgeSource_Module extends EndgeModule {
75
76
  * Валидирует source указанного source-kind для editor-facing сценариев.
76
77
  */
77
78
  validate(sourceKind: SourceKind | string, source: string, context?: Omit<SourceLanguageContext, 'source'>): SourceLanguageValidationResult;
79
+ /**
80
+ * Возвращает фасеты и Configuration текущего boot для проверки Source в редакторе;
81
+ * null, пока configuration не разрешена.
82
+ */
83
+ currentSourceContext(): SourceContextValues | null;
78
84
  /**
79
85
  * Возвращает editor-facing completion items для указанного source-kind.
80
86
  */
@@ -4,6 +4,7 @@ import { I18nCompiledLocales } from '../../../i18n/domain/i18n.types';
4
4
  import { EndgeMockReference } from '../../../mock/domain/types/mock-data.type';
5
5
  import { ProgramMetadataMap } from '../../../program/domain/types/program-metadata.types';
6
6
  import { ProgramDiagnostic } from '../../../program/domain/types/program.types';
7
+ import { ControllerDependencyBindings } from '../../../runtime/domain/controllers/controller.types';
7
8
  import { RuntimeHost } from '../../../runtime/domain/runtime-host.types';
8
9
  import { RuntimeScopeHandle } from '../../../runtime/domain/runtime-scope.types';
9
10
  import { VocabLoadPolicy } from '../../../runtime/domain/vocab-cache.types';
@@ -11,7 +12,7 @@ import { FilterViewControlDefinition } from './filter-view.type';
11
12
  import { SourceExpressionIR, SourceFieldDefinition } from './source-expression.types';
12
13
  import { UpdateMutationStrategy } from './update-source.types';
13
14
  import { EndgeDataMode } from '../../../workspace/domain/workspace.types';
14
- export type CompositionRuntimeKind = 'filter' | 'query' | 'component' | 'composition' | 'stream' | 'filter-view';
15
+ export type CompositionRuntimeKind = 'controller' | 'filter' | 'query' | 'component' | 'composition' | 'stream' | 'filter-view';
15
16
  export type CompositionActivationMode = 'startup' | 'manual';
16
17
  export interface CompositionActivationDescriptor {
17
18
  mode: CompositionActivationMode;
@@ -59,6 +60,8 @@ export interface CompositionScopeDescriptor {
59
60
  parentPath: string | null;
60
61
  activationOverride: CompositionActivationDescriptor | null;
61
62
  effectiveActivation: CompositionActivationDescriptor;
63
+ enabledWhen?: Readonly<Record<string, string>>;
64
+ activateWhen?: CompositionBindingValue;
62
65
  data?: string[];
63
66
  resources: string[];
64
67
  runtimes: string[];
@@ -149,6 +152,7 @@ export interface CompositionRuntimeDescriptor {
149
152
  end: number;
150
153
  } | null;
151
154
  };
155
+ controllerDependencies?: ControllerDependencyBindings;
152
156
  kind: CompositionRuntimeKind;
153
157
  identity: string;
154
158
  contextSwitch?: {
@@ -165,6 +169,8 @@ export interface CompositionRuntimeDescriptor {
165
169
  };
166
170
  activationOverride: CompositionActivationDescriptor | null;
167
171
  effectiveActivation: CompositionActivationDescriptor;
172
+ enabledWhen?: Readonly<Record<string, string>>;
173
+ activateWhen?: CompositionBindingValue;
168
174
  fields?: string[];
169
175
  controls?: Record<string, FilterViewControlDefinition>;
170
176
  componentIdentity?: string;
@@ -225,7 +231,12 @@ export interface ComponentEventExecuteActionEffect {
225
231
  action: string;
226
232
  input?: ComponentSFCEventInputValue;
227
233
  }
228
- export type CompositionComponentEventEffect = ComponentEventApplyUpdateEffect | ComponentEventStoreMutationEffect | ComponentEventExecuteActionEffect;
234
+ export type CompositionComponentEventEffect = {
235
+ kind: 'controller-command';
236
+ runtime: string;
237
+ command: string;
238
+ input?: ComponentSFCEventInputValue;
239
+ } | ComponentEventApplyUpdateEffect | ComponentEventStoreMutationEffect | ComponentEventExecuteActionEffect;
229
240
  export interface CompositionComponentEventHook {
230
241
  kind: 'event';
231
242
  runtime: string;
@@ -56,11 +56,14 @@ export interface DataViewFromStep {
56
56
  dataViews?: DataViewRef[];
57
57
  }
58
58
  export type DataViewRef = DataViewExternalRef | DataViewInlineRef | DataViewLocalRef;
59
- export interface DataViewExternalRef {
59
+ export interface DataViewContextVariants {
60
+ contextVariants?: Array<DataViewExternalRef | DataViewInlineRef>;
61
+ }
62
+ export interface DataViewExternalRef extends DataViewContextVariants {
60
63
  kind: 'external';
61
64
  identity: string;
62
65
  }
63
- export interface DataViewInlineRef {
66
+ export interface DataViewInlineRef extends DataViewContextVariants {
64
67
  kind: 'inline';
65
68
  source: string;
66
69
  }
@@ -0,0 +1,17 @@
1
+ import { SourceContextPattern } from './source-context.types';
2
+ export interface GraphQLFragmentVariant {
3
+ when: SourceContextPattern | null;
4
+ document: string;
5
+ }
6
+ export interface GraphQLFragmentSource {
7
+ variants: GraphQLFragmentVariant[];
8
+ selected: number;
9
+ }
10
+ export interface GraphQLDocumentFragments {
11
+ operation: string;
12
+ fragments: Record<string, GraphQLFragmentSource>;
13
+ }
14
+ export interface GraphQLDocumentVariant {
15
+ context: SourceContextPattern;
16
+ document: string;
17
+ }
@@ -2,10 +2,11 @@ import { RQueryAuth } from '../../../domain/types/document/query.types';
2
2
  import { ProgramMetadataMap } from '../../../program/domain/types/program-metadata.types';
3
3
  import { ProgramDiagnostic, QueryProgramPayload } from '../../../program/domain/types/program.types';
4
4
  import { DataViewRef } from './data-view-source.types';
5
+ import { GraphQLDocumentFragments } from './graphql-fragments.types';
5
6
  import { ResponseOutputTransform } from './response-output.types';
6
7
  import { QueryProgramProp, SourceExpressionIR, SourceFieldDefinition } from './source-expression.types';
7
8
  export type QuerySourceKind = 'rest' | 'graphql';
8
- export type QueryGraphQLErrorPolicy = 'throw' | 'ignore';
9
+ export type QueryGraphQLErrorPolicy = 'throw' | 'ignore' | 'all';
9
10
  export type QuerySourceRequestValue<T> = T | SourceExpressionIR;
10
11
  export interface QuerySourceRestRequest {
11
12
  endpoint: QuerySourceRequestValue<string>;
@@ -20,6 +21,7 @@ export interface QuerySourceRestRequest {
20
21
  export interface QuerySourceGraphQLRequest {
21
22
  endpoint: QuerySourceRequestValue<string>;
22
23
  document: string;
24
+ fragments?: GraphQLDocumentFragments;
23
25
  operationName?: string;
24
26
  variables?: SourceExpressionIR | null;
25
27
  headers: QuerySourceRequestValue<Record<string, string>>;
@@ -30,6 +32,7 @@ export interface QuerySourceGraphQLRequest {
30
32
  export interface QuerySourceMock {
31
33
  enabled: boolean;
32
34
  data: unknown;
35
+ errors?: unknown[];
33
36
  }
34
37
  export type QueryOutputSource = {
35
38
  type: 'response';
@@ -5,6 +5,7 @@ export interface SimulationMockRequest {
5
5
  seed?: string;
6
6
  useExamples?: boolean;
7
7
  arrays: Record<string, number>;
8
+ errors?: SimulationGraphQLError[];
8
9
  }
9
10
  export interface SimulationFieldConstraints {
10
11
  enum?: Array<string | number | boolean>;
@@ -19,6 +20,12 @@ export interface SimulationMockStream {
19
20
  intervalMs: number;
20
21
  itemsPerMessage: number;
21
22
  fields: Record<string, SimulationFieldConstraints>;
23
+ errors?: SimulationGraphQLError[];
24
+ }
25
+ export interface SimulationGraphQLError {
26
+ message: string;
27
+ path?: Array<string | number>;
28
+ [key: string]: unknown;
22
29
  }
23
30
  export interface SimulationRuntimeOverride {
24
31
  alias: string;
@@ -64,4 +71,5 @@ export interface SimulationSourceCatalog {
64
71
  compositions: readonly SimulationSourceInput[];
65
72
  queries: readonly SimulationSourceInput[];
66
73
  types: readonly SimulationSourceInput[];
74
+ streams?: readonly SimulationSourceInput[];
67
75
  }
@@ -0,0 +1,6 @@
1
+ export type SourceContextPattern = Readonly<Record<string, string>>;
2
+ export interface SourceContextValues {
3
+ facets: Readonly<Record<string, string>>;
4
+ config: Readonly<Record<string, unknown>>;
5
+ knownFacets?: readonly string[];
6
+ }
@@ -1,9 +1,11 @@
1
1
  import { I18nCatalogProvenance, I18nRuntimeCatalog } from '../../../i18n/domain/i18n.types';
2
+ import { SourceContextValues } from './source-context.types';
2
3
  import { TypeSourceDefinition } from './type-source.types';
3
4
  export type SourceKind = 'action' | 'query' | 'vocab' | 'data-view' | 'filter' | 'composition' | 'store' | 'stream' | 'simulation' | 'update' | 'computation' | 'style' | 'type' | 'configuration';
4
5
  export interface SourceEngineCompileContext {
5
6
  sourceVersion?: number;
6
7
  executionContext?: Readonly<Record<string, string>>;
8
+ sourceContext?: SourceContextValues;
7
9
  }
8
10
  export type SourceLanguageCompletionKind = 'keyword' | 'function' | 'property' | 'value' | 'snippet';
9
11
  export interface SourceLanguagePosition {
@@ -30,6 +32,7 @@ export interface SourceLanguageContext {
30
32
  description?: string | null;
31
33
  }>;
32
34
  ownerIdentity?: string;
35
+ sourceContext?: SourceContextValues;
33
36
  i18n?: SourceLanguageI18nContext;
34
37
  }
35
38
  export interface SourceLanguageI18nOccurrence {
@@ -1,7 +1,7 @@
1
1
  import { ProgramMetadataMap } from '../../../program/domain/types/program-metadata.types';
2
2
  import { TypeSourceExpression } from './type-source.types';
3
3
  export type SourceFieldType = 'String' | 'Number' | 'Boolean' | 'Date' | 'Time' | 'DateTime' | 'Object' | 'Any' | (string & {});
4
- export type SourceExpressionReadKind = 'env' | 'prop' | 'value' | 'row' | 'response' | 'store' | 'current' | 'scope' | 'composition-output' | 'composition-outputs' | 'composition-data' | 'composition-store' | 'composition-filter-fields' | 'composition-runtime-metadata' | 'metadata' | 'computation-output' | 'update-input' | 'update-item' | 'update-parent' | 'update-data' | 'update-meta' | 'update-has-data' | 'update-has-meta';
4
+ export type SourceExpressionReadKind = 'env' | 'prop' | 'value' | 'row' | 'response' | 'graphql-errors' | 'store' | 'current' | 'scope' | 'composition-output' | 'composition-outputs' | 'composition-data' | 'composition-store' | 'composition-filter-fields' | 'composition-runtime-metadata' | 'metadata' | 'computation-output' | 'update-input' | 'update-item' | 'update-parent' | 'update-data' | 'update-meta' | 'update-has-data' | 'update-has-meta';
5
5
  export type SourceExpressionOperation = 'merge' | 'compact' | 'get' | 'get-or' | 'has' | 'default-to' | 'pick' | 'omit' | 'defaults' | 'keys' | 'values' | 'entries' | 'map' | 'where' | 'reject' | 'find' | 'some' | 'every' | 'flat-map' | 'flatten' | 'uniq' | 'uniq-by' | 'concat' | 'take' | 'drop' | 'sort-by' | 'group-by' | 'key-by' | 'size' | 'sum' | 'sum-by' | 'min' | 'max' | 'min-by' | 'max-by' | 'trim' | 'lower-case' | 'upper-case' | 'split' | 'join' | 'match' | 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'includes' | 'or' | 'when' | 'not' | 'is-nil' | 'is-empty' | 'and' | 'between' | 'in-list' | 'in-array' | 'relative-date' | 'relative-date-time' | 'left-join' | 'full-join' | 'join-by' | 'join-by-any' | 'join-coalesce' | 'lookup-one' | 'lookup-many' | 'enrich' | 'coalesce' | 'choose' | 'lookup-value' | 'to-string' | 'to-number' | 'to-boolean' | 'type-of' | 'is-string' | 'is-number' | 'is-boolean' | 'is-array' | 'is-object' | 'is-date-time' | 'is-duration' | 'add' | 'subtract' | 'multiply' | 'divide' | 'modulo' | 'abs' | 'negate' | 'round' | 'floor' | 'ceil' | 'clamp' | 'average' | 'average-by' | 'starts-with' | 'ends-with' | 'replace' | 'replace-all' | 'slice' | 'pad-start' | 'pad-end' | 'normalize-whitespace' | 'set' | 'unset' | 'rename' | 'get-key' | 'from-entries' | 'first' | 'last' | 'at' | 'reverse' | 'sort-by-desc' | 'order-by' | 'chunk' | 'union' | 'intersection' | 'difference' | 'count-by' | 'date-time' | 'duration' | 'date-time-add' | 'date-time-subtract' | 'date-time-difference' | 'date-time-start-of' | 'date-time-end-of' | 'date-time-part' | 'duration-add' | 'duration-subtract' | 'duration-total' | 'contains-all' | 'contains-any';
6
6
  export type SourceExpressionIR = {
7
7
  type: 'literal';
@@ -41,6 +41,7 @@ export interface SourceFieldDefinition {
41
41
  key: string;
42
42
  type: SourceFieldType;
43
43
  typeExpression?: TypeSourceExpression;
44
+ typeVariants?: TypeSourceExpression[];
44
45
  optional: boolean;
45
46
  array: boolean;
46
47
  defaultValue?: SourceExpressionIR;
@@ -74,6 +75,7 @@ export interface SourceExpressionContext {
74
75
  values?: Record<string, unknown>;
75
76
  row?: unknown;
76
77
  response?: unknown;
78
+ graphQLErrors?: readonly unknown[];
77
79
  stores?: Record<string, unknown>;
78
80
  current?: unknown;
79
81
  scope?: unknown;
@@ -1,5 +1,9 @@
1
1
  import { ProgramMetadataMap } from '../../../program/domain/types/program-metadata.types';
2
2
  import { ProgramDiagnostic } from '../../../program/domain/types/program.types';
3
+ import { GraphQLResponseError } from '../../../runtime/domain/graphql-query-error';
4
+ import { GraphQLDocumentFragments } from './graphql-fragments.types';
5
+ import { QueryGraphQLErrorPolicy } from './query-source.types';
6
+ import { QueryProgramProp, SourceExpressionIR } from './source-expression.types';
3
7
  export interface StreamSseTransportDescriptor {
4
8
  kind: 'sse';
5
9
  url: string;
@@ -15,7 +19,29 @@ export interface StreamWebSocketTransportDescriptor {
15
19
  url: string;
16
20
  onOpen: StreamJsonValue[];
17
21
  }
18
- export type StreamTransportDescriptor = StreamSseTransportDescriptor | StreamWebSocketTransportDescriptor;
22
+ /**
23
+ * GraphQL subscription по протоколу graphql-sse (distinct connections mode):
24
+ * одно HTTP-соединение на подписку, события next (ExecutionResult) и complete.
25
+ */
26
+ export interface StreamGraphQLSseTransportDescriptor {
27
+ kind: 'graphql-sse';
28
+ url: string;
29
+ urlExpression?: SourceExpressionIR;
30
+ method: 'POST' | 'GET';
31
+ document: string;
32
+ fragments?: GraphQLDocumentFragments;
33
+ operationName?: string;
34
+ variables: SourceExpressionIR | null;
35
+ headers: SourceExpressionIR | null;
36
+ extensions?: SourceExpressionIR;
37
+ withCredentials: boolean;
38
+ authMode: 'inherit' | 'profile' | 'none';
39
+ authProfileIdentity: string | null;
40
+ errorPolicy: QueryGraphQLErrorPolicy;
41
+ reconnectDelayMs: number;
42
+ }
43
+ export type StreamTransportDescriptor = StreamSseTransportDescriptor | StreamWebSocketTransportDescriptor | StreamGraphQLSseTransportDescriptor;
44
+ export type StreamProgramProp = QueryProgramProp;
19
45
  export interface StreamEventDescriptor {
20
46
  sourceEvent: string;
21
47
  type: string | null;
@@ -25,6 +51,7 @@ export interface StreamEventDescriptor {
25
51
  eachFrom?: string;
26
52
  }
27
53
  export interface StreamSourceDocument {
54
+ props?: StreamProgramProp[];
28
55
  transport: StreamTransportDescriptor;
29
56
  events: StreamEventDescriptor[];
30
57
  }
@@ -48,5 +75,6 @@ export interface StreamEventEnvelope {
48
75
  source: string;
49
76
  sourceEvent: string;
50
77
  occurredAt: string;
78
+ graphQLErrors?: readonly GraphQLResponseError[];
51
79
  };
52
80
  }
@@ -1,6 +1,9 @@
1
1
  import { ProgramMetadataMap } from '../../../program/domain/types/program-metadata.types';
2
2
  import { ProgramDiagnostic } from '../../../program/domain/types/program.types';
3
- export interface TypeSourceReference {
3
+ export interface TypeSourceContextVariants {
4
+ contextVariants?: TypeSourceExpression[];
5
+ }
6
+ export interface TypeSourceReference extends TypeSourceContextVariants {
4
7
  kind: 'reference';
5
8
  identity: string;
6
9
  }
@@ -13,24 +16,26 @@ export interface TypeSourceField {
13
16
  min?: number;
14
17
  max?: number;
15
18
  examples: unknown[];
19
+ inheritedFrom?: string;
16
20
  }
17
- export interface TypeSourceObjectDefinition {
21
+ export interface TypeSourceObjectDefinition extends TypeSourceContextVariants {
18
22
  kind: 'object';
19
23
  fields: TypeSourceField[];
24
+ extends?: TypeSourceReference;
20
25
  }
21
- export interface TypeSourceEnumDefinition {
26
+ export interface TypeSourceEnumDefinition extends TypeSourceContextVariants {
22
27
  kind: 'enum';
23
28
  values: Array<string | number | boolean>;
24
29
  }
25
- export interface TypeSourceUnionDefinition {
30
+ export interface TypeSourceUnionDefinition extends TypeSourceContextVariants {
26
31
  kind: 'union';
27
32
  variants: TypeSourceExpression[];
28
33
  }
29
- export interface TypeSourceArrayDefinition {
34
+ export interface TypeSourceArrayDefinition extends TypeSourceContextVariants {
30
35
  kind: 'array';
31
36
  items: TypeSourceExpression;
32
37
  }
33
- export interface TypeSourceRecordDefinition {
38
+ export interface TypeSourceRecordDefinition extends TypeSourceContextVariants {
34
39
  kind: 'record';
35
40
  values: TypeSourceExpression;
36
41
  }
@@ -1,6 +1,7 @@
1
1
  import { ProgramDependency } from '../../program/domain/types/program.types';
2
2
  import { CompositionSourceDocument } from '../domain/types/composition-source.types';
3
3
  import { SimulationSourceCatalog, SimulationSourceCompileResult, SimulationSourceInput, SimulationTargetReference } from '../domain/types/simulation-source.types';
4
+ import { StreamTransportDescriptor } from '../domain/types/stream-source.types';
4
5
  interface SimulationCompositionBranch {
5
6
  owner: SimulationSourceInput;
6
7
  document: CompositionSourceDocument;
@@ -16,6 +17,7 @@ interface QueryArrayContract {
16
17
  paths: string[];
17
18
  dependencies: ProgramDependency[];
18
19
  errors: string[];
20
+ graphql?: boolean;
19
21
  }
20
22
  /**
21
23
  * Read-only разрешение aliases и контрактов; не создаёт RuntimeHost или generator payload.
@@ -31,6 +33,10 @@ export declare class SimulationSourceResolver {
31
33
  children(branch: SimulationCompositionBranch): SimulationSourceTarget[];
32
34
  target(reference: SimulationTargetReference, aliases: readonly string[]): SimulationSourceTarget | null;
33
35
  queryContract(identity: string): QueryArrayContract;
36
+ /**
37
+ * Вид transport Stream из каталога; null — Stream отсутствует в каталоге или содержит ошибки Source.
38
+ */
39
+ streamTransport(identity: string): StreamTransportDescriptor['kind'] | null;
34
40
  analyze(result: SimulationSourceCompileResult): SimulationSourceCompileResult;
35
41
  }
36
42
  export {};
@@ -0,0 +1,52 @@
1
+ import { ProgramDiagnostic } from '../../../program/domain/types/program.types';
2
+ import { GraphQLDocumentFragments, GraphQLFragmentVariant } from '../../domain/types/graphql-fragments.types';
3
+ import { SourceExpressionIR } from '../../domain/types/source-expression.types';
4
+ import * as t from '@babel/types';
5
+ type DiagnosticDraft = Omit<ProgramDiagnostic, 'entityRef'>;
6
+ export type GraphQLOperationKind = 'query' | 'mutation' | 'subscription';
7
+ export interface GraphQLOperationSourceOptions {
8
+ codePrefix: string;
9
+ sourcePathPrefix: string;
10
+ operations: readonly GraphQLOperationKind[];
11
+ unsupportedOperation: {
12
+ code: string;
13
+ message: string;
14
+ };
15
+ }
16
+ export declare function readGraphQLDocumentSource(node: t.Expression, diagnostics: DiagnosticDraft[], options: GraphQLOperationSourceOptions): string;
17
+ export declare function readGraphQLVariablesSource(node: t.Expression, diagnostics: DiagnosticDraft[], options: GraphQLOperationSourceOptions): SourceExpressionIR | null;
18
+ /**
19
+ * Проверяет синтаксис документа, вид operations и operationName.
20
+ * Возвращает итоговое имя operation: заданное или единственное в документе.
21
+ */
22
+ export declare function validateGraphQLOperationSource(document: string, requestedOperationName: string | undefined, diagnostics: DiagnosticDraft[], options: GraphQLOperationSourceOptions, node?: t.Node): string | undefined;
23
+ export declare function readStaticStringSource(node: t.Expression, diagnostics: DiagnosticDraft[], sourcePath: string, codePrefix: string): string | undefined;
24
+ /**
25
+ * Сверяет variables(...) с объявлениями переменных выбранной operation без схемы.
26
+ * Лишние ключи — warning, отсутствующие обязательные (`!` без default) — error.
27
+ * Проверка выполняется, только если variables(...) отсутствует или возвращает object literal:
28
+ * для вычисляемого объекта набор ключей статически неизвестен.
29
+ */
30
+ export declare function validateGraphQLVariablesSource(document: string, operationName: string | undefined, variablesNode: t.Node | undefined, variables: SourceExpressionIR | null, diagnostics: DiagnosticDraft[], options: GraphQLOperationSourceOptions, documentNode?: t.Node): void;
31
+ export interface GraphQLFragmentsSourceDraft {
32
+ node: t.Node;
33
+ entries: Map<string, {
34
+ variants: GraphQLFragmentVariant[];
35
+ selected: number;
36
+ node: t.Node;
37
+ }>;
38
+ }
39
+ /**
40
+ * Читает `fragments: { Имя: gql\`fragment Имя on Тип {...}\` | contextSwitch({...}) }`.
41
+ * Все ветки contextSwitch проверяются; выбирается ветка по фасетам сборки (вне сборки — default).
42
+ */
43
+ export declare function readGraphQLFragmentsSource(node: t.Expression, diagnostics: DiagnosticDraft[], options: GraphQLOperationSourceOptions): GraphQLFragmentsSourceDraft;
44
+ /**
45
+ * Проверяет spread-ы и фрагменты относительно document operation и подставляет выбранные варианты.
46
+ * Без поля fragments проверяет только, что все spread document определены в нём самом.
47
+ */
48
+ export declare function applyGraphQLFragmentsSource(document: string, operationName: string | undefined, draft: GraphQLFragmentsSourceDraft | null, diagnostics: DiagnosticDraft[], options: GraphQLOperationSourceOptions, documentNode?: t.Node): {
49
+ document: string;
50
+ fragments?: GraphQLDocumentFragments;
51
+ };
52
+ export {};
@@ -1,8 +1,29 @@
1
1
  import { ProgramDiagnostic } from '../../../program/domain/types/program.types';
2
+ import { SourceContextPattern } from '../../domain/types/source-context.types';
2
3
  import { SourceExpressionIR } from '../../domain/types/source-expression.types';
3
4
  import * as t from '@babel/types';
4
5
  type DiagnosticDraft = Omit<ProgramDiagnostic, 'entityRef'>;
5
6
  export declare function compileSourceExpression(raw: t.Expression | null | undefined, diagnostics: DiagnosticDraft[], sourcePath: string): SourceExpressionIR | null;
7
+ export interface ContextSwitchNode<T> {
8
+ defaultValue: T;
9
+ branches: Array<{
10
+ when: SourceContextPattern;
11
+ value: T;
12
+ node: t.Node;
13
+ }>;
14
+ }
15
+ export declare function readContextSwitchNode<T>(node: t.CallExpression, diagnostics: DiagnosticDraft[], switchPath: string, readBranch: (node: t.Expression, diagnostics: DiagnosticDraft[], sourcePath: string) => T): ContextSwitchNode<T> | null;
16
+ export declare function selectContextSwitchNode<T>(node: t.CallExpression, diagnostics: DiagnosticDraft[], sourcePath: string, readBranch: (node: t.Expression, diagnostics: DiagnosticDraft[], sourcePath: string) => T | null): {
17
+ selected: T;
18
+ variants: T[];
19
+ } | null;
20
+ export declare function isContextSwitchCall(node: t.Node | null | undefined): boolean;
21
+ export declare function readContextPatternNode(node: t.ObjectExpression, diagnostics: DiagnosticDraft[], sourcePath: string, codes: {
22
+ entry: string;
23
+ duplicate: string;
24
+ }): Record<string, string>;
25
+ export declare function pushContextUnbound(name: string, diagnostics: DiagnosticDraft[], sourcePath: string, node: t.Node): void;
26
+ export declare function validateSourcePath(path: string, diagnostics: DiagnosticDraft[], sourcePath: string, node?: t.Node | null): void;
6
27
  export declare const compileValueExpression: typeof compileSourceExpression;
7
28
  export declare function compileSourceCallback(raw: t.CallExpression['arguments'][number] | undefined, diagnostics: DiagnosticDraft[], sourcePath: string): SourceExpressionIR | null;
8
29
  export declare function unwrapExpression<T extends t.Node>(node: T): T;
@@ -1,5 +1,8 @@
1
+ import { ProgramDiagnostic } from '../../../program/domain/types/program.types';
2
+ import { DataViewExternalRef, DataViewInlineRef } from '../../domain/types/data-view-source.types';
1
3
  import * as t from '@babel/types';
2
- export type ParsedSourceModelReference = {
4
+ type DiagnosticDraft = Omit<ProgramDiagnostic, 'entityRef'>;
5
+ type ParsedSourceModelReferenceBranch = {
3
6
  kind: 'external';
4
7
  identity: string;
5
8
  } | {
@@ -7,8 +10,15 @@ export type ParsedSourceModelReference = {
7
10
  source: string;
8
11
  definition: t.CallExpression;
9
12
  };
13
+ export type ParsedSourceModelReference = ParsedSourceModelReferenceBranch & {
14
+ variants?: ParsedSourceModelReferenceBranch[];
15
+ };
16
+ export declare function toDataViewRef(reference: ParsedSourceModelReference): DataViewExternalRef | DataViewInlineRef;
10
17
  export declare function readSourceModelIdentity(raw: t.CallExpression['arguments'][number] | undefined, referenceCall: string): string | null;
11
18
  export declare function readSourceModelReference(raw: t.CallExpression['arguments'][number] | undefined, source: string, options: {
12
19
  referenceCall: string;
13
20
  defineCall: string;
21
+ diagnostics?: DiagnosticDraft[];
22
+ sourcePath?: string;
14
23
  }): ParsedSourceModelReference | null;
24
+ export {};
@@ -1,2 +1,7 @@
1
- import { CompositionActivationDescriptor } from '../domain/types/composition-source.types';
1
+ import { CompositionActivationDescriptor, CompositionScopeDescriptor } from '../domain/types/composition-source.types';
2
2
  export declare function resolveCompositionActivation(invocationOverride: CompositionActivationDescriptor | null | undefined, targetRoot: CompositionActivationDescriptor | null | undefined, ownerScope: CompositionActivationDescriptor | null | undefined): CompositionActivationDescriptor;
3
+ /**
4
+ * Активация содержимого scope: `effectiveActivation` scope описывает его собственный запуск
5
+ * относительно владельца, а runtime внутри scope с `.activateWhen(...)` стартуют вместе с ним.
6
+ */
7
+ export declare function resolveScopeContentActivation(scope: Pick<CompositionScopeDescriptor, 'effectiveActivation' | 'activateWhen'> | null | undefined): CompositionActivationDescriptor | undefined;
@@ -0,0 +1,23 @@
1
+ import { DocumentNode } from 'graphql';
2
+ import { GraphQLDocumentFragments, GraphQLDocumentVariant } from '../domain/types/graphql-fragments.types';
3
+ import { GraphQLDocumentDiagnostic, GraphQLSchemaInput } from './graphql-schema';
4
+ export interface GraphQLDocumentUsage {
5
+ spreads: Set<string>;
6
+ variables: Set<string>;
7
+ }
8
+ export declare function collectGraphQLDocumentUsage(document: DocumentNode): GraphQLDocumentUsage;
9
+ /**
10
+ * Подставляет фрагменты в document operation: добавляются только фрагменты, достижимые из
11
+ * operation (в том числе через вложенные spread). `pick` выбирает текст фрагмента по имени.
12
+ */
13
+ export declare function composeGraphQLDocument(operation: string, pick: (name: string) => string | undefined): string;
14
+ /**
15
+ * Возвращает document для каждого различимого сочетания фасетов: default и условие каждого
16
+ * case всех фрагментов. Одинаковые documents объединяются (остаётся первое сочетание).
17
+ */
18
+ export declare function createGraphQLDocumentVariants(source: GraphQLDocumentFragments): GraphQLDocumentVariant[];
19
+ export interface GraphQLDocumentVariantValidation extends GraphQLDocumentVariant {
20
+ diagnostics: GraphQLDocumentDiagnostic[];
21
+ }
22
+ export declare function validateGraphQLDocumentVariants(schema: GraphQLSchemaInput, source: GraphQLDocumentFragments): GraphQLDocumentVariantValidation[];
23
+ export declare function readGraphQLFragmentDefinitions(document: DocumentNode): Set<string>;