@dorapocket-tech/link-service-sdk 0.1.1 → 0.2.1

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 CHANGED
@@ -23,6 +23,11 @@ const created = await client.createLink({
23
23
  payload: { source: 'campaign-a' },
24
24
  });
25
25
 
26
+ const appLink = await client.createAppLink({
27
+ payload: { source: 'campaign-a' },
28
+ expiresIn: '7d',
29
+ });
30
+
26
31
  const payload = await client.resolvePayload(created.code);
27
32
  ```
28
33
 
@@ -35,6 +40,7 @@ const payload = await client.resolvePayload(created.code);
35
40
 
36
41
  - `LinkServiceClient.configure({ environment, apiKey })`
37
42
  - `client.createLink(request, options?)`
43
+ - `client.createAppLink(request, options?)`
38
44
  - `client.resolvePayload(codeOrUrl, options?)`
39
45
 
40
46
  ## Requirements
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { LinkServiceClient } from './link-service-client.js';
2
2
  export { LinkServiceError } from './errors.js';
3
3
  export { LINK_SERVICE_ENVIRONMENT_URLS } from './types.js';
4
- export type { LinkServiceConfigurationOptions, LinkServiceEnvironment, LinkServiceRequestOptions, CreateLinkRequest, CreateLinkResponse, LinkPayload, } from './types.js';
4
+ export type { LinkServiceConfigurationOptions, LinkServiceEnvironment, LinkServiceRequestOptions, CreateLinkRequest, CreateAppLinkRequest, CreateLinkResponse, LinkPayload, } from './types.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC3D,YAAY,EACV,+BAA+B,EAC/B,sBAAsB,EACtB,yBAAyB,EACzB,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,GACZ,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC3D,YAAY,EACV,+BAA+B,EAC/B,sBAAsB,EACtB,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,GACZ,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const E = {
2
2
  SHORT_CODE_PARAMETER: "_code"
3
- }, m = {
3
+ }, f = {
4
4
  LINK_MANAGEMENT_BASE_PATH: "links"
5
5
  };
6
6
  class d extends Error {
@@ -27,7 +27,7 @@ const T = {
27
27
  if (!e)
28
28
  throw new Error(`Unsupported Link Service environment: "${n}".`);
29
29
  return e;
30
- }, v = () => {
30
+ }, A = () => {
31
31
  if (typeof DOMException < "u")
32
32
  return new DOMException("Request timed out", "TimeoutError");
33
33
  const n = new Error("Request timed out");
@@ -69,7 +69,15 @@ class p {
69
69
  async createLink(e, r) {
70
70
  return this.performRequest(
71
71
  "POST",
72
- `/${m.LINK_MANAGEMENT_BASE_PATH}`,
72
+ `/${f.LINK_MANAGEMENT_BASE_PATH}`,
73
+ e,
74
+ r
75
+ );
76
+ }
77
+ async createAppLink(e, r) {
78
+ return this.performRequest(
79
+ "POST",
80
+ `/${f.LINK_MANAGEMENT_BASE_PATH}/app`,
73
81
  e,
74
82
  r
75
83
  );
@@ -78,7 +86,7 @@ class p {
78
86
  const t = this.resolveShortCode(e);
79
87
  return this.performRequest(
80
88
  "GET",
81
- `/${m.LINK_MANAGEMENT_BASE_PATH}/${t}/payload`,
89
+ `/${f.LINK_MANAGEMENT_BASE_PATH}/${t}/payload`,
82
90
  void 0,
83
91
  r
84
92
  );
@@ -101,9 +109,9 @@ class p {
101
109
  const o = E.SHORT_CODE_PARAMETER, c = s.searchParams.get(o)?.trim();
102
110
  if (c)
103
111
  return c;
104
- const u = s.pathname.replace(/\/+$/, "").split("/").filter(Boolean).at(-1)?.trim();
105
- if (u)
106
- return u;
112
+ const l = s.pathname.replace(/\/+$/, "").split("/").filter(Boolean).at(-1)?.trim();
113
+ if (l)
114
+ return l;
107
115
  throw new Error("Short link URL does not contain a code");
108
116
  }
109
117
  }
@@ -132,7 +140,7 @@ class p {
132
140
  ) : (o = () => i.abort(
133
141
  t.reason
134
142
  ), t.addEventListener("abort", o))), r && r > 0 && (s = setTimeout(() => {
135
- i.signal.aborted || i.abort(v());
143
+ i.signal.aborted || i.abort(A());
136
144
  }, r));
137
145
  const c = () => {
138
146
  o && t && t.removeEventListener("abort", o), s && clearTimeout(s);
@@ -153,28 +161,28 @@ class p {
153
161
  async performRequest(e, r, t, a) {
154
162
  const i = this.buildUrl(r), s = this.resolveTimeout(a), { signal: o, cleanup: c } = this.createSignal(a, s), h = t != null;
155
163
  try {
156
- const l = await this.fetchImpl(i, {
164
+ const u = await this.fetchImpl(i, {
157
165
  method: e,
158
166
  headers: this.mergeHeaders(h, a),
159
167
  body: h ? JSON.stringify(t) : void 0,
160
168
  signal: o
161
169
  });
162
- return await this.handleResponse(l, e, i);
163
- } catch (l) {
164
- if (l instanceof d)
165
- throw l;
166
- let u = "Network request failed. Please try again.";
167
- if (l && typeof l == "object" && "name" in l) {
168
- const f = String(l.name);
169
- f === "TimeoutError" ? u = "Request timed out. Please try again." : f === "AbortError" && (u = "Request was cancelled.");
170
+ return await this.handleResponse(u, e, i);
171
+ } catch (u) {
172
+ if (u instanceof d)
173
+ throw u;
174
+ let l = "Network request failed. Please try again.";
175
+ if (u && typeof u == "object" && "name" in u) {
176
+ const m = String(u.name);
177
+ m === "TimeoutError" ? l = "Request timed out. Please try again." : m === "AbortError" && (l = "Request was cancelled.");
170
178
  }
171
179
  throw new d(
172
- u,
180
+ l,
173
181
  {
174
182
  status: 0,
175
183
  method: e,
176
184
  url: i,
177
- cause: l
185
+ cause: u
178
186
  }
179
187
  );
180
188
  } finally {
@@ -1,4 +1,4 @@
1
- import { CreateLinkRequest, CreateLinkResponse, LinkPayload, LinkServiceConfigurationOptions, LinkServiceRequestOptions } from './types.js';
1
+ import { CreateAppLinkRequest, CreateLinkRequest, CreateLinkResponse, LinkPayload, LinkServiceConfigurationOptions, LinkServiceRequestOptions } from './types.js';
2
2
  type LinkServiceClientInit = {
3
3
  baseUrl: string;
4
4
  apiKey: string;
@@ -12,6 +12,7 @@ export declare class LinkServiceClient {
12
12
  private readonly defaultHeaders;
13
13
  constructor(options: LinkServiceClientInit);
14
14
  createLink(request: CreateLinkRequest, options?: LinkServiceRequestOptions): Promise<CreateLinkResponse>;
15
+ createAppLink(request: CreateAppLinkRequest, options?: LinkServiceRequestOptions): Promise<CreateLinkResponse>;
15
16
  resolvePayload(code: string, options?: LinkServiceRequestOptions): Promise<LinkPayload>;
16
17
  private resolveShortCode;
17
18
  private normalizeToken;
@@ -1 +1 @@
1
- {"version":3,"file":"link-service-client.d.ts","sourceRoot":"","sources":["../src/link-service-client.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAElB,WAAW,EACX,+BAA+B,EAE/B,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAiDpB,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,SAAS,CACd,OAAO,EAAE,+BAA+B,GACvC,iBAAiB;IASpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS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AAE,oBAAoB,EAC7B,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,kBAAkB,CAAC;IASxB,cAAc,CAClB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,WAAW,CAAC;IAUvB,OAAO,CAAC,gBAAgB;IA2CxB,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,YAAY;IAsDpB,OAAO,CAAC,YAAY;YAkBN,cAAc;IAiD5B,OAAO,CAAC,QAAQ;YAOF,cAAc;CAuD7B"}
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dorapocket-tech/link-service-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "Typed client SDK for interacting with the Dorapocket link service API.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/dist/types.d.ts CHANGED
@@ -36,6 +36,11 @@ export interface CreateLinkRequest {
36
36
  expiresIn?: string;
37
37
  maxUses?: number;
38
38
  }
39
+ export interface CreateAppLinkRequest {
40
+ payload?: Record<string, unknown>;
41
+ expiresIn?: string;
42
+ maxUses?: number;
43
+ }
39
44
  export interface CreateLinkResponse {
40
45
  shortUrl: string;
41
46
  code: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B;;;CAGhC,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAChC,MAAM,OAAO,6BAA6B,CAAC;AAE7C,MAAM,WAAW,+BAA+B;IAC9C;;OAEG;IACH,WAAW,EAAE,sBAAsB,CAAC;IACpC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,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AAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dorapocket-tech/link-service-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "Typed client SDK for interacting with the Dorapocket link service API.",
5
5
  "license": "MIT",
6
6
  "repository": {