@voxgig/station 0.1.0 → 0.2.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.
Files changed (44) hide show
  1. package/dist/src/Station.d.ts +1 -118
  2. package/dist/src/Station.js +26 -412
  3. package/dist/src/Station.js.map +1 -1
  4. package/dist/src/adapter.js +0 -54
  5. package/dist/src/adapter.js.map +1 -1
  6. package/dist/src/config-shape.js +0 -11
  7. package/dist/src/config-shape.js.map +1 -1
  8. package/dist/src/descriptor.js +0 -38
  9. package/dist/src/descriptor.js.map +1 -1
  10. package/dist/src/error.js +0 -5
  11. package/dist/src/error.js.map +1 -1
  12. package/dist/src/factory.d.ts +0 -9
  13. package/dist/src/factory.js +0 -37
  14. package/dist/src/factory.js.map +1 -1
  15. package/dist/src/feature.d.ts +0 -75
  16. package/dist/src/feature.js +0 -87
  17. package/dist/src/feature.js.map +1 -1
  18. package/dist/src/index.js +0 -7
  19. package/dist/src/index.js.map +1 -1
  20. package/dist/src/loader.d.ts +0 -29
  21. package/dist/src/loader.js +0 -66
  22. package/dist/src/loader.js.map +1 -1
  23. package/dist/src/profile.js +0 -91
  24. package/dist/src/profile.js.map +1 -1
  25. package/dist/src/secrets.d.ts +5 -0
  26. package/dist/src/secrets.js +106 -32
  27. package/dist/src/secrets.js.map +1 -1
  28. package/dist/src/shape.d.ts +0 -22
  29. package/dist/src/shape.js +0 -113
  30. package/dist/src/shape.js.map +1 -1
  31. package/package.json +3 -3
  32. package/src/Station.ts +28 -413
  33. package/src/adapter.ts +0 -57
  34. package/src/config-shape.ts +0 -11
  35. package/src/descriptor.ts +0 -38
  36. package/src/error.ts +0 -5
  37. package/src/factory.ts +0 -37
  38. package/src/feature.ts +0 -87
  39. package/src/index.ts +0 -7
  40. package/src/loader.ts +0 -66
  41. package/src/profile.ts +0 -95
  42. package/src/secrets.ts +104 -32
  43. package/src/shape.ts +0 -113
  44. package/src/types.ts +0 -59
@@ -1,36 +1,10 @@
1
1
  import { Binding, PluginEntry, ResolvedInstance, SdkBlock, StationEvent, StationOptions } from './types';
2
- /** §6.1: `as` IS A TAG, NOT A FREE NAME.
3
- *
4
- * The api comes from the SDK being passed, so the resulting ref is
5
- * `<api>$<tag>` and multi-instance works imperatively too. A full ref is
6
- * also accepted and is VALIDATED: its name must equal the SDK's api
7
- * slug, or it is `station_instance_api`.
8
- *
9
- * Both forms are needed because the imperative path is where the api is
10
- * implicit in an argument rather than written in a key. An `as` that
11
- * took an arbitrary name would reintroduce exactly the second-identity
12
- * problem the ref re-key removed: under the ref invariant
13
- * `as: 'solar-eu'` would denote the untagged `solar-eu` DEFINITION, not
14
- * an instance of the SDK just handed in, and registry grouping, api
15
- * defaults and every ref consumer would disagree about what it is.
16
- *
17
- * A bare connect(SDK) with no name falls back to the descriptor slug,
18
- * which is today's behaviour and why the single-instance case is
19
- * unchanged to the byte. */
20
2
  export declare function instanceRef(api: string, fopts?: any): string;
21
3
  export declare function checkInstanceName(name: string): boolean;
22
4
  export declare function checkInstanceTag(tag: string): boolean;
23
5
  export declare class Station {
24
6
  private static ambient;
25
7
  private static ambientOpts;
26
- /** §6.2's second path, and the front door the docs name.
27
- *
28
- * The package exported only the free `provide()` and the class had no
29
- * static — so the documented `Station.provide(...)` call failed, and
30
- * so did the remediation `station_no_factory` prints, which tells the
31
- * user to make exactly that call. Delegates to the same
32
- * process-global table the free function fills; there is one
33
- * registry, not two. */
34
8
  static provide(api: string, factory: any): void;
35
9
  private opts;
36
10
  private profile;
@@ -56,51 +30,17 @@ export declare class Station {
56
30
  private construct;
57
31
  options(a?: any, b?: any): any;
58
32
  _boundEntry(client: any): PluginEntry | null;
59
- /** The profile block that governs an instance — its own if the
60
- * profile declares it, otherwise its **api's**.
61
- *
62
- * `resolveProfile` builds `profile.sdk` from the declared refs alone
63
- * ("an api block declares no instance, so the ref set comes from the
64
- * two `sdk` maps"), shallow-merging `profile.api[a]` into each. That
65
- * is right for a declared instance and leaves an IMPERATIVE one —
66
- * `connect(SDK, { as: 'test' })`, named but never written into
67
- * config — with no block at all. The api-level `secret`, `base` and
68
- * most seriously `policy.hosts` then did not reach it, so a profile
69
- * that denies egress everywhere denied nothing for a tagged client.
70
- *
71
- * ONE RULE, ONE PLACE: registration and the transport seam both ask
72
- * here, because they disagreeing is how the credential and the
73
- * allowlist came apart in the first place. */
74
33
  private blockFor;
75
- /** The DECLARED instance an assigned tag stands for, or the name
76
- * itself. `create('stripe$prod')` registers under `stripe$1`, and
77
- * every question about that client's configuration — its secret, its
78
- * base, its egress policy — is a question about `stripe$prod`. */
79
34
  private declaredRef;
80
35
  _register(client: any, config: any, options: any, _calleropts: any, fopts?: any): {
81
36
  binding: Binding;
82
37
  profilePlugin?: SdkBlock;
83
38
  };
84
39
  private descriptorCache;
85
- /** The descriptor describes the API, and is SHARED by every instance
86
- * of it — which is §7.4's own reasoning for why the effective secret
87
- * name moved to `Binding` and is not read off the descriptor.
88
- *
89
- * The same argument applies to feature activation, and this did not
90
- * follow it: the cache is keyed by slug alone while
91
- * `normalizeDescriptor`'s second argument decides each feature row's
92
- * `active`. So two instances of one api constructed with different
93
- * feature maps shared the FIRST one's feature state, and
94
- * `descriptorOf()` / `canonicalDescriptor()` became
95
- * construction-order-dependent.
96
- *
97
- * Normalized with no per-instance features, so the shared value holds
98
- * only API-stable metadata — which is what `factory.ts` already does
99
- * when it normalizes at provide time. Per-instance activation is
100
- * `featuresOf(name)`'s answer, and always was. */
101
40
  private describe;
102
41
  _hoist(name: string, value: string): void;
103
42
  _transport(name: string, inner: any, fctx: any, fullurl: string, fetchdef: any): Promise<any>;
43
+ private scrubbed;
104
44
  private emitHttp;
105
45
  private emitErr;
106
46
  _opEvent(name: string, ctx: any, outcome: string): void;
@@ -113,63 +53,16 @@ export declare class Station {
113
53
  secretname?: string;
114
54
  warnings: string[];
115
55
  }[];
116
- /** The instance, constructed on first call and CACHED: same name ->
117
- * same object. That caching is what makes "get it where you need it"
118
- * a real instruction - call it in a request handler, in a worker, in
119
- * a test, and the first call pays construction while the rest are a
120
- * map lookup.
121
- *
122
- * SYNCHRONOUS (§6.3), which is what bounds the loader to CommonJS. */
123
56
  sdk(name: string): any;
124
- /** An UNCACHED client from the same resolved config plus overrides,
125
- * for the case that genuinely wants a distinct one - a per-request
126
- * credential scope, a test double. Deliberately the longer name.
127
- *
128
- * It registers under an AUTO-ASSIGNED TAG, because §7.5 registers
129
- * every constructed adapter under its instance name and
130
- * `station_bound_twice` fires on a second binding of one name: a
131
- * second `create('stripe')` would otherwise throw, which is exactly
132
- * the per-request case this exists for. The tag is the lowest unused
133
- * positive integer, so an auto-tagged instance is an ORDINARY
134
- * instance rather than a parallel identity scheme - `plugins()`, the
135
- * placeholder, the event stream and `station_bound_twice` all keep
136
- * working on one identity model.
137
- *
138
- * The SECRET NAME does not follow the assigned tag: it resolves from
139
- * the DECLARED instance the tag was assigned under, so every client
140
- * of one instance shares one broker cache entry rather than
141
- * re-resolving per request (§5.3). */
142
57
  create(name: string, overrides?: any): any;
143
- /** The lowest positive integer tag not already taken, by a LIVE
144
- * instance or a DECLARED one.
145
- *
146
- * The registry alone was not enough: a profile may declare
147
- * `stripe$1`, and until something constructs it `registry.has` says
148
- * false — so `create('stripe$prod')` took that identity for a client
149
- * built from the `stripe$prod` block. `instances()` then reported the
150
- * declared `stripe$1` as live with the wrong client, and a later
151
- * `sdk('stripe$1')` failed `station_bound_twice` against a binding
152
- * that was never its own. Declaration reserves the name whether or
153
- * not it has been built. */
154
58
  private autotag;
155
59
  private build;
156
- /** §6.2's three paths, in order of preference: self-registration,
157
- * `Station.provide`, then the loader. */
158
60
  private resolveFactory;
159
- /** `package` is honoured only from repo-scoped config (§6.3), and a
160
- * user-level one is IGNORED WITH A WARNING rather than imported - it
161
- * names code to load and sits outside the repo's review boundary. */
162
61
  private loaderPackage;
163
62
  /** ts/js only: preload ESM packages into the factory table, after
164
63
  * which `sdk()` is synchronous again for everything (§6.3). One
165
64
  * `await` at startup rather than one per call site. */
166
65
  load(): Promise<void>;
167
- /** The merged, ordered feature set for one instance, WITH
168
- * PROVENANCE (§8.7): which config level set each value.
169
- *
170
- * Provenance is the half that makes a fleet view usable rather than
171
- * merely correct - at 26 instances "why is retry off here" is the
172
- * question, and a merged map alone cannot answer it. */
173
66
  featuresOf(name: string): {
174
67
  ordered: string[];
175
68
  merged: {
@@ -188,10 +81,6 @@ export declare class Station {
188
81
  api?: string;
189
82
  feature?: string;
190
83
  }): any[];
191
- /** Eagerly resolve and construct every ACTIVE instance - for CI
192
- * (§6.6). The point is to turn availability errors, which are
193
- * deliberately deferred to first use, into one failure at a moment
194
- * somebody is watching. */
195
84
  check(): {
196
85
  ok: string[];
197
86
  failed: {
@@ -200,12 +89,6 @@ export declare class Station {
200
89
  message: string;
201
90
  }[];
202
91
  };
203
- /** Batch-resolve secrets for ACTIVE instances (§5.5).
204
- *
205
- * With no argument it warms the active ones only, because reaching
206
- * for a credential belonging to a disabled integration is the wrong
207
- * default. `warm(names)` warms exactly what it is given, inactive
208
- * included, because an explicit name is an explicit request. */
209
92
  warm(names?: string[]): Promise<{
210
93
  warmed: string[];
211
94
  missed: string[];