@arcote.tech/arc 0.1.3 → 0.1.4

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,12 @@ 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;
20
23
  withParams<NewParams extends ArcRawShape>(schema: NewParams | ArcObject<NewParams>): ArcCommand<Name, ArcObject<NewParams>, Results, Elements>;
21
24
  withResult<NewResults extends ArcRawShape[]>(...schemas: NewResults): ArcCommand<Name, Params, { [K in keyof NewResults]: ArcObject<NewResults[K]>; }, Elements>;
22
25
  handle(handler: ArcCommmandHandler<Elements, Params, Results> | false): ArcCommand<Name, Params, Results, Elements>;
@@ -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;
package/dist/index.js CHANGED
@@ -1281,6 +1281,7 @@ class ArcCommand extends ArcContextElement {
1281
1281
  _results;
1282
1282
  _elements;
1283
1283
  _handler;
1284
+ _isPublic = false;
1284
1285
  constructor(name) {
1285
1286
  super();
1286
1287
  this.name = name;
@@ -1295,6 +1296,14 @@ class ArcCommand extends ArcContextElement {
1295
1296
  clone._description = description;
1296
1297
  return clone;
1297
1298
  }
1299
+ public() {
1300
+ const clone = this.clone();
1301
+ clone._isPublic = true;
1302
+ return clone;
1303
+ }
1304
+ get isPublic() {
1305
+ return this._isPublic;
1306
+ }
1298
1307
  withParams(schema) {
1299
1308
  const clone = this.clone();
1300
1309
  clone._params = schema instanceof ArcObject ? schema : object(schema);
@@ -1323,6 +1332,7 @@ class ArcCommand extends ArcContextElement {
1323
1332
  clone._results = this._results;
1324
1333
  clone._handler = this._handler;
1325
1334
  clone._elements = this._elements;
1335
+ clone._isPublic = this._isPublic;
1326
1336
  return clone;
1327
1337
  }
1328
1338
  }
@@ -3119,7 +3129,8 @@ class ArcView extends ArcContextElementWithStore {
3119
3129
  from,
3120
3130
  to
3121
3131
  });
3122
- }
3132
+ },
3133
+ $auth: authContext
3123
3134
  };
3124
3135
  await value(ctx, event3);
3125
3136
  },
@@ -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.4",
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.",