@arcote.tech/arc 0.4.5 → 0.4.7

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.
@@ -16,6 +16,16 @@ export declare class ArcContext<const Elements extends ArcContextElement<any>[]>
16
16
  * @returns The element if found, undefined otherwise
17
17
  */
18
18
  get<E extends Elements[number]>(name: E["name"]): E | undefined;
19
+ /**
20
+ * Replace a context element by name with a new element.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const accounts = ctx.get("userAccounts")!;
25
+ * const seeded = ctx.replace("userAccounts", accounts.withSeeds([...]));
26
+ * ```
27
+ */
28
+ replace(name: Elements[number]["name"], element: ArcContextElementAny): ArcContext<Elements>;
19
29
  }
20
30
  /**
21
31
  * Create a new context from an array of elements
@@ -9,7 +9,7 @@ import type { ArcObjectAny } from "../../elements/object";
9
9
  import type { ModelAdapters } from "../../model/model-adapters";
10
10
  import type { $type } from "../../utils/types/get-type";
11
11
  import type { ArcViewItem } from "../view/view-context";
12
- import type { AggregateInstanceCtx } from "./aggregate-builder";
12
+ import type { AggregateInstanceCtx } from "./aggregate-element";
13
13
  import type { AggregateEventEntry } from "./aggregate-data";
14
14
  /**
15
15
  * Base class for aggregate instances.
@@ -1,139 +1,12 @@
1
+ /**
2
+ * aggregate() — entry point for creating aggregate context elements.
3
+ *
4
+ * Returns an ArcAggregateElement directly (no .build() needed).
5
+ * Chain methods like .publicEvent(), .mutateMethod(), .clientQuery(), .seedWith()
6
+ * to configure the aggregate — each returns a new immutable instance.
7
+ */
8
+ import { ArcObject, type ArcRawShape } from "../../elements/object";
1
9
  import type { ArcIdAny } from "../../elements/id";
2
- import { ArcObject, type ArcObjectAny, type ArcRawShape } from "../../elements/object";
3
- import type { ArcTokenAny } from "../../token/token";
4
- import type { $type } from "../../utils/types/get-type";
5
- import type { Simplify } from "../../utils";
6
- import { ArcEvent, type ArcEventAny } from "../event/event";
7
- import type { ArcEventInstance } from "../event/instance";
8
- import type { ArcViewHandlerContext } from "../view/view-context";
9
- import type { ViewProtection, ViewProtectionFn } from "../view/view-data";
10
- import { AggregateBase } from "./aggregate-base";
11
- import type { AggregateCronMethodEntry, AggregateEventEntry, AggregateMutateMethodEntry, AggregateQueryMethodEntry } from "./aggregate-data";
12
- type InlineArcEvent<EN extends string, PS extends ArcRawShape> = ArcEvent<{
13
- name: EN;
14
- payload: ArcObject<PS>;
15
- protections: [];
16
- }>;
17
- type AggregateRow<Id extends ArcIdAny, Schema extends ArcObjectAny> = Simplify<$type<Schema> & {
18
- _id: $type<Id>;
19
- }>;
20
- type AggregatePrivateQuery<Id extends ArcIdAny, Schema extends ArcObjectAny> = {
21
- find: (options?: any) => Promise<AggregateRow<Id, Schema>[]>;
22
- findOne: (where?: any) => Promise<AggregateRow<Id, Schema> | undefined>;
23
- };
24
- type MutateMethodContext<Id extends ArcIdAny, Schema extends ArcObjectAny, Events extends AggregateEventEntry[]> = {
25
- [E in Events[number] as E["event"]["name"]]: {
26
- emit: (payload: E["event"]["payload"] extends {
27
- deserialize: (...a: any) => any;
28
- } ? $type<E["event"]["payload"]> : undefined) => Promise<void>;
29
- };
30
- } & {
31
- $auth: {
32
- params: any;
33
- tokenName: string;
34
- };
35
- $query: AggregatePrivateQuery<Id, Schema>;
36
- };
37
- type ClientQueryContext<Id extends ArcIdAny, Schema extends ArcObjectAny> = {
38
- $query: {
39
- find: {
40
- <M extends new (row: AggregateRow<Id, Schema>, adapters: any) => any>(options: any, mapper: M): Promise<InstanceType<M>[]>;
41
- (options?: any): Promise<AggregateRow<Id, Schema>[]>;
42
- };
43
- findOne: {
44
- <M extends new (row: AggregateRow<Id, Schema>, adapters: any) => any>(where: any, mapper: M): Promise<InstanceType<M> | undefined>;
45
- (where?: any): Promise<AggregateRow<Id, Schema> | undefined>;
46
- };
47
- };
48
- $auth: {
49
- params: any;
50
- tokenName: string;
51
- };
52
- };
53
- export type AggregateInstanceCtx<Events extends AggregateEventEntry[]> = {
54
- [E in Events[number] as E["event"]["name"]]: {
55
- emit: (payload: E["event"]["payload"] extends {
56
- deserialize: (...a: any) => any;
57
- } ? $type<E["event"]["payload"]> : undefined) => Promise<void>;
58
- };
59
- };
60
- type PublicEvents<Events extends AggregateEventEntry[]> = Extract<Events[number], {
61
- isPublic: true;
62
- }>;
63
- type PublicEventNames<Events extends AggregateEventEntry[]> = PublicEvents<Events>["event"]["name"];
64
- type GetPublicEvent<Events extends AggregateEventEntry[], Name extends string> = Extract<PublicEvents<Events>, {
65
- event: {
66
- name: Name;
67
- };
68
- }>["event"];
69
- export declare class AggregateBuilder<Name extends string, Id extends ArcIdAny, Schema extends ArcObjectAny, Events extends AggregateEventEntry[], MutateMethods extends AggregateMutateMethodEntry[], QueryMethods extends AggregateQueryMethodEntry[] = []> {
70
- private readonly _name;
71
- private readonly _id;
72
- private readonly _schema;
73
- private readonly _events;
74
- private readonly _protections;
75
- private readonly _mutateMethods;
76
- private readonly _queryMethods;
77
- constructor(name: Name, id: Id, schema: Schema, events?: Events, protections?: ViewProtection[], mutateMethods?: MutateMethods, queryMethods?: QueryMethods);
78
- protectBy<T extends ArcTokenAny>(token: T, protectionFn: ViewProtectionFn<any>): AggregateBuilder<Name, Id, Schema, Events, MutateMethods, QueryMethods>;
79
- event<const EventName extends string, PayloadShape extends ArcRawShape>(eventName: EventName, payload: PayloadShape, handler: (ctx: ArcViewHandlerContext<Id, Schema>, event: ArcEventInstance<InlineArcEvent<EventName, PayloadShape>>) => Promise<void>): AggregateBuilder<Name, Id, Schema, [
80
- ...Events,
81
- AggregateEventEntry<InlineArcEvent<EventName, PayloadShape>, Id, Schema, false>
82
- ], MutateMethods, QueryMethods>;
83
- publicEvent<const EventName extends string, PayloadShape extends ArcRawShape>(eventName: EventName, payload: PayloadShape, handler: (ctx: ArcViewHandlerContext<Id, Schema>, event: ArcEventInstance<InlineArcEvent<EventName, PayloadShape>>) => Promise<void>): AggregateBuilder<Name, Id, Schema, [
84
- ...Events,
85
- AggregateEventEntry<InlineArcEvent<EventName, PayloadShape>, Id, Schema, true>
86
- ], MutateMethods, QueryMethods>;
87
- handleEvent<E extends ArcEventAny>(arcEvent: E, handler: (ctx: ArcViewHandlerContext<Id, Schema>, event: ArcEventInstance<E>) => Promise<void>): AggregateBuilder<Name, Id, Schema, [
88
- ...Events,
89
- AggregateEventEntry<E, ArcIdAny, ArcObjectAny, false>
90
- ], MutateMethods, QueryMethods>;
91
- mutateMethod<const MethodName extends string, ParamsShape extends ArcRawShape, HR = void, R = never>(methodName: MethodName, config: {
92
- params: ParamsShape;
93
- result?: R;
94
- }, handler: ((ctx: MutateMethodContext<Id, Schema, Events>, params: $type<ArcObject<ParamsShape>>) => Promise<HR>) | false): AggregateBuilder<Name, Id, Schema, Events, [
95
- ...MutateMethods,
96
- {
97
- name: MethodName;
98
- params: ArcObject<ParamsShape>;
99
- handler: typeof handler;
100
- handlerReturn: HR;
101
- result: R;
102
- }
103
- ], QueryMethods>;
104
- /**
105
- * Attach a cron schedule to the last declared mutateMethod.
106
- * The CronScheduler will call this method on the given schedule
107
- * for every existing aggregate instance.
108
- *
109
- * @param expression - A cron expression (e.g. "0 *\/6 * * *" for every 6 hours)
110
- */
111
- cron(expression: string): AggregateBuilder<Name, Id, Schema, Events, MutateMethods, QueryMethods>;
112
- clientQuery<const MethodName extends string, H extends (ctx: ClientQueryContext<Id, Schema>, ...args: any[]) => Promise<any>>(methodName: MethodName, handler: H): AggregateBuilder<Name, Id, Schema, Events, MutateMethods, [
113
- ...QueryMethods,
114
- {
115
- name: MethodName;
116
- handler: H;
117
- }
118
- ]>;
119
- build(): AggregateConstructor<Name, Id, Schema, Events, MutateMethods, QueryMethods>;
120
- }
121
- export type AggregateConstructor<Name extends string = string, Id extends ArcIdAny = ArcIdAny, Schema extends ArcObjectAny = ArcObjectAny, Events extends AggregateEventEntry[] = AggregateEventEntry[], MutateMethods extends AggregateMutateMethodEntry[] = AggregateMutateMethodEntry[], QueryMethods extends AggregateQueryMethodEntry[] = AggregateQueryMethodEntry[]> = (new (row: import("../view/view-context").ArcViewItem<Id, Schema>, adapters: import("../../model/model-adapters").ModelAdapters) => AggregateBase<Id, Schema, Events>) & {
122
- readonly __aggregateName: Name;
123
- readonly __aggregateId: Id;
124
- readonly __aggregateSchema: Schema;
125
- readonly __aggregateEvents: Events;
126
- readonly __aggregateProtections: ViewProtection[];
127
- readonly __aggregateMutateMethods: MutateMethods;
128
- readonly __aggregateQueryMethods: QueryMethods;
129
- readonly __aggregateCronMethods: AggregateCronMethodEntry[];
130
- getEvent<EventName extends PublicEventNames<Events>>(name: EventName): GetPublicEvent<Events, EventName>;
131
- };
132
- export type AggregateConstructorAny = AggregateConstructor<any, any, any, any, any, any>;
133
- /** Extract the full row type ({ _id, ...fields }) from an aggregate constructor. */
134
- export type AggregateData<Ctor extends AggregateConstructorAny> = {
135
- _id: $type<Ctor["__aggregateId"]>;
136
- } & $type<Ctor["__aggregateSchema"]>;
137
- export declare function aggregate<const Name extends string, Id extends ArcIdAny, SchemaShape extends ArcRawShape>(name: Name, id: Id, schema: SchemaShape): AggregateBuilder<Name, Id, ArcObject<SchemaShape>, [], [], []>;
138
- export {};
10
+ import { ArcAggregateElement } from "./aggregate-element";
11
+ export declare function aggregate<const Name extends string, Id extends ArcIdAny, SchemaShape extends ArcRawShape>(name: Name, id: Id, schema: SchemaShape): ArcAggregateElement<Name, Id, ArcObject<SchemaShape>, [], [], []>;
139
12
  //# sourceMappingURL=aggregate-builder.d.ts.map
@@ -1,69 +1,183 @@
1
1
  /**
2
- * ArcAggregateElement
2
+ * ArcAggregateElement — unified aggregate builder + context element.
3
3
  *
4
- * Implements ArcContextElement for an aggregate.
5
- * Created by aggregateContextElement(Constructor).
4
+ * aggregate() returns this directly. No .build() or aggregateContextElement() needed.
5
+ * Each builder method returns a new immutable instance.
6
6
  *
7
- * Looks like an ArcView to the rest of the system:
8
- * - queryContext() → find/findOne returning class instances
9
- * - mutateContext() → emit per registered event
10
- * - getHandlers() / getElements() → for eventPublisher.registerViews()
11
- * - databaseStoreSchema() → view table schema
7
+ * From the framework's perspective, behaves like a view:
8
+ * - queryContext() → named query methods
9
+ * - mutateContext() → named mutation methods
10
+ * - getHandlers() / getElements() → for eventPublisher registration
11
+ * - databaseStoreSchema() → table schema
12
12
  */
13
13
  import type { DatabaseStoreSchema } from "../../data-storage/database-store";
14
+ import type { ArcIdAny } from "../../elements/id";
15
+ import { ArcObject, type ArcObjectAny, type ArcRawShape } from "../../elements/object";
14
16
  import type { ModelAdapters } from "../../model/model-adapters";
17
+ import type { Simplify } from "../../utils";
18
+ import type { $type } from "../../utils/types/get-type";
19
+ import type { ArcTokenAny } from "../../token/token";
15
20
  import { ArcContextElement } from "../context-element";
16
- import type { ArcEventAny } from "../event/event";
17
- import type { AggregateConstructorAny } from "./aggregate-builder";
18
- import type { AggregateMutateMethodContext, AggregateQueryContext } from "./aggregate-data";
19
- /**
20
- * ArcAggregateElement single context element for an aggregate.
21
- *
22
- * From the framework's perspective this behaves like a view:
23
- * - eventPublisher.registerViews() accepts it (duck typing via getHandlers/getElements/schema)
24
- * - queryContext provides find/findOne
25
- * - mutateContext provides emit per event
26
- */
27
- export declare class ArcAggregateElement<Ctor extends AggregateConstructorAny> extends ArcContextElement<Ctor["__aggregateName"]> {
28
- private readonly ctor;
21
+ import { ArcEvent, type ArcEventAny } from "../event/event";
22
+ import type { ArcEventInstance } from "../event/instance";
23
+ import type { ArcViewHandlerContext, ArcViewItem } from "../view/view-context";
24
+ import type { ViewProtection, ViewProtectionFn } from "../view/view-data";
25
+ import { AggregateBase } from "./aggregate-base";
26
+ import type { AggregateCronMethodEntry, AggregateEventEntry, AggregateMutateMethodContext, AggregateMutateMethodEntry, AggregateQueryContext, AggregateQueryMethodEntry } from "./aggregate-data";
27
+ type InlineArcEvent<EN extends string, PS extends ArcRawShape> = ArcEvent<{
28
+ name: EN;
29
+ payload: ArcObject<PS>;
30
+ protections: [];
31
+ }>;
32
+ export type AggregateRow<Id extends ArcIdAny, Schema extends ArcObjectAny> = Simplify<$type<Schema> & {
33
+ _id: $type<Id>;
34
+ }>;
35
+ type AggregatePrivateQuery<Id extends ArcIdAny, Schema extends ArcObjectAny> = {
36
+ find: {
37
+ <M extends new (row: AggregateRow<Id, Schema>, adapters: any) => any>(options: any, mapper: M): Promise<InstanceType<M>[]>;
38
+ (options?: any): Promise<AggregateRow<Id, Schema>[]>;
39
+ };
40
+ findOne: {
41
+ <M extends new (row: AggregateRow<Id, Schema>, adapters: any) => any>(where: any, mapper: M): Promise<InstanceType<M> | undefined>;
42
+ (where?: any): Promise<AggregateRow<Id, Schema> | undefined>;
43
+ };
44
+ };
45
+ type MutateMethodContext<Id extends ArcIdAny, Schema extends ArcObjectAny, Events extends AggregateEventEntry[]> = {
46
+ [E in Events[number] as E["event"]["name"]]: {
47
+ emit: (payload: E["event"]["payload"] extends {
48
+ deserialize: (...a: any) => any;
49
+ } ? $type<E["event"]["payload"]> : undefined) => Promise<void>;
50
+ };
51
+ } & {
52
+ $auth: {
53
+ params: any;
54
+ tokenName: string;
55
+ };
56
+ $query: AggregatePrivateQuery<Id, Schema>;
57
+ };
58
+ type ClientQueryContext<Id extends ArcIdAny, Schema extends ArcObjectAny, Events extends AggregateEventEntry[]> = {
59
+ $query: AggregatePrivateQuery<Id, Schema>;
60
+ $auth: {
61
+ params: any;
62
+ tokenName: string;
63
+ };
64
+ Aggregate: AggregateConstructor<Id, Schema, Events>;
65
+ };
66
+ export type AggregateInstanceCtx<Events extends AggregateEventEntry[]> = {
67
+ [E in Events[number] as E["event"]["name"]]: {
68
+ emit: (payload: E["event"]["payload"] extends {
69
+ deserialize: (...a: any) => any;
70
+ } ? $type<E["event"]["payload"]> : undefined) => Promise<void>;
71
+ };
72
+ };
73
+ type PublicEvents<Events extends AggregateEventEntry[]> = Extract<Events[number], {
74
+ isPublic: true;
75
+ }>;
76
+ type PublicEventNames<Events extends AggregateEventEntry[]> = PublicEvents<Events>["event"]["name"];
77
+ type GetPublicEvent<Events extends AggregateEventEntry[], Name extends string> = Extract<PublicEvents<Events>, {
78
+ event: {
79
+ name: Name;
80
+ };
81
+ }>["event"];
82
+ export type AggregateConstructor<Id extends ArcIdAny = ArcIdAny, Schema extends ArcObjectAny = ArcObjectAny, Events extends AggregateEventEntry[] = AggregateEventEntry[]> = (new (row: ArcViewItem<Id, Schema>, adapters: ModelAdapters) => AggregateBase<Id, Schema, Events>) & {
83
+ readonly __aggregateName: string;
84
+ readonly __aggregateId: Id;
85
+ readonly __aggregateSchema: Schema;
86
+ readonly __aggregateEvents: Events;
87
+ readonly __aggregateProtections: ViewProtection[];
88
+ readonly __aggregateMutateMethods: AggregateMutateMethodEntry[];
89
+ readonly __aggregateQueryMethods: AggregateQueryMethodEntry[];
90
+ readonly __aggregateCronMethods: AggregateCronMethodEntry[];
91
+ getEvent<EventName extends PublicEventNames<Events>>(name: EventName): GetPublicEvent<Events, EventName>;
92
+ };
93
+ export type AggregateConstructorAny = AggregateConstructor<any, any, any>;
94
+ /** Extract the full row type from an aggregate element. */
95
+ export type AggregateData<El extends ArcAggregateElement<any, any, any, any, any>> = AggregateRow<El extends ArcAggregateElement<infer _N, infer I, any, any, any> ? I : never, El extends ArcAggregateElement<infer _N, any, infer S, any, any> ? S : never>;
96
+ export declare class ArcAggregateElement<Name extends string = string, Id extends ArcIdAny = ArcIdAny, Schema extends ArcObjectAny = ArcObjectAny, Events extends AggregateEventEntry[] = AggregateEventEntry[], MutateMethods extends AggregateMutateMethodEntry[] = AggregateMutateMethodEntry[], QueryMethods extends AggregateQueryMethodEntry[] = AggregateQueryMethodEntry[]> extends ArcContextElement<Name> {
29
97
  /** Expose schema for eventPublisher view registration (duck typing) */
30
- readonly schema: Ctor["__aggregateSchema"];
31
- constructor(ctor: Ctor);
98
+ readonly schema: Schema;
99
+ private readonly _id_factory;
100
+ private readonly _events;
101
+ private readonly _protections;
102
+ private readonly _mutateMethods;
103
+ private readonly _queryMethods;
104
+ private _ctor?;
105
+ constructor(name: Name, idFactory: Id, schema: Schema, events?: Events, protections?: ViewProtection[], mutateMethods?: MutateMethods, queryMethods?: QueryMethods, seeds?: {
106
+ data: any[];
107
+ version: number;
108
+ });
109
+ protectBy<T extends ArcTokenAny>(token: T, protectionFn: ViewProtectionFn<any>): ArcAggregateElement<Name, Id, Schema, Events, MutateMethods, QueryMethods>;
110
+ event<const EventName extends string, PayloadShape extends ArcRawShape>(eventName: EventName, payload: PayloadShape, handler: (ctx: ArcViewHandlerContext<Id, Schema>, event: ArcEventInstance<InlineArcEvent<EventName, PayloadShape>>) => Promise<void>): ArcAggregateElement<Name, Id, Schema, [
111
+ ...Events,
112
+ AggregateEventEntry<InlineArcEvent<EventName, PayloadShape>, Id, Schema, false>
113
+ ], MutateMethods, QueryMethods>;
114
+ publicEvent<const EventName extends string, PayloadShape extends ArcRawShape>(eventName: EventName, payload: PayloadShape, handler: (ctx: ArcViewHandlerContext<Id, Schema>, event: ArcEventInstance<InlineArcEvent<EventName, PayloadShape>>) => Promise<void>): ArcAggregateElement<Name, Id, Schema, [
115
+ ...Events,
116
+ AggregateEventEntry<InlineArcEvent<EventName, PayloadShape>, Id, Schema, true>
117
+ ], MutateMethods, QueryMethods>;
118
+ handleEvent<E extends ArcEventAny>(arcEvent: E, handler: (ctx: ArcViewHandlerContext<Id, Schema>, event: ArcEventInstance<E>) => Promise<void>): ArcAggregateElement<Name, Id, Schema, [
119
+ ...Events,
120
+ AggregateEventEntry<E, ArcIdAny, ArcObjectAny, false>
121
+ ], MutateMethods, QueryMethods>;
122
+ mutateMethod<const MethodName extends string, ParamsShape extends ArcRawShape, HR = void, R = never>(methodName: MethodName, config: {
123
+ params: ParamsShape;
124
+ result?: R;
125
+ }, handler: ((ctx: MutateMethodContext<Id, Schema, Events>, params: $type<ArcObject<ParamsShape>>) => Promise<HR>) | false): ArcAggregateElement<Name, Id, Schema, Events, [
126
+ ...MutateMethods,
127
+ {
128
+ name: MethodName;
129
+ params: ArcObject<ParamsShape>;
130
+ handler: typeof handler;
131
+ handlerReturn: HR;
132
+ result: R;
133
+ }
134
+ ], QueryMethods>;
135
+ cron(expression: string): ArcAggregateElement<Name, Id, Schema, Events, MutateMethods, QueryMethods>;
136
+ clientQuery<const MethodName extends string, H extends (ctx: ClientQueryContext<Id, Schema, Events>, ...args: any[]) => Promise<any>>(methodName: MethodName, handler: H): ArcAggregateElement<Name, Id, Schema, Events, MutateMethods, [
137
+ ...QueryMethods,
138
+ {
139
+ name: MethodName;
140
+ handler: H;
141
+ }
142
+ ]>;
32
143
  /**
33
- * Returns event handlers keyed by event name.
34
- * Same shape as ArcView.getHandlers().
144
+ * Declare seed data inserted after table creation.
145
+ * Rows with `_id` use it as-is; rows without get auto-generated IDs.
35
146
  */
36
- getHandlers(): Record<string, (ctx: any, event: any) => Promise<void>>;
147
+ seedWith(data: Array<$type<Schema> & {
148
+ _id?: $type<Id>;
149
+ }>, options?: {
150
+ version?: number;
151
+ }): ArcAggregateElement<Name, Id, Schema, Events, MutateMethods, QueryMethods>;
37
152
  /**
38
- * Returns event elements this aggregate listens to.
39
- * Same shape as ArcView.getElements().
153
+ * Return a copy with seed data attached.
154
+ * Use with context.replace() to add seeds to framework-provided aggregates.
40
155
  */
156
+ withSeeds(data: Array<$type<Schema> & {
157
+ _id?: $type<Id>;
158
+ }>, options?: {
159
+ version?: number;
160
+ }): ArcAggregateElement<Name, Id, Schema, Events, MutateMethods, QueryMethods>;
161
+ /** The internal AggregateConstructor class. Use in clientQuery to extend with business methods. */
162
+ get Aggregate(): AggregateConstructor<Id, Schema, Events>;
163
+ private buildConstructor;
164
+ getHandlers(): Record<string, (ctx: any, event: any) => Promise<void>>;
41
165
  getElements(): ArcEventAny[];
42
- /**
43
- * queryContext exposes declared queryMethod entries as callable functions.
44
- *
45
- * Each queryMethod handler receives { $query: { find, findOne }, $auth }
46
- * where $query reads from the appropriate adapter (dataStorage, streamingCache, or queryWire).
47
- * Returns aggregate class instances.
48
- */
49
- queryContext(adapters: ModelAdapters): AggregateQueryContext<Ctor["__aggregateQueryMethods"]>;
50
- /**
51
- * Build private query methods (find/findOne) that work across all adapter modes.
52
- * Used internally by queryMethod handlers via ctx.$query.
53
- */
166
+ /** Public event accessor (same as old static getEvent) */
167
+ getEvent<EventName extends PublicEventNames<Events>>(eventName: EventName): GetPublicEvent<Events, EventName>;
168
+ /** Cron methods for CronScheduler discovery */
169
+ get cronMethods(): AggregateCronMethodEntry[];
170
+ queryContext(adapters: ModelAdapters): AggregateQueryContext<QueryMethods>;
54
171
  private buildPrivateQuery;
172
+ private buildUnrestrictedQuery;
55
173
  private getAuth;
56
- /**
57
- * mutateContext — exposes declared mutateMethod entries as callable functions.
58
- *
59
- * Each mutateMethod becomes a named function: `(params) => Promise<any>`.
60
- * The handler receives a context with emit per event + $auth + $query.
61
- */
62
- mutateContext(adapters: ModelAdapters): AggregateMutateMethodContext<Ctor["__aggregateMutateMethods"]>;
63
- /**
64
- * databaseStoreSchema — same as ArcView.
65
- * Creates a table named after the aggregate with _id + schema fields.
66
- */
174
+ mutateContext(adapters: ModelAdapters): AggregateMutateMethodContext<MutateMethods>;
67
175
  databaseStoreSchema(): DatabaseStoreSchema;
176
+ getSeeds(): {
177
+ idFactory: Id;
178
+ data: any[];
179
+ version: number;
180
+ } | undefined;
68
181
  }
182
+ export {};
69
183
  //# sourceMappingURL=aggregate-element.d.ts.map
@@ -2,30 +2,14 @@
2
2
  * Aggregate module
3
3
  *
4
4
  * Exports:
5
- * - aggregate() — builder entry point
6
- * - aggregateContextElement()creates ArcContextElement from aggregate class
7
- * - AggregateBase — base class for instances
5
+ * - aggregate() — creates ArcAggregateElement directly (no .build() needed)
6
+ * - ArcAggregateElementthe unified builder + context element
7
+ * - AggregateBase — base class for instances (used internally and in clientQuery)
8
8
  * - Types
9
9
  */
10
- export { aggregate, AggregateBuilder } from "./aggregate-builder";
11
- export type { AggregateConstructor, AggregateConstructorAny, AggregateData, AggregateInstanceCtx, } from "./aggregate-builder";
10
+ export { aggregate } from "./aggregate-builder";
11
+ export { ArcAggregateElement, type AggregateConstructor, type AggregateConstructorAny, type AggregateData, type AggregateInstanceCtx, type AggregateRow, } from "./aggregate-element";
12
12
  export { AggregateBase } from "./aggregate-base";
13
- export { ArcAggregateElement } from "./aggregate-element";
14
13
  export type { AggregateCronMethodEntry, AggregateEventEntry, AggregateEventHandler, AggregateMutateMethodContext, AggregateMutateMethodEntry, AggregateQueryContext, AggregateQueryMethodEntry, AggregateStaticConfig, } from "./aggregate-data";
15
14
  export type { ArcEventPayload } from "../event/instance";
16
- import type { AggregateConstructorAny } from "./aggregate-builder";
17
- import { ArcAggregateElement } from "./aggregate-element";
18
- /**
19
- * Create an ArcContextElement from an aggregate class.
20
- *
21
- * @param ctor - Aggregate class (extends the result of aggregate().build())
22
- * @returns ArcAggregateElement ready for context([])
23
- *
24
- * @example
25
- * ```ts
26
- * const taskElement = aggregateContextElement(Task);
27
- * const appContext = context([taskElement]);
28
- * ```
29
- */
30
- export declare function aggregateContextElement<Ctor extends AggregateConstructorAny>(ctor: Ctor): ArcAggregateElement<Ctor>;
31
15
  //# sourceMappingURL=index.d.ts.map
@@ -69,6 +69,13 @@ export declare abstract class ArcContextElement<const Name extends string> exten
69
69
  * - Views: { findOne: (query) => Promise<data>, findMany: (query) => Promise<data[]> }
70
70
  */
71
71
  queryContext?(adapters: ModelAdapters): unknown;
72
+ protected _seeds?: {
73
+ data: any[];
74
+ version: number;
75
+ idFactory?: any;
76
+ };
77
+ /** Get seed data declared via seedWith() or withSeeds(). */
78
+ getSeeds(): typeof this._seeds;
72
79
  }
73
80
  /**
74
81
  * Type helper to extract element name from element type
package/dist/index.js CHANGED
@@ -714,6 +714,12 @@ class ArcContext {
714
714
  get(name) {
715
715
  return this.elementMap.get(name);
716
716
  }
717
+ replace(name, element) {
718
+ if (!this.elementMap.has(name))
719
+ throw new Error(`Context element "${name}" not found`);
720
+ const newElements = this.elements.map((el) => el.name === name ? element : el);
721
+ return new ArcContext(newElements);
722
+ }
717
723
  }
718
724
  function context(elements) {
719
725
  return new ArcContext(elements);
@@ -1266,42 +1272,6 @@ class ArcPrimitive extends ArcAbstract {
1266
1272
  }
1267
1273
  }
1268
1274
 
1269
- // src/elements/boolean.ts
1270
- class ArcBoolean extends ArcPrimitive {
1271
- hasToBeTrue() {
1272
- return this.validation("hasToBeTrue", (value) => {
1273
- if (!value)
1274
- return {
1275
- current: value
1276
- };
1277
- });
1278
- }
1279
- validation(name, validator) {
1280
- const instance = this.pipeValidation(name, validator);
1281
- return instance;
1282
- }
1283
- toJsonSchema() {
1284
- const schema = { type: "boolean" };
1285
- if (this._description) {
1286
- schema.description = this._description;
1287
- }
1288
- return schema;
1289
- }
1290
- getColumnData() {
1291
- const storeData = this.getStoreData();
1292
- return {
1293
- type: "boolean",
1294
- storeData: {
1295
- ...storeData,
1296
- isNullable: false
1297
- }
1298
- };
1299
- }
1300
- }
1301
- function boolean() {
1302
- return new ArcBoolean;
1303
- }
1304
-
1305
1275
  // src/elements/string.ts
1306
1276
  var stringValidator = typeValidatorBuilder("string");
1307
1277
 
@@ -1455,6 +1425,66 @@ function string() {
1455
1425
  return new ArcString;
1456
1426
  }
1457
1427
 
1428
+ // src/fragment/arc-fragment.ts
1429
+ class ArcFragmentBase {
1430
+ is(type) {
1431
+ return this.types.includes(type);
1432
+ }
1433
+ }
1434
+
1435
+ // src/context-element/context-element.ts
1436
+ class ArcContextElement extends ArcFragmentBase {
1437
+ name;
1438
+ types = ["context-element"];
1439
+ get id() {
1440
+ return this.name;
1441
+ }
1442
+ constructor(name) {
1443
+ super();
1444
+ this.name = name;
1445
+ }
1446
+ _seeds;
1447
+ getSeeds() {
1448
+ return this._seeds;
1449
+ }
1450
+ }
1451
+
1452
+ // src/elements/boolean.ts
1453
+ class ArcBoolean extends ArcPrimitive {
1454
+ hasToBeTrue() {
1455
+ return this.validation("hasToBeTrue", (value) => {
1456
+ if (!value)
1457
+ return {
1458
+ current: value
1459
+ };
1460
+ });
1461
+ }
1462
+ validation(name, validator) {
1463
+ const instance = this.pipeValidation(name, validator);
1464
+ return instance;
1465
+ }
1466
+ toJsonSchema() {
1467
+ const schema = { type: "boolean" };
1468
+ if (this._description) {
1469
+ schema.description = this._description;
1470
+ }
1471
+ return schema;
1472
+ }
1473
+ getColumnData() {
1474
+ const storeData = this.getStoreData();
1475
+ return {
1476
+ type: "boolean",
1477
+ storeData: {
1478
+ ...storeData,
1479
+ isNullable: false
1480
+ }
1481
+ };
1482
+ }
1483
+ }
1484
+ function boolean() {
1485
+ return new ArcBoolean;
1486
+ }
1487
+
1458
1488
  // src/elements/id.ts
1459
1489
  class ArcCustomId extends ArcBranded {
1460
1490
  createFn;
@@ -1545,26 +1575,6 @@ function number() {
1545
1575
  return new ArcNumber;
1546
1576
  }
1547
1577
 
1548
- // src/fragment/arc-fragment.ts
1549
- class ArcFragmentBase {
1550
- is(type) {
1551
- return this.types.includes(type);
1552
- }
1553
- }
1554
-
1555
- // src/context-element/context-element.ts
1556
- class ArcContextElement extends ArcFragmentBase {
1557
- name;
1558
- types = ["context-element"];
1559
- get id() {
1560
- return this.name;
1561
- }
1562
- constructor(name) {
1563
- super();
1564
- this.name = name;
1565
- }
1566
- }
1567
-
1568
1578
  // src/context-element/event/event.ts
1569
1579
  class ArcEvent extends ArcContextElement {
1570
1580
  data;
@@ -1715,7 +1725,7 @@ class AggregateBase {
1715
1725
  }
1716
1726
  }
1717
1727
 
1718
- // src/context-element/aggregate/aggregate-builder.ts
1728
+ // src/context-element/aggregate/aggregate-element.ts
1719
1729
  function createInlineEvent(eventName, payload) {
1720
1730
  const po = payload instanceof ArcObject ? payload : new ArcObject(payload);
1721
1731
  return new ArcEvent({
@@ -1725,25 +1735,27 @@ function createInlineEvent(eventName, payload) {
1725
1735
  });
1726
1736
  }
1727
1737
 
1728
- class AggregateBuilder {
1729
- _name;
1730
- _id;
1731
- _schema;
1738
+ class ArcAggregateElement extends ArcContextElement {
1739
+ schema;
1740
+ _id_factory;
1732
1741
  _events;
1733
1742
  _protections;
1734
1743
  _mutateMethods;
1735
1744
  _queryMethods;
1736
- constructor(name, id2, schema, events = [], protections = [], mutateMethods = [], queryMethods = []) {
1737
- this._name = name;
1738
- this._id = id2;
1739
- this._schema = schema;
1745
+ _ctor;
1746
+ constructor(name, idFactory, schema, events = [], protections = [], mutateMethods = [], queryMethods = [], seeds) {
1747
+ super(name);
1748
+ this._id_factory = idFactory;
1749
+ this.schema = schema;
1740
1750
  this._events = events;
1741
1751
  this._protections = protections;
1742
1752
  this._mutateMethods = mutateMethods;
1743
1753
  this._queryMethods = queryMethods;
1754
+ if (seeds)
1755
+ this._seeds = { ...seeds, idFactory };
1744
1756
  }
1745
1757
  protectBy(token, protectionFn) {
1746
- return new AggregateBuilder(this._name, this._id, this._schema, this._events, [...this._protections, { token, protectionFn }], this._mutateMethods, this._queryMethods);
1758
+ return new ArcAggregateElement(this.name, this._id_factory, this.schema, this._events, [...this._protections, { token, protectionFn }], this._mutateMethods, this._queryMethods, this._seeds);
1747
1759
  }
1748
1760
  event(eventName, payload, handler) {
1749
1761
  const arcEvent = createInlineEvent(eventName, payload);
@@ -1753,7 +1765,7 @@ class AggregateBuilder {
1753
1765
  isInline: true,
1754
1766
  isPublic: false
1755
1767
  };
1756
- return new AggregateBuilder(this._name, this._id, this._schema, [...this._events, entry], this._protections, this._mutateMethods, this._queryMethods);
1768
+ return new ArcAggregateElement(this.name, this._id_factory, this.schema, [...this._events, entry], this._protections, this._mutateMethods, this._queryMethods, this._seeds);
1757
1769
  }
1758
1770
  publicEvent(eventName, payload, handler) {
1759
1771
  const arcEvent = createInlineEvent(eventName, payload);
@@ -1763,7 +1775,7 @@ class AggregateBuilder {
1763
1775
  isInline: true,
1764
1776
  isPublic: true
1765
1777
  };
1766
- return new AggregateBuilder(this._name, this._id, this._schema, [...this._events, entry], this._protections, this._mutateMethods, this._queryMethods);
1778
+ return new ArcAggregateElement(this.name, this._id_factory, this.schema, [...this._events, entry], this._protections, this._mutateMethods, this._queryMethods, this._seeds);
1767
1779
  }
1768
1780
  handleEvent(arcEvent, handler) {
1769
1781
  const entry = {
@@ -1772,7 +1784,7 @@ class AggregateBuilder {
1772
1784
  isInline: false,
1773
1785
  isPublic: false
1774
1786
  };
1775
- return new AggregateBuilder(this._name, this._id, this._schema, [...this._events, entry], this._protections, this._mutateMethods, this._queryMethods);
1787
+ return new ArcAggregateElement(this.name, this._id_factory, this.schema, [...this._events, entry], this._protections, this._mutateMethods, this._queryMethods, this._seeds);
1776
1788
  }
1777
1789
  mutateMethod(methodName, config, handler) {
1778
1790
  const paramsObj = config.params instanceof ArcObject ? config.params : new ArcObject(config.params);
@@ -1781,28 +1793,39 @@ class AggregateBuilder {
1781
1793
  params: paramsObj,
1782
1794
  handler
1783
1795
  };
1784
- return new AggregateBuilder(this._name, this._id, this._schema, this._events, this._protections, [...this._mutateMethods, entry], this._queryMethods);
1796
+ return new ArcAggregateElement(this.name, this._id_factory, this.schema, this._events, this._protections, [...this._mutateMethods, entry], this._queryMethods, this._seeds);
1785
1797
  }
1786
1798
  cron(expression) {
1787
1799
  if (this._mutateMethods.length === 0) {
1788
1800
  throw new Error("cron() must be called immediately after mutateMethod()");
1789
1801
  }
1790
1802
  const methods = [...this._mutateMethods];
1791
- const lastIndex = methods.length - 1;
1792
- methods[lastIndex] = { ...methods[lastIndex], cronExpression: expression };
1793
- return new AggregateBuilder(this._name, this._id, this._schema, this._events, this._protections, methods, this._queryMethods);
1803
+ methods[methods.length - 1] = { ...methods[methods.length - 1], cronExpression: expression };
1804
+ return new ArcAggregateElement(this.name, this._id_factory, this.schema, this._events, this._protections, methods, this._queryMethods, this._seeds);
1794
1805
  }
1795
1806
  clientQuery(methodName, handler) {
1796
1807
  const entry = {
1797
1808
  name: methodName,
1798
1809
  handler
1799
1810
  };
1800
- return new AggregateBuilder(this._name, this._id, this._schema, this._events, this._protections, this._mutateMethods, [...this._queryMethods, entry]);
1811
+ return new ArcAggregateElement(this.name, this._id_factory, this.schema, this._events, this._protections, this._mutateMethods, [...this._queryMethods, entry], this._seeds);
1812
+ }
1813
+ seedWith(data, options) {
1814
+ return new ArcAggregateElement(this.name, this._id_factory, this.schema, this._events, this._protections, this._mutateMethods, this._queryMethods, { data, version: options?.version ?? 1 });
1801
1815
  }
1802
- build() {
1803
- const name = this._name;
1804
- const id2 = this._id;
1805
- const schema = this._schema;
1816
+ withSeeds(data, options) {
1817
+ return this.seedWith(data, options);
1818
+ }
1819
+ get Aggregate() {
1820
+ if (!this._ctor) {
1821
+ this._ctor = this.buildConstructor();
1822
+ }
1823
+ return this._ctor;
1824
+ }
1825
+ buildConstructor() {
1826
+ const name = this.name;
1827
+ const id2 = this._id_factory;
1828
+ const schema = this.schema;
1806
1829
  const events = this._events;
1807
1830
  const protections = this._protections;
1808
1831
  const mutateMethods = this._mutateMethods;
@@ -1831,52 +1854,52 @@ class AggregateBuilder {
1831
1854
  return entry?.event;
1832
1855
  }
1833
1856
  };
1834
- Object.defineProperty(AggregateClass, "name", {
1835
- value: `${name}Aggregate`
1836
- });
1857
+ Object.defineProperty(AggregateClass, "name", { value: `${name}Aggregate` });
1837
1858
  return AggregateClass;
1838
1859
  }
1839
- }
1840
- function aggregate(name, id2, schema) {
1841
- const schemaObj = schema instanceof ArcObject ? schema : new ArcObject(schema);
1842
- return new AggregateBuilder(name, id2, schemaObj, [], [], [], []);
1843
- }
1844
- // src/context-element/aggregate/aggregate-element.ts
1845
- class ArcAggregateElement extends ArcContextElement {
1846
- ctor;
1847
- schema;
1848
- constructor(ctor) {
1849
- super(ctor.__aggregateName);
1850
- this.ctor = ctor;
1851
- this.schema = ctor.__aggregateSchema;
1852
- }
1853
1860
  getHandlers() {
1854
1861
  const handlers = {};
1855
- for (const entry of this.ctor.__aggregateEvents) {
1862
+ for (const entry of this._events) {
1856
1863
  handlers[entry.event.name] = entry.handler;
1857
1864
  }
1858
1865
  return handlers;
1859
1866
  }
1860
1867
  getElements() {
1861
- return this.ctor.__aggregateEvents.map((e) => e.event);
1868
+ return this._events.map((e) => e.event);
1869
+ }
1870
+ getEvent(eventName) {
1871
+ const entry = this._events.find((e) => e.isPublic && e.event.name === eventName);
1872
+ return entry?.event;
1873
+ }
1874
+ get cronMethods() {
1875
+ const result = [];
1876
+ for (const method of this._mutateMethods) {
1877
+ if (method.cronExpression) {
1878
+ result.push({
1879
+ aggregateName: this.name,
1880
+ methodName: method.name,
1881
+ cronExpression: method.cronExpression
1882
+ });
1883
+ }
1884
+ }
1885
+ return result;
1862
1886
  }
1863
1887
  queryContext(adapters) {
1864
1888
  const privateQuery = this.buildPrivateQuery(adapters);
1865
- const queryMethods = this.ctor.__aggregateQueryMethods ?? [];
1866
1889
  const auth = this.getAuth(adapters);
1890
+ const AggCtor = this.Aggregate;
1867
1891
  const result = {};
1868
- for (const method of queryMethods) {
1892
+ for (const method of this._queryMethods) {
1869
1893
  result[method.name] = (...args) => {
1870
- const ctx = { $query: privateQuery, $auth: auth };
1894
+ const ctx = { $query: privateQuery, $auth: auth, Aggregate: AggCtor };
1871
1895
  return method.handler(ctx, ...args);
1872
1896
  };
1873
1897
  }
1874
1898
  return result;
1875
1899
  }
1876
1900
  buildPrivateQuery(adapters) {
1877
- const viewName = this.ctor.__aggregateName;
1878
- const protections = this.ctor.__aggregateProtections;
1879
- const Ctor = this.ctor;
1901
+ const viewName = this.name;
1902
+ const protections = this._protections;
1880
1903
  const getReadRestrictions = () => {
1881
1904
  if (protections.length === 0)
1882
1905
  return null;
@@ -1906,18 +1929,15 @@ class ArcAggregateElement extends ArcContextElement {
1906
1929
  return { ...options, where };
1907
1930
  };
1908
1931
  const findRows = async (options) => {
1909
- if (adapters.dataStorage) {
1932
+ if (adapters.dataStorage)
1910
1933
  return adapters.dataStorage.getStore(viewName).find(options);
1911
- }
1912
- if (adapters.streamingCache) {
1934
+ if (adapters.streamingCache)
1913
1935
  return adapters.streamingCache.getStore(viewName).find(options);
1914
- }
1915
- if (adapters.queryWire) {
1936
+ if (adapters.queryWire)
1916
1937
  return adapters.queryWire.query(viewName, options);
1917
- }
1918
1938
  return [];
1919
1939
  };
1920
- const schema = this.ctor.__aggregateSchema;
1940
+ const schema = this.schema;
1921
1941
  const deserializeRow = (row) => {
1922
1942
  const { _id, ...rest } = row;
1923
1943
  return { _id, ...schema.deserialize(rest) };
@@ -1943,6 +1963,36 @@ class ArcAggregateElement extends ArcContextElement {
1943
1963
  }
1944
1964
  };
1945
1965
  }
1966
+ buildUnrestrictedQuery(adapters) {
1967
+ const viewName = this.name;
1968
+ const schema = this.schema;
1969
+ const deserializeRow = (row) => {
1970
+ const { _id, ...rest } = row;
1971
+ return { _id, ...schema.deserialize(rest) };
1972
+ };
1973
+ const findRows = async (options) => {
1974
+ if (adapters.dataStorage)
1975
+ return adapters.dataStorage.getStore(viewName).find(options);
1976
+ if (adapters.streamingCache)
1977
+ return adapters.streamingCache.getStore(viewName).find(options);
1978
+ if (adapters.queryWire)
1979
+ return adapters.queryWire.query(viewName, options);
1980
+ return [];
1981
+ };
1982
+ return {
1983
+ find: async (options, mapper) => {
1984
+ const rows = await findRows(options || {});
1985
+ return mapper ? rows.map((row) => new mapper(row, adapters)) : rows.map(deserializeRow);
1986
+ },
1987
+ findOne: async (where, mapper) => {
1988
+ const rows = await findRows({ where });
1989
+ const row = rows[0];
1990
+ if (!row)
1991
+ return;
1992
+ return mapper ? new mapper(row, adapters) : deserializeRow(row);
1993
+ }
1994
+ };
1995
+ }
1946
1996
  getAuth(adapters) {
1947
1997
  if (adapters.authAdapter) {
1948
1998
  const decoded = adapters.authAdapter.getDecoded();
@@ -1951,9 +2001,10 @@ class ArcAggregateElement extends ArcContextElement {
1951
2001
  return { params: {}, tokenName: "" };
1952
2002
  }
1953
2003
  mutateContext(adapters) {
1954
- const events = this.ctor.__aggregateEvents;
1955
- const privateQuery = this.buildPrivateQuery(adapters);
2004
+ const events = this._events;
2005
+ const privateQuery = this.buildUnrestrictedQuery(adapters);
1956
2006
  const auth = this.getAuth(adapters);
2007
+ const aggregateName = this.name;
1957
2008
  const buildMutateMethodCtx = () => {
1958
2009
  const ctx = {};
1959
2010
  for (const entry of events) {
@@ -1978,14 +2029,14 @@ class ArcAggregateElement extends ArcContextElement {
1978
2029
  return ctx;
1979
2030
  };
1980
2031
  const result = {};
1981
- for (const method of this.ctor.__aggregateMutateMethods ?? []) {
2032
+ for (const method of this._mutateMethods) {
1982
2033
  result[method.name] = async (params) => {
1983
2034
  if (!method.handler) {
1984
2035
  if (!adapters.commandWire) {
1985
2036
  throw new Error(`Method "${method.name}" is server-only but no commandWire (WebSocket) is available.`);
1986
2037
  }
1987
2038
  const wireAuth = adapters.scope ? { scope: adapters.scope.scopeName, token: adapters.scope.getToken() } : undefined;
1988
- return adapters.commandWire.executeCommand(`${this.ctor.__aggregateName}.${method.name}`, params, wireAuth);
2039
+ return adapters.commandWire.executeCommand(`${aggregateName}.${method.name}`, params, wireAuth);
1989
2040
  }
1990
2041
  const ctx = buildMutateMethodCtx();
1991
2042
  return method.handler(ctx, params);
@@ -1994,26 +2045,27 @@ class ArcAggregateElement extends ArcContextElement {
1994
2045
  return result;
1995
2046
  }
1996
2047
  databaseStoreSchema() {
1997
- const viewName = this.ctor.__aggregateName;
1998
- const idSchema = new ArcObject({
1999
- _id: new ArcString().primaryKey()
2000
- });
2001
- const viewSchema = idSchema.merge(this.ctor.__aggregateSchema.rawShape || {});
2048
+ const idSchema = new ArcObject({ _id: new ArcString().primaryKey() });
2049
+ const viewSchema = idSchema.merge(this.schema.rawShape || {});
2002
2050
  const eventSchema = ArcEvent.sharedDatabaseStoreSchema();
2003
2051
  return {
2004
2052
  tables: [
2005
- {
2006
- name: viewName,
2007
- schema: viewSchema
2008
- },
2053
+ { name: this.name, schema: viewSchema },
2009
2054
  ...eventSchema.tables
2010
2055
  ]
2011
2056
  };
2012
2057
  }
2058
+ getSeeds() {
2059
+ if (!this._seeds)
2060
+ return;
2061
+ return { ...this._seeds, idFactory: this._id_factory };
2062
+ }
2013
2063
  }
2014
- // src/context-element/aggregate/index.ts
2015
- function aggregateContextElement(ctor) {
2016
- return new ArcAggregateElement(ctor);
2064
+
2065
+ // src/context-element/aggregate/aggregate-builder.ts
2066
+ function aggregate(name, id2, schema) {
2067
+ const schemaObj = schema instanceof ArcObject ? schema : new ArcObject(schema);
2068
+ return new ArcAggregateElement(name, id2, schemaObj);
2017
2069
  }
2018
2070
  // src/context-element/element-context.ts
2019
2071
  function buildElementContext(queryElements, mutationElements, adapters) {
@@ -4967,7 +5019,6 @@ export {
4967
5019
  array,
4968
5020
  applyOrderByAndLimit,
4969
5021
  any,
4970
- aggregateContextElement,
4971
5022
  aggregate,
4972
5023
  Wire,
4973
5024
  TokenInstance,
@@ -5019,6 +5070,5 @@ export {
5019
5070
  ArcAny,
5020
5071
  ArcAggregateElement,
5021
5072
  ArcAbstract,
5022
- AggregateBuilder,
5023
5073
  AggregateBase
5024
5074
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arcote.tech/arc",
3
3
  "type": "module",
4
- "version": "0.4.5",
4
+ "version": "0.4.7",
5
5
  "private": false,
6
6
  "author": "Przemysław Krasiński [arcote.tech]",
7
7
  "description": "Arc framework core rewrite with improved event emission and type safety",