@codixus/server 0.1.5 → 0.1.6

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/index.d.cts CHANGED
@@ -265,6 +265,80 @@ interface RestOptions {
265
265
  allowWrite?: (req: AuthenticatedRequest, doc: Record<string, unknown>, patch: Record<string, unknown>) => HookResult;
266
266
  }
267
267
 
268
+ type PushMessage = {
269
+ token: string;
270
+ title: string;
271
+ body: string;
272
+ data?: Record<string, unknown>;
273
+ ttl?: number;
274
+ badge?: number;
275
+ sound?: string;
276
+ channelId?: string;
277
+ };
278
+ type PushTicket = {
279
+ token: string;
280
+ status: "ok" | "error";
281
+ ticketId?: string;
282
+ errorCode?: string;
283
+ errorMessage?: string;
284
+ };
285
+ type PushReceipt = {
286
+ ticketId: string;
287
+ status: "ok" | "error";
288
+ errorCode?: string;
289
+ };
290
+ interface PushTransport {
291
+ readonly name: string;
292
+ send(messages: PushMessage[]): Promise<PushTicket[]>;
293
+ getReceipts?(ticketIds: string[]): Promise<PushReceipt[]>;
294
+ }
295
+ type PushSendInput = {
296
+ deviceId: string | string[];
297
+ title: string;
298
+ body: string;
299
+ data?: Record<string, unknown>;
300
+ idempotencyKey?: string;
301
+ };
302
+ type PushSendToInput = {
303
+ filter: Record<string, unknown>;
304
+ title: string;
305
+ body: string;
306
+ data?: Record<string, unknown>;
307
+ idempotencyKey?: string;
308
+ };
309
+ type PushDeviceDoc = {
310
+ _id: string;
311
+ deviceId: string;
312
+ token: string;
313
+ provider: string;
314
+ platform: "ios" | "android";
315
+ locale?: string;
316
+ timezone?: string;
317
+ appVersion?: string;
318
+ permissionStatus?: string;
319
+ enabled: boolean;
320
+ lastSeenAt: Date;
321
+ properties?: Record<string, unknown>;
322
+ createdAt: Date;
323
+ updatedAt: Date;
324
+ };
325
+ type PushDeliveryDoc = {
326
+ _id: string;
327
+ deviceId: string;
328
+ token: string;
329
+ provider: string;
330
+ title: string;
331
+ body: string;
332
+ data?: Record<string, unknown>;
333
+ status: "submitted" | "failed" | "opened";
334
+ ticketId?: string;
335
+ errorCode?: string;
336
+ idempotencyKey: string;
337
+ createdAt: Date;
338
+ openedAt?: Date;
339
+ receiptedAt?: Date;
340
+ };
341
+
268
342
  interface CodixusServerConfig {
269
343
  mongoUri: string;
270
344
  jwtSecret: string;
@@ -273,6 +347,12 @@ interface CodixusServerConfig {
273
347
  refreshTokenTtl?: string;
274
348
  dbName: string;
275
349
  appSecret?: string;
350
+ push?: {
351
+ transport: PushTransport;
352
+ };
353
+ admin?: {
354
+ token: string;
355
+ };
276
356
  }
277
357
  declare class CodixusServer {
278
358
  private config;
@@ -309,6 +389,16 @@ declare class CodixusServer {
309
389
  transaction: <T>(fn: (session: ClientSession) => Promise<T>) => Promise<T>;
310
390
  getDb: () => Db;
311
391
  };
392
+ push?: {
393
+ router: () => Router;
394
+ send: (input: PushSendInput) => Promise<void>;
395
+ sendTo: (input: PushSendToInput) => Promise<void>;
396
+ pollReceipts: () => Promise<void>;
397
+ find: (filter: Record<string, unknown>) => Promise<PushDeviceDoc[]>;
398
+ };
399
+ admin?: {
400
+ router: () => Router;
401
+ };
312
402
  constructor(config: CodixusServerConfig);
313
403
  connect(): Promise<void>;
314
404
  /**
@@ -330,4 +420,9 @@ declare class CodixusServer {
330
420
 
331
421
  declare function validate<T extends z.ZodType>(schema: T): (req: Request, res: Response, next: NextFunction) => void;
332
422
 
333
- export { type AuthRouterConfig, type AuthenticatedRequest, CodixusServer, type CodixusServerConfig, type GuardOptions, Model, type ModelDefinition, type ModelType, Query, type RateLimitConfig, RestErrorCode, type RestOptions, type SigningConfig, SubCollection, model, validate };
423
+ declare function createExpoTransport(opts?: {
424
+ accessToken?: string;
425
+ fetchImpl?: typeof fetch;
426
+ }): PushTransport;
427
+
428
+ export { type AuthRouterConfig, type AuthenticatedRequest, CodixusServer, type CodixusServerConfig, type GuardOptions, Model, type ModelDefinition, type ModelType, type PushDeliveryDoc, type PushDeviceDoc, type PushMessage, type PushReceipt, type PushSendInput, type PushSendToInput, type PushTicket, type PushTransport, Query, type RateLimitConfig, RestErrorCode, type RestOptions, type SigningConfig, SubCollection, createExpoTransport, model, validate };
package/dist/index.d.ts CHANGED
@@ -265,6 +265,80 @@ interface RestOptions {
265
265
  allowWrite?: (req: AuthenticatedRequest, doc: Record<string, unknown>, patch: Record<string, unknown>) => HookResult;
266
266
  }
267
267
 
268
+ type PushMessage = {
269
+ token: string;
270
+ title: string;
271
+ body: string;
272
+ data?: Record<string, unknown>;
273
+ ttl?: number;
274
+ badge?: number;
275
+ sound?: string;
276
+ channelId?: string;
277
+ };
278
+ type PushTicket = {
279
+ token: string;
280
+ status: "ok" | "error";
281
+ ticketId?: string;
282
+ errorCode?: string;
283
+ errorMessage?: string;
284
+ };
285
+ type PushReceipt = {
286
+ ticketId: string;
287
+ status: "ok" | "error";
288
+ errorCode?: string;
289
+ };
290
+ interface PushTransport {
291
+ readonly name: string;
292
+ send(messages: PushMessage[]): Promise<PushTicket[]>;
293
+ getReceipts?(ticketIds: string[]): Promise<PushReceipt[]>;
294
+ }
295
+ type PushSendInput = {
296
+ deviceId: string | string[];
297
+ title: string;
298
+ body: string;
299
+ data?: Record<string, unknown>;
300
+ idempotencyKey?: string;
301
+ };
302
+ type PushSendToInput = {
303
+ filter: Record<string, unknown>;
304
+ title: string;
305
+ body: string;
306
+ data?: Record<string, unknown>;
307
+ idempotencyKey?: string;
308
+ };
309
+ type PushDeviceDoc = {
310
+ _id: string;
311
+ deviceId: string;
312
+ token: string;
313
+ provider: string;
314
+ platform: "ios" | "android";
315
+ locale?: string;
316
+ timezone?: string;
317
+ appVersion?: string;
318
+ permissionStatus?: string;
319
+ enabled: boolean;
320
+ lastSeenAt: Date;
321
+ properties?: Record<string, unknown>;
322
+ createdAt: Date;
323
+ updatedAt: Date;
324
+ };
325
+ type PushDeliveryDoc = {
326
+ _id: string;
327
+ deviceId: string;
328
+ token: string;
329
+ provider: string;
330
+ title: string;
331
+ body: string;
332
+ data?: Record<string, unknown>;
333
+ status: "submitted" | "failed" | "opened";
334
+ ticketId?: string;
335
+ errorCode?: string;
336
+ idempotencyKey: string;
337
+ createdAt: Date;
338
+ openedAt?: Date;
339
+ receiptedAt?: Date;
340
+ };
341
+
268
342
  interface CodixusServerConfig {
269
343
  mongoUri: string;
270
344
  jwtSecret: string;
@@ -273,6 +347,12 @@ interface CodixusServerConfig {
273
347
  refreshTokenTtl?: string;
274
348
  dbName: string;
275
349
  appSecret?: string;
350
+ push?: {
351
+ transport: PushTransport;
352
+ };
353
+ admin?: {
354
+ token: string;
355
+ };
276
356
  }
277
357
  declare class CodixusServer {
278
358
  private config;
@@ -309,6 +389,16 @@ declare class CodixusServer {
309
389
  transaction: <T>(fn: (session: ClientSession) => Promise<T>) => Promise<T>;
310
390
  getDb: () => Db;
311
391
  };
392
+ push?: {
393
+ router: () => Router;
394
+ send: (input: PushSendInput) => Promise<void>;
395
+ sendTo: (input: PushSendToInput) => Promise<void>;
396
+ pollReceipts: () => Promise<void>;
397
+ find: (filter: Record<string, unknown>) => Promise<PushDeviceDoc[]>;
398
+ };
399
+ admin?: {
400
+ router: () => Router;
401
+ };
312
402
  constructor(config: CodixusServerConfig);
313
403
  connect(): Promise<void>;
314
404
  /**
@@ -330,4 +420,9 @@ declare class CodixusServer {
330
420
 
331
421
  declare function validate<T extends z.ZodType>(schema: T): (req: Request, res: Response, next: NextFunction) => void;
332
422
 
333
- export { type AuthRouterConfig, type AuthenticatedRequest, CodixusServer, type CodixusServerConfig, type GuardOptions, Model, type ModelDefinition, type ModelType, Query, type RateLimitConfig, RestErrorCode, type RestOptions, type SigningConfig, SubCollection, model, validate };
423
+ declare function createExpoTransport(opts?: {
424
+ accessToken?: string;
425
+ fetchImpl?: typeof fetch;
426
+ }): PushTransport;
427
+
428
+ export { type AuthRouterConfig, type AuthenticatedRequest, CodixusServer, type CodixusServerConfig, type GuardOptions, Model, type ModelDefinition, type ModelType, type PushDeliveryDoc, type PushDeviceDoc, type PushMessage, type PushReceipt, type PushSendInput, type PushSendToInput, type PushTicket, type PushTransport, Query, type RateLimitConfig, RestErrorCode, type RestOptions, type SigningConfig, SubCollection, createExpoTransport, model, validate };