sr-npm 1.7.270 → 1.7.272

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/backend/consts.js CHANGED
@@ -67,7 +67,7 @@ const TASKS = {
67
67
  [TASKS_NAMES.CREATE_API_KEY_COLLECTION_AND_FILL_IT]: {
68
68
  name: TASKS_NAMES.CREATE_API_KEY_COLLECTION_AND_FILL_IT,
69
69
  getIdentifier:()=> "SHOULD_NEVER_SKIP",
70
- process:()=>createApiKeyCollectionAndFillIt(),
70
+ process:createApiKeyCollectionAndFillIt,
71
71
  shouldSkipCheck:()=>false,
72
72
  estimatedDurationSec:3
73
73
  },
package/backend/data.js CHANGED
@@ -291,15 +291,25 @@ function fetchJobLocation(jobDetails) {
291
291
  async function createApiKeyCollectionAndFillIt() {
292
292
  console.log("Creating ApiKey collection and filling it with the smart token");
293
293
  await createCollectionIfMissing(COLLECTIONS.API_KEY, COLLECTIONS_FIELDS.API_KEY,null,'singleItem');
294
- console.log("Getting the smart token");
294
+ console.log("Getting the smart token ");
295
295
  const token = await getSmartToken();
296
296
  console.log("token is : ", token);
297
297
  console.log("Inserting the smart token into the ApiKey collection");
298
- await wixData.insert(COLLECTIONS.API_KEY, {
299
- token: token.value
300
- });
298
+ try {
299
+ await wixData.insert(COLLECTIONS.API_KEY, {
300
+ token: token.value
301
+ });
302
+ console.log("Smart token inserted into the ApiKey collection");
303
+ } catch (error) {
304
+ if (error.message.includes("WDE0074: An item with _id [SINGLE_ITEM_ID] already exists")) {
305
+ console.log("Smart token already exists in the ApiKey collection");
306
+ }
307
+ else {
308
+ throw error;
309
+ }
310
+ }
301
311
 
302
- console.log("Smart token inserted into the ApiKey collection");
312
+
303
313
  }
304
314
 
305
315
  async function createCollections() {
@@ -330,6 +340,7 @@ async function referenceJobs() {
330
340
 
331
341
  async function syncJobsFast() {
332
342
  console.log("Syncing jobs fast");
343
+ await createApiKeyCollectionAndFillIt();
333
344
  await createCollections();
334
345
  await clearCollections();
335
346
  console.log("saving jobs data to CMS");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.270",
3
+ "version": "1.7.272",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {