@openlimiter/connectors 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/fixtures.d.ts +30 -0
- package/dist/fixtures.d.ts.map +1 -1
- package/dist/fixtures.js +34 -4
- package/dist/fixtures.js.map +1 -1
- package/dist/openrouter.d.ts.map +1 -1
- package/dist/openrouter.js +9 -1
- package/dist/openrouter.js.map +1 -1
- package/dist/shared.d.ts +9 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +2 -1
- package/dist/shared.js.map +1 -1
- package/package.json +2 -2
package/dist/fixtures.d.ts
CHANGED
|
@@ -8,9 +8,39 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const FIXTURE_NOW = "2026-01-01T00:00:00.000Z";
|
|
10
10
|
export declare function claudeFixture(now?: string): Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* A credit plan with real money in it, so the dollar line has something to say.
|
|
13
|
+
*
|
|
14
|
+
* Twelve dollars and change out of twenty is 62.35 percent, which also puts the
|
|
15
|
+
* one credit based provider in the middle pressure band. Both numbers are
|
|
16
|
+
* invented for this file and belong to no account.
|
|
17
|
+
*/
|
|
11
18
|
export declare function openrouterFixture(): Record<string, unknown>;
|
|
19
|
+
/**
|
|
20
|
+
* The one fixture in the orange band.
|
|
21
|
+
*
|
|
22
|
+
* Eighty four percent is deliberate, the same way ninety two is below. The
|
|
23
|
+
* meter colour scale has four bands and a demo that never reaches one of them
|
|
24
|
+
* cannot teach it, so this fixture sits between the engine's NEAR_CAP threshold
|
|
25
|
+
* at 80 and the visual red at 90, which is the band that exists to show the gap
|
|
26
|
+
* between the two.
|
|
27
|
+
*
|
|
28
|
+
* Eighty four also keeps the demo's routing advice where it was. The policy
|
|
29
|
+
* stops recommending a provider at 80, so Codex drops out of the running here,
|
|
30
|
+
* and the lowest reading still under that line is Antigravity at 28. The demo
|
|
31
|
+
* therefore still says PREFER ANTIGRAVITY, exactly as it did when this fixture
|
|
32
|
+
* read 51.
|
|
33
|
+
*/
|
|
12
34
|
export declare function codexFixture(now?: string): Record<string, unknown>;
|
|
13
35
|
export declare function antigravityFixture(now?: string): Record<string, unknown>;
|
|
36
|
+
/**
|
|
37
|
+
* The one fixture in the red band.
|
|
38
|
+
*
|
|
39
|
+
* Ninety two percent is deliberate. A demo where nothing is ever in trouble
|
|
40
|
+
* teaches nobody what trouble looks like, so one provider sits above the
|
|
41
|
+
* critical threshold and every surface has to draw it. With Codex at 84 above,
|
|
42
|
+
* the demo set now lands one meter in each of the four bands.
|
|
43
|
+
*/
|
|
14
44
|
export declare function opencodeFixture(now?: string): Record<string, unknown>;
|
|
15
45
|
export declare function manualFixture(now?: string): Record<string, unknown>;
|
|
16
46
|
export declare const hostileFixture: {
|
package/dist/fixtures.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../src/fixtures.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,WAAW,6BAA6B,CAAC;AAatD,wBAAgB,aAAa,CAAC,GAAG,GAAE,MAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAahF;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAO3D;AAED,wBAAgB,YAAY,CAAC,GAAG,GAAE,MAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAS/E;AAED,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,MAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOrF;AAED,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQlF;AAED,wBAAgB,aAAa,CAAC,GAAG,GAAE,MAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAShF;AAED,eAAO,MAAM,cAAc;;;;CAIjB,CAAC"}
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../src/fixtures.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,WAAW,6BAA6B,CAAC;AAatD,wBAAgB,aAAa,CAAC,GAAG,GAAE,MAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAahF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAO3D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,GAAG,GAAE,MAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAS/E;AAED,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,MAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOrF;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQlF;AAED,wBAAgB,aAAa,CAAC,GAAG,GAAE,MAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAShF;AAED,eAAO,MAAM,cAAc;;;;CAIjB,CAAC"}
|
package/dist/fixtures.js
CHANGED
|
@@ -30,19 +30,41 @@ export function claudeFixture(now = FIXTURE_NOW) {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* A credit plan with real money in it, so the dollar line has something to say.
|
|
35
|
+
*
|
|
36
|
+
* Twelve dollars and change out of twenty is 62.35 percent, which also puts the
|
|
37
|
+
* one credit based provider in the middle pressure band. Both numbers are
|
|
38
|
+
* invented for this file and belong to no account.
|
|
39
|
+
*/
|
|
33
40
|
export function openrouterFixture() {
|
|
34
41
|
return {
|
|
35
42
|
data: {
|
|
36
|
-
total_credits:
|
|
37
|
-
total_usage:
|
|
43
|
+
total_credits: 20,
|
|
44
|
+
total_usage: 12.47
|
|
38
45
|
}
|
|
39
46
|
};
|
|
40
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* The one fixture in the orange band.
|
|
50
|
+
*
|
|
51
|
+
* Eighty four percent is deliberate, the same way ninety two is below. The
|
|
52
|
+
* meter colour scale has four bands and a demo that never reaches one of them
|
|
53
|
+
* cannot teach it, so this fixture sits between the engine's NEAR_CAP threshold
|
|
54
|
+
* at 80 and the visual red at 90, which is the band that exists to show the gap
|
|
55
|
+
* between the two.
|
|
56
|
+
*
|
|
57
|
+
* Eighty four also keeps the demo's routing advice where it was. The policy
|
|
58
|
+
* stops recommending a provider at 80, so Codex drops out of the running here,
|
|
59
|
+
* and the lowest reading still under that line is Antigravity at 28. The demo
|
|
60
|
+
* therefore still says PREFER ANTIGRAVITY, exactly as it did when this fixture
|
|
61
|
+
* read 51.
|
|
62
|
+
*/
|
|
41
63
|
export function codexFixture(now = FIXTURE_NOW) {
|
|
42
64
|
return {
|
|
43
65
|
rate_limits: {
|
|
44
66
|
primary_window: {
|
|
45
|
-
used_percent:
|
|
67
|
+
used_percent: 84,
|
|
46
68
|
reset_at: offset(now, FIVE_HOURS)
|
|
47
69
|
}
|
|
48
70
|
}
|
|
@@ -56,10 +78,18 @@ export function antigravityFixture(now = FIXTURE_NOW) {
|
|
|
56
78
|
}
|
|
57
79
|
};
|
|
58
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* The one fixture in the red band.
|
|
83
|
+
*
|
|
84
|
+
* Ninety two percent is deliberate. A demo where nothing is ever in trouble
|
|
85
|
+
* teaches nobody what trouble looks like, so one provider sits above the
|
|
86
|
+
* critical threshold and every surface has to draw it. With Codex at 84 above,
|
|
87
|
+
* the demo set now lands one meter in each of the four bands.
|
|
88
|
+
*/
|
|
59
89
|
export function opencodeFixture(now = FIXTURE_NOW) {
|
|
60
90
|
return {
|
|
61
91
|
usage: {
|
|
62
|
-
percent:
|
|
92
|
+
percent: 92,
|
|
63
93
|
reset_at: offset(now, ONE_DAY),
|
|
64
94
|
account_label: "demo@example.test"
|
|
65
95
|
}
|
package/dist/fixtures.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../src/fixtures.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAEtD,MAAM,UAAU,GAAG,MAAM,CAAC;AAC1B,MAAM,OAAO,GAAG,MAAM,CAAC;AACvB,MAAM,UAAU,GAAG,OAAO,CAAC;AAC3B,MAAM,eAAe,GAAG,SAAS,CAAC;AAElC,SAAS,MAAM,CAAC,GAAW,EAAE,OAAe;IAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACtE,OAAO,IAAI,IAAI,CAAC,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAc,WAAW;IACrD,OAAO;QACL,WAAW,EAAE;YACX,SAAS,EAAE;gBACT,WAAW,EAAE,EAAE;gBACf,SAAS,EAAE,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC;aACnC;YACD,SAAS,EAAE;gBACT,WAAW,EAAE,EAAE;gBACf,SAAS,EAAE,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC;aACnC;SACF;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,IAAI,EAAE;YACJ,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../src/fixtures.ts"],"names":[],"m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ACF;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAc,WAAW;IAC1D,OAAO;QACL,KAAK,EAAE;YACL,YAAY,EAAE,EAAE;YAChB,QAAQ,EAAE,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC;SAC/B;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc,WAAW;IACvD,OAAO;QACL,KAAK,EAAE;YACL,OAAO,EAAE,EAAE;YACX,QAAQ,EAAE,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC;YAC9B,aAAa,EAAE,mBAAmB;SACnC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAc,WAAW;IACrD,OAAO;QACL,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,CAAC;gBACP,IAAI,EAAE,SAAS;gBACf,YAAY,EAAE,EAAE;gBAChB,QAAQ,EAAE,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC;aACvC,CAAC;KACH,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,iDAAiD;IAC1D,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC;CACd,CAAC"}
|
package/dist/openrouter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openrouter.d.ts","sourceRoot":"","sources":["../src/openrouter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAGjB,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAG3B,eAAO,MAAM,gBAAgB;;;;;CAKO,CAAC;AAErC,eAAO,MAAM,oBAAoB;;;;;;CAMvB,CAAC;AAEX,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,EAAE,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"openrouter.d.ts","sourceRoot":"","sources":["../src/openrouter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAGjB,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAG3B,eAAO,MAAM,gBAAgB;;;;;CAKO,CAAC;AAErC,eAAO,MAAM,oBAAoB;;;;;;CAMvB,CAAC;AAEX,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,EAAE,GAAG,IAAI,CAmCvF;AAED,eAAO,MAAM,mBAAmB,EAAE,iBAajC,CAAC"}
|
package/dist/openrouter.js
CHANGED
|
@@ -27,6 +27,13 @@ export function parseOpenrouterPayload(payload, now) {
|
|
|
27
27
|
const percent = (usage / credits) * 100;
|
|
28
28
|
if (!Number.isFinite(percent) || percent < 0 || percent > 100)
|
|
29
29
|
return null;
|
|
30
|
+
/*
|
|
31
|
+
* OpenRouter is the one provider whose documented shape states money rather
|
|
32
|
+
* than a percentage: total_credits is what the plan holds and total_usage is
|
|
33
|
+
* what has been spent out of it. Both are handed on as they were read. The
|
|
34
|
+
* normalizer decides whether they are believable and drops all three fields
|
|
35
|
+
* together if they are not, which leaves the percentage above intact.
|
|
36
|
+
*/
|
|
30
37
|
return [rawMeter({
|
|
31
38
|
provider: "OPENROUTER",
|
|
32
39
|
meter: "CREDITS",
|
|
@@ -37,7 +44,8 @@ export function parseOpenrouterPayload(payload, now) {
|
|
|
37
44
|
precision: "exact",
|
|
38
45
|
observedAt: now,
|
|
39
46
|
expiresAt,
|
|
40
|
-
labels: openrouterLabels
|
|
47
|
+
labels: openrouterLabels,
|
|
48
|
+
amounts: { usedAmount: usage, limitAmount: credits, currency: "USD" }
|
|
41
49
|
})];
|
|
42
50
|
}
|
|
43
51
|
export const openrouterConnector = {
|
package/dist/openrouter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openrouter.js","sourceRoot":"","sources":["../src/openrouter.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C3B,CAAC;CACF,CAAC"}
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConnectorLabels, ProviderCode, RawMeter, SnapshotPrecision, SnapshotSource, SnapshotWindow } from "@openlimiter/core";
|
|
1
|
+
import type { ConnectorLabels, ProviderCode, RawMeter, SnapshotAmounts, SnapshotPrecision, SnapshotSource, SnapshotWindow } from "@openlimiter/core";
|
|
2
2
|
export declare function record(value: unknown): Record<string, unknown> | null;
|
|
3
3
|
export declare function boundedNumber(value: unknown, maximum?: number): number | null;
|
|
4
4
|
export declare function futureInstant(value: unknown, now: string): string | null;
|
|
@@ -14,5 +14,13 @@ export declare function rawMeter(input: {
|
|
|
14
14
|
observedAt: string;
|
|
15
15
|
expiresAt: string;
|
|
16
16
|
labels: ConnectorLabels;
|
|
17
|
+
/**
|
|
18
|
+
* Money, when the provider's own documented payload states it.
|
|
19
|
+
*
|
|
20
|
+
* Passed through untouched. The normalizer is the only thing that decides
|
|
21
|
+
* whether these are believable, and it drops all three together or keeps all
|
|
22
|
+
* three together, so a connector never has to reason about the pair.
|
|
23
|
+
*/
|
|
24
|
+
amounts?: SnapshotAmounts;
|
|
17
25
|
}): RawMeter;
|
|
18
26
|
//# sourceMappingURL=shared.d.ts.map
|
package/dist/shared.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAIrE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,SAAM,GAAG,MAAM,GAAG,IAAI,CAO1E;AAED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,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,eAAe,CAAC;IACxB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B,GAAG,QAAQ,CAGX"}
|
package/dist/shared.js
CHANGED
|
@@ -25,6 +25,7 @@ export function shortExpiry(now) {
|
|
|
25
25
|
return Number.isFinite(parsed) ? new Date(parsed + 60_000).toISOString() : null;
|
|
26
26
|
}
|
|
27
27
|
export function rawMeter(input) {
|
|
28
|
-
|
|
28
|
+
const { amounts, ...rest } = input;
|
|
29
|
+
return { ...rest, unit: "PERCENT", ...(amounts === undefined ? {} : amounts) };
|
|
29
30
|
}
|
|
30
31
|
//# sourceMappingURL=shared.js.map
|
package/dist/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzE,CAAC,CAAC,KAAgC;QAClC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAc,EAAE,OAAO,GAAG,GAAG;IACzD,OAAO,OAAO,KAAK,KAAK,QAAQ;QAC9B,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QACtB,KAAK,IAAI,CAAC;QACV,KAAK,IAAI,OAAO;QAChB,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAc,EAAE,GAAW;IACvD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,MAAM,GAAG,OAAO;QAC5E,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE;QAChC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAmBxB;IACC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACnC,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;AACjF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openlimiter/connectors",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Provider connectors that collect quota and usage data for OpenLimiter.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"NOTICE"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@openlimiter/core": "0.
|
|
22
|
+
"@openlimiter/core": "0.2.0"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|