@hot-updater/firebase 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/firebase/functions/index.cjs +1005 -106
- 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/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -6,6 +6,7 @@ let node_crypto = require("node:crypto");
|
|
|
6
6
|
let firebase_admin_storage = require("firebase-admin/storage");
|
|
7
7
|
let _hot_updater_server_plugins_api_keys = require("@hot-updater/server/plugins/api-keys");
|
|
8
8
|
let _hot_updater_server_plugins_insights = require("@hot-updater/server/plugins/insights");
|
|
9
|
+
let _hot_updater_server_plugins_remote_config = require("@hot-updater/server/plugins/remote-config");
|
|
9
10
|
//#region src/firebaseInfrastructureNames.ts
|
|
10
11
|
/**
|
|
11
12
|
* The one collection the storage engine keeps every item in. It namespaces
|
|
@@ -263,10 +264,14 @@ const firebaseStorage = (config) => {
|
|
|
263
264
|
//#endregion
|
|
264
265
|
//#region src/plugins.ts
|
|
265
266
|
/**
|
|
266
|
-
* The plugins the managed Firebase server runs: Insights,
|
|
267
|
-
* client route. Its Cloud Function imports this list.
|
|
267
|
+
* The plugins the managed Firebase server runs: Insights, API keys on every
|
|
268
|
+
* client route, and Remote Config. Its Cloud Function imports this list.
|
|
268
269
|
*/
|
|
269
|
-
const plugins = [
|
|
270
|
+
const plugins = [
|
|
271
|
+
(0, _hot_updater_server_plugins_insights.insights)(),
|
|
272
|
+
(0, _hot_updater_server_plugins_api_keys.apiKeys)(),
|
|
273
|
+
(0, _hot_updater_server_plugins_remote_config.remoteConfig)()
|
|
274
|
+
];
|
|
270
275
|
//#endregion
|
|
271
276
|
exports.firebaseDatabase = firebaseDatabase;
|
|
272
277
|
exports.firebaseStorage = firebaseStorage;
|
package/dist/index.d.cts
CHANGED
|
@@ -365,10 +365,198 @@ interface CreatedApiKey {
|
|
|
365
365
|
readonly record: ApiKeyMetadata;
|
|
366
366
|
}
|
|
367
367
|
//#endregion
|
|
368
|
+
//#region ../remote-config/dist/shared/wire.d.mts
|
|
369
|
+
//#region src/shared/wire.d.ts
|
|
370
|
+
/** What a device tells the server, so the server can evaluate conditions. */
|
|
371
|
+
interface RemoteConfigDeviceContext {
|
|
372
|
+
readonly platform: "ios" | "android";
|
|
373
|
+
/** The native app version, or null when the build has none. */
|
|
374
|
+
readonly appVersion: string | null;
|
|
375
|
+
readonly channel: string;
|
|
376
|
+
/** A numeric cohort from 1 to 1000, or a custom cohort's slug. */
|
|
377
|
+
readonly cohort: string;
|
|
378
|
+
/** The native build's fingerprint, or null without one. */
|
|
379
|
+
readonly fingerprintHash: string | null;
|
|
380
|
+
}
|
|
381
|
+
/** The body of a `200` from `GET /remote-config`. */
|
|
382
|
+
interface RemoteConfigFetchResponse {
|
|
383
|
+
/** The published template version the values come from; 0 before the first publish. */
|
|
384
|
+
readonly version: number;
|
|
385
|
+
/**
|
|
386
|
+
* Each parameter's value for this device, as text. A parameter whose
|
|
387
|
+
* value is the app's own default is left out.
|
|
388
|
+
*/
|
|
389
|
+
readonly values: Readonly<Record<string, string>>;
|
|
390
|
+
}
|
|
391
|
+
//#endregion
|
|
392
|
+
//#region ../remote-config/dist/server/template.d.mts
|
|
393
|
+
//#region src/server/template.d.ts
|
|
394
|
+
/**
|
|
395
|
+
* How the Console edits a parameter's value and checks it before a publish.
|
|
396
|
+
* Devices receive every value as text.
|
|
397
|
+
*/
|
|
398
|
+
type RemoteConfigValueType = "STRING" | "NUMBER" | "BOOLEAN" | "JSON";
|
|
399
|
+
/** A value a parameter takes: text, or the app's own default. */
|
|
400
|
+
type RemoteConfigParameterValue = {
|
|
401
|
+
readonly value: string;
|
|
402
|
+
} | {
|
|
403
|
+
readonly useInAppDefault: true;
|
|
404
|
+
};
|
|
405
|
+
interface RemoteConfigParameter {
|
|
406
|
+
readonly valueType: RemoteConfigValueType;
|
|
407
|
+
/** The value when none of the parameter's conditions match. */
|
|
408
|
+
readonly defaultValue: RemoteConfigParameterValue;
|
|
409
|
+
/**
|
|
410
|
+
* Values by condition name. When several of these conditions match, the
|
|
411
|
+
* one listed first in the template's `conditions` wins.
|
|
412
|
+
*/
|
|
413
|
+
readonly conditionalValues?: Readonly<Record<string, RemoteConfigParameterValue>>;
|
|
414
|
+
readonly description?: string;
|
|
415
|
+
}
|
|
416
|
+
/** A test on a device's context; a condition matches when all of its rules do. */
|
|
417
|
+
type RemoteConfigRule = {
|
|
418
|
+
readonly type: "platform";
|
|
419
|
+
readonly platforms: readonly ("ios" | "android")[];
|
|
420
|
+
} | {
|
|
421
|
+
readonly type: "channel";
|
|
422
|
+
readonly channels: readonly string[];
|
|
423
|
+
} |
|
|
424
|
+
/** A semver range, such as `>=1.4.0` or `2.x`, as release targets use. */
|
|
425
|
+
{
|
|
426
|
+
readonly type: "appVersion";
|
|
427
|
+
readonly range: string;
|
|
428
|
+
} |
|
|
429
|
+
/** Devices whose cohort is one of these: numbers from 1 to 1000 or slugs. */
|
|
430
|
+
{
|
|
431
|
+
readonly type: "cohort";
|
|
432
|
+
readonly cohorts: readonly string[];
|
|
433
|
+
} |
|
|
434
|
+
/**
|
|
435
|
+
* A share of numeric cohorts: the devices whose cohort lands in
|
|
436
|
+
* `[from, to)` percent once `seed` shuffles the 1,000 cohorts. Rules with
|
|
437
|
+
* one seed pick from one order, so `0–10` and `10–20` never overlap; a new
|
|
438
|
+
* seed picks other devices. Custom cohorts never match.
|
|
439
|
+
*/
|
|
440
|
+
{
|
|
441
|
+
readonly type: "percent";
|
|
442
|
+
readonly seed: string;
|
|
443
|
+
readonly from: number;
|
|
444
|
+
readonly to: number;
|
|
445
|
+
} | {
|
|
446
|
+
readonly type: "fingerprint";
|
|
447
|
+
readonly hashes: readonly string[];
|
|
448
|
+
} |
|
|
449
|
+
/**
|
|
450
|
+
* While the server's clock is in `[from, to)`: ISO 8601 date-times in UTC,
|
|
451
|
+
* either of them open. A device gets the change at its next fetch.
|
|
452
|
+
*/
|
|
453
|
+
{
|
|
454
|
+
readonly type: "dateTime";
|
|
455
|
+
readonly from?: string;
|
|
456
|
+
readonly to?: string;
|
|
457
|
+
};
|
|
458
|
+
interface RemoteConfigCondition {
|
|
459
|
+
/** Unique in the template; parameters name it in `conditionalValues`. */
|
|
460
|
+
readonly name: string;
|
|
461
|
+
/** Every rule must match. */
|
|
462
|
+
readonly rules: readonly RemoteConfigRule[];
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Everything Remote Config serves, published as a whole and versioned.
|
|
466
|
+
*/
|
|
467
|
+
interface RemoteConfigTemplate {
|
|
468
|
+
/** In priority order: the first one that matches decides a parameter's value. */
|
|
469
|
+
readonly conditions: readonly RemoteConfigCondition[];
|
|
470
|
+
readonly parameters: Readonly<Record<string, RemoteConfigParameter>>;
|
|
471
|
+
}
|
|
472
|
+
/** What the server knows of a device; a rule on a missing field never matches. */
|
|
473
|
+
type RemoteConfigEvaluationContext = Partial<Readonly<{ [K in keyof RemoteConfigDeviceContext]: RemoteConfigDeviceContext[K] | null; }>> & {
|
|
474
|
+
/**
|
|
475
|
+
* When to evaluate, in ms since the epoch. The server uses its own clock;
|
|
476
|
+
* a `dateTime` rule never matches without it.
|
|
477
|
+
*/
|
|
478
|
+
readonly now?: number;
|
|
479
|
+
};
|
|
480
|
+
//#endregion
|
|
481
|
+
//#region ../remote-config/dist/server/api.d.mts
|
|
482
|
+
//#region src/server/api.d.ts
|
|
483
|
+
/** A published version's record, without its template. */
|
|
484
|
+
interface RemoteConfigVersion {
|
|
485
|
+
readonly version: number;
|
|
486
|
+
readonly description: string | null;
|
|
487
|
+
/** `ROLLBACK` when the version copies `rollbackSource`. */
|
|
488
|
+
readonly updateType: "PUBLISH" | "ROLLBACK";
|
|
489
|
+
readonly rollbackSource: number | null;
|
|
490
|
+
readonly createdAtMs: number;
|
|
491
|
+
}
|
|
492
|
+
interface RemoteConfigVersionDetail extends RemoteConfigVersion {
|
|
493
|
+
readonly template: RemoteConfigTemplate;
|
|
494
|
+
}
|
|
495
|
+
/** The template devices receive now. */
|
|
496
|
+
interface RemoteConfigActive {
|
|
497
|
+
/** 0, with an empty template, before the first publish. */
|
|
498
|
+
readonly version: number;
|
|
499
|
+
readonly template: RemoteConfigTemplate;
|
|
500
|
+
readonly updatedAtMs: number | null;
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* How a publish or a rollback ended: `conflict` when another publish moved
|
|
504
|
+
* the active version past `baseVersion` first, so a stale edit never
|
|
505
|
+
* replaces a newer template.
|
|
506
|
+
*/
|
|
507
|
+
type RemoteConfigPublishResult = {
|
|
508
|
+
readonly status: "published";
|
|
509
|
+
readonly version: RemoteConfigVersion;
|
|
510
|
+
} | {
|
|
511
|
+
readonly status: "conflict";
|
|
512
|
+
readonly currentVersion: number;
|
|
513
|
+
};
|
|
514
|
+
interface RemoteConfigVersionsPage {
|
|
515
|
+
/** Newest first. */
|
|
516
|
+
readonly versions: readonly RemoteConfigVersion[];
|
|
517
|
+
/** Pass as `cursor` for the next page; absent on the last one. */
|
|
518
|
+
readonly next?: string;
|
|
519
|
+
}
|
|
520
|
+
/** `hotUpdater.api.remoteConfig`. */
|
|
521
|
+
interface RemoteConfigApi {
|
|
522
|
+
/** The active template and its version. */
|
|
523
|
+
getActive(): Promise<RemoteConfigActive>;
|
|
524
|
+
/**
|
|
525
|
+
* Validates and publishes a template as the next version. Throws
|
|
526
|
+
* `RemoteConfigValidationError` for an invalid template.
|
|
527
|
+
*/
|
|
528
|
+
publish(input: {
|
|
529
|
+
readonly template: unknown;
|
|
530
|
+
/** The version the edit started from; 0 before the first publish. */
|
|
531
|
+
readonly baseVersion: number;
|
|
532
|
+
readonly description?: string;
|
|
533
|
+
}): Promise<RemoteConfigPublishResult>;
|
|
534
|
+
/** Publishes a copy of an earlier version; `not_found` when it does not exist. */
|
|
535
|
+
rollback(input: {
|
|
536
|
+
readonly version: number;
|
|
537
|
+
readonly baseVersion: number;
|
|
538
|
+
readonly description?: string;
|
|
539
|
+
}): Promise<RemoteConfigPublishResult | {
|
|
540
|
+
readonly status: "not_found";
|
|
541
|
+
}>;
|
|
542
|
+
/** One page of published versions, newest first. */
|
|
543
|
+
listVersions(input?: {
|
|
544
|
+
readonly limit?: number;
|
|
545
|
+
readonly cursor?: string;
|
|
546
|
+
}): Promise<RemoteConfigVersionsPage>;
|
|
547
|
+
/** One version with its template, or null. */
|
|
548
|
+
getVersion(version: number): Promise<RemoteConfigVersionDetail | null>;
|
|
549
|
+
/**
|
|
550
|
+
* What a device with this context receives from `GET /remote-config`, at
|
|
551
|
+
* `context.now` or, without it, now.
|
|
552
|
+
*/
|
|
553
|
+
resolve(context: RemoteConfigEvaluationContext): Promise<RemoteConfigFetchResponse>;
|
|
554
|
+
}
|
|
555
|
+
//#endregion
|
|
368
556
|
//#region src/plugins.d.ts
|
|
369
557
|
/**
|
|
370
|
-
* The plugins the managed Firebase server runs: Insights,
|
|
371
|
-
* client route. Its Cloud Function imports this list.
|
|
558
|
+
* The plugins the managed Firebase server runs: Insights, API keys on every
|
|
559
|
+
* client route, and Remote Config. Its Cloud Function imports this list.
|
|
372
560
|
*/
|
|
373
561
|
declare const plugins: readonly [import("@hot-updater/plugin-core").HotUpdaterPlugin<"insights", {
|
|
374
562
|
readonly bundle_events: import("@hot-updater/plugin-core").TableDefinition<{
|
|
@@ -810,6 +998,54 @@ declare const plugins: readonly [import("@hot-updater/plugin-core").HotUpdaterPl
|
|
|
810
998
|
};
|
|
811
999
|
}, {
|
|
812
1000
|
readonly clientAuth: true;
|
|
813
|
-
}
|
|
1001
|
+
}>, import("@hot-updater/plugin-core").HotUpdaterPlugin<"remoteConfig", {
|
|
1002
|
+
readonly remote_config_active: import("@hot-updater/plugin-core").TableDefinition<{
|
|
1003
|
+
readonly id: {
|
|
1004
|
+
readonly type: "string";
|
|
1005
|
+
readonly maxLength: 16;
|
|
1006
|
+
};
|
|
1007
|
+
readonly version: {
|
|
1008
|
+
readonly type: "integer";
|
|
1009
|
+
};
|
|
1010
|
+
readonly template: {
|
|
1011
|
+
readonly type: "json";
|
|
1012
|
+
};
|
|
1013
|
+
readonly updated_at_ms: {
|
|
1014
|
+
readonly type: "integer";
|
|
1015
|
+
};
|
|
1016
|
+
}, {}, {}, readonly ["id"]>;
|
|
1017
|
+
readonly remote_config_versions: import("@hot-updater/plugin-core").TableDefinition<{
|
|
1018
|
+
readonly version: {
|
|
1019
|
+
readonly type: "integer";
|
|
1020
|
+
};
|
|
1021
|
+
readonly template: {
|
|
1022
|
+
readonly type: "json";
|
|
1023
|
+
};
|
|
1024
|
+
readonly description: {
|
|
1025
|
+
readonly type: "string";
|
|
1026
|
+
readonly maxLength: 256;
|
|
1027
|
+
readonly required: false;
|
|
1028
|
+
};
|
|
1029
|
+
readonly update_type: {
|
|
1030
|
+
readonly type: "string";
|
|
1031
|
+
readonly maxLength: 16;
|
|
1032
|
+
};
|
|
1033
|
+
readonly rollback_source: {
|
|
1034
|
+
readonly type: "integer";
|
|
1035
|
+
readonly required: false;
|
|
1036
|
+
};
|
|
1037
|
+
readonly created_at_ms: {
|
|
1038
|
+
readonly type: "integer";
|
|
1039
|
+
};
|
|
1040
|
+
}, {}, {
|
|
1041
|
+
readonly byVersion: {
|
|
1042
|
+
readonly eq: readonly [];
|
|
1043
|
+
readonly sort: readonly ["version"];
|
|
1044
|
+
};
|
|
1045
|
+
}, readonly ["version"]>;
|
|
1046
|
+
}, {
|
|
1047
|
+
api: RemoteConfigApi;
|
|
1048
|
+
endpoints: readonly import("@hot-updater/plugin-core").PluginEndpoint[];
|
|
1049
|
+
}, {}>];
|
|
814
1050
|
//#endregion
|
|
815
1051
|
export { FirebaseDatabaseConfig, FirebaseStorageConfig, firebaseDatabase, firebaseStorage, migrateFirebaseDatabase, plugins };
|
package/dist/index.d.mts
CHANGED
|
@@ -365,10 +365,198 @@ interface CreatedApiKey {
|
|
|
365
365
|
readonly record: ApiKeyMetadata;
|
|
366
366
|
}
|
|
367
367
|
//#endregion
|
|
368
|
+
//#region ../remote-config/dist/shared/wire.d.mts
|
|
369
|
+
//#region src/shared/wire.d.ts
|
|
370
|
+
/** What a device tells the server, so the server can evaluate conditions. */
|
|
371
|
+
interface RemoteConfigDeviceContext {
|
|
372
|
+
readonly platform: "ios" | "android";
|
|
373
|
+
/** The native app version, or null when the build has none. */
|
|
374
|
+
readonly appVersion: string | null;
|
|
375
|
+
readonly channel: string;
|
|
376
|
+
/** A numeric cohort from 1 to 1000, or a custom cohort's slug. */
|
|
377
|
+
readonly cohort: string;
|
|
378
|
+
/** The native build's fingerprint, or null without one. */
|
|
379
|
+
readonly fingerprintHash: string | null;
|
|
380
|
+
}
|
|
381
|
+
/** The body of a `200` from `GET /remote-config`. */
|
|
382
|
+
interface RemoteConfigFetchResponse {
|
|
383
|
+
/** The published template version the values come from; 0 before the first publish. */
|
|
384
|
+
readonly version: number;
|
|
385
|
+
/**
|
|
386
|
+
* Each parameter's value for this device, as text. A parameter whose
|
|
387
|
+
* value is the app's own default is left out.
|
|
388
|
+
*/
|
|
389
|
+
readonly values: Readonly<Record<string, string>>;
|
|
390
|
+
}
|
|
391
|
+
//#endregion
|
|
392
|
+
//#region ../remote-config/dist/server/template.d.mts
|
|
393
|
+
//#region src/server/template.d.ts
|
|
394
|
+
/**
|
|
395
|
+
* How the Console edits a parameter's value and checks it before a publish.
|
|
396
|
+
* Devices receive every value as text.
|
|
397
|
+
*/
|
|
398
|
+
type RemoteConfigValueType = "STRING" | "NUMBER" | "BOOLEAN" | "JSON";
|
|
399
|
+
/** A value a parameter takes: text, or the app's own default. */
|
|
400
|
+
type RemoteConfigParameterValue = {
|
|
401
|
+
readonly value: string;
|
|
402
|
+
} | {
|
|
403
|
+
readonly useInAppDefault: true;
|
|
404
|
+
};
|
|
405
|
+
interface RemoteConfigParameter {
|
|
406
|
+
readonly valueType: RemoteConfigValueType;
|
|
407
|
+
/** The value when none of the parameter's conditions match. */
|
|
408
|
+
readonly defaultValue: RemoteConfigParameterValue;
|
|
409
|
+
/**
|
|
410
|
+
* Values by condition name. When several of these conditions match, the
|
|
411
|
+
* one listed first in the template's `conditions` wins.
|
|
412
|
+
*/
|
|
413
|
+
readonly conditionalValues?: Readonly<Record<string, RemoteConfigParameterValue>>;
|
|
414
|
+
readonly description?: string;
|
|
415
|
+
}
|
|
416
|
+
/** A test on a device's context; a condition matches when all of its rules do. */
|
|
417
|
+
type RemoteConfigRule = {
|
|
418
|
+
readonly type: "platform";
|
|
419
|
+
readonly platforms: readonly ("ios" | "android")[];
|
|
420
|
+
} | {
|
|
421
|
+
readonly type: "channel";
|
|
422
|
+
readonly channels: readonly string[];
|
|
423
|
+
} |
|
|
424
|
+
/** A semver range, such as `>=1.4.0` or `2.x`, as release targets use. */
|
|
425
|
+
{
|
|
426
|
+
readonly type: "appVersion";
|
|
427
|
+
readonly range: string;
|
|
428
|
+
} |
|
|
429
|
+
/** Devices whose cohort is one of these: numbers from 1 to 1000 or slugs. */
|
|
430
|
+
{
|
|
431
|
+
readonly type: "cohort";
|
|
432
|
+
readonly cohorts: readonly string[];
|
|
433
|
+
} |
|
|
434
|
+
/**
|
|
435
|
+
* A share of numeric cohorts: the devices whose cohort lands in
|
|
436
|
+
* `[from, to)` percent once `seed` shuffles the 1,000 cohorts. Rules with
|
|
437
|
+
* one seed pick from one order, so `0–10` and `10–20` never overlap; a new
|
|
438
|
+
* seed picks other devices. Custom cohorts never match.
|
|
439
|
+
*/
|
|
440
|
+
{
|
|
441
|
+
readonly type: "percent";
|
|
442
|
+
readonly seed: string;
|
|
443
|
+
readonly from: number;
|
|
444
|
+
readonly to: number;
|
|
445
|
+
} | {
|
|
446
|
+
readonly type: "fingerprint";
|
|
447
|
+
readonly hashes: readonly string[];
|
|
448
|
+
} |
|
|
449
|
+
/**
|
|
450
|
+
* While the server's clock is in `[from, to)`: ISO 8601 date-times in UTC,
|
|
451
|
+
* either of them open. A device gets the change at its next fetch.
|
|
452
|
+
*/
|
|
453
|
+
{
|
|
454
|
+
readonly type: "dateTime";
|
|
455
|
+
readonly from?: string;
|
|
456
|
+
readonly to?: string;
|
|
457
|
+
};
|
|
458
|
+
interface RemoteConfigCondition {
|
|
459
|
+
/** Unique in the template; parameters name it in `conditionalValues`. */
|
|
460
|
+
readonly name: string;
|
|
461
|
+
/** Every rule must match. */
|
|
462
|
+
readonly rules: readonly RemoteConfigRule[];
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Everything Remote Config serves, published as a whole and versioned.
|
|
466
|
+
*/
|
|
467
|
+
interface RemoteConfigTemplate {
|
|
468
|
+
/** In priority order: the first one that matches decides a parameter's value. */
|
|
469
|
+
readonly conditions: readonly RemoteConfigCondition[];
|
|
470
|
+
readonly parameters: Readonly<Record<string, RemoteConfigParameter>>;
|
|
471
|
+
}
|
|
472
|
+
/** What the server knows of a device; a rule on a missing field never matches. */
|
|
473
|
+
type RemoteConfigEvaluationContext = Partial<Readonly<{ [K in keyof RemoteConfigDeviceContext]: RemoteConfigDeviceContext[K] | null; }>> & {
|
|
474
|
+
/**
|
|
475
|
+
* When to evaluate, in ms since the epoch. The server uses its own clock;
|
|
476
|
+
* a `dateTime` rule never matches without it.
|
|
477
|
+
*/
|
|
478
|
+
readonly now?: number;
|
|
479
|
+
};
|
|
480
|
+
//#endregion
|
|
481
|
+
//#region ../remote-config/dist/server/api.d.mts
|
|
482
|
+
//#region src/server/api.d.ts
|
|
483
|
+
/** A published version's record, without its template. */
|
|
484
|
+
interface RemoteConfigVersion {
|
|
485
|
+
readonly version: number;
|
|
486
|
+
readonly description: string | null;
|
|
487
|
+
/** `ROLLBACK` when the version copies `rollbackSource`. */
|
|
488
|
+
readonly updateType: "PUBLISH" | "ROLLBACK";
|
|
489
|
+
readonly rollbackSource: number | null;
|
|
490
|
+
readonly createdAtMs: number;
|
|
491
|
+
}
|
|
492
|
+
interface RemoteConfigVersionDetail extends RemoteConfigVersion {
|
|
493
|
+
readonly template: RemoteConfigTemplate;
|
|
494
|
+
}
|
|
495
|
+
/** The template devices receive now. */
|
|
496
|
+
interface RemoteConfigActive {
|
|
497
|
+
/** 0, with an empty template, before the first publish. */
|
|
498
|
+
readonly version: number;
|
|
499
|
+
readonly template: RemoteConfigTemplate;
|
|
500
|
+
readonly updatedAtMs: number | null;
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* How a publish or a rollback ended: `conflict` when another publish moved
|
|
504
|
+
* the active version past `baseVersion` first, so a stale edit never
|
|
505
|
+
* replaces a newer template.
|
|
506
|
+
*/
|
|
507
|
+
type RemoteConfigPublishResult = {
|
|
508
|
+
readonly status: "published";
|
|
509
|
+
readonly version: RemoteConfigVersion;
|
|
510
|
+
} | {
|
|
511
|
+
readonly status: "conflict";
|
|
512
|
+
readonly currentVersion: number;
|
|
513
|
+
};
|
|
514
|
+
interface RemoteConfigVersionsPage {
|
|
515
|
+
/** Newest first. */
|
|
516
|
+
readonly versions: readonly RemoteConfigVersion[];
|
|
517
|
+
/** Pass as `cursor` for the next page; absent on the last one. */
|
|
518
|
+
readonly next?: string;
|
|
519
|
+
}
|
|
520
|
+
/** `hotUpdater.api.remoteConfig`. */
|
|
521
|
+
interface RemoteConfigApi {
|
|
522
|
+
/** The active template and its version. */
|
|
523
|
+
getActive(): Promise<RemoteConfigActive>;
|
|
524
|
+
/**
|
|
525
|
+
* Validates and publishes a template as the next version. Throws
|
|
526
|
+
* `RemoteConfigValidationError` for an invalid template.
|
|
527
|
+
*/
|
|
528
|
+
publish(input: {
|
|
529
|
+
readonly template: unknown;
|
|
530
|
+
/** The version the edit started from; 0 before the first publish. */
|
|
531
|
+
readonly baseVersion: number;
|
|
532
|
+
readonly description?: string;
|
|
533
|
+
}): Promise<RemoteConfigPublishResult>;
|
|
534
|
+
/** Publishes a copy of an earlier version; `not_found` when it does not exist. */
|
|
535
|
+
rollback(input: {
|
|
536
|
+
readonly version: number;
|
|
537
|
+
readonly baseVersion: number;
|
|
538
|
+
readonly description?: string;
|
|
539
|
+
}): Promise<RemoteConfigPublishResult | {
|
|
540
|
+
readonly status: "not_found";
|
|
541
|
+
}>;
|
|
542
|
+
/** One page of published versions, newest first. */
|
|
543
|
+
listVersions(input?: {
|
|
544
|
+
readonly limit?: number;
|
|
545
|
+
readonly cursor?: string;
|
|
546
|
+
}): Promise<RemoteConfigVersionsPage>;
|
|
547
|
+
/** One version with its template, or null. */
|
|
548
|
+
getVersion(version: number): Promise<RemoteConfigVersionDetail | null>;
|
|
549
|
+
/**
|
|
550
|
+
* What a device with this context receives from `GET /remote-config`, at
|
|
551
|
+
* `context.now` or, without it, now.
|
|
552
|
+
*/
|
|
553
|
+
resolve(context: RemoteConfigEvaluationContext): Promise<RemoteConfigFetchResponse>;
|
|
554
|
+
}
|
|
555
|
+
//#endregion
|
|
368
556
|
//#region src/plugins.d.ts
|
|
369
557
|
/**
|
|
370
|
-
* The plugins the managed Firebase server runs: Insights,
|
|
371
|
-
* client route. Its Cloud Function imports this list.
|
|
558
|
+
* The plugins the managed Firebase server runs: Insights, API keys on every
|
|
559
|
+
* client route, and Remote Config. Its Cloud Function imports this list.
|
|
372
560
|
*/
|
|
373
561
|
declare const plugins: readonly [import("@hot-updater/plugin-core").HotUpdaterPlugin<"insights", {
|
|
374
562
|
readonly bundle_events: import("@hot-updater/plugin-core").TableDefinition<{
|
|
@@ -810,6 +998,54 @@ declare const plugins: readonly [import("@hot-updater/plugin-core").HotUpdaterPl
|
|
|
810
998
|
};
|
|
811
999
|
}, {
|
|
812
1000
|
readonly clientAuth: true;
|
|
813
|
-
}
|
|
1001
|
+
}>, import("@hot-updater/plugin-core").HotUpdaterPlugin<"remoteConfig", {
|
|
1002
|
+
readonly remote_config_active: import("@hot-updater/plugin-core").TableDefinition<{
|
|
1003
|
+
readonly id: {
|
|
1004
|
+
readonly type: "string";
|
|
1005
|
+
readonly maxLength: 16;
|
|
1006
|
+
};
|
|
1007
|
+
readonly version: {
|
|
1008
|
+
readonly type: "integer";
|
|
1009
|
+
};
|
|
1010
|
+
readonly template: {
|
|
1011
|
+
readonly type: "json";
|
|
1012
|
+
};
|
|
1013
|
+
readonly updated_at_ms: {
|
|
1014
|
+
readonly type: "integer";
|
|
1015
|
+
};
|
|
1016
|
+
}, {}, {}, readonly ["id"]>;
|
|
1017
|
+
readonly remote_config_versions: import("@hot-updater/plugin-core").TableDefinition<{
|
|
1018
|
+
readonly version: {
|
|
1019
|
+
readonly type: "integer";
|
|
1020
|
+
};
|
|
1021
|
+
readonly template: {
|
|
1022
|
+
readonly type: "json";
|
|
1023
|
+
};
|
|
1024
|
+
readonly description: {
|
|
1025
|
+
readonly type: "string";
|
|
1026
|
+
readonly maxLength: 256;
|
|
1027
|
+
readonly required: false;
|
|
1028
|
+
};
|
|
1029
|
+
readonly update_type: {
|
|
1030
|
+
readonly type: "string";
|
|
1031
|
+
readonly maxLength: 16;
|
|
1032
|
+
};
|
|
1033
|
+
readonly rollback_source: {
|
|
1034
|
+
readonly type: "integer";
|
|
1035
|
+
readonly required: false;
|
|
1036
|
+
};
|
|
1037
|
+
readonly created_at_ms: {
|
|
1038
|
+
readonly type: "integer";
|
|
1039
|
+
};
|
|
1040
|
+
}, {}, {
|
|
1041
|
+
readonly byVersion: {
|
|
1042
|
+
readonly eq: readonly [];
|
|
1043
|
+
readonly sort: readonly ["version"];
|
|
1044
|
+
};
|
|
1045
|
+
}, readonly ["version"]>;
|
|
1046
|
+
}, {
|
|
1047
|
+
api: RemoteConfigApi;
|
|
1048
|
+
endpoints: readonly import("@hot-updater/plugin-core").PluginEndpoint[];
|
|
1049
|
+
}, {}>];
|
|
814
1050
|
//#endregion
|
|
815
1051
|
export { FirebaseDatabaseConfig, FirebaseStorageConfig, firebaseDatabase, firebaseStorage, migrateFirebaseDatabase, plugins };
|
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { createHash } from "node:crypto";
|
|
|
5
5
|
import { getStorage } from "firebase-admin/storage";
|
|
6
6
|
import { apiKeys } from "@hot-updater/server/plugins/api-keys";
|
|
7
7
|
import { insights } from "@hot-updater/server/plugins/insights";
|
|
8
|
+
import { remoteConfig } from "@hot-updater/server/plugins/remote-config";
|
|
8
9
|
//#region src/firebaseInfrastructureNames.ts
|
|
9
10
|
/**
|
|
10
11
|
* The one collection the storage engine keeps every item in. It namespaces
|
|
@@ -262,9 +263,13 @@ const firebaseStorage = (config) => {
|
|
|
262
263
|
//#endregion
|
|
263
264
|
//#region src/plugins.ts
|
|
264
265
|
/**
|
|
265
|
-
* The plugins the managed Firebase server runs: Insights,
|
|
266
|
-
* client route. Its Cloud Function imports this list.
|
|
266
|
+
* The plugins the managed Firebase server runs: Insights, API keys on every
|
|
267
|
+
* client route, and Remote Config. Its Cloud Function imports this list.
|
|
267
268
|
*/
|
|
268
|
-
const plugins = [
|
|
269
|
+
const plugins = [
|
|
270
|
+
insights(),
|
|
271
|
+
apiKeys(),
|
|
272
|
+
remoteConfig()
|
|
273
|
+
];
|
|
269
274
|
//#endregion
|
|
270
275
|
export { firebaseDatabase, firebaseStorage, migrateFirebaseDatabase, plugins };
|
package/dist/init/index.cjs
CHANGED
|
@@ -52,6 +52,7 @@ let firebase_admin_firestore = require("firebase-admin/firestore");
|
|
|
52
52
|
let node_crypto = require("node:crypto");
|
|
53
53
|
let _hot_updater_server_plugins_api_keys = require("@hot-updater/server/plugins/api-keys");
|
|
54
54
|
let _hot_updater_server_plugins_insights = require("@hot-updater/server/plugins/insights");
|
|
55
|
+
let _hot_updater_server_plugins_remote_config = require("@hot-updater/server/plugins/remote-config");
|
|
55
56
|
let fs_promises = require("fs/promises");
|
|
56
57
|
fs_promises = __toESM(fs_promises, 1);
|
|
57
58
|
let node_fs_promises = require("node:fs/promises");
|
|
@@ -6899,10 +6900,14 @@ const firebaseDatabase = (config) => (0, _hot_updater_plugin_core.createEngineDa
|
|
|
6899
6900
|
//#endregion
|
|
6900
6901
|
//#region src/plugins.ts
|
|
6901
6902
|
/**
|
|
6902
|
-
* The plugins the managed Firebase server runs: Insights,
|
|
6903
|
-
* client route. Its Cloud Function imports this list.
|
|
6903
|
+
* The plugins the managed Firebase server runs: Insights, API keys on every
|
|
6904
|
+
* client route, and Remote Config. Its Cloud Function imports this list.
|
|
6904
6905
|
*/
|
|
6905
|
-
const plugins = [
|
|
6906
|
+
const plugins = [
|
|
6907
|
+
(0, _hot_updater_server_plugins_insights.insights)(),
|
|
6908
|
+
(0, _hot_updater_server_plugins_api_keys.apiKeys)(),
|
|
6909
|
+
(0, _hot_updater_server_plugins_remote_config.remoteConfig)()
|
|
6910
|
+
];
|
|
6906
6911
|
//#endregion
|
|
6907
6912
|
//#region iac/init/index.ts
|
|
6908
6913
|
const isFirebaseRegion = (value) => value !== void 0 && /^[a-z]+(?:-[a-z]+)+[0-9]+$/.test(value);
|
package/dist/init/index.mjs
CHANGED
|
@@ -23,6 +23,7 @@ import { FieldPath, FieldValue, Timestamp, getFirestore } from "firebase-admin/f
|
|
|
23
23
|
import { createHash } from "node:crypto";
|
|
24
24
|
import { apiKeys } from "@hot-updater/server/plugins/api-keys";
|
|
25
25
|
import { insights } from "@hot-updater/server/plugins/insights";
|
|
26
|
+
import { remoteConfig } from "@hot-updater/server/plugins/remote-config";
|
|
26
27
|
import fs$1 from "fs/promises";
|
|
27
28
|
import fs$2 from "node:fs/promises";
|
|
28
29
|
//#region \0rolldown/runtime.js
|
|
@@ -6892,10 +6893,14 @@ const firebaseDatabase = (config) => createEngineDatabase({
|
|
|
6892
6893
|
//#endregion
|
|
6893
6894
|
//#region src/plugins.ts
|
|
6894
6895
|
/**
|
|
6895
|
-
* The plugins the managed Firebase server runs: Insights,
|
|
6896
|
-
* client route. Its Cloud Function imports this list.
|
|
6896
|
+
* The plugins the managed Firebase server runs: Insights, API keys on every
|
|
6897
|
+
* client route, and Remote Config. Its Cloud Function imports this list.
|
|
6897
6898
|
*/
|
|
6898
|
-
const plugins = [
|
|
6899
|
+
const plugins = [
|
|
6900
|
+
insights(),
|
|
6901
|
+
apiKeys(),
|
|
6902
|
+
remoteConfig()
|
|
6903
|
+
];
|
|
6899
6904
|
//#endregion
|
|
6900
6905
|
//#region iac/init/index.ts
|
|
6901
6906
|
const isFirebaseRegion = (value) => value !== void 0 && /^[a-z]+(?:-[a-z]+)+[0-9]+$/.test(value);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/firebase",
|
|
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
|
"types": "dist/index.d.cts",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"hono": "4.12.34",
|
|
40
|
-
"@hot-updater/
|
|
41
|
-
"@hot-updater/protocol": "1.0.0-rc.
|
|
42
|
-
"@hot-updater/
|
|
43
|
-
"@hot-updater/
|
|
40
|
+
"@hot-updater/plugin-core": "1.0.0-rc.41",
|
|
41
|
+
"@hot-updater/protocol": "1.0.0-rc.41",
|
|
42
|
+
"@hot-updater/server": "1.0.0-rc.41",
|
|
43
|
+
"@hot-updater/cli-tools": "1.0.0-rc.41"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"firebase-tools": "15.29.0",
|
|
56
56
|
"fkill": "^9.0.0",
|
|
57
57
|
"mime": "^4.0.4",
|
|
58
|
-
"@hot-updater/mock": "1.0.0-rc.
|
|
59
|
-
"@hot-updater/test-utils": "1.0.0-rc.
|
|
58
|
+
"@hot-updater/mock": "1.0.0-rc.41",
|
|
59
|
+
"@hot-updater/test-utils": "1.0.0-rc.41"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"firebase-admin": "*",
|