Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: rename role -> membership #172

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions proto/role/v1.proto → proto/membership/v1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import "google/protobuf/timestamp.proto";
import "common/v1.proto";
import "options.proto";

message Role_1 {
message Membership_1 {
// **DO NOT CHANGE dataTypeId** generated with `openssl rand -hex 6`
option (dataTypeId) = "69acce0ea09b";
option (schemaName) = "role";
option (schemaName) = "membership";

Common_1 common = 1;

Expand Down
8 changes: 4 additions & 4 deletions schema/role/v1.json → schema/membership/v1.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://mapeo.world/schemas/role/v1.json",
"title": "Role",
"$id": "http://mapeo.world/schemas/membership/v1.json",
"title": "Membership",
"type": "object",
"properties": {
"schemaName": {
"type": "string",
"const": "role"
"const": "membership"
},
"roleId": {
"type": "string",
Expand All @@ -15,7 +15,7 @@
"fromIndex": {
"type": "integer",
"minimum": 0,
"description": "This is the index of the auth core that this role applies to (identified by the `docId`) to apply this role from. E.g. documents in the auth core assigned this role from this index will be evaluated according to this role."
"description": "This is the index of the auth core that this membership applies to (identified by the `docId`) to apply the role from. E.g. documents in the auth core assigned this membership from this index will be evaluated according to the assigned roleId."
}
},
"required": ["schemaName", "roleId", "fromIndex"],
Expand Down
6 changes: 3 additions & 3 deletions src/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
convertField,
convertObservation,
convertPreset,
convertRole,
convertMembership,
convertDeviceInfo,
convertCoreOwnership,
convertIcon,
Expand Down Expand Up @@ -64,8 +64,8 @@ export function decode(
return convertField(message, versionObj)
case 'preset':
return convertPreset(message, versionObj)
case 'role':
return convertRole(message, versionObj)
case 'membership':
return convertMembership(message, versionObj)
case 'deviceInfo':
return convertDeviceInfo(message, versionObj)
case 'coreOwnership':
Expand Down
6 changes: 3 additions & 3 deletions src/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
convertObservation,
convertPreset,
convertProjectSettings,
convertRole,
convertMembership,
convertDeviceInfo,
convertCoreOwnership,
convertIcon,
Expand Down Expand Up @@ -60,8 +60,8 @@ export function encode(
protobuf = Encode[mapeoDoc.schemaName](message).finish()
break
}
case 'role': {
const message = convertRole(mapeoDoc)
case 'membership': {
const message = convertMembership(mapeoDoc)
protobuf = Encode[mapeoDoc.schemaName](message).finish()
break
}
Expand Down
5 changes: 4 additions & 1 deletion src/lib/decode-conversions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ export const convertPreset: ConvertFunction<'preset'> = (
}
}

export const convertRole: ConvertFunction<'role'> = (message, versionObj) => {
export const convertMembership: ConvertFunction<'membership'> = (
message,
versionObj
) => {
if (message.roleId.length === 0) {
throw new Error('Invalid roleId')
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/encode-conversions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const convertObservation: ConvertFunction<'observation'> = (
}
}

export const convertRole: ConvertFunction<'role'> = (mapeoDoc) => {
export const convertMembership: ConvertFunction<'membership'> = (mapeoDoc) => {
const roleId = Buffer.from(mapeoDoc.roleId, 'hex')
if (roleId.length === 0) {
throw new Error('Invalid roleId')
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type SupportedSchemaNames =
| 'observation'
| 'field'
| 'preset'
| 'role'
| 'membership'
| 'icon'
| 'deviceInfo'
| 'coreOwnership'
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/bad-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ export const badDocs = [
},
},
{
text: 'role doc with empty roleId',
/** @type {import('../../dist/index.js').Role} */
text: 'membership doc with empty roleId',
/** @type {import('../../dist/index.js').Membership} */
doc: {
docId: cachedValues.docId,
versionId: cachedValues.versionId,
schemaName: 'role',
schemaName: 'membership',
createdAt: cachedValues.createdAt,
updatedAt: cachedValues.updatedAt,
createdBy: cachedValues.createdBy,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/good-docs-completed.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const goodDocsCompleted = [
doc: {
docId: cachedValues.docId,
versionId: cachedValues.versionId,
schemaName: 'role',
schemaName: 'membership',
createdAt: cachedValues.createdAt,
updatedAt: cachedValues.updatedAt,
createdBy: cachedValues.createdBy,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/good-docs-minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const goodDocsMinimal = [
doc: {
docId: cachedValues.docId,
versionId: cachedValues.versionId,
schemaName: 'role',
schemaName: 'membership',
createdAt: cachedValues.createdAt,
updatedAt: cachedValues.updatedAt,
createdBy: cachedValues.createdBy,
Expand Down
Loading