ketting 7.5.0 → 7.5.2

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/field.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare type Field = BooleanField | BasicStringField | DateTimeField | FileField | HiddenField | NumberField | SelectFieldSingle | SelectFieldMulti | RangeStringField | TextAreaField | TextField;
1
+ export type Field = BooleanField | BasicStringField | DateTimeField | FileField | HiddenField | NumberField | SelectFieldSingle | SelectFieldMulti | RangeStringField | TextAreaField | TextField;
2
2
  /**
3
3
  * A Field describes a single field in an action or form.
4
4
  *
@@ -83,7 +83,7 @@ interface NumberField extends RangeField<number> {
83
83
  * OptionsDataSource is a helper type that specifiess the different data
84
84
  * sources for lists of options.
85
85
  */
86
- export declare type OptionsDataSource = {
86
+ export type OptionsDataSource = {
87
87
  /**
88
88
  * Keys and values are labels and values.
89
89
  *
@@ -134,7 +134,7 @@ export declare type OptionsDataSource = {
134
134
  /**
135
135
  * Encodes a field that has a list of options a user can choose from.
136
136
  */
137
- declare type SelectFieldSingle = BaseField<string> & {
137
+ type SelectFieldSingle = BaseField<string> & {
138
138
  type: 'select';
139
139
  renderAs?: 'radio' | 'dropdown';
140
140
  multiple?: false;
@@ -142,7 +142,7 @@ declare type SelectFieldSingle = BaseField<string> & {
142
142
  /**
143
143
  * An options field where users can select more than 1 item
144
144
  */
145
- declare type SelectFieldMulti = BaseField<string> & {
145
+ type SelectFieldMulti = BaseField<string> & {
146
146
  type: 'select';
147
147
  renderAs?: 'checkbox' | 'dropdown';
148
148
  multiple: true;
@@ -1,5 +1,5 @@
1
1
  import './fetch-polyfill';
2
- export declare type FetchMiddleware = (request: Request, next: (request: Request) => Promise<Response>) => Promise<Response>;
2
+ export type FetchMiddleware = (request: Request, next: (request: Request) => Promise<Response>) => Promise<Response>;
3
3
  /**
4
4
  * The fetcher object is responsible for calling fetch()
5
5
  *
package/dist/link.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { LinkHints } from 'hal-types';
2
- export declare type Link = {
2
+ export type Link = {
3
3
  /**
4
4
  * Target URI
5
5
  */
@@ -46,7 +46,7 @@ export declare type Link = {
46
46
  */
47
47
  hints?: LinkHints;
48
48
  };
49
- declare type NewLink = Omit<Link, 'context'>;
49
+ type NewLink = Omit<Link, 'context'>;
50
50
  /**
51
51
  * Links container, providing an easy way to manage a set of links.
52
52
  */
@@ -103,7 +103,7 @@ export declare class LinkNotFound extends Error {
103
103
  /**
104
104
  * A key->value map of variables to place in a templated link
105
105
  */
106
- export declare type LinkVariables = {
106
+ export type LinkVariables = {
107
107
  [key: string]: string | number;
108
108
  };
109
109
  export {};
@@ -1,4 +1,4 @@
1
- export declare type Field = BooleanField | BasicStringField | DateTimeField | FileField | HiddenField | NumberField | SelectFieldSingle | SelectFieldMulti | RangeStringField | TextAreaField | TextField;
1
+ export type Field = BooleanField | BasicStringField | DateTimeField | FileField | HiddenField | NumberField | SelectFieldSingle | SelectFieldMulti | RangeStringField | TextAreaField | TextField;
2
2
  /**
3
3
  * A Field describes a single field in an action or form.
4
4
  *
@@ -83,7 +83,7 @@ interface NumberField extends RangeField<number> {
83
83
  * OptionsDataSource is a helper type that specifiess the different data
84
84
  * sources for lists of options.
85
85
  */
86
- export declare type OptionsDataSource = {
86
+ export type OptionsDataSource = {
87
87
  /**
88
88
  * Keys and values are labels and values.
89
89
  *
@@ -134,7 +134,7 @@ export declare type OptionsDataSource = {
134
134
  /**
135
135
  * Encodes a field that has a list of options a user can choose from.
136
136
  */
137
- declare type SelectFieldSingle = BaseField<string> & {
137
+ type SelectFieldSingle = BaseField<string> & {
138
138
  type: 'select';
139
139
  renderAs?: 'radio' | 'dropdown';
140
140
  multiple?: false;
@@ -142,7 +142,7 @@ declare type SelectFieldSingle = BaseField<string> & {
142
142
  /**
143
143
  * An options field where users can select more than 1 item
144
144
  */
145
- declare type SelectFieldMulti = BaseField<string> & {
145
+ type SelectFieldMulti = BaseField<string> & {
146
146
  type: 'select';
147
147
  renderAs?: 'checkbox' | 'dropdown';
148
148
  multiple: true;
@@ -1,5 +1,5 @@
1
1
  import './fetch-polyfill';
2
- export declare type FetchMiddleware = (request: Request, next: (request: Request) => Promise<Response>) => Promise<Response>;
2
+ export type FetchMiddleware = (request: Request, next: (request: Request) => Promise<Response>) => Promise<Response>;
3
3
  /**
4
4
  * The fetcher object is responsible for calling fetch()
5
5
  *
@@ -1,5 +1,5 @@
1
1
  import { LinkHints } from 'hal-types';
2
- export declare type Link = {
2
+ export type Link = {
3
3
  /**
4
4
  * Target URI
5
5
  */
@@ -46,7 +46,7 @@ export declare type Link = {
46
46
  */
47
47
  hints?: LinkHints;
48
48
  };
49
- declare type NewLink = Omit<Link, 'context'>;
49
+ type NewLink = Omit<Link, 'context'>;
50
50
  /**
51
51
  * Links container, providing an easy way to manage a set of links.
52
52
  */
@@ -103,7 +103,7 @@ export declare class LinkNotFound extends Error {
103
103
  /**
104
104
  * A key->value map of variables to place in a templated link
105
105
  */
106
- export declare type LinkVariables = {
106
+ export type LinkVariables = {
107
107
  [key: string]: string | number;
108
108
  };
109
109
  export {};
@@ -4,7 +4,7 @@ import { Links, LinkVariables } from '../link';
4
4
  import Client from '../client';
5
5
  import { Action, ActionInfo } from '../action';
6
6
  import { Resource } from '../resource';
7
- declare type HeadStateInit = {
7
+ type HeadStateInit = {
8
8
  client: Client;
9
9
  uri: string;
10
10
  links: Links;
@@ -13,7 +13,7 @@ declare type HeadStateInit = {
13
13
  */
14
14
  headers: Headers;
15
15
  };
16
- declare type StateInit<T> = {
16
+ type StateInit<T> = {
17
17
  client: Client;
18
18
  uri: string;
19
19
  data: T;
@@ -83,7 +83,7 @@ export declare class BaseState<T> extends BaseHeadState implements State<T> {
83
83
  * If no name is given, the first action is returned. This is useful for
84
84
  * formats that only supply 1 action, and no name.
85
85
  */
86
- action<TFormData = any>(name?: string): Action<TFormData>;
86
+ action<TFormData extends Record<string, any> = any>(name?: string): Action<TFormData>;
87
87
  /**
88
88
  * Returns all actions
89
89
  */
@@ -3,7 +3,7 @@ import { Action } from '../action';
3
3
  import { Links, LinkVariables } from '../link';
4
4
  import Client from '../client';
5
5
  import { Resource } from '../resource';
6
- export declare type State<T = any> = {
6
+ export type State<T = any> = {
7
7
  /**
8
8
  * The URI associated with this state
9
9
  */
@@ -46,7 +46,7 @@ export declare type State<T = any> = {
46
46
  *
47
47
  * If the format provides a default action, the name may be omitted.
48
48
  */
49
- action<TFormData = any>(name?: string): Action<TFormData>;
49
+ action<TFormData extends Record<string, any> = any>(name?: string): Action<TFormData>;
50
50
  /**
51
51
  * Returns all actions
52
52
  */
@@ -99,10 +99,10 @@ export declare type State<T = any> = {
99
99
  * Some information in HEAD responses might be available, but many aren't.
100
100
  * Notably, the body.
101
101
  */
102
- export declare type HeadState = Omit<State, 'data' | 'action' | 'actions' | 'hasAction' | 'serializeBody' | 'getEmbedded' | 'client' | 'clone'>;
102
+ export type HeadState = Omit<State, 'data' | 'action' | 'actions' | 'hasAction' | 'serializeBody' | 'getEmbedded' | 'client' | 'clone'>;
103
103
  /**
104
104
  * A 'StateFactory' is responsible for taking a Fetch Response, and returning
105
105
  * an object that impements the State interface
106
106
  */
107
- export declare type StateFactory<T = any> = (client: Client, uri: string, request: Response) => Promise<State<T>>;
107
+ export type StateFactory<T = any> = (client: Client, uri: string, request: Response) => Promise<State<T>>;
108
108
  export declare function isState(input: Record<string, any>): input is State;
@@ -8,14 +8,14 @@ export declare const factory: (client: Client, uri: string, response: Response)
8
8
  * A JSON:API link can either be a string, or an object with at least a href
9
9
  * property.
10
10
  */
11
- declare type JsonApiLink = string | {
11
+ type JsonApiLink = string | {
12
12
  href: string;
13
13
  };
14
14
  /**
15
15
  * This type is a full 'links' object, which might appear on the top level
16
16
  * or on resource objects.
17
17
  */
18
- declare type JsonApiLinksObject = {
18
+ type JsonApiLinksObject = {
19
19
  self?: JsonApiLink;
20
20
  profile?: JsonApiLink;
21
21
  [rel: string]: JsonApiLink | JsonApiLink[] | undefined;
@@ -24,7 +24,7 @@ declare type JsonApiLinksObject = {
24
24
  * This is a single JSON:API resource. Its type contains just the properties
25
25
  * we care about.
26
26
  */
27
- declare type JsonApiResource = {
27
+ type JsonApiResource = {
28
28
  type: string;
29
29
  id: string;
30
30
  links?: JsonApiLinksObject;
@@ -34,7 +34,7 @@ declare type JsonApiResource = {
34
34
  * in the links object at the moment, so everything else is (for now)
35
35
  * untyped.
36
36
  */
37
- declare type JsonApiTopLevelObject = {
37
+ type JsonApiTopLevelObject = {
38
38
  links?: JsonApiLinksObject;
39
39
  data: JsonApiResource | JsonApiResource[] | null;
40
40
  [s: string]: any;
@@ -1,12 +1,12 @@
1
1
  /// <reference types="node" />
2
- export declare type HttpHeaders = Record<string, string>;
2
+ export type HttpHeaders = Record<string, string>;
3
3
  /**
4
4
  * RequestOptions is a set of properties that define
5
5
  * a request, or state change.
6
6
  *
7
7
  * Everything is usually optional.
8
8
  */
9
- export declare type RequestOptions<T = any> = {
9
+ export type RequestOptions<T = any> = {
10
10
  /**
11
11
  * Should return a string or a Buffer.
12
12
  *
@@ -32,8 +32,8 @@ export declare type RequestOptions<T = any> = {
32
32
  */
33
33
  headers?: HttpHeaders | Headers;
34
34
  };
35
- export declare type GetRequestOptions = Omit<RequestOptions, 'serializeBody' | 'data'>;
36
- export declare type HeadRequestOptions = GetRequestOptions;
37
- export declare type PatchRequestOptions<T = any> = RequestOptions<T>;
38
- export declare type PutRequestOptions<T = any> = RequestOptions<T>;
39
- export declare type PostRequestOptions<T = any> = RequestOptions<T>;
35
+ export type GetRequestOptions = Omit<RequestOptions, 'serializeBody' | 'data'>;
36
+ export type HeadRequestOptions = GetRequestOptions;
37
+ export type PatchRequestOptions<T = any> = RequestOptions<T>;
38
+ export type PutRequestOptions<T = any> = RequestOptions<T>;
39
+ export type PostRequestOptions<T = any> = RequestOptions<T>;
@@ -1,12 +1,12 @@
1
1
  import { Link } from '../link';
2
- export declare type HtmlForm = {
2
+ export type HtmlForm = {
3
3
  action: string;
4
4
  method: string | null;
5
5
  enctype: string | null;
6
6
  rel: string | null;
7
7
  id: string | null;
8
8
  };
9
- declare type ParseHtmlResult = {
9
+ type ParseHtmlResult = {
10
10
  links: Link[];
11
11
  forms: HtmlForm[];
12
12
  };
@@ -1,12 +1,12 @@
1
1
  import { Link } from '../link';
2
- export declare type HtmlForm = {
2
+ export type HtmlForm = {
3
3
  action: string;
4
4
  method: string | null;
5
5
  enctype: string | null;
6
6
  rel: string | null;
7
7
  id: string | null;
8
8
  };
9
- declare type ParseHtmlResult = {
9
+ type ParseHtmlResult = {
10
10
  links: Link[];
11
11
  forms: HtmlForm[];
12
12
  };
@@ -1,5 +1,5 @@
1
1
  import { Link } from '../link';
2
- declare type UrlParts = {
2
+ type UrlParts = {
3
3
  host?: string | null;
4
4
  };
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { Link } from '../link';
2
- declare type UrlParts = {
2
+ type UrlParts = {
3
3
  host?: string;
4
4
  };
5
5
  /**
@@ -4,7 +4,7 @@ import { Links, LinkVariables } from '../link';
4
4
  import Client from '../client';
5
5
  import { Action, ActionInfo } from '../action';
6
6
  import { Resource } from '../resource';
7
- declare type HeadStateInit = {
7
+ type HeadStateInit = {
8
8
  client: Client;
9
9
  uri: string;
10
10
  links: Links;
@@ -13,7 +13,7 @@ declare type HeadStateInit = {
13
13
  */
14
14
  headers: Headers;
15
15
  };
16
- declare type StateInit<T> = {
16
+ type StateInit<T> = {
17
17
  client: Client;
18
18
  uri: string;
19
19
  data: T;
@@ -83,7 +83,7 @@ export declare class BaseState<T> extends BaseHeadState implements State<T> {
83
83
  * If no name is given, the first action is returned. This is useful for
84
84
  * formats that only supply 1 action, and no name.
85
85
  */
86
- action<TFormData = any>(name?: string): Action<TFormData>;
86
+ action<TFormData extends Record<string, any> = any>(name?: string): Action<TFormData>;
87
87
  /**
88
88
  * Returns all actions
89
89
  */
@@ -1 +1 @@
1
- {"version":3,"file":"base-state.js","sourceRoot":"","sources":["../../src/state/base-state.ts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G;IACH,SAAS,CAAC,IAAa;QAErB,IAAI,IAAI,KAAG,SAAS;YAAE,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,GAAC,CAAC,CAAC;QACtD,KAAI,MAAM,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE;YACnC,IAAI,IAAI,KAAK,MAAM,CAAC,IAAI,EAAE;gBACxB,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC;IAEf,CAAC;IAED;;;;;;OAMG;IACH,aAAa;QAEX,IACE,CAAE,MAAc,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,YAAY,MAAM,CAAC;YACvD,CAAE,MAAc,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,YAAY,IAAI,CAAC;YACnD,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAC/B;YACE,OAAO,IAAI,CAAC,IAAI,CAAC;SAClB;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEnC,CAAC;IAED;;;;;;;;OAQG;IACH,WAAW;QAET,OAAO,IAAI,CAAC,QAAQ,CAAC;IAEvB,CAAC;IAED,KAAK;QAEH,OAAO,IAAI,SAAS,CAAC;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;YAClC,KAAK,EAAE,IAAI,YAAK,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YAChE,OAAO,EAAE,IAAI,CAAC,UAAU;SACzB,CAAC,CAAC;IAEL,CAAC;CAEF;AAlHD,8BAkHC"}
package/dist/state/hal.js CHANGED
@@ -259,7 +259,7 @@ function parseHalField(halField) {
259
259
  value: halField.value,
260
260
  pattern: halField.regex ? new RegExp(halField.regex) : undefined,
261
261
  label: halField.prompt,
262
- placeholder: halField.placeHolder,
262
+ placeholder: halField.placeholder,
263
263
  minLength: halField.minLength,
264
264
  maxLength: halField.maxLength,
265
265
  };
@@ -272,7 +272,7 @@ function parseHalField(halField) {
272
272
  readOnly: halField.readOnly || false,
273
273
  value: halField.value,
274
274
  label: halField.prompt,
275
- placeholder: halField.placeHolder,
275
+ placeholder: halField.placeholder,
276
276
  };
277
277
  case 'textarea':
278
278
  return {
@@ -282,7 +282,7 @@ function parseHalField(halField) {
282
282
  readOnly: halField.readOnly || false,
283
283
  value: halField.value,
284
284
  label: halField.prompt,
285
- placeholder: halField.placeHolder,
285
+ placeholder: halField.placeholder,
286
286
  cols: halField.cols,
287
287
  rows: halField.rows,
288
288
  minLength: halField.minLength,
@@ -295,7 +295,7 @@ function parseHalField(halField) {
295
295
  required: halField.required || false,
296
296
  readOnly: halField.readOnly || false,
297
297
  label: halField.prompt,
298
- placeholder: halField.placeHolder,
298
+ placeholder: halField.placeholder,
299
299
  minLength: halField.minLength,
300
300
  maxLength: halField.maxLength,
301
301
  };
@@ -3,7 +3,7 @@ import { Action } from '../action';
3
3
  import { Links, LinkVariables } from '../link';
4
4
  import Client from '../client';
5
5
  import { Resource } from '../resource';
6
- export declare type State<T = any> = {
6
+ export type State<T = any> = {
7
7
  /**
8
8
  * The URI associated with this state
9
9
  */
@@ -46,7 +46,7 @@ export declare type State<T = any> = {
46
46
  *
47
47
  * If the format provides a default action, the name may be omitted.
48
48
  */
49
- action<TFormData = any>(name?: string): Action<TFormData>;
49
+ action<TFormData extends Record<string, any> = any>(name?: string): Action<TFormData>;
50
50
  /**
51
51
  * Returns all actions
52
52
  */
@@ -99,10 +99,10 @@ export declare type State<T = any> = {
99
99
  * Some information in HEAD responses might be available, but many aren't.
100
100
  * Notably, the body.
101
101
  */
102
- export declare type HeadState = Omit<State, 'data' | 'action' | 'actions' | 'hasAction' | 'serializeBody' | 'getEmbedded' | 'client' | 'clone'>;
102
+ export type HeadState = Omit<State, 'data' | 'action' | 'actions' | 'hasAction' | 'serializeBody' | 'getEmbedded' | 'client' | 'clone'>;
103
103
  /**
104
104
  * A 'StateFactory' is responsible for taking a Fetch Response, and returning
105
105
  * an object that impements the State interface
106
106
  */
107
- export declare type StateFactory<T = any> = (client: Client, uri: string, request: Response) => Promise<State<T>>;
107
+ export type StateFactory<T = any> = (client: Client, uri: string, request: Response) => Promise<State<T>>;
108
108
  export declare function isState(input: Record<string, any>): input is State;
@@ -8,14 +8,14 @@ export declare const factory: (client: Client, uri: string, response: Response)
8
8
  * A JSON:API link can either be a string, or an object with at least a href
9
9
  * property.
10
10
  */
11
- declare type JsonApiLink = string | {
11
+ type JsonApiLink = string | {
12
12
  href: string;
13
13
  };
14
14
  /**
15
15
  * This type is a full 'links' object, which might appear on the top level
16
16
  * or on resource objects.
17
17
  */
18
- declare type JsonApiLinksObject = {
18
+ type JsonApiLinksObject = {
19
19
  self?: JsonApiLink;
20
20
  profile?: JsonApiLink;
21
21
  [rel: string]: JsonApiLink | JsonApiLink[] | undefined;
@@ -24,7 +24,7 @@ declare type JsonApiLinksObject = {
24
24
  * This is a single JSON:API resource. Its type contains just the properties
25
25
  * we care about.
26
26
  */
27
- declare type JsonApiResource = {
27
+ type JsonApiResource = {
28
28
  type: string;
29
29
  id: string;
30
30
  links?: JsonApiLinksObject;
@@ -34,7 +34,7 @@ declare type JsonApiResource = {
34
34
  * in the links object at the moment, so everything else is (for now)
35
35
  * untyped.
36
36
  */
37
- declare type JsonApiTopLevelObject = {
37
+ type JsonApiTopLevelObject = {
38
38
  links?: JsonApiLinksObject;
39
39
  data: JsonApiResource | JsonApiResource[] | null;
40
40
  [s: string]: any;
package/dist/types.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /// <reference types="node" />
2
- export declare type HttpHeaders = Record<string, string>;
2
+ export type HttpHeaders = Record<string, string>;
3
3
  /**
4
4
  * RequestOptions is a set of properties that define
5
5
  * a request, or state change.
6
6
  *
7
7
  * Everything is usually optional.
8
8
  */
9
- export declare type RequestOptions<T = any> = {
9
+ export type RequestOptions<T = any> = {
10
10
  /**
11
11
  * Should return a string or a Buffer.
12
12
  *
@@ -32,8 +32,8 @@ export declare type RequestOptions<T = any> = {
32
32
  */
33
33
  headers?: HttpHeaders | Headers;
34
34
  };
35
- export declare type GetRequestOptions = Omit<RequestOptions, 'serializeBody' | 'data'>;
36
- export declare type HeadRequestOptions = GetRequestOptions;
37
- export declare type PatchRequestOptions<T = any> = RequestOptions<T>;
38
- export declare type PutRequestOptions<T = any> = RequestOptions<T>;
39
- export declare type PostRequestOptions<T = any> = RequestOptions<T>;
35
+ export type GetRequestOptions = Omit<RequestOptions, 'serializeBody' | 'data'>;
36
+ export type HeadRequestOptions = GetRequestOptions;
37
+ export type PatchRequestOptions<T = any> = RequestOptions<T>;
38
+ export type PutRequestOptions<T = any> = RequestOptions<T>;
39
+ export type PostRequestOptions<T = any> = RequestOptions<T>;
@@ -1,12 +1,12 @@
1
1
  import { Link } from '../link';
2
- export declare type HtmlForm = {
2
+ export type HtmlForm = {
3
3
  action: string;
4
4
  method: string | null;
5
5
  enctype: string | null;
6
6
  rel: string | null;
7
7
  id: string | null;
8
8
  };
9
- declare type ParseHtmlResult = {
9
+ type ParseHtmlResult = {
10
10
  links: Link[];
11
11
  forms: HtmlForm[];
12
12
  };
@@ -1,12 +1,12 @@
1
1
  import { Link } from '../link';
2
- export declare type HtmlForm = {
2
+ export type HtmlForm = {
3
3
  action: string;
4
4
  method: string | null;
5
5
  enctype: string | null;
6
6
  rel: string | null;
7
7
  id: string | null;
8
8
  };
9
- declare type ParseHtmlResult = {
9
+ type ParseHtmlResult = {
10
10
  links: Link[];
11
11
  forms: HtmlForm[];
12
12
  };
@@ -1,5 +1,5 @@
1
1
  import { Link } from '../link';
2
- declare type UrlParts = {
2
+ type UrlParts = {
3
3
  host?: string | null;
4
4
  };
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { Link } from '../link';
2
- declare type UrlParts = {
2
+ type UrlParts = {
3
3
  host?: string;
4
4
  };
5
5
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ketting",
3
- "version": "7.5.0",
3
+ "version": "7.5.2",
4
4
  "description": "Opiniated HATEAOS / Rest client.",
5
5
  "main": "dist/index.js",
6
6
  "browser": "browser/ketting.min.js",
@@ -163,7 +163,7 @@ export class BaseState<T> extends BaseHeadState implements State<T> {
163
163
  * If no name is given, the first action is returned. This is useful for
164
164
  * formats that only supply 1 action, and no name.
165
165
  */
166
- action<TFormData = any>(name?: string): Action<TFormData> {
166
+ action<TFormData extends Record<string, any> = any>(name?: string): Action<TFormData> {
167
167
 
168
168
  if (!this.actionInfo.length) {
169
169
  throw new ActionNotFound('This State does not define any actions');
package/src/state/hal.ts CHANGED
@@ -334,7 +334,7 @@ function parseHalField(halField: hal.HalFormsProperty): Field {
334
334
  value: halField.value,
335
335
  pattern: halField.regex ? new RegExp(halField.regex) : undefined,
336
336
  label: halField.prompt,
337
- placeholder: halField.placeHolder,
337
+ placeholder: halField.placeholder,
338
338
  minLength: halField.minLength,
339
339
  maxLength: halField.maxLength,
340
340
  };
@@ -347,7 +347,7 @@ function parseHalField(halField: hal.HalFormsProperty): Field {
347
347
  readOnly: halField.readOnly || false,
348
348
  value: halField.value,
349
349
  label: halField.prompt,
350
- placeholder: halField.placeHolder,
350
+ placeholder: halField.placeholder,
351
351
  };
352
352
  case 'textarea' :
353
353
  return {
@@ -357,7 +357,7 @@ function parseHalField(halField: hal.HalFormsProperty): Field {
357
357
  readOnly: halField.readOnly || false,
358
358
  value: halField.value,
359
359
  label: halField.prompt,
360
- placeholder: halField.placeHolder,
360
+ placeholder: halField.placeholder,
361
361
  cols: halField.cols,
362
362
  rows: halField.rows,
363
363
  minLength: halField.minLength,
@@ -370,7 +370,7 @@ function parseHalField(halField: hal.HalFormsProperty): Field {
370
370
  required: halField.required || false,
371
371
  readOnly: halField.readOnly || false,
372
372
  label: halField.prompt,
373
- placeholder: halField.placeHolder,
373
+ placeholder: halField.placeholder,
374
374
  minLength: halField.minLength,
375
375
  maxLength: halField.maxLength,
376
376
  };
@@ -54,7 +54,7 @@ export type State<T = any> = {
54
54
  *
55
55
  * If the format provides a default action, the name may be omitted.
56
56
  */
57
- action<TFormData = any>(name?: string): Action<TFormData>;
57
+ action<TFormData extends Record<string, any> = any>(name?: string): Action<TFormData>;
58
58
 
59
59
  /**
60
60
  * Returns all actions