@encore.dev/sdk 0.0.0 → 2.0.0-beta.4
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/LICENSE +362 -0
- package/README.md +122 -2
- package/app_meta.test.ts +134 -0
- package/app_meta.ts +186 -0
- package/config/config.test.ts +381 -0
- package/config/config.ts +178 -0
- package/config/mod.ts +14 -0
- package/config/secrets.ts +147 -0
- package/config/value.ts +243 -0
- package/cron/mod.ts +23 -0
- package/dist/app_meta.d.ts +93 -0
- package/dist/app_meta.js +65 -0
- package/dist/app_meta.js.map +1 -0
- package/dist/config/config.d.ts +105 -0
- package/dist/config/config.js +87 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/mod.d.ts +4 -0
- package/dist/config/mod.js +3 -0
- package/dist/config/mod.js.map +1 -0
- package/dist/config/secrets.d.ts +92 -0
- package/dist/config/secrets.js +80 -0
- package/dist/config/secrets.js.map +1 -0
- package/dist/config/value.d.ts +51 -0
- package/dist/config/value.js +178 -0
- package/dist/config/value.js.map +1 -0
- package/dist/cron/mod.d.ts +22 -0
- package/dist/cron/mod.js +9 -0
- package/dist/cron/mod.js.map +1 -0
- package/dist/internal/otel/backend.d.ts +50 -0
- package/dist/internal/otel/backend.js +2 -0
- package/dist/internal/otel/backend.js.map +1 -0
- package/dist/internal/otel/context.d.ts +10 -0
- package/dist/internal/otel/context.js +34 -0
- package/dist/internal/otel/context.js.map +1 -0
- package/dist/internal/otel/context_manager.d.ts +22 -0
- package/dist/internal/otel/context_manager.js +120 -0
- package/dist/internal/otel/context_manager.js.map +1 -0
- package/dist/internal/otel/encode.d.ts +112 -0
- package/dist/internal/otel/encode.js +290 -0
- package/dist/internal/otel/encode.js.map +1 -0
- package/dist/internal/otel/index.d.ts +9 -0
- package/dist/internal/otel/index.js +9 -0
- package/dist/internal/otel/index.js.map +1 -0
- package/dist/internal/otel/meter.d.ts +73 -0
- package/dist/internal/otel/meter.js +265 -0
- package/dist/internal/otel/meter.js.map +1 -0
- package/dist/internal/otel/propagator.d.ts +14 -0
- package/dist/internal/otel/propagator.js +61 -0
- package/dist/internal/otel/propagator.js.map +1 -0
- package/dist/internal/otel/provider.d.ts +9 -0
- package/dist/internal/otel/provider.js +19 -0
- package/dist/internal/otel/provider.js.map +1 -0
- package/dist/internal/otel/request_context.d.ts +11 -0
- package/dist/internal/otel/request_context.js +20 -0
- package/dist/internal/otel/request_context.js.map +1 -0
- package/dist/internal/otel/span.d.ts +61 -0
- package/dist/internal/otel/span.js +206 -0
- package/dist/internal/otel/span.js.map +1 -0
- package/dist/internal/otel/tracer.d.ts +15 -0
- package/dist/internal/otel/tracer.js +65 -0
- package/dist/internal/otel/tracer.js.map +1 -0
- package/dist/internal/reqtrack/mod.d.ts +6 -0
- package/dist/internal/reqtrack/mod.js +28 -0
- package/dist/internal/reqtrack/mod.js.map +1 -0
- package/dist/internal/runtime/meter.d.ts +11 -0
- package/dist/internal/runtime/meter.js +22 -0
- package/dist/internal/runtime/meter.js.map +1 -0
- package/dist/internal/runtime/mod.d.ts +12 -0
- package/dist/internal/runtime/mod.js +28 -0
- package/dist/internal/runtime/mod.js.map +1 -0
- package/dist/internal/runtime/napi/napi.cjs +122 -0
- package/dist/internal/runtime/napi/napi.d.cts +601 -0
- package/dist/internal/runtime/shutdown.d.ts +13 -0
- package/dist/internal/runtime/shutdown.js +56 -0
- package/dist/internal/runtime/shutdown.js.map +1 -0
- package/dist/internal/utils/constraints.d.ts +9 -0
- package/dist/internal/utils/constraints.js +2 -0
- package/dist/internal/utils/constraints.js.map +1 -0
- package/dist/log/index.d.ts +39 -0
- package/dist/log/index.js +44 -0
- package/dist/log/index.js.map +1 -0
- package/dist/log/logger.d.ts +123 -0
- package/dist/log/logger.js +203 -0
- package/dist/log/logger.js.map +1 -0
- package/dist/log/runtime.d.ts +19 -0
- package/dist/log/runtime.js +22 -0
- package/dist/log/runtime.js.map +1 -0
- package/dist/log/stderr.d.ts +9 -0
- package/dist/log/stderr.js +25 -0
- package/dist/log/stderr.js.map +1 -0
- package/dist/metrics/mod.d.ts +315 -0
- package/dist/metrics/mod.js +488 -0
- package/dist/metrics/mod.js.map +1 -0
- package/dist/mod.d.ts +6 -0
- package/dist/mod.js +4 -0
- package/dist/mod.js.map +1 -0
- package/dist/otel.d.ts +9 -0
- package/dist/otel.js +13 -0
- package/dist/otel.js.map +1 -0
- package/dist/pubsub/encoding.d.ts +3 -0
- package/dist/pubsub/encoding.js +10 -0
- package/dist/pubsub/encoding.js.map +1 -0
- package/dist/pubsub/mod.d.ts +6 -0
- package/dist/pubsub/mod.js +3 -0
- package/dist/pubsub/mod.js.map +1 -0
- package/dist/pubsub/refs.d.ts +12 -0
- package/dist/pubsub/refs.js +11 -0
- package/dist/pubsub/refs.js.map +1 -0
- package/dist/pubsub/subscription.d.ts +128 -0
- package/dist/pubsub/subscription.js +39 -0
- package/dist/pubsub/subscription.js.map +1 -0
- package/dist/pubsub/topic.d.ts +148 -0
- package/dist/pubsub/topic.js +164 -0
- package/dist/pubsub/topic.js.map +1 -0
- package/dist/req_meta.d.ts +47 -0
- package/dist/req_meta.js +26 -0
- package/dist/req_meta.js.map +1 -0
- package/dist/services/index.d.ts +7 -0
- package/dist/services/index.js +17 -0
- package/dist/services/index.js.map +1 -0
- package/dist/shutdown/mod.d.ts +23 -0
- package/dist/shutdown/mod.js +24 -0
- package/dist/shutdown/mod.js.map +1 -0
- package/dist/storage/objects/bucket.d.ts +216 -0
- package/dist/storage/objects/bucket.js +123 -0
- package/dist/storage/objects/bucket.js.map +1 -0
- package/dist/storage/objects/error.d.ts +14 -0
- package/dist/storage/objects/error.js +81 -0
- package/dist/storage/objects/error.js.map +1 -0
- package/dist/storage/objects/mod.d.ts +4 -0
- package/dist/storage/objects/mod.js +3 -0
- package/dist/storage/objects/mod.js.map +1 -0
- package/dist/storage/objects/refs.d.ts +31 -0
- package/dist/storage/objects/refs.js +20 -0
- package/dist/storage/objects/refs.js.map +1 -0
- package/dist/storage/postgres/database.d.ts +295 -0
- package/dist/storage/postgres/database.js +378 -0
- package/dist/storage/postgres/database.js.map +1 -0
- package/dist/storage/postgres/mod.d.ts +2 -0
- package/dist/storage/postgres/mod.js +2 -0
- package/dist/storage/postgres/mod.js.map +1 -0
- package/dist/storage/redis/commands.d.ts +573 -0
- package/dist/storage/redis/commands.js +637 -0
- package/dist/storage/redis/commands.js.map +1 -0
- package/dist/storage/redis/database.d.ts +302 -0
- package/dist/storage/redis/database.js +336 -0
- package/dist/storage/redis/database.js.map +1 -0
- package/dist/storage/redis/mod.d.ts +88 -0
- package/dist/storage/redis/mod.js +84 -0
- package/dist/storage/redis/mod.js.map +1 -0
- package/dist/storage/redis/native.d.ts +8 -0
- package/dist/storage/redis/native.js +11 -0
- package/dist/storage/redis/native.js.map +1 -0
- package/dist/storage/redis/options.d.ts +89 -0
- package/dist/storage/redis/options.js +53 -0
- package/dist/storage/redis/options.js.map +1 -0
- package/dist/storage/redis/pubsub.d.ts +53 -0
- package/dist/storage/redis/pubsub.js +88 -0
- package/dist/storage/redis/pubsub.js.map +1 -0
- package/dist/storage/redis/reply.d.ts +256 -0
- package/dist/storage/redis/reply.js +572 -0
- package/dist/storage/redis/reply.js.map +1 -0
- package/dist/storage/redis/scan.d.ts +11 -0
- package/dist/storage/redis/scan.js +76 -0
- package/dist/storage/redis/scan.js.map +1 -0
- package/dist/storage/redis/script.d.ts +91 -0
- package/dist/storage/redis/script.js +143 -0
- package/dist/storage/redis/script.js.map +1 -0
- package/dist/storage/redis/target.d.ts +47 -0
- package/dist/storage/redis/target.js +82 -0
- package/dist/storage/redis/target.js.map +1 -0
- package/dist/storage/redis/wire.d.ts +105 -0
- package/dist/storage/redis/wire.js +333 -0
- package/dist/storage/redis/wire.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/mod.d.ts +42 -0
- package/dist/types/mod.js +65 -0
- package/dist/types/mod.js.map +1 -0
- package/internal/otel/backend.ts +60 -0
- package/internal/otel/context.test.ts +70 -0
- package/internal/otel/context.ts +48 -0
- package/internal/otel/context_manager.test.ts +154 -0
- package/internal/otel/context_manager.ts +141 -0
- package/internal/otel/encode.test.ts +266 -0
- package/internal/otel/encode.ts +408 -0
- package/internal/otel/index.ts +20 -0
- package/internal/otel/meter.test.ts +231 -0
- package/internal/otel/meter.ts +332 -0
- package/internal/otel/propagator.test.ts +105 -0
- package/internal/otel/propagator.ts +68 -0
- package/internal/otel/provider.ts +23 -0
- package/internal/otel/request_context.ts +32 -0
- package/internal/otel/span.ts +252 -0
- package/internal/otel/tracer.test.ts +352 -0
- package/internal/otel/tracer.ts +104 -0
- package/internal/reqtrack/mod.ts +39 -0
- package/internal/runtime/meter.ts +26 -0
- package/internal/runtime/mod.ts +41 -0
- package/internal/runtime/napi/napi.cjs +122 -0
- package/internal/runtime/napi/napi.d.cts +601 -0
- package/internal/runtime/shutdown.test.ts +248 -0
- package/internal/runtime/shutdown.ts +64 -0
- package/internal/utils/constraints.ts +12 -0
- package/log/index.ts +107 -0
- package/log/logger.test.ts +194 -0
- package/log/logger.ts +308 -0
- package/log/runtime.test.ts +65 -0
- package/log/runtime.ts +40 -0
- package/log/stderr.test.ts +23 -0
- package/log/stderr.ts +24 -0
- package/metrics/export.test.ts +337 -0
- package/metrics/mod.test.ts +180 -0
- package/metrics/mod.ts +619 -0
- package/mod.ts +22 -0
- package/otel.test.ts +84 -0
- package/otel.ts +17 -0
- package/package.json +121 -5
- package/pubsub/encoding.ts +8 -0
- package/pubsub/mod.ts +14 -0
- package/pubsub/pubsub.test.ts +186 -0
- package/pubsub/refs.ts +22 -0
- package/pubsub/subscription.ts +180 -0
- package/pubsub/topic.test.ts +121 -0
- package/pubsub/topic.ts +212 -0
- package/req_meta.ts +75 -0
- package/services/index.test.ts +30 -0
- package/services/index.ts +16 -0
- package/shutdown/mod.ts +24 -0
- package/storage/objects/bucket.ts +338 -0
- package/storage/objects/error.ts +94 -0
- package/storage/objects/mod.ts +35 -0
- package/storage/objects/refs.ts +69 -0
- package/storage/postgres/database.integration.test.ts +175 -0
- package/storage/postgres/database.test.ts +241 -0
- package/storage/postgres/database.ts +497 -0
- package/storage/postgres/mod.ts +15 -0
- package/storage/redis/commands.ts +1221 -0
- package/storage/redis/database.ts +466 -0
- package/storage/redis/mod.ts +135 -0
- package/storage/redis/native.ts +11 -0
- package/storage/redis/options.ts +119 -0
- package/storage/redis/pubsub.ts +92 -0
- package/storage/redis/redis.test.ts +706 -0
- package/storage/redis/reply.ts +705 -0
- package/storage/redis/runtime.test.ts +233 -0
- package/storage/redis/scan.ts +125 -0
- package/storage/redis/script.ts +162 -0
- package/storage/redis/target.ts +131 -0
- package/storage/redis/wire.ts +369 -0
- package/types/mod.ts +92 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import {activeCtxBytes} from '../../internal/otel/index';
|
|
2
|
+
import * as runtime from '../../internal/runtime/mod';
|
|
3
|
+
import {StringLiteral} from '../../internal/utils/constraints';
|
|
4
|
+
import {unwrapErr} from './error';
|
|
5
|
+
import {
|
|
6
|
+
BucketPerms,
|
|
7
|
+
Uploader,
|
|
8
|
+
SignedUploader,
|
|
9
|
+
Downloader,
|
|
10
|
+
SignedDownloader,
|
|
11
|
+
Attrser,
|
|
12
|
+
Lister,
|
|
13
|
+
Remover,
|
|
14
|
+
PublicUrler,
|
|
15
|
+
} from './refs';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Configuration options for declaring a Bucket.
|
|
19
|
+
*/
|
|
20
|
+
export interface BucketConfig {
|
|
21
|
+
/**
|
|
22
|
+
* Whether the objects in the bucket should be publicly
|
|
23
|
+
* accessible, via CDN. Defaults to false if unset.
|
|
24
|
+
*/
|
|
25
|
+
public?: boolean;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Whether to enable versioning of the objects in the bucket.
|
|
29
|
+
* Defaults to false if unset.
|
|
30
|
+
*/
|
|
31
|
+
versioned?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Defines a new Object Storage bucket infrastructure resource.
|
|
36
|
+
*/
|
|
37
|
+
export class Bucket
|
|
38
|
+
extends BucketPerms
|
|
39
|
+
implements
|
|
40
|
+
Uploader,
|
|
41
|
+
SignedUploader,
|
|
42
|
+
Downloader,
|
|
43
|
+
SignedDownloader,
|
|
44
|
+
Attrser,
|
|
45
|
+
Lister,
|
|
46
|
+
Remover,
|
|
47
|
+
PublicUrler
|
|
48
|
+
{
|
|
49
|
+
impl: runtime.Bucket;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Creates a new bucket with the given name and configuration
|
|
53
|
+
*/
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
55
|
+
constructor(name: string, cfg?: BucketConfig) {
|
|
56
|
+
super();
|
|
57
|
+
this.impl = runtime.RT.bucket(name);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Reference an existing bucket by name.
|
|
62
|
+
* To create a new storage bucket, use `new StorageBucket(...)` instead.
|
|
63
|
+
*/
|
|
64
|
+
static named<name extends string>(name: StringLiteral<name>): Bucket {
|
|
65
|
+
return new Bucket(name, {});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async *list(options: ListOptions): AsyncGenerator<ListEntry> {
|
|
69
|
+
const source = activeCtxBytes();
|
|
70
|
+
const iter = unwrapErr(await this.impl.list(options, source));
|
|
71
|
+
while (true) {
|
|
72
|
+
const entry = await iter.next();
|
|
73
|
+
if (entry === null) {
|
|
74
|
+
iter.markDone();
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
yield entry;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Returns whether the object exists in the bucket.
|
|
83
|
+
* Throws an error on network failure.
|
|
84
|
+
*/
|
|
85
|
+
async exists(name: string, options?: ExistsOptions): Promise<boolean> {
|
|
86
|
+
const source = activeCtxBytes();
|
|
87
|
+
const impl = this.impl.object(name);
|
|
88
|
+
const res = await impl.exists(options, source);
|
|
89
|
+
return unwrapErr(res);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Returns the object's attributes.
|
|
94
|
+
* Throws an error if the object does not exist.
|
|
95
|
+
*/
|
|
96
|
+
async attrs(name: string, options?: AttrsOptions): Promise<ObjectAttrs> {
|
|
97
|
+
const source = activeCtxBytes();
|
|
98
|
+
const impl = this.impl.object(name);
|
|
99
|
+
const res = await impl.attrs(options, source);
|
|
100
|
+
return unwrapErr(res);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Uploads an object to the bucket.
|
|
105
|
+
*/
|
|
106
|
+
async upload(
|
|
107
|
+
name: string,
|
|
108
|
+
data: Buffer,
|
|
109
|
+
options?: UploadOptions,
|
|
110
|
+
): Promise<ObjectAttrs> {
|
|
111
|
+
const source = activeCtxBytes();
|
|
112
|
+
const impl = this.impl.object(name);
|
|
113
|
+
const res = await impl.upload(data, options, source);
|
|
114
|
+
return unwrapErr(res);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Generate an external URL to allow uploading an object to the bucket.
|
|
119
|
+
*
|
|
120
|
+
* Anyone with possession of the URL can write to the given object name
|
|
121
|
+
* without any additional auth.
|
|
122
|
+
*/
|
|
123
|
+
async signedUploadUrl(
|
|
124
|
+
name: string,
|
|
125
|
+
options?: UploadUrlOptions,
|
|
126
|
+
): Promise<SignedUploadUrl> {
|
|
127
|
+
const source = activeCtxBytes();
|
|
128
|
+
const impl = this.impl.object(name);
|
|
129
|
+
const res = await impl.signedUploadUrl(options, source);
|
|
130
|
+
return unwrapErr(res);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Generate an external URL to allow downloading an object from the bucket.
|
|
135
|
+
*
|
|
136
|
+
* Anyone with possession of the URL can download the given object without
|
|
137
|
+
* any additional auth.
|
|
138
|
+
*/
|
|
139
|
+
async signedDownloadUrl(
|
|
140
|
+
name: string,
|
|
141
|
+
options?: DownloadUrlOptions,
|
|
142
|
+
): Promise<SignedDownloadUrl> {
|
|
143
|
+
const source = activeCtxBytes();
|
|
144
|
+
const impl = this.impl.object(name);
|
|
145
|
+
const res = await impl.signedDownloadUrl(options, source);
|
|
146
|
+
return unwrapErr(res);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Downloads an object from the bucket and returns its contents.
|
|
151
|
+
*/
|
|
152
|
+
async download(name: string, options?: DownloadOptions): Promise<Buffer> {
|
|
153
|
+
const source = activeCtxBytes();
|
|
154
|
+
const impl = this.impl.object(name);
|
|
155
|
+
const res = await impl.downloadAll(options, source);
|
|
156
|
+
return unwrapErr(res);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Removes an object from the bucket.
|
|
161
|
+
* Throws an error on network failure.
|
|
162
|
+
*/
|
|
163
|
+
async remove(name: string, options?: DeleteOptions): Promise<void> {
|
|
164
|
+
const source = activeCtxBytes();
|
|
165
|
+
const impl = this.impl.object(name);
|
|
166
|
+
const err = await impl.delete(options, source);
|
|
167
|
+
if (err) {
|
|
168
|
+
unwrapErr(err);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Returns the public URL for accessing the object with the given name.
|
|
174
|
+
* Throws an error if the bucket is not public.
|
|
175
|
+
*/
|
|
176
|
+
publicUrl(name: string): string {
|
|
177
|
+
const obj = this.impl.object(name);
|
|
178
|
+
return obj.publicUrl();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
ref<P extends BucketPerms>(): P {
|
|
182
|
+
return this as unknown as P;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Options for listing objects in a bucket.
|
|
188
|
+
*/
|
|
189
|
+
export interface ListOptions {
|
|
190
|
+
/**
|
|
191
|
+
* Only include objects with this prefix in the listing.
|
|
192
|
+
* If unset, all objects are included.
|
|
193
|
+
*/
|
|
194
|
+
prefix?: string;
|
|
195
|
+
|
|
196
|
+
/** Maximum number of objects to return. Defaults to no limit. */
|
|
197
|
+
limit?: number;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Options for retrieving the attributes of an object.
|
|
202
|
+
*/
|
|
203
|
+
export interface AttrsOptions {
|
|
204
|
+
/**
|
|
205
|
+
* The object version to retrieve attributes for.
|
|
206
|
+
* Defaults to the lastest version if unset.
|
|
207
|
+
*
|
|
208
|
+
* If bucket versioning is not enabled, this option is ignored.
|
|
209
|
+
*/
|
|
210
|
+
version?: string;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Options for checking the existence of an object.
|
|
215
|
+
*/
|
|
216
|
+
export interface ExistsOptions {
|
|
217
|
+
/**
|
|
218
|
+
* The object version to check for existence.
|
|
219
|
+
* Defaults to the lastest version if unset.
|
|
220
|
+
*
|
|
221
|
+
* If bucket versioning is not enabled, this option is ignored.
|
|
222
|
+
*/
|
|
223
|
+
version?: string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Options for deleting an object from a bucket.
|
|
228
|
+
*/
|
|
229
|
+
export interface DeleteOptions {
|
|
230
|
+
/**
|
|
231
|
+
* The object version to delete.
|
|
232
|
+
* Defaults to the lastest version if unset.
|
|
233
|
+
*
|
|
234
|
+
* If bucket versioning is not enabled, this option is ignored.
|
|
235
|
+
*/
|
|
236
|
+
version?: string;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* A contiguous byte range within an object.
|
|
241
|
+
*/
|
|
242
|
+
export interface ByteRange {
|
|
243
|
+
/** The zero-based index of the first byte to read. */
|
|
244
|
+
offset: number;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* The number of bytes to read.
|
|
248
|
+
* Defaults to reading to the end of the object if unset.
|
|
249
|
+
*/
|
|
250
|
+
length?: number;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Options for downloading an object from a bucket.
|
|
255
|
+
*/
|
|
256
|
+
export interface DownloadOptions {
|
|
257
|
+
/**
|
|
258
|
+
* The object version to download.
|
|
259
|
+
* Defaults to the lastest version if unset.
|
|
260
|
+
*
|
|
261
|
+
* If bucket versioning is not enabled, this option is ignored.
|
|
262
|
+
*/
|
|
263
|
+
version?: string;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Download only the given byte range of the object, instead of the whole
|
|
267
|
+
* object. The returned Buffer contains just the requested bytes.
|
|
268
|
+
*
|
|
269
|
+
* Throws InvalidArgument if the range is empty or lies beyond the end
|
|
270
|
+
* of the object.
|
|
271
|
+
*/
|
|
272
|
+
range?: ByteRange;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Describes the attributes of an object stored in a bucket.
|
|
277
|
+
*/
|
|
278
|
+
export interface ObjectAttrs {
|
|
279
|
+
name: string;
|
|
280
|
+
size: number;
|
|
281
|
+
/** The version of the object, if bucket versioning is enabled. */
|
|
282
|
+
version?: string;
|
|
283
|
+
etag: string;
|
|
284
|
+
contentType?: string;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* A single entry returned when listing objects in a bucket.
|
|
289
|
+
*/
|
|
290
|
+
export interface ListEntry {
|
|
291
|
+
name: string;
|
|
292
|
+
size: number;
|
|
293
|
+
etag: string;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Options for uploading an object to a bucket.
|
|
298
|
+
*/
|
|
299
|
+
export interface UploadOptions {
|
|
300
|
+
contentType?: string;
|
|
301
|
+
preconditions?: {
|
|
302
|
+
notExists?: boolean;
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Options for generating a signed upload URL.
|
|
308
|
+
*/
|
|
309
|
+
export interface UploadUrlOptions {
|
|
310
|
+
/** The expiration time of the url, in seconds from signing. The maximum
|
|
311
|
+
* value is seven days. If no value is given, a default of one hour is
|
|
312
|
+
* used. */
|
|
313
|
+
ttl?: number;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* A signed URL that allows uploading an object without additional auth.
|
|
318
|
+
*/
|
|
319
|
+
export interface SignedUploadUrl {
|
|
320
|
+
url: string;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Options for generating a signed download URL.
|
|
325
|
+
*/
|
|
326
|
+
export interface DownloadUrlOptions {
|
|
327
|
+
/** The expiration time of the url, in seconds from signing. The maximum
|
|
328
|
+
* value is seven days. If no value is given, a default of one hour is
|
|
329
|
+
* used. */
|
|
330
|
+
ttl?: number;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* A signed URL that allows downloading an object without additional auth.
|
|
335
|
+
*/
|
|
336
|
+
export interface SignedDownloadUrl {
|
|
337
|
+
url: string;
|
|
338
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as runtime from '../../internal/runtime/mod';
|
|
2
|
+
|
|
3
|
+
export class ObjectsError extends Error {
|
|
4
|
+
constructor(msg: string) {
|
|
5
|
+
// extending errors causes issues after you construct them, unless you apply the following fixes
|
|
6
|
+
super(msg);
|
|
7
|
+
|
|
8
|
+
// set error name as constructor name, make it not enumerable to keep native Error behavior
|
|
9
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target#new.target_in_constructors
|
|
10
|
+
Object.defineProperty(this, 'name', {
|
|
11
|
+
value: 'ObjectsError',
|
|
12
|
+
enumerable: false,
|
|
13
|
+
configurable: true,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// Fix the prototype chain, capture stack trace.
|
|
17
|
+
Object.setPrototypeOf(this, ObjectsError.prototype);
|
|
18
|
+
Error.captureStackTrace(this, this.constructor);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class ObjectNotFound extends ObjectsError {
|
|
23
|
+
constructor(msg: string) {
|
|
24
|
+
// extending errors causes issues after you construct them, unless you apply the following fixes
|
|
25
|
+
super(msg);
|
|
26
|
+
|
|
27
|
+
// set error name as constructor name, make it not enumerable to keep native Error behavior
|
|
28
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target#new.target_in_constructors
|
|
29
|
+
Object.defineProperty(this, 'name', {
|
|
30
|
+
value: 'ObjectNotFound',
|
|
31
|
+
enumerable: false,
|
|
32
|
+
configurable: true,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Fix the prototype chain, capture stack trace.
|
|
36
|
+
Object.setPrototypeOf(this, ObjectNotFound.prototype);
|
|
37
|
+
Error.captureStackTrace(this, this.constructor);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class PreconditionFailed extends ObjectsError {
|
|
42
|
+
constructor(msg: string) {
|
|
43
|
+
// extending errors causes issues after you construct them, unless you apply the following fixes
|
|
44
|
+
super(msg);
|
|
45
|
+
|
|
46
|
+
// set error name as constructor name, make it not enumerable to keep native Error behavior
|
|
47
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target#new.target_in_constructors
|
|
48
|
+
Object.defineProperty(this, 'name', {
|
|
49
|
+
value: 'PrecondionFailed',
|
|
50
|
+
enumerable: false,
|
|
51
|
+
configurable: true,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Fix the prototype chain, capture stack trace.
|
|
55
|
+
Object.setPrototypeOf(this, PreconditionFailed.prototype);
|
|
56
|
+
Error.captureStackTrace(this, this.constructor);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export class InvalidArgument extends ObjectsError {
|
|
61
|
+
constructor(msg: string) {
|
|
62
|
+
// extending errors causes issues after you construct them, unless you apply the following fixes
|
|
63
|
+
super(msg);
|
|
64
|
+
|
|
65
|
+
// set error name as constructor name, make it not enumerable to keep native Error behavior
|
|
66
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target#new.target_in_constructors
|
|
67
|
+
Object.defineProperty(this, 'name', {
|
|
68
|
+
value: 'InvalidArgument',
|
|
69
|
+
enumerable: false,
|
|
70
|
+
configurable: true,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Fix the prototype chain, capture stack trace.
|
|
74
|
+
Object.setPrototypeOf(this, InvalidArgument.prototype);
|
|
75
|
+
Error.captureStackTrace(this, this.constructor);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function unwrapErr<T>(val: T | runtime.TypedObjectError): T {
|
|
80
|
+
if (val instanceof runtime.TypedObjectError) {
|
|
81
|
+
switch (val.kind) {
|
|
82
|
+
case runtime.ObjectErrorKind.NotFound:
|
|
83
|
+
throw new ObjectNotFound(val.message);
|
|
84
|
+
case runtime.ObjectErrorKind.PreconditionFailed:
|
|
85
|
+
throw new PreconditionFailed(val.message);
|
|
86
|
+
case runtime.ObjectErrorKind.InvalidArgument:
|
|
87
|
+
throw new InvalidArgument(val.message);
|
|
88
|
+
default:
|
|
89
|
+
throw new ObjectsError(val.message);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return val;
|
|
94
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export {Bucket} from './bucket';
|
|
2
|
+
export type {
|
|
3
|
+
BucketConfig,
|
|
4
|
+
ObjectAttrs,
|
|
5
|
+
UploadOptions,
|
|
6
|
+
ListEntry,
|
|
7
|
+
SignedDownloadUrl,
|
|
8
|
+
SignedUploadUrl,
|
|
9
|
+
AttrsOptions,
|
|
10
|
+
ByteRange,
|
|
11
|
+
DownloadOptions,
|
|
12
|
+
ExistsOptions,
|
|
13
|
+
ListOptions,
|
|
14
|
+
DeleteOptions,
|
|
15
|
+
DownloadUrlOptions,
|
|
16
|
+
UploadUrlOptions,
|
|
17
|
+
} from './bucket';
|
|
18
|
+
export {
|
|
19
|
+
ObjectsError,
|
|
20
|
+
ObjectNotFound,
|
|
21
|
+
PreconditionFailed,
|
|
22
|
+
InvalidArgument,
|
|
23
|
+
} from './error';
|
|
24
|
+
export type {
|
|
25
|
+
BucketPerms,
|
|
26
|
+
Uploader,
|
|
27
|
+
SignedUploader,
|
|
28
|
+
Downloader,
|
|
29
|
+
SignedDownloader,
|
|
30
|
+
Attrser,
|
|
31
|
+
Lister,
|
|
32
|
+
ReadWriter,
|
|
33
|
+
PublicUrler,
|
|
34
|
+
Remover,
|
|
35
|
+
} from './refs';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AttrsOptions,
|
|
3
|
+
DeleteOptions,
|
|
4
|
+
DownloadOptions,
|
|
5
|
+
DownloadUrlOptions,
|
|
6
|
+
ExistsOptions,
|
|
7
|
+
ListEntry,
|
|
8
|
+
ListOptions,
|
|
9
|
+
ObjectAttrs,
|
|
10
|
+
SignedDownloadUrl,
|
|
11
|
+
SignedUploadUrl,
|
|
12
|
+
UploadOptions,
|
|
13
|
+
UploadUrlOptions,
|
|
14
|
+
} from './bucket';
|
|
15
|
+
|
|
16
|
+
export abstract class BucketPerms {
|
|
17
|
+
private bucketPerms(): void {}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export abstract class Uploader extends BucketPerms {
|
|
21
|
+
abstract upload(
|
|
22
|
+
name: string,
|
|
23
|
+
data: Buffer,
|
|
24
|
+
options?: UploadOptions,
|
|
25
|
+
): Promise<ObjectAttrs>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export abstract class SignedUploader extends BucketPerms {
|
|
29
|
+
abstract signedUploadUrl(
|
|
30
|
+
name: string,
|
|
31
|
+
options?: UploadUrlOptions,
|
|
32
|
+
): Promise<SignedUploadUrl>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export abstract class Downloader extends BucketPerms {
|
|
36
|
+
abstract download(name: string, options?: DownloadOptions): Promise<Buffer>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export abstract class SignedDownloader extends BucketPerms {
|
|
40
|
+
abstract signedDownloadUrl(
|
|
41
|
+
name: string,
|
|
42
|
+
options?: DownloadUrlOptions,
|
|
43
|
+
): Promise<SignedDownloadUrl>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export abstract class Attrser extends BucketPerms {
|
|
47
|
+
abstract attrs(name: string, options?: AttrsOptions): Promise<ObjectAttrs>;
|
|
48
|
+
abstract exists(name: string, options?: ExistsOptions): Promise<boolean>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export abstract class Lister extends BucketPerms {
|
|
52
|
+
abstract list(options: ListOptions): AsyncGenerator<ListEntry>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export abstract class Remover extends BucketPerms {
|
|
56
|
+
abstract remove(name: string, options?: DeleteOptions): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export abstract class PublicUrler extends BucketPerms {
|
|
60
|
+
abstract publicUrl(name: string): string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type ReadWriter = Uploader &
|
|
64
|
+
SignedUploader &
|
|
65
|
+
Downloader &
|
|
66
|
+
SignedDownloader &
|
|
67
|
+
Attrser &
|
|
68
|
+
Lister &
|
|
69
|
+
Remover;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import {expect, test} from 'bun:test';
|
|
2
|
+
|
|
3
|
+
// A child process isolates native runtime initialization and other tests' mocks.
|
|
4
|
+
test.skipIf(!process.env.ENCORE_TS_POSTGRES_TEST_HOST)(
|
|
5
|
+
'native Postgres counts, cursor leases, connection transactions, and async disposal',
|
|
6
|
+
() => {
|
|
7
|
+
const proc = Bun.spawnSync({
|
|
8
|
+
cmd: [
|
|
9
|
+
process.execPath,
|
|
10
|
+
'-e',
|
|
11
|
+
`
|
|
12
|
+
import assert from "node:assert/strict";
|
|
13
|
+
import { Database } from ${JSON.stringify(`${import.meta.dir}/mod.ts`)};
|
|
14
|
+
const db = new Database("postgres-tests");
|
|
15
|
+
await using conn = await db.write().acquire();
|
|
16
|
+
await conn.rawExec("CREATE TEMP TABLE encore_ts_sql_test (id int)");
|
|
17
|
+
const inserted = await conn.rawExec("INSERT INTO encore_ts_sql_test VALUES (1), (2) RETURNING id");
|
|
18
|
+
assert.equal(inserted.rowsAffected, 2n);
|
|
19
|
+
assert.equal(await conn.rawQueryRow("SELECT id FROM encore_ts_sql_test WHERE false"), null);
|
|
20
|
+
await assert.rejects(conn.rawQueryRow("SELECT id FROM encore_ts_sql_test"), /more than one row/);
|
|
21
|
+
assert.equal((await conn.rawQueryAll("SELECT id FROM encore_ts_sql_test")).length, 2);
|
|
22
|
+
|
|
23
|
+
const stream = conn.rawQuery("SELECT id FROM encore_ts_sql_test");
|
|
24
|
+
await stream.next();
|
|
25
|
+
await assert.rejects(conn.begin(), /active operation/);
|
|
26
|
+
await assert.rejects(conn.close(), /active operation/);
|
|
27
|
+
await stream.return();
|
|
28
|
+
{
|
|
29
|
+
await using tx = await conn.begin();
|
|
30
|
+
await assert.rejects(conn.rawQueryRow("SELECT 1"), /active operation/);
|
|
31
|
+
await assert.rejects(conn.close(), /active operation/);
|
|
32
|
+
const rows = tx.rawQuery("SELECT id FROM encore_ts_sql_test");
|
|
33
|
+
await rows.next();
|
|
34
|
+
await assert.rejects(tx.commit(), /active operation/);
|
|
35
|
+
await rows.return();
|
|
36
|
+
await tx.rawExec("INSERT INTO encore_ts_sql_test VALUES (3)");
|
|
37
|
+
// A previously rejected busy commit must not prevent disposal rollback.
|
|
38
|
+
}
|
|
39
|
+
assert.equal((await conn.rawQueryAll("SELECT id FROM encore_ts_sql_test")).length, 2);
|
|
40
|
+
{
|
|
41
|
+
await using tx = await conn.begin();
|
|
42
|
+
await tx.rawExec("INSERT INTO encore_ts_sql_test VALUES (3)");
|
|
43
|
+
await tx.commit();
|
|
44
|
+
await assert.rejects(tx.rawExec("SELECT 1"), /closed/);
|
|
45
|
+
}
|
|
46
|
+
assert.equal((await conn.rawQueryAll("SELECT id FROM encore_ts_sql_test")).length, 3);
|
|
47
|
+
{
|
|
48
|
+
await using tx = await conn.begin();
|
|
49
|
+
await assert.rejects(tx.rawExec("SELECT 1 / 0"));
|
|
50
|
+
}
|
|
51
|
+
assert.deepEqual(await conn.rawQueryRow("SELECT 1 AS id"), { id: 1 });
|
|
52
|
+
await conn.close();
|
|
53
|
+
await assert.rejects(conn.rawQueryRow("SELECT 1"), /closed/);
|
|
54
|
+
`,
|
|
55
|
+
],
|
|
56
|
+
env: {
|
|
57
|
+
...process.env,
|
|
58
|
+
NODE_ENV: 'test',
|
|
59
|
+
ENCORE_RUNTIME_CONFIG: runtimeConfig(
|
|
60
|
+
process.env.ENCORE_TS_POSTGRES_TEST_HOST!,
|
|
61
|
+
),
|
|
62
|
+
},
|
|
63
|
+
timeout: 30_000,
|
|
64
|
+
});
|
|
65
|
+
expect(proc.exitCode, proc.stderr.toString()).toBe(0);
|
|
66
|
+
},
|
|
67
|
+
35_000,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// The pool has two connections: holding one, every handle runs on the other.
|
|
71
|
+
test.skipIf(!process.env.ENCORE_TS_POSTGRES_TEST_HOST)(
|
|
72
|
+
'native Postgres read handles refuse writes, and write handles still write on their connection',
|
|
73
|
+
() => {
|
|
74
|
+
const proc = Bun.spawnSync({
|
|
75
|
+
cmd: [
|
|
76
|
+
process.execPath,
|
|
77
|
+
'-e',
|
|
78
|
+
`
|
|
79
|
+
import assert from "node:assert/strict";
|
|
80
|
+
import { Database } from ${JSON.stringify(`${import.meta.dir}/mod.ts`)};
|
|
81
|
+
const db = new Database("postgres-tests");
|
|
82
|
+
const table = "encore_ts_access_" + process.pid;
|
|
83
|
+
await db.rawExec("CREATE TABLE " + table + " (pid int)");
|
|
84
|
+
const write = "INSERT INTO " + table + " VALUES (pg_backend_pid())";
|
|
85
|
+
const refused = /cannot execute INSERT in a read-only transaction/;
|
|
86
|
+
try {
|
|
87
|
+
await using held = await db.write().acquire();
|
|
88
|
+
for (const reader of [db.read(), db.read({ primary: true })]) {
|
|
89
|
+
const { pid } = await reader.rawQueryRow("SELECT pg_backend_pid() AS pid");
|
|
90
|
+
await assert.rejects(reader.rawExec(write), refused);
|
|
91
|
+
{
|
|
92
|
+
await using tx = await reader.begin();
|
|
93
|
+
await assert.rejects(tx.rawExec(write), refused);
|
|
94
|
+
}
|
|
95
|
+
{
|
|
96
|
+
await using conn = await reader.acquire();
|
|
97
|
+
await assert.rejects(conn.rawExec(write), refused);
|
|
98
|
+
await using tx = await conn.begin();
|
|
99
|
+
await assert.rejects(tx.rawExec(write), refused);
|
|
100
|
+
}
|
|
101
|
+
for (const writer of [db.write(), db.admin(), db]) {
|
|
102
|
+
assert.equal((await writer.rawExec(write)).rowsAffected, 1n);
|
|
103
|
+
{
|
|
104
|
+
await using tx = await writer.begin();
|
|
105
|
+
await tx.rawExec(write);
|
|
106
|
+
await tx.commit();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Every write ran on the connection the read handle used.
|
|
110
|
+
const pids = await db.rawQueryAll("SELECT DISTINCT pid FROM " + table);
|
|
111
|
+
assert.deepEqual(pids, [{ pid }]);
|
|
112
|
+
}
|
|
113
|
+
} finally {
|
|
114
|
+
await db.rawExec("DROP TABLE " + table);
|
|
115
|
+
}
|
|
116
|
+
`,
|
|
117
|
+
],
|
|
118
|
+
env: {
|
|
119
|
+
...process.env,
|
|
120
|
+
NODE_ENV: 'test',
|
|
121
|
+
ENCORE_RUNTIME_CONFIG: runtimeConfig(
|
|
122
|
+
process.env.ENCORE_TS_POSTGRES_TEST_HOST!,
|
|
123
|
+
),
|
|
124
|
+
},
|
|
125
|
+
timeout: 30_000,
|
|
126
|
+
});
|
|
127
|
+
expect(proc.exitCode, proc.stderr.toString()).toBe(0);
|
|
128
|
+
},
|
|
129
|
+
35_000,
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
// Minimal RuntimeConfig protobuf, matching the Python SDK's test server setup.
|
|
133
|
+
function runtimeConfig(host: string): string {
|
|
134
|
+
function varint(n: number): Buffer {
|
|
135
|
+
const bytes: number[] = [];
|
|
136
|
+
while (n > 127) {
|
|
137
|
+
bytes.push((n & 127) | 128);
|
|
138
|
+
n >>>= 7;
|
|
139
|
+
}
|
|
140
|
+
return Buffer.from([...bytes, n]);
|
|
141
|
+
}
|
|
142
|
+
function message(field: number, data: Buffer): Buffer {
|
|
143
|
+
return Buffer.concat([varint(field * 8 + 2), varint(data.length), data]);
|
|
144
|
+
}
|
|
145
|
+
const str = (field: number, value: string) =>
|
|
146
|
+
message(field, Buffer.from(value));
|
|
147
|
+
const num = (field: number, value: number) =>
|
|
148
|
+
Buffer.concat([varint(field * 8), varint(value)]);
|
|
149
|
+
const server = Buffer.concat([str(1, 'sql:server'), str(2, host), num(3, 1)]);
|
|
150
|
+
const pool = Buffer.concat([str(2, 'sql:role'), num(4, 2)]);
|
|
151
|
+
const database = Buffer.concat([
|
|
152
|
+
str(1, 'sql:db'),
|
|
153
|
+
str(2, 'postgres-tests'),
|
|
154
|
+
str(3, 'postgres'),
|
|
155
|
+
message(4, pool),
|
|
156
|
+
]);
|
|
157
|
+
const cluster = Buffer.concat([
|
|
158
|
+
str(1, 'sql:cluster'),
|
|
159
|
+
message(2, server),
|
|
160
|
+
message(3, database),
|
|
161
|
+
]);
|
|
162
|
+
const role = Buffer.concat([
|
|
163
|
+
str(1, 'sql:role'),
|
|
164
|
+
str(2, 'postgres'),
|
|
165
|
+
message(3, str(1, 'encore-test')),
|
|
166
|
+
]);
|
|
167
|
+
const infra = Buffer.concat([
|
|
168
|
+
message(1, message(2, cluster)),
|
|
169
|
+
message(2, message(2, role)),
|
|
170
|
+
]);
|
|
171
|
+
return Buffer.concat([
|
|
172
|
+
message(1, str(1, 'ts-sql-test')),
|
|
173
|
+
message(2, infra),
|
|
174
|
+
]).toString('base64');
|
|
175
|
+
}
|