rcs-js 2.0.0-rc.11 → 2.0.0-rc.13

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 (106) hide show
  1. package/dist/cjs/Client.js +2 -2
  2. package/dist/cjs/api/resources/campaigns/resources/rcs/client/Client.d.ts +1 -0
  3. package/dist/cjs/api/resources/campaigns/resources/rcs/client/Client.js +3 -0
  4. package/dist/cjs/api/resources/messages/resources/rcs/client/Client.d.ts +2 -2
  5. package/dist/cjs/api/resources/messages/resources/rcs/client/Client.js +1 -1
  6. package/dist/cjs/api/resources/tools/resources/file/client/Client.d.ts +21 -0
  7. package/dist/cjs/api/resources/tools/resources/file/client/Client.js +74 -0
  8. package/dist/cjs/api/resources/tools/resources/file/client/requests/RefreshFileParams.d.ts +21 -0
  9. package/dist/cjs/api/resources/tools/resources/file/client/requests/index.d.ts +1 -0
  10. package/dist/cjs/api/resources/tools/resources/url/client/Client.d.ts +1 -1
  11. package/dist/cjs/api/resources/tools/resources/url/client/Client.js +1 -1
  12. package/dist/cjs/api/types/AutofillDlcCampaignResponse.d.ts +11 -11
  13. package/dist/cjs/api/types/ButtonClicked.d.ts +11 -0
  14. package/dist/cjs/api/types/ButtonClickedData.d.ts +56 -0
  15. package/dist/cjs/api/types/ButtonClickedData.js +16 -0
  16. package/dist/cjs/api/types/CreateUrlOptions.d.ts +1 -1
  17. package/dist/cjs/api/types/DlcCampaignWithExtendedBrandAndStatus.d.ts +13 -10
  18. package/dist/cjs/api/types/ExtendedBrand.d.ts +7 -4
  19. package/dist/cjs/api/types/ExtendedRcsCampaign.d.ts +9 -8
  20. package/dist/cjs/api/types/MessageContent.d.ts +2 -2
  21. package/dist/cjs/api/types/MessageEvent.d.ts +56 -0
  22. package/dist/cjs/api/types/MessageEvent.js +13 -0
  23. package/dist/cjs/api/types/ProfileStatusEnum.d.ts +7 -4
  24. package/dist/cjs/api/types/RcsBase.d.ts +2 -0
  25. package/dist/cjs/api/types/RcsButtonCall.d.ts +2 -0
  26. package/dist/cjs/api/types/RcsButtonOpenUrl.d.ts +2 -0
  27. package/dist/cjs/api/types/RcsButtonRequestUserLocation.d.ts +2 -0
  28. package/dist/cjs/api/types/RcsButtonScheduleEvent.d.ts +2 -0
  29. package/dist/cjs/api/types/RcsButtonSendLocation.d.ts +2 -0
  30. package/dist/cjs/api/types/RcsButtonTrigger.d.ts +2 -2
  31. package/dist/cjs/api/types/RefreshedFile.d.ts +9 -0
  32. package/dist/cjs/api/types/{Rcs.d.ts → RichMessage.d.ts} +1 -1
  33. package/dist/cjs/api/types/RichMessage.js +5 -0
  34. package/dist/cjs/api/types/index.d.ts +5 -3
  35. package/dist/cjs/api/types/index.js +5 -3
  36. package/dist/cjs/index.d.ts +1 -1
  37. package/dist/cjs/index.js +2 -2
  38. package/dist/cjs/version.d.ts +1 -1
  39. package/dist/cjs/version.js +1 -1
  40. package/dist/cjs/wrapper/PinnacleClient.d.ts +9 -0
  41. package/dist/cjs/wrapper/PinnacleClient.js +17 -0
  42. package/dist/cjs/wrapper/messages/Client.d.ts +13 -0
  43. package/dist/cjs/wrapper/messages/Client.js +49 -0
  44. package/dist/cjs/wrapper/tools/Client.d.ts +6 -0
  45. package/dist/cjs/wrapper/tools/Client.js +12 -0
  46. package/dist/cjs/wrapper/tools/FileUploader.d.ts +15 -0
  47. package/dist/cjs/wrapper/tools/FileUploader.js +162 -0
  48. package/dist/esm/Client.mjs +2 -2
  49. package/dist/esm/api/resources/campaigns/resources/rcs/client/Client.d.mts +1 -0
  50. package/dist/esm/api/resources/campaigns/resources/rcs/client/Client.mjs +3 -0
  51. package/dist/esm/api/resources/messages/resources/rcs/client/Client.d.mts +2 -2
  52. package/dist/esm/api/resources/messages/resources/rcs/client/Client.mjs +1 -1
  53. package/dist/esm/api/resources/tools/resources/file/client/Client.d.mts +21 -0
  54. package/dist/esm/api/resources/tools/resources/file/client/Client.mjs +74 -0
  55. package/dist/esm/api/resources/tools/resources/file/client/requests/RefreshFileParams.d.mts +21 -0
  56. package/dist/esm/api/resources/tools/resources/file/client/requests/index.d.mts +1 -0
  57. package/dist/esm/api/resources/tools/resources/url/client/Client.d.mts +1 -1
  58. package/dist/esm/api/resources/tools/resources/url/client/Client.mjs +1 -1
  59. package/dist/esm/api/types/AutofillDlcCampaignResponse.d.mts +11 -11
  60. package/dist/esm/api/types/ButtonClicked.d.mts +11 -0
  61. package/dist/esm/api/types/ButtonClickedData.d.mts +56 -0
  62. package/dist/esm/api/types/ButtonClickedData.mjs +13 -0
  63. package/dist/esm/api/types/CreateUrlOptions.d.mts +1 -1
  64. package/dist/esm/api/types/DlcCampaignWithExtendedBrandAndStatus.d.mts +13 -10
  65. package/dist/esm/api/types/ExtendedBrand.d.mts +7 -4
  66. package/dist/esm/api/types/ExtendedRcsCampaign.d.mts +9 -8
  67. package/dist/esm/api/types/MessageContent.d.mts +2 -2
  68. package/dist/esm/api/types/MessageEvent.d.mts +56 -0
  69. package/dist/esm/api/types/MessageEvent.mjs +10 -0
  70. package/dist/esm/api/types/ProfileStatusEnum.d.mts +7 -4
  71. package/dist/esm/api/types/RcsBase.d.mts +2 -0
  72. package/dist/esm/api/types/RcsButtonCall.d.mts +2 -0
  73. package/dist/esm/api/types/RcsButtonOpenUrl.d.mts +2 -0
  74. package/dist/esm/api/types/RcsButtonRequestUserLocation.d.mts +2 -0
  75. package/dist/esm/api/types/RcsButtonScheduleEvent.d.mts +2 -0
  76. package/dist/esm/api/types/RcsButtonSendLocation.d.mts +2 -0
  77. package/dist/esm/api/types/RcsButtonTrigger.d.mts +2 -2
  78. package/dist/esm/api/types/RefreshedFile.d.mts +9 -0
  79. package/dist/esm/api/types/{Rcs.d.mts → RichMessage.d.mts} +1 -1
  80. package/dist/esm/api/types/RichMessage.mjs +4 -0
  81. package/dist/esm/api/types/index.d.mts +5 -3
  82. package/dist/esm/api/types/index.mjs +5 -3
  83. package/dist/esm/index.d.mts +1 -1
  84. package/dist/esm/index.mjs +1 -1
  85. package/dist/esm/version.d.mts +1 -1
  86. package/dist/esm/version.mjs +1 -1
  87. package/dist/esm/wrapper/PinnacleClient.d.mts +9 -0
  88. package/dist/esm/wrapper/PinnacleClient.mjs +13 -0
  89. package/dist/esm/wrapper/messages/Client.d.mts +13 -0
  90. package/dist/esm/wrapper/messages/Client.mjs +45 -0
  91. package/dist/esm/wrapper/tools/Client.d.mts +6 -0
  92. package/dist/esm/wrapper/tools/Client.mjs +8 -0
  93. package/dist/esm/wrapper/tools/FileUploader.d.mts +15 -0
  94. package/dist/esm/wrapper/tools/FileUploader.mjs +125 -0
  95. package/package.json +7 -3
  96. package/reference.md +76 -2
  97. package/dist/cjs/api/types/ClickAction.d.ts +0 -28
  98. package/dist/cjs/api/types/InboundButton.d.ts +0 -11
  99. package/dist/esm/api/types/ClickAction.d.mts +0 -28
  100. package/dist/esm/api/types/InboundButton.d.mts +0 -11
  101. /package/dist/cjs/api/{types/ClickAction.js → resources/tools/resources/file/client/requests/RefreshFileParams.js} +0 -0
  102. /package/dist/cjs/api/types/{InboundButton.js → ButtonClicked.js} +0 -0
  103. /package/dist/cjs/api/types/{Rcs.js → RefreshedFile.js} +0 -0
  104. /package/dist/esm/api/{types/ClickAction.mjs → resources/tools/resources/file/client/requests/RefreshFileParams.mjs} +0 -0
  105. /package/dist/esm/api/types/{InboundButton.mjs → ButtonClicked.mjs} +0 -0
  106. /package/dist/esm/api/types/{Rcs.mjs → RefreshedFile.mjs} +0 -0
@@ -13,6 +13,8 @@ export interface RcsButtonScheduleEvent {
13
13
  eventStartTime: string;
14
14
  /** Title of the event. */
15
15
  eventTitle: string;
16
+ /** Optional additional data to attach to this button. */
17
+ metadata?: string;
16
18
  /** Display text for the button. */
17
19
  title: string;
18
20
  }
@@ -7,6 +7,8 @@
7
7
  export interface RcsButtonSendLocation {
8
8
  /** Geographic coordinates of the location to share. */
9
9
  latLong: RcsButtonSendLocation.LatLong;
10
+ /** Optional additional data to attach to this button. */
11
+ metadata?: string;
10
12
  /** Display text for the button. */
11
13
  title: string;
12
14
  }
@@ -5,8 +5,8 @@
5
5
  * Button that sends custom data back to your application when tapped by the recipient.
6
6
  */
7
7
  export interface RcsButtonTrigger {
8
- /** Additional data attached to the button interaction. */
9
- metadata: string;
8
+ /** Optional additional data to attach to this button. */
9
+ metadata?: string;
10
10
  /** Custom data sent to your webhook when the button is tapped. Use this to identify the user's choice. */
11
11
  payload: string;
12
12
  /** Display text for the button. */
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface RefreshedFile {
5
+ /** The original file URI that was provided in the request. */
6
+ original: string;
7
+ /** The new refreshed presigned URL that expires in one hour. */
8
+ refreshed: string;
9
+ }
@@ -2,7 +2,7 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  import * as Pinnacle from "../index.js";
5
- export type Rcs =
5
+ export type RichMessage =
6
6
  /**
7
7
  * Send a text RCS message with optional quick reply buttons. */
8
8
  Pinnacle.RichTextMessage
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -59,9 +59,9 @@ export * from "./RcsMediaDetailsContent.js";
59
59
  export * from "./RcsMediaContent.js";
60
60
  export * from "./RcsCardsContent.js";
61
61
  export * from "./RcsContent.js";
62
- export * from "./ClickAction.js";
62
+ export * from "./ButtonClickedData.js";
63
63
  export * from "./LocationShareAction.js";
64
- export * from "./InboundButton.js";
64
+ export * from "./ButtonClicked.js";
65
65
  export * from "./MessageContent.js";
66
66
  export * from "./MessageMethodEnum.js";
67
67
  export * from "./MessageStatusEnum.js";
@@ -78,7 +78,7 @@ export * from "./RichTextMessage.js";
78
78
  export * from "./RichMediaMessage.js";
79
79
  export * from "./RcsCards.js";
80
80
  export * from "./RichCardsMessage.js";
81
- export * from "./Rcs.js";
81
+ export * from "./RichMessage.js";
82
82
  export * from "./SentRcsDetails.js";
83
83
  export * from "./SmsValidationResult.js";
84
84
  export * from "./MmsValidationResult.js";
@@ -119,6 +119,7 @@ export * from "./ShortenedUrl.js";
119
119
  export * from "./LinkClickEvent.js";
120
120
  export * from "./ShortenedUrlWithClickData.js";
121
121
  export * from "./UploadResults.js";
122
+ export * from "./RefreshedFile.js";
122
123
  export * from "./VcardAddress.js";
123
124
  export * from "./VcardPhone.js";
124
125
  export * from "./VcardEmail.js";
@@ -128,3 +129,4 @@ export * from "./VCardData.js";
128
129
  export * from "./VcardResource.js";
129
130
  export * from "./Webhooks.js";
130
131
  export * from "./WebhookResult.js";
132
+ export * from "./MessageEvent.js";
@@ -75,9 +75,9 @@ __exportStar(require("./RcsMediaDetailsContent.js"), exports);
75
75
  __exportStar(require("./RcsMediaContent.js"), exports);
76
76
  __exportStar(require("./RcsCardsContent.js"), exports);
77
77
  __exportStar(require("./RcsContent.js"), exports);
78
- __exportStar(require("./ClickAction.js"), exports);
78
+ __exportStar(require("./ButtonClickedData.js"), exports);
79
79
  __exportStar(require("./LocationShareAction.js"), exports);
80
- __exportStar(require("./InboundButton.js"), exports);
80
+ __exportStar(require("./ButtonClicked.js"), exports);
81
81
  __exportStar(require("./MessageContent.js"), exports);
82
82
  __exportStar(require("./MessageMethodEnum.js"), exports);
83
83
  __exportStar(require("./MessageStatusEnum.js"), exports);
@@ -94,7 +94,7 @@ __exportStar(require("./RichTextMessage.js"), exports);
94
94
  __exportStar(require("./RichMediaMessage.js"), exports);
95
95
  __exportStar(require("./RcsCards.js"), exports);
96
96
  __exportStar(require("./RichCardsMessage.js"), exports);
97
- __exportStar(require("./Rcs.js"), exports);
97
+ __exportStar(require("./RichMessage.js"), exports);
98
98
  __exportStar(require("./SentRcsDetails.js"), exports);
99
99
  __exportStar(require("./SmsValidationResult.js"), exports);
100
100
  __exportStar(require("./MmsValidationResult.js"), exports);
@@ -135,6 +135,7 @@ __exportStar(require("./ShortenedUrl.js"), exports);
135
135
  __exportStar(require("./LinkClickEvent.js"), exports);
136
136
  __exportStar(require("./ShortenedUrlWithClickData.js"), exports);
137
137
  __exportStar(require("./UploadResults.js"), exports);
138
+ __exportStar(require("./RefreshedFile.js"), exports);
138
139
  __exportStar(require("./VcardAddress.js"), exports);
139
140
  __exportStar(require("./VcardPhone.js"), exports);
140
141
  __exportStar(require("./VcardEmail.js"), exports);
@@ -144,3 +145,4 @@ __exportStar(require("./VCardData.js"), exports);
144
145
  __exportStar(require("./VcardResource.js"), exports);
145
146
  __exportStar(require("./Webhooks.js"), exports);
146
147
  __exportStar(require("./WebhookResult.js"), exports);
148
+ __exportStar(require("./MessageEvent.js"), exports);
@@ -1,4 +1,4 @@
1
1
  export * as Pinnacle from "./api/index.js";
2
- export { PinnacleClient } from "./Client.js";
2
+ export { PinnacleClient } from "./wrapper/PinnacleClient.js";
3
3
  export { PinnacleEnvironment } from "./environments.js";
4
4
  export { PinnacleError, PinnacleTimeoutError } from "./errors/index.js";
package/dist/cjs/index.js CHANGED
@@ -35,8 +35,8 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.PinnacleTimeoutError = exports.PinnacleError = exports.PinnacleEnvironment = exports.PinnacleClient = exports.Pinnacle = void 0;
37
37
  exports.Pinnacle = __importStar(require("./api/index.js"));
38
- var Client_js_1 = require("./Client.js");
39
- Object.defineProperty(exports, "PinnacleClient", { enumerable: true, get: function () { return Client_js_1.PinnacleClient; } });
38
+ var PinnacleClient_js_1 = require("./wrapper/PinnacleClient.js");
39
+ Object.defineProperty(exports, "PinnacleClient", { enumerable: true, get: function () { return PinnacleClient_js_1.PinnacleClient; } });
40
40
  var environments_js_1 = require("./environments.js");
41
41
  Object.defineProperty(exports, "PinnacleEnvironment", { enumerable: true, get: function () { return environments_js_1.PinnacleEnvironment; } });
42
42
  var index_js_1 = require("./errors/index.js");
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.0-rc.11";
1
+ export declare const SDK_VERSION = "2.0.0-rc.13";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "2.0.0-rc.11";
4
+ exports.SDK_VERSION = "2.0.0-rc.13";
@@ -0,0 +1,9 @@
1
+ import { PinnacleClient as FernClient } from "../Client.js";
2
+ import { EnhancedTools } from "./tools/Client.js";
3
+ import { EnhancedMessages } from "./messages/Client.js";
4
+ export declare class PinnacleClient extends FernClient {
5
+ protected _tools: EnhancedTools | undefined;
6
+ protected _messages: EnhancedMessages | undefined;
7
+ get tools(): EnhancedTools;
8
+ get messages(): EnhancedMessages;
9
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PinnacleClient = void 0;
4
+ const Client_js_1 = require("../Client.js");
5
+ const Client_js_2 = require("./tools/Client.js");
6
+ const Client_js_3 = require("./messages/Client.js");
7
+ class PinnacleClient extends Client_js_1.PinnacleClient {
8
+ get tools() {
9
+ var _a;
10
+ return ((_a = this._tools) !== null && _a !== void 0 ? _a : (this._tools = new Client_js_2.EnhancedTools(this._options)));
11
+ }
12
+ get messages() {
13
+ var _a;
14
+ return ((_a = this._messages) !== null && _a !== void 0 ? _a : (this._messages = new Client_js_3.EnhancedMessages(this._options)));
15
+ }
16
+ }
17
+ exports.PinnacleClient = PinnacleClient;
@@ -0,0 +1,13 @@
1
+ import { Messages } from "../../api/resources/messages/client/Client.js";
2
+ import * as Pinnacle from "../../api/index.js";
3
+ interface ExpressLikeRequest {
4
+ headers: Record<string, string | string[] | undefined>;
5
+ body?: any;
6
+ get?: (name: string) => string | undefined;
7
+ protocol?: string;
8
+ originalUrl?: string;
9
+ }
10
+ export declare class EnhancedMessages extends Messages {
11
+ process(req: Request | ExpressLikeRequest, secret?: string): Promise<Pinnacle.MessageEvent>;
12
+ }
13
+ export {};
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EnhancedMessages = void 0;
13
+ const Client_js_1 = require("../../api/resources/messages/client/Client.js");
14
+ const index_js_1 = require("../../api/errors/index.js");
15
+ class EnhancedMessages extends Client_js_1.Messages {
16
+ process(req, secret) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ var _a, _b;
19
+ const signingSecret = secret || process.env.PINNACLE_SIGNING_SECRET;
20
+ let headerSecret;
21
+ let body;
22
+ if (req instanceof Request) {
23
+ headerSecret =
24
+ ((_a = req.headers) === null || _a === void 0 ? void 0 : _a.get("PINNACLE-SIGNING-SECRET")) || ((_b = req.headers) === null || _b === void 0 ? void 0 : _b.get("pinnacle-signing-secret")) || undefined;
25
+ body = yield req.json();
26
+ }
27
+ else {
28
+ const headers = req.headers;
29
+ headerSecret = headers["pinnacle-signing-secret"];
30
+ body = req.body;
31
+ }
32
+ if (!signingSecret) {
33
+ throw new index_js_1.UnauthorizedError({
34
+ error: "Make sure to set the PINNACLE-SIGNING-SECRET environment variable or pass the secret as an argument to the process method",
35
+ });
36
+ }
37
+ if (!headerSecret) {
38
+ throw new index_js_1.UnauthorizedError({
39
+ error: "Failed to get the PINNACLE-SIGNING-SECRET header from request",
40
+ });
41
+ }
42
+ if (headerSecret !== signingSecret) {
43
+ throw new index_js_1.UnauthorizedError({ error: "Invalid webhook signature" });
44
+ }
45
+ return body;
46
+ });
47
+ }
48
+ }
49
+ exports.EnhancedMessages = EnhancedMessages;
@@ -0,0 +1,6 @@
1
+ import { Tools } from '../../api/resources/tools/client/Client.js';
2
+ import { FileUploader } from './FileUploader.js';
3
+ export declare class EnhancedTools extends Tools {
4
+ protected _fileUploader: FileUploader | undefined;
5
+ get file(): FileUploader;
6
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnhancedTools = void 0;
4
+ const Client_js_1 = require("../../api/resources/tools/client/Client.js");
5
+ const FileUploader_js_1 = require("./FileUploader.js");
6
+ class EnhancedTools extends Client_js_1.Tools {
7
+ get file() {
8
+ var _a;
9
+ return ((_a = this._fileUploader) !== null && _a !== void 0 ? _a : (this._fileUploader = new FileUploader_js_1.FileUploader(this._options)));
10
+ }
11
+ }
12
+ exports.EnhancedTools = EnhancedTools;
@@ -0,0 +1,15 @@
1
+ import { File_ } from "../../api/resources/tools/resources/file/client/Client.js";
2
+ import { UploadFileParams } from "../../api/resources/tools/resources/file/client/requests/index.js";
3
+ export declare class FileUploader extends File_ {
4
+ /**
5
+ * Upload a file from a file path (Node.js) or File object (browser)
6
+ * @param fileInput - File path string (Node.js) or File object (browser)
7
+ * @param options - Upload options
8
+ * @returns The download URL of the uploaded file
9
+ */
10
+ uploadFromPath(fileInput: string | File, options?: {
11
+ name?: string;
12
+ options?: UploadFileParams.Options;
13
+ }): Promise<string>;
14
+ private getMimeType;
15
+ }
@@ -0,0 +1,162 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.FileUploader = void 0;
46
+ const mime = __importStar(require("mime-types"));
47
+ const Client_js_1 = require("../../api/resources/tools/resources/file/client/Client.js");
48
+ const index_js_1 = require("../../api/errors/index.js");
49
+ class FileUploader extends Client_js_1.File_ {
50
+ /**
51
+ * Upload a file from a file path (Node.js) or File object (browser)
52
+ * @param fileInput - File path string (Node.js) or File object (browser)
53
+ * @param options - Upload options
54
+ * @returns The download URL of the uploaded file
55
+ */
56
+ uploadFromPath(fileInput, options) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ let size;
59
+ let fileName;
60
+ let contentType;
61
+ let blob;
62
+ if (typeof window === "undefined") {
63
+ if (typeof fileInput !== "string") {
64
+ throw new index_js_1.BadRequestError({ message: "In Node.js, fileInput must be a file path string" });
65
+ }
66
+ const fs = yield Promise.resolve().then(() => __importStar(require("fs")));
67
+ const path = yield Promise.resolve().then(() => __importStar(require("path")));
68
+ const filePath = fileInput;
69
+ let stats;
70
+ try {
71
+ stats = yield fs.promises.stat(filePath);
72
+ }
73
+ catch (error) {
74
+ if (error.code === "ENOENT") {
75
+ throw new index_js_1.NotFoundError({ error: `File not found: ${filePath}` });
76
+ }
77
+ throw new index_js_1.InternalServerError({ error: `Failed to access file: ${error.message}` });
78
+ }
79
+ if (stats.isDirectory()) {
80
+ throw new index_js_1.BadRequestError({ message: `Path is a directory, not a file: ${filePath}` });
81
+ }
82
+ size = stats.size;
83
+ fileName = (options === null || options === void 0 ? void 0 : options.name) || path.default.basename(filePath);
84
+ contentType = this.getMimeType(filePath);
85
+ const fileBuffer = yield fs.promises.readFile(filePath);
86
+ const arrayBuffer = new Uint8Array(fileBuffer).buffer;
87
+ blob = new Blob([arrayBuffer], { type: contentType });
88
+ }
89
+ else {
90
+ if (!(fileInput instanceof File)) {
91
+ throw new index_js_1.BadRequestError({ message: "In browser, fileInput must be a File object" });
92
+ }
93
+ const file = fileInput;
94
+ size = file.size;
95
+ fileName = (options === null || options === void 0 ? void 0 : options.name) || file.name;
96
+ contentType = file.type || this.getMimeType(file.name);
97
+ blob = file;
98
+ }
99
+ const uploadParams = {
100
+ contentType,
101
+ size,
102
+ name: fileName,
103
+ options: options === null || options === void 0 ? void 0 : options.options,
104
+ };
105
+ const uploadResult = yield this.upload(uploadParams);
106
+ if (uploadResult.uploadUrl) {
107
+ yield fetch(uploadResult.uploadUrl, {
108
+ method: "PUT",
109
+ body: blob,
110
+ headers: {
111
+ "Content-Type": contentType,
112
+ },
113
+ });
114
+ }
115
+ return uploadResult.downloadUrl;
116
+ });
117
+ }
118
+ getMimeType(filePath) {
119
+ const mimeType = mime.lookup(filePath);
120
+ if (!mimeType) {
121
+ return "application/octet-stream";
122
+ }
123
+ const supportedTypes = new Set([
124
+ "audio/mpeg",
125
+ "audio/mp4",
126
+ "audio/ogg",
127
+ "audio/aac",
128
+ "audio/webm",
129
+ "audio/wav",
130
+ "audio/3gpp",
131
+ "audio/amr",
132
+ "video/mp4",
133
+ "video/mpeg",
134
+ "video/quicktime",
135
+ "video/webm",
136
+ "video/3gpp",
137
+ "video/H264",
138
+ "video/x-m4v",
139
+ "image/jpeg",
140
+ "image/png",
141
+ "image/gif",
142
+ "image/bmp",
143
+ "image/tiff",
144
+ "image/webp",
145
+ "application/pdf",
146
+ "text/csv",
147
+ "application/rtf",
148
+ "text/vcard",
149
+ "text/calendar",
150
+ ]);
151
+ if (supportedTypes.has(mimeType)) {
152
+ return mimeType;
153
+ }
154
+ const baseType = mimeType.split("/")[0];
155
+ if (["audio", "video", "image"].includes(baseType)) {
156
+ console.warn(`MIME type ${mimeType} may not be fully supported. Proceeding anyway.`);
157
+ return mimeType;
158
+ }
159
+ return "application/octet-stream";
160
+ }
161
+ }
162
+ exports.FileUploader = FileUploader;
@@ -18,8 +18,8 @@ export class PinnacleClient {
18
18
  this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
19
19
  "X-Fern-Language": "JavaScript",
20
20
  "X-Fern-SDK-Name": "rcs-js",
21
- "X-Fern-SDK-Version": "2.0.0-rc.11",
22
- "User-Agent": "rcs-js/2.0.0-rc.11",
21
+ "X-Fern-SDK-Version": "2.0.0-rc.13",
22
+ "User-Agent": "rcs-js/2.0.0-rc.13",
23
23
  "X-Fern-Runtime": core.RUNTIME.type,
24
24
  "X-Fern-Runtime-Version": core.RUNTIME.version,
25
25
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -71,6 +71,7 @@ export declare class Rcs {
71
71
  *
72
72
  * @throws {@link Pinnacle.BadRequestError}
73
73
  * @throws {@link Pinnacle.UnauthorizedError}
74
+ * @throws {@link Pinnacle.PaymentRequiredError}
74
75
  * @throws {@link Pinnacle.NotFoundError}
75
76
  * @throws {@link Pinnacle.InternalServerError}
76
77
  *
@@ -169,6 +169,7 @@ export class Rcs {
169
169
  *
170
170
  * @throws {@link Pinnacle.BadRequestError}
171
171
  * @throws {@link Pinnacle.UnauthorizedError}
172
+ * @throws {@link Pinnacle.PaymentRequiredError}
172
173
  * @throws {@link Pinnacle.NotFoundError}
173
174
  * @throws {@link Pinnacle.InternalServerError}
174
175
  *
@@ -200,6 +201,8 @@ export class Rcs {
200
201
  throw new Pinnacle.BadRequestError(_response.error.body, _response.rawResponse);
201
202
  case 401:
202
203
  throw new Pinnacle.UnauthorizedError(_response.error.body, _response.rawResponse);
204
+ case 402:
205
+ throw new Pinnacle.PaymentRequiredError(_response.error.body, _response.rawResponse);
203
206
  case 404:
204
207
  throw new Pinnacle.NotFoundError(_response.error.body, _response.rawResponse);
205
208
  case 500:
@@ -34,7 +34,7 @@ export declare class Rcs {
34
34
  *
35
35
  * Requires an active RCS agent and recipient devices that support RCS Business Messaging.
36
36
  *
37
- * @param {Pinnacle.Rcs} request
37
+ * @param {Pinnacle.RichMessage} request
38
38
  * @param {Rcs.RequestOptions} requestOptions - Request-specific configuration.
39
39
  *
40
40
  * @throws {@link Pinnacle.BadRequestError}
@@ -56,7 +56,7 @@ export declare class Rcs {
56
56
  * to: "to"
57
57
  * })
58
58
  */
59
- send(request: Pinnacle.Rcs, requestOptions?: Rcs.RequestOptions): core.HttpResponsePromise<Pinnacle.messages.RcsSendResponse>;
59
+ send(request: Pinnacle.RichMessage, requestOptions?: Rcs.RequestOptions): core.HttpResponsePromise<Pinnacle.messages.RcsSendResponse>;
60
60
  private __send;
61
61
  /**
62
62
  * Validate RCS message content without sending it.
@@ -24,7 +24,7 @@ export class Rcs {
24
24
  *
25
25
  * Requires an active RCS agent and recipient devices that support RCS Business Messaging.
26
26
  *
27
- * @param {Pinnacle.Rcs} request
27
+ * @param {Pinnacle.RichMessage} request
28
28
  * @param {Rcs.RequestOptions} requestOptions - Request-specific configuration.
29
29
  *
30
30
  * @throws {@link Pinnacle.BadRequestError}
@@ -53,6 +53,27 @@ export declare class File_ {
53
53
  */
54
54
  upload(request: Pinnacle.tools.UploadFileParams, requestOptions?: File_.RequestOptions): core.HttpResponsePromise<Pinnacle.UploadResults>;
55
55
  private __upload;
56
+ /**
57
+ * Refresh expiring presigned URLs for Pinnacle-hosted files to extend their access time.
58
+ *
59
+ * <Callout type="info">
60
+ * This only works for presigned download URLs. At this moment, you cannot refresh a presigned upload URL, generate a new one instead.
61
+ * </Callout>
62
+ *
63
+ * @param {Pinnacle.tools.RefreshFileParams} request
64
+ * @param {File_.RequestOptions} requestOptions - Request-specific configuration.
65
+ *
66
+ * @throws {@link Pinnacle.BadRequestError}
67
+ * @throws {@link Pinnacle.UnauthorizedError}
68
+ * @throws {@link Pinnacle.InternalServerError}
69
+ *
70
+ * @example
71
+ * await client.tools.file.refresh({
72
+ * uris: ["https://server.trypinnacle.app/storage/v1/object/sign/vault/3/test.jpg?token=oldtoken", "https://server.trypinnacle.app/storage/v1/object/sign/vault/3/document.pdf?token=oldtoken2", "icons/3/test.jpg", "invalid/url", "https://google.com"]
73
+ * })
74
+ */
75
+ refresh(request: Pinnacle.tools.RefreshFileParams, requestOptions?: File_.RequestOptions): core.HttpResponsePromise<Pinnacle.RefreshedFile[]>;
76
+ private __refresh;
56
77
  protected _getCustomAuthorizationHeaders(): Promise<{
57
78
  "PINNACLE-API-KEY": string;
58
79
  }>;
@@ -96,6 +96,80 @@ export class File_ {
96
96
  }
97
97
  });
98
98
  }
99
+ /**
100
+ * Refresh expiring presigned URLs for Pinnacle-hosted files to extend their access time.
101
+ *
102
+ * <Callout type="info">
103
+ * This only works for presigned download URLs. At this moment, you cannot refresh a presigned upload URL, generate a new one instead.
104
+ * </Callout>
105
+ *
106
+ * @param {Pinnacle.tools.RefreshFileParams} request
107
+ * @param {File_.RequestOptions} requestOptions - Request-specific configuration.
108
+ *
109
+ * @throws {@link Pinnacle.BadRequestError}
110
+ * @throws {@link Pinnacle.UnauthorizedError}
111
+ * @throws {@link Pinnacle.InternalServerError}
112
+ *
113
+ * @example
114
+ * await client.tools.file.refresh({
115
+ * uris: ["https://server.trypinnacle.app/storage/v1/object/sign/vault/3/test.jpg?token=oldtoken", "https://server.trypinnacle.app/storage/v1/object/sign/vault/3/document.pdf?token=oldtoken2", "icons/3/test.jpg", "invalid/url", "https://google.com"]
116
+ * })
117
+ */
118
+ refresh(request, requestOptions) {
119
+ return core.HttpResponsePromise.fromPromise(this.__refresh(request, requestOptions));
120
+ }
121
+ __refresh(request, requestOptions) {
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ var _a, _b, _c;
124
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
125
+ const _response = yield core.fetcher({
126
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PinnacleEnvironment.Default, "tools/files/refresh"),
127
+ method: "POST",
128
+ headers: _headers,
129
+ contentType: "application/json",
130
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
131
+ requestType: "json",
132
+ body: request,
133
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
134
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
135
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
136
+ });
137
+ if (_response.ok) {
138
+ return { data: _response.body, rawResponse: _response.rawResponse };
139
+ }
140
+ if (_response.error.reason === "status-code") {
141
+ switch (_response.error.statusCode) {
142
+ case 400:
143
+ throw new Pinnacle.BadRequestError(_response.error.body, _response.rawResponse);
144
+ case 401:
145
+ throw new Pinnacle.UnauthorizedError(_response.error.body, _response.rawResponse);
146
+ case 500:
147
+ throw new Pinnacle.InternalServerError(_response.error.body, _response.rawResponse);
148
+ default:
149
+ throw new errors.PinnacleError({
150
+ statusCode: _response.error.statusCode,
151
+ body: _response.error.body,
152
+ rawResponse: _response.rawResponse,
153
+ });
154
+ }
155
+ }
156
+ switch (_response.error.reason) {
157
+ case "non-json":
158
+ throw new errors.PinnacleError({
159
+ statusCode: _response.error.statusCode,
160
+ body: _response.error.rawBody,
161
+ rawResponse: _response.rawResponse,
162
+ });
163
+ case "timeout":
164
+ throw new errors.PinnacleTimeoutError("Timeout exceeded when calling POST /tools/files/refresh.");
165
+ case "unknown":
166
+ throw new errors.PinnacleError({
167
+ message: _response.error.errorMessage,
168
+ rawResponse: _response.rawResponse,
169
+ });
170
+ }
171
+ });
172
+ }
99
173
  _getCustomAuthorizationHeaders() {
100
174
  return __awaiter(this, void 0, void 0, function* () {
101
175
  const apiKeyValue = yield core.Supplier.get(this._options.apiKey);