@chrt-inc/typescript-sdk 1.441.1 → 1.441.2

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 (162) hide show
  1. package/README.md +11 -9
  2. package/dist/cjs/Client.d.ts +3 -3
  3. package/dist/cjs/Client.js +19 -19
  4. package/dist/cjs/api/resources/billing/resources/lineItemGroups/resources/s3Objects/client/Client.d.ts +1 -1
  5. package/dist/cjs/api/resources/billing/resources/lineItemGroups/resources/s3Objects/client/Client.js +2 -2
  6. package/dist/cjs/api/resources/billing/resources/lineItemGroups/resources/s3Objects/client/requests/BodyLineItemGroupsS3ObjectPostAddV1BillingLineItemGroupsS3ObjectsAddV1LineItemGroupIdPost.d.ts +2 -3
  7. package/dist/cjs/api/resources/index.d.ts +1 -2
  8. package/dist/cjs/api/resources/index.js +2 -3
  9. package/dist/cjs/api/resources/orgs/client/Client.d.ts +6 -72
  10. package/dist/cjs/api/resources/orgs/client/Client.js +14 -348
  11. package/dist/cjs/api/resources/orgs/client/requests/index.d.ts +0 -2
  12. package/dist/cjs/api/resources/orgs/resources/index.d.ts +3 -0
  13. package/dist/cjs/api/resources/orgs/resources/index.js +4 -1
  14. package/dist/cjs/api/resources/orgs/resources/privateData/client/Client.d.ts +44 -0
  15. package/dist/cjs/api/resources/orgs/resources/privateData/client/Client.js +118 -0
  16. package/dist/cjs/api/resources/orgs/resources/privateData/index.d.ts +1 -0
  17. package/dist/cjs/{core/exports.js → api/resources/orgs/resources/privateData/index.js} +1 -1
  18. package/dist/cjs/api/resources/orgs/resources/publicData/client/Client.d.ts +96 -0
  19. package/dist/cjs/api/resources/orgs/resources/publicData/client/Client.js +361 -0
  20. package/dist/cjs/api/resources/orgs/resources/publicData/client/index.d.ts +2 -0
  21. package/dist/cjs/{core/file → api/resources/orgs/resources/publicData/client}/index.js +1 -2
  22. package/dist/cjs/api/resources/orgs/resources/publicData/client/requests/index.d.ts +2 -0
  23. package/dist/cjs/api/resources/orgs/resources/publicData/index.d.ts +1 -0
  24. package/dist/cjs/{exports.js → api/resources/orgs/resources/publicData/index.js} +1 -1
  25. package/dist/cjs/api/resources/shipping/resources/taskArtifacts/resources/s3Object/client/Client.d.ts +1 -1
  26. package/dist/cjs/api/resources/shipping/resources/taskArtifacts/resources/s3Object/client/Client.js +2 -2
  27. package/dist/cjs/api/resources/shipping/resources/taskArtifacts/resources/s3Object/client/requests/BodyPostTaskArtifactsS3ObjectAddV1ShippingTaskArtifactsS3ObjectAddV1TaskArtifactIdPost.d.ts +2 -3
  28. package/dist/cjs/api/resources/shipping/resources/taskGroups/resources/s3Object/client/Client.d.ts +1 -1
  29. package/dist/cjs/api/resources/shipping/resources/taskGroups/resources/s3Object/client/Client.js +2 -2
  30. package/dist/cjs/api/resources/shipping/resources/taskGroups/resources/s3Object/client/requests/BodyPostTaskGroupsS3ObjectAddV1ShippingTaskGroupsS3ObjectAddV1TaskGroupIdPost.d.ts +2 -3
  31. package/dist/cjs/api/resources/users/client/Client.d.ts +6 -77
  32. package/dist/cjs/api/resources/users/client/Client.js +11 -349
  33. package/dist/cjs/api/resources/users/client/index.d.ts +0 -1
  34. package/dist/cjs/api/resources/users/client/index.js +0 -15
  35. package/dist/cjs/api/resources/users/resources/index.d.ts +3 -0
  36. package/dist/cjs/api/resources/users/resources/index.js +4 -1
  37. package/dist/cjs/api/resources/users/resources/privateData/client/Client.d.ts +87 -0
  38. package/dist/cjs/api/resources/users/resources/privateData/client/Client.js +309 -0
  39. package/dist/cjs/api/resources/users/resources/privateData/client/index.d.ts +2 -0
  40. package/dist/cjs/api/resources/users/resources/privateData/client/index.js +17 -0
  41. package/dist/cjs/api/resources/users/{client → resources/privateData/client}/requests/FirebaseCloudMessagingTokenClientCreate1.d.ts +1 -1
  42. package/dist/cjs/api/resources/users/resources/privateData/index.d.ts +1 -0
  43. package/dist/cjs/api/resources/users/resources/privateData/index.js +17 -0
  44. package/dist/cjs/api/resources/users/resources/publicData/client/Client.d.ts +44 -0
  45. package/dist/cjs/api/resources/users/resources/publicData/client/Client.js +118 -0
  46. package/dist/cjs/api/resources/users/resources/publicData/client/index.js +2 -0
  47. package/dist/cjs/api/resources/users/resources/publicData/index.d.ts +1 -0
  48. package/dist/cjs/api/resources/users/resources/publicData/index.js +17 -0
  49. package/dist/cjs/api/types/TaskArtifactS3ObjectMetadata1.d.ts +1 -1
  50. package/dist/cjs/api/types/TaskGroupS3ObjectMetadata1.d.ts +1 -1
  51. package/dist/cjs/api/types/ValidationError.d.ts +2 -0
  52. package/dist/cjs/core/index.d.ts +0 -1
  53. package/dist/cjs/core/index.js +1 -2
  54. package/dist/cjs/index.d.ts +0 -1
  55. package/dist/cjs/index.js +0 -4
  56. package/dist/cjs/version.d.ts +1 -1
  57. package/dist/cjs/version.js +1 -1
  58. package/dist/esm/Client.d.mts +3 -3
  59. package/dist/esm/Client.mjs +7 -7
  60. package/dist/esm/api/resources/billing/resources/lineItemGroups/resources/s3Objects/client/Client.d.mts +1 -1
  61. package/dist/esm/api/resources/billing/resources/lineItemGroups/resources/s3Objects/client/Client.mjs +2 -2
  62. package/dist/esm/api/resources/billing/resources/lineItemGroups/resources/s3Objects/client/requests/BodyLineItemGroupsS3ObjectPostAddV1BillingLineItemGroupsS3ObjectsAddV1LineItemGroupIdPost.d.mts +2 -3
  63. package/dist/esm/api/resources/index.d.mts +1 -2
  64. package/dist/esm/api/resources/index.mjs +1 -2
  65. package/dist/esm/api/resources/orgs/client/Client.d.mts +6 -72
  66. package/dist/esm/api/resources/orgs/client/Client.mjs +10 -344
  67. package/dist/esm/api/resources/orgs/client/requests/index.d.mts +0 -2
  68. package/dist/esm/api/resources/orgs/resources/index.d.mts +3 -0
  69. package/dist/esm/api/resources/orgs/resources/index.mjs +3 -0
  70. package/dist/esm/api/resources/orgs/resources/privateData/client/Client.d.mts +44 -0
  71. package/dist/esm/api/resources/orgs/resources/privateData/client/Client.mjs +81 -0
  72. package/dist/esm/api/resources/orgs/resources/privateData/client/index.mjs +1 -0
  73. package/dist/esm/api/resources/orgs/resources/privateData/index.d.mts +1 -0
  74. package/dist/esm/api/resources/orgs/resources/privateData/index.mjs +1 -0
  75. package/dist/esm/api/resources/orgs/resources/publicData/client/Client.d.mts +96 -0
  76. package/dist/esm/api/resources/orgs/resources/publicData/client/Client.mjs +324 -0
  77. package/dist/esm/api/resources/orgs/resources/publicData/client/index.d.mts +2 -0
  78. package/dist/esm/api/resources/orgs/resources/publicData/client/index.mjs +1 -0
  79. package/dist/esm/api/resources/orgs/resources/publicData/client/requests/index.d.mts +2 -0
  80. package/dist/esm/api/resources/orgs/resources/publicData/client/requests/index.mjs +1 -0
  81. package/dist/esm/api/resources/orgs/resources/publicData/index.d.mts +1 -0
  82. package/dist/esm/api/resources/orgs/resources/publicData/index.mjs +1 -0
  83. package/dist/esm/api/resources/shipping/resources/taskArtifacts/resources/s3Object/client/Client.d.mts +1 -1
  84. package/dist/esm/api/resources/shipping/resources/taskArtifacts/resources/s3Object/client/Client.mjs +2 -2
  85. package/dist/esm/api/resources/shipping/resources/taskArtifacts/resources/s3Object/client/requests/BodyPostTaskArtifactsS3ObjectAddV1ShippingTaskArtifactsS3ObjectAddV1TaskArtifactIdPost.d.mts +2 -3
  86. package/dist/esm/api/resources/shipping/resources/taskGroups/resources/s3Object/client/Client.d.mts +1 -1
  87. package/dist/esm/api/resources/shipping/resources/taskGroups/resources/s3Object/client/Client.mjs +2 -2
  88. package/dist/esm/api/resources/shipping/resources/taskGroups/resources/s3Object/client/requests/BodyPostTaskGroupsS3ObjectAddV1ShippingTaskGroupsS3ObjectAddV1TaskGroupIdPost.d.mts +2 -3
  89. package/dist/esm/api/resources/users/client/Client.d.mts +6 -77
  90. package/dist/esm/api/resources/users/client/Client.mjs +10 -315
  91. package/dist/esm/api/resources/users/client/index.d.mts +0 -1
  92. package/dist/esm/api/resources/users/client/index.mjs +1 -1
  93. package/dist/esm/api/resources/users/resources/index.d.mts +3 -0
  94. package/dist/esm/api/resources/users/resources/index.mjs +3 -0
  95. package/dist/esm/api/resources/users/resources/privateData/client/Client.d.mts +87 -0
  96. package/dist/esm/api/resources/users/resources/privateData/client/Client.mjs +272 -0
  97. package/dist/esm/api/resources/users/resources/privateData/client/index.d.mts +2 -0
  98. package/dist/esm/api/resources/users/resources/privateData/client/index.mjs +1 -0
  99. package/dist/esm/api/resources/users/{client → resources/privateData/client}/requests/FirebaseCloudMessagingTokenClientCreate1.d.mts +1 -1
  100. package/dist/esm/api/resources/users/resources/privateData/client/requests/index.mjs +1 -0
  101. package/dist/esm/api/resources/users/resources/privateData/index.d.mts +1 -0
  102. package/dist/esm/api/resources/users/resources/privateData/index.mjs +1 -0
  103. package/dist/esm/api/resources/users/resources/publicData/client/Client.d.mts +44 -0
  104. package/dist/esm/api/resources/users/resources/publicData/client/Client.mjs +81 -0
  105. package/dist/esm/api/resources/users/resources/publicData/client/index.d.mts +1 -0
  106. package/dist/esm/api/resources/users/resources/publicData/client/index.mjs +1 -0
  107. package/dist/esm/api/resources/users/resources/publicData/index.d.mts +1 -0
  108. package/dist/esm/api/resources/users/resources/publicData/index.mjs +1 -0
  109. package/dist/esm/api/types/TaskArtifactS3ObjectMetadata1.d.mts +1 -1
  110. package/dist/esm/api/types/TaskGroupS3ObjectMetadata1.d.mts +1 -1
  111. package/dist/esm/api/types/ValidationError.d.mts +2 -0
  112. package/dist/esm/core/index.d.mts +0 -1
  113. package/dist/esm/core/index.mjs +0 -1
  114. package/dist/esm/index.d.mts +0 -1
  115. package/dist/esm/index.mjs +0 -1
  116. package/dist/esm/version.d.mts +1 -1
  117. package/dist/esm/version.mjs +1 -1
  118. package/package.json +1 -1
  119. package/reference.md +1962 -1956
  120. package/dist/cjs/core/exports.d.ts +0 -1
  121. package/dist/cjs/core/file/exports.d.ts +0 -1
  122. package/dist/cjs/core/file/file.d.ts +0 -5
  123. package/dist/cjs/core/file/file.js +0 -203
  124. package/dist/cjs/core/file/index.d.ts +0 -2
  125. package/dist/cjs/core/file/types.d.ts +0 -66
  126. package/dist/cjs/exports.d.ts +0 -1
  127. package/dist/esm/core/exports.d.mts +0 -1
  128. package/dist/esm/core/exports.mjs +0 -1
  129. package/dist/esm/core/file/exports.d.mts +0 -1
  130. package/dist/esm/core/file/file.d.mts +0 -5
  131. package/dist/esm/core/file/file.mjs +0 -167
  132. package/dist/esm/core/file/index.d.mts +0 -2
  133. package/dist/esm/core/file/index.mjs +0 -2
  134. package/dist/esm/core/file/types.d.mts +0 -66
  135. package/dist/esm/exports.d.mts +0 -1
  136. package/dist/esm/exports.mjs +0 -1
  137. /package/dist/{esm/api/resources/users/client/requests/index.mjs → cjs/api/resources/orgs/resources/privateData/client/index.d.ts} +0 -0
  138. /package/dist/cjs/api/resources/{users/client/requests → orgs/resources/privateData/client}/index.js +0 -0
  139. /package/dist/cjs/api/resources/orgs/{client → resources/publicData/client}/requests/CreateOrgPublicDataReq.d.ts +0 -0
  140. /package/dist/cjs/api/resources/orgs/{client → resources/publicData/client}/requests/CreateOrgPublicDataReq.js +0 -0
  141. /package/dist/cjs/api/resources/orgs/{client → resources/publicData/client}/requests/UpdateOrgPublicDataReq.d.ts +0 -0
  142. /package/dist/cjs/api/resources/orgs/{client → resources/publicData/client}/requests/UpdateOrgPublicDataReq.js +0 -0
  143. /package/dist/cjs/{core/file/exports.js → api/resources/orgs/resources/publicData/client/requests/index.js} +0 -0
  144. /package/dist/cjs/api/resources/users/{client → resources/privateData/client}/requests/FirebaseCloudMessagingTokenClientCreate1.js +0 -0
  145. /package/dist/cjs/api/resources/users/{client → resources/privateData/client}/requests/UserPrivateDataClientCreate1.d.ts +0 -0
  146. /package/dist/cjs/api/resources/users/{client → resources/privateData/client}/requests/UserPrivateDataClientCreate1.js +0 -0
  147. /package/dist/cjs/api/resources/users/{client → resources/privateData/client}/requests/UserPrivateDataClientUpdate1.d.ts +0 -0
  148. /package/dist/cjs/api/resources/users/{client → resources/privateData/client}/requests/UserPrivateDataClientUpdate1.js +0 -0
  149. /package/dist/cjs/api/resources/users/{client → resources/privateData/client}/requests/index.d.ts +0 -0
  150. /package/dist/cjs/{core/file/types.js → api/resources/users/resources/privateData/client/requests/index.js} +0 -0
  151. /package/dist/{esm/core/file/exports.mjs → cjs/api/resources/users/resources/publicData/client/index.d.ts} +0 -0
  152. /package/dist/esm/{core/file/types.mjs → api/resources/orgs/resources/privateData/client/index.d.mts} +0 -0
  153. /package/dist/esm/api/resources/orgs/{client → resources/publicData/client}/requests/CreateOrgPublicDataReq.d.mts +0 -0
  154. /package/dist/esm/api/resources/orgs/{client → resources/publicData/client}/requests/CreateOrgPublicDataReq.mjs +0 -0
  155. /package/dist/esm/api/resources/orgs/{client → resources/publicData/client}/requests/UpdateOrgPublicDataReq.d.mts +0 -0
  156. /package/dist/esm/api/resources/orgs/{client → resources/publicData/client}/requests/UpdateOrgPublicDataReq.mjs +0 -0
  157. /package/dist/esm/api/resources/users/{client → resources/privateData/client}/requests/FirebaseCloudMessagingTokenClientCreate1.mjs +0 -0
  158. /package/dist/esm/api/resources/users/{client → resources/privateData/client}/requests/UserPrivateDataClientCreate1.d.mts +0 -0
  159. /package/dist/esm/api/resources/users/{client → resources/privateData/client}/requests/UserPrivateDataClientCreate1.mjs +0 -0
  160. /package/dist/esm/api/resources/users/{client → resources/privateData/client}/requests/UserPrivateDataClientUpdate1.d.mts +0 -0
  161. /package/dist/esm/api/resources/users/{client → resources/privateData/client}/requests/UserPrivateDataClientUpdate1.mjs +0 -0
  162. /package/dist/esm/api/resources/users/{client → resources/privateData/client}/requests/index.d.mts +0 -0
@@ -1 +0,0 @@
1
- export * from "./file/exports.js";
@@ -1 +0,0 @@
1
- export { Uploadable } from "./types.js";
@@ -1,5 +0,0 @@
1
- import { Uploadable } from "./types.js";
2
- export declare function toBinaryUploadRequest(file: Uploadable): Promise<{
3
- body: Uploadable.FileLike;
4
- headers?: Record<string, string>;
5
- }>;
@@ -1,203 +0,0 @@
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.toBinaryUploadRequest = toBinaryUploadRequest;
46
- function toBinaryUploadRequest(file) {
47
- return __awaiter(this, void 0, void 0, function* () {
48
- const { data, filename, contentLength, contentType } = yield getFileWithMetadata(file);
49
- const request = {
50
- body: data,
51
- headers: {},
52
- };
53
- if (filename) {
54
- request.headers["Content-Disposition"] = `attachment; filename="${filename}"`;
55
- }
56
- if (contentType) {
57
- request.headers["Content-Type"] = contentType;
58
- }
59
- if (contentLength != null) {
60
- request.headers["Content-Length"] = contentLength.toString();
61
- }
62
- return request;
63
- });
64
- }
65
- function getFileWithMetadata(file) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- var _a, _b, _c, _d, _e;
68
- if (isFileLike(file)) {
69
- return getFileWithMetadata({
70
- data: file,
71
- });
72
- }
73
- if ("path" in file) {
74
- const fs = yield Promise.resolve().then(() => __importStar(require("fs")));
75
- if (!fs || !fs.createReadStream) {
76
- throw new Error("File path uploads are not supported in this environment.");
77
- }
78
- const data = fs.createReadStream(file.path);
79
- const contentLength = (_a = file.contentLength) !== null && _a !== void 0 ? _a : (yield tryGetFileSizeFromPath(file.path));
80
- const filename = (_b = file.filename) !== null && _b !== void 0 ? _b : getNameFromPath(file.path);
81
- return {
82
- data,
83
- filename,
84
- contentType: file.contentType,
85
- contentLength,
86
- };
87
- }
88
- if ("data" in file) {
89
- const data = file.data;
90
- const contentLength = (_c = file.contentLength) !== null && _c !== void 0 ? _c : (yield tryGetContentLengthFromFileLike(data));
91
- const filename = (_d = file.filename) !== null && _d !== void 0 ? _d : tryGetNameFromFileLike(data);
92
- return {
93
- data,
94
- filename,
95
- contentType: (_e = file.contentType) !== null && _e !== void 0 ? _e : tryGetContentTypeFromFileLike(data),
96
- contentLength,
97
- };
98
- }
99
- throw new Error(`Invalid FileUpload of type ${typeof file}: ${JSON.stringify(file)}`);
100
- });
101
- }
102
- function isFileLike(value) {
103
- return (isBuffer(value) ||
104
- isArrayBufferView(value) ||
105
- isArrayBuffer(value) ||
106
- isUint8Array(value) ||
107
- isBlob(value) ||
108
- isFile(value) ||
109
- isStreamLike(value) ||
110
- isReadableStream(value));
111
- }
112
- function tryGetFileSizeFromPath(path) {
113
- return __awaiter(this, void 0, void 0, function* () {
114
- try {
115
- const fs = yield Promise.resolve().then(() => __importStar(require("fs")));
116
- if (!fs || !fs.promises || !fs.promises.stat) {
117
- return undefined;
118
- }
119
- const fileStat = yield fs.promises.stat(path);
120
- return fileStat.size;
121
- }
122
- catch (fallbackError) {
123
- return undefined;
124
- }
125
- });
126
- }
127
- function tryGetNameFromFileLike(data) {
128
- if (isNamedValue(data)) {
129
- return data.name;
130
- }
131
- if (isPathedValue(data)) {
132
- return getNameFromPath(data.path.toString());
133
- }
134
- return undefined;
135
- }
136
- function tryGetContentLengthFromFileLike(data) {
137
- return __awaiter(this, void 0, void 0, function* () {
138
- if (isBuffer(data)) {
139
- return data.length;
140
- }
141
- if (isArrayBufferView(data)) {
142
- return data.byteLength;
143
- }
144
- if (isArrayBuffer(data)) {
145
- return data.byteLength;
146
- }
147
- if (isBlob(data)) {
148
- return data.size;
149
- }
150
- if (isFile(data)) {
151
- return data.size;
152
- }
153
- if (isPathedValue(data)) {
154
- return yield tryGetFileSizeFromPath(data.path.toString());
155
- }
156
- return undefined;
157
- });
158
- }
159
- function tryGetContentTypeFromFileLike(data) {
160
- if (isBlob(data)) {
161
- return data.type;
162
- }
163
- if (isFile(data)) {
164
- return data.type;
165
- }
166
- return undefined;
167
- }
168
- function getNameFromPath(path) {
169
- const lastForwardSlash = path.lastIndexOf("/");
170
- const lastBackSlash = path.lastIndexOf("\\");
171
- const lastSlashIndex = Math.max(lastForwardSlash, lastBackSlash);
172
- return lastSlashIndex >= 0 ? path.substring(lastSlashIndex + 1) : path;
173
- }
174
- function isNamedValue(value) {
175
- return typeof value === "object" && value != null && "name" in value;
176
- }
177
- function isPathedValue(value) {
178
- return typeof value === "object" && value != null && "path" in value;
179
- }
180
- function isStreamLike(value) {
181
- return typeof value === "object" && value != null && ("read" in value || "pipe" in value);
182
- }
183
- function isReadableStream(value) {
184
- return typeof value === "object" && value != null && "getReader" in value;
185
- }
186
- function isBuffer(value) {
187
- return typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(value);
188
- }
189
- function isArrayBufferView(value) {
190
- return typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView(value);
191
- }
192
- function isArrayBuffer(value) {
193
- return typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer;
194
- }
195
- function isUint8Array(value) {
196
- return typeof Uint8Array !== "undefined" && value instanceof Uint8Array;
197
- }
198
- function isBlob(value) {
199
- return typeof Blob !== "undefined" && value instanceof Blob;
200
- }
201
- function isFile(value) {
202
- return typeof File !== "undefined" && value instanceof File;
203
- }
@@ -1,2 +0,0 @@
1
- export * from "./file.js";
2
- export * from "./types.js";
@@ -1,66 +0,0 @@
1
- /**
2
- * A file that can be uploaded. Can be a file-like object (stream, buffer, blob, etc.),
3
- * a path to a file, or an object with a file-like object and metadata.
4
- */
5
- export type Uploadable = Uploadable.FileLike | Uploadable.FromPath | Uploadable.WithMetadata;
6
- export declare namespace Uploadable {
7
- /**
8
- * Various file-like objects that can be used to upload a file.
9
- */
10
- type FileLike = ArrayBuffer | ArrayBufferLike | ArrayBufferView | Uint8Array | import("buffer").Buffer | import("buffer").Blob | import("buffer").File | import("stream").Readable | import("stream/web").ReadableStream | globalThis.Blob | globalThis.File | ReadableStream;
11
- /**
12
- * A file path with optional metadata, used for uploading a file from the file system.
13
- */
14
- type FromPath = {
15
- /** The path to the file to upload */
16
- path: string;
17
- /**
18
- * Optional override for the file name (defaults to basename of path).
19
- * This is used to set the `Content-Disposition` header in upload requests.
20
- */
21
- filename?: string;
22
- /**
23
- * Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain').
24
- * This is used to set the `Content-Type` header in upload requests.
25
- */
26
- contentType?: string;
27
- /**
28
- * Optional file size in bytes.
29
- * If not provided, the file size will be determined from the file system.
30
- * The content length is used to set the `Content-Length` header in upload requests.
31
- */
32
- contentLength?: number;
33
- };
34
- /**
35
- * A file-like object with metadata, used for uploading files.
36
- */
37
- type WithMetadata = {
38
- /** The file data */
39
- data: FileLike;
40
- /**
41
- * Optional override for the file name (defaults to basename of path).
42
- * This is used to set the `Content-Disposition` header in upload requests.
43
- */
44
- filename?: string;
45
- /**
46
- * Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain').
47
- * This is used to set the `Content-Type` header in upload requests.
48
- *
49
- * If not provided, the content type may be determined from the data itself.
50
- * * If the data is a `File`, `Blob`, or similar, the content type will be determined from the file itself, if the type is set.
51
- * * Any other data type will not have a content type set, and the upload request will use `Content-Type: application/octet-stream` instead.
52
- */
53
- contentType?: string;
54
- /**
55
- * Optional file size in bytes.
56
- * The content length is used to set the `Content-Length` header in upload requests.
57
- * If the content length is not provided and cannot be determined, the upload request will not include the `Content-Length` header, but will use `Transfer-Encoding: chunked` instead.
58
- *
59
- * If not provided, the file size will be determined depending on the data type.
60
- * * If the data is of type `fs.ReadStream` (`createReadStream`), the size will be determined from the file system.
61
- * * If the data is a `Buffer`, `ArrayBuffer`, `Uint8Array`, `Blob`, `File`, or similar, the size will be determined from the data itself.
62
- * * If the data is a `Readable` or `ReadableStream`, the size will not be determined.
63
- */
64
- contentLength?: number;
65
- };
66
- }
@@ -1 +0,0 @@
1
- export * from "./core/exports.js";
@@ -1 +0,0 @@
1
- export * from "./file/exports.mjs";
@@ -1 +0,0 @@
1
- export * from "./file/exports.mjs";
@@ -1 +0,0 @@
1
- export { Uploadable } from "./types.mjs";
@@ -1,5 +0,0 @@
1
- import { Uploadable } from "./types.mjs";
2
- export declare function toBinaryUploadRequest(file: Uploadable): Promise<{
3
- body: Uploadable.FileLike;
4
- headers?: Record<string, string>;
5
- }>;
@@ -1,167 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- export function toBinaryUploadRequest(file) {
11
- return __awaiter(this, void 0, void 0, function* () {
12
- const { data, filename, contentLength, contentType } = yield getFileWithMetadata(file);
13
- const request = {
14
- body: data,
15
- headers: {},
16
- };
17
- if (filename) {
18
- request.headers["Content-Disposition"] = `attachment; filename="${filename}"`;
19
- }
20
- if (contentType) {
21
- request.headers["Content-Type"] = contentType;
22
- }
23
- if (contentLength != null) {
24
- request.headers["Content-Length"] = contentLength.toString();
25
- }
26
- return request;
27
- });
28
- }
29
- function getFileWithMetadata(file) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- var _a, _b, _c, _d, _e;
32
- if (isFileLike(file)) {
33
- return getFileWithMetadata({
34
- data: file,
35
- });
36
- }
37
- if ("path" in file) {
38
- const fs = yield import("fs");
39
- if (!fs || !fs.createReadStream) {
40
- throw new Error("File path uploads are not supported in this environment.");
41
- }
42
- const data = fs.createReadStream(file.path);
43
- const contentLength = (_a = file.contentLength) !== null && _a !== void 0 ? _a : (yield tryGetFileSizeFromPath(file.path));
44
- const filename = (_b = file.filename) !== null && _b !== void 0 ? _b : getNameFromPath(file.path);
45
- return {
46
- data,
47
- filename,
48
- contentType: file.contentType,
49
- contentLength,
50
- };
51
- }
52
- if ("data" in file) {
53
- const data = file.data;
54
- const contentLength = (_c = file.contentLength) !== null && _c !== void 0 ? _c : (yield tryGetContentLengthFromFileLike(data));
55
- const filename = (_d = file.filename) !== null && _d !== void 0 ? _d : tryGetNameFromFileLike(data);
56
- return {
57
- data,
58
- filename,
59
- contentType: (_e = file.contentType) !== null && _e !== void 0 ? _e : tryGetContentTypeFromFileLike(data),
60
- contentLength,
61
- };
62
- }
63
- throw new Error(`Invalid FileUpload of type ${typeof file}: ${JSON.stringify(file)}`);
64
- });
65
- }
66
- function isFileLike(value) {
67
- return (isBuffer(value) ||
68
- isArrayBufferView(value) ||
69
- isArrayBuffer(value) ||
70
- isUint8Array(value) ||
71
- isBlob(value) ||
72
- isFile(value) ||
73
- isStreamLike(value) ||
74
- isReadableStream(value));
75
- }
76
- function tryGetFileSizeFromPath(path) {
77
- return __awaiter(this, void 0, void 0, function* () {
78
- try {
79
- const fs = yield import("fs");
80
- if (!fs || !fs.promises || !fs.promises.stat) {
81
- return undefined;
82
- }
83
- const fileStat = yield fs.promises.stat(path);
84
- return fileStat.size;
85
- }
86
- catch (fallbackError) {
87
- return undefined;
88
- }
89
- });
90
- }
91
- function tryGetNameFromFileLike(data) {
92
- if (isNamedValue(data)) {
93
- return data.name;
94
- }
95
- if (isPathedValue(data)) {
96
- return getNameFromPath(data.path.toString());
97
- }
98
- return undefined;
99
- }
100
- function tryGetContentLengthFromFileLike(data) {
101
- return __awaiter(this, void 0, void 0, function* () {
102
- if (isBuffer(data)) {
103
- return data.length;
104
- }
105
- if (isArrayBufferView(data)) {
106
- return data.byteLength;
107
- }
108
- if (isArrayBuffer(data)) {
109
- return data.byteLength;
110
- }
111
- if (isBlob(data)) {
112
- return data.size;
113
- }
114
- if (isFile(data)) {
115
- return data.size;
116
- }
117
- if (isPathedValue(data)) {
118
- return yield tryGetFileSizeFromPath(data.path.toString());
119
- }
120
- return undefined;
121
- });
122
- }
123
- function tryGetContentTypeFromFileLike(data) {
124
- if (isBlob(data)) {
125
- return data.type;
126
- }
127
- if (isFile(data)) {
128
- return data.type;
129
- }
130
- return undefined;
131
- }
132
- function getNameFromPath(path) {
133
- const lastForwardSlash = path.lastIndexOf("/");
134
- const lastBackSlash = path.lastIndexOf("\\");
135
- const lastSlashIndex = Math.max(lastForwardSlash, lastBackSlash);
136
- return lastSlashIndex >= 0 ? path.substring(lastSlashIndex + 1) : path;
137
- }
138
- function isNamedValue(value) {
139
- return typeof value === "object" && value != null && "name" in value;
140
- }
141
- function isPathedValue(value) {
142
- return typeof value === "object" && value != null && "path" in value;
143
- }
144
- function isStreamLike(value) {
145
- return typeof value === "object" && value != null && ("read" in value || "pipe" in value);
146
- }
147
- function isReadableStream(value) {
148
- return typeof value === "object" && value != null && "getReader" in value;
149
- }
150
- function isBuffer(value) {
151
- return typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(value);
152
- }
153
- function isArrayBufferView(value) {
154
- return typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView(value);
155
- }
156
- function isArrayBuffer(value) {
157
- return typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer;
158
- }
159
- function isUint8Array(value) {
160
- return typeof Uint8Array !== "undefined" && value instanceof Uint8Array;
161
- }
162
- function isBlob(value) {
163
- return typeof Blob !== "undefined" && value instanceof Blob;
164
- }
165
- function isFile(value) {
166
- return typeof File !== "undefined" && value instanceof File;
167
- }
@@ -1,2 +0,0 @@
1
- export * from "./file.mjs";
2
- export * from "./types.mjs";
@@ -1,2 +0,0 @@
1
- export * from "./file.mjs";
2
- export * from "./types.mjs";
@@ -1,66 +0,0 @@
1
- /**
2
- * A file that can be uploaded. Can be a file-like object (stream, buffer, blob, etc.),
3
- * a path to a file, or an object with a file-like object and metadata.
4
- */
5
- export type Uploadable = Uploadable.FileLike | Uploadable.FromPath | Uploadable.WithMetadata;
6
- export declare namespace Uploadable {
7
- /**
8
- * Various file-like objects that can be used to upload a file.
9
- */
10
- type FileLike = ArrayBuffer | ArrayBufferLike | ArrayBufferView | Uint8Array | import("buffer").Buffer | import("buffer").Blob | import("buffer").File | import("stream").Readable | import("stream/web").ReadableStream | globalThis.Blob | globalThis.File | ReadableStream;
11
- /**
12
- * A file path with optional metadata, used for uploading a file from the file system.
13
- */
14
- type FromPath = {
15
- /** The path to the file to upload */
16
- path: string;
17
- /**
18
- * Optional override for the file name (defaults to basename of path).
19
- * This is used to set the `Content-Disposition` header in upload requests.
20
- */
21
- filename?: string;
22
- /**
23
- * Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain').
24
- * This is used to set the `Content-Type` header in upload requests.
25
- */
26
- contentType?: string;
27
- /**
28
- * Optional file size in bytes.
29
- * If not provided, the file size will be determined from the file system.
30
- * The content length is used to set the `Content-Length` header in upload requests.
31
- */
32
- contentLength?: number;
33
- };
34
- /**
35
- * A file-like object with metadata, used for uploading files.
36
- */
37
- type WithMetadata = {
38
- /** The file data */
39
- data: FileLike;
40
- /**
41
- * Optional override for the file name (defaults to basename of path).
42
- * This is used to set the `Content-Disposition` header in upload requests.
43
- */
44
- filename?: string;
45
- /**
46
- * Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain').
47
- * This is used to set the `Content-Type` header in upload requests.
48
- *
49
- * If not provided, the content type may be determined from the data itself.
50
- * * If the data is a `File`, `Blob`, or similar, the content type will be determined from the file itself, if the type is set.
51
- * * Any other data type will not have a content type set, and the upload request will use `Content-Type: application/octet-stream` instead.
52
- */
53
- contentType?: string;
54
- /**
55
- * Optional file size in bytes.
56
- * The content length is used to set the `Content-Length` header in upload requests.
57
- * If the content length is not provided and cannot be determined, the upload request will not include the `Content-Length` header, but will use `Transfer-Encoding: chunked` instead.
58
- *
59
- * If not provided, the file size will be determined depending on the data type.
60
- * * If the data is of type `fs.ReadStream` (`createReadStream`), the size will be determined from the file system.
61
- * * If the data is a `Buffer`, `ArrayBuffer`, `Uint8Array`, `Blob`, `File`, or similar, the size will be determined from the data itself.
62
- * * If the data is a `Readable` or `ReadableStream`, the size will not be determined.
63
- */
64
- contentLength?: number;
65
- };
66
- }
@@ -1 +0,0 @@
1
- export * from "./core/exports.mjs";
@@ -1 +0,0 @@
1
- export * from "./core/exports.mjs";