@mpgd/catalog 0.7.7 → 0.8.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 +2 -0
- package/dist/index.js +35 -11
- package/package.json +2 -2
- package/placements.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -55,6 +55,8 @@ export type AdPlacementEntry = (AdPlacementEntryBase & {
|
|
|
55
55
|
export interface AdPlacements {
|
|
56
56
|
readonly version: string;
|
|
57
57
|
readonly placements: readonly AdPlacementEntry[];
|
|
58
|
+
/** Explicitly share a physical placement among logical placements of the same format. */
|
|
59
|
+
readonly sharedPlatformPlacementTargets?: readonly string[];
|
|
58
60
|
}
|
|
59
61
|
export declare const assertProductGrant: (input: unknown) => ProductGrant;
|
|
60
62
|
export declare function assertProductCatalog(input: unknown): ProductCatalog;
|
package/dist/index.js
CHANGED
|
@@ -207,14 +207,14 @@ const assertAdPlacementsShape = (() => {
|
|
|
207
207
|
path: _path + ".placements",
|
|
208
208
|
expected: "ReadonlyArray<AdPlacementEntry>",
|
|
209
209
|
value: input.placements
|
|
210
|
-
}, _errorFactory)) && input.placements.every((elem,
|
|
210
|
+
}, _errorFactory)) && input.placements.every((elem, _index3) => ("object" === typeof elem && null !== elem || _assertGuard_1._assertGuard(_exceptionable, {
|
|
211
211
|
method: "typia.createAssert",
|
|
212
|
-
path: _path + ".placements[" +
|
|
212
|
+
path: _path + ".placements[" + _index3 + "]",
|
|
213
213
|
expected: _ae0,
|
|
214
214
|
value: elem
|
|
215
|
-
}, _errorFactory)) && _au0(elem, _path + ".placements[" +
|
|
215
|
+
}, _errorFactory)) && _au0(elem, _path + ".placements[" + _index3 + "]", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
|
|
216
216
|
method: "typia.createAssert",
|
|
217
|
-
path: _path + ".placements[" +
|
|
217
|
+
path: _path + ".placements[" + _index3 + "]",
|
|
218
218
|
expected: _ae0,
|
|
219
219
|
value: elem
|
|
220
220
|
}, _errorFactory)) || _assertGuard_1._assertGuard(_exceptionable, {
|
|
@@ -222,6 +222,21 @@ const assertAdPlacementsShape = (() => {
|
|
|
222
222
|
path: _path + ".placements",
|
|
223
223
|
expected: "ReadonlyArray<AdPlacementEntry>",
|
|
224
224
|
value: input.placements
|
|
225
|
+
}, _errorFactory)) && (undefined === input.sharedPlatformPlacementTargets || (Array.isArray(input.sharedPlatformPlacementTargets) || _assertGuard_1._assertGuard(_exceptionable, {
|
|
226
|
+
method: "typia.createAssert",
|
|
227
|
+
path: _path + ".sharedPlatformPlacementTargets",
|
|
228
|
+
expected: "(ReadonlyArray<string> | undefined)",
|
|
229
|
+
value: input.sharedPlatformPlacementTargets
|
|
230
|
+
}, _errorFactory)) && input.sharedPlatformPlacementTargets.every((elem, _index4) => "string" === typeof elem || _assertGuard_1._assertGuard(_exceptionable, {
|
|
231
|
+
method: "typia.createAssert",
|
|
232
|
+
path: _path + ".sharedPlatformPlacementTargets[" + _index4 + "]",
|
|
233
|
+
expected: "string",
|
|
234
|
+
value: elem
|
|
235
|
+
}, _errorFactory)) || _assertGuard_1._assertGuard(_exceptionable, {
|
|
236
|
+
method: "typia.createAssert",
|
|
237
|
+
path: _path + ".sharedPlatformPlacementTargets",
|
|
238
|
+
expected: "(ReadonlyArray<string> | undefined)",
|
|
239
|
+
value: input.sharedPlatformPlacementTargets
|
|
225
240
|
}, _errorFactory));
|
|
226
241
|
const _ao1 = (input, _path, _exceptionable = true) => _ao2(input, _path, true && _exceptionable) && (("rewarded" === input.type || _assertGuard_1._assertGuard(_exceptionable, {
|
|
227
242
|
method: "typia.createAssert",
|
|
@@ -351,7 +366,7 @@ const assertAdPlacementsShape = (() => {
|
|
|
351
366
|
value: input
|
|
352
367
|
}, _errorFactory);
|
|
353
368
|
})();
|
|
354
|
-
const _io0 = input => "string" === typeof input.version && (Array.isArray(input.placements) && input.placements.every(elem => "object" === typeof elem && null !== elem && _iu0(elem)));
|
|
369
|
+
const _io0 = input => "string" === typeof input.version && (Array.isArray(input.placements) && input.placements.every(elem => "object" === typeof elem && null !== elem && _iu0(elem))) && (undefined === input.sharedPlatformPlacementTargets || Array.isArray(input.sharedPlatformPlacementTargets) && input.sharedPlatformPlacementTargets.every(elem => "string" === typeof elem));
|
|
355
370
|
const _io1 = input => _io2(input) && ("rewarded" === input.type && (undefined === input.reward || "object" === typeof input.reward && null !== input.reward && _iu1(input.reward)));
|
|
356
371
|
const _io2 = input => "string" === typeof input.id && ("object" === typeof input.frequencyCap && null !== input.frequencyCap && _io3(input.frequencyCap)) && ("object" === typeof input.platformPlacementIds && null !== input.platformPlacementIds && false === Array.isArray(input.platformPlacementIds) && _io4(input.platformPlacementIds));
|
|
357
372
|
const _io3 = input => "number" === typeof input.cooldownSeconds && (undefined === input.maxPerSession || "number" === typeof input.maxPerSession) && (undefined === input.minStageInterval || "number" === typeof input.minStageInterval);
|
|
@@ -518,10 +533,16 @@ export function assertProductCatalog(input) {
|
|
|
518
533
|
}
|
|
519
534
|
export function assertAdPlacements(input) {
|
|
520
535
|
const placements = assertAdPlacementsShape(input);
|
|
536
|
+
const sharingTargets = new Set(placements.sharedPlatformPlacementTargets ?? []);
|
|
537
|
+
if (sharingTargets.size !== (placements.sharedPlatformPlacementTargets?.length ?? 0)
|
|
538
|
+
|| [...sharingTargets].some((target) => target.trim() !== target || target.length === 0)) {
|
|
539
|
+
throw new Error('Shared placement targets must be unique non-empty identifiers.');
|
|
540
|
+
}
|
|
521
541
|
assertUniqueNormalizedPlatformIdentifiers(placements.placements.map((placement) => ({
|
|
522
542
|
logicalId: placement.id,
|
|
523
543
|
identifiers: placement.platformPlacementIds,
|
|
524
|
-
|
|
544
|
+
format: placement.type,
|
|
545
|
+
})), 'ad placement', sharingTargets);
|
|
525
546
|
return placements;
|
|
526
547
|
}
|
|
527
548
|
export function resolveProductPlatformId(product, target) {
|
|
@@ -540,7 +561,7 @@ function normalizePlatformIdentifier(identifier) {
|
|
|
540
561
|
const normalized = identifier?.trim();
|
|
541
562
|
return normalized === undefined || normalized.length === 0 ? undefined : normalized;
|
|
542
563
|
}
|
|
543
|
-
function assertUniqueNormalizedPlatformIdentifiers(entries, kind) {
|
|
564
|
+
function assertUniqueNormalizedPlatformIdentifiers(entries, kind, sharingTargets = new Set()) {
|
|
544
565
|
const identifiersByTarget = new Map();
|
|
545
566
|
for (const entry of entries) {
|
|
546
567
|
for (const [target, identifier] of Object.entries(entry.identifiers)) {
|
|
@@ -549,12 +570,15 @@ function assertUniqueNormalizedPlatformIdentifiers(entries, kind) {
|
|
|
549
570
|
continue;
|
|
550
571
|
}
|
|
551
572
|
const targetIdentifiers = identifiersByTarget.get(target) ?? new Map();
|
|
552
|
-
const
|
|
553
|
-
if (
|
|
573
|
+
const existing = targetIdentifiers.get(normalized);
|
|
574
|
+
if (existing !== undefined && (!sharingTargets.has(target) || existing.format !== entry.format)) {
|
|
554
575
|
throw new Error(`Duplicate normalized ${kind} platform identifier ${normalized} for target ${target}: `
|
|
555
|
-
+ `${
|
|
576
|
+
+ `${existing.logicalId} and ${entry.logicalId}.`);
|
|
556
577
|
}
|
|
557
|
-
targetIdentifiers.set(normalized,
|
|
578
|
+
targetIdentifiers.set(normalized, {
|
|
579
|
+
logicalId: entry.logicalId,
|
|
580
|
+
...(entry.format === undefined ? {} : { format: entry.format }),
|
|
581
|
+
});
|
|
558
582
|
identifiersByTarget.set(target, targetIdentifiers);
|
|
559
583
|
}
|
|
560
584
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpgd/catalog",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Product catalog and ad placement configuration schemas for mpgd games.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"typia": "13.0.2",
|
|
42
|
-
"@mpgd/platform": "0.
|
|
42
|
+
"@mpgd/platform": "0.17.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"ttsc": "0.30.4",
|
package/placements.json
CHANGED