Skip to content

Commit eec3660

Browse files
feat(rc): Add Remote Config Version Management API (#920)
* Get remote config template by version number (#874) * Get remote config template by version number * Refactor unit tests for Remote Config (#884) * Refactor unit tests * Add Remote Config Rollback operation (#885) * Add Remote Config Rollback operation * Update docs and move etag validation to a helper function * Update docs * Introduce a util to create a template from API response * PR fixes * Remote Config Add list versions operation (#896) * Remote Config: Add list versions operation * Add version Impl and other PR fixes * PR fixes * Imrpoved unit tests and some code clean up * Fix code formatting * Add a separate function to get a Template with version (#902) * Add version meta data to RC templates (#906) * Add version meta data to RC templates * PR fixes * Use assertion to unwrap template.version * Update Remote Config Docstrings in index.d.ts
1 parent 98b4788 commit eec3660

File tree

5 files changed

+1353
-598
lines changed

5 files changed

+1353
-598
lines changed

src/index.d.ts

Lines changed: 159 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,11 @@ declare namespace admin.remoteConfig {
880880
* ETag of the current Remote Config template (readonly).
881881
*/
882882
readonly etag: string;
883+
884+
/**
885+
* Version information for the current Remote Config template.
886+
*/
887+
version?: Version;
883888
}
884889

885890
/**
@@ -984,6 +989,123 @@ declare namespace admin.remoteConfig {
984989
*/
985990
type RemoteConfigParameterValue = ExplicitParameterValue | InAppDefaultValue;
986991

992+
/**
993+
* Interface representing a Remote Config template version.
994+
* Output only, except for the version description. Contains metadata about a particular
995+
* version of the Remote Config template. All fields are set at the time the specified Remote
996+
* Config template is published. A version's description field may be specified in
997+
* `publishTemplate` calls.
998+
*/
999+
export interface Version {
1000+
/**
1001+
* The version number of a Remote Config template.
1002+
*/
1003+
versionNumber?: string;
1004+
1005+
/**
1006+
* The timestamp of when this version of the Remote Config template was written to the
1007+
* Remote Config backend.
1008+
*/
1009+
updateTime?: string;
1010+
1011+
/**
1012+
* The origin of the template update action.
1013+
*/
1014+
updateOrigin?: ('REMOTE_CONFIG_UPDATE_ORIGIN_UNSPECIFIED' | 'CONSOLE' |
1015+
'REST_API' | 'ADMIN_SDK_NODE');
1016+
1017+
/**
1018+
* The type of the template update action.
1019+
*/
1020+
updateType?: ('REMOTE_CONFIG_UPDATE_TYPE_UNSPECIFIED' |
1021+
'INCREMENTAL_UPDATE' | 'FORCED_UPDATE' | 'ROLLBACK');
1022+
1023+
/**
1024+
* Aggregation of all metadata fields about the account that performed the update.
1025+
*/
1026+
updateUser?: RemoteConfigUser;
1027+
1028+
/**
1029+
* The user-provided description of the corresponding Remote Config template.
1030+
*/
1031+
description?: string;
1032+
1033+
/**
1034+
* The version number of the Remote Config template that has become the current version
1035+
* due to a rollback. Only present if this version is the result of a rollback.
1036+
*/
1037+
rollbackSource?: string;
1038+
1039+
/**
1040+
* Indicates whether this Remote Config template was published before version history was
1041+
* supported.
1042+
*/
1043+
isLegacy?: boolean;
1044+
}
1045+
1046+
/** Interface representing a list of Remote Config template versions. */
1047+
export interface ListVersionsResult {
1048+
/**
1049+
* A list of version metadata objects, sorted in reverse chronological order.
1050+
*/
1051+
versions: Version[];
1052+
1053+
/**
1054+
* Token to retrieve the next page of results, or empty if there are no more results
1055+
* in the list.
1056+
*/
1057+
nextPageToken?: string;
1058+
}
1059+
1060+
/** Interface representing options for Remote Config list versions operation. */
1061+
export interface ListVersionsOptions {
1062+
/**
1063+
* The maximum number of items to return per page.
1064+
*/
1065+
pageSize?: number;
1066+
1067+
/**
1068+
* The `nextPageToken` value returned from a previous list versions request, if any.
1069+
*/
1070+
pageToken?: string;
1071+
1072+
/**
1073+
* Specifies the newest version number to include in the results.
1074+
* If specified, must be greater than zero. Defaults to the newest version.
1075+
*/
1076+
endVersionNumber?: string | number;
1077+
1078+
/**
1079+
* Specifies the earliest update time to include in the results. Any entries updated before this
1080+
* time are omitted.
1081+
*/
1082+
startTime?: Date | string;
1083+
1084+
/**
1085+
* Specifies the latest update time to include in the results. Any entries updated on or after
1086+
* this time are omitted.
1087+
*/
1088+
endTime?: Date | string;
1089+
}
1090+
1091+
/** Interface representing a Remote Config user.*/
1092+
export interface RemoteConfigUser {
1093+
/**
1094+
* Email address. Output only.
1095+
*/
1096+
email: string;
1097+
1098+
/**
1099+
* Display name. Output only.
1100+
*/
1101+
name?: string;
1102+
1103+
/**
1104+
* Image URL. Output only.
1105+
*/
1106+
imageUrl?: string;
1107+
}
1108+
9871109
/**
9881110
* The Firebase `RemoteConfig` service interface.
9891111
*
@@ -1001,6 +1123,16 @@ declare namespace admin.remoteConfig {
10011123
*/
10021124
getTemplate(): Promise<RemoteConfigTemplate>;
10031125

1126+
/**
1127+
* Gets the requested version of the {@link admin.remoteConfig.RemoteConfigTemplate
1128+
* `RemoteConfigTemplate`} of the project.
1129+
*
1130+
* @param versionNumber Version number of the Remote Config template to look up.
1131+
*
1132+
* @return A promise that fulfills with a `RemoteConfigTemplate`.
1133+
*/
1134+
getTemplateAtVersion(versionNumber: number | string): Promise<RemoteConfigTemplate>;
1135+
10041136
/**
10051137
* Validates a {@link admin.remoteConfig.RemoteConfigTemplate `RemoteConfigTemplate`}.
10061138
*
@@ -1025,6 +1157,32 @@ declare namespace admin.remoteConfig {
10251157
*/
10261158
publishTemplate(template: RemoteConfigTemplate, options?: { force: boolean }): Promise<RemoteConfigTemplate>;
10271159

1160+
/**
1161+
* Rolls back a project's published Remote Config template to the specified version.
1162+
* A rollback is equivalent to getting a previously published Remote Config
1163+
* template and re-publishing it using a force update.
1164+
*
1165+
* @param versionNumber The version number of the Remote Config template to roll back to.
1166+
* The specified version number must be lower than the current version number, and not have
1167+
* been deleted due to staleness. Only the last 300 versions are stored.
1168+
* All versions that correspond to non-active Remote Config templates (that is, all except the
1169+
* template that is being fetched by clients) are also deleted if they are more than 90 days old.
1170+
* @return A promise that fulfills with the published `RemoteConfigTemplate`.
1171+
*/
1172+
rollback(versionNumber: string | number): Promise<RemoteConfigTemplate>;
1173+
1174+
/**
1175+
* Gets a list of Remote Config template versions that have been published, sorted in reverse
1176+
* chronological order. Only the last 300 versions are stored.
1177+
* All versions that correspond to non-active Remote Config templates (that is, all except the
1178+
* template that is being fetched by clients) are also deleted if they are more than 90 days old.
1179+
*
1180+
* @param options Optional {@link admin.remoteConfig.ListVersionsOptions `ListVersionsOptions`}
1181+
* object for getting a list of template versions.
1182+
* @return A promise that fulfills with a `ListVersionsResult`.
1183+
*/
1184+
listVersions(options?: ListVersionsOptions): Promise<ListVersionsResult>;
1185+
10281186
/**
10291187
* Creates and returns a new Remote Config template from a JSON string.
10301188
*
@@ -1110,7 +1268,7 @@ declare namespace admin.machineLearning {
11101268
*
11111269
* Example: `tfliteModel: { gcsTfliteUri: 'gs://your-bucket/your-model.tflite' }`
11121270
*/
1113-
tfliteModel?: {gcsTfliteUri: string};
1271+
tfliteModel?: { gcsTfliteUri: string };
11141272
}
11151273

11161274
/**

0 commit comments

Comments
 (0)