@dyne/interfacer-client 0.4.1 → 0.6.0

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/index.js CHANGED
@@ -316,6 +316,44 @@ function gql(strings, ...values) {
316
316
  }
317
317
 
318
318
  // src/graphql/operations.ts
319
+ var QUERY_VARIABLES = gql`
320
+ query GetVariables {
321
+ instanceVariables {
322
+ specs {
323
+ specCurrency { id name }
324
+ specProjectDesign { id name }
325
+ specProjectProduct { id name }
326
+ specProjectService { id name }
327
+ specDpp { id name }
328
+ specMachine { id name }
329
+ specMaterial { id name }
330
+ }
331
+ units { unitOne { id } }
332
+ }
333
+ }
334
+ `;
335
+ var QUERY_PROJECT_TYPES = gql`
336
+ query GetProjectTypes {
337
+ instanceVariables {
338
+ specs {
339
+ specProjectDesign { id name }
340
+ specProjectProduct { id name }
341
+ specProjectService { id name }
342
+ specDpp { id name }
343
+ specMachine { id name }
344
+ specMaterial { id name }
345
+ }
346
+ }
347
+ }
348
+ `;
349
+ var QUERY_UNIT_AND_CURRENCY = gql`
350
+ query GetUnitAndCurrency {
351
+ instanceVariables {
352
+ units { unitOne { id } }
353
+ specs { specCurrency { id } }
354
+ }
355
+ }
356
+ `;
319
357
  var REGISTER_USER = gql`
320
358
  mutation RegisterUser($firstRegistration: Boolean!, $userData: JSONObject!) {
321
359
  keypairoomServer(firstRegistration: $firstRegistration, userData: $userData)
@@ -354,6 +392,16 @@ var CLAIM_DID = gql`
354
392
  claimPerson(id: $id)
355
393
  }
356
394
  `;
395
+ var PERSON_EXISTS = gql`
396
+ query PersonExists($email: String, $user: String) {
397
+ personExists(email: $email, user: $user)
398
+ }
399
+ `;
400
+ var VERIFY_EMAIL = gql`
401
+ mutation VerifyEmail($token: String!) {
402
+ personVerifyEmailVerification(token: $token)
403
+ }
404
+ `;
357
405
  var QUERY_RESOURCE = gql`
358
406
  query getResourceTable($id: ID!) {
359
407
  economicResource(id: $id) {
@@ -363,7 +411,7 @@ var QUERY_RESOURCE = gql`
363
411
  accountingQuantity { hasUnit { label symbol } hasNumericalValue }
364
412
  primaryAccountable { id name }
365
413
  currentLocation { id name mappableAddress lat long }
366
- images { hash name mimeType bin }
414
+ images { hash name mimeType }
367
415
  }
368
416
  }
369
417
  `;
@@ -406,7 +454,7 @@ var QUERY_PROJECTS = gql`
406
454
  primaryAccountable { name id }
407
455
  name id note metadata
408
456
  onhandQuantity { hasUnit { label } }
409
- images { hash name mimeType bin }
457
+ images { hash name mimeType }
410
458
  }
411
459
  }
412
460
  reciprocalIntents {
@@ -450,7 +498,81 @@ var QUERY_PROJECT_FOR_METADATA_UPDATE = gql`
450
498
  var ASK_RESOURCE_PRIMARY_ACCOUNTABLE = gql`
451
499
  query askResourcePrimaryAccountable($id: ID!) {
452
500
  economicResource(id: $id) {
453
- id name primaryAccountable { id name images { bin mimeType } }
501
+ id name primaryAccountable { id name }
502
+ }
503
+ }
504
+ `;
505
+ var GET_PROJECT_LAYOUT = gql`
506
+ query getProjectLayout($id: ID!) {
507
+ economicResource(id: $id) {
508
+ id name note metadata license licensor repo classifiedAs
509
+ accountingQuantity { hasNumericalValue }
510
+ onhandQuantity { hasUnit { id } hasNumericalValue }
511
+ conformsTo { id name }
512
+ primaryAccountable {
513
+ id name
514
+ primaryLocation { name mappableAddress lat long }
515
+ }
516
+ currentLocation { id name mappableAddress lat long }
517
+ images { hash name mimeType date description extension size }
518
+ }
519
+ }
520
+ `;
521
+ var SEARCH_PROJECT = gql`
522
+ query SearchProject($id: ID!) {
523
+ economicResource(id: $id) {
524
+ id name metadata
525
+ images { hash mimeType }
526
+ conformsTo { name id }
527
+ primaryAccountable { name }
528
+ }
529
+ }
530
+ `;
531
+ var SEARCH_PROJECTS = gql`
532
+ query SearchProjects(
533
+ $last: Int $IDs: [ID!] $name: String
534
+ $conformsTo: [ID!] $primaryAccountable: [ID!]
535
+ ) {
536
+ economicResources(
537
+ last: $last
538
+ filter: { id: $IDs, name: $name, conformsTo: $conformsTo, primaryAccountable: $primaryAccountable }
539
+ ) {
540
+ edges {
541
+ node {
542
+ id name metadata
543
+ conformsTo { id name }
544
+ primaryAccountable { id name }
545
+ images { hash name mimeType }
546
+ }
547
+ }
548
+ }
549
+ }
550
+ `;
551
+ var SELECT_RESOURCES = gql`
552
+ query FetchResources($filter: EconomicResourceFilterParams) {
553
+ economicResources(last: 10, filter: $filter) {
554
+ edges { cursor node { id name } }
555
+ }
556
+ }
557
+ `;
558
+ var EDIT_IMAGES = gql`
559
+ mutation EditImages($id: ID!, $images: [IFile!]) {
560
+ updateEconomicResource(resource: { id: $id, images: $images }) {
561
+ economicResource { id }
562
+ }
563
+ }
564
+ `;
565
+ var EDIT_MAIN = gql`
566
+ mutation EditMain($id: ID!, $classifiedAs: [URI!], $note: String, $name: String, $repo: String) {
567
+ updateEconomicResource(
568
+ resource: { id: $id, classifiedAs: $classifiedAs, name: $name, note: $note, repo: $repo }
569
+ ) { economicResource { id } }
570
+ }
571
+ `;
572
+ var EDIT_SPECS = gql`
573
+ mutation EditSpecs($id: ID!, $classifiedAs: [URI!]) {
574
+ updateEconomicResource(resource: { id: $id, classifiedAs: $classifiedAs }) {
575
+ economicResource { id }
454
576
  }
455
577
  }
456
578
  `;
@@ -511,7 +633,7 @@ var QUERY_PROPOSAL = gql`
511
633
  id provider { id name } receiver { id name }
512
634
  inputOf { name id } outputOf { id name } hasPointInTime
513
635
  resourceInventoriedAs {
514
- id name repo metadata images { hash name mimeType bin }
636
+ id name repo metadata images { hash name mimeType }
515
637
  primaryAccountable { id name } onhandQuantity { hasNumericalValue hasUnit { id } }
516
638
  }
517
639
  resourceConformsTo { id name }
@@ -595,13 +717,14 @@ var CREATE_PROJECT = gql`
595
717
  var CREATE_MACHINE_RESOURCE = gql`
596
718
  mutation createMachineResource(
597
719
  $agent: ID! $creationTime: DateTime! $process: ID! $resourceSpec: ID!
598
- $unitOne: ID! $name: String! $note: String $metadata: JSONObject
720
+ $unitOne: ID! $name: String! $note: String $metadata: JSONObject $tags: [URI!]
599
721
  ) {
600
722
  createEconomicEvent(
601
723
  event: {
602
724
  action: "produce" outputOf: $process provider: $agent receiver: $agent
603
725
  hasPointInTime: $creationTime resourceConformsTo: $resourceSpec
604
726
  resourceQuantity: { hasNumericalValue: 1 hasUnit: $unitOne } resourceMetadata: $metadata
727
+ resourceClassifiedAs: $tags
605
728
  }
606
729
  newInventoriedResource: { name: $name note: $note }
607
730
  ) {
@@ -724,6 +847,18 @@ var UPDATE_RESOURCE_CLASSIFIED_AS = gql`
724
847
  updateEconomicResource(resource: { id: $id classifiedAs: $classifiedAs }) { economicResource { id } }
725
848
  }
726
849
  `;
850
+ var UPDATE_CONTRIBUTION = gql`
851
+ mutation updateContribution(
852
+ $process: ID! $agent: ID! $resource: ID! $quantity: IMeasure!
853
+ $now: DateTime! $metadata: JSONObject! $conformsTo: ID! $unitOne: ID!
854
+ ) {
855
+ contribute: createEconomicEvent(event: {
856
+ action: "work" inputOf: $process provider: $agent receiver: $agent
857
+ resourceConformsTo: $conformsTo hasPointInTime: $now
858
+ effortQuantity: { hasNumericalValue: 1 hasUnit: $unitOne }
859
+ }) { economicEvent { id } }
860
+ }
861
+ `;
727
862
  var RELOCATE_PROJECT = gql`
728
863
  mutation relocateProject(
729
864
  $process: ID! $agent: ID! $resource: ID! $quantity: IMeasure! $now: DateTime! $location: ID!
@@ -761,11 +896,71 @@ var FETCH_USER = gql`
761
896
  }
762
897
  }
763
898
  `;
899
+ var GET_USER_LAYOUT = gql`
900
+ query GetUserLayout($id: ID!) {
901
+ person(id: $id) {
902
+ id name note email user
903
+ images { hash name mimeType bin size extension description }
904
+ ethereumAddress
905
+ primaryLocation { id name mappableAddress lat long }
906
+ }
907
+ }
908
+ `;
909
+ var UPDATE_USER = gql`
910
+ mutation updateUser(
911
+ $id: ID! $name: String $note: String $primaryLocation: ID $user: String $images: [IFile!]
912
+ ) {
913
+ updatePerson(
914
+ person: { id: $id name: $name note: $note primaryLocation: $primaryLocation user: $user images: $images }
915
+ ) {
916
+ agent {
917
+ id name note
918
+ images { name }
919
+ primaryLocation { id lat long name }
920
+ }
921
+ }
922
+ }
923
+ `;
924
+ var GET_USER_IMAGES = gql`
925
+ query GetUserImages($userId: ID!) {
926
+ person(id: $userId) {
927
+ id name
928
+ images { bin mimeType date description extension hash name size }
929
+ }
930
+ }
931
+ `;
932
+ var SEARCH_PERSON = gql`
933
+ query getPerson($id: ID!) {
934
+ person(id: $id) {
935
+ id name user
936
+ images { bin mimeType }
937
+ primaryLocation { id name }
938
+ }
939
+ }
940
+ `;
941
+ var SEARCH_PEOPLE = gql`
942
+ query SearchPeople($filter: PersonFilterParams, $last: Int) {
943
+ people(last: $last, filter: $filter) {
944
+ edges {
945
+ node {
946
+ id name user note
947
+ images { bin mimeType }
948
+ primaryLocation { id name }
949
+ }
950
+ }
951
+ }
952
+ }
953
+ `;
764
954
  var GET_TAGS = gql`
765
955
  query GetTags {
766
956
  economicResourceClassifications
767
957
  }
768
958
  `;
959
+ var SEARCH_TAGS = gql`
960
+ query SearchTags($text: URI!) {
961
+ economicResourceClassifications(filter: { uri: $text })
962
+ }
963
+ `;
769
964
  var GET_RESOURCE_DETAILS = gql`
770
965
  query GetResourceDetails($id: ID!) {
771
966
  proposal(id: $id) {
@@ -775,12 +970,20 @@ var GET_RESOURCE_DETAILS = gql`
775
970
  resourceInventoriedAs {
776
971
  conformsTo { name id } currentLocation { name } name id note
777
972
  classifiedAs metadata primaryAccountable { name id }
778
- onhandQuantity { hasUnit { label } } images { hash name mimeType bin }
973
+ onhandQuantity { hasUnit { label } } images { hash name mimeType }
779
974
  }
780
975
  }
781
976
  }
782
977
  }
783
978
  `;
979
+ var QUERY_RESOURCE_TRACE_DPP = gql`
980
+ query GetResourceTraceDpp($id: ID!) {
981
+ economicResource(id: $id) {
982
+ id
983
+ traceDpp
984
+ }
985
+ }
986
+ `;
784
987
 
785
988
  // src/auth/AuthClient.ts
786
989
  var AuthClient = class {
@@ -1543,385 +1746,6 @@ function clearInstanceVariablesCache() {
1543
1746
  cachedVars = null;
1544
1747
  }
1545
1748
 
1546
- // src/resources/ResourceClient.ts
1547
- var ResourceClient = class {
1548
- constructor(config, store, graphql) {
1549
- this.config = config;
1550
- this.store = store;
1551
- this.graphql = graphql;
1552
- }
1553
- config;
1554
- store;
1555
- graphql;
1556
- get userId() {
1557
- const id = this.store.getItem("authId");
1558
- if (!id) throw new Error("Not authenticated");
1559
- return id;
1560
- }
1561
- async getInstanceVars() {
1562
- return getInstanceVariables(this.graphql);
1563
- }
1564
- // ─── Helpers ───────────────────────────────────────────────────────
1565
- specIdForType(vars, type) {
1566
- switch (type) {
1567
- case "Design" /* DESIGN */:
1568
- return vars.projectDesign.id;
1569
- case "Product" /* PRODUCT */:
1570
- return vars.projectProduct?.id || this.config.specs?.product || "";
1571
- case "Service" /* SERVICE */:
1572
- return vars.projectService?.id || this.config.specs?.service || "";
1573
- case "Machine" /* MACHINE */:
1574
- return vars.machine?.id || this.config.specs?.machine || "";
1575
- case "DPP" /* DPP */:
1576
- return vars.dpp?.id || this.config.specs?.dpp || "";
1577
- }
1578
- }
1579
- // ─── Process ───────────────────────────────────────────────────────
1580
- async createProcess(name) {
1581
- const res = await this.graphql.request(
1582
- CREATE_PROCESS,
1583
- { name }
1584
- );
1585
- if (res.errors?.length) throw new Error(`createProcess failed: ${res.errors[0].message}`);
1586
- return res.data.createProcess.process.id;
1587
- }
1588
- // ─── Location ──────────────────────────────────────────────────────
1589
- async createLocation(params) {
1590
- const res = await this.graphql.request(CREATE_LOCATION, {
1591
- name: params.name,
1592
- addr: params.address || "",
1593
- lat: params.lat || 0,
1594
- lng: params.lng || 0
1595
- });
1596
- if (res.errors?.length) throw new Error(`createLocation failed: ${res.errors[0].message}`);
1597
- return res.data.createSpatialThing.spatialThing;
1598
- }
1599
- // ─── Create Project (Design, Product, Service) ─────────────────────
1600
- async createProject(params) {
1601
- const vars = await this.getInstanceVars();
1602
- const specId = this.specIdForType(vars, params.projectType);
1603
- if (!specId) throw new Error(`${params.projectType} spec ID not found in instance variables or config`);
1604
- const processId = params.processId || await this.createProcess(`creation of ${params.name} by owner`);
1605
- let locationId = params.locationId;
1606
- if (!locationId && params.location) {
1607
- const loc = await this.createLocation(params.location);
1608
- locationId = loc.id;
1609
- }
1610
- const variables = {
1611
- name: params.name,
1612
- note: params.note || "",
1613
- metadata: JSON.stringify(params.metadata || {}),
1614
- agent: this.userId,
1615
- creationTime: (/* @__PURE__ */ new Date()).toISOString(),
1616
- location: locationId,
1617
- resourceSpec: specId,
1618
- oneUnit: vars.unitOne,
1619
- images: params.images || [],
1620
- repo: params.repo || "",
1621
- process: processId,
1622
- license: params.license || ""
1623
- };
1624
- if (params.tags && params.tags.length > 0) {
1625
- variables.tags = params.tags;
1626
- }
1627
- const res = await this.graphql.request(CREATE_PROJECT, variables);
1628
- if (res.errors?.length) throw new Error(`createProject failed: ${res.errors[0].message}`);
1629
- return res.data.createEconomicEvent.economicEvent.resourceInventoriedAs;
1630
- }
1631
- // ─── Create Machine ────────────────────────────────────────────────
1632
- async createMachine(params) {
1633
- const vars = await this.getInstanceVars();
1634
- const machineSpecId = vars.machine?.id || this.config.specs?.machine;
1635
- if (!machineSpecId) throw new Error("Machine spec ID not found in instance variables or config");
1636
- const processId = await this.createProcess(`creation of machine ${params.name}`);
1637
- const res = await this.graphql.request(CREATE_MACHINE_RESOURCE, {
1638
- agent: this.userId,
1639
- creationTime: (/* @__PURE__ */ new Date()).toISOString(),
1640
- process: processId,
1641
- resourceSpec: machineSpecId,
1642
- unitOne: vars.unitOne,
1643
- name: params.name,
1644
- note: params.note || "",
1645
- metadata: JSON.stringify(params.metadata || {})
1646
- });
1647
- if (res.errors?.length) throw new Error(`createMachine failed: ${res.errors[0].message}`);
1648
- return res.data.createEconomicEvent.economicEvent.resourceInventoriedAs;
1649
- }
1650
- // ─── Create DPP Resource ───────────────────────────────────────────
1651
- async createDppResource(params) {
1652
- const vars = await this.getInstanceVars();
1653
- const dppSpecId = vars.dpp?.id || this.config.specs?.dpp;
1654
- if (!dppSpecId) throw new Error("DPP spec ID not found in instance variables or config");
1655
- const processId = await this.createProcess(`DPP creation for ${params.name}`);
1656
- const res = await this.graphql.request(CREATE_DPP_RESOURCE, {
1657
- agent: this.userId,
1658
- creationTime: (/* @__PURE__ */ new Date()).toISOString(),
1659
- process: processId,
1660
- resourceSpec: dppSpecId,
1661
- unitOne: vars.unitOne,
1662
- dppUlid: JSON.stringify({ dppServiceUlid: params.dppUlid }),
1663
- name: params.name,
1664
- note: params.note || ""
1665
- });
1666
- if (res.errors?.length) throw new Error(`createDppResource failed: ${res.errors[0].message}`);
1667
- return res.data.createEconomicEvent.economicEvent.resourceInventoriedAs;
1668
- }
1669
- // ─── Queries ───────────────────────────────────────────────────────
1670
- async getResource(id) {
1671
- const res = await this.graphql.request(
1672
- QUERY_RESOURCE,
1673
- { id }
1674
- );
1675
- return res.data?.economicResource ?? null;
1676
- }
1677
- async listResources(filter, pagination) {
1678
- const res = await this.graphql.request(FETCH_RESOURCES, {
1679
- ...pagination,
1680
- filter: filter || {}
1681
- });
1682
- return res.data || {};
1683
- }
1684
- async getProjects(filter, pagination) {
1685
- const res = await this.graphql.request(QUERY_PROJECTS, {
1686
- ...pagination,
1687
- filter: filter || {}
1688
- });
1689
- return res.data || {};
1690
- }
1691
- async getMachines() {
1692
- const vars = await this.getInstanceVars();
1693
- const machineSpecId = vars.machine?.id || this.config.specs?.machine;
1694
- if (!machineSpecId) throw new Error("Machine spec ID not found in instance variables or config");
1695
- const res = await this.graphql.request(QUERY_MACHINES, {
1696
- resourceSpecId: machineSpecId
1697
- });
1698
- return res.data || {};
1699
- }
1700
- // ─── Relations ─────────────────────────────────────────────────────
1701
- async citeResource(resourceId, processId) {
1702
- const vars = await this.getInstanceVars();
1703
- const res = await this.graphql.request(CITE_PROJECT, {
1704
- agent: this.userId,
1705
- creationTime: (/* @__PURE__ */ new Date()).toISOString(),
1706
- resource: resourceId,
1707
- process: processId,
1708
- unitOne: vars.unitOne
1709
- });
1710
- if (res.errors?.length) throw new Error(`citeResource failed: ${res.errors[0].message}`);
1711
- }
1712
- async consumeResource(resourceId, processId) {
1713
- const vars = await this.getInstanceVars();
1714
- const res = await this.graphql.request(CONSUME_RESOURCE, {
1715
- agent: this.userId,
1716
- creationTime: (/* @__PURE__ */ new Date()).toISOString(),
1717
- resource: resourceId,
1718
- process: processId,
1719
- unitOne: vars.unitOne
1720
- });
1721
- if (res.errors?.length) throw new Error(`consumeResource failed: ${res.errors[0].message}`);
1722
- }
1723
- async contributeToResource(processId, contributionTypeSpecId) {
1724
- const vars = await this.getInstanceVars();
1725
- const res = await this.graphql.request(CONTRIBUTE_TO_PROJECT, {
1726
- agent: this.userId,
1727
- creationTime: (/* @__PURE__ */ new Date()).toISOString(),
1728
- process: processId,
1729
- unitOne: vars.unitOne,
1730
- conformsTo: contributionTypeSpecId
1731
- });
1732
- if (res.errors?.length) throw new Error(`contribute failed: ${res.errors[0].message}`);
1733
- }
1734
- // ─── Metadata ──────────────────────────────────────────────────────
1735
- async updateMetadata(resourceId, metadata, quantity) {
1736
- const res = await this.graphql.request(UPDATE_METADATA, {
1737
- process: await this.createProcess(`metadata update`),
1738
- agent: this.userId,
1739
- resource: resourceId,
1740
- quantity: quantity || { hasNumericalValue: 1, hasUnit: (await this.getInstanceVars()).unitOne },
1741
- now: (/* @__PURE__ */ new Date()).toISOString(),
1742
- metadata: JSON.stringify(metadata)
1743
- });
1744
- if (res.errors?.length) throw new Error(`updateMetadata failed: ${res.errors[0].message}`);
1745
- }
1746
- async updateClassifiedAs(resourceId, tags) {
1747
- const res = await this.graphql.request(UPDATE_RESOURCE_CLASSIFIED_AS, {
1748
- id: resourceId,
1749
- classifiedAs: tags
1750
- });
1751
- if (res.errors?.length) throw new Error(`updateClassifiedAs failed: ${res.errors[0].message}`);
1752
- }
1753
- async relocateResource(resourceId, locationId) {
1754
- const vars = await this.getInstanceVars();
1755
- const res = await this.graphql.request(RELOCATE_PROJECT, {
1756
- process: await this.createProcess(`relocate`),
1757
- agent: this.userId,
1758
- resource: resourceId,
1759
- quantity: { hasNumericalValue: 1, hasUnit: vars.unitOne },
1760
- now: (/* @__PURE__ */ new Date()).toISOString(),
1761
- location: locationId
1762
- });
1763
- if (res.errors?.length) throw new Error(`relocate failed: ${res.errors[0].message}`);
1764
- }
1765
- // ─── Proposals ─────────────────────────────────────────────────────
1766
- async proposeContribution(params) {
1767
- const vars = await this.getInstanceVars();
1768
- const processId = await this.createProcess("contribution proposal");
1769
- const creationTime = (/* @__PURE__ */ new Date()).toISOString();
1770
- const intentsRes = await this.graphql.request(PROPOSE_CONTRIBUTION, {
1771
- process: processId,
1772
- owner: params.ownerId,
1773
- proposer: this.userId,
1774
- creationTime,
1775
- resourceForked: params.resourceForkedId,
1776
- unitOne: vars.unitOne,
1777
- resourceOrigin: params.resourceOriginId
1778
- });
1779
- if (intentsRes.errors?.length) throw new Error(`proposeContribution intents failed: ${intentsRes.errors[0].message}`);
1780
- const proposalRes = await this.graphql.request(CREATE_PROPOSAL, {
1781
- name: `Contribution to resource`,
1782
- note: params.note
1783
- });
1784
- if (proposalRes.errors?.length) throw new Error(`createProposal failed: ${proposalRes.errors[0].message}`);
1785
- const proposalId = proposalRes.data.createProposal.proposal.id;
1786
- const citeIntentId = intentsRes.data.citeResourceForked.intent.id;
1787
- const acceptIntentId = intentsRes.data.acceptResourceOrigin.intent.id;
1788
- const modifyIntentId = intentsRes.data.modifyResourceOrigin.intent.id;
1789
- const linkRes = await this.graphql.request(LINK_CONTRIBUTION_PROPOSAL_INTENT, {
1790
- proposal: proposalId,
1791
- citeIntent: citeIntentId,
1792
- acceptIntent: acceptIntentId,
1793
- modifyIntent: modifyIntentId
1794
- });
1795
- if (linkRes.errors?.length) throw new Error(`linkIntents failed: ${linkRes.errors[0].message}`);
1796
- return { proposalId, citeIntentId, acceptIntentId, modifyIntentId };
1797
- }
1798
- async acceptProposal(params) {
1799
- const vars = await this.getInstanceVars();
1800
- const processId = await this.createProcess("accept contribution");
1801
- const eventsRes = await this.graphql.request(ACCEPT_PROPOSAL, {
1802
- process: processId,
1803
- owner: params.ownerId,
1804
- proposer: params.proposerId,
1805
- unitOne: vars.unitOne,
1806
- resourceForked: params.resourceForkedId,
1807
- resourceOrigin: params.resourceOriginId,
1808
- creationTime: (/* @__PURE__ */ new Date()).toISOString(),
1809
- metadata: JSON.stringify(params.newMetadata)
1810
- });
1811
- if (eventsRes.errors?.length) throw new Error(`acceptProposal events failed: ${eventsRes.errors[0].message}`);
1812
- const satRes = await this.graphql.request(SATISFY_INTENTS, {
1813
- unitOne: vars.unitOne,
1814
- intentCited: params.citeIntentId,
1815
- intentAccepted: params.acceptIntentId,
1816
- intentModify: params.modifyIntentId,
1817
- eventCite: eventsRes.data.cite.economicEvent.id,
1818
- eventAccept: eventsRes.data.accept.economicEvent.id,
1819
- eventModify: eventsRes.data.modify.economicEvent.id
1820
- });
1821
- if (satRes.errors?.length) throw new Error(`satisfyIntents failed: ${satRes.errors[0].message}`);
1822
- }
1823
- async rejectProposal(intentCite, intentAccept, intentModify) {
1824
- const res = await this.graphql.request(REJECT_PROPOSAL, {
1825
- intentCite,
1826
- intentAccept,
1827
- intentModify
1828
- });
1829
- if (res.errors?.length) throw new Error(`rejectProposal failed: ${res.errors[0].message}`);
1830
- }
1831
- };
1832
-
1833
- // src/social/SocialClient.ts
1834
- init_sign();
1835
- var SocialClient = class {
1836
- constructor(config, store) {
1837
- this.config = config;
1838
- this.store = store;
1839
- }
1840
- config;
1841
- store;
1842
- get personBase() {
1843
- const base = this.config.social?.personBase;
1844
- if (!base) throw new Error("social.personBase URL not configured");
1845
- return base;
1846
- }
1847
- get erBase() {
1848
- const base = this.config.social?.economicResourceBase;
1849
- if (!base) throw new Error("social.economicResourceBase URL not configured");
1850
- return base;
1851
- }
1852
- get userId() {
1853
- const id = this.store.getItem("authId");
1854
- if (!id) throw new Error("Not authenticated");
1855
- return id;
1856
- }
1857
- /** Post an ActivityStreams activity to the user's outbox. */
1858
- async postActivity(activity) {
1859
- const body = JSON.stringify(activity);
1860
- const headers = await signGraphQLRequest(body, this.store);
1861
- const res = await fetch(`${this.personBase}/${this.userId}/outbox`, {
1862
- method: "POST",
1863
- headers: { ...headers, "Content-Type": "application/json" },
1864
- body
1865
- });
1866
- if (!res.ok) throw new Error(`ActivityPub post failed: ${res.statusText}`);
1867
- }
1868
- /** Like a resource. */
1869
- async likeResource(resourceId) {
1870
- await this.postActivity({
1871
- "@context": "https://www.w3.org/ns/activitystreams",
1872
- type: "Like",
1873
- actor: `${this.personBase}/${this.userId}`,
1874
- object: `${this.erBase}/${resourceId}`,
1875
- published: (/* @__PURE__ */ new Date()).toISOString()
1876
- });
1877
- }
1878
- /** Follow (watch) a resource. */
1879
- async followResource(resourceId) {
1880
- await this.postActivity({
1881
- "@context": "https://www.w3.org/ns/activitystreams",
1882
- type: "Follow",
1883
- actor: `${this.personBase}/${this.userId}`,
1884
- object: `${this.erBase}/${resourceId}`,
1885
- published: (/* @__PURE__ */ new Date()).toISOString()
1886
- });
1887
- }
1888
- /** Get the list of resource IDs the current user has liked. */
1889
- async getLikes() {
1890
- const res = await fetch(`${this.personBase}/${this.userId}/liked`);
1891
- const data = await res.json();
1892
- const likes = [];
1893
- for (const item of data.data?.items || []) {
1894
- const likeRes = await fetch(item);
1895
- const likeData = await likeRes.json();
1896
- const object = likeData.data?.object || "";
1897
- likes.push(object.split("economicresource/")[1] || object);
1898
- }
1899
- return likes.filter(Boolean);
1900
- }
1901
- /** Check if the current user liked a resource. */
1902
- async isLiked(resourceId) {
1903
- const likes = await this.getLikes();
1904
- return likes.includes(resourceId);
1905
- }
1906
- /** Get the list of follower IDs for a resource. */
1907
- async getFollowers(resourceId) {
1908
- const res = await fetch(`${this.erBase}/${resourceId}/follower`);
1909
- const data = await res.json();
1910
- return (data.data || []).map((f) => f.split("person/")[1] || f).filter(Boolean);
1911
- }
1912
- /** Get the list of resources the current user is following. */
1913
- async getFollowing() {
1914
- const res = await fetch(`${this.personBase}/${this.userId}/following`);
1915
- const data = await res.json();
1916
- return (data.data || []).map((f) => f.split("economicresource/")[1] || f).filter(Boolean);
1917
- }
1918
- /** Check if the current user is following a resource. */
1919
- async isFollowing(resourceId) {
1920
- const followers = await this.getFollowers(resourceId);
1921
- return followers.includes(this.userId);
1922
- }
1923
- };
1924
-
1925
1749
  // src/tagging/constants.ts
1926
1750
  var TAG_PREFIX = {
1927
1751
  USER: "tag",
@@ -1938,7 +1762,8 @@ var TAG_PREFIX = {
1938
1762
  SERVICE_TYPE: "servicetype",
1939
1763
  AVAILABILITY: "availability",
1940
1764
  LICENSE: "license",
1941
- MANUFACTURABLE: "manufacturable"
1765
+ MANUFACTURABLE: "manufacturable",
1766
+ COMPLEXITY: "complexity"
1942
1767
  };
1943
1768
  var SYSTEM_TAG_PREFIXES = [
1944
1769
  TAG_PREFIX.CATEGORY,
@@ -1954,7 +1779,8 @@ var SYSTEM_TAG_PREFIXES = [
1954
1779
  TAG_PREFIX.SERVICE_TYPE,
1955
1780
  TAG_PREFIX.AVAILABILITY,
1956
1781
  TAG_PREFIX.LICENSE,
1957
- TAG_PREFIX.MANUFACTURABLE
1782
+ TAG_PREFIX.MANUFACTURABLE,
1783
+ TAG_PREFIX.COMPLEXITY
1958
1784
  ];
1959
1785
  var LEGACY_SYSTEM_TAG_PATTERNS = [
1960
1786
  "power_compat-",
@@ -1988,6 +1814,7 @@ var POWER_COMPATIBILITY_OPTIONS = [
1988
1814
  "USB-C"
1989
1815
  ];
1990
1816
  var REPLICABILITY_OPTIONS = ["High", "Medium", "Low"];
1817
+ var COMPLEXITY_OPTIONS = ["Beginner", "Intermediate", "Advanced"];
1991
1818
  var SERVICE_TYPE_OPTIONS = ["Fabrication", "Learning & Education", "Space Access"];
1992
1819
  var AVAILABILITY_OPTIONS = [
1993
1820
  "Available Now",
@@ -2200,6 +2027,404 @@ var TaggingClient = class {
2200
2027
  MANUFACTURABLE_TRUE_TAG = MANUFACTURABLE_TRUE_TAG;
2201
2028
  };
2202
2029
 
2030
+ // src/resources/ResourceClient.ts
2031
+ var ResourceClient = class {
2032
+ constructor(config, store, graphql) {
2033
+ this.config = config;
2034
+ this.store = store;
2035
+ this.graphql = graphql;
2036
+ }
2037
+ config;
2038
+ store;
2039
+ graphql;
2040
+ get userId() {
2041
+ const id = this.store.getItem("authId");
2042
+ if (!id) throw new Error("Not authenticated");
2043
+ return id;
2044
+ }
2045
+ async getInstanceVars() {
2046
+ return getInstanceVariables(this.graphql);
2047
+ }
2048
+ // ─── Helpers ───────────────────────────────────────────────────────
2049
+ specIdForType(vars, type) {
2050
+ switch (type) {
2051
+ case "Design" /* DESIGN */:
2052
+ return vars.projectDesign.id;
2053
+ case "Product" /* PRODUCT */:
2054
+ return vars.projectProduct?.id || this.config.specs?.product || "";
2055
+ case "Service" /* SERVICE */:
2056
+ return vars.projectService?.id || this.config.specs?.service || "";
2057
+ case "Machine" /* MACHINE */:
2058
+ return vars.machine?.id || this.config.specs?.machine || "";
2059
+ case "DPP" /* DPP */:
2060
+ return vars.dpp?.id || this.config.specs?.dpp || "";
2061
+ }
2062
+ }
2063
+ // ─── Process ───────────────────────────────────────────────────────
2064
+ async createProcess(name) {
2065
+ const res = await this.graphql.request(
2066
+ CREATE_PROCESS,
2067
+ { name }
2068
+ );
2069
+ if (res.errors?.length) throw new Error(`createProcess failed: ${res.errors[0].message}`);
2070
+ return res.data.createProcess.process.id;
2071
+ }
2072
+ // ─── Location ──────────────────────────────────────────────────────
2073
+ async createLocation(params) {
2074
+ const res = await this.graphql.request(CREATE_LOCATION, {
2075
+ name: params.name,
2076
+ addr: params.address || "",
2077
+ lat: params.lat || 0,
2078
+ lng: params.lng || 0
2079
+ });
2080
+ if (res.errors?.length) throw new Error(`createLocation failed: ${res.errors[0].message}`);
2081
+ return res.data.createSpatialThing.spatialThing;
2082
+ }
2083
+ // ─── Create Project (Design, Product, Service) ─────────────────────
2084
+ async createProject(params) {
2085
+ const vars = await this.getInstanceVars();
2086
+ const specId = this.specIdForType(vars, params.projectType);
2087
+ if (!specId) throw new Error(`${params.projectType} spec ID not found in instance variables or config`);
2088
+ const processId = params.processId || await this.createProcess(`creation of ${params.name} by owner`);
2089
+ let locationId = params.locationId;
2090
+ if (!locationId && params.location) {
2091
+ const loc = await this.createLocation(params.location);
2092
+ locationId = loc.id;
2093
+ }
2094
+ const variables = {
2095
+ name: params.name,
2096
+ note: params.note || "",
2097
+ metadata: JSON.stringify(params.metadata || {}),
2098
+ agent: this.userId,
2099
+ creationTime: (/* @__PURE__ */ new Date()).toISOString(),
2100
+ location: locationId,
2101
+ resourceSpec: specId,
2102
+ oneUnit: vars.unitOne,
2103
+ images: params.images || [],
2104
+ repo: params.repo || "",
2105
+ process: processId,
2106
+ license: params.license || ""
2107
+ };
2108
+ if (params.tags && params.tags.length > 0) {
2109
+ variables.tags = params.tags;
2110
+ }
2111
+ const res = await this.graphql.request(CREATE_PROJECT, variables);
2112
+ if (res.errors?.length) throw new Error(`createProject failed: ${res.errors[0].message}`);
2113
+ return res.data.createEconomicEvent.economicEvent.resourceInventoriedAs;
2114
+ }
2115
+ // ─── Create Machine ────────────────────────────────────────────────
2116
+ async createMachine(params) {
2117
+ const vars = await this.getInstanceVars();
2118
+ const machineSpecId = vars.machine?.id || this.config.specs?.machine;
2119
+ if (!machineSpecId) throw new Error("Machine spec ID not found in instance variables or config");
2120
+ const processId = await this.createProcess(`creation of machine ${params.name}`);
2121
+ const metadata = {
2122
+ ...params.type && { machineType: params.type },
2123
+ ...params.location && { location: params.location },
2124
+ ...params.image && { image: params.image },
2125
+ ...params.metadata || {}
2126
+ };
2127
+ const tags = [...params.tags || []];
2128
+ if (params.type) {
2129
+ const typeTag = prefixedTag(TAG_PREFIX.MACHINE, params.type);
2130
+ if (typeTag) tags.push(typeTag);
2131
+ }
2132
+ const variables = {
2133
+ agent: this.userId,
2134
+ creationTime: (/* @__PURE__ */ new Date()).toISOString(),
2135
+ process: processId,
2136
+ resourceSpec: machineSpecId,
2137
+ unitOne: vars.unitOne,
2138
+ name: params.name,
2139
+ note: params.note || "",
2140
+ metadata: JSON.stringify(metadata)
2141
+ };
2142
+ if (tags.length > 0) variables.tags = tags;
2143
+ const res = await this.graphql.request(CREATE_MACHINE_RESOURCE, variables);
2144
+ if (res.errors?.length) throw new Error(`createMachine failed: ${res.errors[0].message}`);
2145
+ return res.data.createEconomicEvent.economicEvent.resourceInventoriedAs;
2146
+ }
2147
+ // ─── Create DPP Resource ───────────────────────────────────────────
2148
+ async createDppResource(params) {
2149
+ const vars = await this.getInstanceVars();
2150
+ const dppSpecId = vars.dpp?.id || this.config.specs?.dpp;
2151
+ if (!dppSpecId) throw new Error("DPP spec ID not found in instance variables or config");
2152
+ const processId = await this.createProcess(`DPP creation for ${params.name}`);
2153
+ const res = await this.graphql.request(CREATE_DPP_RESOURCE, {
2154
+ agent: this.userId,
2155
+ creationTime: (/* @__PURE__ */ new Date()).toISOString(),
2156
+ process: processId,
2157
+ resourceSpec: dppSpecId,
2158
+ unitOne: vars.unitOne,
2159
+ dppUlid: JSON.stringify({ dppServiceUlid: params.dppUlid }),
2160
+ name: params.name,
2161
+ note: params.note || ""
2162
+ });
2163
+ if (res.errors?.length) throw new Error(`createDppResource failed: ${res.errors[0].message}`);
2164
+ return res.data.createEconomicEvent.economicEvent.resourceInventoriedAs;
2165
+ }
2166
+ // ─── Queries ───────────────────────────────────────────────────────
2167
+ async getResource(id) {
2168
+ const res = await this.graphql.request(
2169
+ QUERY_RESOURCE,
2170
+ { id }
2171
+ );
2172
+ return res.data?.economicResource ?? null;
2173
+ }
2174
+ async listResources(filter, pagination) {
2175
+ const res = await this.graphql.request(FETCH_RESOURCES, {
2176
+ ...pagination,
2177
+ filter: filter || {}
2178
+ });
2179
+ return res.data || {};
2180
+ }
2181
+ async getProjects(filter, pagination) {
2182
+ const res = await this.graphql.request(QUERY_PROJECTS, {
2183
+ ...pagination,
2184
+ filter: filter || {}
2185
+ });
2186
+ return res.data || {};
2187
+ }
2188
+ async getMachines() {
2189
+ const vars = await this.getInstanceVars();
2190
+ const machineSpecId = vars.machine?.id || this.config.specs?.machine;
2191
+ if (!machineSpecId) throw new Error("Machine spec ID not found in instance variables or config");
2192
+ const res = await this.graphql.request(QUERY_MACHINES, {
2193
+ resourceSpecId: machineSpecId
2194
+ });
2195
+ return res.data || {};
2196
+ }
2197
+ // ─── Relations ─────────────────────────────────────────────────────
2198
+ async citeResource(resourceId, processId) {
2199
+ const vars = await this.getInstanceVars();
2200
+ const res = await this.graphql.request(CITE_PROJECT, {
2201
+ agent: this.userId,
2202
+ creationTime: (/* @__PURE__ */ new Date()).toISOString(),
2203
+ resource: resourceId,
2204
+ process: processId,
2205
+ unitOne: vars.unitOne
2206
+ });
2207
+ if (res.errors?.length) throw new Error(`citeResource failed: ${res.errors[0].message}`);
2208
+ }
2209
+ async consumeResource(resourceId, processId) {
2210
+ const vars = await this.getInstanceVars();
2211
+ const res = await this.graphql.request(CONSUME_RESOURCE, {
2212
+ agent: this.userId,
2213
+ creationTime: (/* @__PURE__ */ new Date()).toISOString(),
2214
+ resource: resourceId,
2215
+ process: processId,
2216
+ unitOne: vars.unitOne
2217
+ });
2218
+ if (res.errors?.length) throw new Error(`consumeResource failed: ${res.errors[0].message}`);
2219
+ }
2220
+ async contributeToResource(processId, contributionTypeSpecId) {
2221
+ const vars = await this.getInstanceVars();
2222
+ const res = await this.graphql.request(CONTRIBUTE_TO_PROJECT, {
2223
+ agent: this.userId,
2224
+ creationTime: (/* @__PURE__ */ new Date()).toISOString(),
2225
+ process: processId,
2226
+ unitOne: vars.unitOne,
2227
+ conformsTo: contributionTypeSpecId
2228
+ });
2229
+ if (res.errors?.length) throw new Error(`contribute failed: ${res.errors[0].message}`);
2230
+ }
2231
+ // ─── Metadata ──────────────────────────────────────────────────────
2232
+ async updateMetadata(resourceId, metadata, quantity) {
2233
+ const res = await this.graphql.request(UPDATE_METADATA, {
2234
+ process: await this.createProcess(`metadata update`),
2235
+ agent: this.userId,
2236
+ resource: resourceId,
2237
+ quantity: quantity || { hasNumericalValue: 1, hasUnit: (await this.getInstanceVars()).unitOne },
2238
+ now: (/* @__PURE__ */ new Date()).toISOString(),
2239
+ metadata: JSON.stringify(metadata)
2240
+ });
2241
+ if (res.errors?.length) throw new Error(`updateMetadata failed: ${res.errors[0].message}`);
2242
+ }
2243
+ async updateClassifiedAs(resourceId, tags) {
2244
+ const res = await this.graphql.request(UPDATE_RESOURCE_CLASSIFIED_AS, {
2245
+ id: resourceId,
2246
+ classifiedAs: tags
2247
+ });
2248
+ if (res.errors?.length) throw new Error(`updateClassifiedAs failed: ${res.errors[0].message}`);
2249
+ }
2250
+ async relocateResource(resourceId, locationId) {
2251
+ const vars = await this.getInstanceVars();
2252
+ const res = await this.graphql.request(RELOCATE_PROJECT, {
2253
+ process: await this.createProcess(`relocate`),
2254
+ agent: this.userId,
2255
+ resource: resourceId,
2256
+ quantity: { hasNumericalValue: 1, hasUnit: vars.unitOne },
2257
+ now: (/* @__PURE__ */ new Date()).toISOString(),
2258
+ location: locationId
2259
+ });
2260
+ if (res.errors?.length) throw new Error(`relocate failed: ${res.errors[0].message}`);
2261
+ }
2262
+ // ─── Proposals ─────────────────────────────────────────────────────
2263
+ async proposeContribution(params) {
2264
+ const vars = await this.getInstanceVars();
2265
+ const processId = await this.createProcess("contribution proposal");
2266
+ const creationTime = (/* @__PURE__ */ new Date()).toISOString();
2267
+ const intentsRes = await this.graphql.request(PROPOSE_CONTRIBUTION, {
2268
+ process: processId,
2269
+ owner: params.ownerId,
2270
+ proposer: this.userId,
2271
+ creationTime,
2272
+ resourceForked: params.resourceForkedId,
2273
+ unitOne: vars.unitOne,
2274
+ resourceOrigin: params.resourceOriginId
2275
+ });
2276
+ if (intentsRes.errors?.length) throw new Error(`proposeContribution intents failed: ${intentsRes.errors[0].message}`);
2277
+ const proposalRes = await this.graphql.request(CREATE_PROPOSAL, {
2278
+ name: `Contribution to resource`,
2279
+ note: params.note
2280
+ });
2281
+ if (proposalRes.errors?.length) throw new Error(`createProposal failed: ${proposalRes.errors[0].message}`);
2282
+ const proposalId = proposalRes.data.createProposal.proposal.id;
2283
+ const citeIntentId = intentsRes.data.citeResourceForked.intent.id;
2284
+ const acceptIntentId = intentsRes.data.acceptResourceOrigin.intent.id;
2285
+ const modifyIntentId = intentsRes.data.modifyResourceOrigin.intent.id;
2286
+ const linkRes = await this.graphql.request(LINK_CONTRIBUTION_PROPOSAL_INTENT, {
2287
+ proposal: proposalId,
2288
+ citeIntent: citeIntentId,
2289
+ acceptIntent: acceptIntentId,
2290
+ modifyIntent: modifyIntentId
2291
+ });
2292
+ if (linkRes.errors?.length) throw new Error(`linkIntents failed: ${linkRes.errors[0].message}`);
2293
+ return { proposalId, citeIntentId, acceptIntentId, modifyIntentId };
2294
+ }
2295
+ async acceptProposal(params) {
2296
+ const vars = await this.getInstanceVars();
2297
+ const processId = await this.createProcess("accept contribution");
2298
+ const eventsRes = await this.graphql.request(ACCEPT_PROPOSAL, {
2299
+ process: processId,
2300
+ owner: params.ownerId,
2301
+ proposer: params.proposerId,
2302
+ unitOne: vars.unitOne,
2303
+ resourceForked: params.resourceForkedId,
2304
+ resourceOrigin: params.resourceOriginId,
2305
+ creationTime: (/* @__PURE__ */ new Date()).toISOString(),
2306
+ metadata: JSON.stringify(params.newMetadata)
2307
+ });
2308
+ if (eventsRes.errors?.length) throw new Error(`acceptProposal events failed: ${eventsRes.errors[0].message}`);
2309
+ const satRes = await this.graphql.request(SATISFY_INTENTS, {
2310
+ unitOne: vars.unitOne,
2311
+ intentCited: params.citeIntentId,
2312
+ intentAccepted: params.acceptIntentId,
2313
+ intentModify: params.modifyIntentId,
2314
+ eventCite: eventsRes.data.cite.economicEvent.id,
2315
+ eventAccept: eventsRes.data.accept.economicEvent.id,
2316
+ eventModify: eventsRes.data.modify.economicEvent.id
2317
+ });
2318
+ if (satRes.errors?.length) throw new Error(`satisfyIntents failed: ${satRes.errors[0].message}`);
2319
+ }
2320
+ async getTraceDpp(id) {
2321
+ const res = await this.graphql.request(QUERY_RESOURCE_TRACE_DPP, { id });
2322
+ if (res.errors?.length) throw new Error(`getTraceDpp failed: ${res.errors[0].message}`);
2323
+ const traceDpp = res.data?.economicResource?.traceDpp;
2324
+ return Array.isArray(traceDpp) ? traceDpp : [];
2325
+ }
2326
+ async rejectProposal(intentCite, intentAccept, intentModify) {
2327
+ const res = await this.graphql.request(REJECT_PROPOSAL, {
2328
+ intentCite,
2329
+ intentAccept,
2330
+ intentModify
2331
+ });
2332
+ if (res.errors?.length) throw new Error(`rejectProposal failed: ${res.errors[0].message}`);
2333
+ }
2334
+ };
2335
+
2336
+ // src/social/SocialClient.ts
2337
+ init_sign();
2338
+ var SocialClient = class {
2339
+ constructor(config, store) {
2340
+ this.config = config;
2341
+ this.store = store;
2342
+ }
2343
+ config;
2344
+ store;
2345
+ get personBase() {
2346
+ const base = this.config.social?.personBase;
2347
+ if (!base) throw new Error("social.personBase URL not configured");
2348
+ return base;
2349
+ }
2350
+ get erBase() {
2351
+ const base = this.config.social?.economicResourceBase;
2352
+ if (!base) throw new Error("social.economicResourceBase URL not configured");
2353
+ return base;
2354
+ }
2355
+ get userId() {
2356
+ const id = this.store.getItem("authId");
2357
+ if (!id) throw new Error("Not authenticated");
2358
+ return id;
2359
+ }
2360
+ /** Post an ActivityStreams activity to the user's outbox. */
2361
+ async postActivity(activity) {
2362
+ const body = JSON.stringify(activity);
2363
+ const headers = await signGraphQLRequest(body, this.store);
2364
+ const res = await fetch(`${this.personBase}/${this.userId}/outbox`, {
2365
+ method: "POST",
2366
+ headers: { ...headers, "Content-Type": "application/json" },
2367
+ body
2368
+ });
2369
+ if (!res.ok) throw new Error(`ActivityPub post failed: ${res.statusText}`);
2370
+ }
2371
+ /** Like a resource. */
2372
+ async likeResource(resourceId) {
2373
+ await this.postActivity({
2374
+ "@context": "https://www.w3.org/ns/activitystreams",
2375
+ type: "Like",
2376
+ actor: `${this.personBase}/${this.userId}`,
2377
+ object: `${this.erBase}/${resourceId}`,
2378
+ published: (/* @__PURE__ */ new Date()).toISOString()
2379
+ });
2380
+ }
2381
+ /** Follow (watch) a resource. */
2382
+ async followResource(resourceId) {
2383
+ await this.postActivity({
2384
+ "@context": "https://www.w3.org/ns/activitystreams",
2385
+ type: "Follow",
2386
+ actor: `${this.personBase}/${this.userId}`,
2387
+ object: `${this.erBase}/${resourceId}`,
2388
+ published: (/* @__PURE__ */ new Date()).toISOString()
2389
+ });
2390
+ }
2391
+ /** Get the list of resource IDs the current user has liked. */
2392
+ async getLikes() {
2393
+ const res = await fetch(`${this.personBase}/${this.userId}/liked`);
2394
+ const data = await res.json();
2395
+ const likes = [];
2396
+ for (const item of data.data?.items || []) {
2397
+ const likeRes = await fetch(item);
2398
+ const likeData = await likeRes.json();
2399
+ const object = likeData.data?.object || "";
2400
+ likes.push(object.split("economicresource/")[1] || object);
2401
+ }
2402
+ return likes.filter(Boolean);
2403
+ }
2404
+ /** Check if the current user liked a resource. */
2405
+ async isLiked(resourceId) {
2406
+ const likes = await this.getLikes();
2407
+ return likes.includes(resourceId);
2408
+ }
2409
+ /** Get the list of follower IDs for a resource. */
2410
+ async getFollowers(resourceId) {
2411
+ const res = await fetch(`${this.erBase}/${resourceId}/follower`);
2412
+ const data = await res.json();
2413
+ return (data.data || []).map((f) => f.split("person/")[1] || f).filter(Boolean);
2414
+ }
2415
+ /** Get the list of resources the current user is following. */
2416
+ async getFollowing() {
2417
+ const res = await fetch(`${this.personBase}/${this.userId}/following`);
2418
+ const data = await res.json();
2419
+ return (data.data || []).map((f) => f.split("economicresource/")[1] || f).filter(Boolean);
2420
+ }
2421
+ /** Check if the current user is following a resource. */
2422
+ async isFollowing(resourceId) {
2423
+ const followers = await this.getFollowers(resourceId);
2424
+ return followers.includes(this.userId);
2425
+ }
2426
+ };
2427
+
2203
2428
  // src/wallet/WalletClient.ts
2204
2429
  init_sign();
2205
2430
  var WalletClient = class {
@@ -2381,30 +2606,91 @@ function createConfig(config) {
2381
2606
  // src/index.ts
2382
2607
  init_sign();
2383
2608
  export {
2609
+ ACCEPT_PROPOSAL,
2610
+ ASK_RESOURCE_PRIMARY_ACCOUNTABLE,
2384
2611
  AVAILABILITY_OPTIONS,
2385
2612
  AuthClient,
2613
+ CITE_PROJECT,
2614
+ CLAIM_DID,
2386
2615
  CO2_THRESHOLDS_KG,
2616
+ COMPLEXITY_OPTIONS,
2617
+ CONSUME_RESOURCE,
2618
+ CONTRIBUTE_TO_PROJECT,
2619
+ CREATE_DPP_RESOURCE,
2620
+ CREATE_INTENT,
2621
+ CREATE_LOCATION,
2622
+ CREATE_MACHINE_RESOURCE,
2623
+ CREATE_PROCESS,
2624
+ CREATE_PROJECT,
2625
+ CREATE_PROPOSAL,
2387
2626
  DppClient,
2627
+ EDIT_IMAGES,
2628
+ EDIT_MAIN,
2629
+ EDIT_SPECS,
2388
2630
  ENERGY_THRESHOLDS_KWH,
2631
+ FETCH_AGENTS,
2632
+ FETCH_RESOURCES,
2633
+ FETCH_SELF,
2634
+ FETCH_USER,
2635
+ FORK_PROJECT,
2389
2636
  FeedbackClient,
2390
2637
  FileClient,
2638
+ GET_PROJECT_LAYOUT,
2639
+ GET_RESOURCE_DETAILS,
2640
+ GET_TAGS,
2641
+ GET_USER_IMAGES,
2642
+ GET_USER_LAYOUT,
2391
2643
  GraphQLClient,
2392
2644
  ImportClient,
2393
2645
  InboxClient,
2394
2646
  InterfacerClient,
2647
+ LINK_CONTRIBUTION_PROPOSAL_INTENT,
2648
+ LINK_PROPOSAL_AND_INTENT,
2395
2649
  MANUFACTURABLE_TRUE_TAG,
2650
+ PERSON_EXISTS,
2396
2651
  POWER_COMPATIBILITY_OPTIONS,
2397
2652
  POWER_REQUIREMENT_THRESHOLDS_W,
2398
2653
  PRODUCT_CATEGORY_OPTIONS,
2654
+ PROPOSE_CONTRIBUTION,
2655
+ QUERY_AGENTS,
2656
+ QUERY_CITED_RESOURCES,
2657
+ QUERY_MACHINES,
2658
+ QUERY_PROJECTS,
2659
+ QUERY_PROJECT_FOR_METADATA_UPDATE,
2660
+ QUERY_PROJECT_TYPES,
2661
+ QUERY_PROPOSAL,
2662
+ QUERY_RESOURCE,
2663
+ QUERY_RESOURCE_PROPOSALS,
2664
+ QUERY_RESOURCE_TRACE_DPP,
2665
+ QUERY_UNIT_AND_CURRENCY,
2666
+ QUERY_VARIABLES,
2399
2667
  RECYCLABILITY_THRESHOLDS_PCT,
2668
+ REGISTER_USER,
2669
+ REJECT_PROPOSAL,
2670
+ RELOCATE_PROJECT,
2400
2671
  REPAIRABILITY_AVAILABLE_TAG,
2401
2672
  REPLICABILITY_OPTIONS,
2402
2673
  ResourceClient,
2674
+ SATISFY_INTENTS,
2675
+ SEARCH_PEOPLE,
2676
+ SEARCH_PERSON,
2677
+ SEARCH_PROJECT,
2678
+ SEARCH_PROJECTS,
2679
+ SEARCH_TAGS,
2680
+ SELECT_RESOURCES,
2681
+ SEND_EMAIL_VERIFICATION,
2403
2682
  SERVICE_TYPE_OPTIONS,
2683
+ SIGN_UP,
2404
2684
  SYSTEM_TAG_PREFIXES,
2405
2685
  SocialClient,
2406
2686
  TAG_PREFIX,
2687
+ TRANSFER_PROJECT,
2407
2688
  TaggingClient,
2689
+ UPDATE_CONTRIBUTION,
2690
+ UPDATE_METADATA,
2691
+ UPDATE_RESOURCE_CLASSIFIED_AS,
2692
+ UPDATE_USER,
2693
+ VERIFY_EMAIL,
2408
2694
  WalletClient,
2409
2695
  clearInstanceVariablesCache,
2410
2696
  createConfig,