@show-karma/karma-gap-sdk 0.4.16 → 0.4.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.
Files changed (188) hide show
  1. package/core/abi/AirdropNFT.json +1 -1
  2. package/core/abi/Allo.json +860 -860
  3. package/core/abi/AlloRegistry.json +578 -578
  4. package/core/abi/CommunityResolverABI.json +506 -506
  5. package/core/abi/Donations.json +251 -251
  6. package/core/abi/EAS.json +1 -1
  7. package/core/abi/MultiAttester.json +746 -746
  8. package/core/abi/ProjectResolver.json +574 -574
  9. package/core/abi/SchemaRegistry.json +1 -1
  10. package/core/abi/index.d.ts +1114 -0
  11. package/core/abi/index.js +26 -0
  12. package/core/class/AllGapSchemas.d.ts +9 -0
  13. package/core/class/AllGapSchemas.js +19 -0
  14. package/core/class/Attestation.d.ts +173 -0
  15. package/core/class/Attestation.js +333 -0
  16. package/core/class/Fetcher.d.ts +175 -0
  17. package/core/class/Fetcher.js +13 -0
  18. package/core/class/GAP.d.ts +254 -0
  19. package/core/class/GAP.js +289 -0
  20. package/core/class/GapSchema.d.ts +34 -0
  21. package/core/class/GapSchema.js +62 -0
  22. package/core/class/Gelato/{Gelato.ts → Gelato.js} +0 -23
  23. package/core/class/GrantProgramRegistry/Allo.d.ts +17 -0
  24. package/core/class/GrantProgramRegistry/Allo.js +137 -0
  25. package/core/class/GrantProgramRegistry/AlloRegistry.d.ts +15 -0
  26. package/core/class/GrantProgramRegistry/AlloRegistry.js +70 -0
  27. package/core/class/GraphQL/AxiosGQL.d.ts +6 -0
  28. package/core/class/GraphQL/AxiosGQL.js +25 -0
  29. package/core/class/GraphQL/EASClient.d.ts +16 -0
  30. package/core/class/GraphQL/EASClient.js +26 -0
  31. package/core/class/GraphQL/GapEasClient.d.ts +71 -0
  32. package/core/class/GraphQL/GapEasClient.js +451 -0
  33. package/core/class/GraphQL/index.js +19 -0
  34. package/core/class/Schema.d.ts +233 -0
  35. package/core/class/Schema.js +490 -0
  36. package/core/class/SchemaError.d.ts +30 -0
  37. package/core/class/SchemaError.js +39 -0
  38. package/core/class/contract/GapContract.d.ts +102 -0
  39. package/core/class/contract/GapContract.js +285 -0
  40. package/core/class/entities/Community.d.ts +34 -0
  41. package/core/class/entities/Community.js +109 -0
  42. package/core/class/entities/ContributorProfile.d.ts +41 -0
  43. package/core/class/entities/ContributorProfile.js +69 -0
  44. package/core/class/entities/Grant.d.ts +54 -0
  45. package/core/class/entities/Grant.js +223 -0
  46. package/core/class/entities/GrantUpdate.d.ts +62 -0
  47. package/core/class/entities/GrantUpdate.js +114 -0
  48. package/core/class/entities/MemberOf.d.ts +11 -0
  49. package/core/class/entities/MemberOf.js +33 -0
  50. package/core/class/entities/Milestone.d.ts +168 -0
  51. package/core/class/entities/Milestone.js +657 -0
  52. package/core/class/entities/Project.d.ts +92 -0
  53. package/core/class/entities/Project.js +418 -0
  54. package/core/class/entities/ProjectImpact.d.ts +50 -0
  55. package/core/class/entities/ProjectImpact.js +112 -0
  56. package/core/class/entities/ProjectMilestone.d.ts +60 -0
  57. package/core/class/entities/ProjectMilestone.js +174 -0
  58. package/core/class/entities/ProjectPointer.d.ts +12 -0
  59. package/core/class/entities/ProjectPointer.js +22 -0
  60. package/core/class/entities/ProjectUpdate.d.ts +50 -0
  61. package/core/class/entities/ProjectUpdate.js +110 -0
  62. package/core/class/entities/Track.d.ts +16 -0
  63. package/core/class/entities/Track.js +21 -0
  64. package/core/class/entities/index.js +26 -0
  65. package/core/class/index.js +26 -0
  66. package/core/class/karma-indexer/GapIndexerClient.d.ts +66 -0
  67. package/core/class/karma-indexer/GapIndexerClient.js +207 -0
  68. package/core/class/karma-indexer/api/GapIndexerApi.d.ts +73 -0
  69. package/core/class/karma-indexer/api/GapIndexerApi.js +256 -0
  70. package/core/class/karma-indexer/api/types.d.ts +309 -0
  71. package/core/class/karma-indexer/api/types.js +2 -0
  72. package/core/class/remote-storage/IpfsStorage.d.ts +23 -0
  73. package/core/class/remote-storage/IpfsStorage.js +56 -0
  74. package/core/class/remote-storage/RemoteStorage.d.ts +41 -0
  75. package/core/class/remote-storage/RemoteStorage.js +38 -0
  76. package/core/class/types/allo.d.ts +78 -0
  77. package/core/class/types/allo.js +2 -0
  78. package/core/class/types/attestations.d.ts +173 -0
  79. package/core/class/types/attestations.js +66 -0
  80. package/core/consts.d.ts +50 -0
  81. package/core/consts.js +699 -0
  82. package/core/index.js +24 -0
  83. package/core/shared/types.d.ts +13 -0
  84. package/core/shared/types.js +2 -0
  85. package/core/types.d.ts +131 -0
  86. package/core/types.js +13 -0
  87. package/core/utils/gelato/index.js +19 -0
  88. package/core/utils/gelato/send-gelato-txn.d.ts +55 -0
  89. package/core/utils/gelato/send-gelato-txn.js +100 -0
  90. package/core/utils/gelato/sponsor-handler.d.ts +9 -0
  91. package/core/utils/gelato/sponsor-handler.js +60 -0
  92. package/core/utils/gelato/watch-gelato-txn.d.ts +7 -0
  93. package/core/utils/gelato/watch-gelato-txn.js +63 -0
  94. package/core/utils/get-date.d.ts +1 -0
  95. package/core/utils/get-date.js +7 -0
  96. package/core/utils/get-ipfs-data.d.ts +1 -0
  97. package/core/utils/get-ipfs-data.js +20 -0
  98. package/core/utils/get-web3-provider.d.ts +2 -0
  99. package/core/utils/get-web3-provider.js +18 -0
  100. package/core/utils/gql-queries.d.ts +12 -0
  101. package/core/utils/gql-queries.js +90 -0
  102. package/core/utils/index.js +23 -0
  103. package/core/utils/map-filter.d.ts +8 -0
  104. package/core/utils/map-filter.js +20 -0
  105. package/core/utils/serialize-bigint.d.ts +1 -0
  106. package/core/utils/serialize-bigint.js +8 -0
  107. package/core/utils/to-unix.d.ts +1 -0
  108. package/core/utils/to-unix.js +25 -0
  109. package/index.js +17 -0
  110. package/package.json +45 -45
  111. package/.cursorrules +0 -43
  112. package/core/abi/index.ts +0 -21
  113. package/core/class/AllGapSchemas.ts +0 -21
  114. package/core/class/Attestation.ts +0 -429
  115. package/core/class/Fetcher.ts +0 -224
  116. package/core/class/GAP.ts +0 -481
  117. package/core/class/GapSchema.ts +0 -93
  118. package/core/class/GrantProgramRegistry/Allo.ts +0 -188
  119. package/core/class/GrantProgramRegistry/AlloRegistry.ts +0 -101
  120. package/core/class/GraphQL/AxiosGQL.ts +0 -29
  121. package/core/class/GraphQL/EASClient.ts +0 -34
  122. package/core/class/GraphQL/GapEasClient.ts +0 -869
  123. package/core/class/Schema.ts +0 -659
  124. package/core/class/SchemaError.ts +0 -42
  125. package/core/class/contract/GapContract.ts +0 -457
  126. package/core/class/entities/Community.ts +0 -148
  127. package/core/class/entities/ContributorProfile.ts +0 -108
  128. package/core/class/entities/Grant.ts +0 -321
  129. package/core/class/entities/GrantUpdate.ts +0 -187
  130. package/core/class/entities/MemberOf.ts +0 -52
  131. package/core/class/entities/Milestone.ts +0 -898
  132. package/core/class/entities/Project.ts +0 -672
  133. package/core/class/entities/ProjectImpact.ts +0 -170
  134. package/core/class/entities/ProjectMilestone.ts +0 -254
  135. package/core/class/entities/ProjectPointer.ts +0 -39
  136. package/core/class/entities/ProjectUpdate.ts +0 -176
  137. package/core/class/entities/Track.ts +0 -32
  138. package/core/class/karma-indexer/GapIndexerClient.ts +0 -383
  139. package/core/class/karma-indexer/api/GapIndexerApi.ts +0 -446
  140. package/core/class/karma-indexer/api/types.ts +0 -313
  141. package/core/class/remote-storage/IpfsStorage.ts +0 -76
  142. package/core/class/remote-storage/RemoteStorage.ts +0 -65
  143. package/core/class/types/allo.ts +0 -93
  144. package/core/class/types/attestations.ts +0 -223
  145. package/core/consts.ts +0 -775
  146. package/core/scripts/create-grant.ts +0 -102
  147. package/core/scripts/create-program.ts +0 -43
  148. package/core/scripts/create-schemas.ts +0 -65
  149. package/core/scripts/deploy.ts +0 -65
  150. package/core/scripts/index.ts +0 -1
  151. package/core/scripts/milestone-multi-grants.ts +0 -125
  152. package/core/shared/types.ts +0 -13
  153. package/core/types.ts +0 -224
  154. package/core/utils/gelato/send-gelato-txn.ts +0 -114
  155. package/core/utils/gelato/sponsor-handler.ts +0 -77
  156. package/core/utils/gelato/watch-gelato-txn.ts +0 -67
  157. package/core/utils/get-date.ts +0 -3
  158. package/core/utils/get-ipfs-data.ts +0 -13
  159. package/core/utils/get-web3-provider.ts +0 -18
  160. package/core/utils/gql-queries.ts +0 -133
  161. package/core/utils/map-filter.ts +0 -21
  162. package/core/utils/serialize-bigint.ts +0 -7
  163. package/core/utils/to-unix.ts +0 -18
  164. package/create-community-example.ts +0 -119
  165. package/csv-upload/README.md +0 -74
  166. package/csv-upload/config.ts +0 -41
  167. package/csv-upload/example.csv +0 -2
  168. package/csv-upload/keys.example.json +0 -8
  169. package/csv-upload/scripts/run.ts +0 -417
  170. package/csv-upload/types.ts +0 -39
  171. package/docs/.gitkeep +0 -0
  172. package/docs/images/attestation-architecture.png +0 -0
  173. package/docs/images/dfd-get-projects.png +0 -0
  174. package/gap-schema.yaml +0 -155
  175. package/milestone-workflow-example.ts +0 -353
  176. package/readme.md +0 -872
  177. package/schemas/.gitkeep +0 -0
  178. package/schemas/GAP-schemas-1692135812877.json +0 -33
  179. package/test-file-indexer-api.ts +0 -25
  180. package/tsconfig.json +0 -26
  181. /package/{csv-upload/.gitkeep → core/class/Gelato/Gelato.d.ts} +0 -0
  182. /package/core/class/GraphQL/{index.ts → index.d.ts} +0 -0
  183. /package/core/class/entities/{index.ts → index.d.ts} +0 -0
  184. /package/core/class/{index.ts → index.d.ts} +0 -0
  185. /package/core/{index.ts → index.d.ts} +0 -0
  186. /package/core/utils/gelato/{index.ts → index.d.ts} +0 -0
  187. /package/core/utils/{index.ts → index.d.ts} +0 -0
  188. /package/{index.ts → index.d.ts} +0 -0
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GapIndexerClient = void 0;
4
+ const Attestation_1 = require("../Attestation");
5
+ const Fetcher_1 = require("../Fetcher");
6
+ const entities_1 = require("../entities");
7
+ const GapIndexerApi_1 = require("./api/GapIndexerApi");
8
+ const ProjectMilestone_1 = require("../entities/ProjectMilestone");
9
+ const Endpoints = {
10
+ attestations: {
11
+ all: () => "/attestations",
12
+ byUid: (uid) => `/attestations/${uid}`,
13
+ },
14
+ communities: {
15
+ all: () => "/communities",
16
+ byUidOrSlug: (uidOrSlug) => `/communities/${uidOrSlug}`,
17
+ grants: (uidOrSlug) => `/communities/${uidOrSlug}/grants`,
18
+ },
19
+ grantees: {
20
+ all: () => "/grantees",
21
+ byAddress: (address) => `/grantees/${address}`,
22
+ grants: (address) => `/grantees/${address}/grants`,
23
+ projects: (address) => `/grantees/${address}/projects`,
24
+ communities: (address, withGrants) => `/grantees/${address}/communities${withGrants ? "?withGrants=true" : ""}`,
25
+ communitiesAdmin: (address, withGrants) => `/grantees/${address}/communities/admin${withGrants ? "?withGrants=true" : ""}`,
26
+ },
27
+ grants: {
28
+ all: () => "/grants",
29
+ byUid: (uid) => `/grants/${uid}`,
30
+ byExternalId: (id) => `/grants/external-id/${id}`,
31
+ },
32
+ project: {
33
+ all: () => "/projects",
34
+ byUidOrSlug: (uidOrSlug) => `/projects/${uidOrSlug}`,
35
+ grants: (uidOrSlug) => `/projects/${uidOrSlug}/grants`,
36
+ milestones: (uidOrSlug) => `/projects/${uidOrSlug}/milestones`,
37
+ },
38
+ };
39
+ class GapIndexerClient extends Fetcher_1.Fetcher {
40
+ constructor(params) {
41
+ super(params);
42
+ this.apiClient = new GapIndexerApi_1.GapIndexerApi(params);
43
+ }
44
+ async attestation(uid) {
45
+ const { data } = await this.apiClient.attestation(uid);
46
+ if (!data)
47
+ throw new Error("Attestation not found");
48
+ return Attestation_1.Attestation.fromInterface([data], this.gap.network)[0];
49
+ }
50
+ async attestations(schemaName, search) {
51
+ const schemaUID = this.gap.findSchema(schemaName).uid;
52
+ const { data } = await this.apiClient.attestations(schemaUID, search);
53
+ return data || [];
54
+ }
55
+ async attestationsOf(schemaName, attester) {
56
+ const schemaUID = this.gap.findSchema(schemaName).uid;
57
+ const { data } = await this.apiClient.attestationsOf(schemaUID, attester);
58
+ return data || [];
59
+ }
60
+ attestationsTo(schemaName, recipient) {
61
+ return this.attestationsOf(schemaName, recipient);
62
+ }
63
+ async communities(search) {
64
+ const { data } = await this.apiClient.communities(search);
65
+ return entities_1.Community.from(data, this.gap.network);
66
+ }
67
+ async communitiesOf(address, withGrants) {
68
+ const { data } = await this.apiClient.communitiesOf(address, withGrants);
69
+ return entities_1.Community.from(data, this.gap.network);
70
+ }
71
+ async adminOf(address) {
72
+ const { data } = await this.apiClient.adminOf(address);
73
+ return entities_1.Community.from(data, this.gap.network);
74
+ }
75
+ async communitiesAdminOf(address, withGrants) {
76
+ const { data } = await this.client.get(Endpoints.grantees.communitiesAdmin(address, withGrants));
77
+ return entities_1.Community.from(data, this.gap.network);
78
+ }
79
+ communitiesByIds(uids) {
80
+ throw new Error("Method not implemented.");
81
+ }
82
+ async communityBySlug(slug) {
83
+ const { data } = await this.apiClient.communityBySlug(slug);
84
+ return entities_1.Community.from([data], this.gap.network)[0];
85
+ }
86
+ communityById(uid) {
87
+ return this.communityBySlug(uid);
88
+ }
89
+ async communityAdmins(uid) {
90
+ const { data } = await this.apiClient.communityAdmins(uid);
91
+ return data;
92
+ }
93
+ async projectBySlug(slug) {
94
+ const { data } = await this.apiClient.projectBySlug(slug);
95
+ return entities_1.Project.from([data], this.gap.network)[0];
96
+ }
97
+ projectById(uid) {
98
+ return this.projectBySlug(uid);
99
+ }
100
+ async search(query) {
101
+ const { data } = await this.apiClient.search(query);
102
+ return { data };
103
+ }
104
+ async searchProjects(query) {
105
+ const { data } = await this.apiClient.searchProjects(query);
106
+ return entities_1.Project.from(data, this.gap.network);
107
+ }
108
+ async projects(name) {
109
+ const { data } = await this.apiClient.projects(name);
110
+ return entities_1.Project.from(data, this.gap.network);
111
+ }
112
+ async projectsOf(grantee) {
113
+ const { data } = await this.apiClient.projectsOf(grantee);
114
+ return entities_1.Project.from(data, this.gap.network);
115
+ }
116
+ async projectMilestones(uidOrSlug) {
117
+ const { data } = await this.apiClient.projectMilestones(uidOrSlug);
118
+ return ProjectMilestone_1.ProjectMilestone.from(data, this.gap.network);
119
+ }
120
+ async grantee(address) {
121
+ const { data } = await this.apiClient.grantee(address);
122
+ return data;
123
+ }
124
+ async grantees() {
125
+ const { data } = await this.apiClient.grantees();
126
+ return data; // TODO: Remove this casting after the api is fixed
127
+ }
128
+ async grantsOf(grantee, withCommunity) {
129
+ const { data } = await this.apiClient.grantsOf(grantee, withCommunity);
130
+ return entities_1.Grant.from(data, this.gap.network);
131
+ }
132
+ async grantsFor(projects, withCommunity) {
133
+ const { data } = await this.apiClient.grantsFor(projects[0].uid, withCommunity);
134
+ return entities_1.Grant.from(data, this.gap.network);
135
+ }
136
+ async grantsForExtProject(projectExtId) {
137
+ const { data } = await this.apiClient.grantsForExtProject(projectExtId);
138
+ return entities_1.Grant.from(data, this.gap.network);
139
+ }
140
+ async grantsByCommunity(uid, page = 0, pageLimit = 100) {
141
+ const { data } = await this.apiClient.grantsByCommunity(uid, page, pageLimit);
142
+ const grants = data.data;
143
+ return entities_1.Grant.from(grants, this.gap.network);
144
+ }
145
+ async milestonesOf(grants) {
146
+ const { data } = await this.apiClient.milestonesOf(grants[0].uid);
147
+ return entities_1.Milestone.from(data, this.gap.network);
148
+ }
149
+ async membersOf(projects) {
150
+ throw new Error("Method not implemented.");
151
+ }
152
+ async slugExists(slug) {
153
+ return await this.apiClient.slugExists(slug);
154
+ }
155
+ /**
156
+ * Track related methods
157
+ */
158
+ async getTracks(communityUID, includeArchived = false) {
159
+ const { data } = await this.apiClient.getTracks(communityUID, includeArchived);
160
+ return entities_1.Track.from(data, this.gap.network);
161
+ }
162
+ async getTrackById(id) {
163
+ const { data } = await this.apiClient.getTrackById(id);
164
+ return entities_1.Track.from([data], this.gap.network)[0];
165
+ }
166
+ async createTrack(trackData) {
167
+ const { data } = await this.apiClient.createTrack(trackData);
168
+ return entities_1.Track.from([data], this.gap.network)[0];
169
+ }
170
+ async updateTrack(id, trackData) {
171
+ const { data } = await this.apiClient.updateTrack(id, trackData);
172
+ return entities_1.Track.from([data], this.gap.network)[0];
173
+ }
174
+ async archiveTrack(id) {
175
+ const { data } = await this.apiClient.archiveTrack(id);
176
+ return entities_1.Track.from([data], this.gap.network)[0];
177
+ }
178
+ async assignTracksToProgram(programId, trackIds) {
179
+ const { data } = await this.apiClient.assignTracksToProgram(programId, trackIds);
180
+ return data;
181
+ }
182
+ async unassignTrackFromProgram(programId, trackId) {
183
+ const { data } = await this.apiClient.unassignTrackFromProgram(programId, trackId);
184
+ return data;
185
+ }
186
+ async getTracksForProgram(programId) {
187
+ const { data } = await this.apiClient.getTracksForProgram(programId);
188
+ return entities_1.Track.from(data, this.gap.network);
189
+ }
190
+ async getTracksForProject(projectId, programId, activeOnly = true) {
191
+ const { data } = await this.apiClient.getTracksForProject(projectId, programId, activeOnly);
192
+ return entities_1.Track.from(data, this.gap.network);
193
+ }
194
+ async assignTracksToProject(projectId, programId, trackIds) {
195
+ const { data } = await this.apiClient.assignTracksToProject(projectId, programId, trackIds);
196
+ return data;
197
+ }
198
+ async unassignTracksFromProject(projectId, programId, trackIds) {
199
+ const { data } = await this.apiClient.unassignTracksFromProject(projectId, programId, trackIds);
200
+ return data;
201
+ }
202
+ async getProjectsByTrack(communityId, programId, trackId) {
203
+ const { data } = await this.apiClient.getProjectsByTrack(communityId, programId, trackId);
204
+ return data;
205
+ }
206
+ }
207
+ exports.GapIndexerClient = GapIndexerClient;
@@ -0,0 +1,73 @@
1
+ import { AxiosGQL } from "../../GraphQL/AxiosGQL";
2
+ import { Hex, IAttestationResponse, ICommunityResponse, ICommunityAdminsResponse, IGrantResponse, IProjectResponse, ISearchResponse, IProjectMilestoneResponse, ITrackResponse, ITrackAssignmentResponse, IProjectTrackResponse } from "./types";
3
+ export declare class GapIndexerApi extends AxiosGQL {
4
+ constructor(url: string);
5
+ attestation(uid: Hex): Promise<import("axios").AxiosResponse<IAttestationResponse, any>>;
6
+ attestations(schemaUID: string, search?: string): Promise<import("axios").AxiosResponse<IAttestationResponse[], any>>;
7
+ attestationsOf(schemaUID: string, attester: Hex): Promise<import("axios").AxiosResponse<IAttestationResponse[], any>>;
8
+ /**
9
+ * Community
10
+ */
11
+ communities(search?: string): Promise<import("axios").AxiosResponse<ICommunityResponse[], any>>;
12
+ communitiesOf(address: Hex, withGrants: boolean): Promise<import("axios").AxiosResponse<ICommunityResponse[], any>>;
13
+ adminOf(address: Hex): Promise<import("axios").AxiosResponse<ICommunityResponse[], any>>;
14
+ communityBySlug(slug: string): Promise<import("axios").AxiosResponse<ICommunityResponse, any>>;
15
+ communityAdmins(uid: Hex): Promise<import("axios").AxiosResponse<ICommunityAdminsResponse, any>>;
16
+ /**
17
+ * Project
18
+ */
19
+ projectBySlug(slug: string): Promise<import("axios").AxiosResponse<IProjectResponse, any>>;
20
+ search(query: string): Promise<import("axios").AxiosResponse<ISearchResponse, any>>;
21
+ searchProjects(query: string): Promise<import("axios").AxiosResponse<IProjectResponse[], any>>;
22
+ projects(name?: string): Promise<import("axios").AxiosResponse<IProjectResponse[], any>>;
23
+ projectsOf(grantee: Hex): Promise<import("axios").AxiosResponse<IProjectResponse[], any>>;
24
+ projectMilestones(uidOrSlug: string): Promise<import("axios").AxiosResponse<IProjectMilestoneResponse[], any>>;
25
+ /**
26
+ * Grantee
27
+ */
28
+ grantee(address: Hex): Promise<import("axios").AxiosResponse<any, any>>;
29
+ grantees(): Promise<import("axios").AxiosResponse<{
30
+ [key: `0x${string}`]: {
31
+ grants: number;
32
+ projects: number;
33
+ };
34
+ }, any>>;
35
+ /**
36
+ * Grant
37
+ */
38
+ grantsOf(grantee: Hex, withCommunity?: boolean): Promise<import("axios").AxiosResponse<IGrantResponse[], any>>;
39
+ grantsFor(uid: string, withCommunity?: boolean): Promise<import("axios").AxiosResponse<IGrantResponse[], any>>;
40
+ grantsForExtProject(projectExtId: string): Promise<import("axios").AxiosResponse<IGrantResponse[], any>>;
41
+ grantBySlug(slug: Hex): Promise<import("axios").AxiosResponse<IGrantResponse, any>>;
42
+ grantsByCommunity(uid: Hex, page?: number, pageLimit?: number): Promise<import("axios").AxiosResponse<{
43
+ data: IGrantResponse[];
44
+ }, any>>;
45
+ /**
46
+ * Milestone
47
+ */
48
+ milestonesOf(uid: Hex): Promise<import("axios").AxiosResponse<any, any>>;
49
+ slugExists(slug: string): Promise<boolean>;
50
+ /**
51
+ * Tracks
52
+ */
53
+ getTracks(communityUID: string, includeArchived?: boolean): Promise<import("axios").AxiosResponse<ITrackResponse[], any>>;
54
+ getTrackById(id: string): Promise<import("axios").AxiosResponse<ITrackResponse, any>>;
55
+ createTrack(data: {
56
+ name: string;
57
+ description?: string;
58
+ communityUID: string;
59
+ }): Promise<import("axios").AxiosResponse<ITrackResponse, any>>;
60
+ updateTrack(id: string, data: {
61
+ name?: string;
62
+ description?: string;
63
+ communityUID?: string;
64
+ }): Promise<import("axios").AxiosResponse<ITrackResponse, any>>;
65
+ archiveTrack(id: string): Promise<import("axios").AxiosResponse<ITrackResponse, any>>;
66
+ assignTracksToProgram(programId: string, trackIds: string[]): Promise<import("axios").AxiosResponse<ITrackAssignmentResponse[], any>>;
67
+ unassignTrackFromProgram(programId: string, trackId: string): Promise<import("axios").AxiosResponse<ITrackAssignmentResponse, any>>;
68
+ getTracksForProgram(programId: string): Promise<import("axios").AxiosResponse<ITrackResponse[], any>>;
69
+ getTracksForProject(projectId: string, programId: string, activeOnly?: boolean): Promise<import("axios").AxiosResponse<ITrackResponse[], any>>;
70
+ assignTracksToProject(projectId: string, programId: string, trackIds: string[]): Promise<import("axios").AxiosResponse<any[], any>>;
71
+ unassignTracksFromProject(projectId: string, programId: string, trackIds: string[]): Promise<import("axios").AxiosResponse<any[], any>>;
72
+ getProjectsByTrack(communityId: string, programId: string, trackId?: string): Promise<import("axios").AxiosResponse<IProjectTrackResponse[], any>>;
73
+ }
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GapIndexerApi = void 0;
4
+ const AxiosGQL_1 = require("../../GraphQL/AxiosGQL");
5
+ const Endpoints = {
6
+ attestations: {
7
+ all: () => "/attestations",
8
+ byUid: (uid) => `/attestations/${uid}`,
9
+ },
10
+ communities: {
11
+ all: () => "/communities",
12
+ admins: (uid) => `/communities/${uid}/admins`,
13
+ byUidOrSlug: (uidOrSlug) => `/communities/${uidOrSlug}`,
14
+ grants: (uidOrSlug, page = 0, pageLimit = 100) => `/communities/${uidOrSlug}/grants?${page ? `page=${page}` : ""}${pageLimit ? `&pageLimit=${pageLimit}` : ""}`,
15
+ },
16
+ grantees: {
17
+ all: () => "/grantees",
18
+ byAddress: (address) => `/grantees/${address}`,
19
+ grants: (address) => `/grantees/${address}/grants`,
20
+ projects: (address) => `/grantees/${address}/projects`,
21
+ communities: (address, withGrants) => `/grantees/${address}/communities${withGrants ? "?withGrants=true" : ""}`,
22
+ adminOf: (address) => `/grantees/${address}/communities/admin`,
23
+ },
24
+ grants: {
25
+ all: () => "/grants",
26
+ byUid: (uid) => `/grants/${uid}`,
27
+ byExternalId: (id) => `/grants/external-id/${id}`,
28
+ },
29
+ project: {
30
+ all: () => "/projects",
31
+ checkSlug: (slug) => `/projects/check-slug/${slug}`,
32
+ byUidOrSlug: (uidOrSlug) => `/projects/${uidOrSlug}`,
33
+ grants: (uidOrSlug) => `/projects/${uidOrSlug}/grants`,
34
+ milestones: (uidOrSlug) => `/projects/${uidOrSlug}/milestones`,
35
+ projectMilestones: (uidOrSlug) => `/projects/${uidOrSlug}/project-milestones`,
36
+ },
37
+ search: {
38
+ all: () => "/search",
39
+ },
40
+ tracks: {
41
+ all: () => "/tracks",
42
+ byId: (id) => `/tracks/${id}`,
43
+ byCommunity: (communityUID, includeArchived = false) => `/tracks?communityUID=${communityUID}${includeArchived ? "&includeArchived=true" : ""}`,
44
+ },
45
+ programs: {
46
+ tracks: {
47
+ all: (programId) => `/programs/${programId}/tracks`,
48
+ assign: (programId) => `/programs/${programId}/tracks`,
49
+ remove: (programId, trackId) => `/programs/${programId}/tracks/${trackId}`,
50
+ },
51
+ },
52
+ projectTracks: {
53
+ all: (projectId, programId, activeOnly = true) => `/programs/${programId}/projects/${projectId}/tracks${activeOnly ? "" : "?activeOnly=false"}`,
54
+ assign: (projectId) => `/projects/${projectId}/tracks`,
55
+ remove: (programId, projectId) => `/programs/${programId}/project/${projectId}/tracks`,
56
+ },
57
+ community: {
58
+ programProjects: (communityId, programId, trackId) => `/community/${communityId}/program/${programId}/projects${trackId ? `?trackId=${trackId}` : ""}`,
59
+ },
60
+ };
61
+ class GapIndexerApi extends AxiosGQL_1.AxiosGQL {
62
+ constructor(url) {
63
+ super(url);
64
+ }
65
+ async attestation(uid) {
66
+ const response = await this.client.get(Endpoints.attestations.byUid(uid));
67
+ return response;
68
+ }
69
+ async attestations(schemaUID, search) {
70
+ const response = await this.client.get(Endpoints.attestations.all(), {
71
+ params: {
72
+ "filter[schemaUID]": schemaUID,
73
+ "filter[data]": search,
74
+ },
75
+ });
76
+ return response;
77
+ }
78
+ async attestationsOf(schemaUID, attester) {
79
+ const response = await this.client.get(Endpoints.attestations.all(), {
80
+ params: {
81
+ "filter[schemaUID]": schemaUID,
82
+ "filter[recipient]": attester,
83
+ },
84
+ });
85
+ return response;
86
+ }
87
+ /**
88
+ * Community
89
+ */
90
+ async communities(search) {
91
+ const response = await this.client.get(Endpoints.communities.all(), {
92
+ params: {
93
+ "filter[name]": search,
94
+ },
95
+ });
96
+ return response;
97
+ }
98
+ async communitiesOf(address, withGrants) {
99
+ const response = await this.client.get(Endpoints.grantees.communities(address, withGrants));
100
+ return response;
101
+ }
102
+ async adminOf(address) {
103
+ const response = await this.client.get(Endpoints.grantees.adminOf(address));
104
+ return response;
105
+ }
106
+ async communityBySlug(slug) {
107
+ const response = await this.client.get(Endpoints.communities.byUidOrSlug(slug));
108
+ return response;
109
+ }
110
+ async communityAdmins(uid) {
111
+ const response = await this.client.get(Endpoints.communities.admins(uid));
112
+ return response;
113
+ }
114
+ /**
115
+ * Project
116
+ */
117
+ async projectBySlug(slug) {
118
+ const response = await this.client.get(Endpoints.project.byUidOrSlug(slug));
119
+ return response;
120
+ }
121
+ async search(query) {
122
+ const response = await this.client.get(Endpoints.search.all(), {
123
+ params: {
124
+ q: query,
125
+ },
126
+ });
127
+ return response;
128
+ }
129
+ async searchProjects(query) {
130
+ const response = await this.client.get(Endpoints.project.all(), {
131
+ params: {
132
+ q: query,
133
+ },
134
+ });
135
+ return response;
136
+ }
137
+ async projects(name) {
138
+ const response = await this.client.get(Endpoints.project.all(), {
139
+ params: {
140
+ "filter[title]": name,
141
+ },
142
+ });
143
+ return response;
144
+ }
145
+ async projectsOf(grantee) {
146
+ const response = await this.client.get(Endpoints.grantees.projects(grantee));
147
+ return response;
148
+ }
149
+ async projectMilestones(uidOrSlug) {
150
+ const response = await this.client.get(Endpoints.project.projectMilestones(uidOrSlug));
151
+ return response;
152
+ }
153
+ /**
154
+ * Grantee
155
+ */
156
+ async grantee(address) {
157
+ // TODO: update response type when the endpoint works
158
+ const response = await this.client.get(Endpoints.grantees.byAddress(address));
159
+ return response;
160
+ }
161
+ async grantees() {
162
+ const response = await this.client.get(Endpoints.grantees.all());
163
+ return response;
164
+ }
165
+ /**
166
+ * Grant
167
+ */
168
+ async grantsOf(grantee, withCommunity) {
169
+ const response = await this.client.get(Endpoints.grantees.grants(grantee));
170
+ return response;
171
+ }
172
+ async grantsFor(uid, withCommunity) {
173
+ const response = await this.client.get(Endpoints.project.grants(uid));
174
+ return response;
175
+ }
176
+ async grantsForExtProject(projectExtId) {
177
+ const response = await this.client.get(Endpoints.grants.byExternalId(projectExtId));
178
+ return response;
179
+ }
180
+ async grantBySlug(slug) {
181
+ const response = await this.client.get(Endpoints.grants.byUid(slug));
182
+ return response;
183
+ }
184
+ async grantsByCommunity(uid, page = 0, pageLimit = 100) {
185
+ const response = await this.client.get(Endpoints.communities.grants(uid, page, pageLimit));
186
+ return response;
187
+ }
188
+ /**
189
+ * Milestone
190
+ */
191
+ async milestonesOf(uid) {
192
+ const response = await this.client.get(Endpoints.project.milestones(uid));
193
+ return response;
194
+ }
195
+ async slugExists(slug) {
196
+ try {
197
+ await this.client.get(Endpoints.project.checkSlug(slug));
198
+ return true;
199
+ }
200
+ catch (err) {
201
+ return false;
202
+ }
203
+ }
204
+ /**
205
+ * Tracks
206
+ */
207
+ async getTracks(communityUID, includeArchived = false) {
208
+ const response = await this.client.get(Endpoints.tracks.byCommunity(communityUID, includeArchived));
209
+ return response;
210
+ }
211
+ async getTrackById(id) {
212
+ const response = await this.client.get(Endpoints.tracks.byId(id));
213
+ return response;
214
+ }
215
+ async createTrack(data) {
216
+ const response = await this.client.post(Endpoints.tracks.all(), data);
217
+ return response;
218
+ }
219
+ async updateTrack(id, data) {
220
+ const response = await this.client.put(Endpoints.tracks.byId(id), data);
221
+ return response;
222
+ }
223
+ async archiveTrack(id) {
224
+ const response = await this.client.delete(Endpoints.tracks.byId(id));
225
+ return response;
226
+ }
227
+ async assignTracksToProgram(programId, trackIds) {
228
+ const response = await this.client.post(Endpoints.programs.tracks.assign(programId), { trackIds });
229
+ return response;
230
+ }
231
+ async unassignTrackFromProgram(programId, trackId) {
232
+ const response = await this.client.delete(Endpoints.programs.tracks.remove(programId, trackId));
233
+ return response;
234
+ }
235
+ async getTracksForProgram(programId) {
236
+ const response = await this.client.get(Endpoints.programs.tracks.all(programId));
237
+ return response;
238
+ }
239
+ async getTracksForProject(projectId, programId, activeOnly = true) {
240
+ const response = await this.client.get(Endpoints.projectTracks.all(projectId, programId, activeOnly));
241
+ return response;
242
+ }
243
+ async assignTracksToProject(projectId, programId, trackIds) {
244
+ const response = await this.client.post(Endpoints.projectTracks.assign(projectId), { trackIds, programId });
245
+ return response;
246
+ }
247
+ async unassignTracksFromProject(projectId, programId, trackIds) {
248
+ const response = await this.client.delete(Endpoints.projectTracks.remove(programId, projectId), { data: { trackIds } });
249
+ return response;
250
+ }
251
+ async getProjectsByTrack(communityId, programId, trackId) {
252
+ const response = await this.client.get(Endpoints.community.programProjects(communityId, programId, trackId));
253
+ return response;
254
+ }
255
+ }
256
+ exports.GapIndexerApi = GapIndexerApi;