@arcote.tech/arc 0.1.3 → 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.
@@ -14,9 +14,16 @@ export declare class ArcCommand<Name extends string, Params extends ArcObjectAny
14
14
  private _results?;
15
15
  private _elements?;
16
16
  private _handler?;
17
+ private _isPublic;
17
18
  constructor(name: Name);
18
19
  use<const E extends ArcContextElementAny[]>(elements: E): ArcCommand<Name, Params, Results, E>;
19
20
  description(description: string): ArcCommand<Name, Params, Results, Elements>;
21
+ public(): ArcCommand<Name, Params, Results, Elements>;
22
+ get isPublic(): boolean;
23
+ matchesCommandPath(pathname: string): {
24
+ matches: boolean;
25
+ isPublic: boolean;
26
+ };
20
27
  withParams<NewParams extends ArcRawShape>(schema: NewParams | ArcObject<NewParams>): ArcCommand<Name, ArcObject<NewParams>, Results, Elements>;
21
28
  withResult<NewResults extends ArcRawShape[]>(...schemas: NewResults): ArcCommand<Name, Params, { [K in keyof NewResults]: ArcObject<NewResults[K]>; }, Elements>;
22
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 (ArcContextElementAny | false | Promise<{
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
@@ -10,6 +10,7 @@ export type ListenerConfig = {
10
10
  export interface AuthContext {
11
11
  userId: string;
12
12
  roles: string[];
13
+ ipAddress?: string;
13
14
  }
14
15
  export type AuthorizationRestrictions = {
15
16
  default?: WhereCondition;
@@ -49,7 +50,7 @@ export type StoreSchema = {
49
50
  export declare abstract class ArcContextElement<const Event, const Name extends string | undefined = undefined> {
50
51
  readonly $event: Event;
51
52
  readonly name?: Name;
52
- queryBuilder?(queryContext: QueryBuilderContext, authContext: AuthContext): any;
53
+ queryBuilder?: (queryContext: QueryBuilderContext, authContext: AuthContext) => any;
53
54
  commandContext?: (dataStorage: DataStorage, publishEvent: PublishEventFunction, authContext: AuthContext) => any;
54
55
  commandClient?: (commandContext: any, authContext: AuthContext) => (...args: any[]) => any;
55
56
  observer?: (authContext: AuthContext) => Record<string, ListenerConfig>;
@@ -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
- occurredAt: string;
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
@@ -1,3 +1,4 @@
1
+ export * from "./any";
1
2
  export * from "./array";
2
3
  export * from "./blob";
3
4
  export * from "./boolean";
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from "./db";
6
6
  export * from "./elements";
7
7
  export * from "./listener";
8
8
  export * from "./model";
9
+ export * from "./route";
9
10
  export * from "./rtc";
10
11
  export * from "./state";
11
12
  export * from "./utils";
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?.toArray() || [];
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);
@@ -1281,6 +1300,7 @@ class ArcCommand extends ArcContextElement {
1281
1300
  _results;
1282
1301
  _elements;
1283
1302
  _handler;
1303
+ _isPublic = false;
1284
1304
  constructor(name) {
1285
1305
  super();
1286
1306
  this.name = name;
@@ -1295,6 +1315,24 @@ class ArcCommand extends ArcContextElement {
1295
1315
  clone._description = description;
1296
1316
  return clone;
1297
1317
  }
1318
+ public() {
1319
+ const clone = this.clone();
1320
+ clone._isPublic = true;
1321
+ return clone;
1322
+ }
1323
+ get isPublic() {
1324
+ return this._isPublic;
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
+ }
1298
1336
  withParams(schema) {
1299
1337
  const clone = this.clone();
1300
1338
  clone._params = schema instanceof ArcObject ? schema : object(schema);
@@ -1323,6 +1361,7 @@ class ArcCommand extends ArcContextElement {
1323
1361
  clone._results = this._results;
1324
1362
  clone._handler = this._handler;
1325
1363
  clone._elements = this._elements;
1364
+ clone._isPublic = this._isPublic;
1326
1365
  return clone;
1327
1366
  }
1328
1367
  }
@@ -1486,7 +1525,7 @@ class ArcEvent extends ArcContextElementWithStore {
1486
1525
  id: eventId.generate(),
1487
1526
  type: this.name,
1488
1527
  payload,
1489
- createdAt: new Date().toISOString()
1528
+ createdAt: new Date
1490
1529
  };
1491
1530
  await dataStorage.getStore("events").set(event);
1492
1531
  await publishEvent(event);
@@ -2485,6 +2524,40 @@ class Model extends ModelBase {
2485
2524
  }
2486
2525
  });
2487
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
+ }
2488
2561
  get $debug() {
2489
2562
  return {};
2490
2563
  }
@@ -2633,8 +2706,7 @@ class RemoteModelClient extends ModelBase {
2633
2706
  if (!response.ok) {
2634
2707
  throw new Error(`Query failed: ${response.statusText}`);
2635
2708
  }
2636
- const { result } = await response.json();
2637
- return result;
2709
+ return await response.json();
2638
2710
  }
2639
2711
  subscribe(queryBuilderFn, callback, authContext) {
2640
2712
  const result = this.query(queryBuilderFn, authContext);
@@ -2678,6 +2750,95 @@ class RemoteModelClient extends ModelBase {
2678
2750
  });
2679
2751
  return commandsProxy;
2680
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);
2681
2842
  }
2682
2843
  // rtc/client.ts
2683
2844
  class RTCClient {
@@ -2785,22 +2946,6 @@ class ArcViewQuery extends ArcSerializableQuery {
2785
2946
  }
2786
2947
 
2787
2948
  // view/queries/find.ts
2788
- class QueryViewResult {
2789
- result;
2790
- constructor(result) {
2791
- this.result = result;
2792
- }
2793
- get(id3) {
2794
- return id3 ? this.result.find((r) => r._id === id3) : undefined;
2795
- }
2796
- map(callbackfn) {
2797
- return this.result.map(callbackfn);
2798
- }
2799
- toArray() {
2800
- return this.result;
2801
- }
2802
- }
2803
-
2804
2949
  class ArcViewFindQuery extends ArcViewQuery {
2805
2950
  params;
2806
2951
  constructor(view, params) {
@@ -2847,7 +2992,7 @@ class ArcViewFindQuery extends ArcViewQuery {
2847
2992
  }
2848
2993
  onChange(change) {
2849
2994
  const lastResult = this.lastResult;
2850
- const lastResultAsArray = lastResult?.toArray() || [];
2995
+ const lastResultAsArray = lastResult || [];
2851
2996
  const index = lastResultAsArray.findIndex((e) => e._id === (change.type === "delete" ? change.id : change.id));
2852
2997
  const isInLastResult = index !== -1;
2853
2998
  const shouldBeInTheResult = change.type !== "delete" && this.checkItem(change.item);
@@ -2860,7 +3005,7 @@ class ArcViewFindQuery extends ArcViewQuery {
2860
3005
  return false;
2861
3006
  }
2862
3007
  createResult(result) {
2863
- return new QueryViewResult(result);
3008
+ return result;
2864
3009
  }
2865
3010
  }
2866
3011
 
@@ -2886,19 +3031,6 @@ class ArcViewFindQueryBuilder {
2886
3031
  }
2887
3032
 
2888
3033
  // view/queries/find-one.ts
2889
- class QueryViewFindOneResult {
2890
- result;
2891
- constructor(result) {
2892
- this.result = result;
2893
- }
2894
- get() {
2895
- return this.result;
2896
- }
2897
- exists() {
2898
- return this.result !== undefined;
2899
- }
2900
- }
2901
-
2902
3034
  class ArcViewFindOneQuery extends ArcViewQuery {
2903
3035
  params;
2904
3036
  constructor(view, params) {
@@ -2945,7 +3077,7 @@ class ArcViewFindOneQuery extends ArcViewQuery {
2945
3077
  }
2946
3078
  onChange(change) {
2947
3079
  const lastResult = this.lastResult;
2948
- const currentItem = lastResult?.get();
3080
+ const currentItem = lastResult;
2949
3081
  const itemId = change.type === "delete" ? change.id : change.id;
2950
3082
  const hasCurrentItem = currentItem !== undefined;
2951
3083
  const isCurrentItem = hasCurrentItem && currentItem._id === itemId;
@@ -2959,7 +3091,7 @@ class ArcViewFindOneQuery extends ArcViewQuery {
2959
3091
  return false;
2960
3092
  }
2961
3093
  createResult(result) {
2962
- return new QueryViewFindOneResult(result);
3094
+ return result;
2963
3095
  }
2964
3096
  }
2965
3097
 
@@ -3119,7 +3251,8 @@ class ArcView extends ArcContextElementWithStore {
3119
3251
  from,
3120
3252
  to
3121
3253
  });
3122
- }
3254
+ },
3255
+ $auth: authContext
3123
3256
  };
3124
3257
  await value(ctx, event3);
3125
3258
  },
@@ -3146,6 +3279,7 @@ export {
3146
3279
  stringEnum,
3147
3280
  string,
3148
3281
  rtcClientFactory,
3282
+ route,
3149
3283
  record,
3150
3284
  reactive,
3151
3285
  object,
@@ -3164,6 +3298,7 @@ export {
3164
3298
  boolean,
3165
3299
  blob,
3166
3300
  array,
3301
+ any,
3167
3302
  StoreState,
3168
3303
  SQLiteAdapter,
3169
3304
  RemoteModelClient,
@@ -3179,6 +3314,7 @@ export {
3179
3314
  ArcView,
3180
3315
  ArcStringEnum,
3181
3316
  ArcString,
3317
+ ArcRoute,
3182
3318
  ArcRecord,
3183
3319
  ArcQueryBuilder,
3184
3320
  ArcQuery,
@@ -3200,5 +3336,6 @@ export {
3200
3336
  ArcBranded,
3201
3337
  ArcBoolean,
3202
3338
  ArcBlob,
3203
- ArcArray
3339
+ ArcArray,
3340
+ ArcAny
3204
3341
  };
@@ -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,2 @@
1
+ export * from "./route";
2
+ //# sourceMappingURL=index.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 QueryViewFindOneResult<V extends ArcViewAny> {
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<QueryViewFindOneResult<View>>;
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 | QueryViewFindOneResult<View>;
16
- protected createResult(result: ArcViewItem<View["id"], View["schema"]> | undefined): QueryViewFindOneResult<View>;
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, QueryViewResult<View>, FindOptions<ArcViewItem<View["id"], View["schema"]>>> {
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<QueryViewResult<View>>;
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 | QueryViewResult<View>;
18
- protected createResult(result: ArcViewItem<View["id"], View["schema"]>[]): QueryViewResult<View>;
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<ArcViewAny>;
11
- run(): import("../queries/find-one").QueryViewFindOneResult<ArcViewAny>;
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<ArcViewAny>;
11
- run(): import("..").QueryViewResult<ArcViewAny>;
10
+ toQuery(): ArcViewFindQuery<V>;
11
+ run(): ArcViewItem<V["id"], V["schema"]>[];
12
12
  }
13
13
  //# sourceMappingURL=find.d.ts.map
@@ -13,6 +13,7 @@ type ArcViewHandlerContext<Id extends ArcIdAny, Schema extends ArcObjectAny> = {
13
13
  remove: (id: $type<Id>) => Promise<void>;
14
14
  find: (options: FindOptions<ArcViewItem<Id, Schema>>) => Promise<ArcViewItem<Id, Schema>[]>;
15
15
  findOne: (where: FindOptions<ArcViewItem<Id, Schema>>["where"]) => Promise<ArcViewItem<Id, Schema> | undefined>;
16
+ $auth: AuthContext;
16
17
  };
17
18
  type ArcViewItem<Id extends ArcIdAny, Schema extends ArcObjectAny> = {
18
19
  _id: $type<Id>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arcote.tech/arc",
3
3
  "type": "module",
4
- "version": "0.1.3",
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.",