@deveye/types 0.20.3 → 0.21.1
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/package.json +1 -1
- package/src/domain/admission.ts +37 -0
- package/src/domain/device.ts +7 -3
- package/src/domain/featureRegistry.ts +3 -2
- package/src/domain/maintenance.ts +7 -1
- package/src/domain/notifications.ts +16 -0
- package/src/domain/packages.ts +34 -2
- package/src/domain/report.ts +15 -3
- package/src/domain/secrecy.ts +13 -0
- package/src/domain/user.ts +10 -1
- package/src/features/admin.ts +59 -1
- package/src/features/debug.ts +372 -0
- package/src/features/registry.ts +2 -0
- package/src/features/user.ts +46 -0
- package/src/http/auth.ts +2 -0
- package/src/http/device.ts +33 -15
- package/src/http/status.ts +6 -0
- package/src/index.ts +125 -6
- package/src/protocol/agent.ts +127 -5
- package/src/protocol/error.ts +4 -1
- package/src/sdk/accountExport.test.ts +115 -0
- package/src/sdk/accountExport.ts +254 -0
- package/src/sdk/client-ambient.d.ts +86 -0
- package/src/sdk/client.ts +44 -0
- package/src/sdk/devb.test.ts +148 -0
- package/src/sdk/devb.ts +146 -0
- package/src/sdk/download.test.ts +40 -0
- package/src/sdk/download.ts +48 -0
- package/src/sdk/manifest.test.ts +17 -1
- package/src/sdk/manifest.ts +51 -11
- package/src/sdk/net.test.ts +42 -1
- package/src/sdk/net.ts +100 -2
- package/src/sdk/pool.test.ts +36 -0
- package/src/sdk/pool.ts +26 -0
- package/src/sdk/providers.ts +107 -11
- package/src/sdk/server.ts +402 -13
- package/src/sdk/testing.test.ts +66 -0
- package/src/sdk/testing.ts +222 -2
package/src/sdk/providers.ts
CHANGED
|
@@ -182,17 +182,15 @@ export interface MailTransportProvider {
|
|
|
182
182
|
* `text` stays mandatory whatever else is given: a recipient whose client
|
|
183
183
|
* shows no HTML must lose nothing.
|
|
184
184
|
*/
|
|
185
|
-
send(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
): Promise<boolean>;
|
|
185
|
+
send(accountId: number, workspaceId: number, message: MailTransportMessage): Promise<boolean>;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface MailTransportMessage {
|
|
189
|
+
to: string;
|
|
190
|
+
subject: string;
|
|
191
|
+
text: string;
|
|
192
|
+
html?: string;
|
|
193
|
+
attachments?: readonly MailAttachment[];
|
|
196
194
|
}
|
|
197
195
|
|
|
198
196
|
/**
|
|
@@ -223,6 +221,62 @@ export interface AudienceItemsProvider {
|
|
|
223
221
|
labelOf(siteId: number, workspaceId: number): Promise<string | null>;
|
|
224
222
|
}
|
|
225
223
|
|
|
224
|
+
/**
|
|
225
|
+
* Key under `FeatureService.providers` for DevEye's own usage figures: the
|
|
226
|
+
* app reports the pages its members open and the actions they take into an
|
|
227
|
+
* Audience site of this very instance, chosen by an administrator. Absent
|
|
228
|
+
* module: nothing is reported, and the admin page says why.
|
|
229
|
+
*/
|
|
230
|
+
export const AUDIENCE_SELF_PROVIDER = 'audience.self' as const;
|
|
231
|
+
|
|
232
|
+
export interface AudienceSelfSite {
|
|
233
|
+
siteId: number;
|
|
234
|
+
workspaceId: number;
|
|
235
|
+
name: string;
|
|
236
|
+
active: boolean;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** One measure, as the public beacon takes it: a page or an action, never who. */
|
|
240
|
+
export interface AudienceSelfEvent {
|
|
241
|
+
type: 'view' | 'event';
|
|
242
|
+
/** A static path (`/uptime/settings`), never an id or a name. */
|
|
243
|
+
path: string;
|
|
244
|
+
/** Required for an `event`. */
|
|
245
|
+
name?: string;
|
|
246
|
+
/** Milliseconds since the epoch; now when absent. */
|
|
247
|
+
at?: number;
|
|
248
|
+
referrer?: string;
|
|
249
|
+
language?: string;
|
|
250
|
+
timezone?: string;
|
|
251
|
+
tzOffset?: number;
|
|
252
|
+
screenWidth?: number;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface AudienceSelfProvider {
|
|
256
|
+
/**
|
|
257
|
+
* Creates an anonymous site for this host in this workspace, active, with
|
|
258
|
+
* no per-visitor limit. The caller owns the authorisation; the owner's
|
|
259
|
+
* plan still applies.
|
|
260
|
+
*/
|
|
261
|
+
createSite(
|
|
262
|
+
workspaceId: number,
|
|
263
|
+
input: { name: string; host: string }
|
|
264
|
+
): Promise<AudienceSelfSite & { publicKey: string }>;
|
|
265
|
+
/** The site behind this key, wherever it lives; `null` when unknown. */
|
|
266
|
+
findByKey(publicKey: string): Promise<AudienceSelfSite | null>;
|
|
267
|
+
/**
|
|
268
|
+
* Queued as if sent through the public beacon by that visitor, the Origin
|
|
269
|
+
* check aside: the app vouches for them. The bot filter and the plan's
|
|
270
|
+
* monthly limit still apply. Never throws.
|
|
271
|
+
*/
|
|
272
|
+
ingest(req: {
|
|
273
|
+
key: string;
|
|
274
|
+
ip: string;
|
|
275
|
+
userAgent: string;
|
|
276
|
+
events: readonly AudienceSelfEvent[];
|
|
277
|
+
}): void;
|
|
278
|
+
}
|
|
279
|
+
|
|
226
280
|
/**
|
|
227
281
|
* Key under `FeatureClient.providers` for the Audience pieces the app's
|
|
228
282
|
* Projects screens compose: the list of the workspace's sites, a linked site
|
|
@@ -297,6 +351,33 @@ export const DEPLOY_CLIENT_PROVIDER = 'deploy.client' as const;
|
|
|
297
351
|
*/
|
|
298
352
|
export const DATABASE_CLIENT_PROVIDER = 'database.client' as const;
|
|
299
353
|
|
|
354
|
+
/**
|
|
355
|
+
* Key under `FeatureService.providers` for the Hosting folders the app's
|
|
356
|
+
* Projects feature links to: same shape and same reason as
|
|
357
|
+
* `UPTIME_ITEMS_PROVIDER` (`project_hosting_links` is Projects' table).
|
|
358
|
+
* Hosting is a private module: absent, the tab never shows and nothing links.
|
|
359
|
+
*/
|
|
360
|
+
export const HOSTING_ITEMS_PROVIDER = 'hosting.items' as const;
|
|
361
|
+
|
|
362
|
+
export interface HostingItemsProvider {
|
|
363
|
+
/** Is this folder visible from this workspace: its home, or one it is projected into? */
|
|
364
|
+
exists(packId: number, workspaceId: number): Promise<boolean>;
|
|
365
|
+
/**
|
|
366
|
+
* The item's display name as seen from `workspaceId` (its home, or a
|
|
367
|
+
* workspace it is projected into): the provider resolves the home and its
|
|
368
|
+
* OPEN cipher itself. `null` when it is gone or unreadable.
|
|
369
|
+
*/
|
|
370
|
+
labelOf(packId: number, workspaceId: number): Promise<string | null>;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Key under `FeatureClient.providers` for the Hosting pieces the app's
|
|
375
|
+
* Projects screens compose: the list of the workspace's folders, a linked
|
|
376
|
+
* folder shown inside a project's tab, and the feature's own folder dialog.
|
|
377
|
+
* The contract types live in `@deveye/types/sdk/client`.
|
|
378
|
+
*/
|
|
379
|
+
export const HOSTING_CLIENT_PROVIDER = 'hosting.client' as const;
|
|
380
|
+
|
|
300
381
|
/**
|
|
301
382
|
* Key of what Projects knows about the items of OTHER features: the projects
|
|
302
383
|
* of the workspace that link them (a module's list shows how many projects use
|
|
@@ -564,6 +645,12 @@ export interface AccountPlan {
|
|
|
564
645
|
label: string;
|
|
565
646
|
/** `<featureId>.<quotaKey>` to its maximum. An absent key is unlimited. */
|
|
566
647
|
limits: Readonly<Record<string, number>>;
|
|
648
|
+
/**
|
|
649
|
+
* The account is served first when the host sheds load. While the admin
|
|
650
|
+
* gives priority to such accounts, every limit of the others reads 0: their
|
|
651
|
+
* stock is paused and their creations refused, until the mode ends.
|
|
652
|
+
*/
|
|
653
|
+
priority: boolean;
|
|
567
654
|
/** The plan is a trial ending then (ms since the epoch). */
|
|
568
655
|
trialEndsAt?: number;
|
|
569
656
|
/**
|
|
@@ -573,6 +660,15 @@ export interface AccountPlan {
|
|
|
573
660
|
changesAt?: number;
|
|
574
661
|
}
|
|
575
662
|
|
|
663
|
+
/**
|
|
664
|
+
* Whether a plan is a paying one: the paid tier (trial included), an
|
|
665
|
+
* administrator, a plan granted on the paid tier (`priority`), or no provider
|
|
666
|
+
* at all (`null`, a self-hosted instance).
|
|
667
|
+
*/
|
|
668
|
+
export function isPaidPlan(plan: AccountPlan | null): boolean {
|
|
669
|
+
return plan === null || plan.id === 'pro' || plan.id === 'admin' || plan.priority;
|
|
670
|
+
}
|
|
671
|
+
|
|
576
672
|
export interface AccountPlanProvider {
|
|
577
673
|
/** `fresh`: never from a cache, the host is about to pause or resume on the answer. */
|
|
578
674
|
planFor(userId: number, opts?: { fresh?: boolean }): Promise<AccountPlan>;
|