@forklaunch/implementation-billing-base 1.0.37 → 1.0.38
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.
|
@@ -22,9 +22,12 @@ export class BaseSubscriptionService<
|
|
|
22
22
|
PartyType,
|
|
23
23
|
BillingProviderType,
|
|
24
24
|
MapperEntities extends BaseSubscriptionEntities,
|
|
25
|
-
Dto extends BaseSubscriptionDtos<
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
Dto extends BaseSubscriptionDtos<
|
|
26
|
+
PartyType,
|
|
27
|
+
BillingProviderType
|
|
28
|
+
> = BaseSubscriptionDtos<PartyType, BillingProviderType>
|
|
29
|
+
> implements SubscriptionService<PartyType, BillingProviderType>
|
|
30
|
+
{
|
|
28
31
|
protected evaluatedTelemetryOptions: {
|
|
29
32
|
logging?: boolean;
|
|
30
33
|
metrics?: boolean;
|
|
@@ -107,6 +110,24 @@ export class BaseSubscriptionService<
|
|
|
107
110
|
);
|
|
108
111
|
}
|
|
109
112
|
|
|
113
|
+
/**
|
|
114
|
+
* The row id of the subscription a billing provider knows by
|
|
115
|
+
* `externalId`, or null. Reads only the id, so it works before the row's
|
|
116
|
+
* tenant is known and never touches an encrypted column: it is how a
|
|
117
|
+
* webhook maps the provider's subscription id onto our own row.
|
|
118
|
+
*/
|
|
119
|
+
async findSubscriptionIdByExternalId(
|
|
120
|
+
{ externalId }: { externalId: string },
|
|
121
|
+
em?: EntityManager
|
|
122
|
+
): Promise<IdDto | null> {
|
|
123
|
+
const subscription = await (em ?? this.em).findOne(
|
|
124
|
+
this.mappers.SubscriptionMapper.entity as typeof Subscription,
|
|
125
|
+
{ externalId },
|
|
126
|
+
{ fields: ['id'] }
|
|
127
|
+
);
|
|
128
|
+
return subscription ? { id: subscription.id } : null;
|
|
129
|
+
}
|
|
130
|
+
|
|
110
131
|
async getUserSubscription(
|
|
111
132
|
{ id }: IdDto,
|
|
112
133
|
em?: EntityManager
|
package/lib/services/index.js
CHANGED
|
@@ -536,6 +536,20 @@ var BaseSubscriptionService = class {
|
|
|
536
536
|
subscription
|
|
537
537
|
);
|
|
538
538
|
}
|
|
539
|
+
/**
|
|
540
|
+
* The row id of the subscription a billing provider knows by
|
|
541
|
+
* `externalId`, or null. Reads only the id, so it works before the row's
|
|
542
|
+
* tenant is known and never touches an encrypted column: it is how a
|
|
543
|
+
* webhook maps the provider's subscription id onto our own row.
|
|
544
|
+
*/
|
|
545
|
+
async findSubscriptionIdByExternalId({ externalId }, em) {
|
|
546
|
+
const subscription = await (em ?? this.em).findOne(
|
|
547
|
+
this.mappers.SubscriptionMapper.entity,
|
|
548
|
+
{ externalId },
|
|
549
|
+
{ fields: ["id"] }
|
|
550
|
+
);
|
|
551
|
+
return subscription ? { id: subscription.id } : null;
|
|
552
|
+
}
|
|
539
553
|
async getUserSubscription({ id }, em) {
|
|
540
554
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
541
555
|
this.openTelemetryCollector.info("Getting user subscription", id);
|
package/lib/services/index.mjs
CHANGED
|
@@ -515,6 +515,20 @@ var BaseSubscriptionService = class {
|
|
|
515
515
|
subscription
|
|
516
516
|
);
|
|
517
517
|
}
|
|
518
|
+
/**
|
|
519
|
+
* The row id of the subscription a billing provider knows by
|
|
520
|
+
* `externalId`, or null. Reads only the id, so it works before the row's
|
|
521
|
+
* tenant is known and never touches an encrypted column: it is how a
|
|
522
|
+
* webhook maps the provider's subscription id onto our own row.
|
|
523
|
+
*/
|
|
524
|
+
async findSubscriptionIdByExternalId({ externalId }, em) {
|
|
525
|
+
const subscription = await (em ?? this.em).findOne(
|
|
526
|
+
this.mappers.SubscriptionMapper.entity,
|
|
527
|
+
{ externalId },
|
|
528
|
+
{ fields: ["id"] }
|
|
529
|
+
);
|
|
530
|
+
return subscription ? { id: subscription.id } : null;
|
|
531
|
+
}
|
|
518
532
|
async getUserSubscription({ id }, em) {
|
|
519
533
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
520
534
|
this.openTelemetryCollector.info("Getting user subscription", id);
|
|
@@ -25,6 +25,15 @@ export declare class BaseSubscriptionService<SchemaValidator extends AnySchemaVa
|
|
|
25
25
|
} | undefined);
|
|
26
26
|
createSubscription(subscriptionDto: CreateSubscriptionDto<PartyType, BillingProviderType>, em?: EntityManager, ...args: unknown[]): Promise<Dto['SubscriptionMapper']>;
|
|
27
27
|
getSubscription(idDto: IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
|
|
28
|
+
/**
|
|
29
|
+
* The row id of the subscription a billing provider knows by
|
|
30
|
+
* `externalId`, or null. Reads only the id, so it works before the row's
|
|
31
|
+
* tenant is known and never touches an encrypted column: it is how a
|
|
32
|
+
* webhook maps the provider's subscription id onto our own row.
|
|
33
|
+
*/
|
|
34
|
+
findSubscriptionIdByExternalId({ externalId }: {
|
|
35
|
+
externalId: string;
|
|
36
|
+
}, em?: EntityManager): Promise<IdDto | null>;
|
|
28
37
|
getUserSubscription({ id }: IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
|
|
29
38
|
getOrganizationSubscription({ id }: IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
|
|
30
39
|
updateSubscription(subscriptionDto: UpdateSubscriptionDto<PartyType, BillingProviderType>, em?: EntityManager, ...args: unknown[]): Promise<Dto['SubscriptionMapper']>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.service.d.ts","sourceRoot":"","sources":["../../services/subscription.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAEL,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uB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