owostack 0.1.4 → 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/index.d.ts +18 -2
- package/dist/index.js +26 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckResult, PlanFeatureEntry, ResetInterval, CreditSystemDefinition, AddEntityResult, RemoveEntityResult, ListEntitiesResult, MeteredFeatureConfig, TrackResult, CatalogEntry, SyncPayload, Currency, PlanInterval, PlanDefinition, OwostackConfig, BillingUsageParams, BillingUsageResult, InvoiceParams, InvoiceResult, InvoicesParams, InvoicesResult, PayInvoiceParams, PayInvoiceResult, WalletResult, WalletSetupResult, WalletRemoveResult, SyncResult, AttachParams, AttachResult, CheckParams, TrackParams, AddonParams, AddonResult, CustomerParams, CustomerResult, AddEntityParams, RemoveEntityParams, ListEntitiesParams, PlansParams, PlansResult, PublicPlan } from '@owostack/types';
|
|
1
|
+
import { CheckResult, PlanFeatureEntry, ResetInterval, CreditSystemDefinition, AddEntityResult, RemoveEntityResult, ListEntitiesResult, MeteredFeatureConfig, TrackResult, CatalogEntry, SyncPayload, Currency, CreditPackDefinition, PlanInterval, PlanDefinition, OwostackConfig, BillingUsageParams, BillingUsageResult, InvoiceParams, InvoiceResult, InvoicesParams, InvoicesResult, PayInvoiceParams, PayInvoiceResult, WalletResult, WalletSetupResult, WalletRemoveResult, SyncResult, AttachParams, AttachResult, CheckParams, TrackParams, AddonParams, AddonResult, CustomerParams, CustomerResult, AddEntityParams, RemoveEntityParams, ListEntitiesParams, PlansParams, PlansResult, PublicPlan } from '@owostack/types';
|
|
2
2
|
export { AddEntityParams, AddEntityResult, AddonParams, AddonResult, AttachParams, AttachResult, BillingFeatureUsage, BillingUsageParams, BillingUsageResult, BooleanFeatureConfig, CardInfo, CatalogEntry, CheckCode, CheckParams, CheckResult, CustomerData, CustomerParams, CustomerResult, Invoice, InvoiceLineItem, InvoiceParams, InvoiceResult, InvoicesParams, InvoicesResult, ListEntitiesParams, ListEntitiesResult, MeteredFeatureConfig, OverageDetails, OwostackConfig, PayInvoiceParams, PayInvoiceResult, PaymentMethodInfo, PlanCredits, PlanDefinition, PlanFeatureEntry, PlansParams, PlansResult, PublicPlan, PublicPlanFeature, RemoveEntityParams, RemoveEntityResult, ResponseDetails, SyncChanges, SyncPayload, SyncResult, TrackCode, TrackParams, TrackResult, WalletRemoveResult, WalletResult, WalletSetupResult } from '@owostack/types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -133,7 +133,23 @@ declare function plan(slug: string, config: {
|
|
|
133
133
|
trialDays?: number;
|
|
134
134
|
provider?: string;
|
|
135
135
|
metadata?: Record<string, unknown>;
|
|
136
|
+
autoEnable?: boolean;
|
|
137
|
+
isAddon?: boolean;
|
|
136
138
|
}): PlanDefinition;
|
|
139
|
+
/**
|
|
140
|
+
* Create a credit pack definition.
|
|
141
|
+
* Credit packs are one-time purchases that add credits to a customer's balance.
|
|
142
|
+
*/
|
|
143
|
+
declare function creditPack(slug: string, config: {
|
|
144
|
+
name: string;
|
|
145
|
+
description?: string;
|
|
146
|
+
credits: number;
|
|
147
|
+
price: number;
|
|
148
|
+
currency: Currency;
|
|
149
|
+
creditSystem: string;
|
|
150
|
+
provider?: string;
|
|
151
|
+
metadata?: Record<string, unknown>;
|
|
152
|
+
}): CreditPackDefinition;
|
|
137
153
|
/**
|
|
138
154
|
* Extract SyncPayload from catalog.
|
|
139
155
|
*/
|
|
@@ -446,4 +462,4 @@ declare class OwostackError extends Error {
|
|
|
446
462
|
constructor(code: string, message: string);
|
|
447
463
|
}
|
|
448
464
|
|
|
449
|
-
export { BooleanHandle, CreditSystemHandle, EntityHandle, type MeteredHandle, Owostack, OwostackError, boolean, buildSyncPayload, creditSystem, entity, metered, plan };
|
|
465
|
+
export { BooleanHandle, CreditSystemHandle, EntityHandle, type MeteredHandle, Owostack, OwostackError, boolean, buildSyncPayload, creditPack, creditSystem, entity, metered, plan };
|
package/dist/index.js
CHANGED
|
@@ -258,6 +258,13 @@ function plan(slug, config) {
|
|
|
258
258
|
...config
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
|
+
function creditPack(slug, config) {
|
|
262
|
+
return {
|
|
263
|
+
_type: "credit_pack",
|
|
264
|
+
slug,
|
|
265
|
+
...config
|
|
266
|
+
};
|
|
267
|
+
}
|
|
261
268
|
function slugToName(slug) {
|
|
262
269
|
return slug.split(/[-_]/).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
263
270
|
}
|
|
@@ -273,7 +280,9 @@ function buildSyncPayload(catalog, defaultProvider) {
|
|
|
273
280
|
slug: f.slug,
|
|
274
281
|
type: f.featureType,
|
|
275
282
|
name: f.name || slugToName(f.slug),
|
|
276
|
-
...handle instanceof EntityHandle && {
|
|
283
|
+
...handle instanceof EntityHandle && {
|
|
284
|
+
meterType: "non_consumable"
|
|
285
|
+
}
|
|
277
286
|
});
|
|
278
287
|
}
|
|
279
288
|
}
|
|
@@ -310,6 +319,8 @@ function buildSyncPayload(catalog, defaultProvider) {
|
|
|
310
319
|
trialDays: p.trialDays ?? void 0,
|
|
311
320
|
provider: p.provider ?? void 0,
|
|
312
321
|
metadata: p.metadata ?? void 0,
|
|
322
|
+
autoEnable: p.autoEnable ?? void 0,
|
|
323
|
+
isAddon: p.isAddon ?? void 0,
|
|
313
324
|
features: p.features.map((f) => ({
|
|
314
325
|
slug: f.slug,
|
|
315
326
|
enabled: f.enabled,
|
|
@@ -334,10 +345,22 @@ function buildSyncPayload(catalog, defaultProvider) {
|
|
|
334
345
|
}
|
|
335
346
|
}))
|
|
336
347
|
}));
|
|
348
|
+
const creditPacks = catalog.filter((e) => e._type === "credit_pack").map((cp) => ({
|
|
349
|
+
slug: cp.slug,
|
|
350
|
+
name: cp.name,
|
|
351
|
+
description: cp.description ?? void 0,
|
|
352
|
+
credits: cp.credits,
|
|
353
|
+
price: cp.price,
|
|
354
|
+
currency: cp.currency,
|
|
355
|
+
creditSystem: cp.creditSystem,
|
|
356
|
+
provider: cp.provider ?? void 0,
|
|
357
|
+
metadata: cp.metadata ?? void 0
|
|
358
|
+
}));
|
|
337
359
|
return {
|
|
338
360
|
defaultProvider,
|
|
339
361
|
features: Array.from(featureMap.values()),
|
|
340
362
|
creditSystems,
|
|
363
|
+
creditPacks,
|
|
341
364
|
plans
|
|
342
365
|
};
|
|
343
366
|
}
|
|
@@ -428,6 +451,7 @@ var Owostack = class {
|
|
|
428
451
|
success: true,
|
|
429
452
|
features: { created: [], updated: [], unchanged: [] },
|
|
430
453
|
creditSystems: { created: [], updated: [], unchanged: [] },
|
|
454
|
+
creditPacks: { created: [], updated: [], unchanged: [] },
|
|
431
455
|
plans: { created: [], updated: [], unchanged: [] },
|
|
432
456
|
warnings: ["No catalog entries to sync."]
|
|
433
457
|
};
|
|
@@ -809,6 +833,7 @@ export {
|
|
|
809
833
|
OwostackError,
|
|
810
834
|
boolean,
|
|
811
835
|
buildSyncPayload,
|
|
836
|
+
creditPack,
|
|
812
837
|
creditSystem,
|
|
813
838
|
entity,
|
|
814
839
|
metered,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "owostack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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.
|
|
33
|
+
"@owostack/types": "0.2.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"tsup": "^8.3.6",
|