@venizia/ardor-kernel 0.4.8-0 → 0.4.8-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.
Files changed (102) hide show
  1. package/README.md +3 -1
  2. package/dist/base/applications/abstract.d.ts +17 -1
  3. package/dist/base/applications/abstract.js +7 -0
  4. package/dist/base/providers/base.d.ts +2 -0
  5. package/dist/base/providers/base.js +1 -0
  6. package/dist/base/services/auth.d.ts +11 -0
  7. package/dist/base/services/auth.js +8 -0
  8. package/dist/base/services/base.d.ts +1 -0
  9. package/dist/base/services/base.js +1 -0
  10. package/dist/base/services/network-request.d.ts +53 -2
  11. package/dist/base/services/network-request.js +72 -6
  12. package/dist/common/constants.d.ts +47 -0
  13. package/dist/common/constants.js +47 -0
  14. package/dist/common/keys.d.ts +16 -0
  15. package/dist/common/keys.js +16 -0
  16. package/dist/common/types.d.ts +86 -4
  17. package/dist/helpers/auth-token-store.d.ts +1 -0
  18. package/dist/helpers/auth-token-store.js +1 -0
  19. package/dist/helpers/networks/auth-recovery.d.ts +1 -0
  20. package/dist/helpers/networks/request-body-encoder.d.ts +1 -0
  21. package/dist/helpers/networks/request-body-encoder.js +1 -0
  22. package/dist/helpers/networks/response-reader.d.ts +8 -0
  23. package/dist/helpers/networks/response-reader.js +8 -0
  24. package/dist/utilities/browser-clipboard.d.ts +17 -0
  25. package/dist/utilities/browser-clipboard.js +37 -0
  26. package/dist/utilities/browser-storage.d.ts +30 -0
  27. package/dist/utilities/browser-storage.js +26 -0
  28. package/dist/utilities/browser.d.ts +2 -0
  29. package/dist/utilities/browser.js +2 -0
  30. package/dist/utilities/file.d.ts +1 -0
  31. package/dist/utilities/file.js +1 -0
  32. package/dist/utilities/index.d.ts +2 -0
  33. package/dist/utilities/index.js +2 -0
  34. package/dist/utilities/runtime-config.d.ts +4 -0
  35. package/dist/utilities/runtime-config.js +1 -0
  36. package/dist/utilities/storage-codecs.d.ts +9 -0
  37. package/dist/utilities/storage-codecs.js +19 -0
  38. package/dist/utilities/value.d.ts +3 -0
  39. package/dist/utilities/value.js +3 -0
  40. package/package.json +14 -13
  41. package/dist/base/applications/abstract.d.ts.map +0 -1
  42. package/dist/base/applications/abstract.js.map +0 -1
  43. package/dist/base/applications/index.d.ts.map +0 -1
  44. package/dist/base/applications/index.js.map +0 -1
  45. package/dist/base/decorators/api.d.ts.map +0 -1
  46. package/dist/base/decorators/api.js.map +0 -1
  47. package/dist/base/decorators/index.d.ts.map +0 -1
  48. package/dist/base/decorators/index.js.map +0 -1
  49. package/dist/base/index.d.ts.map +0 -1
  50. package/dist/base/index.js.map +0 -1
  51. package/dist/base/metadata/index.d.ts.map +0 -1
  52. package/dist/base/metadata/index.js.map +0 -1
  53. package/dist/base/providers/base.d.ts.map +0 -1
  54. package/dist/base/providers/base.js.map +0 -1
  55. package/dist/base/providers/index.d.ts.map +0 -1
  56. package/dist/base/providers/index.js.map +0 -1
  57. package/dist/base/repositories/index.d.ts.map +0 -1
  58. package/dist/base/repositories/index.js.map +0 -1
  59. package/dist/base/services/auth.d.ts.map +0 -1
  60. package/dist/base/services/auth.js.map +0 -1
  61. package/dist/base/services/base.d.ts.map +0 -1
  62. package/dist/base/services/base.js.map +0 -1
  63. package/dist/base/services/index.d.ts.map +0 -1
  64. package/dist/base/services/index.js.map +0 -1
  65. package/dist/base/services/network-request.d.ts.map +0 -1
  66. package/dist/base/services/network-request.js.map +0 -1
  67. package/dist/common/constants.d.ts.map +0 -1
  68. package/dist/common/constants.js.map +0 -1
  69. package/dist/common/index.d.ts.map +0 -1
  70. package/dist/common/index.js.map +0 -1
  71. package/dist/common/keys.d.ts.map +0 -1
  72. package/dist/common/keys.js.map +0 -1
  73. package/dist/common/types.d.ts.map +0 -1
  74. package/dist/common/types.js.map +0 -1
  75. package/dist/helpers/auth-token-store.d.ts.map +0 -1
  76. package/dist/helpers/auth-token-store.js.map +0 -1
  77. package/dist/helpers/index.d.ts.map +0 -1
  78. package/dist/helpers/index.js.map +0 -1
  79. package/dist/helpers/networks/auth-recovery.d.ts.map +0 -1
  80. package/dist/helpers/networks/auth-recovery.js.map +0 -1
  81. package/dist/helpers/networks/headers.d.ts.map +0 -1
  82. package/dist/helpers/networks/headers.js.map +0 -1
  83. package/dist/helpers/networks/index.d.ts.map +0 -1
  84. package/dist/helpers/networks/index.js.map +0 -1
  85. package/dist/helpers/networks/request-body-encoder.d.ts.map +0 -1
  86. package/dist/helpers/networks/request-body-encoder.js.map +0 -1
  87. package/dist/helpers/networks/response-reader.d.ts.map +0 -1
  88. package/dist/helpers/networks/response-reader.js.map +0 -1
  89. package/dist/index.d.ts.map +0 -1
  90. package/dist/index.js.map +0 -1
  91. package/dist/utilities/browser-storage.d.ts.map +0 -1
  92. package/dist/utilities/browser-storage.js.map +0 -1
  93. package/dist/utilities/browser.d.ts.map +0 -1
  94. package/dist/utilities/browser.js.map +0 -1
  95. package/dist/utilities/file.d.ts.map +0 -1
  96. package/dist/utilities/file.js.map +0 -1
  97. package/dist/utilities/index.d.ts.map +0 -1
  98. package/dist/utilities/index.js.map +0 -1
  99. package/dist/utilities/runtime-config.d.ts.map +0 -1
  100. package/dist/utilities/runtime-config.js.map +0 -1
  101. package/dist/utilities/value.d.ts.map +0 -1
  102. package/dist/utilities/value.js.map +0 -1
@@ -1,23 +1,33 @@
1
+ /** Values of the running environment, read once when the module loads. */
1
2
  export class App {
3
+ /** The IANA name of the timezone of the runtime. */
2
4
  static { this.TIMEZONE = Intl.DateTimeFormat().resolvedOptions().timeZone; }
5
+ /** The offset from UTC in hours, positive east of UTC (the opposite sign of `getTimezoneOffset()`). */
3
6
  static { this.TIMEZONE_OFFSET = -(new Date().getTimezoneOffset() / 60); }
7
+ /** In milliseconds. */
4
8
  static { this.DEFAULT_DEBOUNCE_TIME = 500; }
5
9
  }
10
+ /** Authorization schemes (`Basic`, `Bearer`) and strategies (`basic`, `jwt`). */
6
11
  export class Authentication {
12
+ /** The scheme in the `authorization` header. */
7
13
  static { this.TYPE_BASIC = 'Basic'; }
8
14
  static { this.TYPE_BEARER = 'Bearer'; }
15
+ /** The name of the auth strategy. */
9
16
  static { this.STRATEGY_BASIC = 'basic'; }
10
17
  static { this.STRATEGY_JWT = 'jwt'; }
18
+ /** Every value of this class that `isValid` accepts. */
11
19
  static { this.SCHEME_SET = new Set([
12
20
  this.TYPE_BASIC,
13
21
  this.TYPE_BEARER,
14
22
  this.STRATEGY_BASIC,
15
23
  this.STRATEGY_JWT,
16
24
  ]); }
25
+ /** Whether `value` is in `SCHEME_SET`. */
17
26
  static isValid(value) {
18
27
  return this.SCHEME_SET.has(value);
19
28
  }
20
29
  }
30
+ /** HTTP methods. */
21
31
  export class RequestMethods {
22
32
  static { this.HEAD = 'HEAD'; }
23
33
  static { this.OPTIONS = 'OPTIONS'; }
@@ -26,6 +36,7 @@ export class RequestMethods {
26
36
  static { this.PUT = 'PUT'; }
27
37
  static { this.PATCH = 'PATCH'; }
28
38
  static { this.DELETE = 'DELETE'; }
39
+ /** Every value of this class that `isValid` accepts. */
29
40
  static { this.SCHEME_SET = new Set([
30
41
  this.HEAD,
31
42
  this.OPTIONS,
@@ -35,11 +46,14 @@ export class RequestMethods {
35
46
  this.PATCH,
36
47
  this.DELETE,
37
48
  ]); }
49
+ /** Whether `value` is in `SCHEME_SET`. */
38
50
  static isValid(value) {
39
51
  return this.SCHEME_SET.has(value);
40
52
  }
41
53
  }
54
+ /** What a request is for, which decides how its response is read: `SEND`, and react-admin's data provider calls. */
42
55
  export class RequestTypes {
56
+ /** A request that is not a react-admin call. */
43
57
  static { this.SEND = 'SEND'; }
44
58
  // react-admin
45
59
  static { this.GET_LIST = 'GET_LIST'; }
@@ -51,6 +65,7 @@ export class RequestTypes {
51
65
  static { this.UPDATE_MANY = 'UPDATE_MANY'; }
52
66
  static { this.DELETE = 'DELETE'; }
53
67
  static { this.DELETE_MANY = 'DELETE_MANY'; }
68
+ /** Every value of this class that `isValid` accepts. */
54
69
  static { this.SCHEME_SET = new Set([
55
70
  this.SEND,
56
71
  this.GET_ONE,
@@ -63,20 +78,27 @@ export class RequestTypes {
63
78
  this.DELETE,
64
79
  this.DELETE_MANY,
65
80
  ]); }
81
+ /** Whether `value` is in `SCHEME_SET`. */
66
82
  static isValid(value) {
67
83
  return this.SCHEME_SET.has(value);
68
84
  }
69
85
  }
86
+ /** The Web Storage areas `BrowserStorage` reads and writes. */
70
87
  export class StorageAreas {
88
+ /** `localStorage`. */
71
89
  static { this.LOCAL = 'local'; }
90
+ /** `sessionStorage`. */
72
91
  static { this.SESSION = 'session'; }
73
92
  }
93
+ /** How a request body is encoded; see `RequestBodyEncoder`. */
74
94
  export class RequestBodyTypes {
95
+ /** The body goes through as it is. */
75
96
  static { this.NONE = 'none'; }
76
97
  static { this.FORM_DATA = 'form-data'; }
77
98
  static { this.FORM_URL_ENCODED = 'x-www-form-urlencoded'; }
78
99
  static { this.JSON = 'json'; }
79
100
  static { this.BINARY = 'binary'; }
101
+ /** Every value of this class that `isValid` accepts. */
80
102
  static { this.SCHEME_SET = new Set([
81
103
  this.NONE,
82
104
  this.FORM_DATA,
@@ -84,19 +106,25 @@ export class RequestBodyTypes {
84
106
  this.JSON,
85
107
  this.BINARY,
86
108
  ]); }
109
+ /** Whether `value` is in `SCHEME_SET`. */
87
110
  static isValid(value) {
88
111
  return this.SCHEME_SET.has(value);
89
112
  }
90
113
  }
114
+ /** Names of the build environments. */
91
115
  export class Environments {
92
116
  static { this.DEVELOPMENT = 'development'; }
93
117
  static { this.PRODUCTION = 'production'; }
118
+ /** Every value of this class that `isValid` accepts. */
94
119
  static { this.SCHEME_SET = new Set([this.DEVELOPMENT, this.PRODUCTION]); }
120
+ /** Whether `value` is in `SCHEME_SET`. */
95
121
  static isValid(value) {
96
122
  return this.SCHEME_SET.has(value);
97
123
  }
98
124
  }
125
+ /** Header names, lowercase, and patterns on header values. */
99
126
  export class HeaderConstants {
127
+ /** The header on a request body and on a response. */
100
128
  static { this.CONTENT_TYPE = 'content-type'; }
101
129
  /**
102
130
  * content-range: <unit> <range-start>-<range-end>/<size>
@@ -104,27 +132,44 @@ export class HeaderConstants {
104
132
  * The positions are zero-indexed, the end inclusive; the total is `*` if unknown.
105
133
  */
106
134
  static { this.CONTENT_RANGE = 'content-range'; }
135
+ /** Names the file of a file response. */
107
136
  static { this.CONTENT_DISPOSITION = 'content-disposition'; }
137
+ /** Carries `<type> <token>`. */
108
138
  static { this.AUTHORIZATION = 'authorization'; }
139
+ /** Names the provider of the token; sent only when the token names one. */
109
140
  static { this.X_AUTH_PROVIDER = 'x-auth-provider'; }
141
+ /** The locale of the request, the header `useRequestHeaderLocale` sets by default. */
110
142
  static { this.X_LOCALE = 'x-locale'; }
111
143
  // Lowercase: the service keys its header record by lowercased name.
144
+ /** Carries `App.TIMEZONE`. */
112
145
  static { this.TIMEZONE = 'timezone'; }
146
+ /** Carries `App.TIMEZONE_OFFSET`, in hours. */
113
147
  static { this.TIMEZONE_OFFSET = 'timezone-offset'; }
148
+ /** Carries the tracing id of a request. */
114
149
  static { this.REQUEST_TRACING_ID = 'x-request-id'; }
150
+ /** Carries a `RequestChannel` value. */
115
151
  static { this.REQUEST_CHANNEL = 'x-request-channel'; }
152
+ /** Carries a `RequestCountData` value: what the request asks the server to return. */
116
153
  static { this.REQUEST_COUNT_DATA = 'x-request-count'; }
154
+ /** Carries the count a server sends with a response that is not a list. */
117
155
  static { this.RESPONSE_COUNT_DATA = 'x-response-count'; }
156
+ /** Content types read as text. */
118
157
  static { this.TEXTUAL_CONTENT_TYPE_RE = /^(application\/(json|.*\+json|xml|.*\+xml|x-www-form-urlencoded|javascript|graphql)|text\/)/i; }
158
+ /** A `content-disposition` that marks a file download. */
119
159
  static { this.ATTACHMENT_CONTENT_DISPOSITION_RE = /^attachment/i; }
120
160
  }
161
+ /** The channels a request says it comes from, sent in `x-request-channel`. */
121
162
  export class RequestChannel {
163
+ /** A browser application; what a request says unless `requestTracingChannel` is set. */
122
164
  static { this.WEB = '100_WEB'; }
165
+ /** Every value of this class that `isValid` accepts. */
123
166
  static { this.SCHEME_SET = new Set([this.WEB]); }
167
+ /** Whether `value` is in `SCHEME_SET`. */
124
168
  static isValid(value) {
125
169
  return this.SCHEME_SET.has(value);
126
170
  }
127
171
  }
172
+ /** Whether a response carries a count, sent in `x-request-count`. */
128
173
  export class RequestCountData {
129
174
  /**
130
175
  * @description Only the data is returned in the response body
@@ -134,7 +179,9 @@ export class RequestCountData {
134
179
  * @description Both data and count are returned in the response body
135
180
  */
136
181
  static { this.DATA_WITH_COUNT = '1'; }
182
+ /** Every value of this class that `isValid` accepts. */
137
183
  static { this.SCHEME_SET = new Set([this.DATA_ONLY, this.DATA_WITH_COUNT]); }
184
+ /** Whether `value` is in `SCHEME_SET`. */
138
185
  static isValid(value) {
139
186
  return this.SCHEME_SET.has(value);
140
187
  }
@@ -1,27 +1,43 @@
1
+ /** The container keys the kernel binds and reads. */
1
2
  export declare class CoreBindings {
3
+ /** The application itself, bound by `preConfigure`. */
2
4
  static readonly APPLICATION_INSTANCE = "@app/application/instance";
5
+ /** The `IApplicationInfo`, bound by `preConfigure`. */
3
6
  static readonly APPLICATION_INFO = "@app/application/info";
7
+ /** The auth provider. */
4
8
  static readonly DEFAULT_AUTH_PROVIDER = "@app/application/auth/default";
9
+ /** The i18n provider. */
5
10
  static readonly DEFAULT_I18N_PROVIDER = "@app/application/i18n/default";
11
+ /** The REST data provider. */
6
12
  static readonly DEFAULT_REST_DATA_PROVIDER = "@app/application/data/rest/default";
13
+ /** The `IAuthProviderOptions`. */
7
14
  static readonly AUTH_PROVIDER_OPTIONS = "@app/application/options/auth";
15
+ /** The `DefaultAuthService`. */
8
16
  static readonly DEFAULT_AUTH_SERVICE = "@app/application/service/auth/default";
17
+ /** The `IRestDataProviderOptions`. */
9
18
  static readonly REST_DATA_PROVIDER_OPTIONS = "@app/application/options/rest/data";
19
+ /** The options of the i18n provider. */
10
20
  static readonly I18N_PROVIDER_OPTIONS = "@app/application/options/i18n";
11
21
  /** The `features()` an application mounts, bound by `preConfigure()`. */
12
22
  static readonly FEATURES = "@app/application/features";
13
23
  /** An `IPermissionProvider`, bound by the application; unbound means every check passes. */
14
24
  static readonly PERMISSION_PROVIDER = "@app/application/permission/provider";
15
25
  }
26
+ /** The `localStorage` keys the kernel owns. */
16
27
  export declare class LocalStorageKeys {
17
28
  /** Everything under this prefix is the session: `DefaultAuthService.cleanUp` removes it all. */
18
29
  static readonly PREFIX_AUTH = "@app/auth/";
19
30
  /** The namespace `BrowserStorage` recommends for the keys of an application. */
20
31
  static readonly PREFIX_STORE = "@app/store/";
32
+ /** The stored `IAuthTokenRecord`, as JSON. */
21
33
  static readonly KEY_AUTH_TOKEN = "@app/auth/token";
34
+ /** The stored identity (`userId`, `username`, `referenceId`, `provider`), as JSON. */
22
35
  static readonly KEY_AUTH_IDENTITY = "@app/auth/identity";
36
+ /** The stored roles, as a JSON array of names. */
23
37
  static readonly KEY_AUTH_PERMISSION = "@app/auth/permission";
38
+ /** The three session keys. */
24
39
  static readonly SCHEME_SET: Set<string>;
40
+ /** Whether `value` is a session key in `SCHEME_SET`. */
25
41
  static isValid(value: string): boolean;
26
42
  }
27
43
  //# sourceMappingURL=keys.d.ts.map
@@ -1,31 +1,47 @@
1
+ /** The container keys the kernel binds and reads. */
1
2
  export class CoreBindings {
3
+ /** The application itself, bound by `preConfigure`. */
2
4
  static { this.APPLICATION_INSTANCE = '@app/application/instance'; }
5
+ /** The `IApplicationInfo`, bound by `preConfigure`. */
3
6
  static { this.APPLICATION_INFO = '@app/application/info'; }
7
+ /** The auth provider. */
4
8
  static { this.DEFAULT_AUTH_PROVIDER = '@app/application/auth/default'; }
9
+ /** The i18n provider. */
5
10
  static { this.DEFAULT_I18N_PROVIDER = '@app/application/i18n/default'; }
11
+ /** The REST data provider. */
6
12
  static { this.DEFAULT_REST_DATA_PROVIDER = '@app/application/data/rest/default'; }
13
+ /** The `IAuthProviderOptions`. */
7
14
  static { this.AUTH_PROVIDER_OPTIONS = '@app/application/options/auth'; }
15
+ /** The `DefaultAuthService`. */
8
16
  static { this.DEFAULT_AUTH_SERVICE = '@app/application/service/auth/default'; }
17
+ /** The `IRestDataProviderOptions`. */
9
18
  static { this.REST_DATA_PROVIDER_OPTIONS = '@app/application/options/rest/data'; }
19
+ /** The options of the i18n provider. */
10
20
  static { this.I18N_PROVIDER_OPTIONS = '@app/application/options/i18n'; }
11
21
  /** The `features()` an application mounts, bound by `preConfigure()`. */
12
22
  static { this.FEATURES = '@app/application/features'; }
13
23
  /** An `IPermissionProvider`, bound by the application; unbound means every check passes. */
14
24
  static { this.PERMISSION_PROVIDER = '@app/application/permission/provider'; }
15
25
  }
26
+ /** The `localStorage` keys the kernel owns. */
16
27
  export class LocalStorageKeys {
17
28
  /** Everything under this prefix is the session: `DefaultAuthService.cleanUp` removes it all. */
18
29
  static { this.PREFIX_AUTH = '@app/auth/'; }
19
30
  /** The namespace `BrowserStorage` recommends for the keys of an application. */
20
31
  static { this.PREFIX_STORE = '@app/store/'; }
32
+ /** The stored `IAuthTokenRecord`, as JSON. */
21
33
  static { this.KEY_AUTH_TOKEN = '@app/auth/token'; }
34
+ /** The stored identity (`userId`, `username`, `referenceId`, `provider`), as JSON. */
22
35
  static { this.KEY_AUTH_IDENTITY = '@app/auth/identity'; }
36
+ /** The stored roles, as a JSON array of names. */
23
37
  static { this.KEY_AUTH_PERMISSION = '@app/auth/permission'; }
38
+ /** The three session keys. */
24
39
  static { this.SCHEME_SET = new Set([
25
40
  this.KEY_AUTH_TOKEN,
26
41
  this.KEY_AUTH_IDENTITY,
27
42
  this.KEY_AUTH_PERMISSION,
28
43
  ]); }
44
+ /** Whether `value` is a session key in `SCHEME_SET`. */
29
45
  static isValid(value) {
30
46
  return this.SCHEME_SET.has(value);
31
47
  }
@@ -3,41 +3,67 @@ import type { TBuildInfoRecord } from '@venizia/ignis-helpers/core';
3
3
  import type { TClass } from '@venizia/ignis-inversion';
4
4
  import type { TExtraRequest } from '@venizia/ignis-kernel/repository';
5
5
  import type { Environments, RequestBodyTypes, RequestCountData, RequestMethods, RequestTypes, StorageAreas } from './constants.js';
6
+ /** A record id: a string or a number. */
6
7
  export type IdType = string | number;
7
8
  export type { AnyObject, AnyType, TConstValue, TNumberConstValue, TPrettify, TStringConstValue, ValueOf, ValueOptional, ValueOptionalExcept, ValueOrPromise, };
9
+ /** One of the `RequestMethods` values. */
8
10
  export type TRequestMethod = TStringConstValue<typeof RequestMethods>;
11
+ /** One of the `Environments` values. */
9
12
  export type TEnvironment = TStringConstValue<typeof Environments>;
13
+ /** What `IDataProvider.send` takes. */
10
14
  export interface ISendParams {
15
+ /** Required: `send` throws without it. */
11
16
  method?: TRequestMethod;
17
+ /** How the response is read. `RequestTypes.SEND` when absent. */
12
18
  requestType?: TRequestType;
19
+ /** How `body` is encoded; it goes through as JSON when absent. */
13
20
  bodyType?: TRequestBodyType;
14
21
  body?: unknown;
22
+ /** Sent as the query string of the request. */
15
23
  query?: Record<string, unknown>;
24
+ /** Added to the headers of this request. */
16
25
  headers?: Record<string, string | number>;
26
+ /**
27
+ * Whether the response carries a count; sent in `x-request-count`.
28
+ * @default RequestCountData.DATA_ONLY
29
+ */
17
30
  requestCountData?: TConstValue<typeof RequestCountData>;
18
31
  /** The list extras to ask the route for, sent in `x-request-extra`. */
19
32
  extra?: TExtraRequest;
20
33
  }
21
34
  /** What `IDataProvider.send` answers: the network service's response. */
22
35
  export type ISendResponse<T = unknown> = INetworkResponse<T>;
36
+ /** One of the `RequestBodyTypes` values. */
23
37
  export type TRequestBodyType = TStringConstValue<typeof RequestBodyTypes>;
38
+ /** One of the `StorageAreas` values. */
24
39
  export type TStorageArea = TStringConstValue<typeof StorageAreas>;
25
40
  /** How `BrowserStorage` turns a value into text and back. `decode` may throw: `get` then gives the fallback. */
26
41
  export interface IStorageCodec<TValue> {
27
42
  encode: (value: TValue) => string;
28
43
  decode: (text: string) => TValue;
29
44
  }
45
+ /** One of the `RequestTypes` values. */
30
46
  export type TRequestType = TStringConstValue<typeof RequestTypes>;
47
+ /** What `DefaultNetworkRequestService.getRequestProps` takes. */
31
48
  export interface IGetRequestPropsParams {
49
+ /** Decides whether the request goes without a token (`noAuthPaths`, `noAuthPathRegex`). */
32
50
  resource: string;
51
+ /**
52
+ * Whether the response carries a count.
53
+ * @default RequestCountData.DATA_ONLY
54
+ */
33
55
  requestCountData?: TConstValue<typeof RequestCountData>;
34
56
  body?: unknown;
57
+ /** How `body` is encoded. */
35
58
  bodyType?: TRequestBodyType;
59
+ /** Gives the request channel. */
36
60
  restDataProviderOptions: IRestDataProviderOptions;
61
+ /** Gives the name the tracing id starts with. */
37
62
  applicationInfo: IApplicationInfo;
38
63
  /** The list extras to ask the route for, sent in `x-request-extra`. */
39
64
  extra?: TExtraRequest;
40
65
  }
66
+ /** The headers and the encoded body of a request. */
41
67
  export interface IGetRequestPropsResult {
42
68
  headers?: HeadersInit;
43
69
  body?: unknown;
@@ -59,18 +85,47 @@ export interface ISignInSession {
59
85
  /** Data only: where the auth provider talks to. Behaviour is in `DefaultAuthProvider`'s protected hooks. */
60
86
  export interface IAuthProviderOptions {
61
87
  paths?: {
62
- /** Where `login` posts. Default `/auth/sign-in`, the IGNIS auth controller's route. */
88
+ /**
89
+ * Where `login` posts: the IGNIS auth controller's route.
90
+ * @default '/auth/sign-in'
91
+ */
63
92
  signIn?: string;
64
93
  /** Where `checkAuth` validates the stored token. Default: not called; the stored token is enough. */
65
94
  checkAuth?: string;
66
- /** Where the admin goes once `login` resolves. Default `/`. */
95
+ /**
96
+ * Where the admin goes once `login` resolves.
97
+ * @default '/'
98
+ */
67
99
  afterLogin?: string;
68
100
  };
69
101
  }
102
+ /** How a request recovers from a 401. */
70
103
  export interface IAuthRecoveryOptions {
71
- /** A request to this path never starts a refresh: it is the refresh. */
104
+ /**
105
+ * A request to this path never starts a refresh: it is the refresh. Listing it in `noAuthPaths`
106
+ * as well keeps the expired token off that request.
107
+ * @example
108
+ * ```ts
109
+ * import { configuration, CoreBindings, provide } from '@venizia/ardor';
110
+ *
111
+ * @configuration()
112
+ * export class ApiConfiguration {
113
+ * @provide({ key: CoreBindings.REST_DATA_PROVIDER_OPTIONS })
114
+ * restDataProviderOptions() {
115
+ * return {
116
+ * url: 'https://api.example.com',
117
+ * // The refresh path is also a no-auth path: the expired token stays off that request, so the
118
+ * // server identifies the session another way, such as a cookie.
119
+ * noAuthPaths: ['/auth/sign-in', '/auth/refresh'],
120
+ * authRecovery: { refreshTokenPath: '/auth/refresh' },
121
+ * };
122
+ * }
123
+ * }
124
+ * ```
125
+ */
72
126
  refreshTokenPath?: string;
73
127
  }
128
+ /** One pattern or a list; a string is compiled with `new RegExp(...)`. */
74
129
  export type TNoAuthPathRegex = string | RegExp | Array<string | RegExp>;
75
130
  /**
76
131
  * Data only. A request that matches goes without an `Authorization` header; to send none at all (an
@@ -87,14 +142,23 @@ export interface INoAuthOptions {
87
142
  */
88
143
  noAuthPathRegex?: TNoAuthPathRegex;
89
144
  }
145
+ /** Data only: where and how the REST data provider sends. */
90
146
  export interface IRestDataProviderOptions extends INoAuthOptions {
147
+ /** The base URL requests are sent to. */
91
148
  url: string;
92
- /** Sent in `x-request-channel`. Default `RequestChannel.WEB`. */
149
+ /**
150
+ * Sent in `x-request-channel`.
151
+ * @default RequestChannel.WEB
152
+ */
93
153
  requestTracingChannel?: string;
154
+ /** Sent with every request. */
94
155
  headers?: HeadersInit;
156
+ /** Enables the refresh-and-retry after a 401. */
95
157
  authRecovery?: IAuthRecoveryOptions;
96
158
  }
159
+ /** The token an application is signed in with. */
97
160
  export interface IAuthTokenRecord {
161
+ /** The authorization scheme; the service sends `Bearer` when it is empty or absent. */
98
162
  type?: string;
99
163
  value: string;
100
164
  provider?: string;
@@ -116,7 +180,9 @@ export interface IDataSourceAuth {
116
180
  }
117
181
  /** What `DefaultNetworkRequestService.doRequest` answers. */
118
182
  export interface INetworkResponse<TResult = unknown> {
183
+ /** The response body, or its rows for a list. */
119
184
  data: TResult;
185
+ /** The count the server sent, in the body or in `x-response-count`; absent when it sent none. */
120
186
  count?: number;
121
187
  /** GET_LIST and GET_MANY_REFERENCE: the total of `Content-Range`, else the page's own row count. */
122
188
  total?: number;
@@ -136,6 +202,7 @@ export interface IFeatureBase {
136
202
  /**
137
203
  * The feature's `@configuration()` classes, by value. Referencing them keeps a bundler from
138
204
  * dropping a module nothing else imports, and `start()` checks each was discovered.
205
+ * @default []
139
206
  */
140
207
  configurations?: Array<TClass<unknown>>;
141
208
  /** What the feature checks, in the application's vocabulary. Declared for a role editor; ARDOR enforces nothing. */
@@ -162,18 +229,31 @@ export interface IPermissionProvider {
162
229
  record?: unknown;
163
230
  }): Promise<boolean>;
164
231
  }
232
+ /** The contract of an application: lifecycle hooks, registration of artifacts, and `start`. */
165
233
  export interface IArdorApplication {
234
+ /** Binds the application instance and info, then the discovered, feature and listed classes. */
166
235
  preConfigure(): ValueOrPromise<void>;
236
+ /** Runs after `preConfigure` in `start`. */
167
237
  postConfigure(): ValueOrPromise<void>;
238
+ /** The application's own bindings, bound last in `preConfigure`. */
168
239
  bindContext(): ValueOrPromise<void>;
240
+ /** Classes bound by key as singletons. */
169
241
  bindingList(): Record<string, TClass<unknown>>;
242
+ /** The features this application mounts. */
170
243
  features(): Array<IFeatureBase>;
244
+ /** The artifact indexes `start` checks every stereotyped class against. */
171
245
  artifacts(): Array<IArtifactIndex>;
246
+ /** Binds `value` under `<scope>.<ClassName>` as a singleton. */
172
247
  injectable<T>(scope: string, value: TClass<T>, tags?: Array<string>): void;
248
+ /** Binds `value` in the service namespace. */
173
249
  service<T>(value: TClass<T>): unknown;
250
+ /** Binds `value` in the repository namespace. */
174
251
  repository<T>(value: TClass<T>): unknown;
252
+ /** Binds `value` in the data source namespace. */
175
253
  dataSource<T>(value: TClass<T>): unknown;
254
+ /** Binds `value` in the component namespace. */
176
255
  component<T>(value: TClass<T>): unknown;
256
+ /** Runs the whole startup: resolves the indexes, then `preConfigure`, then `postConfigure`. */
177
257
  start(): ValueOrPromise<void>;
178
258
  }
179
259
  type TDeepPath = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
@@ -187,9 +267,11 @@ type TIsAny<TValue> = 0 extends 1 & TValue ? true : false;
187
267
  export type TPaths<T, DeepLevel extends number = 10> = DeepLevel extends 0 ? never : T extends Array<AnyType> | TPathLeaf ? never : T extends object ? {
188
268
  [K in keyof T]-?: K extends string | number ? TIsAny<T[K]> extends true ? `${K}` : NonNullable<T[K]> extends Array<AnyType> | TPathLeaf ? `${K}` : NonNullable<T[K]> extends object ? `${K}` | `${K}.${TPaths<NonNullable<T[K]>, TDeepPath[DeepLevel]>}` : `${K}` : never;
189
269
  }[keyof T] : never;
270
+ /** The dotted paths of an object type, to `DeepLevel` levels (10 by default); unlike `TPaths`, only the paths down to a leaf value. */
190
271
  export type TFullPaths<T, DeepLevel extends number = 10> = DeepLevel extends never ? never : T extends Array<infer U> ? TFullPaths<U> : T extends object ? {
191
272
  [K in keyof T]-?: K extends string | number ? T[K] extends Array<any> | object ? `${K}.${TFullPaths<T[K], TDeepPath[DeepLevel]>}` : `${K}` : never;
192
273
  }[keyof T] : never;
274
+ /** What an application is: bound under `CoreBindings.APPLICATION_INFO`, and the name a tracing id starts with. */
193
275
  export interface IApplicationInfo {
194
276
  name: string;
195
277
  version: string;
@@ -4,6 +4,7 @@ export declare class AuthTokenStore {
4
4
  private static readonly logger;
5
5
  /** The stored token, or `undefined` when none is stored, it is unusable, or there is no `localStorage`. */
6
6
  static read(): IAuthTokenRecord | undefined;
7
+ /** Stores the token with its `provider` under `LocalStorageKeys.KEY_AUTH_TOKEN`. Throws when `localStorage` is not available. */
7
8
  static write(opts: {
8
9
  token: {
9
10
  value: string;
@@ -23,6 +23,7 @@ export class AuthTokenStore {
23
23
  return undefined;
24
24
  }
25
25
  }
26
+ /** Stores the token with its `provider` under `LocalStorageKeys.KEY_AUTH_TOKEN`. Throws when `localStorage` is not available. */
26
27
  static write(opts) {
27
28
  // Not a silent skip: a sign-in that is not kept would look like it worked.
28
29
  if (typeof localStorage === 'undefined') {
@@ -15,6 +15,7 @@ export declare class AuthRecovery {
15
15
  refresh: () => Promise<boolean>;
16
16
  /** Runs once when the refresh threw. */
17
17
  onFailure: () => Promise<void>;
18
+ /** Whether the request, given by its paths, goes without a token; such a request never recovers. */
18
19
  isNoAuthPath: (paths: string[]) => boolean;
19
20
  });
20
21
  /** Once for every 401 in flight: the callers share one `refresh`. `true` when the token was refreshed. */
@@ -6,6 +6,7 @@ export interface IEncodedBody {
6
6
  }
7
7
  /** The body types that go through as they are, under the JSON content type. */
8
8
  type TPassThroughBodyType = typeof RequestBodyTypes.JSON | typeof RequestBodyTypes.NONE | typeof RequestBodyTypes.BINARY;
9
+ /** Turns a request body into what `fetch` sends, by `RequestBodyTypes`. */
9
10
  export declare class RequestBodyEncoder {
10
11
  /**
11
12
  * The body as it is sent and the content type to send it under. The overloads give the type of what
@@ -1,6 +1,7 @@
1
1
  import { getError } from '@venizia/ignis-inversion';
2
2
  import { RequestBodyTypes } from '../../common/index.js';
3
3
  import { ValueUtility } from '../../utilities/index.js';
4
+ /** Turns a request body into what `fetch` sends, by `RequestBodyTypes`. */
4
5
  export class RequestBodyEncoder {
5
6
  static encode(opts) {
6
7
  const { bodyType, body } = opts;
@@ -1,4 +1,5 @@
1
1
  import { type INetworkResponse, RequestCountData, type TConstValue, type TRequestType } from '../../common/index.js';
2
+ /** Reads a `Response` into an `INetworkResponse`, and an error response into an error. */
2
3
  export declare class ResponseReader {
3
4
  /** The server wraps an error body under this key; both transports unwrap it. */
4
5
  static readonly ERROR_ROOT_KEY = "error";
@@ -8,6 +9,13 @@ export declare class ResponseReader {
8
9
  type: TRequestType;
9
10
  requestCountData?: TConstValue<typeof RequestCountData>;
10
11
  }): Promise<INetworkResponse<TResult>>;
12
+ /**
13
+ * Shapes a parsed body by request type. `GET_LIST` and `GET_MANY_REFERENCE` give `data` as an
14
+ * array and `total` from `Content-Range`, else the row count; with `RequestCountData.DATA_WITH_COUNT`
15
+ * the body must be `{ data, count }`, or it throws. Any other type gives `data` as is, and `count`
16
+ * from `x-response-count` when that is a number; with `DATA_WITH_COUNT` it returns the
17
+ * `{ data, count }` body unchanged.
18
+ */
11
19
  static convert<TData = unknown>(opts: {
12
20
  response: {
13
21
  data: TData | {
@@ -5,6 +5,7 @@ import { HeaderConstants, RequestCountData, RequestTypes, } from '../../common/i
5
5
  const isCountedBody = (value) => {
6
6
  return typeof value === 'object' && value !== null && 'data' in value && 'count' in value;
7
7
  };
8
+ /** Reads a `Response` into an `INetworkResponse`, and an error response into an error. */
8
9
  export class ResponseReader {
9
10
  /** The server wraps an error body under this key; both transports unwrap it. */
10
11
  static { this.ERROR_ROOT_KEY = 'error'; }
@@ -41,6 +42,13 @@ export class ResponseReader {
41
42
  });
42
43
  return extra ? { ...converted, extra } : converted;
43
44
  }
45
+ /**
46
+ * Shapes a parsed body by request type. `GET_LIST` and `GET_MANY_REFERENCE` give `data` as an
47
+ * array and `total` from `Content-Range`, else the row count; with `RequestCountData.DATA_WITH_COUNT`
48
+ * the body must be `{ data, count }`, or it throws. Any other type gives `data` as is, and `count`
49
+ * from `x-response-count` when that is a number; with `DATA_WITH_COUNT` it returns the
50
+ * `{ data, count }` body unchanged.
51
+ */
44
52
  static convert(opts) {
45
53
  const { response: { data, headers }, type, requestCountData, } = opts;
46
54
  switch (type) {
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The clipboard of the browser, for code outside React. Nothing throws or rejects: no `navigator`
3
+ * (a server), no `navigator.clipboard` (an insecure context, an old WebView), a denied permission,
4
+ * a missing user gesture and an unfocused document all answer `false` or `undefined`. Nothing
5
+ * touches `navigator` at import.
6
+ */
7
+ export declare class BrowserClipboard {
8
+ /** The one catch: every refusal the browser can make is the case this class absorbs. */
9
+ private static safe;
10
+ /** `true` when the text is on the clipboard. */
11
+ static writeText(opts: {
12
+ text: string;
13
+ }): Promise<boolean>;
14
+ /** The text on the clipboard, or `undefined`: reading needs a permission and a gesture, and some browsers do not offer it. */
15
+ static readText(): Promise<string | undefined>;
16
+ }
17
+ //# sourceMappingURL=browser-clipboard.d.ts.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The clipboard of the browser, for code outside React. Nothing throws or rejects: no `navigator`
3
+ * (a server), no `navigator.clipboard` (an insecure context, an old WebView), a denied permission,
4
+ * a missing user gesture and an unfocused document all answer `false` or `undefined`. Nothing
5
+ * touches `navigator` at import.
6
+ */
7
+ export class BrowserClipboard {
8
+ /** The one catch: every refusal the browser can make is the case this class absorbs. */
9
+ static async safe(opts) {
10
+ try {
11
+ const result = await opts.run();
12
+ return result;
13
+ // eslint-disable-next-line venizia/no-silent-catch -- absorbing a refusing clipboard is the contract of BrowserClipboard
14
+ }
15
+ catch {
16
+ return opts.fallback;
17
+ }
18
+ }
19
+ /** `true` when the text is on the clipboard. */
20
+ static writeText(opts) {
21
+ return BrowserClipboard.safe({
22
+ run: async () => {
23
+ await globalThis.navigator.clipboard.writeText(opts.text);
24
+ return true;
25
+ },
26
+ fallback: false,
27
+ });
28
+ }
29
+ /** The text on the clipboard, or `undefined`: reading needs a permission and a gesture, and some browsers do not offer it. */
30
+ static readText() {
31
+ return BrowserClipboard.safe({
32
+ run: () => globalThis.navigator.clipboard.readText(),
33
+ fallback: undefined,
34
+ });
35
+ }
36
+ }
37
+ //# sourceMappingURL=browser-clipboard.js.map