@amityco/ts-sdk 6.35.3-854efd4.0 → 6.35.3-c7e7d80.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.
@@ -0,0 +1,12 @@
1
+ export {};
2
+ declare global {
3
+ namespace Amity {
4
+ type LinkPreview = {
5
+ title: string | null;
6
+ description: string | null;
7
+ image: string | null;
8
+ video: string | null;
9
+ };
10
+ }
11
+ }
12
+ //# sourceMappingURL=linkPreview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linkPreview.d.ts","sourceRoot":"","sources":["../../../src/@types/core/linkPreview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,WAAW,GAAG;YACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;YACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;YAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;YACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;SACtB,CAAC;KACH;CACF"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * ```js
3
+ * import { fetchLinkPreview } from '@amityco/ts-sdk'
4
+ * const { title, description, imageUrl } = fetchLinkPreview('https://www.example.com/')
5
+ * ```
6
+ *
7
+ *
8
+ * @param url the url to fetch link preview
9
+ * @returns A {@link Amity.LinkPreview} instance
10
+ *
11
+ * @category Client API
12
+ * */
13
+ export declare const fetchLinkPreview: (url: string) => Promise<Amity.LinkPreview>;
14
+ //# sourceMappingURL=fetchLinkPreview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchLinkPreview.d.ts","sourceRoot":"","sources":["../../../src/client/api/fetchLinkPreview.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;KAWK;AAEL,eAAO,MAAM,gBAAgB,QAAe,MAAM,KAAG,QAAQ,MAAM,WAAW,CAc7E,CAAC"}
@@ -10,4 +10,5 @@ export * from './renewal';
10
10
  export * from './markerSync';
11
11
  export * from './enableUnreadCount';
12
12
  export * from './setUploadedFileAccessType';
13
+ export * from './fetchLinkPreview';
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,cAAc,cAAc,CAAC;AAE7B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAE/B,cAAc,eAAe,CAAC;AAE9B,cAAc,mBAAmB,CAAC;AAElC,cAAc,WAAW,CAAC;AAE1B,cAAc,cAAc,CAAC;AAE7B,cAAc,qBAAqB,CAAC;AAEpC,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,cAAc,cAAc,CAAC;AAE7B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAE/B,cAAc,eAAe,CAAC;AAE9B,cAAc,mBAAmB,CAAC;AAElC,cAAc,WAAW,CAAC;AAE1B,cAAc,cAAc,CAAC;AAE7B,cAAc,qBAAqB,CAAC;AAEpC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,oBAAoB,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -9478,6 +9478,28 @@ function setUploadedFileAccessType(accessType) {
9478
9478
  GlobalFileAccessType$1.getInstance().setFileAccessType(accessType);
9479
9479
  }
9480
9480
 
9481
+ /**
9482
+ * ```js
9483
+ * import { fetchLinkPreview } from '@amityco/ts-sdk'
9484
+ * const { title, description, imageUrl } = fetchLinkPreview('https://www.example.com/')
9485
+ * ```
9486
+ *
9487
+ *
9488
+ * @param url the url to fetch link preview
9489
+ * @returns A {@link Amity.LinkPreview} instance
9490
+ *
9491
+ * @category Client API
9492
+ * */
9493
+ const fetchLinkPreview = async (url) => {
9494
+ const client = getActiveClient();
9495
+ let fetchUrl = url;
9496
+ if (!/^https?:\/\//i.test(url)) {
9497
+ fetchUrl = `https://${url}`;
9498
+ }
9499
+ const { data } = await client.http.get(`/api/v1/link-preview?url=${encodeURIComponent(fetchUrl)}`);
9500
+ return data;
9501
+ };
9502
+
9481
9503
  /**
9482
9504
  * ```js
9483
9505
  * import { onChannelMarkerFetched } from '@amityco/ts-sdk'
@@ -9845,6 +9867,7 @@ var index$l = /*#__PURE__*/Object.freeze({
9845
9867
  markerSync: markerSync,
9846
9868
  enableUnreadCount: enableUnreadCount,
9847
9869
  setUploadedFileAccessType: setUploadedFileAccessType,
9870
+ fetchLinkPreview: fetchLinkPreview,
9848
9871
  onConnectionError: onConnectionError,
9849
9872
  onClientDisconnected: onClientDisconnected,
9850
9873
  onClientBanned: onClientBanned,
package/dist/index.esm.js CHANGED
@@ -25570,6 +25570,28 @@ function setUploadedFileAccessType(accessType) {
25570
25570
  GlobalFileAccessType$1.getInstance().setFileAccessType(accessType);
25571
25571
  }
25572
25572
 
25573
+ /**
25574
+ * ```js
25575
+ * import { fetchLinkPreview } from '@amityco/ts-sdk'
25576
+ * const { title, description, imageUrl } = fetchLinkPreview('https://www.example.com/')
25577
+ * ```
25578
+ *
25579
+ *
25580
+ * @param url the url to fetch link preview
25581
+ * @returns A {@link Amity.LinkPreview} instance
25582
+ *
25583
+ * @category Client API
25584
+ * */
25585
+ const fetchLinkPreview = async (url) => {
25586
+ const client = getActiveClient();
25587
+ let fetchUrl = url;
25588
+ if (!/^https?:\/\//i.test(url)) {
25589
+ fetchUrl = `https://${url}`;
25590
+ }
25591
+ const { data } = await client.http.get(`/api/v1/link-preview?url=${encodeURIComponent(fetchUrl)}`);
25592
+ return data;
25593
+ };
25594
+
25573
25595
  /**
25574
25596
  * ```js
25575
25597
  * import { onChannelMarkerFetched } from '@amityco/ts-sdk'
@@ -25937,6 +25959,7 @@ var index$l = /*#__PURE__*/Object.freeze({
25937
25959
  markerSync: markerSync,
25938
25960
  enableUnreadCount: enableUnreadCount,
25939
25961
  setUploadedFileAccessType: setUploadedFileAccessType,
25962
+ fetchLinkPreview: fetchLinkPreview,
25940
25963
  onConnectionError: onConnectionError,
25941
25964
  onClientDisconnected: onClientDisconnected,
25942
25965
  onClientBanned: onClientBanned,