@dyne/interfacer-client 0.2.9 → 0.3.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 +37 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +63 -6
- package/dist/index.d.ts +63 -6
- package/dist/index.js +36 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration for the InterfacerClient.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* The simplest way to configure is via `proxyUrl` — all service URLs
|
|
5
|
+
* are derived from it using well-known path conventions:
|
|
6
|
+
*
|
|
7
|
+
* zenflowsUrl → ${proxyUrl}/zenflows/api
|
|
8
|
+
* zenflowsFileUrl → ${proxyUrl}/zenflows/api/file
|
|
9
|
+
* dppUrl → ${proxyUrl}/interfacer-dpp
|
|
10
|
+
* inbox.send → ${proxyUrl}/inbox/send
|
|
11
|
+
* inbox.read → ${proxyUrl}/inbox/read
|
|
12
|
+
* inbox.countUnread → ${proxyUrl}/inbox/count-unread
|
|
13
|
+
* inbox.setRead → ${proxyUrl}/inbox/set-read
|
|
14
|
+
* walletUrl → ${proxyUrl}/wallet/token
|
|
15
|
+
* social.personBase → ${proxyUrl}/inbox/person
|
|
16
|
+
* social.economicResourceBase → ${proxyUrl}/inbox/economicresource
|
|
17
|
+
* oshUrl → ${proxyUrl}/osh
|
|
18
|
+
*
|
|
19
|
+
* You can override any derived URL by passing it explicitly.
|
|
20
|
+
*
|
|
21
|
+
* Fields that CANNOT be derived from proxyUrl (must be provided
|
|
22
|
+
* separately): loshId, zenflowsAdmin, specs, walletCycle, location.
|
|
6
23
|
*/
|
|
7
24
|
interface InterfacerConfig {
|
|
25
|
+
/**
|
|
26
|
+
* Proxy base URL. When provided, all service URLs below are derived
|
|
27
|
+
* automatically using well-known paths. Individual URLs can still be
|
|
28
|
+
* overridden if needed.
|
|
29
|
+
*
|
|
30
|
+
* Example: "https://proxy.dpp-dev.ddns.dyne.org"
|
|
31
|
+
*/
|
|
32
|
+
proxyUrl?: string;
|
|
8
33
|
/** Base URL of the Zenflows GraphQL API (e.g. https://proxy.example.com/zenflows/api) */
|
|
9
|
-
zenflowsUrl
|
|
34
|
+
zenflowsUrl?: string;
|
|
10
35
|
/** Base URL of the Zenflows file storage endpoint */
|
|
11
36
|
zenflowsFileUrl?: string;
|
|
12
37
|
/** Base URL of the DPP service (e.g. https://proxy.example.com/interfacer-dpp) */
|
|
@@ -56,8 +81,40 @@ interface InterfacerConfig {
|
|
|
56
81
|
};
|
|
57
82
|
}
|
|
58
83
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
84
|
+
* Endpoints derived from a proxy URL.
|
|
85
|
+
* Returned by {@link deriveEndpointsFromProxy}.
|
|
86
|
+
*/
|
|
87
|
+
interface DerivedEndpoints {
|
|
88
|
+
zenflowsUrl: string;
|
|
89
|
+
zenflowsFileUrl: string;
|
|
90
|
+
dppUrl: string;
|
|
91
|
+
inbox: {
|
|
92
|
+
send: string;
|
|
93
|
+
read: string;
|
|
94
|
+
countUnread: string;
|
|
95
|
+
setRead: string;
|
|
96
|
+
};
|
|
97
|
+
walletUrl: string;
|
|
98
|
+
social: {
|
|
99
|
+
personBase: string;
|
|
100
|
+
economicResourceBase: string;
|
|
101
|
+
};
|
|
102
|
+
oshUrl: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Derive all service endpoints from a proxy base URL using well-known paths.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* const endpoints = deriveEndpointsFromProxy("https://proxy.dpp-dev.ddns.dyne.org");
|
|
109
|
+
* // endpoints.zenflowsUrl === "https://proxy.dpp-dev.ddns.dyne.org/zenflows/api"
|
|
110
|
+
* // endpoints.dppUrl === "https://proxy.dpp-dev.ddns.dyne.org/interfacer-dpp"
|
|
111
|
+
*/
|
|
112
|
+
declare function deriveEndpointsFromProxy(proxyUrl: string): DerivedEndpoints;
|
|
113
|
+
/**
|
|
114
|
+
* Create a resolved config object.
|
|
115
|
+
*
|
|
116
|
+
* If `proxyUrl` is provided, all service URLs that are not explicitly
|
|
117
|
+
* set will be derived from it. Explicit values always take precedence.
|
|
61
118
|
*/
|
|
62
119
|
declare function createConfig(config: InterfacerConfig): InterfacerConfig;
|
|
63
120
|
|
|
@@ -1101,4 +1158,4 @@ declare function signDidRequest(body: string, store: KeyStorage): Promise<{
|
|
|
1101
1158
|
*/
|
|
1102
1159
|
declare function signFileUpload(checksumHex: string, store: KeyStorage): Promise<string>;
|
|
1103
1160
|
|
|
1104
|
-
export { AVAILABILITY_OPTIONS, AuthClient, CO2_THRESHOLDS_KG, type Contributor, type CreateProjectParams, type DppAttachment, DppClient, type DppDocument, type DppStatus, ENERGY_THRESHOLDS_KWH, FileClient, type GqlFile, GraphQLClient, type ImageRef, ImportClient, InboxClient, type InstanceVariables, InterfacerClient, type InterfacerConfig, type KeyStorage, type Keyring, type License, type Location, MANUFACTURABLE_TRUE_TAG, type MachineRef, type MaterialRef, type ModelFile, POWER_COMPATIBILITY_OPTIONS, POWER_REQUIREMENT_THRESHOLDS_W, PRODUCT_CATEGORY_OPTIONS, type ProductFilters, type Project, type ProjectFilter, type ProjectModelMetadata, ProjectType, type Proposal, RECYCLABILITY_THRESHOLDS_PCT, REPAIRABILITY_AVAILABLE_TAG, REPLICABILITY_OPTIONS, ResourceClient, SERVICE_TYPE_OPTIONS, SYSTEM_TAG_PREFIXES, type ServiceFilters, SocialClient, TAG_PREFIX, TaggingClient, type UserChallenges, WalletClient, type ZenflowsFile, clearInstanceVariablesCache, createConfig, createMemoryStorage, derivedProductFilterTags, extractUserTagValues, formatImageSrc, getInstanceVariables, getResourceImage, isSystemTag, isUserTag, mergeTags, monotonicRangeTags, normalizeUserTagsForSave, prefixedTag, prepFileForZenflows, prepFilesForZenflows, rangeFilterTags, removeTagsWithPrefixes, signDidRequest, signFileUpload, signGraphQLRequest, slugifyTagValue, stripUserTagPrefix, userTag };
|
|
1161
|
+
export { AVAILABILITY_OPTIONS, AuthClient, CO2_THRESHOLDS_KG, type Contributor, type CreateProjectParams, type DerivedEndpoints, type DppAttachment, DppClient, type DppDocument, type DppStatus, ENERGY_THRESHOLDS_KWH, FileClient, type GqlFile, GraphQLClient, type ImageRef, ImportClient, InboxClient, type InstanceVariables, InterfacerClient, type InterfacerConfig, type KeyStorage, type Keyring, type License, type Location, MANUFACTURABLE_TRUE_TAG, type MachineRef, type MaterialRef, type ModelFile, POWER_COMPATIBILITY_OPTIONS, POWER_REQUIREMENT_THRESHOLDS_W, PRODUCT_CATEGORY_OPTIONS, type ProductFilters, type Project, type ProjectFilter, type ProjectModelMetadata, ProjectType, type Proposal, RECYCLABILITY_THRESHOLDS_PCT, REPAIRABILITY_AVAILABLE_TAG, REPLICABILITY_OPTIONS, ResourceClient, SERVICE_TYPE_OPTIONS, SYSTEM_TAG_PREFIXES, type ServiceFilters, SocialClient, TAG_PREFIX, TaggingClient, type UserChallenges, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration for the InterfacerClient.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* The simplest way to configure is via `proxyUrl` — all service URLs
|
|
5
|
+
* are derived from it using well-known path conventions:
|
|
6
|
+
*
|
|
7
|
+
* zenflowsUrl → ${proxyUrl}/zenflows/api
|
|
8
|
+
* zenflowsFileUrl → ${proxyUrl}/zenflows/api/file
|
|
9
|
+
* dppUrl → ${proxyUrl}/interfacer-dpp
|
|
10
|
+
* inbox.send → ${proxyUrl}/inbox/send
|
|
11
|
+
* inbox.read → ${proxyUrl}/inbox/read
|
|
12
|
+
* inbox.countUnread → ${proxyUrl}/inbox/count-unread
|
|
13
|
+
* inbox.setRead → ${proxyUrl}/inbox/set-read
|
|
14
|
+
* walletUrl → ${proxyUrl}/wallet/token
|
|
15
|
+
* social.personBase → ${proxyUrl}/inbox/person
|
|
16
|
+
* social.economicResourceBase → ${proxyUrl}/inbox/economicresource
|
|
17
|
+
* oshUrl → ${proxyUrl}/osh
|
|
18
|
+
*
|
|
19
|
+
* You can override any derived URL by passing it explicitly.
|
|
20
|
+
*
|
|
21
|
+
* Fields that CANNOT be derived from proxyUrl (must be provided
|
|
22
|
+
* separately): loshId, zenflowsAdmin, specs, walletCycle, location.
|
|
6
23
|
*/
|
|
7
24
|
interface InterfacerConfig {
|
|
25
|
+
/**
|
|
26
|
+
* Proxy base URL. When provided, all service URLs below are derived
|
|
27
|
+
* automatically using well-known paths. Individual URLs can still be
|
|
28
|
+
* overridden if needed.
|
|
29
|
+
*
|
|
30
|
+
* Example: "https://proxy.dpp-dev.ddns.dyne.org"
|
|
31
|
+
*/
|
|
32
|
+
proxyUrl?: string;
|
|
8
33
|
/** Base URL of the Zenflows GraphQL API (e.g. https://proxy.example.com/zenflows/api) */
|
|
9
|
-
zenflowsUrl
|
|
34
|
+
zenflowsUrl?: string;
|
|
10
35
|
/** Base URL of the Zenflows file storage endpoint */
|
|
11
36
|
zenflowsFileUrl?: string;
|
|
12
37
|
/** Base URL of the DPP service (e.g. https://proxy.example.com/interfacer-dpp) */
|
|
@@ -56,8 +81,40 @@ interface InterfacerConfig {
|
|
|
56
81
|
};
|
|
57
82
|
}
|
|
58
83
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
84
|
+
* Endpoints derived from a proxy URL.
|
|
85
|
+
* Returned by {@link deriveEndpointsFromProxy}.
|
|
86
|
+
*/
|
|
87
|
+
interface DerivedEndpoints {
|
|
88
|
+
zenflowsUrl: string;
|
|
89
|
+
zenflowsFileUrl: string;
|
|
90
|
+
dppUrl: string;
|
|
91
|
+
inbox: {
|
|
92
|
+
send: string;
|
|
93
|
+
read: string;
|
|
94
|
+
countUnread: string;
|
|
95
|
+
setRead: string;
|
|
96
|
+
};
|
|
97
|
+
walletUrl: string;
|
|
98
|
+
social: {
|
|
99
|
+
personBase: string;
|
|
100
|
+
economicResourceBase: string;
|
|
101
|
+
};
|
|
102
|
+
oshUrl: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Derive all service endpoints from a proxy base URL using well-known paths.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* const endpoints = deriveEndpointsFromProxy("https://proxy.dpp-dev.ddns.dyne.org");
|
|
109
|
+
* // endpoints.zenflowsUrl === "https://proxy.dpp-dev.ddns.dyne.org/zenflows/api"
|
|
110
|
+
* // endpoints.dppUrl === "https://proxy.dpp-dev.ddns.dyne.org/interfacer-dpp"
|
|
111
|
+
*/
|
|
112
|
+
declare function deriveEndpointsFromProxy(proxyUrl: string): DerivedEndpoints;
|
|
113
|
+
/**
|
|
114
|
+
* Create a resolved config object.
|
|
115
|
+
*
|
|
116
|
+
* If `proxyUrl` is provided, all service URLs that are not explicitly
|
|
117
|
+
* set will be derived from it. Explicit values always take precedence.
|
|
61
118
|
*/
|
|
62
119
|
declare function createConfig(config: InterfacerConfig): InterfacerConfig;
|
|
63
120
|
|
|
@@ -1101,4 +1158,4 @@ declare function signDidRequest(body: string, store: KeyStorage): Promise<{
|
|
|
1101
1158
|
*/
|
|
1102
1159
|
declare function signFileUpload(checksumHex: string, store: KeyStorage): Promise<string>;
|
|
1103
1160
|
|
|
1104
|
-
export { AVAILABILITY_OPTIONS, AuthClient, CO2_THRESHOLDS_KG, type Contributor, type CreateProjectParams, type DppAttachment, DppClient, type DppDocument, type DppStatus, ENERGY_THRESHOLDS_KWH, FileClient, type GqlFile, GraphQLClient, type ImageRef, ImportClient, InboxClient, type InstanceVariables, InterfacerClient, type InterfacerConfig, type KeyStorage, type Keyring, type License, type Location, MANUFACTURABLE_TRUE_TAG, type MachineRef, type MaterialRef, type ModelFile, POWER_COMPATIBILITY_OPTIONS, POWER_REQUIREMENT_THRESHOLDS_W, PRODUCT_CATEGORY_OPTIONS, type ProductFilters, type Project, type ProjectFilter, type ProjectModelMetadata, ProjectType, type Proposal, RECYCLABILITY_THRESHOLDS_PCT, REPAIRABILITY_AVAILABLE_TAG, REPLICABILITY_OPTIONS, ResourceClient, SERVICE_TYPE_OPTIONS, SYSTEM_TAG_PREFIXES, type ServiceFilters, SocialClient, TAG_PREFIX, TaggingClient, type UserChallenges, WalletClient, type ZenflowsFile, clearInstanceVariablesCache, createConfig, createMemoryStorage, derivedProductFilterTags, extractUserTagValues, formatImageSrc, getInstanceVariables, getResourceImage, isSystemTag, isUserTag, mergeTags, monotonicRangeTags, normalizeUserTagsForSave, prefixedTag, prepFileForZenflows, prepFilesForZenflows, rangeFilterTags, removeTagsWithPrefixes, signDidRequest, signFileUpload, signGraphQLRequest, slugifyTagValue, stripUserTagPrefix, userTag };
|
|
1161
|
+
export { AVAILABILITY_OPTIONS, AuthClient, CO2_THRESHOLDS_KG, type Contributor, type CreateProjectParams, type DerivedEndpoints, type DppAttachment, DppClient, type DppDocument, type DppStatus, ENERGY_THRESHOLDS_KWH, FileClient, type GqlFile, GraphQLClient, type ImageRef, ImportClient, InboxClient, type InstanceVariables, InterfacerClient, type InterfacerConfig, type KeyStorage, type Keyring, type License, type Location, MANUFACTURABLE_TRUE_TAG, type MachineRef, type MaterialRef, type ModelFile, POWER_COMPATIBILITY_OPTIONS, POWER_REQUIREMENT_THRESHOLDS_W, PRODUCT_CATEGORY_OPTIONS, type ProductFilters, type Project, type ProjectFilter, type ProjectModelMetadata, ProjectType, type Proposal, RECYCLABILITY_THRESHOLDS_PCT, REPAIRABILITY_AVAILABLE_TAG, REPLICABILITY_OPTIONS, ResourceClient, SERVICE_TYPE_OPTIONS, SYSTEM_TAG_PREFIXES, type ServiceFilters, SocialClient, TAG_PREFIX, TaggingClient, type UserChallenges, 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 };
|
package/dist/index.js
CHANGED
|
@@ -1189,7 +1189,9 @@ var GraphQLClient = class {
|
|
|
1189
1189
|
console.warn("[interfacer-client] GraphQL signing failed:", err);
|
|
1190
1190
|
}
|
|
1191
1191
|
}
|
|
1192
|
-
const
|
|
1192
|
+
const url = this.config.zenflowsUrl;
|
|
1193
|
+
if (!url) throw new Error("zenflowsUrl not configured. Provide zenflowsUrl or proxyUrl in config.");
|
|
1194
|
+
const res = await fetch(url, {
|
|
1193
1195
|
method: "POST",
|
|
1194
1196
|
headers,
|
|
1195
1197
|
body
|
|
@@ -2217,8 +2219,39 @@ var InterfacerClient = class {
|
|
|
2217
2219
|
init_hashing();
|
|
2218
2220
|
|
|
2219
2221
|
// src/config/config.ts
|
|
2222
|
+
function deriveEndpointsFromProxy(proxyUrl) {
|
|
2223
|
+
const base = proxyUrl.replace(/\/$/, "");
|
|
2224
|
+
return {
|
|
2225
|
+
zenflowsUrl: `${base}/zenflows/api`,
|
|
2226
|
+
zenflowsFileUrl: `${base}/zenflows/api/file`,
|
|
2227
|
+
dppUrl: `${base}/interfacer-dpp`,
|
|
2228
|
+
inbox: {
|
|
2229
|
+
send: `${base}/inbox/send`,
|
|
2230
|
+
read: `${base}/inbox/read`,
|
|
2231
|
+
countUnread: `${base}/inbox/count-unread`,
|
|
2232
|
+
setRead: `${base}/inbox/set-read`
|
|
2233
|
+
},
|
|
2234
|
+
walletUrl: `${base}/wallet/token`,
|
|
2235
|
+
social: {
|
|
2236
|
+
personBase: `${base}/inbox/person`,
|
|
2237
|
+
economicResourceBase: `${base}/inbox/economicresource`
|
|
2238
|
+
},
|
|
2239
|
+
oshUrl: `${base}/osh`
|
|
2240
|
+
};
|
|
2241
|
+
}
|
|
2220
2242
|
function createConfig(config) {
|
|
2221
|
-
return config;
|
|
2243
|
+
if (!config.proxyUrl) return config;
|
|
2244
|
+
const derived = deriveEndpointsFromProxy(config.proxyUrl);
|
|
2245
|
+
return {
|
|
2246
|
+
...config,
|
|
2247
|
+
zenflowsUrl: config.zenflowsUrl ?? derived.zenflowsUrl,
|
|
2248
|
+
zenflowsFileUrl: config.zenflowsFileUrl ?? derived.zenflowsFileUrl,
|
|
2249
|
+
dppUrl: config.dppUrl ?? derived.dppUrl,
|
|
2250
|
+
inbox: config.inbox ?? derived.inbox,
|
|
2251
|
+
walletUrl: config.walletUrl ?? derived.walletUrl,
|
|
2252
|
+
social: config.social ?? derived.social,
|
|
2253
|
+
oshUrl: config.oshUrl ?? derived.oshUrl
|
|
2254
|
+
};
|
|
2222
2255
|
}
|
|
2223
2256
|
|
|
2224
2257
|
// src/index.ts
|
|
@@ -2251,6 +2284,7 @@ export {
|
|
|
2251
2284
|
clearInstanceVariablesCache,
|
|
2252
2285
|
createConfig,
|
|
2253
2286
|
createMemoryStorage,
|
|
2287
|
+
deriveEndpointsFromProxy,
|
|
2254
2288
|
derivedProductFilterTags,
|
|
2255
2289
|
extractUserTagValues,
|
|
2256
2290
|
formatImageSrc,
|