@dyne/interfacer-client 0.6.1 → 0.7.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 +296 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +124 -7
- package/dist/index.d.ts +124 -7
- package/dist/index.js +290 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -138,6 +138,36 @@ interface KeyStorage {
|
|
|
138
138
|
*/
|
|
139
139
|
declare function createMemoryStorage(): KeyStorage;
|
|
140
140
|
|
|
141
|
+
/** GraphQL error metadata is part of the SDK contract, not just display text. */
|
|
142
|
+
interface GraphQLError {
|
|
143
|
+
message: string;
|
|
144
|
+
path?: Array<string | number>;
|
|
145
|
+
locations?: Array<{
|
|
146
|
+
line: number;
|
|
147
|
+
column: number;
|
|
148
|
+
}>;
|
|
149
|
+
extensions?: {
|
|
150
|
+
code?: string;
|
|
151
|
+
httpStatus?: number;
|
|
152
|
+
[key: string]: unknown;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
interface GraphQLResult<TData = unknown> {
|
|
156
|
+
data?: TData;
|
|
157
|
+
errors?: GraphQLError[];
|
|
158
|
+
}
|
|
159
|
+
declare class GraphQLRequestError extends Error {
|
|
160
|
+
readonly graphQLErrors: GraphQLError[];
|
|
161
|
+
readonly code: string;
|
|
162
|
+
readonly httpStatus?: number;
|
|
163
|
+
constructor(errors: GraphQLError[], context?: string);
|
|
164
|
+
}
|
|
165
|
+
/** Never retain/log the signing exception: it may contain key material. */
|
|
166
|
+
declare class GraphQLSigningError extends GraphQLRequestError {
|
|
167
|
+
constructor();
|
|
168
|
+
}
|
|
169
|
+
declare function throwIfGraphQLErrors(result: GraphQLResult, context?: string): void;
|
|
170
|
+
|
|
141
171
|
/**
|
|
142
172
|
* Fetch-based GraphQL client with automatic EdDSA request signing.
|
|
143
173
|
*
|
|
@@ -152,12 +182,7 @@ declare class GraphQLClient {
|
|
|
152
182
|
/** Enable or disable request signing (use after authentication). */
|
|
153
183
|
setSigningEnabled(enabled: boolean): void;
|
|
154
184
|
/** Execute a GraphQL query or mutation. */
|
|
155
|
-
request<TData = unknown, TVariables = Record<string, unknown>>(operation: string, variables?: TVariables, extraHeaders?: Record<string, string>): Promise<
|
|
156
|
-
data?: TData;
|
|
157
|
-
errors?: Array<{
|
|
158
|
-
message: string;
|
|
159
|
-
}>;
|
|
160
|
-
}>;
|
|
185
|
+
request<TData = unknown, TVariables = Record<string, unknown>>(operation: string, variables?: TVariables, extraHeaders?: Record<string, string>): Promise<GraphQLResult<TData>>;
|
|
161
186
|
}
|
|
162
187
|
|
|
163
188
|
/**
|
|
@@ -514,8 +539,20 @@ declare class DppClient {
|
|
|
514
539
|
private get dppUrl();
|
|
515
540
|
/** Sign a request body and return DID headers + x-user-id. */
|
|
516
541
|
private signedRequest;
|
|
542
|
+
/**
|
|
543
|
+
* Sign a body-less request (DELETE) by signing the object id string. The
|
|
544
|
+
* DPP service reconstructs the signed bytes from the path id, so the
|
|
545
|
+
* signature is bound to exactly this object (cross-service authz contract
|
|
546
|
+
* §2). Returns DID headers plus x-user-id as a logged hint the server does
|
|
547
|
+
* not trust for the principal.
|
|
548
|
+
*/
|
|
549
|
+
private signedIdRequest;
|
|
550
|
+
/** Throw a uniform error for a non-ok DPP response. */
|
|
551
|
+
private ensureOk;
|
|
517
552
|
/** Generic request helper. */
|
|
518
553
|
private request;
|
|
554
|
+
/** DELETE a body-less resource, signing the given object id. */
|
|
555
|
+
private deleteSigned;
|
|
519
556
|
createDpp(data: Omit<DppDocument, "id">): Promise<CreateDppResponse>;
|
|
520
557
|
getDpp(id: string): Promise<DppDocument>;
|
|
521
558
|
updateDpp(id: string, data: Partial<DppDocument>): Promise<UpdateDppResponse>;
|
|
@@ -765,6 +802,39 @@ declare class InboxClient {
|
|
|
765
802
|
* Manages Process creation, location, resource creation, relations, and metadata.
|
|
766
803
|
*/
|
|
767
804
|
|
|
805
|
+
interface MetadataPatchOptions {
|
|
806
|
+
/** Compare with a fingerprint from economicResource.metadataHash; not a control epoch. */
|
|
807
|
+
expectedMetadataHash?: string;
|
|
808
|
+
}
|
|
809
|
+
interface MetadataPatchResult {
|
|
810
|
+
id: string;
|
|
811
|
+
metadata: Record<string, unknown> | null;
|
|
812
|
+
metadataHash: string;
|
|
813
|
+
}
|
|
814
|
+
interface ContributionProposalParams {
|
|
815
|
+
resourceForkedId: string;
|
|
816
|
+
resourceOriginId: string;
|
|
817
|
+
name?: string;
|
|
818
|
+
note?: string;
|
|
819
|
+
}
|
|
820
|
+
interface ContributionProposalResult {
|
|
821
|
+
proposalId: string;
|
|
822
|
+
processId: string;
|
|
823
|
+
citeIntentId: string;
|
|
824
|
+
acceptIntentId: string;
|
|
825
|
+
modifyIntentId: string;
|
|
826
|
+
/** The origin's controller, chosen by the server (Person or Organization). */
|
|
827
|
+
ownerId: string;
|
|
828
|
+
/** False when the server returned an existing pending proposal. */
|
|
829
|
+
created: boolean;
|
|
830
|
+
}
|
|
831
|
+
interface AcceptContributionResult {
|
|
832
|
+
proposalId: string;
|
|
833
|
+
status: "ACCEPTED";
|
|
834
|
+
citeEventId: string;
|
|
835
|
+
acceptEventId: string;
|
|
836
|
+
modifyEventId: string;
|
|
837
|
+
}
|
|
768
838
|
interface CreateProjectParams$1 {
|
|
769
839
|
name: string;
|
|
770
840
|
note?: string;
|
|
@@ -873,12 +943,34 @@ declare class ResourceClient {
|
|
|
873
943
|
citeResource(resourceId: string, processId: string): Promise<void>;
|
|
874
944
|
consumeResource(resourceId: string, processId: string): Promise<void>;
|
|
875
945
|
contributeToResource(processId: string, contributionTypeSpecId: string): Promise<void>;
|
|
946
|
+
/**
|
|
947
|
+
* One signed metadata-only mutation: shallow field replacement under the
|
|
948
|
+
* backend row lock, with optional content CAS. No processes/economic events,
|
|
949
|
+
* quantity changes, preflight or retry. Arrays/nested objects replace a field;
|
|
950
|
+
* null is a value, not deletion. Without CAS, overlapping fields are last-write-wins.
|
|
951
|
+
* The token detects differing current content, not ABA or every historical revision.
|
|
952
|
+
*/
|
|
953
|
+
patchMetadata(resourceId: string, fields: Record<string, unknown>, options?: MetadataPatchOptions): Promise<MetadataPatchResult>;
|
|
954
|
+
/** Legacy full replacement through economic events; not an atomic field patch. */
|
|
876
955
|
updateMetadata(resourceId: string, metadata: Record<string, unknown>, quantity?: {
|
|
877
956
|
hasNumericalValue: number;
|
|
878
957
|
hasUnit: string;
|
|
879
958
|
}): Promise<void>;
|
|
880
959
|
updateClassifiedAs(resourceId: string, tags: string[]): Promise<void>;
|
|
881
960
|
relocateResource(resourceId: string, locationId: string): Promise<void>;
|
|
961
|
+
/**
|
|
962
|
+
* Create a contribution proposal with one signed mutation; the server writes
|
|
963
|
+
* the process, intents, proposal and links in one transaction, names the
|
|
964
|
+
* origin's controller as owner and returns an existing pending proposal for
|
|
965
|
+
* the same fork and origin (created: false). Never retried by the SDK.
|
|
966
|
+
* Requires zenflows#77.
|
|
967
|
+
*/
|
|
968
|
+
createContributionProposal(params: ContributionProposalParams): Promise<ContributionProposalResult>;
|
|
969
|
+
/**
|
|
970
|
+
* @deprecated Four non-transactional requests that name a caller-supplied
|
|
971
|
+
* owner: a failure leaves orphans and a retry duplicates. Use
|
|
972
|
+
* createContributionProposal.
|
|
973
|
+
*/
|
|
882
974
|
proposeContribution(params: {
|
|
883
975
|
resourceForkedId: string;
|
|
884
976
|
resourceOriginId: string;
|
|
@@ -890,6 +982,18 @@ declare class ResourceClient {
|
|
|
890
982
|
acceptIntentId: string;
|
|
891
983
|
modifyIntentId: string;
|
|
892
984
|
}>;
|
|
985
|
+
/**
|
|
986
|
+
* Accept a contribution proposal with one signed mutation: the backend writes
|
|
987
|
+
* the events, satisfactions and the origin's new relation in one transaction.
|
|
988
|
+
* Accepting an accepted proposal returns the same events, so a caller may
|
|
989
|
+
* retry after an uncertain outcome; the SDK itself never retries. A rejected
|
|
990
|
+
* or half-accepted proposal fails with CONFLICT. Requires zenflows#76.
|
|
991
|
+
*/
|
|
992
|
+
acceptContribution(proposalId: string): Promise<AcceptContributionResult>;
|
|
993
|
+
/**
|
|
994
|
+
* @deprecated Two non-transactional requests: a failure between them leaves
|
|
995
|
+
* committed events and a retry duplicates them. Use acceptContribution.
|
|
996
|
+
*/
|
|
893
997
|
acceptProposal(params: {
|
|
894
998
|
proposalId: string;
|
|
895
999
|
citeIntentId: string;
|
|
@@ -1065,6 +1169,16 @@ declare class WalletClient {
|
|
|
1065
1169
|
getBalanceAt(agentId: string, token: Token, timestamp: number): Promise<number>;
|
|
1066
1170
|
/** Add points to an agent. */
|
|
1067
1171
|
addPoints(agentId: string, token: Token, amount?: number): Promise<void>;
|
|
1172
|
+
/**
|
|
1173
|
+
* Issue points for a ValueFlows/social event. Unlike addPoints, the caller
|
|
1174
|
+
* does NOT choose the recipient or amount: it names the event that justifies
|
|
1175
|
+
* the issuance, and the server (Zenflows PDP) attests it and derives the
|
|
1176
|
+
* recipients and server-authoritative amounts. Phase 1 supports `accept`.
|
|
1177
|
+
*/
|
|
1178
|
+
issueForEvent(event: {
|
|
1179
|
+
type: string;
|
|
1180
|
+
id: string;
|
|
1181
|
+
}): Promise<void>;
|
|
1068
1182
|
/** Get point trend over a period (change since period start). */
|
|
1069
1183
|
getTrend(agentId: string, token: Token, periodStartMs: number): Promise<number>;
|
|
1070
1184
|
}
|
|
@@ -1206,6 +1320,9 @@ declare const MANUFACTURABLE_TRUE_TAG = "manufacturable-true";
|
|
|
1206
1320
|
* Ported from interfacer-gui lib/QueryAndMutation.ts.
|
|
1207
1321
|
* These are raw GQL documents used by the GraphQLClient.
|
|
1208
1322
|
*/
|
|
1323
|
+
declare const PATCH_RESOURCE_METADATA: string;
|
|
1324
|
+
declare const PROPOSE_CONTRIBUTION_ATOMIC: string;
|
|
1325
|
+
declare const ACCEPT_CONTRIBUTION: string;
|
|
1209
1326
|
declare const QUERY_VARIABLES: string;
|
|
1210
1327
|
declare const QUERY_PROJECT_TYPES: string;
|
|
1211
1328
|
declare const QUERY_UNIT_AND_CURRENCY: string;
|
|
@@ -1336,4 +1453,4 @@ declare function signDidRequest(body: string, store: KeyStorage): Promise<{
|
|
|
1336
1453
|
*/
|
|
1337
1454
|
declare function signFileUpload(checksumHex: string, store: KeyStorage): Promise<string>;
|
|
1338
1455
|
|
|
1339
|
-
export { ACCEPT_PROPOSAL, ASK_RESOURCE_PRIMARY_ACCOUNTABLE, AVAILABILITY_OPTIONS, AuthClient, CITE_PROJECT, CLAIM_DID, CO2_THRESHOLDS_KG, COMPLEXITY_OPTIONS, CONSUME_RESOURCE, CONTRIBUTE_TO_PROJECT, CREATE_DPP_RESOURCE, CREATE_INTENT, CREATE_LOCATION, CREATE_MACHINE_RESOURCE, CREATE_PROCESS, CREATE_PROJECT, CREATE_PROPOSAL, type Comment, type Contributor, type CreateProjectParams, type DerivedEndpoints, type DppAttachment, DppClient, type DppDocument, type DppStatus, EDIT_IMAGES, EDIT_MAIN, EDIT_SPECS, ENERGY_THRESHOLDS_KWH, FETCH_AGENTS, FETCH_RESOURCES, FETCH_SELF, FETCH_USER, FORK_PROJECT, FeedbackClient, FileClient, GET_PROJECT_LAYOUT, GET_RESOURCE_DETAILS, GET_TAGS, GET_USER_IMAGES, GET_USER_LAYOUT, type GetCommentsParams, type GetReviewsParams, type GqlFile, GraphQLClient, type ImageRef, ImportClient, InboxClient, type InstanceVariables, InterfacerClient, type InterfacerConfig, type KeyStorage, type Keyring, LINK_CONTRIBUTION_PROPOSAL_INTENT, LINK_PROPOSAL_AND_INTENT, type License, type Location, MANUFACTURABLE_TRUE_TAG, type MachineRef, type MaterialRef, type ModelFile, PERSON_EXISTS, POWER_COMPATIBILITY_OPTIONS, POWER_REQUIREMENT_THRESHOLDS_W, PRODUCT_CATEGORY_OPTIONS, PROPOSE_CONTRIBUTION, type ProductFilters, type Project, type ProjectFilter, type ProjectModelMetadata, ProjectType, type Proposal, QUERY_AGENTS, QUERY_CITED_RESOURCES, QUERY_MACHINES, QUERY_PROJECTS, QUERY_PROJECT_FOR_METADATA_UPDATE, QUERY_PROJECT_TYPES, QUERY_PROPOSAL, QUERY_RESOURCE, QUERY_RESOURCE_PROPOSALS, QUERY_RESOURCE_TRACE_DPP, QUERY_UNIT_AND_CURRENCY, QUERY_VARIABLES, RECYCLABILITY_THRESHOLDS_PCT, REGISTER_USER, REJECT_PROPOSAL, RELOCATE_PROJECT, REPAIRABILITY_AVAILABLE_TAG, REPLICABILITY_OPTIONS, ResourceClient, type Review, type ReviewSummary, SATISFY_INTENTS, SEARCH_PEOPLE, SEARCH_PERSON, SEARCH_PROJECT, SEARCH_PROJECTS, SEARCH_TAGS, SELECT_RESOURCES, SEND_EMAIL_VERIFICATION, SERVICE_TYPE_OPTIONS, SIGN_UP, SYSTEM_TAG_PREFIXES, type ServiceFilters, SocialClient, TAG_PREFIX, TRANSFER_PROJECT, TaggingClient, type TraceDppNode, type TraceDppNodeType, UPDATE_CONTRIBUTION, UPDATE_METADATA, UPDATE_RESOURCE_CLASSIFIED_AS, UPDATE_USER, type UserChallenges, VERIFY_EMAIL, WalletClient, type ZenflowsFile, clearInstanceVariablesCache, createConfig, createMemoryStorage, deriveEndpointsFromProxy, derivedProductFilterTags, extractUserTagValues, formatImageSrc, getInstanceVariables, getResourceImage, isSystemTag, isUserTag, mergeTags, monotonicRangeTags, normalizeUserTagsForSave, prefixedTag, prepFileForZenflows, prepFilesForZenflows, rangeFilterTags, removeTagsWithPrefixes, signDidRequest, signFileUpload, signGraphQLRequest, slugifyTagValue, stripUserTagPrefix, userTag };
|
|
1456
|
+
export { ACCEPT_CONTRIBUTION, ACCEPT_PROPOSAL, ASK_RESOURCE_PRIMARY_ACCOUNTABLE, AVAILABILITY_OPTIONS, type AcceptContributionResult, AuthClient, CITE_PROJECT, CLAIM_DID, CO2_THRESHOLDS_KG, COMPLEXITY_OPTIONS, CONSUME_RESOURCE, CONTRIBUTE_TO_PROJECT, CREATE_DPP_RESOURCE, CREATE_INTENT, CREATE_LOCATION, CREATE_MACHINE_RESOURCE, CREATE_PROCESS, CREATE_PROJECT, CREATE_PROPOSAL, type Comment, type ContributionProposalParams, type ContributionProposalResult, type Contributor, type CreateProjectParams, type DerivedEndpoints, type DppAttachment, DppClient, type DppDocument, type DppStatus, EDIT_IMAGES, EDIT_MAIN, EDIT_SPECS, ENERGY_THRESHOLDS_KWH, FETCH_AGENTS, FETCH_RESOURCES, FETCH_SELF, FETCH_USER, FORK_PROJECT, FeedbackClient, FileClient, GET_PROJECT_LAYOUT, GET_RESOURCE_DETAILS, GET_TAGS, GET_USER_IMAGES, GET_USER_LAYOUT, type GetCommentsParams, type GetReviewsParams, type GqlFile, GraphQLClient, type GraphQLError, GraphQLRequestError, type GraphQLResult, GraphQLSigningError, type ImageRef, ImportClient, InboxClient, type InstanceVariables, InterfacerClient, type InterfacerConfig, type KeyStorage, type Keyring, LINK_CONTRIBUTION_PROPOSAL_INTENT, LINK_PROPOSAL_AND_INTENT, type License, type Location, MANUFACTURABLE_TRUE_TAG, type MachineRef, type MaterialRef, type MetadataPatchOptions, type MetadataPatchResult, type ModelFile, PATCH_RESOURCE_METADATA, PERSON_EXISTS, POWER_COMPATIBILITY_OPTIONS, POWER_REQUIREMENT_THRESHOLDS_W, PRODUCT_CATEGORY_OPTIONS, PROPOSE_CONTRIBUTION, PROPOSE_CONTRIBUTION_ATOMIC, type ProductFilters, type Project, type ProjectFilter, type ProjectModelMetadata, ProjectType, type Proposal, QUERY_AGENTS, QUERY_CITED_RESOURCES, QUERY_MACHINES, QUERY_PROJECTS, QUERY_PROJECT_FOR_METADATA_UPDATE, QUERY_PROJECT_TYPES, QUERY_PROPOSAL, QUERY_RESOURCE, QUERY_RESOURCE_PROPOSALS, QUERY_RESOURCE_TRACE_DPP, QUERY_UNIT_AND_CURRENCY, QUERY_VARIABLES, RECYCLABILITY_THRESHOLDS_PCT, REGISTER_USER, REJECT_PROPOSAL, RELOCATE_PROJECT, REPAIRABILITY_AVAILABLE_TAG, REPLICABILITY_OPTIONS, ResourceClient, type Review, type ReviewSummary, SATISFY_INTENTS, SEARCH_PEOPLE, SEARCH_PERSON, SEARCH_PROJECT, SEARCH_PROJECTS, SEARCH_TAGS, SELECT_RESOURCES, SEND_EMAIL_VERIFICATION, SERVICE_TYPE_OPTIONS, SIGN_UP, SYSTEM_TAG_PREFIXES, type ServiceFilters, SocialClient, TAG_PREFIX, TRANSFER_PROJECT, TaggingClient, type TraceDppNode, type TraceDppNodeType, UPDATE_CONTRIBUTION, UPDATE_METADATA, UPDATE_RESOURCE_CLASSIFIED_AS, UPDATE_USER, type UserChallenges, VERIFY_EMAIL, WalletClient, type ZenflowsFile, clearInstanceVariablesCache, createConfig, createMemoryStorage, deriveEndpointsFromProxy, derivedProductFilterTags, extractUserTagValues, formatImageSrc, getInstanceVariables, getResourceImage, isSystemTag, isUserTag, mergeTags, monotonicRangeTags, normalizeUserTagsForSave, prefixedTag, prepFileForZenflows, prepFilesForZenflows, rangeFilterTags, removeTagsWithPrefixes, signDidRequest, signFileUpload, signGraphQLRequest, slugifyTagValue, stripUserTagPrefix, throwIfGraphQLErrors, userTag };
|
package/dist/index.d.ts
CHANGED
|
@@ -138,6 +138,36 @@ interface KeyStorage {
|
|
|
138
138
|
*/
|
|
139
139
|
declare function createMemoryStorage(): KeyStorage;
|
|
140
140
|
|
|
141
|
+
/** GraphQL error metadata is part of the SDK contract, not just display text. */
|
|
142
|
+
interface GraphQLError {
|
|
143
|
+
message: string;
|
|
144
|
+
path?: Array<string | number>;
|
|
145
|
+
locations?: Array<{
|
|
146
|
+
line: number;
|
|
147
|
+
column: number;
|
|
148
|
+
}>;
|
|
149
|
+
extensions?: {
|
|
150
|
+
code?: string;
|
|
151
|
+
httpStatus?: number;
|
|
152
|
+
[key: string]: unknown;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
interface GraphQLResult<TData = unknown> {
|
|
156
|
+
data?: TData;
|
|
157
|
+
errors?: GraphQLError[];
|
|
158
|
+
}
|
|
159
|
+
declare class GraphQLRequestError extends Error {
|
|
160
|
+
readonly graphQLErrors: GraphQLError[];
|
|
161
|
+
readonly code: string;
|
|
162
|
+
readonly httpStatus?: number;
|
|
163
|
+
constructor(errors: GraphQLError[], context?: string);
|
|
164
|
+
}
|
|
165
|
+
/** Never retain/log the signing exception: it may contain key material. */
|
|
166
|
+
declare class GraphQLSigningError extends GraphQLRequestError {
|
|
167
|
+
constructor();
|
|
168
|
+
}
|
|
169
|
+
declare function throwIfGraphQLErrors(result: GraphQLResult, context?: string): void;
|
|
170
|
+
|
|
141
171
|
/**
|
|
142
172
|
* Fetch-based GraphQL client with automatic EdDSA request signing.
|
|
143
173
|
*
|
|
@@ -152,12 +182,7 @@ declare class GraphQLClient {
|
|
|
152
182
|
/** Enable or disable request signing (use after authentication). */
|
|
153
183
|
setSigningEnabled(enabled: boolean): void;
|
|
154
184
|
/** Execute a GraphQL query or mutation. */
|
|
155
|
-
request<TData = unknown, TVariables = Record<string, unknown>>(operation: string, variables?: TVariables, extraHeaders?: Record<string, string>): Promise<
|
|
156
|
-
data?: TData;
|
|
157
|
-
errors?: Array<{
|
|
158
|
-
message: string;
|
|
159
|
-
}>;
|
|
160
|
-
}>;
|
|
185
|
+
request<TData = unknown, TVariables = Record<string, unknown>>(operation: string, variables?: TVariables, extraHeaders?: Record<string, string>): Promise<GraphQLResult<TData>>;
|
|
161
186
|
}
|
|
162
187
|
|
|
163
188
|
/**
|
|
@@ -514,8 +539,20 @@ declare class DppClient {
|
|
|
514
539
|
private get dppUrl();
|
|
515
540
|
/** Sign a request body and return DID headers + x-user-id. */
|
|
516
541
|
private signedRequest;
|
|
542
|
+
/**
|
|
543
|
+
* Sign a body-less request (DELETE) by signing the object id string. The
|
|
544
|
+
* DPP service reconstructs the signed bytes from the path id, so the
|
|
545
|
+
* signature is bound to exactly this object (cross-service authz contract
|
|
546
|
+
* §2). Returns DID headers plus x-user-id as a logged hint the server does
|
|
547
|
+
* not trust for the principal.
|
|
548
|
+
*/
|
|
549
|
+
private signedIdRequest;
|
|
550
|
+
/** Throw a uniform error for a non-ok DPP response. */
|
|
551
|
+
private ensureOk;
|
|
517
552
|
/** Generic request helper. */
|
|
518
553
|
private request;
|
|
554
|
+
/** DELETE a body-less resource, signing the given object id. */
|
|
555
|
+
private deleteSigned;
|
|
519
556
|
createDpp(data: Omit<DppDocument, "id">): Promise<CreateDppResponse>;
|
|
520
557
|
getDpp(id: string): Promise<DppDocument>;
|
|
521
558
|
updateDpp(id: string, data: Partial<DppDocument>): Promise<UpdateDppResponse>;
|
|
@@ -765,6 +802,39 @@ declare class InboxClient {
|
|
|
765
802
|
* Manages Process creation, location, resource creation, relations, and metadata.
|
|
766
803
|
*/
|
|
767
804
|
|
|
805
|
+
interface MetadataPatchOptions {
|
|
806
|
+
/** Compare with a fingerprint from economicResource.metadataHash; not a control epoch. */
|
|
807
|
+
expectedMetadataHash?: string;
|
|
808
|
+
}
|
|
809
|
+
interface MetadataPatchResult {
|
|
810
|
+
id: string;
|
|
811
|
+
metadata: Record<string, unknown> | null;
|
|
812
|
+
metadataHash: string;
|
|
813
|
+
}
|
|
814
|
+
interface ContributionProposalParams {
|
|
815
|
+
resourceForkedId: string;
|
|
816
|
+
resourceOriginId: string;
|
|
817
|
+
name?: string;
|
|
818
|
+
note?: string;
|
|
819
|
+
}
|
|
820
|
+
interface ContributionProposalResult {
|
|
821
|
+
proposalId: string;
|
|
822
|
+
processId: string;
|
|
823
|
+
citeIntentId: string;
|
|
824
|
+
acceptIntentId: string;
|
|
825
|
+
modifyIntentId: string;
|
|
826
|
+
/** The origin's controller, chosen by the server (Person or Organization). */
|
|
827
|
+
ownerId: string;
|
|
828
|
+
/** False when the server returned an existing pending proposal. */
|
|
829
|
+
created: boolean;
|
|
830
|
+
}
|
|
831
|
+
interface AcceptContributionResult {
|
|
832
|
+
proposalId: string;
|
|
833
|
+
status: "ACCEPTED";
|
|
834
|
+
citeEventId: string;
|
|
835
|
+
acceptEventId: string;
|
|
836
|
+
modifyEventId: string;
|
|
837
|
+
}
|
|
768
838
|
interface CreateProjectParams$1 {
|
|
769
839
|
name: string;
|
|
770
840
|
note?: string;
|
|
@@ -873,12 +943,34 @@ declare class ResourceClient {
|
|
|
873
943
|
citeResource(resourceId: string, processId: string): Promise<void>;
|
|
874
944
|
consumeResource(resourceId: string, processId: string): Promise<void>;
|
|
875
945
|
contributeToResource(processId: string, contributionTypeSpecId: string): Promise<void>;
|
|
946
|
+
/**
|
|
947
|
+
* One signed metadata-only mutation: shallow field replacement under the
|
|
948
|
+
* backend row lock, with optional content CAS. No processes/economic events,
|
|
949
|
+
* quantity changes, preflight or retry. Arrays/nested objects replace a field;
|
|
950
|
+
* null is a value, not deletion. Without CAS, overlapping fields are last-write-wins.
|
|
951
|
+
* The token detects differing current content, not ABA or every historical revision.
|
|
952
|
+
*/
|
|
953
|
+
patchMetadata(resourceId: string, fields: Record<string, unknown>, options?: MetadataPatchOptions): Promise<MetadataPatchResult>;
|
|
954
|
+
/** Legacy full replacement through economic events; not an atomic field patch. */
|
|
876
955
|
updateMetadata(resourceId: string, metadata: Record<string, unknown>, quantity?: {
|
|
877
956
|
hasNumericalValue: number;
|
|
878
957
|
hasUnit: string;
|
|
879
958
|
}): Promise<void>;
|
|
880
959
|
updateClassifiedAs(resourceId: string, tags: string[]): Promise<void>;
|
|
881
960
|
relocateResource(resourceId: string, locationId: string): Promise<void>;
|
|
961
|
+
/**
|
|
962
|
+
* Create a contribution proposal with one signed mutation; the server writes
|
|
963
|
+
* the process, intents, proposal and links in one transaction, names the
|
|
964
|
+
* origin's controller as owner and returns an existing pending proposal for
|
|
965
|
+
* the same fork and origin (created: false). Never retried by the SDK.
|
|
966
|
+
* Requires zenflows#77.
|
|
967
|
+
*/
|
|
968
|
+
createContributionProposal(params: ContributionProposalParams): Promise<ContributionProposalResult>;
|
|
969
|
+
/**
|
|
970
|
+
* @deprecated Four non-transactional requests that name a caller-supplied
|
|
971
|
+
* owner: a failure leaves orphans and a retry duplicates. Use
|
|
972
|
+
* createContributionProposal.
|
|
973
|
+
*/
|
|
882
974
|
proposeContribution(params: {
|
|
883
975
|
resourceForkedId: string;
|
|
884
976
|
resourceOriginId: string;
|
|
@@ -890,6 +982,18 @@ declare class ResourceClient {
|
|
|
890
982
|
acceptIntentId: string;
|
|
891
983
|
modifyIntentId: string;
|
|
892
984
|
}>;
|
|
985
|
+
/**
|
|
986
|
+
* Accept a contribution proposal with one signed mutation: the backend writes
|
|
987
|
+
* the events, satisfactions and the origin's new relation in one transaction.
|
|
988
|
+
* Accepting an accepted proposal returns the same events, so a caller may
|
|
989
|
+
* retry after an uncertain outcome; the SDK itself never retries. A rejected
|
|
990
|
+
* or half-accepted proposal fails with CONFLICT. Requires zenflows#76.
|
|
991
|
+
*/
|
|
992
|
+
acceptContribution(proposalId: string): Promise<AcceptContributionResult>;
|
|
993
|
+
/**
|
|
994
|
+
* @deprecated Two non-transactional requests: a failure between them leaves
|
|
995
|
+
* committed events and a retry duplicates them. Use acceptContribution.
|
|
996
|
+
*/
|
|
893
997
|
acceptProposal(params: {
|
|
894
998
|
proposalId: string;
|
|
895
999
|
citeIntentId: string;
|
|
@@ -1065,6 +1169,16 @@ declare class WalletClient {
|
|
|
1065
1169
|
getBalanceAt(agentId: string, token: Token, timestamp: number): Promise<number>;
|
|
1066
1170
|
/** Add points to an agent. */
|
|
1067
1171
|
addPoints(agentId: string, token: Token, amount?: number): Promise<void>;
|
|
1172
|
+
/**
|
|
1173
|
+
* Issue points for a ValueFlows/social event. Unlike addPoints, the caller
|
|
1174
|
+
* does NOT choose the recipient or amount: it names the event that justifies
|
|
1175
|
+
* the issuance, and the server (Zenflows PDP) attests it and derives the
|
|
1176
|
+
* recipients and server-authoritative amounts. Phase 1 supports `accept`.
|
|
1177
|
+
*/
|
|
1178
|
+
issueForEvent(event: {
|
|
1179
|
+
type: string;
|
|
1180
|
+
id: string;
|
|
1181
|
+
}): Promise<void>;
|
|
1068
1182
|
/** Get point trend over a period (change since period start). */
|
|
1069
1183
|
getTrend(agentId: string, token: Token, periodStartMs: number): Promise<number>;
|
|
1070
1184
|
}
|
|
@@ -1206,6 +1320,9 @@ declare const MANUFACTURABLE_TRUE_TAG = "manufacturable-true";
|
|
|
1206
1320
|
* Ported from interfacer-gui lib/QueryAndMutation.ts.
|
|
1207
1321
|
* These are raw GQL documents used by the GraphQLClient.
|
|
1208
1322
|
*/
|
|
1323
|
+
declare const PATCH_RESOURCE_METADATA: string;
|
|
1324
|
+
declare const PROPOSE_CONTRIBUTION_ATOMIC: string;
|
|
1325
|
+
declare const ACCEPT_CONTRIBUTION: string;
|
|
1209
1326
|
declare const QUERY_VARIABLES: string;
|
|
1210
1327
|
declare const QUERY_PROJECT_TYPES: string;
|
|
1211
1328
|
declare const QUERY_UNIT_AND_CURRENCY: string;
|
|
@@ -1336,4 +1453,4 @@ declare function signDidRequest(body: string, store: KeyStorage): Promise<{
|
|
|
1336
1453
|
*/
|
|
1337
1454
|
declare function signFileUpload(checksumHex: string, store: KeyStorage): Promise<string>;
|
|
1338
1455
|
|
|
1339
|
-
export { ACCEPT_PROPOSAL, ASK_RESOURCE_PRIMARY_ACCOUNTABLE, AVAILABILITY_OPTIONS, AuthClient, CITE_PROJECT, CLAIM_DID, CO2_THRESHOLDS_KG, COMPLEXITY_OPTIONS, CONSUME_RESOURCE, CONTRIBUTE_TO_PROJECT, CREATE_DPP_RESOURCE, CREATE_INTENT, CREATE_LOCATION, CREATE_MACHINE_RESOURCE, CREATE_PROCESS, CREATE_PROJECT, CREATE_PROPOSAL, type Comment, type Contributor, type CreateProjectParams, type DerivedEndpoints, type DppAttachment, DppClient, type DppDocument, type DppStatus, EDIT_IMAGES, EDIT_MAIN, EDIT_SPECS, ENERGY_THRESHOLDS_KWH, FETCH_AGENTS, FETCH_RESOURCES, FETCH_SELF, FETCH_USER, FORK_PROJECT, FeedbackClient, FileClient, GET_PROJECT_LAYOUT, GET_RESOURCE_DETAILS, GET_TAGS, GET_USER_IMAGES, GET_USER_LAYOUT, type GetCommentsParams, type GetReviewsParams, type GqlFile, GraphQLClient, type ImageRef, ImportClient, InboxClient, type InstanceVariables, InterfacerClient, type InterfacerConfig, type KeyStorage, type Keyring, LINK_CONTRIBUTION_PROPOSAL_INTENT, LINK_PROPOSAL_AND_INTENT, type License, type Location, MANUFACTURABLE_TRUE_TAG, type MachineRef, type MaterialRef, type ModelFile, PERSON_EXISTS, POWER_COMPATIBILITY_OPTIONS, POWER_REQUIREMENT_THRESHOLDS_W, PRODUCT_CATEGORY_OPTIONS, PROPOSE_CONTRIBUTION, type ProductFilters, type Project, type ProjectFilter, type ProjectModelMetadata, ProjectType, type Proposal, QUERY_AGENTS, QUERY_CITED_RESOURCES, QUERY_MACHINES, QUERY_PROJECTS, QUERY_PROJECT_FOR_METADATA_UPDATE, QUERY_PROJECT_TYPES, QUERY_PROPOSAL, QUERY_RESOURCE, QUERY_RESOURCE_PROPOSALS, QUERY_RESOURCE_TRACE_DPP, QUERY_UNIT_AND_CURRENCY, QUERY_VARIABLES, RECYCLABILITY_THRESHOLDS_PCT, REGISTER_USER, REJECT_PROPOSAL, RELOCATE_PROJECT, REPAIRABILITY_AVAILABLE_TAG, REPLICABILITY_OPTIONS, ResourceClient, type Review, type ReviewSummary, SATISFY_INTENTS, SEARCH_PEOPLE, SEARCH_PERSON, SEARCH_PROJECT, SEARCH_PROJECTS, SEARCH_TAGS, SELECT_RESOURCES, SEND_EMAIL_VERIFICATION, SERVICE_TYPE_OPTIONS, SIGN_UP, SYSTEM_TAG_PREFIXES, type ServiceFilters, SocialClient, TAG_PREFIX, TRANSFER_PROJECT, TaggingClient, type TraceDppNode, type TraceDppNodeType, UPDATE_CONTRIBUTION, UPDATE_METADATA, UPDATE_RESOURCE_CLASSIFIED_AS, UPDATE_USER, type UserChallenges, VERIFY_EMAIL, WalletClient, type ZenflowsFile, clearInstanceVariablesCache, createConfig, createMemoryStorage, deriveEndpointsFromProxy, derivedProductFilterTags, extractUserTagValues, formatImageSrc, getInstanceVariables, getResourceImage, isSystemTag, isUserTag, mergeTags, monotonicRangeTags, normalizeUserTagsForSave, prefixedTag, prepFileForZenflows, prepFilesForZenflows, rangeFilterTags, removeTagsWithPrefixes, signDidRequest, signFileUpload, signGraphQLRequest, slugifyTagValue, stripUserTagPrefix, userTag };
|
|
1456
|
+
export { ACCEPT_CONTRIBUTION, ACCEPT_PROPOSAL, ASK_RESOURCE_PRIMARY_ACCOUNTABLE, AVAILABILITY_OPTIONS, type AcceptContributionResult, AuthClient, CITE_PROJECT, CLAIM_DID, CO2_THRESHOLDS_KG, COMPLEXITY_OPTIONS, CONSUME_RESOURCE, CONTRIBUTE_TO_PROJECT, CREATE_DPP_RESOURCE, CREATE_INTENT, CREATE_LOCATION, CREATE_MACHINE_RESOURCE, CREATE_PROCESS, CREATE_PROJECT, CREATE_PROPOSAL, type Comment, type ContributionProposalParams, type ContributionProposalResult, type Contributor, type CreateProjectParams, type DerivedEndpoints, type DppAttachment, DppClient, type DppDocument, type DppStatus, EDIT_IMAGES, EDIT_MAIN, EDIT_SPECS, ENERGY_THRESHOLDS_KWH, FETCH_AGENTS, FETCH_RESOURCES, FETCH_SELF, FETCH_USER, FORK_PROJECT, FeedbackClient, FileClient, GET_PROJECT_LAYOUT, GET_RESOURCE_DETAILS, GET_TAGS, GET_USER_IMAGES, GET_USER_LAYOUT, type GetCommentsParams, type GetReviewsParams, type GqlFile, GraphQLClient, type GraphQLError, GraphQLRequestError, type GraphQLResult, GraphQLSigningError, type ImageRef, ImportClient, InboxClient, type InstanceVariables, InterfacerClient, type InterfacerConfig, type KeyStorage, type Keyring, LINK_CONTRIBUTION_PROPOSAL_INTENT, LINK_PROPOSAL_AND_INTENT, type License, type Location, MANUFACTURABLE_TRUE_TAG, type MachineRef, type MaterialRef, type MetadataPatchOptions, type MetadataPatchResult, type ModelFile, PATCH_RESOURCE_METADATA, PERSON_EXISTS, POWER_COMPATIBILITY_OPTIONS, POWER_REQUIREMENT_THRESHOLDS_W, PRODUCT_CATEGORY_OPTIONS, PROPOSE_CONTRIBUTION, PROPOSE_CONTRIBUTION_ATOMIC, type ProductFilters, type Project, type ProjectFilter, type ProjectModelMetadata, ProjectType, type Proposal, QUERY_AGENTS, QUERY_CITED_RESOURCES, QUERY_MACHINES, QUERY_PROJECTS, QUERY_PROJECT_FOR_METADATA_UPDATE, QUERY_PROJECT_TYPES, QUERY_PROPOSAL, QUERY_RESOURCE, QUERY_RESOURCE_PROPOSALS, QUERY_RESOURCE_TRACE_DPP, QUERY_UNIT_AND_CURRENCY, QUERY_VARIABLES, RECYCLABILITY_THRESHOLDS_PCT, REGISTER_USER, REJECT_PROPOSAL, RELOCATE_PROJECT, REPAIRABILITY_AVAILABLE_TAG, REPLICABILITY_OPTIONS, ResourceClient, type Review, type ReviewSummary, SATISFY_INTENTS, SEARCH_PEOPLE, SEARCH_PERSON, SEARCH_PROJECT, SEARCH_PROJECTS, SEARCH_TAGS, SELECT_RESOURCES, SEND_EMAIL_VERIFICATION, SERVICE_TYPE_OPTIONS, SIGN_UP, SYSTEM_TAG_PREFIXES, type ServiceFilters, SocialClient, TAG_PREFIX, TRANSFER_PROJECT, TaggingClient, type TraceDppNode, type TraceDppNodeType, UPDATE_CONTRIBUTION, UPDATE_METADATA, UPDATE_RESOURCE_CLASSIFIED_AS, UPDATE_USER, type UserChallenges, VERIFY_EMAIL, WalletClient, type ZenflowsFile, clearInstanceVariablesCache, createConfig, createMemoryStorage, deriveEndpointsFromProxy, derivedProductFilterTags, extractUserTagValues, formatImageSrc, getInstanceVariables, getResourceImage, isSystemTag, isUserTag, mergeTags, monotonicRangeTags, normalizeUserTagsForSave, prefixedTag, prepFileForZenflows, prepFilesForZenflows, rangeFilterTags, removeTagsWithPrefixes, signDidRequest, signFileUpload, signGraphQLRequest, slugifyTagValue, stripUserTagPrefix, throwIfGraphQLErrors, userTag };
|