@hot-updater/cloudflare 1.0.0-rc.40 → 1.0.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 +8 -3
- package/dist/index.d.cts +239 -3
- package/dist/index.d.mts +239 -3
- package/dist/index.mjs +8 -3
- package/dist/init/index.cjs +8 -3
- package/dist/init/index.mjs +8 -3
- package/dist/worker/index.cjs +8 -3
- package/dist/worker/index.d.cts +239 -3
- package/dist/worker/index.d.mts +239 -3
- package/dist/worker/index.mjs +8 -3
- package/package.json +6 -6
- package/sql/bundles.sql +6 -0
- package/src/plugins.ts +4 -3
- package/worker/dist/README.md +1 -1
- package/worker/dist/index.js +901 -31
- package/worker/dist/index.js.map +4 -4
- package/worker/migrations/0001_hot-updater_1.0.0.sql +6 -0
package/dist/worker/index.d.cts
CHANGED
|
@@ -354,10 +354,198 @@ interface CreatedApiKey {
|
|
|
354
354
|
readonly record: ApiKeyMetadata;
|
|
355
355
|
}
|
|
356
356
|
//#endregion
|
|
357
|
+
//#region ../remote-config/dist/shared/wire.d.mts
|
|
358
|
+
//#region src/shared/wire.d.ts
|
|
359
|
+
/** What a device tells the server, so the server can evaluate conditions. */
|
|
360
|
+
interface RemoteConfigDeviceContext {
|
|
361
|
+
readonly platform: "ios" | "android";
|
|
362
|
+
/** The native app version, or null when the build has none. */
|
|
363
|
+
readonly appVersion: string | null;
|
|
364
|
+
readonly channel: string;
|
|
365
|
+
/** A numeric cohort from 1 to 1000, or a custom cohort's slug. */
|
|
366
|
+
readonly cohort: string;
|
|
367
|
+
/** The native build's fingerprint, or null without one. */
|
|
368
|
+
readonly fingerprintHash: string | null;
|
|
369
|
+
}
|
|
370
|
+
/** The body of a `200` from `GET /remote-config`. */
|
|
371
|
+
interface RemoteConfigFetchResponse {
|
|
372
|
+
/** The published template version the values come from; 0 before the first publish. */
|
|
373
|
+
readonly version: number;
|
|
374
|
+
/**
|
|
375
|
+
* Each parameter's value for this device, as text. A parameter whose
|
|
376
|
+
* value is the app's own default is left out.
|
|
377
|
+
*/
|
|
378
|
+
readonly values: Readonly<Record<string, string>>;
|
|
379
|
+
}
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region ../remote-config/dist/server/template.d.mts
|
|
382
|
+
//#region src/server/template.d.ts
|
|
383
|
+
/**
|
|
384
|
+
* How the Console edits a parameter's value and checks it before a publish.
|
|
385
|
+
* Devices receive every value as text.
|
|
386
|
+
*/
|
|
387
|
+
type RemoteConfigValueType = "STRING" | "NUMBER" | "BOOLEAN" | "JSON";
|
|
388
|
+
/** A value a parameter takes: text, or the app's own default. */
|
|
389
|
+
type RemoteConfigParameterValue = {
|
|
390
|
+
readonly value: string;
|
|
391
|
+
} | {
|
|
392
|
+
readonly useInAppDefault: true;
|
|
393
|
+
};
|
|
394
|
+
interface RemoteConfigParameter {
|
|
395
|
+
readonly valueType: RemoteConfigValueType;
|
|
396
|
+
/** The value when none of the parameter's conditions match. */
|
|
397
|
+
readonly defaultValue: RemoteConfigParameterValue;
|
|
398
|
+
/**
|
|
399
|
+
* Values by condition name. When several of these conditions match, the
|
|
400
|
+
* one listed first in the template's `conditions` wins.
|
|
401
|
+
*/
|
|
402
|
+
readonly conditionalValues?: Readonly<Record<string, RemoteConfigParameterValue>>;
|
|
403
|
+
readonly description?: string;
|
|
404
|
+
}
|
|
405
|
+
/** A test on a device's context; a condition matches when all of its rules do. */
|
|
406
|
+
type RemoteConfigRule = {
|
|
407
|
+
readonly type: "platform";
|
|
408
|
+
readonly platforms: readonly ("ios" | "android")[];
|
|
409
|
+
} | {
|
|
410
|
+
readonly type: "channel";
|
|
411
|
+
readonly channels: readonly string[];
|
|
412
|
+
} |
|
|
413
|
+
/** A semver range, such as `>=1.4.0` or `2.x`, as release targets use. */
|
|
414
|
+
{
|
|
415
|
+
readonly type: "appVersion";
|
|
416
|
+
readonly range: string;
|
|
417
|
+
} |
|
|
418
|
+
/** Devices whose cohort is one of these: numbers from 1 to 1000 or slugs. */
|
|
419
|
+
{
|
|
420
|
+
readonly type: "cohort";
|
|
421
|
+
readonly cohorts: readonly string[];
|
|
422
|
+
} |
|
|
423
|
+
/**
|
|
424
|
+
* A share of numeric cohorts: the devices whose cohort lands in
|
|
425
|
+
* `[from, to)` percent once `seed` shuffles the 1,000 cohorts. Rules with
|
|
426
|
+
* one seed pick from one order, so `0–10` and `10–20` never overlap; a new
|
|
427
|
+
* seed picks other devices. Custom cohorts never match.
|
|
428
|
+
*/
|
|
429
|
+
{
|
|
430
|
+
readonly type: "percent";
|
|
431
|
+
readonly seed: string;
|
|
432
|
+
readonly from: number;
|
|
433
|
+
readonly to: number;
|
|
434
|
+
} | {
|
|
435
|
+
readonly type: "fingerprint";
|
|
436
|
+
readonly hashes: readonly string[];
|
|
437
|
+
} |
|
|
438
|
+
/**
|
|
439
|
+
* While the server's clock is in `[from, to)`: ISO 8601 date-times in UTC,
|
|
440
|
+
* either of them open. A device gets the change at its next fetch.
|
|
441
|
+
*/
|
|
442
|
+
{
|
|
443
|
+
readonly type: "dateTime";
|
|
444
|
+
readonly from?: string;
|
|
445
|
+
readonly to?: string;
|
|
446
|
+
};
|
|
447
|
+
interface RemoteConfigCondition {
|
|
448
|
+
/** Unique in the template; parameters name it in `conditionalValues`. */
|
|
449
|
+
readonly name: string;
|
|
450
|
+
/** Every rule must match. */
|
|
451
|
+
readonly rules: readonly RemoteConfigRule[];
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Everything Remote Config serves, published as a whole and versioned.
|
|
455
|
+
*/
|
|
456
|
+
interface RemoteConfigTemplate {
|
|
457
|
+
/** In priority order: the first one that matches decides a parameter's value. */
|
|
458
|
+
readonly conditions: readonly RemoteConfigCondition[];
|
|
459
|
+
readonly parameters: Readonly<Record<string, RemoteConfigParameter>>;
|
|
460
|
+
}
|
|
461
|
+
/** What the server knows of a device; a rule on a missing field never matches. */
|
|
462
|
+
type RemoteConfigEvaluationContext = Partial<Readonly<{ [K in keyof RemoteConfigDeviceContext]: RemoteConfigDeviceContext[K] | null; }>> & {
|
|
463
|
+
/**
|
|
464
|
+
* When to evaluate, in ms since the epoch. The server uses its own clock;
|
|
465
|
+
* a `dateTime` rule never matches without it.
|
|
466
|
+
*/
|
|
467
|
+
readonly now?: number;
|
|
468
|
+
};
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region ../remote-config/dist/server/api.d.mts
|
|
471
|
+
//#region src/server/api.d.ts
|
|
472
|
+
/** A published version's record, without its template. */
|
|
473
|
+
interface RemoteConfigVersion {
|
|
474
|
+
readonly version: number;
|
|
475
|
+
readonly description: string | null;
|
|
476
|
+
/** `ROLLBACK` when the version copies `rollbackSource`. */
|
|
477
|
+
readonly updateType: "PUBLISH" | "ROLLBACK";
|
|
478
|
+
readonly rollbackSource: number | null;
|
|
479
|
+
readonly createdAtMs: number;
|
|
480
|
+
}
|
|
481
|
+
interface RemoteConfigVersionDetail extends RemoteConfigVersion {
|
|
482
|
+
readonly template: RemoteConfigTemplate;
|
|
483
|
+
}
|
|
484
|
+
/** The template devices receive now. */
|
|
485
|
+
interface RemoteConfigActive {
|
|
486
|
+
/** 0, with an empty template, before the first publish. */
|
|
487
|
+
readonly version: number;
|
|
488
|
+
readonly template: RemoteConfigTemplate;
|
|
489
|
+
readonly updatedAtMs: number | null;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* How a publish or a rollback ended: `conflict` when another publish moved
|
|
493
|
+
* the active version past `baseVersion` first, so a stale edit never
|
|
494
|
+
* replaces a newer template.
|
|
495
|
+
*/
|
|
496
|
+
type RemoteConfigPublishResult = {
|
|
497
|
+
readonly status: "published";
|
|
498
|
+
readonly version: RemoteConfigVersion;
|
|
499
|
+
} | {
|
|
500
|
+
readonly status: "conflict";
|
|
501
|
+
readonly currentVersion: number;
|
|
502
|
+
};
|
|
503
|
+
interface RemoteConfigVersionsPage {
|
|
504
|
+
/** Newest first. */
|
|
505
|
+
readonly versions: readonly RemoteConfigVersion[];
|
|
506
|
+
/** Pass as `cursor` for the next page; absent on the last one. */
|
|
507
|
+
readonly next?: string;
|
|
508
|
+
}
|
|
509
|
+
/** `hotUpdater.api.remoteConfig`. */
|
|
510
|
+
interface RemoteConfigApi {
|
|
511
|
+
/** The active template and its version. */
|
|
512
|
+
getActive(): Promise<RemoteConfigActive>;
|
|
513
|
+
/**
|
|
514
|
+
* Validates and publishes a template as the next version. Throws
|
|
515
|
+
* `RemoteConfigValidationError` for an invalid template.
|
|
516
|
+
*/
|
|
517
|
+
publish(input: {
|
|
518
|
+
readonly template: unknown;
|
|
519
|
+
/** The version the edit started from; 0 before the first publish. */
|
|
520
|
+
readonly baseVersion: number;
|
|
521
|
+
readonly description?: string;
|
|
522
|
+
}): Promise<RemoteConfigPublishResult>;
|
|
523
|
+
/** Publishes a copy of an earlier version; `not_found` when it does not exist. */
|
|
524
|
+
rollback(input: {
|
|
525
|
+
readonly version: number;
|
|
526
|
+
readonly baseVersion: number;
|
|
527
|
+
readonly description?: string;
|
|
528
|
+
}): Promise<RemoteConfigPublishResult | {
|
|
529
|
+
readonly status: "not_found";
|
|
530
|
+
}>;
|
|
531
|
+
/** One page of published versions, newest first. */
|
|
532
|
+
listVersions(input?: {
|
|
533
|
+
readonly limit?: number;
|
|
534
|
+
readonly cursor?: string;
|
|
535
|
+
}): Promise<RemoteConfigVersionsPage>;
|
|
536
|
+
/** One version with its template, or null. */
|
|
537
|
+
getVersion(version: number): Promise<RemoteConfigVersionDetail | null>;
|
|
538
|
+
/**
|
|
539
|
+
* What a device with this context receives from `GET /remote-config`, at
|
|
540
|
+
* `context.now` or, without it, now.
|
|
541
|
+
*/
|
|
542
|
+
resolve(context: RemoteConfigEvaluationContext): Promise<RemoteConfigFetchResponse>;
|
|
543
|
+
}
|
|
544
|
+
//#endregion
|
|
357
545
|
//#region src/plugins.d.ts
|
|
358
546
|
/**
|
|
359
|
-
* The plugins the managed Cloudflare server runs: Insights,
|
|
360
|
-
* client route. Its Worker imports this list.
|
|
547
|
+
* The plugins the managed Cloudflare server runs: Insights, API keys on every
|
|
548
|
+
* client route, and Remote Config. Its Worker imports this list.
|
|
361
549
|
*/
|
|
362
550
|
declare const plugins: readonly [import("@hot-updater/plugin-core").HotUpdaterPlugin<"insights", {
|
|
363
551
|
readonly bundle_events: import("@hot-updater/plugin-core").TableDefinition<{
|
|
@@ -799,7 +987,55 @@ declare const plugins: readonly [import("@hot-updater/plugin-core").HotUpdaterPl
|
|
|
799
987
|
};
|
|
800
988
|
}, {
|
|
801
989
|
readonly clientAuth: true;
|
|
802
|
-
}
|
|
990
|
+
}>, import("@hot-updater/plugin-core").HotUpdaterPlugin<"remoteConfig", {
|
|
991
|
+
readonly remote_config_active: import("@hot-updater/plugin-core").TableDefinition<{
|
|
992
|
+
readonly id: {
|
|
993
|
+
readonly type: "string";
|
|
994
|
+
readonly maxLength: 16;
|
|
995
|
+
};
|
|
996
|
+
readonly version: {
|
|
997
|
+
readonly type: "integer";
|
|
998
|
+
};
|
|
999
|
+
readonly template: {
|
|
1000
|
+
readonly type: "json";
|
|
1001
|
+
};
|
|
1002
|
+
readonly updated_at_ms: {
|
|
1003
|
+
readonly type: "integer";
|
|
1004
|
+
};
|
|
1005
|
+
}, {}, {}, readonly ["id"]>;
|
|
1006
|
+
readonly remote_config_versions: import("@hot-updater/plugin-core").TableDefinition<{
|
|
1007
|
+
readonly version: {
|
|
1008
|
+
readonly type: "integer";
|
|
1009
|
+
};
|
|
1010
|
+
readonly template: {
|
|
1011
|
+
readonly type: "json";
|
|
1012
|
+
};
|
|
1013
|
+
readonly description: {
|
|
1014
|
+
readonly type: "string";
|
|
1015
|
+
readonly maxLength: 256;
|
|
1016
|
+
readonly required: false;
|
|
1017
|
+
};
|
|
1018
|
+
readonly update_type: {
|
|
1019
|
+
readonly type: "string";
|
|
1020
|
+
readonly maxLength: 16;
|
|
1021
|
+
};
|
|
1022
|
+
readonly rollback_source: {
|
|
1023
|
+
readonly type: "integer";
|
|
1024
|
+
readonly required: false;
|
|
1025
|
+
};
|
|
1026
|
+
readonly created_at_ms: {
|
|
1027
|
+
readonly type: "integer";
|
|
1028
|
+
};
|
|
1029
|
+
}, {}, {
|
|
1030
|
+
readonly byVersion: {
|
|
1031
|
+
readonly eq: readonly [];
|
|
1032
|
+
readonly sort: readonly ["version"];
|
|
1033
|
+
};
|
|
1034
|
+
}, readonly ["version"]>;
|
|
1035
|
+
}, {
|
|
1036
|
+
api: RemoteConfigApi;
|
|
1037
|
+
endpoints: readonly import("@hot-updater/plugin-core").PluginEndpoint[];
|
|
1038
|
+
}, {}>];
|
|
803
1039
|
//#endregion
|
|
804
1040
|
//#region src/r2WorkerStorage.d.ts
|
|
805
1041
|
interface CloudflareWorkerStorageConfig {
|
package/dist/worker/index.d.mts
CHANGED
|
@@ -354,10 +354,198 @@ interface CreatedApiKey {
|
|
|
354
354
|
readonly record: ApiKeyMetadata;
|
|
355
355
|
}
|
|
356
356
|
//#endregion
|
|
357
|
+
//#region ../remote-config/dist/shared/wire.d.mts
|
|
358
|
+
//#region src/shared/wire.d.ts
|
|
359
|
+
/** What a device tells the server, so the server can evaluate conditions. */
|
|
360
|
+
interface RemoteConfigDeviceContext {
|
|
361
|
+
readonly platform: "ios" | "android";
|
|
362
|
+
/** The native app version, or null when the build has none. */
|
|
363
|
+
readonly appVersion: string | null;
|
|
364
|
+
readonly channel: string;
|
|
365
|
+
/** A numeric cohort from 1 to 1000, or a custom cohort's slug. */
|
|
366
|
+
readonly cohort: string;
|
|
367
|
+
/** The native build's fingerprint, or null without one. */
|
|
368
|
+
readonly fingerprintHash: string | null;
|
|
369
|
+
}
|
|
370
|
+
/** The body of a `200` from `GET /remote-config`. */
|
|
371
|
+
interface RemoteConfigFetchResponse {
|
|
372
|
+
/** The published template version the values come from; 0 before the first publish. */
|
|
373
|
+
readonly version: number;
|
|
374
|
+
/**
|
|
375
|
+
* Each parameter's value for this device, as text. A parameter whose
|
|
376
|
+
* value is the app's own default is left out.
|
|
377
|
+
*/
|
|
378
|
+
readonly values: Readonly<Record<string, string>>;
|
|
379
|
+
}
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region ../remote-config/dist/server/template.d.mts
|
|
382
|
+
//#region src/server/template.d.ts
|
|
383
|
+
/**
|
|
384
|
+
* How the Console edits a parameter's value and checks it before a publish.
|
|
385
|
+
* Devices receive every value as text.
|
|
386
|
+
*/
|
|
387
|
+
type RemoteConfigValueType = "STRING" | "NUMBER" | "BOOLEAN" | "JSON";
|
|
388
|
+
/** A value a parameter takes: text, or the app's own default. */
|
|
389
|
+
type RemoteConfigParameterValue = {
|
|
390
|
+
readonly value: string;
|
|
391
|
+
} | {
|
|
392
|
+
readonly useInAppDefault: true;
|
|
393
|
+
};
|
|
394
|
+
interface RemoteConfigParameter {
|
|
395
|
+
readonly valueType: RemoteConfigValueType;
|
|
396
|
+
/** The value when none of the parameter's conditions match. */
|
|
397
|
+
readonly defaultValue: RemoteConfigParameterValue;
|
|
398
|
+
/**
|
|
399
|
+
* Values by condition name. When several of these conditions match, the
|
|
400
|
+
* one listed first in the template's `conditions` wins.
|
|
401
|
+
*/
|
|
402
|
+
readonly conditionalValues?: Readonly<Record<string, RemoteConfigParameterValue>>;
|
|
403
|
+
readonly description?: string;
|
|
404
|
+
}
|
|
405
|
+
/** A test on a device's context; a condition matches when all of its rules do. */
|
|
406
|
+
type RemoteConfigRule = {
|
|
407
|
+
readonly type: "platform";
|
|
408
|
+
readonly platforms: readonly ("ios" | "android")[];
|
|
409
|
+
} | {
|
|
410
|
+
readonly type: "channel";
|
|
411
|
+
readonly channels: readonly string[];
|
|
412
|
+
} |
|
|
413
|
+
/** A semver range, such as `>=1.4.0` or `2.x`, as release targets use. */
|
|
414
|
+
{
|
|
415
|
+
readonly type: "appVersion";
|
|
416
|
+
readonly range: string;
|
|
417
|
+
} |
|
|
418
|
+
/** Devices whose cohort is one of these: numbers from 1 to 1000 or slugs. */
|
|
419
|
+
{
|
|
420
|
+
readonly type: "cohort";
|
|
421
|
+
readonly cohorts: readonly string[];
|
|
422
|
+
} |
|
|
423
|
+
/**
|
|
424
|
+
* A share of numeric cohorts: the devices whose cohort lands in
|
|
425
|
+
* `[from, to)` percent once `seed` shuffles the 1,000 cohorts. Rules with
|
|
426
|
+
* one seed pick from one order, so `0–10` and `10–20` never overlap; a new
|
|
427
|
+
* seed picks other devices. Custom cohorts never match.
|
|
428
|
+
*/
|
|
429
|
+
{
|
|
430
|
+
readonly type: "percent";
|
|
431
|
+
readonly seed: string;
|
|
432
|
+
readonly from: number;
|
|
433
|
+
readonly to: number;
|
|
434
|
+
} | {
|
|
435
|
+
readonly type: "fingerprint";
|
|
436
|
+
readonly hashes: readonly string[];
|
|
437
|
+
} |
|
|
438
|
+
/**
|
|
439
|
+
* While the server's clock is in `[from, to)`: ISO 8601 date-times in UTC,
|
|
440
|
+
* either of them open. A device gets the change at its next fetch.
|
|
441
|
+
*/
|
|
442
|
+
{
|
|
443
|
+
readonly type: "dateTime";
|
|
444
|
+
readonly from?: string;
|
|
445
|
+
readonly to?: string;
|
|
446
|
+
};
|
|
447
|
+
interface RemoteConfigCondition {
|
|
448
|
+
/** Unique in the template; parameters name it in `conditionalValues`. */
|
|
449
|
+
readonly name: string;
|
|
450
|
+
/** Every rule must match. */
|
|
451
|
+
readonly rules: readonly RemoteConfigRule[];
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Everything Remote Config serves, published as a whole and versioned.
|
|
455
|
+
*/
|
|
456
|
+
interface RemoteConfigTemplate {
|
|
457
|
+
/** In priority order: the first one that matches decides a parameter's value. */
|
|
458
|
+
readonly conditions: readonly RemoteConfigCondition[];
|
|
459
|
+
readonly parameters: Readonly<Record<string, RemoteConfigParameter>>;
|
|
460
|
+
}
|
|
461
|
+
/** What the server knows of a device; a rule on a missing field never matches. */
|
|
462
|
+
type RemoteConfigEvaluationContext = Partial<Readonly<{ [K in keyof RemoteConfigDeviceContext]: RemoteConfigDeviceContext[K] | null; }>> & {
|
|
463
|
+
/**
|
|
464
|
+
* When to evaluate, in ms since the epoch. The server uses its own clock;
|
|
465
|
+
* a `dateTime` rule never matches without it.
|
|
466
|
+
*/
|
|
467
|
+
readonly now?: number;
|
|
468
|
+
};
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region ../remote-config/dist/server/api.d.mts
|
|
471
|
+
//#region src/server/api.d.ts
|
|
472
|
+
/** A published version's record, without its template. */
|
|
473
|
+
interface RemoteConfigVersion {
|
|
474
|
+
readonly version: number;
|
|
475
|
+
readonly description: string | null;
|
|
476
|
+
/** `ROLLBACK` when the version copies `rollbackSource`. */
|
|
477
|
+
readonly updateType: "PUBLISH" | "ROLLBACK";
|
|
478
|
+
readonly rollbackSource: number | null;
|
|
479
|
+
readonly createdAtMs: number;
|
|
480
|
+
}
|
|
481
|
+
interface RemoteConfigVersionDetail extends RemoteConfigVersion {
|
|
482
|
+
readonly template: RemoteConfigTemplate;
|
|
483
|
+
}
|
|
484
|
+
/** The template devices receive now. */
|
|
485
|
+
interface RemoteConfigActive {
|
|
486
|
+
/** 0, with an empty template, before the first publish. */
|
|
487
|
+
readonly version: number;
|
|
488
|
+
readonly template: RemoteConfigTemplate;
|
|
489
|
+
readonly updatedAtMs: number | null;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* How a publish or a rollback ended: `conflict` when another publish moved
|
|
493
|
+
* the active version past `baseVersion` first, so a stale edit never
|
|
494
|
+
* replaces a newer template.
|
|
495
|
+
*/
|
|
496
|
+
type RemoteConfigPublishResult = {
|
|
497
|
+
readonly status: "published";
|
|
498
|
+
readonly version: RemoteConfigVersion;
|
|
499
|
+
} | {
|
|
500
|
+
readonly status: "conflict";
|
|
501
|
+
readonly currentVersion: number;
|
|
502
|
+
};
|
|
503
|
+
interface RemoteConfigVersionsPage {
|
|
504
|
+
/** Newest first. */
|
|
505
|
+
readonly versions: readonly RemoteConfigVersion[];
|
|
506
|
+
/** Pass as `cursor` for the next page; absent on the last one. */
|
|
507
|
+
readonly next?: string;
|
|
508
|
+
}
|
|
509
|
+
/** `hotUpdater.api.remoteConfig`. */
|
|
510
|
+
interface RemoteConfigApi {
|
|
511
|
+
/** The active template and its version. */
|
|
512
|
+
getActive(): Promise<RemoteConfigActive>;
|
|
513
|
+
/**
|
|
514
|
+
* Validates and publishes a template as the next version. Throws
|
|
515
|
+
* `RemoteConfigValidationError` for an invalid template.
|
|
516
|
+
*/
|
|
517
|
+
publish(input: {
|
|
518
|
+
readonly template: unknown;
|
|
519
|
+
/** The version the edit started from; 0 before the first publish. */
|
|
520
|
+
readonly baseVersion: number;
|
|
521
|
+
readonly description?: string;
|
|
522
|
+
}): Promise<RemoteConfigPublishResult>;
|
|
523
|
+
/** Publishes a copy of an earlier version; `not_found` when it does not exist. */
|
|
524
|
+
rollback(input: {
|
|
525
|
+
readonly version: number;
|
|
526
|
+
readonly baseVersion: number;
|
|
527
|
+
readonly description?: string;
|
|
528
|
+
}): Promise<RemoteConfigPublishResult | {
|
|
529
|
+
readonly status: "not_found";
|
|
530
|
+
}>;
|
|
531
|
+
/** One page of published versions, newest first. */
|
|
532
|
+
listVersions(input?: {
|
|
533
|
+
readonly limit?: number;
|
|
534
|
+
readonly cursor?: string;
|
|
535
|
+
}): Promise<RemoteConfigVersionsPage>;
|
|
536
|
+
/** One version with its template, or null. */
|
|
537
|
+
getVersion(version: number): Promise<RemoteConfigVersionDetail | null>;
|
|
538
|
+
/**
|
|
539
|
+
* What a device with this context receives from `GET /remote-config`, at
|
|
540
|
+
* `context.now` or, without it, now.
|
|
541
|
+
*/
|
|
542
|
+
resolve(context: RemoteConfigEvaluationContext): Promise<RemoteConfigFetchResponse>;
|
|
543
|
+
}
|
|
544
|
+
//#endregion
|
|
357
545
|
//#region src/plugins.d.ts
|
|
358
546
|
/**
|
|
359
|
-
* The plugins the managed Cloudflare server runs: Insights,
|
|
360
|
-
* client route. Its Worker imports this list.
|
|
547
|
+
* The plugins the managed Cloudflare server runs: Insights, API keys on every
|
|
548
|
+
* client route, and Remote Config. Its Worker imports this list.
|
|
361
549
|
*/
|
|
362
550
|
declare const plugins: readonly [import("@hot-updater/plugin-core").HotUpdaterPlugin<"insights", {
|
|
363
551
|
readonly bundle_events: import("@hot-updater/plugin-core").TableDefinition<{
|
|
@@ -799,7 +987,55 @@ declare const plugins: readonly [import("@hot-updater/plugin-core").HotUpdaterPl
|
|
|
799
987
|
};
|
|
800
988
|
}, {
|
|
801
989
|
readonly clientAuth: true;
|
|
802
|
-
}
|
|
990
|
+
}>, import("@hot-updater/plugin-core").HotUpdaterPlugin<"remoteConfig", {
|
|
991
|
+
readonly remote_config_active: import("@hot-updater/plugin-core").TableDefinition<{
|
|
992
|
+
readonly id: {
|
|
993
|
+
readonly type: "string";
|
|
994
|
+
readonly maxLength: 16;
|
|
995
|
+
};
|
|
996
|
+
readonly version: {
|
|
997
|
+
readonly type: "integer";
|
|
998
|
+
};
|
|
999
|
+
readonly template: {
|
|
1000
|
+
readonly type: "json";
|
|
1001
|
+
};
|
|
1002
|
+
readonly updated_at_ms: {
|
|
1003
|
+
readonly type: "integer";
|
|
1004
|
+
};
|
|
1005
|
+
}, {}, {}, readonly ["id"]>;
|
|
1006
|
+
readonly remote_config_versions: import("@hot-updater/plugin-core").TableDefinition<{
|
|
1007
|
+
readonly version: {
|
|
1008
|
+
readonly type: "integer";
|
|
1009
|
+
};
|
|
1010
|
+
readonly template: {
|
|
1011
|
+
readonly type: "json";
|
|
1012
|
+
};
|
|
1013
|
+
readonly description: {
|
|
1014
|
+
readonly type: "string";
|
|
1015
|
+
readonly maxLength: 256;
|
|
1016
|
+
readonly required: false;
|
|
1017
|
+
};
|
|
1018
|
+
readonly update_type: {
|
|
1019
|
+
readonly type: "string";
|
|
1020
|
+
readonly maxLength: 16;
|
|
1021
|
+
};
|
|
1022
|
+
readonly rollback_source: {
|
|
1023
|
+
readonly type: "integer";
|
|
1024
|
+
readonly required: false;
|
|
1025
|
+
};
|
|
1026
|
+
readonly created_at_ms: {
|
|
1027
|
+
readonly type: "integer";
|
|
1028
|
+
};
|
|
1029
|
+
}, {}, {
|
|
1030
|
+
readonly byVersion: {
|
|
1031
|
+
readonly eq: readonly [];
|
|
1032
|
+
readonly sort: readonly ["version"];
|
|
1033
|
+
};
|
|
1034
|
+
}, readonly ["version"]>;
|
|
1035
|
+
}, {
|
|
1036
|
+
api: RemoteConfigApi;
|
|
1037
|
+
endpoints: readonly import("@hot-updater/plugin-core").PluginEndpoint[];
|
|
1038
|
+
}, {}>];
|
|
803
1039
|
//#endregion
|
|
804
1040
|
//#region src/r2WorkerStorage.d.ts
|
|
805
1041
|
interface CloudflareWorkerStorageConfig {
|
package/dist/worker/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createEngineDatabase, createSqlAdapter, createStorageAdapter, createStorageDownloadUrl, createStorageKeyBuilder, createStorageUri, parseStorageUri } from "@hot-updater/plugin-core";
|
|
2
2
|
import { apiKeys } from "@hot-updater/server/plugins/api-keys";
|
|
3
3
|
import { insights } from "@hot-updater/server/plugins/insights";
|
|
4
|
+
import { remoteConfig } from "@hot-updater/server/plugins/remote-config";
|
|
4
5
|
//#region src/d1Executor.ts
|
|
5
6
|
var D1ExecutionError = class extends Error {
|
|
6
7
|
name = "D1ExecutionError";
|
|
@@ -62,10 +63,14 @@ const d1Database = (database) => createD1Database({
|
|
|
62
63
|
//#endregion
|
|
63
64
|
//#region src/plugins.ts
|
|
64
65
|
/**
|
|
65
|
-
* The plugins the managed Cloudflare server runs: Insights,
|
|
66
|
-
* client route. Its Worker imports this list.
|
|
66
|
+
* The plugins the managed Cloudflare server runs: Insights, API keys on every
|
|
67
|
+
* client route, and Remote Config. Its Worker imports this list.
|
|
67
68
|
*/
|
|
68
|
-
const plugins = [
|
|
69
|
+
const plugins = [
|
|
70
|
+
insights(),
|
|
71
|
+
apiKeys(),
|
|
72
|
+
remoteConfig()
|
|
73
|
+
];
|
|
69
74
|
//#endregion
|
|
70
75
|
//#region src/r2WorkerStorage.ts
|
|
71
76
|
const r2WorkerStorage = (config) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/cloudflare",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.41",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"cloudflare": "4.2.0",
|
|
57
57
|
"hono": "4.12.34",
|
|
58
58
|
"uuidv7": "^1.0.2",
|
|
59
|
-
"@hot-updater/
|
|
60
|
-
"@hot-updater/
|
|
61
|
-
"@hot-updater/plugin-core": "1.0.0-rc.
|
|
62
|
-
"@hot-updater/server": "1.0.0-rc.
|
|
59
|
+
"@hot-updater/cli-tools": "1.0.0-rc.41",
|
|
60
|
+
"@hot-updater/protocol": "1.0.0-rc.41",
|
|
61
|
+
"@hot-updater/plugin-core": "1.0.0-rc.41",
|
|
62
|
+
"@hot-updater/server": "1.0.0-rc.41"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@cloudflare/vitest-pool-workers": "0.13.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"vitest": "4.1.4",
|
|
76
76
|
"wrangler": "^4.69.0",
|
|
77
77
|
"xdg-app-paths": "^8.3.0",
|
|
78
|
-
"@hot-updater/test-utils": "1.0.0-rc.
|
|
78
|
+
"@hot-updater/test-utils": "1.0.0-rc.41"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"build": "tsdown && pnpm build:worker",
|
package/sql/bundles.sql
CHANGED
|
@@ -104,6 +104,10 @@ CREATE INDEX IF NOT EXISTS "api_keys_byCreated" ON "api_keys" ("created_at_ms",
|
|
|
104
104
|
|
|
105
105
|
CREATE UNIQUE INDEX IF NOT EXISTS "api_keys_hash" ON "api_keys" ("hash");
|
|
106
106
|
|
|
107
|
+
CREATE TABLE IF NOT EXISTS "remote_config_active" ("id" TEXT NOT NULL, "version" INTEGER NOT NULL, "template" TEXT NOT NULL, "updated_at_ms" INTEGER NOT NULL, "_v" INTEGER NOT NULL DEFAULT 0, PRIMARY KEY ("id"));
|
|
108
|
+
|
|
109
|
+
CREATE TABLE IF NOT EXISTS "remote_config_versions" ("version" INTEGER NOT NULL, "template" TEXT NOT NULL, "description" TEXT, "update_type" TEXT NOT NULL, "rollback_source" INTEGER, "created_at_ms" INTEGER NOT NULL, "_v" INTEGER NOT NULL DEFAULT 0, PRIMARY KEY ("version"));
|
|
110
|
+
|
|
107
111
|
CREATE TABLE IF NOT EXISTS "private_hot_updater_settings" ("key" TEXT NOT NULL, "value" TEXT NOT NULL, "_v" INTEGER NOT NULL DEFAULT 0, PRIMARY KEY ("key"));
|
|
108
112
|
|
|
109
113
|
INSERT INTO "private_hot_updater_settings" ("key", "value", "_v") VALUES ('schema.engine', '1', 0) ON CONFLICT ("key") DO UPDATE SET "value" = excluded."value";
|
|
@@ -113,3 +117,5 @@ INSERT INTO "private_hot_updater_settings" ("key", "value", "_v") VALUES ('schem
|
|
|
113
117
|
INSERT INTO "private_hot_updater_settings" ("key", "value", "_v") VALUES ('schema.insights', '1.0.0', 0) ON CONFLICT ("key") DO UPDATE SET "value" = excluded."value";
|
|
114
118
|
|
|
115
119
|
INSERT INTO "private_hot_updater_settings" ("key", "value", "_v") VALUES ('schema.apiKeys', '1.0.0', 0) ON CONFLICT ("key") DO UPDATE SET "value" = excluded."value";
|
|
120
|
+
|
|
121
|
+
INSERT INTO "private_hot_updater_settings" ("key", "value", "_v") VALUES ('schema.remoteConfig', '1.0.0', 0) ON CONFLICT ("key") DO UPDATE SET "value" = excluded."value";
|
package/src/plugins.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { apiKeys } from "@hot-updater/server/plugins/api-keys";
|
|
2
2
|
import { insights } from "@hot-updater/server/plugins/insights";
|
|
3
|
+
import { remoteConfig } from "@hot-updater/server/plugins/remote-config";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* The plugins the managed Cloudflare server runs: Insights,
|
|
6
|
-
* client route. Its Worker imports this list.
|
|
6
|
+
* The plugins the managed Cloudflare server runs: Insights, API keys on every
|
|
7
|
+
* client route, and Remote Config. Its Worker imports this list.
|
|
7
8
|
*/
|
|
8
|
-
export const plugins = [insights(), apiKeys()] as const;
|
|
9
|
+
export const plugins = [insights(), apiKeys(), remoteConfig()] as const;
|
package/worker/dist/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
This folder contains the built output assets for the worker "hot-updater" generated at 2026-10-
|
|
1
|
+
This folder contains the built output assets for the worker "hot-updater" generated at 2026-10-08T17:56:27.300Z.
|