@arcote.tech/arc 0.3.6 → 0.4.1
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/dist/adapters/auth-adapter.d.ts +35 -20
- package/dist/adapters/command-wire.d.ts +4 -2
- package/dist/adapters/event-wire.d.ts +28 -3
- package/dist/adapters/index.d.ts +1 -0
- package/dist/adapters/query-wire.d.ts +6 -4
- package/dist/adapters/wire.d.ts +7 -11
- package/dist/context-element/aggregate/aggregate-base.d.ts +31 -0
- package/dist/context-element/aggregate/aggregate-builder.d.ts +139 -0
- package/dist/context-element/aggregate/aggregate-data.d.ts +114 -0
- package/dist/context-element/aggregate/aggregate-element.d.ts +69 -0
- package/dist/context-element/aggregate/index.d.ts +31 -0
- package/dist/context-element/aggregate/simple-aggregate.d.ts +94 -0
- package/dist/context-element/command/command-context.d.ts +3 -32
- package/dist/context-element/context-element.d.ts +7 -1
- package/dist/context-element/element-context.d.ts +39 -0
- package/dist/context-element/index.d.ts +2 -0
- package/dist/context-element/route/route.d.ts +8 -26
- package/dist/context-element/static-view/static-view.d.ts +2 -2
- package/dist/context-element/view/index.d.ts +1 -1
- package/dist/data-storage/store-state.abstract.d.ts +1 -0
- package/dist/elements/branded.d.ts +1 -0
- package/dist/elements/object.d.ts +2 -2
- package/dist/elements/optional.d.ts +1 -1
- package/dist/fragment/arc-fragment.d.ts +18 -0
- package/dist/fragment/index.d.ts +2 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +1006 -458
- package/dist/model/context-accessor.d.ts +51 -0
- package/dist/model/index.d.ts +4 -0
- package/dist/model/live-query/live-query.d.ts +4 -26
- package/dist/model/model-adapters.d.ts +5 -0
- package/dist/model/model-like.d.ts +9 -0
- package/dist/model/model.d.ts +10 -1
- package/dist/model/mutation-executor/mutation-executor.d.ts +2 -2
- package/dist/model/scoped-model.d.ts +66 -0
- package/dist/model/scoped-wire-proxy.d.ts +23 -0
- package/dist/streaming/index.d.ts +0 -2
- package/dist/streaming/streaming-live-query.d.ts +10 -12
- package/dist/streaming/streaming-query-cache.d.ts +25 -4
- package/package.json +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { ArcIdAny } from "../../elements/id";
|
|
2
|
+
import type { ArcRawShape } from "../../elements/object";
|
|
3
|
+
/**
|
|
4
|
+
* Create a simple CRUD aggregate with auto-generated upsert event and update method.
|
|
5
|
+
*
|
|
6
|
+
* Equivalent to manually calling:
|
|
7
|
+
* aggregate(name, id, schema)
|
|
8
|
+
* .publicEvent("updated", { id, ...schema }, upsertHandler)
|
|
9
|
+
* .mutateMethod("update", { id, ...schema }, emitHandler)
|
|
10
|
+
* .build()
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const Task = simpleAggregate("task", taskId, {
|
|
15
|
+
* title: string(),
|
|
16
|
+
* done: boolean(),
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function simpleAggregate<const Name extends string, Id extends ArcIdAny, SchemaShape extends ArcRawShape>(name: Name, id: Id, schema: SchemaShape): import("./aggregate-builder").AggregateConstructor<Name, Id, import("../..").ArcObject<SchemaShape, [{
|
|
21
|
+
name: "type";
|
|
22
|
+
validator: (value: any) => false | {
|
|
23
|
+
current: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
24
|
+
expected: "object";
|
|
25
|
+
};
|
|
26
|
+
}, {
|
|
27
|
+
name: "schema";
|
|
28
|
+
validator: (value: any) => false | { [key in keyof SchemaShape]: ReturnType<SchemaShape[key]["validate"]>; };
|
|
29
|
+
}]>, [import("./aggregate-data").AggregateEventEntry<import("..").ArcEvent<{
|
|
30
|
+
name: "updated";
|
|
31
|
+
payload: import("../..").ArcObject<{
|
|
32
|
+
[x: string]: ArcIdAny;
|
|
33
|
+
} & SchemaShape, [{
|
|
34
|
+
name: "type";
|
|
35
|
+
validator: (value: any) => false | {
|
|
36
|
+
current: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
37
|
+
expected: "object";
|
|
38
|
+
};
|
|
39
|
+
}, {
|
|
40
|
+
name: "schema";
|
|
41
|
+
validator: (value: any) => false | ({
|
|
42
|
+
[x: string]: ArcIdAny;
|
|
43
|
+
} & SchemaShape extends infer T ? { [key in keyof T]: ReturnType<T[key]["validate"]>; } : never);
|
|
44
|
+
}]>;
|
|
45
|
+
protections: [];
|
|
46
|
+
}>, Id, import("../..").ArcObject<SchemaShape, [{
|
|
47
|
+
name: "type";
|
|
48
|
+
validator: (value: any) => false | {
|
|
49
|
+
current: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
50
|
+
expected: "object";
|
|
51
|
+
};
|
|
52
|
+
}, {
|
|
53
|
+
name: "schema";
|
|
54
|
+
validator: (value: any) => false | { [key in keyof SchemaShape]: ReturnType<SchemaShape[key]["validate"]>; };
|
|
55
|
+
}]>, true>], [{
|
|
56
|
+
name: "update";
|
|
57
|
+
params: import("../..").ArcObject<{
|
|
58
|
+
[x: string]: ArcIdAny;
|
|
59
|
+
} & SchemaShape, [{
|
|
60
|
+
name: "type";
|
|
61
|
+
validator: (value: any) => false | {
|
|
62
|
+
current: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
63
|
+
expected: "object";
|
|
64
|
+
};
|
|
65
|
+
}, {
|
|
66
|
+
name: "schema";
|
|
67
|
+
validator: (value: any) => false | ({
|
|
68
|
+
[x: string]: ArcIdAny;
|
|
69
|
+
} & SchemaShape extends infer T ? { [key in keyof T]: ReturnType<T[key]["validate"]>; } : never);
|
|
70
|
+
}]>;
|
|
71
|
+
handler: false | ((ctx: {
|
|
72
|
+
updated: {
|
|
73
|
+
emit: (payload: {
|
|
74
|
+
[x: string]: ArcIdAny;
|
|
75
|
+
} & SchemaShape extends infer T extends ArcRawShape ? { [key in keyof T]: ReturnType<T[key]["deserialize"]>; } : never) => Promise<void>;
|
|
76
|
+
};
|
|
77
|
+
} & {
|
|
78
|
+
$auth: {
|
|
79
|
+
params: any;
|
|
80
|
+
tokenName: string;
|
|
81
|
+
};
|
|
82
|
+
$query: {
|
|
83
|
+
find: (options?: any) => Promise<({ [key in keyof SchemaShape]: ReturnType<SchemaShape[key]["deserialize"]>; } & {
|
|
84
|
+
_id: ReturnType<Id["deserialize"]>;
|
|
85
|
+
})[]>;
|
|
86
|
+
findOne: (where?: any) => Promise<({ [key in keyof SchemaShape]: ReturnType<SchemaShape[key]["deserialize"]>; } & {
|
|
87
|
+
_id: ReturnType<Id["deserialize"]>;
|
|
88
|
+
}) | undefined>;
|
|
89
|
+
};
|
|
90
|
+
}, params: {
|
|
91
|
+
[x: string]: ArcIdAny;
|
|
92
|
+
} & SchemaShape extends infer T extends ArcRawShape ? { [key in keyof T]: ReturnType<T[key]["deserialize"]>; } : never) => Promise<any>);
|
|
93
|
+
}]>;
|
|
94
|
+
//# sourceMappingURL=simple-aggregate.d.ts.map
|
|
@@ -1,23 +1,8 @@
|
|
|
1
1
|
import type { ArcToken, ArcTokenAny } from "../../token/token";
|
|
2
2
|
import type { $type } from "../../utils/types/get-type";
|
|
3
3
|
import type { ArcContextElement } from "../context-element";
|
|
4
|
+
import type { ElementContext } from "../element-context";
|
|
4
5
|
import type { CommandProtection } from "./command-data";
|
|
5
|
-
/**
|
|
6
|
-
* Build context object from query elements
|
|
7
|
-
* Each element gets its context by calling element.queryContext(adapters)
|
|
8
|
-
* Only includes elements that have queryContext method
|
|
9
|
-
*/
|
|
10
|
-
type QueryContext<Elements extends ArcContextElement<any>[]> = {
|
|
11
|
-
[K in Elements[number] as K["queryContext"] extends (...args: any) => any ? K["name"] : never]: K["queryContext"] extends (...args: any) => infer R ? R : never;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Build context object from mutation elements
|
|
15
|
-
* Each element gets its context by calling element.mutateContext(adapters)
|
|
16
|
-
* Only includes elements that have mutateContext method
|
|
17
|
-
*/
|
|
18
|
-
type MutationContext<Elements extends ArcContextElement<any>[]> = {
|
|
19
|
-
[K in Elements[number] as K["mutateContext"] extends (...args: any) => any ? K["name"] : never]: K["mutateContext"] extends (...args: any) => infer R ? R : never;
|
|
20
|
-
};
|
|
21
6
|
/**
|
|
22
7
|
* Extract token params type from a token
|
|
23
8
|
*/
|
|
@@ -38,25 +23,11 @@ export type AuthContext<T extends ArcTokenAny> = {
|
|
|
38
23
|
* Extract union of all token types from protections array
|
|
39
24
|
*/
|
|
40
25
|
type ProtectionTokens<Protections extends CommandProtection[]> = Protections[number]["token"];
|
|
41
|
-
/**
|
|
42
|
-
* Get function type for backward compatibility
|
|
43
|
-
* Allows: ctx.get(view).findOne() or ctx.get(event).emit()
|
|
44
|
-
* Returns any for flexibility - the runtime will provide the correct context
|
|
45
|
-
*/
|
|
46
|
-
type GetFunction<_QueryElements extends ArcContextElement<any>[], _MutationElements extends ArcContextElement<any>[]> = {
|
|
47
|
-
get: <T extends ArcContextElement<any>>(element: T) => any;
|
|
48
|
-
};
|
|
49
26
|
/**
|
|
50
27
|
* Command context provided to command handlers
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* Each element is accessible by its name:
|
|
54
|
-
* - Query elements: ctx.myView.findOne(...)
|
|
55
|
-
* - Mutation elements: ctx.myEvent.emit(...)
|
|
56
|
-
* - Auth context: ctx.$auth.params (only for protected commands)
|
|
57
|
-
* - Get function: ctx.get(element) for backward compatibility
|
|
28
|
+
* Extends shared ElementContext with command-specific $auth support.
|
|
58
29
|
*/
|
|
59
|
-
export type ArcCommandContext<QueryElements extends ArcContextElement<any>[], MutationElements extends ArcContextElement<any>[], Protections extends CommandProtection[] = []> =
|
|
30
|
+
export type ArcCommandContext<QueryElements extends ArcContextElement<any>[], MutationElements extends ArcContextElement<any>[], Protections extends CommandProtection[] = []> = ElementContext<QueryElements, MutationElements> & (Protections extends [] ? object : {
|
|
60
31
|
$auth: AuthContext<ProtectionTokens<Protections>>;
|
|
61
32
|
});
|
|
62
33
|
/**
|
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Every element in Arc (command, event, view, listener) extends this base class.
|
|
5
5
|
* Elements provide type-safe access to their functionality through the context system.
|
|
6
|
+
*
|
|
7
|
+
* ArcContextElement extends ArcFragmentBase — context elements ARE fragments,
|
|
8
|
+
* enabling unified fragment-based registration in modules.
|
|
6
9
|
*/
|
|
7
10
|
import type { ModelAdapters } from "../model/model-adapters";
|
|
11
|
+
import { ArcFragmentBase } from "../fragment/arc-fragment";
|
|
8
12
|
export type ArcEnvironment = "client" | "server" | "universal";
|
|
9
13
|
/**
|
|
10
14
|
* Base class for all Arc context elements
|
|
@@ -20,12 +24,14 @@ export type ArcEnvironment = "client" | "server" | "universal";
|
|
|
20
24
|
* 2. Its context generation logic
|
|
21
25
|
* 3. Its handler/logic
|
|
22
26
|
*/
|
|
23
|
-
export declare abstract class ArcContextElement<const Name extends string> {
|
|
27
|
+
export declare abstract class ArcContextElement<const Name extends string> extends ArcFragmentBase {
|
|
24
28
|
/**
|
|
25
29
|
* Element name - used for identification and error messages
|
|
26
30
|
* Must be unique within a context
|
|
27
31
|
*/
|
|
28
32
|
readonly name: Name;
|
|
33
|
+
readonly types: readonly ["context-element"];
|
|
34
|
+
get id(): string;
|
|
29
35
|
constructor(name: Name);
|
|
30
36
|
/**
|
|
31
37
|
* Initialize element in the given environment
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ModelAdapters } from "../model/model-adapters";
|
|
2
|
+
import type { ArcContextElement } from "./context-element";
|
|
3
|
+
/**
|
|
4
|
+
* Query context — maps element names to their queryContext return types.
|
|
5
|
+
* Uses key remapping to filter only elements that have queryContext.
|
|
6
|
+
*/
|
|
7
|
+
type QueryContext<Elements extends ArcContextElement<any>[]> = {
|
|
8
|
+
[K in Elements[number] as K["queryContext"] extends (...args: any) => any ? K["name"] : never]: K["queryContext"] extends (...args: any) => infer R ? R : never;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Mutation context — maps element names to their mutateContext return types.
|
|
12
|
+
* Uses key remapping to filter only elements that have mutateContext.
|
|
13
|
+
*/
|
|
14
|
+
type MutationContext<Elements extends ArcContextElement<any>[]> = {
|
|
15
|
+
[K in Elements[number] as K["mutateContext"] extends (...args: any) => any ? K["name"] : never]: K["mutateContext"] extends (...args: any) => infer R ? R : never;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Unified element context — shared between routes, commands, and any
|
|
19
|
+
* handler that needs typed access to query/mutation elements.
|
|
20
|
+
*
|
|
21
|
+
* Elements are accessible by name (ctx.myView, ctx.myAggregate) or
|
|
22
|
+
* by reference (ctx.query(element), ctx.mutate(element)).
|
|
23
|
+
*/
|
|
24
|
+
export type ElementContext<QueryElements extends ArcContextElement<any>[], MutationElements extends ArcContextElement<any>[]> = QueryContext<QueryElements> & MutationContext<MutationElements> & {
|
|
25
|
+
get: <T extends ArcContextElement<any>>(element: T) => any;
|
|
26
|
+
query: <T extends ArcContextElement<any>>(element: T) => T extends {
|
|
27
|
+
queryContext: (...args: any) => infer R;
|
|
28
|
+
} ? R : never;
|
|
29
|
+
mutate: <T extends ArcContextElement<any>>(element: T) => T extends {
|
|
30
|
+
mutateContext: (...args: any) => infer R;
|
|
31
|
+
} ? R : never;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Build element context at runtime.
|
|
35
|
+
* Shared implementation for routes, commands, etc.
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildElementContext(queryElements: ArcContextElement<any>[], mutationElements: ArcContextElement<any>[], adapters: ModelAdapters): any;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=element-context.d.ts.map
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides dependency injection and element registration
|
|
5
5
|
*/
|
|
6
|
+
export * from "./aggregate";
|
|
6
7
|
export * from "./command";
|
|
7
8
|
export * from "./context-element";
|
|
9
|
+
export * from "./element-context";
|
|
8
10
|
export * from "./event";
|
|
9
11
|
export * from "./listener";
|
|
10
12
|
export * from "./route";
|
|
@@ -3,31 +3,8 @@ import type { ArcTokenAny } from "../../token/token";
|
|
|
3
3
|
import type { TokenInstanceAny } from "../../token/token-instance";
|
|
4
4
|
import type { Merge } from "../../utils";
|
|
5
5
|
import { ArcContextElement } from "../context-element";
|
|
6
|
+
import { type ElementContext } from "../element-context";
|
|
6
7
|
import type { ArcRouteData, HttpMethod, RouteHandler, RouteHandlers, RouteProtectionCheck } from "./route-data";
|
|
7
|
-
/**
|
|
8
|
-
* Route context passed to handlers
|
|
9
|
-
*/
|
|
10
|
-
export type ArcRouteContext<QueryElements extends ArcContextElement<any>[], MutationElements extends ArcContextElement<any>[]> = {
|
|
11
|
-
[K in QueryElements[number]["name"]]: QueryElements[number] extends {
|
|
12
|
-
name: K;
|
|
13
|
-
queryContext: (...args: any[]) => infer R;
|
|
14
|
-
} ? R : never;
|
|
15
|
-
} & {
|
|
16
|
-
[K in MutationElements[number]["name"]]: MutationElements[number] extends {
|
|
17
|
-
name: K;
|
|
18
|
-
mutateContext: (...args: any[]) => infer R;
|
|
19
|
-
} ? R : never;
|
|
20
|
-
} & {
|
|
21
|
-
get: <T extends ArcContextElement<any>>(element: T) => T extends {
|
|
22
|
-
queryContext: (...args: any[]) => infer R;
|
|
23
|
-
} ? R : T extends {
|
|
24
|
-
mutateContext: (...args: any[]) => infer R;
|
|
25
|
-
} ? R : never;
|
|
26
|
-
$auth?: {
|
|
27
|
-
params: Record<string, any>;
|
|
28
|
-
tokenName: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
8
|
/**
|
|
32
9
|
* Arc Route - Custom HTTP endpoint handler
|
|
33
10
|
*
|
|
@@ -96,7 +73,12 @@ export declare class ArcRoute<const Data extends ArcRouteData> extends ArcContex
|
|
|
96
73
|
/**
|
|
97
74
|
* Set route handlers for HTTP methods
|
|
98
75
|
*/
|
|
99
|
-
handle<Handlers extends RouteHandlers<
|
|
76
|
+
handle<Handlers extends RouteHandlers<ElementContext<Data["queryElements"], Data["mutationElements"]> & {
|
|
77
|
+
$auth?: {
|
|
78
|
+
params: Record<string, any>;
|
|
79
|
+
tokenName: string;
|
|
80
|
+
};
|
|
81
|
+
}>>(handlers: Handlers): ArcRoute<Merge<Data, {
|
|
100
82
|
handlers: Handlers;
|
|
101
83
|
}>>;
|
|
102
84
|
/**
|
|
@@ -141,7 +123,7 @@ export declare class ArcRoute<const Data extends ArcRouteData> extends ArcContex
|
|
|
141
123
|
buildContext(adapters: ModelAdapters, authParams?: {
|
|
142
124
|
params: Record<string, any>;
|
|
143
125
|
tokenName: string;
|
|
144
|
-
}):
|
|
126
|
+
}): any;
|
|
145
127
|
}
|
|
146
128
|
/**
|
|
147
129
|
* Create a new route with the given name
|
|
@@ -104,7 +104,7 @@ export declare class ArcStaticView<const Data extends ArcStaticViewData> extends
|
|
|
104
104
|
export declare function staticView<const Name extends string, Id, Schema extends ArcObjectAny | ArcRawShape>(name: Name, id: Id, schema: Schema): ArcStaticView<{
|
|
105
105
|
name: Name;
|
|
106
106
|
id: Id;
|
|
107
|
-
schema:
|
|
107
|
+
schema: ArcObject<ArcRawShape, [{
|
|
108
108
|
name: "type";
|
|
109
109
|
validator: (value: any) => false | {
|
|
110
110
|
current: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
@@ -115,7 +115,7 @@ export declare function staticView<const Name extends string, Id, Schema extends
|
|
|
115
115
|
validator: (value: any) => false | {
|
|
116
116
|
[x: string]: unknown;
|
|
117
117
|
};
|
|
118
|
-
}]
|
|
118
|
+
}]> | (Schema & ArcObject<any, any>);
|
|
119
119
|
items: [];
|
|
120
120
|
}>;
|
|
121
121
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ArcView, view, type ArcViewAny, type ArcViewRecord } from "./view";
|
|
2
|
-
export type { ArcViewData } from "./view-data";
|
|
2
|
+
export type { ArcViewData, ViewProtection, ViewProtectionFn } from "./view-data";
|
|
3
3
|
export type { ArcViewHandlerContext, ArcViewItem, ArcViewQueryContext, } from "./view-context";
|
|
4
4
|
export type { ArcObjectAny } from "../../elements/object";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -30,6 +30,7 @@ export declare abstract class StoreState<Item extends {
|
|
|
30
30
|
from: Item | null;
|
|
31
31
|
to: Item | null;
|
|
32
32
|
}[]>;
|
|
33
|
+
get listenerCount(): number;
|
|
33
34
|
unsubscribe(listener: QueryListenerCallback<Item>): void;
|
|
34
35
|
protected notifyListeners(events: ListenerEvent<Item>[]): void;
|
|
35
36
|
}
|
|
@@ -7,6 +7,7 @@ export declare class ArcBranded<E extends ArcAbstractAny, Brand extends string |
|
|
|
7
7
|
private parent;
|
|
8
8
|
private brand;
|
|
9
9
|
constructor(parent: E, brand: Brand);
|
|
10
|
+
get name(): Brand;
|
|
10
11
|
serialize(value: FirstArgument<E["serialize"]> & {
|
|
11
12
|
__brand: Brand;
|
|
12
13
|
}): ReturnType<E["serialize"]>;
|
|
@@ -37,9 +37,9 @@ export declare class ArcObject<E extends ArcRawShape, V extends Validators = [
|
|
|
37
37
|
};
|
|
38
38
|
deserialize(value: AddQuestionMarks<{
|
|
39
39
|
[key in keyof E]: FirstArgument<E[key]["deserialize"]>;
|
|
40
|
-
}>): {
|
|
40
|
+
}>): AddQuestionMarks<{
|
|
41
41
|
[key in keyof E]: ReturnType<E[key]["deserialize"]>;
|
|
42
|
-
}
|
|
42
|
+
}>;
|
|
43
43
|
deserializePath(path: string[], value: any): any;
|
|
44
44
|
parsePartial(value: Partial<{
|
|
45
45
|
[key in keyof E]: FirstArgument<E[key]["parse"]>;
|
|
@@ -7,7 +7,7 @@ export declare class ArcOptional<E extends ArcElement> implements ArcElement {
|
|
|
7
7
|
constructor(parent: E);
|
|
8
8
|
parse(value: FirstArgument<E["parse"]> | null | undefined): ReturnType<E["parse"]> | null;
|
|
9
9
|
serialize(value: FirstArgument<E["serialize"]> | null | undefined): ReturnType<E["serialize"]> | null;
|
|
10
|
-
deserialize(value: FirstArgument<E["deserialize"]> |
|
|
10
|
+
deserialize(value: FirstArgument<E["deserialize"]> | undefined): ReturnType<E["deserialize"]> | undefined;
|
|
11
11
|
validate(value: unknown): unknown;
|
|
12
12
|
toJsonSchema(): {
|
|
13
13
|
anyOf: any[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArcFragmentBase — abstract base class for all Arc fragments.
|
|
3
|
+
*
|
|
4
|
+
* Every element in Arc (context element, page, wrapper, slot) extends this class.
|
|
5
|
+
* Fragments declare their types as a list, enabling type-based filtering
|
|
6
|
+
* without a closed enum — the type system is extensible.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* fragment.is("context-element") // check single type
|
|
10
|
+
* fragment.is("page") // check single type
|
|
11
|
+
* fragments.filter(f => f.is("context-element")) // filter by type
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class ArcFragmentBase {
|
|
14
|
+
abstract readonly id: string;
|
|
15
|
+
abstract readonly types: readonly string[];
|
|
16
|
+
is(type: string): boolean;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=arc-fragment.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -8,8 +8,24 @@ export * from "./context";
|
|
|
8
8
|
export * from "./context-element";
|
|
9
9
|
export * from "./data-storage";
|
|
10
10
|
export * from "./elements";
|
|
11
|
+
export * from "./fragment";
|
|
11
12
|
export * from "./model";
|
|
12
13
|
export * from "./streaming";
|
|
13
14
|
export * from "./token";
|
|
14
15
|
export * from "./utils";
|
|
16
|
+
/**
|
|
17
|
+
* ONLY_CLIENT — global constant for tree shaking.
|
|
18
|
+
*
|
|
19
|
+
* Set via Bun/bundler define plugin:
|
|
20
|
+
* define: { ONLY_CLIENT: "true" } // client build
|
|
21
|
+
* define: { ONLY_CLIENT: "false" } // server build
|
|
22
|
+
*
|
|
23
|
+
* Usage in aggregate classes (use function() to preserve this):
|
|
24
|
+
* toBadge = ONLY_CLIENT && function(this: Task) {
|
|
25
|
+
* return <Badge>{this.value.title}</Badge>;
|
|
26
|
+
* }
|
|
27
|
+
*/
|
|
28
|
+
declare global {
|
|
29
|
+
var ONLY_CLIENT: boolean;
|
|
30
|
+
}
|
|
15
31
|
//# sourceMappingURL=index.d.ts.map
|