@internxt/sdk 1.9.14 → 1.9.16

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.
@@ -3,7 +3,7 @@ import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
3
3
  import { RequestCanceler } from '../../shared/http/client';
4
4
  import { UUID } from '../../shared/types/userSettings';
5
5
  import { ItemType } from './../../workspaces/types';
6
- import { AddItemsToTrashPayload, CheckDuplicatedFilesPayload, CheckDuplicatedFilesResponse, CheckDuplicatedFolderPayload, CheckDuplicatedFoldersResponse, CreateFolderByUuidPayload, CreateFolderPayload, CreateFolderResponse, DeleteFilePayload, DriveFileData, FetchFolderContentResponse, FetchLimitResponse, FetchPaginatedFilesContent, FetchPaginatedFolderContentResponse, FetchPaginatedFoldersContent, FileEntry, FileEntryByUuid, FileMeta, FolderAncestor, FolderAncestorWorkspace, FolderMeta, FolderTreeResponse, MoveFilePayload, MoveFileResponse, MoveFileUuidPayload, MoveFolderPayload, MoveFolderResponse, MoveFolderUuidPayload, ReplaceFile, SearchResultData, Thumbnail, ThumbnailEntry, UpdateFilePayload, UpdateFolderMetadataPayload, UsageResponse } from './types';
6
+ import { AddItemsToTrashPayload, CheckDuplicatedFilesPayload, CheckDuplicatedFilesResponse, CheckDuplicatedFolderPayload, CheckDuplicatedFoldersResponse, CreateFolderByUuidPayload, CreateFolderPayload, CreateFolderResponse, CreateThumbnailEntryPayload, DeleteFilePayload, DriveFileData, FetchFolderContentResponse, FetchLimitResponse, FetchPaginatedFilesContent, FetchPaginatedFolderContentResponse, FetchPaginatedFoldersContent, FileEntry, FileEntryByUuid, FileMeta, FolderAncestor, FolderAncestorWorkspace, FolderMeta, FolderTreeResponse, MoveFilePayload, MoveFileResponse, MoveFileUuidPayload, MoveFolderPayload, MoveFolderResponse, MoveFolderUuidPayload, ReplaceFile, SearchResultData, Thumbnail, ThumbnailEntry, UpdateFilePayload, UpdateFolderMetadataPayload, UsageResponse } from './types';
7
7
  export * as StorageTypes from './types';
8
8
  export declare class Storage {
9
9
  private readonly client;
@@ -148,6 +148,11 @@ export declare class Storage {
148
148
  * @param thumbnailEntry
149
149
  */
150
150
  createThumbnailEntry(thumbnailEntry: ThumbnailEntry, resourcesToken?: Token): Promise<Thumbnail>;
151
+ /**
152
+ * Creates a new thumbnail entry using drive-server-wip
153
+ * @param CreateThumbnailEntryPayload
154
+ */
155
+ createThumbnailEntryWithUUID(thumbnailEntry: CreateThumbnailEntryPayload, resourcesToken?: string): Promise<Thumbnail>;
151
156
  /**
152
157
  * Updates the details of a file entry
153
158
  * @param payload
@@ -371,6 +371,13 @@ var Storage = /** @class */ (function () {
371
371
  thumbnail: thumbnailEntry,
372
372
  }, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
373
373
  };
374
+ /**
375
+ * Creates a new thumbnail entry using drive-server-wip
376
+ * @param CreateThumbnailEntryPayload
377
+ */
378
+ Storage.prototype.createThumbnailEntryWithUUID = function (thumbnailEntry, resourcesToken) {
379
+ return this.client.post('/files/thumbnail', __assign({}, thumbnailEntry), (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
380
+ };
374
381
  /**
375
382
  * Updates the details of a file entry
376
383
  * @param payload
@@ -275,6 +275,17 @@ export interface ThumbnailEntry {
275
275
  bucket_file: string;
276
276
  encrypt_version: EncryptionVersion;
277
277
  }
278
+ export interface CreateThumbnailEntryPayload {
279
+ fileId: number;
280
+ fileUuid: string;
281
+ type: string;
282
+ size: number;
283
+ maxWidth: number;
284
+ maxHeight: number;
285
+ bucketId: string;
286
+ bucketFile: string;
287
+ encryptVersion: EncryptionVersion;
288
+ }
278
289
  export interface CreateFolderPayload {
279
290
  parentFolderId: number;
280
291
  folderName: string;
package/dist/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export * as photos from './photos';
5
5
  export * as Shared from './shared';
6
6
  export * as Workspaces from './workspaces';
7
7
  export * from './meet';
8
+ export * as Payments from './payments';
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
26
  return result;
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.Workspaces = exports.Shared = exports.photos = exports.Network = exports.Drive = void 0;
29
+ exports.Payments = exports.Workspaces = exports.Shared = exports.photos = exports.Network = exports.Drive = void 0;
30
30
  __exportStar(require("./auth"), exports);
31
31
  exports.Drive = __importStar(require("./drive"));
32
32
  exports.Network = __importStar(require("./network"));
@@ -34,3 +34,4 @@ exports.photos = __importStar(require("./photos"));
34
34
  exports.Shared = __importStar(require("./shared"));
35
35
  exports.Workspaces = __importStar(require("./workspaces"));
36
36
  __exportStar(require("./meet"), exports);
37
+ exports.Payments = __importStar(require("./payments"));
@@ -0,0 +1,76 @@
1
+ import { CreatedSubscriptionData } from '../drive/payments/types/types';
2
+ import { ApiSecurity, ApiUrl, AppDetails } from '../shared';
3
+ import { CreatePaymentIntentPayload, CreateSubscriptionPayload, GetPriceByIdPayload, PriceWithTax } from './types';
4
+ export declare class Checkout {
5
+ private readonly client;
6
+ private readonly appDetails;
7
+ private readonly apiSecurity;
8
+ static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity: ApiSecurity): Checkout;
9
+ private constructor();
10
+ /**
11
+ * @description Creates a customer or gets the existing one if it already exists
12
+ * @param country - The country of the customer
13
+ * @param postalCode - The postal code of the customer
14
+ * @param companyVatId - The VAT ID of the company (optional)
15
+ * @returns The customer ID and the user token used to create a subscription or payment intent
16
+ */
17
+ getCustomerId({ country, postalCode, companyVatId, companyName, }: {
18
+ country: string;
19
+ postalCode: string;
20
+ companyVatId?: string;
21
+ companyName?: string;
22
+ }): Promise<{
23
+ customerId: string;
24
+ token: string;
25
+ }>;
26
+ /**
27
+ * @description Creates a subscription for a given customer
28
+ * @param customerId - The ID of the customer
29
+ * @param priceId - The ID of the price
30
+ * @param token - The token used to authenticate the customer
31
+ * @param currency - The currency of the subscription (optional)
32
+ * @param promoCodeId - The ID of the promo code (optional)
33
+ * @param quantity - The quantity of the subscription (optional)
34
+ * @returns The created subscription data:
35
+ * - `type`: The type of the subscription (setup or payment)
36
+ * - `clientSecret`: The client secret for the subscription to be used with Stripe Elements
37
+ * - `subscriptionId`: The ID of the subscription (optional)
38
+ * - `paymentIntentId`: The ID of the payment intent (optional)
39
+ */
40
+ createSubscription({ customerId, priceId, token, currency, promoCodeId, quantity, }: CreateSubscriptionPayload): Promise<CreatedSubscriptionData>;
41
+ /**
42
+ * @description Creates a payment intent for a given customer
43
+ * @param customerId - The ID of the customer
44
+ * @param priceId - The ID of the price
45
+ * @param token - The token used to authenticate the customer
46
+ * @param currency - The currency of the payment intent (optional)
47
+ * @param promoCodeId - The ID of the promo code (optional)
48
+ * @returns The created invoice data:
49
+ * - `clientSecret`: The client secret for the invoice to be used with Stripe Elements
50
+ * - `id`: The ID of the invoice
51
+ * - `invoiceStatus`: The status of the invoice (only when the status is 'paid')
52
+ */
53
+ createPaymentIntent({ customerId, priceId, token, currency, promoCodeId, }: CreatePaymentIntentPayload): Promise<{
54
+ clientSecret: string;
55
+ id: string;
56
+ invoiceStatus?: string;
57
+ }>;
58
+ /**
59
+ * @description Fetch a requested price by its ID and its tax rate
60
+ * @param priceId - The ID of the price
61
+ * @param promoCodeName - The name of the promo code (optional)
62
+ * @param currency - The currency of the price (optional)
63
+ * @returns The price object containing the details of the requested price
64
+ */
65
+ getPriceById({ priceId, promoCodeName, currency, postalCode, country, }: GetPriceByIdPayload): Promise<PriceWithTax>;
66
+ /**
67
+ * Returns the needed headers with authorization header for the module requests
68
+ * @private
69
+ */
70
+ private authHeaders;
71
+ /**
72
+ * Returns the basic needed headers for the module requests
73
+ * @private
74
+ */
75
+ private headers;
76
+ }
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.Checkout = void 0;
15
+ var headers_1 = require("../shared/headers");
16
+ var client_1 = require("../shared/http/client");
17
+ var Checkout = /** @class */ (function () {
18
+ function Checkout(apiUrl, appDetails, apiSecurity) {
19
+ this.client = client_1.HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback);
20
+ this.appDetails = appDetails;
21
+ this.apiSecurity = apiSecurity;
22
+ }
23
+ Checkout.client = function (apiUrl, appDetails, apiSecurity) {
24
+ return new Checkout(apiUrl, appDetails, apiSecurity);
25
+ };
26
+ /**
27
+ * @description Creates a customer or gets the existing one if it already exists
28
+ * @param country - The country of the customer
29
+ * @param postalCode - The postal code of the customer
30
+ * @param companyVatId - The VAT ID of the company (optional)
31
+ * @returns The customer ID and the user token used to create a subscription or payment intent
32
+ */
33
+ Checkout.prototype.getCustomerId = function (_a) {
34
+ var country = _a.country, postalCode = _a.postalCode, companyVatId = _a.companyVatId, companyName = _a.companyName;
35
+ var query = new URLSearchParams();
36
+ query.set('country', country);
37
+ query.set('postalCode', postalCode);
38
+ if (companyVatId !== undefined)
39
+ query.set('companyVatId', companyVatId);
40
+ if (companyName !== undefined)
41
+ query.set('companyName', companyName);
42
+ return this.client.get("/checkout/customer?".concat(query.toString()), this.authHeaders());
43
+ };
44
+ /**
45
+ * @description Creates a subscription for a given customer
46
+ * @param customerId - The ID of the customer
47
+ * @param priceId - The ID of the price
48
+ * @param token - The token used to authenticate the customer
49
+ * @param currency - The currency of the subscription (optional)
50
+ * @param promoCodeId - The ID of the promo code (optional)
51
+ * @param quantity - The quantity of the subscription (optional)
52
+ * @returns The created subscription data:
53
+ * - `type`: The type of the subscription (setup or payment)
54
+ * - `clientSecret`: The client secret for the subscription to be used with Stripe Elements
55
+ * - `subscriptionId`: The ID of the subscription (optional)
56
+ * - `paymentIntentId`: The ID of the payment intent (optional)
57
+ */
58
+ Checkout.prototype.createSubscription = function (_a) {
59
+ var customerId = _a.customerId, priceId = _a.priceId, token = _a.token, currency = _a.currency, promoCodeId = _a.promoCodeId, quantity = _a.quantity;
60
+ return this.client.post('/checkout/subscription', {
61
+ customerId: customerId,
62
+ priceId: priceId,
63
+ token: token,
64
+ currency: currency,
65
+ promoCodeId: promoCodeId,
66
+ quantity: quantity,
67
+ }, this.authHeaders());
68
+ };
69
+ /**
70
+ * @description Creates a payment intent for a given customer
71
+ * @param customerId - The ID of the customer
72
+ * @param priceId - The ID of the price
73
+ * @param token - The token used to authenticate the customer
74
+ * @param currency - The currency of the payment intent (optional)
75
+ * @param promoCodeId - The ID of the promo code (optional)
76
+ * @returns The created invoice data:
77
+ * - `clientSecret`: The client secret for the invoice to be used with Stripe Elements
78
+ * - `id`: The ID of the invoice
79
+ * - `invoiceStatus`: The status of the invoice (only when the status is 'paid')
80
+ */
81
+ Checkout.prototype.createPaymentIntent = function (_a) {
82
+ var customerId = _a.customerId, priceId = _a.priceId, token = _a.token, currency = _a.currency, promoCodeId = _a.promoCodeId;
83
+ return this.client.post('/checkout/payment-intent', {
84
+ customerId: customerId,
85
+ priceId: priceId,
86
+ token: token,
87
+ currency: currency,
88
+ promoCodeId: promoCodeId,
89
+ }, this.authHeaders());
90
+ };
91
+ /**
92
+ * @description Fetch a requested price by its ID and its tax rate
93
+ * @param priceId - The ID of the price
94
+ * @param promoCodeName - The name of the promo code (optional)
95
+ * @param currency - The currency of the price (optional)
96
+ * @returns The price object containing the details of the requested price
97
+ */
98
+ Checkout.prototype.getPriceById = function (_a) {
99
+ var priceId = _a.priceId, promoCodeName = _a.promoCodeName, currency = _a.currency, postalCode = _a.postalCode, country = _a.country;
100
+ var query = new URLSearchParams();
101
+ query.set('priceId', priceId);
102
+ if (promoCodeName !== undefined)
103
+ query.set('promoCodeName', promoCodeName);
104
+ if (currency !== undefined)
105
+ query.set('currency', currency);
106
+ if (postalCode !== undefined)
107
+ query.set('postalCode', postalCode);
108
+ if (country !== undefined)
109
+ query.set('country', country);
110
+ return this.client.get("/checkout/price-by-id?".concat(query.toString()), this.headers());
111
+ };
112
+ /**
113
+ * Returns the needed headers with authorization header for the module requests
114
+ * @private
115
+ */
116
+ Checkout.prototype.authHeaders = function () {
117
+ var additionalHeaders = {};
118
+ if (this.appDetails.desktopHeader) {
119
+ additionalHeaders['x-internxt-desktop-header'] = this.appDetails.desktopHeader;
120
+ }
121
+ return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token, undefined, additionalHeaders);
122
+ };
123
+ /**
124
+ * Returns the basic needed headers for the module requests
125
+ * @private
126
+ */
127
+ Checkout.prototype.headers = function () {
128
+ var _a;
129
+ var additionalHeaders = __assign({}, ((_a = this.appDetails.customHeaders) !== null && _a !== void 0 ? _a : {}));
130
+ return (0, headers_1.basicHeaders)(this.appDetails.clientName, this.appDetails.clientVersion, additionalHeaders);
131
+ };
132
+ return Checkout;
133
+ }());
134
+ exports.Checkout = Checkout;
@@ -0,0 +1 @@
1
+ export * from './checkout';
@@ -0,0 +1,17 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./checkout"), exports);
@@ -0,0 +1,45 @@
1
+ import { UserType } from 'src/drive/payments/types/types';
2
+ export interface CreateSubscriptionPayload {
3
+ customerId: string;
4
+ priceId: string;
5
+ token: string;
6
+ currency?: string;
7
+ promoCodeId?: string;
8
+ quantity?: number;
9
+ }
10
+ export interface CreatePaymentIntentPayload {
11
+ customerId: string;
12
+ priceId: string;
13
+ token: string;
14
+ currency?: string;
15
+ promoCodeId?: string;
16
+ }
17
+ export interface GetPriceByIdPayload {
18
+ priceId: string;
19
+ promoCodeName?: string;
20
+ currency?: string;
21
+ postalCode?: string;
22
+ country?: string;
23
+ }
24
+ export type Price = {
25
+ id: string;
26
+ currency: string;
27
+ amount: number;
28
+ bytes: number;
29
+ interval: 'lifetime' | 'year';
30
+ decimalAmount: number;
31
+ type: UserType;
32
+ product: string;
33
+ minimumSeats?: number;
34
+ maximumSeats?: number;
35
+ };
36
+ export type Taxes = {
37
+ tax: number;
38
+ decimalTax: number;
39
+ amountWithTax: number;
40
+ decimalAmountWithTax: number;
41
+ };
42
+ export type PriceWithTax = {
43
+ price: Price;
44
+ taxes: Taxes;
45
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -11,7 +11,7 @@ type InternxtHeaders = {
11
11
  'x-token'?: string;
12
12
  'internxt-resources-token'?: string;
13
13
  };
14
- export declare function basicHeaders(clientName: string, clientVersion: string): InternxtHeaders;
14
+ export declare function basicHeaders(clientName: string, clientVersion: string, customHeaders?: Record<string, string>): InternxtHeaders;
15
15
  export declare function basicHeadersWithPassword(clientName: string, clientVersion: string, password: string): InternxtHeaders;
16
16
  export declare function headersWithToken(clientName: string, clientVersion: string, token: Token, workspaceToken?: Token, customHeaders?: CustomHeaders): InternxtHeaders;
17
17
  export declare function headersWithTokenAndPassword(clientName: string, clientVersion: string, token: Token, workspaceToken: Token | undefined, password: string): InternxtHeaders;
@@ -12,12 +12,8 @@ var __assign = (this && this.__assign) || function () {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.addResourcesTokenToHeaders = exports.headersWithAuthToken = exports.headersWithBasicAuth = exports.headersWithTokenAndPassword = exports.headersWithToken = exports.basicHeadersWithPassword = exports.basicHeaders = void 0;
15
- function basicHeaders(clientName, clientVersion) {
16
- return {
17
- 'content-type': 'application/json; charset=utf-8',
18
- 'internxt-version': clientVersion,
19
- 'internxt-client': clientName,
20
- };
15
+ function basicHeaders(clientName, clientVersion, customHeaders) {
16
+ return __assign({ 'content-type': 'application/json; charset=utf-8', 'internxt-version': clientVersion, 'internxt-client': clientName }, customHeaders);
21
17
  }
22
18
  exports.basicHeaders = basicHeaders;
23
19
  function basicHeadersWithPassword(clientName, clientVersion, password) {
@@ -4,6 +4,7 @@ export type ApiUrl = string;
4
4
  export interface AppDetails {
5
5
  clientName: string;
6
6
  clientVersion: string;
7
+ customHeaders?: Record<string, string>;
7
8
  desktopHeader?: string;
8
9
  }
9
10
  export interface ApiSecurity {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@internxt/sdk",
3
3
  "author": "Internxt <hello@internxt.com>",
4
- "version": "1.9.14",
4
+ "version": "1.9.16",
5
5
  "description": "An sdk for interacting with Internxt's services",
6
6
  "repository": {
7
7
  "type": "git",