@show-karma/karma-gap-sdk 0.4.15 → 0.4.16
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/.cursorrules +43 -0
- package/core/abi/AirdropNFT.json +1 -1
- package/core/abi/Allo.json +860 -860
- package/core/abi/AlloRegistry.json +578 -578
- package/core/abi/CommunityResolverABI.json +506 -506
- package/core/abi/Donations.json +251 -251
- package/core/abi/EAS.json +1 -1
- package/core/abi/MultiAttester.json +746 -746
- package/core/abi/ProjectResolver.json +574 -574
- package/core/abi/SchemaRegistry.json +1 -1
- package/core/abi/index.ts +21 -0
- package/core/class/AllGapSchemas.ts +21 -0
- package/core/class/Attestation.ts +429 -0
- package/core/class/Fetcher.ts +224 -0
- package/core/class/GAP.ts +481 -0
- package/core/class/GapSchema.ts +93 -0
- package/core/class/Gelato/{Gelato.js → Gelato.ts} +23 -0
- package/core/class/GrantProgramRegistry/Allo.ts +188 -0
- package/core/class/GrantProgramRegistry/AlloRegistry.ts +101 -0
- package/core/class/GraphQL/AxiosGQL.ts +29 -0
- package/core/class/GraphQL/EASClient.ts +34 -0
- package/core/class/GraphQL/GapEasClient.ts +869 -0
- package/core/class/Schema.ts +659 -0
- package/core/class/SchemaError.ts +42 -0
- package/core/class/contract/GapContract.ts +457 -0
- package/core/class/entities/Community.ts +148 -0
- package/core/class/entities/ContributorProfile.ts +108 -0
- package/core/class/entities/Grant.ts +321 -0
- package/core/class/entities/GrantUpdate.ts +187 -0
- package/core/class/entities/MemberOf.ts +52 -0
- package/core/class/entities/Milestone.ts +898 -0
- package/core/class/entities/Project.ts +672 -0
- package/core/class/entities/ProjectImpact.ts +170 -0
- package/core/class/entities/ProjectMilestone.ts +254 -0
- package/core/class/entities/ProjectPointer.ts +39 -0
- package/core/class/entities/ProjectUpdate.ts +176 -0
- package/core/class/entities/Track.ts +32 -0
- package/core/class/karma-indexer/GapIndexerClient.ts +383 -0
- package/core/class/karma-indexer/api/GapIndexerApi.ts +446 -0
- package/core/class/karma-indexer/api/types.ts +313 -0
- package/core/class/remote-storage/IpfsStorage.ts +76 -0
- package/core/class/remote-storage/RemoteStorage.ts +65 -0
- package/core/class/types/allo.ts +93 -0
- package/core/class/types/attestations.ts +223 -0
- package/core/consts.ts +775 -0
- package/core/scripts/create-grant.ts +102 -0
- package/core/scripts/create-program.ts +43 -0
- package/core/scripts/create-schemas.ts +65 -0
- package/core/scripts/deploy.ts +65 -0
- package/core/scripts/index.ts +1 -0
- package/core/scripts/milestone-multi-grants.ts +125 -0
- package/core/shared/types.ts +13 -0
- package/core/types.ts +224 -0
- package/core/utils/gelato/send-gelato-txn.ts +114 -0
- package/core/utils/gelato/sponsor-handler.ts +77 -0
- package/core/utils/gelato/watch-gelato-txn.ts +67 -0
- package/core/utils/get-date.ts +3 -0
- package/core/utils/get-ipfs-data.ts +13 -0
- package/core/utils/get-web3-provider.ts +18 -0
- package/core/utils/gql-queries.ts +133 -0
- package/core/utils/map-filter.ts +21 -0
- package/core/utils/serialize-bigint.ts +7 -0
- package/core/utils/to-unix.ts +18 -0
- package/create-community-example.ts +119 -0
- package/csv-upload/README.md +74 -0
- package/csv-upload/config.ts +41 -0
- package/csv-upload/example.csv +2 -0
- package/csv-upload/keys.example.json +8 -0
- package/csv-upload/scripts/run.ts +417 -0
- package/csv-upload/types.ts +39 -0
- package/docs/.gitkeep +0 -0
- package/docs/images/attestation-architecture.png +0 -0
- package/docs/images/dfd-get-projects.png +0 -0
- package/gap-schema.yaml +155 -0
- package/milestone-workflow-example.ts +353 -0
- package/package.json +45 -39
- package/readme.md +872 -0
- package/schemas/.gitkeep +0 -0
- package/schemas/GAP-schemas-1692135812877.json +33 -0
- package/test-file-indexer-api.ts +25 -0
- package/tsconfig.json +26 -0
- package/core/abi/index.d.ts +0 -1114
- package/core/abi/index.js +0 -26
- package/core/class/AllGapSchemas.d.ts +0 -9
- package/core/class/AllGapSchemas.js +0 -19
- package/core/class/Attestation.d.ts +0 -173
- package/core/class/Attestation.js +0 -333
- package/core/class/Fetcher.d.ts +0 -175
- package/core/class/Fetcher.js +0 -13
- package/core/class/GAP.d.ts +0 -254
- package/core/class/GAP.js +0 -289
- package/core/class/GapSchema.d.ts +0 -34
- package/core/class/GapSchema.js +0 -62
- package/core/class/GrantProgramRegistry/Allo.d.ts +0 -17
- package/core/class/GrantProgramRegistry/Allo.js +0 -137
- package/core/class/GrantProgramRegistry/AlloRegistry.d.ts +0 -15
- package/core/class/GrantProgramRegistry/AlloRegistry.js +0 -70
- package/core/class/GraphQL/AxiosGQL.d.ts +0 -6
- package/core/class/GraphQL/AxiosGQL.js +0 -25
- package/core/class/GraphQL/EASClient.d.ts +0 -16
- package/core/class/GraphQL/EASClient.js +0 -26
- package/core/class/GraphQL/GapEasClient.d.ts +0 -71
- package/core/class/GraphQL/GapEasClient.js +0 -451
- package/core/class/GraphQL/index.js +0 -19
- package/core/class/Schema.d.ts +0 -233
- package/core/class/Schema.js +0 -488
- package/core/class/SchemaError.d.ts +0 -30
- package/core/class/SchemaError.js +0 -39
- package/core/class/contract/GapContract.d.ts +0 -102
- package/core/class/contract/GapContract.js +0 -285
- package/core/class/entities/Community.d.ts +0 -34
- package/core/class/entities/Community.js +0 -109
- package/core/class/entities/ContributorProfile.d.ts +0 -41
- package/core/class/entities/ContributorProfile.js +0 -69
- package/core/class/entities/Grant.d.ts +0 -54
- package/core/class/entities/Grant.js +0 -223
- package/core/class/entities/GrantUpdate.d.ts +0 -40
- package/core/class/entities/GrantUpdate.js +0 -114
- package/core/class/entities/MemberOf.d.ts +0 -11
- package/core/class/entities/MemberOf.js +0 -33
- package/core/class/entities/Milestone.d.ts +0 -168
- package/core/class/entities/Milestone.js +0 -657
- package/core/class/entities/Project.d.ts +0 -92
- package/core/class/entities/Project.js +0 -418
- package/core/class/entities/ProjectImpact.d.ts +0 -50
- package/core/class/entities/ProjectImpact.js +0 -112
- package/core/class/entities/ProjectMilestone.d.ts +0 -60
- package/core/class/entities/ProjectMilestone.js +0 -174
- package/core/class/entities/ProjectPointer.d.ts +0 -12
- package/core/class/entities/ProjectPointer.js +0 -22
- package/core/class/entities/ProjectUpdate.d.ts +0 -50
- package/core/class/entities/ProjectUpdate.js +0 -110
- package/core/class/entities/Track.d.ts +0 -16
- package/core/class/entities/Track.js +0 -21
- package/core/class/entities/index.js +0 -26
- package/core/class/index.js +0 -26
- package/core/class/karma-indexer/GapIndexerClient.d.ts +0 -66
- package/core/class/karma-indexer/GapIndexerClient.js +0 -207
- package/core/class/karma-indexer/api/GapIndexerApi.d.ts +0 -73
- package/core/class/karma-indexer/api/GapIndexerApi.js +0 -256
- package/core/class/karma-indexer/api/types.d.ts +0 -295
- package/core/class/karma-indexer/api/types.js +0 -2
- package/core/class/remote-storage/IpfsStorage.d.ts +0 -23
- package/core/class/remote-storage/IpfsStorage.js +0 -56
- package/core/class/remote-storage/RemoteStorage.d.ts +0 -41
- package/core/class/remote-storage/RemoteStorage.js +0 -38
- package/core/class/types/allo.d.ts +0 -78
- package/core/class/types/allo.js +0 -2
- package/core/class/types/attestations.d.ts +0 -168
- package/core/class/types/attestations.js +0 -66
- package/core/consts.d.ts +0 -48
- package/core/consts.js +0 -641
- package/core/index.js +0 -24
- package/core/shared/types.d.ts +0 -6
- package/core/shared/types.js +0 -2
- package/core/types.d.ts +0 -131
- package/core/types.js +0 -13
- package/core/utils/gelato/index.js +0 -19
- package/core/utils/gelato/send-gelato-txn.d.ts +0 -55
- package/core/utils/gelato/send-gelato-txn.js +0 -100
- package/core/utils/gelato/sponsor-handler.d.ts +0 -9
- package/core/utils/gelato/sponsor-handler.js +0 -60
- package/core/utils/gelato/watch-gelato-txn.d.ts +0 -7
- package/core/utils/gelato/watch-gelato-txn.js +0 -63
- package/core/utils/get-date.d.ts +0 -1
- package/core/utils/get-date.js +0 -7
- package/core/utils/get-ipfs-data.d.ts +0 -1
- package/core/utils/get-ipfs-data.js +0 -20
- package/core/utils/get-web3-provider.d.ts +0 -2
- package/core/utils/get-web3-provider.js +0 -18
- package/core/utils/gql-queries.d.ts +0 -12
- package/core/utils/gql-queries.js +0 -90
- package/core/utils/index.js +0 -23
- package/core/utils/map-filter.d.ts +0 -8
- package/core/utils/map-filter.js +0 -20
- package/core/utils/serialize-bigint.d.ts +0 -1
- package/core/utils/serialize-bigint.js +0 -8
- package/core/utils/to-unix.d.ts +0 -1
- package/core/utils/to-unix.js +0 -25
- package/index.js +0 -17
- /package/core/class/GraphQL/{index.d.ts → index.ts} +0 -0
- /package/core/class/entities/{index.d.ts → index.ts} +0 -0
- /package/core/class/{index.d.ts → index.ts} +0 -0
- /package/core/{index.d.ts → index.ts} +0 -0
- /package/core/utils/gelato/{index.d.ts → index.ts} +0 -0
- /package/core/utils/{index.d.ts → index.ts} +0 -0
- /package/{core/class/Gelato/Gelato.d.ts → csv-upload/.gitkeep} +0 -0
- /package/{index.d.ts → index.ts} +0 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { TSchemaName, IAttestation, TNetwork, Hex } from "core/types";
|
|
2
|
+
import { Attestation } from "../Attestation";
|
|
3
|
+
import { GapSchema } from "../GapSchema";
|
|
4
|
+
import { Fetcher } from "../Fetcher";
|
|
5
|
+
import {
|
|
6
|
+
Community,
|
|
7
|
+
Project,
|
|
8
|
+
Grant,
|
|
9
|
+
Milestone,
|
|
10
|
+
MemberOf,
|
|
11
|
+
Track,
|
|
12
|
+
} from "../entities";
|
|
13
|
+
import { Grantee } from "../types/attestations";
|
|
14
|
+
import { GapIndexerApi } from "./api/GapIndexerApi";
|
|
15
|
+
import { ICommunityAdminsResponse, ICommunityResponse } from "./api/types";
|
|
16
|
+
import { ProjectMilestone } from "../entities/ProjectMilestone";
|
|
17
|
+
|
|
18
|
+
const Endpoints = {
|
|
19
|
+
attestations: {
|
|
20
|
+
all: () => "/attestations",
|
|
21
|
+
byUid: (uid: Hex) => `/attestations/${uid}`,
|
|
22
|
+
},
|
|
23
|
+
communities: {
|
|
24
|
+
all: () => "/communities",
|
|
25
|
+
byUidOrSlug: (uidOrSlug: string) => `/communities/${uidOrSlug}`,
|
|
26
|
+
grants: (uidOrSlug: string) => `/communities/${uidOrSlug}/grants`,
|
|
27
|
+
},
|
|
28
|
+
grantees: {
|
|
29
|
+
all: () => "/grantees",
|
|
30
|
+
byAddress: (address: Hex) => `/grantees/${address}`,
|
|
31
|
+
grants: (address: Hex) => `/grantees/${address}/grants`,
|
|
32
|
+
projects: (address: Hex) => `/grantees/${address}/projects`,
|
|
33
|
+
communities: (address: Hex, withGrants) =>
|
|
34
|
+
`/grantees/${address}/communities${withGrants ? "?withGrants=true" : ""}`,
|
|
35
|
+
communitiesAdmin: (address: Hex, withGrants) =>
|
|
36
|
+
`/grantees/${address}/communities/admin${
|
|
37
|
+
withGrants ? "?withGrants=true" : ""
|
|
38
|
+
}`,
|
|
39
|
+
},
|
|
40
|
+
grants: {
|
|
41
|
+
all: () => "/grants",
|
|
42
|
+
byUid: (uid: Hex) => `/grants/${uid}`,
|
|
43
|
+
byExternalId: (id: string) => `/grants/external-id/${id}`,
|
|
44
|
+
},
|
|
45
|
+
project: {
|
|
46
|
+
all: () => "/projects",
|
|
47
|
+
byUidOrSlug: (uidOrSlug: string) => `/projects/${uidOrSlug}`,
|
|
48
|
+
grants: (uidOrSlug: string) => `/projects/${uidOrSlug}/grants`,
|
|
49
|
+
milestones: (uidOrSlug: string) => `/projects/${uidOrSlug}/milestones`,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export class GapIndexerClient extends Fetcher {
|
|
54
|
+
private apiClient: GapIndexerApi;
|
|
55
|
+
constructor(params) {
|
|
56
|
+
super(params);
|
|
57
|
+
this.apiClient = new GapIndexerApi(params);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async attestation<T = unknown>(
|
|
61
|
+
uid: `0x${string}`
|
|
62
|
+
): Promise<Attestation<T, GapSchema>> {
|
|
63
|
+
const { data } = await this.apiClient.attestation(uid);
|
|
64
|
+
|
|
65
|
+
if (!data) throw new Error("Attestation not found");
|
|
66
|
+
return Attestation.fromInterface<Attestation<T>>(
|
|
67
|
+
[data],
|
|
68
|
+
this.gap.network
|
|
69
|
+
)[0];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async attestations(
|
|
73
|
+
schemaName: TSchemaName,
|
|
74
|
+
search?: string
|
|
75
|
+
): Promise<IAttestation[]> {
|
|
76
|
+
const schemaUID = this.gap.findSchema(schemaName).uid;
|
|
77
|
+
const { data } = await this.apiClient.attestations(schemaUID, search);
|
|
78
|
+
|
|
79
|
+
return data || [];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async attestationsOf(
|
|
83
|
+
schemaName: TSchemaName,
|
|
84
|
+
attester: `0x${string}`
|
|
85
|
+
): Promise<IAttestation[]> {
|
|
86
|
+
const schemaUID = this.gap.findSchema(schemaName).uid;
|
|
87
|
+
const { data } = await this.apiClient.attestationsOf(schemaUID, attester);
|
|
88
|
+
|
|
89
|
+
return data || [];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
attestationsTo(
|
|
93
|
+
schemaName: TSchemaName,
|
|
94
|
+
recipient: `0x${string}`
|
|
95
|
+
): Promise<IAttestation[]> {
|
|
96
|
+
return this.attestationsOf(schemaName, recipient);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async communities(search?: string): Promise<Community[]> {
|
|
100
|
+
const { data } = await this.apiClient.communities(search);
|
|
101
|
+
|
|
102
|
+
return Community.from(data, this.gap.network);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async communitiesOf(address: Hex, withGrants: boolean): Promise<Community[]> {
|
|
106
|
+
const { data } = await this.apiClient.communitiesOf(address, withGrants);
|
|
107
|
+
|
|
108
|
+
return Community.from(data, this.gap.network);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async adminOf(address: Hex): Promise<Community[]> {
|
|
112
|
+
const { data } = await this.apiClient.adminOf(address);
|
|
113
|
+
|
|
114
|
+
return Community.from(data, this.gap.network);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async communitiesAdminOf(
|
|
118
|
+
address: Hex,
|
|
119
|
+
withGrants: boolean
|
|
120
|
+
): Promise<Community[]> {
|
|
121
|
+
const { data } = await this.client.get<Community[]>(
|
|
122
|
+
Endpoints.grantees.communitiesAdmin(address, withGrants)
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
return Community.from(
|
|
126
|
+
data as any as ICommunityResponse[],
|
|
127
|
+
this.gap.network
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
communitiesByIds(uids: `0x${string}`[]): Promise<Community[]> {
|
|
132
|
+
throw new Error("Method not implemented.");
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async communityBySlug(slug: string): Promise<Community> {
|
|
136
|
+
const { data } = await this.apiClient.communityBySlug(slug);
|
|
137
|
+
|
|
138
|
+
return Community.from([data], this.gap.network)[0];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
communityById(uid: `0x${string}`): Promise<Community> {
|
|
142
|
+
return this.communityBySlug(uid);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async communityAdmins(uid: `0x${string}`): Promise<ICommunityAdminsResponse> {
|
|
146
|
+
const { data } = await this.apiClient.communityAdmins(uid);
|
|
147
|
+
return data;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async projectBySlug(slug: string): Promise<Project> {
|
|
151
|
+
const { data } = await this.apiClient.projectBySlug(slug);
|
|
152
|
+
|
|
153
|
+
return Project.from([data], this.gap.network)[0];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
projectById(uid: `0x${string}`): Promise<Project> {
|
|
157
|
+
return this.projectBySlug(uid);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async search(
|
|
161
|
+
query: string
|
|
162
|
+
): Promise<{ projects: Project[]; communities: Community[] }> {
|
|
163
|
+
const { data } = await this.apiClient.search(query);
|
|
164
|
+
|
|
165
|
+
return { data } as unknown as {
|
|
166
|
+
projects: Project[];
|
|
167
|
+
communities: Community[];
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async searchProjects(query: string): Promise<Project[]> {
|
|
172
|
+
const { data } = await this.apiClient.searchProjects(query);
|
|
173
|
+
|
|
174
|
+
return Project.from(data, this.gap.network);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async projects(name?: string): Promise<Project[]> {
|
|
178
|
+
const { data } = await this.apiClient.projects(name);
|
|
179
|
+
|
|
180
|
+
return Project.from(data, this.gap.network);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async projectsOf(grantee: `0x${string}`): Promise<Project[]> {
|
|
184
|
+
const { data } = await this.apiClient.projectsOf(grantee);
|
|
185
|
+
|
|
186
|
+
return Project.from(data, this.gap.network);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async projectMilestones(uidOrSlug: string): Promise<ProjectMilestone[]> {
|
|
190
|
+
const { data } = await this.apiClient.projectMilestones(uidOrSlug);
|
|
191
|
+
|
|
192
|
+
return ProjectMilestone.from(data, this.gap.network);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async grantee(address: `0x${string}`): Promise<Grantee> {
|
|
196
|
+
const { data } = await this.apiClient.grantee(address);
|
|
197
|
+
|
|
198
|
+
return data as Grantee;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async grantees(): Promise<Grantee[]> {
|
|
202
|
+
const { data } = await this.apiClient.grantees();
|
|
203
|
+
|
|
204
|
+
return data as any as Grantee[]; // TODO: Remove this casting after the api is fixed
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async grantsOf(
|
|
208
|
+
grantee: `0x${string}`,
|
|
209
|
+
withCommunity?: boolean
|
|
210
|
+
): Promise<Grant[]> {
|
|
211
|
+
const { data } = await this.apiClient.grantsOf(grantee, withCommunity);
|
|
212
|
+
|
|
213
|
+
return Grant.from(data, this.gap.network);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
async grantsFor(
|
|
217
|
+
projects: Project[],
|
|
218
|
+
withCommunity?: boolean
|
|
219
|
+
): Promise<Grant[]> {
|
|
220
|
+
const { data } = await this.apiClient.grantsFor(
|
|
221
|
+
projects[0].uid,
|
|
222
|
+
withCommunity
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
return Grant.from(data, this.gap.network);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
async grantsForExtProject(projectExtId: string): Promise<Grant[]> {
|
|
229
|
+
const { data } = await this.apiClient.grantsForExtProject(projectExtId);
|
|
230
|
+
|
|
231
|
+
return Grant.from(data, this.gap.network);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
async grantsByCommunity(
|
|
235
|
+
uid: `0x${string}`,
|
|
236
|
+
page: number = 0,
|
|
237
|
+
pageLimit: number = 100
|
|
238
|
+
) {
|
|
239
|
+
const { data } = await this.apiClient.grantsByCommunity(
|
|
240
|
+
uid,
|
|
241
|
+
page,
|
|
242
|
+
pageLimit
|
|
243
|
+
);
|
|
244
|
+
const grants = data.data;
|
|
245
|
+
|
|
246
|
+
return Grant.from(grants, this.gap.network);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
async milestonesOf(grants: Grant[]): Promise<Milestone[]> {
|
|
250
|
+
const { data } = await this.apiClient.milestonesOf(grants[0].uid);
|
|
251
|
+
|
|
252
|
+
return Milestone.from(data, this.gap.network);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
async membersOf(projects: Project[]): Promise<MemberOf[]> {
|
|
256
|
+
throw new Error("Method not implemented.");
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
async slugExists(slug: string): Promise<boolean> {
|
|
260
|
+
return await this.apiClient.slugExists(slug);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Track related methods
|
|
265
|
+
*/
|
|
266
|
+
|
|
267
|
+
async getTracks(
|
|
268
|
+
communityUID: string,
|
|
269
|
+
includeArchived: boolean = false
|
|
270
|
+
): Promise<Track[]> {
|
|
271
|
+
const { data } = await this.apiClient.getTracks(
|
|
272
|
+
communityUID,
|
|
273
|
+
includeArchived
|
|
274
|
+
);
|
|
275
|
+
return Track.from(data, this.gap.network);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
async getTrackById(id: string): Promise<Track> {
|
|
279
|
+
const { data } = await this.apiClient.getTrackById(id);
|
|
280
|
+
return Track.from([data], this.gap.network)[0];
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
async createTrack(trackData: {
|
|
284
|
+
name: string;
|
|
285
|
+
description?: string;
|
|
286
|
+
communityUID: string;
|
|
287
|
+
}): Promise<Track> {
|
|
288
|
+
const { data } = await this.apiClient.createTrack(trackData);
|
|
289
|
+
return Track.from([data], this.gap.network)[0];
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
async updateTrack(
|
|
293
|
+
id: string,
|
|
294
|
+
trackData: { name?: string; description?: string; communityUID?: string }
|
|
295
|
+
): Promise<Track> {
|
|
296
|
+
const { data } = await this.apiClient.updateTrack(id, trackData);
|
|
297
|
+
return Track.from([data], this.gap.network)[0];
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async archiveTrack(id: string): Promise<Track> {
|
|
301
|
+
const { data } = await this.apiClient.archiveTrack(id);
|
|
302
|
+
return Track.from([data], this.gap.network)[0];
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
async assignTracksToProgram(
|
|
306
|
+
programId: string,
|
|
307
|
+
trackIds: string[]
|
|
308
|
+
): Promise<any[]> {
|
|
309
|
+
const { data } = await this.apiClient.assignTracksToProgram(
|
|
310
|
+
programId,
|
|
311
|
+
trackIds
|
|
312
|
+
);
|
|
313
|
+
return data;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
async unassignTrackFromProgram(
|
|
317
|
+
programId: string,
|
|
318
|
+
trackId: string
|
|
319
|
+
): Promise<any> {
|
|
320
|
+
const { data } = await this.apiClient.unassignTrackFromProgram(
|
|
321
|
+
programId,
|
|
322
|
+
trackId
|
|
323
|
+
);
|
|
324
|
+
return data;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
async getTracksForProgram(programId: string): Promise<Track[]> {
|
|
328
|
+
const { data } = await this.apiClient.getTracksForProgram(programId);
|
|
329
|
+
return Track.from(data, this.gap.network);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
async getTracksForProject(
|
|
333
|
+
projectId: string,
|
|
334
|
+
programId: string,
|
|
335
|
+
activeOnly: boolean = true
|
|
336
|
+
): Promise<Track[]> {
|
|
337
|
+
const { data } = await this.apiClient.getTracksForProject(
|
|
338
|
+
projectId,
|
|
339
|
+
programId,
|
|
340
|
+
activeOnly
|
|
341
|
+
);
|
|
342
|
+
return Track.from(data, this.gap.network);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
async assignTracksToProject(
|
|
346
|
+
projectId: string,
|
|
347
|
+
programId: string,
|
|
348
|
+
trackIds: string[]
|
|
349
|
+
): Promise<any[]> {
|
|
350
|
+
const { data } = await this.apiClient.assignTracksToProject(
|
|
351
|
+
projectId,
|
|
352
|
+
programId,
|
|
353
|
+
trackIds
|
|
354
|
+
);
|
|
355
|
+
return data;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
async unassignTracksFromProject(
|
|
359
|
+
projectId: string,
|
|
360
|
+
programId: string,
|
|
361
|
+
trackIds: string[]
|
|
362
|
+
): Promise<any[]> {
|
|
363
|
+
const { data } = await this.apiClient.unassignTracksFromProject(
|
|
364
|
+
projectId,
|
|
365
|
+
programId,
|
|
366
|
+
trackIds
|
|
367
|
+
);
|
|
368
|
+
return data;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
async getProjectsByTrack(
|
|
372
|
+
communityId: string,
|
|
373
|
+
programId: string,
|
|
374
|
+
trackId?: string
|
|
375
|
+
): Promise<any[]> {
|
|
376
|
+
const { data } = await this.apiClient.getProjectsByTrack(
|
|
377
|
+
communityId,
|
|
378
|
+
programId,
|
|
379
|
+
trackId
|
|
380
|
+
);
|
|
381
|
+
return data;
|
|
382
|
+
}
|
|
383
|
+
}
|