@mpgd/adapter-verse8 0.2.1 → 0.2.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/agent8.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ProductCatalog } from '@mpgd/catalog';
1
+ import { type CatalogTarget, type ProductCatalog } from '@mpgd/catalog';
2
2
  import type { Entitlement, LogicalProductId } from '@mpgd/platform';
3
3
  export * from './agent8-services.js';
4
4
  export interface Verse8Agent8PurchaseEvent {
@@ -15,6 +15,7 @@ export interface Verse8Agent8Context {
15
15
  }
16
16
  export interface Verse8Agent8CommerceOptions {
17
17
  readonly catalog: ProductCatalog;
18
+ readonly target?: CatalogTarget;
18
19
  readonly stateNamespace?: string;
19
20
  readonly now?: () => string;
20
21
  }
package/dist/agent8.js CHANGED
@@ -1,9 +1,11 @@
1
+ import { resolveProductPlatformId, } from '@mpgd/catalog';
2
+ import { defaultVerse8CatalogTarget } from './catalog-target.js';
1
3
  export * from './agent8-services.js';
2
4
  const defaultStateNamespace = 'mpgdVerse8Commerce';
3
5
  export function createVerse8Agent8CommerceService(options) {
4
6
  const namespace = normalizeNamespace(options.stateNamespace ?? defaultStateNamespace);
5
7
  const now = options.now ?? (() => new Date().toISOString());
6
- const products = createPlatformProductMap(options.catalog);
8
+ const products = createPlatformProductMap(options.catalog, options.target ?? defaultVerse8CatalogTarget);
7
9
  return {
8
10
  async handleItemPurchased(event, context) {
9
11
  const normalized = assertPurchaseEvent(event);
@@ -74,11 +76,11 @@ async function readSnapshot(account, context, namespace) {
74
76
  entitlements: [...state.entitlements],
75
77
  };
76
78
  }
77
- function createPlatformProductMap(catalog) {
79
+ function createPlatformProductMap(catalog, target) {
78
80
  const products = new Map();
79
81
  for (const product of catalog.products) {
80
- const platformProductId = product.platformProductIds.verse8?.trim();
81
- if (platformProductId === undefined || platformProductId.length === 0) {
82
+ const platformProductId = resolveProductPlatformId(product, target);
83
+ if (platformProductId === undefined) {
82
84
  continue;
83
85
  }
84
86
  if (products.has(platformProductId)) {
@@ -0,0 +1,2 @@
1
+ import type { CatalogTarget } from '@mpgd/catalog';
2
+ export declare const defaultVerse8CatalogTarget: CatalogTarget;
@@ -0,0 +1 @@
1
+ export const defaultVerse8CatalogTarget = 'verse8';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type InterstitialAdResult as Verse8InterstitialAdResult, type RewardedAdResult as Verse8RewardedAdResult } from '@verse8/ads';
2
- import type { ProductCatalog } from '@mpgd/catalog';
2
+ import { type CatalogTarget, type ProductCatalog } from '@mpgd/catalog';
3
3
  import { type Entitlement, type LogicalAdPlacementId, type LogicalProductId, type PlatformGateway, type ProductType, type StorageAdapter } from '@mpgd/platform';
4
4
  export { verse8AdsRewardEvidenceSchema } from './ads-contract.js';
5
5
  export interface Verse8Credential {
@@ -79,7 +79,7 @@ export interface Verse8CommerceOptions {
79
79
  };
80
80
  readonly canOpenShop?: () => boolean;
81
81
  }
82
- export declare function createVerse8CommerceProducts(catalog: ProductCatalog): readonly Verse8CommerceProduct[];
82
+ export declare function createVerse8CommerceProducts(catalog: ProductCatalog, target?: CatalogTarget): readonly Verse8CommerceProduct[];
83
83
  export interface Verse8PlatformGatewayOptions {
84
84
  readonly authClient?: Verse8AuthClient;
85
85
  readonly adsClient?: Verse8AdsClient;
package/dist/index.js CHANGED
@@ -1,11 +1,13 @@
1
1
  import { Verse8Ads, } from '@verse8/ads';
2
2
  import { Verse8, VXShop } from '@verse8/platform/vanilla';
3
+ import { resolveProductPlatformId } from '@mpgd/catalog';
3
4
  import { createUnsupportedCapabilities, } from '@mpgd/platform';
4
5
  import { verse8AdsRewardEvidenceSchema } from './ads-contract.js';
6
+ import { defaultVerse8CatalogTarget } from './catalog-target.js';
5
7
  export { verse8AdsRewardEvidenceSchema } from './ads-contract.js';
6
- export function createVerse8CommerceProducts(catalog) {
8
+ export function createVerse8CommerceProducts(catalog, target = defaultVerse8CatalogTarget) {
7
9
  return normalizeCommerceProducts(catalog.products.flatMap((product) => {
8
- const platformProductId = product.platformProductIds.verse8;
10
+ const platformProductId = resolveProductPlatformId(product, target);
9
11
  return platformProductId === undefined || product.grant.type === 'resource'
10
12
  ? []
11
13
  : [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpgd/adapter-verse8",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Verse8 iframe platform adapter for mpgd games.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,9 +43,9 @@
43
43
  "dependencies": {
44
44
  "@verse8/ads": "0.4.0",
45
45
  "@verse8/platform": "2.1.0",
46
- "@mpgd/catalog": "0.5.0",
47
- "@mpgd/platform": "0.7.0",
48
- "@mpgd/game-services": "0.10.0"
46
+ "@mpgd/catalog": "0.5.2",
47
+ "@mpgd/platform": "0.8.0",
48
+ "@mpgd/game-services": "0.11.1"
49
49
  },
50
50
  "devDependencies": {
51
51
  "ttsc": "0.18.4",