@balena/open-balena-api 38.0.0-build-enum-fields-cf3d6c91975bdced3520c32518d1a53195e913cb-1 → 38.0.0-build-Limit-size-ofl-arge-fields-7b29e06f8391501d61a8512e197634ceadfa93c5-1
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/balena-model.d.ts +6 -6
- package/dist/balena.sbvr +89 -8
- package/dist/features/device-state/middleware.d.ts +8 -1
- package/dist/features/device-state/middleware.js +16 -9
- package/dist/features/device-state/middleware.js.map +1 -1
- package/dist/features/device-state/routes/state-get-v3.d.ts +2 -2
- package/dist/features/device-state/routes/state-patch-v2.js +2 -2
- package/dist/features/device-state/routes/state-patch-v2.js.map +1 -1
- package/dist/features/device-state/routes/state-patch-v3.js +2 -2
- package/dist/features/device-state/routes/state-patch-v3.js.map +1 -1
- package/dist/features/device-state/state-patch-utils.d.ts +2 -2
- package/dist/features/device-state/state-patch-utils.js +18 -11
- package/dist/features/device-state/state-patch-utils.js.map +1 -1
- package/dist/features/field-size-limits/hooks.d.ts +1 -0
- package/dist/features/field-size-limits/hooks.js +24 -0
- package/dist/features/field-size-limits/hooks.js.map +1 -0
- package/dist/features/field-size-limits/setup-field-size-limits.d.ts +4 -0
- package/dist/features/field-size-limits/setup-field-size-limits.js +37 -0
- package/dist/features/field-size-limits/setup-field-size-limits.js.map +1 -0
- package/dist/hooks.d.ts +1 -0
- package/dist/hooks.js +1 -0
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/migrations/00103-extend-device-ip-address-mac-address-fields.sql +52 -0
- package/dist/migrations/00105-add-size-constraints-to-text-fields.sql +719 -0
- package/package.json +2 -2
- /package/dist/migrations/{00103-add-check-constraints-enum-fields.sql → 00104-add-check-constraints-enum-fields.sql} +0 -0
package/dist/balena-model.d.ts
CHANGED
@@ -466,7 +466,7 @@ export interface ServiceInstance {
|
|
466
466
|
modified_at: Types['Date Time']['Read'];
|
467
467
|
id: Types['Serial']['Read'];
|
468
468
|
service_type: Types['Short Text']['Read'];
|
469
|
-
ip_address: Types['
|
469
|
+
ip_address: Types['Text']['Read'];
|
470
470
|
last_heartbeat: Types['Date Time']['Read'];
|
471
471
|
manages__device?: Array<Device['Read']>;
|
472
472
|
};
|
@@ -475,7 +475,7 @@ export interface ServiceInstance {
|
|
475
475
|
modified_at: Types['Date Time']['Write'];
|
476
476
|
id: Types['Serial']['Write'];
|
477
477
|
service_type: Types['Short Text']['Write'];
|
478
|
-
ip_address: Types['
|
478
|
+
ip_address: Types['Text']['Write'];
|
479
479
|
last_heartbeat: Types['Date Time']['Write'];
|
480
480
|
};
|
481
481
|
}
|
@@ -703,8 +703,8 @@ export interface Device {
|
|
703
703
|
last_vpn_event: Types['Date Time']['Read'] | null;
|
704
704
|
is_locked_until__date: Types['Date Time']['Read'] | null;
|
705
705
|
public_address: Types['Short Text']['Read'] | null;
|
706
|
-
ip_address: Types['
|
707
|
-
mac_address: Types['
|
706
|
+
ip_address: Types['Text']['Read'] | null;
|
707
|
+
mac_address: Types['Text']['Read'] | null;
|
708
708
|
memory_usage: Types['Integer']['Read'] | null;
|
709
709
|
memory_total: Types['Integer']['Read'] | null;
|
710
710
|
storage_block_device: Types['Short Text']['Read'] | null;
|
@@ -785,8 +785,8 @@ export interface Device {
|
|
785
785
|
last_vpn_event: Types['Date Time']['Write'] | null;
|
786
786
|
is_locked_until__date: Types['Date Time']['Write'] | null;
|
787
787
|
public_address: Types['Short Text']['Write'] | null;
|
788
|
-
ip_address: Types['
|
789
|
-
mac_address: Types['
|
788
|
+
ip_address: Types['Text']['Write'] | null;
|
789
|
+
mac_address: Types['Text']['Write'] | null;
|
790
790
|
memory_usage: Types['Integer']['Write'] | null;
|
791
791
|
memory_total: Types['Integer']['Write'] | null;
|
792
792
|
storage_block_device: Types['Short Text']['Write'] | null;
|
package/dist/balena.sbvr
CHANGED
@@ -41,6 +41,7 @@ Term: user
|
|
41
41
|
Concept Type: actor
|
42
42
|
Fact type: user has username
|
43
43
|
Necessity: Each user has exactly one username.
|
44
|
+
Necessity: Each user has a username that has a Length (Type) that is less than or equal to 73.
|
44
45
|
Necessity: Each username is of exactly one user.
|
45
46
|
Fact type: user has password
|
46
47
|
Necessity: Each user has at most one password.
|
@@ -69,8 +70,12 @@ Fact type: api key is of actor
|
|
69
70
|
Necessity: each api key is of exactly one actor
|
70
71
|
Fact type: api key has name
|
71
72
|
Necessity: Each api key has at most one name.
|
73
|
+
-- TODO: Pitch cleanup and reduce to 50
|
74
|
+
Necessity: each api key has a name that has a Length (Type) that is less than or equal to 1564.
|
72
75
|
Fact type: api key has description
|
73
76
|
Necessity: Each api key has at most one description.
|
77
|
+
-- TODO: Pitch cleanup and reduce to 150
|
78
|
+
Necessity: each api key has a description that has a Length (Type) that is less than or equal to 1244.
|
74
79
|
|
75
80
|
|
76
81
|
Vocabulary: balena
|
@@ -158,7 +163,7 @@ Term: invalidation reason
|
|
158
163
|
Concept Type: Text (Type)
|
159
164
|
|
160
165
|
Term: ip address
|
161
|
-
Concept Type:
|
166
|
+
Concept Type: Text (Type)
|
162
167
|
|
163
168
|
Term: known issue list
|
164
169
|
Concept Type: Text (Type)
|
@@ -185,7 +190,7 @@ Term: logo
|
|
185
190
|
Concept Type: Text (Type)
|
186
191
|
|
187
192
|
Term: mac address
|
188
|
-
Concept Type:
|
193
|
+
Concept Type: Text (Type)
|
189
194
|
|
190
195
|
Term: memory usage
|
191
196
|
Concept Type: Integer (Type)
|
@@ -353,6 +358,7 @@ Term: application
|
|
353
358
|
Fact type: application has service name
|
354
359
|
Term Form: service
|
355
360
|
Database Table Name: service
|
361
|
+
Necessity: each service has a service name that has a Length (Type) that is greater than 0 and is less than or equal to 63.
|
356
362
|
|
357
363
|
Fact type: service has label name
|
358
364
|
Term Form: service label
|
@@ -365,7 +371,7 @@ Term: application
|
|
365
371
|
Fact type: application has tag key
|
366
372
|
Term Form: application tag
|
367
373
|
Database Table Name: application tag
|
368
|
-
Necessity: each application tag has a tag key that has a Length (Type) that is greater than 0.
|
374
|
+
Necessity: each application tag has a tag key that has a Length (Type) that is greater than 0 and is less than or equal to 100.
|
369
375
|
|
370
376
|
Term: device
|
371
377
|
Concept Type: actor (Auth)
|
@@ -402,14 +408,15 @@ Term: device
|
|
402
408
|
Fact type: device has tag key
|
403
409
|
Term Form: device tag
|
404
410
|
Database Table Name: device tag
|
405
|
-
Necessity: each device tag has a tag key that has a Length (Type) that is greater than 0.
|
411
|
+
Necessity: each device tag has a tag key that has a Length (Type) that is greater than 0 and is less than or equal to 100.
|
406
412
|
|
407
413
|
Term: release
|
408
414
|
|
409
415
|
Fact type: release has tag key
|
410
416
|
Term Form: release tag
|
411
417
|
Database Table Name: release tag
|
412
|
-
|
418
|
+
-- TODO: Pitch cleanup and reduce to 100
|
419
|
+
Necessity: each release tag has a tag key that has a Length (Type) that is greater than 0 and is less than or equal to 164.
|
413
420
|
|
414
421
|
Fact type: image is part of release
|
415
422
|
Synonymous Form: release contains image
|
@@ -433,46 +440,54 @@ Fact type: user (Auth) is member of organization
|
|
433
440
|
|
434
441
|
Fact type: organization has name (Auth)
|
435
442
|
Necessity: each organization has exactly one name (Auth).
|
436
|
-
|
443
|
+
-- TODO: Pitch cleanup and reduce to 100
|
444
|
+
Necessity: each name (Auth) of an organization, has a Length (Type) that is greater than 0 and is less than or equal to 220.
|
437
445
|
Fact type: organization has handle
|
438
446
|
Necessity: each organization has exactly one handle.
|
439
447
|
Necessity: each handle is of exactly one organization.
|
440
|
-
|
448
|
+
-- TODO: Pitch cleanup and reduce to 100
|
449
|
+
Necessity: each handle of an organization, has a Length (Type) that is greater than 0 and is less than or equal to 220.
|
441
450
|
|
442
451
|
|
443
452
|
-- user
|
444
453
|
|
445
454
|
Fact type: user (Auth) has email
|
446
455
|
Necessity: each user (Auth) has at most one email.
|
447
|
-
Necessity: each user (Auth) that has an email, has an email that has a Length (Type) that is greater than 4.
|
456
|
+
Necessity: each user (Auth) that has an email, has an email that has a Length (Type) that is greater than 4 and is less than or equal to 254.
|
448
457
|
Necessity: each email is of exactly one user (Auth).
|
449
458
|
|
450
459
|
Fact type: user (Auth) has public key
|
451
460
|
Term Form: user public key
|
461
|
+
Necessity: each user public key has a public key that has a Length (Type) that is less than or equal to 2850.
|
452
462
|
|
453
463
|
|
454
464
|
-- user public key
|
455
465
|
|
456
466
|
Fact type: user public key has title
|
457
467
|
Necessity: each user public key has exactly one title
|
468
|
+
Necessity: each user public key has a title that has a Length (Type) that is less than or equal to 120.
|
458
469
|
|
459
470
|
|
460
471
|
-- application type
|
461
472
|
|
462
473
|
Fact type: application type has name (Auth)
|
463
474
|
Necessity: each application type has exactly one name (Auth)
|
475
|
+
Necessity: each application type has a name (Auth) that has a Length (Type) that is less than or equal to 20.
|
464
476
|
Fact type: application type supports web url
|
465
477
|
Fact type: application type supports multicontainer
|
466
478
|
Fact type: application type supports gateway mode
|
467
479
|
Fact type: application type needs os version range
|
468
480
|
Necessity: each application type needs at most one os version range
|
481
|
+
Necessity: each application type that needs an os version range, needs an os version range that has a Length (Type) that is less than or equal to 50.
|
469
482
|
Fact type: application type requires payment
|
470
483
|
Fact type: application type is legacy
|
471
484
|
Fact type: application type has slug
|
472
485
|
Necessity: each application type has exactly one slug
|
486
|
+
Necessity: each application type has a slug that has a Length (Type) that is less than or equal to 30.
|
473
487
|
Necessity: each slug is of exactly one application type
|
474
488
|
Fact type: application type has description (Auth)
|
475
489
|
Necessity: each application type has at most one description (Auth).
|
490
|
+
Necessity: each application type that has a description (Auth), has a description (Auth) that has a Length (Type) that is less than or equal to 200.
|
476
491
|
Fact type: application type has maximum device count
|
477
492
|
Necessity: each application type has at most one maximum device count
|
478
493
|
|
@@ -488,6 +503,8 @@ Fact type: application has app name
|
|
488
503
|
Fact type: application has slug
|
489
504
|
Necessity: each application has exactly one slug
|
490
505
|
Necessity: each slug is of exactly one application
|
506
|
+
-- handle size [1, 220] + '/' + name size [4, 100] => total slug size [6, 321]
|
507
|
+
Necessity: each application has a slug that has a Length (Type) that is greater than or equal to 6 and is less than or equal to 321.
|
491
508
|
Fact type: application is for device type
|
492
509
|
Synonymous Form: device type is default for application
|
493
510
|
Necessity: each application is for exactly one device type
|
@@ -511,6 +528,7 @@ Fact type: service instance has service type
|
|
511
528
|
Definition: "vpn"
|
512
529
|
Fact type: service instance has ip address
|
513
530
|
Necessity: each service instance has exactly one ip address.
|
531
|
+
Necessity: each service instance has an ip address that has a Length (Type) that is less than or equal to 39.
|
514
532
|
Fact type: service instance has last heartbeat
|
515
533
|
Necessity: each service instance has exactly one last heartbeat.
|
516
534
|
|
@@ -520,12 +538,16 @@ Fact type: service instance has last heartbeat
|
|
520
538
|
Fact type: device has uuid
|
521
539
|
Necessity: each device has exactly one uuid.
|
522
540
|
Necessity: each uuid is of exactly one device.
|
541
|
+
-- We enforce uuids to be 32 or 62 using a hook b/c of pre-existing data
|
542
|
+
Necessity: each device has a uuid that has a Length (Type) that is less than or equal to 62.
|
523
543
|
Fact type: device has local id
|
524
544
|
Necessity: each device has at most one local id.
|
525
545
|
Fact type: device has device name
|
526
546
|
Necessity: each device has exactly one device name.
|
527
547
|
Fact type: device has note
|
528
548
|
Necessity: each device has at most one note.
|
549
|
+
-- 1MB
|
550
|
+
Necessity: each device that has a note, has a note that has a Length (Type) that is less than or equal to 1000000.
|
529
551
|
Fact type: device is of device type
|
530
552
|
Synonymous Form: device type describes device
|
531
553
|
Necessity: each device is of exactly one device type.
|
@@ -542,10 +564,15 @@ Fact type: device is locked until date
|
|
542
564
|
Necessity: each device is locked until at most one date.
|
543
565
|
Fact type: device has public address
|
544
566
|
Necessity: each device has at most one public address
|
567
|
+
Necessity: each device that has a public address, has a public address that has a Length (Type) that is less than or equal to 50.
|
545
568
|
Fact type: device has ip address
|
546
569
|
Necessity: each device has at most one ip address
|
570
|
+
-- Enough to fit 50 IPv6 addresses (39 chars long) space delimited
|
571
|
+
Necessity: each device that has an ip address, has an ip address that has a Length (Type) that is less than or equal to 2000.
|
547
572
|
Fact type: device has mac address
|
548
573
|
Necessity: each device has at most one mac address
|
574
|
+
-- Enough to fit 50 MAC addresses (17 chars logs) space delimited
|
575
|
+
Necessity: each device that has a mac address, has a mac address that has a Length (Type) that is less than or equal to 900.
|
549
576
|
Fact type: device has memory usage
|
550
577
|
Necessity: each device has at most one memory usage
|
551
578
|
Fact type: device has memory total
|
@@ -571,13 +598,17 @@ Fact type: device has download progress
|
|
571
598
|
Necessity: each device has at most one download progress.
|
572
599
|
Fact type: device has status
|
573
600
|
Necessity: each device has at most one status.
|
601
|
+
-- TODO: Pitch changing this to an ENUM
|
602
|
+
Necessity: each device that has a status, has a status that has a Length (Type) that is less than or equal to 50.
|
574
603
|
Fact type: device has os version
|
575
604
|
Necessity: each device has at most one os version
|
605
|
+
Necessity: each device that has an os version, has an os version that has a Length (Type) that is less than or equal to 70.
|
576
606
|
Fact type: device has os variant
|
577
607
|
Necessity: each device has at most one os variant
|
578
608
|
Definition: "prod" or "dev"
|
579
609
|
Fact type: device has supervisor version
|
580
610
|
Necessity: each device has at most one supervisor version
|
611
|
+
Necessity: each device that has a supervisor version, has a supervisor version that has a Length (Type) that is less than or equal to 20.
|
581
612
|
Fact type: device has provisioning progress
|
582
613
|
Necessity: each device has at most one provisioning progress
|
583
614
|
Fact type: device has provisioning state
|
@@ -586,6 +617,7 @@ Fact type: device has api port
|
|
586
617
|
Necessity: each device has at most one api port
|
587
618
|
Fact type: device has api secret
|
588
619
|
Necessity: each device has at most one api secret
|
620
|
+
Necessity: each device that has an api secret, has an api secret that has a Length (Type) that is less than or equal to 64.
|
589
621
|
Fact type: device is managed by service instance
|
590
622
|
Synonymous Form: service instance manages device
|
591
623
|
Necessity: each device is managed by at most one service instance
|
@@ -613,12 +645,16 @@ Fact type: device has last update status event
|
|
613
645
|
|
614
646
|
Fact type: application config variable has value
|
615
647
|
Necessity: each application config variable has exactly one value.
|
648
|
+
-- TODO: Pitch cleanup and reduce to 100KB
|
649
|
+
Necessity: each application config variable has a value that has a Length (Type) that is less than or equal to 492001.
|
616
650
|
|
617
651
|
|
618
652
|
-- device config variable
|
619
653
|
|
620
654
|
Fact type: device config variable has value
|
621
655
|
Necessity: each device config variable has exactly one value.
|
656
|
+
-- TODO: Pitch cleanup and reduce to 100KB
|
657
|
+
Necessity: each device config variable has a value that has a Length (Type) that is less than or equal to 372340.
|
622
658
|
|
623
659
|
-- device type
|
624
660
|
|
@@ -636,6 +672,8 @@ Fact type: device type is of cpu architecture
|
|
636
672
|
|
637
673
|
Fact type: device type has logo
|
638
674
|
Necessity: each device type has at most one logo
|
675
|
+
-- 300KB in base64
|
676
|
+
Necessity: each device type that has a logo, has a logo that has a Length (Type) that is less than or equal to 400000.
|
639
677
|
|
640
678
|
Fact type: device type has contract
|
641
679
|
Necessity: each device type has at most one contract
|
@@ -661,17 +699,21 @@ Fact type: cpu architecture has slug
|
|
661
699
|
|
662
700
|
Fact type: device manufacturer has slug
|
663
701
|
Necessity: each device manufacturer has exactly one slug
|
702
|
+
Necessity: each device manufacturer has a slug that has a Length (Type) that is less than or equal to 50.
|
664
703
|
Necessity: each slug is of exactly one device manufacturer
|
665
704
|
Fact type: device manufacturer has name (Auth)
|
666
705
|
Necessity: each device manufacturer has exactly one name (Auth)
|
706
|
+
Necessity: each device manufacturer has a name (Auth) that has a Length (Type) that is less than or equal to 100.
|
667
707
|
|
668
708
|
-- device family
|
669
709
|
|
670
710
|
Fact type: device family has slug
|
671
711
|
Necessity: each device family has exactly one slug
|
712
|
+
Necessity: each device family has a slug that has a Length (Type) that is less than or equal to 50.
|
672
713
|
Necessity: each slug is of exactly one device family
|
673
714
|
Fact type: device family has name (Auth)
|
674
715
|
Necessity: each device family has exactly one name (Auth)
|
716
|
+
Necessity: each device family has a name (Auth) that has a Length (Type) that is less than or equal to 50.
|
675
717
|
Fact type: device family is manufactured by device manufacturer
|
676
718
|
Synonymous Form: device manufacturer manufactures device family
|
677
719
|
Necessity: each device family is manufactured by at most one device manufacturer
|
@@ -684,6 +726,7 @@ Fact type: release belongs to application
|
|
684
726
|
Necessity: each release belongs to exactly one application.
|
685
727
|
Fact type: release has commit
|
686
728
|
Necessity: each release has exactly one commit.
|
729
|
+
Necessity: each release has a commit that has a Length (Type) that is less than or equal to 40.
|
687
730
|
Fact type: release has composition
|
688
731
|
Necessity: each release has exactly one composition.
|
689
732
|
Fact type: release has status
|
@@ -695,6 +738,8 @@ Fact type: release has source
|
|
695
738
|
Definition: "cloud" or "local"
|
696
739
|
Fact type: release has build log
|
697
740
|
Necessity: each release has at most one build log.
|
741
|
+
-- 1MB
|
742
|
+
Necessity: each release that has a build log, has a build log that has a Length (Type) that is less than or equal to 1000000.
|
698
743
|
Fact type: release is invalidated
|
699
744
|
Fact type: release has start timestamp
|
700
745
|
Necessity: each release has exactly one start timestamp.
|
@@ -704,6 +749,7 @@ Fact type: release has update timestamp
|
|
704
749
|
Necessity: each release has exactly one update timestamp.
|
705
750
|
Fact type: release has release version
|
706
751
|
Necessity: each release has at most one release version
|
752
|
+
Necessity: each release that has a release version, has a release version that has a Length (Type) that is less than or equal to 81.
|
707
753
|
Note: Deprecated.
|
708
754
|
Fact type: release has contract
|
709
755
|
Necessity: each release has at most one contract
|
@@ -721,19 +767,26 @@ Fact type: release has semver patch
|
|
721
767
|
Necessity: each release has exactly one semver patch.
|
722
768
|
Fact type: release has semver prerelease
|
723
769
|
Necessity: each release has exactly one semver prerelease.
|
770
|
+
Necessity: each release has a semver prerelease that has a Length (Type) that is less than or equal to 100.
|
724
771
|
Fact type: release has semver build
|
725
772
|
Necessity: each release has exactly one semver build.
|
773
|
+
Necessity: each release has a semver build that has a Length (Type) that is less than or equal to 50.
|
726
774
|
Fact type: release has variant
|
727
775
|
Necessity: each release has exactly one variant.
|
776
|
+
Necessity: each release has a variant that has a Length (Type) that is less than or equal to 50.
|
728
777
|
Fact type: release has revision
|
729
778
|
Necessity: each release has at most one revision.
|
730
779
|
Necessity: each release that has a revision, has a revision that is greater than or equal to 0.
|
731
780
|
Fact type: release has known issue list
|
732
781
|
Necessity: each release has at most one known issue list.
|
782
|
+
Necessity: each release that has a known issue list, has a known issue list that has a Length (Type) that is less than or equal to 1000.
|
733
783
|
Fact type: release has note
|
734
784
|
Necessity: each release has at most one note.
|
785
|
+
-- 1MB
|
786
|
+
Necessity: each release that has a note, has a note that has a Length (Type) that is less than or equal to 1000000.
|
735
787
|
Fact type: release has invalidation reason
|
736
788
|
Necessity: each release has at most one invalidation reason.
|
789
|
+
Necessity: each release has an invalidation reason, has an invalidation reason that has a Length (Type) that is less than or equal to 255.
|
737
790
|
Necessity: each release that has an invalidation reason, is invalidated.
|
738
791
|
Fact type: release has asset key
|
739
792
|
Term Form: release asset
|
@@ -749,6 +802,8 @@ Fact type: release asset has asset
|
|
749
802
|
|
750
803
|
Fact type: service environment variable has value
|
751
804
|
Necessity: each service environment variable has exactly one value.
|
805
|
+
-- 100KB
|
806
|
+
Necessity: each service environment variable has a value that has a Length (Type) that is less than or equal to 100000.
|
752
807
|
|
753
808
|
|
754
809
|
-- image
|
@@ -759,6 +814,8 @@ Fact type: image has end timestamp
|
|
759
814
|
Necessity: each image has at most one end timestamp.
|
760
815
|
Fact type: image has dockerfile
|
761
816
|
Necessity: each image has at most one dockerfile.
|
817
|
+
-- 1MB
|
818
|
+
Necessity: each image that has a dockerfile, has a dockerfile that has a Length (Type) that is less than or equal to 1000000.
|
762
819
|
Fact type: image is a build of service
|
763
820
|
Synonymous Form: service is built by image
|
764
821
|
Necessity: each image is a build of exactly one service.
|
@@ -774,8 +831,12 @@ Fact type: image has project type
|
|
774
831
|
Definition: "Standard Dockerfile" or "project type unavailable" or "NodeJS" or "node.js" or "local deploy" or "external service" or "Dockerfile.template" or "dockerfile template" or "dockerfile" or "Could not be detected" or "Architecture-specific Dockerfile" or "Archicture-specific Dockerfile"
|
775
832
|
Fact type: image has error message
|
776
833
|
Necessity: each image has at most one error message
|
834
|
+
-- 300KB
|
835
|
+
Necessity: each image that has an error message, has an error message that has a Length (Type) that is less than or equal to 300000.
|
777
836
|
Fact type: image has build log
|
778
837
|
Necessity: each image has at most one build log.
|
838
|
+
-- 1.5MB
|
839
|
+
Necessity: each image that has a build log, has a build log that has a Length (Type) that is less than or equal to 1500000.
|
779
840
|
Fact type: image has push timestamp
|
780
841
|
Necessity: each image has at most one push timestamp.
|
781
842
|
Fact type: image has status
|
@@ -783,6 +844,8 @@ Fact type: image has status
|
|
783
844
|
Definition: "running" or "success" or "failed" or "error" or "cancelled" or "interrupted"
|
784
845
|
Fact type: image has content hash
|
785
846
|
Necessity: each image has at most one content hash.
|
847
|
+
-- TODO: Pitch cleanup and change to exactly equal 71
|
848
|
+
Necessity: each image that has a content hash, has a content hash that has a Length (Type) that is less than or equal to 71.
|
786
849
|
Fact type: image has contract
|
787
850
|
Necessity: each image has at most one contract
|
788
851
|
|
@@ -791,36 +854,48 @@ Fact type: image has contract
|
|
791
854
|
|
792
855
|
Fact type: image label has value
|
793
856
|
Necessity: each image label has exactly one value.
|
857
|
+
-- TODO: Pitch cleanup and reduce to 255
|
858
|
+
Necessity: each image label has a value that has a Length (Type) that is less than or equal to 300.
|
794
859
|
|
795
860
|
|
796
861
|
-- service label
|
797
862
|
|
798
863
|
Fact type: service label has value
|
799
864
|
Necessity: each service label has exactly one value.
|
865
|
+
-- TODO: Pitch cleanup and reduce to 255
|
866
|
+
Necessity: each service label has a value that has a Length (Type) that is less than or equal to 300.
|
800
867
|
|
801
868
|
|
802
869
|
-- device environment variable
|
803
870
|
|
804
871
|
Fact type: device environment variable has value
|
805
872
|
Necessity: each device environment variable has exactly one value.
|
873
|
+
-- TODO: Pitch cleanup and reduce to 100KB
|
874
|
+
Necessity: each device environment variable has a value that has a Length (Type) that is less than or equal to 515798.
|
806
875
|
|
807
876
|
|
808
877
|
-- application environment variable
|
809
878
|
|
810
879
|
Fact type: application environment variable has value
|
811
880
|
Necessity: each application environment variable has exactly one value.
|
881
|
+
-- TODO: Pitch cleanup and reduce to 100KB
|
882
|
+
Necessity: each application environment variable has a value that has a Length (Type) that is less than or equal to 106104.
|
812
883
|
|
813
884
|
|
814
885
|
-- image environment variable
|
815
886
|
|
816
887
|
Fact type: image environment variable has value
|
817
888
|
Necessity: each image environment variable has exactly one value.
|
889
|
+
-- 100KB
|
890
|
+
Necessity: each image environment variable has a value that has a Length (Type) that is less than or equal to 100000.
|
818
891
|
|
819
892
|
|
820
893
|
-- device service environment variable
|
821
894
|
|
822
895
|
Fact type: device service environment variable has value
|
823
896
|
Necessity: each device service environment variable has exactly one value.
|
897
|
+
-- TODO: Pitch cleanup and reduce to 100KB
|
898
|
+
Necessity: each device service environment variable has a value that has a Length (Type) that is less than or equal to 278379.
|
824
899
|
Fact type: device service environment variable has service install
|
825
900
|
Necessity: each device service environment variable has exactly one service install.
|
826
901
|
|
@@ -829,18 +904,24 @@ Fact type: device service environment variable has service install
|
|
829
904
|
|
830
905
|
Fact type: application tag has value
|
831
906
|
Necessity: each application tag has exactly one value.
|
907
|
+
-- 1KB
|
908
|
+
Necessity: each application tag has a value that has a Length (Type) that is greater than 0 and is less than or equal to 1000.
|
832
909
|
|
833
910
|
|
834
911
|
-- device tag
|
835
912
|
|
836
913
|
Fact type: device tag has value
|
837
914
|
Necessity: each device tag has exactly one value.
|
915
|
+
-- TODO: Pitch cleanup and reduce to 10KB
|
916
|
+
Necessity: each device tag has a value that has a Length (Type) that is greater than 0 and is less than or equal to 60158.
|
838
917
|
|
839
918
|
|
840
919
|
-- release tag
|
841
920
|
|
842
921
|
Fact type: release tag has value
|
843
922
|
Necessity: each release tag has exactly one value.
|
923
|
+
-- 1KB
|
924
|
+
Necessity: each release tag has a value that has a Length (Type) that is greater than 0 and is less than or equal to 1000.
|
844
925
|
|
845
926
|
|
846
927
|
-- image install
|
@@ -1,9 +1,15 @@
|
|
1
|
-
import type { RequestHandler, Request } from 'express';
|
1
|
+
import type { RequestHandler, Request, Response } from 'express';
|
2
2
|
import type { Device } from '../../balena-model.js';
|
3
3
|
export declare const checkDeviceExistsIsFrozen: import("../../infra/cache/multi-level-memoizee.js").MemoizedFn<(uuid: string) => Promise<Pick<Device["Read"], "id" | "is_frozen"> | undefined>>;
|
4
4
|
export interface ResolveDeviceInfoCustomObject {
|
5
5
|
resolvedDeviceIds: Array<Device['Read']['id']>;
|
6
6
|
}
|
7
|
+
export declare const defaultRespondFn: (_req: Request, res: Response, delayMs: number, status: number) => Promise<void>;
|
8
|
+
declare let respondFn: (_req: Request, res: Response, delayMs: number, status: number) => Promise<void>;
|
9
|
+
/**
|
10
|
+
* Set the function used to respond to the deleted/frozen device request.
|
11
|
+
*/
|
12
|
+
export declare const setRespondFn: ($respondFn: typeof respondFn) => void;
|
7
13
|
/**
|
8
14
|
* This checks if a device is deleted or frozen and responds according to the passed statusCode(s)
|
9
15
|
*/
|
@@ -11,3 +17,4 @@ export declare const resolveOrDenyDevicesWithStatus: (statusCode: number | {
|
|
11
17
|
deleted: number;
|
12
18
|
frozen: number;
|
13
19
|
}, uuidResolver?: (req: Request) => string[], delayMs?: number) => RequestHandler;
|
20
|
+
export {};
|
@@ -24,22 +24,29 @@ export const checkDeviceExistsIsFrozen = multiCacheMemoizee(async (uuid) => {
|
|
24
24
|
maxAge: DEVICE_EXISTS_CACHE_TIMEOUT,
|
25
25
|
}, { useVersion: false });
|
26
26
|
const requestParamsUuidResolver = (req) => [req.params.uuid];
|
27
|
+
export const defaultRespondFn = async (_req, res, delayMs, status) => {
|
28
|
+
if (delayMs > 0) {
|
29
|
+
await setTimeout(delayMs);
|
30
|
+
}
|
31
|
+
res.status(status).end();
|
32
|
+
};
|
33
|
+
let respondFn = defaultRespondFn;
|
34
|
+
/**
|
35
|
+
* Set the function used to respond to the deleted/frozen device request.
|
36
|
+
*/
|
37
|
+
export const setRespondFn = ($respondFn) => {
|
38
|
+
respondFn = $respondFn;
|
39
|
+
};
|
27
40
|
/**
|
28
41
|
* This checks if a device is deleted or frozen and responds according to the passed statusCode(s)
|
29
42
|
*/
|
30
43
|
export const resolveOrDenyDevicesWithStatus = (statusCode, uuidResolver = requestParamsUuidResolver, delayMs = 0) => {
|
31
44
|
const deletedStatusCode = typeof statusCode === 'number' ? statusCode : statusCode.deleted;
|
32
45
|
const frozenStatusCode = typeof statusCode === 'number' ? statusCode : statusCode.frozen;
|
33
|
-
const respond = async (res, status) => {
|
34
|
-
if (delayMs > 0) {
|
35
|
-
await setTimeout(delayMs);
|
36
|
-
}
|
37
|
-
res.status(status).end();
|
38
|
-
};
|
39
46
|
return async (req, res, next) => {
|
40
47
|
const uuids = uuidResolver(req);
|
41
48
|
if (!uuids.length) {
|
42
|
-
await
|
49
|
+
await respondFn(req, res, delayMs, deletedStatusCode);
|
43
50
|
return;
|
44
51
|
}
|
45
52
|
const deviceIds = [];
|
@@ -51,12 +58,12 @@ export const resolveOrDenyDevicesWithStatus = (statusCode, uuidResolver = reques
|
|
51
58
|
// per request.
|
52
59
|
if (device == null) {
|
53
60
|
// Gracefully deny deleted devices
|
54
|
-
await
|
61
|
+
await respondFn(req, res, delayMs, deletedStatusCode);
|
55
62
|
return;
|
56
63
|
}
|
57
64
|
if (device.is_frozen) {
|
58
65
|
// Gracefully deny frozen devices
|
59
|
-
await
|
66
|
+
await respondFn(req, res, delayMs, frozenStatusCode);
|
60
67
|
return;
|
61
68
|
}
|
62
69
|
deviceIds.push(device.id);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/features/device-state/middleware.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;AAE1B,MAAM,8BAA8B,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAClD,GAAG,CAAC,KAAK,CAAC,OAAO,CAChB;IACC,QAAQ,EAAE,QAAQ;IAClB,WAAW,EAAE,EAAE,GAAG,EAAE,WAAW,CAAC,IAAI,EAAE;IACtC,EAAE,EAAE;QACH,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE;KACrB;IACD,OAAO,EAAE;QACR,OAAO,EAAE,CAAC,IAAI,EAAE,WAAW,CAAC;KAC5B;CACD,EACD,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,CACpB,CACD,CAAC;AACF,MAAM,CAAC,MAAM,yBAAyB,GAAG,kBAAkB,CAC1D,KAAK,EACJ,IAAY,EACoD,EAAE;IAClE,OAAO,MAAM,8BAA8B,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AACzD,CAAC,EACD;IACC,QAAQ,EAAE,2BAA2B;IACrC,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,KAAK;IAClB,MAAM,EAAE,2BAA2B;CACnC,EACD,EAAE,UAAU,EAAE,KAAK,EAAE,CACrB,CAAC;AAMF,MAAM,yBAAyB,GAAG,CAAC,GAAY,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAEtE
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/features/device-state/middleware.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,EAAE,GAAG,EAAE,GA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YACR,CAAC;YACD,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC3B,CAAC;QACD,GAAG,CAAC,MAAM,KAAK,EAAE,CAAC;QACjB,GAAG,CAAC,MAAwC,CAAC,iBAAiB,GAAG,SAAS,CAAC;QAC5E,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;AACH,CAAC,CAAC"}
|
@@ -131,8 +131,8 @@ declare const getDevice: (req: import("@balena/pinejs/out/sbvr-api/permissions.j
|
|
131
131
|
last_vpn_event: import("@balena/sbvr-types").Types["Date Time"]["Read"] | null;
|
132
132
|
is_locked_until__date: import("@balena/sbvr-types").Types["Date Time"]["Read"] | null;
|
133
133
|
public_address: import("@balena/sbvr-types").Types["Short Text"]["Read"] | null;
|
134
|
-
ip_address: import("@balena/sbvr-types").Types["
|
135
|
-
mac_address: import("@balena/sbvr-types").Types["
|
134
|
+
ip_address: import("@balena/sbvr-types").Types["Text"]["Read"] | null;
|
135
|
+
mac_address: import("@balena/sbvr-types").Types["Text"]["Read"] | null;
|
136
136
|
memory_usage: import("@balena/sbvr-types").Types["Integer"]["Read"] | null;
|
137
137
|
memory_total: import("@balena/sbvr-types").Types["Integer"]["Read"] | null;
|
138
138
|
storage_block_device: import("@balena/sbvr-types").Types["Short Text"]["Read"] | null;
|
@@ -2,7 +2,7 @@ import _ from 'lodash';
|
|
2
2
|
import { captureException, handleHttpErrors, } from '../../../infra/error-handling/index.js';
|
3
3
|
import { sbvrUtils, errors } from '@balena/pinejs';
|
4
4
|
import { getIP } from '../../../lib/utils.js';
|
5
|
-
import { shouldUpdateMetrics, metricsPatchFields, v2ValidPatchFields, upsertImageInstall, deleteOldImageInstalls,
|
5
|
+
import { shouldUpdateMetrics, metricsPatchFields, v2ValidPatchFields, upsertImageInstall, deleteOldImageInstalls, truncateConstrainedDeviceFields, limitMetricNumbers, normalizeStatePatchDeviceBody, } from '../state-patch-utils.js';
|
6
6
|
const { BadRequestError, UnauthorizedError } = errors;
|
7
7
|
const { api } = sbvrUtils;
|
8
8
|
const appAndReleaseOfDeviceQuery = _.once(() =>
|
@@ -112,7 +112,7 @@ export const statePatchV2 = async (req, res) => {
|
|
112
112
|
// truncate for resilient legacy compatible device state patch so that supervisors don't fail
|
113
113
|
// to update b/c of length violation of 255 (SBVR SHORT TEXT type) for ip and mac address.
|
114
114
|
// sbvr-types does not export SHORT TEXT VARCHAR length 255 to import.
|
115
|
-
deviceBody =
|
115
|
+
deviceBody = truncateConstrainedDeviceFields(deviceBody, deviceId);
|
116
116
|
await resinApiTx.patch({
|
117
117
|
resource: 'device',
|
118
118
|
id: deviceId,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"state-patch-v2.js","sourceRoot":"","sources":["../../../../src/features/device-state/routes/state-patch-v2.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EACN,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,EACN,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,
|
1
|
+
{"version":3,"file":"state-patch-v2.js","sourceRoot":"","sources":["../../../../src/features/device-state/routes/state-patch-v2.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EACN,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,EACN,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,+BAA+B,EAC/B,kB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YAC1B,wEAAwE;YAExE,MAAM,MAAM,GAAc,EAAE,CAAC,CAAC,+DAA+D;YAC7F,uEAAuE;YACvE,IAAI,GAAG,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;gBACxB,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YAC/B,CAAC;YACD,MAAM,SAAS,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;gBAC3C,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC;oBAClC,WAAW,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE;iBAChC,CAAC,CAAC;gBAEH,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACtE,CAAC,CAAC,CAAC;QACJ,CAAC;QAED,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACvB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,IAAI,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;YACrC,OAAO;QACR,CAAC;QACD,gBAAgB,CAAC,GAAG,EAAE,4BAA4B,CAAC,CAAC;QACpD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACvB,CAAC;AACF,CAAC,CAAC"}
|
@@ -3,7 +3,7 @@ import { captureException, handleHttpErrors, } from '../../../infra/error-handli
|
|
3
3
|
import { sbvrUtils, errors } from '@balena/pinejs';
|
4
4
|
import { getIP } from '../../../lib/utils.js';
|
5
5
|
import { metricsPatchFields, v3ValidPatchFields } from '../index.js';
|
6
|
-
import { deleteOldImageInstalls, limitMetricNumbers, upsertImageInstall, shouldUpdateMetrics,
|
6
|
+
import { deleteOldImageInstalls, limitMetricNumbers, upsertImageInstall, shouldUpdateMetrics, truncateConstrainedDeviceFields, normalizeStatePatchDeviceBody, } from '../state-patch-utils.js';
|
7
7
|
const { BadRequestError, UnauthorizedError, InternalRequestError } = errors;
|
8
8
|
const { api } = sbvrUtils;
|
9
9
|
var updateStatusPrecedence;
|
@@ -203,7 +203,7 @@ export const statePatchV3 = async (req, res) => {
|
|
203
203
|
// truncate for resilient legacy compatible device state patch so that supervisors don't fail
|
204
204
|
// to update b/c of length violation of 255 (SBVR SHORT TEXT type) for ip and mac address.
|
205
205
|
// sbvr-types does not export SHORT TEXT VARCHAR length 255 to import.
|
206
|
-
deviceBody =
|
206
|
+
deviceBody = truncateConstrainedDeviceFields(deviceBody, device.id);
|
207
207
|
updateFns.push(async (resinApiTx) => {
|
208
208
|
await resinApiTx.patch({
|
209
209
|
resource: 'device',
|