Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

WNS migration #394

Merged
merged 4 commits into from
Jan 19, 2021
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,5 @@ public/
# Protocol buffer generated source files
**/proto/gen/

.yalc
yalc.lock
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Consistent error logging.
- Pipeline logging/metrics.
- Consistent async functions (latch, trigger, etc.)
- WRN model/item formats.
- DXN model/item formats.
- Rewrite FeedStore (remove hypertrie, path, etc.)

NOTE: Issue with each module generating overlapping protobuf TS definitions.
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at contact@dxos.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at admin@dxos.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

Expand Down
16 changes: 8 additions & 8 deletions packages/echo-db/src/echo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('api tests', () => {
});

// TODO(burdon): Check item mutations.
const result = await party.database.queryItems({ type: 'wrn://dxos/item/document' });
const result = await party.database.queryItems({ type: 'dxn://dxos.org/item/document' });
expect(result.value).toHaveLength(2);
onUpdate();
});
Expand All @@ -69,9 +69,9 @@ describe('api tests', () => {
expect(members[0].displayName).toEqual(members[0].publicKey.humanize());

// TODO(burdon): Test item mutations.
await party.database.createItem({ model: ObjectModel, type: 'wrn://dxos/item/document' });
await party.database.createItem({ model: ObjectModel, type: 'wrn://dxos/item/document' });
await party.database.createItem({ model: ObjectModel, type: 'wrn://dxos/item/kanban' });
await party.database.createItem({ model: ObjectModel, type: 'dxn://dxos.org/item/document' });
await party.database.createItem({ model: ObjectModel, type: 'dxn://dxos.org/item/document' });
await party.database.createItem({ model: ObjectModel, type: 'dxn://dxos.org/item/kanban' });

await updated;
unsubscribe();
Expand All @@ -95,7 +95,7 @@ describe('api tests', () => {
log('Item:', String(item));
});

const { first: item } = await party.database.queryItems({ type: 'wrn://dxos/item/document' });
const { first: item } = await party.database.queryItems({ type: 'dxn://dxos.org/item/document' });
expect(item.children).toHaveLength(1);
expect(item.children[0].type).toBe(undefined);
// TODO(burdon): Test parent.
Expand All @@ -111,7 +111,7 @@ describe('api tests', () => {
// Within this test, we use the humanized key as the name.
expect(members[0].displayName).toEqual(members[0].publicKey.humanize());

const parent = await party.database.createItem({ model: ObjectModel, type: 'wrn://dxos/item/document' });
const parent = await party.database.createItem({ model: ObjectModel, type: 'dxn://dxos.org/item/document' });
await party.database.createItem({ model: ObjectModel, parent: parent.id });

await updated;
Expand All @@ -133,12 +133,12 @@ describe('api tests', () => {
// Within this test, we use the humanized key as the name.
expect(members[0].displayName).toEqual(members[0].publicKey.humanize());

const parentA = await party.database.createItem({ model: ObjectModel, type: 'wrn://dxos/item/document' });
const parentA = await party.database.createItem({ model: ObjectModel, type: 'dxn://dxos.org/item/document' });
const childA = await party.database.createItem({ model: ObjectModel, parent: parentA.id });
expect(parentA.children).toHaveLength(1);
expect(parentA.children[0].id).toEqual(childA.id);

const parentB = await party.database.createItem({ model: ObjectModel, type: 'wrn://dxos/item/document' });
const parentB = await party.database.createItem({ model: ObjectModel, type: 'dxn://dxos.org/item/document' });
const childB = await party.database.createItem({ model: ObjectModel, parent: parentB.id });
expect(parentB.children).toHaveLength(1);
expect(parentB.children[0].id).toEqual(childB.id);
Expand Down
2 changes: 1 addition & 1 deletion packages/echo-db/src/items/default-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const noopCodec: Codec<Uint8Array> = {
// TODO(burdon): Optional. Set as null and ignore messages for items that have unregistered models?
export class DefaultModel extends Model<Uint8Array> {
static meta: ModelMeta = {
type: 'wrn://dxos/model/default',
type: 'dxn://dxos.org/model/default',
mutation: noopCodec
};

Expand Down
2 changes: 1 addition & 1 deletion packages/echo-db/src/items/item-demuxer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test('set-up', async () => {
const message: EchoEnvelope = {
itemId,
genesis: {
itemType: 'wrn://dxos/item/test',
itemType: 'dxn://dxos.org/item/test',
modelType: TestModel.meta.type
}
};
Expand Down
2 changes: 1 addition & 1 deletion packages/echo-db/src/items/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class Item<M extends Model<any>> {
/**
* Items are constructed by the `Database` object.
* @param {ItemID} _itemId - Addressable ID.
* @param {ItemType} _itemType - User defined type (WRN).
* @param {ItemType} _itemType - User defined type (DXN).
* @param {Model} _modelMeta - Data model metadata.
* @param {Model} _model - Data model (provided by `ModelFactory`).
* @param [_writeStream] - Write stream (if not read-only).
Expand Down
6 changes: 3 additions & 3 deletions packages/echo-db/src/items/link.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { ObjectModel } from '@dxos/object-model';

import { createTestInstance } from '../testing/test-utils';

const OBJECT_ORG = 'wrn://dxos/object/org';
const OBJECT_PERSON = 'wrn://dxos/object/person';
const LINK_EMPLOYEE = 'wrn://dxos/link/employee';
const OBJECT_ORG = 'dxn://dxos.org/object/org';
const OBJECT_PERSON = 'dxn://dxos.org/object/person';
const LINK_EMPLOYEE = 'dxn://dxos.org/link/employee';

test('directed links', async () => {
const echo = await createTestInstance({ initialize: true });
Expand Down
8 changes: 4 additions & 4 deletions packages/echo-db/src/items/selection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { Item } from './item';
import { Link } from './link';
import { Selection } from './selection';

const OBJECT_ORG = 'wrn://dxos/object/org';
const OBJECT_PERSON = 'wrn://dxos/object/person';
const LINK_EMPLOYEE = 'wrn://dxos/link/employee';
const OBJECT_ORG = 'dxn://dxos.org/object/org';
const OBJECT_PERSON = 'dxn://dxos.org/object/person';
const LINK_EMPLOYEE = 'dxn://dxos.org/link/employee';

const createItem = (id: ItemID, type: ItemType) =>
new Item(id, type, ObjectModel.meta, new ObjectModel(ObjectModel.meta, id));
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('Selection', () => {

test('filter', () => {
expect(new Selection(items, new Event())
.filter({ type: 'wrn://dxos/type/invalid' }).items).toHaveLength(0);
.filter({ type: 'dxn://dxos.org/type/invalid' }).items).toHaveLength(0);

expect(new Selection(items, new Event())
.filter({ type: OBJECT_PERSON }).items).toHaveLength(3);
Expand Down
8 changes: 4 additions & 4 deletions packages/echo-db/src/parties/halo-party.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import { Item } from '../items';
import { ResultSet } from '../result';
import { PARTY_TITLE_PROPERTY, PartyActivator, PartyInternal } from './party-internal';

export const HALO_PARTY_DESCRIPTOR_TYPE = 'wrn://dxos/item/halo/party-descriptor';
export const HALO_CONTACT_LIST_TYPE = 'wrn://dxos/item/halo/contact-list';
export const HALO_GENERAL_PREFERENCES_TYPE = 'wrn://dxos/item/halo/preferences';
export const HALO_DEVICE_PREFERENCES_TYPE = 'wrn://dxos/item/halo/device/preferences';
export const HALO_PARTY_DESCRIPTOR_TYPE = 'dxn://dxos.org/item/halo/party-descriptor';
export const HALO_CONTACT_LIST_TYPE = 'dxn://dxos.org/item/halo/contact-list';
export const HALO_GENERAL_PREFERENCES_TYPE = 'dxn://dxos.org/item/halo/preferences';
export const HALO_DEVICE_PREFERENCES_TYPE = 'dxn://dxos.org/item/halo/device/preferences';

/**
* A record in HALO party representing a party that user is currently a member of.
Expand Down
2 changes: 1 addition & 1 deletion packages/echo-db/src/parties/party-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Pipeline } from './pipeline';

// TODO(burdon): Format?
const DEFAULT_SNAPSHOT_INTERVAL = 100; // every 100 messages
export const PARTY_ITEM_TYPE = 'wrn://dxos/item/party';
export const PARTY_ITEM_TYPE = 'dxn://dxos.org/item/party';
export const PARTY_TITLE_PROPERTY = 'title';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
Expand Down
44 changes: 22 additions & 22 deletions packages/echo-db/src/parties/party-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ describe('Party manager', () => {
const [updated, onUpdate] = latch();

// Subscribe to Item updates on B.
partyB.database.queryItems({ type: 'wrn://dxos/item/test' })
partyB.database.queryItems({ type: 'dxn://dxos.org/item/test' })
.subscribe((result) => {
if (result.length) {
const [itemB] = result;
Expand All @@ -257,7 +257,7 @@ describe('Party manager', () => {
});

// Create a new Item on A.
itemA = await partyA.database.createItem({ model: ObjectModel, type: 'wrn://dxos/item/test' });
itemA = await partyA.database.createItem({ model: ObjectModel, type: 'dxn://dxos.org/item/test' });
log(`A created ${itemA.id}`);

// Now wait to see it on B.
Expand Down Expand Up @@ -327,7 +327,7 @@ describe('Party manager', () => {
const [updated, onUpdate] = latch();

// Subscribe to Item updates on B.
partyB.database.queryItems({ type: 'wrn://dxos/item/test' })
partyB.database.queryItems({ type: 'dxn://dxos.org/item/test' })
.subscribe((result) => {
if (result.length) {
const [itemB] = result;
Expand All @@ -339,7 +339,7 @@ describe('Party manager', () => {
});

// Create a new Item on A.
itemA = await partyA.database.createItem({ model: ObjectModel, type: 'wrn://dxos/item/test' }) as Item<any>;
itemA = await partyA.database.createItem({ model: ObjectModel, type: 'dxn://dxos.org/item/test' }) as Item<any>;
log(`A created ${itemA.id}`);

// Now wait to see it on B.
Expand Down Expand Up @@ -400,7 +400,7 @@ describe('Party manager', () => {
const [updated, onUpdate] = latch();

// Subscribe to Item updates on B.
identityManagerB.halo?.database.queryItems({ type: 'wrn://dxos/item/test' })
identityManagerB.halo?.database.queryItems({ type: 'dxn://dxos.org/item/test' })
.subscribe((result) => {
if (result.length) {
if (itemA && result.find(item => item.id === itemA?.id)) {
Expand All @@ -412,7 +412,7 @@ describe('Party manager', () => {

// Create a new Item on A.
itemA = await identityManagerA.halo?.database
.createItem({ model: ObjectModel, type: 'wrn://dxos/item/test' }) as Item<any>;
.createItem({ model: ObjectModel, type: 'dxn://dxos.org/item/test' }) as Item<any>;
log(`A created ${itemA.id}`);

// Now wait to see it on B.
Expand All @@ -437,7 +437,7 @@ describe('Party manager', () => {
const [updated, onUpdate] = latch();

// Subscribe to Item updates on A.
partyManagerA.parties[0].database.queryItems({ type: 'wrn://dxos/item/test' })
partyManagerA.parties[0].database.queryItems({ type: 'dxn://dxos.org/item/test' })
.subscribe((result) => {
if (result.length) {
const [itemB] = result;
Expand All @@ -450,7 +450,7 @@ describe('Party manager', () => {

// Create a new Item on B.
itemA = await partyManagerB.parties[0].database
.createItem({ model: ObjectModel, type: 'wrn://dxos/item/test' }) as Item<any>;
.createItem({ model: ObjectModel, type: 'dxn://dxos.org/item/test' }) as Item<any>;

// Now wait to see it on A.
await updated;
Expand Down Expand Up @@ -536,7 +536,7 @@ describe('Party manager', () => {
// Empty across the board.
for (const partyManager of [partyManagerA1, partyManagerA2, partyManagerB1, partyManagerB2]) {
const [party] = partyManager.parties;
expect(party.database.queryItems({ type: 'wrn://dxos/item/test' }).value.length).toBe(0);
expect(party.database.queryItems({ type: 'dxn://dxos.org/item/test' }).value.length).toBe(0);
}

for await (const partyManager of [partyManagerA1, partyManagerA2, partyManagerB1, partyManagerB2]) {
Expand All @@ -548,7 +548,7 @@ describe('Party manager', () => {
if (partyManager !== otherManager) {
const [otherParty] = otherManager.parties;
const [updated, onUpdate] = latch();
otherParty.database.queryItems({ type: 'wrn://dxos/item/test' })
otherParty.database.queryItems({ type: 'dxn://dxos.org/item/test' })
.subscribe((result) => {
if (result.find(current => current.id === item?.id)) {
log(`other has ${item?.id}`);
Expand All @@ -559,7 +559,7 @@ describe('Party manager', () => {
}
}

item = await party.database.createItem({ model: ObjectModel, type: 'wrn://dxos/item/test' }) as Item<any>;
item = await party.database.createItem({ model: ObjectModel, type: 'dxn://dxos.org/item/test' }) as Item<any>;
await Promise.all(itemPromises);
}
});
Expand All @@ -582,7 +582,7 @@ describe('Party manager', () => {
const [updated, onUpdate] = latch();

// Subscribe to Item updates on B.
identityManagerB.halo?.database.queryItems({ type: 'wrn://dxos/item/test' })
identityManagerB.halo?.database.queryItems({ type: 'dxn://dxos.org/item/test' })
.subscribe((result) => {
if (result.length) {
const [itemB] = result;
Expand All @@ -595,7 +595,7 @@ describe('Party manager', () => {

// Create a new Item on A.
itemA = await identityManagerA.halo?.database
.createItem({ model: ObjectModel, type: 'wrn://dxos/item/test' }) as Item<any>;
.createItem({ model: ObjectModel, type: 'dxn://dxos.org/item/test' }) as Item<any>;
log(`A created ${itemA.id}`);

// Now wait to see it on B.
Expand All @@ -622,7 +622,7 @@ describe('Party manager', () => {
const [updated, onUpdate] = latch();

// Subscribe to Item updates on A.
partyManagerA.parties[0].database.queryItems({ type: 'wrn://dxos/item/test' })
partyManagerA.parties[0].database.queryItems({ type: 'dxn://dxos.org/item/test' })
.subscribe((result) => {
if (result.length) {
const [itemB] = result;
Expand All @@ -635,7 +635,7 @@ describe('Party manager', () => {

// Create a new Item on B.
itemA = await partyManagerB.parties[0].database
.createItem({ model: ObjectModel, type: 'wrn://dxos/item/test' }) as Item<any>;
.createItem({ model: ObjectModel, type: 'dxn://dxos.org/item/test' }) as Item<any>;

// Now wait to see it on A.
await updated;
Expand Down Expand Up @@ -671,7 +671,7 @@ describe('Party manager', () => {
const [updated, onUpdate] = latch();

// Subscribe to Item updates on B.
partyB.database.queryItems({ type: 'wrn://dxos/item/test' })
partyB.database.queryItems({ type: 'dxn://dxos.org/item/test' })
.subscribe((result) => {
if (result.length) {
const [itemB] = result;
Expand All @@ -683,7 +683,7 @@ describe('Party manager', () => {
});

// Create a new Item on A.
itemA = await partyA.database.createItem({ model: ObjectModel, type: 'wrn://dxos/item/test' }) as Item<any>;
itemA = await partyA.database.createItem({ model: ObjectModel, type: 'dxn://dxos.org/item/test' }) as Item<any>;
log(`A created ${itemA.id}`);

// Now wait to see it on B.
Expand Down Expand Up @@ -799,7 +799,7 @@ describe('Party manager', () => {
let itemA: Item<any> | null = null;
const [updated, onUpdate] = latch();

partyA.database.queryItems({ type: 'wrn://dxos/item/test' })
partyA.database.queryItems({ type: 'dxn://dxos.org/item/test' })
.subscribe((result) => {
if (result.length) {
const [receivedItem] = result;
Expand All @@ -809,19 +809,19 @@ describe('Party manager', () => {
}
});

itemA = await partyA.database.createItem({ model: ObjectModel, type: 'wrn://dxos/item/test' }) as Item<any>;
itemA = await partyA.database.createItem({ model: ObjectModel, type: 'dxn://dxos.org/item/test' }) as Item<any>;
await updated; // wait to see the update

expect((await partyA.database.queryItems({ type: 'wrn://dxos/item/test' })).value.length).toEqual(1);
expect((await partyA.database.queryItems({ type: 'dxn://dxos.org/item/test' })).value.length).toEqual(1);

await partyA.deactivate({ global: true });
await partyA.activate({ global: true });

expect(partyA.isOpen).toBe(true);
expect(partyA.isActive()).toBe(true);

await waitForCondition(() => partyA.database.queryItems({ type: 'wrn://dxos/item/test' }).value.length > 0, 5000);
expect((await partyA.database.queryItems({ type: 'wrn://dxos/item/test' })).value.length).toEqual(1);
await waitForCondition(() => partyA.database.queryItems({ type: 'dxn://dxos.org/item/test' }).value.length > 0, 5000);
expect((await partyA.database.queryItems({ type: 'dxn://dxos.org/item/test' })).value.length).toEqual(1);
}, 10000);

test('Deactivate Party - multi device', async () => {
Expand Down
14 changes: 7 additions & 7 deletions packages/echo-demo/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Copyright 2020 DXOS.org
//

export const OBJECT_ORG = 'wrn://dxos/object/org';
export const OBJECT_PERSON = 'wrn://dxos/object/person';
export const OBJECT_PROJECT = 'wrn://dxos/object/project';
export const OBJECT_TASK = 'wrn://dxos/object/task';
export const OBJECT_ORG = 'dxn://dxos.org/object/org';
export const OBJECT_PERSON = 'dxn://dxos.org/object/person';
export const OBJECT_PROJECT = 'dxn://dxos.org/object/project';
export const OBJECT_TASK = 'dxn://dxos.org/object/task';

export const LINK_EMPLOYEE = 'wrn://dxos/link/employee';
export const LINK_PROJECT = 'wrn://dxos/link/project';
export const LINK_ASSIGNED = 'wrn://dxos/link/assigned';
export const LINK_EMPLOYEE = 'dxn://dxos.org/link/employee';
export const LINK_PROJECT = 'dxn://dxos.org/link/project';
export const LINK_ASSIGNED = 'dxn://dxos.org/link/assigned';

// TODO(burdon): Query objects-only (i.e., not root party item).
export const itemSelector = selection => {
Expand Down
2 changes: 1 addition & 1 deletion packages/echo-protocol/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export type ItemType = string;
// Party
//

// TODO(burdon): How does this map into IPLD? (https://ipld.io) and WRN?
// TODO(burdon): How does this map into IPLD? (https://ipld.io) and DXN?
export type PartyKey = PublicKey;

//
Expand Down
2 changes: 1 addition & 1 deletion packages/model-factory/src/testing/test-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ModelMeta } from '../types';
*/
export class TestModel extends Model<TestItemMutation> {
static meta: ModelMeta = {
type: 'wrn://dxos/model/test',
type: 'dxn://dxos.org/model/test',
mutation: schema.getCodecForType('dxos.echo.testing.TestItemMutation')
};

Expand Down
2 changes: 1 addition & 1 deletion packages/object-model/src/object-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const log = debug('dxos:echo:object-model');
*/
export class ObjectModel extends Model<ObjectMutationSet> {
static meta: ModelMeta = {
type: 'wrn://dxos/model/object',
type: 'dxn://dxos.org/model/object',
mutation: schema.getCodecForType('dxos.echo.object.ObjectMutationSet'),

// TODO(burdon): Remove.
Expand Down
Loading