@arcote.tech/arc 0.1.4 → 0.1.5
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/command/command.d.ts +4 -0
- package/dist/context/context.d.ts +1 -3
- package/dist/context/element.d.ts +1 -1
- package/dist/context/event.d.ts +1 -8
- package/dist/elements/any.d.ts +9 -0
- package/dist/elements/index.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +164 -38
- package/dist/model/model.d.ts +3 -0
- package/dist/route/index.d.ts +2 -0
- package/dist/route/route.d.ts +35 -0
- package/dist/view/queries/find-one.d.ts +4 -10
- package/dist/view/queries/find.d.ts +4 -4
- package/dist/view/query-builders/find-one.d.ts +2 -2
- package/dist/view/query-builders/find.d.ts +2 -2
- package/package.json +1 -1
|
@@ -20,6 +20,10 @@ export declare class ArcCommand<Name extends string, Params extends ArcObjectAny
|
|
|
20
20
|
description(description: string): ArcCommand<Name, Params, Results, Elements>;
|
|
21
21
|
public(): ArcCommand<Name, Params, Results, Elements>;
|
|
22
22
|
get isPublic(): boolean;
|
|
23
|
+
matchesCommandPath(pathname: string): {
|
|
24
|
+
matches: boolean;
|
|
25
|
+
isPublic: boolean;
|
|
26
|
+
};
|
|
23
27
|
withParams<NewParams extends ArcRawShape>(schema: NewParams | ArcObject<NewParams>): ArcCommand<Name, ArcObject<NewParams>, Results, Elements>;
|
|
24
28
|
withResult<NewResults extends ArcRawShape[]>(...schemas: NewResults): ArcCommand<Name, Params, { [K in keyof NewResults]: ArcObject<NewResults[K]>; }, Elements>;
|
|
25
29
|
handle(handler: ArcCommmandHandler<Elements, Params, Results> | false): ArcCommand<Name, Params, Results, Elements>;
|
|
@@ -41,8 +41,6 @@ export type ContextEvents<Context extends ArcContextAny> = {
|
|
|
41
41
|
} & ElementEvents<Element>>;
|
|
42
42
|
}[Context["elements"][number]["name"]];
|
|
43
43
|
export type Listener<Context extends ArcContextAny> = (event: ContextEvents<Context>, context: CommandContext<Context>) => Promise<void> | void;
|
|
44
|
-
export declare function context<const Elements extends (
|
|
45
|
-
default: ArcContextElementAny;
|
|
46
|
-
}>)[]>(elementsPromise: Elements): Promise<ArcContext<RemoveFalseAndResolvedPromiseFromArray<Elements>>>;
|
|
44
|
+
export declare function context<const Elements extends ArcContextElementAny[]>(elementsPromise: Elements): Promise<ArcContext<Elements>>;
|
|
47
45
|
export {};
|
|
48
46
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -50,7 +50,7 @@ export type StoreSchema = {
|
|
|
50
50
|
export declare abstract class ArcContextElement<const Event, const Name extends string | undefined = undefined> {
|
|
51
51
|
readonly $event: Event;
|
|
52
52
|
readonly name?: Name;
|
|
53
|
-
queryBuilder
|
|
53
|
+
queryBuilder?: (queryContext: QueryBuilderContext, authContext: AuthContext) => any;
|
|
54
54
|
commandContext?: (dataStorage: DataStorage, publishEvent: PublishEventFunction, authContext: AuthContext) => any;
|
|
55
55
|
commandClient?: (commandContext: any, authContext: AuthContext) => (...args: any[]) => any;
|
|
56
56
|
observer?: (authContext: AuthContext) => Record<string, ListenerConfig>;
|
package/dist/context/event.d.ts
CHANGED
|
@@ -3,14 +3,7 @@ import { ArcObject, type ArcObjectAny, type ArcRawShape } from "../elements/obje
|
|
|
3
3
|
import type { $type } from "../utils";
|
|
4
4
|
import { ArcContextElementWithStore, type AuthContext, type AuthorizationRestrictions, type EventAuthorizationRestrictions, type StoreSchema } from "./element";
|
|
5
5
|
export type EventMetadata = {
|
|
6
|
-
|
|
7
|
-
createdBy?: {
|
|
8
|
-
id: string;
|
|
9
|
-
type: string;
|
|
10
|
-
};
|
|
11
|
-
source?: string;
|
|
12
|
-
correlationId?: string;
|
|
13
|
-
version?: number;
|
|
6
|
+
createdAt: Date;
|
|
14
7
|
};
|
|
15
8
|
export declare class ArcEvent<const Name extends string, const PayloadShape extends ArcObjectAny | undefined> extends ArcContextElementWithStore<ArcEventInstance<ArcEvent<Name, PayloadShape>>, Name> {
|
|
16
9
|
readonly name: Name;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ArcAbstract, type Validators } from "./abstract";
|
|
2
|
+
export declare class ArcAny<V extends Validators = []> extends ArcAbstract<V> {
|
|
3
|
+
constructor();
|
|
4
|
+
parse(value: any): any;
|
|
5
|
+
serialize(value: any): any;
|
|
6
|
+
deserialize(value: any): any;
|
|
7
|
+
}
|
|
8
|
+
export declare function any(): ArcAny<[]>;
|
|
9
|
+
//# sourceMappingURL=any.d.ts.map
|
package/dist/elements/index.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
class ArcContextElement {
|
|
3
3
|
$event;
|
|
4
4
|
name;
|
|
5
|
+
queryBuilder;
|
|
5
6
|
commandContext;
|
|
6
7
|
commandClient;
|
|
7
8
|
observer;
|
|
@@ -314,6 +315,24 @@ function customId(name, createFn) {
|
|
|
314
315
|
return new ArcCustomId(name, createFn);
|
|
315
316
|
}
|
|
316
317
|
|
|
318
|
+
// elements/any.ts
|
|
319
|
+
class ArcAny extends ArcAbstract {
|
|
320
|
+
constructor() {
|
|
321
|
+
super([]);
|
|
322
|
+
}
|
|
323
|
+
parse(value) {
|
|
324
|
+
return value;
|
|
325
|
+
}
|
|
326
|
+
serialize(value) {
|
|
327
|
+
return value;
|
|
328
|
+
}
|
|
329
|
+
deserialize(value) {
|
|
330
|
+
return value;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
function any() {
|
|
334
|
+
return new ArcAny;
|
|
335
|
+
}
|
|
317
336
|
// elements/object.ts
|
|
318
337
|
var objectValidator = typeValidatorBuilder("object");
|
|
319
338
|
|
|
@@ -1114,7 +1133,7 @@ class ArcFindQuery extends ArcCollectionQuery {
|
|
|
1114
1133
|
}
|
|
1115
1134
|
onChange(change) {
|
|
1116
1135
|
const lastResult = this.lastResult;
|
|
1117
|
-
const lastResultAsArray = lastResult
|
|
1136
|
+
const lastResultAsArray = lastResult || [];
|
|
1118
1137
|
const index = lastResultAsArray.findIndex((e) => e._id === (change.type === "delete" ? change.id : change.id));
|
|
1119
1138
|
const isInLastResult = index !== -1;
|
|
1120
1139
|
const shouldBeInTheResult = change.type !== "delete" && this.checkItem(change.item);
|
|
@@ -1304,6 +1323,16 @@ class ArcCommand extends ArcContextElement {
|
|
|
1304
1323
|
get isPublic() {
|
|
1305
1324
|
return this._isPublic;
|
|
1306
1325
|
}
|
|
1326
|
+
matchesCommandPath(pathname) {
|
|
1327
|
+
if (!pathname.startsWith("/command/")) {
|
|
1328
|
+
return { matches: false, isPublic: false };
|
|
1329
|
+
}
|
|
1330
|
+
const commandName = pathname.split("/command/")[1];
|
|
1331
|
+
if (commandName === this.name) {
|
|
1332
|
+
return { matches: true, isPublic: this._isPublic };
|
|
1333
|
+
}
|
|
1334
|
+
return { matches: false, isPublic: false };
|
|
1335
|
+
}
|
|
1307
1336
|
withParams(schema) {
|
|
1308
1337
|
const clone = this.clone();
|
|
1309
1338
|
clone._params = schema instanceof ArcObject ? schema : object(schema);
|
|
@@ -1496,7 +1525,7 @@ class ArcEvent extends ArcContextElementWithStore {
|
|
|
1496
1525
|
id: eventId.generate(),
|
|
1497
1526
|
type: this.name,
|
|
1498
1527
|
payload,
|
|
1499
|
-
createdAt: new Date
|
|
1528
|
+
createdAt: new Date
|
|
1500
1529
|
};
|
|
1501
1530
|
await dataStorage.getStore("events").set(event);
|
|
1502
1531
|
await publishEvent(event);
|
|
@@ -2495,6 +2524,40 @@ class Model extends ModelBase {
|
|
|
2495
2524
|
}
|
|
2496
2525
|
});
|
|
2497
2526
|
}
|
|
2527
|
+
routes(authContext) {
|
|
2528
|
+
return new Proxy({}, {
|
|
2529
|
+
get: (_, name) => {
|
|
2530
|
+
const element3 = this.context.elements.find((element4) => element4.name === name);
|
|
2531
|
+
if (!element3) {
|
|
2532
|
+
throw new Error(`Route element "${String(name)}" not found`);
|
|
2533
|
+
}
|
|
2534
|
+
if (typeof element3.getHandler !== "function") {
|
|
2535
|
+
throw new Error(`Element "${String(name)}" does not have route handlers`);
|
|
2536
|
+
}
|
|
2537
|
+
return async (method, req, routeParams, url) => {
|
|
2538
|
+
const handler = element3.getHandler(method);
|
|
2539
|
+
if (!handler) {
|
|
2540
|
+
throw new Error(`Method ${method} not allowed for route ${String(name)}`);
|
|
2541
|
+
}
|
|
2542
|
+
const forkedDataStorage = this.dataStorage.fork();
|
|
2543
|
+
const eventPublisher = new EventPublisher(this.context, this.dataStorage, authContext);
|
|
2544
|
+
const publishEvent = async (event3) => {
|
|
2545
|
+
await eventPublisher.publishEvent(event3, forkedDataStorage);
|
|
2546
|
+
};
|
|
2547
|
+
const commandContext = this.context.commandContext(forkedDataStorage, publishEvent, authContext);
|
|
2548
|
+
try {
|
|
2549
|
+
const result = await handler(commandContext, req, routeParams, url);
|
|
2550
|
+
await forkedDataStorage.merge();
|
|
2551
|
+
eventPublisher.runAsyncListeners();
|
|
2552
|
+
return result;
|
|
2553
|
+
} catch (error) {
|
|
2554
|
+
this.catchErrorCallback(error);
|
|
2555
|
+
throw error;
|
|
2556
|
+
}
|
|
2557
|
+
};
|
|
2558
|
+
}
|
|
2559
|
+
});
|
|
2560
|
+
}
|
|
2498
2561
|
get $debug() {
|
|
2499
2562
|
return {};
|
|
2500
2563
|
}
|
|
@@ -2643,8 +2706,7 @@ class RemoteModelClient extends ModelBase {
|
|
|
2643
2706
|
if (!response.ok) {
|
|
2644
2707
|
throw new Error(`Query failed: ${response.statusText}`);
|
|
2645
2708
|
}
|
|
2646
|
-
|
|
2647
|
-
return result;
|
|
2709
|
+
return await response.json();
|
|
2648
2710
|
}
|
|
2649
2711
|
subscribe(queryBuilderFn, callback, authContext) {
|
|
2650
2712
|
const result = this.query(queryBuilderFn, authContext);
|
|
@@ -2688,6 +2750,95 @@ class RemoteModelClient extends ModelBase {
|
|
|
2688
2750
|
});
|
|
2689
2751
|
return commandsProxy;
|
|
2690
2752
|
}
|
|
2753
|
+
routes(authContext) {
|
|
2754
|
+
throw new Error("Remote model client does not support route execution");
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
// route/route.ts
|
|
2758
|
+
class ArcRoute extends ArcContextElement {
|
|
2759
|
+
name;
|
|
2760
|
+
_description;
|
|
2761
|
+
_path;
|
|
2762
|
+
_elements;
|
|
2763
|
+
_handlers;
|
|
2764
|
+
_isPublic = false;
|
|
2765
|
+
constructor(name) {
|
|
2766
|
+
super();
|
|
2767
|
+
this.name = name;
|
|
2768
|
+
}
|
|
2769
|
+
use(elements) {
|
|
2770
|
+
const clone = this.clone();
|
|
2771
|
+
clone._elements = elements;
|
|
2772
|
+
return clone;
|
|
2773
|
+
}
|
|
2774
|
+
description(description) {
|
|
2775
|
+
const clone = this.clone();
|
|
2776
|
+
clone._description = description;
|
|
2777
|
+
return clone;
|
|
2778
|
+
}
|
|
2779
|
+
path(path) {
|
|
2780
|
+
const clone = this.clone();
|
|
2781
|
+
clone._path = path;
|
|
2782
|
+
return clone;
|
|
2783
|
+
}
|
|
2784
|
+
public() {
|
|
2785
|
+
const clone = this.clone();
|
|
2786
|
+
clone._isPublic = true;
|
|
2787
|
+
return clone;
|
|
2788
|
+
}
|
|
2789
|
+
get isPublic() {
|
|
2790
|
+
return this._isPublic;
|
|
2791
|
+
}
|
|
2792
|
+
get routePath() {
|
|
2793
|
+
return this._path || `/${this.name}`;
|
|
2794
|
+
}
|
|
2795
|
+
handle(handlers) {
|
|
2796
|
+
const clone = this.clone();
|
|
2797
|
+
clone._handlers = handlers;
|
|
2798
|
+
return clone;
|
|
2799
|
+
}
|
|
2800
|
+
getHandler(method) {
|
|
2801
|
+
return this._handlers?.[method];
|
|
2802
|
+
}
|
|
2803
|
+
matchesPath(pathname) {
|
|
2804
|
+
const routePath = this.routePath;
|
|
2805
|
+
const routeParts = routePath.split("/").filter(Boolean);
|
|
2806
|
+
const pathParts = pathname.split("/").filter(Boolean);
|
|
2807
|
+
if (routeParts.length !== pathParts.length) {
|
|
2808
|
+
return { matches: false, params: {} };
|
|
2809
|
+
}
|
|
2810
|
+
const params = {};
|
|
2811
|
+
for (let i = 0;i < routeParts.length; i++) {
|
|
2812
|
+
const routePart = routeParts[i];
|
|
2813
|
+
const pathPart = pathParts[i];
|
|
2814
|
+
if (routePart.startsWith(":")) {
|
|
2815
|
+
const paramName = routePart.slice(1);
|
|
2816
|
+
params[paramName] = pathPart;
|
|
2817
|
+
} else if (routePart !== pathPart) {
|
|
2818
|
+
return { matches: false, params: {} };
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
return { matches: true, params };
|
|
2822
|
+
}
|
|
2823
|
+
matchesRoutePath(pathname) {
|
|
2824
|
+
const { matches, params } = this.matchesPath(pathname);
|
|
2825
|
+
if (matches) {
|
|
2826
|
+
return { matches: true, isPublic: this._isPublic, params };
|
|
2827
|
+
}
|
|
2828
|
+
return { matches: false, isPublic: false };
|
|
2829
|
+
}
|
|
2830
|
+
clone() {
|
|
2831
|
+
const clone = new ArcRoute(this.name);
|
|
2832
|
+
clone._description = this._description;
|
|
2833
|
+
clone._path = this._path;
|
|
2834
|
+
clone._handlers = this._handlers;
|
|
2835
|
+
clone._elements = this._elements;
|
|
2836
|
+
clone._isPublic = this._isPublic;
|
|
2837
|
+
return clone;
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
function route(name) {
|
|
2841
|
+
return new ArcRoute(name);
|
|
2691
2842
|
}
|
|
2692
2843
|
// rtc/client.ts
|
|
2693
2844
|
class RTCClient {
|
|
@@ -2795,22 +2946,6 @@ class ArcViewQuery extends ArcSerializableQuery {
|
|
|
2795
2946
|
}
|
|
2796
2947
|
|
|
2797
2948
|
// view/queries/find.ts
|
|
2798
|
-
class QueryViewResult {
|
|
2799
|
-
result;
|
|
2800
|
-
constructor(result) {
|
|
2801
|
-
this.result = result;
|
|
2802
|
-
}
|
|
2803
|
-
get(id3) {
|
|
2804
|
-
return id3 ? this.result.find((r) => r._id === id3) : undefined;
|
|
2805
|
-
}
|
|
2806
|
-
map(callbackfn) {
|
|
2807
|
-
return this.result.map(callbackfn);
|
|
2808
|
-
}
|
|
2809
|
-
toArray() {
|
|
2810
|
-
return this.result;
|
|
2811
|
-
}
|
|
2812
|
-
}
|
|
2813
|
-
|
|
2814
2949
|
class ArcViewFindQuery extends ArcViewQuery {
|
|
2815
2950
|
params;
|
|
2816
2951
|
constructor(view, params) {
|
|
@@ -2857,7 +2992,7 @@ class ArcViewFindQuery extends ArcViewQuery {
|
|
|
2857
2992
|
}
|
|
2858
2993
|
onChange(change) {
|
|
2859
2994
|
const lastResult = this.lastResult;
|
|
2860
|
-
const lastResultAsArray = lastResult
|
|
2995
|
+
const lastResultAsArray = lastResult || [];
|
|
2861
2996
|
const index = lastResultAsArray.findIndex((e) => e._id === (change.type === "delete" ? change.id : change.id));
|
|
2862
2997
|
const isInLastResult = index !== -1;
|
|
2863
2998
|
const shouldBeInTheResult = change.type !== "delete" && this.checkItem(change.item);
|
|
@@ -2870,7 +3005,7 @@ class ArcViewFindQuery extends ArcViewQuery {
|
|
|
2870
3005
|
return false;
|
|
2871
3006
|
}
|
|
2872
3007
|
createResult(result) {
|
|
2873
|
-
return
|
|
3008
|
+
return result;
|
|
2874
3009
|
}
|
|
2875
3010
|
}
|
|
2876
3011
|
|
|
@@ -2896,19 +3031,6 @@ class ArcViewFindQueryBuilder {
|
|
|
2896
3031
|
}
|
|
2897
3032
|
|
|
2898
3033
|
// view/queries/find-one.ts
|
|
2899
|
-
class QueryViewFindOneResult {
|
|
2900
|
-
result;
|
|
2901
|
-
constructor(result) {
|
|
2902
|
-
this.result = result;
|
|
2903
|
-
}
|
|
2904
|
-
get() {
|
|
2905
|
-
return this.result;
|
|
2906
|
-
}
|
|
2907
|
-
exists() {
|
|
2908
|
-
return this.result !== undefined;
|
|
2909
|
-
}
|
|
2910
|
-
}
|
|
2911
|
-
|
|
2912
3034
|
class ArcViewFindOneQuery extends ArcViewQuery {
|
|
2913
3035
|
params;
|
|
2914
3036
|
constructor(view, params) {
|
|
@@ -2955,7 +3077,7 @@ class ArcViewFindOneQuery extends ArcViewQuery {
|
|
|
2955
3077
|
}
|
|
2956
3078
|
onChange(change) {
|
|
2957
3079
|
const lastResult = this.lastResult;
|
|
2958
|
-
const currentItem = lastResult
|
|
3080
|
+
const currentItem = lastResult;
|
|
2959
3081
|
const itemId = change.type === "delete" ? change.id : change.id;
|
|
2960
3082
|
const hasCurrentItem = currentItem !== undefined;
|
|
2961
3083
|
const isCurrentItem = hasCurrentItem && currentItem._id === itemId;
|
|
@@ -2969,7 +3091,7 @@ class ArcViewFindOneQuery extends ArcViewQuery {
|
|
|
2969
3091
|
return false;
|
|
2970
3092
|
}
|
|
2971
3093
|
createResult(result) {
|
|
2972
|
-
return
|
|
3094
|
+
return result;
|
|
2973
3095
|
}
|
|
2974
3096
|
}
|
|
2975
3097
|
|
|
@@ -3157,6 +3279,7 @@ export {
|
|
|
3157
3279
|
stringEnum,
|
|
3158
3280
|
string,
|
|
3159
3281
|
rtcClientFactory,
|
|
3282
|
+
route,
|
|
3160
3283
|
record,
|
|
3161
3284
|
reactive,
|
|
3162
3285
|
object,
|
|
@@ -3175,6 +3298,7 @@ export {
|
|
|
3175
3298
|
boolean,
|
|
3176
3299
|
blob,
|
|
3177
3300
|
array,
|
|
3301
|
+
any,
|
|
3178
3302
|
StoreState,
|
|
3179
3303
|
SQLiteAdapter,
|
|
3180
3304
|
RemoteModelClient,
|
|
@@ -3190,6 +3314,7 @@ export {
|
|
|
3190
3314
|
ArcView,
|
|
3191
3315
|
ArcStringEnum,
|
|
3192
3316
|
ArcString,
|
|
3317
|
+
ArcRoute,
|
|
3193
3318
|
ArcRecord,
|
|
3194
3319
|
ArcQueryBuilder,
|
|
3195
3320
|
ArcQuery,
|
|
@@ -3211,5 +3336,6 @@ export {
|
|
|
3211
3336
|
ArcBranded,
|
|
3212
3337
|
ArcBoolean,
|
|
3213
3338
|
ArcBlob,
|
|
3214
|
-
ArcArray
|
|
3339
|
+
ArcArray,
|
|
3340
|
+
ArcAny
|
|
3215
3341
|
};
|
package/dist/model/model.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare abstract class ModelBase<C extends ArcContextAny> {
|
|
|
15
15
|
unsubscribe: () => void;
|
|
16
16
|
};
|
|
17
17
|
abstract commands(authContext: AuthContext): ArcContextElementMethodReturnType<C["elements"], "commandClient">;
|
|
18
|
+
abstract routes(authContext: AuthContext): any;
|
|
18
19
|
}
|
|
19
20
|
export declare class Model<C extends ArcContextAny> extends ModelBase<C> {
|
|
20
21
|
private readonly context;
|
|
@@ -28,6 +29,7 @@ export declare class Model<C extends ArcContextAny> extends ModelBase<C> {
|
|
|
28
29
|
unsubscribe: () => void;
|
|
29
30
|
};
|
|
30
31
|
commands(authContext: AuthContext): ArcContextElementMethodReturnType<C["elements"], "commandClient">;
|
|
32
|
+
routes(authContext: AuthContext): any;
|
|
31
33
|
get $debug(): {};
|
|
32
34
|
}
|
|
33
35
|
export declare class RemoteModelClient<C extends ArcContextAny> extends ModelBase<C> {
|
|
@@ -62,6 +64,7 @@ export declare class RemoteModelClient<C extends ArcContextAny> extends ModelBas
|
|
|
62
64
|
unsubscribe: () => void;
|
|
63
65
|
};
|
|
64
66
|
commands(authContext: AuthContext): ArcContextElementMethodReturnType<C["elements"], "commandClient">;
|
|
67
|
+
routes(authContext: AuthContext): any;
|
|
65
68
|
}
|
|
66
69
|
export {};
|
|
67
70
|
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ArcCommandContext } from "../context";
|
|
2
|
+
import { ArcContextElement, type ArcContextElementAny } from "../context/element";
|
|
3
|
+
export type ArcRouteHandler<ContextElements extends ArcContextElementAny[]> = (ctx: ArcCommandContext<ContextElements>, request: Request, params: Record<string, string>, url: URL) => Promise<Response> | Response;
|
|
4
|
+
export type ArcRouteHandlers<ContextElements extends ArcContextElementAny[]> = {
|
|
5
|
+
[Method in "GET" | "POST" | "PUT" | "DELETE" | "PATCH"]?: ArcRouteHandler<ContextElements>;
|
|
6
|
+
};
|
|
7
|
+
export declare class ArcRoute<Name extends string, const Elements extends ArcContextElementAny[]> extends ArcContextElement<null, Name> {
|
|
8
|
+
readonly name: Name;
|
|
9
|
+
private _description?;
|
|
10
|
+
private _path?;
|
|
11
|
+
private _elements?;
|
|
12
|
+
private _handlers?;
|
|
13
|
+
private _isPublic;
|
|
14
|
+
constructor(name: Name);
|
|
15
|
+
use<const E extends ArcContextElementAny[]>(elements: E): ArcRoute<Name, E>;
|
|
16
|
+
description(description: string): ArcRoute<Name, Elements>;
|
|
17
|
+
path(path: string): ArcRoute<Name, Elements>;
|
|
18
|
+
public(): ArcRoute<Name, Elements>;
|
|
19
|
+
get isPublic(): boolean;
|
|
20
|
+
get routePath(): string;
|
|
21
|
+
handle(handlers: ArcRouteHandlers<Elements>): ArcRoute<Name, Elements>;
|
|
22
|
+
getHandler(method: string): ArcRouteHandler<Elements> | undefined;
|
|
23
|
+
matchesPath(pathname: string): {
|
|
24
|
+
matches: boolean;
|
|
25
|
+
params: Record<string, string>;
|
|
26
|
+
};
|
|
27
|
+
matchesRoutePath(pathname: string): {
|
|
28
|
+
matches: boolean;
|
|
29
|
+
isPublic: boolean;
|
|
30
|
+
params?: Record<string, string>;
|
|
31
|
+
};
|
|
32
|
+
private clone;
|
|
33
|
+
}
|
|
34
|
+
export declare function route<Name extends string>(name: Name): ArcRoute<Name, any[]>;
|
|
35
|
+
//# sourceMappingURL=route.d.ts.map
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import type { ListenerEvent, StoreState } from "../../data-storage";
|
|
2
2
|
import type { FindOptions } from "../../data-storage/types";
|
|
3
3
|
import { ArcViewQuery, type ArcViewAny, type ArcViewItem } from "./abstract-view-query";
|
|
4
|
-
export declare class
|
|
5
|
-
private result;
|
|
6
|
-
constructor(result: ArcViewItem<V["id"], V["schema"]> | undefined);
|
|
7
|
-
get(): ArcViewItem<V["id"], V["schema"]> | undefined;
|
|
8
|
-
exists(): boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare class ArcViewFindOneQuery<View extends ArcViewAny> extends ArcViewQuery<View, QueryViewFindOneResult<View>, FindOptions<ArcViewItem<View["id"], View["schema"]>>> {
|
|
4
|
+
export declare class ArcViewFindOneQuery<View extends ArcViewAny> extends ArcViewQuery<View, ArcViewItem<View["id"], View["schema"]> | undefined, FindOptions<ArcViewItem<View["id"], View["schema"]>>> {
|
|
11
5
|
protected params: FindOptions<ArcViewItem<View["id"], View["schema"]>>;
|
|
12
6
|
constructor(view: View, params: FindOptions<ArcViewItem<View["id"], View["schema"]>>);
|
|
13
|
-
protected fetch(store: StoreState<ArcViewItem<View["id"], View["schema"]>>): Promise<
|
|
7
|
+
protected fetch(store: StoreState<ArcViewItem<View["id"], View["schema"]>>): Promise<ArcViewItem<View["id"], View["schema"]> | undefined>;
|
|
14
8
|
protected checkItem(item: ArcViewItem<View["id"], View["schema"]>): boolean;
|
|
15
|
-
protected onChange(change: ListenerEvent<ArcViewItem<View["id"], View["schema"]>>): false |
|
|
16
|
-
protected createResult(result: ArcViewItem<View["id"], View["schema"]> | undefined):
|
|
9
|
+
protected onChange(change: ListenerEvent<ArcViewItem<View["id"], View["schema"]>>): false | ArcViewItem<View["id"], View["schema"]> | undefined;
|
|
10
|
+
protected createResult(result: ArcViewItem<View["id"], View["schema"]> | undefined): ArcViewItem<View["id"], View["schema"]> | undefined;
|
|
17
11
|
}
|
|
18
12
|
//# sourceMappingURL=find-one.d.ts.map
|
|
@@ -9,12 +9,12 @@ export declare class QueryViewResult<V extends ArcViewAny> {
|
|
|
9
9
|
map<U>(callbackfn: (value: ArcViewItem<V["id"], V["schema"]>, index: number, array: ArcViewItem<V["id"], V["schema"]>[]) => U): U[];
|
|
10
10
|
toArray(): ArcViewItem<V["id"], V["schema"]>[];
|
|
11
11
|
}
|
|
12
|
-
export declare class ArcViewFindQuery<View extends ArcViewAny> extends ArcViewQuery<View,
|
|
12
|
+
export declare class ArcViewFindQuery<View extends ArcViewAny> extends ArcViewQuery<View, ArcViewItem<View["id"], View["schema"]>[], FindOptions<ArcViewItem<View["id"], View["schema"]>>> {
|
|
13
13
|
protected params: FindOptions<ArcViewItem<View["id"], View["schema"]>>;
|
|
14
14
|
constructor(view: View, params: FindOptions<ArcViewItem<View["id"], View["schema"]>>);
|
|
15
|
-
protected fetch(store: StoreState<ArcViewItem<View["id"], View["schema"]>>): Promise<
|
|
15
|
+
protected fetch(store: StoreState<ArcViewItem<View["id"], View["schema"]>>): Promise<ArcViewItem<View["id"], View["schema"]>[]>;
|
|
16
16
|
protected checkItem(item: ArcViewItem<View["id"], View["schema"]>): boolean;
|
|
17
|
-
protected onChange(change: ListenerEvent<ArcViewItem<View["id"], View["schema"]>>): false |
|
|
18
|
-
protected createResult(result: ArcViewItem<View["id"], View["schema"]>[]):
|
|
17
|
+
protected onChange(change: ListenerEvent<ArcViewItem<View["id"], View["schema"]>>): false | ArcViewItem<View["id"], View["schema"]>[];
|
|
18
|
+
protected createResult(result: ArcViewItem<View["id"], View["schema"]>[]): ArcViewItem<View["id"], View["schema"]>[];
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=find.d.ts.map
|
|
@@ -7,7 +7,7 @@ export declare class ArcViewFindOneQueryBuilder<V extends ArcViewAny> {
|
|
|
7
7
|
protected queryContext: QueryBuilderContext;
|
|
8
8
|
protected options: FindOptions<ArcViewItem<V["id"], V["schema"]>>;
|
|
9
9
|
constructor(view: V, queryContext: QueryBuilderContext, options: FindOptions<ArcViewItem<V["id"], V["schema"]>>);
|
|
10
|
-
toQuery(): ArcViewFindOneQuery<
|
|
11
|
-
run():
|
|
10
|
+
toQuery(): ArcViewFindOneQuery<V>;
|
|
11
|
+
run(): ArcViewItem<V["id"], V["schema"]> | undefined;
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=find-one.d.ts.map
|
|
@@ -7,7 +7,7 @@ export declare class ArcViewFindQueryBuilder<V extends ArcViewAny> {
|
|
|
7
7
|
protected queryContext: QueryBuilderContext;
|
|
8
8
|
protected options: FindOptions<ArcViewItem<V["id"], V["schema"]>>;
|
|
9
9
|
constructor(view: V, queryContext: QueryBuilderContext, options: FindOptions<ArcViewItem<V["id"], V["schema"]>>);
|
|
10
|
-
toQuery(): ArcViewFindQuery<
|
|
11
|
-
run():
|
|
10
|
+
toQuery(): ArcViewFindQuery<V>;
|
|
11
|
+
run(): ArcViewItem<V["id"], V["schema"]>[];
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=find.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcote.tech/arc",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.5",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Przemysław Krasiński [arcote.tech]",
|
|
7
7
|
"description": "Arc is a framework designed to align code closely with business logic, streamlining development and enhancing productivity.",
|