@gmb/bitmark-parser-generator 5.4.0 → 5.6.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.cts CHANGED
@@ -419,6 +419,7 @@ declare const BitType: {
419
419
  readonly pageHero: "page-hero";
420
420
  readonly pageOpenBook: "page-open-book";
421
421
  readonly pageOpenBookList: "page-open-book-list";
422
+ readonly printBook: "print-book";
422
423
  readonly openBookChapter: "open-book-chapter";
423
424
  readonly pagePerson: "page-person";
424
425
  readonly pageProduct: "page-product";
@@ -712,6 +713,7 @@ declare const ConfigKey: {
712
713
  readonly property_ageRange: "@ageRange";
713
714
  readonly property_aiGenerated: "@aiGenerated";
714
715
  readonly property_allowedBit: "@allowedBit";
716
+ readonly property_allowPrint: "@allowPrint";
715
717
  readonly property_allowSubtitles: "@allowSubtitles";
716
718
  readonly property_alt: "@alt";
717
719
  readonly property_altLangTag: "@altLangTag";
@@ -816,6 +818,7 @@ declare const ConfigKey: {
816
818
  readonly property_internalPrintPdf: "@internalPrintPdf";
817
819
  readonly property_hasPrintRestriction: "@hasPrintRestriction";
818
820
  readonly property_enforceUpdateOverUserInput: "@enforceUpdateOverUserInput";
821
+ readonly property_extractorExtractionTimestamp: "@extractorExtractionTimestamp";
819
822
  readonly property_isCaseSensitive: "@isCaseSensitive";
820
823
  readonly property_isInfoOnly: "@isInfoOnly";
821
824
  readonly property_isPublic: "@isPublic";
@@ -853,6 +856,7 @@ declare const ConfigKey: {
853
856
  readonly property_mute: "@mute";
854
857
  readonly property_padletId: "@padletId";
855
858
  readonly property_page: "@page";
859
+ readonly property_printParentChapterLevel: "@printParentChapterLevel";
856
860
  readonly property_pageNo: "@pageNo";
857
861
  readonly property_partialAnswer: "@partialAnswer";
858
862
  readonly property_partner: "@partner";
@@ -1791,10 +1795,13 @@ interface BitJson {
1791
1795
  maxCreatedBits: number;
1792
1796
  maxDisplayLevel: number;
1793
1797
  maxTocChapterLevel: number;
1798
+ allowPrint: boolean;
1799
+ printParentChapterLevel: number;
1794
1800
  sourceDocument: string;
1795
1801
  internalPrintPdf: string;
1796
1802
  hasPrintRestriction: boolean;
1797
1803
  enforceUpdateOverUserInput: boolean;
1804
+ extractorExtractionTimestamp: string[];
1798
1805
  tocResource: string | string[];
1799
1806
  tocContent: string | string[];
1800
1807
  page: string;
@@ -2408,9 +2415,13 @@ interface Bit {
2408
2415
  internalPrintPdf?: Property;
2409
2416
  hasPrintRestriction?: Property;
2410
2417
  enforceUpdateOverUserInput?: Property;
2418
+ extractorExtractionTimestamp?: Property;
2411
2419
  tocResource?: Property;
2412
2420
  tocContent?: Property;
2413
2421
  page?: Property;
2422
+ allowPrint?: Property;
2423
+ allowPrintValue?: Property;
2424
+ printParentChapterLevel?: Property;
2414
2425
  platformBrandTarget?: Property;
2415
2426
  platformName?: Property;
2416
2427
  platformIcon?: ImageResourceWrapperJson;
@@ -2559,6 +2570,8 @@ declare const NodeType: {
2559
2570
  readonly alignment: "alignment";
2560
2571
  readonly allowedBit: "allowedBit";
2561
2572
  readonly allowedBitValue: "allowedBitValue";
2573
+ readonly allowPrint: "allowPrint";
2574
+ readonly allowPrintValue: "allowPrintValue";
2562
2575
  readonly alt: "alt";
2563
2576
  readonly alternativeAnswers: "alternativeAnswers";
2564
2577
  readonly alternativeAnswersValue: "alternativeAnswersValue";
@@ -2816,6 +2829,8 @@ declare const NodeType: {
2816
2829
  readonly hasPrintRestrictionValue: "hasPrintRestrictionValue";
2817
2830
  readonly enforceUpdateOverUserInput: "enforceUpdateOverUserInput";
2818
2831
  readonly enforceUpdateOverUserInputValue: "enforceUpdateOverUserInputValue";
2832
+ readonly extractorExtractionTimestamp: "extractorExtractionTimestamp";
2833
+ readonly extractorExtractionTimestampValue: "extractorExtractionTimestampValue";
2819
2834
  readonly isCaseSensitive: "isCaseSensitive";
2820
2835
  readonly isCommented: "isCommented";
2821
2836
  readonly isCorrect: "isCorrect";
@@ -2918,6 +2933,8 @@ declare const NodeType: {
2918
2933
  readonly pageNumber: "pageNumber";
2919
2934
  readonly pageNumberValue: "pageNumberValue";
2920
2935
  readonly pageValue: "pageValue";
2936
+ readonly printParentChapterLevel: "printParentChapterLevel";
2937
+ readonly printParentChapterLevelValue: "printParentChapterLevelValue";
2921
2938
  readonly pairs: "pairs";
2922
2939
  readonly pairsValue: "pairsValue";
2923
2940
  readonly parent: "parent";
@@ -4212,11 +4229,14 @@ declare class Builder extends BaseBuilder {
4212
4229
  maxTocChapterLevel?: number;
4213
4230
  sourceDocument?: string;
4214
4231
  internalPrintPdf?: string;
4232
+ allowPrint?: boolean;
4215
4233
  hasPrintRestriction?: boolean;
4216
4234
  enforceUpdateOverUserInput?: boolean;
4235
+ extractorExtractionTimestamp?: string[];
4217
4236
  tocResource?: string | string[];
4218
4237
  tocContent?: string | string[];
4219
4238
  page?: string | string[];
4239
+ printParentChapterLevel?: number;
4220
4240
  platformBrandTarget?: string;
4221
4241
  platformName?: string;
4222
4242
  platformIcon?: Partial<ImageResourceWrapperJson>;
package/dist/index.d.ts CHANGED
@@ -419,6 +419,7 @@ declare const BitType: {
419
419
  readonly pageHero: "page-hero";
420
420
  readonly pageOpenBook: "page-open-book";
421
421
  readonly pageOpenBookList: "page-open-book-list";
422
+ readonly printBook: "print-book";
422
423
  readonly openBookChapter: "open-book-chapter";
423
424
  readonly pagePerson: "page-person";
424
425
  readonly pageProduct: "page-product";
@@ -712,6 +713,7 @@ declare const ConfigKey: {
712
713
  readonly property_ageRange: "@ageRange";
713
714
  readonly property_aiGenerated: "@aiGenerated";
714
715
  readonly property_allowedBit: "@allowedBit";
716
+ readonly property_allowPrint: "@allowPrint";
715
717
  readonly property_allowSubtitles: "@allowSubtitles";
716
718
  readonly property_alt: "@alt";
717
719
  readonly property_altLangTag: "@altLangTag";
@@ -816,6 +818,7 @@ declare const ConfigKey: {
816
818
  readonly property_internalPrintPdf: "@internalPrintPdf";
817
819
  readonly property_hasPrintRestriction: "@hasPrintRestriction";
818
820
  readonly property_enforceUpdateOverUserInput: "@enforceUpdateOverUserInput";
821
+ readonly property_extractorExtractionTimestamp: "@extractorExtractionTimestamp";
819
822
  readonly property_isCaseSensitive: "@isCaseSensitive";
820
823
  readonly property_isInfoOnly: "@isInfoOnly";
821
824
  readonly property_isPublic: "@isPublic";
@@ -853,6 +856,7 @@ declare const ConfigKey: {
853
856
  readonly property_mute: "@mute";
854
857
  readonly property_padletId: "@padletId";
855
858
  readonly property_page: "@page";
859
+ readonly property_printParentChapterLevel: "@printParentChapterLevel";
856
860
  readonly property_pageNo: "@pageNo";
857
861
  readonly property_partialAnswer: "@partialAnswer";
858
862
  readonly property_partner: "@partner";
@@ -1791,10 +1795,13 @@ interface BitJson {
1791
1795
  maxCreatedBits: number;
1792
1796
  maxDisplayLevel: number;
1793
1797
  maxTocChapterLevel: number;
1798
+ allowPrint: boolean;
1799
+ printParentChapterLevel: number;
1794
1800
  sourceDocument: string;
1795
1801
  internalPrintPdf: string;
1796
1802
  hasPrintRestriction: boolean;
1797
1803
  enforceUpdateOverUserInput: boolean;
1804
+ extractorExtractionTimestamp: string[];
1798
1805
  tocResource: string | string[];
1799
1806
  tocContent: string | string[];
1800
1807
  page: string;
@@ -2408,9 +2415,13 @@ interface Bit {
2408
2415
  internalPrintPdf?: Property;
2409
2416
  hasPrintRestriction?: Property;
2410
2417
  enforceUpdateOverUserInput?: Property;
2418
+ extractorExtractionTimestamp?: Property;
2411
2419
  tocResource?: Property;
2412
2420
  tocContent?: Property;
2413
2421
  page?: Property;
2422
+ allowPrint?: Property;
2423
+ allowPrintValue?: Property;
2424
+ printParentChapterLevel?: Property;
2414
2425
  platformBrandTarget?: Property;
2415
2426
  platformName?: Property;
2416
2427
  platformIcon?: ImageResourceWrapperJson;
@@ -2559,6 +2570,8 @@ declare const NodeType: {
2559
2570
  readonly alignment: "alignment";
2560
2571
  readonly allowedBit: "allowedBit";
2561
2572
  readonly allowedBitValue: "allowedBitValue";
2573
+ readonly allowPrint: "allowPrint";
2574
+ readonly allowPrintValue: "allowPrintValue";
2562
2575
  readonly alt: "alt";
2563
2576
  readonly alternativeAnswers: "alternativeAnswers";
2564
2577
  readonly alternativeAnswersValue: "alternativeAnswersValue";
@@ -2816,6 +2829,8 @@ declare const NodeType: {
2816
2829
  readonly hasPrintRestrictionValue: "hasPrintRestrictionValue";
2817
2830
  readonly enforceUpdateOverUserInput: "enforceUpdateOverUserInput";
2818
2831
  readonly enforceUpdateOverUserInputValue: "enforceUpdateOverUserInputValue";
2832
+ readonly extractorExtractionTimestamp: "extractorExtractionTimestamp";
2833
+ readonly extractorExtractionTimestampValue: "extractorExtractionTimestampValue";
2819
2834
  readonly isCaseSensitive: "isCaseSensitive";
2820
2835
  readonly isCommented: "isCommented";
2821
2836
  readonly isCorrect: "isCorrect";
@@ -2918,6 +2933,8 @@ declare const NodeType: {
2918
2933
  readonly pageNumber: "pageNumber";
2919
2934
  readonly pageNumberValue: "pageNumberValue";
2920
2935
  readonly pageValue: "pageValue";
2936
+ readonly printParentChapterLevel: "printParentChapterLevel";
2937
+ readonly printParentChapterLevelValue: "printParentChapterLevelValue";
2921
2938
  readonly pairs: "pairs";
2922
2939
  readonly pairsValue: "pairsValue";
2923
2940
  readonly parent: "parent";
@@ -4212,11 +4229,14 @@ declare class Builder extends BaseBuilder {
4212
4229
  maxTocChapterLevel?: number;
4213
4230
  sourceDocument?: string;
4214
4231
  internalPrintPdf?: string;
4232
+ allowPrint?: boolean;
4215
4233
  hasPrintRestriction?: boolean;
4216
4234
  enforceUpdateOverUserInput?: boolean;
4235
+ extractorExtractionTimestamp?: string[];
4217
4236
  tocResource?: string | string[];
4218
4237
  tocContent?: string | string[];
4219
4238
  page?: string | string[];
4239
+ printParentChapterLevel?: number;
4220
4240
  platformBrandTarget?: string;
4221
4241
  platformName?: string;
4222
4242
  platformIcon?: Partial<ImageResourceWrapperJson>;
package/dist/index.js CHANGED
@@ -428,6 +428,7 @@ var BitType = {
428
428
  pageHero: "page-hero",
429
429
  pageOpenBook: "page-open-book",
430
430
  pageOpenBookList: "page-open-book-list",
431
+ printBook: "print-book",
431
432
  openBookChapter: "open-book-chapter",
432
433
  pagePerson: "page-person",
433
434
  pageProduct: "page-product",
@@ -1137,6 +1138,7 @@ var propertyKeys = {
1137
1138
  property_ageRange: "@ageRange",
1138
1139
  property_aiGenerated: "@aiGenerated",
1139
1140
  property_allowedBit: "@allowedBit",
1141
+ property_allowPrint: "@allowPrint",
1140
1142
  property_allowSubtitles: "@allowSubtitles",
1141
1143
  property_alt: "@alt",
1142
1144
  property_altLangTag: "@altLangTag",
@@ -1241,6 +1243,7 @@ var propertyKeys = {
1241
1243
  property_internalPrintPdf: "@internalPrintPdf",
1242
1244
  property_hasPrintRestriction: "@hasPrintRestriction",
1243
1245
  property_enforceUpdateOverUserInput: "@enforceUpdateOverUserInput",
1246
+ property_extractorExtractionTimestamp: "@extractorExtractionTimestamp",
1244
1247
  property_isCaseSensitive: "@isCaseSensitive",
1245
1248
  property_isInfoOnly: "@isInfoOnly",
1246
1249
  property_isPublic: "@isPublic",
@@ -1278,6 +1281,7 @@ var propertyKeys = {
1278
1281
  property_mute: "@mute",
1279
1282
  property_padletId: "@padletId",
1280
1283
  property_page: "@page",
1284
+ property_printParentChapterLevel: "@printParentChapterLevel",
1281
1285
  property_pageNo: "@pageNo",
1282
1286
  property_partialAnswer: "@partialAnswer",
1283
1287
  property_partner: "@partner",
@@ -3406,6 +3410,12 @@ var GROUPS = {
3406
3410
  description: "Url of the internal print PDF for the book",
3407
3411
  format: TagFormat.plainText
3408
3412
  },
3413
+ {
3414
+ key: ConfigKey.property_allowPrint,
3415
+ description: "If true, the book allows printing",
3416
+ format: TagFormat.boolean,
3417
+ defaultValue: "false"
3418
+ },
3409
3419
  {
3410
3420
  key: ConfigKey.property_hasPrintRestriction,
3411
3421
  description: "If true, the book has print restrictions",
@@ -3417,6 +3427,12 @@ var GROUPS = {
3417
3427
  description: "If true, prioritize new content over legacy content from the instance API",
3418
3428
  format: TagFormat.boolean,
3419
3429
  defaultValue: "false"
3430
+ },
3431
+ {
3432
+ key: ConfigKey.property_extractorExtractionTimestamp,
3433
+ description: "Extraction timestamps for book conversion",
3434
+ format: TagFormat.plainText,
3435
+ maxCount: Count.infinity
3420
3436
  }
3421
3437
  ]
3422
3438
  },
@@ -6813,6 +6829,12 @@ var BITS = {
6813
6829
  key: ConfigKey.property_buttonCaption,
6814
6830
  description: "The caption of the print button",
6815
6831
  format: TagFormat.plainText
6832
+ },
6833
+ {
6834
+ key: ConfigKey.property_printParentChapterLevel,
6835
+ description: "The parent chapter level to print",
6836
+ format: TagFormat.number,
6837
+ defaultValue: "-1"
6816
6838
  }
6817
6839
  ]
6818
6840
  },
@@ -7393,6 +7415,39 @@ var BITS = {
7393
7415
  }
7394
7416
  ]
7395
7417
  },
7418
+ [BitType.printBook]: {
7419
+ since: "5.5.0",
7420
+ baseBitType: BitType.article,
7421
+ description: "Print book bit, used to create pages that open books without author information in articles or books",
7422
+ tags: [
7423
+ {
7424
+ key: ConfigKey.property_slug,
7425
+ description: "Slug for the book, used to identify the book in the system",
7426
+ format: TagFormat.plainText
7427
+ },
7428
+ {
7429
+ key: ConfigKey.property_book,
7430
+ description: "Book reference for the page, used to link to a specific book",
7431
+ format: TagFormat.plainText,
7432
+ chain: [
7433
+ {
7434
+ key: ConfigKey.tag_reference,
7435
+ description: "Reference tag for the book, used to link to the book in the system",
7436
+ maxCount: 2
7437
+ }
7438
+ ]
7439
+ },
7440
+ {
7441
+ /* Allow incorrectly chained reference tag */
7442
+ key: ConfigKey.tag_reference,
7443
+ description: "Reference tag for the book, used to link to the book in the system"
7444
+ },
7445
+ {
7446
+ key: ConfigKey.property_buttonCaption,
7447
+ description: "Caption for the button, used to define the text displayed on the button"
7448
+ }
7449
+ ]
7450
+ },
7396
7451
  [BitType.openBookChapter]: {
7397
7452
  since: "4.16.0",
7398
7453
  baseBitType: BitType.pageOpenBook,
@@ -10288,7 +10343,7 @@ var instance2 = new Config();
10288
10343
  // src/generated/package_info.ts
10289
10344
  var PACKAGE_INFO = {
10290
10345
  "name": "@gmb/bitmark-parser-generator",
10291
- "version": "5.4.0",
10346
+ "version": "5.6.0",
10292
10347
  "author": "Get More Brain Ltd",
10293
10348
  "license": "ISC",
10294
10349
  "description": "A bitmark parser and generator using Peggy.js"
@@ -10649,6 +10704,8 @@ var NodeType = {
10649
10704
  alignment: "alignment",
10650
10705
  allowedBit: "allowedBit",
10651
10706
  allowedBitValue: "allowedBitValue",
10707
+ allowPrint: "allowPrint",
10708
+ allowPrintValue: "allowPrintValue",
10652
10709
  alt: "alt",
10653
10710
  alternativeAnswers: "alternativeAnswers",
10654
10711
  alternativeAnswersValue: "alternativeAnswersValue",
@@ -10911,6 +10968,8 @@ var NodeType = {
10911
10968
  hasPrintRestrictionValue: "hasPrintRestrictionValue",
10912
10969
  enforceUpdateOverUserInput: "enforceUpdateOverUserInput",
10913
10970
  enforceUpdateOverUserInputValue: "enforceUpdateOverUserInputValue",
10971
+ extractorExtractionTimestamp: "extractorExtractionTimestamp",
10972
+ extractorExtractionTimestampValue: "extractorExtractionTimestampValue",
10914
10973
  isCaseSensitive: "isCaseSensitive",
10915
10974
  isCommented: "isCommented",
10916
10975
  isCorrect: "isCorrect",
@@ -11014,6 +11073,8 @@ var NodeType = {
11014
11073
  pageNumber: "pageNumber",
11015
11074
  pageNumberValue: "pageNumberValue",
11016
11075
  pageValue: "pageValue",
11076
+ printParentChapterLevel: "printParentChapterLevel",
11077
+ printParentChapterLevelValue: "printParentChapterLevelValue",
11017
11078
  pairs: "pairs",
11018
11079
  pairsValue: "pairsValue",
11019
11080
  parent: "parent",
@@ -24793,6 +24854,12 @@ var Builder = class extends BaseBuilder {
24793
24854
  data.enforceUpdateOverUserInput,
24794
24855
  options
24795
24856
  ),
24857
+ extractorExtractionTimestamp: this.toAstProperty(
24858
+ bitType,
24859
+ ConfigKey.property_extractorExtractionTimestamp,
24860
+ data.extractorExtractionTimestamp,
24861
+ options
24862
+ ),
24796
24863
  tocResource: this.toAstProperty(
24797
24864
  bitType,
24798
24865
  ConfigKey.property_tocResource,
@@ -24806,6 +24873,18 @@ var Builder = class extends BaseBuilder {
24806
24873
  options
24807
24874
  ),
24808
24875
  page: this.toAstProperty(bitType, ConfigKey.property_page, data.page, options),
24876
+ allowPrint: this.toAstProperty(
24877
+ bitType,
24878
+ ConfigKey.property_allowPrint,
24879
+ data.allowPrint,
24880
+ options
24881
+ ),
24882
+ printParentChapterLevel: this.toAstProperty(
24883
+ bitType,
24884
+ ConfigKey.property_printParentChapterLevel,
24885
+ data.printParentChapterLevel,
24886
+ options
24887
+ ),
24809
24888
  platformBrandTarget: this.toAstProperty(
24810
24889
  bitType,
24811
24890
  ConfigKey.property_platformBrandTarget,
@@ -30476,6 +30555,7 @@ var JsonGenerator = class extends AstWalkerGenerator {
30476
30555
  BitType.pageFooter,
30477
30556
  BitType.pageOpenBook,
30478
30557
  BitType.pagePerson,
30558
+ BitType.printBook,
30479
30559
  BitType.pageProduct,
30480
30560
  BitType.pageProductList,
30481
30561
  BitType.pageProductVideo,
@@ -30496,8 +30576,12 @@ var JsonGenerator = class extends AstWalkerGenerator {
30496
30576
  if (instance2.isOfBitType(bitType, BitType.tocContent)) {
30497
30577
  if (bitJson.tocContent == null) bitJson.tocContent = [];
30498
30578
  }
30579
+ if (instance2.isOfBitType(bitType, BitType.printThisChapter)) {
30580
+ if (bitJson.printParentChapterLevel == null) bitJson.printParentChapterLevel = -1;
30581
+ }
30499
30582
  if (instance2.isOfBitType(bitType, BitType.book)) {
30500
30583
  if (bitJson.maxTocChapterLevel == null) bitJson.maxTocChapterLevel = -1;
30584
+ if (bitJson.allowPrint == null) bitJson.allowPrint = false;
30501
30585
  if (bitJson.hasPrintRestriction == null) bitJson.hasPrintRestriction = true;
30502
30586
  if (bitJson.enforceUpdateOverUserInput == null) bitJson.enforceUpdateOverUserInput = false;
30503
30587
  if (bitJson.hasMarkAsDone == null) bitJson.hasMarkAsDone = false;
@@ -38967,6 +39051,7 @@ var JsonFileGenerator = class {
38967
39051
  import path3 from "path";
38968
39052
  import { Enum as Enum22 } from "@ncoderz/superenum";
38969
39053
  import fs3 from "fs-extra";
39054
+ var normalizeCardKey = (cardSetKey) => stringUtils.camelToKebab(cardSetKey);
38970
39055
  var ConfigBuilder = class {
38971
39056
  build(options) {
38972
39057
  const opts = Object.assign({}, options);
@@ -39007,8 +39092,10 @@ var ConfigBuilder = class {
39007
39092
  const outputFolder = opts.outputDir ?? "assets/config";
39008
39093
  const outputFolderBits = path3.join(outputFolder, "bits");
39009
39094
  const outputFolderGroups = path3.join(outputFolder, "partials");
39095
+ const outputFolderCards = path3.join(outputFolder, "cards");
39010
39096
  fs3.ensureDirSync(outputFolderBits);
39011
39097
  fs3.ensureDirSync(outputFolderGroups);
39098
+ fs3.ensureDirSync(outputFolderCards);
39012
39099
  const bitsFiles = fs3.readdirSync(outputFolderBits).filter((f) => f.endsWith(".jsonc"));
39013
39100
  for (const file of bitsFiles) {
39014
39101
  fs3.removeSync(path3.join(outputFolderBits, file));
@@ -39017,7 +39104,18 @@ var ConfigBuilder = class {
39017
39104
  for (const file of partialsFiles) {
39018
39105
  fs3.removeSync(path3.join(outputFolderGroups, file));
39019
39106
  }
39107
+ const cardsFiles = fs3.readdirSync(outputFolderCards).filter((f) => f.endsWith(".jsonc"));
39108
+ for (const file of cardsFiles) {
39109
+ fs3.removeSync(path3.join(outputFolderCards, file));
39110
+ }
39020
39111
  const fileWrites = [];
39112
+ const tagEntriesTypeOrder = [
39113
+ BitTagConfigKeyType.tag,
39114
+ BitTagConfigKeyType.property,
39115
+ BitTagConfigKeyType.resource,
39116
+ BitTagConfigKeyType.group,
39117
+ BitTagConfigKeyType.unknown
39118
+ ];
39021
39119
  const resolveGroupReferences = (groupKey) => {
39022
39120
  if (squashedGroups.has(groupKey)) {
39023
39121
  const replacements = squashedGroups.get(groupKey);
@@ -39122,6 +39220,38 @@ var ConfigBuilder = class {
39122
39220
  tags2.push(t);
39123
39221
  return tags2;
39124
39222
  };
39223
+ const serializeCardSet = (cardSetKey) => {
39224
+ const cardSetConfig = CARDSETS[cardSetKey];
39225
+ if (!cardSetConfig) return void 0;
39226
+ const normalizedKey = normalizeCardKey(cardSetKey);
39227
+ const sides = cardSetConfig.variants.map((variantList) => {
39228
+ const variants = variantList.map((variant) => {
39229
+ const variantTags = [];
39230
+ const variantTagEntries = Object.entries(variant.tags ?? []).sort((a, b) => {
39231
+ const tagA = a[1];
39232
+ const tagB = b[1];
39233
+ const typeA = typeFromConfigKey(tagA.key);
39234
+ const typeB = typeFromConfigKey(tagB.key);
39235
+ const typeOrder = tagEntriesTypeOrder.indexOf(typeA) - tagEntriesTypeOrder.indexOf(typeB);
39236
+ return typeOrder;
39237
+ });
39238
+ for (const [, variantTag] of variantTagEntries) {
39239
+ variantTags.push(...processTagEntries(variantTag, []));
39240
+ }
39241
+ return {
39242
+ tags: variantTags,
39243
+ repeatCount: variant.repeatCount ?? 1,
39244
+ bodyAllowed: variant.bodyAllowed ?? true,
39245
+ bodyRequired: variant.bodyRequired ?? false
39246
+ };
39247
+ });
39248
+ return { variants };
39249
+ });
39250
+ return {
39251
+ key: normalizedKey,
39252
+ sides
39253
+ };
39254
+ };
39125
39255
  for (const bt of bitGroupConfigKeys) {
39126
39256
  const bitType = instance2.getBitType(bt);
39127
39257
  const _bitConfig = BITS[bitType];
@@ -39154,13 +39284,6 @@ var ConfigBuilder = class {
39154
39284
  for (const b of bitConfigs) {
39155
39285
  const resolvedBitConfig = instance2.getBitConfig(b.bitType);
39156
39286
  const tags2 = [];
39157
- const tagEntriesTypeOrder = [
39158
- BitTagConfigKeyType.tag,
39159
- BitTagConfigKeyType.property,
39160
- BitTagConfigKeyType.resource,
39161
- BitTagConfigKeyType.group,
39162
- BitTagConfigKeyType.unknown
39163
- ];
39164
39287
  const tagEntries = Object.entries(b.tags ?? []).sort((a, b2) => {
39165
39288
  const tagA = a[1];
39166
39289
  const tagB = b2[1];
@@ -39192,6 +39315,10 @@ var ConfigBuilder = class {
39192
39315
  tags2.push(...processTagEntries(tag, []));
39193
39316
  }
39194
39317
  }
39318
+ let cardRef;
39319
+ if (b.cardSet && CARDSETS[b.cardSet]) {
39320
+ cardRef = normalizeCardKey(b.cardSet);
39321
+ }
39195
39322
  const bitJson = {
39196
39323
  name: b.bitType,
39197
39324
  description: b.description ?? "",
@@ -39209,7 +39336,8 @@ var ConfigBuilder = class {
39209
39336
  footerAllowed: resolvedBitConfig.footerAllowed ?? true,
39210
39337
  footerRequired: resolvedBitConfig.footerRequired ?? false,
39211
39338
  resourceAttachmentAllowed: resolvedBitConfig.resourceAttachmentAllowed ?? true,
39212
- tags: tags2
39339
+ tags: tags2,
39340
+ ...cardRef ? { card: cardRef } : {}
39213
39341
  };
39214
39342
  const output = path3.join(outputFolderBits, `${b.bitType}.jsonc`);
39215
39343
  const str = JSON.stringify(bitJson, null, 2);
@@ -39219,7 +39347,7 @@ var ConfigBuilder = class {
39219
39347
  for (const g of groupConfigs2) {
39220
39348
  const tags2 = [];
39221
39349
  const groupKey = stringUtils.camelToKebab(g.key);
39222
- const tagEntriesTypeOrder = [
39350
+ const tagEntriesTypeOrder2 = [
39223
39351
  BitTagConfigKeyType.tag,
39224
39352
  BitTagConfigKeyType.property,
39225
39353
  BitTagConfigKeyType.resource,
@@ -39228,7 +39356,7 @@ var ConfigBuilder = class {
39228
39356
  const tagEntries = Object.entries(g.tags ?? []).sort((a, b) => {
39229
39357
  const tagA = a[1];
39230
39358
  const tagB = b[1];
39231
- const typeOrder = tagEntriesTypeOrder.indexOf(tagA.type) - tagEntriesTypeOrder.indexOf(tagB.type);
39359
+ const typeOrder = tagEntriesTypeOrder2.indexOf(tagA.type) - tagEntriesTypeOrder2.indexOf(tagB.type);
39232
39360
  return typeOrder;
39233
39361
  });
39234
39362
  for (const [_tagKey, tag] of tagEntries) {
@@ -39276,6 +39404,15 @@ var ConfigBuilder = class {
39276
39404
  }
39277
39405
  };
39278
39406
  writeGroupConfigs(groupConfigs);
39407
+ const writeCardConfigs = () => {
39408
+ for (const cardSetKey of Object.keys(CARDSETS)) {
39409
+ const cardJson = serializeCardSet(cardSetKey);
39410
+ if (!cardJson) continue;
39411
+ const output = path3.join(outputFolderCards, `${cardJson.key}.jsonc`);
39412
+ const str = JSON.stringify(cardJson, null, 2);
39413
+ fileWrites.push(fs3.writeFile(output, str));
39414
+ }
39415
+ };
39279
39416
  const writeBitsAsGroupConfigs = (bitsAsGroupConfigs) => {
39280
39417
  for (const b of bitsAsGroupConfigs) {
39281
39418
  const groupKey = `group-${b.bitType}`;
@@ -39292,13 +39429,6 @@ var ConfigBuilder = class {
39292
39429
  });
39293
39430
  }
39294
39431
  }
39295
- const tagEntriesTypeOrder = [
39296
- BitTagConfigKeyType.tag,
39297
- BitTagConfigKeyType.property,
39298
- BitTagConfigKeyType.resource,
39299
- BitTagConfigKeyType.group,
39300
- BitTagConfigKeyType.unknown
39301
- ];
39302
39432
  const tagEntries = Object.entries(b.tags ?? []).sort((a, b2) => {
39303
39433
  const tagA = a[1];
39304
39434
  const tagB = b2[1];
@@ -39329,6 +39459,7 @@ var ConfigBuilder = class {
39329
39459
  }
39330
39460
  };
39331
39461
  writeBitsAsGroupConfigs(bitGroupConfigs);
39462
+ writeCardConfigs();
39332
39463
  Promise.all(fileWrites).then(() => {
39333
39464
  const validationErrors = this.validateConfigTree(outputFolder);
39334
39465
  if (validationErrors.length > 0) {
@@ -39354,6 +39485,7 @@ var ConfigBuilder = class {
39354
39485
  const errors = [];
39355
39486
  const outputFolderBits = path3.join(outputFolder, "bits");
39356
39487
  const outputFolderGroups = path3.join(outputFolder, "partials");
39488
+ const outputFolderCards = path3.join(outputFolder, "cards");
39357
39489
  const availableGroups = /* @__PURE__ */ new Set();
39358
39490
  if (fs3.existsSync(outputFolderGroups)) {
39359
39491
  const groupFiles = fs3.readdirSync(outputFolderGroups).filter((f) => f.endsWith(".jsonc"));
@@ -39362,16 +39494,22 @@ var ConfigBuilder = class {
39362
39494
  availableGroups.add(groupName);
39363
39495
  }
39364
39496
  }
39497
+ const availableCards = /* @__PURE__ */ new Set();
39498
+ const cardFiles = fs3.existsSync(outputFolderCards) ? fs3.readdirSync(outputFolderCards).filter((f) => f.endsWith(".jsonc")) : [];
39499
+ for (const file of cardFiles) {
39500
+ const cardName = file.replace(".jsonc", "");
39501
+ availableCards.add(cardName);
39502
+ }
39365
39503
  const checkTags = (tags2, filePath, lineOffset) => {
39366
39504
  for (let i = 0; i < tags2.length; i++) {
39367
39505
  const tag = tags2[i];
39368
- if (tag.type === "group") {
39506
+ if (tag?.type === "group" && tag.key) {
39369
39507
  if (!availableGroups.has(tag.key)) {
39370
39508
  const line = lineOffset + i + 1;
39371
39509
  errors.push(`Missing group reference '${tag.key}' in ${filePath}:${line}`);
39372
39510
  }
39373
39511
  }
39374
- if (tag.tags && Array.isArray(tag.tags)) {
39512
+ if (Array.isArray(tag?.tags)) {
39375
39513
  checkTags(tag.tags, filePath, lineOffset + i + 1);
39376
39514
  }
39377
39515
  }
@@ -39386,6 +39524,27 @@ var ConfigBuilder = class {
39386
39524
  if (config.tags && Array.isArray(config.tags)) {
39387
39525
  checkTags(config.tags, `bits/${file}`, 15);
39388
39526
  }
39527
+ if (typeof config.card === "string") {
39528
+ if (!availableCards.has(config.card)) {
39529
+ errors.push(`Missing card file '${config.card}' referenced in bits/${file}`);
39530
+ }
39531
+ } else if (config.card?.sides && Array.isArray(config.card.sides)) {
39532
+ config.card.sides.forEach((side, sideIdx) => {
39533
+ const variants = side.variants;
39534
+ if (Array.isArray(variants)) {
39535
+ variants.forEach((variant, variantIdx) => {
39536
+ const variantTags = variant.tags;
39537
+ if (Array.isArray(variantTags)) {
39538
+ checkTags(
39539
+ variantTags,
39540
+ `bits/${file} (card side ${sideIdx}, variant ${variantIdx})`,
39541
+ 15
39542
+ );
39543
+ }
39544
+ });
39545
+ }
39546
+ });
39547
+ }
39389
39548
  } catch (err) {
39390
39549
  errors.push(`Failed to parse ${file}: ${err}`);
39391
39550
  }
@@ -39406,6 +39565,38 @@ var ConfigBuilder = class {
39406
39565
  }
39407
39566
  }
39408
39567
  }
39568
+ if (cardFiles.length > 0) {
39569
+ for (const file of cardFiles) {
39570
+ const filePath = path3.join(outputFolderCards, file);
39571
+ try {
39572
+ const content = fs3.readFileSync(filePath, "utf-8");
39573
+ const config = JSON.parse(content);
39574
+ const expectedKey = file.replace(".jsonc", "");
39575
+ if (config.key && config.key !== expectedKey) {
39576
+ errors.push(`Card key mismatch in cards/${file}: expected '${expectedKey}'`);
39577
+ }
39578
+ if (Array.isArray(config.sides)) {
39579
+ config.sides.forEach((side, sideIdx) => {
39580
+ const variants = side.variants;
39581
+ if (Array.isArray(variants)) {
39582
+ variants.forEach((variant, variantIdx) => {
39583
+ const variantTags = variant.tags;
39584
+ if (Array.isArray(variantTags)) {
39585
+ checkTags(
39586
+ variantTags,
39587
+ `cards/${file} (side ${sideIdx}, variant ${variantIdx})`,
39588
+ 10
39589
+ );
39590
+ }
39591
+ });
39592
+ }
39593
+ });
39594
+ }
39595
+ } catch (err) {
39596
+ errors.push(`Failed to parse cards/${file}: ${err}`);
39597
+ }
39598
+ }
39599
+ }
39409
39600
  return errors;
39410
39601
  }
39411
39602
  // Build flat bit configs
@@ -39500,6 +39691,11 @@ var ConfigBuilder = class {
39500
39691
  for (const [_tagKey, tag] of tagEntries) {
39501
39692
  tags2.push(...processTagEntries(tag));
39502
39693
  }
39694
+ let cardRef;
39695
+ const cardSetKey = b.cardSet?.configKey;
39696
+ if (cardSetKey && CARDSETS[cardSetKey]) {
39697
+ cardRef = normalizeCardKey(cardSetKey);
39698
+ }
39503
39699
  const bitJson = {
39504
39700
  name: b.bitType,
39505
39701
  description: "",
@@ -39517,7 +39713,8 @@ var ConfigBuilder = class {
39517
39713
  footerAllowed: b.footerAllowed ?? true,
39518
39714
  footerRequired: b.footerRequired ?? false,
39519
39715
  resourceAttachmentAllowed: b.resourceAttachmentAllowed ?? true,
39520
- tags: tags2
39716
+ tags: tags2,
39717
+ ...cardRef ? { card: cardRef } : {}
39521
39718
  };
39522
39719
  const output = path3.join(outputFolderBits, `${b.bitType}.jsonc`);
39523
39720
  const str = JSON.stringify(bitJson, null, 2);