@owox/connectors 0.12.0-next-20251113083123 → 0.12.0-next-20251113104154

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.
Files changed (3) hide show
  1. package/dist/index.cjs +10 -132
  2. package/dist/index.js +10 -132
  3. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -3779,21 +3779,9 @@ const XAds = (function() {
3779
3779
  }
3780
3780
  }));
3781
3781
  this.fieldsSchema = XAdsFieldsSchema;
3782
- this._tweetsCache = /* @__PURE__ */ new Map();
3783
3782
  this._promotedTweetsCache = /* @__PURE__ */ new Map();
3784
3783
  this.BASE_URL = "https://ads-api.x.com/";
3785
3784
  }
3786
- /**
3787
- * Returns credential fields for this source
3788
- */
3789
- getCredentialFields() {
3790
- return {
3791
- ConsumerKey: this.config.ConsumerKey,
3792
- ConsumerSecret: this.config.ConsumerSecret,
3793
- AccessToken: this.config.AccessToken,
3794
- AccessTokenSecret: this.config.AccessTokenSecret
3795
- };
3796
- }
3797
3785
  /**
3798
3786
  * Single entry point for *all* fetches.
3799
3787
  * @param {Object} opts
@@ -3836,34 +3824,6 @@ const XAds = (function() {
3836
3824
  throw new ConfigurationError(`Unknown node: ${nodeName}`);
3837
3825
  }
3838
3826
  }
3839
- /**
3840
- * Get cached data if all requested fields are present
3841
- * @param {Map} cache - Cache map to check
3842
- * @param {string} accountId - Account ID to look up
3843
- * @param {Array<string>} fields - Required fields
3844
- * @returns {Array|null} - Cached data or null if not found/invalid
3845
- * @private
3846
- */
3847
- _getCachedData(cache, accountId, fields) {
3848
- if (!cache.has(accountId)) return null;
3849
- const cached = cache.get(accountId);
3850
- const hasAllFields = fields.every((field) => cached.fields.has(field));
3851
- return hasAllFields ? cached.data : null;
3852
- }
3853
- /**
3854
- * Store data in cache with its fields
3855
- * @param {Map} cache - Cache map to store in
3856
- * @param {string} accountId - Account ID as key
3857
- * @param {Array} data - Data to cache
3858
- * @param {Array<string>} fields - Fields present in the data
3859
- * @private
3860
- */
3861
- _setCacheData(cache, accountId, data, fields) {
3862
- cache.set(accountId, {
3863
- data,
3864
- fields: new Set(fields)
3865
- });
3866
- }
3867
3827
  /**
3868
3828
  * Shared logic for non-time-series endpoints
3869
3829
  */
@@ -3873,23 +3833,9 @@ const XAds = (function() {
3873
3833
  if (missingKeys.length > 0) {
3874
3834
  throw new Error(`Missing required unique fields for endpoint '${nodeName}'. Missing fields: ${missingKeys.join(", ")}`);
3875
3835
  }
3876
- if (nodeName === "promoted_tweets") {
3877
- const cached = this._getCachedData(this._promotedTweetsCache, accountId, fields);
3878
- if (cached) {
3879
- console.log("returning cached promoted_tweets");
3880
- return cached;
3881
- }
3882
- console.log("deleting cached promoted_tweets");
3883
- this._promotedTweetsCache.delete(accountId);
3884
- }
3885
- if (nodeName === "tweets") {
3886
- const cached = this._getCachedData(this._tweetsCache, accountId, fields);
3887
- if (cached) {
3888
- console.log("returning cached tweets");
3889
- return cached;
3890
- }
3891
- console.log("deleting cached tweets");
3892
- this._tweetsCache.delete(accountId);
3836
+ if (nodeName === "promoted_tweets" && this._promotedTweetsCache.has(accountId)) {
3837
+ console.log(`[XAdsSource] Using cached promoted_tweets for account ${accountId}`);
3838
+ return this._promotedTweetsCache.get(accountId);
3893
3839
  }
3894
3840
  let all = await this._fetchPages({
3895
3841
  accountId,
@@ -3905,10 +3851,8 @@ const XAds = (function() {
3905
3851
  }));
3906
3852
  }
3907
3853
  if (nodeName === "promoted_tweets") {
3908
- this._setCacheData(this._promotedTweetsCache, accountId, all, fields);
3909
- }
3910
- if (nodeName === "tweets") {
3911
- this._setCacheData(this._tweetsCache, accountId, all, fields);
3854
+ console.log(`[XAdsSource] Fetched promoted_tweets from API for account ${accountId}`);
3855
+ this._promotedTweetsCache.set(accountId, all);
3912
3856
  }
3913
3857
  return all;
3914
3858
  }
@@ -4132,10 +4076,10 @@ const XAds = (function() {
4132
4076
  return "OAuth " + Object.keys(oauth).map((k) => `${encodeURIComponent(k)}="${encodeURIComponent(oauth[k])}"`).join(", ");
4133
4077
  }
4134
4078
  /**
4135
- * Clear tweet/promoted-tweet caches.
4136
- * */
4137
- clearTweetsCache(accountId) {
4138
- this._tweetsCache.delete(accountId);
4079
+ * Clear cache for a specific account
4080
+ * Called after processing all nodes for an account to free up memory
4081
+ */
4082
+ clearCache(accountId) {
4139
4083
  this._promotedTweetsCache.delete(accountId);
4140
4084
  }
4141
4085
  };
@@ -4159,7 +4103,7 @@ const XAds = (function() {
4159
4103
  fields: fields[nodeName] || []
4160
4104
  });
4161
4105
  }
4162
- this.source.clearTweetsCache(accountId);
4106
+ this.source.clearCache(accountId);
4163
4107
  }
4164
4108
  }
4165
4109
  /**
@@ -5668,16 +5612,6 @@ const TikTokAds = (function() {
5668
5612
  }
5669
5613
  return processedRecord;
5670
5614
  }
5671
- /**
5672
- * Returns credential fields for this source
5673
- */
5674
- getCredentialFields() {
5675
- return {
5676
- AccessToken: this.config.AccessToken,
5677
- AppId: this.config.AppId,
5678
- AppSecret: this.config.AppSecret
5679
- };
5680
- }
5681
5615
  };
5682
5616
  var TikTokAdsConnector = class TikTokAdsConnector extends AbstractConnector3 {
5683
5617
  constructor(config, source, storageName = "GoogleBigQueryStorage", runConfig = null) {
@@ -9369,18 +9303,6 @@ const RedditAds = (function() {
9369
9303
  }
9370
9304
  return false;
9371
9305
  }
9372
- /**
9373
- * Returns credential fields for this source
9374
- */
9375
- getCredentialFields() {
9376
- return {
9377
- ClientId: this.config.ClientId,
9378
- ClientSecret: this.config.ClientSecret,
9379
- RedirectUri: this.config.RedirectUri,
9380
- RefreshToken: this.config.RefreshToken,
9381
- UserAgent: this.config.UserAgent
9382
- };
9383
- }
9384
9306
  /**
9385
9307
  * Keep only requestedFields plus any schema-required keys.
9386
9308
  * @param {Array<Object>|Object} items - Array of objects or single object
@@ -11271,18 +11193,6 @@ API Response: ${JSON.stringify(statusResult, null, 2)}`);
11271
11193
  }));
11272
11194
  this.fieldsSchema = MicrosoftAdsFieldsSchema;
11273
11195
  }
11274
- /**
11275
- * Returns credential fields for this source
11276
- * @returns {Object}
11277
- */
11278
- getCredentialFields() {
11279
- return {
11280
- DeveloperToken: this.config.DeveloperToken,
11281
- ClientID: this.config.ClientID,
11282
- ClientSecret: this.config.ClientSecret,
11283
- RefreshToken: this.config.RefreshToken
11284
- };
11285
- }
11286
11196
  /**
11287
11197
  * Retrieve and store an OAuth access token using the refresh token
11288
11198
  */
@@ -11993,17 +11903,6 @@ const LinkedInPages = (function() {
11993
11903
  this.fieldsSchema = LinkedInPagesFieldsSchema;
11994
11904
  this.BASE_URL = "https://api.linkedin.com/rest/";
11995
11905
  }
11996
- /**
11997
- * Returns credential fields for this source
11998
- * @returns {Object}
11999
- */
12000
- getCredentialFields() {
12001
- return {
12002
- ClientID: this.config.ClientID,
12003
- ClientSecret: this.config.ClientSecret,
12004
- RefreshToken: this.config.RefreshToken
12005
- };
12006
- }
12007
11906
  /**
12008
11907
  * Main entry point for fetching data from LinkedIn Pages API
12009
11908
  * @param {string} nodeName - Type of resource to fetch
@@ -13269,17 +13168,6 @@ const LinkedInAds = (function() {
13269
13168
  this.MAX_FIELDS_PER_REQUEST = 20;
13270
13169
  this.BASE_URL = "https://api.linkedin.com/rest/";
13271
13170
  }
13272
- /**
13273
- * Returns credential fields for this source
13274
- * @returns {Object}
13275
- */
13276
- getCredentialFields() {
13277
- return {
13278
- ClientID: this.config.ClientID,
13279
- ClientSecret: this.config.ClientSecret,
13280
- RefreshToken: this.config.RefreshToken
13281
- };
13282
- }
13283
13171
  /**
13284
13172
  * Main entry point for fetching data from LinkedIn Ads API
13285
13173
  * @param {string} nodeName - Type of resource to fetch (e.g., adAccounts, adCampaigns)
@@ -21155,16 +21043,6 @@ const CriteoAds = (function() {
21155
21043
  }));
21156
21044
  this.fieldsSchema = CriteoAdsFieldsSchema;
21157
21045
  }
21158
- /**
21159
- * Return the credential fields needed for this connector
21160
- * @returns {Object} Object with credential field names and their config objects
21161
- */
21162
- getCredentialFields() {
21163
- return {
21164
- ClientId: this.config.ClientId,
21165
- ClientSecret: this.config.ClientSecret
21166
- };
21167
- }
21168
21046
  /**
21169
21047
  * Single entry point for *all* fetches.
21170
21048
  * @param {Object} opts
package/dist/index.js CHANGED
@@ -3784,21 +3784,9 @@ OPTIONS(description="${this.description}")`;
3784
3784
  }
3785
3785
  }));
3786
3786
  this.fieldsSchema = XAdsFieldsSchema;
3787
- this._tweetsCache = /* @__PURE__ */ new Map();
3788
3787
  this._promotedTweetsCache = /* @__PURE__ */ new Map();
3789
3788
  this.BASE_URL = "https://ads-api.x.com/";
3790
3789
  }
3791
- /**
3792
- * Returns credential fields for this source
3793
- */
3794
- getCredentialFields() {
3795
- return {
3796
- ConsumerKey: this.config.ConsumerKey,
3797
- ConsumerSecret: this.config.ConsumerSecret,
3798
- AccessToken: this.config.AccessToken,
3799
- AccessTokenSecret: this.config.AccessTokenSecret
3800
- };
3801
- }
3802
3790
  /**
3803
3791
  * Single entry point for *all* fetches.
3804
3792
  * @param {Object} opts
@@ -3841,34 +3829,6 @@ OPTIONS(description="${this.description}")`;
3841
3829
  throw new ConfigurationError(`Unknown node: ${nodeName}`);
3842
3830
  }
3843
3831
  }
3844
- /**
3845
- * Get cached data if all requested fields are present
3846
- * @param {Map} cache - Cache map to check
3847
- * @param {string} accountId - Account ID to look up
3848
- * @param {Array<string>} fields - Required fields
3849
- * @returns {Array|null} - Cached data or null if not found/invalid
3850
- * @private
3851
- */
3852
- _getCachedData(cache, accountId, fields) {
3853
- if (!cache.has(accountId)) return null;
3854
- const cached = cache.get(accountId);
3855
- const hasAllFields = fields.every((field) => cached.fields.has(field));
3856
- return hasAllFields ? cached.data : null;
3857
- }
3858
- /**
3859
- * Store data in cache with its fields
3860
- * @param {Map} cache - Cache map to store in
3861
- * @param {string} accountId - Account ID as key
3862
- * @param {Array} data - Data to cache
3863
- * @param {Array<string>} fields - Fields present in the data
3864
- * @private
3865
- */
3866
- _setCacheData(cache, accountId, data, fields) {
3867
- cache.set(accountId, {
3868
- data,
3869
- fields: new Set(fields)
3870
- });
3871
- }
3872
3832
  /**
3873
3833
  * Shared logic for non-time-series endpoints
3874
3834
  */
@@ -3878,23 +3838,9 @@ OPTIONS(description="${this.description}")`;
3878
3838
  if (missingKeys.length > 0) {
3879
3839
  throw new Error(`Missing required unique fields for endpoint '${nodeName}'. Missing fields: ${missingKeys.join(", ")}`);
3880
3840
  }
3881
- if (nodeName === "promoted_tweets") {
3882
- const cached = this._getCachedData(this._promotedTweetsCache, accountId, fields);
3883
- if (cached) {
3884
- console.log("returning cached promoted_tweets");
3885
- return cached;
3886
- }
3887
- console.log("deleting cached promoted_tweets");
3888
- this._promotedTweetsCache.delete(accountId);
3889
- }
3890
- if (nodeName === "tweets") {
3891
- const cached = this._getCachedData(this._tweetsCache, accountId, fields);
3892
- if (cached) {
3893
- console.log("returning cached tweets");
3894
- return cached;
3895
- }
3896
- console.log("deleting cached tweets");
3897
- this._tweetsCache.delete(accountId);
3841
+ if (nodeName === "promoted_tweets" && this._promotedTweetsCache.has(accountId)) {
3842
+ console.log(`[XAdsSource] Using cached promoted_tweets for account ${accountId}`);
3843
+ return this._promotedTweetsCache.get(accountId);
3898
3844
  }
3899
3845
  let all = await this._fetchPages({
3900
3846
  accountId,
@@ -3910,10 +3856,8 @@ OPTIONS(description="${this.description}")`;
3910
3856
  }));
3911
3857
  }
3912
3858
  if (nodeName === "promoted_tweets") {
3913
- this._setCacheData(this._promotedTweetsCache, accountId, all, fields);
3914
- }
3915
- if (nodeName === "tweets") {
3916
- this._setCacheData(this._tweetsCache, accountId, all, fields);
3859
+ console.log(`[XAdsSource] Fetched promoted_tweets from API for account ${accountId}`);
3860
+ this._promotedTweetsCache.set(accountId, all);
3917
3861
  }
3918
3862
  return all;
3919
3863
  }
@@ -4137,10 +4081,10 @@ OPTIONS(description="${this.description}")`;
4137
4081
  return "OAuth " + Object.keys(oauth).map((k) => `${encodeURIComponent(k)}="${encodeURIComponent(oauth[k])}"`).join(", ");
4138
4082
  }
4139
4083
  /**
4140
- * Clear tweet/promoted-tweet caches.
4141
- * */
4142
- clearTweetsCache(accountId) {
4143
- this._tweetsCache.delete(accountId);
4084
+ * Clear cache for a specific account
4085
+ * Called after processing all nodes for an account to free up memory
4086
+ */
4087
+ clearCache(accountId) {
4144
4088
  this._promotedTweetsCache.delete(accountId);
4145
4089
  }
4146
4090
  };
@@ -4164,7 +4108,7 @@ OPTIONS(description="${this.description}")`;
4164
4108
  fields: fields[nodeName] || []
4165
4109
  });
4166
4110
  }
4167
- this.source.clearTweetsCache(accountId);
4111
+ this.source.clearCache(accountId);
4168
4112
  }
4169
4113
  }
4170
4114
  /**
@@ -5673,16 +5617,6 @@ OPTIONS(description="${this.description}")`;
5673
5617
  }
5674
5618
  return processedRecord;
5675
5619
  }
5676
- /**
5677
- * Returns credential fields for this source
5678
- */
5679
- getCredentialFields() {
5680
- return {
5681
- AccessToken: this.config.AccessToken,
5682
- AppId: this.config.AppId,
5683
- AppSecret: this.config.AppSecret
5684
- };
5685
- }
5686
5620
  };
5687
5621
  var TikTokAdsConnector = class TikTokAdsConnector extends AbstractConnector2 {
5688
5622
  constructor(config, source, storageName = "GoogleBigQueryStorage", runConfig = null) {
@@ -9374,18 +9308,6 @@ OPTIONS(description="${this.description}")`;
9374
9308
  }
9375
9309
  return false;
9376
9310
  }
9377
- /**
9378
- * Returns credential fields for this source
9379
- */
9380
- getCredentialFields() {
9381
- return {
9382
- ClientId: this.config.ClientId,
9383
- ClientSecret: this.config.ClientSecret,
9384
- RedirectUri: this.config.RedirectUri,
9385
- RefreshToken: this.config.RefreshToken,
9386
- UserAgent: this.config.UserAgent
9387
- };
9388
- }
9389
9311
  /**
9390
9312
  * Keep only requestedFields plus any schema-required keys.
9391
9313
  * @param {Array<Object>|Object} items - Array of objects or single object
@@ -11276,18 +11198,6 @@ API Response: ${JSON.stringify(statusResult, null, 2)}`);
11276
11198
  }));
11277
11199
  this.fieldsSchema = MicrosoftAdsFieldsSchema;
11278
11200
  }
11279
- /**
11280
- * Returns credential fields for this source
11281
- * @returns {Object}
11282
- */
11283
- getCredentialFields() {
11284
- return {
11285
- DeveloperToken: this.config.DeveloperToken,
11286
- ClientID: this.config.ClientID,
11287
- ClientSecret: this.config.ClientSecret,
11288
- RefreshToken: this.config.RefreshToken
11289
- };
11290
- }
11291
11201
  /**
11292
11202
  * Retrieve and store an OAuth access token using the refresh token
11293
11203
  */
@@ -11998,17 +11908,6 @@ API Response: ${JSON.stringify(statusResult, null, 2)}`);
11998
11908
  this.fieldsSchema = LinkedInPagesFieldsSchema;
11999
11909
  this.BASE_URL = "https://api.linkedin.com/rest/";
12000
11910
  }
12001
- /**
12002
- * Returns credential fields for this source
12003
- * @returns {Object}
12004
- */
12005
- getCredentialFields() {
12006
- return {
12007
- ClientID: this.config.ClientID,
12008
- ClientSecret: this.config.ClientSecret,
12009
- RefreshToken: this.config.RefreshToken
12010
- };
12011
- }
12012
11911
  /**
12013
11912
  * Main entry point for fetching data from LinkedIn Pages API
12014
11913
  * @param {string} nodeName - Type of resource to fetch
@@ -13274,17 +13173,6 @@ API Response: ${JSON.stringify(statusResult, null, 2)}`);
13274
13173
  this.MAX_FIELDS_PER_REQUEST = 20;
13275
13174
  this.BASE_URL = "https://api.linkedin.com/rest/";
13276
13175
  }
13277
- /**
13278
- * Returns credential fields for this source
13279
- * @returns {Object}
13280
- */
13281
- getCredentialFields() {
13282
- return {
13283
- ClientID: this.config.ClientID,
13284
- ClientSecret: this.config.ClientSecret,
13285
- RefreshToken: this.config.RefreshToken
13286
- };
13287
- }
13288
13176
  /**
13289
13177
  * Main entry point for fetching data from LinkedIn Ads API
13290
13178
  * @param {string} nodeName - Type of resource to fetch (e.g., adAccounts, adCampaigns)
@@ -21160,16 +21048,6 @@ API Response: ${JSON.stringify(statusResult, null, 2)}`);
21160
21048
  }));
21161
21049
  this.fieldsSchema = CriteoAdsFieldsSchema;
21162
21050
  }
21163
- /**
21164
- * Return the credential fields needed for this connector
21165
- * @returns {Object} Object with credential field names and their config objects
21166
- */
21167
- getCredentialFields() {
21168
- return {
21169
- ClientId: this.config.ClientId,
21170
- ClientSecret: this.config.ClientSecret
21171
- };
21172
- }
21173
21051
  /**
21174
21052
  * Single entry point for *all* fetches.
21175
21053
  * @param {Object} opts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owox/connectors",
3
- "version": "0.12.0-next-20251113083123",
3
+ "version": "0.12.0-next-20251113104154",
4
4
  "description": "Connectors and storages for different data sources",
5
5
  "license": "MIT",
6
6
  "publishConfig": {