@amityco/ts-sdk 7.34.0 → 7.34.1-0b076f5c.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 (38) hide show
  1. package/dist/@types/core/errors.d.ts +7 -1
  2. package/dist/@types/core/errors.d.ts.map +1 -1
  3. package/dist/@types/domains/widget.d.ts +32 -0
  4. package/dist/@types/domains/widget.d.ts.map +1 -0
  5. package/dist/@types/index.d.ts +1 -0
  6. package/dist/@types/index.d.ts.map +1 -1
  7. package/dist/core/errors.d.ts +18 -0
  8. package/dist/core/errors.d.ts.map +1 -1
  9. package/dist/index.cjs.js +445 -61
  10. package/dist/index.d.ts +2 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.esm.js +419 -37
  13. package/dist/index.umd.js +2 -2
  14. package/dist/widgetRepository/api/act.d.ts +19 -0
  15. package/dist/widgetRepository/api/act.d.ts.map +1 -0
  16. package/dist/widgetRepository/api/getSetup.d.ts +17 -0
  17. package/dist/widgetRepository/api/getSetup.d.ts.map +1 -0
  18. package/dist/widgetRepository/api/getWidget.d.ts +18 -0
  19. package/dist/widgetRepository/api/getWidget.d.ts.map +1 -0
  20. package/dist/widgetRepository/api/index.d.ts +5 -0
  21. package/dist/widgetRepository/api/index.d.ts.map +1 -0
  22. package/dist/widgetRepository/api/tests/widgetHeaders.test.d.ts +2 -0
  23. package/dist/widgetRepository/api/tests/widgetHeaders.test.d.ts.map +1 -0
  24. package/dist/widgetRepository/api/tests/widgetRepository.test.d.ts +2 -0
  25. package/dist/widgetRepository/api/tests/widgetRepository.test.d.ts.map +1 -0
  26. package/dist/widgetRepository/api/upload.d.ts +19 -0
  27. package/dist/widgetRepository/api/upload.d.ts.map +1 -0
  28. package/dist/widgetRepository/index.d.ts +2 -0
  29. package/dist/widgetRepository/index.d.ts.map +1 -0
  30. package/dist/widgetRepository/utils/settleWidgetResponse.d.ts +29 -0
  31. package/dist/widgetRepository/utils/settleWidgetResponse.d.ts.map +1 -0
  32. package/dist/widgetRepository/utils/tests/settleWidgetResponse.test.d.ts +2 -0
  33. package/dist/widgetRepository/utils/tests/settleWidgetResponse.test.d.ts.map +1 -0
  34. package/dist/widgetRepository/utils/tests/widgetTarget.test.d.ts +2 -0
  35. package/dist/widgetRepository/utils/tests/widgetTarget.test.d.ts.map +1 -0
  36. package/dist/widgetRepository/utils/widgetRequest.d.ts +61 -0
  37. package/dist/widgetRepository/utils/widgetRequest.d.ts.map +1 -0
  38. package/package.json +1 -1
@@ -0,0 +1,19 @@
1
+ /**
2
+ * ```js
3
+ * import { WidgetRepository } from '@amityco/ts-sdk'
4
+ * const result = await WidgetRepository.act(url, { coreVersion, locale, tz }, request)
5
+ * ```
6
+ *
7
+ * Posts a widget action to the widget service, as JSON. Nothing is cached or parsed.
8
+ *
9
+ * @param url The action's path under `/api/v1/widgets/`, or that path as a full URL on the SDK's HTTP origin
10
+ * @param call What the call carries: `coreVersion`, and `locale`, `tz`
11
+ * @param request The action's request, sent as JSON
12
+ * @returns The body
13
+ * @throws {AmityWidgetError}
14
+ *
15
+ * @category Widget API
16
+ * @async
17
+ */
18
+ export declare const act: (url: string, call: Amity.WidgetCall, request: unknown) => Promise<Amity.WidgetBody>;
19
+ //# sourceMappingURL=act.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"act.d.ts","sourceRoot":"","sources":["../../../src/widgetRepository/api/act.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,GAAG,QACT,MAAM,QACL,MAAM,UAAU,WACb,OAAO,KACf,QAAQ,MAAM,UAAU,CAe1B,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * ```js
3
+ * import { WidgetRepository } from '@amityco/ts-sdk'
4
+ * const result = await WidgetRepository.getSetup({ coreVersion, locale })
5
+ * ```
6
+ *
7
+ * Fetches the widget setup bundle from the widget service. Nothing is cached or parsed.
8
+ *
9
+ * @param call What the call carries: `coreVersion`, and `locale`, `etag`
10
+ * @returns The body, or `notModified` (304)
11
+ * @throws {AmityWidgetError}
12
+ *
13
+ * @category Widget API
14
+ * @async
15
+ */
16
+ export declare const getSetup: (call: Amity.WidgetCall) => Promise<Amity.WidgetBody | Amity.WidgetNotModified>;
17
+ //# sourceMappingURL=getSetup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSetup.d.ts","sourceRoot":"","sources":["../../../src/widgetRepository/api/getSetup.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,QAAQ,SACb,MAAM,UAAU,KACrB,QAAQ,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAepD,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * ```js
3
+ * import { WidgetRepository } from '@amityco/ts-sdk'
4
+ * const result = await WidgetRepository.getWidget(slotId, { coreVersion, locale, tz })
5
+ * ```
6
+ *
7
+ * Fetches a slot's widget from the widget service. Nothing is cached or parsed.
8
+ *
9
+ * @param slotId The slot to fetch
10
+ * @param call What the call carries: `coreVersion`, and `locale`, `tz`, `cursor`, `etag`
11
+ * @returns The body, `notModified` (304) or `noContent` (204)
12
+ * @throws {AmityWidgetError}
13
+ *
14
+ * @category Widget API
15
+ * @async
16
+ */
17
+ export declare const getWidget: (slotId: string, call: Amity.WidgetCall) => Promise<Amity.WidgetBody | Amity.WidgetNotModified | Amity.WidgetNoContent>;
18
+ //# sourceMappingURL=getWidget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWidget.d.ts","sourceRoot":"","sources":["../../../src/widgetRepository/api/getWidget.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,SAAS,WACZ,MAAM,QACR,MAAM,UAAU,KACrB,QAAQ,MAAM,UAAU,GAAG,MAAM,iBAAiB,GAAG,MAAM,eAAe,CAa5E,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './getWidget';
2
+ export * from './getSetup';
3
+ export * from './act';
4
+ export * from './upload';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/widgetRepository/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=widgetHeaders.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widgetHeaders.test.d.ts","sourceRoot":"","sources":["../../../../src/widgetRepository/api/tests/widgetHeaders.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=widgetRepository.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widgetRepository.test.d.ts","sourceRoot":"","sources":["../../../../src/widgetRepository/api/tests/widgetRepository.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * ```js
3
+ * import { WidgetRepository } from '@amityco/ts-sdk'
4
+ * const result = await WidgetRepository.upload(url, file, { coreVersion })
5
+ * ```
6
+ *
7
+ * Uploads one file to the widget service, as multipart part `file`, with no query.
8
+ *
9
+ * @param url `/api/v4/images` or `/api/v4/videos`, or either as a full URL on the SDK's HTTP origin
10
+ * @param file The file to send; a `File` keeps its name
11
+ * @param call What the call carries: `coreVersion`
12
+ * @returns The body
13
+ * @throws {AmityWidgetError}
14
+ *
15
+ * @category Widget API
16
+ * @async
17
+ */
18
+ export declare const upload: (url: string, file: Blob, call: Amity.WidgetCall) => Promise<Amity.WidgetBody>;
19
+ //# sourceMappingURL=upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/widgetRepository/api/upload.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,QACZ,MAAM,QACL,IAAI,QACJ,MAAM,UAAU,KACrB,QAAQ,MAAM,UAAU,CAgB1B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './api';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/widgetRepository/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { AmityWidgetError } from '~/core/errors';
2
+ /** A 2xx body over this many bytes is `MALFORMED_DATA`; an error body is passed on whatever its size. */
3
+ export declare const WIDGET_MAX_BODY_BYTES = 524288;
4
+ /** What a widget service request came back with, before it is read as a result. */
5
+ export declare type WidgetExchange = {
6
+ status: number;
7
+ body: string;
8
+ etag: string | null;
9
+ };
10
+ /** The answers beyond a body that a call accepts. */
11
+ export declare type WidgetAllowed = {
12
+ notModified?: boolean;
13
+ noContent?: boolean;
14
+ };
15
+ /**
16
+ * The error for a status that is no success: an error body whose `code` is
17
+ * 400323 first, then the status. Nothing else of the body is read.
18
+ *
19
+ * @hidden
20
+ */
21
+ export declare const widgetErrorOf: (status: number, body: string) => AmityWidgetError;
22
+ /**
23
+ * A widget service answer as the call's result: 304 and 204 where the call
24
+ * allows them, any 2xx a body, anything else its {@link AmityWidgetError}.
25
+ *
26
+ * @hidden
27
+ */
28
+ export declare const settleWidgetResponse: ({ status, body, etag }: WidgetExchange, allowed: WidgetAllowed) => Amity.WidgetResult;
29
+ //# sourceMappingURL=settleWidgetResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settleWidgetResponse.d.ts","sourceRoot":"","sources":["../../../src/widgetRepository/utils/settleWidgetResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,yGAAyG;AACzG,eAAO,MAAM,qBAAqB,SAAU,CAAC;AAE7C,mFAAmF;AACnF,oBAAY,cAAc,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAEnF,qDAAqD;AACrD,oBAAY,aAAa,GAAG;IAAE,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AA0B3E;;;;;GAKG;AACH,eAAO,MAAM,aAAa,WAAY,MAAM,QAAQ,MAAM,KAAG,gBAa5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,2BACP,cAAc,WAC7B,aAAa,KACrB,MAAM,YAeR,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=settleWidgetResponse.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settleWidgetResponse.test.d.ts","sourceRoot":"","sources":["../../../../src/widgetRepository/utils/tests/settleWidgetResponse.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=widgetTarget.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widgetTarget.test.d.ts","sourceRoot":"","sources":["../../../../src/widgetRepository/utils/tests/widgetTarget.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,61 @@
1
+ export declare const WIDGET_PLATFORM = "WEB";
2
+ export declare const WIDGET_BASE_PATH = "/api/v1/widgets";
3
+ export declare const WIDGET_TIMEOUT_MS = 5000;
4
+ export declare const WIDGET_UPLOAD_TIMEOUT_MS = 30000;
5
+ /** How long a call waits for a session that is being established. */
6
+ export declare const WIDGET_SESSION_WAIT_MS = 15000;
7
+ export declare type WidgetRequest = {
8
+ method: 'get' | 'post';
9
+ /** A path joined to the SDK's HTTP endpoint, or a full URL on that endpoint's origin. */
10
+ url: string;
11
+ call: Amity.WidgetCall;
12
+ params?: Record<string, string>;
13
+ data?: unknown;
14
+ json?: boolean;
15
+ timeout: number;
16
+ /** The paths this call may send the token to. */
17
+ allowed: (path: string) => boolean;
18
+ };
19
+ /**
20
+ * The active client once its session is ready; `ESTABLISHING_ERROR` when it is
21
+ * not ready within the wait. The session is the caller's to start.
22
+ *
23
+ * @hidden
24
+ */
25
+ export declare const widgetSession: (waitMs?: number) => Promise<Amity.Client>;
26
+ /** The paths a widget call may send the token to: anything under `/api/v1/widgets/`. */
27
+ export declare const isWidgetPath: (path: string) => boolean;
28
+ /** The paths an upload may send the token to: exactly the SDK's image and video uploads. */
29
+ export declare const isUploadPath: (path: string) => boolean;
30
+ /**
31
+ * Where a widget request goes, refused (`CONNECTION_ERROR`) unless it is a clean,
32
+ * allowed path on the SDK's HTTP origin: the client sends its token to any URL.
33
+ * A path is joined to the SDK's HTTP endpoint; a full URL keeps its own.
34
+ *
35
+ * @hidden
36
+ */
37
+ export declare const widgetTarget: (url: string, endpoint: string | undefined, allowed: (path: string) => boolean) => {
38
+ url: string;
39
+ baseURL?: string | undefined;
40
+ };
41
+ /**
42
+ * The headers of a widget request, on that request only: never on the client's
43
+ * defaults or an interceptor, so no other SDK request carries them.
44
+ *
45
+ * @hidden
46
+ */
47
+ export declare const widgetHeaders: (apiKey: string | undefined, call: Amity.WidgetCall, json?: boolean) => Record<string, string>;
48
+ /** The query of a call: `locale`, `tz` and `cursor` where they are given, in that order. */
49
+ export declare const widgetQuery: (call: Amity.WidgetCall, keys: ReadonlyArray<'locale' | 'tz' | 'cursor'>) => Record<string, string>;
50
+ /**
51
+ * Sends one widget service request through the SDK's HTTP client, with the
52
+ * session's token, and returns its status, raw body and `ETag`.
53
+ *
54
+ * @hidden
55
+ */
56
+ export declare const sendWidgetRequest: ({ method, url, call, params, data, json, timeout, allowed, }: WidgetRequest) => Promise<{
57
+ status: number;
58
+ body: string;
59
+ etag: string | null;
60
+ }>;
61
+ //# sourceMappingURL=widgetRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widgetRequest.d.ts","sourceRoot":"","sources":["../../../src/widgetRepository/utils/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AAO,MAAM,EAAE,MAAM,CAKhB,CAAC;AAQT;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,iEAS3B,aAAa;YAAqB,MAAM;UAAQ,MAAM;UAAQ,MAAM,GAAG,IAAI;EAkC7E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amityco/ts-sdk",
3
- "version": "7.34.0",
3
+ "version": "7.34.1-0b076f5c.0",
4
4
  "license": "CC-BY-ND-4.0",
5
5
  "author": "amity.co <developers@amity.co> (https://amity.co)",
6
6
  "description": "Amity Social Cloud Typescript SDK",