Skip to content

Commit

Permalink
fix(crowdin): move from import to require (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
thompsonsj authored Jan 10, 2025
1 parent bc9eb3e commit 33f5cf9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
6 changes: 0 additions & 6 deletions plugin/src/lib/api/connection.ts

This file was deleted.

7 changes: 5 additions & 2 deletions plugin/src/lib/api/payload-crowdin-sync/translations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import crowdin, {
import {
Credentials,
CrowdinError,
Translations,
Expand Down Expand Up @@ -35,6 +35,9 @@ import { getRelationshipId } from "../../utilities/payload";
import { merge } from "es-toolkit";
import { isEmpty } from 'es-toolkit/compat';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const crowdin = require('@crowdin/crowdin-api-client');

interface IgetLatestDocumentTranslation {
collection: string;
doc: any;
Expand Down Expand Up @@ -87,7 +90,7 @@ export class payloadCrowdinSyncTranslationsApi {
token: pluginOptions.token,
organization: pluginOptions.organization,
};
const { translationsApi } = new crowdin(credentials);
const { translationsApi } = new crowdin.default(credentials);
this.projectId = pluginOptions.projectId;
this.directoryId = pluginOptions.directoryId;
this.translationsApi = translationsApi;
Expand Down
8 changes: 5 additions & 3 deletions plugin/src/lib/hooks/collections/afterChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import {

import { CrowdinArticleDirectory, CrowdinFile } from "./../../payload-types";
import { toWords } from 'payload';
import crowdin, { Credentials, SourceFiles, UploadStorage, } from "@crowdin/crowdin-api-client";
// eslint-disable-next-line @typescript-eslint/no-var-requires
const crowdin = require('@crowdin/crowdin-api-client');
import { Credentials, SourceFiles, UploadStorage } from "@crowdin/crowdin-api-client";

import { getCollectionConfig, getArticleDirectory,
getFileByDocumentID,
Expand Down Expand Up @@ -69,7 +71,7 @@ export class payloadCrowdinSyncFilesApi {
const credentials: Credentials = {
token: pluginOptions.token,
};
const { sourceFilesApi, uploadStorageApi } = new crowdin(credentials);
const { sourceFilesApi, uploadStorageApi } = new crowdin.default(credentials);
this.projectId = pluginOptions.projectId;
this.directoryId = pluginOptions.directoryId;
this.sourceFilesApi = sourceFilesApi;
Expand Down Expand Up @@ -217,7 +219,7 @@ export class filesApiByDocument {
token: pluginOptions.token,
organization: pluginOptions.organization,
};
const { sourceFilesApi } = new crowdin(credentials);
const { sourceFilesApi } = new crowdin.default(credentials);
this.projectId = pluginOptions.projectId;
this.directoryId = pluginOptions.directoryId;
this.sourceFilesApi = sourceFilesApi;
Expand Down
10 changes: 6 additions & 4 deletions plugin/src/lib/hooks/collections/afterDelete.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type {
BlocksField as BlockField,
CollectionConfig,
Config,
Document,
GlobalConfig,
PayloadRequest,
Expand All @@ -25,7 +24,7 @@ import {

import { CrowdinArticleDirectory, CrowdinFile } from "./../../payload-types";
import { toWords } from 'payload';
import crowdin, { Credentials, SourceFiles, UploadStorage, } from "@crowdin/crowdin-api-client";
import { Credentials, SourceFiles, UploadStorage, } from "@crowdin/crowdin-api-client";

import { getCollectionConfig, getArticleDirectory,
getFileByDocumentID,
Expand All @@ -36,6 +35,9 @@ import { isEmpty } from 'es-toolkit/compat';
import { convertLexicalToHtml, convertSlateToHtml } from '../../utilities/richTextConversion'
import { extractLexicalBlockContent, getLexicalBlockFields, getLexicalEditorConfig } from '../../utilities/lexical';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const crowdin = require('@crowdin/crowdin-api-client');

interface IcreateOrUpdateFile {
name: string;
fileData: string | object;
Expand Down Expand Up @@ -63,7 +65,7 @@ export class payloadCrowdinSyncFilesApi {
const credentials: Credentials = {
token: pluginOptions.token,
};
const { sourceFilesApi, uploadStorageApi } = new crowdin(credentials);
const { sourceFilesApi, uploadStorageApi } = new crowdin.default(credentials);
this.projectId = pluginOptions.projectId;
this.directoryId = pluginOptions.directoryId;
this.sourceFilesApi = sourceFilesApi;
Expand Down Expand Up @@ -211,7 +213,7 @@ export class filesApiByDocument {
token: pluginOptions.token,
organization: pluginOptions.organization,
};
const { sourceFilesApi } = new crowdin(credentials);
const { sourceFilesApi } = new crowdin.default(credentials);
this.projectId = pluginOptions.projectId;
this.directoryId = pluginOptions.directoryId;
this.sourceFilesApi = sourceFilesApi;
Expand Down

0 comments on commit 33f5cf9

Please sign in to comment.