@junobuild/core-peer 0.0.18 → 0.0.20
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/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/node/index.mjs +1 -1
- package/dist/node/index.mjs.map +4 -4
- package/dist/types/api/storage.api.d.ts +3 -2
- package/dist/types/index.d.ts +2 -0
- package/dist/types/services/storage.services.d.ts +18 -1
- package/dist/types/types/storage.types.d.ts +1 -135
- package/package.json +3 -2
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { Asset, AssetKey, Storage } from '@junobuild/storage';
|
|
1
2
|
import type { AssetNoContent } from '../../declarations/satellite/satellite.did';
|
|
2
3
|
import type { ListParams } from '../types/list.types';
|
|
3
4
|
import type { SatelliteOptions } from '../types/satellite.types';
|
|
4
|
-
import type {
|
|
5
|
+
import type { Assets } from '../types/storage.types';
|
|
5
6
|
/**
|
|
6
7
|
* Uploads a blob to the storage.
|
|
7
8
|
* @param {Storage & {satellite?: SatelliteOptions}} params - The storage parameters. Satellite options are required only in NodeJS environment.
|
|
@@ -83,3 +84,19 @@ export declare const getManyAssets: ({ satellite, ...rest }: {
|
|
|
83
84
|
} & Pick<AssetKey, 'fullPath'>)[];
|
|
84
85
|
satellite?: SatelliteOptions;
|
|
85
86
|
}) => Promise<(AssetNoContent | undefined)[]>;
|
|
87
|
+
/**
|
|
88
|
+
* Generates a download URL for a given asset.
|
|
89
|
+
*
|
|
90
|
+
* @param {Object} params - The parameters for generating the download URL.
|
|
91
|
+
* @param {Object} params.assetKey - The key details of the asset.
|
|
92
|
+
* @param {string} params.assetKey.fullPath - The full path of the asset.
|
|
93
|
+
* @param {string} params.assetKey.token - The access token for the asset.
|
|
94
|
+
* @param {SatelliteOptions} [params.satellite] - The satellite options (required only in NodeJS environment).
|
|
95
|
+
*
|
|
96
|
+
* @returns {string} The generated download URL.
|
|
97
|
+
*/
|
|
98
|
+
export declare const downloadUrl: ({ assetKey: { fullPath, token }, satellite: satelliteOptions }: {
|
|
99
|
+
assetKey: Pick<Asset, 'fullPath' | 'token'>;
|
|
100
|
+
} & {
|
|
101
|
+
satellite?: SatelliteOptions;
|
|
102
|
+
}) => string;
|
|
@@ -1,94 +1,6 @@
|
|
|
1
|
+
import type { Asset } from '@junobuild/storage';
|
|
1
2
|
import type { AssetNoContent } from '../../declarations/satellite/satellite.did';
|
|
2
3
|
import type { ListResults } from './list.types';
|
|
3
|
-
/**
|
|
4
|
-
* Represents the encoding details of an asset.
|
|
5
|
-
* @interface
|
|
6
|
-
*/
|
|
7
|
-
export interface AssetEncoding {
|
|
8
|
-
/**
|
|
9
|
-
* The timestamp when the encoding was modified.
|
|
10
|
-
* @type {bigint}
|
|
11
|
-
*/
|
|
12
|
-
modified: bigint;
|
|
13
|
-
/**
|
|
14
|
-
* The SHA-256 hash of the encoding.
|
|
15
|
-
* @type {string}
|
|
16
|
-
*/
|
|
17
|
-
sha256: string;
|
|
18
|
-
/**
|
|
19
|
-
* The total length of the encoding.
|
|
20
|
-
* @type {bigint}
|
|
21
|
-
*/
|
|
22
|
-
total_length: bigint;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Represents the key details of an asset.
|
|
26
|
-
* @interface
|
|
27
|
-
*/
|
|
28
|
-
export interface AssetKey {
|
|
29
|
-
/**
|
|
30
|
-
* The full path of the asset, i.e., URL.pathname. Except for the dApps assets (HTML, JS, etc.), the full path must start with `/collection/`.
|
|
31
|
-
* @type {string}
|
|
32
|
-
*/
|
|
33
|
-
fullPath: string;
|
|
34
|
-
/**
|
|
35
|
-
* The name of the asset.
|
|
36
|
-
* @type {string}
|
|
37
|
-
*/
|
|
38
|
-
name: string;
|
|
39
|
-
/**
|
|
40
|
-
* The download URL of the asset.
|
|
41
|
-
* @type {string}
|
|
42
|
-
*/
|
|
43
|
-
downloadUrl: string;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Type representing the possible encoding types.
|
|
47
|
-
* @typedef {('identity' | 'gzip' | 'compress' | 'deflate' | 'br')} ENCODING_TYPE
|
|
48
|
-
*/
|
|
49
|
-
export type ENCODING_TYPE = 'identity' | 'gzip' | 'compress' | 'deflate' | 'br';
|
|
50
|
-
/**
|
|
51
|
-
* Represents an asset with its key details, encodings, and metadata.
|
|
52
|
-
* @interface
|
|
53
|
-
* @extends {AssetKey}
|
|
54
|
-
*/
|
|
55
|
-
export interface Asset extends AssetKey {
|
|
56
|
-
/**
|
|
57
|
-
* An optional description of the asset. A field which can be used to filter assets when listing those.
|
|
58
|
-
* @type {string}
|
|
59
|
-
*/
|
|
60
|
-
description?: string;
|
|
61
|
-
/**
|
|
62
|
-
* An optional token associated with the asset. Tokens are used to protect assets on the web. If a token is provided, the asset is delivered on the web only if the query parameter `token` is provided with a matching value.
|
|
63
|
-
* @type {string}
|
|
64
|
-
*/
|
|
65
|
-
token?: string;
|
|
66
|
-
/**
|
|
67
|
-
* The headers associated with the asset.
|
|
68
|
-
* @type {[string, string][]}
|
|
69
|
-
*/
|
|
70
|
-
headers: [string, string][];
|
|
71
|
-
/**
|
|
72
|
-
* The encodings of the asset.
|
|
73
|
-
* @type {Record<ENCODING_TYPE, AssetEncoding>}
|
|
74
|
-
*/
|
|
75
|
-
encodings: Record<ENCODING_TYPE, AssetEncoding>;
|
|
76
|
-
/**
|
|
77
|
-
* The owner of the asset.
|
|
78
|
-
* @type {string}
|
|
79
|
-
*/
|
|
80
|
-
owner?: string;
|
|
81
|
-
/**
|
|
82
|
-
* The timestamp when the asset was created.
|
|
83
|
-
* @type {bigint}
|
|
84
|
-
*/
|
|
85
|
-
created_at?: bigint;
|
|
86
|
-
/**
|
|
87
|
-
* The timestamp when the asset was last updated.
|
|
88
|
-
* @type {bigint}
|
|
89
|
-
*/
|
|
90
|
-
updated_at?: bigint;
|
|
91
|
-
}
|
|
92
4
|
/**
|
|
93
5
|
* Represents a collection of assets with pagination details.
|
|
94
6
|
* @interface
|
|
@@ -107,49 +19,3 @@ export interface Assets extends Omit<ListResults<AssetNoContent>, 'items'> {
|
|
|
107
19
|
*/
|
|
108
20
|
assets: Asset[];
|
|
109
21
|
}
|
|
110
|
-
/**
|
|
111
|
-
* Represents the details required to store an asset.
|
|
112
|
-
* @interface
|
|
113
|
-
*/
|
|
114
|
-
export interface Storage {
|
|
115
|
-
/**
|
|
116
|
-
* The filename of the asset.
|
|
117
|
-
* @type {string}
|
|
118
|
-
*/
|
|
119
|
-
filename: string;
|
|
120
|
-
/**
|
|
121
|
-
* The data of the asset.
|
|
122
|
-
* @type {Blob}
|
|
123
|
-
*/
|
|
124
|
-
data: Blob;
|
|
125
|
-
/**
|
|
126
|
-
* The collection to which the asset belongs.
|
|
127
|
-
* @type {string}
|
|
128
|
-
*/
|
|
129
|
-
collection: string;
|
|
130
|
-
/**
|
|
131
|
-
* The full path of the asset, i.e., URL.pathname. Except for the dApps assets (HTML, JS, etc.), the full path must start with `/collection/`.
|
|
132
|
-
* @type {string}
|
|
133
|
-
*/
|
|
134
|
-
fullPath?: string;
|
|
135
|
-
/**
|
|
136
|
-
* The headers associated with the asset.
|
|
137
|
-
* @type {[string, string][]}
|
|
138
|
-
*/
|
|
139
|
-
headers?: [string, string][];
|
|
140
|
-
/**
|
|
141
|
-
* An optional token associated with the asset. Tokens are used to protect assets on the web. If a token is provided, the asset is delivered on the web only if the query parameter `token` is provided with a matching value.
|
|
142
|
-
* @type {string}
|
|
143
|
-
*/
|
|
144
|
-
token?: string;
|
|
145
|
-
/**
|
|
146
|
-
* The encoding type of the asset.
|
|
147
|
-
* @type {ENCODING_TYPE}
|
|
148
|
-
*/
|
|
149
|
-
encoding?: ENCODING_TYPE;
|
|
150
|
-
/**
|
|
151
|
-
* An optional description of the asset. A field which can be used to filter assets when listing those.
|
|
152
|
-
* @type {string}
|
|
153
|
-
*/
|
|
154
|
-
description?: string;
|
|
155
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junobuild/core-peer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "JavaScript core client for Juno minus DFINITY agent-js dependencies",
|
|
5
5
|
"author": "David Dal Busco (https://daviddalbusco.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
],
|
|
55
55
|
"homepage": "https://juno.build",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@junobuild/utils": "*"
|
|
57
|
+
"@junobuild/utils": "*",
|
|
58
|
+
"@junobuild/storage": "*"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|
|
60
61
|
"@dfinity/agent": "^1.3.0",
|