@slotchain/sdk 1.4.0 → 1.5.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/dist/index.cjs.js +36 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +72 -2
- package/dist/index.d.ts +72 -2
- package/dist/index.esm.js +36 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/clients/notices-client.ts +52 -0
- package/src/index.ts +7 -0
- package/src/types/api.ts +48 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { AxiosInstance } from 'axios';
|
|
2
|
+
import type { ApiResponse, SlotNotice, ListNoticesOptions } from '../types/api';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* NoticesClient — read active slot-scoped operational notices.
|
|
6
|
+
*
|
|
7
|
+
* Notices are a product concept (early closure, venue change, general alert)
|
|
8
|
+
* backed by `slot_moments` internally — the SDK surface reflects the product,
|
|
9
|
+
* not the storage model. Each notice's attached graphic (if any) is already
|
|
10
|
+
* resolved to a signed `imageUrl` server-side.
|
|
11
|
+
*
|
|
12
|
+
* @example List active notices for a tenant
|
|
13
|
+
* ```ts
|
|
14
|
+
* const { data } = await slotly.notices.list({ tenantId });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export class NoticesClient {
|
|
18
|
+
private readonly client: AxiosInstance;
|
|
19
|
+
private readonly base = '/api/v1/notices';
|
|
20
|
+
|
|
21
|
+
constructor(client: AxiosInstance) {
|
|
22
|
+
this.client = client;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* List active notices for a tenant.
|
|
27
|
+
* Returns only notices where visible_until > activeAt (default: now).
|
|
28
|
+
*/
|
|
29
|
+
async list(options: ListNoticesOptions): Promise<ApiResponse<SlotNotice[]>> {
|
|
30
|
+
const response = await this.client.get<ApiResponse<SlotNotice[]>>(this.base, {
|
|
31
|
+
params: {
|
|
32
|
+
tenant_id: options.tenantId,
|
|
33
|
+
active_at: options.activeAt,
|
|
34
|
+
slot_id: options.slotId,
|
|
35
|
+
types: options.types?.join(','),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
return response.data;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get a single notice by its slot_moment id.
|
|
43
|
+
*/
|
|
44
|
+
async getById(id: string, tenantId: string): Promise<SlotNotice> {
|
|
45
|
+
const response = await this.client.get<ApiResponse<SlotNotice>>(`${this.base}/${id}`, {
|
|
46
|
+
params: { tenant_id: tenantId },
|
|
47
|
+
});
|
|
48
|
+
const { data } = response.data;
|
|
49
|
+
if (!data) throw new Error(`Notice ${id} not found`);
|
|
50
|
+
return data;
|
|
51
|
+
}
|
|
52
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { NotificationClient } from './clients/notification-client';
|
|
|
11
11
|
import { DataQualityClient } from './clients/data-quality-client';
|
|
12
12
|
import { OrganizationClient } from './clients/organization-client';
|
|
13
13
|
import { DocumentClient } from './clients/document-client';
|
|
14
|
+
import { NoticesClient } from './clients/notices-client';
|
|
14
15
|
import { setupRequestInterceptor, setupResponseInterceptor, setupErrorInterceptor } from './interceptors';
|
|
15
16
|
import { setupRetryInterceptor } from './retry';
|
|
16
17
|
import { SlotlyConfigurationError } from './errors';
|
|
@@ -55,6 +56,9 @@ export type {
|
|
|
55
56
|
ArtifactMimeCategory,
|
|
56
57
|
ListArtifactsOptions,
|
|
57
58
|
UploadArtifactOptions,
|
|
59
|
+
SlotNotice,
|
|
60
|
+
NoticeMomentType,
|
|
61
|
+
ListNoticesOptions,
|
|
58
62
|
} from './types/api';
|
|
59
63
|
|
|
60
64
|
// Re-export errors
|
|
@@ -123,6 +127,8 @@ export interface SlotlyApi {
|
|
|
123
127
|
organization: OrganizationClient;
|
|
124
128
|
/** Upload and retrieve file artifacts (CVs, invoices, images) linked to any Slotly entity */
|
|
125
129
|
document: DocumentClient;
|
|
130
|
+
/** List slot-scoped operational notices (early closure, venue change, general alerts) */
|
|
131
|
+
notices: NoticesClient;
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
const defaultBaseURL = typeof process !== 'undefined' && process.env?.SLOTLY_API_URL
|
|
@@ -317,6 +323,7 @@ export const useSlotly = (options: SlotlyClientOptions): SlotlyApi => {
|
|
|
317
323
|
dataQuality: new DataQualityClient(client),
|
|
318
324
|
organization: new OrganizationClient(client),
|
|
319
325
|
document: new DocumentClient(client),
|
|
326
|
+
notices: new NoticesClient(client),
|
|
320
327
|
};
|
|
321
328
|
};
|
|
322
329
|
|
package/src/types/api.ts
CHANGED
|
@@ -424,7 +424,7 @@ export interface GetOrganizationOptions {
|
|
|
424
424
|
/**
|
|
425
425
|
* Artifact / document attached to a customer or booking
|
|
426
426
|
*/
|
|
427
|
-
export type ArtifactEntityType = 'customer' | 'booking' | 'slot' | 'service' | 'tenant';
|
|
427
|
+
export type ArtifactEntityType = 'customer' | 'booking' | 'slot' | 'service' | 'tenant' | 'slot_moment';
|
|
428
428
|
|
|
429
429
|
export type ArtifactMimeCategory = 'pdf' | 'document' | 'image' | 'spreadsheet' | 'video' | 'audio' | 'other';
|
|
430
430
|
|
|
@@ -488,6 +488,53 @@ export interface UploadArtifactOptions {
|
|
|
488
488
|
metadata?: Record<string, unknown>;
|
|
489
489
|
}
|
|
490
490
|
|
|
491
|
+
/**
|
|
492
|
+
* Slot-scoped operational notice (early closure, venue change, general alert).
|
|
493
|
+
* Backed by a `slot_moment` — see NOTICES_PLAN.md in slotly-admin.
|
|
494
|
+
*/
|
|
495
|
+
export type NoticeMomentType =
|
|
496
|
+
| 'general_notice'
|
|
497
|
+
| 'early_closure'
|
|
498
|
+
| 'closure_notice'
|
|
499
|
+
| 'venue_change';
|
|
500
|
+
|
|
501
|
+
export interface SlotNotice {
|
|
502
|
+
id: string;
|
|
503
|
+
slotId: string;
|
|
504
|
+
tenantId: string;
|
|
505
|
+
momentType: NoticeMomentType;
|
|
506
|
+
createdAt: string;
|
|
507
|
+
createdBy: string | null;
|
|
508
|
+
notice: {
|
|
509
|
+
type: string;
|
|
510
|
+
title: string;
|
|
511
|
+
message: string;
|
|
512
|
+
/** YYYY-MM-DD — the day the notice applies to */
|
|
513
|
+
affectedDate: string;
|
|
514
|
+
/** HH:MM — only present for early_closure notices */
|
|
515
|
+
closesAt?: string;
|
|
516
|
+
severity: 'info' | 'warning' | 'urgent';
|
|
517
|
+
visibleFrom: string;
|
|
518
|
+
visibleUntil: string;
|
|
519
|
+
dismissible: boolean;
|
|
520
|
+
/** Signed URL for the notice's attached graphic, if one was uploaded */
|
|
521
|
+
imageUrl?: string | null;
|
|
522
|
+
/** Staff-picked display treatment — 'banner' (compact, stacks) or 'modal' (full-screen, one at a time) */
|
|
523
|
+
presentation: 'banner' | 'modal';
|
|
524
|
+
};
|
|
525
|
+
affectedBookingIds: string[];
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
export interface ListNoticesOptions {
|
|
529
|
+
tenantId: string;
|
|
530
|
+
/** Filter to notices active at this ISO timestamp. Defaults to now. */
|
|
531
|
+
activeAt?: string;
|
|
532
|
+
/** Filter to a specific slot */
|
|
533
|
+
slotId?: string;
|
|
534
|
+
/** Specific notice types to include. Defaults to all notice types. */
|
|
535
|
+
types?: NoticeMomentType[];
|
|
536
|
+
}
|
|
537
|
+
|
|
491
538
|
/**
|
|
492
539
|
* Full tenant configuration including branding, services, and service items
|
|
493
540
|
* Service items are nested within each service object (not as a separate top-level array)
|