@nehorai/credits 1.0.1 → 1.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/adapters/generic.d.ts +1 -1
- package/dist/adapters/generic.d.ts.map +1 -1
- package/dist/adapters/generic.js +10 -6
- package/dist/adapters/generic.js.map +1 -1
- package/dist/adapters/index.d.ts +2 -2
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +1 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/types.d.ts +4 -4
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/auth/api-key.d.ts +1 -1
- package/dist/auth/api-key.d.ts.map +1 -1
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/config/costs.d.ts +15 -20
- package/dist/config/costs.d.ts.map +1 -1
- package/dist/config/costs.js +17 -32
- package/dist/config/costs.js.map +1 -1
- package/dist/config/index.d.ts +27 -8
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +63 -7
- package/dist/config/index.js.map +1 -1
- package/dist/config/provider.d.ts +12 -0
- package/dist/config/provider.d.ts.map +1 -0
- package/dist/config/provider.js +14 -0
- package/dist/config/provider.js.map +1 -0
- package/dist/core/index.d.ts +7 -7
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +4 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/operations.d.ts +2 -2
- package/dist/core/operations.d.ts.map +1 -1
- package/dist/core/operations.js +3 -2
- package/dist/core/operations.js.map +1 -1
- package/dist/core/types.d.ts +0 -11
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +0 -11
- package/dist/core/types.js.map +1 -1
- package/dist/index.d.ts +18 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -14
- package/dist/index.js.map +1 -1
- package/dist/notifications/index.d.ts +1 -1
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +3 -11
- package/dist/notifications/index.js.map +1 -1
- package/dist/repository/index.d.ts +4 -4
- package/dist/repository/index.d.ts.map +1 -1
- package/dist/repository/index.js +3 -3
- package/dist/repository/index.js.map +1 -1
- package/dist/repository/memory/index.d.ts +2 -2
- package/dist/repository/memory/index.d.ts.map +1 -1
- package/dist/repository/memory/index.js +2 -2
- package/dist/repository/memory/index.js.map +1 -1
- package/dist/repository/types.d.ts +1 -1
- package/dist/repository/types.d.ts.map +1 -1
- package/dist/sdk/admin-client.d.ts +1 -1
- package/dist/sdk/admin-client.d.ts.map +1 -1
- package/dist/sdk/admin-client.js +1 -1
- package/dist/sdk/admin-client.js.map +1 -1
- package/dist/sdk/client.d.ts +1 -1
- package/dist/sdk/client.d.ts.map +1 -1
- package/dist/sdk/client.js +1 -1
- package/dist/sdk/client.js.map +1 -1
- package/dist/sdk/errors.d.ts +1 -1
- package/dist/sdk/errors.d.ts.map +1 -1
- package/dist/sdk/errors.js +1 -1
- package/dist/sdk/errors.js.map +1 -1
- package/dist/sdk/index.d.ts +6 -6
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +4 -4
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/types.d.ts +1 -1
- package/dist/sdk/types.d.ts.map +1 -1
- package/dist/service/credits-service.d.ts +2 -2
- package/dist/service/credits-service.d.ts.map +1 -1
- package/dist/service/credits-service.js +9 -13
- package/dist/service/credits-service.js.map +1 -1
- package/dist/service/index.d.ts +2 -2
- package/dist/service/index.d.ts.map +1 -1
- package/dist/service/index.js +1 -1
- package/dist/service/index.js.map +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +10 -11
- package/LICENSE +0 -21
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This adapter uses standard JavaScript APIs and works in any
|
|
5
5
|
* JavaScript environment (Node.js, browser, etc.).
|
|
6
6
|
*/
|
|
7
|
-
import type { CreditsAdapter, CreditsAdapterConfig } from "./types";
|
|
7
|
+
import type { CreditsAdapter, CreditsAdapterConfig } from "./types.js";
|
|
8
8
|
/**
|
|
9
9
|
* Create a generic credits adapter
|
|
10
10
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../src/adapters/generic.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAgB,cAAc,EAAE,oBAAoB,EAAuB,MAAM,
|
|
1
|
+
{"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../src/adapters/generic.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAgB,cAAc,EAAE,oBAAoB,EAAuB,MAAM,YAAY,CAAC;AAgB1G;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,cAAc,CAqIjF"}
|
package/dist/adapters/generic.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This adapter uses standard JavaScript APIs and works in any
|
|
5
5
|
* JavaScript environment (Node.js, browser, etc.).
|
|
6
6
|
*/
|
|
7
|
-
import { commitReservationWithJournal, releaseReservationWithJournal, reserveCreditsForOperation, } from "../core/operations";
|
|
7
|
+
import { commitReservationWithJournal, releaseReservationWithJournal, reserveCreditsForOperation, } from "../core/operations.js";
|
|
8
8
|
/**
|
|
9
9
|
* Generate a unique request ID
|
|
10
10
|
*/
|
|
@@ -25,7 +25,12 @@ function generateRequestId() {
|
|
|
25
25
|
export function createGenericAdapter(config) {
|
|
26
26
|
const { repository, authProvider, deferred, operationCosts } = config;
|
|
27
27
|
function getOperationCost(operationType) {
|
|
28
|
-
|
|
28
|
+
const cost = operationCosts[operationType];
|
|
29
|
+
if (cost === undefined) {
|
|
30
|
+
throw new Error(`Unknown operation type: "${operationType}". ` +
|
|
31
|
+
`Configured types: ${Object.keys(operationCosts).join(", ")}`);
|
|
32
|
+
}
|
|
33
|
+
return cost;
|
|
29
34
|
}
|
|
30
35
|
function logUsage(params) {
|
|
31
36
|
deferred.defer(async () => {
|
|
@@ -56,11 +61,10 @@ export function createGenericAdapter(config) {
|
|
|
56
61
|
const dummyReservation = createDummyReservation(user.id, options.operationType);
|
|
57
62
|
return handler(user, data, dummyReservation);
|
|
58
63
|
}
|
|
59
|
-
// Calculate cost
|
|
60
|
-
const cost = options.customCost ?? getOperationCost(options.operationType);
|
|
61
|
-
// Reserve credits
|
|
64
|
+
// Calculate cost and reserve credits
|
|
62
65
|
let reservation;
|
|
63
66
|
try {
|
|
67
|
+
const cost = options.customCost ?? getOperationCost(options.operationType);
|
|
64
68
|
reservation = await reserveCreditsForOperation(repository, user.id, cost, options.operationType);
|
|
65
69
|
}
|
|
66
70
|
catch (error) {
|
|
@@ -85,7 +89,7 @@ export function createGenericAdapter(config) {
|
|
|
85
89
|
logUsage({
|
|
86
90
|
userId: user.id,
|
|
87
91
|
operationType: options.operationType,
|
|
88
|
-
creditsUsed:
|
|
92
|
+
creditsUsed: reservation.amount,
|
|
89
93
|
success: true,
|
|
90
94
|
resourceId: options.resourceId,
|
|
91
95
|
resourceType: options.resourceType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../../src/adapters/generic.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,
|
|
1
|
+
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../../src/adapters/generic.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,SAAS,iBAAiB;IACxB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE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AAU,EAAE,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;oBACzE,QAAQ,CAAC;wBACP,MAAM,EAAE,IAAI,CAAC,EAAE;wBACf,aAAa,EAAE,OAAO,CAAC,aAAa;wBACpC,WAAW,EAAE,CAAC;wBACd,OAAO,EAAE,KAAK;wBACd,YAAY,EAAE,OAAO;wBACrB,UAAU,EAAE,OAAO,CAAC,UAAU;wBAC9B,YAAY,EAAE,OAAO,CAAC,YAAY;wBAClC,SAAS;qBACV,CAAC,CAAC;oBACH,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;oBACtC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;gBAC5C,CAAC;YACH,CAAC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,IAAa;IAClC,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,SAAS,IAAI,IAAI;QAChB,IAAgC,CAAC,OAAO,KAAK,IAAI,CACnD,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB,CAAC,MAAc,EAAE,aAAqB;IACnE,OAAO;QACL,EAAE,EAAE,cAAc;QAClB,MAAM;QACN,MAAM,EAAE,CAAC;QACT,aAAa;QACb,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC;AACJ,CAAC"}
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { ActionResult, CreditActionHandler, CreditsAdapterConfig, CreditsAdapter, } from "./types";
|
|
2
|
-
export { createGenericAdapter } from "./generic";
|
|
1
|
+
export type { ActionResult, CreditActionHandler, CreditsAdapterConfig, CreditsAdapter, } from "./types.js";
|
|
2
|
+
export { createGenericAdapter } from "./generic.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,GACf,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/adapters/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createGenericAdapter } from "./generic";
|
|
1
|
+
export { createGenericAdapter } from "./generic.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/adapters/types.d.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Defines the interface for framework-specific adapters that wrap
|
|
5
5
|
* credit operations with different execution strategies.
|
|
6
6
|
*/
|
|
7
|
-
import type { PortableReservation, WithCreditsOptions } from "../core/types";
|
|
8
|
-
import type { CreditsUser, ICreditsAuthProvider } from "../auth/types";
|
|
9
|
-
import type { ICreditRepository } from "../repository/types";
|
|
10
|
-
import type { DeferredExecutor } from "../core";
|
|
7
|
+
import type { PortableReservation, WithCreditsOptions } from "../core/types.js";
|
|
8
|
+
import type { CreditsUser, ICreditsAuthProvider } from "../auth/types.js";
|
|
9
|
+
import type { ICreditRepository } from "../repository/types.js";
|
|
10
|
+
import type { DeferredExecutor } from "../core/index.js";
|
|
11
11
|
/**
|
|
12
12
|
* Generic action result type
|
|
13
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/adapters/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/adapters/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,MAAM,EAAE,OAAO,IAAI,CACjD,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,mBAAmB,KAC7B,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,uCAAuC;IACvC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,4CAA4C;IAC5C,YAAY,EAAE,oBAAoB,CAAC;IACnC,6CAA6C;IAC7C,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,kCAAkC;IAClC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,WAAW,CAAC,MAAM,EAAE,OAAO,EACzB,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5C,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;CACrD"}
|
package/dist/auth/api-key.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../src/auth/api-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../src/auth/api-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAwBpE;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAUhF;AAED;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,oBAAoB;IAChE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,WAAW,CAAS;gBAEhB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM;IASjD,cAAc,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAa7C,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;CAG5C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAarF;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,qBAAqB,CAG7F"}
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides authentication abstraction for credits system
|
|
5
5
|
*/
|
|
6
|
-
export type { ICreditsAuthProvider, CreditsAuthProviderFactory, CreditsUser, } from "./types";
|
|
7
|
-
export { ApiKeyCreditsProvider, verifyAdminApiKey, createApiKeyProvider, verifyBearerToken, } from "./api-key";
|
|
6
|
+
export type { ICreditsAuthProvider, CreditsAuthProviderFactory, CreditsUser, } from "./types.js";
|
|
7
|
+
export { ApiKeyCreditsProvider, verifyAdminApiKey, createApiKeyProvider, verifyBearerToken, } from "./api-key.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/auth/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,WAAW,GACZ,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,WAAW,GACZ,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,cAAc,CAAC"}
|
package/dist/auth/index.js
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* Provides authentication abstraction for credits system
|
|
5
5
|
*/
|
|
6
6
|
// API Key implementation (for admin routes)
|
|
7
|
-
export { ApiKeyCreditsProvider, verifyAdminApiKey, createApiKeyProvider, verifyBearerToken, } from "./api-key";
|
|
7
|
+
export { ApiKeyCreditsProvider, verifyAdminApiKey, createApiKeyProvider, verifyBearerToken, } from "./api-key.js";
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/auth/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,4CAA4C;AAC5C,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,4CAA4C;AAC5C,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,cAAc,CAAC"}
|
package/dist/config/costs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SubscriptionTier, TierConfig } from "../core/types";
|
|
2
|
-
import { getValidOperationTypes, isValidOperationType } from "./index";
|
|
1
|
+
import type { SubscriptionTier, TierConfig } from "../core/types.js";
|
|
2
|
+
import { getValidOperationTypes, isValidOperationType } from "./index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Get operation costs as a record
|
|
5
5
|
* Returns all configured operation costs from the current config
|
|
@@ -15,14 +15,6 @@ export declare function getOperationCosts(): Record<string, number>;
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function getOperationCost(type: string): number;
|
|
17
17
|
export { getValidOperationTypes, isValidOperationType };
|
|
18
|
-
/**
|
|
19
|
-
* Tier configurations with monthly limits and pricing
|
|
20
|
-
*
|
|
21
|
-
* NOTE: This is kept for backward compatibility.
|
|
22
|
-
* The actual configs are loaded from configuration.
|
|
23
|
-
* Use getTierConfig() instead of accessing this directly.
|
|
24
|
-
*/
|
|
25
|
-
export declare const TIER_CONFIGS: Record<SubscriptionTier, TierConfig>;
|
|
26
18
|
/**
|
|
27
19
|
* Get tier configuration
|
|
28
20
|
* Uses the configuration system for dynamic configs
|
|
@@ -40,22 +32,25 @@ export declare function getTierConfig(tier: SubscriptionTier): TierConfig;
|
|
|
40
32
|
* @returns Monthly credit limit
|
|
41
33
|
*/
|
|
42
34
|
export declare function getMonthlyLimit(tier: SubscriptionTier): number;
|
|
43
|
-
/**
|
|
44
|
-
* Default credits for new users (free tier)
|
|
45
|
-
* Uses the configuration system
|
|
46
|
-
*/
|
|
47
|
-
export declare const DEFAULT_FREE_CREDITS = 25;
|
|
48
35
|
/**
|
|
49
36
|
* Get default free credits from configuration
|
|
50
37
|
*/
|
|
51
38
|
export declare function getDefaultFreeCredits(): number;
|
|
52
|
-
/**
|
|
53
|
-
* Reservation expiry time in milliseconds
|
|
54
|
-
* Uses the configuration system
|
|
55
|
-
*/
|
|
56
|
-
export declare const RESERVATION_EXPIRY_MS: number;
|
|
57
39
|
/**
|
|
58
40
|
* Get reservation expiry time from configuration
|
|
59
41
|
*/
|
|
60
42
|
export declare function getReservationExpiryMs(): number;
|
|
43
|
+
/**
|
|
44
|
+
* Information about an operation's cost and display label
|
|
45
|
+
*/
|
|
46
|
+
export interface OperationCostInfo {
|
|
47
|
+
key: string;
|
|
48
|
+
cost: number;
|
|
49
|
+
label: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get all operation costs with their display labels.
|
|
53
|
+
* Returns a record keyed by operation type with cost + label.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getOperationCostsWithLabels(): Record<string, OperationCostInfo>;
|
|
61
56
|
//# sourceMappingURL=costs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"costs.d.ts","sourceRoot":"","sources":["../../src/config/costs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"costs.d.ts","sourceRoot":"","sources":["../../src/config/costs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAKL,sBAAsB,EACtB,oBAAoB,EAErB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE1D;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAGD,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,gBAAgB,GAAG,UAAU,CAEhE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAE9D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAW/E"}
|
package/dist/config/costs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getConfig, getConfigOperationCost, getConfigTierConfig, getConfigMonthlyLimit, getValidOperationTypes, isValidOperationType, } from "./index";
|
|
1
|
+
import { getConfig, getConfigOperationCost, getConfigTierConfig, getConfigMonthlyLimit, getValidOperationTypes, isValidOperationType, getOperationLabel, } from "./index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Get operation costs as a record
|
|
4
4
|
* Returns all configured operation costs from the current config
|
|
@@ -19,27 +19,6 @@ export function getOperationCost(type) {
|
|
|
19
19
|
}
|
|
20
20
|
// Re-export validation helpers for convenience
|
|
21
21
|
export { getValidOperationTypes, isValidOperationType };
|
|
22
|
-
/**
|
|
23
|
-
* Tier configurations with monthly limits and pricing
|
|
24
|
-
*
|
|
25
|
-
* NOTE: This is kept for backward compatibility.
|
|
26
|
-
* The actual configs are loaded from configuration.
|
|
27
|
-
* Use getTierConfig() instead of accessing this directly.
|
|
28
|
-
*/
|
|
29
|
-
export const TIER_CONFIGS = {
|
|
30
|
-
get free() {
|
|
31
|
-
return getConfig().tierConfigs.free;
|
|
32
|
-
},
|
|
33
|
-
get basic() {
|
|
34
|
-
return getConfig().tierConfigs.basic;
|
|
35
|
-
},
|
|
36
|
-
get premium() {
|
|
37
|
-
return getConfig().tierConfigs.premium;
|
|
38
|
-
},
|
|
39
|
-
get unlimited() {
|
|
40
|
-
return getConfig().tierConfigs.unlimited;
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
22
|
/**
|
|
44
23
|
* Get tier configuration
|
|
45
24
|
* Uses the configuration system for dynamic configs
|
|
@@ -61,26 +40,32 @@ export function getTierConfig(tier) {
|
|
|
61
40
|
export function getMonthlyLimit(tier) {
|
|
62
41
|
return getConfigMonthlyLimit(tier);
|
|
63
42
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Default credits for new users (free tier)
|
|
66
|
-
* Uses the configuration system
|
|
67
|
-
*/
|
|
68
|
-
export const DEFAULT_FREE_CREDITS = 25; // Static fallback, actual value from getConfig().defaultFreeCredits
|
|
69
43
|
/**
|
|
70
44
|
* Get default free credits from configuration
|
|
71
45
|
*/
|
|
72
46
|
export function getDefaultFreeCredits() {
|
|
73
47
|
return getConfig().defaultFreeCredits;
|
|
74
48
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Reservation expiry time in milliseconds
|
|
77
|
-
* Uses the configuration system
|
|
78
|
-
*/
|
|
79
|
-
export const RESERVATION_EXPIRY_MS = 5 * 60 * 1000; // Static fallback
|
|
80
49
|
/**
|
|
81
50
|
* Get reservation expiry time from configuration
|
|
82
51
|
*/
|
|
83
52
|
export function getReservationExpiryMs() {
|
|
84
53
|
return getConfig().reservationExpiryMs;
|
|
85
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Get all operation costs with their display labels.
|
|
57
|
+
* Returns a record keyed by operation type with cost + label.
|
|
58
|
+
*/
|
|
59
|
+
export function getOperationCostsWithLabels() {
|
|
60
|
+
const config = getConfig();
|
|
61
|
+
const result = {};
|
|
62
|
+
for (const [key, cost] of Object.entries(config.operationCosts)) {
|
|
63
|
+
result[key] = {
|
|
64
|
+
key,
|
|
65
|
+
cost,
|
|
66
|
+
label: getOperationLabel(key),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
86
71
|
//# sourceMappingURL=costs.js.map
|
package/dist/config/costs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"costs.js","sourceRoot":"","sources":["../../src/config/costs.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"costs.js","sourceRoot":"","sources":["../../src/config/costs.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC,cAAc,EAAE,CAAC;AAC3C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAED,+CAA+C;AAC/C,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,IAAsB;IAClD,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,IAAsB;IACpD,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,SAAS,EAAE,CAAC,kBAAkB,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,SAAS,EAAE,CAAC,mBAAmB,CAAC;AACzC,CAAC;AAWD;;;GAGG;AACH,MAAM,UAAU,2BAA2B;IACzC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAsC,EAAE,CAAC;IACrD,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;QAChE,MAAM,CAAC,GAAG,CAAC,GAAG;YACZ,GAAG;YACH,IAAI;YACJ,KAAK,EAAE,iBAAiB,CAAC,GAAG,CAAC;SAC9B,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import type { SubscriptionTier, TierConfig } from "../core/types";
|
|
2
|
+
import type { SubscriptionTier, TierConfig } from "../core/types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Schema for credit system configuration
|
|
5
5
|
*/
|
|
@@ -10,6 +10,11 @@ declare const creditSystemConfigSchema: z.ZodObject<{
|
|
|
10
10
|
* Values are positive numbers representing credit cost
|
|
11
11
|
*/
|
|
12
12
|
operationCosts: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
13
|
+
/**
|
|
14
|
+
* Display labels for operation types (English canonical labels).
|
|
15
|
+
* Falls back to auto-generating from snake_case keys if not provided.
|
|
16
|
+
*/
|
|
17
|
+
operationLabels: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
13
18
|
/**
|
|
14
19
|
* Tier configurations
|
|
15
20
|
*/
|
|
@@ -69,19 +74,20 @@ declare const creditSystemConfigSchema: z.ZodObject<{
|
|
|
69
74
|
usageHistory?: boolean | undefined;
|
|
70
75
|
}>>;
|
|
71
76
|
}, "strip", z.ZodTypeAny, {
|
|
72
|
-
features: {
|
|
73
|
-
journalEntries: boolean;
|
|
74
|
-
notifications: boolean;
|
|
75
|
-
subscriptionExpiry: boolean;
|
|
76
|
-
usageHistory: boolean;
|
|
77
|
-
};
|
|
78
77
|
operationCosts: Record<string, number>;
|
|
78
|
+
operationLabels: Record<string, string>;
|
|
79
79
|
tierConfigs: Partial<Record<"free" | "basic" | "premium" | "unlimited", {
|
|
80
80
|
tier: "free" | "basic" | "premium" | "unlimited";
|
|
81
81
|
monthlyCredits: number;
|
|
82
82
|
priceUsd: number;
|
|
83
83
|
features: string[];
|
|
84
84
|
}>>;
|
|
85
|
+
features: {
|
|
86
|
+
journalEntries: boolean;
|
|
87
|
+
notifications: boolean;
|
|
88
|
+
subscriptionExpiry: boolean;
|
|
89
|
+
usageHistory: boolean;
|
|
90
|
+
};
|
|
85
91
|
reservationExpiryMs: number;
|
|
86
92
|
defaultFreeCredits: number;
|
|
87
93
|
subscriptionGracePeriodDays: number;
|
|
@@ -95,6 +101,7 @@ declare const creditSystemConfigSchema: z.ZodObject<{
|
|
|
95
101
|
priceUsd: number;
|
|
96
102
|
features: string[];
|
|
97
103
|
}>>;
|
|
104
|
+
operationLabels?: Record<string, string> | undefined;
|
|
98
105
|
features?: {
|
|
99
106
|
journalEntries?: boolean | undefined;
|
|
100
107
|
notifications?: boolean | undefined;
|
|
@@ -125,7 +132,9 @@ export declare function loadConfigFromEnv(): Partial<CreditSystemConfig>;
|
|
|
125
132
|
*/
|
|
126
133
|
export declare function initializeConfig(overrides?: Partial<CreditSystemConfig>): CreditSystemConfig;
|
|
127
134
|
/**
|
|
128
|
-
* Get the current configuration
|
|
135
|
+
* Get the current configuration.
|
|
136
|
+
* If an external provider is registered, delegates to it.
|
|
137
|
+
* Otherwise falls back to the local currentConfig.
|
|
129
138
|
*/
|
|
130
139
|
export declare function getConfig(): CreditSystemConfig;
|
|
131
140
|
/**
|
|
@@ -157,6 +166,16 @@ export declare function getConfigMonthlyLimit(tier: SubscriptionTier): number;
|
|
|
157
166
|
* Check if a feature is enabled
|
|
158
167
|
*/
|
|
159
168
|
export declare function isFeatureEnabled(feature: keyof CreditSystemConfig["features"]): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Get the display label for an operation type.
|
|
171
|
+
* Falls back to converting snake_case to Title Case if no label is configured.
|
|
172
|
+
*/
|
|
173
|
+
export declare function getOperationLabel(operationType: string): string;
|
|
174
|
+
/**
|
|
175
|
+
* Get all operation labels as a record.
|
|
176
|
+
* For any operation in operationCosts that lacks a label, generates one from the key.
|
|
177
|
+
*/
|
|
178
|
+
export declare function getOperationLabels(): Record<string, string>;
|
|
160
179
|
/**
|
|
161
180
|
* Reset configuration to defaults (for testing)
|
|
162
181
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAarE;;GAEG;AACH,QAAA,MAAM,wBAAwB;IAC5B;;;;OAIG;;IAMH;;;OAGG;;IAMH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|
package/dist/config/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { getConfigProvider } from "./provider.js";
|
|
2
3
|
/**
|
|
3
4
|
* Schema for tier configuration
|
|
4
5
|
*/
|
|
@@ -18,6 +19,11 @@ const creditSystemConfigSchema = z.object({
|
|
|
18
19
|
* Values are positive numbers representing credit cost
|
|
19
20
|
*/
|
|
20
21
|
operationCosts: z.record(z.string().min(1), z.number().positive()),
|
|
22
|
+
/**
|
|
23
|
+
* Display labels for operation types (English canonical labels).
|
|
24
|
+
* Falls back to auto-generating from snake_case keys if not provided.
|
|
25
|
+
*/
|
|
26
|
+
operationLabels: z.record(z.string().min(1), z.string().min(1)).optional().default({}),
|
|
21
27
|
/**
|
|
22
28
|
* Tier configurations
|
|
23
29
|
*/
|
|
@@ -67,6 +73,12 @@ const DEFAULT_CONFIG = {
|
|
|
67
73
|
image_generation: 10,
|
|
68
74
|
template_generation: 10,
|
|
69
75
|
},
|
|
76
|
+
operationLabels: {
|
|
77
|
+
story_generation: "Story generation",
|
|
78
|
+
conversation: "Conversation",
|
|
79
|
+
image_generation: "Image generation",
|
|
80
|
+
template_generation: "Template generation",
|
|
81
|
+
},
|
|
70
82
|
tierConfigs: {
|
|
71
83
|
free: {
|
|
72
84
|
tier: "free",
|
|
@@ -203,6 +215,11 @@ export function initializeConfig(overrides) {
|
|
|
203
215
|
...envConfig.operationCosts,
|
|
204
216
|
...overrides?.operationCosts,
|
|
205
217
|
},
|
|
218
|
+
operationLabels: {
|
|
219
|
+
...DEFAULT_CONFIG.operationLabels,
|
|
220
|
+
...envConfig.operationLabels,
|
|
221
|
+
...overrides?.operationLabels,
|
|
222
|
+
},
|
|
206
223
|
tierConfigs: {
|
|
207
224
|
...DEFAULT_CONFIG.tierConfigs,
|
|
208
225
|
...envConfig.tierConfigs,
|
|
@@ -224,9 +241,15 @@ export function initializeConfig(overrides) {
|
|
|
224
241
|
return currentConfig;
|
|
225
242
|
}
|
|
226
243
|
/**
|
|
227
|
-
* Get the current configuration
|
|
244
|
+
* Get the current configuration.
|
|
245
|
+
* If an external provider is registered, delegates to it.
|
|
246
|
+
* Otherwise falls back to the local currentConfig.
|
|
228
247
|
*/
|
|
229
248
|
export function getConfig() {
|
|
249
|
+
const provider = getConfigProvider();
|
|
250
|
+
if (provider) {
|
|
251
|
+
return provider.getConfig();
|
|
252
|
+
}
|
|
230
253
|
return currentConfig;
|
|
231
254
|
}
|
|
232
255
|
/**
|
|
@@ -234,7 +257,7 @@ export function getConfig() {
|
|
|
234
257
|
* Returns the keys of the operationCosts object
|
|
235
258
|
*/
|
|
236
259
|
export function getValidOperationTypes() {
|
|
237
|
-
return Object.keys(
|
|
260
|
+
return Object.keys(getConfig().operationCosts);
|
|
238
261
|
}
|
|
239
262
|
/**
|
|
240
263
|
* Check if an operation type is valid (configured in the system)
|
|
@@ -242,14 +265,14 @@ export function getValidOperationTypes() {
|
|
|
242
265
|
* @returns true if the operation type is configured
|
|
243
266
|
*/
|
|
244
267
|
export function isValidOperationType(type) {
|
|
245
|
-
return type in
|
|
268
|
+
return type in getConfig().operationCosts;
|
|
246
269
|
}
|
|
247
270
|
/**
|
|
248
271
|
* Get operation cost from configuration
|
|
249
272
|
* @throws Error if the operation type is not configured
|
|
250
273
|
*/
|
|
251
274
|
export function getConfigOperationCost(operationType) {
|
|
252
|
-
const cost =
|
|
275
|
+
const cost = getConfig().operationCosts[operationType];
|
|
253
276
|
if (cost === undefined) {
|
|
254
277
|
throw new Error(`Unknown operation type: ${operationType}. Valid types: ${getValidOperationTypes().join(", ")}`);
|
|
255
278
|
}
|
|
@@ -259,21 +282,54 @@ export function getConfigOperationCost(operationType) {
|
|
|
259
282
|
* Get tier configuration from configuration
|
|
260
283
|
*/
|
|
261
284
|
export function getConfigTierConfig(tier) {
|
|
262
|
-
return
|
|
285
|
+
return getConfig().tierConfigs[tier];
|
|
263
286
|
}
|
|
264
287
|
/**
|
|
265
288
|
* Get monthly limit for a tier from configuration
|
|
266
289
|
* Returns Infinity for unlimited tier
|
|
267
290
|
*/
|
|
268
291
|
export function getConfigMonthlyLimit(tier) {
|
|
269
|
-
const config =
|
|
292
|
+
const config = getConfig().tierConfigs[tier];
|
|
270
293
|
return config.monthlyCredits === 0 ? Infinity : config.monthlyCredits;
|
|
271
294
|
}
|
|
272
295
|
/**
|
|
273
296
|
* Check if a feature is enabled
|
|
274
297
|
*/
|
|
275
298
|
export function isFeatureEnabled(feature) {
|
|
276
|
-
return
|
|
299
|
+
return getConfig().features[feature];
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Convert a snake_case string to Title Case.
|
|
303
|
+
* E.g., "story_generation" -> "Story Generation"
|
|
304
|
+
*/
|
|
305
|
+
function snakeCaseToTitleCase(str) {
|
|
306
|
+
return str
|
|
307
|
+
.replace(/_/g, " ")
|
|
308
|
+
.replace(/\b\w/g, (c) => c.toUpperCase());
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Get the display label for an operation type.
|
|
312
|
+
* Falls back to converting snake_case to Title Case if no label is configured.
|
|
313
|
+
*/
|
|
314
|
+
export function getOperationLabel(operationType) {
|
|
315
|
+
const labels = getConfig().operationLabels;
|
|
316
|
+
if (labels && operationType in labels) {
|
|
317
|
+
return labels[operationType];
|
|
318
|
+
}
|
|
319
|
+
return snakeCaseToTitleCase(operationType);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Get all operation labels as a record.
|
|
323
|
+
* For any operation in operationCosts that lacks a label, generates one from the key.
|
|
324
|
+
*/
|
|
325
|
+
export function getOperationLabels() {
|
|
326
|
+
const config = getConfig();
|
|
327
|
+
const result = {};
|
|
328
|
+
for (const key of Object.keys(config.operationCosts)) {
|
|
329
|
+
result[key] = config.operationLabels?.[key]
|
|
330
|
+
?? snakeCaseToTitleCase(key);
|
|
331
|
+
}
|
|
332
|
+
return result;
|
|
277
333
|
}
|
|
278
334
|
/**
|
|
279
335
|
* Reset configuration to defaults (for testing)
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD;;GAEG;AACH,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;IACvD,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CAC9B,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC;;;;OAIG;IACH,cAAc,EAAE,CAAC,CAAC,MAAM,CACtB,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EACjB,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CACtB;IAED;;;OAGG;IACH,eAAe,EAAE,CAAC,CAAC,MAAM,CACvB,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EACjB,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAClB,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAExB;;OAEG;IACH,WAAW,EAAE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EAAE,CAAC,GAAG,CAAC;eACtC,oBAAoB,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,aAAa,GAAG,cAAc,CAAC;AACjC,CAAC;AAED,0CAA0C;AAC1C,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CreditSystemConfig } from "./index.js";
|
|
2
|
+
/** Interface for external config providers (e.g. Firestore-backed) */
|
|
3
|
+
export interface ICreditConfigProvider {
|
|
4
|
+
getConfig(): CreditSystemConfig;
|
|
5
|
+
}
|
|
6
|
+
/** Register an external config provider. Called once at app startup. */
|
|
7
|
+
export declare function registerConfigProvider(provider: ICreditConfigProvider): void;
|
|
8
|
+
/** Get the registered provider, or null if none registered. */
|
|
9
|
+
export declare function getConfigProvider(): ICreditConfigProvider | null;
|
|
10
|
+
/** Clear registered provider (for testing). */
|
|
11
|
+
export declare function clearConfigProvider(): void;
|
|
12
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/config/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,sEAAsE;AACtE,MAAM,WAAW,qBAAqB;IACpC,SAAS,IAAI,kBAAkB,CAAC;CACjC;AAID,wEAAwE;AACxE,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI,CAE5E;AAED,+DAA+D;AAC/D,wBAAgB,iBAAiB,IAAI,qBAAqB,GAAG,IAAI,CAEhE;AAED,+CAA+C;AAC/C,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
let configProvider = null;
|
|
2
|
+
/** Register an external config provider. Called once at app startup. */
|
|
3
|
+
export function registerConfigProvider(provider) {
|
|
4
|
+
configProvider = provider;
|
|
5
|
+
}
|
|
6
|
+
/** Get the registered provider, or null if none registered. */
|
|
7
|
+
export function getConfigProvider() {
|
|
8
|
+
return configProvider;
|
|
9
|
+
}
|
|
10
|
+
/** Clear registered provider (for testing). */
|
|
11
|
+
export function clearConfigProvider() {
|
|
12
|
+
configProvider = null;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/config/provider.ts"],"names":[],"mappings":"AAOA,IAAI,cAAc,GAAiC,IAAI,CAAC;AAExD,wEAAwE;AACxE,MAAM,UAAU,sBAAsB,CAAC,QAA+B;IACpE,cAAc,GAAG,QAAQ,CAAC;AAC5B,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,iBAAiB;IAC/B,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,mBAAmB;IACjC,cAAc,GAAG,IAAI,CAAC;AACxB,CAAC"}
|