workerdeck 2.2.1 → 2.4.0

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/build/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as ConfigError, d as parseArgs, f as resolveInstanceConfig, r as startInstance, u as loadConfigFile } from "./instance-DeDxfiBR.mjs";
2
+ import { a as ConfigError, d as parseArgs, f as resolveInstanceConfig, r as startInstance, u as loadConfigFile } from "./instance-DqbdaKrO.mjs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { readFile } from "node:fs/promises";
5
5
  import { fileURLToPath } from "node:url";
package/build/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Authenticator, WorkerServer, WorkerServerOptions } from "@workerdeck/server";
2
2
  import { KeyObject } from "node:crypto";
3
+ import { ProfileInfo, SessionNotification, SessionNotificationType } from "@workerdeck/protocol";
3
4
  import { IncomingMessage, ServerResponse } from "node:http";
4
- import { ProfileInfo, SessionNotification } from "@workerdeck/protocol";
5
5
  //#region src/apns/client.d.ts
6
6
  type ApnsEnvironment = 'development' | 'production';
7
7
  type ApnsConfig = {
@@ -11,10 +11,12 @@ type ApnsConfig = {
11
11
  topic: string;
12
12
  production?: boolean;
13
13
  };
14
+ type ApnsPushType = 'alert' | 'liveactivity';
14
15
  type ApnsRequest = {
15
16
  deviceToken: string;
16
17
  environment: ApnsEnvironment;
17
18
  payload: unknown;
19
+ pushType?: ApnsPushType;
18
20
  priority?: 5 | 10;
19
21
  expiration?: number;
20
22
  collapseId?: string;
@@ -200,12 +202,15 @@ type DeviceRecord = {
200
202
  hostId?: string;
201
203
  bundleId?: string;
202
204
  platform?: string;
205
+ liveActivityStartToken?: string;
206
+ notify?: SessionNotificationType[];
203
207
  updatedAt: number;
204
208
  };
205
209
  type DeviceRegistry = {
206
210
  list(): DeviceRecord[];
207
211
  register(record: Omit<DeviceRecord, 'updatedAt'>): Promise<void>;
208
212
  remove(token: string): Promise<void>;
213
+ clearStartToken(token: string): Promise<void>;
209
214
  };
210
215
  declare function createDeviceRegistry(options: {
211
216
  dir: string | null;
@@ -214,13 +219,103 @@ declare function createDeviceRegistry(options: {
214
219
  path: string;
215
220
  }) => void;
216
221
  }): Promise<DeviceRegistry>;
217
- declare function createDeviceRoute(registry: DeviceRegistry, authenticate: (req: IncomingMessage) => unknown): (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
222
+ declare function createDeviceRoute(registry: DeviceRegistry | null, authenticate: (req: IncomingMessage) => unknown): (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
223
+ //#endregion
224
+ //#region src/apns/activities.d.ts
225
+ type ActivityPhase = 'starting' | 'live' | 'ending';
226
+ type ActivityRecord = {
227
+ deviceToken: string;
228
+ sessionId: string;
229
+ hostId?: string;
230
+ environment: ApnsEnvironment;
231
+ updateToken?: string;
232
+ phase: ActivityPhase;
233
+ startedAt: number;
234
+ lastPushAt?: number;
235
+ contentHash?: string;
236
+ };
237
+ type ActivityRegistry = {
238
+ list(): ActivityRecord[];
239
+ get(deviceToken: string, sessionId: string): ActivityRecord | undefined;
240
+ forSession(sessionId: string): ActivityRecord[];
241
+ start(record: Omit<ActivityRecord, 'phase' | 'startedAt'> & {
242
+ startedAt?: number;
243
+ }): Promise<ActivityRecord>;
244
+ attach(match: {
245
+ sessionId: string;
246
+ deviceToken?: string;
247
+ environment: ApnsEnvironment;
248
+ }, updateToken: string): Promise<ActivityRecord | undefined>;
249
+ touch(deviceToken: string, sessionId: string, changes: Partial<Pick<ActivityRecord, 'phase' | 'lastPushAt' | 'contentHash'>>): Promise<void>;
250
+ remove(deviceToken: string, sessionId: string): Promise<void>;
251
+ removeByUpdateToken(updateToken: string): Promise<void>;
252
+ };
253
+ declare function createActivityRegistry(options: {
254
+ dir: string | null;
255
+ onError?: (error: unknown, context: {
256
+ op: string;
257
+ path: string;
258
+ }) => void;
259
+ }): Promise<ActivityRegistry>;
260
+ declare function createActivityRoute(registry: ActivityRegistry | null, authenticate: (req: IncomingMessage) => unknown): (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
261
+ //#endregion
262
+ //#region src/apns/routes.d.ts
263
+ type ApnsRouteHandler = (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
264
+ declare function createApnsRoute(registries: {
265
+ devices: DeviceRegistry;
266
+ activities: ActivityRegistry;
267
+ } | null, authenticate: (req: IncomingMessage) => unknown): ApnsRouteHandler;
268
+ //#endregion
269
+ //#region src/apns/live-activity.d.ts
270
+ type ActivityAttributes = {
271
+ sessionId: string;
272
+ hostId?: string;
273
+ engine?: string;
274
+ cwdLeaf: string;
275
+ };
276
+ type ActivityChoice = {
277
+ index: number;
278
+ label: string;
279
+ };
280
+ type ActivityRequestState = {
281
+ id: string;
282
+ kind: 'permission' | 'question' | 'plan';
283
+ choices: ActivityChoice[];
284
+ inputJSON?: string;
285
+ };
286
+ type ActivityContentState = {
287
+ phase: ActivityPhaseName;
288
+ title: string;
289
+ headline: string;
290
+ detail?: string;
291
+ startedAtMs: number;
292
+ expiresAtMs?: number;
293
+ pendingCount: number;
294
+ steps?: {
295
+ done: number;
296
+ total: number;
297
+ };
298
+ request?: ActivityRequestState;
299
+ epoch?: number;
300
+ seq?: number;
301
+ decision: null;
302
+ };
303
+ type ActivityPhaseName = 'running' | 'approval' | 'question' | 'plan' | 'done' | 'failed' | 'parked' | 'ended';
218
304
  //#endregion
219
305
  //#region src/apns/forwarder.d.ts
220
306
  type ApnsForwarder = {
221
307
  onNotification: (notification: SessionNotification) => void;
222
308
  handleRequest: (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
223
309
  deviceCount: () => number;
310
+ activity: {
311
+ start: (attributes: ActivityAttributes, state: ActivityContentState) => void;
312
+ update: (sessionId: string, state: ActivityContentState, options: {
313
+ urgent: boolean;
314
+ }) => void;
315
+ end: (sessionId: string, state: ActivityContentState) => void;
316
+ endAll: (headline: string) => Promise<void>;
317
+ count: () => number;
318
+ };
224
319
  close: () => void;
225
320
  };
226
321
  declare function buildPush(notification: SessionNotification, hostId: string | undefined): Omit<ApnsRequest, 'deviceToken' | 'environment'>;
@@ -231,5 +326,5 @@ declare function createApnsForwarder(options: {
231
326
  warn?: (message: string) => void;
232
327
  }): Promise<ApnsForwarder>;
233
328
  //#endregion
234
- export { type ApnsClient, type ApnsConfig, type ApnsEnvironment, type ApnsForwarder, type ApnsRequest, type ApnsResult, type AuthSessionStoreOptions, type CliAuth, type CliAuthOptions, type CliFlags, type CliPrincipal, type CliSessionStore, ConfigError, type DeviceRecord, type DeviceRegistry, type Instance, type LoadedConfig, type LoginPageOptions, type MaterializedAuthKey, type ResolvedConfig, type StoredSession, type WorkerDeckConfig, buildPush, createApnsClient, createApnsForwarder, createAuthSessionStore, createCliAuth, createDeviceRegistry, createDeviceRoute, createHostGuard, defaultStateDir, hostnameOf, isLoopback, isLoopbackHostname, loadApnsKey, loadConfigFile, materializeAuthKey, parseArgs, renderLoginPage, resolveInstanceConfig, resolveWebRoot, runGuard, startInstance };
329
+ export { type ActivityRecord, type ActivityRegistry, type ApnsClient, type ApnsConfig, type ApnsEnvironment, type ApnsForwarder, type ApnsRequest, type ApnsResult, type ApnsRouteHandler, type AuthSessionStoreOptions, type CliAuth, type CliAuthOptions, type CliFlags, type CliPrincipal, type CliSessionStore, ConfigError, type DeviceRecord, type DeviceRegistry, type Instance, type LoadedConfig, type LoginPageOptions, type MaterializedAuthKey, type ResolvedConfig, type StoredSession, type WorkerDeckConfig, buildPush, createActivityRegistry, createActivityRoute, createApnsClient, createApnsForwarder, createApnsRoute, createAuthSessionStore, createCliAuth, createDeviceRegistry, createDeviceRoute, createHostGuard, defaultStateDir, hostnameOf, isLoopback, isLoopbackHostname, loadApnsKey, loadConfigFile, materializeAuthKey, parseArgs, renderLoginPage, resolveInstanceConfig, resolveWebRoot, runGuard, startInstance };
235
330
  //# sourceMappingURL=index.d.mts.map
package/build/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  import { n as runGuard } from "./guard-CGPVzJ3Q.mjs";
2
- import { _ as createApnsForwarder, a as ConfigError, b as createApnsClient, c as isLoopback, d as parseArgs, f as resolveInstanceConfig, g as buildPush, h as materializeAuthKey, i as renderLoginPage, l as isLoopbackHostname, m as createAuthSessionStore, n as resolveWebRoot, o as defaultStateDir, p as createCliAuth, r as startInstance, s as hostnameOf, t as createHostGuard, u as loadConfigFile, v as createDeviceRegistry, x as loadApnsKey, y as createDeviceRoute } from "./instance-DeDxfiBR.mjs";
3
- export { ConfigError, buildPush, createApnsClient, createApnsForwarder, createAuthSessionStore, createCliAuth, createDeviceRegistry, createDeviceRoute, createHostGuard, defaultStateDir, hostnameOf, isLoopback, isLoopbackHostname, loadApnsKey, loadConfigFile, materializeAuthKey, parseArgs, renderLoginPage, resolveInstanceConfig, resolveWebRoot, runGuard, startInstance };
2
+ import { C as createActivityRegistry, S as createDeviceRoute, _ as createApnsForwarder, a as ConfigError, b as createApnsRoute, c as isLoopback, d as parseArgs, f as resolveInstanceConfig, g as buildPush, h as materializeAuthKey, i as renderLoginPage, l as isLoopbackHostname, m as createAuthSessionStore, n as resolveWebRoot, o as defaultStateDir, p as createCliAuth, r as startInstance, s as hostnameOf, t as createHostGuard, u as loadConfigFile, v as createApnsClient, w as createActivityRoute, x as createDeviceRegistry, y as loadApnsKey } from "./instance-DqbdaKrO.mjs";
3
+ export { ConfigError, buildPush, createActivityRegistry, createActivityRoute, createApnsClient, createApnsForwarder, createApnsRoute, createAuthSessionStore, createCliAuth, createDeviceRegistry, createDeviceRoute, createHostGuard, defaultStateDir, hostnameOf, isLoopback, isLoopbackHostname, loadApnsKey, loadConfigFile, materializeAuthKey, parseArgs, renderLoginPage, resolveInstanceConfig, resolveWebRoot, runGuard, startInstance };