@show-karma/karma-gap-sdk 0.4.26 → 0.4.27
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/core/class/Fetcher.d.ts +1 -1
- package/core/class/GAP.d.ts +1 -1
- package/core/class/GAP.js +2 -2
- package/core/class/GraphQL/GapEasClient.d.ts +1 -1
- package/core/class/GraphQL/GapEasClient.js +1 -1
- package/core/class/karma-indexer/GapIndexerClient.d.ts +1 -1
- package/core/class/karma-indexer/GapIndexerClient.js +2 -2
- package/core/class/karma-indexer/api/GapIndexerApi.d.ts +1 -1
- package/core/class/karma-indexer/api/GapIndexerApi.js +6 -2
- package/package.json +1 -1
package/core/class/Fetcher.d.ts
CHANGED
|
@@ -165,7 +165,7 @@ export declare abstract class Fetcher extends AxiosGQL {
|
|
|
165
165
|
* @param slug
|
|
166
166
|
* @returns
|
|
167
167
|
*/
|
|
168
|
-
abstract slugExists(slug: string): Promise<boolean>;
|
|
168
|
+
abstract slugExists(slug: string, type?: "project" | "community"): Promise<boolean>;
|
|
169
169
|
/**
|
|
170
170
|
* Get grants for a project by an external uid
|
|
171
171
|
* > Works only for the indexed projects
|
package/core/class/GAP.d.ts
CHANGED
|
@@ -225,7 +225,7 @@ export declare class GAP extends Facade {
|
|
|
225
225
|
* @param text
|
|
226
226
|
* @returns
|
|
227
227
|
*/
|
|
228
|
-
generateSlug: (text: string) => Promise<string>;
|
|
228
|
+
generateSlug: (text: string, type?: "project" | "community") => Promise<string>;
|
|
229
229
|
/**
|
|
230
230
|
* Returns a copy of the original schema with no pointers.
|
|
231
231
|
* @param name
|
package/core/class/GAP.js
CHANGED
|
@@ -103,7 +103,7 @@ class GAP extends types_1.Facade {
|
|
|
103
103
|
* @param text
|
|
104
104
|
* @returns
|
|
105
105
|
*/
|
|
106
|
-
this.generateSlug = async (text) => {
|
|
106
|
+
this.generateSlug = async (text, type) => {
|
|
107
107
|
let slug = text
|
|
108
108
|
.toLowerCase()
|
|
109
109
|
// Remove emojis
|
|
@@ -116,7 +116,7 @@ class GAP extends types_1.Facade {
|
|
|
116
116
|
.replace(/^-+|-+$/g, ""); // Remove leading and trailing hyphens
|
|
117
117
|
const checkSlug = async (currentSlug, counter = 0) => {
|
|
118
118
|
const slugToCheck = counter === 0 ? currentSlug : `${currentSlug}-${counter}`;
|
|
119
|
-
const slugExists = await this.fetch.slugExists(slugToCheck);
|
|
119
|
+
const slugExists = await this.fetch.slugExists(slugToCheck, type);
|
|
120
120
|
if (slugExists) {
|
|
121
121
|
return checkSlug(currentSlug, counter + 1);
|
|
122
122
|
}
|
|
@@ -44,7 +44,7 @@ export declare class GapEasClient extends Fetcher {
|
|
|
44
44
|
projectsDetails(projects: Project[]): Promise<Project[]>;
|
|
45
45
|
projectById(uid: Hex): Promise<Project>;
|
|
46
46
|
projectBySlug(slug: string): Promise<Project>;
|
|
47
|
-
slugExists(slug: string): Promise<boolean>;
|
|
47
|
+
slugExists(slug: string, _type?: "project" | "community"): Promise<boolean>;
|
|
48
48
|
search(query: string): Promise<{
|
|
49
49
|
projects: Project[];
|
|
50
50
|
communities: Community[];
|
|
@@ -230,7 +230,7 @@ class GapEasClient extends Fetcher_1.Fetcher {
|
|
|
230
230
|
throw new Error("Project not found.");
|
|
231
231
|
return withDetails;
|
|
232
232
|
}
|
|
233
|
-
async slugExists(slug) {
|
|
233
|
+
async slugExists(slug, _type) {
|
|
234
234
|
const details = this.gap.findSchema("ProjectDetails");
|
|
235
235
|
const query = gql_queries_1.gqlQueries.attestationsOf(details.uid, "slug");
|
|
236
236
|
const { schema: { attestations }, } = await this.query(query);
|
|
@@ -39,7 +39,7 @@ export declare class GapIndexerClient extends Fetcher {
|
|
|
39
39
|
grantsByCommunity(uid: `0x${string}`, page?: number, pageLimit?: number): Promise<Grant[]>;
|
|
40
40
|
milestonesOf(grants: Grant[]): Promise<Milestone[]>;
|
|
41
41
|
membersOf(projects: Project[]): Promise<MemberOf[]>;
|
|
42
|
-
slugExists(slug: string): Promise<boolean>;
|
|
42
|
+
slugExists(slug: string, type?: "project" | "community"): Promise<boolean>;
|
|
43
43
|
/**
|
|
44
44
|
* Track related methods
|
|
45
45
|
*/
|
|
@@ -149,8 +149,8 @@ class GapIndexerClient extends Fetcher_1.Fetcher {
|
|
|
149
149
|
async membersOf(projects) {
|
|
150
150
|
throw new Error("Method not implemented.");
|
|
151
151
|
}
|
|
152
|
-
async slugExists(slug) {
|
|
153
|
-
return await this.apiClient.slugExists(slug);
|
|
152
|
+
async slugExists(slug, type) {
|
|
153
|
+
return await this.apiClient.slugExists(slug, type);
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
156
|
* Track related methods
|
|
@@ -46,7 +46,7 @@ export declare class GapIndexerApi extends AxiosGQL {
|
|
|
46
46
|
* Milestone
|
|
47
47
|
*/
|
|
48
48
|
milestonesOf(uid: Hex): Promise<import("axios").AxiosResponse<any, any>>;
|
|
49
|
-
slugExists(slug: string): Promise<boolean>;
|
|
49
|
+
slugExists(slug: string, type?: "project" | "community"): Promise<boolean>;
|
|
50
50
|
/**
|
|
51
51
|
* Tracks
|
|
52
52
|
*/
|
|
@@ -11,6 +11,7 @@ const Endpoints = {
|
|
|
11
11
|
all: () => "/communities",
|
|
12
12
|
admins: (uid) => `/communities/${uid}/admins`,
|
|
13
13
|
byUidOrSlug: (uidOrSlug) => `/communities/${uidOrSlug}`,
|
|
14
|
+
checkSlugAvailability: (slug) => `/v2/communities/slug/check/${slug}`,
|
|
14
15
|
grants: (uidOrSlug, page = 0, pageLimit = 100) => `/communities/${uidOrSlug}/grants?${page ? `page=${page}` : ""}${pageLimit ? `&pageLimit=${pageLimit}` : ""}`,
|
|
15
16
|
},
|
|
16
17
|
grantees: {
|
|
@@ -192,8 +193,11 @@ class GapIndexerApi extends AxiosGQL_1.AxiosGQL {
|
|
|
192
193
|
const response = await this.client.get(Endpoints.project.milestones(uid));
|
|
193
194
|
return response;
|
|
194
195
|
}
|
|
195
|
-
async slugExists(slug) {
|
|
196
|
-
const
|
|
196
|
+
async slugExists(slug, type) {
|
|
197
|
+
const endpoint = type === "community"
|
|
198
|
+
? Endpoints.communities.checkSlugAvailability(slug)
|
|
199
|
+
: Endpoints.project.checkSlugAvailability(slug);
|
|
200
|
+
const { data } = await this.client.get(endpoint);
|
|
197
201
|
return !data.available;
|
|
198
202
|
}
|
|
199
203
|
/**
|