@ecency/sdk 1.5.16 → 1.5.18
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/dist/browser/index.d.ts +7 -4
- package/dist/browser/index.js +66 -12
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +66 -12
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +66 -12
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -845,6 +845,11 @@ declare const CONFIG: {
|
|
|
845
845
|
dmcaPatternRegexes: RegExp[];
|
|
846
846
|
_dmcaInitialized: boolean;
|
|
847
847
|
};
|
|
848
|
+
type DmcaListsInput = {
|
|
849
|
+
accounts?: string[];
|
|
850
|
+
tags?: string[];
|
|
851
|
+
posts?: string[];
|
|
852
|
+
};
|
|
848
853
|
declare namespace ConfigManager {
|
|
849
854
|
function setQueryClient(client: QueryClient): void;
|
|
850
855
|
/**
|
|
@@ -872,11 +877,9 @@ declare namespace ConfigManager {
|
|
|
872
877
|
function setImageHost(host: string): void;
|
|
873
878
|
/**
|
|
874
879
|
* Set DMCA filtering lists
|
|
875
|
-
* @param accounts -
|
|
876
|
-
* @param tags - List of tag patterns (regex strings) to filter
|
|
877
|
-
* @param patterns - List of post patterns (plain strings) like "@author/permlink" for exact matching
|
|
880
|
+
* @param accounts - DMCA lists object containing accounts/tags/posts arrays
|
|
878
881
|
*/
|
|
879
|
-
function setDmcaLists(accounts?:
|
|
882
|
+
function setDmcaLists(accounts?: DmcaListsInput): void;
|
|
880
883
|
}
|
|
881
884
|
|
|
882
885
|
declare function makeQueryClient(): QueryClient;
|
package/dist/browser/index.js
CHANGED
|
@@ -216,18 +216,24 @@ var ConfigManager;
|
|
|
216
216
|
return null;
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
function setDmcaLists(accounts =
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
219
|
+
function setDmcaLists(accounts = {}) {
|
|
220
|
+
const coerceList = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
221
|
+
const resolved = {
|
|
222
|
+
accounts: coerceList(accounts.accounts),
|
|
223
|
+
tags: coerceList(accounts.tags),
|
|
224
|
+
patterns: coerceList(accounts.posts)
|
|
225
|
+
};
|
|
226
|
+
CONFIG.dmcaAccounts = resolved.accounts;
|
|
227
|
+
CONFIG.dmcaTags = resolved.tags;
|
|
228
|
+
CONFIG.dmcaPatterns = resolved.patterns;
|
|
229
|
+
CONFIG.dmcaTagRegexes = resolved.tags.map((pattern) => safeCompileRegex(pattern)).filter((r) => r !== null);
|
|
224
230
|
CONFIG.dmcaPatternRegexes = [];
|
|
225
|
-
const rejectedTagCount = tags.length - CONFIG.dmcaTagRegexes.length;
|
|
231
|
+
const rejectedTagCount = resolved.tags.length - CONFIG.dmcaTagRegexes.length;
|
|
226
232
|
if (!CONFIG._dmcaInitialized && isDevelopment) {
|
|
227
233
|
console.log(`[SDK] DMCA configuration loaded:`);
|
|
228
|
-
console.log(` - Accounts: ${accounts.length}`);
|
|
229
|
-
console.log(` - Tag patterns: ${CONFIG.dmcaTagRegexes.length}/${tags.length} compiled (${rejectedTagCount} rejected)`);
|
|
230
|
-
console.log(` - Post patterns: ${patterns.length} (using exact string matching)`);
|
|
234
|
+
console.log(` - Accounts: ${resolved.accounts.length}`);
|
|
235
|
+
console.log(` - Tag patterns: ${CONFIG.dmcaTagRegexes.length}/${resolved.tags.length} compiled (${rejectedTagCount} rejected)`);
|
|
236
|
+
console.log(` - Post patterns: ${resolved.patterns.length} (using exact string matching)`);
|
|
231
237
|
if (rejectedTagCount > 0) {
|
|
232
238
|
console.warn(`[SDK] ${rejectedTagCount} DMCA tag patterns were rejected due to security validation. Check warnings above for details.`);
|
|
233
239
|
}
|
|
@@ -2718,6 +2724,11 @@ function useAccountRelationsUpdate(reference, target, auth, onSuccess, onError)
|
|
|
2718
2724
|
["accounts", "relations", reference, target],
|
|
2719
2725
|
data
|
|
2720
2726
|
);
|
|
2727
|
+
if (target) {
|
|
2728
|
+
getQueryClient().invalidateQueries(
|
|
2729
|
+
getAccountFullQueryOptions(target)
|
|
2730
|
+
);
|
|
2731
|
+
}
|
|
2721
2732
|
}
|
|
2722
2733
|
});
|
|
2723
2734
|
}
|
|
@@ -3312,10 +3323,23 @@ function useAddFragment(username, code) {
|
|
|
3312
3323
|
return response.json();
|
|
3313
3324
|
},
|
|
3314
3325
|
onSuccess(response) {
|
|
3315
|
-
getQueryClient()
|
|
3326
|
+
const queryClient = getQueryClient();
|
|
3327
|
+
queryClient.setQueryData(
|
|
3316
3328
|
getFragmentsQueryOptions(username, code).queryKey,
|
|
3317
3329
|
(data) => [response, ...data ?? []]
|
|
3318
3330
|
);
|
|
3331
|
+
queryClient.setQueriesData(
|
|
3332
|
+
{ queryKey: ["posts", "fragments", "infinite", username] },
|
|
3333
|
+
(oldData) => {
|
|
3334
|
+
if (!oldData) return oldData;
|
|
3335
|
+
return {
|
|
3336
|
+
...oldData,
|
|
3337
|
+
pages: oldData.pages.map(
|
|
3338
|
+
(page, index) => index === 0 ? { ...page, data: [response, ...page.data] } : page
|
|
3339
|
+
)
|
|
3340
|
+
};
|
|
3341
|
+
}
|
|
3342
|
+
);
|
|
3319
3343
|
}
|
|
3320
3344
|
});
|
|
3321
3345
|
}
|
|
@@ -3349,7 +3373,8 @@ function useEditFragment(username, code) {
|
|
|
3349
3373
|
return response.json();
|
|
3350
3374
|
},
|
|
3351
3375
|
onSuccess(response, variables) {
|
|
3352
|
-
getQueryClient()
|
|
3376
|
+
const queryClient = getQueryClient();
|
|
3377
|
+
queryClient.setQueryData(
|
|
3353
3378
|
getFragmentsQueryOptions(username, code).queryKey,
|
|
3354
3379
|
(data) => {
|
|
3355
3380
|
if (!data) {
|
|
@@ -3362,6 +3387,21 @@ function useEditFragment(username, code) {
|
|
|
3362
3387
|
return [...data];
|
|
3363
3388
|
}
|
|
3364
3389
|
);
|
|
3390
|
+
queryClient.setQueriesData(
|
|
3391
|
+
{ queryKey: ["posts", "fragments", "infinite", username] },
|
|
3392
|
+
(oldData) => {
|
|
3393
|
+
if (!oldData) return oldData;
|
|
3394
|
+
return {
|
|
3395
|
+
...oldData,
|
|
3396
|
+
pages: oldData.pages.map((page) => ({
|
|
3397
|
+
...page,
|
|
3398
|
+
data: page.data.map(
|
|
3399
|
+
(fragment) => fragment.id === variables.fragmentId ? response : fragment
|
|
3400
|
+
)
|
|
3401
|
+
}))
|
|
3402
|
+
};
|
|
3403
|
+
}
|
|
3404
|
+
);
|
|
3365
3405
|
}
|
|
3366
3406
|
});
|
|
3367
3407
|
}
|
|
@@ -3385,10 +3425,24 @@ function useRemoveFragment(username, code) {
|
|
|
3385
3425
|
});
|
|
3386
3426
|
},
|
|
3387
3427
|
onSuccess(_data, variables) {
|
|
3388
|
-
getQueryClient()
|
|
3428
|
+
const queryClient = getQueryClient();
|
|
3429
|
+
queryClient.setQueryData(
|
|
3389
3430
|
getFragmentsQueryOptions(username, code).queryKey,
|
|
3390
3431
|
(data) => [...data ?? []].filter(({ id }) => id !== variables.fragmentId)
|
|
3391
3432
|
);
|
|
3433
|
+
queryClient.setQueriesData(
|
|
3434
|
+
{ queryKey: ["posts", "fragments", "infinite", username] },
|
|
3435
|
+
(oldData) => {
|
|
3436
|
+
if (!oldData) return oldData;
|
|
3437
|
+
return {
|
|
3438
|
+
...oldData,
|
|
3439
|
+
pages: oldData.pages.map((page) => ({
|
|
3440
|
+
...page,
|
|
3441
|
+
data: page.data.filter((fragment) => fragment.id !== variables.fragmentId)
|
|
3442
|
+
}))
|
|
3443
|
+
};
|
|
3444
|
+
}
|
|
3445
|
+
);
|
|
3392
3446
|
}
|
|
3393
3447
|
});
|
|
3394
3448
|
}
|