@appwrite.io/console 17.0.0 → 18.1.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 +3 -3
- package/dist/cjs/sdk.js +6007 -4860
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +6004 -4861
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +8009 -4863
- package/package.json +5 -2
- package/types/client.d.ts +25 -1
- package/types/enums/conversation-type.d.ts +9 -0
- package/types/enums/o-auth-2-auth-0-prompt.d.ts +5 -0
- package/types/enums/o-auth-2-discord-prompt.d.ts +4 -0
- package/types/enums/o-auth-2-github-prompt.d.ts +3 -0
- package/types/enums/o-auth-2-kakao-prompt.d.ts +6 -0
- package/types/enums/o-auth-2-microsoft-prompt.d.ts +6 -0
- package/types/enums/o-auth-2-okta-prompt.d.ts +5 -0
- package/types/enums/o-auth-2-salesforce-prompt.d.ts +4 -0
- package/types/enums/o-auth-2-zoho-prompt.d.ts +3 -0
- package/types/enums/project-email-template-id.d.ts +2 -1
- package/types/enums/project-o-auth-2-auth-0-prompt.d.ts +5 -0
- package/types/enums/project-o-auth-2-discord-prompt.d.ts +4 -0
- package/types/enums/project-o-auth-2-git-hub-prompt.d.ts +3 -0
- package/types/enums/project-o-auth-2-kakao-prompt.d.ts +6 -0
- package/types/enums/project-o-auth-2-microsoft-prompt.d.ts +6 -0
- package/types/enums/project-o-auth-2-okta-prompt.d.ts +5 -0
- package/types/enums/project-o-auth-2-salesforce-prompt.d.ts +4 -0
- package/types/enums/project-o-auth-2-zoho-prompt.d.ts +3 -0
- package/types/enums/query-suggestion-resource.d.ts +1 -1
- package/types/index.d.ts +22 -1
- package/types/models.d.ts +68 -7
- package/types/services/account.d.ts +57 -2
- package/types/services/assistant.d.ts +4 -4
- package/types/services/console.d.ts +2 -2
- package/types/services/databases.d.ts +4 -4
- package/types/services/domains.d.ts +4 -4
- package/types/services/growth.d.ts +100 -0
- package/types/services/manager.d.ts +25 -0
- package/types/services/messaging.d.ts +14 -2
- package/types/services/organizations.d.ts +0 -19
- package/types/services/project.d.ts +52 -20
- package/types/services/push.d.ts +153 -0
- package/types/services/tables-db.d.ts +37 -37
- package/types/services/users.d.ts +2 -2
- package/types/topic.d.ts +34 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Client } from '../client';
|
|
2
|
+
import { Service } from '../service';
|
|
3
|
+
import type { ResolvedTopic, Topic } from '../topic';
|
|
4
|
+
/** A message delivered on a subscribed topic (the MQTT analog of a Realtime event). */
|
|
5
|
+
export interface PushMessage {
|
|
6
|
+
topic: string;
|
|
7
|
+
/** The payload decoded as UTF-8 text, as it was sent. */
|
|
8
|
+
data: string;
|
|
9
|
+
/** The raw payload, for binary messages. */
|
|
10
|
+
payload: Uint8Array;
|
|
11
|
+
qos: number;
|
|
12
|
+
}
|
|
13
|
+
export type MessageCallback = (message: PushMessage) => void | Promise<void>;
|
|
14
|
+
/** Per-subscription options passed to `subscribe` and `PushSubscription.update`. */
|
|
15
|
+
export interface SubscribeOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Also surface each matching message as a browser notification while the tab is
|
|
18
|
+
* open. Defaults to false.
|
|
19
|
+
*/
|
|
20
|
+
background?: boolean;
|
|
21
|
+
/** Notification title for this subscription. Defaults to the message topic. */
|
|
22
|
+
title?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Retry delivery of messages missed while disconnected. `true` (the default) subscribes
|
|
25
|
+
* at QoS 1 so the broker holds this topic's messages and redelivers them on reconnect;
|
|
26
|
+
* `false` uses QoS 0 (at-most-once, may be lost). Per-subscription — the connection
|
|
27
|
+
* always keeps its session (clean start off).
|
|
28
|
+
*/
|
|
29
|
+
retry?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Handle for a live subscription. `unsubscribe()` drops it (and closes the connection
|
|
33
|
+
* once the last one is gone); `update()` toggles this subscription's per-message options
|
|
34
|
+
* without resubscribing.
|
|
35
|
+
*/
|
|
36
|
+
export interface PushSubscription {
|
|
37
|
+
unsubscribe(): void;
|
|
38
|
+
update(options: SubscribeOptions): void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Appwrite native push service — the Realtime analog over an MQTT broker, without
|
|
42
|
+
* FCM or APNS. In the browser the transport is MQTT 5 over WebSocket: while the page is
|
|
43
|
+
* open the connection stays up and each message is handed to your callback, and a
|
|
44
|
+
* subscription may also opt into a browser notification per message.
|
|
45
|
+
*
|
|
46
|
+
* The connection has no tunables — it always keeps its session (clean start off) so the
|
|
47
|
+
* broker can redeliver missed messages, and reliability is chosen per subscription via
|
|
48
|
+
* `retry`. `subscribe` opens the connection lazily and returns a
|
|
49
|
+
* {@link PushSubscription} handle (unlike Realtime's bare unsubscribe callable — Push
|
|
50
|
+
* carries per-subscription state). The credential is read off the client — set a JWT or
|
|
51
|
+
* session on it (`Client.setJWT` / `Client.setSession`), the same way every other service
|
|
52
|
+
* reads auth.
|
|
53
|
+
*
|
|
54
|
+
* const client = new Client().setEndpoint(...).setProject(...).setJWT(jwt);
|
|
55
|
+
* const push = new Push(client);
|
|
56
|
+
* const sub = await push.subscribe('user/123/#', (m) =>
|
|
57
|
+
* console.log(m.topic, m.data),
|
|
58
|
+
* );
|
|
59
|
+
* // sub.update({ background: true }); sub.unsubscribe();
|
|
60
|
+
*/
|
|
61
|
+
export declare class Push extends Service {
|
|
62
|
+
private mqtt;
|
|
63
|
+
private connecting;
|
|
64
|
+
/** Set once the first CONNACK lands, so 'connect' events after are reconnects. */
|
|
65
|
+
private everConnected;
|
|
66
|
+
private onOpenCb?;
|
|
67
|
+
private onCloseCb?;
|
|
68
|
+
private onErrorCb?;
|
|
69
|
+
/** Errors already handed to onError, so one failure is reported once. */
|
|
70
|
+
private reported;
|
|
71
|
+
/** mqtt.js connect errors mapped to the error handed out for them (see connectError). */
|
|
72
|
+
private connectErrors;
|
|
73
|
+
/** True while the first connect is in flight: its errors go to the waiting caller. */
|
|
74
|
+
private opening;
|
|
75
|
+
/**
|
|
76
|
+
* The client id when the credential names no user (and none was set): random, but kept for
|
|
77
|
+
* this instance so reconnects resume the same broker session.
|
|
78
|
+
*/
|
|
79
|
+
private readonly fallbackClientId;
|
|
80
|
+
private readonly subscriptions;
|
|
81
|
+
constructor(client: Client);
|
|
82
|
+
private effectiveQos;
|
|
83
|
+
/** Register a callback invoked when the connection opens (CONNACK success). */
|
|
84
|
+
onOpen(callback: () => void): this;
|
|
85
|
+
/** Register a callback invoked when the connection closes. */
|
|
86
|
+
onClose(callback: () => void): this;
|
|
87
|
+
/** Register a callback invoked on a connection error. */
|
|
88
|
+
onError(callback: (error: Error) => void): this;
|
|
89
|
+
/**
|
|
90
|
+
* The signed-in user's own topic, `users/<userId>`, for a topic-less subscribe. The id comes
|
|
91
|
+
* from the credential the connection authenticates with: the JWT when one is set (never
|
|
92
|
+
* the session, which could belong to a different user), else the session.
|
|
93
|
+
*/
|
|
94
|
+
private userTopic;
|
|
95
|
+
/**
|
|
96
|
+
* Hand an error to the onError callback, once per error. These errors happen outside any
|
|
97
|
+
* call (reconnects, broker DISCONNECTs, background re-subscribes), so they are never
|
|
98
|
+
* thrown, which would crash the app from inside mqtt.js: with no callback registered
|
|
99
|
+
* they are logged, like Realtime does.
|
|
100
|
+
*/
|
|
101
|
+
private report;
|
|
102
|
+
/**
|
|
103
|
+
* For a call that fails to its caller: report the error to onError when a callback is
|
|
104
|
+
* registered, then throw it to the caller, who can catch it.
|
|
105
|
+
*/
|
|
106
|
+
private fail;
|
|
107
|
+
/**
|
|
108
|
+
* Subscribe to one or more topics. Resolves to a {@link PushSubscription} handle.
|
|
109
|
+
*
|
|
110
|
+
* Each topic is a string or a `Topic` builder, e.g.
|
|
111
|
+
* `Topic.path(['user', userId]).all()`.
|
|
112
|
+
*
|
|
113
|
+
* Called with only a callback, `subscribe((message) => {...}, options)` subscribes to the
|
|
114
|
+
* signed-in user's own topic, `users/<userId>`, like FCM/APNs delivery to a device. The
|
|
115
|
+
* user id is read from the JWT (or session) set on the client. This form defaults to
|
|
116
|
+
* `background: true` and `retry: true` (QoS 1); pass either in the options to override.
|
|
117
|
+
*
|
|
118
|
+
* Awaiting resolves only once the broker has acked every SUBSCRIBE (SUBACK):
|
|
119
|
+
* the broker only starts routing a topic once its subscription is registered,
|
|
120
|
+
* so publishing before the ack races the message ahead of the subscription and
|
|
121
|
+
* it is dropped (no retained replay on MQTT). Awaiting here makes
|
|
122
|
+
* subscribe-then-publish reliable.
|
|
123
|
+
*
|
|
124
|
+
* Pass `{ background: true, title }` to also show a browser notification per matching
|
|
125
|
+
* message while the tab is open, and `{ retry: false }` for at-most-once
|
|
126
|
+
* (QoS 0) delivery; toggle either later with the handle's `update`.
|
|
127
|
+
*/
|
|
128
|
+
subscribe(callback: MessageCallback, options?: SubscribeOptions): Promise<PushSubscription>;
|
|
129
|
+
subscribe(topics: string | Topic | ResolvedTopic | (string | Topic | ResolvedTopic)[], callback: MessageCallback, options?: SubscribeOptions): Promise<PushSubscription>;
|
|
130
|
+
private subscribeWith;
|
|
131
|
+
/** Tear down the connection and drop all active subscriptions. */
|
|
132
|
+
close(): void;
|
|
133
|
+
/**
|
|
134
|
+
* Re-register every active subscription. Called on each reconnect so a client that
|
|
135
|
+
* reconnects with a fresh (or cleared) session does not silently stop receiving;
|
|
136
|
+
* re-subscribing an existing filter is idempotent.
|
|
137
|
+
*/
|
|
138
|
+
private resubscribeAll;
|
|
139
|
+
private connect;
|
|
140
|
+
private endpointUrl;
|
|
141
|
+
private open;
|
|
142
|
+
/**
|
|
143
|
+
* The error for a failed connect: the broker's Reason String when it sent one (a refused
|
|
144
|
+
* CONNACK), else mqtt.js's error. Memoized so both error listeners hand out the same
|
|
145
|
+
* object and it is reported once.
|
|
146
|
+
*/
|
|
147
|
+
private connectError;
|
|
148
|
+
/** Fan a delivered packet out to every subscription whose filter matches. */
|
|
149
|
+
private dispatch;
|
|
150
|
+
private requestNotificationPermission;
|
|
151
|
+
/** Post a browser notification for a message a background subscription matched. */
|
|
152
|
+
private notify;
|
|
153
|
+
}
|
|
@@ -1642,6 +1642,39 @@ export declare class TablesDB {
|
|
|
1642
1642
|
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1643
1643
|
*/
|
|
1644
1644
|
createRelationshipColumn(databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise<Models.ColumnRelationship>;
|
|
1645
|
+
/**
|
|
1646
|
+
* Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns).
|
|
1647
|
+
*
|
|
1648
|
+
*
|
|
1649
|
+
* @param {string} params.databaseId - Database ID.
|
|
1650
|
+
* @param {string} params.tableId - Table ID.
|
|
1651
|
+
* @param {string} params.key - Column Key.
|
|
1652
|
+
* @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull.
|
|
1653
|
+
* @param {string} params.newKey - New Column Key.
|
|
1654
|
+
* @throws {AppwriteException}
|
|
1655
|
+
* @returns {Promise<Models.ColumnRelationship>}
|
|
1656
|
+
*/
|
|
1657
|
+
updateRelationshipColumn(params: {
|
|
1658
|
+
databaseId: string;
|
|
1659
|
+
tableId: string;
|
|
1660
|
+
key: string;
|
|
1661
|
+
onDelete?: RelationMutate;
|
|
1662
|
+
newKey?: string;
|
|
1663
|
+
}): Promise<Models.ColumnRelationship>;
|
|
1664
|
+
/**
|
|
1665
|
+
* Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns).
|
|
1666
|
+
*
|
|
1667
|
+
*
|
|
1668
|
+
* @param {string} databaseId - Database ID.
|
|
1669
|
+
* @param {string} tableId - Table ID.
|
|
1670
|
+
* @param {string} key - Column Key.
|
|
1671
|
+
* @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull.
|
|
1672
|
+
* @param {string} newKey - New Column Key.
|
|
1673
|
+
* @throws {AppwriteException}
|
|
1674
|
+
* @returns {Promise<Models.ColumnRelationship>}
|
|
1675
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1676
|
+
*/
|
|
1677
|
+
updateRelationshipColumn(databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise<Models.ColumnRelationship>;
|
|
1645
1678
|
/**
|
|
1646
1679
|
* Create a string column.
|
|
1647
1680
|
*
|
|
@@ -1960,13 +1993,13 @@ export declare class TablesDB {
|
|
|
1960
1993
|
* @param {string} params.tableId - Table ID.
|
|
1961
1994
|
* @param {string} params.key - Column Key.
|
|
1962
1995
|
* @throws {AppwriteException}
|
|
1963
|
-
* @returns {Promise<Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnString>}
|
|
1996
|
+
* @returns {Promise<Models.ColumnBoolean | Models.ColumnBigint | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString>}
|
|
1964
1997
|
*/
|
|
1965
1998
|
getColumn(params: {
|
|
1966
1999
|
databaseId: string;
|
|
1967
2000
|
tableId: string;
|
|
1968
2001
|
key: string;
|
|
1969
|
-
}): Promise<Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnString>;
|
|
2002
|
+
}): Promise<Models.ColumnBoolean | Models.ColumnBigint | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString>;
|
|
1970
2003
|
/**
|
|
1971
2004
|
* Get column by ID.
|
|
1972
2005
|
*
|
|
@@ -1974,10 +2007,10 @@ export declare class TablesDB {
|
|
|
1974
2007
|
* @param {string} tableId - Table ID.
|
|
1975
2008
|
* @param {string} key - Column Key.
|
|
1976
2009
|
* @throws {AppwriteException}
|
|
1977
|
-
* @returns {Promise<Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnString>}
|
|
2010
|
+
* @returns {Promise<Models.ColumnBoolean | Models.ColumnBigint | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString>}
|
|
1978
2011
|
* @deprecated Use the object parameter style method for a better developer experience.
|
|
1979
2012
|
*/
|
|
1980
|
-
getColumn(databaseId: string, tableId: string, key: string): Promise<Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnString>;
|
|
2013
|
+
getColumn(databaseId: string, tableId: string, key: string): Promise<Models.ColumnBoolean | Models.ColumnBigint | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString>;
|
|
1981
2014
|
/**
|
|
1982
2015
|
* Deletes a column.
|
|
1983
2016
|
*
|
|
@@ -2003,39 +2036,6 @@ export declare class TablesDB {
|
|
|
2003
2036
|
* @deprecated Use the object parameter style method for a better developer experience.
|
|
2004
2037
|
*/
|
|
2005
2038
|
deleteColumn(databaseId: string, tableId: string, key: string): Promise<{}>;
|
|
2006
|
-
/**
|
|
2007
|
-
* Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns).
|
|
2008
|
-
*
|
|
2009
|
-
*
|
|
2010
|
-
* @param {string} params.databaseId - Database ID.
|
|
2011
|
-
* @param {string} params.tableId - Table ID.
|
|
2012
|
-
* @param {string} params.key - Column Key.
|
|
2013
|
-
* @param {RelationMutate} params.onDelete - Delete constraint. Possible values are: cascade, restrict, setNull.
|
|
2014
|
-
* @param {string} params.newKey - New Column Key.
|
|
2015
|
-
* @throws {AppwriteException}
|
|
2016
|
-
* @returns {Promise<Models.ColumnRelationship>}
|
|
2017
|
-
*/
|
|
2018
|
-
updateRelationshipColumn(params: {
|
|
2019
|
-
databaseId: string;
|
|
2020
|
-
tableId: string;
|
|
2021
|
-
key: string;
|
|
2022
|
-
onDelete?: RelationMutate;
|
|
2023
|
-
newKey?: string;
|
|
2024
|
-
}): Promise<Models.ColumnRelationship>;
|
|
2025
|
-
/**
|
|
2026
|
-
* Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns).
|
|
2027
|
-
*
|
|
2028
|
-
*
|
|
2029
|
-
* @param {string} databaseId - Database ID.
|
|
2030
|
-
* @param {string} tableId - Table ID.
|
|
2031
|
-
* @param {string} key - Column Key.
|
|
2032
|
-
* @param {RelationMutate} onDelete - Delete constraint. Possible values are: cascade, restrict, setNull.
|
|
2033
|
-
* @param {string} newKey - New Column Key.
|
|
2034
|
-
* @throws {AppwriteException}
|
|
2035
|
-
* @returns {Promise<Models.ColumnRelationship>}
|
|
2036
|
-
* @deprecated Use the object parameter style method for a better developer experience.
|
|
2037
|
-
*/
|
|
2038
|
-
updateRelationshipColumn(databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise<Models.ColumnRelationship>;
|
|
2039
2039
|
/**
|
|
2040
2040
|
* List indexes on the table.
|
|
2041
2041
|
*
|
|
@@ -412,7 +412,7 @@ export declare class Users {
|
|
|
412
412
|
*/
|
|
413
413
|
updateEmail<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string): Promise<Models.User<Preferences>>;
|
|
414
414
|
/**
|
|
415
|
-
* Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data.
|
|
415
|
+
* Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. Account endpoints are read-only while impersonating: they report the target's account, and anything that would change it is refused, so an impersonator cannot alter the target's credentials or delete their account.
|
|
416
416
|
*
|
|
417
417
|
*
|
|
418
418
|
* @param {string} params.userId - User ID.
|
|
@@ -425,7 +425,7 @@ export declare class Users {
|
|
|
425
425
|
impersonator: boolean;
|
|
426
426
|
}): Promise<Models.User<Preferences>>;
|
|
427
427
|
/**
|
|
428
|
-
* Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data.
|
|
428
|
+
* Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. Account endpoints are read-only while impersonating: they report the target's account, and anything that would change it is refused, so an impersonator cannot alter the target's credentials or delete their account.
|
|
429
429
|
*
|
|
430
430
|
*
|
|
431
431
|
* @param {string} userId - User ID.
|
package/types/topic.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper to build MQTT topics for `Push`, level by level.
|
|
3
|
+
*
|
|
4
|
+
* Topic.path(['user', userId, 'notification']); // "user/123/notification"
|
|
5
|
+
* Topic.path(['user']).any().path(['notification']); // "user/+/notification"
|
|
6
|
+
* Topic.path(['org']).any().path(['logs']).all(); // "org/+/logs/#"
|
|
7
|
+
*
|
|
8
|
+
* `any()` matches exactly one level and `all()` everything below, at any depth (including the
|
|
9
|
+
* parent itself). `all()` ends the topic, so it returns a {@link ResolvedTopic}.
|
|
10
|
+
*/
|
|
11
|
+
export declare class Topic {
|
|
12
|
+
private readonly levels;
|
|
13
|
+
private constructor();
|
|
14
|
+
/** Start a topic with the given levels, e.g. `Topic.path(['user', userId])`. */
|
|
15
|
+
static path(levels: string[]): Topic;
|
|
16
|
+
/** Start a topic with a single-level wildcard (`+`). */
|
|
17
|
+
static any(): Topic;
|
|
18
|
+
/** The multi-level wildcard alone (`#`): matches every topic. */
|
|
19
|
+
static all(): ResolvedTopic;
|
|
20
|
+
/** Append the given levels. */
|
|
21
|
+
path(levels: string[]): Topic;
|
|
22
|
+
/** Append a single-level wildcard (`+`): matches exactly one level. */
|
|
23
|
+
any(): Topic;
|
|
24
|
+
/** Append the multi-level wildcard (`#`) and end the topic. */
|
|
25
|
+
all(): ResolvedTopic;
|
|
26
|
+
toString(): string;
|
|
27
|
+
}
|
|
28
|
+
/** A topic ended by `all()`: nothing can be appended after the `#` wildcard. */
|
|
29
|
+
export declare class ResolvedTopic {
|
|
30
|
+
private readonly levels;
|
|
31
|
+
/** @internal Created by {@link Topic.all}. */
|
|
32
|
+
constructor(levels: readonly string[]);
|
|
33
|
+
toString(): string;
|
|
34
|
+
}
|