Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

feat: support mapping avatar url from oauth2

johnnyjoyeb33a604b276
diff --git a/plugin/idp/idp.go b/plugin/idp/idp.go
index c83bccfdc..1360d6af8 100644
--- a/plugin/idp/idp.go
+++ b/plugin/idp/idp.go
@@ -4,4 +4,5 @@ type IdentityProviderUserInfo struct {
Identifier string
DisplayName string
Email string
+ AvatarURL string
}
diff --git a/plugin/idp/oauth2/oauth2.go b/plugin/idp/oauth2/oauth2.go
index f28a9869b..3ce29ce89 100644
--- a/plugin/idp/oauth2/oauth2.go
+++ b/plugin/idp/oauth2/oauth2.go
@@ -113,5 +113,10 @@ func (p *IdentityProvider) UserInfo(token string) (*idp.IdentityProviderUserInfo
userInfo.Email = v
}
}
+ if p.config.FieldMapping.AvatarUrl != "" {
+ if v, ok := claims[p.config.FieldMapping.AvatarUrl].(string); ok {
+ userInfo.AvatarURL = v
+ }
+ }
return userInfo, nil
}
diff --git a/proto/api/v1/idp_service.proto b/proto/api/v1/idp_service.proto
index 826495db3..7c7d47e5b 100644
--- a/proto/api/v1/idp_service.proto
+++ b/proto/api/v1/idp_service.proto
@@ -69,6 +69,7 @@ message FieldMapping {
string identifier = 1;
string display_name = 2;
string email = 3;
+ string avatar_url = 4;
}
message OAuth2Config {
diff --git a/proto/buf.gen.yaml b/proto/buf.gen.yaml
index 14b4cc256..df6063688 100644
--- a/proto/buf.gen.yaml
+++ b/proto/buf.gen.yaml
@@ -1,5 +1,4 @@
version: v2
-clean: true
managed:
enabled: true
disable:
diff --git a/proto/gen/api/v1/idp_service.pb.go b/proto/gen/api/v1/idp_service.pb.go
index e816c0fc5..6a6f94db5 100644
--- a/proto/gen/api/v1/idp_service.pb.go
+++ b/proto/gen/api/v1/idp_service.pb.go
@@ -219,6 +219,7 @@ type FieldMapping struct {
Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"`
DisplayName string `protobuf:"bytes,2,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"`
Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
+ AvatarUrl string `protobuf:"bytes,4,opt,name=avatar_url,json=avatarUrl,proto3" json:"avatar_url,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -274,6 +275,13 @@ func (x *FieldMapping) GetEmail() string {
return ""
}
+func (x *FieldMapping) GetAvatarUrl() string {
+ if x != nil {
+ return x.AvatarUrl
+ }
+ return ""
+}
+
type OAuth2Config struct {
state protoimpl.MessageState `protogen:"open.v1"`
ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
@@ -653,13 +661,15 @@ const file_api_v1_idp_service_proto_rawDesc = "" +
"\x06OAUTH2\x10\x01\"e\n" +
"\x16IdentityProviderConfig\x12A\n" +
"\roauth2_config\x18\x01 \x01(\v2\x1a.memos.api.v1.OAuth2ConfigH\x00R\foauth2ConfigB\b\n" +
- "\x06config\"g\n" +
+ "\x06config\"\x86\x01\n" +
"\fFieldMapping\x12\x1e\n" +
"\n" +
"identifier\x18\x01 \x01(\tR\n" +
"identifier\x12!\n" +
"\fdisplay_name\x18\x02 \x01(\tR\vdisplayName\x12\x14\n" +
- "\x05email\x18\x03 \x01(\tR\x05email\"\x85\x02\n" +
+ "\x05email\x18\x03 \x01(\tR\x05email\x12\x1d\n" +
+ "\n" +
+ "avatar_url\x18\x04 \x01(\tR\tavatarUrl\"\x85\x02\n" +
"\fOAuth2Config\x12\x1b\n" +
"\tclient_id\x18\x01 \x01(\tR\bclientId\x12#\n" +
"\rclient_secret\x18\x02 \x01(\tR\fclientSecret\x12\x19\n" +
diff --git a/proto/gen/apidocs.swagger.yaml b/proto/gen/apidocs.swagger.yaml
index a4942be92..8c0caa938 100644
--- a/proto/gen/apidocs.swagger.yaml
+++ b/proto/gen/apidocs.swagger.yaml
@@ -305,9 +305,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: parent
- description: |-
- The parent is the owner of the memos.
- If not specified or `users/-`, it will list all memos.
+ description: "The parent is the owner of the memos.\r\nIf not specified or `users/-`, it will list all memos."
in: query
required: false
type: string
@@ -318,16 +316,12 @@ paths:
type: integer
format: int32
- name: pageToken
- description: |-
- A page token, received from a previous `ListMemos` call.
- Provide this to retrieve the subsequent page.
+ description: "A page token, received from a previous `ListMemos` call.\r\nProvide this to retrieve the subsequent page."
in: query
required: false
type: string
- name: state
- description: |-
- The state of the memos to list.
- Default to `NORMAL`. Set to `ARCHIVED` to list archived memos.
+ description: "The state of the memos to list.\r\nDefault to `NORMAL`. Set to `ARCHIVED` to list archived memos."
in: query
required: false
type: string
@@ -337,16 +331,12 @@ paths:
- ARCHIVED
default: STATE_UNSPECIFIED
- name: sort
- description: |-
- What field to sort the results by.
- Default to display_time.
+ description: "What field to sort the results by.\r\nDefault to display_time."
in: query
required: false
type: string
- name: direction
- description: |-
- The direction to sort the results by.
- Default to DESC.
+ description: "The direction to sort the results by.\r\nDefault to DESC."
in: query
required: false
type: string
@@ -356,16 +346,12 @@ paths:
- DESC
default: DIRECTION_UNSPECIFIED
- name: filter
- description: |-
- Filter is a CEL expression to filter memos.
- Refer to `Shortcut.filter`.
+ description: "Filter is a CEL expression to filter memos.\r\nRefer to `Shortcut.filter`."
in: query
required: false
type: string
- name: oldFilter
- description: |-
- [Deprecated] Old filter contains some specific conditions to filter memos.
- Format: "creator == 'users/{user}' && visibilities == ['PUBLIC', 'PROTECTED']"
+ description: "[Deprecated] Old filter contains some specific conditions to filter memos.\r\nFormat: \"creator == 'users/{user}' && visibilities == ['PUBLIC', 'PROTECTED']\""
in: query
required: false
type: string
@@ -410,9 +396,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: id
- description: |-
- The id of the reaction.
- Refer to the `Reaction.id`.
+ description: "The id of the reaction.\r\nRefer to the `Reaction.id`."
in: path
required: true
type: integer
@@ -678,9 +662,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: name
- description: |-
- The resource name of the workspace setting.
- Format: settings/{setting}
+ description: "The resource name of the workspace setting.\r\nFormat: settings/{setting}"
in: path
required: true
type: string
@@ -702,9 +684,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: setting.name
- description: |-
- name is the name of the setting.
- Format: settings/{setting}
+ description: "name is the name of the setting.\r\nFormat: settings/{setting}"
in: path
required: true
type: string
@@ -826,17 +806,13 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: memo.name
- description: |-
- The name of the memo.
- Format: memos/{memo}, memo is the user defined id or uuid.
+ description: "The name of the memo.\r\nFormat: memos/{memo}, memo is the user defined id or uuid."
in: path
required: true
type: string
pattern: memos/[^/]+
- name: memo
- description: |-
- The memo to update.
- The `name` field is required.
+ description: "The memo to update.\r\nThe `name` field is required."
in: body
required: true
schema:
@@ -846,9 +822,7 @@ paths:
$ref: '#/definitions/v1State'
creator:
type: string
- title: |-
- The name of the creator.
- Format: users/{user}
+ title: "The name of the creator.\r\nFormat: users/{user}"
createTime:
type: string
format: date-time
@@ -896,9 +870,7 @@ paths:
readOnly: true
parent:
type: string
- title: |-
- The name of the parent memo.
- Format: memos/{id}
+ title: "The name of the parent memo.\r\nFormat: memos/{id}"
readOnly: true
snippet:
type: string
@@ -907,9 +879,7 @@ paths:
location:
$ref: '#/definitions/apiv1Location'
description: The location of the memo.
- title: |-
- The memo to update.
- The `name` field is required.
+ title: "The memo to update.\r\nThe `name` field is required."
required:
- memo
tags:
@@ -1105,9 +1075,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: name
- description: |-
- The name of the activity.
- Format: activities/{id}, id is the system generated auto-incremented id.
+ description: "The name of the activity.\r\nFormat: activities/{id}, id is the system generated auto-incremented id."
in: path
required: true
type: string
@@ -1466,9 +1434,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: parent
- description: |-
- The parent is the owner of the memos.
- If not specified or `users/-`, it will list all memos.
+ description: "The parent is the owner of the memos.\r\nIf not specified or `users/-`, it will list all memos."
in: path
required: true
type: string
@@ -1480,16 +1446,12 @@ paths:
type: integer
format: int32
- name: pageToken
- description: |-
- A page token, received from a previous `ListMemos` call.
- Provide this to retrieve the subsequent page.
+ description: "A page token, received from a previous `ListMemos` call.\r\nProvide this to retrieve the subsequent page."
in: query
required: false
type: string
- name: state
- description: |-
- The state of the memos to list.
- Default to `NORMAL`. Set to `ARCHIVED` to list archived memos.
+ description: "The state of the memos to list.\r\nDefault to `NORMAL`. Set to `ARCHIVED` to list archived memos."
in: query
required: false
type: string
@@ -1499,16 +1461,12 @@ paths:
- ARCHIVED
default: STATE_UNSPECIFIED
- name: sort
- description: |-
- What field to sort the results by.
- Default to display_time.
+ description: "What field to sort the results by.\r\nDefault to display_time."
in: query
required: false
type: string
- name: direction
- description: |-
- The direction to sort the results by.
- Default to DESC.
+ description: "The direction to sort the results by.\r\nDefault to DESC."
in: query
required: false
type: string
@@ -1518,16 +1476,12 @@ paths:
- DESC
default: DIRECTION_UNSPECIFIED
- name: filter
- description: |-
- Filter is a CEL expression to filter memos.
- Refer to `Shortcut.filter`.
+ description: "Filter is a CEL expression to filter memos.\r\nRefer to `Shortcut.filter`."
in: query
required: false
type: string
- name: oldFilter
- description: |-
- [Deprecated] Old filter contains some specific conditions to filter memos.
- Format: "creator == 'users/{user}' && visibilities == ['PUBLIC', 'PROTECTED']"
+ description: "[Deprecated] Old filter contains some specific conditions to filter memos.\r\nFormat: \"creator == 'users/{user}' && visibilities == ['PUBLIC', 'PROTECTED']\""
in: query
required: false
type: string
@@ -1665,9 +1619,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: parent
- description: |-
- The parent, who owns the tags.
- Format: memos/{id}. Use "memos/-" to delete all tags.
+ description: "The parent, who owns the tags.\r\nFormat: memos/{id}. Use \"memos/-\" to delete all tags."
in: path
required: true
type: string
@@ -1698,9 +1650,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: parent
- description: |-
- The parent, who owns the tags.
- Format: memos/{id}. Use "memos/-" to rename all tags.
+ description: "The parent, who owns the tags.\r\nFormat: memos/{id}. Use \"memos/-\" to rename all tags."
in: path
required: true
type: string
@@ -1727,9 +1677,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: resource.name
- description: |-
- The name of the resource.
- Format: resources/{resource}, resource is the user defined if or uuid.
+ description: "The name of the resource.\r\nFormat: resources/{resource}, resource is the user defined if or uuid."
in: path
required: true
type: string
@@ -1815,9 +1763,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: user.name
- description: |-
- The name of the user.
- Format: users/{id}, id is the system generated auto-incremented id.
+ description: "The name of the user.\r\nFormat: users/{id}, id is the system generated auto-incremented id."
in: path
required: true
type: string
@@ -2080,9 +2026,7 @@ definitions:
properties:
memo:
type: string
- description: |-
- The memo name of comment.
- Refer to `Memo.name`.
+ description: "The memo name of comment.\r\nRefer to `Memo.name`."
relatedMemo:
type: string
description: The name of related memo.
@@ -2101,6 +2045,8 @@ definitions:
type: string
email:
type: string
+ avatarUrl:
+ type: string
apiv1IdentityProvider:
type: object
properties:
@@ -2144,17 +2090,13 @@ definitions:
properties:
name:
type: string
- description: |-
- The name of the memo.
- Format: memos/{memo}, memo is the user defined id or uuid.
+ description: "The name of the memo.\r\nFormat: memos/{memo}, memo is the user defined id or uuid."
readOnly: true
state:
$ref: '#/definitions/v1State'
creator:
type: string
- title: |-
- The name of the creator.
- Format: users/{user}
+ title: "The name of the creator.\r\nFormat: users/{user}"
createTime:
type: string
format: date-time
@@ -2202,9 +2144,7 @@ definitions:
readOnly: true
parent:
type: string
- title: |-
- The name of the parent memo.
- Format: memos/{id}
+ title: "The name of the parent memo.\r\nFormat: memos/{id}"
readOnly: true
snippet:
type: string
@@ -2290,10 +2230,7 @@ definitions:
weekStartDayOffset:
type: integer
format: int32
- description: |-
- week_start_day_offset is the week start day offset from Sunday.
- 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday
- Default is Sunday.
+ description: "week_start_day_offset is the week start day offset from Sunday.\r\n0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday\r\nDefault is Sunday."
disallowChangeUsername:
type: boolean
description: disallow_change_username disallows changing username.
@@ -2346,9 +2283,7 @@ definitions:
properties:
name:
type: string
- title: |-
- name is the name of the setting.
- Format: settings/{setting}
+ title: "name is the name of the setting.\r\nFormat: settings/{setting}"
generalSetting:
$ref: '#/definitions/apiv1WorkspaceGeneralSetting'
storageSetting:
@@ -2363,9 +2298,7 @@ definitions:
description: storage_type is the storage type.
filepathTemplate:
type: string
- title: |-
- The template of file path.
- e.g. assets/{timestamp}_{filename}
+ title: "The template of file path.\r\ne.g. assets/{timestamp}_{filename}"
uploadSizeLimitMb:
type: string
format: int64
@@ -2524,15 +2457,11 @@ definitions:
properties:
name:
type: string
- title: |-
- The name of the activity.
- Format: activities/{id}
+ title: "The name of the activity.\r\nFormat: activities/{id}"
readOnly: true
creator:
type: string
- title: |-
- The name of the creator.
- Format: users/{user}
+ title: "The name of the creator.\r\nFormat: users/{user}"
type:
type: string
description: The type of the activity.
@@ -2794,9 +2723,7 @@ definitions:
$ref: '#/definitions/apiv1Memo'
nextPageToken:
type: string
- description: |-
- A token, which can be sent as `page_token` to retrieve the next page.
- If this field is omitted, there are no subsequent pages.
+ description: "A token, which can be sent as `page_token` to retrieve the next page.\r\nIf this field is omitted, there are no subsequent pages."
v1ListNode:
type: object
properties:
@@ -2885,9 +2812,7 @@ definitions:
properties:
name:
type: string
- title: |-
- The name of the memo.
- Format: memos/{id}
+ title: "The name of the memo.\r\nFormat: memos/{id}"
uid:
type: string
snippet:
@@ -3073,9 +2998,7 @@ definitions:
properties:
name:
type: string
- description: |-
- The name of the resource.
- Format: resources/{resource}, resource is the user defined if or uuid.
+ description: "The name of the resource.\r\nFormat: resources/{resource}, resource is the user defined if or uuid."
readOnly: true
createTime:
type: string
@@ -3209,9 +3132,7 @@ definitions:
properties:
name:
type: string
- description: |-
- The name of the user.
- Format: users/{id}, id is the system generated auto-incremented id.
+ description: "The name of the user.\r\nFormat: users/{id}, id is the system generated auto-incremented id."
readOnly: true
role:
$ref: '#/definitions/UserRole'
@@ -3261,9 +3182,7 @@ definitions:
items:
type: string
format: date-time
- description: |-
- The timestamps when the memos were displayed.
- We should return raw data to the client, and let the client format the data with the user's timezone.
+ description: "The timestamps when the memos were displayed.\r\nWe should return raw data to the client, and let the client format the data with the user's timezone."
memoTypeStats:
$ref: '#/definitions/UserStatsMemoTypeStats'
description: The stats of memo types.
@@ -3272,9 +3191,7 @@ definitions:
additionalProperties:
type: integer
format: int32
- title: |-
- The count of tags.
- Format: "tag1": 1, "tag2": 2
+ title: "The count of tags.\r\nFormat: \"tag1\": 1, \"tag2\": 2"
pinnedMemos:
type: array
items:
diff --git a/proto/gen/store/idp.pb.go b/proto/gen/store/idp.pb.go
index 08aa1fd56..28f5e8030 100644
--- a/proto/gen/store/idp.pb.go
+++ b/proto/gen/store/idp.pb.go
@@ -214,6 +214,7 @@ type FieldMapping struct {
Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"`
DisplayName string `protobuf:"bytes,2,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"`
Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
+ AvatarUrl string `protobuf:"bytes,4,opt,name=avatar_url,json=avatarUrl,proto3" json:"avatar_url,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -269,6 +270,13 @@ func (x *FieldMapping) GetEmail() string {
return ""
}
+func (x *FieldMapping) GetAvatarUrl() string {
+ if x != nil {
+ return x.AvatarUrl
+ }
+ return ""
+}
+
type OAuth2Config struct {
state protoimpl.MessageState `protogen:"open.v1"`
ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
@@ -378,13 +386,15 @@ const file_store_idp_proto_rawDesc = "" +
"\x06OAUTH2\x10\x01\"d\n" +
"\x16IdentityProviderConfig\x12@\n" +
"\roauth2_config\x18\x01 \x01(\v2\x19.memos.store.OAuth2ConfigH\x00R\foauth2ConfigB\b\n" +
- "\x06config\"g\n" +
+ "\x06config\"\x86\x01\n" +
"\fFieldMapping\x12\x1e\n" +
"\n" +
"identifier\x18\x01 \x01(\tR\n" +
"identifier\x12!\n" +
"\fdisplay_name\x18\x02 \x01(\tR\vdisplayName\x12\x14\n" +
- "\x05email\x18\x03 \x01(\tR\x05email\"\x84\x02\n" +
+ "\x05email\x18\x03 \x01(\tR\x05email\x12\x1d\n" +
+ "\n" +
+ "avatar_url\x18\x04 \x01(\tR\tavatarUrl\"\x84\x02\n" +
"\fOAuth2Config\x12\x1b\n" +
"\tclient_id\x18\x01 \x01(\tR\bclientId\x12#\n" +
"\rclient_secret\x18\x02 \x01(\tR\fclientSecret\x12\x19\n" +
diff --git a/proto/store/idp.proto b/proto/store/idp.proto
index b0b0ecaf3..990376cda 100644
--- a/proto/store/idp.proto
+++ b/proto/store/idp.proto
@@ -27,6 +27,7 @@ message FieldMapping {
string identifier = 1;
string display_name = 2;
string email = 3;
+ string avatar_url = 4;
}
message OAuth2Config {
diff --git a/server/router/api/v1/auth_service.go b/server/router/api/v1/auth_service.go
index 30d87905c..ed77f092d 100644
--- a/server/router/api/v1/auth_service.go
+++ b/server/router/api/v1/auth_service.go
@@ -129,9 +129,10 @@ func (s *APIV1Service) SignInWithSSO(ctx context.Context, request *v1pb.SignInWi
userCreate := &store.User{
Username: userInfo.Identifier,
// The new signup user should be normal user by default.
- Role: store.RoleUser,
- Nickname: userInfo.DisplayName,
- Email: userInfo.Email,
+ Role: store.RoleUser,
+ Nickname: userInfo.DisplayName,
+ Email: userInfo.Email,
+ AvatarURL: userInfo.AvatarURL,
}
password, err := util.RandomString(20)
if err != nil {
diff --git a/web/src/types/proto/api/v1/idp_service.ts b/web/src/types/proto/api/v1/idp_service.ts
index b24019edb..bb04f1781 100644
--- a/web/src/types/proto/api/v1/idp_service.ts
+++ b/web/src/types/proto/api/v1/idp_service.ts
@@ -64,6 +64,7 @@ export interface FieldMapping {
identifier: string;
displayName: string;
email: string;
+ avatarUrl: string;
}
export interface OAuth2Config {
@@ -255,7 +256,7 @@ export const IdentityProviderConfig: MessageFns<IdentityProviderConfig> = {
};
function createBaseFieldMapping(): FieldMapping {
- return { identifier: "", displayName: "", email: "" };
+ return { identifier: "", displayName: "", email: "", avatarUrl: "" };
}
export const FieldMapping: MessageFns<FieldMapping> = {
@@ -269,6 +270,9 @@ export const FieldMapping: MessageFns<FieldMapping> = {
if (message.email !== "") {
writer.uint32(26).string(message.email);
}
+ if (message.avatarUrl !== "") {
+ writer.uint32(34).string(message.avatarUrl);
+ }
return writer;
},
@@ -303,6 +307,14 @@ export const FieldMapping: MessageFns<FieldMapping> = {
message.email = reader.string();
continue;
}
+ case 4: {
+ if (tag !== 34) {
+ break;
+ }
+
+ message.avatarUrl = reader.string();
+ continue;
+ }
}
if ((tag & 7) === 4 || tag === 0) {
break;
@@ -320,6 +332,7 @@ export const FieldMapping: MessageFns<FieldMapping> = {
message.identifier = object.identifier ?? "";
message.displayName = object.displayName ?? "";
message.email = object.email ?? "";
+ message.avatarUrl = object.avatarUrl ?? "";
return message;
},
};
diff --git a/web/src/types/proto/google/protobuf/descriptor.ts b/web/src/types/proto/google/protobuf/descriptor.ts
index 89514564e..9f55f0344 100644
--- a/web/src/types/proto/google/protobuf/descriptor.ts
+++ b/web/src/types/proto/google/protobuf/descriptor.ts
@@ -35,7 +35,7 @@ export enum Edition {
EDITION_2024 = "EDITION_2024",
/**
* EDITION_1_TEST_ONLY - Placeholder editions for testing feature resolution. These should not be
- * used or relied on outside of tests.
+ * used or relyed on outside of tests.
*/
EDITION_1_TEST_ONLY = "EDITION_1_TEST_ONLY",
EDITION_2_TEST_ONLY = "EDITION_2_TEST_ONLY",
@@ -177,19 +177,11 @@ export interface FileDescriptorProto {
* The supported values are "proto2", "proto3", and "editions".
*
* If `edition` is present, this value must be "editions".
- * WARNING: This field should only be used by protobuf plugins or special
- * cases like the proto compiler. Other uses are discouraged and
- * developers should rely on the protoreflect APIs for their client language.
*/
syntax?:
| string
| undefined;
- /**
- * The edition of the proto file.
- * WARNING: This field should only be used by protobuf plugins or special
- * cases like the proto compiler. Other uses are discouraged and
- * developers should rely on the protoreflect APIs for their client language.
- */
+ /** The edition of the proto file. */
edition?: Edition | undefined;
}
@@ -836,12 +828,7 @@ export interface FileOptions {
rubyPackage?:
| string
| undefined;
- /**
- * Any features defined in the specific edition.
- * WARNING: This field should only be used by protobuf plugins or special
- * cases like the proto compiler. Other uses are discouraged and
- * developers should rely on the protoreflect APIs for their client language.
- */
+ /** Any features defined in the specific edition. */
features?:
| FeatureSet
| undefined;
@@ -979,12 +966,7 @@ export interface MessageOptions {
deprecatedLegacyJsonFieldConflicts?:
| boolean
| undefined;
- /**
- * Any features defined in the specific edition.
- * WARNING: This field should only be used by protobuf plugins or special
- * cases like the proto compiler. Other uses are discouraged and
- * developers should rely on the protoreflect APIs for their client language.
- */
+ /** Any features defined in the specific edition. */
features?:
| FeatureSet
| undefined;
@@ -994,13 +976,12 @@ export interface MessageOptions {
export interface FieldOptions {
/**
- * NOTE: ctype is deprecated. Use `features.(pb.cpp).string_type` instead.
* The ctype option instructs the C++ code generator to use a different
* representation of the field than it normally would. See the specific
* options below. This option is only implemented to support use of
* [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of
- * type "bytes" in the open source release.
- * TODO: make ctype actually deprecated.
+ * type "bytes" in the open source release -- sorry, we'll try to include
+ * other types in a future version!
*/
ctype?:
| FieldOptions_CType
@@ -1089,12 +1070,7 @@ export interface FieldOptions {
retention?: FieldOptions_OptionRetention | undefined;
targets: FieldOptions_OptionTargetType[];
editionDefaults: FieldOptions_EditionDefault[];
- /**
- * Any features defined in the specific edition.
- * WARNING: This field should only be used by protobuf plugins or special
- * cases like the proto compiler. Other uses are discouraged and
- * developers should rely on the protoreflect APIs for their client language.
- */
+ /** Any features defined in the specific edition. */
features?: FeatureSet | undefined;
featureSupport?:
| FieldOptions_FeatureSupport
@@ -1193,7 +1169,11 @@ export function fieldOptions_JSTypeToNumber(object: FieldOptions_JSType): number
}
}
-/** If set to RETENTION_SOURCE, the option will be omitted from the binary. */
+/**
+ * If set to RETENTION_SOURCE, the option will be omitted from the binary.
+ * Note: as of January 2023, support for this is in progress and does not yet
+ * have an effect (b/264593489).
+ */
export enum FieldOptions_OptionRetention {
RETENTION_UNKNOWN = "RETENTION_UNKNOWN",
RETENTION_RUNTIME = "RETENTION_RUNTIME",
@@ -1236,7 +1216,8 @@ export function fieldOptions_OptionRetentionToNumber(object: FieldOptions_Option
/**
* This indicates the types of entities that the field may apply to when used
* as an option. If it is unset, then the field may be freely used as an
- * option on any kind of entity.
+ * option on any kind of entity. Note: as of January 2023, support for this is
+ * in progress and does not yet have an effect (b/264593489).
*/
export enum FieldOptions_OptionTargetType {
TARGET_TYPE_UNKNOWN = "TARGET_TYPE_UNKNOWN",
@@ -1360,12 +1341,7 @@ export interface FieldOptions_FeatureSupport {
}
export interface OneofOptions {
- /**
- * Any features defined in the specific edition.
- * WARNING: This field should only be used by protobuf plugins or special
- * cases like the proto compiler. Other uses are discouraged and
- * developers should rely on the protoreflect APIs for their client language.
- */
+ /** Any features defined in the specific edition. */
features?:
| FeatureSet
| undefined;
@@ -1403,12 +1379,7 @@ export interface EnumOptions {
deprecatedLegacyJsonFieldConflicts?:
| boolean
| undefined;
- /**
- * Any features defined in the specific edition.
- * WARNING: This field should only be used by protobuf plugins or special
- * cases like the proto compiler. Other uses are discouraged and
- * developers should rely on the protoreflect APIs for their client language.
- */
+ /** Any features defined in the specific edition. */
features?:
| FeatureSet
| undefined;
@@ -1426,12 +1397,7 @@ export interface EnumValueOptions {
deprecated?:
| boolean
| undefined;
- /**
- * Any features defined in the specific edition.
- * WARNING: This field should only be used by protobuf plugins or special
- * cases like the proto compiler. Other uses are discouraged and
- * developers should rely on the protoreflect APIs for their client language.
- */
+ /** Any features defined in the specific edition. */
features?:
| FeatureSet
| undefined;
@@ -1452,12 +1418,7 @@ export interface EnumValueOptions {
}
export interface ServiceOptions {
- /**
- * Any features defined in the specific edition.
- * WARNING: This field should only be used by protobuf plugins or special
- * cases like the proto compiler. Other uses are discouraged and
- * developers should rely on the protoreflect APIs for their client language.
- */
+ /** Any features defined in the specific edition. */
features?:
| FeatureSet
| undefined;
@@ -1485,12 +1446,7 @@ export interface MethodOptions {
idempotencyLevel?:
| MethodOptions_IdempotencyLevel
| undefined;
- /**
- * Any features defined in the specific edition.
- * WARNING: This field should only be used by protobuf plugins or special
- * cases like the proto compiler. Other uses are discouraged and
- * developers should rely on the protoreflect APIs for their client language.
- */
+ /** Any features defined in the specific edition. */
features?:
| FeatureSet
| undefined;
@@ -1593,7 +1549,6 @@ export interface FeatureSet {
utf8Validation?: FeatureSet_Utf8Validation | undefined;
messageEncoding?: FeatureSet_MessageEncoding | undefined;
jsonFormat?: FeatureSet_JsonFormat | undefined;
- enforceNamingStyle?: FeatureSet_EnforceNamingStyle | undefined;
}
export enum FeatureSet_FieldPresence {
@@ -1836,45 +1791,6 @@ export function featureSet_JsonFormatToNumber(object: FeatureSet_JsonFormat): nu
}
}
-export enum FeatureSet_EnforceNamingStyle {
- ENFORCE_NAMING_STYLE_UNKNOWN = "ENFORCE_NAMING_STYLE_UNKNOWN",
- STYLE2024 = "STYLE2024",
- STYLE_LEGACY = "STYLE_LEGACY",
- UNRECOGNIZED = "UNRECOGNIZED",
-}
-
-export function featureSet_EnforceNamingStyleFromJSON(object: any): FeatureSet_EnforceNamingStyle {
- switch (object) {
- case 0:
- case "ENFORCE_NAMING_STYLE_UNKNOWN":
- return FeatureSet_EnforceNamingStyle.ENFORCE_NAMING_STYLE_UNKNOWN;
- case 1:
- case "STYLE2024":
- return FeatureSet_EnforceNamingStyle.STYLE2024;
- case 2:
- case "STYLE_LEGACY":
- return FeatureSet_EnforceNamingStyle.STYLE_LEGACY;
- case -1:
- case "UNRECOGNIZED":
- default:
- return FeatureSet_EnforceNamingStyle.UNRECOGNIZED;
- }
-}
-
-export function featureSet_EnforceNamingStyleToNumber(object: FeatureSet_EnforceNamingStyle): number {
- switch (object) {
- case FeatureSet_EnforceNamingStyle.ENFORCE_NAMING_STYLE_UNKNOWN:
- return 0;
- case FeatureSet_EnforceNamingStyle.STYLE2024:
- return 1;
- case FeatureSet_EnforceNamingStyle.STYLE_LEGACY:
- return 2;
- case FeatureSet_EnforceNamingStyle.UNRECOGNIZED:
- default:
- return -1;
- }
-}
-
/**
* A compiled specification for the defaults of a set of features. These
* messages are generated from FeatureSet extensions and can be used to seed
@@ -4998,7 +4914,6 @@ function createBaseFeatureSet(): FeatureSet {
utf8Validation: FeatureSet_Utf8Validation.UTF8_VALIDATION_UNKNOWN,
messageEncoding: FeatureSet_MessageEncoding.MESSAGE_ENCODING_UNKNOWN,
jsonFormat: FeatureSet_JsonFormat.JSON_FORMAT_UNKNOWN,
- enforceNamingStyle: FeatureSet_EnforceNamingStyle.ENFORCE_NAMING_STYLE_UNKNOWN,
};
}
@@ -5033,12 +4948,6 @@ export const FeatureSet: MessageFns<FeatureSet> = {
if (message.jsonFormat !== undefined && message.jsonFormat !== FeatureSet_JsonFormat.JSON_FORMAT_UNKNOWN) {
writer.uint32(48).int32(featureSet_JsonFormatToNumber(message.jsonFormat));
}
- if (
- message.enforceNamingStyle !== undefined &&
- message.enforceNamingStyle !== FeatureSet_EnforceNamingStyle.ENFORCE_NAMING_STYLE_UNKNOWN
- ) {
- writer.uint32(56).int32(featureSet_EnforceNamingStyleToNumber(message.enforceNamingStyle));
- }
return writer;
},
@@ -5097,14 +5006,6 @@ export const FeatureSet: MessageFns<FeatureSet> = {
message.jsonFormat = featureSet_JsonFormatFromJSON(reader.int32());
continue;
}
- case 7: {
- if (tag !== 56) {
- break;
- }
-
- message.enforceNamingStyle = featureSet_EnforceNamingStyleFromJSON(reader.int32());
- continue;
- }
}
if ((tag & 7) === 4 || tag === 0) {
break;
@@ -5126,8 +5027,6 @@ export const FeatureSet: MessageFns<FeatureSet> = {
message.utf8Validation = object.utf8Validation ?? FeatureSet_Utf8Validation.UTF8_VALIDATION_UNKNOWN;
message.messageEncoding = object.messageEncoding ?? FeatureSet_MessageEncoding.MESSAGE_ENCODING_UNKNOWN;
message.jsonFormat = object.jsonFormat ?? FeatureSet_JsonFormat.JSON_FORMAT_UNKNOWN;
- message.enforceNamingStyle = object.enforceNamingStyle ??
- FeatureSet_EnforceNamingStyle.ENFORCE_NAMING_STYLE_UNKNOWN;
return message;
},
};