@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.
- package/dist/src/Station.d.ts +1 -118
- package/dist/src/Station.js +26 -412
- package/dist/src/Station.js.map +1 -1
- package/dist/src/adapter.js +0 -54
- package/dist/src/adapter.js.map +1 -1
- package/dist/src/config-shape.js +0 -11
- package/dist/src/config-shape.js.map +1 -1
- package/dist/src/descriptor.js +0 -38
- package/dist/src/descriptor.js.map +1 -1
- package/dist/src/error.js +0 -5
- package/dist/src/error.js.map +1 -1
- package/dist/src/factory.d.ts +0 -9
- package/dist/src/factory.js +0 -37
- package/dist/src/factory.js.map +1 -1
- package/dist/src/feature.d.ts +0 -75
- package/dist/src/feature.js +0 -87
- package/dist/src/feature.js.map +1 -1
- package/dist/src/index.js +0 -7
- package/dist/src/index.js.map +1 -1
- package/dist/src/loader.d.ts +0 -29
- package/dist/src/loader.js +0 -66
- package/dist/src/loader.js.map +1 -1
- package/dist/src/profile.js +0 -91
- package/dist/src/profile.js.map +1 -1
- package/dist/src/secrets.d.ts +5 -0
- package/dist/src/secrets.js +106 -32
- package/dist/src/secrets.js.map +1 -1
- package/dist/src/shape.d.ts +0 -22
- package/dist/src/shape.js +0 -113
- package/dist/src/shape.js.map +1 -1
- package/package.json +3 -3
- package/src/Station.ts +28 -413
- package/src/adapter.ts +0 -57
- package/src/config-shape.ts +0 -11
- package/src/descriptor.ts +0 -38
- package/src/error.ts +0 -5
- package/src/factory.ts +0 -37
- package/src/feature.ts +0 -87
- package/src/index.ts +0 -7
- package/src/loader.ts +0 -66
- package/src/profile.ts +0 -95
- package/src/secrets.ts +104 -32
- package/src/shape.ts +0 -113
- package/src/types.ts +0 -59
package/dist/src/feature.d.ts
CHANGED
|
@@ -1,78 +1,20 @@
|
|
|
1
|
-
/** Reserved on a feature entry: not options, and never passed through
|
|
2
|
-
* to the SDK's own option map. */
|
|
3
1
|
export declare const RESERVED_KEYS: string[];
|
|
4
|
-
/** The six sources, in §3.3's order extended by the profile level:
|
|
5
|
-
*
|
|
6
|
-
* 1 base.feature 4 overlay.feature
|
|
7
|
-
* 2 base.api[<api>].feature 5 overlay.api[<api>].feature
|
|
8
|
-
* 3 base.sdk[<ref>].feature 6 overlay.sdk[<ref>].feature
|
|
9
|
-
*
|
|
10
|
-
* PROFILE SPECIFICITY OUTRANKS BLOCK SPECIFICITY, and within a profile
|
|
11
|
-
* the narrower block wins — the same principle as §3.3, one level down.
|
|
12
|
-
*
|
|
13
|
-
* `feature` is the ONE key where §3.3's shallow-per-key rule is wrong:
|
|
14
|
-
* composition is the entire point, a fleet default plus a per-instance
|
|
15
|
-
* tweak. So it is a TWO-LEVEL merge — per feature name, then per option
|
|
16
|
-
* key — and no deeper. A map-valued option REPLACES wholesale, which is
|
|
17
|
-
* what `{"$MERGE": {"deep": 2}}` states and what a port defaulting to a
|
|
18
|
-
* deep merge would silently get wrong.
|
|
19
|
-
*
|
|
20
|
-
* Same defaults-after-merge rule as §3.3, one level down: an entry
|
|
21
|
-
* mentioned at one level with only a tuning key must NOT synthesize
|
|
22
|
-
* `active` and switch on a feature a broader level turned off. That is
|
|
23
|
-
* the §3.3 defect one level down, and it is why the caller passes RAW
|
|
24
|
-
* blocks here. */
|
|
25
2
|
export declare function mergefeatures(sources: any[]): {
|
|
26
3
|
[name: string]: any;
|
|
27
4
|
};
|
|
28
|
-
/** The six sources for one instance, in order. Assembled here rather
|
|
29
|
-
* than at the call site so the order lives in exactly one place. */
|
|
30
5
|
export declare function featuresources(base: any, overlay: any, api: string, ref: string): any[];
|
|
31
|
-
/** `test` substitutes the base transport, so it takes the innermost
|
|
32
|
-
* band; `station` sits immediately outside it, pinned; everything else
|
|
33
|
-
* is band 0, outside station.
|
|
34
|
-
*
|
|
35
|
-
* THE DEFAULT IS TODAY'S BEHAVIOUR EXPRESSED IN THE NEW MODEL rather
|
|
36
|
-
* than as a special case: a project that writes no `order` anywhere
|
|
37
|
-
* sees exactly today's nesting, and sdkgen's two `makeOptions` special
|
|
38
|
-
* cases become two band values rather than two branches. */
|
|
39
6
|
export declare const BAND_DEFAULT = 0;
|
|
40
7
|
export declare const BAND_STATION = 100;
|
|
41
8
|
export declare const BAND_TEST = 200;
|
|
42
|
-
/** Higher is further IN. */
|
|
43
9
|
export declare function defaultband(name: string): number;
|
|
44
10
|
export type Ordered = {
|
|
45
11
|
name: string;
|
|
46
12
|
band: number;
|
|
47
13
|
entry: any;
|
|
48
14
|
};
|
|
49
|
-
/** Resolve the activation order: constraints, then bands, then the
|
|
50
|
-
* feature's position in the merged map.
|
|
51
|
-
*
|
|
52
|
-
* `before`/`after` take a feature name or a list of them and are
|
|
53
|
-
* SATISFIED VACUOUSLY when the named feature is absent — `after: 'test'`
|
|
54
|
-
* loads fine in a project with no test feature, which is sdkgen's
|
|
55
|
-
* `__after__` behaviour kept rather than reinvented.
|
|
56
|
-
*
|
|
57
|
-
* Constraints beat bands; bands break ties no constraint decides;
|
|
58
|
-
* remaining ties break by declaration position, so the result is a
|
|
59
|
-
* stable topological sort with no alphabetical accident in it.
|
|
60
|
-
*
|
|
61
|
-
* Returns OUTERMOST FIRST, which is the array form the constructor
|
|
62
|
-
* takes and the direction plugin's chain composes in. */
|
|
63
15
|
export declare function resolveorder(merged: {
|
|
64
16
|
[name: string]: any;
|
|
65
17
|
}): Ordered[];
|
|
66
|
-
/** Station's own position is PINNED and not orderable (§8.4): an order
|
|
67
|
-
* that moves `station` away from immediately-outside-the-base is
|
|
68
|
-
* REJECTED, not honoured.
|
|
69
|
-
*
|
|
70
|
-
* The pin is `innermost`, and the spelling matters. A chain composes
|
|
71
|
-
* with the FIRST binding outermost, so a pin written in sort terms —
|
|
72
|
-
* "station first" — would place every other wrapper between the adapter
|
|
73
|
-
* and the base: the exact inversion of the invariant, and one that
|
|
74
|
-
* would leave station's wire-truth events observing the wrong boundary
|
|
75
|
-
* while still looking ordered. */
|
|
76
18
|
export declare function checkpin(ordered: Ordered[]): void;
|
|
77
19
|
export type FeatureFault = {
|
|
78
20
|
code: string;
|
|
@@ -80,23 +22,6 @@ export type FeatureFault = {
|
|
|
80
22
|
key?: string;
|
|
81
23
|
message: string;
|
|
82
24
|
};
|
|
83
|
-
/** Check a merged feature map against the SDK'S OWN DECLARATION.
|
|
84
|
-
*
|
|
85
|
-
* The schema arrives with the FACTORY rather than with a live client
|
|
86
|
-
* (§6.2), so this needs no construction and no network — which is what
|
|
87
|
-
* lets `check()` run it for every instance in CI.
|
|
88
|
-
*
|
|
89
|
-
* Derived from the descriptor, never hand-written, so it cannot drift:
|
|
90
|
-
* when a feature gains an option, the next regeneration teaches station
|
|
91
|
-
* about it with no station change.
|
|
92
|
-
*
|
|
93
|
-
* SCALARS AGREE BY CONSTRUCTION; COMPOUND OPTIONS ARE KIND-CHECKED, and
|
|
94
|
-
* that limit is real. An empty list default says nothing reliable about
|
|
95
|
-
* its element type and a nested map default says nothing about its
|
|
96
|
-
* value shapes, so `methods: [{}]` against a `['GET']` default is
|
|
97
|
-
* caught while `noProxy: []` accepts anything list-shaped. Closing that
|
|
98
|
-
* needs the feature model to declare an explicit option schema rather
|
|
99
|
-
* than only a default. */
|
|
100
25
|
export declare function checkfeatures(merged: {
|
|
101
26
|
[name: string]: any;
|
|
102
27
|
}, descriptor: any): FeatureFault[];
|
package/dist/src/feature.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* Feature management (design §8): the three-level merge, the
|
|
3
|
-
* constraint-and-band resolver, and the descriptor-derived checker.
|
|
4
|
-
*
|
|
5
|
-
* The resolver is written to voxgig/plugin's §7 semantics so plugin can
|
|
6
|
-
* extract it — this is one of the pieces the joint plan means by
|
|
7
|
-
* "station builds natively to plugin's semantics". Keeping the two
|
|
8
|
-
* spellings identical is what C4 holds station to. */
|
|
9
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
3
|
exports.BAND_TEST = exports.BAND_STATION = exports.BAND_DEFAULT = exports.RESERVED_KEYS = void 0;
|
|
11
4
|
exports.mergefeatures = mergefeatures;
|
|
@@ -19,30 +12,7 @@ const error_1 = require("./error");
|
|
|
19
12
|
// ---------------------------------------------------------------------
|
|
20
13
|
// §8.3 — the merge
|
|
21
14
|
// ---------------------------------------------------------------------
|
|
22
|
-
/** Reserved on a feature entry: not options, and never passed through
|
|
23
|
-
* to the SDK's own option map. */
|
|
24
15
|
exports.RESERVED_KEYS = ['active', 'order'];
|
|
25
|
-
/** The six sources, in §3.3's order extended by the profile level:
|
|
26
|
-
*
|
|
27
|
-
* 1 base.feature 4 overlay.feature
|
|
28
|
-
* 2 base.api[<api>].feature 5 overlay.api[<api>].feature
|
|
29
|
-
* 3 base.sdk[<ref>].feature 6 overlay.sdk[<ref>].feature
|
|
30
|
-
*
|
|
31
|
-
* PROFILE SPECIFICITY OUTRANKS BLOCK SPECIFICITY, and within a profile
|
|
32
|
-
* the narrower block wins — the same principle as §3.3, one level down.
|
|
33
|
-
*
|
|
34
|
-
* `feature` is the ONE key where §3.3's shallow-per-key rule is wrong:
|
|
35
|
-
* composition is the entire point, a fleet default plus a per-instance
|
|
36
|
-
* tweak. So it is a TWO-LEVEL merge — per feature name, then per option
|
|
37
|
-
* key — and no deeper. A map-valued option REPLACES wholesale, which is
|
|
38
|
-
* what `{"$MERGE": {"deep": 2}}` states and what a port defaulting to a
|
|
39
|
-
* deep merge would silently get wrong.
|
|
40
|
-
*
|
|
41
|
-
* Same defaults-after-merge rule as §3.3, one level down: an entry
|
|
42
|
-
* mentioned at one level with only a tuning key must NOT synthesize
|
|
43
|
-
* `active` and switch on a feature a broader level turned off. That is
|
|
44
|
-
* the §3.3 defect one level down, and it is why the caller passes RAW
|
|
45
|
-
* blocks here. */
|
|
46
16
|
function mergefeatures(sources) {
|
|
47
17
|
const out = {};
|
|
48
18
|
for (const src of sources) {
|
|
@@ -55,14 +25,11 @@ function mergefeatures(sources) {
|
|
|
55
25
|
out[name] = entry;
|
|
56
26
|
continue;
|
|
57
27
|
}
|
|
58
|
-
// Per option key, and NOT deeper.
|
|
59
28
|
out[name] = { ...(ismap(out[name]) ? out[name] : {}), ...entry };
|
|
60
29
|
}
|
|
61
30
|
}
|
|
62
31
|
return out;
|
|
63
32
|
}
|
|
64
|
-
/** The six sources for one instance, in order. Assembled here rather
|
|
65
|
-
* than at the call site so the order lives in exactly one place. */
|
|
66
33
|
function featuresources(base, overlay, api, ref) {
|
|
67
34
|
return [
|
|
68
35
|
base?.feature,
|
|
@@ -76,18 +43,9 @@ function featuresources(base, overlay, api, ref) {
|
|
|
76
43
|
// ---------------------------------------------------------------------
|
|
77
44
|
// §8.4 — activation and order
|
|
78
45
|
// ---------------------------------------------------------------------
|
|
79
|
-
/** `test` substitutes the base transport, so it takes the innermost
|
|
80
|
-
* band; `station` sits immediately outside it, pinned; everything else
|
|
81
|
-
* is band 0, outside station.
|
|
82
|
-
*
|
|
83
|
-
* THE DEFAULT IS TODAY'S BEHAVIOUR EXPRESSED IN THE NEW MODEL rather
|
|
84
|
-
* than as a special case: a project that writes no `order` anywhere
|
|
85
|
-
* sees exactly today's nesting, and sdkgen's two `makeOptions` special
|
|
86
|
-
* cases become two band values rather than two branches. */
|
|
87
46
|
exports.BAND_DEFAULT = 0;
|
|
88
47
|
exports.BAND_STATION = 100;
|
|
89
48
|
exports.BAND_TEST = 200;
|
|
90
|
-
/** Higher is further IN. */
|
|
91
49
|
function defaultband(name) {
|
|
92
50
|
if ('test' === name) {
|
|
93
51
|
return exports.BAND_TEST;
|
|
@@ -97,20 +55,6 @@ function defaultband(name) {
|
|
|
97
55
|
}
|
|
98
56
|
return exports.BAND_DEFAULT;
|
|
99
57
|
}
|
|
100
|
-
/** Resolve the activation order: constraints, then bands, then the
|
|
101
|
-
* feature's position in the merged map.
|
|
102
|
-
*
|
|
103
|
-
* `before`/`after` take a feature name or a list of them and are
|
|
104
|
-
* SATISFIED VACUOUSLY when the named feature is absent — `after: 'test'`
|
|
105
|
-
* loads fine in a project with no test feature, which is sdkgen's
|
|
106
|
-
* `__after__` behaviour kept rather than reinvented.
|
|
107
|
-
*
|
|
108
|
-
* Constraints beat bands; bands break ties no constraint decides;
|
|
109
|
-
* remaining ties break by declaration position, so the result is a
|
|
110
|
-
* stable topological sort with no alphabetical accident in it.
|
|
111
|
-
*
|
|
112
|
-
* Returns OUTERMOST FIRST, which is the array form the constructor
|
|
113
|
-
* takes and the direction plugin's chain composes in. */
|
|
114
58
|
function resolveorder(merged) {
|
|
115
59
|
const names = Object.keys(merged).filter((n) => active(merged[n]));
|
|
116
60
|
const pos = new Map();
|
|
@@ -121,7 +65,6 @@ function resolveorder(merged) {
|
|
|
121
65
|
const b = ismap(o) && 'number' === typeof o.band ? o.band : defaultband(n);
|
|
122
66
|
band.set(n, b);
|
|
123
67
|
}
|
|
124
|
-
// edges: from OUTER to INNER. `after: X` means "further in than X".
|
|
125
68
|
const inner = new Map();
|
|
126
69
|
for (const n of names) {
|
|
127
70
|
inner.set(n, new Set());
|
|
@@ -132,7 +75,6 @@ function resolveorder(merged) {
|
|
|
132
75
|
if (!ismap(o)) {
|
|
133
76
|
continue;
|
|
134
77
|
}
|
|
135
|
-
// Vacuous when absent: an unknown name is not an error here.
|
|
136
78
|
for (const other of listof(o.after)) {
|
|
137
79
|
if (inner.has(other)) {
|
|
138
80
|
inner.get(other).add(n);
|
|
@@ -181,24 +123,12 @@ function resolveorder(merged) {
|
|
|
181
123
|
}
|
|
182
124
|
return out;
|
|
183
125
|
}
|
|
184
|
-
/** A feature named in the config is one you are ASKING for, so an entry
|
|
185
|
-
* with no `active` is active. */
|
|
186
126
|
function active(entry) {
|
|
187
127
|
if (!ismap(entry)) {
|
|
188
128
|
return false !== entry;
|
|
189
129
|
}
|
|
190
130
|
return false !== entry.active;
|
|
191
131
|
}
|
|
192
|
-
/** Station's own position is PINNED and not orderable (§8.4): an order
|
|
193
|
-
* that moves `station` away from immediately-outside-the-base is
|
|
194
|
-
* REJECTED, not honoured.
|
|
195
|
-
*
|
|
196
|
-
* The pin is `innermost`, and the spelling matters. A chain composes
|
|
197
|
-
* with the FIRST binding outermost, so a pin written in sort terms —
|
|
198
|
-
* "station first" — would place every other wrapper between the adapter
|
|
199
|
-
* and the base: the exact inversion of the invariant, and one that
|
|
200
|
-
* would leave station's wire-truth events observing the wrong boundary
|
|
201
|
-
* while still looking ordered. */
|
|
202
132
|
function checkpin(ordered) {
|
|
203
133
|
const i = ordered.findIndex((o) => 'station' === o.name);
|
|
204
134
|
if (-1 === i) {
|
|
@@ -214,23 +144,6 @@ function checkpin(ordered) {
|
|
|
214
144
|
'orderable (§8.4)');
|
|
215
145
|
}
|
|
216
146
|
}
|
|
217
|
-
/** Check a merged feature map against the SDK'S OWN DECLARATION.
|
|
218
|
-
*
|
|
219
|
-
* The schema arrives with the FACTORY rather than with a live client
|
|
220
|
-
* (§6.2), so this needs no construction and no network — which is what
|
|
221
|
-
* lets `check()` run it for every instance in CI.
|
|
222
|
-
*
|
|
223
|
-
* Derived from the descriptor, never hand-written, so it cannot drift:
|
|
224
|
-
* when a feature gains an option, the next regeneration teaches station
|
|
225
|
-
* about it with no station change.
|
|
226
|
-
*
|
|
227
|
-
* SCALARS AGREE BY CONSTRUCTION; COMPOUND OPTIONS ARE KIND-CHECKED, and
|
|
228
|
-
* that limit is real. An empty list default says nothing reliable about
|
|
229
|
-
* its element type and a nested map default says nothing about its
|
|
230
|
-
* value shapes, so `methods: [{}]` against a `['GET']` default is
|
|
231
|
-
* caught while `noProxy: []` accepts anything list-shaped. Closing that
|
|
232
|
-
* needs the feature model to declare an explicit option schema rather
|
|
233
|
-
* than only a default. */
|
|
234
147
|
function checkfeatures(merged, descriptor) {
|
|
235
148
|
const faults = [];
|
|
236
149
|
const declared = descriptor?.features || [];
|
package/dist/src/feature.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.js","sourceRoot":"","sources":["../../src/feature.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"feature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AM;IACpB,IAAI,IAAI,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;QAAC,OAAO,MAAM,CAAA;IAAC,CAAC;IACpD,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QAAC,OAAO,MAAM,CAAA;IAAC,CAAC;IACvC,IAAI,QAAQ,KAAK,OAAO,CAAC,EAAE,CAAC;QAAC,OAAO,QAAQ,CAAA;IAAC,CAAC;IAC9C,IAAI,QAAQ,KAAK,OAAO,CAAC,EAAE,CAAC;QAAC,OAAO,KAAK,CAAA;IAAC,CAAC;IAC3C,OAAO,OAAO,CAAC,CAAA;AACjB,CAAC;AAED,SAAS,KAAK,CAAC,CAAM;IACnB,OAAO,IAAI,IAAI,CAAC,IAAI,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAChE,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// @voxgig/station - one control surface for outbound integrations.
|
|
3
|
-
//
|
|
4
|
-
// THE ONLY ENTRY. There was a second, `index.browser.ts`, selected by a
|
|
5
|
-
// `browser` condition: the same surface minus the file-loading half, so
|
|
6
|
-
// no `node:` builtin was reachable from it. Station is server-side only,
|
|
7
|
-
// so that entry, the `ConfigFileIO` seam it needed and the graph-walk
|
|
8
|
-
// test that guarded it are all gone.
|
|
9
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
3
|
exports.validateConfig = exports.normalizeConfig = exports.configShape = exports.PROFILE_DEFAULTS = exports.MERGE_SENSITIVE = exports.BLOCK_DEFAULTS = exports.selectProfile = exports.resolveProfile = exports.refapi = exports.loadConfig = exports.findConfigFile = exports.configScope = exports.placeholderFor = exports.secretnameDefault = exports.normalizeDescriptor = exports.envtoken = exports.canonicalSerialize = exports.StationError = exports.featureBinding = exports.adapterFeature = exports.loadSync = exports.loadAsync = exports.factoryFromModule = exports.checkPackage = exports.camelify = exports.DEFAULT_EXPORT = exports.resetFactories = exports.provided = exports.factoryFor = exports.provide = exports.instanceRef = exports.Station = void 0;
|
|
11
4
|
var Station_1 = require("./Station");
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,qCAAgD;AAAvC,kGAAA,OAAO,OAAA;AAAE,sGAAA,WAAW,OAAA;AAC7B,qCAAyE;AAAhE,kGAAA,OAAO,OAAA;AAAE,qGAAA,UAAU,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAAE,yGAAA,cAAc,OAAA;AAEtD,mCAEiB;AADf,wGAAA,cAAc,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,2GAAA,iBAAiB,OAAA;AAAE,mGAAA,SAAS,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAEhF,qCAA0D;AAAjD,yGAAA,cAAc,OAAA;AAAE,yGAAA,cAAc,OAAA;AAEvC,iCAAsC;AAA7B,qGAAA,YAAY,OAAA;AACrB,2CAKqB;AAJnB,gHAAA,kBAAkB,OAAA;AAClB,sGAAA,QAAQ,OAAA;AACR,iHAAA,mBAAmB,OAAA;AACnB,+GAAA,iBAAiB,OAAA;AAEnB,qCAA0C;AAAjC,yGAAA,cAAc,OAAA;AACvB,qCAGkB;AAFhB,sGAAA,WAAW,OAAA;AAAE,yGAAA,cAAc,OAAA;AAAE,qGAAA,UAAU,OAAA;AAAE,iGAAA,MAAM,OAAA;AAAE,yGAAA,cAAc,OAAA;AAC/D,wGAAA,aAAa,OAAA;AAGf,iCAGgB;AAFd,uGAAA,cAAc,OAAA;AAAE,wGAAA,eAAe,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AACjD,oGAAA,WAAW,OAAA;AAAE,wGAAA,eAAe,OAAA;AAAE,uGAAA,cAAc,OAAA"}
|
package/dist/src/loader.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { Factory } from './factory';
|
|
2
|
-
/** The fixed alias every generated package exports.
|
|
3
|
-
*
|
|
4
|
-
* `export` defaults to this rather than to a derived class name because
|
|
5
|
-
* it is the same identifier in every generated package, where
|
|
6
|
-
* `camelify(slug) + 'SDK'` is a rule that has to be recomputed and can
|
|
7
|
-
* be wrong. The derived name is the SECOND attempt and an explicit
|
|
8
|
-
* `export` the third. */
|
|
9
2
|
export declare const DEFAULT_EXPORT = "SDK";
|
|
10
|
-
/** `stripe-eu` -> `StripeEu`, for the second-attempt export name. */
|
|
11
3
|
export declare function camelify(slug: string): string;
|
|
12
4
|
/** Only MODULE NAMES, resolved by the host language's ordinary
|
|
13
5
|
* resolution from the application root. Never a filesystem path, never
|
|
@@ -15,31 +7,10 @@ export declare function camelify(slug: string): string;
|
|
|
15
7
|
* config file reaching outside the dependency graph it is allowed to
|
|
16
8
|
* name. */
|
|
17
9
|
export declare function checkPackage(api: string, pkg: string): string;
|
|
18
|
-
/** Build a `{construct, config}` pair from a module that self-registered
|
|
19
|
-
* nothing — the retrofit path for a package whose SDK predates the
|
|
20
|
-
* station feature. It is not descriptor-blind: a generated main module
|
|
21
|
-
* exports its constructor AND the `config` singleton beside it. */
|
|
22
10
|
export declare function factoryFromModule(api: string, mod: any, exportName?: string): Factory;
|
|
23
11
|
/** Synchronous load, for CommonJS. Returns true when the api has a
|
|
24
12
|
* factory afterwards — either because importing the package triggered
|
|
25
13
|
* self-registration, or because one was built from its exports. */
|
|
26
14
|
export declare function loadSync(api: string, pkg: string, exportName?: string): boolean;
|
|
27
|
-
/** The ESM preload behind `await station.load()`. Imports the package
|
|
28
|
-
* and fills the SAME table the synchronous path fills. */
|
|
29
|
-
/** A dynamic `import()` that SURVIVES THE COMMONJS EMIT.
|
|
30
|
-
*
|
|
31
|
-
* This package compiles with `module: "commonjs"`, and TypeScript
|
|
32
|
-
* rewrites a literal `import(pkg)` into a promise around `require(pkg)`
|
|
33
|
-
* — so `await station.load()` threw `ERR_REQUIRE_ESM` for exactly the
|
|
34
|
-
* ESM-only packages it exists to preload, leaving no working path to
|
|
35
|
-
* those SDKs at all. Verified against the emitted `dist/src/loader.js`,
|
|
36
|
-
* which read `mod = require(pkg)`.
|
|
37
|
-
*
|
|
38
|
-
* `new Function` is the seam the compiler does not look inside. It is
|
|
39
|
-
* deliberately the only one in this file, and it takes no caller input:
|
|
40
|
-
* `pkg` has already been through `checkPackage`, and the body is a
|
|
41
|
-
* constant. Changing the package to `module: "node16"` would fix it
|
|
42
|
-
* more cleanly and is a whole-package decision rather than a defect
|
|
43
|
-
* fix. */
|
|
44
15
|
export declare const nativeImport: (p: string) => Promise<any>;
|
|
45
16
|
export declare function loadAsync(api: string, pkg: string, exportName?: string): Promise<boolean>;
|
package/dist/src/loader.js
CHANGED
|
@@ -1,30 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* The loader (design §6.3), where the language allows it.
|
|
3
|
-
*
|
|
4
|
-
* In ts, js, py, rb, php, perl, lua, elixir and clojure a module can be
|
|
5
|
-
* imported by name at runtime, so `api.<slug>.package` closes the loop:
|
|
6
|
-
* station imports the package (which triggers self-registration, §6.2
|
|
7
|
-
* path 1) and then looks up the factory.
|
|
8
|
-
*
|
|
9
|
-
* `sdk()` IS SYNCHRONOUS, AND IN TS/JS THAT BOUNDS WHAT THE LOADER CAN
|
|
10
|
-
* IMPORT. A CommonJS package loads synchronously through `require`; an
|
|
11
|
-
* ESM-only package only loads through `import()`, which is a promise.
|
|
12
|
-
* Making `sdk()` async to cover that would put an `await` in front of
|
|
13
|
-
* every call site in every language for a cost only two of them pay.
|
|
14
|
-
* So the rule is explicit rather than discovered at runtime:
|
|
15
|
-
*
|
|
16
|
-
* - the synchronous loader handles CommonJS, which is every SDK sdkgen
|
|
17
|
-
* generates (the ts target is `"type": "commonjs"`);
|
|
18
|
-
* - ESM packages load through an explicit `await station.load()`
|
|
19
|
-
* preload, after which `sdk()` is synchronous again for everything —
|
|
20
|
-
* one `await` at startup rather than one per call site;
|
|
21
|
-
* - a package only `import()` can load, reached through `sdk()`
|
|
22
|
-
* without a preload, is `station_sdk_load` WITH THE REMEDY IN THE
|
|
23
|
-
* MESSAGE. Never a silent half-loaded client.
|
|
24
|
-
*
|
|
25
|
-
* THIS IS A CODE-LOADING SURFACE DRIVEN BY A CONFIG FILE, so it has
|
|
26
|
-
* rules, and they are enforced here rather than documented and hoped
|
|
27
|
-
* for. See `checkPackage` and the `repoScoped` argument. */
|
|
28
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
3
|
exports.nativeImport = exports.DEFAULT_EXPORT = void 0;
|
|
30
4
|
exports.camelify = camelify;
|
|
@@ -34,15 +8,7 @@ exports.loadSync = loadSync;
|
|
|
34
8
|
exports.loadAsync = loadAsync;
|
|
35
9
|
const error_1 = require("./error");
|
|
36
10
|
const factory_1 = require("./factory");
|
|
37
|
-
/** The fixed alias every generated package exports.
|
|
38
|
-
*
|
|
39
|
-
* `export` defaults to this rather than to a derived class name because
|
|
40
|
-
* it is the same identifier in every generated package, where
|
|
41
|
-
* `camelify(slug) + 'SDK'` is a rule that has to be recomputed and can
|
|
42
|
-
* be wrong. The derived name is the SECOND attempt and an explicit
|
|
43
|
-
* `export` the third. */
|
|
44
11
|
exports.DEFAULT_EXPORT = 'SDK';
|
|
45
|
-
/** `stripe-eu` -> `StripeEu`, for the second-attempt export name. */
|
|
46
12
|
function camelify(slug) {
|
|
47
13
|
return String(slug).split(/[^A-Za-z0-9]+/).filter((s) => '' !== s)
|
|
48
14
|
.map((s) => s[0].toUpperCase() + s.slice(1))
|
|
@@ -55,13 +21,6 @@ function camelify(slug) {
|
|
|
55
21
|
* name. */
|
|
56
22
|
function checkPackage(api, pkg) {
|
|
57
23
|
const p = String(pkg);
|
|
58
|
-
// A TRAVERSAL SEGMENT IS NOT A LEADING MARKER, and checking only the
|
|
59
|
-
// first character missed it: `pkg/../../escape` starts with neither
|
|
60
|
-
// `.` nor `/`, so it passed — and node resolves it through
|
|
61
|
-
// `node_modules/pkg/../../escape`, importing application-local code
|
|
62
|
-
// from outside the named dependency. The whole point of this function
|
|
63
|
-
// is that a configured package stays inside the dependency graph a
|
|
64
|
-
// reviewer can see.
|
|
65
24
|
const seg = p.split('/').some((x) => '.' === x || '..' === x);
|
|
66
25
|
const bad = '' === p ||
|
|
67
26
|
p.startsWith('.') ||
|
|
@@ -76,10 +35,6 @@ function checkPackage(api, pkg) {
|
|
|
76
35
|
}
|
|
77
36
|
return p;
|
|
78
37
|
}
|
|
79
|
-
/** Build a `{construct, config}` pair from a module that self-registered
|
|
80
|
-
* nothing — the retrofit path for a package whose SDK predates the
|
|
81
|
-
* station feature. It is not descriptor-blind: a generated main module
|
|
82
|
-
* exports its constructor AND the `config` singleton beside it. */
|
|
83
38
|
function factoryFromModule(api, mod, exportName) {
|
|
84
39
|
const tried = [];
|
|
85
40
|
const pick = (n) => {
|
|
@@ -121,8 +76,6 @@ function loadSync(api, pkg, exportName) {
|
|
|
121
76
|
mod = require(pkg);
|
|
122
77
|
}
|
|
123
78
|
catch (e) {
|
|
124
|
-
// ERR_REQUIRE_ESM is the case the preload exists for, and the
|
|
125
|
-
// message has to name the remedy rather than the symptom.
|
|
126
79
|
const code = String(e?.code || '');
|
|
127
80
|
if ('ERR_REQUIRE_ESM' === code) {
|
|
128
81
|
throw new error_1.StationError('station_sdk_load', 'api "' + api + '": package "' + pkg + '" is ESM-only and cannot be ' +
|
|
@@ -132,30 +85,12 @@ function loadSync(api, pkg, exportName) {
|
|
|
132
85
|
throw new error_1.StationError('station_sdk_load', 'api "' + api + '": package "' + pkg + '" could not be imported: ' +
|
|
133
86
|
String(e?.message || e));
|
|
134
87
|
}
|
|
135
|
-
// Path 1: the module self-registered while being imported.
|
|
136
88
|
if (null != (0, factory_1.factoryFor)(api)) {
|
|
137
89
|
return true;
|
|
138
90
|
}
|
|
139
91
|
(0, factory_1.provide)(api, factoryFromModule(api, mod, exportName));
|
|
140
92
|
return true;
|
|
141
93
|
}
|
|
142
|
-
/** The ESM preload behind `await station.load()`. Imports the package
|
|
143
|
-
* and fills the SAME table the synchronous path fills. */
|
|
144
|
-
/** A dynamic `import()` that SURVIVES THE COMMONJS EMIT.
|
|
145
|
-
*
|
|
146
|
-
* This package compiles with `module: "commonjs"`, and TypeScript
|
|
147
|
-
* rewrites a literal `import(pkg)` into a promise around `require(pkg)`
|
|
148
|
-
* — so `await station.load()` threw `ERR_REQUIRE_ESM` for exactly the
|
|
149
|
-
* ESM-only packages it exists to preload, leaving no working path to
|
|
150
|
-
* those SDKs at all. Verified against the emitted `dist/src/loader.js`,
|
|
151
|
-
* which read `mod = require(pkg)`.
|
|
152
|
-
*
|
|
153
|
-
* `new Function` is the seam the compiler does not look inside. It is
|
|
154
|
-
* deliberately the only one in this file, and it takes no caller input:
|
|
155
|
-
* `pkg` has already been through `checkPackage`, and the body is a
|
|
156
|
-
* constant. Changing the package to `module: "node16"` would fix it
|
|
157
|
-
* more cleanly and is a whole-package decision rather than a defect
|
|
158
|
-
* fix. */
|
|
159
94
|
exports.nativeImport = new Function('p', 'return import(p)');
|
|
160
95
|
async function loadAsync(api, pkg, exportName) {
|
|
161
96
|
checkPackage(api, pkg);
|
|
@@ -173,7 +108,6 @@ async function loadAsync(api, pkg, exportName) {
|
|
|
173
108
|
if (null != (0, factory_1.factoryFor)(api)) {
|
|
174
109
|
return true;
|
|
175
110
|
}
|
|
176
|
-
// An ESM namespace puts a CommonJS module's exports under `default`.
|
|
177
111
|
const flat = null != mod?.default && null == mod?.config ? mod.default : mod;
|
|
178
112
|
(0, factory_1.provide)(api, factoryFromModule(api, flat, exportName));
|
|
179
113
|
return true;
|
package/dist/src/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src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