owostack 0.3.1 → 0.3.3
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/index.d.ts +1 -0
- package/dist/index.js +41 -4
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -378,7 +378,8 @@ function plan(slug, config) {
|
|
|
378
378
|
return {
|
|
379
379
|
_type: "plan",
|
|
380
380
|
slug,
|
|
381
|
-
...config
|
|
381
|
+
...config,
|
|
382
|
+
billingType: config.billingType ?? "recurring"
|
|
382
383
|
};
|
|
383
384
|
}
|
|
384
385
|
function creditPack(slug, config) {
|
|
@@ -410,6 +411,40 @@ function buildSyncPayload(catalog, defaultProvider) {
|
|
|
410
411
|
}
|
|
411
412
|
}
|
|
412
413
|
}
|
|
414
|
+
for (const entry of catalog) {
|
|
415
|
+
if (entry._type !== "credit_system") continue;
|
|
416
|
+
for (const csFeature of entry.features) {
|
|
417
|
+
const featureSlug = csFeature.feature;
|
|
418
|
+
if (!featureMap.has(featureSlug)) {
|
|
419
|
+
const handle = _featureRegistry.get(featureSlug);
|
|
420
|
+
featureMap.set(featureSlug, {
|
|
421
|
+
slug: featureSlug,
|
|
422
|
+
type: "metered",
|
|
423
|
+
name: handle?.featureName || slugToName(featureSlug)
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
for (const entry of catalog) {
|
|
429
|
+
if (entry._type !== "plan") continue;
|
|
430
|
+
for (const f of entry.features) {
|
|
431
|
+
const csHandle = _creditSystemRegistry.get(f.slug);
|
|
432
|
+
if (csHandle) {
|
|
433
|
+
const def = csHandle._buildDefinition();
|
|
434
|
+
for (const csFeature of def.features) {
|
|
435
|
+
const featureSlug = csFeature.feature;
|
|
436
|
+
if (!featureMap.has(featureSlug)) {
|
|
437
|
+
const handle = _featureRegistry.get(featureSlug);
|
|
438
|
+
featureMap.set(featureSlug, {
|
|
439
|
+
slug: featureSlug,
|
|
440
|
+
type: "metered",
|
|
441
|
+
name: handle?.featureName || slugToName(featureSlug)
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
413
448
|
const creditSystems = catalog.filter((e) => e._type === "credit_system").map((cs) => ({
|
|
414
449
|
slug: cs.slug,
|
|
415
450
|
name: cs.name,
|
|
@@ -438,6 +473,7 @@ function buildSyncPayload(catalog, defaultProvider) {
|
|
|
438
473
|
price: p.price,
|
|
439
474
|
currency: p.currency,
|
|
440
475
|
interval: p.interval,
|
|
476
|
+
billingType: p.billingType,
|
|
441
477
|
planGroup: p.planGroup ?? void 0,
|
|
442
478
|
trialDays: p.trialDays ?? void 0,
|
|
443
479
|
provider: p.provider ?? void 0,
|
|
@@ -453,6 +489,7 @@ function buildSyncPayload(catalog, defaultProvider) {
|
|
|
453
489
|
enabled: f.enabled,
|
|
454
490
|
// Boolean features have no limit concept (null), metered features use limit from config
|
|
455
491
|
limit: f.featureType === "boolean" ? null : f.config?.limit ?? null,
|
|
492
|
+
trialLimit: f.featureType === "boolean" ? null : f.config?.trialLimit ?? null,
|
|
456
493
|
// Boolean features have no reset interval
|
|
457
494
|
...f.featureType !== "boolean" && {
|
|
458
495
|
reset: f.config?.reset || "monthly"
|
|
@@ -552,12 +589,12 @@ var Owostack = class {
|
|
|
552
589
|
return config.apiUrl;
|
|
553
590
|
}
|
|
554
591
|
if (config.mode === "sandbox") {
|
|
555
|
-
return "https://sandbox.owostack.com";
|
|
592
|
+
return "https://sandbox.owostack.com/v1";
|
|
556
593
|
}
|
|
557
594
|
if (config.mode === "live") {
|
|
558
|
-
return "https://api.owostack.com";
|
|
595
|
+
return "https://api.owostack.com/v1";
|
|
559
596
|
}
|
|
560
|
-
return "https://api.owostack.com";
|
|
597
|
+
return "https://api.owostack.com/v1";
|
|
561
598
|
}
|
|
562
599
|
/**
|
|
563
600
|
* Override the API key at runtime (used by CLI).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "owostack",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Core SDK for Owostack billing infrastructure",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"payments"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@owostack/types": "0.3.
|
|
33
|
+
"@owostack/types": "0.3.3"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"tsup": "^8.3.6",
|
|
@@ -44,6 +44,6 @@
|
|
|
44
44
|
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
45
45
|
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
46
46
|
"test": "vitest",
|
|
47
|
-
"lint": "
|
|
47
|
+
"lint": "tsc --noEmit -p tsconfig.json"
|
|
48
48
|
}
|
|
49
49
|
}
|