intercom-client 6.1.1 → 6.3.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.
- package/Client.d.ts +5 -0
- package/Client.js +7 -2
- package/README.md +18 -30
- package/api/errors/BadRequestError.js +17 -7
- package/api/errors/ForbiddenError.js +17 -7
- package/api/errors/NotFoundError.js +17 -7
- package/api/errors/UnauthorizedError.js +17 -7
- package/api/errors/UnprocessableEntityError.js +17 -7
- package/api/resources/admins/client/Client.d.ts +2 -0
- package/api/resources/admins/client/Client.js +34 -24
- package/api/resources/aiAgent/types/AiAgent.js +1 -1
- package/api/resources/aiContentSource/types/ContentSource.d.ts +1 -14
- package/api/resources/aiContentSource/types/ContentSource.js +0 -11
- package/api/resources/articles/client/Client.d.ts +2 -0
- package/api/resources/articles/client/Client.js +41 -31
- package/api/resources/articles/client/requests/CreateArticleRequest.js +1 -1
- package/api/resources/articles/client/requests/UpdateArticleRequest.js +1 -1
- package/api/resources/articles/types/ArticleListItem.js +1 -1
- package/api/resources/articles/types/ArticleSearchHighlights.js +1 -1
- package/api/resources/companies/client/Client.d.ts +3 -1
- package/api/resources/companies/client/Client.js +60 -50
- package/api/resources/companies/types/CompaniesRetrieveResponse.d.ts +13 -0
- package/api/resources/companies/types/CompaniesRetrieveResponse.js +5 -0
- package/api/resources/companies/types/Company.d.ts +0 -2
- package/api/resources/companies/types/index.d.ts +1 -0
- package/api/resources/companies/types/index.js +1 -0
- package/api/resources/contacts/client/Client.d.ts +2 -0
- package/api/resources/contacts/client/Client.js +66 -56
- package/api/resources/conversations/client/Client.d.ts +2 -0
- package/api/resources/conversations/client/Client.js +57 -47
- package/api/resources/conversations/client/requests/CreateConversationRequest.js +1 -1
- package/api/resources/conversations/types/Conversation.js +1 -1
- package/api/resources/conversations/types/ConversationsManageRequestBody.d.ts +1 -1
- package/api/resources/customChannelEvents/client/Client.d.ts +61 -0
- package/api/resources/customChannelEvents/client/Client.js +245 -0
- package/api/resources/customChannelEvents/client/index.d.ts +1 -0
- package/api/resources/customChannelEvents/client/index.js +2 -0
- package/api/resources/customChannelEvents/index.d.ts +1 -0
- package/api/resources/customChannelEvents/index.js +17 -0
- package/api/resources/dataAttributes/client/Client.d.ts +2 -0
- package/api/resources/dataAttributes/client/Client.js +30 -20
- package/api/resources/dataAttributes/client/requests/CreateDataAttributeRequest.js +1 -1
- package/api/resources/dataAttributes/types/DataAttribute.js +1 -1
- package/api/resources/dataAttributes/types/DataAttributesListRequestModel.d.ts +1 -1
- package/api/resources/dataExport/client/Client.d.ts +2 -0
- package/api/resources/dataExport/client/Client.js +31 -21
- package/api/resources/dataExport/types/DataExport.js +1 -1
- package/api/resources/events/client/Client.d.ts +2 -0
- package/api/resources/events/client/Client.js +30 -20
- package/api/resources/helpCenters/client/Client.d.ts +2 -0
- package/api/resources/helpCenters/client/Client.js +27 -17
- package/api/resources/helpCenters/resources/collections/client/Client.d.ts +2 -0
- package/api/resources/helpCenters/resources/collections/client/Client.js +36 -26
- package/api/resources/helpCenters/resources/index.js +17 -7
- package/api/resources/index.d.ts +1 -0
- package/api/resources/index.js +19 -8
- package/api/resources/messages/client/Client.d.ts +2 -0
- package/api/resources/messages/client/Client.js +22 -12
- package/api/resources/messages/types/Message.js +1 -1
- package/api/resources/news/client/Client.d.ts +2 -12
- package/api/resources/news/resources/feeds/client/Client.d.ts +2 -0
- package/api/resources/news/resources/feeds/client/Client.js +28 -18
- package/api/resources/news/resources/index.js +17 -7
- package/api/resources/news/resources/items/client/Client.d.ts +2 -0
- package/api/resources/news/resources/items/client/Client.js +34 -24
- package/api/resources/news/types/NewsItem.js +1 -1
- package/api/resources/notes/client/Client.d.ts +2 -0
- package/api/resources/notes/client/Client.js +28 -18
- package/api/resources/phoneCallRedirects/client/Client.d.ts +2 -0
- package/api/resources/phoneCallRedirects/client/Client.js +22 -12
- package/api/resources/segments/client/Client.d.ts +2 -0
- package/api/resources/segments/client/Client.js +27 -17
- package/api/resources/segments/types/Segment.js +1 -1
- package/api/resources/subscriptionTypes/client/Client.d.ts +2 -0
- package/api/resources/subscriptionTypes/client/Client.js +22 -12
- package/api/resources/subscriptionTypes/types/SubscriptionType.js +1 -1
- package/api/resources/tags/client/Client.d.ts +2 -0
- package/api/resources/tags/client/Client.js +49 -39
- package/api/resources/tags/types/TagsCreateRequestBody.d.ts +1 -1
- package/api/resources/teams/client/Client.d.ts +2 -0
- package/api/resources/teams/client/Client.js +25 -15
- package/api/resources/ticketTypes/client/Client.d.ts +2 -0
- package/api/resources/ticketTypes/client/Client.js +31 -21
- package/api/resources/ticketTypes/client/requests/CreateTicketTypeRequest.js +1 -1
- package/api/resources/ticketTypes/client/requests/UpdateTicketTypeRequest.js +1 -1
- package/api/resources/ticketTypes/resources/attributes/client/Client.d.ts +2 -0
- package/api/resources/ticketTypes/resources/attributes/client/Client.js +25 -15
- package/api/resources/ticketTypes/resources/attributes/client/requests/CreateTicketTypeAttributeRequest.js +1 -1
- package/api/resources/ticketTypes/resources/index.js +17 -7
- package/api/resources/tickets/client/Client.d.ts +2 -0
- package/api/resources/tickets/client/Client.js +34 -24
- package/api/resources/tickets/client/requests/UpdateTicketRequest.js +1 -1
- package/api/resources/tickets/types/Ticket.js +1 -1
- package/api/resources/tickets/types/TicketPart.js +1 -1
- package/api/resources/tickets/types/TicketType.js +1 -1
- package/api/resources/tickets/types/TicketsReplyRequestBody.d.ts +1 -1
- package/api/resources/visitors/client/Client.d.ts +2 -0
- package/api/resources/visitors/client/Client.js +28 -18
- package/api/types/ActionComponent.d.ts +1 -1
- package/api/types/ActivityLog.js +1 -1
- package/api/types/AdminReplyConversationRequest.js +1 -1
- package/api/types/AdminReplyTicketRequest.js +1 -1
- package/api/types/ArticleContent.js +1 -1
- package/api/types/AssignConversationRequest.js +1 -1
- package/api/types/ButtonComponent.js +1 -1
- package/api/types/CheckboxComponent.js +1 -1
- package/api/types/CompanyList.d.ts +0 -2
- package/api/types/Component.d.ts +1 -1
- package/api/types/ConfigureRequest.d.ts +1 -1
- package/api/types/ConfigureResponse.d.ts +1 -1
- package/api/types/ContactReplyConversationRequest.d.ts +1 -1
- package/api/types/ContactReplyTicketRequest.d.ts +1 -1
- package/api/types/Context.js +1 -1
- package/api/types/ConversationSource.js +1 -1
- package/api/types/CreateContactRequest.d.ts +1 -1
- package/api/types/CreateDataEventRequest.d.ts +1 -1
- package/api/types/CreateMessageRequest.d.ts +1 -1
- package/api/types/CreateMessageRequest.js +1 -1
- package/api/types/CreateTicketReplyWithCommentRequest.d.ts +1 -1
- package/api/types/CustomAttributes.d.ts +1 -1
- package/api/types/CustomerRequest.d.ts +1 -1
- package/api/types/DropdownComponent.js +1 -1
- package/api/types/ImageComponent.js +1 -1
- package/api/types/InputComponent.js +1 -1
- package/api/types/LinkedObject.js +1 -1
- package/api/types/MultipleFilterSearchRequest.js +1 -1
- package/api/types/MultipleOrSingleFilterSearchRequest.d.ts +1 -1
- package/api/types/NewsItemRequest.js +1 -1
- package/api/types/RedactConversationRequest.d.ts +1 -1
- package/api/types/ReplyConversationRequest.d.ts +1 -1
- package/api/types/SingleFilterSearchRequest.js +1 -1
- package/api/types/SingleSelectComponent.js +1 -1
- package/api/types/SlaApplied.js +1 -1
- package/api/types/SpacerComponent.js +1 -1
- package/api/types/TextComponent.js +1 -1
- package/api/types/TicketCustomAttributes.d.ts +1 -5
- package/api/types/TicketPartAuthor.js +1 -1
- package/api/types/TicketReply.js +1 -1
- package/api/types/TicketRequestCustomAttributes.d.ts +1 -4
- package/api/types/TicketTypeAttribute.js +1 -1
- package/api/types/UpdateVisitorRequest.d.ts +1 -1
- package/api/version.d.ts +1 -1
- package/core/auth/BearerToken.d.ts +1 -1
- package/core/fetcher/APIResponse.d.ts +1 -1
- package/core/fetcher/Fetcher.d.ts +2 -2
- package/core/fetcher/Fetcher.js +6 -5
- package/core/fetcher/Supplier.d.ts +1 -1
- package/core/fetcher/createRequestUrl.d.ts +1 -1
- package/core/fetcher/createRequestUrl.js +1 -2
- package/core/fetcher/getFetchFn.js +18 -9
- package/core/fetcher/getHeader.js +1 -2
- package/core/fetcher/getRequestBody.js +5 -5
- package/core/fetcher/getResponseBody.js +1 -2
- package/core/fetcher/makeRequest.d.ts +1 -1
- package/core/fetcher/requestWithRetries.js +4 -5
- package/core/fetcher/signals.d.ts +0 -1
- package/core/fetcher/signals.js +2 -3
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +0 -1
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +6 -4
- package/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +1 -1
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +1 -1
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +18 -9
- package/core/json.d.ts +15 -0
- package/core/json.js +24 -0
- package/core/pagination/Page.js +9 -6
- package/core/runtime/runtime.d.ts +1 -1
- package/core/runtime/runtime.js +51 -41
- package/core/utils/setObjectProperty.js +1 -2
- package/dist/Client.d.ts +5 -0
- package/dist/Client.js +7 -2
- package/dist/api/errors/BadRequestError.js +17 -7
- package/dist/api/errors/ForbiddenError.js +17 -7
- package/dist/api/errors/NotFoundError.js +17 -7
- package/dist/api/errors/UnauthorizedError.js +17 -7
- package/dist/api/errors/UnprocessableEntityError.js +17 -7
- package/dist/api/resources/admins/client/Client.d.ts +2 -0
- package/dist/api/resources/admins/client/Client.js +34 -24
- package/dist/api/resources/aiAgent/types/AiAgent.js +1 -1
- package/dist/api/resources/aiContentSource/types/ContentSource.d.ts +1 -14
- package/dist/api/resources/aiContentSource/types/ContentSource.js +0 -11
- package/dist/api/resources/articles/client/Client.d.ts +2 -0
- package/dist/api/resources/articles/client/Client.js +41 -31
- package/dist/api/resources/articles/client/requests/CreateArticleRequest.js +1 -1
- package/dist/api/resources/articles/client/requests/UpdateArticleRequest.js +1 -1
- package/dist/api/resources/articles/types/ArticleListItem.js +1 -1
- package/dist/api/resources/articles/types/ArticleSearchHighlights.js +1 -1
- package/dist/api/resources/companies/client/Client.d.ts +3 -1
- package/dist/api/resources/companies/client/Client.js +60 -50
- package/dist/api/resources/companies/types/CompaniesRetrieveResponse.d.ts +13 -0
- package/dist/api/resources/companies/types/CompaniesRetrieveResponse.js +5 -0
- package/dist/api/resources/companies/types/Company.d.ts +0 -2
- package/dist/api/resources/companies/types/index.d.ts +1 -0
- package/dist/api/resources/companies/types/index.js +1 -0
- package/dist/api/resources/contacts/client/Client.d.ts +2 -0
- package/dist/api/resources/contacts/client/Client.js +66 -56
- package/dist/api/resources/conversations/client/Client.d.ts +2 -0
- package/dist/api/resources/conversations/client/Client.js +57 -47
- package/dist/api/resources/conversations/client/requests/CreateConversationRequest.js +1 -1
- package/dist/api/resources/conversations/types/Conversation.js +1 -1
- package/dist/api/resources/conversations/types/ConversationsManageRequestBody.d.ts +1 -1
- package/dist/api/resources/customChannelEvents/client/Client.d.ts +61 -0
- package/dist/api/resources/customChannelEvents/client/Client.js +245 -0
- package/dist/api/resources/customChannelEvents/client/index.d.ts +1 -0
- package/dist/api/resources/customChannelEvents/client/index.js +2 -0
- package/dist/api/resources/customChannelEvents/index.d.ts +1 -0
- package/dist/api/resources/customChannelEvents/index.js +17 -0
- package/dist/api/resources/dataAttributes/client/Client.d.ts +2 -0
- package/dist/api/resources/dataAttributes/client/Client.js +30 -20
- package/dist/api/resources/dataAttributes/client/requests/CreateDataAttributeRequest.js +1 -1
- package/dist/api/resources/dataAttributes/types/DataAttribute.js +1 -1
- package/dist/api/resources/dataAttributes/types/DataAttributesListRequestModel.d.ts +1 -1
- package/dist/api/resources/dataExport/client/Client.d.ts +2 -0
- package/dist/api/resources/dataExport/client/Client.js +31 -21
- package/dist/api/resources/dataExport/types/DataExport.js +1 -1
- package/dist/api/resources/events/client/Client.d.ts +2 -0
- package/dist/api/resources/events/client/Client.js +30 -20
- package/dist/api/resources/helpCenters/client/Client.d.ts +2 -0
- package/dist/api/resources/helpCenters/client/Client.js +27 -17
- package/dist/api/resources/helpCenters/resources/collections/client/Client.d.ts +2 -0
- package/dist/api/resources/helpCenters/resources/collections/client/Client.js +36 -26
- package/dist/api/resources/helpCenters/resources/index.js +17 -7
- package/dist/api/resources/index.d.ts +1 -0
- package/dist/api/resources/index.js +19 -8
- package/dist/api/resources/messages/client/Client.d.ts +2 -0
- package/dist/api/resources/messages/client/Client.js +22 -12
- package/dist/api/resources/messages/types/Message.js +1 -1
- package/dist/api/resources/news/client/Client.d.ts +2 -12
- package/dist/api/resources/news/resources/feeds/client/Client.d.ts +2 -0
- package/dist/api/resources/news/resources/feeds/client/Client.js +28 -18
- package/dist/api/resources/news/resources/index.js +17 -7
- package/dist/api/resources/news/resources/items/client/Client.d.ts +2 -0
- package/dist/api/resources/news/resources/items/client/Client.js +34 -24
- package/dist/api/resources/news/types/NewsItem.js +1 -1
- package/dist/api/resources/notes/client/Client.d.ts +2 -0
- package/dist/api/resources/notes/client/Client.js +28 -18
- package/dist/api/resources/phoneCallRedirects/client/Client.d.ts +2 -0
- package/dist/api/resources/phoneCallRedirects/client/Client.js +22 -12
- package/dist/api/resources/segments/client/Client.d.ts +2 -0
- package/dist/api/resources/segments/client/Client.js +27 -17
- package/dist/api/resources/segments/types/Segment.js +1 -1
- package/dist/api/resources/subscriptionTypes/client/Client.d.ts +2 -0
- package/dist/api/resources/subscriptionTypes/client/Client.js +22 -12
- package/dist/api/resources/subscriptionTypes/types/SubscriptionType.js +1 -1
- package/dist/api/resources/tags/client/Client.d.ts +2 -0
- package/dist/api/resources/tags/client/Client.js +49 -39
- package/dist/api/resources/tags/types/TagsCreateRequestBody.d.ts +1 -1
- package/dist/api/resources/teams/client/Client.d.ts +2 -0
- package/dist/api/resources/teams/client/Client.js +25 -15
- package/dist/api/resources/ticketTypes/client/Client.d.ts +2 -0
- package/dist/api/resources/ticketTypes/client/Client.js +31 -21
- package/dist/api/resources/ticketTypes/client/requests/CreateTicketTypeRequest.js +1 -1
- package/dist/api/resources/ticketTypes/client/requests/UpdateTicketTypeRequest.js +1 -1
- package/dist/api/resources/ticketTypes/resources/attributes/client/Client.d.ts +2 -0
- package/dist/api/resources/ticketTypes/resources/attributes/client/Client.js +25 -15
- package/dist/api/resources/ticketTypes/resources/attributes/client/requests/CreateTicketTypeAttributeRequest.js +1 -1
- package/dist/api/resources/ticketTypes/resources/index.js +17 -7
- package/dist/api/resources/tickets/client/Client.d.ts +2 -0
- package/dist/api/resources/tickets/client/Client.js +34 -24
- package/dist/api/resources/tickets/client/requests/UpdateTicketRequest.js +1 -1
- package/dist/api/resources/tickets/types/Ticket.js +1 -1
- package/dist/api/resources/tickets/types/TicketPart.js +1 -1
- package/dist/api/resources/tickets/types/TicketType.js +1 -1
- package/dist/api/resources/tickets/types/TicketsReplyRequestBody.d.ts +1 -1
- package/dist/api/resources/visitors/client/Client.d.ts +2 -0
- package/dist/api/resources/visitors/client/Client.js +28 -18
- package/dist/api/types/ActionComponent.d.ts +1 -1
- package/dist/api/types/ActivityLog.js +1 -1
- package/dist/api/types/AdminReplyConversationRequest.js +1 -1
- package/dist/api/types/AdminReplyTicketRequest.js +1 -1
- package/dist/api/types/ArticleContent.js +1 -1
- package/dist/api/types/AssignConversationRequest.js +1 -1
- package/dist/api/types/ButtonComponent.js +1 -1
- package/dist/api/types/CheckboxComponent.js +1 -1
- package/dist/api/types/CompanyList.d.ts +0 -2
- package/dist/api/types/Component.d.ts +1 -1
- package/dist/api/types/ConfigureRequest.d.ts +1 -1
- package/dist/api/types/ConfigureResponse.d.ts +1 -1
- package/dist/api/types/ContactReplyConversationRequest.d.ts +1 -1
- package/dist/api/types/ContactReplyTicketRequest.d.ts +1 -1
- package/dist/api/types/Context.js +1 -1
- package/dist/api/types/ConversationSource.js +1 -1
- package/dist/api/types/CreateContactRequest.d.ts +1 -1
- package/dist/api/types/CreateDataEventRequest.d.ts +1 -1
- package/dist/api/types/CreateMessageRequest.d.ts +1 -1
- package/dist/api/types/CreateMessageRequest.js +1 -1
- package/dist/api/types/CreateTicketReplyWithCommentRequest.d.ts +1 -1
- package/dist/api/types/CustomAttributes.d.ts +1 -1
- package/dist/api/types/CustomerRequest.d.ts +1 -1
- package/dist/api/types/DropdownComponent.js +1 -1
- package/dist/api/types/ImageComponent.js +1 -1
- package/dist/api/types/InputComponent.js +1 -1
- package/dist/api/types/LinkedObject.js +1 -1
- package/dist/api/types/MultipleFilterSearchRequest.js +1 -1
- package/dist/api/types/MultipleOrSingleFilterSearchRequest.d.ts +1 -1
- package/dist/api/types/NewsItemRequest.js +1 -1
- package/dist/api/types/RedactConversationRequest.d.ts +1 -1
- package/dist/api/types/ReplyConversationRequest.d.ts +1 -1
- package/dist/api/types/SingleFilterSearchRequest.js +1 -1
- package/dist/api/types/SingleSelectComponent.js +1 -1
- package/dist/api/types/SlaApplied.js +1 -1
- package/dist/api/types/SpacerComponent.js +1 -1
- package/dist/api/types/TextComponent.js +1 -1
- package/dist/api/types/TicketCustomAttributes.d.ts +1 -5
- package/dist/api/types/TicketPartAuthor.js +1 -1
- package/dist/api/types/TicketReply.js +1 -1
- package/dist/api/types/TicketRequestCustomAttributes.d.ts +1 -4
- package/dist/api/types/TicketTypeAttribute.js +1 -1
- package/dist/api/types/UpdateVisitorRequest.d.ts +1 -1
- package/dist/api/version.d.ts +1 -1
- package/dist/core/auth/BearerToken.d.ts +1 -1
- package/dist/core/fetcher/APIResponse.d.ts +1 -1
- package/dist/core/fetcher/Fetcher.d.ts +2 -2
- package/dist/core/fetcher/Fetcher.js +6 -5
- package/dist/core/fetcher/Supplier.d.ts +1 -1
- package/dist/core/fetcher/createRequestUrl.d.ts +1 -1
- package/dist/core/fetcher/createRequestUrl.js +1 -2
- package/dist/core/fetcher/getFetchFn.js +18 -9
- package/dist/core/fetcher/getHeader.js +1 -2
- package/dist/core/fetcher/getRequestBody.js +5 -5
- package/dist/core/fetcher/getResponseBody.js +1 -2
- package/dist/core/fetcher/makeRequest.d.ts +1 -1
- package/dist/core/fetcher/requestWithRetries.js +4 -5
- package/dist/core/fetcher/signals.d.ts +0 -1
- package/dist/core/fetcher/signals.js +2 -3
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +0 -1
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +6 -4
- package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +1 -1
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +1 -1
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +18 -9
- package/dist/core/json.d.ts +15 -0
- package/dist/core/json.js +24 -0
- package/dist/core/pagination/Page.js +9 -6
- package/dist/core/runtime/runtime.d.ts +1 -1
- package/dist/core/runtime/runtime.js +51 -41
- package/dist/core/utils/setObjectProperty.js +1 -2
- package/dist/environments.d.ts +1 -1
- package/dist/errors/IntercomError.js +2 -1
- package/dist/index.js +17 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/environments.d.ts +1 -1
- package/errors/IntercomError.js +2 -1
- package/index.js +17 -7
- package/{jest.config.js → jest.config.mjs} +4 -1
- package/package.json +16 -16
- package/reference.md +195 -33
- package/scripts/rename-to-esm-files.js +115 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs").promises;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const extensionMap = {
|
|
7
|
+
".js": ".mjs",
|
|
8
|
+
".d.ts": ".d.mts",
|
|
9
|
+
};
|
|
10
|
+
const oldExtensions = Object.keys(extensionMap);
|
|
11
|
+
|
|
12
|
+
async function findFiles(rootPath) {
|
|
13
|
+
const files = [];
|
|
14
|
+
|
|
15
|
+
async function scan(directory) {
|
|
16
|
+
const entries = await fs.readdir(directory, { withFileTypes: true });
|
|
17
|
+
|
|
18
|
+
for (const entry of entries) {
|
|
19
|
+
const fullPath = path.join(directory, entry.name);
|
|
20
|
+
|
|
21
|
+
if (entry.isDirectory()) {
|
|
22
|
+
if (entry.name !== "node_modules" && !entry.name.startsWith(".")) {
|
|
23
|
+
await scan(fullPath);
|
|
24
|
+
}
|
|
25
|
+
} else if (entry.isFile()) {
|
|
26
|
+
if (oldExtensions.some((ext) => entry.name.endsWith(ext))) {
|
|
27
|
+
files.push(fullPath);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
await scan(rootPath);
|
|
34
|
+
return files;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function updateFiles(files) {
|
|
38
|
+
const updatedFiles = [];
|
|
39
|
+
for (const file of files) {
|
|
40
|
+
const updated = await updateFileContents(file);
|
|
41
|
+
updatedFiles.push(updated);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
console.log(`Updated imports in ${updatedFiles.length} files.`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function updateFileContents(file) {
|
|
48
|
+
const content = await fs.readFile(file, "utf8");
|
|
49
|
+
|
|
50
|
+
let newContent = content;
|
|
51
|
+
// Update each extension type defined in the map
|
|
52
|
+
for (const [oldExt, newExt] of Object.entries(extensionMap)) {
|
|
53
|
+
const regex = new RegExp(`(import|export)(.+from\\s+['"])(\\.\\.?\\/[^'"]+)(\\${oldExt})(['"])`, "g");
|
|
54
|
+
newContent = newContent.replace(regex, `$1$2$3${newExt}$5`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (content !== newContent) {
|
|
58
|
+
await fs.writeFile(file, newContent, "utf8");
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function renameFiles(files) {
|
|
65
|
+
let counter = 0;
|
|
66
|
+
for (const file of files) {
|
|
67
|
+
const ext = oldExtensions.find((ext) => file.endsWith(ext));
|
|
68
|
+
const newExt = extensionMap[ext];
|
|
69
|
+
|
|
70
|
+
if (newExt) {
|
|
71
|
+
const newPath = file.slice(0, -ext.length) + newExt;
|
|
72
|
+
await fs.rename(file, newPath);
|
|
73
|
+
counter++;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
console.log(`Renamed ${counter} files.`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function main() {
|
|
81
|
+
try {
|
|
82
|
+
const targetDir = process.argv[2];
|
|
83
|
+
if (!targetDir) {
|
|
84
|
+
console.error("Please provide a target directory");
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const targetPath = path.resolve(targetDir);
|
|
89
|
+
const targetStats = await fs.stat(targetPath);
|
|
90
|
+
|
|
91
|
+
if (!targetStats.isDirectory()) {
|
|
92
|
+
console.error("The provided path is not a directory");
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
console.log(`Scanning directory: ${targetDir}`);
|
|
97
|
+
|
|
98
|
+
const files = await findFiles(targetDir);
|
|
99
|
+
|
|
100
|
+
if (files.length === 0) {
|
|
101
|
+
console.log("No matching files found.");
|
|
102
|
+
process.exit(0);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
console.log(`Found ${files.length} files.`);
|
|
106
|
+
await updateFiles(files);
|
|
107
|
+
await renameFiles(files);
|
|
108
|
+
console.log("\nDone!");
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.error("An error occurred:", error.message);
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
main();
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "
|
|
1
|
+
export declare const SDK_VERSION = "6.3.0";
|
package/version.js
CHANGED