@fragmentsx/client-core 0.4.1 → 0.4.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/createCampaignManager.d.ts +14 -0
- package/dist/createCampaignManager.d.ts.map +1 -0
- package/dist/createCampaignManager.test.d.ts +2 -0
- package/dist/createCampaignManager.test.d.ts.map +1 -0
- package/dist/index.cjs.js +74 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +74 -10
- package/dist/plugins/fetch/index.d.ts +3 -0
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/load/index.d.ts +6 -0
- package/dist/plugins/load/index.d.ts.map +1 -1
- package/dist/plugins/properties/index.d.ts.map +1 -1
- package/dist/testing/createTestFragmentsClient.d.ts +3 -0
- package/dist/testing/createTestFragmentsClient.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare module "@graph-state/core" {
|
|
2
|
+
interface GraphState {
|
|
3
|
+
$campaign?: {
|
|
4
|
+
campaignId: number;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
interface CreateCampaignManagerOptions {
|
|
9
|
+
campaignId: number;
|
|
10
|
+
campaignProperties?: any[];
|
|
11
|
+
}
|
|
12
|
+
export declare const createCampaignManager: (options: CreateCampaignManagerOptions) => import('@graph-state/core').GraphState<import('@graph-state/core').SystemFields, "CampaignManager">;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=createCampaignManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createCampaignManager.d.ts","sourceRoot":"","sources":["../src/createCampaignManager.ts"],"names":[],"mappings":"AAKA,OAAO,QAAQ,mBAAmB,CAAC;IACjC,UAAU,UAAU;QAClB,SAAS,CAAC,EAAE;YACV,UAAU,EAAE,MAAM,CAAC;SACpB,CAAC;KACH;CACF;AAED,UAAU,4BAA4B;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,GAAG,EAAE,CAAC;CAC5B;AAUD,eAAO,MAAM,qBAAqB,YAAa,4BAA4B,wGAwB1E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createCampaignManager.test.d.ts","sourceRoot":"","sources":["../src/createCampaignManager.test.ts"],"names":[],"mappings":""}
|
package/dist/index.cjs.js
CHANGED
|
@@ -317,7 +317,8 @@ const variableType = createConstants$1(
|
|
|
317
317
|
"Enum",
|
|
318
318
|
"Number",
|
|
319
319
|
"Image",
|
|
320
|
-
"Object"
|
|
320
|
+
"Object",
|
|
321
|
+
"Goal"
|
|
321
322
|
);
|
|
322
323
|
const whiteSpace = createConstants$1(
|
|
323
324
|
"normal",
|
|
@@ -1392,6 +1393,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1392
1393
|
}),
|
|
1393
1394
|
defaultValue: layerField(/* @__PURE__ */ number(), { fallback: 0 }),
|
|
1394
1395
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1396
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1395
1397
|
min: layerField(/* @__PURE__ */ number(), { fallback: 1 }),
|
|
1396
1398
|
max: layerField(/* @__PURE__ */ number(), { fallback: 100 }),
|
|
1397
1399
|
step: layerField(/* @__PURE__ */ number(), { fallback: 1 }),
|
|
@@ -1410,6 +1412,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1410
1412
|
}),
|
|
1411
1413
|
defaultValue: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1412
1414
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1415
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1413
1416
|
...GraphFieldSchema.entries
|
|
1414
1417
|
});
|
|
1415
1418
|
/* @__PURE__ */ object({
|
|
@@ -1425,6 +1428,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1425
1428
|
// TODO Add color validator
|
|
1426
1429
|
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "#000" }),
|
|
1427
1430
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1431
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1428
1432
|
...GraphFieldSchema.entries
|
|
1429
1433
|
});
|
|
1430
1434
|
/* @__PURE__ */ object({
|
|
@@ -1439,6 +1443,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1439
1443
|
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1440
1444
|
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1441
1445
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1446
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1442
1447
|
placeholder: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1443
1448
|
isTextarea: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1444
1449
|
isRich: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
@@ -1459,6 +1464,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1459
1464
|
}),
|
|
1460
1465
|
defaultValue: layerField(/* @__PURE__ */ any()),
|
|
1461
1466
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1467
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1462
1468
|
...GraphFieldSchema.entries
|
|
1463
1469
|
});
|
|
1464
1470
|
/* @__PURE__ */ object({
|
|
@@ -1473,6 +1479,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1473
1479
|
}),
|
|
1474
1480
|
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1475
1481
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1482
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1476
1483
|
...GraphFieldSchema.entries
|
|
1477
1484
|
});
|
|
1478
1485
|
/* @__PURE__ */ object({
|
|
@@ -1487,6 +1494,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1487
1494
|
}),
|
|
1488
1495
|
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1489
1496
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1497
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1490
1498
|
cases: layerField(
|
|
1491
1499
|
/* @__PURE__ */ array(
|
|
1492
1500
|
/* @__PURE__ */ object({
|
|
@@ -1511,6 +1519,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1511
1519
|
defaultValue: layerField(/* @__PURE__ */ object({}), { fallback: {} }),
|
|
1512
1520
|
fields: layerField(/* @__PURE__ */ record(/* @__PURE__ */ string(), linkValidator), { fallback: {} }),
|
|
1513
1521
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1522
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1514
1523
|
...GraphFieldSchema.entries
|
|
1515
1524
|
});
|
|
1516
1525
|
/* @__PURE__ */ object({
|
|
@@ -1525,6 +1534,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1525
1534
|
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1526
1535
|
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1527
1536
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1537
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1528
1538
|
...GraphFieldSchema.entries
|
|
1529
1539
|
});
|
|
1530
1540
|
/* @__PURE__ */ pipe(
|
|
@@ -1562,6 +1572,22 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1562
1572
|
defaultValue: layerField(/* @__PURE__ */ array(linkValidator), { fallback: [] }),
|
|
1563
1573
|
definition: layerField(linkValidator, { fallback: null }),
|
|
1564
1574
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1575
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1576
|
+
...GraphFieldSchema.entries
|
|
1577
|
+
});
|
|
1578
|
+
/* @__PURE__ */ object({
|
|
1579
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1580
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1581
|
+
fallback: "Goal",
|
|
1582
|
+
overridable: false
|
|
1583
|
+
}),
|
|
1584
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1585
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Goal), {
|
|
1586
|
+
fallback: variableType.Goal
|
|
1587
|
+
}),
|
|
1588
|
+
defaultValue: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), { fallback: null }),
|
|
1589
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1590
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1565
1591
|
...GraphFieldSchema.entries
|
|
1566
1592
|
});
|
|
1567
1593
|
/* @__PURE__ */ object({
|
|
@@ -1859,12 +1885,8 @@ function generateDisplayName(parsed) {
|
|
|
1859
1885
|
} else if (variant === "italic-normal") {
|
|
1860
1886
|
baseName = "Italic";
|
|
1861
1887
|
} else if (variant === "italic") {
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
} else {
|
|
1865
|
-
const variantName = VARIANT_NAMES[variant];
|
|
1866
|
-
baseName = variantName ? `${baseName} ${variantName}` : baseName;
|
|
1867
|
-
}
|
|
1888
|
+
const variantName = VARIANT_NAMES[variant];
|
|
1889
|
+
baseName = variantName ? `${baseName} ${variantName}` : baseName;
|
|
1868
1890
|
}
|
|
1869
1891
|
}
|
|
1870
1892
|
return baseName.trim();
|
|
@@ -1980,8 +2002,14 @@ const fetchPlugin = (state) => {
|
|
|
1980
2002
|
font: dto.font,
|
|
1981
2003
|
areaId: dto.areaId,
|
|
1982
2004
|
campaignId: dto.campaignId,
|
|
1983
|
-
variantId: (_d2 = dto.variant) == null ? void 0 : _d2.id
|
|
2005
|
+
variantId: (_d2 = dto.variant) == null ? void 0 : _d2.id,
|
|
2006
|
+
areaProperties: dto.areaProperties ?? null,
|
|
2007
|
+
campaignProperties: dto.campaignProperties ?? null,
|
|
2008
|
+
projectProperties: dto.projectProperties ?? null
|
|
1984
2009
|
};
|
|
2010
|
+
if ("$properties" in state && Array.isArray(dto.projectProperties) && dto.projectProperties.length > 0) {
|
|
2011
|
+
state.$properties.hydrate(dto.projectProperties);
|
|
2012
|
+
}
|
|
1985
2013
|
state.$fetch.cacheAreaDocuments.set(code, entity);
|
|
1986
2014
|
})
|
|
1987
2015
|
);
|
|
@@ -2301,12 +2329,18 @@ const propertiesPlugin = (state) => {
|
|
|
2301
2329
|
const keys = [];
|
|
2302
2330
|
for (const prop of properties) {
|
|
2303
2331
|
if (!prop || !prop._id) continue;
|
|
2304
|
-
|
|
2332
|
+
keys.push(`${index.nodes.Variable}:${prop._id}`);
|
|
2333
|
+
}
|
|
2334
|
+
const currentKeys = getPropertyKeys();
|
|
2335
|
+
if (keys.length === currentKeys.length && keys.every((k) => currentKeys.includes(k))) {
|
|
2336
|
+
return;
|
|
2337
|
+
}
|
|
2338
|
+
for (const prop of properties) {
|
|
2339
|
+
if (!prop || !prop._id) continue;
|
|
2305
2340
|
state.mutate(
|
|
2306
2341
|
{ ...prop, _type: index.nodes.Variable, _id: String(prop._id) },
|
|
2307
2342
|
{ replace: true }
|
|
2308
2343
|
);
|
|
2309
|
-
keys.push(key);
|
|
2310
2344
|
}
|
|
2311
2345
|
state.mutate(
|
|
2312
2346
|
PROPERTIES_ROOT_KEY,
|
|
@@ -2712,6 +2746,35 @@ const createAreaManager = (options) => {
|
|
|
2712
2746
|
}
|
|
2713
2747
|
return manager;
|
|
2714
2748
|
};
|
|
2749
|
+
const campaignMetaPlugin = (options) => (state) => {
|
|
2750
|
+
state.$campaign = {
|
|
2751
|
+
campaignId: options.campaignId
|
|
2752
|
+
};
|
|
2753
|
+
};
|
|
2754
|
+
const createCampaignManager = (options) => {
|
|
2755
|
+
var _a;
|
|
2756
|
+
const manager = kt({
|
|
2757
|
+
_type: "CampaignManager",
|
|
2758
|
+
_id: String(options.campaignId),
|
|
2759
|
+
initialState: {},
|
|
2760
|
+
skip: [
|
|
2761
|
+
u([
|
|
2762
|
+
...Object.keys(index.nodes),
|
|
2763
|
+
"PropertiesRoot"
|
|
2764
|
+
])
|
|
2765
|
+
],
|
|
2766
|
+
plugins: [
|
|
2767
|
+
campaignMetaPlugin({
|
|
2768
|
+
campaignId: options.campaignId
|
|
2769
|
+
}),
|
|
2770
|
+
propertiesPlugin
|
|
2771
|
+
]
|
|
2772
|
+
});
|
|
2773
|
+
if ((_a = options.campaignProperties) == null ? void 0 : _a.length) {
|
|
2774
|
+
manager.$properties.hydrate(options.campaignProperties);
|
|
2775
|
+
}
|
|
2776
|
+
return manager;
|
|
2777
|
+
};
|
|
2715
2778
|
const ssrPlugin = (state) => {
|
|
2716
2779
|
var _a, _b, _c;
|
|
2717
2780
|
if (!["$fragments"].every((field) => field in state)) {
|
|
@@ -2786,6 +2849,7 @@ function createTestFragmentsClient(options) {
|
|
|
2786
2849
|
return client;
|
|
2787
2850
|
}
|
|
2788
2851
|
exports.createAreaManager = createAreaManager;
|
|
2852
|
+
exports.createCampaignManager = createCampaignManager;
|
|
2789
2853
|
exports.createFragmentsClient = createFragmentsClient;
|
|
2790
2854
|
exports.createTestFragmentsClient = createTestFragmentsClient;
|
|
2791
2855
|
exports.filtersPlugin = filtersPlugin;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { createFragmentsClient } from './fragmentsClient';
|
|
2
2
|
export { createAreaManager } from './createAreaManager';
|
|
3
|
+
export { createCampaignManager } from './createCampaignManager';
|
|
3
4
|
export { ssrPlugin } from './plugins/ssr';
|
|
4
5
|
export { propertiesPlugin } from './plugins/properties';
|
|
5
6
|
export { filtersPlugin, type FilterOverrides } from './plugins/filters';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,EACL,yBAAyB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,qCAAqC,CAAC"}
|
package/dist/index.es.js
CHANGED
|
@@ -315,7 +315,8 @@ const variableType = createConstants$1(
|
|
|
315
315
|
"Enum",
|
|
316
316
|
"Number",
|
|
317
317
|
"Image",
|
|
318
|
-
"Object"
|
|
318
|
+
"Object",
|
|
319
|
+
"Goal"
|
|
319
320
|
);
|
|
320
321
|
const whiteSpace = createConstants$1(
|
|
321
322
|
"normal",
|
|
@@ -1390,6 +1391,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1390
1391
|
}),
|
|
1391
1392
|
defaultValue: layerField(/* @__PURE__ */ number(), { fallback: 0 }),
|
|
1392
1393
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1394
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1393
1395
|
min: layerField(/* @__PURE__ */ number(), { fallback: 1 }),
|
|
1394
1396
|
max: layerField(/* @__PURE__ */ number(), { fallback: 100 }),
|
|
1395
1397
|
step: layerField(/* @__PURE__ */ number(), { fallback: 1 }),
|
|
@@ -1408,6 +1410,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1408
1410
|
}),
|
|
1409
1411
|
defaultValue: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1410
1412
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1413
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1411
1414
|
...GraphFieldSchema.entries
|
|
1412
1415
|
});
|
|
1413
1416
|
/* @__PURE__ */ object({
|
|
@@ -1423,6 +1426,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1423
1426
|
// TODO Add color validator
|
|
1424
1427
|
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "#000" }),
|
|
1425
1428
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1429
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1426
1430
|
...GraphFieldSchema.entries
|
|
1427
1431
|
});
|
|
1428
1432
|
/* @__PURE__ */ object({
|
|
@@ -1437,6 +1441,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1437
1441
|
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1438
1442
|
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1439
1443
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1444
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1440
1445
|
placeholder: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1441
1446
|
isTextarea: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1442
1447
|
isRich: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
@@ -1457,6 +1462,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1457
1462
|
}),
|
|
1458
1463
|
defaultValue: layerField(/* @__PURE__ */ any()),
|
|
1459
1464
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1465
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1460
1466
|
...GraphFieldSchema.entries
|
|
1461
1467
|
});
|
|
1462
1468
|
/* @__PURE__ */ object({
|
|
@@ -1471,6 +1477,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1471
1477
|
}),
|
|
1472
1478
|
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1473
1479
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1480
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1474
1481
|
...GraphFieldSchema.entries
|
|
1475
1482
|
});
|
|
1476
1483
|
/* @__PURE__ */ object({
|
|
@@ -1485,6 +1492,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1485
1492
|
}),
|
|
1486
1493
|
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1487
1494
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1495
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1488
1496
|
cases: layerField(
|
|
1489
1497
|
/* @__PURE__ */ array(
|
|
1490
1498
|
/* @__PURE__ */ object({
|
|
@@ -1509,6 +1517,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1509
1517
|
defaultValue: layerField(/* @__PURE__ */ object({}), { fallback: {} }),
|
|
1510
1518
|
fields: layerField(/* @__PURE__ */ record(/* @__PURE__ */ string(), linkValidator), { fallback: {} }),
|
|
1511
1519
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1520
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1512
1521
|
...GraphFieldSchema.entries
|
|
1513
1522
|
});
|
|
1514
1523
|
/* @__PURE__ */ object({
|
|
@@ -1523,6 +1532,7 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1523
1532
|
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1524
1533
|
defaultValue: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1525
1534
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1535
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1526
1536
|
...GraphFieldSchema.entries
|
|
1527
1537
|
});
|
|
1528
1538
|
/* @__PURE__ */ pipe(
|
|
@@ -1560,6 +1570,22 @@ const CssOverrideSchema = /* @__PURE__ */ object({
|
|
|
1560
1570
|
defaultValue: layerField(/* @__PURE__ */ array(linkValidator), { fallback: [] }),
|
|
1561
1571
|
definition: layerField(linkValidator, { fallback: null }),
|
|
1562
1572
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1573
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1574
|
+
...GraphFieldSchema.entries
|
|
1575
|
+
});
|
|
1576
|
+
/* @__PURE__ */ object({
|
|
1577
|
+
nodePropertyControlReference: layerField(/* @__PURE__ */ string(), { fallback: null }),
|
|
1578
|
+
name: layerField(/* @__PURE__ */ string(), {
|
|
1579
|
+
fallback: "Goal",
|
|
1580
|
+
overridable: false
|
|
1581
|
+
}),
|
|
1582
|
+
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
1583
|
+
type: layerField(/* @__PURE__ */ literal(variableType.Goal), {
|
|
1584
|
+
fallback: variableType.Goal
|
|
1585
|
+
}),
|
|
1586
|
+
defaultValue: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), { fallback: null }),
|
|
1587
|
+
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1588
|
+
editable: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
|
|
1563
1589
|
...GraphFieldSchema.entries
|
|
1564
1590
|
});
|
|
1565
1591
|
/* @__PURE__ */ object({
|
|
@@ -1857,12 +1883,8 @@ function generateDisplayName(parsed) {
|
|
|
1857
1883
|
} else if (variant === "italic-normal") {
|
|
1858
1884
|
baseName = "Italic";
|
|
1859
1885
|
} else if (variant === "italic") {
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
} else {
|
|
1863
|
-
const variantName = VARIANT_NAMES[variant];
|
|
1864
|
-
baseName = variantName ? `${baseName} ${variantName}` : baseName;
|
|
1865
|
-
}
|
|
1886
|
+
const variantName = VARIANT_NAMES[variant];
|
|
1887
|
+
baseName = variantName ? `${baseName} ${variantName}` : baseName;
|
|
1866
1888
|
}
|
|
1867
1889
|
}
|
|
1868
1890
|
return baseName.trim();
|
|
@@ -1978,8 +2000,14 @@ const fetchPlugin = (state) => {
|
|
|
1978
2000
|
font: dto.font,
|
|
1979
2001
|
areaId: dto.areaId,
|
|
1980
2002
|
campaignId: dto.campaignId,
|
|
1981
|
-
variantId: (_d2 = dto.variant) == null ? void 0 : _d2.id
|
|
2003
|
+
variantId: (_d2 = dto.variant) == null ? void 0 : _d2.id,
|
|
2004
|
+
areaProperties: dto.areaProperties ?? null,
|
|
2005
|
+
campaignProperties: dto.campaignProperties ?? null,
|
|
2006
|
+
projectProperties: dto.projectProperties ?? null
|
|
1982
2007
|
};
|
|
2008
|
+
if ("$properties" in state && Array.isArray(dto.projectProperties) && dto.projectProperties.length > 0) {
|
|
2009
|
+
state.$properties.hydrate(dto.projectProperties);
|
|
2010
|
+
}
|
|
1983
2011
|
state.$fetch.cacheAreaDocuments.set(code, entity);
|
|
1984
2012
|
})
|
|
1985
2013
|
);
|
|
@@ -2299,12 +2327,18 @@ const propertiesPlugin = (state) => {
|
|
|
2299
2327
|
const keys = [];
|
|
2300
2328
|
for (const prop of properties) {
|
|
2301
2329
|
if (!prop || !prop._id) continue;
|
|
2302
|
-
|
|
2330
|
+
keys.push(`${index.nodes.Variable}:${prop._id}`);
|
|
2331
|
+
}
|
|
2332
|
+
const currentKeys = getPropertyKeys();
|
|
2333
|
+
if (keys.length === currentKeys.length && keys.every((k) => currentKeys.includes(k))) {
|
|
2334
|
+
return;
|
|
2335
|
+
}
|
|
2336
|
+
for (const prop of properties) {
|
|
2337
|
+
if (!prop || !prop._id) continue;
|
|
2303
2338
|
state.mutate(
|
|
2304
2339
|
{ ...prop, _type: index.nodes.Variable, _id: String(prop._id) },
|
|
2305
2340
|
{ replace: true }
|
|
2306
2341
|
);
|
|
2307
|
-
keys.push(key);
|
|
2308
2342
|
}
|
|
2309
2343
|
state.mutate(
|
|
2310
2344
|
PROPERTIES_ROOT_KEY,
|
|
@@ -2710,6 +2744,35 @@ const createAreaManager = (options) => {
|
|
|
2710
2744
|
}
|
|
2711
2745
|
return manager;
|
|
2712
2746
|
};
|
|
2747
|
+
const campaignMetaPlugin = (options) => (state) => {
|
|
2748
|
+
state.$campaign = {
|
|
2749
|
+
campaignId: options.campaignId
|
|
2750
|
+
};
|
|
2751
|
+
};
|
|
2752
|
+
const createCampaignManager = (options) => {
|
|
2753
|
+
var _a;
|
|
2754
|
+
const manager = kt({
|
|
2755
|
+
_type: "CampaignManager",
|
|
2756
|
+
_id: String(options.campaignId),
|
|
2757
|
+
initialState: {},
|
|
2758
|
+
skip: [
|
|
2759
|
+
u([
|
|
2760
|
+
...Object.keys(index.nodes),
|
|
2761
|
+
"PropertiesRoot"
|
|
2762
|
+
])
|
|
2763
|
+
],
|
|
2764
|
+
plugins: [
|
|
2765
|
+
campaignMetaPlugin({
|
|
2766
|
+
campaignId: options.campaignId
|
|
2767
|
+
}),
|
|
2768
|
+
propertiesPlugin
|
|
2769
|
+
]
|
|
2770
|
+
});
|
|
2771
|
+
if ((_a = options.campaignProperties) == null ? void 0 : _a.length) {
|
|
2772
|
+
manager.$properties.hydrate(options.campaignProperties);
|
|
2773
|
+
}
|
|
2774
|
+
return manager;
|
|
2775
|
+
};
|
|
2713
2776
|
const ssrPlugin = (state) => {
|
|
2714
2777
|
var _a, _b, _c;
|
|
2715
2778
|
if (!["$fragments"].every((field) => field in state)) {
|
|
@@ -2785,6 +2848,7 @@ function createTestFragmentsClient(options) {
|
|
|
2785
2848
|
}
|
|
2786
2849
|
export {
|
|
2787
2850
|
createAreaManager,
|
|
2851
|
+
createCampaignManager,
|
|
2788
2852
|
createFragmentsClient,
|
|
2789
2853
|
createTestFragmentsClient,
|
|
2790
2854
|
filtersPlugin,
|
|
@@ -7,6 +7,9 @@ interface AreaCacheEntity {
|
|
|
7
7
|
areaId: number;
|
|
8
8
|
campaignId: number;
|
|
9
9
|
variantId: number;
|
|
10
|
+
areaProperties: any[] | null;
|
|
11
|
+
campaignProperties: any[] | null;
|
|
12
|
+
projectProperties: any[] | null;
|
|
10
13
|
}
|
|
11
14
|
declare module "@graph-state/core" {
|
|
12
15
|
interface GraphState {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/fetch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAA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AAQ,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;YACjE,aAAa,EAAE,CACb,SAAS,EAAE,MAAM,EAAE,KAChB,OAAO,CAAC,CAAC,eAAe,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;YACzC,UAAU,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,YAAY,CAAC,CAAC;YACzD,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;SACtC,CAAC;KACH;CACF;AAED,eAAO,MAAM,WAAW,EAAE,MA0IzB,CAAC"}
|
|
@@ -6,9 +6,15 @@ declare module "@graph-state/core" {
|
|
|
6
6
|
loadArea: (areaCode: string) => {
|
|
7
7
|
fragmentId: number;
|
|
8
8
|
props: unknown;
|
|
9
|
+
areaProperties?: any[] | null;
|
|
10
|
+
campaignProperties?: any[] | null;
|
|
11
|
+
projectProperties?: any[] | null;
|
|
9
12
|
} | Promise<{
|
|
10
13
|
fragmentId: number;
|
|
11
14
|
props: unknown;
|
|
15
|
+
areaProperties?: any[] | null;
|
|
16
|
+
campaignProperties?: any[] | null;
|
|
17
|
+
projectProperties?: any[] | null;
|
|
12
18
|
}>;
|
|
13
19
|
};
|
|
14
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/load/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,QAAQ,mBAAmB,CAAC;IACjC,UAAU,UAAU;QAClB,KAAK,EAAE;YACL,YAAY,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,UAAU,GAAG,IAAI,CAAC;YACxD,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/load/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,MA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AAW,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC;YAC1D,cAAc,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;YACvC,iBAAiB,EAAE,MAAM,GAAG,EAAE,CAAC;YAC/B,eAAe,EAAE,MAAM,OAAO,EAAE,CAAC;SAClC,CAAC;KACH;CACF;AAED,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/properties/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIpD,QAAA,MAAM,mBAAmB,EAA4B,OAAO,CAAC;AAE7D,OAAO,QAAQ,mBAAmB,CAAC;IACjC,UAAU,UAAU;QAClB,WAAW,EAAE;YACX,GAAG,EAAE,OAAO,mBAAmB,CAAC;YAChC,OAAO,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;YACrC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC;YAC1D,cAAc,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;YACvC,iBAAiB,EAAE,MAAM,GAAG,EAAE,CAAC;YAC/B,eAAe,EAAE,MAAM,OAAO,EAAE,CAAC;SAClC,CAAC;KACH;CACF;AAED,eAAO,MAAM,gBAAgB,EAAE,MAqH9B,CAAC"}
|
|
@@ -19,6 +19,9 @@ export interface AreaCacheEntity {
|
|
|
19
19
|
areaId: number;
|
|
20
20
|
campaignId: number;
|
|
21
21
|
variantId: number;
|
|
22
|
+
areaProperties?: any[] | null;
|
|
23
|
+
campaignProperties?: any[] | null;
|
|
24
|
+
projectProperties?: any[] | null;
|
|
22
25
|
}
|
|
23
26
|
export interface TestFragmentsClientOptions {
|
|
24
27
|
apiToken?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTestFragmentsClient.d.ts","sourceRoot":"","sources":["../../src/testing/createTestFragmentsClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"createTestFragmentsClient.d.ts","sourceRoot":"","sources":["../../src/testing/createTestFragmentsClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC9B,kBAAkB,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAClC,iBAAiB,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC7C,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CACzC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,CAAC,EAAE,0BAA0B,GACnC,UAAU,CAkBZ"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fragmentsx/client-core",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@graph-state/checkers": "^0.1.3",
|
|
23
23
|
"@graph-state/core": "^0.13.2",
|
|
24
|
-
"@fragmentsx/
|
|
25
|
-
"@fragmentsx/
|
|
24
|
+
"@fragmentsx/definition": "0.2.2",
|
|
25
|
+
"@fragmentsx/utils": "0.2.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@graph-state/plugin-logger": "^0.3.0",
|