appwrite-utils-cli 0.0.44 → 0.0.46

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.
@@ -78,7 +78,7 @@ export class ImportController {
78
78
  dataLoader.getCollectionKey(collection.name);
79
79
  const importOperationId = dataLoader.collectionImportOperations.get(dataLoader.getCollectionKey(collection.name));
80
80
  const createBatches = (finalData) => {
81
- let maxBatchLength = 25;
81
+ let maxBatchLength = 100;
82
82
  const finalBatches = [];
83
83
  for (let i = 0; i < finalData.length; i++) {
84
84
  if (i % maxBatchLength === 0) {
@@ -43,4 +43,4 @@ export declare let numTimesFailedTotal: number;
43
43
  * @param {number} [attemptNum=0] - The number of attempts made so far (default: 0).
44
44
  * @return {Promise<any>} - A promise that resolves to the result of the createFunction or rejects with an error if it fails after 5 attempts.
45
45
  */
46
- export declare const tryAwaitWithRetry: <T>(createFunction: () => Promise<T>, attemptNum?: number) => Promise<T>;
46
+ export declare const tryAwaitWithRetry: <T>(createFunction: () => Promise<T>, attemptNum?: number, throwError?: boolean) => Promise<T>;
@@ -87,7 +87,7 @@ export let numTimesFailedTotal = 0;
87
87
  * @param {number} [attemptNum=0] - The number of attempts made so far (default: 0).
88
88
  * @return {Promise<any>} - A promise that resolves to the result of the createFunction or rejects with an error if it fails after 5 attempts.
89
89
  */
90
- export const tryAwaitWithRetry = async (createFunction, attemptNum = 0) => {
90
+ export const tryAwaitWithRetry = async (createFunction, attemptNum = 0, throwError = false) => {
91
91
  try {
92
92
  return await createFunction();
93
93
  }
@@ -102,6 +102,10 @@ export const tryAwaitWithRetry = async (createFunction, attemptNum = 0) => {
102
102
  }
103
103
  return tryAwaitWithRetry(createFunction, attemptNum + 1);
104
104
  }
105
- throw error;
105
+ if (throwError) {
106
+ throw error;
107
+ }
108
+ // @ts-ignore
109
+ return Promise.resolve();
106
110
  }
107
111
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "appwrite-utils-cli",
3
3
  "description": "Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.",
4
- "version": "0.0.44",
4
+ "version": "0.0.46",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -125,7 +125,7 @@ export class ImportController {
125
125
  dataLoader.getCollectionKey(collection.name)
126
126
  );
127
127
  const createBatches = (finalData: CollectionImportData["data"]) => {
128
- let maxBatchLength = 25;
128
+ let maxBatchLength = 100;
129
129
  const finalBatches: CollectionImportData["data"][] = [];
130
130
  for (let i = 0; i < finalData.length; i++) {
131
131
  if (i % maxBatchLength === 0) {
@@ -137,7 +137,8 @@ export let numTimesFailedTotal = 0;
137
137
  */
138
138
  export const tryAwaitWithRetry = async <T>(
139
139
  createFunction: () => Promise<T>,
140
- attemptNum: number = 0
140
+ attemptNum: number = 0,
141
+ throwError: boolean = false
141
142
  ): Promise<T> => {
142
143
  try {
143
144
  return await createFunction();
@@ -154,6 +155,10 @@ export const tryAwaitWithRetry = async <T>(
154
155
  }
155
156
  return tryAwaitWithRetry(createFunction, attemptNum + 1);
156
157
  }
157
- throw error;
158
+ if (throwError) {
159
+ throw error;
160
+ }
161
+ // @ts-ignore
162
+ return Promise.resolve();
158
163
  }
159
164
  };