@great-detail/support-sdk 0.2.9 → 0.2.10

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.d.cts CHANGED
@@ -212,4 +212,21 @@ declare class PublicAuthentication implements Authentication {
212
212
  getHeaders(): {};
213
213
  }
214
214
 
215
- export { DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication };
215
+ /**
216
+ * Great Detail Support System.
217
+ *
218
+ * @copyright 2024 Great Detail Ltd
219
+ * @author Great Detail Ltd <info@greatdetail.com>
220
+ * @author Dom Webber <dom.webber@greatdetail.com>
221
+ * @see https://greatdetail.com
222
+ */
223
+
224
+ type CreateContactSubscriptionResponsePayload = {
225
+ subscription: {
226
+ id: string;
227
+ createdAt: string;
228
+ updatedAt: string;
229
+ };
230
+ };
231
+
232
+ export { type CreateContactSubscriptionResponsePayload, DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication };
package/dist/index.d.ts CHANGED
@@ -212,4 +212,21 @@ declare class PublicAuthentication implements Authentication {
212
212
  getHeaders(): {};
213
213
  }
214
214
 
215
- export { DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication };
215
+ /**
216
+ * Great Detail Support System.
217
+ *
218
+ * @copyright 2024 Great Detail Ltd
219
+ * @author Great Detail Ltd <info@greatdetail.com>
220
+ * @author Dom Webber <dom.webber@greatdetail.com>
221
+ * @see https://greatdetail.com
222
+ */
223
+
224
+ type CreateContactSubscriptionResponsePayload = {
225
+ subscription: {
226
+ id: string;
227
+ createdAt: string;
228
+ updatedAt: string;
229
+ };
230
+ };
231
+
232
+ export { type CreateContactSubscriptionResponsePayload, DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as d,b as g,c as s,d as n,e as a,f as p,g as f,h as u,i as m,j as c,k as l,l as x,m as A,n as h,o as _}from"./chunk-KG7KNOPC.js";var E={};d(E,{AuthError:()=>u,AuthenticationError:()=>m,AuthorizationError:()=>c,LogicError:()=>l,NetworkError:()=>x,SupportError:()=>f,ValidationError:()=>A});var r=class o{static DEFAULT_NAME=s;name;#t;constructor({name:t=process.env[p]??o.DEFAULT_NAME,key:i=process.env[a]}={}){if(!i)throw new Error("API Key option must be specified when using Key Authentication");this.name=t,this.#t=i}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var e=class{#t;constructor({token:t=process.env[n]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};export{h as Client,g as DEFAULT_SUPPORT_BASE_URL,E as Error,r as KeyAuthentication,_ as PublicAuthentication,e as TokenAuthentication,h as default};
1
+ import{a as d,b as g,c as s,d as n,e as a,f as p,g as f,h as m,i as u,j as c,k as l,l as x,m as A,n as h,o as _}from"./chunk-KG7KNOPC.js";var E={};d(E,{AuthError:()=>m,AuthenticationError:()=>u,AuthorizationError:()=>c,LogicError:()=>l,NetworkError:()=>x,SupportError:()=>f,ValidationError:()=>A});var r=class o{static DEFAULT_NAME=s;name;#t;constructor({name:t=process.env[p]??o.DEFAULT_NAME,key:i=process.env[a]}={}){if(!i)throw new Error("API Key option must be specified when using Key Authentication");this.name=t,this.#t=i}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var e=class{#t;constructor({token:t=process.env[n]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};export{h as Client,g as DEFAULT_SUPPORT_BASE_URL,E as Error,r as KeyAuthentication,_ as PublicAuthentication,e as TokenAuthentication,h as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@great-detail/support-sdk",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "type": "module",
5
5
  "description": "JavaScript SDK for the Great Detail Support System",
6
6
  "author": "Great Detail Ltd <info@greatdetail.com>",
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Great Detail Support System.
3
+ *
4
+ * @copyright 2024 Great Detail Ltd
5
+ * @author Great Detail Ltd <info@greatdetail.com>
6
+ * @author Dom Webber <dom.webber@greatdetail.com>
7
+ * @see https://greatdetail.com
8
+ */
9
+
10
+ import { z } from "zod";
11
+ import FetchTransport from "../Transport/FetchTransport.js";
12
+
13
+ export interface Options {
14
+ id: string;
15
+ body: z.infer<typeof CreateContactSubscription.SCHEMA>;
16
+ request?: RequestInit;
17
+ }
18
+
19
+ export default class CreateContactSubscription {
20
+ public static SCHEMA = z.discriminatedUnion("type", [
21
+ z.object({
22
+ type: z.literal("vapid"),
23
+ endpoint: z.string().url(),
24
+ keys: z.object({
25
+ p256dh: z.string(),
26
+ auth: z.string(),
27
+ }),
28
+ }),
29
+ ]);
30
+
31
+ constructor(protected _transport: FetchTransport) {}
32
+
33
+ public async send({ id, body, request = {} }: Options) {
34
+ return this._transport
35
+ .send("v1/contacts/" + encodeURIComponent(id) + "/subscriptions", {
36
+ ...request,
37
+ method: "POST",
38
+ headers: {
39
+ ...request.headers,
40
+ "Content-Type": "application/json",
41
+ },
42
+ body: JSON.stringify(CreateContactSubscription.SCHEMA.parse(body)),
43
+ })
44
+ .then((response) => new CreateContactSubscriptionResponse(response));
45
+ }
46
+ }
47
+
48
+ export type CreateContactSubscriptionResponsePayload = {
49
+ subscription: {
50
+ id: string;
51
+ createdAt: string;
52
+ updatedAt: string;
53
+ };
54
+ };
55
+
56
+ export class CreateContactSubscriptionResponse {
57
+ constructor(public response: Response) {}
58
+
59
+ public async result(): Promise<CreateContactSubscriptionResponsePayload> {
60
+ return this.response.json();
61
+ }
62
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Great Detail Support System.
3
+ *
4
+ * @copyright 2024 Great Detail Ltd
5
+ * @author Great Detail Ltd <info@greatdetail.com>
6
+ * @author Dom Webber <dom.webber@greatdetail.com>
7
+ * @see https://greatdetail.com
8
+ */
9
+
10
+ export { type CreateContactSubscriptionResponsePayload } from "./CreateContactSubscription.js";
package/src/index.ts CHANGED
@@ -34,3 +34,4 @@ export * from "./Message/index.js";
34
34
  export * from "./Model/index.js";
35
35
  export * from "./Note/index.js";
36
36
  export * from "./Source/index.js";
37
+ export * from "./Subscription/index.js";