@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,488 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metrics: counters, up-down counters, histograms and gauges of what an app
|
|
3
|
+
* does.
|
|
4
|
+
*
|
|
5
|
+
* A metric is declared at module level and used wherever the thing it
|
|
6
|
+
* measures happens. Its JSDoc comment, else its `description` option, is
|
|
7
|
+
* its description:
|
|
8
|
+
*
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { Counter, Histogram } from "@encore.dev/sdk/metrics";
|
|
11
|
+
*
|
|
12
|
+
* export const ordersPlaced = new Counter("orders_placed", { unit: "{order}" });
|
|
13
|
+
* export const uploadSize = new Histogram("upload_size", {
|
|
14
|
+
* unit: "By",
|
|
15
|
+
* buckets: [1024, 65536, 1048576]
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* ordersPlaced.increment();
|
|
19
|
+
* uploadSize.record(2048);
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Each is an instrument of the OpenTelemetry Metrics API
|
|
23
|
+
* (`@opentelemetry/api`), of the meter `encore`, named as declared, a
|
|
24
|
+
* service's own prefixed with its service's name (`orders_placed` of the
|
|
25
|
+
* service `shop` is exported as `shop.orders_placed`), created when it is
|
|
26
|
+
* first recorded to, recording through Encore's meter provider whatever the
|
|
27
|
+
* global one is. Instruments of the API itself made with it
|
|
28
|
+
* (`meterProvider().getMeter(…)`) are exported alongside: observable
|
|
29
|
+
* instruments are made with it.
|
|
30
|
+
*
|
|
31
|
+
* Which class declares a metric says who records to it: a `Counter`
|
|
32
|
+
* belongs to the declaring service, which alone records to it; a
|
|
33
|
+
* `SharedCounter` is shared between services, each that records to it
|
|
34
|
+
* tracked as using it; a `GlobalCounter` is the whole app's, recorded to
|
|
35
|
+
* from any code, untracked. `SharedCounter` and `GlobalCounter` extend
|
|
36
|
+
* `Counter`, so code taking a `Counter` takes one of any scope. The
|
|
37
|
+
* `…Group` classes take a label type, whose fields are the attributes of
|
|
38
|
+
* what is recorded:
|
|
39
|
+
*
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import { CounterGroup } from "@encore.dev/sdk/metrics";
|
|
42
|
+
*
|
|
43
|
+
* interface Outcome {
|
|
44
|
+
* method: string;
|
|
45
|
+
* status: number;
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
* export const requests = new CounterGroup<Outcome>("requests_handled");
|
|
49
|
+
*
|
|
50
|
+
* requests.with({ method: "GET", status: 200 }).increment();
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* A shared or global metric is declared once in the app, as a shared
|
|
54
|
+
* secret is. Other code records to it by importing the declaration, or,
|
|
55
|
+
* from another service in another language, binds it by name with
|
|
56
|
+
* `named`, which states the declaration's kind and labels and takes its
|
|
57
|
+
* scope, unit, description and buckets. Every scope's class has it and
|
|
58
|
+
* binds alike: `SharedCounter.named` is `Counter.named`. A bound metric is
|
|
59
|
+
* exported as declared, never prefixed.
|
|
60
|
+
*
|
|
61
|
+
* ```typescript
|
|
62
|
+
* import { CounterGroup } from "@encore.dev/sdk/metrics";
|
|
63
|
+
*
|
|
64
|
+
* const served = CounterGroup.named<Served>("greetings.served");
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* To hand a metric to other code, pass its `ref()`: it counts as recording
|
|
68
|
+
* to it.
|
|
69
|
+
*
|
|
70
|
+
* @module
|
|
71
|
+
*/
|
|
72
|
+
import { hostedService, meter, meterProvider } from '../internal/runtime/meter.js';
|
|
73
|
+
export { meterProvider };
|
|
74
|
+
/** A metric's instrument, made when first recorded to. */
|
|
75
|
+
class Lazy {
|
|
76
|
+
kind;
|
|
77
|
+
name;
|
|
78
|
+
opts;
|
|
79
|
+
own;
|
|
80
|
+
inst;
|
|
81
|
+
/** `own`: the declaring service's alone, exported as
|
|
82
|
+
* `<service>.<name>`. */
|
|
83
|
+
constructor(kind, name, opts, own) {
|
|
84
|
+
this.kind = kind;
|
|
85
|
+
this.name = name;
|
|
86
|
+
this.opts = opts;
|
|
87
|
+
this.own = own;
|
|
88
|
+
}
|
|
89
|
+
get() {
|
|
90
|
+
this.inst ??= this.make();
|
|
91
|
+
return this.inst;
|
|
92
|
+
}
|
|
93
|
+
make() {
|
|
94
|
+
const m = meter();
|
|
95
|
+
const svc = this.own ? hostedService() : undefined;
|
|
96
|
+
const name = svc ? `${svc}.${this.name}` : this.name;
|
|
97
|
+
const opts = { unit: this.opts?.unit, description: this.opts?.description };
|
|
98
|
+
switch (this.kind) {
|
|
99
|
+
case 'counter':
|
|
100
|
+
return m.createCounter(name, opts);
|
|
101
|
+
case 'upDownCounter':
|
|
102
|
+
return m.createUpDownCounter(name, opts);
|
|
103
|
+
case 'gauge':
|
|
104
|
+
return m.createGauge(name, opts);
|
|
105
|
+
case 'histogram':
|
|
106
|
+
return m.createHistogram(name, {
|
|
107
|
+
...opts,
|
|
108
|
+
advice: this.opts?.buckets && {
|
|
109
|
+
explicitBucketBoundaries: this.opts.buckets,
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/** A `cls` recording to `inst` with `attrs`, attributes as a JSON object's
|
|
116
|
+
* text, made without its constructor, which declares a metric. */
|
|
117
|
+
function bind(cls, inst, attrs) {
|
|
118
|
+
return Object.assign(Object.create(cls.prototype), {
|
|
119
|
+
inst,
|
|
120
|
+
attrs,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/** A group's instrument, for a subclass's `with`. */
|
|
124
|
+
function lazy(group) {
|
|
125
|
+
return group.inst;
|
|
126
|
+
}
|
|
127
|
+
/** `labels` as attributes, a JSON object's text: keys in snake_case,
|
|
128
|
+
* numbers floored. */
|
|
129
|
+
function attributes(labels) {
|
|
130
|
+
const out = {};
|
|
131
|
+
for (const [key, value] of Object.entries(labels)) {
|
|
132
|
+
out[snakeCase(key)] = typeof value === 'number' ? Math.floor(value) : value;
|
|
133
|
+
}
|
|
134
|
+
return JSON.stringify(out);
|
|
135
|
+
}
|
|
136
|
+
/** `statusCode` is `status_code`, `HTTPStatus` `http_status`. */
|
|
137
|
+
function snakeCase(s) {
|
|
138
|
+
return s
|
|
139
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1_$2')
|
|
140
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
|
|
141
|
+
.toLowerCase();
|
|
142
|
+
}
|
|
143
|
+
// Encore reads a metric's scope from the class that declares it. A name is a
|
|
144
|
+
// string literal: a letter, then letters, digits, `_`, `.`, `-` and `/`.
|
|
145
|
+
// `named` binds a shared or global metric declared elsewhere, by another
|
|
146
|
+
// service, possibly in another language: its kind and labels are the
|
|
147
|
+
// declaration's, and so are its scope, unit, description and buckets.
|
|
148
|
+
/** A number that only goes up: how many times something happened, or how
|
|
149
|
+
* much of something there has been. Belongs to the declaring service: only it records to it. */
|
|
150
|
+
export class Counter {
|
|
151
|
+
inst;
|
|
152
|
+
attrs;
|
|
153
|
+
/** Declares the counter `name`. */
|
|
154
|
+
constructor(name, opts) {
|
|
155
|
+
this.inst = new Lazy('counter', name, opts, new.target === Counter);
|
|
156
|
+
}
|
|
157
|
+
/** Binds the shared or global counter `name`, declared elsewhere. */
|
|
158
|
+
static named(name) {
|
|
159
|
+
return bind(Counter, new Lazy('counter', name, undefined, false));
|
|
160
|
+
}
|
|
161
|
+
/** Adds one. */
|
|
162
|
+
increment() {
|
|
163
|
+
this.inst.get().recordEncoded(1, this.attrs);
|
|
164
|
+
}
|
|
165
|
+
/** Adds `n`. A counter does not go down: an amount below zero is
|
|
166
|
+
* ignored. */
|
|
167
|
+
add(n) {
|
|
168
|
+
this.inst.get().recordEncoded(n, this.attrs);
|
|
169
|
+
}
|
|
170
|
+
/** The counter itself, to hand to other code. */
|
|
171
|
+
ref() {
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** A counter shared between services: each that records to it is tracked as
|
|
176
|
+
* using it. */
|
|
177
|
+
export class SharedCounter extends Counter {
|
|
178
|
+
/** Declares the shared counter `name`. */
|
|
179
|
+
constructor(name, opts) {
|
|
180
|
+
super(name, opts);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/** A counter of the whole app: any code may record to it. */
|
|
184
|
+
export class GlobalCounter extends Counter {
|
|
185
|
+
/** Declares the global counter `name`. */
|
|
186
|
+
constructor(name, opts) {
|
|
187
|
+
super(name, opts);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/** A number that goes up and down by what is added to it: how many
|
|
191
|
+
* requests are in flight, how many jobs are queued. Belongs to the declaring service: only it records to it. */
|
|
192
|
+
export class UpDownCounter {
|
|
193
|
+
inst;
|
|
194
|
+
attrs;
|
|
195
|
+
/** Declares the up-down counter `name`. */
|
|
196
|
+
constructor(name, opts) {
|
|
197
|
+
this.inst = new Lazy('upDownCounter', name, opts, new.target === UpDownCounter);
|
|
198
|
+
}
|
|
199
|
+
/** Binds the shared or global up-down counter `name`, declared elsewhere. */
|
|
200
|
+
static named(name) {
|
|
201
|
+
return bind(UpDownCounter, new Lazy('upDownCounter', name, undefined, false));
|
|
202
|
+
}
|
|
203
|
+
/** Adds `n`, which may be below zero. */
|
|
204
|
+
add(n) {
|
|
205
|
+
this.inst.get().recordEncoded(n, this.attrs);
|
|
206
|
+
}
|
|
207
|
+
/** Adds one. */
|
|
208
|
+
increment() {
|
|
209
|
+
this.inst.get().recordEncoded(1, this.attrs);
|
|
210
|
+
}
|
|
211
|
+
/** Takes away one. */
|
|
212
|
+
decrement() {
|
|
213
|
+
this.inst.get().recordEncoded(-1, this.attrs);
|
|
214
|
+
}
|
|
215
|
+
/** The up-down counter itself, to hand to other code. */
|
|
216
|
+
ref() {
|
|
217
|
+
return this;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/** An up-down counter shared between services: each that records to it is tracked as
|
|
221
|
+
* using it. */
|
|
222
|
+
export class SharedUpDownCounter extends UpDownCounter {
|
|
223
|
+
/** Declares the shared up-down counter `name`. */
|
|
224
|
+
constructor(name, opts) {
|
|
225
|
+
super(name, opts);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/** An up-down counter of the whole app: any code may record to it. */
|
|
229
|
+
export class GlobalUpDownCounter extends UpDownCounter {
|
|
230
|
+
/** Declares the global up-down counter `name`. */
|
|
231
|
+
constructor(name, opts) {
|
|
232
|
+
super(name, opts);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/** A number that is what it was last set to: what something is right now. Belongs to the declaring service: only it records to it. */
|
|
236
|
+
export class Gauge {
|
|
237
|
+
inst;
|
|
238
|
+
attrs;
|
|
239
|
+
/** Declares the gauge `name`. */
|
|
240
|
+
constructor(name, opts) {
|
|
241
|
+
this.inst = new Lazy('gauge', name, opts, new.target === Gauge);
|
|
242
|
+
}
|
|
243
|
+
/** Binds the shared or global gauge `name`, declared elsewhere. */
|
|
244
|
+
static named(name) {
|
|
245
|
+
return bind(Gauge, new Lazy('gauge', name, undefined, false));
|
|
246
|
+
}
|
|
247
|
+
/** Sets the gauge to `value`. */
|
|
248
|
+
set(value) {
|
|
249
|
+
this.inst.get().recordEncoded(value, this.attrs);
|
|
250
|
+
}
|
|
251
|
+
/** The gauge itself, to hand to other code. */
|
|
252
|
+
ref() {
|
|
253
|
+
return this;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/** A gauge shared between services: each that records to it is tracked as
|
|
257
|
+
* using it. */
|
|
258
|
+
export class SharedGauge extends Gauge {
|
|
259
|
+
/** Declares the shared gauge `name`. */
|
|
260
|
+
constructor(name, opts) {
|
|
261
|
+
super(name, opts);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/** A gauge of the whole app: any code may record to it. */
|
|
265
|
+
export class GlobalGauge extends Gauge {
|
|
266
|
+
/** Declares the global gauge `name`. */
|
|
267
|
+
constructor(name, opts) {
|
|
268
|
+
super(name, opts);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/** How what is recorded is distributed: how long requests take, how large
|
|
272
|
+
* uploads are. Belongs to the declaring service: only it records to it. */
|
|
273
|
+
export class Histogram {
|
|
274
|
+
inst;
|
|
275
|
+
attrs;
|
|
276
|
+
/** Declares the histogram `name`. */
|
|
277
|
+
constructor(name, opts) {
|
|
278
|
+
this.inst = new Lazy('histogram', name, opts, new.target === Histogram);
|
|
279
|
+
}
|
|
280
|
+
/** Binds the shared or global histogram `name`, declared elsewhere. */
|
|
281
|
+
static named(name) {
|
|
282
|
+
return bind(Histogram, new Lazy('histogram', name, undefined, false));
|
|
283
|
+
}
|
|
284
|
+
/** Records `value`. */
|
|
285
|
+
record(value) {
|
|
286
|
+
this.inst.get().recordEncoded(value, this.attrs);
|
|
287
|
+
}
|
|
288
|
+
/** The histogram itself, to hand to other code. */
|
|
289
|
+
ref() {
|
|
290
|
+
return this;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
/** A histogram shared between services: each that records to it is tracked as
|
|
294
|
+
* using it. */
|
|
295
|
+
export class SharedHistogram extends Histogram {
|
|
296
|
+
/** Declares the shared histogram `name`. */
|
|
297
|
+
constructor(name, opts) {
|
|
298
|
+
super(name, opts);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/** A histogram of the whole app: any code may record to it. */
|
|
302
|
+
export class GlobalHistogram extends Histogram {
|
|
303
|
+
/** Declares the global histogram `name`. */
|
|
304
|
+
constructor(name, opts) {
|
|
305
|
+
super(name, opts);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
// A group's `named` takes its label type as its type argument. TypeScript
|
|
309
|
+
// cannot infer the name's literal type beside an explicit type argument, so
|
|
310
|
+
// the name is a plain `string`, and the parser's check is the only one it
|
|
311
|
+
// gets.
|
|
312
|
+
/** A counter for each combination of the labels `L`. Belongs to the
|
|
313
|
+
* declaring service: only it records to it. */
|
|
314
|
+
export class CounterGroup {
|
|
315
|
+
inst;
|
|
316
|
+
/** Declares the counter group `name`. */
|
|
317
|
+
constructor(name, opts) {
|
|
318
|
+
this.inst = new Lazy('counter', name, opts, new.target === CounterGroup);
|
|
319
|
+
}
|
|
320
|
+
/** Binds the shared or global counter group `name`, declared elsewhere,
|
|
321
|
+
* whose labels are `L`. */
|
|
322
|
+
static named(name) {
|
|
323
|
+
return bind(CounterGroup, new Lazy('counter', name, undefined, false));
|
|
324
|
+
}
|
|
325
|
+
/** The counter for `labels`. Worth keeping where it is used often:
|
|
326
|
+
* making it encodes the labels' attributes. */
|
|
327
|
+
with(labels) {
|
|
328
|
+
return bind(Counter, this.inst, attributes(labels));
|
|
329
|
+
}
|
|
330
|
+
/** The group itself, to hand to other code. */
|
|
331
|
+
ref() {
|
|
332
|
+
return this;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
/** A counter group shared between services: each that records to it is tracked
|
|
336
|
+
* as using it. */
|
|
337
|
+
export class SharedCounterGroup extends CounterGroup {
|
|
338
|
+
/** Declares the shared counter group `name`. */
|
|
339
|
+
constructor(name, opts) {
|
|
340
|
+
super(name, opts);
|
|
341
|
+
}
|
|
342
|
+
with(labels) {
|
|
343
|
+
return bind(SharedCounter, lazy(this), attributes(labels));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/** A counter group of the whole app: any code may record to it. */
|
|
347
|
+
export class GlobalCounterGroup extends CounterGroup {
|
|
348
|
+
/** Declares the global counter group `name`. */
|
|
349
|
+
constructor(name, opts) {
|
|
350
|
+
super(name, opts);
|
|
351
|
+
}
|
|
352
|
+
with(labels) {
|
|
353
|
+
return bind(GlobalCounter, lazy(this), attributes(labels));
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
/** An up-down counter for each combination of the labels `L`. Belongs to the
|
|
357
|
+
* declaring service: only it records to it. */
|
|
358
|
+
export class UpDownCounterGroup {
|
|
359
|
+
inst;
|
|
360
|
+
/** Declares the up-down counter group `name`. */
|
|
361
|
+
constructor(name, opts) {
|
|
362
|
+
this.inst = new Lazy('upDownCounter', name, opts, new.target === UpDownCounterGroup);
|
|
363
|
+
}
|
|
364
|
+
/** Binds the shared or global up-down counter group `name`, declared elsewhere,
|
|
365
|
+
* whose labels are `L`. */
|
|
366
|
+
static named(name) {
|
|
367
|
+
return bind(UpDownCounterGroup, new Lazy('upDownCounter', name, undefined, false));
|
|
368
|
+
}
|
|
369
|
+
/** The up-down counter for `labels`. Worth keeping where it is used often:
|
|
370
|
+
* making it encodes the labels' attributes. */
|
|
371
|
+
with(labels) {
|
|
372
|
+
return bind(UpDownCounter, this.inst, attributes(labels));
|
|
373
|
+
}
|
|
374
|
+
/** The group itself, to hand to other code. */
|
|
375
|
+
ref() {
|
|
376
|
+
return this;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
/** An up-down counter group shared between services: each that records to it is tracked
|
|
380
|
+
* as using it. */
|
|
381
|
+
export class SharedUpDownCounterGroup extends UpDownCounterGroup {
|
|
382
|
+
/** Declares the shared up-down counter group `name`. */
|
|
383
|
+
constructor(name, opts) {
|
|
384
|
+
super(name, opts);
|
|
385
|
+
}
|
|
386
|
+
with(labels) {
|
|
387
|
+
return bind(SharedUpDownCounter, lazy(this), attributes(labels));
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/** An up-down counter group of the whole app: any code may record to it. */
|
|
391
|
+
export class GlobalUpDownCounterGroup extends UpDownCounterGroup {
|
|
392
|
+
/** Declares the global up-down counter group `name`. */
|
|
393
|
+
constructor(name, opts) {
|
|
394
|
+
super(name, opts);
|
|
395
|
+
}
|
|
396
|
+
with(labels) {
|
|
397
|
+
return bind(GlobalUpDownCounter, lazy(this), attributes(labels));
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/** A gauge for each combination of the labels `L`. Belongs to the
|
|
401
|
+
* declaring service: only it records to it. */
|
|
402
|
+
export class GaugeGroup {
|
|
403
|
+
inst;
|
|
404
|
+
/** Declares the gauge group `name`. */
|
|
405
|
+
constructor(name, opts) {
|
|
406
|
+
this.inst = new Lazy('gauge', name, opts, new.target === GaugeGroup);
|
|
407
|
+
}
|
|
408
|
+
/** Binds the shared or global gauge group `name`, declared elsewhere,
|
|
409
|
+
* whose labels are `L`. */
|
|
410
|
+
static named(name) {
|
|
411
|
+
return bind(GaugeGroup, new Lazy('gauge', name, undefined, false));
|
|
412
|
+
}
|
|
413
|
+
/** The gauge for `labels`. Worth keeping where it is used often:
|
|
414
|
+
* making it encodes the labels' attributes. */
|
|
415
|
+
with(labels) {
|
|
416
|
+
return bind(Gauge, this.inst, attributes(labels));
|
|
417
|
+
}
|
|
418
|
+
/** The group itself, to hand to other code. */
|
|
419
|
+
ref() {
|
|
420
|
+
return this;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
/** A gauge group shared between services: each that records to it is tracked
|
|
424
|
+
* as using it. */
|
|
425
|
+
export class SharedGaugeGroup extends GaugeGroup {
|
|
426
|
+
/** Declares the shared gauge group `name`. */
|
|
427
|
+
constructor(name, opts) {
|
|
428
|
+
super(name, opts);
|
|
429
|
+
}
|
|
430
|
+
with(labels) {
|
|
431
|
+
return bind(SharedGauge, lazy(this), attributes(labels));
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
/** A gauge group of the whole app: any code may record to it. */
|
|
435
|
+
export class GlobalGaugeGroup extends GaugeGroup {
|
|
436
|
+
/** Declares the global gauge group `name`. */
|
|
437
|
+
constructor(name, opts) {
|
|
438
|
+
super(name, opts);
|
|
439
|
+
}
|
|
440
|
+
with(labels) {
|
|
441
|
+
return bind(GlobalGauge, lazy(this), attributes(labels));
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
/** A histogram for each combination of the labels `L`. Belongs to the
|
|
445
|
+
* declaring service: only it records to it. */
|
|
446
|
+
export class HistogramGroup {
|
|
447
|
+
inst;
|
|
448
|
+
/** Declares the histogram group `name`. */
|
|
449
|
+
constructor(name, opts) {
|
|
450
|
+
this.inst = new Lazy('histogram', name, opts, new.target === HistogramGroup);
|
|
451
|
+
}
|
|
452
|
+
/** Binds the shared or global histogram group `name`, declared elsewhere,
|
|
453
|
+
* whose labels are `L`. */
|
|
454
|
+
static named(name) {
|
|
455
|
+
return bind(HistogramGroup, new Lazy('histogram', name, undefined, false));
|
|
456
|
+
}
|
|
457
|
+
/** The histogram for `labels`. Worth keeping where it is used often:
|
|
458
|
+
* making it encodes the labels' attributes. */
|
|
459
|
+
with(labels) {
|
|
460
|
+
return bind(Histogram, this.inst, attributes(labels));
|
|
461
|
+
}
|
|
462
|
+
/** The group itself, to hand to other code. */
|
|
463
|
+
ref() {
|
|
464
|
+
return this;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
/** A histogram group shared between services: each that records to it is tracked
|
|
468
|
+
* as using it. */
|
|
469
|
+
export class SharedHistogramGroup extends HistogramGroup {
|
|
470
|
+
/** Declares the shared histogram group `name`. */
|
|
471
|
+
constructor(name, opts) {
|
|
472
|
+
super(name, opts);
|
|
473
|
+
}
|
|
474
|
+
with(labels) {
|
|
475
|
+
return bind(SharedHistogram, lazy(this), attributes(labels));
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
/** A histogram group of the whole app: any code may record to it. */
|
|
479
|
+
export class GlobalHistogramGroup extends HistogramGroup {
|
|
480
|
+
/** Declares the global histogram group `name`. */
|
|
481
|
+
constructor(name, opts) {
|
|
482
|
+
super(name, opts);
|
|
483
|
+
}
|
|
484
|
+
with(labels) {
|
|
485
|
+
return bind(GlobalHistogram, lazy(this), attributes(labels));
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
//# sourceMappingURL=mod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../metrics/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAGH,OAAO,EAAC,aAAa,EAAE,KAAK,EAAE,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAG9E,OAAO,EAAC,aAAa,EAAC,CAAC;AA4BvB,0DAA0D;AAC1D,MAAM,IAAI;IAMW;IACA;IACA;IACA;IARX,IAAI,CAAY;IAExB;6BACyB;IACzB,YACmB,IAAU,EACV,IAAY,EACZ,IAAkC,EAClC,GAAY;QAHZ,SAAI,GAAJ,IAAI,CAAM;QACV,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAA8B;QAClC,QAAG,GAAH,GAAG,CAAS;IAC5B,CAAC;IAEJ,GAAG;QACD,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAEO,IAAI;QACV,MAAM,CAAC,GAAG,KAAK,EAAE,CAAC;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QACnD,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACrD,MAAM,IAAI,GAAG,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,IA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Meta, EnvironmentMeta, EnvironmentType, GatewayMeta, HostedService, } from './app_meta.js';
|
|
3
|
+
export { currentRequest } from './req_meta.js';
|
|
4
|
+
export type { BaseRequestMeta, PubSubMessageMeta, RequestMeta, TraceData, } from './req_meta.js';
|
|
5
|
+
export { meterProvider, tracerProvider } from './otel.js';
|
|
6
|
+
export type { MeterProvider, TracerProvider } from './otel.js';
|
package/dist/mod.js
ADDED
package/dist/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AAYnC,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAQ1C,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,QAAQ,CAAC"}
|
package/dist/otel.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TracerProvider } from './internal/otel/index.js';
|
|
2
|
+
import { meterProvider } from './internal/runtime/meter.js';
|
|
3
|
+
export { meterProvider };
|
|
4
|
+
export type { MeterProvider } from './internal/otel/meter.js';
|
|
5
|
+
export type { TracerProvider };
|
|
6
|
+
/** Encore's tracer provider, recording into the runtime's telemetry
|
|
7
|
+
* pipeline. Encore records its own spans without it; pass it to an
|
|
8
|
+
* instrumentation, or register it with `trace.setGlobalTracerProvider`. */
|
|
9
|
+
export declare function tracerProvider(): TracerProvider;
|
package/dist/otel.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TracerProvider } from './internal/otel/index.js';
|
|
2
|
+
import { meterProvider } from './internal/runtime/meter.js';
|
|
3
|
+
import { RT } from './internal/runtime/mod.js';
|
|
4
|
+
export { meterProvider };
|
|
5
|
+
let tracers;
|
|
6
|
+
/** Encore's tracer provider, recording into the runtime's telemetry
|
|
7
|
+
* pipeline. Encore records its own spans without it; pass it to an
|
|
8
|
+
* instrumentation, or register it with `trace.setGlobalTracerProvider`. */
|
|
9
|
+
export function tracerProvider() {
|
|
10
|
+
tracers ??= new TracerProvider(RT.telemetry());
|
|
11
|
+
return tracers;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=otel.js.map
|
package/dist/otel.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otel.js","sourceRoot":"","sources":["../otel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,EAAE,EAAC,MAAM,wBAAwB,CAAC;AAE1C,OAAO,EAAC,aAAa,EAAC,CAAC;AAIvB,IAAI,OAAmC,CAAC;AAExC;;2EAE2E;AAC3E,MAAM,UAAU,cAAc;IAC5B,OAAO,KAAK,IAAI,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Serialize JSON values, or preserve raw byte payloads. */
|
|
2
|
+
export function encodePayload(value) {
|
|
3
|
+
if (value instanceof Uint8Array)
|
|
4
|
+
return Buffer.from(value);
|
|
5
|
+
const json = JSON.stringify(value);
|
|
6
|
+
if (json === undefined)
|
|
7
|
+
throw new TypeError('Pub/Sub payload must be JSON or bytes');
|
|
8
|
+
return Buffer.from(json);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=encoding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../pubsub/encoding.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,KAAK,YAAY,UAAU;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,IAAI,KAAK,SAAS;QACpB,MAAM,IAAI,SAAS,CAAC,uCAAuC,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Topic, OrderedTopic } from './topic.js';
|
|
2
|
+
export type { TopicConfig, OrderedTopicConfig, DeliveryGuarantee } from './topic.js';
|
|
3
|
+
export { Subscription } from './subscription.js';
|
|
4
|
+
export type { SubscriptionConfig, RetryPolicy, Message } from './subscription.js';
|
|
5
|
+
export type { TopicPerms, Publisher, OrderedTopicPerms, OrderedPublisher, } from './refs.js';
|
|
6
|
+
export type { DurationString } from '../types/mod.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../pubsub/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,YAAY,EAAC,MAAM,SAAS,CAAC;AAG5C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare abstract class TopicPerms {
|
|
2
|
+
private topicPerms;
|
|
3
|
+
}
|
|
4
|
+
export declare abstract class Publisher<Msg> extends TopicPerms {
|
|
5
|
+
abstract publish(msg: Msg, attributes?: Record<string, string>): Promise<string>;
|
|
6
|
+
}
|
|
7
|
+
export declare abstract class OrderedTopicPerms {
|
|
8
|
+
private orderedTopicPerms;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class OrderedPublisher<Msg> extends OrderedTopicPerms {
|
|
11
|
+
abstract publish(msg: Msg, orderingKey: string, attributes?: Record<string, string>): Promise<string>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class TopicPerms {
|
|
2
|
+
topicPerms() { }
|
|
3
|
+
}
|
|
4
|
+
export class Publisher extends TopicPerms {
|
|
5
|
+
}
|
|
6
|
+
export class OrderedTopicPerms {
|
|
7
|
+
orderedTopicPerms() { }
|
|
8
|
+
}
|
|
9
|
+
export class OrderedPublisher extends OrderedTopicPerms {
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=refs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../../pubsub/refs.ts"],"names":[],"mappings":"AAAA,MAAM,OAAgB,UAAU;IACtB,UAAU,KAAU,CAAC;CAC9B;AAED,MAAM,OAAgB,SAAe,SAAQ,UAAU;CAKtD;AAED,MAAM,OAAgB,iBAAiB;IAC7B,iBAAiB,KAAU,CAAC;CACrC;AAED,MAAM,OAAgB,gBAAsB,SAAQ,iBAAiB;CAMpE"}
|