@hashgraphonline/standards-sdk 0.1.166 → 0.1.167

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.
@@ -1,76 +1,553 @@
1
- import BigNumber from "bignumber.js";
2
- const TINYBAR_DIVISOR = 1e8;
3
- function safePositiveTransfers(transfers) {
4
- if (!Array.isArray(transfers)) {
5
- return [];
6
- }
7
- return transfers.filter(
8
- (transfer) => typeof transfer.amount === "number" && transfer.amount > 0
9
- ).map((transfer) => ({
10
- account: transfer.account,
11
- amountTinybar: transfer.amount
12
- }));
13
- }
14
- function resolvePayerDebitTinybar(transfers, payerAccountId) {
15
- if (!Array.isArray(transfers)) {
16
- return null;
17
- }
18
- const payerDebit = transfers.find(
19
- (transfer) => transfer.account === payerAccountId && typeof transfer.amount === "number" && transfer.amount < 0
20
- );
21
- if (!payerDebit || typeof payerDebit.amount !== "number") {
22
- return null;
23
- }
24
- return Math.abs(payerDebit.amount);
25
- }
26
- function toHbarString(tinybar) {
27
- return new BigNumber(tinybar).dividedBy(TINYBAR_DIVISOR).toFixed();
28
- }
29
- function fallbackFeeTinybar(chargedTxFee) {
30
- if (typeof chargedTxFee !== "number" || !Number.isFinite(chargedTxFee)) {
31
- return null;
32
- }
33
- if (chargedTxFee <= 0) {
34
- return null;
35
- }
36
- return chargedTxFee;
37
- }
38
- function computeInscriptionCostSummary(params) {
39
- const { txn, payerAccountId } = params;
40
- const positiveTransfers = safePositiveTransfers(txn.transfers);
41
- const payerDebitTinybar = resolvePayerDebitTinybar(
42
- txn.transfers,
43
- payerAccountId
44
- );
45
- const transferOutflowTinybar = payerDebitTinybar ?? positiveTransfers.reduce((sum, t) => sum + t.amountTinybar, 0);
46
- const chargedFeeTinybar = fallbackFeeTinybar(txn.charged_tx_fee);
47
- const resolvedTotalTinybar = transferOutflowTinybar > 0 ? transferOutflowTinybar : chargedFeeTinybar;
48
- if (!resolvedTotalTinybar || resolvedTotalTinybar <= 0) {
49
- return null;
50
- }
51
- const totalCostHbar = toHbarString(resolvedTotalTinybar);
52
- const breakdownTransfers = positiveTransfers.length > 0 ? positiveTransfers.map((transfer) => ({
53
- to: transfer.account,
54
- amount: toHbarString(transfer.amountTinybar),
55
- description: `HBAR transfer from ${payerAccountId}`
56
- })) : [
1
+ import { skillRegistryConfigResponseSchema, skillRegistryListResponseSchema, skillSecurityBreakdownResponseSchema, skillCatalogResponseSchema, skillRegistryVersionsResponseSchema, skillRegistryMineResponseSchema, skillRegistryMyListResponseSchema, skillRegistryQuoteResponseSchema, skillRegistryPublishResponseSchema, skillRegistryJobStatusResponseSchema, skillRegistryOwnershipResponseSchema, skillRecommendedVersionResponseSchema, skillDeprecationsResponseSchema, skillDeprecationRecordSchema, skillBadgeResponseSchema, skillRegistryTagsResponseSchema, skillRegistryCategoriesResponseSchema, skillResolverManifestResponseSchema, skillRegistryVoteStatusResponseSchema, skillVerificationRequestCreateResponseSchema, skillVerificationStatusResponseSchema, skillVerificationDomainProofChallengeResponseSchema, skillVerificationDomainProofVerifyResponseSchema } from "./standards-sdk.es140.js";
2
+ async function skillsConfig(client) {
3
+ const raw = await client.requestJson("/skills/config", {
4
+ method: "GET"
5
+ });
6
+ return client.parseWithSchema(
7
+ raw,
8
+ skillRegistryConfigResponseSchema,
9
+ "skill registry config response"
10
+ );
11
+ }
12
+ async function listSkills(client, params = {}) {
13
+ const query = new URLSearchParams();
14
+ if (params.name) {
15
+ query.set("name", params.name);
16
+ }
17
+ if (params.version) {
18
+ query.set("version", params.version);
19
+ }
20
+ if (typeof params.limit === "number" && Number.isFinite(params.limit)) {
21
+ query.set("limit", String(Math.trunc(params.limit)));
22
+ }
23
+ if (params.cursor) {
24
+ query.set("cursor", params.cursor);
25
+ }
26
+ if (typeof params.includeFiles === "boolean") {
27
+ query.set("includeFiles", params.includeFiles ? "true" : "false");
28
+ }
29
+ if (params.accountId) {
30
+ query.set("accountId", params.accountId);
31
+ }
32
+ if (params.q) {
33
+ query.set("q", params.q);
34
+ }
35
+ if (params.tag) {
36
+ query.set("tag", params.tag);
37
+ }
38
+ if (params.category) {
39
+ query.set("category", params.category);
40
+ }
41
+ if (typeof params.featured === "boolean") {
42
+ query.set("featured", params.featured ? "true" : "false");
43
+ }
44
+ if (typeof params.verified === "boolean") {
45
+ query.set("verified", params.verified ? "true" : "false");
46
+ }
47
+ if (params.view) {
48
+ query.set("view", params.view);
49
+ }
50
+ const suffix = query.size > 0 ? `?${query.toString()}` : "";
51
+ const raw = await client.requestJson(`/skills${suffix}`, {
52
+ method: "GET"
53
+ });
54
+ return client.parseWithSchema(
55
+ raw,
56
+ skillRegistryListResponseSchema,
57
+ "skill registry list response"
58
+ );
59
+ }
60
+ async function getSkillSecurityBreakdown(client, params) {
61
+ const normalizedJobId = params.jobId.trim();
62
+ if (!normalizedJobId) {
63
+ throw new Error("jobId is required");
64
+ }
65
+ const raw = await client.requestJson(
66
+ `/skills/${encodeURIComponent(normalizedJobId)}/security-breakdown`,
67
+ { method: "GET" }
68
+ );
69
+ return client.parseWithSchema(
70
+ raw,
71
+ skillSecurityBreakdownResponseSchema,
72
+ "skill security breakdown response"
73
+ );
74
+ }
75
+ async function getSkillsCatalog(client, params = {}) {
76
+ const query = new URLSearchParams();
77
+ if (params.q) {
78
+ query.set("q", params.q);
79
+ }
80
+ if (params.category) {
81
+ query.set("category", params.category);
82
+ }
83
+ params.tags?.forEach((tag) => {
84
+ if (tag.trim()) {
85
+ query.append("tag", tag.trim());
86
+ }
87
+ });
88
+ if (typeof params.featured === "boolean") {
89
+ query.set("featured", params.featured ? "true" : "false");
90
+ }
91
+ if (typeof params.verified === "boolean") {
92
+ query.set("verified", params.verified ? "true" : "false");
93
+ }
94
+ if (params.channel) {
95
+ query.set("channel", params.channel);
96
+ }
97
+ if (params.sortBy) {
98
+ query.set("sortBy", params.sortBy);
99
+ }
100
+ if (typeof params.limit === "number" && Number.isFinite(params.limit)) {
101
+ query.set("limit", String(Math.trunc(params.limit)));
102
+ }
103
+ if (params.cursor) {
104
+ query.set("cursor", params.cursor);
105
+ }
106
+ const suffix = query.size > 0 ? `?${query.toString()}` : "";
107
+ const raw = await client.requestJson(`/skills/catalog${suffix}`, {
108
+ method: "GET"
109
+ });
110
+ return client.parseWithSchema(
111
+ raw,
112
+ skillCatalogResponseSchema,
113
+ "skill catalog response"
114
+ );
115
+ }
116
+ async function listSkillVersions(client, params) {
117
+ const normalizedName = params.name.trim();
118
+ if (!normalizedName) {
119
+ throw new Error("name is required");
120
+ }
121
+ const query = new URLSearchParams();
122
+ query.set("name", normalizedName);
123
+ const raw = await client.requestJson(
124
+ `/skills/versions?${query.toString()}`,
125
+ { method: "GET" }
126
+ );
127
+ return client.parseWithSchema(
128
+ raw,
129
+ skillRegistryVersionsResponseSchema,
130
+ "skill registry versions response"
131
+ );
132
+ }
133
+ async function listMySkills(client, params = {}) {
134
+ const query = new URLSearchParams();
135
+ if (typeof params.limit === "number" && Number.isFinite(params.limit)) {
136
+ query.set("limit", String(Math.trunc(params.limit)));
137
+ }
138
+ const suffix = query.size > 0 ? `?${query.toString()}` : "";
139
+ const raw = await client.requestJson(`/skills/mine${suffix}`, {
140
+ method: "GET"
141
+ });
142
+ return client.parseWithSchema(
143
+ raw,
144
+ skillRegistryMineResponseSchema,
145
+ "skill registry mine response"
146
+ );
147
+ }
148
+ async function getMySkillsList(client, params = {}) {
149
+ const query = new URLSearchParams();
150
+ if (typeof params.limit === "number" && Number.isFinite(params.limit)) {
151
+ query.set("limit", String(Math.trunc(params.limit)));
152
+ }
153
+ if (params.cursor) {
154
+ query.set("cursor", params.cursor);
155
+ }
156
+ if (params.accountId) {
157
+ query.set("accountId", params.accountId);
158
+ }
159
+ const suffix = query.size > 0 ? `?${query.toString()}` : "";
160
+ const raw = await client.requestJson(`/skills/my-list${suffix}`, {
161
+ method: "GET"
162
+ });
163
+ return client.parseWithSchema(
164
+ raw,
165
+ skillRegistryMyListResponseSchema,
166
+ "skill registry my list response"
167
+ );
168
+ }
169
+ async function quoteSkillPublish(client, payload) {
170
+ const raw = await client.requestJson("/skills/quote", {
171
+ method: "POST",
172
+ body: payload,
173
+ headers: { "content-type": "application/json" }
174
+ });
175
+ return client.parseWithSchema(
176
+ raw,
177
+ skillRegistryQuoteResponseSchema,
178
+ "skill registry quote response"
179
+ );
180
+ }
181
+ async function publishSkill(client, payload) {
182
+ const raw = await client.requestJson("/skills/publish", {
183
+ method: "POST",
184
+ body: payload,
185
+ headers: { "content-type": "application/json" }
186
+ });
187
+ return client.parseWithSchema(
188
+ raw,
189
+ skillRegistryPublishResponseSchema,
190
+ "skill registry publish response"
191
+ );
192
+ }
193
+ async function getSkillPublishJob(client, jobId, params = {}) {
194
+ const normalized = jobId.trim();
195
+ if (!normalized) {
196
+ throw new Error("jobId is required");
197
+ }
198
+ const query = new URLSearchParams();
199
+ if (params.accountId) {
200
+ query.set("accountId", params.accountId);
201
+ }
202
+ const suffix = query.size > 0 ? `?${query.toString()}` : "";
203
+ const raw = await client.requestJson(
204
+ `/skills/jobs/${encodeURIComponent(normalized)}${suffix}`,
205
+ { method: "GET" }
206
+ );
207
+ return client.parseWithSchema(
208
+ raw,
209
+ skillRegistryJobStatusResponseSchema,
210
+ "skill registry job status response"
211
+ );
212
+ }
213
+ async function getSkillOwnership(client, params) {
214
+ const normalizedName = params.name.trim();
215
+ if (!normalizedName) {
216
+ throw new Error("name is required");
217
+ }
218
+ const query = new URLSearchParams();
219
+ query.set("name", normalizedName);
220
+ if (params.accountId) {
221
+ query.set("accountId", params.accountId);
222
+ }
223
+ const raw = await client.requestJson(
224
+ `/skills/ownership?${query.toString()}`,
57
225
  {
58
- to: "Hedera network",
59
- amount: totalCostHbar,
60
- description: `Transaction fee debited from ${payerAccountId}`
226
+ method: "GET"
61
227
  }
62
- ];
63
- return {
64
- totalTinybar: resolvedTotalTinybar,
65
- summary: {
66
- totalCostHbar,
67
- breakdown: {
68
- transfers: breakdownTransfers
228
+ );
229
+ return client.parseWithSchema(
230
+ raw,
231
+ skillRegistryOwnershipResponseSchema,
232
+ "skill registry ownership response"
233
+ );
234
+ }
235
+ async function getRecommendedSkillVersion(client, params) {
236
+ const normalizedName = params.name.trim();
237
+ if (!normalizedName) {
238
+ throw new Error("name is required");
239
+ }
240
+ const query = new URLSearchParams();
241
+ query.set("name", normalizedName);
242
+ const raw = await client.requestJson(
243
+ `/skills/recommended?${query.toString()}`,
244
+ { method: "GET" }
245
+ );
246
+ return client.parseWithSchema(
247
+ raw,
248
+ skillRecommendedVersionResponseSchema,
249
+ "skill recommended version response"
250
+ );
251
+ }
252
+ async function setRecommendedSkillVersion(client, payload) {
253
+ const normalizedName = payload.name.trim();
254
+ const normalizedVersion = payload.version.trim();
255
+ if (!normalizedName) {
256
+ throw new Error("name is required");
257
+ }
258
+ if (!normalizedVersion) {
259
+ throw new Error("version is required");
260
+ }
261
+ const raw = await client.requestJson("/skills/recommended", {
262
+ method: "POST",
263
+ body: {
264
+ name: normalizedName,
265
+ version: normalizedVersion
266
+ },
267
+ headers: { "content-type": "application/json" }
268
+ });
269
+ return client.parseWithSchema(
270
+ raw,
271
+ skillRecommendedVersionResponseSchema,
272
+ "skill recommended version response"
273
+ );
274
+ }
275
+ async function getSkillDeprecations(client, params) {
276
+ const normalizedName = params.name.trim();
277
+ if (!normalizedName) {
278
+ throw new Error("name is required");
279
+ }
280
+ const query = new URLSearchParams();
281
+ query.set("name", normalizedName);
282
+ const raw = await client.requestJson(
283
+ `/skills/deprecations?${query.toString()}`,
284
+ { method: "GET" }
285
+ );
286
+ return client.parseWithSchema(
287
+ raw,
288
+ skillDeprecationsResponseSchema,
289
+ "skill deprecations response"
290
+ );
291
+ }
292
+ async function setSkillDeprecation(client, payload) {
293
+ const normalizedName = payload.name.trim();
294
+ if (!normalizedName) {
295
+ throw new Error("name is required");
296
+ }
297
+ const version = payload.version?.trim();
298
+ const reason = payload.reason.trim();
299
+ if (!reason) {
300
+ throw new Error("reason is required");
301
+ }
302
+ const replacementRef = payload.replacementRef?.trim();
303
+ const raw = await client.requestJson("/skills/deprecate", {
304
+ method: "POST",
305
+ body: {
306
+ name: normalizedName,
307
+ version,
308
+ reason,
309
+ replacementRef
310
+ },
311
+ headers: { "content-type": "application/json" }
312
+ });
313
+ return client.parseWithSchema(
314
+ raw,
315
+ skillDeprecationRecordSchema,
316
+ "skill deprecation response"
317
+ );
318
+ }
319
+ async function getSkillBadge(client, params) {
320
+ const normalizedName = params.name.trim();
321
+ if (!normalizedName) {
322
+ throw new Error("name is required");
323
+ }
324
+ const query = new URLSearchParams();
325
+ query.set("name", normalizedName);
326
+ if (params.metric) {
327
+ query.set("metric", params.metric);
328
+ }
329
+ if (params.label?.trim()) {
330
+ query.set("label", params.label.trim());
331
+ }
332
+ if (params.style) {
333
+ query.set("style", params.style);
334
+ }
335
+ const raw = await client.requestJson(
336
+ `/skills/badge?${query.toString()}`,
337
+ { method: "GET" }
338
+ );
339
+ return client.parseWithSchema(
340
+ raw,
341
+ skillBadgeResponseSchema,
342
+ "skill badge response"
343
+ );
344
+ }
345
+ async function listSkillTags(client) {
346
+ const raw = await client.requestJson("/skills/tags", {
347
+ method: "GET"
348
+ });
349
+ return client.parseWithSchema(
350
+ raw,
351
+ skillRegistryTagsResponseSchema,
352
+ "skill tags response"
353
+ );
354
+ }
355
+ async function listSkillCategories(client) {
356
+ const raw = await client.requestJson("/skills/categories", {
357
+ method: "GET"
358
+ });
359
+ return client.parseWithSchema(
360
+ raw,
361
+ skillRegistryCategoriesResponseSchema,
362
+ "skill categories response"
363
+ );
364
+ }
365
+ async function resolveSkillMarkdown(client, skillRef) {
366
+ const normalizedSkillRef = skillRef.trim();
367
+ if (!normalizedSkillRef) {
368
+ throw new Error("skillRef is required");
369
+ }
370
+ const response = await client.request(
371
+ `/skills/${encodeURIComponent(normalizedSkillRef)}/SKILL.md`,
372
+ {
373
+ method: "GET",
374
+ headers: {
375
+ accept: "text/markdown, text/plain;q=0.9, */*;q=0.8"
69
376
  }
70
377
  }
71
- };
378
+ );
379
+ return response.text();
380
+ }
381
+ async function resolveSkillManifest(client, skillRef) {
382
+ const normalizedSkillRef = skillRef.trim();
383
+ if (!normalizedSkillRef) {
384
+ throw new Error("skillRef is required");
385
+ }
386
+ const raw = await client.requestJson(
387
+ `/skills/${encodeURIComponent(normalizedSkillRef)}/manifest`,
388
+ {
389
+ method: "GET"
390
+ }
391
+ );
392
+ return client.parseWithSchema(
393
+ raw,
394
+ skillResolverManifestResponseSchema,
395
+ "skill resolver manifest response"
396
+ );
397
+ }
398
+ async function getSkillVoteStatus(client, params) {
399
+ const normalizedName = params.name.trim();
400
+ if (!normalizedName) {
401
+ throw new Error("name is required");
402
+ }
403
+ const query = new URLSearchParams();
404
+ query.set("name", normalizedName);
405
+ const raw = await client.requestJson(
406
+ `/skills/vote?${query.toString()}`,
407
+ { method: "GET" }
408
+ );
409
+ return client.parseWithSchema(
410
+ raw,
411
+ skillRegistryVoteStatusResponseSchema,
412
+ "skill registry vote status response"
413
+ );
414
+ }
415
+ async function setSkillVote(client, payload) {
416
+ const normalizedName = payload.name.trim();
417
+ if (!normalizedName) {
418
+ throw new Error("name is required");
419
+ }
420
+ const raw = await client.requestJson("/skills/vote", {
421
+ method: "POST",
422
+ body: { name: normalizedName, upvoted: payload.upvoted },
423
+ headers: { "content-type": "application/json" }
424
+ });
425
+ return client.parseWithSchema(
426
+ raw,
427
+ skillRegistryVoteStatusResponseSchema,
428
+ "skill registry vote status response"
429
+ );
430
+ }
431
+ async function requestSkillVerification(client, payload) {
432
+ const normalizedName = payload.name.trim();
433
+ if (!normalizedName) {
434
+ throw new Error("name is required");
435
+ }
436
+ const raw = await client.requestJson(
437
+ "/skills/verification/request",
438
+ {
439
+ method: "POST",
440
+ body: {
441
+ name: normalizedName,
442
+ version: payload.version,
443
+ tier: payload.tier
444
+ },
445
+ headers: { "content-type": "application/json" }
446
+ }
447
+ );
448
+ return client.parseWithSchema(
449
+ raw,
450
+ skillVerificationRequestCreateResponseSchema,
451
+ "skill verification request create response"
452
+ );
453
+ }
454
+ async function getSkillVerificationStatus(client, params) {
455
+ const normalizedName = params.name.trim();
456
+ if (!normalizedName) {
457
+ throw new Error("name is required");
458
+ }
459
+ const query = new URLSearchParams();
460
+ query.set("name", normalizedName);
461
+ if (params.version) {
462
+ query.set("version", params.version);
463
+ }
464
+ const raw = await client.requestJson(
465
+ `/skills/verification/status?${query.toString()}`,
466
+ { method: "GET" }
467
+ );
468
+ return client.parseWithSchema(
469
+ raw,
470
+ skillVerificationStatusResponseSchema,
471
+ "skill verification status response"
472
+ );
473
+ }
474
+ async function createSkillDomainProofChallenge(client, payload) {
475
+ const normalizedName = payload.name.trim();
476
+ if (!normalizedName) {
477
+ throw new Error("name is required");
478
+ }
479
+ const raw = await client.requestJson(
480
+ "/skills/verification/domain/challenge",
481
+ {
482
+ method: "POST",
483
+ body: {
484
+ name: normalizedName,
485
+ version: payload.version,
486
+ domain: payload.domain
487
+ },
488
+ headers: { "content-type": "application/json" }
489
+ }
490
+ );
491
+ return client.parseWithSchema(
492
+ raw,
493
+ skillVerificationDomainProofChallengeResponseSchema,
494
+ "skill domain proof challenge response"
495
+ );
496
+ }
497
+ async function verifySkillDomainProof(client, payload) {
498
+ const normalizedName = payload.name.trim();
499
+ const challengeToken = payload.challengeToken.trim();
500
+ if (!normalizedName) {
501
+ throw new Error("name is required");
502
+ }
503
+ if (!challengeToken) {
504
+ throw new Error("challengeToken is required");
505
+ }
506
+ const raw = await client.requestJson(
507
+ "/skills/verification/domain/verify",
508
+ {
509
+ method: "POST",
510
+ body: {
511
+ name: normalizedName,
512
+ version: payload.version,
513
+ domain: payload.domain,
514
+ challengeToken
515
+ },
516
+ headers: { "content-type": "application/json" }
517
+ }
518
+ );
519
+ return client.parseWithSchema(
520
+ raw,
521
+ skillVerificationDomainProofVerifyResponseSchema,
522
+ "skill domain proof verify response"
523
+ );
72
524
  }
73
525
  export {
74
- computeInscriptionCostSummary
526
+ createSkillDomainProofChallenge,
527
+ getMySkillsList,
528
+ getRecommendedSkillVersion,
529
+ getSkillBadge,
530
+ getSkillDeprecations,
531
+ getSkillOwnership,
532
+ getSkillPublishJob,
533
+ getSkillSecurityBreakdown,
534
+ getSkillVerificationStatus,
535
+ getSkillVoteStatus,
536
+ getSkillsCatalog,
537
+ listMySkills,
538
+ listSkillCategories,
539
+ listSkillTags,
540
+ listSkillVersions,
541
+ listSkills,
542
+ publishSkill,
543
+ quoteSkillPublish,
544
+ requestSkillVerification,
545
+ resolveSkillManifest,
546
+ resolveSkillMarkdown,
547
+ setRecommendedSkillVersion,
548
+ setSkillDeprecation,
549
+ setSkillVote,
550
+ skillsConfig,
551
+ verifySkillDomainProof
75
552
  };
76
553
  //# sourceMappingURL=standards-sdk.es161.js.map