@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.cjs +734 -387
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +97 -1
- package/dist/index.d.ts +97 -1
- package/dist/index.js +673 -387
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -254,30 +254,91 @@ 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
|
+
COMPLEXITY_OPTIONS: () => COMPLEXITY_OPTIONS,
|
|
265
|
+
CONSUME_RESOURCE: () => CONSUME_RESOURCE,
|
|
266
|
+
CONTRIBUTE_TO_PROJECT: () => CONTRIBUTE_TO_PROJECT,
|
|
267
|
+
CREATE_DPP_RESOURCE: () => CREATE_DPP_RESOURCE,
|
|
268
|
+
CREATE_INTENT: () => CREATE_INTENT,
|
|
269
|
+
CREATE_LOCATION: () => CREATE_LOCATION,
|
|
270
|
+
CREATE_MACHINE_RESOURCE: () => CREATE_MACHINE_RESOURCE,
|
|
271
|
+
CREATE_PROCESS: () => CREATE_PROCESS,
|
|
272
|
+
CREATE_PROJECT: () => CREATE_PROJECT,
|
|
273
|
+
CREATE_PROPOSAL: () => CREATE_PROPOSAL,
|
|
260
274
|
DppClient: () => DppClient,
|
|
275
|
+
EDIT_IMAGES: () => EDIT_IMAGES,
|
|
276
|
+
EDIT_MAIN: () => EDIT_MAIN,
|
|
277
|
+
EDIT_SPECS: () => EDIT_SPECS,
|
|
261
278
|
ENERGY_THRESHOLDS_KWH: () => ENERGY_THRESHOLDS_KWH,
|
|
279
|
+
FETCH_AGENTS: () => FETCH_AGENTS,
|
|
280
|
+
FETCH_RESOURCES: () => FETCH_RESOURCES,
|
|
281
|
+
FETCH_SELF: () => FETCH_SELF,
|
|
282
|
+
FETCH_USER: () => FETCH_USER,
|
|
283
|
+
FORK_PROJECT: () => FORK_PROJECT,
|
|
262
284
|
FeedbackClient: () => FeedbackClient,
|
|
263
285
|
FileClient: () => FileClient,
|
|
286
|
+
GET_PROJECT_LAYOUT: () => GET_PROJECT_LAYOUT,
|
|
287
|
+
GET_RESOURCE_DETAILS: () => GET_RESOURCE_DETAILS,
|
|
288
|
+
GET_TAGS: () => GET_TAGS,
|
|
289
|
+
GET_USER_IMAGES: () => GET_USER_IMAGES,
|
|
290
|
+
GET_USER_LAYOUT: () => GET_USER_LAYOUT,
|
|
264
291
|
GraphQLClient: () => GraphQLClient,
|
|
265
292
|
ImportClient: () => ImportClient,
|
|
266
293
|
InboxClient: () => InboxClient,
|
|
267
294
|
InterfacerClient: () => InterfacerClient,
|
|
295
|
+
LINK_CONTRIBUTION_PROPOSAL_INTENT: () => LINK_CONTRIBUTION_PROPOSAL_INTENT,
|
|
296
|
+
LINK_PROPOSAL_AND_INTENT: () => LINK_PROPOSAL_AND_INTENT,
|
|
268
297
|
MANUFACTURABLE_TRUE_TAG: () => MANUFACTURABLE_TRUE_TAG,
|
|
298
|
+
PERSON_EXISTS: () => PERSON_EXISTS,
|
|
269
299
|
POWER_COMPATIBILITY_OPTIONS: () => POWER_COMPATIBILITY_OPTIONS,
|
|
270
300
|
POWER_REQUIREMENT_THRESHOLDS_W: () => POWER_REQUIREMENT_THRESHOLDS_W,
|
|
271
301
|
PRODUCT_CATEGORY_OPTIONS: () => PRODUCT_CATEGORY_OPTIONS,
|
|
302
|
+
PROPOSE_CONTRIBUTION: () => PROPOSE_CONTRIBUTION,
|
|
303
|
+
QUERY_AGENTS: () => QUERY_AGENTS,
|
|
304
|
+
QUERY_CITED_RESOURCES: () => QUERY_CITED_RESOURCES,
|
|
305
|
+
QUERY_MACHINES: () => QUERY_MACHINES,
|
|
306
|
+
QUERY_PROJECTS: () => QUERY_PROJECTS,
|
|
307
|
+
QUERY_PROJECT_FOR_METADATA_UPDATE: () => QUERY_PROJECT_FOR_METADATA_UPDATE,
|
|
308
|
+
QUERY_PROJECT_TYPES: () => QUERY_PROJECT_TYPES,
|
|
309
|
+
QUERY_PROPOSAL: () => QUERY_PROPOSAL,
|
|
310
|
+
QUERY_RESOURCE: () => QUERY_RESOURCE,
|
|
311
|
+
QUERY_RESOURCE_PROPOSALS: () => QUERY_RESOURCE_PROPOSALS,
|
|
312
|
+
QUERY_RESOURCE_TRACE_DPP: () => QUERY_RESOURCE_TRACE_DPP,
|
|
313
|
+
QUERY_UNIT_AND_CURRENCY: () => QUERY_UNIT_AND_CURRENCY,
|
|
314
|
+
QUERY_VARIABLES: () => QUERY_VARIABLES,
|
|
272
315
|
RECYCLABILITY_THRESHOLDS_PCT: () => RECYCLABILITY_THRESHOLDS_PCT,
|
|
316
|
+
REGISTER_USER: () => REGISTER_USER,
|
|
317
|
+
REJECT_PROPOSAL: () => REJECT_PROPOSAL,
|
|
318
|
+
RELOCATE_PROJECT: () => RELOCATE_PROJECT,
|
|
273
319
|
REPAIRABILITY_AVAILABLE_TAG: () => REPAIRABILITY_AVAILABLE_TAG,
|
|
274
320
|
REPLICABILITY_OPTIONS: () => REPLICABILITY_OPTIONS,
|
|
275
321
|
ResourceClient: () => ResourceClient,
|
|
322
|
+
SATISFY_INTENTS: () => SATISFY_INTENTS,
|
|
323
|
+
SEARCH_PEOPLE: () => SEARCH_PEOPLE,
|
|
324
|
+
SEARCH_PERSON: () => SEARCH_PERSON,
|
|
325
|
+
SEARCH_PROJECT: () => SEARCH_PROJECT,
|
|
326
|
+
SEARCH_PROJECTS: () => SEARCH_PROJECTS,
|
|
327
|
+
SEARCH_TAGS: () => SEARCH_TAGS,
|
|
328
|
+
SELECT_RESOURCES: () => SELECT_RESOURCES,
|
|
329
|
+
SEND_EMAIL_VERIFICATION: () => SEND_EMAIL_VERIFICATION,
|
|
276
330
|
SERVICE_TYPE_OPTIONS: () => SERVICE_TYPE_OPTIONS,
|
|
331
|
+
SIGN_UP: () => SIGN_UP,
|
|
277
332
|
SYSTEM_TAG_PREFIXES: () => SYSTEM_TAG_PREFIXES,
|
|
278
333
|
SocialClient: () => SocialClient,
|
|
279
334
|
TAG_PREFIX: () => TAG_PREFIX,
|
|
335
|
+
TRANSFER_PROJECT: () => TRANSFER_PROJECT,
|
|
280
336
|
TaggingClient: () => TaggingClient,
|
|
337
|
+
UPDATE_CONTRIBUTION: () => UPDATE_CONTRIBUTION,
|
|
338
|
+
UPDATE_METADATA: () => UPDATE_METADATA,
|
|
339
|
+
UPDATE_RESOURCE_CLASSIFIED_AS: () => UPDATE_RESOURCE_CLASSIFIED_AS,
|
|
340
|
+
UPDATE_USER: () => UPDATE_USER,
|
|
341
|
+
VERIFY_EMAIL: () => VERIFY_EMAIL,
|
|
281
342
|
WalletClient: () => WalletClient,
|
|
282
343
|
clearInstanceVariablesCache: () => clearInstanceVariablesCache,
|
|
283
344
|
createConfig: () => createConfig,
|
|
@@ -394,6 +455,44 @@ function gql(strings, ...values) {
|
|
|
394
455
|
}
|
|
395
456
|
|
|
396
457
|
// src/graphql/operations.ts
|
|
458
|
+
var QUERY_VARIABLES = gql`
|
|
459
|
+
query GetVariables {
|
|
460
|
+
instanceVariables {
|
|
461
|
+
specs {
|
|
462
|
+
specCurrency { id name }
|
|
463
|
+
specProjectDesign { id name }
|
|
464
|
+
specProjectProduct { id name }
|
|
465
|
+
specProjectService { id name }
|
|
466
|
+
specDpp { id name }
|
|
467
|
+
specMachine { id name }
|
|
468
|
+
specMaterial { id name }
|
|
469
|
+
}
|
|
470
|
+
units { unitOne { id } }
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
`;
|
|
474
|
+
var QUERY_PROJECT_TYPES = gql`
|
|
475
|
+
query GetProjectTypes {
|
|
476
|
+
instanceVariables {
|
|
477
|
+
specs {
|
|
478
|
+
specProjectDesign { id name }
|
|
479
|
+
specProjectProduct { id name }
|
|
480
|
+
specProjectService { id name }
|
|
481
|
+
specDpp { id name }
|
|
482
|
+
specMachine { id name }
|
|
483
|
+
specMaterial { id name }
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
`;
|
|
488
|
+
var QUERY_UNIT_AND_CURRENCY = gql`
|
|
489
|
+
query GetUnitAndCurrency {
|
|
490
|
+
instanceVariables {
|
|
491
|
+
units { unitOne { id } }
|
|
492
|
+
specs { specCurrency { id } }
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
`;
|
|
397
496
|
var REGISTER_USER = gql`
|
|
398
497
|
mutation RegisterUser($firstRegistration: Boolean!, $userData: JSONObject!) {
|
|
399
498
|
keypairoomServer(firstRegistration: $firstRegistration, userData: $userData)
|
|
@@ -432,6 +531,16 @@ var CLAIM_DID = gql`
|
|
|
432
531
|
claimPerson(id: $id)
|
|
433
532
|
}
|
|
434
533
|
`;
|
|
534
|
+
var PERSON_EXISTS = gql`
|
|
535
|
+
query PersonExists($email: String, $user: String) {
|
|
536
|
+
personExists(email: $email, user: $user)
|
|
537
|
+
}
|
|
538
|
+
`;
|
|
539
|
+
var VERIFY_EMAIL = gql`
|
|
540
|
+
mutation VerifyEmail($token: String!) {
|
|
541
|
+
personVerifyEmailVerification(token: $token)
|
|
542
|
+
}
|
|
543
|
+
`;
|
|
435
544
|
var QUERY_RESOURCE = gql`
|
|
436
545
|
query getResourceTable($id: ID!) {
|
|
437
546
|
economicResource(id: $id) {
|
|
@@ -441,7 +550,7 @@ var QUERY_RESOURCE = gql`
|
|
|
441
550
|
accountingQuantity { hasUnit { label symbol } hasNumericalValue }
|
|
442
551
|
primaryAccountable { id name }
|
|
443
552
|
currentLocation { id name mappableAddress lat long }
|
|
444
|
-
images { hash name mimeType
|
|
553
|
+
images { hash name mimeType }
|
|
445
554
|
}
|
|
446
555
|
}
|
|
447
556
|
`;
|
|
@@ -484,7 +593,7 @@ var QUERY_PROJECTS = gql`
|
|
|
484
593
|
primaryAccountable { name id }
|
|
485
594
|
name id note metadata
|
|
486
595
|
onhandQuantity { hasUnit { label } }
|
|
487
|
-
images { hash name mimeType
|
|
596
|
+
images { hash name mimeType }
|
|
488
597
|
}
|
|
489
598
|
}
|
|
490
599
|
reciprocalIntents {
|
|
@@ -528,7 +637,81 @@ var QUERY_PROJECT_FOR_METADATA_UPDATE = gql`
|
|
|
528
637
|
var ASK_RESOURCE_PRIMARY_ACCOUNTABLE = gql`
|
|
529
638
|
query askResourcePrimaryAccountable($id: ID!) {
|
|
530
639
|
economicResource(id: $id) {
|
|
531
|
-
id name primaryAccountable { id name
|
|
640
|
+
id name primaryAccountable { id name }
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
`;
|
|
644
|
+
var GET_PROJECT_LAYOUT = gql`
|
|
645
|
+
query getProjectLayout($id: ID!) {
|
|
646
|
+
economicResource(id: $id) {
|
|
647
|
+
id name note metadata license licensor repo classifiedAs
|
|
648
|
+
accountingQuantity { hasNumericalValue }
|
|
649
|
+
onhandQuantity { hasUnit { id } hasNumericalValue }
|
|
650
|
+
conformsTo { id name }
|
|
651
|
+
primaryAccountable {
|
|
652
|
+
id name
|
|
653
|
+
primaryLocation { name mappableAddress lat long }
|
|
654
|
+
}
|
|
655
|
+
currentLocation { id name mappableAddress lat long }
|
|
656
|
+
images { hash name mimeType date description extension size }
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
`;
|
|
660
|
+
var SEARCH_PROJECT = gql`
|
|
661
|
+
query SearchProject($id: ID!) {
|
|
662
|
+
economicResource(id: $id) {
|
|
663
|
+
id name metadata
|
|
664
|
+
images { hash mimeType }
|
|
665
|
+
conformsTo { name id }
|
|
666
|
+
primaryAccountable { name }
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
`;
|
|
670
|
+
var SEARCH_PROJECTS = gql`
|
|
671
|
+
query SearchProjects(
|
|
672
|
+
$last: Int $IDs: [ID!] $name: String
|
|
673
|
+
$conformsTo: [ID!] $primaryAccountable: [ID!]
|
|
674
|
+
) {
|
|
675
|
+
economicResources(
|
|
676
|
+
last: $last
|
|
677
|
+
filter: { id: $IDs, name: $name, conformsTo: $conformsTo, primaryAccountable: $primaryAccountable }
|
|
678
|
+
) {
|
|
679
|
+
edges {
|
|
680
|
+
node {
|
|
681
|
+
id name metadata
|
|
682
|
+
conformsTo { id name }
|
|
683
|
+
primaryAccountable { id name }
|
|
684
|
+
images { hash name mimeType }
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
`;
|
|
690
|
+
var SELECT_RESOURCES = gql`
|
|
691
|
+
query FetchResources($filter: EconomicResourceFilterParams) {
|
|
692
|
+
economicResources(last: 10, filter: $filter) {
|
|
693
|
+
edges { cursor node { id name } }
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
`;
|
|
697
|
+
var EDIT_IMAGES = gql`
|
|
698
|
+
mutation EditImages($id: ID!, $images: [IFile!]) {
|
|
699
|
+
updateEconomicResource(resource: { id: $id, images: $images }) {
|
|
700
|
+
economicResource { id }
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
`;
|
|
704
|
+
var EDIT_MAIN = gql`
|
|
705
|
+
mutation EditMain($id: ID!, $classifiedAs: [URI!], $note: String, $name: String, $repo: String) {
|
|
706
|
+
updateEconomicResource(
|
|
707
|
+
resource: { id: $id, classifiedAs: $classifiedAs, name: $name, note: $note, repo: $repo }
|
|
708
|
+
) { economicResource { id } }
|
|
709
|
+
}
|
|
710
|
+
`;
|
|
711
|
+
var EDIT_SPECS = gql`
|
|
712
|
+
mutation EditSpecs($id: ID!, $classifiedAs: [URI!]) {
|
|
713
|
+
updateEconomicResource(resource: { id: $id, classifiedAs: $classifiedAs }) {
|
|
714
|
+
economicResource { id }
|
|
532
715
|
}
|
|
533
716
|
}
|
|
534
717
|
`;
|
|
@@ -589,7 +772,7 @@ var QUERY_PROPOSAL = gql`
|
|
|
589
772
|
id provider { id name } receiver { id name }
|
|
590
773
|
inputOf { name id } outputOf { id name } hasPointInTime
|
|
591
774
|
resourceInventoriedAs {
|
|
592
|
-
id name repo metadata images { hash name mimeType
|
|
775
|
+
id name repo metadata images { hash name mimeType }
|
|
593
776
|
primaryAccountable { id name } onhandQuantity { hasNumericalValue hasUnit { id } }
|
|
594
777
|
}
|
|
595
778
|
resourceConformsTo { id name }
|
|
@@ -673,13 +856,14 @@ var CREATE_PROJECT = gql`
|
|
|
673
856
|
var CREATE_MACHINE_RESOURCE = gql`
|
|
674
857
|
mutation createMachineResource(
|
|
675
858
|
$agent: ID! $creationTime: DateTime! $process: ID! $resourceSpec: ID!
|
|
676
|
-
$unitOne: ID! $name: String! $note: String $metadata: JSONObject
|
|
859
|
+
$unitOne: ID! $name: String! $note: String $metadata: JSONObject $tags: [URI!]
|
|
677
860
|
) {
|
|
678
861
|
createEconomicEvent(
|
|
679
862
|
event: {
|
|
680
863
|
action: "produce" outputOf: $process provider: $agent receiver: $agent
|
|
681
864
|
hasPointInTime: $creationTime resourceConformsTo: $resourceSpec
|
|
682
865
|
resourceQuantity: { hasNumericalValue: 1 hasUnit: $unitOne } resourceMetadata: $metadata
|
|
866
|
+
resourceClassifiedAs: $tags
|
|
683
867
|
}
|
|
684
868
|
newInventoriedResource: { name: $name note: $note }
|
|
685
869
|
) {
|
|
@@ -802,6 +986,18 @@ var UPDATE_RESOURCE_CLASSIFIED_AS = gql`
|
|
|
802
986
|
updateEconomicResource(resource: { id: $id classifiedAs: $classifiedAs }) { economicResource { id } }
|
|
803
987
|
}
|
|
804
988
|
`;
|
|
989
|
+
var UPDATE_CONTRIBUTION = gql`
|
|
990
|
+
mutation updateContribution(
|
|
991
|
+
$process: ID! $agent: ID! $resource: ID! $quantity: IMeasure!
|
|
992
|
+
$now: DateTime! $metadata: JSONObject! $conformsTo: ID! $unitOne: ID!
|
|
993
|
+
) {
|
|
994
|
+
contribute: createEconomicEvent(event: {
|
|
995
|
+
action: "work" inputOf: $process provider: $agent receiver: $agent
|
|
996
|
+
resourceConformsTo: $conformsTo hasPointInTime: $now
|
|
997
|
+
effortQuantity: { hasNumericalValue: 1 hasUnit: $unitOne }
|
|
998
|
+
}) { economicEvent { id } }
|
|
999
|
+
}
|
|
1000
|
+
`;
|
|
805
1001
|
var RELOCATE_PROJECT = gql`
|
|
806
1002
|
mutation relocateProject(
|
|
807
1003
|
$process: ID! $agent: ID! $resource: ID! $quantity: IMeasure! $now: DateTime! $location: ID!
|
|
@@ -839,11 +1035,71 @@ var FETCH_USER = gql`
|
|
|
839
1035
|
}
|
|
840
1036
|
}
|
|
841
1037
|
`;
|
|
1038
|
+
var GET_USER_LAYOUT = gql`
|
|
1039
|
+
query GetUserLayout($id: ID!) {
|
|
1040
|
+
person(id: $id) {
|
|
1041
|
+
id name note email user
|
|
1042
|
+
images { hash name mimeType bin size extension description }
|
|
1043
|
+
ethereumAddress
|
|
1044
|
+
primaryLocation { id name mappableAddress lat long }
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
`;
|
|
1048
|
+
var UPDATE_USER = gql`
|
|
1049
|
+
mutation updateUser(
|
|
1050
|
+
$id: ID! $name: String $note: String $primaryLocation: ID $user: String $images: [IFile!]
|
|
1051
|
+
) {
|
|
1052
|
+
updatePerson(
|
|
1053
|
+
person: { id: $id name: $name note: $note primaryLocation: $primaryLocation user: $user images: $images }
|
|
1054
|
+
) {
|
|
1055
|
+
agent {
|
|
1056
|
+
id name note
|
|
1057
|
+
images { name }
|
|
1058
|
+
primaryLocation { id lat long name }
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
`;
|
|
1063
|
+
var GET_USER_IMAGES = gql`
|
|
1064
|
+
query GetUserImages($userId: ID!) {
|
|
1065
|
+
person(id: $userId) {
|
|
1066
|
+
id name
|
|
1067
|
+
images { bin mimeType date description extension hash name size }
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
`;
|
|
1071
|
+
var SEARCH_PERSON = gql`
|
|
1072
|
+
query getPerson($id: ID!) {
|
|
1073
|
+
person(id: $id) {
|
|
1074
|
+
id name user
|
|
1075
|
+
images { bin mimeType }
|
|
1076
|
+
primaryLocation { id name }
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
`;
|
|
1080
|
+
var SEARCH_PEOPLE = gql`
|
|
1081
|
+
query SearchPeople($filter: PersonFilterParams, $last: Int) {
|
|
1082
|
+
people(last: $last, filter: $filter) {
|
|
1083
|
+
edges {
|
|
1084
|
+
node {
|
|
1085
|
+
id name user note
|
|
1086
|
+
images { bin mimeType }
|
|
1087
|
+
primaryLocation { id name }
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
`;
|
|
842
1093
|
var GET_TAGS = gql`
|
|
843
1094
|
query GetTags {
|
|
844
1095
|
economicResourceClassifications
|
|
845
1096
|
}
|
|
846
1097
|
`;
|
|
1098
|
+
var SEARCH_TAGS = gql`
|
|
1099
|
+
query SearchTags($text: URI!) {
|
|
1100
|
+
economicResourceClassifications(filter: { uri: $text })
|
|
1101
|
+
}
|
|
1102
|
+
`;
|
|
847
1103
|
var GET_RESOURCE_DETAILS = gql`
|
|
848
1104
|
query GetResourceDetails($id: ID!) {
|
|
849
1105
|
proposal(id: $id) {
|
|
@@ -853,12 +1109,20 @@ var GET_RESOURCE_DETAILS = gql`
|
|
|
853
1109
|
resourceInventoriedAs {
|
|
854
1110
|
conformsTo { name id } currentLocation { name } name id note
|
|
855
1111
|
classifiedAs metadata primaryAccountable { name id }
|
|
856
|
-
onhandQuantity { hasUnit { label } } images { hash name mimeType
|
|
1112
|
+
onhandQuantity { hasUnit { label } } images { hash name mimeType }
|
|
857
1113
|
}
|
|
858
1114
|
}
|
|
859
1115
|
}
|
|
860
1116
|
}
|
|
861
1117
|
`;
|
|
1118
|
+
var QUERY_RESOURCE_TRACE_DPP = gql`
|
|
1119
|
+
query GetResourceTraceDpp($id: ID!) {
|
|
1120
|
+
economicResource(id: $id) {
|
|
1121
|
+
id
|
|
1122
|
+
traceDpp
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
`;
|
|
862
1126
|
|
|
863
1127
|
// src/auth/AuthClient.ts
|
|
864
1128
|
var AuthClient = class {
|
|
@@ -1621,385 +1885,6 @@ function clearInstanceVariablesCache() {
|
|
|
1621
1885
|
cachedVars = null;
|
|
1622
1886
|
}
|
|
1623
1887
|
|
|
1624
|
-
// src/resources/ResourceClient.ts
|
|
1625
|
-
var ResourceClient = class {
|
|
1626
|
-
constructor(config, store, graphql) {
|
|
1627
|
-
this.config = config;
|
|
1628
|
-
this.store = store;
|
|
1629
|
-
this.graphql = graphql;
|
|
1630
|
-
}
|
|
1631
|
-
config;
|
|
1632
|
-
store;
|
|
1633
|
-
graphql;
|
|
1634
|
-
get userId() {
|
|
1635
|
-
const id = this.store.getItem("authId");
|
|
1636
|
-
if (!id) throw new Error("Not authenticated");
|
|
1637
|
-
return id;
|
|
1638
|
-
}
|
|
1639
|
-
async getInstanceVars() {
|
|
1640
|
-
return getInstanceVariables(this.graphql);
|
|
1641
|
-
}
|
|
1642
|
-
// ─── Helpers ───────────────────────────────────────────────────────
|
|
1643
|
-
specIdForType(vars, type) {
|
|
1644
|
-
switch (type) {
|
|
1645
|
-
case "Design" /* DESIGN */:
|
|
1646
|
-
return vars.projectDesign.id;
|
|
1647
|
-
case "Product" /* PRODUCT */:
|
|
1648
|
-
return vars.projectProduct?.id || this.config.specs?.product || "";
|
|
1649
|
-
case "Service" /* SERVICE */:
|
|
1650
|
-
return vars.projectService?.id || this.config.specs?.service || "";
|
|
1651
|
-
case "Machine" /* MACHINE */:
|
|
1652
|
-
return vars.machine?.id || this.config.specs?.machine || "";
|
|
1653
|
-
case "DPP" /* DPP */:
|
|
1654
|
-
return vars.dpp?.id || this.config.specs?.dpp || "";
|
|
1655
|
-
}
|
|
1656
|
-
}
|
|
1657
|
-
// ─── Process ───────────────────────────────────────────────────────
|
|
1658
|
-
async createProcess(name) {
|
|
1659
|
-
const res = await this.graphql.request(
|
|
1660
|
-
CREATE_PROCESS,
|
|
1661
|
-
{ name }
|
|
1662
|
-
);
|
|
1663
|
-
if (res.errors?.length) throw new Error(`createProcess failed: ${res.errors[0].message}`);
|
|
1664
|
-
return res.data.createProcess.process.id;
|
|
1665
|
-
}
|
|
1666
|
-
// ─── Location ──────────────────────────────────────────────────────
|
|
1667
|
-
async createLocation(params) {
|
|
1668
|
-
const res = await this.graphql.request(CREATE_LOCATION, {
|
|
1669
|
-
name: params.name,
|
|
1670
|
-
addr: params.address || "",
|
|
1671
|
-
lat: params.lat || 0,
|
|
1672
|
-
lng: params.lng || 0
|
|
1673
|
-
});
|
|
1674
|
-
if (res.errors?.length) throw new Error(`createLocation failed: ${res.errors[0].message}`);
|
|
1675
|
-
return res.data.createSpatialThing.spatialThing;
|
|
1676
|
-
}
|
|
1677
|
-
// ─── Create Project (Design, Product, Service) ─────────────────────
|
|
1678
|
-
async createProject(params) {
|
|
1679
|
-
const vars = await this.getInstanceVars();
|
|
1680
|
-
const specId = this.specIdForType(vars, params.projectType);
|
|
1681
|
-
if (!specId) throw new Error(`${params.projectType} spec ID not found in instance variables or config`);
|
|
1682
|
-
const processId = params.processId || await this.createProcess(`creation of ${params.name} by owner`);
|
|
1683
|
-
let locationId = params.locationId;
|
|
1684
|
-
if (!locationId && params.location) {
|
|
1685
|
-
const loc = await this.createLocation(params.location);
|
|
1686
|
-
locationId = loc.id;
|
|
1687
|
-
}
|
|
1688
|
-
const variables = {
|
|
1689
|
-
name: params.name,
|
|
1690
|
-
note: params.note || "",
|
|
1691
|
-
metadata: JSON.stringify(params.metadata || {}),
|
|
1692
|
-
agent: this.userId,
|
|
1693
|
-
creationTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1694
|
-
location: locationId,
|
|
1695
|
-
resourceSpec: specId,
|
|
1696
|
-
oneUnit: vars.unitOne,
|
|
1697
|
-
images: params.images || [],
|
|
1698
|
-
repo: params.repo || "",
|
|
1699
|
-
process: processId,
|
|
1700
|
-
license: params.license || ""
|
|
1701
|
-
};
|
|
1702
|
-
if (params.tags && params.tags.length > 0) {
|
|
1703
|
-
variables.tags = params.tags;
|
|
1704
|
-
}
|
|
1705
|
-
const res = await this.graphql.request(CREATE_PROJECT, variables);
|
|
1706
|
-
if (res.errors?.length) throw new Error(`createProject failed: ${res.errors[0].message}`);
|
|
1707
|
-
return res.data.createEconomicEvent.economicEvent.resourceInventoriedAs;
|
|
1708
|
-
}
|
|
1709
|
-
// ─── Create Machine ────────────────────────────────────────────────
|
|
1710
|
-
async createMachine(params) {
|
|
1711
|
-
const vars = await this.getInstanceVars();
|
|
1712
|
-
const machineSpecId = vars.machine?.id || this.config.specs?.machine;
|
|
1713
|
-
if (!machineSpecId) throw new Error("Machine spec ID not found in instance variables or config");
|
|
1714
|
-
const processId = await this.createProcess(`creation of machine ${params.name}`);
|
|
1715
|
-
const res = await this.graphql.request(CREATE_MACHINE_RESOURCE, {
|
|
1716
|
-
agent: this.userId,
|
|
1717
|
-
creationTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1718
|
-
process: processId,
|
|
1719
|
-
resourceSpec: machineSpecId,
|
|
1720
|
-
unitOne: vars.unitOne,
|
|
1721
|
-
name: params.name,
|
|
1722
|
-
note: params.note || "",
|
|
1723
|
-
metadata: JSON.stringify(params.metadata || {})
|
|
1724
|
-
});
|
|
1725
|
-
if (res.errors?.length) throw new Error(`createMachine failed: ${res.errors[0].message}`);
|
|
1726
|
-
return res.data.createEconomicEvent.economicEvent.resourceInventoriedAs;
|
|
1727
|
-
}
|
|
1728
|
-
// ─── Create DPP Resource ───────────────────────────────────────────
|
|
1729
|
-
async createDppResource(params) {
|
|
1730
|
-
const vars = await this.getInstanceVars();
|
|
1731
|
-
const dppSpecId = vars.dpp?.id || this.config.specs?.dpp;
|
|
1732
|
-
if (!dppSpecId) throw new Error("DPP spec ID not found in instance variables or config");
|
|
1733
|
-
const processId = await this.createProcess(`DPP creation for ${params.name}`);
|
|
1734
|
-
const res = await this.graphql.request(CREATE_DPP_RESOURCE, {
|
|
1735
|
-
agent: this.userId,
|
|
1736
|
-
creationTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1737
|
-
process: processId,
|
|
1738
|
-
resourceSpec: dppSpecId,
|
|
1739
|
-
unitOne: vars.unitOne,
|
|
1740
|
-
dppUlid: JSON.stringify({ dppServiceUlid: params.dppUlid }),
|
|
1741
|
-
name: params.name,
|
|
1742
|
-
note: params.note || ""
|
|
1743
|
-
});
|
|
1744
|
-
if (res.errors?.length) throw new Error(`createDppResource failed: ${res.errors[0].message}`);
|
|
1745
|
-
return res.data.createEconomicEvent.economicEvent.resourceInventoriedAs;
|
|
1746
|
-
}
|
|
1747
|
-
// ─── Queries ───────────────────────────────────────────────────────
|
|
1748
|
-
async getResource(id) {
|
|
1749
|
-
const res = await this.graphql.request(
|
|
1750
|
-
QUERY_RESOURCE,
|
|
1751
|
-
{ id }
|
|
1752
|
-
);
|
|
1753
|
-
return res.data?.economicResource ?? null;
|
|
1754
|
-
}
|
|
1755
|
-
async listResources(filter, pagination) {
|
|
1756
|
-
const res = await this.graphql.request(FETCH_RESOURCES, {
|
|
1757
|
-
...pagination,
|
|
1758
|
-
filter: filter || {}
|
|
1759
|
-
});
|
|
1760
|
-
return res.data || {};
|
|
1761
|
-
}
|
|
1762
|
-
async getProjects(filter, pagination) {
|
|
1763
|
-
const res = await this.graphql.request(QUERY_PROJECTS, {
|
|
1764
|
-
...pagination,
|
|
1765
|
-
filter: filter || {}
|
|
1766
|
-
});
|
|
1767
|
-
return res.data || {};
|
|
1768
|
-
}
|
|
1769
|
-
async getMachines() {
|
|
1770
|
-
const vars = await this.getInstanceVars();
|
|
1771
|
-
const machineSpecId = vars.machine?.id || this.config.specs?.machine;
|
|
1772
|
-
if (!machineSpecId) throw new Error("Machine spec ID not found in instance variables or config");
|
|
1773
|
-
const res = await this.graphql.request(QUERY_MACHINES, {
|
|
1774
|
-
resourceSpecId: machineSpecId
|
|
1775
|
-
});
|
|
1776
|
-
return res.data || {};
|
|
1777
|
-
}
|
|
1778
|
-
// ─── Relations ─────────────────────────────────────────────────────
|
|
1779
|
-
async citeResource(resourceId, processId) {
|
|
1780
|
-
const vars = await this.getInstanceVars();
|
|
1781
|
-
const res = await this.graphql.request(CITE_PROJECT, {
|
|
1782
|
-
agent: this.userId,
|
|
1783
|
-
creationTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1784
|
-
resource: resourceId,
|
|
1785
|
-
process: processId,
|
|
1786
|
-
unitOne: vars.unitOne
|
|
1787
|
-
});
|
|
1788
|
-
if (res.errors?.length) throw new Error(`citeResource failed: ${res.errors[0].message}`);
|
|
1789
|
-
}
|
|
1790
|
-
async consumeResource(resourceId, processId) {
|
|
1791
|
-
const vars = await this.getInstanceVars();
|
|
1792
|
-
const res = await this.graphql.request(CONSUME_RESOURCE, {
|
|
1793
|
-
agent: this.userId,
|
|
1794
|
-
creationTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1795
|
-
resource: resourceId,
|
|
1796
|
-
process: processId,
|
|
1797
|
-
unitOne: vars.unitOne
|
|
1798
|
-
});
|
|
1799
|
-
if (res.errors?.length) throw new Error(`consumeResource failed: ${res.errors[0].message}`);
|
|
1800
|
-
}
|
|
1801
|
-
async contributeToResource(processId, contributionTypeSpecId) {
|
|
1802
|
-
const vars = await this.getInstanceVars();
|
|
1803
|
-
const res = await this.graphql.request(CONTRIBUTE_TO_PROJECT, {
|
|
1804
|
-
agent: this.userId,
|
|
1805
|
-
creationTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1806
|
-
process: processId,
|
|
1807
|
-
unitOne: vars.unitOne,
|
|
1808
|
-
conformsTo: contributionTypeSpecId
|
|
1809
|
-
});
|
|
1810
|
-
if (res.errors?.length) throw new Error(`contribute failed: ${res.errors[0].message}`);
|
|
1811
|
-
}
|
|
1812
|
-
// ─── Metadata ──────────────────────────────────────────────────────
|
|
1813
|
-
async updateMetadata(resourceId, metadata, quantity) {
|
|
1814
|
-
const res = await this.graphql.request(UPDATE_METADATA, {
|
|
1815
|
-
process: await this.createProcess(`metadata update`),
|
|
1816
|
-
agent: this.userId,
|
|
1817
|
-
resource: resourceId,
|
|
1818
|
-
quantity: quantity || { hasNumericalValue: 1, hasUnit: (await this.getInstanceVars()).unitOne },
|
|
1819
|
-
now: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1820
|
-
metadata: JSON.stringify(metadata)
|
|
1821
|
-
});
|
|
1822
|
-
if (res.errors?.length) throw new Error(`updateMetadata failed: ${res.errors[0].message}`);
|
|
1823
|
-
}
|
|
1824
|
-
async updateClassifiedAs(resourceId, tags) {
|
|
1825
|
-
const res = await this.graphql.request(UPDATE_RESOURCE_CLASSIFIED_AS, {
|
|
1826
|
-
id: resourceId,
|
|
1827
|
-
classifiedAs: tags
|
|
1828
|
-
});
|
|
1829
|
-
if (res.errors?.length) throw new Error(`updateClassifiedAs failed: ${res.errors[0].message}`);
|
|
1830
|
-
}
|
|
1831
|
-
async relocateResource(resourceId, locationId) {
|
|
1832
|
-
const vars = await this.getInstanceVars();
|
|
1833
|
-
const res = await this.graphql.request(RELOCATE_PROJECT, {
|
|
1834
|
-
process: await this.createProcess(`relocate`),
|
|
1835
|
-
agent: this.userId,
|
|
1836
|
-
resource: resourceId,
|
|
1837
|
-
quantity: { hasNumericalValue: 1, hasUnit: vars.unitOne },
|
|
1838
|
-
now: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1839
|
-
location: locationId
|
|
1840
|
-
});
|
|
1841
|
-
if (res.errors?.length) throw new Error(`relocate failed: ${res.errors[0].message}`);
|
|
1842
|
-
}
|
|
1843
|
-
// ─── Proposals ─────────────────────────────────────────────────────
|
|
1844
|
-
async proposeContribution(params) {
|
|
1845
|
-
const vars = await this.getInstanceVars();
|
|
1846
|
-
const processId = await this.createProcess("contribution proposal");
|
|
1847
|
-
const creationTime = (/* @__PURE__ */ new Date()).toISOString();
|
|
1848
|
-
const intentsRes = await this.graphql.request(PROPOSE_CONTRIBUTION, {
|
|
1849
|
-
process: processId,
|
|
1850
|
-
owner: params.ownerId,
|
|
1851
|
-
proposer: this.userId,
|
|
1852
|
-
creationTime,
|
|
1853
|
-
resourceForked: params.resourceForkedId,
|
|
1854
|
-
unitOne: vars.unitOne,
|
|
1855
|
-
resourceOrigin: params.resourceOriginId
|
|
1856
|
-
});
|
|
1857
|
-
if (intentsRes.errors?.length) throw new Error(`proposeContribution intents failed: ${intentsRes.errors[0].message}`);
|
|
1858
|
-
const proposalRes = await this.graphql.request(CREATE_PROPOSAL, {
|
|
1859
|
-
name: `Contribution to resource`,
|
|
1860
|
-
note: params.note
|
|
1861
|
-
});
|
|
1862
|
-
if (proposalRes.errors?.length) throw new Error(`createProposal failed: ${proposalRes.errors[0].message}`);
|
|
1863
|
-
const proposalId = proposalRes.data.createProposal.proposal.id;
|
|
1864
|
-
const citeIntentId = intentsRes.data.citeResourceForked.intent.id;
|
|
1865
|
-
const acceptIntentId = intentsRes.data.acceptResourceOrigin.intent.id;
|
|
1866
|
-
const modifyIntentId = intentsRes.data.modifyResourceOrigin.intent.id;
|
|
1867
|
-
const linkRes = await this.graphql.request(LINK_CONTRIBUTION_PROPOSAL_INTENT, {
|
|
1868
|
-
proposal: proposalId,
|
|
1869
|
-
citeIntent: citeIntentId,
|
|
1870
|
-
acceptIntent: acceptIntentId,
|
|
1871
|
-
modifyIntent: modifyIntentId
|
|
1872
|
-
});
|
|
1873
|
-
if (linkRes.errors?.length) throw new Error(`linkIntents failed: ${linkRes.errors[0].message}`);
|
|
1874
|
-
return { proposalId, citeIntentId, acceptIntentId, modifyIntentId };
|
|
1875
|
-
}
|
|
1876
|
-
async acceptProposal(params) {
|
|
1877
|
-
const vars = await this.getInstanceVars();
|
|
1878
|
-
const processId = await this.createProcess("accept contribution");
|
|
1879
|
-
const eventsRes = await this.graphql.request(ACCEPT_PROPOSAL, {
|
|
1880
|
-
process: processId,
|
|
1881
|
-
owner: params.ownerId,
|
|
1882
|
-
proposer: params.proposerId,
|
|
1883
|
-
unitOne: vars.unitOne,
|
|
1884
|
-
resourceForked: params.resourceForkedId,
|
|
1885
|
-
resourceOrigin: params.resourceOriginId,
|
|
1886
|
-
creationTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1887
|
-
metadata: JSON.stringify(params.newMetadata)
|
|
1888
|
-
});
|
|
1889
|
-
if (eventsRes.errors?.length) throw new Error(`acceptProposal events failed: ${eventsRes.errors[0].message}`);
|
|
1890
|
-
const satRes = await this.graphql.request(SATISFY_INTENTS, {
|
|
1891
|
-
unitOne: vars.unitOne,
|
|
1892
|
-
intentCited: params.citeIntentId,
|
|
1893
|
-
intentAccepted: params.acceptIntentId,
|
|
1894
|
-
intentModify: params.modifyIntentId,
|
|
1895
|
-
eventCite: eventsRes.data.cite.economicEvent.id,
|
|
1896
|
-
eventAccept: eventsRes.data.accept.economicEvent.id,
|
|
1897
|
-
eventModify: eventsRes.data.modify.economicEvent.id
|
|
1898
|
-
});
|
|
1899
|
-
if (satRes.errors?.length) throw new Error(`satisfyIntents failed: ${satRes.errors[0].message}`);
|
|
1900
|
-
}
|
|
1901
|
-
async rejectProposal(intentCite, intentAccept, intentModify) {
|
|
1902
|
-
const res = await this.graphql.request(REJECT_PROPOSAL, {
|
|
1903
|
-
intentCite,
|
|
1904
|
-
intentAccept,
|
|
1905
|
-
intentModify
|
|
1906
|
-
});
|
|
1907
|
-
if (res.errors?.length) throw new Error(`rejectProposal failed: ${res.errors[0].message}`);
|
|
1908
|
-
}
|
|
1909
|
-
};
|
|
1910
|
-
|
|
1911
|
-
// src/social/SocialClient.ts
|
|
1912
|
-
init_sign();
|
|
1913
|
-
var SocialClient = class {
|
|
1914
|
-
constructor(config, store) {
|
|
1915
|
-
this.config = config;
|
|
1916
|
-
this.store = store;
|
|
1917
|
-
}
|
|
1918
|
-
config;
|
|
1919
|
-
store;
|
|
1920
|
-
get personBase() {
|
|
1921
|
-
const base = this.config.social?.personBase;
|
|
1922
|
-
if (!base) throw new Error("social.personBase URL not configured");
|
|
1923
|
-
return base;
|
|
1924
|
-
}
|
|
1925
|
-
get erBase() {
|
|
1926
|
-
const base = this.config.social?.economicResourceBase;
|
|
1927
|
-
if (!base) throw new Error("social.economicResourceBase URL not configured");
|
|
1928
|
-
return base;
|
|
1929
|
-
}
|
|
1930
|
-
get userId() {
|
|
1931
|
-
const id = this.store.getItem("authId");
|
|
1932
|
-
if (!id) throw new Error("Not authenticated");
|
|
1933
|
-
return id;
|
|
1934
|
-
}
|
|
1935
|
-
/** Post an ActivityStreams activity to the user's outbox. */
|
|
1936
|
-
async postActivity(activity) {
|
|
1937
|
-
const body = JSON.stringify(activity);
|
|
1938
|
-
const headers = await signGraphQLRequest(body, this.store);
|
|
1939
|
-
const res = await fetch(`${this.personBase}/${this.userId}/outbox`, {
|
|
1940
|
-
method: "POST",
|
|
1941
|
-
headers: { ...headers, "Content-Type": "application/json" },
|
|
1942
|
-
body
|
|
1943
|
-
});
|
|
1944
|
-
if (!res.ok) throw new Error(`ActivityPub post failed: ${res.statusText}`);
|
|
1945
|
-
}
|
|
1946
|
-
/** Like a resource. */
|
|
1947
|
-
async likeResource(resourceId) {
|
|
1948
|
-
await this.postActivity({
|
|
1949
|
-
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1950
|
-
type: "Like",
|
|
1951
|
-
actor: `${this.personBase}/${this.userId}`,
|
|
1952
|
-
object: `${this.erBase}/${resourceId}`,
|
|
1953
|
-
published: (/* @__PURE__ */ new Date()).toISOString()
|
|
1954
|
-
});
|
|
1955
|
-
}
|
|
1956
|
-
/** Follow (watch) a resource. */
|
|
1957
|
-
async followResource(resourceId) {
|
|
1958
|
-
await this.postActivity({
|
|
1959
|
-
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1960
|
-
type: "Follow",
|
|
1961
|
-
actor: `${this.personBase}/${this.userId}`,
|
|
1962
|
-
object: `${this.erBase}/${resourceId}`,
|
|
1963
|
-
published: (/* @__PURE__ */ new Date()).toISOString()
|
|
1964
|
-
});
|
|
1965
|
-
}
|
|
1966
|
-
/** Get the list of resource IDs the current user has liked. */
|
|
1967
|
-
async getLikes() {
|
|
1968
|
-
const res = await fetch(`${this.personBase}/${this.userId}/liked`);
|
|
1969
|
-
const data = await res.json();
|
|
1970
|
-
const likes = [];
|
|
1971
|
-
for (const item of data.data?.items || []) {
|
|
1972
|
-
const likeRes = await fetch(item);
|
|
1973
|
-
const likeData = await likeRes.json();
|
|
1974
|
-
const object = likeData.data?.object || "";
|
|
1975
|
-
likes.push(object.split("economicresource/")[1] || object);
|
|
1976
|
-
}
|
|
1977
|
-
return likes.filter(Boolean);
|
|
1978
|
-
}
|
|
1979
|
-
/** Check if the current user liked a resource. */
|
|
1980
|
-
async isLiked(resourceId) {
|
|
1981
|
-
const likes = await this.getLikes();
|
|
1982
|
-
return likes.includes(resourceId);
|
|
1983
|
-
}
|
|
1984
|
-
/** Get the list of follower IDs for a resource. */
|
|
1985
|
-
async getFollowers(resourceId) {
|
|
1986
|
-
const res = await fetch(`${this.erBase}/${resourceId}/follower`);
|
|
1987
|
-
const data = await res.json();
|
|
1988
|
-
return (data.data || []).map((f) => f.split("person/")[1] || f).filter(Boolean);
|
|
1989
|
-
}
|
|
1990
|
-
/** Get the list of resources the current user is following. */
|
|
1991
|
-
async getFollowing() {
|
|
1992
|
-
const res = await fetch(`${this.personBase}/${this.userId}/following`);
|
|
1993
|
-
const data = await res.json();
|
|
1994
|
-
return (data.data || []).map((f) => f.split("economicresource/")[1] || f).filter(Boolean);
|
|
1995
|
-
}
|
|
1996
|
-
/** Check if the current user is following a resource. */
|
|
1997
|
-
async isFollowing(resourceId) {
|
|
1998
|
-
const followers = await this.getFollowers(resourceId);
|
|
1999
|
-
return followers.includes(this.userId);
|
|
2000
|
-
}
|
|
2001
|
-
};
|
|
2002
|
-
|
|
2003
1888
|
// src/tagging/constants.ts
|
|
2004
1889
|
var TAG_PREFIX = {
|
|
2005
1890
|
USER: "tag",
|
|
@@ -2016,7 +1901,8 @@ var TAG_PREFIX = {
|
|
|
2016
1901
|
SERVICE_TYPE: "servicetype",
|
|
2017
1902
|
AVAILABILITY: "availability",
|
|
2018
1903
|
LICENSE: "license",
|
|
2019
|
-
MANUFACTURABLE: "manufacturable"
|
|
1904
|
+
MANUFACTURABLE: "manufacturable",
|
|
1905
|
+
COMPLEXITY: "complexity"
|
|
2020
1906
|
};
|
|
2021
1907
|
var SYSTEM_TAG_PREFIXES = [
|
|
2022
1908
|
TAG_PREFIX.CATEGORY,
|
|
@@ -2032,7 +1918,8 @@ var SYSTEM_TAG_PREFIXES = [
|
|
|
2032
1918
|
TAG_PREFIX.SERVICE_TYPE,
|
|
2033
1919
|
TAG_PREFIX.AVAILABILITY,
|
|
2034
1920
|
TAG_PREFIX.LICENSE,
|
|
2035
|
-
TAG_PREFIX.MANUFACTURABLE
|
|
1921
|
+
TAG_PREFIX.MANUFACTURABLE,
|
|
1922
|
+
TAG_PREFIX.COMPLEXITY
|
|
2036
1923
|
];
|
|
2037
1924
|
var LEGACY_SYSTEM_TAG_PATTERNS = [
|
|
2038
1925
|
"power_compat-",
|
|
@@ -2066,6 +1953,7 @@ var POWER_COMPATIBILITY_OPTIONS = [
|
|
|
2066
1953
|
"USB-C"
|
|
2067
1954
|
];
|
|
2068
1955
|
var REPLICABILITY_OPTIONS = ["High", "Medium", "Low"];
|
|
1956
|
+
var COMPLEXITY_OPTIONS = ["Beginner", "Intermediate", "Advanced"];
|
|
2069
1957
|
var SERVICE_TYPE_OPTIONS = ["Fabrication", "Learning & Education", "Space Access"];
|
|
2070
1958
|
var AVAILABILITY_OPTIONS = [
|
|
2071
1959
|
"Available Now",
|
|
@@ -2278,6 +2166,404 @@ var TaggingClient = class {
|
|
|
2278
2166
|
MANUFACTURABLE_TRUE_TAG = MANUFACTURABLE_TRUE_TAG;
|
|
2279
2167
|
};
|
|
2280
2168
|
|
|
2169
|
+
// src/resources/ResourceClient.ts
|
|
2170
|
+
var ResourceClient = class {
|
|
2171
|
+
constructor(config, store, graphql) {
|
|
2172
|
+
this.config = config;
|
|
2173
|
+
this.store = store;
|
|
2174
|
+
this.graphql = graphql;
|
|
2175
|
+
}
|
|
2176
|
+
config;
|
|
2177
|
+
store;
|
|
2178
|
+
graphql;
|
|
2179
|
+
get userId() {
|
|
2180
|
+
const id = this.store.getItem("authId");
|
|
2181
|
+
if (!id) throw new Error("Not authenticated");
|
|
2182
|
+
return id;
|
|
2183
|
+
}
|
|
2184
|
+
async getInstanceVars() {
|
|
2185
|
+
return getInstanceVariables(this.graphql);
|
|
2186
|
+
}
|
|
2187
|
+
// ─── Helpers ───────────────────────────────────────────────────────
|
|
2188
|
+
specIdForType(vars, type) {
|
|
2189
|
+
switch (type) {
|
|
2190
|
+
case "Design" /* DESIGN */:
|
|
2191
|
+
return vars.projectDesign.id;
|
|
2192
|
+
case "Product" /* PRODUCT */:
|
|
2193
|
+
return vars.projectProduct?.id || this.config.specs?.product || "";
|
|
2194
|
+
case "Service" /* SERVICE */:
|
|
2195
|
+
return vars.projectService?.id || this.config.specs?.service || "";
|
|
2196
|
+
case "Machine" /* MACHINE */:
|
|
2197
|
+
return vars.machine?.id || this.config.specs?.machine || "";
|
|
2198
|
+
case "DPP" /* DPP */:
|
|
2199
|
+
return vars.dpp?.id || this.config.specs?.dpp || "";
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
// ─── Process ───────────────────────────────────────────────────────
|
|
2203
|
+
async createProcess(name) {
|
|
2204
|
+
const res = await this.graphql.request(
|
|
2205
|
+
CREATE_PROCESS,
|
|
2206
|
+
{ name }
|
|
2207
|
+
);
|
|
2208
|
+
if (res.errors?.length) throw new Error(`createProcess failed: ${res.errors[0].message}`);
|
|
2209
|
+
return res.data.createProcess.process.id;
|
|
2210
|
+
}
|
|
2211
|
+
// ─── Location ──────────────────────────────────────────────────────
|
|
2212
|
+
async createLocation(params) {
|
|
2213
|
+
const res = await this.graphql.request(CREATE_LOCATION, {
|
|
2214
|
+
name: params.name,
|
|
2215
|
+
addr: params.address || "",
|
|
2216
|
+
lat: params.lat || 0,
|
|
2217
|
+
lng: params.lng || 0
|
|
2218
|
+
});
|
|
2219
|
+
if (res.errors?.length) throw new Error(`createLocation failed: ${res.errors[0].message}`);
|
|
2220
|
+
return res.data.createSpatialThing.spatialThing;
|
|
2221
|
+
}
|
|
2222
|
+
// ─── Create Project (Design, Product, Service) ─────────────────────
|
|
2223
|
+
async createProject(params) {
|
|
2224
|
+
const vars = await this.getInstanceVars();
|
|
2225
|
+
const specId = this.specIdForType(vars, params.projectType);
|
|
2226
|
+
if (!specId) throw new Error(`${params.projectType} spec ID not found in instance variables or config`);
|
|
2227
|
+
const processId = params.processId || await this.createProcess(`creation of ${params.name} by owner`);
|
|
2228
|
+
let locationId = params.locationId;
|
|
2229
|
+
if (!locationId && params.location) {
|
|
2230
|
+
const loc = await this.createLocation(params.location);
|
|
2231
|
+
locationId = loc.id;
|
|
2232
|
+
}
|
|
2233
|
+
const variables = {
|
|
2234
|
+
name: params.name,
|
|
2235
|
+
note: params.note || "",
|
|
2236
|
+
metadata: JSON.stringify(params.metadata || {}),
|
|
2237
|
+
agent: this.userId,
|
|
2238
|
+
creationTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2239
|
+
location: locationId,
|
|
2240
|
+
resourceSpec: specId,
|
|
2241
|
+
oneUnit: vars.unitOne,
|
|
2242
|
+
images: params.images || [],
|
|
2243
|
+
repo: params.repo || "",
|
|
2244
|
+
process: processId,
|
|
2245
|
+
license: params.license || ""
|
|
2246
|
+
};
|
|
2247
|
+
if (params.tags && params.tags.length > 0) {
|
|
2248
|
+
variables.tags = params.tags;
|
|
2249
|
+
}
|
|
2250
|
+
const res = await this.graphql.request(CREATE_PROJECT, variables);
|
|
2251
|
+
if (res.errors?.length) throw new Error(`createProject failed: ${res.errors[0].message}`);
|
|
2252
|
+
return res.data.createEconomicEvent.economicEvent.resourceInventoriedAs;
|
|
2253
|
+
}
|
|
2254
|
+
// ─── Create Machine ────────────────────────────────────────────────
|
|
2255
|
+
async createMachine(params) {
|
|
2256
|
+
const vars = await this.getInstanceVars();
|
|
2257
|
+
const machineSpecId = vars.machine?.id || this.config.specs?.machine;
|
|
2258
|
+
if (!machineSpecId) throw new Error("Machine spec ID not found in instance variables or config");
|
|
2259
|
+
const processId = await this.createProcess(`creation of machine ${params.name}`);
|
|
2260
|
+
const metadata = {
|
|
2261
|
+
...params.type && { machineType: params.type },
|
|
2262
|
+
...params.location && { location: params.location },
|
|
2263
|
+
...params.image && { image: params.image },
|
|
2264
|
+
...params.metadata || {}
|
|
2265
|
+
};
|
|
2266
|
+
const tags = [...params.tags || []];
|
|
2267
|
+
if (params.type) {
|
|
2268
|
+
const typeTag = prefixedTag(TAG_PREFIX.MACHINE, params.type);
|
|
2269
|
+
if (typeTag) tags.push(typeTag);
|
|
2270
|
+
}
|
|
2271
|
+
const variables = {
|
|
2272
|
+
agent: this.userId,
|
|
2273
|
+
creationTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2274
|
+
process: processId,
|
|
2275
|
+
resourceSpec: machineSpecId,
|
|
2276
|
+
unitOne: vars.unitOne,
|
|
2277
|
+
name: params.name,
|
|
2278
|
+
note: params.note || "",
|
|
2279
|
+
metadata: JSON.stringify(metadata)
|
|
2280
|
+
};
|
|
2281
|
+
if (tags.length > 0) variables.tags = tags;
|
|
2282
|
+
const res = await this.graphql.request(CREATE_MACHINE_RESOURCE, variables);
|
|
2283
|
+
if (res.errors?.length) throw new Error(`createMachine failed: ${res.errors[0].message}`);
|
|
2284
|
+
return res.data.createEconomicEvent.economicEvent.resourceInventoriedAs;
|
|
2285
|
+
}
|
|
2286
|
+
// ─── Create DPP Resource ───────────────────────────────────────────
|
|
2287
|
+
async createDppResource(params) {
|
|
2288
|
+
const vars = await this.getInstanceVars();
|
|
2289
|
+
const dppSpecId = vars.dpp?.id || this.config.specs?.dpp;
|
|
2290
|
+
if (!dppSpecId) throw new Error("DPP spec ID not found in instance variables or config");
|
|
2291
|
+
const processId = await this.createProcess(`DPP creation for ${params.name}`);
|
|
2292
|
+
const res = await this.graphql.request(CREATE_DPP_RESOURCE, {
|
|
2293
|
+
agent: this.userId,
|
|
2294
|
+
creationTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2295
|
+
process: processId,
|
|
2296
|
+
resourceSpec: dppSpecId,
|
|
2297
|
+
unitOne: vars.unitOne,
|
|
2298
|
+
dppUlid: JSON.stringify({ dppServiceUlid: params.dppUlid }),
|
|
2299
|
+
name: params.name,
|
|
2300
|
+
note: params.note || ""
|
|
2301
|
+
});
|
|
2302
|
+
if (res.errors?.length) throw new Error(`createDppResource failed: ${res.errors[0].message}`);
|
|
2303
|
+
return res.data.createEconomicEvent.economicEvent.resourceInventoriedAs;
|
|
2304
|
+
}
|
|
2305
|
+
// ─── Queries ───────────────────────────────────────────────────────
|
|
2306
|
+
async getResource(id) {
|
|
2307
|
+
const res = await this.graphql.request(
|
|
2308
|
+
QUERY_RESOURCE,
|
|
2309
|
+
{ id }
|
|
2310
|
+
);
|
|
2311
|
+
return res.data?.economicResource ?? null;
|
|
2312
|
+
}
|
|
2313
|
+
async listResources(filter, pagination) {
|
|
2314
|
+
const res = await this.graphql.request(FETCH_RESOURCES, {
|
|
2315
|
+
...pagination,
|
|
2316
|
+
filter: filter || {}
|
|
2317
|
+
});
|
|
2318
|
+
return res.data || {};
|
|
2319
|
+
}
|
|
2320
|
+
async getProjects(filter, pagination) {
|
|
2321
|
+
const res = await this.graphql.request(QUERY_PROJECTS, {
|
|
2322
|
+
...pagination,
|
|
2323
|
+
filter: filter || {}
|
|
2324
|
+
});
|
|
2325
|
+
return res.data || {};
|
|
2326
|
+
}
|
|
2327
|
+
async getMachines() {
|
|
2328
|
+
const vars = await this.getInstanceVars();
|
|
2329
|
+
const machineSpecId = vars.machine?.id || this.config.specs?.machine;
|
|
2330
|
+
if (!machineSpecId) throw new Error("Machine spec ID not found in instance variables or config");
|
|
2331
|
+
const res = await this.graphql.request(QUERY_MACHINES, {
|
|
2332
|
+
resourceSpecId: machineSpecId
|
|
2333
|
+
});
|
|
2334
|
+
return res.data || {};
|
|
2335
|
+
}
|
|
2336
|
+
// ─── Relations ─────────────────────────────────────────────────────
|
|
2337
|
+
async citeResource(resourceId, processId) {
|
|
2338
|
+
const vars = await this.getInstanceVars();
|
|
2339
|
+
const res = await this.graphql.request(CITE_PROJECT, {
|
|
2340
|
+
agent: this.userId,
|
|
2341
|
+
creationTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2342
|
+
resource: resourceId,
|
|
2343
|
+
process: processId,
|
|
2344
|
+
unitOne: vars.unitOne
|
|
2345
|
+
});
|
|
2346
|
+
if (res.errors?.length) throw new Error(`citeResource failed: ${res.errors[0].message}`);
|
|
2347
|
+
}
|
|
2348
|
+
async consumeResource(resourceId, processId) {
|
|
2349
|
+
const vars = await this.getInstanceVars();
|
|
2350
|
+
const res = await this.graphql.request(CONSUME_RESOURCE, {
|
|
2351
|
+
agent: this.userId,
|
|
2352
|
+
creationTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2353
|
+
resource: resourceId,
|
|
2354
|
+
process: processId,
|
|
2355
|
+
unitOne: vars.unitOne
|
|
2356
|
+
});
|
|
2357
|
+
if (res.errors?.length) throw new Error(`consumeResource failed: ${res.errors[0].message}`);
|
|
2358
|
+
}
|
|
2359
|
+
async contributeToResource(processId, contributionTypeSpecId) {
|
|
2360
|
+
const vars = await this.getInstanceVars();
|
|
2361
|
+
const res = await this.graphql.request(CONTRIBUTE_TO_PROJECT, {
|
|
2362
|
+
agent: this.userId,
|
|
2363
|
+
creationTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2364
|
+
process: processId,
|
|
2365
|
+
unitOne: vars.unitOne,
|
|
2366
|
+
conformsTo: contributionTypeSpecId
|
|
2367
|
+
});
|
|
2368
|
+
if (res.errors?.length) throw new Error(`contribute failed: ${res.errors[0].message}`);
|
|
2369
|
+
}
|
|
2370
|
+
// ─── Metadata ──────────────────────────────────────────────────────
|
|
2371
|
+
async updateMetadata(resourceId, metadata, quantity) {
|
|
2372
|
+
const res = await this.graphql.request(UPDATE_METADATA, {
|
|
2373
|
+
process: await this.createProcess(`metadata update`),
|
|
2374
|
+
agent: this.userId,
|
|
2375
|
+
resource: resourceId,
|
|
2376
|
+
quantity: quantity || { hasNumericalValue: 1, hasUnit: (await this.getInstanceVars()).unitOne },
|
|
2377
|
+
now: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2378
|
+
metadata: JSON.stringify(metadata)
|
|
2379
|
+
});
|
|
2380
|
+
if (res.errors?.length) throw new Error(`updateMetadata failed: ${res.errors[0].message}`);
|
|
2381
|
+
}
|
|
2382
|
+
async updateClassifiedAs(resourceId, tags) {
|
|
2383
|
+
const res = await this.graphql.request(UPDATE_RESOURCE_CLASSIFIED_AS, {
|
|
2384
|
+
id: resourceId,
|
|
2385
|
+
classifiedAs: tags
|
|
2386
|
+
});
|
|
2387
|
+
if (res.errors?.length) throw new Error(`updateClassifiedAs failed: ${res.errors[0].message}`);
|
|
2388
|
+
}
|
|
2389
|
+
async relocateResource(resourceId, locationId) {
|
|
2390
|
+
const vars = await this.getInstanceVars();
|
|
2391
|
+
const res = await this.graphql.request(RELOCATE_PROJECT, {
|
|
2392
|
+
process: await this.createProcess(`relocate`),
|
|
2393
|
+
agent: this.userId,
|
|
2394
|
+
resource: resourceId,
|
|
2395
|
+
quantity: { hasNumericalValue: 1, hasUnit: vars.unitOne },
|
|
2396
|
+
now: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2397
|
+
location: locationId
|
|
2398
|
+
});
|
|
2399
|
+
if (res.errors?.length) throw new Error(`relocate failed: ${res.errors[0].message}`);
|
|
2400
|
+
}
|
|
2401
|
+
// ─── Proposals ─────────────────────────────────────────────────────
|
|
2402
|
+
async proposeContribution(params) {
|
|
2403
|
+
const vars = await this.getInstanceVars();
|
|
2404
|
+
const processId = await this.createProcess("contribution proposal");
|
|
2405
|
+
const creationTime = (/* @__PURE__ */ new Date()).toISOString();
|
|
2406
|
+
const intentsRes = await this.graphql.request(PROPOSE_CONTRIBUTION, {
|
|
2407
|
+
process: processId,
|
|
2408
|
+
owner: params.ownerId,
|
|
2409
|
+
proposer: this.userId,
|
|
2410
|
+
creationTime,
|
|
2411
|
+
resourceForked: params.resourceForkedId,
|
|
2412
|
+
unitOne: vars.unitOne,
|
|
2413
|
+
resourceOrigin: params.resourceOriginId
|
|
2414
|
+
});
|
|
2415
|
+
if (intentsRes.errors?.length) throw new Error(`proposeContribution intents failed: ${intentsRes.errors[0].message}`);
|
|
2416
|
+
const proposalRes = await this.graphql.request(CREATE_PROPOSAL, {
|
|
2417
|
+
name: `Contribution to resource`,
|
|
2418
|
+
note: params.note
|
|
2419
|
+
});
|
|
2420
|
+
if (proposalRes.errors?.length) throw new Error(`createProposal failed: ${proposalRes.errors[0].message}`);
|
|
2421
|
+
const proposalId = proposalRes.data.createProposal.proposal.id;
|
|
2422
|
+
const citeIntentId = intentsRes.data.citeResourceForked.intent.id;
|
|
2423
|
+
const acceptIntentId = intentsRes.data.acceptResourceOrigin.intent.id;
|
|
2424
|
+
const modifyIntentId = intentsRes.data.modifyResourceOrigin.intent.id;
|
|
2425
|
+
const linkRes = await this.graphql.request(LINK_CONTRIBUTION_PROPOSAL_INTENT, {
|
|
2426
|
+
proposal: proposalId,
|
|
2427
|
+
citeIntent: citeIntentId,
|
|
2428
|
+
acceptIntent: acceptIntentId,
|
|
2429
|
+
modifyIntent: modifyIntentId
|
|
2430
|
+
});
|
|
2431
|
+
if (linkRes.errors?.length) throw new Error(`linkIntents failed: ${linkRes.errors[0].message}`);
|
|
2432
|
+
return { proposalId, citeIntentId, acceptIntentId, modifyIntentId };
|
|
2433
|
+
}
|
|
2434
|
+
async acceptProposal(params) {
|
|
2435
|
+
const vars = await this.getInstanceVars();
|
|
2436
|
+
const processId = await this.createProcess("accept contribution");
|
|
2437
|
+
const eventsRes = await this.graphql.request(ACCEPT_PROPOSAL, {
|
|
2438
|
+
process: processId,
|
|
2439
|
+
owner: params.ownerId,
|
|
2440
|
+
proposer: params.proposerId,
|
|
2441
|
+
unitOne: vars.unitOne,
|
|
2442
|
+
resourceForked: params.resourceForkedId,
|
|
2443
|
+
resourceOrigin: params.resourceOriginId,
|
|
2444
|
+
creationTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2445
|
+
metadata: JSON.stringify(params.newMetadata)
|
|
2446
|
+
});
|
|
2447
|
+
if (eventsRes.errors?.length) throw new Error(`acceptProposal events failed: ${eventsRes.errors[0].message}`);
|
|
2448
|
+
const satRes = await this.graphql.request(SATISFY_INTENTS, {
|
|
2449
|
+
unitOne: vars.unitOne,
|
|
2450
|
+
intentCited: params.citeIntentId,
|
|
2451
|
+
intentAccepted: params.acceptIntentId,
|
|
2452
|
+
intentModify: params.modifyIntentId,
|
|
2453
|
+
eventCite: eventsRes.data.cite.economicEvent.id,
|
|
2454
|
+
eventAccept: eventsRes.data.accept.economicEvent.id,
|
|
2455
|
+
eventModify: eventsRes.data.modify.economicEvent.id
|
|
2456
|
+
});
|
|
2457
|
+
if (satRes.errors?.length) throw new Error(`satisfyIntents failed: ${satRes.errors[0].message}`);
|
|
2458
|
+
}
|
|
2459
|
+
async getTraceDpp(id) {
|
|
2460
|
+
const res = await this.graphql.request(QUERY_RESOURCE_TRACE_DPP, { id });
|
|
2461
|
+
if (res.errors?.length) throw new Error(`getTraceDpp failed: ${res.errors[0].message}`);
|
|
2462
|
+
const traceDpp = res.data?.economicResource?.traceDpp;
|
|
2463
|
+
return Array.isArray(traceDpp) ? traceDpp : [];
|
|
2464
|
+
}
|
|
2465
|
+
async rejectProposal(intentCite, intentAccept, intentModify) {
|
|
2466
|
+
const res = await this.graphql.request(REJECT_PROPOSAL, {
|
|
2467
|
+
intentCite,
|
|
2468
|
+
intentAccept,
|
|
2469
|
+
intentModify
|
|
2470
|
+
});
|
|
2471
|
+
if (res.errors?.length) throw new Error(`rejectProposal failed: ${res.errors[0].message}`);
|
|
2472
|
+
}
|
|
2473
|
+
};
|
|
2474
|
+
|
|
2475
|
+
// src/social/SocialClient.ts
|
|
2476
|
+
init_sign();
|
|
2477
|
+
var SocialClient = class {
|
|
2478
|
+
constructor(config, store) {
|
|
2479
|
+
this.config = config;
|
|
2480
|
+
this.store = store;
|
|
2481
|
+
}
|
|
2482
|
+
config;
|
|
2483
|
+
store;
|
|
2484
|
+
get personBase() {
|
|
2485
|
+
const base = this.config.social?.personBase;
|
|
2486
|
+
if (!base) throw new Error("social.personBase URL not configured");
|
|
2487
|
+
return base;
|
|
2488
|
+
}
|
|
2489
|
+
get erBase() {
|
|
2490
|
+
const base = this.config.social?.economicResourceBase;
|
|
2491
|
+
if (!base) throw new Error("social.economicResourceBase URL not configured");
|
|
2492
|
+
return base;
|
|
2493
|
+
}
|
|
2494
|
+
get userId() {
|
|
2495
|
+
const id = this.store.getItem("authId");
|
|
2496
|
+
if (!id) throw new Error("Not authenticated");
|
|
2497
|
+
return id;
|
|
2498
|
+
}
|
|
2499
|
+
/** Post an ActivityStreams activity to the user's outbox. */
|
|
2500
|
+
async postActivity(activity) {
|
|
2501
|
+
const body = JSON.stringify(activity);
|
|
2502
|
+
const headers = await signGraphQLRequest(body, this.store);
|
|
2503
|
+
const res = await fetch(`${this.personBase}/${this.userId}/outbox`, {
|
|
2504
|
+
method: "POST",
|
|
2505
|
+
headers: { ...headers, "Content-Type": "application/json" },
|
|
2506
|
+
body
|
|
2507
|
+
});
|
|
2508
|
+
if (!res.ok) throw new Error(`ActivityPub post failed: ${res.statusText}`);
|
|
2509
|
+
}
|
|
2510
|
+
/** Like a resource. */
|
|
2511
|
+
async likeResource(resourceId) {
|
|
2512
|
+
await this.postActivity({
|
|
2513
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2514
|
+
type: "Like",
|
|
2515
|
+
actor: `${this.personBase}/${this.userId}`,
|
|
2516
|
+
object: `${this.erBase}/${resourceId}`,
|
|
2517
|
+
published: (/* @__PURE__ */ new Date()).toISOString()
|
|
2518
|
+
});
|
|
2519
|
+
}
|
|
2520
|
+
/** Follow (watch) a resource. */
|
|
2521
|
+
async followResource(resourceId) {
|
|
2522
|
+
await this.postActivity({
|
|
2523
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2524
|
+
type: "Follow",
|
|
2525
|
+
actor: `${this.personBase}/${this.userId}`,
|
|
2526
|
+
object: `${this.erBase}/${resourceId}`,
|
|
2527
|
+
published: (/* @__PURE__ */ new Date()).toISOString()
|
|
2528
|
+
});
|
|
2529
|
+
}
|
|
2530
|
+
/** Get the list of resource IDs the current user has liked. */
|
|
2531
|
+
async getLikes() {
|
|
2532
|
+
const res = await fetch(`${this.personBase}/${this.userId}/liked`);
|
|
2533
|
+
const data = await res.json();
|
|
2534
|
+
const likes = [];
|
|
2535
|
+
for (const item of data.data?.items || []) {
|
|
2536
|
+
const likeRes = await fetch(item);
|
|
2537
|
+
const likeData = await likeRes.json();
|
|
2538
|
+
const object = likeData.data?.object || "";
|
|
2539
|
+
likes.push(object.split("economicresource/")[1] || object);
|
|
2540
|
+
}
|
|
2541
|
+
return likes.filter(Boolean);
|
|
2542
|
+
}
|
|
2543
|
+
/** Check if the current user liked a resource. */
|
|
2544
|
+
async isLiked(resourceId) {
|
|
2545
|
+
const likes = await this.getLikes();
|
|
2546
|
+
return likes.includes(resourceId);
|
|
2547
|
+
}
|
|
2548
|
+
/** Get the list of follower IDs for a resource. */
|
|
2549
|
+
async getFollowers(resourceId) {
|
|
2550
|
+
const res = await fetch(`${this.erBase}/${resourceId}/follower`);
|
|
2551
|
+
const data = await res.json();
|
|
2552
|
+
return (data.data || []).map((f) => f.split("person/")[1] || f).filter(Boolean);
|
|
2553
|
+
}
|
|
2554
|
+
/** Get the list of resources the current user is following. */
|
|
2555
|
+
async getFollowing() {
|
|
2556
|
+
const res = await fetch(`${this.personBase}/${this.userId}/following`);
|
|
2557
|
+
const data = await res.json();
|
|
2558
|
+
return (data.data || []).map((f) => f.split("economicresource/")[1] || f).filter(Boolean);
|
|
2559
|
+
}
|
|
2560
|
+
/** Check if the current user is following a resource. */
|
|
2561
|
+
async isFollowing(resourceId) {
|
|
2562
|
+
const followers = await this.getFollowers(resourceId);
|
|
2563
|
+
return followers.includes(this.userId);
|
|
2564
|
+
}
|
|
2565
|
+
};
|
|
2566
|
+
|
|
2281
2567
|
// src/wallet/WalletClient.ts
|
|
2282
2568
|
init_sign();
|
|
2283
2569
|
var WalletClient = class {
|
|
@@ -2460,30 +2746,91 @@ function createConfig(config) {
|
|
|
2460
2746
|
init_sign();
|
|
2461
2747
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2462
2748
|
0 && (module.exports = {
|
|
2749
|
+
ACCEPT_PROPOSAL,
|
|
2750
|
+
ASK_RESOURCE_PRIMARY_ACCOUNTABLE,
|
|
2463
2751
|
AVAILABILITY_OPTIONS,
|
|
2464
2752
|
AuthClient,
|
|
2753
|
+
CITE_PROJECT,
|
|
2754
|
+
CLAIM_DID,
|
|
2465
2755
|
CO2_THRESHOLDS_KG,
|
|
2756
|
+
COMPLEXITY_OPTIONS,
|
|
2757
|
+
CONSUME_RESOURCE,
|
|
2758
|
+
CONTRIBUTE_TO_PROJECT,
|
|
2759
|
+
CREATE_DPP_RESOURCE,
|
|
2760
|
+
CREATE_INTENT,
|
|
2761
|
+
CREATE_LOCATION,
|
|
2762
|
+
CREATE_MACHINE_RESOURCE,
|
|
2763
|
+
CREATE_PROCESS,
|
|
2764
|
+
CREATE_PROJECT,
|
|
2765
|
+
CREATE_PROPOSAL,
|
|
2466
2766
|
DppClient,
|
|
2767
|
+
EDIT_IMAGES,
|
|
2768
|
+
EDIT_MAIN,
|
|
2769
|
+
EDIT_SPECS,
|
|
2467
2770
|
ENERGY_THRESHOLDS_KWH,
|
|
2771
|
+
FETCH_AGENTS,
|
|
2772
|
+
FETCH_RESOURCES,
|
|
2773
|
+
FETCH_SELF,
|
|
2774
|
+
FETCH_USER,
|
|
2775
|
+
FORK_PROJECT,
|
|
2468
2776
|
FeedbackClient,
|
|
2469
2777
|
FileClient,
|
|
2778
|
+
GET_PROJECT_LAYOUT,
|
|
2779
|
+
GET_RESOURCE_DETAILS,
|
|
2780
|
+
GET_TAGS,
|
|
2781
|
+
GET_USER_IMAGES,
|
|
2782
|
+
GET_USER_LAYOUT,
|
|
2470
2783
|
GraphQLClient,
|
|
2471
2784
|
ImportClient,
|
|
2472
2785
|
InboxClient,
|
|
2473
2786
|
InterfacerClient,
|
|
2787
|
+
LINK_CONTRIBUTION_PROPOSAL_INTENT,
|
|
2788
|
+
LINK_PROPOSAL_AND_INTENT,
|
|
2474
2789
|
MANUFACTURABLE_TRUE_TAG,
|
|
2790
|
+
PERSON_EXISTS,
|
|
2475
2791
|
POWER_COMPATIBILITY_OPTIONS,
|
|
2476
2792
|
POWER_REQUIREMENT_THRESHOLDS_W,
|
|
2477
2793
|
PRODUCT_CATEGORY_OPTIONS,
|
|
2794
|
+
PROPOSE_CONTRIBUTION,
|
|
2795
|
+
QUERY_AGENTS,
|
|
2796
|
+
QUERY_CITED_RESOURCES,
|
|
2797
|
+
QUERY_MACHINES,
|
|
2798
|
+
QUERY_PROJECTS,
|
|
2799
|
+
QUERY_PROJECT_FOR_METADATA_UPDATE,
|
|
2800
|
+
QUERY_PROJECT_TYPES,
|
|
2801
|
+
QUERY_PROPOSAL,
|
|
2802
|
+
QUERY_RESOURCE,
|
|
2803
|
+
QUERY_RESOURCE_PROPOSALS,
|
|
2804
|
+
QUERY_RESOURCE_TRACE_DPP,
|
|
2805
|
+
QUERY_UNIT_AND_CURRENCY,
|
|
2806
|
+
QUERY_VARIABLES,
|
|
2478
2807
|
RECYCLABILITY_THRESHOLDS_PCT,
|
|
2808
|
+
REGISTER_USER,
|
|
2809
|
+
REJECT_PROPOSAL,
|
|
2810
|
+
RELOCATE_PROJECT,
|
|
2479
2811
|
REPAIRABILITY_AVAILABLE_TAG,
|
|
2480
2812
|
REPLICABILITY_OPTIONS,
|
|
2481
2813
|
ResourceClient,
|
|
2814
|
+
SATISFY_INTENTS,
|
|
2815
|
+
SEARCH_PEOPLE,
|
|
2816
|
+
SEARCH_PERSON,
|
|
2817
|
+
SEARCH_PROJECT,
|
|
2818
|
+
SEARCH_PROJECTS,
|
|
2819
|
+
SEARCH_TAGS,
|
|
2820
|
+
SELECT_RESOURCES,
|
|
2821
|
+
SEND_EMAIL_VERIFICATION,
|
|
2482
2822
|
SERVICE_TYPE_OPTIONS,
|
|
2823
|
+
SIGN_UP,
|
|
2483
2824
|
SYSTEM_TAG_PREFIXES,
|
|
2484
2825
|
SocialClient,
|
|
2485
2826
|
TAG_PREFIX,
|
|
2827
|
+
TRANSFER_PROJECT,
|
|
2486
2828
|
TaggingClient,
|
|
2829
|
+
UPDATE_CONTRIBUTION,
|
|
2830
|
+
UPDATE_METADATA,
|
|
2831
|
+
UPDATE_RESOURCE_CLASSIFIED_AS,
|
|
2832
|
+
UPDATE_USER,
|
|
2833
|
+
VERIFY_EMAIL,
|
|
2487
2834
|
WalletClient,
|
|
2488
2835
|
clearInstanceVariablesCache,
|
|
2489
2836
|
createConfig,
|