@revenexx/sdk 0.0.2

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.
Files changed (182) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +148 -0
  3. package/dist/cjs/package.json +3 -0
  4. package/dist/cjs/sdk.js +16340 -0
  5. package/dist/cjs/sdk.js.map +1 -0
  6. package/dist/esm/package.json +3 -0
  7. package/dist/esm/sdk.js +16250 -0
  8. package/dist/esm/sdk.js.map +1 -0
  9. package/dist/iife/sdk.js +20101 -0
  10. package/package.json +56 -0
  11. package/src/channel.ts +158 -0
  12. package/src/client.ts +950 -0
  13. package/src/enums/adapter.ts +4 -0
  14. package/src/enums/attribute-boolean-status.ts +7 -0
  15. package/src/enums/attribute-datetime-status.ts +7 -0
  16. package/src/enums/attribute-email-status.ts +7 -0
  17. package/src/enums/attribute-enum-status.ts +7 -0
  18. package/src/enums/attribute-float-status.ts +7 -0
  19. package/src/enums/attribute-integer-status.ts +7 -0
  20. package/src/enums/attribute-ip-status.ts +7 -0
  21. package/src/enums/attribute-line-status.ts +7 -0
  22. package/src/enums/attribute-longtext-status.ts +7 -0
  23. package/src/enums/attribute-mediumtext-status.ts +7 -0
  24. package/src/enums/attribute-point-status.ts +7 -0
  25. package/src/enums/attribute-polygon-status.ts +7 -0
  26. package/src/enums/attribute-relationship-status.ts +7 -0
  27. package/src/enums/attribute-string-status.ts +7 -0
  28. package/src/enums/attribute-text-status.ts +7 -0
  29. package/src/enums/attribute-url-status.ts +7 -0
  30. package/src/enums/attribute-varchar-status.ts +7 -0
  31. package/src/enums/build-runtime.ts +73 -0
  32. package/src/enums/code.ts +16 -0
  33. package/src/enums/collection.ts +4 -0
  34. package/src/enums/column-boolean-status.ts +7 -0
  35. package/src/enums/column-datetime-status.ts +7 -0
  36. package/src/enums/column-email-status.ts +7 -0
  37. package/src/enums/column-enum-status.ts +7 -0
  38. package/src/enums/column-float-status.ts +7 -0
  39. package/src/enums/column-integer-status.ts +7 -0
  40. package/src/enums/column-ip-status.ts +7 -0
  41. package/src/enums/column-line-status.ts +7 -0
  42. package/src/enums/column-longtext-status.ts +7 -0
  43. package/src/enums/column-mediumtext-status.ts +7 -0
  44. package/src/enums/column-point-status.ts +7 -0
  45. package/src/enums/column-polygon-status.ts +7 -0
  46. package/src/enums/column-relationship-status.ts +7 -0
  47. package/src/enums/column-string-status.ts +7 -0
  48. package/src/enums/column-text-status.ts +7 -0
  49. package/src/enums/column-url-status.ts +7 -0
  50. package/src/enums/column-varchar-status.ts +7 -0
  51. package/src/enums/compression.ts +5 -0
  52. package/src/enums/database-type.ts +4 -0
  53. package/src/enums/deployment-status.ts +8 -0
  54. package/src/enums/execution-status.ts +7 -0
  55. package/src/enums/execution-trigger.ts +5 -0
  56. package/src/enums/framework.ts +17 -0
  57. package/src/enums/gravity.ts +11 -0
  58. package/src/enums/health-antivirus-status.ts +5 -0
  59. package/src/enums/health-status-status.ts +4 -0
  60. package/src/enums/index-status.ts +7 -0
  61. package/src/enums/message-status.ts +7 -0
  62. package/src/enums/method.ts +9 -0
  63. package/src/enums/output.ts +9 -0
  64. package/src/enums/permissions.ts +22 -0
  65. package/src/enums/priority.ts +4 -0
  66. package/src/enums/range.ts +5 -0
  67. package/src/enums/runtime.ts +73 -0
  68. package/src/enums/runtimes.ts +73 -0
  69. package/src/enums/scopes.ts +57 -0
  70. package/src/enums/theme.ts +4 -0
  71. package/src/enums/timezone.ts +421 -0
  72. package/src/enums/type.ts +5 -0
  73. package/src/enums/use-cases.ts +9 -0
  74. package/src/id.ts +47 -0
  75. package/src/index.ts +92 -0
  76. package/src/models.ts +6013 -0
  77. package/src/operator.ts +308 -0
  78. package/src/permission.ts +57 -0
  79. package/src/query.ts +576 -0
  80. package/src/role.ts +100 -0
  81. package/src/service.ts +30 -0
  82. package/src/services/apps.ts +2473 -0
  83. package/src/services/avatars.ts +744 -0
  84. package/src/services/carts.ts +1057 -0
  85. package/src/services/channels.ts +227 -0
  86. package/src/services/customers.ts +729 -0
  87. package/src/services/greetings.ts +294 -0
  88. package/src/services/locale.ts +198 -0
  89. package/src/services/markets.ts +796 -0
  90. package/src/services/messaging.ts +3463 -0
  91. package/src/services/products.ts +3100 -0
  92. package/src/services/realtime.ts +537 -0
  93. package/src/services/search.ts +346 -0
  94. package/src/services/sites.ts +1847 -0
  95. package/src/services/storage.ts +1076 -0
  96. package/src/services/tokens.ts +314 -0
  97. package/types/channel.d.ts +74 -0
  98. package/types/client.d.ts +211 -0
  99. package/types/enums/adapter.d.ts +4 -0
  100. package/types/enums/attribute-boolean-status.d.ts +7 -0
  101. package/types/enums/attribute-datetime-status.d.ts +7 -0
  102. package/types/enums/attribute-email-status.d.ts +7 -0
  103. package/types/enums/attribute-enum-status.d.ts +7 -0
  104. package/types/enums/attribute-float-status.d.ts +7 -0
  105. package/types/enums/attribute-integer-status.d.ts +7 -0
  106. package/types/enums/attribute-ip-status.d.ts +7 -0
  107. package/types/enums/attribute-line-status.d.ts +7 -0
  108. package/types/enums/attribute-longtext-status.d.ts +7 -0
  109. package/types/enums/attribute-mediumtext-status.d.ts +7 -0
  110. package/types/enums/attribute-point-status.d.ts +7 -0
  111. package/types/enums/attribute-polygon-status.d.ts +7 -0
  112. package/types/enums/attribute-relationship-status.d.ts +7 -0
  113. package/types/enums/attribute-string-status.d.ts +7 -0
  114. package/types/enums/attribute-text-status.d.ts +7 -0
  115. package/types/enums/attribute-url-status.d.ts +7 -0
  116. package/types/enums/attribute-varchar-status.d.ts +7 -0
  117. package/types/enums/build-runtime.d.ts +73 -0
  118. package/types/enums/code.d.ts +16 -0
  119. package/types/enums/collection.d.ts +4 -0
  120. package/types/enums/column-boolean-status.d.ts +7 -0
  121. package/types/enums/column-datetime-status.d.ts +7 -0
  122. package/types/enums/column-email-status.d.ts +7 -0
  123. package/types/enums/column-enum-status.d.ts +7 -0
  124. package/types/enums/column-float-status.d.ts +7 -0
  125. package/types/enums/column-integer-status.d.ts +7 -0
  126. package/types/enums/column-ip-status.d.ts +7 -0
  127. package/types/enums/column-line-status.d.ts +7 -0
  128. package/types/enums/column-longtext-status.d.ts +7 -0
  129. package/types/enums/column-mediumtext-status.d.ts +7 -0
  130. package/types/enums/column-point-status.d.ts +7 -0
  131. package/types/enums/column-polygon-status.d.ts +7 -0
  132. package/types/enums/column-relationship-status.d.ts +7 -0
  133. package/types/enums/column-string-status.d.ts +7 -0
  134. package/types/enums/column-text-status.d.ts +7 -0
  135. package/types/enums/column-url-status.d.ts +7 -0
  136. package/types/enums/column-varchar-status.d.ts +7 -0
  137. package/types/enums/compression.d.ts +5 -0
  138. package/types/enums/database-type.d.ts +4 -0
  139. package/types/enums/deployment-status.d.ts +8 -0
  140. package/types/enums/execution-status.d.ts +7 -0
  141. package/types/enums/execution-trigger.d.ts +5 -0
  142. package/types/enums/framework.d.ts +17 -0
  143. package/types/enums/gravity.d.ts +11 -0
  144. package/types/enums/health-antivirus-status.d.ts +5 -0
  145. package/types/enums/health-status-status.d.ts +4 -0
  146. package/types/enums/index-status.d.ts +7 -0
  147. package/types/enums/message-status.d.ts +7 -0
  148. package/types/enums/method.d.ts +9 -0
  149. package/types/enums/output.d.ts +9 -0
  150. package/types/enums/permissions.d.ts +22 -0
  151. package/types/enums/priority.d.ts +4 -0
  152. package/types/enums/range.d.ts +5 -0
  153. package/types/enums/runtime.d.ts +73 -0
  154. package/types/enums/runtimes.d.ts +73 -0
  155. package/types/enums/scopes.d.ts +57 -0
  156. package/types/enums/theme.d.ts +4 -0
  157. package/types/enums/timezone.d.ts +421 -0
  158. package/types/enums/type.d.ts +5 -0
  159. package/types/enums/use-cases.d.ts +9 -0
  160. package/types/id.d.ts +20 -0
  161. package/types/index.d.ts +92 -0
  162. package/types/models.d.ts +5830 -0
  163. package/types/operator.d.ts +180 -0
  164. package/types/permission.d.ts +43 -0
  165. package/types/query.d.ts +442 -0
  166. package/types/role.d.ts +70 -0
  167. package/types/service.d.ts +11 -0
  168. package/types/services/apps.d.ts +932 -0
  169. package/types/services/avatars.d.ts +318 -0
  170. package/types/services/carts.d.ts +352 -0
  171. package/types/services/channels.d.ts +75 -0
  172. package/types/services/customers.d.ts +231 -0
  173. package/types/services/greetings.d.ts +101 -0
  174. package/types/services/locale.d.ts +64 -0
  175. package/types/services/markets.d.ts +274 -0
  176. package/types/services/messaging.d.ts +1324 -0
  177. package/types/services/products.d.ts +1014 -0
  178. package/types/services/realtime.d.ts +134 -0
  179. package/types/services/search.d.ts +131 -0
  180. package/types/services/sites.d.ts +689 -0
  181. package/types/services/storage.d.ts +421 -0
  182. package/types/services/tokens.d.ts +119 -0
@@ -0,0 +1,134 @@
1
+ import { Client } from '../client';
2
+ import { Channel, ActionableChannel, ResolvedChannel } from '../channel';
3
+ import { Query } from '../query';
4
+ export type RealtimeSubscription = {
5
+ close: () => Promise<void>;
6
+ };
7
+ export type RealtimeCallback<T = any> = {
8
+ channels: Set<string>;
9
+ queries: string[];
10
+ callback: (event: RealtimeResponseEvent<T>) => void;
11
+ };
12
+ export type RealtimeResponse = {
13
+ type: string;
14
+ data?: any;
15
+ };
16
+ export type RealtimeResponseEvent<T = any> = {
17
+ events: string[];
18
+ channels: string[];
19
+ timestamp: string;
20
+ payload: T;
21
+ subscriptions: string[];
22
+ };
23
+ export type RealtimeResponseConnected = {
24
+ channels: string[];
25
+ user?: object;
26
+ subscriptions?: {
27
+ [slot: string]: string;
28
+ };
29
+ };
30
+ export type RealtimeRequest = {
31
+ type: 'authentication';
32
+ data: {
33
+ session: string;
34
+ };
35
+ };
36
+ export declare enum RealtimeCode {
37
+ NORMAL_CLOSURE = 1000,
38
+ POLICY_VIOLATION = 1008,
39
+ UNKNOWN_ERROR = -1
40
+ }
41
+ export declare class Realtime {
42
+ private readonly TYPE_ERROR;
43
+ private readonly TYPE_EVENT;
44
+ private readonly TYPE_PONG;
45
+ private readonly TYPE_CONNECTED;
46
+ private readonly DEBOUNCE_MS;
47
+ private readonly HEARTBEAT_INTERVAL;
48
+ private client;
49
+ private socket?;
50
+ private activeSubscriptions;
51
+ private slotToSubscriptionId;
52
+ private subscriptionIdToSlot;
53
+ private heartbeatTimer?;
54
+ private subCallDepth;
55
+ private reconnectAttempts;
56
+ private subscriptionsCounter;
57
+ private connectionId;
58
+ private reconnect;
59
+ private onErrorCallbacks;
60
+ private onCloseCallbacks;
61
+ private onOpenCallbacks;
62
+ constructor(client: Client);
63
+ /**
64
+ * Register a callback function to be called when an error occurs
65
+ *
66
+ * @param {Function} callback - Callback function to handle errors
67
+ * @returns {void}
68
+ */
69
+ onError(callback: (error?: Error, statusCode?: number) => void): void;
70
+ /**
71
+ * Register a callback function to be called when the connection closes
72
+ *
73
+ * @param {Function} callback - Callback function to handle connection close
74
+ * @returns {void}
75
+ */
76
+ onClose(callback: () => void): void;
77
+ /**
78
+ * Register a callback function to be called when the connection opens
79
+ *
80
+ * @param {Function} callback - Callback function to handle connection open
81
+ * @returns {void}
82
+ */
83
+ onOpen(callback: () => void): void;
84
+ private startHeartbeat;
85
+ private stopHeartbeat;
86
+ private createSocket;
87
+ private closeSocket;
88
+ private getTimeout;
89
+ private sleep;
90
+ /**
91
+ * Convert a channel value to a string
92
+ *
93
+ * @private
94
+ * @param {string | Channel<any> | ActionableChannel | ResolvedChannel} channel - Channel value (string or Channel builder instance)
95
+ * @returns {string} Channel string representation
96
+ */
97
+ private channelToString;
98
+ /**
99
+ * Subscribe to a single channel
100
+ *
101
+ * @param {string | Channel<any> | ActionableChannel | ResolvedChannel} channel - Channel name to subscribe to (string or Channel builder instance)
102
+ * @param {Function} callback - Callback function to handle events
103
+ * @returns {Promise<RealtimeSubscription>} Subscription object with close method
104
+ */
105
+ subscribe(channel: string | Channel<any> | ActionableChannel | ResolvedChannel, callback: (event: RealtimeResponseEvent<any>) => void, queries?: (string | Query)[]): Promise<RealtimeSubscription>;
106
+ /**
107
+ * Subscribe to multiple channels
108
+ *
109
+ * @param {(string | Channel<any> | ActionableChannel | ResolvedChannel)[]} channels - Array of channel names to subscribe to (strings or Channel builder instances)
110
+ * @param {Function} callback - Callback function to handle events
111
+ * @returns {Promise<RealtimeSubscription>} Subscription object with close method
112
+ */
113
+ subscribe(channels: (string | Channel<any> | ActionableChannel | ResolvedChannel)[], callback: (event: RealtimeResponseEvent<any>) => void, queries?: (string | Query)[]): Promise<RealtimeSubscription>;
114
+ /**
115
+ * Subscribe to a single channel with typed payload
116
+ *
117
+ * @param {string | Channel<any> | ActionableChannel | ResolvedChannel} channel - Channel name to subscribe to (string or Channel builder instance)
118
+ * @param {Function} callback - Callback function to handle events with typed payload
119
+ * @returns {Promise<RealtimeSubscription>} Subscription object with close method
120
+ */
121
+ subscribe<T>(channel: string | Channel<any> | ActionableChannel | ResolvedChannel, callback: (event: RealtimeResponseEvent<T>) => void, queries?: (string | Query)[]): Promise<RealtimeSubscription>;
122
+ /**
123
+ * Subscribe to multiple channels with typed payload
124
+ *
125
+ * @param {(string | Channel<any> | ActionableChannel | ResolvedChannel)[]} channels - Array of channel names to subscribe to (strings or Channel builder instances)
126
+ * @param {Function} callback - Callback function to handle events with typed payload
127
+ * @returns {Promise<RealtimeSubscription>} Subscription object with close method
128
+ */
129
+ subscribe<T>(channels: (string | Channel<any> | ActionableChannel | ResolvedChannel)[], callback: (event: RealtimeResponseEvent<T>) => void, queries?: (string | Query)[]): Promise<RealtimeSubscription>;
130
+ private handleMessage;
131
+ private handleResponseConnected;
132
+ private handleResponseError;
133
+ private handleResponseEvent;
134
+ }
@@ -0,0 +1,131 @@
1
+ import { Client } from '../client';
2
+ import { Collection } from '../enums/collection';
3
+ export declare class Search {
4
+ client: Client;
5
+ constructor(client: Client);
6
+ /**
7
+ * The collections the tenant's installed apps have provisioned.
8
+ *
9
+ * @throws {RevenexxException}
10
+ * @returns {Promise<{}>}
11
+ */
12
+ searchListCollections(): Promise<{}>;
13
+ /**
14
+ * Full-text search within one collection using Typesense query parameters as the query string.
15
+ *
16
+ * @param {Collection} params.collection - Collection key (one the tenant has installed).
17
+ * @param {string} params.q - Query text. Use `*` to match all.
18
+ * @param {string} params.queryBy - Comma-separated fields to search.
19
+ * @param {string} params.filterBy - Filter expression.
20
+ * @param {string} params.sortBy - Sort expression.
21
+ * @param {number} params.page - 1-based page.
22
+ * @param {number} params.perPage - Hits per page (max 250).
23
+ * @throws {RevenexxException}
24
+ * @returns {Promise<{}>}
25
+ */
26
+ searchSearchDocumentsGet(params: {
27
+ collection: Collection;
28
+ q?: string;
29
+ queryBy?: string;
30
+ filterBy?: string;
31
+ sortBy?: string;
32
+ page?: number;
33
+ perPage?: number;
34
+ }): Promise<{}>;
35
+ /**
36
+ * Full-text search within one collection using Typesense query parameters as the query string.
37
+ *
38
+ * @param {Collection} collection - Collection key (one the tenant has installed).
39
+ * @param {string} q - Query text. Use `*` to match all.
40
+ * @param {string} queryBy - Comma-separated fields to search.
41
+ * @param {string} filterBy - Filter expression.
42
+ * @param {string} sortBy - Sort expression.
43
+ * @param {number} page - 1-based page.
44
+ * @param {number} perPage - Hits per page (max 250).
45
+ * @throws {RevenexxException}
46
+ * @returns {Promise<{}>}
47
+ * @deprecated Use the object parameter style method for a better developer experience.
48
+ */
49
+ searchSearchDocumentsGet(collection: Collection, q?: string, queryBy?: string, filterBy?: string, sortBy?: string, page?: number, perPage?: number): Promise<{}>;
50
+ /**
51
+ * Full-text search within one collection. The body holds Typesense search parameters.
52
+ *
53
+ * @param {Collection} params.collection - Collection key (one the tenant has installed).
54
+ * @param {string} params.facetBy - Comma-separated fields to facet on.
55
+ * @param {string} params.filterBy - Filter expression, e.g. `in_stock:=true`.
56
+ * @param {number} params.page -
57
+ * @param {number} params.perPage -
58
+ * @param {string} params.q - Query text. Use `*` to match all.
59
+ * @param {string} params.queryBy - Comma-separated fields to search.
60
+ * @param {string} params.sortBy - Sort expression, e.g. `price:desc`.
61
+ * @throws {RevenexxException}
62
+ * @returns {Promise<{}>}
63
+ */
64
+ searchSearchDocuments(params: {
65
+ collection: Collection;
66
+ facetBy?: string;
67
+ filterBy?: string;
68
+ page?: number;
69
+ perPage?: number;
70
+ q?: string;
71
+ queryBy?: string;
72
+ sortBy?: string;
73
+ }): Promise<{}>;
74
+ /**
75
+ * Full-text search within one collection. The body holds Typesense search parameters.
76
+ *
77
+ * @param {Collection} collection - Collection key (one the tenant has installed).
78
+ * @param {string} facetBy - Comma-separated fields to facet on.
79
+ * @param {string} filterBy - Filter expression, e.g. `in_stock:=true`.
80
+ * @param {number} page -
81
+ * @param {number} perPage -
82
+ * @param {string} q - Query text. Use `*` to match all.
83
+ * @param {string} queryBy - Comma-separated fields to search.
84
+ * @param {string} sortBy - Sort expression, e.g. `price:desc`.
85
+ * @throws {RevenexxException}
86
+ * @returns {Promise<{}>}
87
+ * @deprecated Use the object parameter style method for a better developer experience.
88
+ */
89
+ searchSearchDocuments(collection: Collection, facetBy?: string, filterBy?: string, page?: number, perPage?: number, q?: string, queryBy?: string, sortBy?: string): Promise<{}>;
90
+ /**
91
+ * Fetch a single document by id from a collection the tenant has installed.
92
+ *
93
+ * @param {Collection} params.collection - Collection key (one the tenant has installed).
94
+ * @param {string} params.documentId - Document id within the collection.
95
+ * @throws {RevenexxException}
96
+ * @returns {Promise<{}>}
97
+ */
98
+ searchGetDocument(params: {
99
+ collection: Collection;
100
+ documentId: string;
101
+ }): Promise<{}>;
102
+ /**
103
+ * Fetch a single document by id from a collection the tenant has installed.
104
+ *
105
+ * @param {Collection} collection - Collection key (one the tenant has installed).
106
+ * @param {string} documentId - Document id within the collection.
107
+ * @throws {RevenexxException}
108
+ * @returns {Promise<{}>}
109
+ * @deprecated Use the object parameter style method for a better developer experience.
110
+ */
111
+ searchGetDocument(collection: Collection, documentId: string): Promise<{}>;
112
+ /**
113
+ * Run several searches in one request (the InstantSearch adapter uses this). Each entry names its collection.
114
+ *
115
+ * @param {object[]} params.searches -
116
+ * @throws {RevenexxException}
117
+ * @returns {Promise<{}>}
118
+ */
119
+ searchMultiSearch(params: {
120
+ searches: object[];
121
+ }): Promise<{}>;
122
+ /**
123
+ * Run several searches in one request (the InstantSearch adapter uses this). Each entry names its collection.
124
+ *
125
+ * @param {object[]} searches -
126
+ * @throws {RevenexxException}
127
+ * @returns {Promise<{}>}
128
+ * @deprecated Use the object parameter style method for a better developer experience.
129
+ */
130
+ searchMultiSearch(searches: object[]): Promise<{}>;
131
+ }