1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
//! # Bundle Configuration.
//!
//! Define basic characteristics of a bundle, like its name, type, and version.
//!
//! The Information Property List file associated with a bundle tells you how to interpret
//! the bundle’s contents. The file describes fundamental features, like whether the
//! bundle contains an app, a framework, or something else. It also includes identifying
//! characteristics of the bundle, like an identifier, a human-readable name, and a
//! version.
//!
//! ## Framework
//! * Bundle Resources

use crate::{serialize_enum_option, serialize_vec_enum_option};
use serde::{Deserialize, Serialize};

/// Categorization
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Default)]
pub struct Categorization {
    /// The type of bundle.
    ///
    /// This key consists of a four-letter code for the bundle type.
    /// For apps, the code is APPL, for frameworks, it's FMWK, and for bundles,
    /// it's BNDL. The default value is derived from the bundle extension or,
    /// if it can't be derived, the default value is BNDL.
    ///
    /// ## Availability
    /// * iOS 2.0+
    /// * macOS 10.0+
    /// * tvOS 9.0+
    /// * watchOS 2.0+
    ///
    /// ## Framework
    /// Core Foundation
    #[serde(
        rename = "CFBundlePackageType",
        skip_serializing_if = "Option::is_none"
    )]
    pub bundle_package_type: Option<String>,
    /// The category that best describes your app for the App Store.
    ///
    /// ## Availability
    /// * macOS 10.0+
    ///
    /// ## Framework
    /// Core Services
    #[serde(
        rename = "LSApplicationCategoryType",
        skip_serializing_if = "Option::is_none",
        serialize_with = "serialize_enum_option"
    )]
    pub application_category_type: Option<AppCategoryType>,
}

/// Identification
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Default)]
pub struct Identification {
    /// A unique identifier for a bundle.
    ///
    /// A bundle ID uniquely identifies a single app throughout the system.
    /// The bundle ID string must contain only alphanumeric characters (A-Z, a-z, and
    /// 0-9), hyphens (-), and periods (.). The string should be in reverse-DNS
    /// format. Bundle IDs are case sensitive.
    ///
    /// ## Availability
    /// * iOS 2.0+
    /// * macOS 10.0+
    /// * tvOS 9.0+
    /// * watchOS 2.0+
    ///
    /// ## Framework
    /// Core Foundation
    #[serde(rename = "CFBundleIdentifier")]
    pub bundle_identifier: String,
    /// The bundle ID of the watchOS app.
    ///
    /// This key is automatically included in your WatchKit extension’s
    /// information property list when you create a watchOS project from a template.
    ///
    /// ## Availability
    /// * watchOS 2.0+
    ///
    /// ## Framework
    /// * WatchKit
    #[serde(
        rename = "WKAppBundleIdentifier",
        skip_serializing_if = "Option::is_none"
    )]
    pub app_bundle_identifier: Option<String>,
    /// The bundle ID of the watchOS app’s companion iOS app.
    ///
    /// Xcode automatically includes this key in the WatchKit app’s information
    /// property list when you create a watchOS project from a template.
    /// The value should be the same as the iOS app’s CFBundleIdentifier.
    ///
    /// ## Availability
    /// * watchOS 2.0+
    ///
    /// ## Framework
    /// * WatchKit
    #[serde(
        rename = "WKCompanionAppBundleIdentifier",
        skip_serializing_if = "Option::is_none"
    )]
    pub companion_app_bundle_identifier: Option<String>,
}

/// Naming
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Default)]
pub struct Naming {
    /// A user-visible short name for the bundle.
    ///
    /// This name can contain up to 15 characters. The system may display
    /// it to users if CFBundleDisplayName isn't set.
    ///
    /// ## Availability
    /// * iOS 2.0+
    /// * macOS 10.0+
    /// * tvOS 9.0+
    /// * watchOS 2.0+
    ///
    /// ## Framework
    /// Core Foundation
    #[serde(rename = "CFBundleName")]
    pub bundle_name: Option<String>,
    /// The user-visible name for the bundle, used by Siri and visible on the iOS Home
    /// screen.
    ///
    /// Use this key if you want a product name that's longer than CFBundleName.
    ///
    /// ## Availability
    /// * iOS 2.0+
    /// * macOS 10.0+
    /// * tvOS 9.0+
    /// * watchOS 2.0+
    ///
    /// ## Framework
    /// Core Foundation
    #[serde(
        rename = "CFBundleDisplayName",
        skip_serializing_if = "Option::is_none"
    )]
    pub bundle_display_name: Option<String>,
    /// A replacement for the app name in text-to-speech operations.
    ///
    /// ## Availability
    /// * iOS 2.0+
    /// * macOS 10.0+
    /// * tvOS 9.0+
    /// * watchOS 2.0+
    ///
    /// ## Framework
    /// Core Foundation
    #[serde(rename = "CFBundleSpokenName", skip_serializing_if = "Option::is_none")]
    pub bundle_spoken_name: Option<String>,
}

/// Bundle Version
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Default)]
pub struct BundleVersion {
    /// The version of the build that identifies an iteration of the bundle.
    ///
    /// This key is a machine-readable string composed of one to three period-separated
    /// integers, such as 10.14.1. The string can only contain numeric characters
    /// (0-9) and periods.
    ///
    /// Each integer provides information about the build version in the format
    /// \[Major\].\[Minor\].\[Patch\]:
    /// - Major: A major revision number.
    /// - Minor: A minor revision number.
    /// - Patch: A maintenance release number.
    ///
    /// You can include more integers but the system ignores them.
    /// You can also abbreviate the build version by using only one or two integers,
    /// where missing integers in the format are interpreted as zeros.
    /// For example, 0 specifies 0.0.0, 10 specifies 10.0.0, and 10.5 specifies 10.5.0.
    /// This key is required by the App Store and is used throughout the system to
    /// identify the version of the build. For macOS apps, increment the build version
    /// before you distribute a build.
    ///
    /// ## Availability
    /// * iOS 2.0+
    /// * macOS 10.0+
    /// * tvOS 9.0+
    /// * watchOS 2.0+
    ///
    /// ## Framework
    /// Core Foundation
    #[serde(rename = "CFBundleVersion", skip_serializing_if = "Option::is_none")]
    pub bundle_version: Option<String>,
    /// The release or version number of the bundle.
    ///
    /// This key is a user-visible string for the version of the bundle. The required
    /// format is three period-separated integers, such as 10.14.1. The string can
    /// only contain numeric characters (0-9) and periods.
    ///
    /// Each integer provides information about the release in the format
    /// \[Major\].\[Minor\].\[Patch\]:
    /// - Major: A major revision number.
    /// - Minor: A minor revision number.
    /// - Patch: A maintenance release number.
    ///
    /// This key is used throughout the system to identify the version of the bundle.
    ///
    /// ## Availability
    /// * iOS 2.0+
    /// * macOS 10.0+
    /// * tvOS 9.0+
    /// * watchOS 2.0+
    ///
    /// ## Framework
    /// Core Foundation
    #[serde(
        rename = "CFBundleShortVersionString",
        skip_serializing_if = "Option::is_none"
    )]
    pub bundle_short_version_string: Option<String>,
    /// The current version of the Information Property List structure.
    ///
    /// Xcode adds this key automatically. Don’t change the value.
    ///
    /// ## Availability
    /// * iOS 2.0+
    /// * macOS 10.0+
    /// * tvOS 9.0+
    /// * watchOS 2.0+
    ///
    /// ## Framework
    /// Core Foundation
    #[serde(
        rename = "CFBundleInfoDictionaryVersion",
        skip_serializing_if = "Option::is_none"
    )]
    pub bundle_info_dictionary_version: Option<String>,
    /// A human-readable copyright notice for the bundle.
    ///
    /// ## Availability
    /// * macOS 10.0+
    ///
    /// ## Framework
    /// * Foundation
    #[serde(
        rename = "NSHumanReadableCopyright",
        skip_serializing_if = "Option::is_none"
    )]
    pub human_readable_copyright: Option<String>,
}

/// Operating System Version
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Default)]
pub struct OperatingSystemVersion {
    /// The minimum operating system version required for the app to run.
    ///
    /// The Mac App Store uses this key to indicate the OS releases on
    /// which your app can run and show compatibility with the user’s Mac.
    ///
    /// ## Availability
    /// * macOS 10.0+
    ///
    /// ## Framework
    /// * Core Services
    #[serde(
        rename = "LSMinimumSystemVersion",
        skip_serializing_if = "Option::is_none"
    )]
    pub minimum_system_version: Option<String>,
    /// The minimum version of macOS required for the app to run on a set of
    /// architectures.
    ///
    /// ## Availability
    /// * macOS 10.0+
    ///
    /// ## Framework
    /// * Core Services
    #[serde(
        rename = "LSMinimumSystemVersionByArchitecture",
        skip_serializing_if = "Option::is_none"
    )]
    pub minimum_system_version_by_architecture: Option<MinimumSystemVersionByArchitecture>,
    /// The minimum operating system version required for the app to run on iOS, tvOS, and
    /// watchOS.
    ///
    /// The App Store uses this key to indicate the OS releases on which your app can run.
    ///
    /// ## Availability
    /// * macOS 3.0+
    /// * tvOS 9.0+
    /// * watchOS 2.0+
    ///
    /// ## Framework
    /// * Core Services
    #[serde(rename = "MinimumOSVersion", skip_serializing_if = "Option::is_none")]
    pub minimum_os_version: Option<String>,
    /// A Boolean value indicating whether the app must run in iOS.
    ///
    /// ## Availability
    /// * iOS 12.0+
    ///
    /// ## Framework
    /// * Core Services
    #[serde(rename = "LSRequiresIPhoneOS", skip_serializing_if = "Option::is_none")]
    pub requires_iphone_os: Option<bool>,
    /// A Boolean value that indicates whether the bundle is a watchOS app.
    ///
    /// Xcode automatically includes this key in the WatchKit app’s information
    /// property list when you create a watchOS project from a template.
    ///
    /// ## Availability
    /// * watchOS 2.0+
    ///
    /// ## Framework
    /// * WatchKit
    #[serde(rename = "WKWatchKitApp", skip_serializing_if = "Option::is_none")]
    pub watch_kit_app: Option<bool>,
}

/// Localization
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Default)]
pub struct Localization {
    /// The default language and region for the bundle, as a language ID.
    ///
    /// The system uses this key as the language if it can't locate a resource for the
    /// user’s preferred language. The value should be a language ID that identifies a
    /// language, dialect, or script.
    ///
    /// To distinguish between different languages and regional dialects, use a language
    /// designator with a region designator and a script designator separated by
    /// hyphens. To specify the English language as it's used in the United Kingdom,
    /// use en-GB, where GB is the region designator. To represent Mandarin Chinese,
    /// spoken in Taiwan, and written in Traditional Chinese script, use zh-Hant-TW.
    ///
    /// To specify a script, combine a language designator with a script designator
    /// separated by a hyphen, as in az-Arab for Azerbaijani in the Arabic script.
    ///
    /// ## Availability
    /// * iOS 2.0+
    /// * macOS 10.0+
    /// * tvOS 9.0+
    /// * watchOS 2.0+
    ///
    /// ## Framework
    /// Core Foundation
    #[serde(
        rename = "CFBundleDevelopmentRegion",
        skip_serializing_if = "Option::is_none"
    )]
    pub bundle_development_region: Option<String>,
    /// The localizations handled manually by your app.
    ///
    /// ## Availability
    /// * iOS 2.0+
    /// * macOS 10.0+
    /// * tvOS 9.0+
    /// * watchOS 2.0+
    ///
    /// ## Framework
    /// Core Foundation
    #[serde(
        rename = "CFBundleLocalizations",
        skip_serializing_if = "Option::is_none",
        serialize_with = "serialize_vec_enum_option"
    )]
    pub bundle_localizations: Option<Vec<BundleLocalizations>>,
    /// A Boolean value that indicates whether the bundle supports the retrieval of
    /// localized strings from frameworks.
    ///
    /// ## Availability
    /// * iOS 2.0+
    /// * macOS 10.0+
    /// * tvOS 9.0+
    /// * watchOS 2.0+
    ///
    /// ## Framework
    /// Core Foundation
    #[serde(
        rename = "CFBundleAllowMixedLocalizations",
        skip_serializing_if = "Option::is_none"
    )]
    pub bundle_allow_mixed_localizations: Option<bool>,
    /// A Boolean value that enables the Caps Lock key to switch between Latin and
    /// non-Latin input sources.
    ///
    /// Latin input sources, such as ABC, U.S., and Vietnamese, output characters in Latin
    /// script. Non-Latin input sources, such as Bulgarian (Cyrillic script), Hindi
    /// (Devanagari script), and Urdu (Arabic script), output characters in scripts
    /// other than Latin.
    ///
    /// After implementing the key, users can enable or disable this functionality by
    /// modifying the “Use Caps Lock to switch to and from” preference, which can be
    /// found in System Preferences > Keyboard > Input Sources.
    ///
    /// ## Availability
    /// * macOS 10.15+
    ///
    /// ## Framework
    /// * AppKit
    #[serde(
        rename = "TICapsLockLanguageSwitchCapable",
        skip_serializing_if = "Option::is_none"
    )]
    pub caps_lock_language_switch_capable: Option<bool>,
}

/// Help
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Default)]
pub struct Help {
    /// The name of the bundle’s HTML help file.
    ///
    /// ## Availability
    /// * macOS 10.0+
    ///
    /// ## Framework
    /// * Core Foundation
    #[serde(rename = "CFAppleHelpAnchor", skip_serializing_if = "Option::is_none")]
    pub apple_help_anchor: Option<String>,
    /// The name of the help file that will be opened in Help Viewer.
    ///
    /// ## Availability
    /// * macOS 10.0+
    ///
    /// ## Framework
    /// * Core Foundation
    #[serde(
        rename = "CFBundleHelpBookName",
        skip_serializing_if = "Option::is_none"
    )]
    pub bundle_help_book_name: Option<String>,
    /// The name of the folder containing the bundle’s help files.
    ///
    /// ## Availability
    /// * macOS 10.0+
    ///
    /// ## Framework
    /// * Core Foundation
    #[serde(
        rename = "CFBundleHelpBookFolder",
        skip_serializing_if = "Option::is_none"
    )]
    pub bundle_help_book_folder: Option<String>,
}

/// App Category Type
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
pub enum AppCategoryType {
    #[serde(rename = "public.app-category.business")]
    Business,
    #[serde(rename = "public.app-category.developer-tools")]
    DeveloperTools,
    #[serde(rename = "public.app-category.education")]
    Education,
    #[serde(rename = "public.app-category.entertainment")]
    Entertainment,
    #[serde(rename = "public.app-category.finance")]
    Finance,
    #[serde(rename = "public.app-category.games")]
    Games,
    #[serde(rename = "public.app-category.action-games")]
    ActionGames,
    #[serde(rename = "public.app-category.adventure-games")]
    AdventureGames,
    #[serde(rename = "public.app-category.arcade-games")]
    ArcadeGames,
    #[serde(rename = "public.app-category.board-games")]
    BoardGames,
    #[serde(rename = "public.app-category.card-games")]
    CardGames,
    #[serde(rename = "public.app-category.casino-games")]
    CasinoGames,
    #[serde(rename = "public.app-category.dice-games")]
    DiceGames,
    #[serde(rename = "public.app-category.educational-games")]
    EducationalGames,
    #[serde(rename = "public.app-category.family-games")]
    FamilyGames,
    #[serde(rename = "public.app-category.kids-games")]
    KidsGames,
    #[serde(rename = "public.app-category.music-games")]
    MusicGames,
    #[serde(rename = "public.app-category.puzzle-games")]
    PuzzleGames,
    #[serde(rename = "public.app-category.racing-games")]
    RacingGames,
    #[serde(rename = "public.app-category.role-playing-games")]
    RolePlayingGames,
    #[serde(rename = "public.app-category.simulation-games")]
    SimulationGames,
    #[serde(rename = "public.app-category.sports-games")]
    SportsGames,
    #[serde(rename = "public.app-category.strategy-games")]
    StrategyGames,
    #[serde(rename = "public.app-category.trivia-games")]
    TriviaGames,
    #[serde(rename = "public.app-category.word-games")]
    WordGames,
    #[serde(rename = "public.app-category.graphics-design")]
    GraphicsDesign,
    #[serde(rename = "public.app-category.healthcare-fitness")]
    HealthcareFitness,
    #[serde(rename = "public.app-category.lifestyle")]
    Lifestyle,
    #[serde(rename = "public.app-category.medical")]
    Medical,
    #[serde(rename = "public.app-category.music")]
    Music,
    #[serde(rename = "public.app-category.news")]
    News,
    #[serde(rename = "public.app-category.photography")]
    Photography,
    #[serde(rename = "public.app-category.productivity")]
    Productivity,
    #[serde(rename = "public.app-category.reference")]
    Reference,
    #[serde(rename = "public.app-category.social-networking")]
    SocialNetworking,
    #[serde(rename = "public.app-category.sports")]
    Sports,
    #[serde(rename = "public.app-category.travel")]
    Travel,
    #[serde(rename = "public.app-category.utilities")]
    Utilities,
    #[serde(rename = "public.app-category.video")]
    Video,
    #[serde(rename = "public.app-category.weather")]
    Weather,
}

/// Operating System Version
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
pub struct MinimumSystemVersionByArchitecture {
    pub i386: String,
    pub ppc: String,
    pub ppc64: String,
    pub x86_64: String,
}

impl Default for MinimumSystemVersionByArchitecture {
    fn default() -> Self {
        Self {
            i386: "10.0.0".to_owned(),
            ppc: "10.0.0".to_owned(),
            ppc64: "10.0.0".to_owned(),
            x86_64: "10.0.0".to_owned(),
        }
    }
}

/// Bundle Localizations
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
pub enum BundleLocalizations {
    #[serde(rename = "zh")]
    Zh,
    #[serde(rename = "zh_CN")]
    ZhCn,
    #[serde(rename = "zh_TW")]
    ZhTw,
    #[serde(rename = "en")]
    En,
    #[serde(rename = "fr")]
    Fr,
    #[serde(rename = "de")]
    De,
    #[serde(rename = "it")]
    It,
    #[serde(rename = "ja")]
    Ja,
    #[serde(rename = "ko")]
    Ko,
}