activitysmith 0.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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -0
  3. package/dist/generated/apis/LiveActivitiesApi.d.ts +57 -0
  4. package/dist/generated/apis/LiveActivitiesApi.js +129 -0
  5. package/dist/generated/apis/NotificationsApi.d.ts +31 -0
  6. package/dist/generated/apis/NotificationsApi.js +59 -0
  7. package/dist/generated/apis/index.d.ts +2 -0
  8. package/dist/generated/apis/index.js +20 -0
  9. package/dist/generated/index.d.ts +3 -0
  10. package/dist/generated/index.js +21 -0
  11. package/dist/generated/models/ContentStateEnd.d.ts +97 -0
  12. package/dist/generated/models/ContentStateEnd.js +89 -0
  13. package/dist/generated/models/ContentStateStart.d.ts +104 -0
  14. package/dist/generated/models/ContentStateStart.js +99 -0
  15. package/dist/generated/models/ContentStateUpdate.d.ts +91 -0
  16. package/dist/generated/models/ContentStateUpdate.js +87 -0
  17. package/dist/generated/models/LiveActivityEndRequest.d.ts +38 -0
  18. package/dist/generated/models/LiveActivityEndRequest.js +51 -0
  19. package/dist/generated/models/LiveActivityEndResponse.d.ts +55 -0
  20. package/dist/generated/models/LiveActivityEndResponse.js +58 -0
  21. package/dist/generated/models/LiveActivityLimitError.d.ts +49 -0
  22. package/dist/generated/models/LiveActivityLimitError.js +58 -0
  23. package/dist/generated/models/LiveActivityStartRequest.d.ts +32 -0
  24. package/dist/generated/models/LiveActivityStartRequest.js +47 -0
  25. package/dist/generated/models/LiveActivityStartResponse.d.ts +55 -0
  26. package/dist/generated/models/LiveActivityStartResponse.js +58 -0
  27. package/dist/generated/models/LiveActivityUpdateRequest.d.ts +38 -0
  28. package/dist/generated/models/LiveActivityUpdateRequest.js +51 -0
  29. package/dist/generated/models/LiveActivityUpdateResponse.d.ts +55 -0
  30. package/dist/generated/models/LiveActivityUpdateResponse.js +58 -0
  31. package/dist/generated/models/PushNotificationRequest.d.ts +43 -0
  32. package/dist/generated/models/PushNotificationRequest.js +50 -0
  33. package/dist/generated/models/PushNotificationResponse.d.ts +49 -0
  34. package/dist/generated/models/PushNotificationResponse.js +54 -0
  35. package/dist/generated/models/RateLimitError.d.ts +37 -0
  36. package/dist/generated/models/RateLimitError.js +50 -0
  37. package/dist/generated/models/SendPushNotification429Response.d.ts +22 -0
  38. package/dist/generated/models/SendPushNotification429Response.js +46 -0
  39. package/dist/generated/models/index.d.ts +14 -0
  40. package/dist/generated/models/index.js +32 -0
  41. package/dist/generated/runtime.d.ts +181 -0
  42. package/dist/generated/runtime.js +329 -0
  43. package/package.json +40 -0
@@ -0,0 +1,22 @@
1
+ /**
2
+ * ActivitySmith API
3
+ * Send push notifications and Live Activities to your own devices via a single API key.
4
+ *
5
+ * The version of the OpenAPI document: 1.0.0
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ import type { LiveActivityLimitError } from './LiveActivityLimitError';
13
+ import type { RateLimitError } from './RateLimitError';
14
+ /**
15
+ * @type SendPushNotification429Response
16
+ *
17
+ * @export
18
+ */
19
+ export type SendPushNotification429Response = LiveActivityLimitError | RateLimitError;
20
+ export declare function SendPushNotification429ResponseFromJSON(json: any): SendPushNotification429Response;
21
+ export declare function SendPushNotification429ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): SendPushNotification429Response;
22
+ export declare function SendPushNotification429ResponseToJSON(value?: SendPushNotification429Response | null): any;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * ActivitySmith API
6
+ * Send push notifications and Live Activities to your own devices via a single API key.
7
+ *
8
+ * The version of the OpenAPI document: 1.0.0
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.SendPushNotification429ResponseFromJSON = SendPushNotification429ResponseFromJSON;
17
+ exports.SendPushNotification429ResponseFromJSONTyped = SendPushNotification429ResponseFromJSONTyped;
18
+ exports.SendPushNotification429ResponseToJSON = SendPushNotification429ResponseToJSON;
19
+ const LiveActivityLimitError_1 = require("./LiveActivityLimitError");
20
+ const RateLimitError_1 = require("./RateLimitError");
21
+ function SendPushNotification429ResponseFromJSON(json) {
22
+ return SendPushNotification429ResponseFromJSONTyped(json, false);
23
+ }
24
+ function SendPushNotification429ResponseFromJSONTyped(json, ignoreDiscriminator) {
25
+ if (json == null) {
26
+ return json;
27
+ }
28
+ if ((0, LiveActivityLimitError_1.instanceOfLiveActivityLimitError)(json)) {
29
+ return (0, LiveActivityLimitError_1.LiveActivityLimitErrorFromJSONTyped)(json, true);
30
+ }
31
+ if ((0, RateLimitError_1.instanceOfRateLimitError)(json)) {
32
+ return (0, RateLimitError_1.RateLimitErrorFromJSONTyped)(json, true);
33
+ }
34
+ }
35
+ function SendPushNotification429ResponseToJSON(value) {
36
+ if (value == null) {
37
+ return value;
38
+ }
39
+ if ((0, LiveActivityLimitError_1.instanceOfLiveActivityLimitError)(value)) {
40
+ return (0, LiveActivityLimitError_1.LiveActivityLimitErrorToJSON)(value);
41
+ }
42
+ if ((0, RateLimitError_1.instanceOfRateLimitError)(value)) {
43
+ return (0, RateLimitError_1.RateLimitErrorToJSON)(value);
44
+ }
45
+ return {};
46
+ }
@@ -0,0 +1,14 @@
1
+ export * from './ContentStateEnd';
2
+ export * from './ContentStateStart';
3
+ export * from './ContentStateUpdate';
4
+ export * from './LiveActivityEndRequest';
5
+ export * from './LiveActivityEndResponse';
6
+ export * from './LiveActivityLimitError';
7
+ export * from './LiveActivityStartRequest';
8
+ export * from './LiveActivityStartResponse';
9
+ export * from './LiveActivityUpdateRequest';
10
+ export * from './LiveActivityUpdateResponse';
11
+ export * from './PushNotificationRequest';
12
+ export * from './PushNotificationResponse';
13
+ export * from './RateLimitError';
14
+ export * from './SendPushNotification429Response';
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ /* tslint:disable */
18
+ /* eslint-disable */
19
+ __exportStar(require("./ContentStateEnd"), exports);
20
+ __exportStar(require("./ContentStateStart"), exports);
21
+ __exportStar(require("./ContentStateUpdate"), exports);
22
+ __exportStar(require("./LiveActivityEndRequest"), exports);
23
+ __exportStar(require("./LiveActivityEndResponse"), exports);
24
+ __exportStar(require("./LiveActivityLimitError"), exports);
25
+ __exportStar(require("./LiveActivityStartRequest"), exports);
26
+ __exportStar(require("./LiveActivityStartResponse"), exports);
27
+ __exportStar(require("./LiveActivityUpdateRequest"), exports);
28
+ __exportStar(require("./LiveActivityUpdateResponse"), exports);
29
+ __exportStar(require("./PushNotificationRequest"), exports);
30
+ __exportStar(require("./PushNotificationResponse"), exports);
31
+ __exportStar(require("./RateLimitError"), exports);
32
+ __exportStar(require("./SendPushNotification429Response"), exports);
@@ -0,0 +1,181 @@
1
+ /**
2
+ * ActivitySmith API
3
+ * Send push notifications and Live Activities to your own devices via a single API key.
4
+ *
5
+ * The version of the OpenAPI document: 1.0.0
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ export declare const BASE_PATH: string;
13
+ export interface ConfigurationParameters {
14
+ basePath?: string;
15
+ fetchApi?: FetchAPI;
16
+ middleware?: Middleware[];
17
+ queryParamsStringify?: (params: HTTPQuery) => string;
18
+ username?: string;
19
+ password?: string;
20
+ apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>);
21
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>);
22
+ headers?: HTTPHeaders;
23
+ credentials?: RequestCredentials;
24
+ }
25
+ export declare class Configuration {
26
+ private configuration;
27
+ constructor(configuration?: ConfigurationParameters);
28
+ set config(configuration: Configuration);
29
+ get basePath(): string;
30
+ get fetchApi(): FetchAPI | undefined;
31
+ get middleware(): Middleware[];
32
+ get queryParamsStringify(): (params: HTTPQuery) => string;
33
+ get username(): string | undefined;
34
+ get password(): string | undefined;
35
+ get apiKey(): ((name: string) => string | Promise<string>) | undefined;
36
+ get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined;
37
+ get headers(): HTTPHeaders | undefined;
38
+ get credentials(): RequestCredentials | undefined;
39
+ }
40
+ export declare const DefaultConfig: Configuration;
41
+ /**
42
+ * This is the base class for all generated API classes.
43
+ */
44
+ export declare class BaseAPI {
45
+ protected configuration: Configuration;
46
+ private static readonly jsonRegex;
47
+ private middleware;
48
+ constructor(configuration?: Configuration);
49
+ withMiddleware<T extends BaseAPI>(this: T, ...middlewares: Middleware[]): T;
50
+ withPreMiddleware<T extends BaseAPI>(this: T, ...preMiddlewares: Array<Middleware['pre']>): T;
51
+ withPostMiddleware<T extends BaseAPI>(this: T, ...postMiddlewares: Array<Middleware['post']>): T;
52
+ /**
53
+ * Check if the given MIME is a JSON MIME.
54
+ * JSON MIME examples:
55
+ * application/json
56
+ * application/json; charset=UTF8
57
+ * APPLICATION/JSON
58
+ * application/vnd.company+json
59
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
60
+ * @return True if the given MIME is JSON, false otherwise.
61
+ */
62
+ protected isJsonMime(mime: string | null | undefined): boolean;
63
+ protected request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise<Response>;
64
+ private createFetchParams;
65
+ private fetchApi;
66
+ /**
67
+ * Create a shallow clone of `this` by constructing a new instance
68
+ * and then shallow cloning data members.
69
+ */
70
+ private clone;
71
+ }
72
+ export declare class ResponseError extends Error {
73
+ response: Response;
74
+ name: "ResponseError";
75
+ constructor(response: Response, msg?: string);
76
+ }
77
+ export declare class FetchError extends Error {
78
+ cause: Error;
79
+ name: "FetchError";
80
+ constructor(cause: Error, msg?: string);
81
+ }
82
+ export declare class RequiredError extends Error {
83
+ field: string;
84
+ name: "RequiredError";
85
+ constructor(field: string, msg?: string);
86
+ }
87
+ export declare const COLLECTION_FORMATS: {
88
+ csv: string;
89
+ ssv: string;
90
+ tsv: string;
91
+ pipes: string;
92
+ };
93
+ export type FetchAPI = WindowOrWorkerGlobalScope['fetch'];
94
+ export type Json = any;
95
+ export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
96
+ export type HTTPHeaders = {
97
+ [key: string]: string;
98
+ };
99
+ export type HTTPQuery = {
100
+ [key: string]: string | number | null | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery;
101
+ };
102
+ export type HTTPBody = Json | FormData | URLSearchParams;
103
+ export type HTTPRequestInit = {
104
+ headers?: HTTPHeaders;
105
+ method: HTTPMethod;
106
+ credentials?: RequestCredentials;
107
+ body?: HTTPBody;
108
+ };
109
+ export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
110
+ export type InitOverrideFunction = (requestContext: {
111
+ init: HTTPRequestInit;
112
+ context: RequestOpts;
113
+ }) => Promise<RequestInit>;
114
+ export interface FetchParams {
115
+ url: string;
116
+ init: RequestInit;
117
+ }
118
+ export interface RequestOpts {
119
+ path: string;
120
+ method: HTTPMethod;
121
+ headers: HTTPHeaders;
122
+ query?: HTTPQuery;
123
+ body?: HTTPBody;
124
+ }
125
+ export declare function querystring(params: HTTPQuery, prefix?: string): string;
126
+ export declare function mapValues(data: any, fn: (item: any) => any): {};
127
+ export declare function canConsumeForm(consumes: Consume[]): boolean;
128
+ export interface Consume {
129
+ contentType: string;
130
+ }
131
+ export interface RequestContext {
132
+ fetch: FetchAPI;
133
+ url: string;
134
+ init: RequestInit;
135
+ }
136
+ export interface ResponseContext {
137
+ fetch: FetchAPI;
138
+ url: string;
139
+ init: RequestInit;
140
+ response: Response;
141
+ }
142
+ export interface ErrorContext {
143
+ fetch: FetchAPI;
144
+ url: string;
145
+ init: RequestInit;
146
+ error: unknown;
147
+ response?: Response;
148
+ }
149
+ export interface Middleware {
150
+ pre?(context: RequestContext): Promise<FetchParams | void>;
151
+ post?(context: ResponseContext): Promise<Response | void>;
152
+ onError?(context: ErrorContext): Promise<Response | void>;
153
+ }
154
+ export interface ApiResponse<T> {
155
+ raw: Response;
156
+ value(): Promise<T>;
157
+ }
158
+ export interface ResponseTransformer<T> {
159
+ (json: any): T;
160
+ }
161
+ export declare class JSONApiResponse<T> {
162
+ raw: Response;
163
+ private transformer;
164
+ constructor(raw: Response, transformer?: ResponseTransformer<T>);
165
+ value(): Promise<T>;
166
+ }
167
+ export declare class VoidApiResponse {
168
+ raw: Response;
169
+ constructor(raw: Response);
170
+ value(): Promise<void>;
171
+ }
172
+ export declare class BlobApiResponse {
173
+ raw: Response;
174
+ constructor(raw: Response);
175
+ value(): Promise<Blob>;
176
+ }
177
+ export declare class TextApiResponse {
178
+ raw: Response;
179
+ constructor(raw: Response);
180
+ value(): Promise<string>;
181
+ }
@@ -0,0 +1,329 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * ActivitySmith API
6
+ * Send push notifications and Live Activities to your own devices via a single API key.
7
+ *
8
+ * The version of the OpenAPI document: 1.0.0
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.TextApiResponse = exports.BlobApiResponse = exports.VoidApiResponse = exports.JSONApiResponse = exports.COLLECTION_FORMATS = exports.RequiredError = exports.FetchError = exports.ResponseError = exports.BaseAPI = exports.DefaultConfig = exports.Configuration = exports.BASE_PATH = void 0;
17
+ exports.querystring = querystring;
18
+ exports.mapValues = mapValues;
19
+ exports.canConsumeForm = canConsumeForm;
20
+ exports.BASE_PATH = "https://activitysmith.com/api".replace(/\/+$/, "");
21
+ class Configuration {
22
+ constructor(configuration = {}) {
23
+ this.configuration = configuration;
24
+ }
25
+ set config(configuration) {
26
+ this.configuration = configuration;
27
+ }
28
+ get basePath() {
29
+ return this.configuration.basePath != null ? this.configuration.basePath : exports.BASE_PATH;
30
+ }
31
+ get fetchApi() {
32
+ return this.configuration.fetchApi;
33
+ }
34
+ get middleware() {
35
+ return this.configuration.middleware || [];
36
+ }
37
+ get queryParamsStringify() {
38
+ return this.configuration.queryParamsStringify || querystring;
39
+ }
40
+ get username() {
41
+ return this.configuration.username;
42
+ }
43
+ get password() {
44
+ return this.configuration.password;
45
+ }
46
+ get apiKey() {
47
+ const apiKey = this.configuration.apiKey;
48
+ if (apiKey) {
49
+ return typeof apiKey === 'function' ? apiKey : () => apiKey;
50
+ }
51
+ return undefined;
52
+ }
53
+ get accessToken() {
54
+ const accessToken = this.configuration.accessToken;
55
+ if (accessToken) {
56
+ return typeof accessToken === 'function' ? accessToken : async () => accessToken;
57
+ }
58
+ return undefined;
59
+ }
60
+ get headers() {
61
+ return this.configuration.headers;
62
+ }
63
+ get credentials() {
64
+ return this.configuration.credentials;
65
+ }
66
+ }
67
+ exports.Configuration = Configuration;
68
+ exports.DefaultConfig = new Configuration();
69
+ /**
70
+ * This is the base class for all generated API classes.
71
+ */
72
+ class BaseAPI {
73
+ constructor(configuration = exports.DefaultConfig) {
74
+ this.configuration = configuration;
75
+ this.fetchApi = async (url, init) => {
76
+ let fetchParams = { url, init };
77
+ for (const middleware of this.middleware) {
78
+ if (middleware.pre) {
79
+ fetchParams = await middleware.pre({
80
+ fetch: this.fetchApi,
81
+ ...fetchParams,
82
+ }) || fetchParams;
83
+ }
84
+ }
85
+ let response = undefined;
86
+ try {
87
+ response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
88
+ }
89
+ catch (e) {
90
+ for (const middleware of this.middleware) {
91
+ if (middleware.onError) {
92
+ response = await middleware.onError({
93
+ fetch: this.fetchApi,
94
+ url: fetchParams.url,
95
+ init: fetchParams.init,
96
+ error: e,
97
+ response: response ? response.clone() : undefined,
98
+ }) || response;
99
+ }
100
+ }
101
+ if (response === undefined) {
102
+ if (e instanceof Error) {
103
+ throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response');
104
+ }
105
+ else {
106
+ throw e;
107
+ }
108
+ }
109
+ }
110
+ for (const middleware of this.middleware) {
111
+ if (middleware.post) {
112
+ response = await middleware.post({
113
+ fetch: this.fetchApi,
114
+ url: fetchParams.url,
115
+ init: fetchParams.init,
116
+ response: response.clone(),
117
+ }) || response;
118
+ }
119
+ }
120
+ return response;
121
+ };
122
+ this.middleware = configuration.middleware;
123
+ }
124
+ withMiddleware(...middlewares) {
125
+ const next = this.clone();
126
+ next.middleware = next.middleware.concat(...middlewares);
127
+ return next;
128
+ }
129
+ withPreMiddleware(...preMiddlewares) {
130
+ const middlewares = preMiddlewares.map((pre) => ({ pre }));
131
+ return this.withMiddleware(...middlewares);
132
+ }
133
+ withPostMiddleware(...postMiddlewares) {
134
+ const middlewares = postMiddlewares.map((post) => ({ post }));
135
+ return this.withMiddleware(...middlewares);
136
+ }
137
+ /**
138
+ * Check if the given MIME is a JSON MIME.
139
+ * JSON MIME examples:
140
+ * application/json
141
+ * application/json; charset=UTF8
142
+ * APPLICATION/JSON
143
+ * application/vnd.company+json
144
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
145
+ * @return True if the given MIME is JSON, false otherwise.
146
+ */
147
+ isJsonMime(mime) {
148
+ if (!mime) {
149
+ return false;
150
+ }
151
+ return BaseAPI.jsonRegex.test(mime);
152
+ }
153
+ async request(context, initOverrides) {
154
+ const { url, init } = await this.createFetchParams(context, initOverrides);
155
+ const response = await this.fetchApi(url, init);
156
+ if (response && (response.status >= 200 && response.status < 300)) {
157
+ return response;
158
+ }
159
+ throw new ResponseError(response, 'Response returned an error code');
160
+ }
161
+ async createFetchParams(context, initOverrides) {
162
+ let url = this.configuration.basePath + context.path;
163
+ if (context.query !== undefined && Object.keys(context.query).length !== 0) {
164
+ // only add the querystring to the URL if there are query parameters.
165
+ // this is done to avoid urls ending with a "?" character which buggy webservers
166
+ // do not handle correctly sometimes.
167
+ url += '?' + this.configuration.queryParamsStringify(context.query);
168
+ }
169
+ const headers = Object.assign({}, this.configuration.headers, context.headers);
170
+ Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {});
171
+ const initOverrideFn = typeof initOverrides === "function"
172
+ ? initOverrides
173
+ : async () => initOverrides;
174
+ const initParams = {
175
+ method: context.method,
176
+ headers,
177
+ body: context.body,
178
+ credentials: this.configuration.credentials,
179
+ };
180
+ const overriddenInit = {
181
+ ...initParams,
182
+ ...(await initOverrideFn({
183
+ init: initParams,
184
+ context,
185
+ }))
186
+ };
187
+ let body;
188
+ if (isFormData(overriddenInit.body)
189
+ || (overriddenInit.body instanceof URLSearchParams)
190
+ || isBlob(overriddenInit.body)) {
191
+ body = overriddenInit.body;
192
+ }
193
+ else if (this.isJsonMime(headers['Content-Type'])) {
194
+ body = JSON.stringify(overriddenInit.body);
195
+ }
196
+ else {
197
+ body = overriddenInit.body;
198
+ }
199
+ const init = {
200
+ ...overriddenInit,
201
+ body
202
+ };
203
+ return { url, init };
204
+ }
205
+ /**
206
+ * Create a shallow clone of `this` by constructing a new instance
207
+ * and then shallow cloning data members.
208
+ */
209
+ clone() {
210
+ const constructor = this.constructor;
211
+ const next = new constructor(this.configuration);
212
+ next.middleware = this.middleware.slice();
213
+ return next;
214
+ }
215
+ }
216
+ exports.BaseAPI = BaseAPI;
217
+ BaseAPI.jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i');
218
+ ;
219
+ function isBlob(value) {
220
+ return typeof Blob !== 'undefined' && value instanceof Blob;
221
+ }
222
+ function isFormData(value) {
223
+ return typeof FormData !== "undefined" && value instanceof FormData;
224
+ }
225
+ class ResponseError extends Error {
226
+ constructor(response, msg) {
227
+ super(msg);
228
+ this.response = response;
229
+ this.name = "ResponseError";
230
+ }
231
+ }
232
+ exports.ResponseError = ResponseError;
233
+ class FetchError extends Error {
234
+ constructor(cause, msg) {
235
+ super(msg);
236
+ this.cause = cause;
237
+ this.name = "FetchError";
238
+ }
239
+ }
240
+ exports.FetchError = FetchError;
241
+ class RequiredError extends Error {
242
+ constructor(field, msg) {
243
+ super(msg);
244
+ this.field = field;
245
+ this.name = "RequiredError";
246
+ }
247
+ }
248
+ exports.RequiredError = RequiredError;
249
+ exports.COLLECTION_FORMATS = {
250
+ csv: ",",
251
+ ssv: " ",
252
+ tsv: "\t",
253
+ pipes: "|",
254
+ };
255
+ function querystring(params, prefix = '') {
256
+ return Object.keys(params)
257
+ .map(key => querystringSingleKey(key, params[key], prefix))
258
+ .filter(part => part.length > 0)
259
+ .join('&');
260
+ }
261
+ function querystringSingleKey(key, value, keyPrefix = '') {
262
+ const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
263
+ if (value instanceof Array) {
264
+ const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue)))
265
+ .join(`&${encodeURIComponent(fullKey)}=`);
266
+ return `${encodeURIComponent(fullKey)}=${multiValue}`;
267
+ }
268
+ if (value instanceof Set) {
269
+ const valueAsArray = Array.from(value);
270
+ return querystringSingleKey(key, valueAsArray, keyPrefix);
271
+ }
272
+ if (value instanceof Date) {
273
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
274
+ }
275
+ if (value instanceof Object) {
276
+ return querystring(value, fullKey);
277
+ }
278
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
279
+ }
280
+ function mapValues(data, fn) {
281
+ return Object.keys(data).reduce((acc, key) => ({ ...acc, [key]: fn(data[key]) }), {});
282
+ }
283
+ function canConsumeForm(consumes) {
284
+ for (const consume of consumes) {
285
+ if ('multipart/form-data' === consume.contentType) {
286
+ return true;
287
+ }
288
+ }
289
+ return false;
290
+ }
291
+ class JSONApiResponse {
292
+ constructor(raw, transformer = (jsonValue) => jsonValue) {
293
+ this.raw = raw;
294
+ this.transformer = transformer;
295
+ }
296
+ async value() {
297
+ return this.transformer(await this.raw.json());
298
+ }
299
+ }
300
+ exports.JSONApiResponse = JSONApiResponse;
301
+ class VoidApiResponse {
302
+ constructor(raw) {
303
+ this.raw = raw;
304
+ }
305
+ async value() {
306
+ return undefined;
307
+ }
308
+ }
309
+ exports.VoidApiResponse = VoidApiResponse;
310
+ class BlobApiResponse {
311
+ constructor(raw) {
312
+ this.raw = raw;
313
+ }
314
+ async value() {
315
+ return await this.raw.blob();
316
+ }
317
+ ;
318
+ }
319
+ exports.BlobApiResponse = BlobApiResponse;
320
+ class TextApiResponse {
321
+ constructor(raw) {
322
+ this.raw = raw;
323
+ }
324
+ async value() {
325
+ return await this.raw.text();
326
+ }
327
+ ;
328
+ }
329
+ exports.TextApiResponse = TextApiResponse;
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "activitysmith",
3
+ "version": "0.1.0",
4
+ "description": "Official ActivitySmith Node.js SDK",
5
+ "keywords": [
6
+ "activitysmith",
7
+ "live activities",
8
+ "push notifications",
9
+ "api"
10
+ ],
11
+ "homepage": "https://github.com/ActivitySmithHQ/activitysmith-node",
12
+ "main": "dist/generated/index.js",
13
+ "types": "dist/generated/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/generated/index.d.ts",
17
+ "import": "./dist/generated/index.js",
18
+ "require": "./dist/generated/index.js",
19
+ "default": "./dist/generated/index.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist/generated",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
27
+ "license": "MIT",
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "scripts": {
32
+ "build": "tsc -p tsconfig.generated.json",
33
+ "prepublishOnly": "npm run build",
34
+ "test": "npm run build && vitest run"
35
+ },
36
+ "devDependencies": {
37
+ "typescript": "^5.3.3",
38
+ "vitest": "^1.6.0"
39
+ }
40
+ }