@shdan/submesh 0.1.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/LICENSE +21 -0
- package/README.md +62 -0
- package/dist/contracts.d.ts +191 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +2 -0
- package/dist/contracts.js.map +1 -0
- package/dist/drizzle/catalog-mapping-repository.d.ts +280 -0
- package/dist/drizzle/catalog-mapping-repository.d.ts.map +1 -0
- package/dist/drizzle/catalog-mapping-repository.js +62 -0
- package/dist/drizzle/catalog-mapping-repository.js.map +1 -0
- package/dist/drizzle/ensure-schema.d.ts +3 -0
- package/dist/drizzle/ensure-schema.d.ts.map +1 -0
- package/dist/drizzle/ensure-schema.js +100 -0
- package/dist/drizzle/ensure-schema.js.map +1 -0
- package/dist/drizzle/inbound-event-repository.d.ts +960 -0
- package/dist/drizzle/inbound-event-repository.d.ts.map +1 -0
- package/dist/drizzle/inbound-event-repository.js +148 -0
- package/dist/drizzle/inbound-event-repository.js.map +1 -0
- package/dist/drizzle/index.d.ts +40 -0
- package/dist/drizzle/index.d.ts.map +1 -0
- package/dist/drizzle/index.js +57 -0
- package/dist/drizzle/index.js.map +1 -0
- package/dist/drizzle/migrate.d.ts +11 -0
- package/dist/drizzle/migrate.d.ts.map +1 -0
- package/dist/drizzle/migrate.js +22 -0
- package/dist/drizzle/migrate.js.map +1 -0
- package/dist/drizzle/plan-repository.d.ts +497 -0
- package/dist/drizzle/plan-repository.d.ts.map +1 -0
- package/dist/drizzle/plan-repository.js +70 -0
- package/dist/drizzle/plan-repository.js.map +1 -0
- package/dist/drizzle/plugin-installation-repository.d.ts +26 -0
- package/dist/drizzle/plugin-installation-repository.d.ts.map +1 -0
- package/dist/drizzle/plugin-installation-repository.js +71 -0
- package/dist/drizzle/plugin-installation-repository.js.map +1 -0
- package/dist/drizzle/repository-set.d.ts +4 -0
- package/dist/drizzle/repository-set.d.ts.map +1 -0
- package/dist/drizzle/repository-set.js +19 -0
- package/dist/drizzle/repository-set.js.map +1 -0
- package/dist/drizzle/schema.d.ts +2370 -0
- package/dist/drizzle/schema.d.ts.map +1 -0
- package/dist/drizzle/schema.js +103 -0
- package/dist/drizzle/schema.js.map +1 -0
- package/dist/drizzle/subject-repository.d.ts +295 -0
- package/dist/drizzle/subject-repository.d.ts.map +1 -0
- package/dist/drizzle/subject-repository.js +76 -0
- package/dist/drizzle/subject-repository.js.map +1 -0
- package/dist/drizzle/subscription-repository.d.ts +60 -0
- package/dist/drizzle/subscription-repository.d.ts.map +1 -0
- package/dist/drizzle/subscription-repository.js +128 -0
- package/dist/drizzle/subscription-repository.js.map +1 -0
- package/dist/drizzle/summary-repository.d.ts +9 -0
- package/dist/drizzle/summary-repository.d.ts.map +1 -0
- package/dist/drizzle/summary-repository.js +25 -0
- package/dist/drizzle/summary-repository.js.map +1 -0
- package/dist/drizzle/types.d.ts +4 -0
- package/dist/drizzle/types.d.ts.map +1 -0
- package/dist/drizzle/types.js +2 -0
- package/dist/drizzle/types.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/hooks.d.ts +24 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +2 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +16 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +8 -0
- package/dist/logger.js.map +1 -0
- package/dist/plugins/builtin-plugins.d.ts +3 -0
- package/dist/plugins/builtin-plugins.d.ts.map +1 -0
- package/dist/plugins/builtin-plugins.js +7 -0
- package/dist/plugins/builtin-plugins.js.map +1 -0
- package/dist/plugins/hash-payload.d.ts +2 -0
- package/dist/plugins/hash-payload.d.ts.map +1 -0
- package/dist/plugins/hash-payload.js +5 -0
- package/dist/plugins/hash-payload.js.map +1 -0
- package/dist/plugins/manual.d.ts +12 -0
- package/dist/plugins/manual.d.ts.map +1 -0
- package/dist/plugins/manual.js +87 -0
- package/dist/plugins/manual.js.map +1 -0
- package/dist/plugins/plan-provisioning.d.ts +18 -0
- package/dist/plugins/plan-provisioning.d.ts.map +1 -0
- package/dist/plugins/plan-provisioning.js +159 -0
- package/dist/plugins/plan-provisioning.js.map +1 -0
- package/dist/plugins/plugin-registry.d.ts +9 -0
- package/dist/plugins/plugin-registry.d.ts.map +1 -0
- package/dist/plugins/plugin-registry.js +18 -0
- package/dist/plugins/plugin-registry.js.map +1 -0
- package/dist/providers/apple/plugin/app-store-plan-sync.d.ts +4 -0
- package/dist/providers/apple/plugin/app-store-plan-sync.d.ts.map +1 -0
- package/dist/providers/apple/plugin/app-store-plan-sync.js +85 -0
- package/dist/providers/apple/plugin/app-store-plan-sync.js.map +1 -0
- package/dist/providers/apple/plugin/app-store.d.ts +20 -0
- package/dist/providers/apple/plugin/app-store.d.ts.map +1 -0
- package/dist/providers/apple/plugin/app-store.js +397 -0
- package/dist/providers/apple/plugin/app-store.js.map +1 -0
- package/dist/providers/apple/security/app-store-verification.d.ts +4 -0
- package/dist/providers/apple/security/app-store-verification.d.ts.map +1 -0
- package/dist/providers/apple/security/app-store-verification.js +100 -0
- package/dist/providers/apple/security/app-store-verification.js.map +1 -0
- package/dist/providers/apple/services/app-store-subscription-verification-service.d.ts +3 -0
- package/dist/providers/apple/services/app-store-subscription-verification-service.d.ts.map +1 -0
- package/dist/providers/apple/services/app-store-subscription-verification-service.js +155 -0
- package/dist/providers/apple/services/app-store-subscription-verification-service.js.map +1 -0
- package/dist/providers/google/plugin/play-plan-sync.d.ts +4 -0
- package/dist/providers/google/plugin/play-plan-sync.d.ts.map +1 -0
- package/dist/providers/google/plugin/play-plan-sync.js +270 -0
- package/dist/providers/google/plugin/play-plan-sync.js.map +1 -0
- package/dist/providers/google/plugin/play.d.ts +20 -0
- package/dist/providers/google/plugin/play.d.ts.map +1 -0
- package/dist/providers/google/plugin/play.js +460 -0
- package/dist/providers/google/plugin/play.js.map +1 -0
- package/dist/providers/google/security/oauth.d.ts +10 -0
- package/dist/providers/google/security/oauth.d.ts.map +1 -0
- package/dist/providers/google/security/oauth.js +116 -0
- package/dist/providers/google/security/oauth.js.map +1 -0
- package/dist/providers/google/security/pubsub-verification.d.ts +3 -0
- package/dist/providers/google/security/pubsub-verification.d.ts.map +1 -0
- package/dist/providers/google/security/pubsub-verification.js +229 -0
- package/dist/providers/google/security/pubsub-verification.js.map +1 -0
- package/dist/providers/google/services/play-subscription-verification-service.d.ts +3 -0
- package/dist/providers/google/services/play-subscription-verification-service.d.ts.map +1 -0
- package/dist/providers/google/services/play-subscription-verification-service.js +96 -0
- package/dist/providers/google/services/play-subscription-verification-service.js.map +1 -0
- package/dist/repositories/catalog-mapping-repository.d.ts +9 -0
- package/dist/repositories/catalog-mapping-repository.d.ts.map +1 -0
- package/dist/repositories/catalog-mapping-repository.js +2 -0
- package/dist/repositories/catalog-mapping-repository.js.map +1 -0
- package/dist/repositories/inbound-event-repository.d.ts +23 -0
- package/dist/repositories/inbound-event-repository.d.ts.map +1 -0
- package/dist/repositories/inbound-event-repository.js +2 -0
- package/dist/repositories/inbound-event-repository.js.map +1 -0
- package/dist/repositories/index.d.ts +30 -0
- package/dist/repositories/index.d.ts.map +1 -0
- package/dist/repositories/index.js +2 -0
- package/dist/repositories/index.js.map +1 -0
- package/dist/repositories/plan-repository.d.ts +10 -0
- package/dist/repositories/plan-repository.d.ts.map +1 -0
- package/dist/repositories/plan-repository.js +2 -0
- package/dist/repositories/plan-repository.js.map +1 -0
- package/dist/repositories/plugin-installation-repository.d.ts +13 -0
- package/dist/repositories/plugin-installation-repository.d.ts.map +1 -0
- package/dist/repositories/plugin-installation-repository.js +2 -0
- package/dist/repositories/plugin-installation-repository.js.map +1 -0
- package/dist/repositories/subject-repository.d.ts +10 -0
- package/dist/repositories/subject-repository.d.ts.map +1 -0
- package/dist/repositories/subject-repository.js +2 -0
- package/dist/repositories/subject-repository.js.map +1 -0
- package/dist/repositories/subscription-repository.d.ts +24 -0
- package/dist/repositories/subscription-repository.d.ts.map +1 -0
- package/dist/repositories/subscription-repository.js +2 -0
- package/dist/repositories/subscription-repository.js.map +1 -0
- package/dist/security/jwt.d.ts +22 -0
- package/dist/security/jwt.d.ts.map +1 -0
- package/dist/security/jwt.js +132 -0
- package/dist/security/jwt.js.map +1 -0
- package/dist/security/plugin-webhook-verification.d.ts +3 -0
- package/dist/security/plugin-webhook-verification.d.ts.map +1 -0
- package/dist/security/plugin-webhook-verification.js +44 -0
- package/dist/security/plugin-webhook-verification.js.map +1 -0
- package/dist/security/relay-signature.d.ts +12 -0
- package/dist/security/relay-signature.d.ts.map +1 -0
- package/dist/security/relay-signature.js +39 -0
- package/dist/security/relay-signature.js.map +1 -0
- package/dist/services/canonical-subscription-service.d.ts +4 -0
- package/dist/services/canonical-subscription-service.d.ts.map +1 -0
- package/dist/services/canonical-subscription-service.js +20 -0
- package/dist/services/canonical-subscription-service.js.map +1 -0
- package/dist/services/managed-subscription-service.d.ts +5 -0
- package/dist/services/managed-subscription-service.d.ts.map +1 -0
- package/dist/services/managed-subscription-service.js +24 -0
- package/dist/services/managed-subscription-service.js.map +1 -0
- package/dist/services/plan-provisioning-service.d.ts +5 -0
- package/dist/services/plan-provisioning-service.d.ts.map +1 -0
- package/dist/services/plan-provisioning-service.js +100 -0
- package/dist/services/plan-provisioning-service.js.map +1 -0
- package/dist/services/plan-resolution.d.ts +4 -0
- package/dist/services/plan-resolution.d.ts.map +1 -0
- package/dist/services/plan-resolution.js +33 -0
- package/dist/services/plan-resolution.js.map +1 -0
- package/dist/services/plugin-installation-service.d.ts +6 -0
- package/dist/services/plugin-installation-service.d.ts.map +1 -0
- package/dist/services/plugin-installation-service.js +19 -0
- package/dist/services/plugin-installation-service.js.map +1 -0
- package/dist/services/provider-subscription-sync-service.d.ts +4 -0
- package/dist/services/provider-subscription-sync-service.d.ts.map +1 -0
- package/dist/services/provider-subscription-sync-service.js +13 -0
- package/dist/services/provider-subscription-sync-service.js.map +1 -0
- package/dist/services/subject-resolution.d.ts +4 -0
- package/dist/services/subject-resolution.d.ts.map +1 -0
- package/dist/services/subject-resolution.js +48 -0
- package/dist/services/subject-resolution.js.map +1 -0
- package/dist/services/webhook-ingestion-service.d.ts +14 -0
- package/dist/services/webhook-ingestion-service.d.ts.map +1 -0
- package/dist/services/webhook-ingestion-service.js +149 -0
- package/dist/services/webhook-ingestion-service.js.map +1 -0
- package/dist/submesh.d.ts +265 -0
- package/dist/submesh.d.ts.map +1 -0
- package/dist/submesh.js +602 -0
- package/dist/submesh.js.map +1 -0
- package/dist/utils/canonical.d.ts +7 -0
- package/dist/utils/canonical.d.ts.map +1 -0
- package/dist/utils/canonical.js +8 -0
- package/dist/utils/canonical.js.map +1 -0
- package/dist/utils/parse.d.ts +42 -0
- package/dist/utils/parse.d.ts.map +1 -0
- package/dist/utils/parse.js +74 -0
- package/dist/utils/parse.js.map +1 -0
- package/dist/utils/records.d.ts +2 -0
- package/dist/utils/records.d.ts.map +1 -0
- package/dist/utils/records.js +7 -0
- package/dist/utils/records.js.map +1 -0
- package/dist/utils/time.d.ts +2 -0
- package/dist/utils/time.d.ts.map +1 -0
- package/dist/utils/time.js +4 -0
- package/dist/utils/time.js.map +1 -0
- package/dist/utils/validation.d.ts +10 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +19 -0
- package/dist/utils/validation.js.map +1 -0
- package/drizzle/0000_cute_the_order.sql +94 -0
- package/drizzle/meta/0000_snapshot.json +559 -0
- package/drizzle/meta/_journal.json +13 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Submesh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @shdan/submesh
|
|
2
|
+
|
|
3
|
+
Submesh SDK for embedding subscription infrastructure into backend services.
|
|
4
|
+
|
|
5
|
+
Use this package to:
|
|
6
|
+
|
|
7
|
+
- model plans and entitlements
|
|
8
|
+
- ingest webhooks from provider plugins
|
|
9
|
+
- verify and sync store subscriptions
|
|
10
|
+
- evaluate feature access decisions
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @shdan/submesh
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick start
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { Submesh } from "@shdan/submesh";
|
|
22
|
+
|
|
23
|
+
const submesh = new Submesh({
|
|
24
|
+
connectionString: process.env.DATABASE_URL!,
|
|
25
|
+
autoMigrate: true,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
await submesh.upsertSubject({ id: "user_123", email: "dev@example.com" });
|
|
29
|
+
|
|
30
|
+
await submesh.createPlan({
|
|
31
|
+
code: "pro_monthly",
|
|
32
|
+
name: "Pro Monthly",
|
|
33
|
+
entitlements: ["feature:reports"],
|
|
34
|
+
interval: "month",
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
await submesh.createSubscription({
|
|
38
|
+
subjectId: "user_123",
|
|
39
|
+
planCode: "pro_monthly",
|
|
40
|
+
status: "active",
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const decision = await submesh.hasAccess("user_123", "feature:reports");
|
|
44
|
+
console.log(decision.allowed, decision.reason);
|
|
45
|
+
|
|
46
|
+
await submesh.close();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Common methods
|
|
50
|
+
|
|
51
|
+
- `upsertSubject`
|
|
52
|
+
- `createPlan`
|
|
53
|
+
- `createSubscription`
|
|
54
|
+
- `ingestWebhook`
|
|
55
|
+
- `hasAccess`
|
|
56
|
+
- `listEvents`
|
|
57
|
+
- `getSummary`
|
|
58
|
+
|
|
59
|
+
## Documentation
|
|
60
|
+
|
|
61
|
+
- https://submesh.shdan.in
|
|
62
|
+
- API reference: https://submesh.shdan.in/api-reference
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import type { CanonicalSubscriptionInput, Plan, PlanProvisioningInput, PluginInstallation, Subscription, SubscriptionPlugin, SubscriptionStatus } from "@shdan/submesh-core";
|
|
2
|
+
import { SubmeshRepositories } from "./repositories/index.js";
|
|
3
|
+
import { DrizzleRepositoriesOptions, SubmeshDrizzleMigrationConfig } from "./drizzle/index.js";
|
|
4
|
+
import { SubmeshLogger } from "./logger.js";
|
|
5
|
+
import { SubmeshHooks } from "./hooks.js";
|
|
6
|
+
export interface UpsertSubjectInput {
|
|
7
|
+
id: string;
|
|
8
|
+
email?: string | null;
|
|
9
|
+
name?: string | null;
|
|
10
|
+
externalRef?: string | null;
|
|
11
|
+
metadata?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export interface LinkIdentityInput {
|
|
14
|
+
subjectId: string;
|
|
15
|
+
provider: string;
|
|
16
|
+
externalId: string;
|
|
17
|
+
metadata?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
export interface CreatePlanInput extends PlanProvisioningInput {
|
|
20
|
+
interval?: Plan["interval"];
|
|
21
|
+
}
|
|
22
|
+
export interface UpdatePlanInput {
|
|
23
|
+
name?: string;
|
|
24
|
+
description?: string | null;
|
|
25
|
+
interval?: Plan["interval"];
|
|
26
|
+
priceAmount?: number;
|
|
27
|
+
currency?: string;
|
|
28
|
+
entitlements?: string[];
|
|
29
|
+
metadata?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
export interface CreateManagedSubscriptionInput {
|
|
32
|
+
subjectId: string;
|
|
33
|
+
planCode: string;
|
|
34
|
+
status?: SubscriptionStatus;
|
|
35
|
+
pluginKey?: string;
|
|
36
|
+
sourceType?: string;
|
|
37
|
+
sourceRef?: string;
|
|
38
|
+
currentPeriodStart?: string | null;
|
|
39
|
+
currentPeriodEnd?: string | null;
|
|
40
|
+
trialEndAt?: string | null;
|
|
41
|
+
cancelAt?: string | null;
|
|
42
|
+
metadata?: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
export interface UpdateSubscriptionInput {
|
|
45
|
+
status?: SubscriptionStatus;
|
|
46
|
+
currentPeriodStart?: string | null;
|
|
47
|
+
currentPeriodEnd?: string | null;
|
|
48
|
+
trialEndAt?: string | null;
|
|
49
|
+
cancelAt?: string | null;
|
|
50
|
+
metadata?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
export interface CancelSubscriptionOptions {
|
|
53
|
+
cancelAt?: string;
|
|
54
|
+
immediate?: boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface UpsertCatalogMappingInput {
|
|
57
|
+
pluginKey: string;
|
|
58
|
+
externalProductId: string;
|
|
59
|
+
planCode: string;
|
|
60
|
+
metadata?: Record<string, unknown>;
|
|
61
|
+
}
|
|
62
|
+
export interface WebhookSecurityConfig {
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
relaySigningSecret?: string;
|
|
65
|
+
allowInsecureWebhook?: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface GoogleOauthServiceAccountConfig extends GoogleServiceAccountInput {
|
|
68
|
+
allowCustomTokenUriHost?: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface GooglePlayPlanSyncConfig {
|
|
71
|
+
enabled?: boolean;
|
|
72
|
+
strategy?: string;
|
|
73
|
+
endpointUrl?: string;
|
|
74
|
+
deprovisionEndpointUrl?: string;
|
|
75
|
+
deprovisionHttpMethod?: string;
|
|
76
|
+
authToken?: string;
|
|
77
|
+
authHeaderName?: string;
|
|
78
|
+
autoProvisionAllPlans?: boolean;
|
|
79
|
+
packageName?: string;
|
|
80
|
+
serviceAccount?: GoogleOauthServiceAccountConfig;
|
|
81
|
+
defaultLanguageCode?: string;
|
|
82
|
+
defaultRegionCode?: string;
|
|
83
|
+
gracePeriodDuration?: string;
|
|
84
|
+
accountHoldDuration?: string;
|
|
85
|
+
resubscribeState?: string;
|
|
86
|
+
prorationMode?: string;
|
|
87
|
+
legacyCompatible?: boolean;
|
|
88
|
+
regionsVersion?: string;
|
|
89
|
+
activateBasePlan?: boolean;
|
|
90
|
+
}
|
|
91
|
+
export interface GooglePlayPluginConfig extends WebhookSecurityConfig {
|
|
92
|
+
googlePubSubAudience?: string;
|
|
93
|
+
googlePubSubServiceAccountEmail?: string;
|
|
94
|
+
googleOpenIdPublicKeys?: Record<string, string>;
|
|
95
|
+
googleOpenIdCertsUrl?: string;
|
|
96
|
+
googleTrustedOpenIdCertHosts?: string[];
|
|
97
|
+
allowCustomGoogleOpenIdCertsUrlHost?: boolean;
|
|
98
|
+
googlePlay?: {
|
|
99
|
+
packageName?: string;
|
|
100
|
+
serviceAccount?: GoogleOauthServiceAccountConfig;
|
|
101
|
+
};
|
|
102
|
+
planSync?: GooglePlayPlanSyncConfig;
|
|
103
|
+
}
|
|
104
|
+
export interface ApplePlanSyncConfig {
|
|
105
|
+
enabled?: boolean;
|
|
106
|
+
endpointUrl?: string;
|
|
107
|
+
deprovisionEndpointUrl?: string;
|
|
108
|
+
deprovisionHttpMethod?: string;
|
|
109
|
+
authToken?: string;
|
|
110
|
+
authHeaderName?: string;
|
|
111
|
+
autoProvisionAllPlans?: boolean;
|
|
112
|
+
}
|
|
113
|
+
export interface AppleAppStorePluginConfig extends WebhookSecurityConfig {
|
|
114
|
+
appleTrustedRootCertificates?: string[];
|
|
115
|
+
appleSignedPayloadPublicKeys?: string[];
|
|
116
|
+
planSync?: ApplePlanSyncConfig;
|
|
117
|
+
}
|
|
118
|
+
export type ManualPluginConfig = WebhookSecurityConfig;
|
|
119
|
+
export interface BuiltinPluginConfigMap {
|
|
120
|
+
manual: ManualPluginConfig;
|
|
121
|
+
"google-play": GooglePlayPluginConfig;
|
|
122
|
+
"apple-app-store": AppleAppStorePluginConfig;
|
|
123
|
+
}
|
|
124
|
+
export type InstallPluginInput<K extends string = string> = {
|
|
125
|
+
pluginKey: K;
|
|
126
|
+
enabled?: boolean;
|
|
127
|
+
config?: K extends keyof BuiltinPluginConfigMap ? BuiltinPluginConfigMap[K] : Record<string, unknown>;
|
|
128
|
+
};
|
|
129
|
+
export interface PluginListItem {
|
|
130
|
+
plugin: SubscriptionPlugin;
|
|
131
|
+
installation?: PluginInstallation;
|
|
132
|
+
}
|
|
133
|
+
export interface IngestWebhookResult {
|
|
134
|
+
processedEvents: number;
|
|
135
|
+
duplicateEvents: number;
|
|
136
|
+
subscriptions: Subscription[];
|
|
137
|
+
}
|
|
138
|
+
export interface IngestWebhookOptions {
|
|
139
|
+
rawBody?: string | Uint8Array;
|
|
140
|
+
}
|
|
141
|
+
export interface GoogleServiceAccountInput {
|
|
142
|
+
clientEmail: string;
|
|
143
|
+
privateKey: string;
|
|
144
|
+
privateKeyId?: string;
|
|
145
|
+
tokenUri?: string;
|
|
146
|
+
scope?: string;
|
|
147
|
+
}
|
|
148
|
+
export interface VerifyGooglePlaySubscriptionInput {
|
|
149
|
+
purchaseToken: string;
|
|
150
|
+
packageName?: string;
|
|
151
|
+
serviceAccount?: GoogleServiceAccountInput;
|
|
152
|
+
subjectId?: string;
|
|
153
|
+
planCode?: string;
|
|
154
|
+
}
|
|
155
|
+
export interface SyncGooglePlaySubscriptionInput extends VerifyGooglePlaySubscriptionInput {
|
|
156
|
+
subjectId: string;
|
|
157
|
+
}
|
|
158
|
+
export interface VerifyAppleAppStoreSubscriptionInput {
|
|
159
|
+
signedTransactionInfo: string;
|
|
160
|
+
signedRenewalInfo?: string;
|
|
161
|
+
appleTrustedRootCertificates?: string[];
|
|
162
|
+
appleSignedPayloadPublicKeys?: string[];
|
|
163
|
+
subjectId?: string;
|
|
164
|
+
planCode?: string;
|
|
165
|
+
}
|
|
166
|
+
export interface SyncAppleAppStoreSubscriptionInput extends VerifyAppleAppStoreSubscriptionInput {
|
|
167
|
+
subjectId: string;
|
|
168
|
+
}
|
|
169
|
+
export interface VerifiedProviderSubscription {
|
|
170
|
+
provider: "google-play" | "apple-app-store";
|
|
171
|
+
sourceRef: string;
|
|
172
|
+
status: SubscriptionStatus;
|
|
173
|
+
canonical: CanonicalSubscriptionInput;
|
|
174
|
+
raw: Record<string, unknown>;
|
|
175
|
+
}
|
|
176
|
+
export interface SyncedProviderSubscription extends VerifiedProviderSubscription {
|
|
177
|
+
subscription: Subscription;
|
|
178
|
+
}
|
|
179
|
+
export interface SubmeshOptions {
|
|
180
|
+
repositories?: SubmeshRepositories;
|
|
181
|
+
connectionString?: string;
|
|
182
|
+
drizzle?: DrizzleRepositoriesOptions;
|
|
183
|
+
autoMigrate?: boolean;
|
|
184
|
+
migration?: SubmeshDrizzleMigrationConfig;
|
|
185
|
+
plugins?: SubscriptionPlugin[];
|
|
186
|
+
autoRegisterBuiltinPlugins?: boolean;
|
|
187
|
+
logger?: SubmeshLogger;
|
|
188
|
+
hooks?: SubmeshHooks;
|
|
189
|
+
}
|
|
190
|
+
export type LinkProviderIdentityInput = LinkIdentityInput;
|
|
191
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,IAAI,EACJ,qBAAqB,EACrB,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC9B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,eAAgB,SAAQ,qBAAqB;IAC5D,QAAQ,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;CAC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AQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kCAAmC,SAAQ,oCAAoC;IAC9F,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,aAAa,GAAG,iBAAiB,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,EAAE,0BAA0B,CAAC;IACtC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,0BAA2B,SAAQ,4BAA4B;IAC9E,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,0BAA0B,CAAC;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,6BAA6B,CAAC;IAC1C,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC/B,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import type { CatalogMappingRepository } from "../repositories/catalog-mapping-repository.js";
|
|
2
|
+
import type { UpsertCatalogMappingInput } from "../contracts.js";
|
|
3
|
+
import type { SubmeshDrizzleDatabase } from "./types.js";
|
|
4
|
+
export declare class DrizzleCatalogMappingRepository implements CatalogMappingRepository {
|
|
5
|
+
private readonly db;
|
|
6
|
+
constructor(db: SubmeshDrizzleDatabase);
|
|
7
|
+
list(): Omit<import("drizzle-orm/pg-core").PgSelectBase<"catalog_mappings", {
|
|
8
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
9
|
+
name: "id";
|
|
10
|
+
tableName: "catalog_mappings";
|
|
11
|
+
dataType: "string";
|
|
12
|
+
columnType: "PgText";
|
|
13
|
+
data: string;
|
|
14
|
+
driverParam: string;
|
|
15
|
+
notNull: true;
|
|
16
|
+
hasDefault: false;
|
|
17
|
+
isPrimaryKey: true;
|
|
18
|
+
isAutoincrement: false;
|
|
19
|
+
hasRuntimeDefault: false;
|
|
20
|
+
enumValues: [string, ...string[]];
|
|
21
|
+
baseColumn: never;
|
|
22
|
+
identity: undefined;
|
|
23
|
+
generated: undefined;
|
|
24
|
+
}, {}, {}>;
|
|
25
|
+
pluginKey: import("drizzle-orm/pg-core").PgColumn<{
|
|
26
|
+
name: "plugin_key";
|
|
27
|
+
tableName: "catalog_mappings";
|
|
28
|
+
dataType: "string";
|
|
29
|
+
columnType: "PgText";
|
|
30
|
+
data: string;
|
|
31
|
+
driverParam: string;
|
|
32
|
+
notNull: true;
|
|
33
|
+
hasDefault: false;
|
|
34
|
+
isPrimaryKey: false;
|
|
35
|
+
isAutoincrement: false;
|
|
36
|
+
hasRuntimeDefault: false;
|
|
37
|
+
enumValues: [string, ...string[]];
|
|
38
|
+
baseColumn: never;
|
|
39
|
+
identity: undefined;
|
|
40
|
+
generated: undefined;
|
|
41
|
+
}, {}, {}>;
|
|
42
|
+
externalProductId: import("drizzle-orm/pg-core").PgColumn<{
|
|
43
|
+
name: "external_product_id";
|
|
44
|
+
tableName: "catalog_mappings";
|
|
45
|
+
dataType: "string";
|
|
46
|
+
columnType: "PgText";
|
|
47
|
+
data: string;
|
|
48
|
+
driverParam: string;
|
|
49
|
+
notNull: true;
|
|
50
|
+
hasDefault: false;
|
|
51
|
+
isPrimaryKey: false;
|
|
52
|
+
isAutoincrement: false;
|
|
53
|
+
hasRuntimeDefault: false;
|
|
54
|
+
enumValues: [string, ...string[]];
|
|
55
|
+
baseColumn: never;
|
|
56
|
+
identity: undefined;
|
|
57
|
+
generated: undefined;
|
|
58
|
+
}, {}, {}>;
|
|
59
|
+
planCode: import("drizzle-orm/pg-core").PgColumn<{
|
|
60
|
+
name: "plan_code";
|
|
61
|
+
tableName: "catalog_mappings";
|
|
62
|
+
dataType: "string";
|
|
63
|
+
columnType: "PgText";
|
|
64
|
+
data: string;
|
|
65
|
+
driverParam: string;
|
|
66
|
+
notNull: true;
|
|
67
|
+
hasDefault: false;
|
|
68
|
+
isPrimaryKey: false;
|
|
69
|
+
isAutoincrement: false;
|
|
70
|
+
hasRuntimeDefault: false;
|
|
71
|
+
enumValues: [string, ...string[]];
|
|
72
|
+
baseColumn: never;
|
|
73
|
+
identity: undefined;
|
|
74
|
+
generated: undefined;
|
|
75
|
+
}, {}, {}>;
|
|
76
|
+
metadata: import("drizzle-orm/pg-core").PgColumn<{
|
|
77
|
+
name: "metadata";
|
|
78
|
+
tableName: "catalog_mappings";
|
|
79
|
+
dataType: "json";
|
|
80
|
+
columnType: "PgJsonb";
|
|
81
|
+
data: Record<string, unknown>;
|
|
82
|
+
driverParam: unknown;
|
|
83
|
+
notNull: true;
|
|
84
|
+
hasDefault: false;
|
|
85
|
+
isPrimaryKey: false;
|
|
86
|
+
isAutoincrement: false;
|
|
87
|
+
hasRuntimeDefault: false;
|
|
88
|
+
enumValues: undefined;
|
|
89
|
+
baseColumn: never;
|
|
90
|
+
identity: undefined;
|
|
91
|
+
generated: undefined;
|
|
92
|
+
}, {}, {
|
|
93
|
+
$type: Record<string, unknown>;
|
|
94
|
+
}>;
|
|
95
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
96
|
+
name: "created_at";
|
|
97
|
+
tableName: "catalog_mappings";
|
|
98
|
+
dataType: "string";
|
|
99
|
+
columnType: "PgText";
|
|
100
|
+
data: string;
|
|
101
|
+
driverParam: string;
|
|
102
|
+
notNull: true;
|
|
103
|
+
hasDefault: false;
|
|
104
|
+
isPrimaryKey: false;
|
|
105
|
+
isAutoincrement: false;
|
|
106
|
+
hasRuntimeDefault: false;
|
|
107
|
+
enumValues: [string, ...string[]];
|
|
108
|
+
baseColumn: never;
|
|
109
|
+
identity: undefined;
|
|
110
|
+
generated: undefined;
|
|
111
|
+
}, {}, {}>;
|
|
112
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
113
|
+
name: "updated_at";
|
|
114
|
+
tableName: "catalog_mappings";
|
|
115
|
+
dataType: "string";
|
|
116
|
+
columnType: "PgText";
|
|
117
|
+
data: string;
|
|
118
|
+
driverParam: string;
|
|
119
|
+
notNull: true;
|
|
120
|
+
hasDefault: false;
|
|
121
|
+
isPrimaryKey: false;
|
|
122
|
+
isAutoincrement: false;
|
|
123
|
+
hasRuntimeDefault: false;
|
|
124
|
+
enumValues: [string, ...string[]];
|
|
125
|
+
baseColumn: never;
|
|
126
|
+
identity: undefined;
|
|
127
|
+
generated: undefined;
|
|
128
|
+
}, {}, {}>;
|
|
129
|
+
}, "single", Record<"catalog_mappings", "not-null">, false, "orderBy", {
|
|
130
|
+
id: string;
|
|
131
|
+
pluginKey: string;
|
|
132
|
+
externalProductId: string;
|
|
133
|
+
planCode: string;
|
|
134
|
+
metadata: Record<string, unknown>;
|
|
135
|
+
createdAt: string;
|
|
136
|
+
updatedAt: string;
|
|
137
|
+
}[], {
|
|
138
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
139
|
+
name: "id";
|
|
140
|
+
tableName: "catalog_mappings";
|
|
141
|
+
dataType: "string";
|
|
142
|
+
columnType: "PgText";
|
|
143
|
+
data: string;
|
|
144
|
+
driverParam: string;
|
|
145
|
+
notNull: true;
|
|
146
|
+
hasDefault: false;
|
|
147
|
+
isPrimaryKey: true;
|
|
148
|
+
isAutoincrement: false;
|
|
149
|
+
hasRuntimeDefault: false;
|
|
150
|
+
enumValues: [string, ...string[]];
|
|
151
|
+
baseColumn: never;
|
|
152
|
+
identity: undefined;
|
|
153
|
+
generated: undefined;
|
|
154
|
+
}, {}, {}>;
|
|
155
|
+
pluginKey: import("drizzle-orm/pg-core").PgColumn<{
|
|
156
|
+
name: "plugin_key";
|
|
157
|
+
tableName: "catalog_mappings";
|
|
158
|
+
dataType: "string";
|
|
159
|
+
columnType: "PgText";
|
|
160
|
+
data: string;
|
|
161
|
+
driverParam: string;
|
|
162
|
+
notNull: true;
|
|
163
|
+
hasDefault: false;
|
|
164
|
+
isPrimaryKey: false;
|
|
165
|
+
isAutoincrement: false;
|
|
166
|
+
hasRuntimeDefault: false;
|
|
167
|
+
enumValues: [string, ...string[]];
|
|
168
|
+
baseColumn: never;
|
|
169
|
+
identity: undefined;
|
|
170
|
+
generated: undefined;
|
|
171
|
+
}, {}, {}>;
|
|
172
|
+
externalProductId: import("drizzle-orm/pg-core").PgColumn<{
|
|
173
|
+
name: "external_product_id";
|
|
174
|
+
tableName: "catalog_mappings";
|
|
175
|
+
dataType: "string";
|
|
176
|
+
columnType: "PgText";
|
|
177
|
+
data: string;
|
|
178
|
+
driverParam: string;
|
|
179
|
+
notNull: true;
|
|
180
|
+
hasDefault: false;
|
|
181
|
+
isPrimaryKey: false;
|
|
182
|
+
isAutoincrement: false;
|
|
183
|
+
hasRuntimeDefault: false;
|
|
184
|
+
enumValues: [string, ...string[]];
|
|
185
|
+
baseColumn: never;
|
|
186
|
+
identity: undefined;
|
|
187
|
+
generated: undefined;
|
|
188
|
+
}, {}, {}>;
|
|
189
|
+
planCode: import("drizzle-orm/pg-core").PgColumn<{
|
|
190
|
+
name: "plan_code";
|
|
191
|
+
tableName: "catalog_mappings";
|
|
192
|
+
dataType: "string";
|
|
193
|
+
columnType: "PgText";
|
|
194
|
+
data: string;
|
|
195
|
+
driverParam: string;
|
|
196
|
+
notNull: true;
|
|
197
|
+
hasDefault: false;
|
|
198
|
+
isPrimaryKey: false;
|
|
199
|
+
isAutoincrement: false;
|
|
200
|
+
hasRuntimeDefault: false;
|
|
201
|
+
enumValues: [string, ...string[]];
|
|
202
|
+
baseColumn: never;
|
|
203
|
+
identity: undefined;
|
|
204
|
+
generated: undefined;
|
|
205
|
+
}, {}, {}>;
|
|
206
|
+
metadata: import("drizzle-orm/pg-core").PgColumn<{
|
|
207
|
+
name: "metadata";
|
|
208
|
+
tableName: "catalog_mappings";
|
|
209
|
+
dataType: "json";
|
|
210
|
+
columnType: "PgJsonb";
|
|
211
|
+
data: Record<string, unknown>;
|
|
212
|
+
driverParam: unknown;
|
|
213
|
+
notNull: true;
|
|
214
|
+
hasDefault: false;
|
|
215
|
+
isPrimaryKey: false;
|
|
216
|
+
isAutoincrement: false;
|
|
217
|
+
hasRuntimeDefault: false;
|
|
218
|
+
enumValues: undefined;
|
|
219
|
+
baseColumn: never;
|
|
220
|
+
identity: undefined;
|
|
221
|
+
generated: undefined;
|
|
222
|
+
}, {}, {
|
|
223
|
+
$type: Record<string, unknown>;
|
|
224
|
+
}>;
|
|
225
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
226
|
+
name: "created_at";
|
|
227
|
+
tableName: "catalog_mappings";
|
|
228
|
+
dataType: "string";
|
|
229
|
+
columnType: "PgText";
|
|
230
|
+
data: string;
|
|
231
|
+
driverParam: string;
|
|
232
|
+
notNull: true;
|
|
233
|
+
hasDefault: false;
|
|
234
|
+
isPrimaryKey: false;
|
|
235
|
+
isAutoincrement: false;
|
|
236
|
+
hasRuntimeDefault: false;
|
|
237
|
+
enumValues: [string, ...string[]];
|
|
238
|
+
baseColumn: never;
|
|
239
|
+
identity: undefined;
|
|
240
|
+
generated: undefined;
|
|
241
|
+
}, {}, {}>;
|
|
242
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
243
|
+
name: "updated_at";
|
|
244
|
+
tableName: "catalog_mappings";
|
|
245
|
+
dataType: "string";
|
|
246
|
+
columnType: "PgText";
|
|
247
|
+
data: string;
|
|
248
|
+
driverParam: string;
|
|
249
|
+
notNull: true;
|
|
250
|
+
hasDefault: false;
|
|
251
|
+
isPrimaryKey: false;
|
|
252
|
+
isAutoincrement: false;
|
|
253
|
+
hasRuntimeDefault: false;
|
|
254
|
+
enumValues: [string, ...string[]];
|
|
255
|
+
baseColumn: never;
|
|
256
|
+
identity: undefined;
|
|
257
|
+
generated: undefined;
|
|
258
|
+
}, {}, {}>;
|
|
259
|
+
}>, "orderBy">;
|
|
260
|
+
findByExternalProduct(pluginKey: string, externalProductId: string): Promise<{
|
|
261
|
+
id: string;
|
|
262
|
+
metadata: Record<string, unknown>;
|
|
263
|
+
createdAt: string;
|
|
264
|
+
updatedAt: string;
|
|
265
|
+
pluginKey: string;
|
|
266
|
+
externalProductId: string;
|
|
267
|
+
planCode: string;
|
|
268
|
+
} | undefined>;
|
|
269
|
+
upsert(input: UpsertCatalogMappingInput): Promise<{
|
|
270
|
+
id: string;
|
|
271
|
+
metadata: Record<string, unknown>;
|
|
272
|
+
createdAt: string;
|
|
273
|
+
updatedAt: string;
|
|
274
|
+
pluginKey: string;
|
|
275
|
+
externalProductId: string;
|
|
276
|
+
planCode: string;
|
|
277
|
+
}>;
|
|
278
|
+
delete(pluginKey: string, externalProductId: string): Promise<boolean>;
|
|
279
|
+
}
|
|
280
|
+
//# sourceMappingURL=catalog-mapping-repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-mapping-repository.d.ts","sourceRoot":"","sources":["../../src/drizzle/catalog-mapping-repository.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAC9F,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAGjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD,qBAAa,+BAAgC,YAAW,wBAAwB;IAClE,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,sBAAsB;IAEvD,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAOE,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM;;;;;;;;;IASlE,MAAM,CAAC,KAAK,EAAE,yBAAyB;;;;;;;;;IAuCvC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM;CAS1D"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { and, desc, eq } from "drizzle-orm";
|
|
3
|
+
import { now } from "../utils/time.js";
|
|
4
|
+
import { catalogMappings } from "./schema.js";
|
|
5
|
+
export class DrizzleCatalogMappingRepository {
|
|
6
|
+
db;
|
|
7
|
+
constructor(db) {
|
|
8
|
+
this.db = db;
|
|
9
|
+
}
|
|
10
|
+
list() {
|
|
11
|
+
return this.db
|
|
12
|
+
.select()
|
|
13
|
+
.from(catalogMappings)
|
|
14
|
+
.orderBy(desc(catalogMappings.updatedAt));
|
|
15
|
+
}
|
|
16
|
+
async findByExternalProduct(pluginKey, externalProductId) {
|
|
17
|
+
return this.db.query.catalogMappings.findFirst({
|
|
18
|
+
where: and(eq(catalogMappings.pluginKey, pluginKey), eq(catalogMappings.externalProductId, externalProductId)),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async upsert(input) {
|
|
22
|
+
const existing = await this.findByExternalProduct(input.pluginKey, input.externalProductId);
|
|
23
|
+
const timestamp = now();
|
|
24
|
+
if (!existing) {
|
|
25
|
+
const [created] = await this.db
|
|
26
|
+
.insert(catalogMappings)
|
|
27
|
+
.values({
|
|
28
|
+
id: randomUUID(),
|
|
29
|
+
pluginKey: input.pluginKey,
|
|
30
|
+
externalProductId: input.externalProductId,
|
|
31
|
+
planCode: input.planCode,
|
|
32
|
+
metadata: input.metadata ?? {},
|
|
33
|
+
createdAt: timestamp,
|
|
34
|
+
updatedAt: timestamp,
|
|
35
|
+
})
|
|
36
|
+
.returning();
|
|
37
|
+
return created;
|
|
38
|
+
}
|
|
39
|
+
const [updated] = await this.db
|
|
40
|
+
.update(catalogMappings)
|
|
41
|
+
.set({
|
|
42
|
+
planCode: input.planCode,
|
|
43
|
+
metadata: {
|
|
44
|
+
...existing.metadata,
|
|
45
|
+
...(input.metadata ?? {}),
|
|
46
|
+
},
|
|
47
|
+
updatedAt: timestamp,
|
|
48
|
+
})
|
|
49
|
+
.where(eq(catalogMappings.id, existing.id))
|
|
50
|
+
.returning();
|
|
51
|
+
return updated;
|
|
52
|
+
}
|
|
53
|
+
async delete(pluginKey, externalProductId) {
|
|
54
|
+
const existing = await this.findByExternalProduct(pluginKey, externalProductId);
|
|
55
|
+
if (!existing) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
await this.db.delete(catalogMappings).where(eq(catalogMappings.id, existing.id));
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=catalog-mapping-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-mapping-repository.js","sourceRoot":"","sources":["../../src/drizzle/catalog-mapping-repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAI5C,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,MAAM,OAAO,+BAA+B;IACb;IAA7B,YAA6B,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