@ariary/notification 4.0.0 → 4.2.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/README.md CHANGED
@@ -12,7 +12,7 @@ yarn add @ariary/notification
12
12
 
13
13
  1. Sign in at [ariari.mg](https://ariari.mg)
14
14
  2. Create a project
15
- 3. You'll receive a `projectId` and a `secret`
15
+ 3. You'll receive a `secret`
16
16
 
17
17
  ## Setup
18
18
 
@@ -20,7 +20,6 @@ yarn add @ariary/notification
20
20
  import Ariari from '@ariary/notification'
21
21
 
22
22
  Ariari.config({
23
- projectId: 'your-project-id',
24
23
  secret: 'your-secret',
25
24
  })
26
25
  ```
@@ -198,13 +197,11 @@ Use `name` to manage separate Ariari instances with different credentials. `Aria
198
197
  ```ts
199
198
  const marketing = Ariari.config({
200
199
  name: 'marketing',
201
- projectId: 'project-a',
202
200
  secret: 'secret-a',
203
201
  })
204
202
 
205
203
  const alerts = Ariari.config({
206
204
  name: 'alerts',
207
- projectId: 'project-b',
208
205
  secret: 'secret-b',
209
206
  })
210
207
 
package/dist/index.d.mts CHANGED
@@ -1,3 +1,120 @@
1
+ interface ConfigurationParameters {
2
+ basePath?: string;
3
+ fetchApi?: FetchAPI;
4
+ middleware?: Middleware[];
5
+ queryParamsStringify?: (params: HTTPQuery) => string;
6
+ username?: string;
7
+ password?: string;
8
+ apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>);
9
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>);
10
+ headers?: HTTPHeaders;
11
+ credentials?: RequestCredentials;
12
+ }
13
+ declare class Configuration {
14
+ private configuration;
15
+ constructor(configuration?: ConfigurationParameters);
16
+ set config(configuration: Configuration);
17
+ get basePath(): string;
18
+ get fetchApi(): FetchAPI | undefined;
19
+ get middleware(): Middleware[];
20
+ get queryParamsStringify(): (params: HTTPQuery) => string;
21
+ get username(): string | undefined;
22
+ get password(): string | undefined;
23
+ get apiKey(): ((name: string) => string | Promise<string>) | undefined;
24
+ get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined;
25
+ get headers(): HTTPHeaders | undefined;
26
+ get credentials(): RequestCredentials | undefined;
27
+ }
28
+ /**
29
+ * This is the base class for all generated API classes.
30
+ */
31
+ declare class BaseAPI {
32
+ protected configuration: Configuration;
33
+ private static readonly jsonRegex;
34
+ private middleware;
35
+ constructor(configuration?: Configuration);
36
+ withMiddleware<T extends BaseAPI>(this: T, ...middlewares: Middleware[]): T;
37
+ withPreMiddleware<T extends BaseAPI>(this: T, ...preMiddlewares: Array<Middleware['pre']>): T;
38
+ withPostMiddleware<T extends BaseAPI>(this: T, ...postMiddlewares: Array<Middleware['post']>): T;
39
+ /**
40
+ * Check if the given MIME is a JSON MIME.
41
+ * JSON MIME examples:
42
+ * application/json
43
+ * application/json; charset=UTF8
44
+ * APPLICATION/JSON
45
+ * application/vnd.company+json
46
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
47
+ * @return True if the given MIME is JSON, false otherwise.
48
+ */
49
+ protected isJsonMime(mime: string | null | undefined): boolean;
50
+ protected request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise<Response>;
51
+ private createFetchParams;
52
+ private fetchApi;
53
+ /**
54
+ * Create a shallow clone of `this` by constructing a new instance
55
+ * and then shallow cloning data members.
56
+ */
57
+ private clone;
58
+ }
59
+ type FetchAPI = WindowOrWorkerGlobalScope['fetch'];
60
+ type Json = any;
61
+ type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
62
+ type HTTPHeaders = {
63
+ [key: string]: string;
64
+ };
65
+ type HTTPQuery = {
66
+ [key: string]: string | number | null | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery;
67
+ };
68
+ type HTTPBody = Json | FormData | URLSearchParams;
69
+ type HTTPRequestInit = {
70
+ headers?: HTTPHeaders;
71
+ method: HTTPMethod;
72
+ credentials?: RequestCredentials;
73
+ body?: HTTPBody;
74
+ };
75
+ type InitOverrideFunction = (requestContext: {
76
+ init: HTTPRequestInit;
77
+ context: RequestOpts;
78
+ }) => Promise<RequestInit>;
79
+ interface FetchParams {
80
+ url: string;
81
+ init: RequestInit;
82
+ }
83
+ interface RequestOpts {
84
+ path: string;
85
+ method: HTTPMethod;
86
+ headers: HTTPHeaders;
87
+ query?: HTTPQuery;
88
+ body?: HTTPBody;
89
+ }
90
+ interface RequestContext {
91
+ fetch: FetchAPI;
92
+ url: string;
93
+ init: RequestInit;
94
+ }
95
+ interface ResponseContext {
96
+ fetch: FetchAPI;
97
+ url: string;
98
+ init: RequestInit;
99
+ response: Response;
100
+ }
101
+ interface ErrorContext {
102
+ fetch: FetchAPI;
103
+ url: string;
104
+ init: RequestInit;
105
+ error: unknown;
106
+ response?: Response;
107
+ }
108
+ interface Middleware {
109
+ pre?(context: RequestContext): Promise<FetchParams | void>;
110
+ post?(context: ResponseContext): Promise<Response | void>;
111
+ onError?(context: ErrorContext): Promise<Response | void>;
112
+ }
113
+ interface ApiResponse<T> {
114
+ raw: Response;
115
+ value(): Promise<T>;
116
+ }
117
+
1
118
  /**
2
119
  * API Payment Service - NestJS
3
120
  * Système de gestion des paiements - NestJS
@@ -144,7 +261,7 @@ type SmsStatus$1 = typeof SmsStatus$1[keyof typeof SmsStatus$1];
144
261
  * @export
145
262
  * @interface SmsDetail
146
263
  */
147
- interface SmsDetail$1 {
264
+ interface SmsDetail {
148
265
  /**
149
266
  * ID unique du SMS
150
267
  * @type {string}
@@ -177,6 +294,99 @@ interface SmsDetail$1 {
177
294
  retryCount: number;
178
295
  }
179
296
 
297
+ /**
298
+ * API Payment Service - NestJS
299
+ * Système de gestion des paiements - NestJS
300
+ *
301
+ * The version of the OpenAPI document: 1.0
302
+ *
303
+ *
304
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
305
+ * https://openapi-generator.tech
306
+ * Do not edit the class manually.
307
+ */
308
+
309
+ /**
310
+ *
311
+ * @export
312
+ * @interface NotifTaskWithSms
313
+ */
314
+ interface NotifTaskWithSms {
315
+ /**
316
+ * ID de la tâche
317
+ * @type {string}
318
+ * @memberof NotifTaskWithSms
319
+ */
320
+ taskId: string;
321
+ /**
322
+ * Statut par SMS
323
+ * @type {NotifTaskStatus}
324
+ * @memberof NotifTaskWithSms
325
+ */
326
+ status: NotifTaskStatus;
327
+ /**
328
+ * Statut par pages SMS
329
+ * @type {NotifTaskStatus}
330
+ * @memberof NotifTaskWithSms
331
+ */
332
+ statusPage: NotifTaskStatus;
333
+ /**
334
+ * Date de création
335
+ * @type {Date}
336
+ * @memberof NotifTaskWithSms
337
+ */
338
+ createdAt: Date;
339
+ /**
340
+ * Date planifiée
341
+ * @type {Date}
342
+ * @memberof NotifTaskWithSms
343
+ */
344
+ scheduledAt?: Date;
345
+ /**
346
+ * Liste des SMS
347
+ * @type {Array<SmsDetail>}
348
+ * @memberof NotifTaskWithSms
349
+ */
350
+ sms: Array<SmsDetail>;
351
+ }
352
+
353
+ /**
354
+ * API Payment Service - NestJS
355
+ * Système de gestion des paiements - NestJS
356
+ *
357
+ * The version of the OpenAPI document: 1.0
358
+ *
359
+ *
360
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
361
+ * https://openapi-generator.tech
362
+ * Do not edit the class manually.
363
+ */
364
+ /**
365
+ *
366
+ * @export
367
+ * @interface PaginationParams
368
+ */
369
+ interface PaginationParams {
370
+ /**
371
+ * Offset de départ
372
+ * @type {number}
373
+ * @memberof PaginationParams
374
+ */
375
+ from?: number;
376
+ /**
377
+ * Nombre d'éléments à retourner
378
+ * @type {number}
379
+ * @memberof PaginationParams
380
+ */
381
+ count?: number;
382
+ /**
383
+ * Ordre de tri (-1 pour DESC, 1 pour ASC)
384
+ * @type {number}
385
+ * @memberof PaginationParams
386
+ */
387
+ order?: number;
388
+ }
389
+
180
390
  /**
181
391
  * API Payment Service - NestJS
182
392
  * Système de gestion des paiements - NestJS
@@ -227,24 +437,114 @@ interface ResponseNotifTask {
227
437
  createdAt: Date;
228
438
  }
229
439
 
230
- type Data = {
231
- body?: Record<string, unknown> | object;
232
- params?: Record<string, string>;
233
- public?: boolean;
234
- };
235
- type PData = Omit<Data, 'body'>;
236
- type Config = {
440
+ /**
441
+ * API Payment Service - NestJS
442
+ * Système de gestion des paiements - NestJS
443
+ *
444
+ * The version of the OpenAPI document: 1.0
445
+ *
446
+ *
447
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
448
+ * https://openapi-generator.tech
449
+ * Do not edit the class manually.
450
+ */
451
+
452
+ /**
453
+ *
454
+ * @export
455
+ * @interface PaginatedNotifTaskResponse
456
+ */
457
+ interface PaginatedNotifTaskResponse {
458
+ /**
459
+ * Liste des tâches
460
+ * @type {Array<ResponseNotifTask>}
461
+ * @memberof PaginatedNotifTaskResponse
462
+ */
463
+ tasks: Array<ResponseNotifTask>;
464
+ /**
465
+ * Paramètres pour la page suivante
466
+ * @type {PaginationParams}
467
+ * @memberof PaginatedNotifTaskResponse
468
+ */
469
+ next: PaginationParams;
470
+ /**
471
+ * Paramètres pour la page précédente
472
+ * @type {PaginationParams}
473
+ * @memberof PaginatedNotifTaskResponse
474
+ */
475
+ prev?: PaginationParams;
476
+ }
477
+
478
+ /**
479
+ * API Payment Service - NestJS
480
+ * Système de gestion des paiements - NestJS
481
+ *
482
+ * The version of the OpenAPI document: 1.0
483
+ *
484
+ *
485
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
486
+ * https://openapi-generator.tech
487
+ * Do not edit the class manually.
488
+ */
489
+
490
+ interface NotifTaskFindAllRequest {
491
+ xSecret: string;
492
+ from: string;
493
+ count: string;
494
+ order: string;
237
495
  projectId: string;
238
- secret: string;
239
- baseUrl?: string;
240
- };
241
- declare const createRequester: (config: Config) => {
242
- get: <T>(url: string, data?: PData) => Promise<T>;
243
- post: <T>(url: string, data?: Data) => Promise<T>;
244
- patch: <T>(url: string, data?: Data) => Promise<T>;
245
- put: <T>(url: string, data?: Data) => Promise<T>;
246
- delete: <T = void>(url: string, data?: PData) => Promise<T>;
247
- };
496
+ }
497
+ interface NotifTaskFindAllWithSmsRequest {
498
+ xSecret: string;
499
+ projectId: string;
500
+ days: string;
501
+ }
502
+ interface NotifTaskFindOneRequest {
503
+ xSecret: string;
504
+ id: string;
505
+ details: string;
506
+ }
507
+ /**
508
+ *
509
+ */
510
+ declare class NotifTaskApi extends BaseAPI {
511
+ /**
512
+ * Creates request options for notifTaskFindAll without sending the request
513
+ */
514
+ notifTaskFindAllRequestOpts(requestParameters: NotifTaskFindAllRequest): Promise<RequestOpts>;
515
+ /**
516
+ * Récupérer les tâches avec pagination
517
+ */
518
+ notifTaskFindAllRaw(requestParameters: NotifTaskFindAllRequest, initOverrides?: RequestInit | InitOverrideFunction): Promise<ApiResponse<PaginatedNotifTaskResponse>>;
519
+ /**
520
+ * Récupérer les tâches avec pagination
521
+ */
522
+ notifTaskFindAll(requestParameters: NotifTaskFindAllRequest, initOverrides?: RequestInit | InitOverrideFunction): Promise<PaginatedNotifTaskResponse>;
523
+ /**
524
+ * Creates request options for notifTaskFindAllWithSms without sending the request
525
+ */
526
+ notifTaskFindAllWithSmsRequestOpts(requestParameters: NotifTaskFindAllWithSmsRequest): Promise<RequestOpts>;
527
+ /**
528
+ * Récupérer toutes les tâches avec SMS détaillés sur N jours pour un projet
529
+ */
530
+ notifTaskFindAllWithSmsRaw(requestParameters: NotifTaskFindAllWithSmsRequest, initOverrides?: RequestInit | InitOverrideFunction): Promise<ApiResponse<Array<NotifTaskWithSms>>>;
531
+ /**
532
+ * Récupérer toutes les tâches avec SMS détaillés sur N jours pour un projet
533
+ */
534
+ notifTaskFindAllWithSms(requestParameters: NotifTaskFindAllWithSmsRequest, initOverrides?: RequestInit | InitOverrideFunction): Promise<Array<NotifTaskWithSms>>;
535
+ /**
536
+ * Creates request options for notifTaskFindOne without sending the request
537
+ */
538
+ notifTaskFindOneRequestOpts(requestParameters: NotifTaskFindOneRequest): Promise<RequestOpts>;
539
+ /**
540
+ * Récupérer une tâche par ID, avec SMS optionnels via ?details=limit,page
541
+ */
542
+ notifTaskFindOneRaw(requestParameters: NotifTaskFindOneRequest, initOverrides?: RequestInit | InitOverrideFunction): Promise<ApiResponse<NotifTaskWithSms>>;
543
+ /**
544
+ * Récupérer une tâche par ID, avec SMS optionnels via ?details=limit,page
545
+ */
546
+ notifTaskFindOne(requestParameters: NotifTaskFindOneRequest, initOverrides?: RequestInit | InitOverrideFunction): Promise<NotifTaskWithSms>;
547
+ }
248
548
 
249
549
  type Message = {
250
550
  phone: string[] | string;
@@ -257,29 +557,25 @@ declare enum SmsStatus {
257
557
  DELIVERED = "DELIVERED",
258
558
  FAILED = "FAILED"
259
559
  }
260
- type SmsDetail = SmsDetail$1;
261
560
  type EstimateMessage = EstimateMessage$1;
262
- type EstimateResponse = EstimateSmsResponse;
263
- type TaskData = ResponseNotifTask & {
264
- scheduledAt?: Date;
265
- };
266
- type TaskResponse = {
267
- task: TaskData;
268
- sms: SmsDetail[];
269
- total: number;
270
- };
271
561
 
562
+ type Config = {
563
+ secret: string;
564
+ baseUrl?: string;
565
+ };
272
566
  declare class Task {
273
567
  id: string;
274
- private _requester;
275
- constructor(id: string, requester: ReturnType<typeof createRequester>);
276
- status(): Promise<TaskResponse>;
277
- status(count: number, page?: number): Promise<TaskResponse>;
278
- fullStatus(): Promise<TaskResponse>;
568
+ private _api;
569
+ private _secret;
570
+ constructor(id: string, api: NotifTaskApi, secret: string);
571
+ status(): Promise<NotifTaskWithSms>;
572
+ status(count: number, page?: number): Promise<NotifTaskWithSms>;
573
+ fullStatus(): Promise<NotifTaskWithSms>;
279
574
  }
280
575
  declare class Ariari {
281
- private _config;
282
- private _requester;
576
+ private _secret;
577
+ private _smsApi;
578
+ private _notifTaskApi;
283
579
  private constructor();
284
580
  static config: (nameAndConfig: Config & {
285
581
  name?: string;
@@ -290,10 +586,10 @@ declare class Ariari {
290
586
  static get: (name?: string) => Ariari;
291
587
  send: (...args: [string, ...Message[]] | Message[]) => Promise<Task>;
292
588
  getTask: (taskId: string) => Task;
293
- estimate: (...messages: EstimateMessage[]) => Promise<EstimateResponse>;
589
+ estimate: (...messages: EstimateMessage[]) => Promise<EstimateSmsResponse>;
294
590
  static send: (...args: [string, ...Message[]] | Message[]) => Promise<Task>;
295
591
  static getTask: (taskId: string) => Task;
296
592
  static estimate: (...messages: EstimateMessage[]) => Promise<EstimateSmsResponse>;
297
593
  }
298
594
 
299
- export { SmsStatus, Ariari as default };
595
+ export { type Config, SmsStatus, Ariari as default };