wirejs-resources 0.1.9 → 0.1.10

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.
@@ -3,11 +3,11 @@ type ApiMethod = (...args: any) => any;
3
3
  type ApiNamespace = {
4
4
  [K in string]: ApiMethod | ApiNamespace;
5
5
  };
6
- type ContextfulApiMethod<T> = T extends ((...args: infer ARGS) => infer RT) ? ((context: Context | undefined | null, ...args: ARGS) => RT extends Promise<any> ? RT : Promise<RT>) : never;
7
- type ContextfulApiNamespace<T> = {
6
+ export type ContextfulApiMethod<T> = T extends ((...args: infer ARGS) => infer RT) ? ((context: Context | undefined | null, ...args: ARGS) => RT extends Promise<any> ? RT : Promise<RT>) : never;
7
+ export type ContextfulApiNamespace<T> = {
8
8
  [K in keyof T]: T[K] extends ApiMethod ? ContextfulApiMethod<T[K]> : ContextfulApiNamespace<T[K]>;
9
9
  };
10
- type ContextWrapped<T extends ApiNamespace | ApiMethod> = T extends ApiMethod ? ContextfulApiMethod<T> : ContextfulApiNamespace<T>;
10
+ export type ContextWrapped<T extends ApiNamespace | ApiMethod> = T extends ApiMethod ? ContextfulApiMethod<T> : ContextfulApiNamespace<T>;
11
11
  export declare function withContext<T extends ApiMethod | ApiNamespace>(contextWrapper: (context: Context) => T, path?: string[]): ContextWrapped<T>;
12
12
  export declare function requiresContext(fnOrNS: Object): fnOrNS is (context: Context) => any;
13
13
  export declare class Context {
@@ -13,12 +13,12 @@ export declare class AuthenticationService extends Resource {
13
13
  setMachineState(cookies: CookieJar, form: AuthenticationMachineInput): Promise<AuthenticationMachineState | {
14
14
  errors: AuthenticationError[];
15
15
  }>;
16
- buildApi(this: AuthenticationService): {
17
- getState: (context: import("../adapters/context.js").Context | undefined | null) => Promise<AuthenticationMachineState>;
18
- setState: (context: import("../adapters/context.js").Context | undefined | null, options: AuthenticationMachineInput) => Promise<AuthenticationMachineState | {
16
+ buildApi(this: AuthenticationService): import("../adapters/context.js").ContextfulApiNamespace<{
17
+ getState: () => Promise<AuthenticationMachineState>;
18
+ setState: (options: Parameters<(typeof this)["setMachineState"]>[1]) => Promise<AuthenticationMachineState | {
19
19
  errors: AuthenticationError[];
20
20
  }>;
21
- getCurrentUser: (context: import("../adapters/context.js").Context | undefined | null) => Promise<User | null>;
22
- requireCurrentUser: (context: import("../adapters/context.js").Context | undefined | null) => Promise<User>;
23
- };
21
+ getCurrentUser: () => Promise<User | null>;
22
+ requireCurrentUser: () => Promise<User>;
23
+ }>;
24
24
  }
@@ -163,7 +163,7 @@ class UserStore {
163
163
  }
164
164
  }
165
165
  async update(username, details) {
166
- await this.files.write(`byUsername/${username}`, JSON.stringify(details));
166
+ await this.files.write(`byUsername/${username}.json`, JSON.stringify(details));
167
167
  }
168
168
  async has(username) {
169
169
  const user = await this.get(username);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wirejs-resources",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Basic services and server-side resources for wirejs apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",