@dyne/interfacer-client 0.4.1 → 0.5.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.cjs CHANGED
@@ -254,30 +254,90 @@ var init_hashing = __esm({
254
254
  // src/index.ts
255
255
  var index_exports = {};
256
256
  __export(index_exports, {
257
+ ACCEPT_PROPOSAL: () => ACCEPT_PROPOSAL,
258
+ ASK_RESOURCE_PRIMARY_ACCOUNTABLE: () => ASK_RESOURCE_PRIMARY_ACCOUNTABLE,
257
259
  AVAILABILITY_OPTIONS: () => AVAILABILITY_OPTIONS,
258
260
  AuthClient: () => AuthClient,
261
+ CITE_PROJECT: () => CITE_PROJECT,
262
+ CLAIM_DID: () => CLAIM_DID,
259
263
  CO2_THRESHOLDS_KG: () => CO2_THRESHOLDS_KG,
264
+ CONSUME_RESOURCE: () => CONSUME_RESOURCE,
265
+ CONTRIBUTE_TO_PROJECT: () => CONTRIBUTE_TO_PROJECT,
266
+ CREATE_DPP_RESOURCE: () => CREATE_DPP_RESOURCE,
267
+ CREATE_INTENT: () => CREATE_INTENT,
268
+ CREATE_LOCATION: () => CREATE_LOCATION,
269
+ CREATE_MACHINE_RESOURCE: () => CREATE_MACHINE_RESOURCE,
270
+ CREATE_PROCESS: () => CREATE_PROCESS,
271
+ CREATE_PROJECT: () => CREATE_PROJECT,
272
+ CREATE_PROPOSAL: () => CREATE_PROPOSAL,
260
273
  DppClient: () => DppClient,
274
+ EDIT_IMAGES: () => EDIT_IMAGES,
275
+ EDIT_MAIN: () => EDIT_MAIN,
276
+ EDIT_SPECS: () => EDIT_SPECS,
261
277
  ENERGY_THRESHOLDS_KWH: () => ENERGY_THRESHOLDS_KWH,
278
+ FETCH_AGENTS: () => FETCH_AGENTS,
279
+ FETCH_RESOURCES: () => FETCH_RESOURCES,
280
+ FETCH_SELF: () => FETCH_SELF,
281
+ FETCH_USER: () => FETCH_USER,
282
+ FORK_PROJECT: () => FORK_PROJECT,
262
283
  FeedbackClient: () => FeedbackClient,
263
284
  FileClient: () => FileClient,
285
+ GET_PROJECT_LAYOUT: () => GET_PROJECT_LAYOUT,
286
+ GET_RESOURCE_DETAILS: () => GET_RESOURCE_DETAILS,
287
+ GET_TAGS: () => GET_TAGS,
288
+ GET_USER_IMAGES: () => GET_USER_IMAGES,
289
+ GET_USER_LAYOUT: () => GET_USER_LAYOUT,
264
290
  GraphQLClient: () => GraphQLClient,
265
291
  ImportClient: () => ImportClient,
266
292
  InboxClient: () => InboxClient,
267
293
  InterfacerClient: () => InterfacerClient,
294
+ LINK_CONTRIBUTION_PROPOSAL_INTENT: () => LINK_CONTRIBUTION_PROPOSAL_INTENT,
295
+ LINK_PROPOSAL_AND_INTENT: () => LINK_PROPOSAL_AND_INTENT,
268
296
  MANUFACTURABLE_TRUE_TAG: () => MANUFACTURABLE_TRUE_TAG,
297
+ PERSON_EXISTS: () => PERSON_EXISTS,
269
298
  POWER_COMPATIBILITY_OPTIONS: () => POWER_COMPATIBILITY_OPTIONS,
270
299
  POWER_REQUIREMENT_THRESHOLDS_W: () => POWER_REQUIREMENT_THRESHOLDS_W,
271
300
  PRODUCT_CATEGORY_OPTIONS: () => PRODUCT_CATEGORY_OPTIONS,
301
+ PROPOSE_CONTRIBUTION: () => PROPOSE_CONTRIBUTION,
302
+ QUERY_AGENTS: () => QUERY_AGENTS,
303
+ QUERY_CITED_RESOURCES: () => QUERY_CITED_RESOURCES,
304
+ QUERY_MACHINES: () => QUERY_MACHINES,
305
+ QUERY_PROJECTS: () => QUERY_PROJECTS,
306
+ QUERY_PROJECT_FOR_METADATA_UPDATE: () => QUERY_PROJECT_FOR_METADATA_UPDATE,
307
+ QUERY_PROJECT_TYPES: () => QUERY_PROJECT_TYPES,
308
+ QUERY_PROPOSAL: () => QUERY_PROPOSAL,
309
+ QUERY_RESOURCE: () => QUERY_RESOURCE,
310
+ QUERY_RESOURCE_PROPOSALS: () => QUERY_RESOURCE_PROPOSALS,
311
+ QUERY_RESOURCE_TRACE_DPP: () => QUERY_RESOURCE_TRACE_DPP,
312
+ QUERY_UNIT_AND_CURRENCY: () => QUERY_UNIT_AND_CURRENCY,
313
+ QUERY_VARIABLES: () => QUERY_VARIABLES,
272
314
  RECYCLABILITY_THRESHOLDS_PCT: () => RECYCLABILITY_THRESHOLDS_PCT,
315
+ REGISTER_USER: () => REGISTER_USER,
316
+ REJECT_PROPOSAL: () => REJECT_PROPOSAL,
317
+ RELOCATE_PROJECT: () => RELOCATE_PROJECT,
273
318
  REPAIRABILITY_AVAILABLE_TAG: () => REPAIRABILITY_AVAILABLE_TAG,
274
319
  REPLICABILITY_OPTIONS: () => REPLICABILITY_OPTIONS,
275
320
  ResourceClient: () => ResourceClient,
321
+ SATISFY_INTENTS: () => SATISFY_INTENTS,
322
+ SEARCH_PEOPLE: () => SEARCH_PEOPLE,
323
+ SEARCH_PERSON: () => SEARCH_PERSON,
324
+ SEARCH_PROJECT: () => SEARCH_PROJECT,
325
+ SEARCH_PROJECTS: () => SEARCH_PROJECTS,
326
+ SEARCH_TAGS: () => SEARCH_TAGS,
327
+ SELECT_RESOURCES: () => SELECT_RESOURCES,
328
+ SEND_EMAIL_VERIFICATION: () => SEND_EMAIL_VERIFICATION,
276
329
  SERVICE_TYPE_OPTIONS: () => SERVICE_TYPE_OPTIONS,
330
+ SIGN_UP: () => SIGN_UP,
277
331
  SYSTEM_TAG_PREFIXES: () => SYSTEM_TAG_PREFIXES,
278
332
  SocialClient: () => SocialClient,
279
333
  TAG_PREFIX: () => TAG_PREFIX,
334
+ TRANSFER_PROJECT: () => TRANSFER_PROJECT,
280
335
  TaggingClient: () => TaggingClient,
336
+ UPDATE_CONTRIBUTION: () => UPDATE_CONTRIBUTION,
337
+ UPDATE_METADATA: () => UPDATE_METADATA,
338
+ UPDATE_RESOURCE_CLASSIFIED_AS: () => UPDATE_RESOURCE_CLASSIFIED_AS,
339
+ UPDATE_USER: () => UPDATE_USER,
340
+ VERIFY_EMAIL: () => VERIFY_EMAIL,
281
341
  WalletClient: () => WalletClient,
282
342
  clearInstanceVariablesCache: () => clearInstanceVariablesCache,
283
343
  createConfig: () => createConfig,
@@ -394,6 +454,44 @@ function gql(strings, ...values) {
394
454
  }
395
455
 
396
456
  // src/graphql/operations.ts
457
+ var QUERY_VARIABLES = gql`
458
+ query GetVariables {
459
+ instanceVariables {
460
+ specs {
461
+ specCurrency { id name }
462
+ specProjectDesign { id name }
463
+ specProjectProduct { id name }
464
+ specProjectService { id name }
465
+ specDpp { id name }
466
+ specMachine { id name }
467
+ specMaterial { id name }
468
+ }
469
+ units { unitOne { id } }
470
+ }
471
+ }
472
+ `;
473
+ var QUERY_PROJECT_TYPES = gql`
474
+ query GetProjectTypes {
475
+ instanceVariables {
476
+ specs {
477
+ specProjectDesign { id name }
478
+ specProjectProduct { id name }
479
+ specProjectService { id name }
480
+ specDpp { id name }
481
+ specMachine { id name }
482
+ specMaterial { id name }
483
+ }
484
+ }
485
+ }
486
+ `;
487
+ var QUERY_UNIT_AND_CURRENCY = gql`
488
+ query GetUnitAndCurrency {
489
+ instanceVariables {
490
+ units { unitOne { id } }
491
+ specs { specCurrency { id } }
492
+ }
493
+ }
494
+ `;
397
495
  var REGISTER_USER = gql`
398
496
  mutation RegisterUser($firstRegistration: Boolean!, $userData: JSONObject!) {
399
497
  keypairoomServer(firstRegistration: $firstRegistration, userData: $userData)
@@ -432,6 +530,16 @@ var CLAIM_DID = gql`
432
530
  claimPerson(id: $id)
433
531
  }
434
532
  `;
533
+ var PERSON_EXISTS = gql`
534
+ query PersonExists($email: String, $user: String) {
535
+ personExists(email: $email, user: $user)
536
+ }
537
+ `;
538
+ var VERIFY_EMAIL = gql`
539
+ mutation VerifyEmail($token: String!) {
540
+ personVerifyEmailVerification(token: $token)
541
+ }
542
+ `;
435
543
  var QUERY_RESOURCE = gql`
436
544
  query getResourceTable($id: ID!) {
437
545
  economicResource(id: $id) {
@@ -441,7 +549,7 @@ var QUERY_RESOURCE = gql`
441
549
  accountingQuantity { hasUnit { label symbol } hasNumericalValue }
442
550
  primaryAccountable { id name }
443
551
  currentLocation { id name mappableAddress lat long }
444
- images { hash name mimeType bin }
552
+ images { hash name mimeType }
445
553
  }
446
554
  }
447
555
  `;
@@ -484,7 +592,7 @@ var QUERY_PROJECTS = gql`
484
592
  primaryAccountable { name id }
485
593
  name id note metadata
486
594
  onhandQuantity { hasUnit { label } }
487
- images { hash name mimeType bin }
595
+ images { hash name mimeType }
488
596
  }
489
597
  }
490
598
  reciprocalIntents {
@@ -528,7 +636,81 @@ var QUERY_PROJECT_FOR_METADATA_UPDATE = gql`
528
636
  var ASK_RESOURCE_PRIMARY_ACCOUNTABLE = gql`
529
637
  query askResourcePrimaryAccountable($id: ID!) {
530
638
  economicResource(id: $id) {
531
- id name primaryAccountable { id name images { bin mimeType } }
639
+ id name primaryAccountable { id name }
640
+ }
641
+ }
642
+ `;
643
+ var GET_PROJECT_LAYOUT = gql`
644
+ query getProjectLayout($id: ID!) {
645
+ economicResource(id: $id) {
646
+ id name note metadata license licensor repo classifiedAs
647
+ accountingQuantity { hasNumericalValue }
648
+ onhandQuantity { hasUnit { id } hasNumericalValue }
649
+ conformsTo { id name }
650
+ primaryAccountable {
651
+ id name
652
+ primaryLocation { name mappableAddress lat long }
653
+ }
654
+ currentLocation { id name mappableAddress lat long }
655
+ images { hash name mimeType date description extension size }
656
+ }
657
+ }
658
+ `;
659
+ var SEARCH_PROJECT = gql`
660
+ query SearchProject($id: ID!) {
661
+ economicResource(id: $id) {
662
+ id name metadata
663
+ images { hash mimeType }
664
+ conformsTo { name id }
665
+ primaryAccountable { name }
666
+ }
667
+ }
668
+ `;
669
+ var SEARCH_PROJECTS = gql`
670
+ query SearchProjects(
671
+ $last: Int $IDs: [ID!] $name: String
672
+ $conformsTo: [ID!] $primaryAccountable: [ID!]
673
+ ) {
674
+ economicResources(
675
+ last: $last
676
+ filter: { id: $IDs, name: $name, conformsTo: $conformsTo, primaryAccountable: $primaryAccountable }
677
+ ) {
678
+ edges {
679
+ node {
680
+ id name metadata
681
+ conformsTo { id name }
682
+ primaryAccountable { id name }
683
+ images { hash name mimeType }
684
+ }
685
+ }
686
+ }
687
+ }
688
+ `;
689
+ var SELECT_RESOURCES = gql`
690
+ query FetchResources($filter: EconomicResourceFilterParams) {
691
+ economicResources(last: 10, filter: $filter) {
692
+ edges { cursor node { id name } }
693
+ }
694
+ }
695
+ `;
696
+ var EDIT_IMAGES = gql`
697
+ mutation EditImages($id: ID!, $images: [IFile!]) {
698
+ updateEconomicResource(resource: { id: $id, images: $images }) {
699
+ economicResource { id }
700
+ }
701
+ }
702
+ `;
703
+ var EDIT_MAIN = gql`
704
+ mutation EditMain($id: ID!, $classifiedAs: [URI!], $note: String, $name: String, $repo: String) {
705
+ updateEconomicResource(
706
+ resource: { id: $id, classifiedAs: $classifiedAs, name: $name, note: $note, repo: $repo }
707
+ ) { economicResource { id } }
708
+ }
709
+ `;
710
+ var EDIT_SPECS = gql`
711
+ mutation EditSpecs($id: ID!, $classifiedAs: [URI!]) {
712
+ updateEconomicResource(resource: { id: $id, classifiedAs: $classifiedAs }) {
713
+ economicResource { id }
532
714
  }
533
715
  }
534
716
  `;
@@ -589,7 +771,7 @@ var QUERY_PROPOSAL = gql`
589
771
  id provider { id name } receiver { id name }
590
772
  inputOf { name id } outputOf { id name } hasPointInTime
591
773
  resourceInventoriedAs {
592
- id name repo metadata images { hash name mimeType bin }
774
+ id name repo metadata images { hash name mimeType }
593
775
  primaryAccountable { id name } onhandQuantity { hasNumericalValue hasUnit { id } }
594
776
  }
595
777
  resourceConformsTo { id name }
@@ -802,6 +984,18 @@ var UPDATE_RESOURCE_CLASSIFIED_AS = gql`
802
984
  updateEconomicResource(resource: { id: $id classifiedAs: $classifiedAs }) { economicResource { id } }
803
985
  }
804
986
  `;
987
+ var UPDATE_CONTRIBUTION = gql`
988
+ mutation updateContribution(
989
+ $process: ID! $agent: ID! $resource: ID! $quantity: IMeasure!
990
+ $now: DateTime! $metadata: JSONObject! $conformsTo: ID! $unitOne: ID!
991
+ ) {
992
+ contribute: createEconomicEvent(event: {
993
+ action: "work" inputOf: $process provider: $agent receiver: $agent
994
+ resourceConformsTo: $conformsTo hasPointInTime: $now
995
+ effortQuantity: { hasNumericalValue: 1 hasUnit: $unitOne }
996
+ }) { economicEvent { id } }
997
+ }
998
+ `;
805
999
  var RELOCATE_PROJECT = gql`
806
1000
  mutation relocateProject(
807
1001
  $process: ID! $agent: ID! $resource: ID! $quantity: IMeasure! $now: DateTime! $location: ID!
@@ -839,11 +1033,71 @@ var FETCH_USER = gql`
839
1033
  }
840
1034
  }
841
1035
  `;
1036
+ var GET_USER_LAYOUT = gql`
1037
+ query GetUserLayout($id: ID!) {
1038
+ person(id: $id) {
1039
+ id name note email user
1040
+ images { hash name mimeType bin size extension description }
1041
+ ethereumAddress
1042
+ primaryLocation { id name mappableAddress lat long }
1043
+ }
1044
+ }
1045
+ `;
1046
+ var UPDATE_USER = gql`
1047
+ mutation updateUser(
1048
+ $id: ID! $name: String $note: String $primaryLocation: ID $user: String $images: [IFile!]
1049
+ ) {
1050
+ updatePerson(
1051
+ person: { id: $id name: $name note: $note primaryLocation: $primaryLocation user: $user images: $images }
1052
+ ) {
1053
+ agent {
1054
+ id name note
1055
+ images { name }
1056
+ primaryLocation { id lat long name }
1057
+ }
1058
+ }
1059
+ }
1060
+ `;
1061
+ var GET_USER_IMAGES = gql`
1062
+ query GetUserImages($userId: ID!) {
1063
+ person(id: $userId) {
1064
+ id name
1065
+ images { bin mimeType date description extension hash name size }
1066
+ }
1067
+ }
1068
+ `;
1069
+ var SEARCH_PERSON = gql`
1070
+ query getPerson($id: ID!) {
1071
+ person(id: $id) {
1072
+ id name user
1073
+ images { bin mimeType }
1074
+ primaryLocation { id name }
1075
+ }
1076
+ }
1077
+ `;
1078
+ var SEARCH_PEOPLE = gql`
1079
+ query SearchPeople($filter: PersonFilterParams, $last: Int) {
1080
+ people(last: $last, filter: $filter) {
1081
+ edges {
1082
+ node {
1083
+ id name user note
1084
+ images { bin mimeType }
1085
+ primaryLocation { id name }
1086
+ }
1087
+ }
1088
+ }
1089
+ }
1090
+ `;
842
1091
  var GET_TAGS = gql`
843
1092
  query GetTags {
844
1093
  economicResourceClassifications
845
1094
  }
846
1095
  `;
1096
+ var SEARCH_TAGS = gql`
1097
+ query SearchTags($text: URI!) {
1098
+ economicResourceClassifications(filter: { uri: $text })
1099
+ }
1100
+ `;
847
1101
  var GET_RESOURCE_DETAILS = gql`
848
1102
  query GetResourceDetails($id: ID!) {
849
1103
  proposal(id: $id) {
@@ -853,12 +1107,20 @@ var GET_RESOURCE_DETAILS = gql`
853
1107
  resourceInventoriedAs {
854
1108
  conformsTo { name id } currentLocation { name } name id note
855
1109
  classifiedAs metadata primaryAccountable { name id }
856
- onhandQuantity { hasUnit { label } } images { hash name mimeType bin }
1110
+ onhandQuantity { hasUnit { label } } images { hash name mimeType }
857
1111
  }
858
1112
  }
859
1113
  }
860
1114
  }
861
1115
  `;
1116
+ var QUERY_RESOURCE_TRACE_DPP = gql`
1117
+ query GetResourceTraceDpp($id: ID!) {
1118
+ economicResource(id: $id) {
1119
+ id
1120
+ traceDpp
1121
+ }
1122
+ }
1123
+ `;
862
1124
 
863
1125
  // src/auth/AuthClient.ts
864
1126
  var AuthClient = class {
@@ -1898,6 +2160,12 @@ var ResourceClient = class {
1898
2160
  });
1899
2161
  if (satRes.errors?.length) throw new Error(`satisfyIntents failed: ${satRes.errors[0].message}`);
1900
2162
  }
2163
+ async getTraceDpp(id) {
2164
+ const res = await this.graphql.request(QUERY_RESOURCE_TRACE_DPP, { id });
2165
+ if (res.errors?.length) throw new Error(`getTraceDpp failed: ${res.errors[0].message}`);
2166
+ const traceDpp = res.data?.economicResource?.traceDpp;
2167
+ return Array.isArray(traceDpp) ? traceDpp : [];
2168
+ }
1901
2169
  async rejectProposal(intentCite, intentAccept, intentModify) {
1902
2170
  const res = await this.graphql.request(REJECT_PROPOSAL, {
1903
2171
  intentCite,
@@ -2460,30 +2728,90 @@ function createConfig(config) {
2460
2728
  init_sign();
2461
2729
  // Annotate the CommonJS export names for ESM import in node:
2462
2730
  0 && (module.exports = {
2731
+ ACCEPT_PROPOSAL,
2732
+ ASK_RESOURCE_PRIMARY_ACCOUNTABLE,
2463
2733
  AVAILABILITY_OPTIONS,
2464
2734
  AuthClient,
2735
+ CITE_PROJECT,
2736
+ CLAIM_DID,
2465
2737
  CO2_THRESHOLDS_KG,
2738
+ CONSUME_RESOURCE,
2739
+ CONTRIBUTE_TO_PROJECT,
2740
+ CREATE_DPP_RESOURCE,
2741
+ CREATE_INTENT,
2742
+ CREATE_LOCATION,
2743
+ CREATE_MACHINE_RESOURCE,
2744
+ CREATE_PROCESS,
2745
+ CREATE_PROJECT,
2746
+ CREATE_PROPOSAL,
2466
2747
  DppClient,
2748
+ EDIT_IMAGES,
2749
+ EDIT_MAIN,
2750
+ EDIT_SPECS,
2467
2751
  ENERGY_THRESHOLDS_KWH,
2752
+ FETCH_AGENTS,
2753
+ FETCH_RESOURCES,
2754
+ FETCH_SELF,
2755
+ FETCH_USER,
2756
+ FORK_PROJECT,
2468
2757
  FeedbackClient,
2469
2758
  FileClient,
2759
+ GET_PROJECT_LAYOUT,
2760
+ GET_RESOURCE_DETAILS,
2761
+ GET_TAGS,
2762
+ GET_USER_IMAGES,
2763
+ GET_USER_LAYOUT,
2470
2764
  GraphQLClient,
2471
2765
  ImportClient,
2472
2766
  InboxClient,
2473
2767
  InterfacerClient,
2768
+ LINK_CONTRIBUTION_PROPOSAL_INTENT,
2769
+ LINK_PROPOSAL_AND_INTENT,
2474
2770
  MANUFACTURABLE_TRUE_TAG,
2771
+ PERSON_EXISTS,
2475
2772
  POWER_COMPATIBILITY_OPTIONS,
2476
2773
  POWER_REQUIREMENT_THRESHOLDS_W,
2477
2774
  PRODUCT_CATEGORY_OPTIONS,
2775
+ PROPOSE_CONTRIBUTION,
2776
+ QUERY_AGENTS,
2777
+ QUERY_CITED_RESOURCES,
2778
+ QUERY_MACHINES,
2779
+ QUERY_PROJECTS,
2780
+ QUERY_PROJECT_FOR_METADATA_UPDATE,
2781
+ QUERY_PROJECT_TYPES,
2782
+ QUERY_PROPOSAL,
2783
+ QUERY_RESOURCE,
2784
+ QUERY_RESOURCE_PROPOSALS,
2785
+ QUERY_RESOURCE_TRACE_DPP,
2786
+ QUERY_UNIT_AND_CURRENCY,
2787
+ QUERY_VARIABLES,
2478
2788
  RECYCLABILITY_THRESHOLDS_PCT,
2789
+ REGISTER_USER,
2790
+ REJECT_PROPOSAL,
2791
+ RELOCATE_PROJECT,
2479
2792
  REPAIRABILITY_AVAILABLE_TAG,
2480
2793
  REPLICABILITY_OPTIONS,
2481
2794
  ResourceClient,
2795
+ SATISFY_INTENTS,
2796
+ SEARCH_PEOPLE,
2797
+ SEARCH_PERSON,
2798
+ SEARCH_PROJECT,
2799
+ SEARCH_PROJECTS,
2800
+ SEARCH_TAGS,
2801
+ SELECT_RESOURCES,
2802
+ SEND_EMAIL_VERIFICATION,
2482
2803
  SERVICE_TYPE_OPTIONS,
2804
+ SIGN_UP,
2483
2805
  SYSTEM_TAG_PREFIXES,
2484
2806
  SocialClient,
2485
2807
  TAG_PREFIX,
2808
+ TRANSFER_PROJECT,
2486
2809
  TaggingClient,
2810
+ UPDATE_CONTRIBUTION,
2811
+ UPDATE_METADATA,
2812
+ UPDATE_RESOURCE_CLASSIFIED_AS,
2813
+ UPDATE_USER,
2814
+ VERIFY_EMAIL,
2487
2815
  WalletClient,
2488
2816
  clearInstanceVariablesCache,
2489
2817
  createConfig,