@hot-updater/aws 1.2.0-rc.4 → 1.2.0-rc.41
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.cjs +144 -188
- package/dist/index.d.cts +30 -12
- package/dist/index.d.mts +30 -12
- package/dist/index.mjs +145 -189
- package/dist/init/index.cjs +66 -22
- package/dist/init/index.d.cts +3 -2
- package/dist/init/index.d.mts +3 -2
- package/dist/init/index.mjs +67 -23
- package/dist/lambda/index.cjs +1079 -237
- package/package.json +8 -7
package/dist/lambda/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ let _aws_sdk_client_cloudfront = require("@aws-sdk/client-cloudfront");
|
|
|
30
30
|
let _aws_sdk_lib_dynamodb = require("@aws-sdk/lib-dynamodb");
|
|
31
31
|
let _aws_sdk_client_s3 = require("@aws-sdk/client-s3");
|
|
32
32
|
let _aws_sdk_lib_storage = require("@aws-sdk/lib-storage");
|
|
33
|
+
let _aws_sdk_s3_request_presigner = require("@aws-sdk/s3-request-presigner");
|
|
33
34
|
const SHA256_FILE_HASH_RE = /^[0-9a-f]{64}$/;
|
|
34
35
|
const isContentAddressedAssetFileHash = (value) => {
|
|
35
36
|
return typeof value === "string" && SHA256_FILE_HASH_RE.test(value);
|
|
@@ -1437,6 +1438,10 @@ const semverSatisfies = (targetAppVersion, currentVersion) => {
|
|
|
1437
1438
|
return satisfies(currentCoerce, targetAppVersion);
|
|
1438
1439
|
};
|
|
1439
1440
|
//#endregion
|
|
1441
|
+
//#region ../plugin-core/dist/types/index.mjs
|
|
1442
|
+
/** The value of a `Lazy`, calling its function. */
|
|
1443
|
+
const resolveLazy = async (value) => typeof value === "function" ? await value() : value;
|
|
1444
|
+
//#endregion
|
|
1440
1445
|
//#region ../plugin-core/dist/serverPlugin/definePlugin.mjs
|
|
1441
1446
|
/** Declares a plugin; Hot Updater's own plugins and third-party ones use the same contract. */
|
|
1442
1447
|
const definePlugin = (plugin) => plugin;
|
|
@@ -2126,7 +2131,10 @@ const CHANNEL_ID = {
|
|
|
2126
2131
|
* every database's migrator creates missing tables and then records the
|
|
2127
2132
|
* version, and none of them changes an existing table, so changing one
|
|
2128
2133
|
* needs a migration step of its own first. The schema fence answers 503 on
|
|
2129
|
-
* a database whose row differs, until it runs.
|
|
2134
|
+
* a database whose row differs, until it runs. Before a version is released,
|
|
2135
|
+
* its tables change in place in its own migration, and a database one of its
|
|
2136
|
+
* prereleases migrated takes the same change by hand: the fence compares this
|
|
2137
|
+
* row, not columns, so nothing reports it.
|
|
2130
2138
|
*/
|
|
2131
2139
|
const HOT_UPDATER_SCHEMA_VERSION = "1.2.0";
|
|
2132
2140
|
const bundles = defineTable({
|
|
@@ -2380,7 +2388,10 @@ const channels = defineTable({
|
|
|
2380
2388
|
/**
|
|
2381
2389
|
* The native builds `native-build android` and `native-build ios` track, newest first
|
|
2382
2390
|
* in each scope: a platform, a channel, and the fingerprint or app version
|
|
2383
|
-
* the build compiled in.
|
|
2391
|
+
* the build compiled in. A sandbox build's scope has no channel: its app ID,
|
|
2392
|
+
* URL scheme, artifact kind and distribution in its place, so pull requests
|
|
2393
|
+
* reuse it across channels, while `channel_id` still names the channel it
|
|
2394
|
+
* embeds. `min_bundle_id` names the build's built-in bundle,
|
|
2384
2395
|
* a `bundles` row no release publishes. Its references keep no counters, so
|
|
2385
2396
|
* adding this table changes no existing one; a channel with builds is
|
|
2386
2397
|
* refused deletion through `byChannel`. `build_key` is the native build key
|
|
@@ -2390,6 +2401,27 @@ const channels = defineTable({
|
|
|
2390
2401
|
* or `versionCode`. `submitted_to`, `submitted_at_ms` and
|
|
2391
2402
|
* `submitted_version` record the store track a build went to, when, and
|
|
2392
2403
|
* the store's label of the build; they stay null for a build no store took.
|
|
2404
|
+
* `is_store_build` is true on the build a person or a job says the store
|
|
2405
|
+
* sells, and false on every other: deploys patch from it over the scope's
|
|
2406
|
+
* newest build. The engine copies the scope key into `store_build_scope_key`
|
|
2407
|
+
* for that build alone, so `byStoreBuild` holds one entry per scope at most,
|
|
2408
|
+
* on every store, while any number of a scope's builds hold none.
|
|
2409
|
+
* `is_sandbox` is true on a sandbox build, set from its artifact when it
|
|
2410
|
+
* registers and never changed, and `sandbox_url_scheme` is the URL scheme its artifact registers,
|
|
2411
|
+
* which its preview links open; null on any other build, and on a sandbox
|
|
2412
|
+
* build registered before the column, which registered the derived one.
|
|
2413
|
+
* `export_method` is how an `.ipa` was exported, read from its profile when
|
|
2414
|
+
* it registers and never changed; null on any other artifact, on an `.ipa`
|
|
2415
|
+
* whose profile couldn't be read, and on one registered before the column.
|
|
2416
|
+
* `native_app_version` is the app version the artifact itself reports, its
|
|
2417
|
+
* `CFBundleShortVersionString` or `versionName`, read from the artifact when
|
|
2418
|
+
* it registers and never changed, whatever the update strategy; `app_version`
|
|
2419
|
+
* stays the version OTAs target, null on a fingerprint build. It is null
|
|
2420
|
+
* when the artifact's can't be read, and on a build registered before the
|
|
2421
|
+
* column.
|
|
2422
|
+
* Boolean columns follow one rule: `is_*` for a fact about the row or
|
|
2423
|
+
* `should_*` for an instruction to the client, never null; a unique index over
|
|
2424
|
+
* the rows where one is true keys a derived slot, not the boolean.
|
|
2393
2425
|
*/
|
|
2394
2426
|
const nativeBuilds = defineTable({
|
|
2395
2427
|
id: {
|
|
@@ -2466,9 +2498,34 @@ const nativeBuilds = defineTable({
|
|
|
2466
2498
|
type: "string",
|
|
2467
2499
|
maxLength: 255,
|
|
2468
2500
|
required: false
|
|
2501
|
+
},
|
|
2502
|
+
is_store_build: { type: "boolean" },
|
|
2503
|
+
is_sandbox: { type: "boolean" },
|
|
2504
|
+
sandbox_url_scheme: {
|
|
2505
|
+
type: "string",
|
|
2506
|
+
maxLength: 255,
|
|
2507
|
+
ascii: true,
|
|
2508
|
+
required: false
|
|
2509
|
+
},
|
|
2510
|
+
export_method: {
|
|
2511
|
+
type: "string",
|
|
2512
|
+
maxLength: 16,
|
|
2513
|
+
required: false
|
|
2514
|
+
},
|
|
2515
|
+
native_app_version: {
|
|
2516
|
+
type: "string",
|
|
2517
|
+
required: false
|
|
2469
2518
|
}
|
|
2470
2519
|
}, {
|
|
2471
2520
|
key: ["id"],
|
|
2521
|
+
derived: {
|
|
2522
|
+
/** The scope this build is the store build of; null on every other. */
|
|
2523
|
+
store_build_scope_key: {
|
|
2524
|
+
type: "string",
|
|
2525
|
+
maxLength: 2048,
|
|
2526
|
+
ascii: true,
|
|
2527
|
+
compute: (row) => row.is_store_build ? row.scope_key : null
|
|
2528
|
+
} },
|
|
2472
2529
|
indexes: {
|
|
2473
2530
|
byScope: {
|
|
2474
2531
|
eq: ["scope_key"],
|
|
@@ -2478,6 +2535,11 @@ const nativeBuilds = defineTable({
|
|
|
2478
2535
|
eq: ["scope_key", "build_key"],
|
|
2479
2536
|
sort: ["id"]
|
|
2480
2537
|
},
|
|
2538
|
+
byStoreBuild: {
|
|
2539
|
+
eq: ["store_build_scope_key"],
|
|
2540
|
+
sort: [],
|
|
2541
|
+
unique: true
|
|
2542
|
+
},
|
|
2481
2543
|
byChannel: {
|
|
2482
2544
|
eq: ["channel_id"],
|
|
2483
2545
|
sort: ["id"],
|
|
@@ -2489,6 +2551,115 @@ const nativeBuilds = defineTable({
|
|
|
2489
2551
|
}
|
|
2490
2552
|
}
|
|
2491
2553
|
});
|
|
2554
|
+
/**
|
|
2555
|
+
* The iPhones a team asks to install ad hoc builds on. A row decides what the
|
|
2556
|
+
* CLI registers with Apple, not what an export includes: Xcode's automatic ad
|
|
2557
|
+
* hoc profile lists every device the Apple account has enabled. `status` is
|
|
2558
|
+
* `pending` until someone approves it, `approved` until a build or
|
|
2559
|
+
* `native-build devices add` registers it with Apple, then `registered`;
|
|
2560
|
+
* declining or removing one deletes its row. `udid` is the UDID in lower case.
|
|
2561
|
+
* `apple_issuer_id` is the App Store Connect issuer whose key registered it,
|
|
2562
|
+
* set once: a build signed by another account never registers these rows.
|
|
2563
|
+
* `apple_error` is Apple's refusal of the device, or why it stopped counting
|
|
2564
|
+
* it, cleared by the next success. `build_id` is the newest native build whose
|
|
2565
|
+
* .ipa the CLI checked lists it; deleting that build never touches the row.
|
|
2566
|
+
* It holds personal data: a UDID, a name, and the emails of who asked and who
|
|
2567
|
+
* approved, null for the CLI.
|
|
2568
|
+
*/
|
|
2569
|
+
const iosDevices = defineTable({
|
|
2570
|
+
id: {
|
|
2571
|
+
type: "string",
|
|
2572
|
+
maxLength: 36
|
|
2573
|
+
},
|
|
2574
|
+
udid: {
|
|
2575
|
+
type: "string",
|
|
2576
|
+
maxLength: 40,
|
|
2577
|
+
ascii: true,
|
|
2578
|
+
unique: true
|
|
2579
|
+
},
|
|
2580
|
+
name: {
|
|
2581
|
+
type: "string",
|
|
2582
|
+
maxLength: 100
|
|
2583
|
+
},
|
|
2584
|
+
status: {
|
|
2585
|
+
type: "string",
|
|
2586
|
+
maxLength: 16
|
|
2587
|
+
},
|
|
2588
|
+
requested_by: {
|
|
2589
|
+
type: "string",
|
|
2590
|
+
maxLength: 320,
|
|
2591
|
+
required: false
|
|
2592
|
+
},
|
|
2593
|
+
created_at_ms: { type: "integer" },
|
|
2594
|
+
approved_by: {
|
|
2595
|
+
type: "string",
|
|
2596
|
+
maxLength: 320,
|
|
2597
|
+
required: false
|
|
2598
|
+
},
|
|
2599
|
+
approved_at_ms: {
|
|
2600
|
+
type: "integer",
|
|
2601
|
+
required: false
|
|
2602
|
+
},
|
|
2603
|
+
registered_at_ms: {
|
|
2604
|
+
type: "integer",
|
|
2605
|
+
required: false
|
|
2606
|
+
},
|
|
2607
|
+
apple_issuer_id: {
|
|
2608
|
+
type: "string",
|
|
2609
|
+
maxLength: 64,
|
|
2610
|
+
ascii: true,
|
|
2611
|
+
required: false
|
|
2612
|
+
},
|
|
2613
|
+
apple_error: {
|
|
2614
|
+
type: "string",
|
|
2615
|
+
maxLength: 512,
|
|
2616
|
+
required: false
|
|
2617
|
+
},
|
|
2618
|
+
build_id: {
|
|
2619
|
+
type: "string",
|
|
2620
|
+
maxLength: 36,
|
|
2621
|
+
required: false
|
|
2622
|
+
}
|
|
2623
|
+
}, {
|
|
2624
|
+
key: ["id"],
|
|
2625
|
+
indexes: {
|
|
2626
|
+
byStatus: {
|
|
2627
|
+
eq: ["status"],
|
|
2628
|
+
sort: ["id"]
|
|
2629
|
+
},
|
|
2630
|
+
all: {
|
|
2631
|
+
eq: [],
|
|
2632
|
+
sort: ["id"]
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2635
|
+
});
|
|
2636
|
+
/**
|
|
2637
|
+
* The Apple account the iOS device registry belongs to: one row, keyed
|
|
2638
|
+
* `registry`, holding the App Store Connect issuer that first registered a
|
|
2639
|
+
* device. A build claims it before it sends Apple anything, and its key makes
|
|
2640
|
+
* the claim atomic on every store, so two builds of two accounts can't both
|
|
2641
|
+
* spend a slot; another account's build then registers nothing. Removing
|
|
2642
|
+
* devices never releases it.
|
|
2643
|
+
*/
|
|
2644
|
+
const iosDeviceAccount = defineTable({
|
|
2645
|
+
id: {
|
|
2646
|
+
type: "string",
|
|
2647
|
+
maxLength: 16,
|
|
2648
|
+
ascii: true
|
|
2649
|
+
},
|
|
2650
|
+
apple_issuer_id: {
|
|
2651
|
+
type: "string",
|
|
2652
|
+
maxLength: 64,
|
|
2653
|
+
ascii: true
|
|
2654
|
+
},
|
|
2655
|
+
claimed_at_ms: { type: "integer" }
|
|
2656
|
+
}, {
|
|
2657
|
+
key: ["id"],
|
|
2658
|
+
indexes: { all: {
|
|
2659
|
+
eq: [],
|
|
2660
|
+
sort: ["id"]
|
|
2661
|
+
} }
|
|
2662
|
+
});
|
|
2492
2663
|
/** Core's module: always installed, never a plugin. */
|
|
2493
2664
|
const coreModule = {
|
|
2494
2665
|
id: "core",
|
|
@@ -2509,7 +2680,9 @@ const coreModule = {
|
|
|
2509
2680
|
sort: []
|
|
2510
2681
|
} }
|
|
2511
2682
|
}),
|
|
2512
|
-
native_builds: nativeBuilds
|
|
2683
|
+
native_builds: nativeBuilds,
|
|
2684
|
+
ios_devices: iosDevices,
|
|
2685
|
+
ios_device_account: iosDeviceAccount
|
|
2513
2686
|
}
|
|
2514
2687
|
};
|
|
2515
2688
|
//#endregion
|
|
@@ -2698,15 +2871,8 @@ const LEASE_TABLE = "aggregate_lease";
|
|
|
2698
2871
|
const LEASE = { id: "compaction" };
|
|
2699
2872
|
/** How long a compaction holds the lease before another process may take it. */
|
|
2700
2873
|
const LEASE_MS = 3e4;
|
|
2701
|
-
/**
|
|
2702
|
-
|
|
2703
|
-
* first; memory mode flushes every 15, since its window is what a crash
|
|
2704
|
-
* loses.
|
|
2705
|
-
*/
|
|
2706
|
-
const WINDOW_MS$1 = {
|
|
2707
|
-
log: 6e4,
|
|
2708
|
-
memory: 15e3
|
|
2709
|
-
};
|
|
2874
|
+
/** A commit compacts once this has passed since the last compaction. */
|
|
2875
|
+
const WINDOW_MS$1 = 6e4;
|
|
2710
2876
|
/** Log rows a compaction reads from each log table for one group. */
|
|
2711
2877
|
const LOG_PAGE = 200;
|
|
2712
2878
|
/**
|
|
@@ -2720,8 +2886,6 @@ const GROUPS = {
|
|
|
2720
2886
|
};
|
|
2721
2887
|
/** Tries per write after a conflict or a transient error. */
|
|
2722
2888
|
const ATTEMPTS = 5;
|
|
2723
|
-
/** Aggregate rows a memory buffer holds before a commit waits for a flush. */
|
|
2724
|
-
const MAX_BUFFERED = 1e4;
|
|
2725
2889
|
const log = defineTable({
|
|
2726
2890
|
id: {
|
|
2727
2891
|
type: "string",
|
|
@@ -2771,7 +2935,7 @@ const valuesOf = ({ deltas, sketches }) => ({
|
|
|
2771
2935
|
/**
|
|
2772
2936
|
* Merges `values` into the change for `key`'s identity as `tx.aggregate`
|
|
2773
2937
|
* does: deltas add up and sketches merge. One constant `shardBy` keys each
|
|
2774
|
-
* identity to one entry;
|
|
2938
|
+
* identity to one entry; `compile` writes it to shard 0.
|
|
2775
2939
|
*/
|
|
2776
2940
|
const merge = (into, model, key, values) => recordAggregate(into, model, Object.fromEntries(shapeOf(model).key.map((field, at) => [field, key[at]])), values, "");
|
|
2777
2941
|
const mergeAll = (into, changes) => {
|
|
@@ -2805,7 +2969,7 @@ const increment = ({ model, deltas }, key) => Object.values(deltas).some((delta)
|
|
|
2805
2969
|
/**
|
|
2806
2970
|
* The guarded write that merges `change` into `current`: insert, patch, or
|
|
2807
2971
|
* delete at zero. Unlike a transaction's, a gauge may go below zero here: a
|
|
2808
|
-
*
|
|
2972
|
+
* group can hold a loss without the gain before it, and reads sum every shard.
|
|
2809
2973
|
*/
|
|
2810
2974
|
const rewrite = (change, key, current) => {
|
|
2811
2975
|
const { model } = change;
|
|
@@ -2843,12 +3007,12 @@ const rewrite = (change, key, current) => {
|
|
|
2843
3007
|
};
|
|
2844
3008
|
};
|
|
2845
3009
|
/**
|
|
2846
|
-
* The write for each change on
|
|
2847
|
-
* the row for counters, and a guarded rewrite
|
|
2848
|
-
* rows are read in one batch per table.
|
|
3010
|
+
* The write for each change on shard 0, since one compaction runs at a time:
|
|
3011
|
+
* a blind increment that creates the row for counters, and a guarded rewrite
|
|
3012
|
+
* for gauges and sketches, whose rows are read in one batch per table.
|
|
2849
3013
|
*/
|
|
2850
|
-
const compile = async (adapter, changes
|
|
2851
|
-
const keys = changes.map(({
|
|
3014
|
+
const compile = async (adapter, changes) => {
|
|
3015
|
+
const keys = changes.map(({ key }) => [...key.slice(0, -1), 0]);
|
|
2852
3016
|
const reads = /* @__PURE__ */ new Map();
|
|
2853
3017
|
changes.forEach((change, at) => {
|
|
2854
3018
|
if (rewrites(change)) reads.set(change.model, [...reads.get(change.model) ?? [], at]);
|
|
@@ -2902,14 +3066,13 @@ const encode = async (changes) => {
|
|
|
2902
3066
|
return zipped !== void 0 && zipped.length < json.length ? `z${zipped}` : json;
|
|
2903
3067
|
};
|
|
2904
3068
|
/**
|
|
2905
|
-
* Batches changes to aggregates declared `batched`. A transaction
|
|
2906
|
-
* them
|
|
2907
|
-
*
|
|
2908
|
-
*
|
|
2909
|
-
*
|
|
2910
|
-
* applies exactly once. One lease row keeps compactions one at a time.
|
|
3069
|
+
* Batches changes to aggregates declared `batched`. A transaction writes
|
|
3070
|
+
* them as one log row in its own atomic write, in place of their rows; a
|
|
3071
|
+
* compaction later merges log rows into the aggregates and deletes them,
|
|
3072
|
+
* atomically again, so each applies exactly once. One lease row keeps
|
|
3073
|
+
* compactions one at a time.
|
|
2911
3074
|
*/
|
|
2912
|
-
const createAggregateBatches = ({ engine, adapter, schema, batching: {
|
|
3075
|
+
const createAggregateBatches = ({ engine, adapter, schema, batching: { windowMs = WINDOW_MS$1 }, now }) => {
|
|
2913
3076
|
if (!schema.models.has(LEASE_TABLE)) throw new DatabaseTransactionError("An engine that batches aggregates needs aggregateBatchingModule in its schema.");
|
|
2914
3077
|
const holder = crypto.randomUUID().replaceAll("-", "");
|
|
2915
3078
|
const table = (name) => schema.models.get(name).table;
|
|
@@ -2937,68 +3100,6 @@ const createAggregateBatches = ({ engine, adapter, schema, batching: { mode = "l
|
|
|
2937
3100
|
}
|
|
2938
3101
|
return changes;
|
|
2939
3102
|
};
|
|
2940
|
-
/**
|
|
2941
|
-
* Writes changes in atomic chunks within `fits`, and returns the ones it
|
|
2942
|
-
* could not apply. A write whose outcome is unknown is dropped, never
|
|
2943
|
-
* resent, so no change applies twice.
|
|
2944
|
-
*/
|
|
2945
|
-
const apply = async (changes, shard) => {
|
|
2946
|
-
let rest = changes;
|
|
2947
|
-
let ops = [];
|
|
2948
|
-
let read = true;
|
|
2949
|
-
for (let failures = 0; rest.length > 0 && failures < ATTEMPTS;) try {
|
|
2950
|
-
if (read) ops = await compile(adapter, rest, shard);
|
|
2951
|
-
let size = rest.length;
|
|
2952
|
-
const chunk = () => ops.slice(0, size).filter(isOp);
|
|
2953
|
-
while (size > 1 && !adapter.fits(chunk())) size = Math.ceil(size / 2);
|
|
2954
|
-
let result = { ok: true };
|
|
2955
|
-
if (chunk().length > 0) result = await adapter.write(chunk()).catch((error) => {
|
|
2956
|
-
warn("flush")(error);
|
|
2957
|
-
return { ok: true };
|
|
2958
|
-
});
|
|
2959
|
-
read = !result.ok && !("retry" in result);
|
|
2960
|
-
if (result.ok) {
|
|
2961
|
-
rest = rest.slice(size);
|
|
2962
|
-
ops = ops.slice(size);
|
|
2963
|
-
failures = 0;
|
|
2964
|
-
} else {
|
|
2965
|
-
failures += 1;
|
|
2966
|
-
if (!read) await sleep$2(failures);
|
|
2967
|
-
}
|
|
2968
|
-
} catch (error) {
|
|
2969
|
-
warn("flush")(error);
|
|
2970
|
-
return rest;
|
|
2971
|
-
}
|
|
2972
|
-
return rest;
|
|
2973
|
-
};
|
|
2974
|
-
let buffer = /* @__PURE__ */ new Map();
|
|
2975
|
-
let timer;
|
|
2976
|
-
let flushing;
|
|
2977
|
-
const shards = /* @__PURE__ */ new Map();
|
|
2978
|
-
/** Each process writes its own shard, so flushes of two processes rarely meet. */
|
|
2979
|
-
const processShard = (model) => {
|
|
2980
|
-
if (!shards.has(model)) shards.set(model, Math.floor(Math.random() * shapeOf(model).shards));
|
|
2981
|
-
return shards.get(model);
|
|
2982
|
-
};
|
|
2983
|
-
const schedule = () => {
|
|
2984
|
-
if (timer !== void 0 || buffer.size === 0) return;
|
|
2985
|
-
timer = setTimeout(() => {
|
|
2986
|
-
timer = void 0;
|
|
2987
|
-
flushBuffer();
|
|
2988
|
-
}, windowMs);
|
|
2989
|
-
timer.unref?.();
|
|
2990
|
-
};
|
|
2991
|
-
/** Never rejects: what it cannot apply goes back into the buffer. */
|
|
2992
|
-
const flushBuffer = () => flushing ??= (async () => {
|
|
2993
|
-
clearTimeout(timer);
|
|
2994
|
-
timer = void 0;
|
|
2995
|
-
const pending = [...buffer.values()];
|
|
2996
|
-
buffer = /* @__PURE__ */ new Map();
|
|
2997
|
-
mergeAll(buffer, await apply(pending, processShard));
|
|
2998
|
-
})().catch(warn("flush")).finally(() => {
|
|
2999
|
-
flushing = void 0;
|
|
3000
|
-
schedule();
|
|
3001
|
-
});
|
|
3002
3103
|
let nextDue = 0;
|
|
3003
3104
|
let compacting;
|
|
3004
3105
|
/** Log rows this process read, by `[log table's index, id]`, for the deletes after a group. */
|
|
@@ -3133,7 +3234,7 @@ const createAggregateBatches = ({ engine, adapter, schema, batching: { mode = "l
|
|
|
3133
3234
|
more
|
|
3134
3235
|
};
|
|
3135
3236
|
};
|
|
3136
|
-
const rowsFor = async (changes) => (await compile(adapter, changes
|
|
3237
|
+
const rowsFor = async (changes) => (await compile(adapter, changes)).filter(isOp);
|
|
3137
3238
|
/**
|
|
3138
3239
|
* Applies the oldest pending log rows whose merged changes fit in one
|
|
3139
3240
|
* atomic write with the lease, which lists them as applied; the rows are
|
|
@@ -3227,20 +3328,6 @@ const createAggregateBatches = ({ engine, adapter, schema, batching: { mode = "l
|
|
|
3227
3328
|
}))).then((pages) => pages.some((page) => page.rows.length > 0)).finally(() => {
|
|
3228
3329
|
checking = void 0;
|
|
3229
3330
|
});
|
|
3230
|
-
/** Takes a committed transaction's changes; never rejects, since the transaction already committed. */
|
|
3231
|
-
const committed = async (changes) => {
|
|
3232
|
-
if (mode === "log") {
|
|
3233
|
-
if (now() >= nextDue) await compact(false, GROUPS.commit);
|
|
3234
|
-
return;
|
|
3235
|
-
}
|
|
3236
|
-
mergeAll(buffer, changes.values());
|
|
3237
|
-
schedule();
|
|
3238
|
-
if (buffer.size >= MAX_BUFFERED) await flushBuffer();
|
|
3239
|
-
};
|
|
3240
|
-
const flush = async () => {
|
|
3241
|
-
await flushBuffer();
|
|
3242
|
-
if (mode === "log" && await hasPending()) await compact(true, GROUPS.flush);
|
|
3243
|
-
};
|
|
3244
3331
|
return {
|
|
3245
3332
|
async transaction(fn) {
|
|
3246
3333
|
let changes = /* @__PURE__ */ new Map();
|
|
@@ -3266,7 +3353,7 @@ const createAggregateBatches = ({ engine, adapter, schema, batching: { mode = "l
|
|
|
3266
3353
|
aggregate
|
|
3267
3354
|
});
|
|
3268
3355
|
if (failure) throw failure.error;
|
|
3269
|
-
if (
|
|
3356
|
+
if (attempt.size > 0) {
|
|
3270
3357
|
const id = `${now().toString(36).padStart(9, "0")}${holder.slice(0, 8)}${crypto.randomUUID().slice(0, 8)}`;
|
|
3271
3358
|
const shard = Math.floor(Math.random() * LOG_TABLES.length);
|
|
3272
3359
|
const merged = mergeAll(/* @__PURE__ */ new Map(), attempt.values());
|
|
@@ -3280,24 +3367,18 @@ const createAggregateBatches = ({ engine, adapter, schema, batching: { mode = "l
|
|
|
3280
3367
|
open = false;
|
|
3281
3368
|
}
|
|
3282
3369
|
});
|
|
3283
|
-
if (changes.size > 0) await
|
|
3370
|
+
if (changes.size > 0 && now() >= nextDue) await compact(false, GROUPS.commit);
|
|
3284
3371
|
return result;
|
|
3285
3372
|
},
|
|
3286
3373
|
async beforeRead(name) {
|
|
3287
3374
|
if (!isBatched(schema.models.get(name))) return;
|
|
3288
|
-
if (
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
return false;
|
|
3293
|
-
})) await compact(true, GROUPS.read);
|
|
3294
|
-
}
|
|
3375
|
+
if (await hasPending().catch((error) => {
|
|
3376
|
+
warn("read")(error);
|
|
3377
|
+
return false;
|
|
3378
|
+
})) await compact(true, GROUPS.read);
|
|
3295
3379
|
},
|
|
3296
|
-
flush
|
|
3297
|
-
|
|
3298
|
-
clearTimeout(timer);
|
|
3299
|
-
timer = void 0;
|
|
3300
|
-
await flush();
|
|
3380
|
+
async flush() {
|
|
3381
|
+
if (await hasPending()) await compact(true, GROUPS.flush);
|
|
3301
3382
|
}
|
|
3302
3383
|
};
|
|
3303
3384
|
};
|
|
@@ -3439,7 +3520,8 @@ const fieldProblems = (definition, add) => {
|
|
|
3439
3520
|
else if (field.required === false) add(`key field "${name}" is nullable`);
|
|
3440
3521
|
else if (field.type === "json") add(`key field "${name}" is json`);
|
|
3441
3522
|
}
|
|
3442
|
-
|
|
3523
|
+
const bounded = [...Object.entries(definition.fields), ...definition.kind === "table" ? Object.entries(definition.derived) : []];
|
|
3524
|
+
for (const [name, { type, maxLength, ascii }] of bounded) {
|
|
3443
3525
|
if (maxLength !== void 0 && (type !== "string" || !Number.isSafeInteger(maxLength) || maxLength < 1)) add(`field "${name}" has an invalid maxLength`);
|
|
3444
3526
|
if (ascii && type !== "string") add(`field "${name}" is ascii but not a string`);
|
|
3445
3527
|
}
|
|
@@ -3556,11 +3638,13 @@ const resolveSchema = (modules) => {
|
|
|
3556
3638
|
...maxLength === void 0 ? {} : { maxLength },
|
|
3557
3639
|
...ascii ? { ascii } : {}
|
|
3558
3640
|
}));
|
|
3559
|
-
if (definition.kind === "table") for (const [field, { type, multi }] of Object.entries(definition.derived)) columns.push({
|
|
3641
|
+
if (definition.kind === "table") for (const [field, { type, multi, maxLength, ascii }] of Object.entries(definition.derived)) columns.push({
|
|
3560
3642
|
name: field,
|
|
3561
3643
|
type,
|
|
3562
3644
|
nullable: true,
|
|
3563
|
-
...multi ? { multi } : {}
|
|
3645
|
+
...multi ? { multi } : {},
|
|
3646
|
+
...maxLength === void 0 ? {} : { maxLength },
|
|
3647
|
+
...ascii ? { ascii } : {}
|
|
3564
3648
|
});
|
|
3565
3649
|
else columns.push(integer(SHARD_COLUMN), ...[...definition.counters, ...definition.gauges].map((metric) => integer(metric)), ...definition.distinct.map((metric) => ({
|
|
3566
3650
|
name: metric,
|
|
@@ -4326,13 +4410,10 @@ const createDatabaseEngine = ({ batching, now = Date.now, meter, ...options }) =
|
|
|
4326
4410
|
};
|
|
4327
4411
|
return {
|
|
4328
4412
|
...engine,
|
|
4329
|
-
/** Applies batched aggregate changes still
|
|
4413
|
+
/** Applies the batched aggregate changes still in the log. */
|
|
4330
4414
|
flush: async () => {
|
|
4331
4415
|
await batches?.flush();
|
|
4332
4416
|
},
|
|
4333
|
-
dispose: async () => {
|
|
4334
|
-
await batches?.dispose();
|
|
4335
|
-
},
|
|
4336
4417
|
database(module) {
|
|
4337
4418
|
const name = (model) => module.namespace ? `${module.namespace}_${model}` : model;
|
|
4338
4419
|
return {
|
|
@@ -4413,8 +4494,7 @@ const createEngine = (database, { plugins = [], now = Date.now } = {}) => {
|
|
|
4413
4494
|
if (module === void 0) throw new HotUpdaterConfigError(`Plugin "${plugin.id}" is not one of this engine's plugins.`);
|
|
4414
4495
|
return engine.database(module);
|
|
4415
4496
|
},
|
|
4416
|
-
flush: () => engine.flush()
|
|
4417
|
-
dispose: () => engine.dispose()
|
|
4497
|
+
flush: () => engine.flush()
|
|
4418
4498
|
};
|
|
4419
4499
|
};
|
|
4420
4500
|
//#endregion
|
|
@@ -4707,7 +4787,7 @@ const createKvAdapter = ({ store, tablePrefix = "" }) => {
|
|
|
4707
4787
|
};
|
|
4708
4788
|
//#endregion
|
|
4709
4789
|
//#region ../../packages/server/dist/version.mjs
|
|
4710
|
-
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.
|
|
4790
|
+
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.41";
|
|
4711
4791
|
//#endregion
|
|
4712
4792
|
//#region ../../packages/server/dist/handlerVersionRoutes.mjs
|
|
4713
4793
|
/**
|
|
@@ -5500,8 +5580,8 @@ const baseBundleIdsOf = (row, range, bundleId, limit) => {
|
|
|
5500
5580
|
//#endregion
|
|
5501
5581
|
//#region ../../packages/server/dist/core/reads.mjs
|
|
5502
5582
|
const PAGE$3 = 500;
|
|
5503
|
-
const pick$
|
|
5504
|
-
const toBundleRow = pick$
|
|
5583
|
+
const pick$2 = (fields) => (row) => Object.fromEntries(fields.map((field) => [field, row[field]]));
|
|
5584
|
+
const toBundleRow = pick$2([
|
|
5505
5585
|
"id",
|
|
5506
5586
|
"platform",
|
|
5507
5587
|
"git_commit_hash",
|
|
@@ -5510,7 +5590,7 @@ const toBundleRow = pick$1([
|
|
|
5510
5590
|
"manifest_file_hash",
|
|
5511
5591
|
"asset_base_storage_uri"
|
|
5512
5592
|
]);
|
|
5513
|
-
const toPatchRow = pick$
|
|
5593
|
+
const toPatchRow = pick$2([
|
|
5514
5594
|
"id",
|
|
5515
5595
|
"bundle_id",
|
|
5516
5596
|
"base_bundle_id",
|
|
@@ -5520,7 +5600,7 @@ const toPatchRow = pick$1([
|
|
|
5520
5600
|
"byte_size",
|
|
5521
5601
|
"order_index"
|
|
5522
5602
|
]);
|
|
5523
|
-
const toReleaseRow = pick$
|
|
5603
|
+
const toReleaseRow = pick$2([
|
|
5524
5604
|
"id",
|
|
5525
5605
|
"revision",
|
|
5526
5606
|
"scope_key",
|
|
@@ -5541,7 +5621,7 @@ const toReleaseRow = pick$1([
|
|
|
5541
5621
|
"created_at_ms",
|
|
5542
5622
|
"updated_at_ms"
|
|
5543
5623
|
]);
|
|
5544
|
-
const toCatalogRow = pick$
|
|
5624
|
+
const toCatalogRow = pick$2([
|
|
5545
5625
|
"scope_key",
|
|
5546
5626
|
"catalog_id",
|
|
5547
5627
|
"strategy",
|
|
@@ -5556,7 +5636,7 @@ const toCatalogRow = pick$1([
|
|
|
5556
5636
|
"is_tombstone",
|
|
5557
5637
|
"updated_at_ms"
|
|
5558
5638
|
]);
|
|
5559
|
-
const toChannelRow = pick$
|
|
5639
|
+
const toChannelRow = pick$2(["id", "name"]);
|
|
5560
5640
|
/** Every page of one read, in order. */
|
|
5561
5641
|
const drain$1 = async (read) => {
|
|
5562
5642
|
const rows = [];
|
|
@@ -5569,7 +5649,15 @@ const drain$1 = async (read) => {
|
|
|
5569
5649
|
return rows;
|
|
5570
5650
|
};
|
|
5571
5651
|
/** A keyset page's range: the keys strictly after `after`, in `order`. */
|
|
5572
|
-
|
|
5652
|
+
/** A keyset read's range on its index's order: past `after`, up to `through`. */
|
|
5653
|
+
const after = (input) => {
|
|
5654
|
+
const asc = (input.order ?? "asc") === "asc";
|
|
5655
|
+
const range = {
|
|
5656
|
+
...input.after === void 0 ? {} : asc ? { gt: input.after } : { lt: input.after },
|
|
5657
|
+
...input.through === void 0 ? {} : asc ? { lte: input.through } : { gte: input.through }
|
|
5658
|
+
};
|
|
5659
|
+
return Object.keys(range).length === 0 ? {} : { range };
|
|
5660
|
+
};
|
|
5573
5661
|
/** Core's reads, each through one declared index or key. */
|
|
5574
5662
|
const createCoreReads = (db, storage) => {
|
|
5575
5663
|
/** A bundle row's patches, exactly as many as its reference counter holds. */
|
|
@@ -5774,6 +5862,326 @@ const createCoreReads = (db, storage) => {
|
|
|
5774
5862
|
};
|
|
5775
5863
|
};
|
|
5776
5864
|
//#endregion
|
|
5865
|
+
//#region ../../packages/server/dist/core/iosDevices.mjs
|
|
5866
|
+
/**
|
|
5867
|
+
* A device's UDID: 40 hex digits, or 8 and 16 joined by a hyphen. The same
|
|
5868
|
+
* rule as `normalizeIosUdid` of `@hot-updater/protocol/native-artifact`,
|
|
5869
|
+
* implemented here so the server's runtime never loads the artifact readers.
|
|
5870
|
+
*/
|
|
5871
|
+
const UDID = /^(?:[0-9a-f]{40}|[0-9a-f]{8}-[0-9a-f]{16})$/iu;
|
|
5872
|
+
/** The form the registry stores and compares a UDID in, or null for text that isn't one. */
|
|
5873
|
+
const normalizeIosUdid = (value) => {
|
|
5874
|
+
const trimmed = value.trim();
|
|
5875
|
+
return UDID.test(trimmed) ? trimmed.toLowerCase() : null;
|
|
5876
|
+
};
|
|
5877
|
+
/** `ios_devices.name`'s bound in core's schema. */
|
|
5878
|
+
const NAME_MAX_LENGTH = 100;
|
|
5879
|
+
/** `ios_devices.requested_by` and `approved_by`'s bound: an email address. */
|
|
5880
|
+
const EMAIL_MAX_LENGTH = 320;
|
|
5881
|
+
/** `ios_devices.apple_issuer_id`'s bound. */
|
|
5882
|
+
const ISSUER_MAX_LENGTH = 64;
|
|
5883
|
+
/** How many registry rows one read takes while finding its account. */
|
|
5884
|
+
const ACCOUNT_SCAN_PAGE = 200;
|
|
5885
|
+
/** The one row of `ios_device_account`. */
|
|
5886
|
+
const ACCOUNT_ROW = "registry";
|
|
5887
|
+
/** `ios_devices.apple_error`'s bound. */
|
|
5888
|
+
const ERROR_MAX_LENGTH = 512;
|
|
5889
|
+
const STATUSES = [
|
|
5890
|
+
"pending",
|
|
5891
|
+
"approved",
|
|
5892
|
+
"registered"
|
|
5893
|
+
];
|
|
5894
|
+
const OUTCOMES = [
|
|
5895
|
+
"registered",
|
|
5896
|
+
"refused",
|
|
5897
|
+
"disabled",
|
|
5898
|
+
"missing"
|
|
5899
|
+
];
|
|
5900
|
+
/** The `apple_error` of a device Apple has disabled. */
|
|
5901
|
+
const IOS_DEVICE_DISABLED_ERROR = "Disabled in the Apple account.";
|
|
5902
|
+
/** The `apple_error` of a registered device Apple no longer lists. */
|
|
5903
|
+
const IOS_DEVICE_MISSING_ERROR = "Gone from the Apple account. Approve it again to register it.";
|
|
5904
|
+
/** A device or registry request core cannot store: the caller's input. */
|
|
5905
|
+
var IosDeviceInputError = class extends TypeError {
|
|
5906
|
+
name = "IosDeviceInputError";
|
|
5907
|
+
};
|
|
5908
|
+
const pick$1 = (row) => ({
|
|
5909
|
+
id: row.id,
|
|
5910
|
+
udid: row.udid,
|
|
5911
|
+
name: row.name,
|
|
5912
|
+
status: row.status,
|
|
5913
|
+
requested_by: row.requested_by ?? null,
|
|
5914
|
+
created_at_ms: row.created_at_ms,
|
|
5915
|
+
approved_by: row.approved_by ?? null,
|
|
5916
|
+
approved_at_ms: row.approved_at_ms ?? null,
|
|
5917
|
+
registered_at_ms: row.registered_at_ms ?? null,
|
|
5918
|
+
apple_issuer_id: row.apple_issuer_id ?? null,
|
|
5919
|
+
apple_error: row.apple_error ?? null,
|
|
5920
|
+
build_id: row.build_id ?? null
|
|
5921
|
+
});
|
|
5922
|
+
const udidOf = (udid) => {
|
|
5923
|
+
const key = typeof udid === "string" ? normalizeIosUdid(udid) : null;
|
|
5924
|
+
if (key === null) throw new IosDeviceInputError("Invalid iOS device: udid must be 40 hex digits, or 8 and 16 joined by a hyphen.");
|
|
5925
|
+
return key;
|
|
5926
|
+
};
|
|
5927
|
+
const nameOf$1 = (name) => {
|
|
5928
|
+
const trimmed = typeof name === "string" ? name.trim() : "";
|
|
5929
|
+
if (trimmed.length === 0 || trimmed.length > NAME_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device: name must be 1 to ${NAME_MAX_LENGTH} characters.`);
|
|
5930
|
+
return trimmed;
|
|
5931
|
+
};
|
|
5932
|
+
/** An email, lower-cased, or null for the CLI. */
|
|
5933
|
+
const personOf = (value, field) => {
|
|
5934
|
+
if (value === null) return null;
|
|
5935
|
+
const email = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
5936
|
+
if (email.length === 0 || email.length > EMAIL_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device: ${field} must be an email of at most ${EMAIL_MAX_LENGTH} characters, or null.`);
|
|
5937
|
+
return email;
|
|
5938
|
+
};
|
|
5939
|
+
/** Apple's words, on one line and within the column's bound. */
|
|
5940
|
+
const errorText = (text) => {
|
|
5941
|
+
const line = text.replace(/\s+/gu, " ").trim();
|
|
5942
|
+
return line.length > ERROR_MAX_LENGTH ? `${line.slice(0, 511)}…` : line;
|
|
5943
|
+
};
|
|
5944
|
+
/**
|
|
5945
|
+
* The iOS device registry: the iPhones and iPads a team asked to install ad hoc
|
|
5946
|
+
* builds on. The Console writes requests and approvals, and the CLI what Apple
|
|
5947
|
+
* said, each over the row it read.
|
|
5948
|
+
*/
|
|
5949
|
+
const createIosDeviceApi = (db, { now = Date.now } = {}) => {
|
|
5950
|
+
const findIosDevice = async (udid) => {
|
|
5951
|
+
const key = normalizeIosUdid(udid);
|
|
5952
|
+
if (key === null) return null;
|
|
5953
|
+
const row = await db.findOne("ios_devices", { udid: key });
|
|
5954
|
+
return row === null ? null : pick$1(row);
|
|
5955
|
+
};
|
|
5956
|
+
/**
|
|
5957
|
+
* The issuer of the registry's earliest registration among its rows, by
|
|
5958
|
+
* when and then by ID, or null when no row names one: read only while the
|
|
5959
|
+
* registry has no account yet, a page at a time.
|
|
5960
|
+
*/
|
|
5961
|
+
const accountOfRows = async () => {
|
|
5962
|
+
let earliest = null;
|
|
5963
|
+
for (let after;;) {
|
|
5964
|
+
const { rows } = await db.findMany("ios_devices", {
|
|
5965
|
+
index: "all",
|
|
5966
|
+
where: {},
|
|
5967
|
+
order: "asc",
|
|
5968
|
+
limit: ACCOUNT_SCAN_PAGE,
|
|
5969
|
+
...after === void 0 ? {} : { range: { gt: after } }
|
|
5970
|
+
});
|
|
5971
|
+
for (const row of rows.map(pick$1)) {
|
|
5972
|
+
if (row.apple_issuer_id === null) continue;
|
|
5973
|
+
if (earliest === null || (row.registered_at_ms ?? 0) < (earliest.registered_at_ms ?? 0)) earliest = row;
|
|
5974
|
+
}
|
|
5975
|
+
if (rows.length < ACCOUNT_SCAN_PAGE) return earliest?.apple_issuer_id ?? null;
|
|
5976
|
+
after = rows.at(-1).id;
|
|
5977
|
+
}
|
|
5978
|
+
};
|
|
5979
|
+
return {
|
|
5980
|
+
async listIosDevices(input) {
|
|
5981
|
+
if (input.status !== void 0 && !STATUSES.includes(input.status)) throw new IosDeviceInputError(`Invalid iOS device status: ${String(input.status)}. Expected ${STATUSES.join(", ")}.`);
|
|
5982
|
+
const page = {
|
|
5983
|
+
order: input.order ?? "asc",
|
|
5984
|
+
limit: input.limit,
|
|
5985
|
+
...after(input)
|
|
5986
|
+
};
|
|
5987
|
+
const { rows } = input.status === void 0 ? await db.findMany("ios_devices", {
|
|
5988
|
+
index: "all",
|
|
5989
|
+
where: {},
|
|
5990
|
+
...page
|
|
5991
|
+
}) : await db.findMany("ios_devices", {
|
|
5992
|
+
index: "byStatus",
|
|
5993
|
+
where: { status: input.status },
|
|
5994
|
+
...page
|
|
5995
|
+
});
|
|
5996
|
+
return rows.map(pick$1);
|
|
5997
|
+
},
|
|
5998
|
+
findIosDevice,
|
|
5999
|
+
async requestIosDevice(input) {
|
|
6000
|
+
const udid = udidOf(input.udid);
|
|
6001
|
+
const name = nameOf$1(input.name);
|
|
6002
|
+
const requestedBy = personOf(input.requestedBy, "requestedBy");
|
|
6003
|
+
const existing = await db.findOne("ios_devices", { udid });
|
|
6004
|
+
if (existing !== null) return {
|
|
6005
|
+
device: pick$1(existing),
|
|
6006
|
+
created: false
|
|
6007
|
+
};
|
|
6008
|
+
const device = {
|
|
6009
|
+
id: createUUIDv7(),
|
|
6010
|
+
udid,
|
|
6011
|
+
name,
|
|
6012
|
+
status: "pending",
|
|
6013
|
+
requested_by: requestedBy,
|
|
6014
|
+
created_at_ms: now(),
|
|
6015
|
+
approved_by: null,
|
|
6016
|
+
approved_at_ms: null,
|
|
6017
|
+
registered_at_ms: null,
|
|
6018
|
+
apple_issuer_id: null,
|
|
6019
|
+
apple_error: null,
|
|
6020
|
+
build_id: null
|
|
6021
|
+
};
|
|
6022
|
+
try {
|
|
6023
|
+
await db.transaction(async (tx) => {
|
|
6024
|
+
tx.create("ios_devices", device);
|
|
6025
|
+
});
|
|
6026
|
+
} catch (error) {
|
|
6027
|
+
if (error instanceof DatabaseConstraintError && error.reason === "unique") {
|
|
6028
|
+
const winner = await db.findOne("ios_devices", { udid });
|
|
6029
|
+
if (winner !== null) return {
|
|
6030
|
+
device: pick$1(winner),
|
|
6031
|
+
created: false
|
|
6032
|
+
};
|
|
6033
|
+
}
|
|
6034
|
+
throw error;
|
|
6035
|
+
}
|
|
6036
|
+
return {
|
|
6037
|
+
device,
|
|
6038
|
+
created: true
|
|
6039
|
+
};
|
|
6040
|
+
},
|
|
6041
|
+
async approveIosDevice(id, input) {
|
|
6042
|
+
const name = input.name === void 0 ? void 0 : nameOf$1(input.name);
|
|
6043
|
+
const approvedBy = personOf(input.approvedBy, "approvedBy");
|
|
6044
|
+
return db.transaction(async (tx) => {
|
|
6045
|
+
const row = await tx.findOne("ios_devices", { id });
|
|
6046
|
+
if (row === null) return null;
|
|
6047
|
+
const device = pick$1(row);
|
|
6048
|
+
const set = {
|
|
6049
|
+
...name === void 0 || name === device.name ? {} : { name },
|
|
6050
|
+
...device.status === "pending" ? {
|
|
6051
|
+
status: "approved",
|
|
6052
|
+
approved_by: approvedBy,
|
|
6053
|
+
approved_at_ms: now()
|
|
6054
|
+
} : {}
|
|
6055
|
+
};
|
|
6056
|
+
if (Object.keys(set).length === 0) return device;
|
|
6057
|
+
tx.update("ios_devices", row, set);
|
|
6058
|
+
return {
|
|
6059
|
+
...device,
|
|
6060
|
+
...set
|
|
6061
|
+
};
|
|
6062
|
+
});
|
|
6063
|
+
},
|
|
6064
|
+
async renameIosDevice(id, input) {
|
|
6065
|
+
const name = nameOf$1(input);
|
|
6066
|
+
return db.transaction(async (tx) => {
|
|
6067
|
+
const row = await tx.findOne("ios_devices", { id });
|
|
6068
|
+
if (row === null) return null;
|
|
6069
|
+
const device = pick$1(row);
|
|
6070
|
+
if (device.name === name) return device;
|
|
6071
|
+
tx.update("ios_devices", row, { name });
|
|
6072
|
+
return {
|
|
6073
|
+
...device,
|
|
6074
|
+
name
|
|
6075
|
+
};
|
|
6076
|
+
});
|
|
6077
|
+
},
|
|
6078
|
+
async recordIosDeviceOutcome({ id, seen, issuerId, outcome, reason }) {
|
|
6079
|
+
if (!OUTCOMES.includes(outcome)) throw new IosDeviceInputError(`Invalid iOS device outcome: ${String(outcome)}. Expected ${OUTCOMES.join(", ")}.`);
|
|
6080
|
+
if (typeof issuerId !== "string" || issuerId.trim().length === 0 || issuerId.length > ISSUER_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device outcome: issuerId must be an App Store Connect issuer of at most ${ISSUER_MAX_LENGTH} characters.`);
|
|
6081
|
+
return db.transaction(async (tx) => {
|
|
6082
|
+
const row = await tx.findOne("ios_devices", { id });
|
|
6083
|
+
if (row === null) return null;
|
|
6084
|
+
const device = pick$1(row);
|
|
6085
|
+
if (device.status !== seen.status || device.approved_at_ms !== seen.approvedAtMs || device.apple_issuer_id !== null && device.apple_issuer_id !== issuerId) return null;
|
|
6086
|
+
let set;
|
|
6087
|
+
switch (outcome) {
|
|
6088
|
+
case "registered":
|
|
6089
|
+
if (device.status === "pending") return null;
|
|
6090
|
+
set = {
|
|
6091
|
+
status: "registered",
|
|
6092
|
+
registered_at_ms: device.registered_at_ms ?? now(),
|
|
6093
|
+
apple_issuer_id: issuerId,
|
|
6094
|
+
apple_error: null
|
|
6095
|
+
};
|
|
6096
|
+
break;
|
|
6097
|
+
case "refused":
|
|
6098
|
+
if (device.status !== "approved") return null;
|
|
6099
|
+
set = { apple_error: errorText(reason === void 0 || reason.trim() === "" ? "Apple refused it." : reason) };
|
|
6100
|
+
break;
|
|
6101
|
+
case "disabled":
|
|
6102
|
+
if (device.status === "pending") return null;
|
|
6103
|
+
set = { apple_error: IOS_DEVICE_DISABLED_ERROR };
|
|
6104
|
+
break;
|
|
6105
|
+
case "missing":
|
|
6106
|
+
if (device.status !== "registered") return null;
|
|
6107
|
+
set = {
|
|
6108
|
+
status: "pending",
|
|
6109
|
+
approved_by: null,
|
|
6110
|
+
approved_at_ms: null,
|
|
6111
|
+
apple_error: IOS_DEVICE_MISSING_ERROR
|
|
6112
|
+
};
|
|
6113
|
+
}
|
|
6114
|
+
if (Object.entries(set).some(([column, value]) => device[column] !== (value ?? null))) tx.update("ios_devices", row, set);
|
|
6115
|
+
return {
|
|
6116
|
+
...device,
|
|
6117
|
+
...set
|
|
6118
|
+
};
|
|
6119
|
+
});
|
|
6120
|
+
},
|
|
6121
|
+
async markIosDevicesInBuild({ buildId, ids }) {
|
|
6122
|
+
for (const id of new Set(ids)) await db.transaction(async (tx) => {
|
|
6123
|
+
const row = await tx.findOne("ios_devices", { id });
|
|
6124
|
+
if (row === null || typeof row.build_id === "string" && row.build_id >= buildId) return;
|
|
6125
|
+
tx.update("ios_devices", row, { build_id: buildId });
|
|
6126
|
+
});
|
|
6127
|
+
},
|
|
6128
|
+
async findIosDeviceAccount() {
|
|
6129
|
+
const existing = await db.findOne("ios_device_account", { id: ACCOUNT_ROW });
|
|
6130
|
+
const issuerId = existing === null ? await accountOfRows() : existing.apple_issuer_id;
|
|
6131
|
+
return issuerId === null ? null : { issuerId };
|
|
6132
|
+
},
|
|
6133
|
+
async claimIosDeviceAccount(issuerId) {
|
|
6134
|
+
if (typeof issuerId !== "string" || issuerId.trim().length === 0 || issuerId.length > ISSUER_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device account: issuerId must be an App Store Connect issuer of at most ${ISSUER_MAX_LENGTH} characters.`);
|
|
6135
|
+
const answer = (held) => ({
|
|
6136
|
+
issuerId: held,
|
|
6137
|
+
claimed: held === issuerId
|
|
6138
|
+
});
|
|
6139
|
+
const existing = await db.findOne("ios_device_account", { id: ACCOUNT_ROW });
|
|
6140
|
+
if (existing !== null) return answer(existing.apple_issuer_id);
|
|
6141
|
+
const holder = await accountOfRows() ?? issuerId;
|
|
6142
|
+
try {
|
|
6143
|
+
await db.transaction(async (tx) => {
|
|
6144
|
+
tx.create("ios_device_account", {
|
|
6145
|
+
id: ACCOUNT_ROW,
|
|
6146
|
+
apple_issuer_id: holder,
|
|
6147
|
+
claimed_at_ms: now()
|
|
6148
|
+
});
|
|
6149
|
+
});
|
|
6150
|
+
return answer(holder);
|
|
6151
|
+
} catch (error) {
|
|
6152
|
+
if (error instanceof DatabaseConstraintError && (error.reason === "exists" || error.reason === "unique")) {
|
|
6153
|
+
const winner = await db.findOne("ios_device_account", { id: ACCOUNT_ROW });
|
|
6154
|
+
if (winner !== null) return answer(winner.apple_issuer_id);
|
|
6155
|
+
}
|
|
6156
|
+
throw error;
|
|
6157
|
+
}
|
|
6158
|
+
},
|
|
6159
|
+
async deleteIosDevice(id, only) {
|
|
6160
|
+
const requestedBy = only?.requestedBy === void 0 ? void 0 : personOf(only.requestedBy, "requestedBy");
|
|
6161
|
+
return db.transaction(async (tx) => {
|
|
6162
|
+
const row = await tx.findOne("ios_devices", { id });
|
|
6163
|
+
if (row === null) return null;
|
|
6164
|
+
const device = pick$1(row);
|
|
6165
|
+
if (only?.status !== void 0 && device.status !== only.status || requestedBy !== void 0 && device.requested_by !== requestedBy) return null;
|
|
6166
|
+
await tx.delete("ios_devices", row);
|
|
6167
|
+
return device;
|
|
6168
|
+
});
|
|
6169
|
+
}
|
|
6170
|
+
};
|
|
6171
|
+
};
|
|
6172
|
+
//#endregion
|
|
6173
|
+
//#region ../../packages/server/dist/core/nativeBuildDestinations.mjs
|
|
6174
|
+
/** Store destinations accepted for each native platform. */
|
|
6175
|
+
const NATIVE_BUILD_SUBMISSION_DESTINATIONS = {
|
|
6176
|
+
android: [
|
|
6177
|
+
"play-internal",
|
|
6178
|
+
"play-closed",
|
|
6179
|
+
"play-open",
|
|
6180
|
+
"play-production"
|
|
6181
|
+
],
|
|
6182
|
+
ios: ["testflight"]
|
|
6183
|
+
};
|
|
6184
|
+
//#endregion
|
|
5777
6185
|
//#region ../../packages/server/dist/core/writes.mjs
|
|
5778
6186
|
const PAGE$2 = 500;
|
|
5779
6187
|
/** Moves one bundle into or out of its platform's total and the overall total. */
|
|
@@ -5803,8 +6211,10 @@ const deleteBundle = async (tx, current) => {
|
|
|
5803
6211
|
/**
|
|
5804
6212
|
* Replaces a bundle's patches with `rows`: kept patches are updated where
|
|
5805
6213
|
* they changed, others deleted or created, so no key is written twice.
|
|
6214
|
+
* `checkNew` sees each patch it is about to create, and refuses one by
|
|
6215
|
+
* throwing, which leaves the transaction's writes undone.
|
|
5806
6216
|
*/
|
|
5807
|
-
const replaceBundlePatches = async (tx, bundle, rows) => {
|
|
6217
|
+
const replaceBundlePatches = async (tx, bundle, rows, checkNew) => {
|
|
5808
6218
|
const wanted = new Map(rows.map((row) => [row.id, row]));
|
|
5809
6219
|
const count = bundle._refs_bundle_patches_bundle_id ?? 0;
|
|
5810
6220
|
let cursor;
|
|
@@ -5829,6 +6239,7 @@ const replaceBundlePatches = async (tx, bundle, rows) => {
|
|
|
5829
6239
|
if (page.next === void 0) break;
|
|
5830
6240
|
cursor = page.next;
|
|
5831
6241
|
}
|
|
6242
|
+
if (checkNew !== void 0) for (const row of wanted.values()) await checkNew(row);
|
|
5832
6243
|
for (const row of wanted.values()) tx.create("bundle_patches", row);
|
|
5833
6244
|
};
|
|
5834
6245
|
/** A channel by name, created when missing; a concurrent creator's row is returned instead. */
|
|
@@ -5891,6 +6302,27 @@ const GIT_COMMIT_HASH_MAX_LENGTH = 255;
|
|
|
5891
6302
|
* and looks up nothing else.
|
|
5892
6303
|
*/
|
|
5893
6304
|
const BUILD_KEY = /^nbk1:[0-9a-f]{64}$/;
|
|
6305
|
+
/** `native_builds.sandbox_url_scheme`'s bound in core's schema. */
|
|
6306
|
+
const SANDBOX_URL_SCHEME_MAX_LENGTH = 255;
|
|
6307
|
+
/**
|
|
6308
|
+
* A URL scheme as RFC 3986 spells it, in lower case: what a sandbox build's
|
|
6309
|
+
* artifact registers, as `@hot-updater/protocol/native-artifact` reads it.
|
|
6310
|
+
*/
|
|
6311
|
+
const URL_SCHEME = new RegExp(`^[a-z][a-z0-9+.-]{0,254}$`);
|
|
6312
|
+
/**
|
|
6313
|
+
* A bundle identifier or application ID, as an artifact reports it: letters,
|
|
6314
|
+
* digits, dots, dashes and underscores, which a scope key holds as they are.
|
|
6315
|
+
*/
|
|
6316
|
+
const APP_ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/;
|
|
6317
|
+
/** A fingerprint hash as a Release Catalog scope key holds it. */
|
|
6318
|
+
const FINGERPRINT_HASH = /^[A-Za-z0-9._~-]{1,255}$/;
|
|
6319
|
+
/** How each kind of artifact can install. */
|
|
6320
|
+
const DISTRIBUTIONS = {
|
|
6321
|
+
apk: ["direct"],
|
|
6322
|
+
app: ["direct"],
|
|
6323
|
+
aab: ["store"],
|
|
6324
|
+
ipa: ["direct", "store"]
|
|
6325
|
+
};
|
|
5894
6326
|
/** A native build or scope core cannot store or look up: the caller's input. */
|
|
5895
6327
|
var NativeBuildInputError = class extends TypeError {
|
|
5896
6328
|
name = "NativeBuildInputError";
|
|
@@ -5912,24 +6344,67 @@ const pick = (row) => ({
|
|
|
5912
6344
|
build_number: row.build_number ?? null,
|
|
5913
6345
|
submitted_to: row.submitted_to ?? null,
|
|
5914
6346
|
submitted_at_ms: row.submitted_at_ms ?? null,
|
|
5915
|
-
submitted_version: row.submitted_version ?? null
|
|
6347
|
+
submitted_version: row.submitted_version ?? null,
|
|
6348
|
+
is_store_build: row.is_store_build === true,
|
|
6349
|
+
is_sandbox: row.is_sandbox === true,
|
|
6350
|
+
sandbox_url_scheme: row.sandbox_url_scheme ?? null,
|
|
6351
|
+
export_method: row.export_method ?? null,
|
|
6352
|
+
native_app_version: row.native_app_version ?? null
|
|
5916
6353
|
});
|
|
5917
|
-
/** The
|
|
5918
|
-
const
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
6354
|
+
/** The export methods an `.ipa` registers with. */
|
|
6355
|
+
const EXPORT_METHODS = /* @__PURE__ */ new Set([
|
|
6356
|
+
"app-store",
|
|
6357
|
+
"ad-hoc",
|
|
6358
|
+
"development",
|
|
6359
|
+
"enterprise"
|
|
6360
|
+
]);
|
|
6361
|
+
/**
|
|
6362
|
+
* How many older builds of a scope one read takes, looking for one older than
|
|
6363
|
+
* a bundle when a build made after the bundle is the newest.
|
|
6364
|
+
*/
|
|
6365
|
+
const OLDER_BUILDS_PAGE = 20;
|
|
6366
|
+
/** How many times a mark runs again after losing its scope's mark to another. */
|
|
6367
|
+
const MARK_ATTEMPTS = 8;
|
|
5922
6368
|
/** `native_builds.build_number`'s bound in core's schema. */
|
|
5923
6369
|
const BUILD_NUMBER_MAX_LENGTH = 64;
|
|
5924
6370
|
/** `native_builds.submitted_version`'s bound in core's schema. */
|
|
5925
6371
|
const SUBMITTED_VERSION_MAX_LENGTH = 255;
|
|
6372
|
+
const checkedScopeKey = (scopeKey) => {
|
|
6373
|
+
if (scopeKey.length > SCOPE_KEY_MAX_LENGTH) throw new NativeBuildInputError(`Invalid native build scope: its key is longer than ${SCOPE_KEY_MAX_LENGTH} characters; shorten the channel or app version.`);
|
|
6374
|
+
return scopeKey;
|
|
6375
|
+
};
|
|
6376
|
+
/**
|
|
6377
|
+
* How a registered artifact installs: an `.ipa` by its export method, and
|
|
6378
|
+
* `unknown` for one whose export no profile confirmed, which no lookup asks
|
|
6379
|
+
* for, so it is never reused as either.
|
|
6380
|
+
*/
|
|
6381
|
+
const registeredDistribution = (kind, exportMethod) => kind !== "ipa" ? DISTRIBUTIONS[kind][0] : exportMethod === void 0 || exportMethod === null ? "unknown" : exportMethod === "app-store" ? "store" : "direct";
|
|
6382
|
+
/**
|
|
6383
|
+
* A sandbox build scope's key, which names no channel: the app ID, URL
|
|
6384
|
+
* scheme, artifact kind and distribution in its place, then the fingerprint,
|
|
6385
|
+
* or the app-version strategy and the exact app version. `v1:sandbox:` is no
|
|
6386
|
+
* Release Catalog strategy, so it never meets a normal build's key.
|
|
6387
|
+
*/
|
|
6388
|
+
const sandboxScopeKey = (scope, sandbox) => {
|
|
6389
|
+
const { appId, urlScheme, artifactKind, distribution } = sandbox;
|
|
6390
|
+
const problem = typeof appId !== "string" || !APP_ID.test(appId) ? "its app ID must be a bundle identifier or application ID, up to 255 characters" : typeof urlScheme !== "string" || !URL_SCHEME.test(urlScheme) ? `its URL scheme must be a URL scheme in lower case, up to ${SANDBOX_URL_SCHEME_MAX_LENGTH} characters` : !ARTIFACT_KINDS[scope.platform]?.includes(artifactKind) ? `its artifact kind must be one an ${scope.platform} build makes` : distribution !== "unknown" && !DISTRIBUTIONS[artifactKind].includes(distribution) ? `an .${artifactKind} doesn't install as ${String(distribution)}` : scope.fingerprintHash !== null && !FINGERPRINT_HASH.test(scope.fingerprintHash) ? "its fingerprint hash must be 1-255 URL-safe ASCII characters" : null;
|
|
6391
|
+
if (problem !== null) throw new NativeBuildInputError(`Invalid sandbox build scope: ${problem}.`);
|
|
6392
|
+
const target = scope.fingerprintHash === null ? `app-version:${encodeURIComponent(scope.appVersion)}` : `fingerprint:${scope.fingerprintHash}`;
|
|
6393
|
+
return checkedScopeKey(`v1:sandbox:${scope.platform}:${appId}:${urlScheme}:${artifactKind}:${distribution}:${target}`);
|
|
6394
|
+
};
|
|
5926
6395
|
/**
|
|
5927
6396
|
* A native build scope's key: the Release Catalog scope key of a
|
|
5928
6397
|
* fingerprint, or of the app-version strategy followed by the exact app
|
|
5929
6398
|
* version the build compiled in. One key serves both strategies, so one
|
|
5930
|
-
* index finds the newest build of either.
|
|
6399
|
+
* index finds the newest build of either. A sandbox scope's key names no
|
|
6400
|
+
* channel, so pull requests find a sandbox build on any.
|
|
5931
6401
|
*/
|
|
5932
6402
|
const nativeBuildScopeKey = (scope) => {
|
|
6403
|
+
const { sandbox } = scope;
|
|
6404
|
+
if (sandbox !== void 0 && sandbox !== null) {
|
|
6405
|
+
if (sandbox.distribution !== "direct" && sandbox.distribution !== "store") throw new NativeBuildInputError("Invalid sandbox build scope: its distribution must be direct or store.");
|
|
6406
|
+
return sandboxScopeKey(scope, sandbox);
|
|
6407
|
+
}
|
|
5933
6408
|
let scopeKey;
|
|
5934
6409
|
try {
|
|
5935
6410
|
const channelKey = encodeChannelKey(scope.channel);
|
|
@@ -5946,22 +6421,71 @@ const nativeBuildScopeKey = (scope) => {
|
|
|
5946
6421
|
} catch (error) {
|
|
5947
6422
|
throw new NativeBuildInputError(`Invalid native build scope: ${error instanceof Error ? error.message : String(error)}.`);
|
|
5948
6423
|
}
|
|
5949
|
-
|
|
5950
|
-
|
|
6424
|
+
return checkedScopeKey(scopeKey);
|
|
6425
|
+
};
|
|
6426
|
+
/** The channel row a registration names, or the refusal of its channel. */
|
|
6427
|
+
const channelIdOf = (channel) => {
|
|
6428
|
+
try {
|
|
6429
|
+
return `channel:${encodeChannelKey(channel)}`;
|
|
6430
|
+
} catch (error) {
|
|
6431
|
+
throw new NativeBuildInputError(`Invalid native build scope: ${error instanceof Error ? error.message : String(error)}.`);
|
|
6432
|
+
}
|
|
6433
|
+
};
|
|
6434
|
+
/**
|
|
6435
|
+
* A registration's scope key, from the registration's own facts: a sandbox
|
|
6436
|
+
* build's from what its artifact says, whatever `sandbox` it names.
|
|
6437
|
+
*/
|
|
6438
|
+
const registrationScopeKey = (registration) => {
|
|
6439
|
+
channelIdOf(registration.channel);
|
|
6440
|
+
return registration.isSandbox === true ? sandboxScopeKey(registration, {
|
|
6441
|
+
appId: registration.sandboxAppId,
|
|
6442
|
+
urlScheme: registration.sandboxUrlScheme,
|
|
6443
|
+
artifactKind: registration.artifact.kind,
|
|
6444
|
+
distribution: registeredDistribution(registration.artifact.kind, registration.exportMethod)
|
|
6445
|
+
}) : nativeBuildScopeKey({
|
|
6446
|
+
...registration,
|
|
6447
|
+
sandbox: null
|
|
6448
|
+
});
|
|
6449
|
+
};
|
|
6450
|
+
/**
|
|
6451
|
+
* Refuses a patch from a sandbox build's built-in bundle: no deploy patches
|
|
6452
|
+
* from one, so no store or test install of the app gets a patch made for a
|
|
6453
|
+
* sandbox build. One unique read of the base.
|
|
6454
|
+
*/
|
|
6455
|
+
const refuseSandboxPatchBase = async (db, baseBundleId) => {
|
|
6456
|
+
if ((await db.findOne("native_builds", { min_bundle_id: baseBundleId }))?.is_sandbox === true) throw new NativeBuildInputError("A sandbox build's built-in bundle is no patch base.");
|
|
5951
6457
|
};
|
|
5952
6458
|
/** Whether `bundleId` is a native build's built-in bundle: one unique read. */
|
|
5953
6459
|
const isBuiltInBundle = async (db, bundleId) => await db.findOne("native_builds", { min_bundle_id: bundleId }) !== null;
|
|
5954
|
-
const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, artifact }) => {
|
|
6460
|
+
const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, sandboxUrlScheme, sandboxAppId, exportMethod, nativeAppVersion, artifact }) => {
|
|
5955
6461
|
if (!isUUIDv7(id)) return "id must be a UUIDv7";
|
|
5956
6462
|
if (!isUUIDv7(minBundleId)) return "minBundleId must be the UUIDv7 a release build compiles in";
|
|
5957
6463
|
if (platform !== "ios" && platform !== "android") return "platform must be ios or android";
|
|
5958
6464
|
if (channel.trim().length === 0) return "channel is required";
|
|
6465
|
+
if (isSandbox !== void 0 && typeof isSandbox !== "boolean") return "isSandbox must be true or false";
|
|
6466
|
+
if (sandboxUrlScheme !== void 0 && sandboxUrlScheme !== null) {
|
|
6467
|
+
if (isSandbox !== true) return "sandboxUrlScheme is a sandbox build's, and this isn't one";
|
|
6468
|
+
if (typeof sandboxUrlScheme !== "string" || !URL_SCHEME.test(sandboxUrlScheme)) return `sandboxUrlScheme must be a URL scheme in lower case, up to ${SANDBOX_URL_SCHEME_MAX_LENGTH} characters, or null`;
|
|
6469
|
+
}
|
|
6470
|
+
if (sandboxAppId !== void 0 && sandboxAppId !== null) {
|
|
6471
|
+
if (isSandbox !== true) return "sandboxAppId is a sandbox build's, and this isn't one";
|
|
6472
|
+
if (typeof sandboxAppId !== "string" || !APP_ID.test(sandboxAppId)) return "sandboxAppId must be the artifact's bundle identifier or application ID, up to 255 characters";
|
|
6473
|
+
}
|
|
6474
|
+
if (isSandbox === true) {
|
|
6475
|
+
if (sandboxUrlScheme === void 0 || sandboxUrlScheme === null) return "a sandbox build needs the sandboxUrlScheme its artifact registers";
|
|
6476
|
+
if (sandboxAppId === void 0 || sandboxAppId === null) return "a sandbox build needs the sandboxAppId its artifact reports, which an older hot-updater CLI doesn't send. Upgrade the hot-updater CLI to the version that matches this server, and build again";
|
|
6477
|
+
}
|
|
5959
6478
|
if (gitCommitHash !== null && gitCommitHash.length > GIT_COMMIT_HASH_MAX_LENGTH) return `gitCommitHash must be at most ${GIT_COMMIT_HASH_MAX_LENGTH} characters`;
|
|
5960
6479
|
if (fingerprintHash === null === (appVersion === null)) return "exactly one of fingerprintHash and appVersion is required";
|
|
5961
6480
|
if (buildKey !== null && !BUILD_KEY.test(buildKey)) return "buildKey must be nbk1: and a SHA-256, or null";
|
|
5962
6481
|
if (buildNumber !== void 0 && buildNumber !== null && (buildNumber.trim().length === 0 || buildNumber.length > BUILD_NUMBER_MAX_LENGTH)) return `buildNumber must be the artifact's build number, up to ${BUILD_NUMBER_MAX_LENGTH} characters, or null`;
|
|
6482
|
+
if (nativeAppVersion !== void 0 && nativeAppVersion !== null && (typeof nativeAppVersion !== "string" || nativeAppVersion.trim().length === 0)) return "nativeAppVersion must be the artifact's app version, or null";
|
|
5963
6483
|
const kinds = ARTIFACT_KINDS[platform];
|
|
5964
6484
|
if (!kinds.includes(artifact.kind)) return `artifact.kind of an ${platform} build must be ${kinds.join(" or ")}`;
|
|
6485
|
+
if (exportMethod !== void 0 && exportMethod !== null) {
|
|
6486
|
+
if (artifact.kind !== "ipa") return "exportMethod is an .ipa's, and this artifact isn't one";
|
|
6487
|
+
if (!EXPORT_METHODS.has(exportMethod)) return `exportMethod must be ${[...EXPORT_METHODS].join(", ")}, or null`;
|
|
6488
|
+
}
|
|
5965
6489
|
if (!Number.isSafeInteger(artifact.byteSize) || artifact.byteSize < 0) return "artifact.byteSize must be a byte count";
|
|
5966
6490
|
return null;
|
|
5967
6491
|
};
|
|
@@ -5970,8 +6494,8 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
5970
6494
|
async registerNativeBuild(registration) {
|
|
5971
6495
|
const problem = problemOf(registration);
|
|
5972
6496
|
if (problem !== null) throw new NativeBuildInputError(`Invalid native build: ${problem}.`);
|
|
5973
|
-
const scopeKey =
|
|
5974
|
-
const channelId =
|
|
6497
|
+
const scopeKey = registrationScopeKey(registration);
|
|
6498
|
+
const channelId = channelIdOf(registration.channel);
|
|
5975
6499
|
const { embeddedBundle } = registration;
|
|
5976
6500
|
const row = {
|
|
5977
6501
|
id: registration.id,
|
|
@@ -5990,7 +6514,12 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
5990
6514
|
build_number: registration.buildNumber ?? null,
|
|
5991
6515
|
submitted_to: null,
|
|
5992
6516
|
submitted_at_ms: null,
|
|
5993
|
-
submitted_version: null
|
|
6517
|
+
submitted_version: null,
|
|
6518
|
+
is_store_build: false,
|
|
6519
|
+
is_sandbox: registration.isSandbox === true,
|
|
6520
|
+
sandbox_url_scheme: registration.sandboxUrlScheme ?? null,
|
|
6521
|
+
export_method: registration.exportMethod ?? null,
|
|
6522
|
+
native_app_version: registration.nativeAppVersion ?? null
|
|
5994
6523
|
};
|
|
5995
6524
|
for (let attempt = 1;; attempt += 1) {
|
|
5996
6525
|
await insertChannel(db, {
|
|
@@ -6028,21 +6557,43 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
6028
6557
|
const scopeKey = nativeBuildScopeKey(scope);
|
|
6029
6558
|
const buildKey = options?.buildKey;
|
|
6030
6559
|
if (buildKey !== void 0 && !BUILD_KEY.test(buildKey)) throw new NativeBuildInputError("Invalid native build key: it must be nbk1: and a SHA-256.");
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6560
|
+
if (options?.storeBuild) {
|
|
6561
|
+
const marked = await db.findOne("native_builds", { store_build_scope_key: scopeKey });
|
|
6562
|
+
return marked === null ? null : pick(marked);
|
|
6563
|
+
}
|
|
6564
|
+
const read = (limit, before) => {
|
|
6565
|
+
const page = {
|
|
6566
|
+
order: "desc",
|
|
6567
|
+
limit,
|
|
6568
|
+
...before === void 0 ? {} : { range: { lt: before } }
|
|
6569
|
+
};
|
|
6570
|
+
return buildKey === void 0 ? db.findMany("native_builds", {
|
|
6571
|
+
index: "byScope",
|
|
6572
|
+
where: { scope_key: scopeKey },
|
|
6573
|
+
...page
|
|
6574
|
+
}) : db.findMany("native_builds", {
|
|
6575
|
+
index: "byBuildKey",
|
|
6576
|
+
where: {
|
|
6577
|
+
scope_key: scopeKey,
|
|
6578
|
+
build_key: buildKey
|
|
6579
|
+
},
|
|
6580
|
+
...page
|
|
6581
|
+
});
|
|
6582
|
+
};
|
|
6583
|
+
const bundleId = options?.builtInOlderThan;
|
|
6584
|
+
if (bundleId !== void 0 && scope.sandbox !== void 0 && scope.sandbox !== null) return null;
|
|
6585
|
+
const { rows } = await read(1);
|
|
6586
|
+
const newest = rows[0];
|
|
6587
|
+
if (newest === void 0) return null;
|
|
6588
|
+
if (bundleId === void 0 || newest.min_bundle_id < bundleId) return pick(newest);
|
|
6589
|
+
for (let before = newest.id;;) {
|
|
6590
|
+
const { rows: older } = await read(OLDER_BUILDS_PAGE, before);
|
|
6591
|
+
const usable = older.find(({ min_bundle_id }) => min_bundle_id < bundleId);
|
|
6592
|
+
if (usable !== void 0) return pick(usable);
|
|
6593
|
+
const last = older.at(-1);
|
|
6594
|
+
if (older.length < OLDER_BUILDS_PAGE || last === void 0) return null;
|
|
6595
|
+
before = last.id;
|
|
6596
|
+
}
|
|
6046
6597
|
},
|
|
6047
6598
|
async recordNativeBuildSubmission(id, { destination, version }) {
|
|
6048
6599
|
if (version.trim().length === 0 || version.length > SUBMITTED_VERSION_MAX_LENGTH) throw new NativeBuildInputError(`Invalid native build submission: version must be the store's label of the build, up to ${SUBMITTED_VERSION_MAX_LENGTH} characters.`);
|
|
@@ -6050,7 +6601,8 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
6050
6601
|
const row = await tx.findOne("native_builds", { id });
|
|
6051
6602
|
if (row === null) return null;
|
|
6052
6603
|
const build = pick(row);
|
|
6053
|
-
if (
|
|
6604
|
+
if (!NATIVE_BUILD_SUBMISSION_DESTINATIONS[build.platform].includes(destination)) throw new NativeBuildInputError(`Invalid native build submission: an ${build.platform} build is submitted to ${NATIVE_BUILD_SUBMISSION_DESTINATIONS[build.platform].join(" or ")}, not ${destination}.`);
|
|
6605
|
+
if (build.is_sandbox && destination !== "testflight" && destination !== "play-internal") throw new NativeBuildInputError("A sandbox build can submit only to TestFlight or Play internal testing.");
|
|
6054
6606
|
const set = {
|
|
6055
6607
|
submitted_to: destination,
|
|
6056
6608
|
submitted_at_ms: now(),
|
|
@@ -6063,6 +6615,46 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
6063
6615
|
};
|
|
6064
6616
|
});
|
|
6065
6617
|
},
|
|
6618
|
+
async markNativeBuild(id, { storeBuild }) {
|
|
6619
|
+
for (let attempt = 1;; attempt += 1) try {
|
|
6620
|
+
return await db.transaction(async (tx) => {
|
|
6621
|
+
const row = await tx.findOne("native_builds", { id });
|
|
6622
|
+
if (row === null) return null;
|
|
6623
|
+
const build = pick(row);
|
|
6624
|
+
if (!storeBuild) {
|
|
6625
|
+
if (build.is_store_build) tx.update("native_builds", row, { is_store_build: false });
|
|
6626
|
+
return {
|
|
6627
|
+
nativeBuild: {
|
|
6628
|
+
...build,
|
|
6629
|
+
is_store_build: false
|
|
6630
|
+
},
|
|
6631
|
+
previous: null
|
|
6632
|
+
};
|
|
6633
|
+
}
|
|
6634
|
+
if (build.is_sandbox) throw new NativeBuildInputError("A sandbox build can't be the store build.");
|
|
6635
|
+
if (build.is_store_build) return {
|
|
6636
|
+
nativeBuild: build,
|
|
6637
|
+
previous: null
|
|
6638
|
+
};
|
|
6639
|
+
const holder = await tx.findOne("native_builds", { store_build_scope_key: build.scope_key });
|
|
6640
|
+
if (holder !== null) tx.update("native_builds", holder, { is_store_build: false });
|
|
6641
|
+
tx.update("native_builds", row, { is_store_build: true });
|
|
6642
|
+
return {
|
|
6643
|
+
nativeBuild: {
|
|
6644
|
+
...build,
|
|
6645
|
+
is_store_build: true
|
|
6646
|
+
},
|
|
6647
|
+
previous: holder === null ? null : {
|
|
6648
|
+
...pick(holder),
|
|
6649
|
+
is_store_build: false
|
|
6650
|
+
}
|
|
6651
|
+
};
|
|
6652
|
+
});
|
|
6653
|
+
} catch (error) {
|
|
6654
|
+
if (attempt < MARK_ATTEMPTS && error instanceof DatabaseConstraintError && error.reason === "unique") continue;
|
|
6655
|
+
throw error;
|
|
6656
|
+
}
|
|
6657
|
+
},
|
|
6066
6658
|
async deleteNativeBuild(id) {
|
|
6067
6659
|
return db.transaction(async (tx) => {
|
|
6068
6660
|
const row = await tx.findOne("native_builds", { id });
|
|
@@ -6409,7 +7001,11 @@ const createCoreOperations = (db, { now = Date.now } = {}) => {
|
|
|
6409
7001
|
for (const { release } of deployments) if (!channels.has(release.channel)) channels.set(release.channel, await ensureChannel(release.channel));
|
|
6410
7002
|
const platforms = /* @__PURE__ */ new Map();
|
|
6411
7003
|
for (const deployment of deployments) {
|
|
6412
|
-
if (!("bundleId" in deployment)
|
|
7004
|
+
if (!("bundleId" in deployment)) {
|
|
7005
|
+
for (const { baseBundleId } of deployment.bundle.patches ?? []) await refuseSandboxPatchBase(db, baseBundleId);
|
|
7006
|
+
continue;
|
|
7007
|
+
}
|
|
7008
|
+
if (platforms.has(deployment.bundleId)) continue;
|
|
6413
7009
|
const row = await db.findOne("bundles", { id: deployment.bundleId });
|
|
6414
7010
|
if (row === null) throw new DatabaseBundleNotFoundError(deployment.bundleId);
|
|
6415
7011
|
if (await isBuiltInBundle(db, deployment.bundleId)) throw new ReleaseManagementError("TARGET_RELEASE_INVALID", `Bundle "${deployment.bundleId}" is a native build's built-in bundle, which no release publishes.`);
|
|
@@ -6613,7 +7209,7 @@ const createCoreOperations = (db, { now = Date.now } = {}) => {
|
|
|
6613
7209
|
if (patches !== void 0) await replaceBundlePatches(tx, current, bundleToPatchRows({
|
|
6614
7210
|
...next,
|
|
6615
7211
|
patches
|
|
6616
|
-
}));
|
|
7212
|
+
}), (row) => refuseSandboxPatchBase(tx, row.base_bundle_id));
|
|
6617
7213
|
}),
|
|
6618
7214
|
deleteBundles: async (ids) => {
|
|
6619
7215
|
try {
|
|
@@ -6675,6 +7271,7 @@ const createCoreApi = (db, storage, options = {}) => {
|
|
|
6675
7271
|
...reads,
|
|
6676
7272
|
...createCoreOperations(purgingCachedRoutes(db, options.onCachedRoutesChange), options),
|
|
6677
7273
|
...createNativeBuildApi(db, options),
|
|
7274
|
+
...createIosDeviceApi(db, options),
|
|
6678
7275
|
/** One read, which checks the schema settings first. */
|
|
6679
7276
|
ready: async () => {
|
|
6680
7277
|
await reads.listReleaseCatalogs({ limit: 1 });
|
|
@@ -6894,10 +7491,12 @@ const keyset = (url, maxValue = LIMITS.maxValue) => {
|
|
|
6894
7491
|
const limit = limitParam === null ? Math.min(LIMITS.defaultValue, maxValue) : Number(limitParam);
|
|
6895
7492
|
if (!Number.isSafeInteger(limit) || limit < 1 || limit > maxValue) throw new HandlerBadRequestError(`limit must be between 1 and ${maxValue}.`);
|
|
6896
7493
|
const cursor = url.searchParams.get("cursor");
|
|
7494
|
+
const through = url.searchParams.get("through");
|
|
6897
7495
|
return {
|
|
6898
7496
|
order,
|
|
6899
7497
|
limit,
|
|
6900
|
-
...cursor === null ? {} : { after: cursor }
|
|
7498
|
+
...cursor === null ? {} : { after: cursor },
|
|
7499
|
+
...through === null ? {} : { through }
|
|
6901
7500
|
};
|
|
6902
7501
|
};
|
|
6903
7502
|
/** A page and the cursor of the next one, when the page is full. */
|
|
@@ -6995,7 +7594,8 @@ const nativeBuildScopeOf = (url) => {
|
|
|
6995
7594
|
const fingerprintHash = params.get("fingerprintHash");
|
|
6996
7595
|
const appVersion = params.get("appVersion");
|
|
6997
7596
|
if (platform === void 0 || !isText$2(channel) || fingerprintHash === null === (appVersion === null) || fingerprintHash === "" || appVersion === "") throw new HandlerBadRequestError("A native build lookup needs platform, channel, and fingerprintHash or appVersion.");
|
|
6998
|
-
|
|
7597
|
+
const sandbox = sandboxScopeOf(params);
|
|
7598
|
+
const scope = fingerprintHash !== null ? {
|
|
6999
7599
|
platform,
|
|
7000
7600
|
channel,
|
|
7001
7601
|
fingerprintHash,
|
|
@@ -7006,17 +7606,49 @@ const nativeBuildScopeOf = (url) => {
|
|
|
7006
7606
|
fingerprintHash: null,
|
|
7007
7607
|
appVersion
|
|
7008
7608
|
};
|
|
7609
|
+
return sandbox === null ? scope : {
|
|
7610
|
+
...scope,
|
|
7611
|
+
sandbox
|
|
7612
|
+
};
|
|
7613
|
+
};
|
|
7614
|
+
/** The query parameters a sandbox lookup names, all four or none. */
|
|
7615
|
+
const SANDBOX_SCOPE_PARAMS = [
|
|
7616
|
+
"sandboxAppId",
|
|
7617
|
+
"sandboxUrlScheme",
|
|
7618
|
+
"artifactKind",
|
|
7619
|
+
"distribution"
|
|
7620
|
+
];
|
|
7621
|
+
/**
|
|
7622
|
+
* A lookup's sandbox scope: null without one, and a bad request for one
|
|
7623
|
+
* named in part. Core checks each value.
|
|
7624
|
+
*/
|
|
7625
|
+
const sandboxScopeOf = (params) => {
|
|
7626
|
+
const [appId, urlScheme, artifactKind, distribution] = SANDBOX_SCOPE_PARAMS.map((name) => params.get(name));
|
|
7627
|
+
const named = [
|
|
7628
|
+
appId,
|
|
7629
|
+
urlScheme,
|
|
7630
|
+
artifactKind,
|
|
7631
|
+
distribution
|
|
7632
|
+
].filter((value) => value !== null).length;
|
|
7633
|
+
if (named === 0) return null;
|
|
7634
|
+
if (named !== SANDBOX_SCOPE_PARAMS.length) throw new HandlerBadRequestError(`A sandbox build lookup needs ${SANDBOX_SCOPE_PARAMS.join(", ")}.`);
|
|
7635
|
+
return {
|
|
7636
|
+
appId,
|
|
7637
|
+
urlScheme,
|
|
7638
|
+
artifactKind,
|
|
7639
|
+
distribution
|
|
7640
|
+
};
|
|
7009
7641
|
};
|
|
7010
7642
|
/** A native build or scope core refuses: a bad request. */
|
|
7011
7643
|
const refusingInvalid = async (operation) => {
|
|
7012
7644
|
try {
|
|
7013
7645
|
return await operation();
|
|
7014
7646
|
} catch (error) {
|
|
7015
|
-
if (error instanceof NativeBuildInputError) throw new HandlerBadRequestError(error.message);
|
|
7647
|
+
if (error instanceof NativeBuildInputError || error instanceof IosDeviceInputError) throw new HandlerBadRequestError(error.message);
|
|
7016
7648
|
throw error;
|
|
7017
7649
|
}
|
|
7018
7650
|
};
|
|
7019
|
-
const isNativeBuildRegistration = (value) => isRecord$5(value) && isText$2(value.id) && isText$2(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText$2(value.channel) && isTextOrNull$1(value.fingerprintHash) && isTextOrNull$1(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull$1(value.gitCommitHash) && isTextOrNull$1(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull$1(value.buildNumber)) && isRecord$5(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText$2(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord$5(value.embeddedBundle) && isText$2(value.embeddedBundle.manifestStorageUri) && isText$2(value.embeddedBundle.manifestFileHash) && isText$2(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord$5(value.embeddedBundle.metadata));
|
|
7651
|
+
const isNativeBuildRegistration = (value) => isRecord$5(value) && isText$2(value.id) && isText$2(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText$2(value.channel) && isTextOrNull$1(value.fingerprintHash) && isTextOrNull$1(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull$1(value.gitCommitHash) && isTextOrNull$1(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull$1(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && (value.sandboxUrlScheme === void 0 || isTextOrNull$1(value.sandboxUrlScheme)) && (value.sandboxAppId === void 0 || isTextOrNull$1(value.sandboxAppId)) && (value.exportMethod === void 0 || isTextOrNull$1(value.exportMethod)) && (value.nativeAppVersion === void 0 || isTextOrNull$1(value.nativeAppVersion)) && isRecord$5(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText$2(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord$5(value.embeddedBundle) && isText$2(value.embeddedBundle.manifestStorageUri) && isText$2(value.embeddedBundle.manifestFileHash) && isText$2(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord$5(value.embeddedBundle.metadata));
|
|
7020
7652
|
const scopeKeyOf = (params) => decodeMaybe(requireRouteParam(params, "scopeKey")) ?? "";
|
|
7021
7653
|
/** Every admin route's handler, by the name `ADMIN_ROUTES` mounts it under. */
|
|
7022
7654
|
const createAdminRouteHandlers = () => ({
|
|
@@ -7098,7 +7730,8 @@ const createAdminRouteHandlers = () => ({
|
|
|
7098
7730
|
rebuildReleaseCatalog: onCore(async (core, _request, params) => json$2({ data: await core.rebuildReleaseCatalog(scopeKeyOf(params)) })),
|
|
7099
7731
|
updateBundle: onCore(async (core, request, params) => {
|
|
7100
7732
|
const bundleId = requireRouteParam(params, "id");
|
|
7101
|
-
|
|
7733
|
+
const update = bundleUpdateOf(await request.json(), bundleId);
|
|
7734
|
+
await refusingInvalid(() => core.updateBundle(bundleId, update));
|
|
7102
7735
|
return noContent();
|
|
7103
7736
|
}),
|
|
7104
7737
|
countBundles: onCore(async (core, request) => json$2({ data: await core.countBundles(platformOf(new URL(request.url))) })),
|
|
@@ -7122,7 +7755,7 @@ const createAdminRouteHandlers = () => ({
|
|
|
7122
7755
|
deployReleases: onCore(async (core, request) => {
|
|
7123
7756
|
const { deployments } = await body(request);
|
|
7124
7757
|
if (!Array.isArray(deployments) || deployments.length === 0 || !deployments.every(isDeployment)) throw new HandlerBadRequestError("Deploy needs deployments, each a bundle and its release policy.");
|
|
7125
|
-
return json$2({ data: await core.deploy(deployments) }, 201);
|
|
7758
|
+
return json$2({ data: await refusingInvalid(() => core.deploy(deployments)) }, 201);
|
|
7126
7759
|
}),
|
|
7127
7760
|
promoteRelease: onCore(async (core, request, params) => {
|
|
7128
7761
|
const input = await body(request);
|
|
@@ -7145,7 +7778,13 @@ const createAdminRouteHandlers = () => ({
|
|
|
7145
7778
|
const url = new URL(request.url);
|
|
7146
7779
|
const scope = nativeBuildScopeOf(url);
|
|
7147
7780
|
const buildKey = url.searchParams.get("buildKey");
|
|
7148
|
-
|
|
7781
|
+
const builtInOlderThan = url.searchParams.get("builtInOlderThan");
|
|
7782
|
+
const options = {
|
|
7783
|
+
...buildKey === null ? {} : { buildKey },
|
|
7784
|
+
...url.searchParams.get("storeBuild") === "true" ? { storeBuild: true } : {},
|
|
7785
|
+
...builtInOlderThan === null ? {} : { builtInOlderThan }
|
|
7786
|
+
};
|
|
7787
|
+
return json$2({ data: await refusingInvalid(() => Object.keys(options).length === 0 ? core.findNativeBuild(scope) : core.findNativeBuild(scope, options)) });
|
|
7149
7788
|
}),
|
|
7150
7789
|
getNativeBuild: onCore(async (core, _request, params) => json$2({ data: await core.getNativeBuild(requireRouteParam(params, "id")) })),
|
|
7151
7790
|
listNativeBuilds: onCore(async (core, request) => {
|
|
@@ -7159,14 +7798,96 @@ const createAdminRouteHandlers = () => ({
|
|
|
7159
7798
|
}),
|
|
7160
7799
|
recordNativeBuildSubmission: onCore(async (core, request, params) => {
|
|
7161
7800
|
const input = await body(request);
|
|
7162
|
-
if (!isRecord$5(input) ||
|
|
7801
|
+
if (!isRecord$5(input) || !Object.values(NATIVE_BUILD_SUBMISSION_DESTINATIONS).flat().includes(input.destination) || !isText$2(input.version)) throw new HandlerBadRequestError("A native build submission needs a valid store destination and version.");
|
|
7163
7802
|
const submission = {
|
|
7164
7803
|
destination: input.destination,
|
|
7165
7804
|
version: input.version
|
|
7166
7805
|
};
|
|
7167
7806
|
return json$2({ data: await refusingInvalid(() => core.recordNativeBuildSubmission(requireRouteParam(params, "id"), submission)) });
|
|
7168
7807
|
}),
|
|
7808
|
+
markNativeBuild: onCore(async (core, request, params) => {
|
|
7809
|
+
const input = await body(request);
|
|
7810
|
+
if (!isRecord$5(input) || typeof input.storeBuild !== "boolean") throw new HandlerBadRequestError("A native build's store build mark needs storeBuild, true or false.");
|
|
7811
|
+
const mark = { storeBuild: input.storeBuild };
|
|
7812
|
+
return json$2({ data: await refusingInvalid(() => core.markNativeBuild(requireRouteParam(params, "id"), mark)) });
|
|
7813
|
+
}),
|
|
7169
7814
|
deleteNativeBuild: onCore(async (core, _request, params) => json$2({ data: await core.deleteNativeBuild(requireRouteParam(params, "id")) })),
|
|
7815
|
+
listIosDevices: onCore(async (core, request) => {
|
|
7816
|
+
const url = new URL(request.url);
|
|
7817
|
+
const input = keyset(url);
|
|
7818
|
+
const status = url.searchParams.get("status");
|
|
7819
|
+
return page(await refusingInvalid(() => core.listIosDevices({
|
|
7820
|
+
...input,
|
|
7821
|
+
...status === null ? {} : { status }
|
|
7822
|
+
})), input, ({ id }) => id);
|
|
7823
|
+
}),
|
|
7824
|
+
findIosDevice: onCore(async (core, _request, params) => json$2({ data: await core.findIosDevice(requireRouteParam(params, "udid")) })),
|
|
7825
|
+
requestIosDevice: onCore(async (core, request) => {
|
|
7826
|
+
const input = await body(request);
|
|
7827
|
+
if (!isText$2(input.udid) || !isText$2(input.name) || !isTextOrNull$1(input.requestedBy)) throw new HandlerBadRequestError("An iOS device request needs udid, name, and requestedBy, an email or null.");
|
|
7828
|
+
const device = {
|
|
7829
|
+
udid: input.udid,
|
|
7830
|
+
name: input.name,
|
|
7831
|
+
requestedBy: input.requestedBy
|
|
7832
|
+
};
|
|
7833
|
+
return json$2({ data: await refusingInvalid(() => core.requestIosDevice(device)) });
|
|
7834
|
+
}),
|
|
7835
|
+
approveIosDevice: onCore(async (core, request, params) => {
|
|
7836
|
+
const input = await body(request);
|
|
7837
|
+
if (!isTextOrNull$1(input.approvedBy) || input.name !== void 0 && !isText$2(input.name)) throw new HandlerBadRequestError("An iOS device approval needs approvedBy, an email or null, and an optional name.");
|
|
7838
|
+
const approval = {
|
|
7839
|
+
approvedBy: input.approvedBy,
|
|
7840
|
+
...input.name === void 0 ? {} : { name: input.name }
|
|
7841
|
+
};
|
|
7842
|
+
return json$2({ data: await refusingInvalid(() => core.approveIosDevice(requireRouteParam(params, "id"), approval)) });
|
|
7843
|
+
}),
|
|
7844
|
+
renameIosDevice: onCore(async (core, request, params) => {
|
|
7845
|
+
const input = await body(request);
|
|
7846
|
+
if (!isText$2(input.name)) throw new HandlerBadRequestError("An iOS device's new name is required.");
|
|
7847
|
+
const name = input.name;
|
|
7848
|
+
return json$2({ data: await refusingInvalid(() => core.renameIosDevice(requireRouteParam(params, "id"), name)) });
|
|
7849
|
+
}),
|
|
7850
|
+
recordIosDeviceOutcome: onCore(async (core, request, params) => {
|
|
7851
|
+
const input = await body(request);
|
|
7852
|
+
const seen = input.seen;
|
|
7853
|
+
if (!isRecord$5(seen) || typeof seen.status !== "string" || !(seen.approvedAtMs === null || Number.isSafeInteger(seen.approvedAtMs)) || !isText$2(input.issuerId) || typeof input.outcome !== "string" || input.reason !== void 0 && typeof input.reason !== "string") throw new HandlerBadRequestError("An iOS device outcome needs seen { status, approvedAtMs }, issuerId, outcome, and an optional reason.");
|
|
7854
|
+
const outcome = {
|
|
7855
|
+
id: requireRouteParam(params, "id"),
|
|
7856
|
+
seen: {
|
|
7857
|
+
status: seen.status,
|
|
7858
|
+
approvedAtMs: seen.approvedAtMs
|
|
7859
|
+
},
|
|
7860
|
+
issuerId: input.issuerId,
|
|
7861
|
+
outcome: input.outcome,
|
|
7862
|
+
...input.reason === void 0 ? {} : { reason: input.reason }
|
|
7863
|
+
};
|
|
7864
|
+
return json$2({ data: await refusingInvalid(() => core.recordIosDeviceOutcome(outcome)) });
|
|
7865
|
+
}),
|
|
7866
|
+
claimIosDeviceAccount: onCore(async (core, request) => {
|
|
7867
|
+
const { issuerId } = await body(request);
|
|
7868
|
+
if (!isText$2(issuerId)) throw new HandlerBadRequestError("Claiming the iOS device account needs issuerId.");
|
|
7869
|
+
return json$2({ data: await refusingInvalid(() => core.claimIosDeviceAccount(issuerId)) });
|
|
7870
|
+
}),
|
|
7871
|
+
findIosDeviceAccount: onCore(async (core) => json$2({ data: await core.findIosDeviceAccount() })),
|
|
7872
|
+
markIosDevicesInBuild: onCore(async (core, request) => {
|
|
7873
|
+
const { buildId, ids } = await body(request);
|
|
7874
|
+
if (!isText$2(buildId) || !Array.isArray(ids) || !ids.every((id) => isText$2(id))) throw new HandlerBadRequestError("Marking iOS devices in a build needs buildId and ids.");
|
|
7875
|
+
await core.markIosDevicesInBuild({
|
|
7876
|
+
buildId,
|
|
7877
|
+
ids
|
|
7878
|
+
});
|
|
7879
|
+
return noContent();
|
|
7880
|
+
}),
|
|
7881
|
+
deleteIosDevice: onCore(async (core, request, params) => {
|
|
7882
|
+
const url = new URL(request.url);
|
|
7883
|
+
const status = url.searchParams.get("status");
|
|
7884
|
+
const requestedBy = url.searchParams.get("requestedBy");
|
|
7885
|
+
const only = {
|
|
7886
|
+
...status === null ? {} : { status },
|
|
7887
|
+
...requestedBy === null ? {} : { requestedBy }
|
|
7888
|
+
};
|
|
7889
|
+
return json$2({ data: await refusingInvalid(() => Object.keys(only).length === 0 ? core.deleteIosDevice(requireRouteParam(params, "id")) : core.deleteIosDevice(requireRouteParam(params, "id"), only)) });
|
|
7890
|
+
}),
|
|
7170
7891
|
deleteBundles: onCore(async (core, request) => {
|
|
7171
7892
|
const { ids } = await body(request);
|
|
7172
7893
|
if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id.length > 0)) throw new HandlerBadRequestError("Bundle deletion needs ids");
|
|
@@ -7311,10 +8032,65 @@ const ADMIN_ROUTES = [
|
|
|
7311
8032
|
path: "/native-builds/:id/submission",
|
|
7312
8033
|
handler: "recordNativeBuildSubmission"
|
|
7313
8034
|
},
|
|
8035
|
+
{
|
|
8036
|
+
method: "POST",
|
|
8037
|
+
path: "/native-builds/:id/store-build",
|
|
8038
|
+
handler: "markNativeBuild"
|
|
8039
|
+
},
|
|
7314
8040
|
{
|
|
7315
8041
|
method: "DELETE",
|
|
7316
8042
|
path: "/native-builds/:id",
|
|
7317
8043
|
handler: "deleteNativeBuild"
|
|
8044
|
+
},
|
|
8045
|
+
{
|
|
8046
|
+
method: "GET",
|
|
8047
|
+
path: "/ios-devices",
|
|
8048
|
+
handler: "listIosDevices"
|
|
8049
|
+
},
|
|
8050
|
+
{
|
|
8051
|
+
method: "POST",
|
|
8052
|
+
path: "/ios-devices",
|
|
8053
|
+
handler: "requestIosDevice"
|
|
8054
|
+
},
|
|
8055
|
+
{
|
|
8056
|
+
method: "GET",
|
|
8057
|
+
path: "/ios-devices/udid/:udid",
|
|
8058
|
+
handler: "findIosDevice"
|
|
8059
|
+
},
|
|
8060
|
+
{
|
|
8061
|
+
method: "POST",
|
|
8062
|
+
path: "/ios-devices/in-build",
|
|
8063
|
+
handler: "markIosDevicesInBuild"
|
|
8064
|
+
},
|
|
8065
|
+
{
|
|
8066
|
+
method: "GET",
|
|
8067
|
+
path: "/ios-devices/account",
|
|
8068
|
+
handler: "findIosDeviceAccount"
|
|
8069
|
+
},
|
|
8070
|
+
{
|
|
8071
|
+
method: "POST",
|
|
8072
|
+
path: "/ios-devices/account",
|
|
8073
|
+
handler: "claimIosDeviceAccount"
|
|
8074
|
+
},
|
|
8075
|
+
{
|
|
8076
|
+
method: "POST",
|
|
8077
|
+
path: "/ios-devices/:id/approval",
|
|
8078
|
+
handler: "approveIosDevice"
|
|
8079
|
+
},
|
|
8080
|
+
{
|
|
8081
|
+
method: "POST",
|
|
8082
|
+
path: "/ios-devices/:id/outcome",
|
|
8083
|
+
handler: "recordIosDeviceOutcome"
|
|
8084
|
+
},
|
|
8085
|
+
{
|
|
8086
|
+
method: "PATCH",
|
|
8087
|
+
path: "/ios-devices/:id",
|
|
8088
|
+
handler: "renameIosDevice"
|
|
8089
|
+
},
|
|
8090
|
+
{
|
|
8091
|
+
method: "DELETE",
|
|
8092
|
+
path: "/ios-devices/:id",
|
|
8093
|
+
handler: "deleteIosDevice"
|
|
7318
8094
|
}
|
|
7319
8095
|
];
|
|
7320
8096
|
//#endregion
|
|
@@ -14295,10 +15071,30 @@ async apply() {
|
|
|
14295
15071
|
};
|
|
14296
15072
|
};
|
|
14297
15073
|
//#endregion
|
|
15074
|
+
//#region src/lazyCredentials.ts
|
|
15075
|
+
/**
|
|
15076
|
+
* `credentials` as the AWS SDK takes them: access keys with a lazy field
|
|
15077
|
+
* become a provider, which the SDK calls once, on its first request.
|
|
15078
|
+
*/
|
|
15079
|
+
const toSdkCredentials$1 = (credentials) => {
|
|
15080
|
+
if (credentials === void 0 || typeof credentials === "function") return credentials;
|
|
15081
|
+
const { accessKeyId, secretAccessKey, sessionToken, ...rest } = credentials;
|
|
15082
|
+
if (typeof accessKeyId !== "function" && typeof secretAccessKey !== "function" && typeof sessionToken !== "function") return credentials;
|
|
15083
|
+
return async () => ({
|
|
15084
|
+
...rest,
|
|
15085
|
+
accessKeyId: await resolveLazy(accessKeyId),
|
|
15086
|
+
secretAccessKey: await resolveLazy(secretAccessKey),
|
|
15087
|
+
...sessionToken === void 0 ? {} : { sessionToken: await resolveLazy(sessionToken) }
|
|
15088
|
+
});
|
|
15089
|
+
};
|
|
15090
|
+
//#endregion
|
|
14298
15091
|
//#region src/dynamoDB.ts
|
|
14299
15092
|
/** The DynamoDB client ignores the CloudFront and batching settings. */
|
|
14300
|
-
const adapterOf = ({ tableName, ...clientConfig }) => {
|
|
14301
|
-
const client = new _aws_sdk_client_dynamodb.DynamoDBClient(
|
|
15093
|
+
const adapterOf = ({ tableName, credentials, ...clientConfig }) => {
|
|
15094
|
+
const client = new _aws_sdk_client_dynamodb.DynamoDBClient({
|
|
15095
|
+
...clientConfig,
|
|
15096
|
+
credentials: toSdkCredentials$1(credentials)
|
|
15097
|
+
});
|
|
14302
15098
|
const store = createDynamoDBStore({
|
|
14303
15099
|
client,
|
|
14304
15100
|
tableName
|
|
@@ -14323,7 +15119,10 @@ const marked = (target) => ({ [DATABASE_TARGET]: target });
|
|
|
14323
15119
|
*/
|
|
14324
15120
|
const dynamoDB = (config) => {
|
|
14325
15121
|
const { client, adapter } = adapterOf(config);
|
|
14326
|
-
const cloudFront = createUpdateRouteInvalidation(
|
|
15122
|
+
const cloudFront = createUpdateRouteInvalidation({
|
|
15123
|
+
...config,
|
|
15124
|
+
credentials: toSdkCredentials$1(config.credentials)
|
|
15125
|
+
});
|
|
14327
15126
|
return {
|
|
14328
15127
|
...createEngineDatabase({
|
|
14329
15128
|
name: "dynamoDB",
|
|
@@ -14340,18 +15139,49 @@ const dynamoDB = (config) => {
|
|
|
14340
15139
|
};
|
|
14341
15140
|
};
|
|
14342
15141
|
//#endregion
|
|
14343
|
-
//#region
|
|
15142
|
+
//#region ../storage-s3/dist/index.mjs
|
|
15143
|
+
/**
|
|
15144
|
+
* `credentials` as the AWS SDK takes them: access keys with a lazy field
|
|
15145
|
+
* become a provider, which the SDK calls once, on its first request.
|
|
15146
|
+
*/
|
|
15147
|
+
const toSdkCredentials = (credentials) => {
|
|
15148
|
+
if (credentials === void 0 || typeof credentials === "function") return credentials;
|
|
15149
|
+
const { accessKeyId, secretAccessKey, sessionToken, ...rest } = credentials;
|
|
15150
|
+
if (typeof accessKeyId !== "function" && typeof secretAccessKey !== "function" && typeof sessionToken !== "function") return credentials;
|
|
15151
|
+
return async () => ({
|
|
15152
|
+
...rest,
|
|
15153
|
+
accessKeyId: await resolveLazy(accessKeyId),
|
|
15154
|
+
secretAccessKey: await resolveLazy(secretAccessKey),
|
|
15155
|
+
...sessionToken === void 0 ? {} : { sessionToken: await resolveLazy(sessionToken) }
|
|
15156
|
+
});
|
|
15157
|
+
};
|
|
14344
15158
|
/** Devices download right after the update check that returns the URL. */
|
|
14345
|
-
const
|
|
14346
|
-
|
|
14347
|
-
|
|
14348
|
-
|
|
14349
|
-
|
|
14350
|
-
|
|
15159
|
+
const DEFAULT_SIGNED_LIFETIME_SECONDS = 3600;
|
|
15160
|
+
/** SigV4's limit on a presigned URL. */
|
|
15161
|
+
const MAX_SIGNED_LIFETIME_SECONDS = 604800;
|
|
15162
|
+
/** DeleteObjects takes at most 1000 keys a request. */
|
|
15163
|
+
const DELETE_BATCH_SIZE = 1e3;
|
|
15164
|
+
const isObjectNotFoundError = (error) => {
|
|
15165
|
+
if (error instanceof Error && (error.name === "NotFound" || error.name === "NoSuchKey")) return true;
|
|
15166
|
+
return typeof error === "object" && error !== null && "$metadata" in error && error.$metadata?.httpStatusCode === 404;
|
|
15167
|
+
};
|
|
15168
|
+
const trimSlashes = (value) => value.replace(/^\/+|\/+$/g, "");
|
|
15169
|
+
/**
|
|
15170
|
+
* A storage adapter over a bucket's S3 API, which AWS S3, Cloudflare R2, and
|
|
15171
|
+
* Neon Object Storage all serve. Each provider package passes its own name,
|
|
15172
|
+
* URI protocol, and client defaults.
|
|
15173
|
+
*/
|
|
15174
|
+
const createS3Storage = ({ name, protocol }, config) => {
|
|
15175
|
+
const { bucketName, basePath, getDownloadUrl, signedUrlExpiresIn = DEFAULT_SIGNED_LIFETIME_SECONDS, credentials, ...clientConfig } = config;
|
|
15176
|
+
if (!Number.isFinite(signedUrlExpiresIn) || signedUrlExpiresIn <= 0 || signedUrlExpiresIn > MAX_SIGNED_LIFETIME_SECONDS) throw new Error(`${name} signedUrlExpiresIn must be between 1 and ${MAX_SIGNED_LIFETIME_SECONDS} seconds (seven days).`);
|
|
15177
|
+
const client = new _aws_sdk_client_s3.S3Client({
|
|
15178
|
+
...clientConfig,
|
|
15179
|
+
credentials: toSdkCredentials(credentials)
|
|
15180
|
+
});
|
|
15181
|
+
const normalizedBasePath = trimSlashes(basePath ?? "");
|
|
14351
15182
|
const getStorageKey = createStorageKeyBuilder(normalizedBasePath);
|
|
14352
15183
|
const getListPrefix = (prefix = "") => {
|
|
14353
|
-
const
|
|
14354
|
-
const value = [normalizedBasePath, normalizedPrefix].filter(Boolean).join("/");
|
|
15184
|
+
const value = [normalizedBasePath, trimSlashes(prefix)].filter(Boolean).join("/");
|
|
14355
15185
|
return value ? `${value}/` : "";
|
|
14356
15186
|
};
|
|
14357
15187
|
/**
|
|
@@ -14363,7 +15193,7 @@ function s3Storage(config) {
|
|
|
14363
15193
|
return createStorageUri({
|
|
14364
15194
|
bucket: bucketName,
|
|
14365
15195
|
key,
|
|
14366
|
-
protocol
|
|
15196
|
+
protocol
|
|
14367
15197
|
});
|
|
14368
15198
|
} catch {
|
|
14369
15199
|
return null;
|
|
@@ -14375,55 +15205,16 @@ function s3Storage(config) {
|
|
|
14375
15205
|
return key.startsWith(basePrefix) ? key.slice(basePrefix.length) : key;
|
|
14376
15206
|
};
|
|
14377
15207
|
const parseAndValidate = (storageUri) => {
|
|
14378
|
-
const parsed = parseStorageUri(storageUri,
|
|
15208
|
+
const parsed = parseStorageUri(storageUri, protocol);
|
|
14379
15209
|
if (parsed.bucket !== bucketName) throw new Error(`Bucket name mismatch: expected "${bucketName}", but found "${parsed.bucket}".`);
|
|
14380
15210
|
return parsed;
|
|
14381
15211
|
};
|
|
14382
15212
|
return createStorageAdapter({
|
|
14383
|
-
name
|
|
14384
|
-
protocol
|
|
14385
|
-
async listObjects(prefix) {
|
|
14386
|
-
const objects = [];
|
|
14387
|
-
let continuationToken;
|
|
14388
|
-
do {
|
|
14389
|
-
const response = await client.send(new _aws_sdk_client_s3.ListObjectsV2Command({
|
|
14390
|
-
Bucket: bucketName,
|
|
14391
|
-
ContinuationToken: continuationToken,
|
|
14392
|
-
Prefix: getListPrefix(prefix)
|
|
14393
|
-
}));
|
|
14394
|
-
for (const object of response.Contents ?? []) {
|
|
14395
|
-
if (!object.Key) continue;
|
|
14396
|
-
const storageUri = getListedStorageUri(object.Key);
|
|
14397
|
-
if (storageUri === null) continue;
|
|
14398
|
-
objects.push({
|
|
14399
|
-
key: getRelativeKey(object.Key),
|
|
14400
|
-
lastModifiedAt: object.LastModified,
|
|
14401
|
-
size: object.Size ?? 0,
|
|
14402
|
-
storageUri
|
|
14403
|
-
});
|
|
14404
|
-
}
|
|
14405
|
-
continuationToken = response.NextContinuationToken;
|
|
14406
|
-
} while (continuationToken);
|
|
14407
|
-
return objects;
|
|
14408
|
-
},
|
|
14409
|
-
async deleteObjects(relativeKeys) {
|
|
14410
|
-
const keys = relativeKeys.map((key) => getStorageKey(key));
|
|
14411
|
-
for (let offset = 0; offset < keys.length; offset += 1e3) {
|
|
14412
|
-
const batch = keys.slice(offset, offset + 1e3);
|
|
14413
|
-
if (batch.length === 0) continue;
|
|
14414
|
-
const response = await client.send(new _aws_sdk_client_s3.DeleteObjectsCommand({
|
|
14415
|
-
Bucket: bucketName,
|
|
14416
|
-
Delete: {
|
|
14417
|
-
Objects: batch.map((Key) => ({ Key })),
|
|
14418
|
-
Quiet: true
|
|
14419
|
-
}
|
|
14420
|
-
}));
|
|
14421
|
-
if (response.Errors && response.Errors.length > 0) throw new Error(`Failed to delete ${response.Errors.length} S3 object(s).`);
|
|
14422
|
-
}
|
|
14423
|
-
},
|
|
15213
|
+
name,
|
|
15214
|
+
protocol,
|
|
14424
15215
|
async put({ key, body, contentLength, contentType }) {
|
|
14425
15216
|
const storageKey = getStorageKey(key);
|
|
14426
|
-
|
|
15217
|
+
await new _aws_sdk_lib_storage.Upload({
|
|
14427
15218
|
client,
|
|
14428
15219
|
params: {
|
|
14429
15220
|
Body: body,
|
|
@@ -14434,11 +15225,10 @@ function s3Storage(config) {
|
|
|
14434
15225
|
Key: storageKey
|
|
14435
15226
|
}
|
|
14436
15227
|
}).done();
|
|
14437
|
-
if (!response.Bucket || !response.Key) throw new Error("Upload failed");
|
|
14438
15228
|
return { storageUri: createStorageUri({
|
|
14439
15229
|
bucket: bucketName,
|
|
14440
15230
|
key: storageKey,
|
|
14441
|
-
protocol
|
|
15231
|
+
protocol
|
|
14442
15232
|
}) };
|
|
14443
15233
|
},
|
|
14444
15234
|
async get({ storageUri }) {
|
|
@@ -14461,11 +15251,10 @@ function s3Storage(config) {
|
|
|
14461
15251
|
async getDownloadUrl({ storageUri }) {
|
|
14462
15252
|
const { key } = parseAndValidate(storageUri);
|
|
14463
15253
|
if (getDownloadUrl) return getDownloadUrl({ storageUri });
|
|
14464
|
-
|
|
14465
|
-
return { url: await getSignedUrl(client, new _aws_sdk_client_s3.GetObjectCommand({
|
|
15254
|
+
return { url: await (0, _aws_sdk_s3_request_presigner.getSignedUrl)(client, new _aws_sdk_client_s3.GetObjectCommand({
|
|
14466
15255
|
Bucket: bucketName,
|
|
14467
15256
|
Key: key
|
|
14468
|
-
}), { expiresIn:
|
|
15257
|
+
}), { expiresIn: signedUrlExpiresIn }) };
|
|
14469
15258
|
},
|
|
14470
15259
|
async exists({ storageUri }) {
|
|
14471
15260
|
const { key } = parseAndValidate(storageUri);
|
|
@@ -14487,8 +15276,61 @@ function s3Storage(config) {
|
|
|
14487
15276
|
Key: key
|
|
14488
15277
|
}));
|
|
14489
15278
|
return { deleted: true };
|
|
15279
|
+
},
|
|
15280
|
+
async listObjects(prefix) {
|
|
15281
|
+
const objects = [];
|
|
15282
|
+
let continuationToken;
|
|
15283
|
+
do {
|
|
15284
|
+
const response = await client.send(new _aws_sdk_client_s3.ListObjectsV2Command({
|
|
15285
|
+
Bucket: bucketName,
|
|
15286
|
+
ContinuationToken: continuationToken,
|
|
15287
|
+
Prefix: getListPrefix(prefix)
|
|
15288
|
+
}));
|
|
15289
|
+
for (const object of response.Contents ?? []) {
|
|
15290
|
+
if (!object.Key) continue;
|
|
15291
|
+
const storageUri = getListedStorageUri(object.Key);
|
|
15292
|
+
if (storageUri === null) continue;
|
|
15293
|
+
objects.push({
|
|
15294
|
+
key: getRelativeKey(object.Key),
|
|
15295
|
+
lastModifiedAt: object.LastModified,
|
|
15296
|
+
size: object.Size ?? 0,
|
|
15297
|
+
storageUri
|
|
15298
|
+
});
|
|
15299
|
+
}
|
|
15300
|
+
continuationToken = response.NextContinuationToken;
|
|
15301
|
+
} while (continuationToken);
|
|
15302
|
+
return objects;
|
|
15303
|
+
},
|
|
15304
|
+
async deleteObjects(relativeKeys) {
|
|
15305
|
+
const keys = relativeKeys.map((key) => getStorageKey(key));
|
|
15306
|
+
for (let offset = 0; offset < keys.length; offset += DELETE_BATCH_SIZE) {
|
|
15307
|
+
const batch = keys.slice(offset, offset + DELETE_BATCH_SIZE);
|
|
15308
|
+
const response = await client.send(new _aws_sdk_client_s3.DeleteObjectsCommand({
|
|
15309
|
+
Bucket: bucketName,
|
|
15310
|
+
Delete: {
|
|
15311
|
+
Objects: batch.map((Key) => ({ Key })),
|
|
15312
|
+
Quiet: true
|
|
15313
|
+
}
|
|
15314
|
+
}));
|
|
15315
|
+
if (response.Errors && response.Errors.length > 0) throw new Error(`Failed to delete ${response.Errors.length} S3 object(s) from bucket "${bucketName}".`);
|
|
15316
|
+
}
|
|
14490
15317
|
}
|
|
14491
15318
|
});
|
|
15319
|
+
};
|
|
15320
|
+
//#endregion
|
|
15321
|
+
//#region src/s3Storage.ts
|
|
15322
|
+
function s3Storage(config) {
|
|
15323
|
+
const { bucketName, basePath, getDownloadUrl, credentials, ...s3Config } = config;
|
|
15324
|
+
return createS3Storage({
|
|
15325
|
+
name: "s3Storage",
|
|
15326
|
+
protocol: "s3"
|
|
15327
|
+
}, {
|
|
15328
|
+
...applyS3RuntimeAwsConfig(s3Config),
|
|
15329
|
+
credentials,
|
|
15330
|
+
bucketName,
|
|
15331
|
+
basePath,
|
|
15332
|
+
getDownloadUrl
|
|
15333
|
+
});
|
|
14492
15334
|
}
|
|
14493
15335
|
//#endregion
|
|
14494
15336
|
//#region lambda/index.ts
|